summaryrefslogtreecommitdiff
path: root/plugins
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2012-09-07 19:18:00 +0200
committerAndrea Azzarone <azzaronea@gmail.com>2012-09-07 19:18:00 +0200
commit7d6cb807653dd02a3b7536c039de831678d82752 (patch)
tree1336bd0555d6bf1ce3d2647a3871eb5971397a5d /plugins
parentf8dc9c803cece59aaae1e140a4b3abf8743f681a (diff)
parentd9ecafc28a656a5f7532c7a750fbe1e488ece9b9 (diff)
Merge trunk.
(bzr r2509.3.3)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp43
-rw-r--r--plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h4
-rw-r--r--plugins/unitydialog/src/unitydialog.cpp131
-rw-r--r--plugins/unitydialog/src/unitydialog.h20
-rw-r--r--plugins/unityshell/src/ScreenEffectFramebufferObject.cpp243
-rw-r--r--plugins/unityshell/src/ScreenEffectFramebufferObject.h89
-rw-r--r--plugins/unityshell/src/unityshell.cpp1268
-rw-r--r--plugins/unityshell/src/unityshell.h93
8 files changed, 608 insertions, 1283 deletions
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 ad840204c..e16cb89c3 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
@@ -223,9 +223,9 @@ UnityMTGrabHandlesScreen::raiseHandle (const boost::shared_ptr <const unity::MT:
void
UnityMTGrabHandlesScreen::handleEvent(XEvent* event)
{
- CompWindow* w, *oldPrev, *oldNext;
+ CompWindow* w;
- w = oldPrev = oldNext = NULL;
+ w = NULL;
switch (event->type)
{
@@ -438,29 +438,19 @@ UnityMTGrabHandlesWindow::getOutputExtents(CompWindowExtents& output)
bool
UnityMTGrabHandlesWindow::glDraw(const GLMatrix& transform,
-#ifdef USE_MODERN_COMPIZ_GL
const GLWindowPaintAttrib& attrib,
-#else
- GLFragment::Attrib& fragment,
-#endif
const CompRegion& region,
unsigned int mask)
{
/* Draw the window on the bottom, we will be drawing the
* handles on top */
-#ifdef USE_MODERN_COMPIZ_GL
bool status = gWindow->glDraw(transform, attrib, region, mask);
-#else
- bool status = gWindow->glDraw(transform, fragment, region, mask);
-#endif
if (mHandles && mHandles->visible())
{
unsigned int allowedHandles = unity::MT::getLayoutForMask (window->state (), window->actions ());
unsigned int handle = 0;
- UMTGH_SCREEN (screen);
-
for(unity::MT::TextureLayout layout : mHandles->layout (allowedHandles))
{
/* We want to set the geometry of the handle to the window
@@ -472,17 +462,11 @@ UnityMTGrabHandlesWindow::glDraw(const GLMatrix& transform,
GLTexture::MatrixList matl;
GLTexture::Matrix mat = tex->matrix();
CompRegion paintRegion(region);
-#ifdef USE_MODERN_COMPIZ_GL
GLWindowPaintAttrib wAttrib(attrib);
-#endif
/* We can reset the window geometry since it will be
* re-added later */
-#ifdef USE_MODERN_COMPIZ_GL
gWindow->vertexBuffer()->begin();
-#else
- gWindow->geometry().reset();
-#endif
/* Not sure what this does, but it is necessary
* (adjusts for scale?) */
@@ -498,35 +482,22 @@ UnityMTGrabHandlesWindow::glDraw(const GLMatrix& transform,
* dim (so we get a nice render for things like
* wobbly etc etc */
gWindow->glAddGeometry(matl, reg, paintRegion);
-#ifdef USE_MODERN_COMPIZ_GL
- gWindow->vertexBuffer()->end();
- wAttrib.opacity = mHandles->opacity();
-#else
- /* Did it succeed? */
- if (gWindow->geometry().vertices)
- {
- fragment.setOpacity(mHandles->opacity());
- /* Texture rendering set-up */
- us->gScreen->setTexEnvMode(GL_MODULATE);
-#endif
+
+ if (gWindow->vertexBuffer()->end())
+ {
+ wAttrib.opacity = mHandles->opacity();
+
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
/* Draw the dim texture with all of it's modified
* geometry glory */
gWindow->glDrawTexture(tex,
-#ifdef USE_MODERN_COMPIZ_GL
transform, wAttrib,
-#else
- fragment,
-#endif
mask | PAINT_WINDOW_BLEND_MASK
| PAINT_WINDOW_TRANSLUCENT_MASK |
PAINT_WINDOW_TRANSFORMED_MASK);
/* Texture rendering tear-down */
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-#ifndef USE_MODERN_COMPIZ_GL
- us->gScreen->setTexEnvMode(GL_REPLACE);
}
-#endif
}
handle++;
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 9cd99b9d1..f0d3776e5 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
@@ -229,11 +229,7 @@ public:
void moveNotify(int dx, int dy, bool immediate);
bool glDraw(const GLMatrix&,
-#ifdef USE_MODERN_COMPIZ_GL
const GLWindowPaintAttrib&,
-#else
- GLFragment::Attrib&,
-#endif
const CompRegion&,
unsigned int);
diff --git a/plugins/unitydialog/src/unitydialog.cpp b/plugins/unitydialog/src/unitydialog.cpp
index 91f7f235e..3951b65f7 100644
--- a/plugins/unitydialog/src/unitydialog.cpp
+++ b/plugins/unitydialog/src/unitydialog.cpp
@@ -420,12 +420,8 @@ UnityDialogWindow::glAddGeometry(const GLTexture::MatrixList& matrices,
/* Collect textures */
void
UnityDialogWindow::glDrawTexture(GLTexture* texture,
-#ifdef USE_MODERN_COMPIZ_GL
const GLMatrix &transform,
const GLWindowPaintAttrib &attrib,
-#else
- GLFragment::Attrib& fa,
-#endif
unsigned int mask)
{
unity::PaintInfoCollector::Active ()->processTexture (texture);
@@ -448,16 +444,12 @@ unity::GeometryCollection::status ()
collectedMinVertices.size () == collectedMatrixLists.size ());
}
-void
+bool
unity::GeometryCollection::addGeometryForWindow (CompWindow *w, const CompRegion &paintRegion)
{
/* We can reset the window geometry since it will be
* re-added later */
-#ifdef USE_MODERN_COMPIZ_GL
GLWindow::get (w)->vertexBuffer()->begin();
-#else
- GLWindow::get (w)->geometry().reset();
-#endif
for (unsigned int i = 0; i < collectedMatrixLists.size (); i++)
{
@@ -472,9 +464,7 @@ unity::GeometryCollection::addGeometryForWindow (CompWindow *w, const CompRegion
GLWindow::get (w)->glAddGeometry(matl, reg, paintRegion, min, max);
}
-#ifdef USE_MODERN_COMPIZ_GL
- GLWindow::get (w)->vertexBuffer()->end();
-#endif
+ return GLWindow::get (w)->vertexBuffer()->end();
}
void
@@ -511,9 +501,7 @@ unity::TexGeometryCollection::setTexture (GLTexture *tex)
void
unity::TexGeometryCollection::addGeometriesAndDrawTextureForWindow(CompWindow *w,
-#ifdef USE_MODERN_COMPIZ_GL
const GLMatrix &transform,
-#endif
unsigned int mask)
{
if (mTexture && mGeometries.status ())
@@ -524,47 +512,25 @@ unity::TexGeometryCollection::addGeometriesAndDrawTextureForWindow(CompWindow *w
if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
paintRegion = infiniteRegion;
- mGeometries.addGeometryForWindow (w, paintRegion);
-
-#ifdef USE_MODERN_COMPIZ_GL
- UnityDialogScreen *uds = UnityDialogScreen::get (screen);
- GLWindowPaintAttrib attrib (gWindow->lastPaintAttrib());
- unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
- /* Texture rendering set-up */
-// uds->gScreen->setTexEnvMode(GL_MODULATE);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- /* Draw the dim texture with all of it's modified
- * geometry glory */
- gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
- gWindow->glDrawTexture(mTexture, transform, attrib, mask
- | PAINT_WINDOW_BLEND_MASK
- | PAINT_WINDOW_TRANSLUCENT_MASK
- | PAINT_WINDOW_TRANSFORMED_MASK);
- gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
- /* Texture rendering tear-down */
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- uds->gScreen->setTexEnvMode(GL_REPLACE);
-#else
- if (gWindow->geometry().vertices)
+ if (mGeometries.addGeometryForWindow (w, paintRegion))
{
- UnityDialogScreen *uds = UnityDialogScreen::get (screen);
- GLFragment::Attrib fa (gWindow->lastPaintAttrib());
- unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
- /* Texture rendering set-up */
- uds->gScreen->setTexEnvMode(GL_MODULATE);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- /* Draw the dim texture with all of it's modified
- * geometry glory */
- gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
- gWindow->glDrawTexture(mTexture, fa, mask | PAINT_WINDOW_BLEND_MASK
- | PAINT_WINDOW_TRANSLUCENT_MASK |
- PAINT_WINDOW_TRANSFORMED_MASK);
- gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
- /* Texture rendering tear-down */
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- uds->gScreen->setTexEnvMode(GL_REPLACE);
+ UnityDialogScreen *uds = UnityDialogScreen::get (screen);
+ GLWindowPaintAttrib attrib (gWindow->lastPaintAttrib());
+ unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
+ /* Texture rendering set-up */
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ /* Draw the dim texture with all of it's modified
+ * geometry glory */
+ gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
+ gWindow->glDrawTexture(mTexture, transform, attrib, mask
+ | PAINT_WINDOW_BLEND_MASK
+ | PAINT_WINDOW_TRANSLUCENT_MASK
+ | PAINT_WINDOW_TRANSFORMED_MASK);
+ gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
+ /* Texture rendering tear-down */
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ uds->gScreen->setTexEnvMode(GL_REPLACE);
}
-#endif
}
}
@@ -619,17 +585,11 @@ unity::PaintInfoCollector::processTexture (GLTexture *tex)
void
unity::PaintInfoCollector::drawGeometriesForWindow(CompWindow *w,
-#ifdef USE_MODERN_COMPIZ_GL
const GLMatrix &transform,
-#endif
unsigned int pm)
{
for (unity::TexGeometryCollection &tcg : mCollection)
-#if USE_MODERN_COMPIZ_GL
tcg.addGeometriesAndDrawTextureForWindow (w, transform, pm);
-#else
- tcg.addGeometriesAndDrawTextureForWindow (w, pm);
-#endif
}
unity::PaintInfoCollector * unity::PaintInfoCollector::active_collector = NULL;
@@ -644,11 +604,7 @@ unity::PaintInfoCollector::Active ()
bool
UnityDialogWindow::glDraw(const GLMatrix& transform,
-#ifdef USE_MODERN_COMPIZ_GL
const GLWindowPaintAttrib& attrib,
-#else
- GLFragment::Attrib& fragment,
-#endif
const CompRegion& region,
unsigned int mask)
{
@@ -660,11 +616,7 @@ UnityDialogWindow::glDraw(const GLMatrix& transform,
/* Draw the window on the bottom, we will be drawing the
* dim render on top */
bool status = gWindow->glDraw(transform,
-#ifdef USE_MODERN_COMPIZ_GL
attrib,
-#else
- fragment,
-#endif
region, mask);
UNITY_DIALOG_SCREEN(screen);
@@ -673,17 +625,11 @@ UnityDialogWindow::glDraw(const GLMatrix& transform,
{
GLTexture::MatrixList matl;
GLTexture::Matrix mat = tex->matrix();
-#ifdef USE_MODERN_COMPIZ_GL
GLWindowPaintAttrib wAttrib(attrib);
-#endif
/* We can reset the window geometry since it will be
* re-added later */
-#ifdef USE_MODERN_COMPIZ_GL
gWindow->vertexBuffer()->begin();
-#else
- gWindow->geometry().reset();
-#endif
/* Scale the dim render by the ratio of dim size
* to window size */
@@ -704,48 +650,25 @@ UnityDialogWindow::glDraw(const GLMatrix& transform,
* dim (so we get a nice render for things like
* wobbly etc etc */
gWindow->glAddGeometry(matl, reg, paintRegion);
-#ifdef USE_MODERN_COMPIZ_GL
- gWindow->vertexBuffer()->end();
-#endif
-
-#ifdef USE_MODERN_COMPIZ_GL
- unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
- wAttrib.opacity = mShadeProgress;
- /* Texture rendering set-up */
-// uds->gScreen->setTexEnvMode(GL_MODULATE);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- /* Draw the dim texture with all of it's modified
- * geometry glory */
- gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
- gWindow->glDrawTexture(tex, transform, attrib, mask
- | PAINT_WINDOW_BLEND_MASK
- | PAINT_WINDOW_TRANSLUCENT_MASK
- | PAINT_WINDOW_TRANSFORMED_MASK);
- gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
- /* Texture rendering tear-down */
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- uds->gScreen->setTexEnvMode(GL_REPLACE);
-#else
- /* Did it succeed? */
- if (gWindow->geometry().vertices)
+ if (gWindow->vertexBuffer()->end())
{
unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
- fragment.setOpacity(mShadeProgress);
+ wAttrib.opacity = mShadeProgress;
/* Texture rendering set-up */
- uds->gScreen->setTexEnvMode(GL_MODULATE);
+ // uds->gScreen->setTexEnvMode(GL_MODULATE);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
/* Draw the dim texture with all of it's modified
* geometry glory */
gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
- gWindow->glDrawTexture(tex, fragment, mask | PAINT_WINDOW_BLEND_MASK
- | PAINT_WINDOW_TRANSLUCENT_MASK |
- PAINT_WINDOW_TRANSFORMED_MASK);
+ gWindow->glDrawTexture(tex, transform, attrib, mask
+ | PAINT_WINDOW_BLEND_MASK
+ | PAINT_WINDOW_TRANSLUCENT_MASK
+ | PAINT_WINDOW_TRANSFORMED_MASK);
gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
/* Texture rendering tear-down */
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
uds->gScreen->setTexEnvMode(GL_REPLACE);
}
-#endif
}
for (CompWindow* w : mTransients)
@@ -759,9 +682,7 @@ UnityDialogWindow::glDraw(const GLMatrix& transform,
pc.collect();
pc.drawGeometriesForWindow (window,
-#ifdef USE_MODERN_COMPIZ_GL
transform,
-#endif
mask);
}
}
diff --git a/plugins/unitydialog/src/unitydialog.h b/plugins/unitydialog/src/unitydialog.h
index eee9adea7..4f3f26338 100644
--- a/plugins/unitydialog/src/unitydialog.h
+++ b/plugins/unitydialog/src/unitydialog.h
@@ -40,7 +40,7 @@ namespace unity
GeometryCollection ();
bool status ();
- void addGeometryForWindow (CompWindow *, const CompRegion &paintRegion);
+ bool addGeometryForWindow (CompWindow *, const CompRegion &paintRegion);
void addGeometry (const GLTexture::MatrixList &ml,
const CompRegion &r,
int min,
@@ -64,13 +64,9 @@ namespace unity
int max);
void setTexture (GLTexture *);
-#ifdef USE_MODERN_COMPIZ_GL
void addGeometriesAndDrawTextureForWindow (CompWindow *w,
const GLMatrix &transform,
- unsigned int mask);
-#else
- void addGeometriesAndDrawTextureForWindow (CompWindow *, unsigned int pm);
-#endif
+ unsigned int mask);
private:
GLTexture* mTexture;
@@ -84,13 +80,9 @@ namespace unity
PaintInfoCollector (CompWindow *w);
void collect ();
-#ifdef USE_MODERN_COMPIZ_GL
void drawGeometriesForWindow (CompWindow *w,
const GLMatrix &transform,
unsigned int pm);
-#else
- void drawGeometriesForWindow (CompWindow *w, unsigned int pm);
-#endif
void processGeometry (const GLTexture::MatrixList &ml,
const CompRegion &r,
@@ -255,11 +247,7 @@ public:
bool
glDraw(const GLMatrix&,
-#ifdef USE_MODERN_COMPIZ_GL
const GLWindowPaintAttrib&,
-#else
- GLFragment::Attrib&,
-#endif
const CompRegion&, unsigned int);
bool
@@ -275,12 +263,8 @@ public:
void
glDrawTexture(GLTexture* texture,
-#ifdef USE_MODERN_COMPIZ_GL
const GLMatrix& transform,
const GLWindowPaintAttrib& attrib,
-#else
- GLFragment::Attrib& attrib,
-#endif
unsigned int mask);
diff --git a/plugins/unityshell/src/ScreenEffectFramebufferObject.cpp b/plugins/unityshell/src/ScreenEffectFramebufferObject.cpp
deleted file mode 100644
index de9be43f3..000000000
--- a/plugins/unityshell/src/ScreenEffectFramebufferObject.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
-/* Compiz unity plugin
- * unity.h
- *
- * Copyright (c) 2010-11 Canonical Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
- */
-
-#ifndef USE_GLES
-#include "ScreenEffectFramebufferObject.h"
-#include "BackgroundEffectHelper.h"
-#include <NuxCore/Logger.h>
-#include <dlfcn.h>
-
-namespace
-{
- nux::logging::Logger logger ("unity.screeneffectframebufferobject");
-}
-
-void unity::ScreenEffectFramebufferObject::paint (const nux::Geometry &output)
-{
- /* Draw the bit of the relevant framebuffer for each output */
-
- glPushAttrib (GL_VIEWPORT_BIT);
- glViewport (0, 0, mScreenSize.width, mScreenSize.height);
-
- if (mFBTexture)
- {
- glEnable (GL_TEXTURE_2D);
- activeTexture (GL_TEXTURE0_ARB);
- glBindTexture (GL_TEXTURE_2D, mFBTexture);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- glPushAttrib (GL_SCISSOR_BIT);
- glEnable (GL_SCISSOR_TEST);
-
- glScissor (output.x, mScreenSize.height - (output.y + output.height),
- output.width, output.height);
-
- /* FIXME: This needs to be GL_TRIANGLE_STRIP */
- glBegin (GL_QUADS);
- glTexCoord2f (0, 1);
- glVertex2i (mGeometry.x, mGeometry.y);
- glTexCoord2f (0, 0);
- glVertex2i (mGeometry.x, mGeometry.y + mGeometry.height);
- glTexCoord2f (1, 0);
- glVertex2i (mGeometry.x + mGeometry.width, mGeometry.y + mGeometry.height);
- glTexCoord2f (1, 1);
- glVertex2i (mGeometry.x + mGeometry.width, mGeometry.y);
- glEnd ();
-
- activeTexture (GL_TEXTURE0_ARB);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glBindTexture (GL_TEXTURE_2D, 0);
- glDisable (GL_TEXTURE_2D);
- glPopAttrib ();
- }
- glPopAttrib ();
-}
-
-void unity::ScreenEffectFramebufferObject::onScreenSizeChanged(const nux::Geometry& screenSize)
-{
- mScreenSize = screenSize;
-}
-
-
-void unity::ScreenEffectFramebufferObject::unbind ()
-{
- if (!mBoundCnt)
- return;
-
- mBoundCnt--;
-
- (*bindFramebuffer) (GL_FRAMEBUFFER_EXT, 0);
-
- glDrawBuffer (GL_BACK);
- glReadBuffer (GL_BACK);
-
- /* Matches the viewport set we did in ::bind () */
- glPopAttrib ();
-
-}
-
-bool unity::ScreenEffectFramebufferObject::status ()
-{
- return mFboStatus;
-}
-
-void unity::ScreenEffectFramebufferObject::bind (const nux::Geometry &output)
-{
- /* Very important!
- * Don't bind unless BackgroundEffectHelper says it's necessary.
- * Because binding has a severe impact on graphics performance and we
- * can't afford to do it every frame. (LP: #861061) (LP: #987304)
- */
- if (!BackgroundEffectHelper::HasDirtyHelpers())
- return;
-
- /* Clear the error bit */
- glGetError ();
-
- if (!mFBTexture)
- {
- glGenTextures (1, &mFBTexture);
-
- glBindTexture (GL_TEXTURE_2D, mFBTexture);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, mGeometry.width, mGeometry.height, 0, GL_BGRA,
-#if IMAGE_BYTE_ORDER == MSBFirst
- GL_UNSIGNED_INT_8_8_8_8_REV,
-#else
- GL_UNSIGNED_BYTE,
-#endif
- NULL);
-
- glBindTexture (GL_TEXTURE_2D, 0);
-
- if (glGetError () != GL_NO_ERROR)
- {
- mFboHandle = 0;
- mFboStatus = false;
- return;
- }
- }
-
- (*bindFramebuffer) (GL_FRAMEBUFFER_EXT, mFboHandle);
-
- (*framebufferTexture2D) (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, mFBTexture, 0);
-
- (*framebufferTexture2D) (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_TEXTURE_2D, 0, 0);
-
- /* Ensure that a framebuffer is actually available */
- if (!mFboStatus)
- {
- GLint status = (*checkFramebufferStatus) (GL_DRAW_FRAMEBUFFER);
-
- if (status != GL_FRAMEBUFFER_COMPLETE)
- {
- switch (status)
- {
- case GL_FRAMEBUFFER_UNDEFINED:
- LOG_WARN (logger) << "no window";
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
- LOG_WARN (logger) << "attachment incomplete";
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
- LOG_WARN (logger) << "no buffers attached to fbo";
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
- LOG_WARN (logger) << "some attachment in glDrawBuffers doesn't exist in FBO";
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
- LOG_WARN (logger) << "some attachment in glReadBuffers doesn't exist in FBO";
- break;
- case GL_FRAMEBUFFER_UNSUPPORTED:
- LOG_WARN (logger) << "unsupported internal format";
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
- LOG_WARN (logger) << "different levels of sampling for each attachment";
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
- LOG_WARN (logger) << "number of layers is different";
- break;
- default:
- LOG_WARN (logger) << "unable to bind the framebuffer for an unknown reason";
- break;
- }
-
- bindFramebuffer (GL_FRAMEBUFFER_EXT, 0);
- deleteFramebuffers (1, &mFboHandle);
-
- glDrawBuffer (GL_BACK);
- glReadBuffer (GL_BACK);
-
- mFboHandle = 0;
-
- mFboStatus = false;
- }
- else
- mFboStatus = true;
- }
-
- if (mFboStatus)
- {
- glPushAttrib (GL_VIEWPORT_BIT);
-
- glViewport (output.x,
- mScreenSize.height - (output.y + output.height),
- output.width,
- output.height);
- }
-
- mBoundCnt++;
-}
-
-
-unity::ScreenEffectFramebufferObject::ScreenEffectFramebufferObject (GLXGetProcAddressProc p, const nux::Geometry &geom)
- : getProcAddressGLX (p)
- , mFboStatus (false)
- , mFBTexture (0)
- , mGeometry (geom)
- , mBoundCnt (0)
- , mScreenSize (geom)
-{
- activeTexture = (GLActiveTextureProc) (*getProcAddressGLX) ((GLubyte *) "glActiveTexture");
- genFramebuffers = (GLGenFramebuffersProc) (*getProcAddressGLX) ((GLubyte *)"glGenFramebuffersEXT");
- deleteFramebuffers = (GLDeleteFramebuffersProc) (*getProcAddressGLX) ((GLubyte *)"glDeleteFramebuffersEXT");
- bindFramebuffer = (GLBindFramebufferProc) (*getProcAddressGLX) ((GLubyte *)"glBindFramebufferEXT");
- checkFramebufferStatus = (GLCheckFramebufferStatusProc) (*getProcAddressGLX) ((GLubyte *) "glCheckFramebufferStatusEXT");
- framebufferTexture2D = (GLFramebufferTexture2DProc) (*getProcAddressGLX) ((GLubyte *) "glFramebufferTexture2DEXT");
-
- (*genFramebuffers) (1, &mFboHandle);
-}
-
-unity::ScreenEffectFramebufferObject::~ScreenEffectFramebufferObject ()
-{
- (*deleteFramebuffers) (1, &mFboHandle);
-
- if (mFBTexture)
- glDeleteTextures (1, &mFBTexture);
-}
-
-#endif // USE_GLES
-
diff --git a/plugins/unityshell/src/ScreenEffectFramebufferObject.h b/plugins/unityshell/src/ScreenEffectFramebufferObject.h
deleted file mode 100644
index 9ccfb9a92..000000000
--- a/plugins/unityshell/src/ScreenEffectFramebufferObject.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
-/* Compiz unity plugin
- * unity.h
- *
- * Copyright (c) 2010-11 Canonical Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
- */
-
-#ifndef UNITY_SCREENEFFECT_FRAMEBUFFER_H
-#define UNITY_SCREENEFFECT_FRAMEBUFFER_H
-
-#ifndef USE_MODERN_COMPIZ_GL
-#include <Nux/Nux.h>
-
-namespace unity
-{
-class ScreenEffectFramebufferObject
-{
-public:
-
- typedef boost::shared_ptr <ScreenEffectFramebufferObject> Ptr;
- typedef void (*FuncPtr) (void);
- typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
-
- ScreenEffectFramebufferObject (GLXGetProcAddressProc, const nux::Geometry &geom);
- ~ScreenEffectFramebufferObject ();
-
-public:
-
- void bind (const nux::Geometry &geom);
- void unbind ();
-
- bool status ();
- void paint (const nux::Geometry &geom);
- bool bound () { return mBoundCnt > 0; }
-
- GLuint texture () { return mFBTexture; }
-
- void onScreenSizeChanged (const nux::Geometry &screenSize);
-
-private:
-
- FuncPtr getProcAddr (const std::string &);
-
- typedef void (*GLActiveTextureProc) (GLenum texture);
- typedef void (*GLGenFramebuffersProc) (GLsizei n,
- GLuint *framebuffers);
- typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
- GLuint *framebuffers);
- typedef void (*GLBindFramebufferProc) (GLenum target,
- GLuint framebuffer);
- typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
- typedef void (*GLFramebufferTexture2DProc) (GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level);
-
- GLXGetProcAddressProc getProcAddressGLX;
- GLActiveTextureProc activeTexture;
- GLGenFramebuffersProc genFramebuffers;
- GLDeleteFramebuffersProc deleteFramebuffers;
- GLBindFramebufferProc bindFramebuffer;
- GLCheckFramebufferStatusProc checkFramebufferStatus;
- GLFramebufferTexture2DProc framebufferTexture2D;
- /* compiz fbo handle that goes through to nux */
- GLuint mFboHandle; // actual handle to the framebuffer_ext
- bool mFboStatus; // did the framebuffer texture bind succeed
- GLuint mFBTexture;
- nux::Geometry mGeometry;
- unsigned int mBoundCnt;
-
- nux::Geometry mScreenSize;
-};
-} // namespace unity
-
-#endif // USE_MODERN_COMPIZ_GL
-#endif
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 640fd3654..0ec87f497 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -83,9 +83,8 @@ nux::logging::Logger logger("unity.shell");
UnityScreen* uScreen = 0;
-static unsigned int CLOSE_ICON_SIZE = 19;
-static unsigned int CLOSE_ICON_SPACE = 5;
-static unsigned int SCALE_WINDOW_TITLE_SIZE = 28;
+const unsigned int SCALE_CLOSE_ICON_SIZE = 19;
+const unsigned int SCALE_ITEMS_PADDING = 5;
void reset_glib_logging();
void configure_logging();
@@ -107,34 +106,6 @@ const std::string RELAYOUT_TIMEOUT = "relayout-timeout";
} // namespace local
} // anon namespace
-class WindowCairoContext
-{
- public:
- Pixmap pixmap_;
- cairo_surface_t* surface_;
- GLTexture::List texture_;
- cairo_t *cr_;
-
- WindowCairoContext ()
- : pixmap_ (0), surface_ (0), cr_ (0)
- {
- }
-
- ~WindowCairoContext ()
- {
- if (cr_)
- cairo_destroy (cr_);
-
- if (surface_)
- cairo_surface_destroy (surface_);
-
- texture_.clear ();
-
- if (pixmap_)
- XFreePixmap (screen->dpy (), pixmap_);
- }
-};
-
UnityScreen::UnityScreen(CompScreen* screen)
: BaseSwitchScreen (screen)
, PluginClassHandler <UnityScreen, CompScreen> (screen)
@@ -153,9 +124,6 @@ UnityScreen::UnityScreen(CompScreen* screen)
, allowWindowPaint(false)
, _key_nav_mode_requested(false)
, _last_output(nullptr)
-#ifndef USE_MODERN_COMPIZ_GL
- , _active_fbo (0)
-#endif
, grab_index_ (0)
, painting_tray_ (false)
, last_scroll_event_(0)
@@ -163,7 +131,7 @@ UnityScreen::UnityScreen(CompScreen* screen)
, panel_texture_has_changed_(true)
, paint_panel_(false)
, scale_just_activated_(false)
- , highlighted_window_(0)
+ , scale_highlighted_window_(0)
, minimize_speed_controller(new WindowMinimizeSpeedController())
{
Timer timer;
@@ -279,25 +247,6 @@ UnityScreen::UnityScreen(CompScreen* screen)
uScreen = this;
_in_paint = false;
-#ifndef USE_MODERN_COMPIZ_GL
- void *dlhand = dlopen ("libunityshell.so", RTLD_LAZY);
-
- if (dlhand)
- {
- dlerror ();
- glXGetProcAddressP = (ScreenEffectFramebufferObject::GLXGetProcAddressProc) dlsym (dlhand, "glXGetProcAddress");
- if (dlerror () != NULL)
- glXGetProcAddressP = NULL;
- }
-
- if (GL::fbo)
- {
- nux::Geometry geometry (0, 0, screen->width (), screen->height ());
- uScreen->_fbo = ScreenEffectFramebufferObject::Ptr (new ScreenEffectFramebufferObject (glXGetProcAddressP, geometry));
- uScreen->_fbo->onScreenSizeChanged (geometry);
- }
-#endif
-
optionSetShowHudInitiate(boost::bind(&UnityScreen::ShowHudInitiate, this, _1, _2, _3));
optionSetShowHudTerminate(boost::bind(&UnityScreen::ShowHudTerminate, this, _1, _2, _3));
optionSetBackgroundColorNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
@@ -421,7 +370,8 @@ UnityScreen::UnityScreen(CompScreen* screen)
}
panel::Style::Instance().changed.connect(sigc::mem_fun(this, &UnityScreen::OnPanelStyleChanged));
-
+ WindowManager::Default()->terminate_spread.connect([this] { scale_highlighted_window_ = 0; });
+
minimize_speed_controller->DurationChanged.connect(
sigc::mem_fun(this, &UnityScreen::OnMinimizeDurationChanged)
);
@@ -534,17 +484,6 @@ void UnityScreen::nuxPrologue()
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
-
-#ifndef USE_MODERN_COMPIZ_GL
- /* This is needed to Fix a crash in glDrawArrays with the NVIDIA driver
- * see bugs #1031554 and #982626.
- * The NVIDIA driver looks to see if the legacy GL_VERTEX_ARRAY,
- * GL_TEXTURE_COORDINATES_ARRAY and other such client states are enabled
- * first before checking if a vertex buffer is bound and will prefer the
- * client buffers over the the vertex buffer object. */
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-#endif
#endif
glGetError();
@@ -553,9 +492,6 @@ void UnityScreen::nuxPrologue()
void UnityScreen::nuxEpilogue()
{
#ifndef USE_GLES
-#ifndef USE_MODERN_COMPIZ_GL
- (*GL::bindFramebuffer)(GL_FRAMEBUFFER_EXT, _active_fbo);
-#endif
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -577,19 +513,9 @@ void UnityScreen::nuxEpilogue()
glPopAttrib();
-#ifndef USE_MODERN_COMPIZ_GL
- /* Re-enable the client states that have been disabled in nuxPrologue, for
- * NVIDIA compatibility reasons */
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-#endif
+ glDepthRange(0, 1);
#else
-#ifdef USE_GLES
glDepthRangef(0, 1);
-#else
- glDepthRange(0, 1);
-#endif
- //glViewport(-1, -1, 2, 2);
gScreen->resetRasterPos();
#endif
@@ -601,86 +527,9 @@ void UnityScreen::setPanelShadowMatrix(const GLMatrix& matrix)
panel_shadow_matrix_ = matrix;
}
+/* Currently unimplemented */
void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
{
-#ifndef USE_MODERN_COMPIZ_GL
- if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
- return;
-
- if (PluginAdapter::Default()->IsExpoActive())
- return;
-
- CompOutput* output = _last_output;
- float vc[4];
- float h = 20.0f;
- float w = 1.0f;
- float panel_h = panel_style_.panel_height;
-
- float x1 = output->x();
- float y1 = output->y() + panel_h;
- float x2 = x1 + output->width();
- float y2 = y1 + h;
-
- glPushMatrix ();
- glLoadMatrixf (panel_shadow_matrix_.getMatrix ());
-
- vc[0] = x1;
- vc[1] = x2;
- vc[2] = y1;
- vc[3] = y2;
-
- // compiz doesn't use the same method of tracking monitors as our toolkit
- // we need to make sure we properly associate with the right monitor
- int current_monitor = -1;
- auto monitors = UScreen::GetDefault()->GetMonitors();
- int i = 0;
- for (auto monitor : monitors)
- {
- if (monitor.x == output->x() && monitor.y == output->y())
- {
- current_monitor = i;
- break;
- }
- i++;
- }
-
- if (!(launcher_controller_->IsOverlayOpen() && current_monitor == dash_monitor_)
- && panel_controller_->opacity() > 0.0f)
- {
- foreach(GLTexture * tex, _shadow_texture)
- {
- glEnable(GL_BLEND);
- glColor4f(1.0f, 1.0f, 1.0f, panel_controller_->opacity());
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- GL::activeTexture(GL_TEXTURE0_ARB);
- tex->enable(GLTexture::Fast);
-
- glTexParameteri(tex->target(), GL_TEXTURE_WRAP_S, GL_REPEAT);
-
- glBegin(GL_QUADS);
- {
- glTexCoord2f(COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), 0));
- glVertex2f(vc[0], vc[2]);
-
- glTexCoord2f(COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), h));
- glVertex2f(vc[0], vc[3]);
-
- glTexCoord2f(COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), h));
- glVertex2f(vc[1], vc[3]);
-
- glTexCoord2f(COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), 0));
- glVertex2f(vc[1], vc[2]);
- }
- glEnd();
-
- tex->disable();
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glDisable(GL_BLEND);
- }
- }
- glPopMatrix();
-#else
return;
if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
@@ -774,7 +623,6 @@ void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
}
}
nuxEpilogue();
-#endif
}
void
@@ -795,90 +643,32 @@ UnityScreen::OnPanelStyleChanged()
panel_texture_has_changed_ = true;
}
-#ifdef USE_MODERN_COMPIZ_GL
void UnityScreen::paintDisplay()
-#else
-void UnityScreen::paintDisplay(const CompRegion& region, const GLMatrix& transform, unsigned int mask)
-#endif
{
CompOutput *output = _last_output;
-#ifndef USE_MODERN_COMPIZ_GL
- bool was_bound = _fbo->bound ();
-
- if (nux::GetGraphicsDisplay()->GetGraphicsEngine()->UsingGLSLCodePath())
- {
- if (was_bound && launcher_controller_->IsOverlayOpen() && paint_panel_)
- {
- if (panel_texture_has_changed_ || !panel_texture_.IsValid())
- {
- panel_texture_.Release();
-
- nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(screen->width (), screen->height(), 1.0f);
- nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
- if (bitmap && texture2D)
- {
- texture2D->Update(bitmap);
- panel_texture_ = texture2D->GetDeviceTexture();
- texture2D->UnReference();
- delete bitmap;
- }
- panel_texture_has_changed_ = false;
- }
-
- if (panel_texture_.IsValid())
- {
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->ResetModelViewMatrixStack();
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f);
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->ResetProjectionMatrix();
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetOrthographicProjectionMatrix(screen->width (), screen->height());
-
- nux::TexCoordXForm texxform;
- int panel_height = panel_style_.panel_height;
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->QRP_GLSL_1Tex(0, 0, screen->width (), panel_height, panel_texture_, texxform, nux::color::White);
- }
- }
- }
-
- _fbo->unbind ();
+ DrawTopPanelBackground();
- /* Draw the bit of the relevant framebuffer for each output */
+ auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice();
- if (was_bound)
- {
- GLMatrix sTransform;
- sTransform.toScreenSpace (&screen->fullscreenOutput (), -DEFAULT_Z_CAMERA);
- glPushMatrix ();
- glLoadMatrixf (sTransform.getMatrix ());
- _fbo->paint (nux::Geometry (output->x (), output->y (), output->width (), output->height ()));
- glPopMatrix ();
- }
-
- nux::ObjectPtr<nux::IOpenGLBaseTexture> device_texture =
- nux::GetGraphicsDisplay()->GetGpuDevice()->CreateTexture2DFromID(_fbo->texture(),
- screen->width (), screen->height(), 1, nux::BITFMT_R8G8B8A8);
-#else
nux::ObjectPtr<nux::IOpenGLTexture2D> device_texture =
- nux::GetGraphicsDisplay()->GetGpuDevice()->CreateTexture2DFromID(gScreen->fbo ()->tex ()->name (),
- screen->width(), screen->height(), 1, nux::BITFMT_R8G8B8A8);
-#endif
+ gpu_device->CreateTexture2DFromID(gScreen->fbo ()->tex ()->name (),
+ screen->width(), screen->height(), 1, nux::BITFMT_R8G8B8A8);
- nux::GetGraphicsDisplay()->GetGpuDevice()->backup_texture0_ = device_texture;
+ gpu_device->backup_texture0_ = device_texture;
- nux::Geometry geo = nux::Geometry (0, 0, screen->width (), screen->height ());
- nux::Geometry oGeo = nux::Geometry (output->x (), output->y (), output->width (), output->height ());
+ nux::Geometry geo(0, 0, screen->width (), screen->height ());
+ nux::Geometry outputGeo(output->x (), output->y (), output->width (), output->height ());
BackgroundEffectHelper::monitor_rect_ = geo;
-#ifdef USE_MODERN_COMPIZ_GL
GLint fboID;
// Nux renders to the referenceFramebuffer when it's embedded.
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fboID);
- wt->GetWindowCompositor().SetReferenceFramebuffer(fboID, oGeo);
-#endif
+ wt->GetWindowCompositor().SetReferenceFramebuffer(fboID, outputGeo);
nuxPrologue();
_in_paint = true;
- wt->RenderInterfaceFromForeignCmd (&oGeo);
+ wt->RenderInterfaceFromForeignCmd (&outputGeo);
_in_paint = false;
nuxEpilogue();
@@ -892,56 +682,28 @@ void UnityScreen::paintDisplay(const CompRegion& region, const GLMatrix& transfo
{
GLMatrix oTransform;
UnityWindow *uTrayWindow = UnityWindow::get (tray);
-#ifndef USE_MODERN_COMPIZ_GL
- GLFragment::Attrib attrib (uTrayWindow->gWindow->lastPaintAttrib());
-#else
GLWindowPaintAttrib attrib (uTrayWindow->gWindow->lastPaintAttrib());
-#endif
unsigned int oldGlAddGeometryIndex = uTrayWindow->gWindow->glAddGeometryGetCurrentIndex ();
unsigned int oldGlDrawIndex = uTrayWindow->gWindow->glDrawGetCurrentIndex ();
-#ifndef USE_MODERN_COMPIZ_GL
- unsigned int oldGlDrawGeometryIndex = uTrayWindow->gWindow->glDrawGeometryGetCurrentIndex ();
-#endif
-#ifndef USE_MODERN_COMPIZ_GL
- attrib.setOpacity (OPAQUE);
- attrib.setBrightness (BRIGHT);
- attrib.setSaturation (COLOR);
-#else
attrib.opacity = OPAQUE;
attrib.brightness = BRIGHT;
attrib.saturation = COLOR;
-#endif
oTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
-#ifndef USE_MODERN_COMPIZ_GL
- glPushMatrix ();
- glLoadMatrixf (oTransform.getMatrix ());
-#endif
-
painting_tray_ = true;
/* force the use of the core functions */
uTrayWindow->gWindow->glDrawSetCurrentIndex (MAXSHORT);
uTrayWindow->gWindow->glAddGeometrySetCurrentIndex ( MAXSHORT);
-#ifndef USE_MODERN_COMPIZ_GL
- uTrayWindow->gWindow->glDrawGeometrySetCurrentIndex (MAXSHORT);
-#endif
uTrayWindow->gWindow->glDraw (oTransform, attrib, infiniteRegion,
PAINT_WINDOW_TRANSFORMED_MASK |
PAINT_WINDOW_BLEND_MASK |
PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK);
-#ifndef USE_MODERN_COMPIZ_GL
- uTrayWindow->gWindow->glDrawGeometrySetCurrentIndex (oldGlDrawGeometryIndex);
-#endif
uTrayWindow->gWindow->glAddGeometrySetCurrentIndex (oldGlAddGeometryIndex);
uTrayWindow->gWindow->glDrawSetCurrentIndex (oldGlDrawIndex);
painting_tray_ = false;
-
-#ifndef USE_MODERN_COMPIZ_GL
- glPopMatrix ();
-#endif
}
}
}
@@ -966,6 +728,53 @@ void UnityScreen::paintDisplay(const CompRegion& region, const GLMatrix& transfo
didShellRepaint = true;
}
+void UnityScreen::DrawTopPanelBackground()
+{
+ auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine();
+
+ if (!graphics_engine->UsingGLSLCodePath() || !launcher_controller_->IsOverlayOpen() || !paint_panel_)
+ return;
+
+ if (TopPanelBackgroundTextureNeedsUpdate())
+ UpdateTopPanelBackgroundTexture();
+
+ if (panel_texture_.IsValid())
+ {
+ graphics_engine->ResetModelViewMatrixStack();
+ graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f);
+ graphics_engine->ResetProjectionMatrix();
+ graphics_engine->SetOrthographicProjectionMatrix(screen->width (), screen->height());
+
+ nux::TexCoordXForm texxform;
+ int panel_height = panel_style_.panel_height;
+ graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width (), panel_height, panel_texture_, texxform, nux::color::White);
+ }
+}
+
+bool UnityScreen::TopPanelBackgroundTextureNeedsUpdate() const
+{
+ return panel_texture_has_changed_ || !panel_texture_.IsValid();
+}
+
+void UnityScreen::UpdateTopPanelBackgroundTexture()
+{
+ auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice();
+ auto &panel_style = panel::Style::Instance();
+
+ panel_texture_.Release();
+
+ std::unique_ptr<nux::NBitmapData> bitmap(panel_style.GetBackground(screen->width(), screen->height(), 1.0f));
+ nux::ObjectPtr<nux::BaseTexture> texture2D(gpu_device->CreateSystemCapableTexture());
+
+ if (bitmap && texture2D)
+ {
+ texture2D->Update(bitmap.get());
+ panel_texture_ = texture2D->GetDeviceTexture();
+ }
+
+ panel_texture_has_changed_ = false;
+}
+
bool UnityScreen::forcePaintOnTop ()
{
return !allowWindowPaint ||
@@ -1094,8 +903,8 @@ void UnityScreen::leaveShowDesktopMode (CompWindow *w)
void UnityWindow::enterShowDesktop ()
{
if (!mShowdesktopHandler)
- mShowdesktopHandler = new ShowdesktopHandler (static_cast <ShowdesktopHandlerWindowInterface *> (this),
- static_cast <compiz::WindowInputRemoverLockAcquireInterface *> (this));
+ mShowdesktopHandler.reset(new ShowdesktopHandler(static_cast <ShowdesktopHandlerWindowInterface *>(this),
+ static_cast <compiz::WindowInputRemoverLockAcquireInterface *>(this)));
window->setShowDesktopMode (true);
mShowdesktopHandler->FadeOut ();
@@ -1216,15 +1025,14 @@ ShowdesktopHandlerWindowInterface::PostPaintAction UnityWindow::DoHandleAnimatio
return action;
}
-void UnityWindow::DoAddDamage ()
+void UnityWindow::DoAddDamage()
{
- cWindow->addDamage ();
+ cWindow->addDamage();
}
void UnityWindow::DoDeleteHandler ()
{
- delete mShowdesktopHandler;
- mShowdesktopHandler = NULL;
+ mShowdesktopHandler.reset();
window->updateFrameRegion ();
}
@@ -1246,20 +1054,74 @@ UnityWindow::GetNoCoreInstanceMask ()
return PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
}
-void UnityWindow::handleEvent (XEvent *event)
+bool UnityWindow::handleEvent(XEvent *event)
{
- if (screen->XShape () &&
- event->type == screen->shapeEvent () + ShapeNotify &&
- !event->xany.send_event)
+ bool handled = false;
+
+ switch(event->type)
{
- if (mShowdesktopHandler)
- mShowdesktopHandler->HandleShapeEvent ();
+ case MotionNotify:
+ if (close_icon_state_ != panel::WindowState::PRESSED)
+ {
+ panel::WindowState old_state = close_icon_state_;
+
+ if (close_button_geo_.IsPointInside(event->xmotion.x_root, event->xmotion.y_root))
+ {
+ close_icon_state_ = panel::WindowState::PRELIGHT;
+ }
+ else
+ {
+ close_icon_state_ = panel::WindowState::NORMAL;
+ }
+
+ if (old_state != close_icon_state_)
+ DoAddDamage();
+ }
+ break;
+
+ case ButtonPress:
+ if (event->xbutton.button == Button1 &&
+ close_button_geo_.IsPointInside(event->xbutton.x_root, event->xbutton.y_root))
+ {
+ close_icon_state_ = panel::WindowState::PRESSED;
+ DoAddDamage();
+ handled = true;
+ }
+ break;
+
+ case ButtonRelease:
+ {
+ bool was_pressed = (close_icon_state_ == panel::WindowState::PRESSED);
+
+ if (close_icon_state_ != panel::WindowState::NORMAL)
+ {
+ close_icon_state_ = panel::WindowState::NORMAL;
+ DoAddDamage();
+ }
+
+ if (was_pressed)
+ {
+ if (close_button_geo_.IsPointInside(event->xbutton.x_root, event->xbutton.y_root))
+ window->close(0);
+
+ handled = true;
+ }
+ }
+ break;
+
+ default:
+ if (!event->xany.send_event && screen->XShape() &&
+ event->type == screen->shapeEvent() + ShapeNotify)
+ {
+ if (mShowdesktopHandler)
+ {
+ mShowdesktopHandler->HandleShapeEvent();
+ handled = true;
+ }
+ }
}
-}
-CompRect UnityWindow::closeButtonArea ()
-{
- return close_button_area_;
+ return handled;
}
bool UnityScreen::shellCouldBeHidden(CompOutput const& output)
@@ -1325,26 +1187,6 @@ bool UnityScreen::glPaintOutput(const GLScreenPaintAttrib& attrib,
_last_output = output;
paint_panel_ = false;
-#ifndef USE_MODERN_COMPIZ_GL
- /* bind the framebuffer here
- * - it will be unbound and flushed
- * to the backbuffer when some
- * plugin requests to draw a
- * a transformed screen or when
- * we have finished this draw cycle.
- * once an fbo is bound any further
- * attempts to bind it will only increment
- * its bind reference so make sure that
- * you always unbind as much as you bind
- *
- * But NOTE: It is only safe to bind the FBO if !shellCouldBeHidden.
- * Otherwise it's possible painting won't occur and that would
- * confuse the state of the FBO.
- */
- if (doShellRepaint && !shellCouldBeHidden(*output))
- _fbo->bind (nux::Geometry (output->x (), output->y (), output->width (), output->height ()));
-#endif
-
// CompRegion has no clear() method. So this is the fastest alternative.
fullscreenRegion = CompRegion();
nuxRegion = CompRegion();
@@ -1356,11 +1198,7 @@ bool UnityScreen::glPaintOutput(const GLScreenPaintAttrib& attrib,
doShellRepaint = false;
if (doShellRepaint)
-#ifdef USE_MODERN_COMPIZ_GL
paintDisplay();
-#else
- paintDisplay(region, transform, mask);
-#endif
return ret;
}
@@ -1390,10 +1228,6 @@ void UnityScreen::preparePaint(int ms)
for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows)
wi->HandleAnimations (ms);
-#ifndef USE_MODERN_COMPIZ_GL
- compizDamageNux(cScreen->currentDamage());
-#endif
-
didShellRepaint = false;
firstWindowAboveShell = NULL;
}
@@ -1520,7 +1354,6 @@ void UnityScreen::compizDamageNux(CompRegion const& damage)
/* Grab changed nux regions and add damage rects for them */
void UnityScreen::nuxDamageCompiz()
{
-#ifdef USE_MODERN_COMPIZ_GL
/*
* If Nux is going to redraw anything then we have to tell Compiz to
* redraw everything. This is because Nux has a bad habit (bug??) of drawing
@@ -1540,60 +1373,6 @@ void UnityScreen::nuxDamageCompiz()
cScreen->damageScreen();
cScreen->damageRegionSetEnabled(this, true);
}
-
-#else
-
- /*
- * WARNING: Nux bug LP: #1014610 (unbounded DrawList growth) will cause
- * this code to be called far too often in some cases and
- * Unity will appear to freeze for a while. Please ensure you
- * have Nux 3.0+ with the fix for LP: #1014610.
- */
-
- if (!launcher_controller_ || !dash_controller_)
- return;
-
- CompRegion nux_damage;
-
- std::vector<nux::Geometry> const& dirty = wt->GetDrawList();
-
- for (auto const& geo : dirty)
- nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height);
-
- if (launcher_controller_->IsOverlayOpen())
- {
- nux::BaseWindow* dash_window = dash_controller_->window();
- nux::Geometry const& geo = dash_window->GetAbsoluteGeometry();
- nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height);
- }
-
- auto const& launchers = launcher_controller_->launchers();
- for (auto const& launcher : launchers)
- {
- if (!launcher->Hidden())
- {
- nux::ObjectPtr<nux::View> tooltip = launcher->GetActiveTooltip();
-
- if (tooltip)
- {
- nux::Geometry const& g = tooltip->GetAbsoluteGeometry();
- nux_damage += CompRegion(g.x, g.y, g.width, g.height);
- }
-
- nux::ObjectPtr<LauncherDragWindow> const& dragged_icon = launcher->GetDraggedIcon();
-
- if (dragged_icon)
- {
- nux::Geometry const& g = dragged_icon->GetAbsoluteGeometry();
- nux_damage += CompRegion(g.x, g.y, g.width, g.height);
- }
- }
- }
-
- cScreen->damageRegionSetEnabled(this, false);
- cScreen->damageRegion(nux_damage);
- cScreen->damageRegionSetEnabled(this, true);
-#endif
}
/* handle X Events */
@@ -1608,9 +1387,6 @@ void UnityScreen::handleEvent(XEvent* event)
PluginAdapter::Default()->OnScreenGrabbed();
else if (event->xfocus.mode == NotifyUngrab)
PluginAdapter::Default()->OnScreenUngrabbed();
-#ifndef USE_MODERN_COMPIZ_GL
- cScreen->damageScreen(); // evil hack
-#endif
if (_key_nav_mode_requested)
{
// Close any overlay that is open.
@@ -1623,28 +1399,23 @@ void UnityScreen::handleEvent(XEvent* event)
}
_key_nav_mode_requested = false;
break;
+ case MotionNotify:
+ if (scale_highlighted_window_ && PluginAdapter::Default()->IsScaleActive())
+ {
+ if (CompWindow *w = screen->findWindow(scale_highlighted_window_))
+ skip_other_plugins = UnityWindow::get(w)->handleEvent(event);
+ }
+ break;
case ButtonPress:
if (super_keypressed_)
{
launcher_controller_->KeyNavTerminate(false);
EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false);
}
- if (PluginAdapter::Default()->IsScaleActive() &&
- event->xbutton.button == Button1 &&
- highlighted_window_ != 0)
+ if (scale_highlighted_window_ && PluginAdapter::Default()->IsScaleActive())
{
- CompWindow *w = screen->findWindow (highlighted_window_);
- if (w)
- {
- UnityWindow *uw = UnityWindow::get (w);
- CompPoint pointer (pointerX, pointerY);
- if (uw->closeButtonArea ().contains (pointer))
- {
- w->close (0);
- skip_other_plugins = true;
- }
- }
-
+ if (CompWindow *w = screen->findWindow(scale_highlighted_window_))
+ skip_other_plugins = UnityWindow::get(w)->handleEvent(event);
}
break;
@@ -1666,6 +1437,11 @@ void UnityScreen::handleEvent(XEvent* event)
}
}
}
+ else if (scale_highlighted_window_ && PluginAdapter::Default()->IsScaleActive())
+ {
+ if (CompWindow *w = screen->findWindow(scale_highlighted_window_))
+ UnityWindow::get(w)->handleEvent(event);
+ }
break;
case KeyPress:
{
@@ -1793,8 +1569,8 @@ void UnityScreen::handleCompizEvent(const char* plugin,
ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
}
- if (PluginAdapter::Default()->IsScaleActive() &&
- g_strcmp0(plugin, "scale") == 0 && super_keypressed_)
+ if (PluginAdapter::Default()->IsScaleActive() && g_strcmp0(plugin, "scale") == 0 &&
+ super_keypressed_)
{
scale_just_activated_ = true;
}
@@ -2575,11 +2351,7 @@ bool UnityWindow::glDraw(const GLMatrix& matrix,
!uScreen->fullscreenRegion.contains(window->geometry())
)
{
-#ifdef USE_MODERN_COMPIZ_GL
uScreen->paintDisplay();
-#else
- uScreen->paintDisplay(region, matrix, mask);
-#endif
}
if (window->type() == CompWindowTypeDesktopMask)
@@ -3096,14 +2868,6 @@ void UnityScreen::Relayout()
if (!needsRelayout)
return;
-#ifndef USE_MODERN_COMPIZ_GL
- if (GL::fbo)
- {
- uScreen->_fbo = ScreenEffectFramebufferObject::Ptr (new ScreenEffectFramebufferObject (glXGetProcAddressP, geometry));
- uScreen->_fbo->onScreenSizeChanged (geometry);
- }
-#endif
-
UScreen *uscreen = UScreen::GetDefault();
int primary_monitor = uscreen->GetPrimaryMonitor();
auto geo = uscreen->GetMonitorGeometry(primary_monitor);
@@ -3218,78 +2982,124 @@ void UnityScreen::InitHints()
{
// TODO move category text into a vector...
+ // Compiz' plug-in names
+ static const std::string COMPIZ_CORE_PLUGIN_NAME = "core";
+ static const std::string COMPIZ_EXPO_PLUGIN_NAME = "expo";
+ static const std::string COMPIZ_GRID_PLUGIN_NAME = "grid";
+ static const std::string COMPIZ_MOVE_PLUGIN_NAME = "move";
+ static const std::string COMPIZ_RESIZE_PLUGIN_NAME = "resize";
+ static const std::string COMPIZ_SCALE_PLUGIN_NAME = "scale";
+ static const std::string COMPIZ_UNITYSHELL_PLUGIN_NAME = "unityshell";
+ static const std::string COMPIZ_WALL_PLUGIN_NAME = "wall";
+
+ // Compiz Core Options
+ static const std::string COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key";
+ static const std::string COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key";
+ static const std::string COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY = "unmaximize_window_key";
+ static const std::string COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key";
+ static const std::string COMPIZ_CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key";
+
+ // Compiz Expo Options
+ static const std::string COMPIZ_EXPO_OPTION_EXPO_KEY = "expo_key";
+
+ // Compiz Grid Options
+ static const std::string COMPIZ_GRID_OPTION_PUT_LEFT_KEY = "put_left_key";
+
+ // Compiz Move Options
+ static const std::string COMPIZ_MOVE_OPTION_INITIATE_BUTTON = "initiate_button";
+
+ // Compiz Resize Options
+ static const std::string COMPIZ_RESIZE_OPTION_INITIATE_BUTTON = "initiate_button";
+
+ // Compiz Scale Options
+ static const std::string COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY = "initiate_all_key";
+
+ // Compiz Unityshell Options
+ static const std::string COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER = "show_launcher";
+ static const std::string COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS = "keyboard_focus";
+ static const std::string COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward";
+ static const std::string COMPIZ_UNITYSHELL_OPTION_SHOW_HUD = "show_hud";
+ static const std::string COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
+ static const std::string COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
+ static const std::string COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
+
+ // Compiz Wall Options
+ static const std::string COMPIZ_WALL_OPTION_LEFT_KEY = "left_key";
+ static const std::string COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY = "left_window_key";
+
+
// Launcher...
- std::string const launcher(_("Launcher"));
+ static const std::string launcher(_("Launcher"));
hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" (Hold)"),
_("Opens the Launcher, displays shortcuts."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher" ));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "",
_("Opens Launcher keyboard navigation mode."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "keyboard_focus"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS));
hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "",
_("Switches applications via the Launcher."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "launcher_switcher_forward"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD));
hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + 1 to 9"),
_("Same as clicking on a Launcher icon."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + Shift + 1 to 9"),
_("Opens a new window in the app."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", " + T",
_("Opens the Trash."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
// Dash...
- std::string const dash( _("Dash"));
+ static const std::string dash( _("Dash"));
hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", _(" (Tap)"),
_("Opens the Dash Home."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + A",
_("Opens the Dash App Lens."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + F",
_("Opens the Dash Files Lens."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + M",
_("Opens the Dash Music Lens."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + V",
_("Opens the Dash Video Lens."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_launcher"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
_("Switches between Lenses."),
@@ -3307,15 +3117,15 @@ void UnityScreen::InitHints()
_("Enter")));
// Menu Bar
- std::string const menubar(_("HUD & Menu Bar"));
+ static const std::string menubar(_("HUD & Menu Bar"));
hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Tap)"),
_("Opens the HUD."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "show_hud"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_SHOW_HUD));
- hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", " (Hold)",
+ hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Hold)"),
_("Reveals the application menu."),
shortcut::HARDCODED_OPTION,
"Alt"));
@@ -3323,8 +3133,8 @@ void UnityScreen::InitHints()
hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "",
_("Opens the indicator menu."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "panel_first_menu"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU));
hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "",
_("Moves focus between indicators."),
@@ -3332,19 +3142,19 @@ void UnityScreen::InitHints()
_("Cursor Left or Right")));
// Switching
- std::string const switching(_("Switching"));
+ static const std::string switching(_("Switching"));
hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
_("Switches between applications."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "alt_tab_forward"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD));
hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
_("Switches windows of current applications."),
shortcut::COMPIZ_KEY_OPTION,
- "unityshell",
- "alt_tab_next_window"));
+ COMPIZ_UNITYSHELL_PLUGIN_NAME,
+ COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW));
hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
_("Moves the focus."),
@@ -3352,69 +3162,71 @@ void UnityScreen::InitHints()
_("Cursor Left or Right")));
// Workspaces
- std::string const workspaces(_("Workspaces"));
+ static const std::string workspaces(_("Workspaces"));
hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", "",
_("Switches between workspaces."),
shortcut::COMPIZ_KEY_OPTION,
- "expo",
- "expo_key"));
+ COMPIZ_EXPO_PLUGIN_NAME,
+ COMPIZ_EXPO_OPTION_EXPO_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"),
_("Switches workspaces."),
shortcut::COMPIZ_METAKEY_OPTION,
- "wall",
- "left_key"));
+ COMPIZ_WALL_PLUGIN_NAME,
+ COMPIZ_WALL_OPTION_LEFT_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"),
_("Moves focused window to another workspace."),
shortcut::COMPIZ_METAKEY_OPTION,
- "wall",
- "left_window_key"));
+ COMPIZ_WALL_PLUGIN_NAME,
+ COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY));
// Windows
- std::string const windows(_("Windows"));
+ static const std::string windows(_("Windows"));
+
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Spreads all windows in the current workspace."),
shortcut::COMPIZ_KEY_OPTION,
- "scale",
- "initiate_all_key"));
+ COMPIZ_SCALE_PLUGIN_NAME,
+ COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Minimises all windows."),
shortcut::COMPIZ_KEY_OPTION,
- "core",
- "show_desktop_key"));
+ COMPIZ_CORE_PLUGIN_NAME,
+ COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Maximises the current window."),
shortcut::COMPIZ_KEY_OPTION,
- "core",
- "maximize_window_key"));
+ COMPIZ_CORE_PLUGIN_NAME,
+ COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Restores or minimises the current window."),
shortcut::COMPIZ_KEY_OPTION,
- "core",
- "unmaximize_window_key"));
+ COMPIZ_CORE_PLUGIN_NAME,
+ COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"),
_("Semi-maximise the current window."),
shortcut::COMPIZ_KEY_OPTION,
- "grid",
- "put_left_key"));
+ COMPIZ_GRID_PLUGIN_NAME,
+ COMPIZ_GRID_OPTION_PUT_LEFT_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Closes the current window."),
shortcut::COMPIZ_KEY_OPTION,
- "core",
- "close_window_key"));
+ COMPIZ_CORE_PLUGIN_NAME,
+ COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Opens the window accessibility menu."),
- shortcut::HARDCODED_OPTION,
- _("Alt + Space")));
+ shortcut::COMPIZ_KEY_OPTION,
+ COMPIZ_CORE_PLUGIN_NAME,
+ COMPIZ_CORE_OPTION_WINDOW_MENU_KEY));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Places the window in corresponding position."),
@@ -3424,14 +3236,14 @@ void UnityScreen::InitHints()
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
_("Moves the window."),
shortcut::COMPIZ_MOUSE_OPTION,
- "move",
- "initiate_button"));
+ COMPIZ_MOVE_PLUGIN_NAME,
+ COMPIZ_MOVE_OPTION_INITIATE_BUTTON));
hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
_("Resizes the window."),
shortcut::COMPIZ_MOUSE_OPTION,
- "resize",
- "initiate_button"));
+ COMPIZ_RESIZE_PLUGIN_NAME,
+ COMPIZ_RESIZE_OPTION_INITIATE_BUTTON));
}
void UnityScreen::InitGesturesSupport()
@@ -3461,14 +3273,61 @@ void UnityScreen::InitGesturesSupport()
}
/* Window init */
+GLTexture::List UnityWindow::close_normal_tex_;
+GLTexture::List UnityWindow::close_prelight_tex_;
+GLTexture::List UnityWindow::close_pressed_tex_;
+
+struct UnityWindow::CairoContext
+{
+ CairoContext(int width, int height)
+ : pixmap_(XCreatePixmap(screen->dpy(), screen->root(), width, height, 32))
+ , texture_(GLTexture::bindPixmapToTexture(pixmap_, width, height, 32))
+ , surface_(nullptr)
+ , cr_(nullptr)
+ {
+ Screen *xscreen = ScreenOfDisplay(screen->dpy(), screen->screenNum());
+ XRenderPictFormat* format = XRenderFindStandardFormat(screen->dpy(), PictStandardARGB32);
+
+ if (texture_.empty())
+ return;
+
+ surface_ = cairo_xlib_surface_create_with_xrender_format(screen->dpy(), pixmap_,
+ xscreen, format,
+ width, height);
+ cr_ = cairo_create(surface_);
+
+ // clear
+ cairo_save(cr_);
+ cairo_set_operator(cr_, CAIRO_OPERATOR_CLEAR);
+ cairo_paint(cr_);
+ cairo_restore(cr_);
+ }
+
+ ~CairoContext ()
+ {
+ if (cr_)
+ cairo_destroy(cr_);
+
+ if (surface_)
+ cairo_surface_destroy(surface_);
+
+ texture_.clear();
+
+ if (pixmap_)
+ XFreePixmap(screen->dpy (), pixmap_);
+ }
+
+ Pixmap pixmap_;
+ GLTexture::List texture_;
+ cairo_surface_t* surface_;
+ cairo_t *cr_;
+};
+
UnityWindow::UnityWindow(CompWindow* window)
: BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *> (UnityScreen::get (screen)), window)
, PluginClassHandler<UnityWindow, CompWindow>(window)
, window(window)
, gWindow(GLWindow::get(window))
- , mMinimizeHandler()
- , mShowdesktopHandler(nullptr)
- , window_header_style_(0)
{
WindowInterface::setHandler(window);
GLWindowInterface::setHandler(gWindow);
@@ -3515,20 +3374,24 @@ UnityWindow::UnityWindow(CompWindow* window)
}
}
}
+
+ WindowManager::Default()->initiate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnInitiateSpreed));
+ WindowManager::Default()->terminate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnTerminateSpreed));
}
-void UnityWindow::DrawTexture (GLTexture* icon,
- const GLWindowPaintAttrib& attrib,
- const GLMatrix& transform,
- unsigned int mask,
- float x, float y,
- int &maxWidth, int &maxHeight)
+void
+UnityWindow::DrawTexture(GLTexture* icon,
+ const GLWindowPaintAttrib& attrib,
+ const GLMatrix& transform,
+ unsigned int mask,
+ float x, float y,
+ int &maxWidth, int &maxHeight)
{
if (icon)
{
int width, height;
- width = icon->width ();
- height = icon->height ();
+ width = icon->width();
+ height = icon->height();
if (height > maxHeight)
maxHeight = height;
@@ -3536,271 +3399,295 @@ void UnityWindow::DrawTexture (GLTexture* icon,
if (width > maxWidth)
maxWidth = width;
- CompRegion iconReg (0, 0, width, height);
- GLTexture::MatrixList ml (1);
+ CompRegion iconReg(0, 0, width, height);
+ GLTexture::MatrixList ml(1);
- ml[0] = icon->matrix ();
- gWindow->vertexBuffer ()->begin ();
+ ml[0] = icon->matrix();
+ gWindow->vertexBuffer()->begin();
if (width && height)
- gWindow->glAddGeometry (ml, iconReg, iconReg);
+ gWindow->glAddGeometry(ml, iconReg, iconReg);
- if (gWindow->vertexBuffer ()->end ())
+ if (gWindow->vertexBuffer()->end())
{
- GLMatrix wTransform (transform);
+ GLMatrix wTransform(transform);
- wTransform.translate (x, y, 0.0f);
+ wTransform.translate(x, y, 0.0f);
- gWindow->glDrawTexture (icon, wTransform, attrib, mask);
+ gWindow->glDrawTexture(icon, wTransform, attrib, mask);
}
}
}
-WindowCairoContext* UnityWindow::CreateCairoContext (float width, float height)
+void
+UnityWindow::RenderText(UnityWindow::CairoContext const& context,
+ float x, float y,
+ float maxWidth, float maxHeight)
{
- XRenderPictFormat *format;
- Screen *xScreen;
- WindowCairoContext *context = new WindowCairoContext();
-
- xScreen = ScreenOfDisplay (screen->dpy (), screen->screenNum ());
+ panel::Style& style = panel::Style::Instance();
+ std::string fontDescription(style.GetFontDescription(panel::PanelItem::TITLE));
- format = XRenderFindStandardFormat (screen->dpy (), PictStandardARGB32);
- context->pixmap_ = XCreatePixmap (screen->dpy (),
- screen->root (),
- width, height, 32);
-
- context->texture_ = GLTexture::bindPixmapToTexture (context->pixmap_,
- width, height,
- 32);
- if (context->texture_.empty ())
- {
- delete context;
- return 0;
- }
+ glib::Object<PangoLayout> layout(pango_cairo_create_layout(context.cr_));
+ std::shared_ptr<PangoFontDescription> font(pango_font_description_from_string(fontDescription.c_str()),
+ pango_font_description_free);
- context->surface_ = cairo_xlib_surface_create_with_xrender_format (screen->dpy (),
- context->pixmap_,
- xScreen,
- format,
- width,
- height);
- context->cr_ = cairo_create (context->surface_);
+ pango_layout_set_font_description(layout, font.get());
- // clear
- cairo_save (context->cr_);
- cairo_set_operator (context->cr_, CAIRO_OPERATOR_CLEAR);
- cairo_paint (context->cr_);
- cairo_restore (context->cr_);
+ GdkScreen* gdkScreen = gdk_screen_get_default();
+ PangoContext* pCxt = pango_layout_get_context(layout);
+ int dpi = style.GetTextDPI();
- return context;
-}
+ pango_cairo_context_set_font_options(pCxt, gdk_screen_get_font_options(gdkScreen));
+ pango_cairo_context_set_resolution(pCxt, dpi / static_cast<float>(PANGO_SCALE));
+ pango_layout_context_changed(layout);
-void UnityWindow::RenderText (WindowCairoContext *context,
- float x, float y,
- float maxWidth, float maxHeight)
-{
- PangoFontDescription* font = pango_font_description_new ();
- pango_font_description_set_family (font, "sans");
- pango_font_description_set_absolute_size (font, 12 * PANGO_SCALE);
- pango_font_description_set_style (font, PANGO_STYLE_NORMAL);
- pango_font_description_set_weight (font, PANGO_WEIGHT_BOLD);
+ pango_layout_set_height(layout, maxHeight);
+ pango_layout_set_width(layout, -1); //avoid wrap lines
+ pango_layout_set_auto_dir(layout, false);
+ pango_layout_set_text(layout,
+ WindowManager::Default()->GetWindowName(window->id()).c_str(),
+ -1);
- PangoLayout* layout = pango_cairo_create_layout (context->cr_);
- pango_layout_set_font_description (layout, font);
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- pango_layout_set_height (layout, maxHeight);
+ /* update the size of the pango layout */
+ pango_cairo_update_layout(context.cr_, layout);
+ cairo_set_operator(context.cr_, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgba(context.cr_,
+ 1.0,
+ 1.0,
+ 1.0,
+ 1.0);
- pango_layout_set_auto_dir (layout, false);
- pango_layout_set_text (layout,
- GetWindowName (window->id ()).c_str (),
- -1);
+ // alignment
+ PangoRectangle lRect;
+ int textWidth, textHeight;
- /* update the size of the pango layout */
- pango_layout_set_width (layout, maxWidth * PANGO_SCALE);
- pango_cairo_update_layout (context->cr_, layout);
+ pango_layout_get_extents(layout, NULL, &lRect);
+ textWidth = lRect.width / PANGO_SCALE;
+ textHeight = lRect.height / PANGO_SCALE;
- cairo_set_operator (context->cr_, CAIRO_OPERATOR_OVER);
+ y = ((maxHeight - textHeight) / 2.0) + y;
+ cairo_translate(context.cr_, x, y);
- cairo_set_source_rgba (context->cr_,
- 1.0,
- 1.0,
- 1.0,
- 1.0);
+ if (textWidth > maxWidth)
+ {
+ // apply a fade effect in the right corner
+ const int outPixels = textWidth - maxWidth;
+ const int fadingPixels = 35;
+ const int fadingWidth = outPixels < fadingPixels ? outPixels : fadingPixels;
- // alignment
- int lWidth, lHeight;
- pango_layout_get_pixel_size (layout, &lWidth, &lHeight);
+ cairo_push_group(context.cr_);
+ pango_cairo_show_layout(context.cr_, layout);
+ cairo_pop_group_to_source(context.cr_);
- y = ((maxHeight - lHeight) / 2.0) + y;
- cairo_translate (context->cr_, x, y);
- pango_cairo_show_layout (context->cr_, layout);
+ std::shared_ptr<cairo_pattern_t> linpat(cairo_pattern_create_linear(maxWidth - fadingWidth,
+ y, maxWidth, y),
+ cairo_pattern_destroy);
+ cairo_pattern_add_color_stop_rgba(linpat.get(), 0, 0, 0, 0, 1);
+ cairo_pattern_add_color_stop_rgba(linpat.get(), 1, 0, 0, 0, 0);
+ cairo_mask(context.cr_, linpat.get());
+ }
+ else
+ {
+ pango_cairo_show_layout(context.cr_, layout);
+ }
}
-void UnityWindow::DrawWindowTitle (const GLWindowPaintAttrib& attrib,
- const GLMatrix& transform,
- unsigned int mask,
- float x, float y, float x2, float y2)
+void
+UnityWindow::DrawWindowDecoration(GLWindowPaintAttrib const& attrib,
+ GLMatrix const& transform,
+ unsigned int mask,
+ bool highlighted,
+ int x, int y, unsigned width, unsigned height)
{
- const float width = x2 - x;
-
// Paint a fake window decoration
- WindowCairoContext *context = CreateCairoContext (width, SCALE_WINDOW_TITLE_SIZE);
+ CairoContext context(width, height);
- cairo_save (context->cr_);
- cairo_push_group (context->cr_);
+ cairo_save(context.cr_);
+ cairo_push_group(context.cr_);
// Round window decoration top border
- const double height = SCALE_WINDOW_TITLE_SIZE;
const double aspect = 1.0;
const double corner_radius = height / 10.0;
const double radius = corner_radius / aspect;
const double degrees = M_PI / 180.0;
- cairo_new_sub_path (context->cr_);
+ cairo_new_sub_path(context.cr_);
- cairo_arc (context->cr_, radius, radius, radius, 180 * degrees, 270 * degrees);
- cairo_arc (context->cr_, width - radius, radius, radius, -90 * degrees, 0 * degrees);
- cairo_line_to (context->cr_, width, height);
- cairo_line_to (context->cr_, 0, height);
+ cairo_arc(context.cr_, radius, radius, radius, 180 * degrees, 270 * degrees);
+ cairo_arc(context.cr_, width - radius, radius, radius, -90 * degrees, 0 * degrees);
+ cairo_line_to(context.cr_, width, height);
+ cairo_line_to(context.cr_, 0, height);
- cairo_close_path (context->cr_);
- cairo_clip (context->cr_);
+ cairo_close_path(context.cr_);
+ cairo_clip(context.cr_);
- // Draw window decoration abased on gtk style
- gtk_render_background (window_header_style_, context->cr_, 0, 0, width, SCALE_WINDOW_TITLE_SIZE);
- gtk_render_frame (window_header_style_, context->cr_, 0, 0, width, SCALE_WINDOW_TITLE_SIZE);
+ // Draw window decoration based on gtk style
+ auto& style = panel::Style::Instance();
+ gtk_render_background(style.GetStyleContext(), context.cr_, 0, 0, width, height);
+ gtk_render_frame(style.GetStyleContext(), context.cr_, 0, 0, width, height);
- cairo_pop_group_to_source (context->cr_);
+ cairo_pop_group_to_source(context.cr_);
- cairo_paint_with_alpha (context->cr_, 1.0);
- cairo_restore (context->cr_);
+ cairo_paint_with_alpha(context.cr_, 1.0);
+ cairo_restore(context.cr_);
- // Draw windows title
- RenderText (context,
- CLOSE_ICON_SPACE * 2 + CLOSE_ICON_SIZE,
- 0.0,
- width, SCALE_WINDOW_TITLE_SIZE);
+ if (highlighted)
+ {
+ // Draw windows title
+ const float xText = SCALE_ITEMS_PADDING * 2 + SCALE_CLOSE_ICON_SIZE;
+ RenderText(context, xText, 0.0, width - xText - SCALE_ITEMS_PADDING, height);
+ }
mask |= PAINT_WINDOW_BLEND_MASK;
int maxWidth, maxHeight;
- foreach(GLTexture *icon, context->texture_)
+
+ for (GLTexture *icon : context.texture_)
+ DrawTexture(icon, attrib, transform, mask, x, y, maxWidth , maxHeight);
+}
+
+void UnityWindow::LoadCloseIcon(panel::WindowState state, GLTexture::List& texture)
+{
+ if (!texture.empty())
+ return;
+
+ auto& style = panel::Style::Instance();
+ auto const& files = style.GetWindowButtonFileNames(panel::WindowButtonType::CLOSE, state);
+
+ CompString pName("unityshell");
+ for (std::string const& file : files)
{
- DrawTexture (icon, attrib, transform, mask,
- x, y,
- maxWidth , maxHeight);
+ CompString fileName(file.c_str());
+ CompSize size(SCALE_CLOSE_ICON_SIZE, SCALE_CLOSE_ICON_SIZE);
+ texture = GLTexture::readImageToTexture(fileName, pName, size);
+ if (!texture.empty())
+ break;
}
- delete context;
+ if (texture.empty())
+ {
+ std::string suffix;
+ if (state == panel::WindowState::PRELIGHT)
+ suffix = "_prelight";
+ else if (state == panel::WindowState::PRESSED)
+ suffix = "_pressed";
+
+ CompString fileName((PKGDATADIR"/close_dash" + suffix + ".png").c_str());
+ CompSize size(SCALE_CLOSE_ICON_SIZE, SCALE_CLOSE_ICON_SIZE);
+ texture = GLTexture::readImageToTexture(fileName, pName, size);
+ }
+}
+
+void UnityWindow::SetupScaleHeaderStyle()
+{
+ LoadCloseIcon(panel::WindowState::NORMAL, close_normal_tex_);
+ LoadCloseIcon(panel::WindowState::PRELIGHT, close_prelight_tex_);
+ LoadCloseIcon(panel::WindowState::PRESSED, close_pressed_tex_);
}
-void UnityWindow::scalePaintDecoration (const GLWindowPaintAttrib& attrib,
- const GLMatrix& transform,
- const CompRegion& region,
- unsigned int mask)
+void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib,
+ GLMatrix const& transform,
+ CompRegion const& region,
+ unsigned int mask)
{
- ScaleWindow *sWindow = ScaleWindow::get (window);
- if (!sWindow)
+ ScaleWindow *scale_win = ScaleWindow::get(window);
+ if (!scale_win)
return;
- sWindow->scalePaintDecoration (attrib, transform, region, mask);
+ scale_win->scalePaintDecoration(attrib, transform, region, mask);
- if (!sWindow->hasSlot()) // animation not finished
+ if (!scale_win->hasSlot()) // animation not finished
return;
- if (!window_header_style_)
- {
- GtkWidgetPath* widget_path = gtk_widget_path_new ();
- gint pos = gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
- gtk_widget_path_iter_set_name (widget_path, pos, "UnityPanelWidget");
-
- window_header_style_ = gtk_style_context_new ();
- gtk_style_context_set_path (window_header_style_, widget_path);
- gtk_style_context_add_class (window_header_style_, "gnome-panel-menu-bar");
- gtk_style_context_add_class (window_header_style_, "unity-panel");
+ UnityScreen* us = UnityScreen::get(screen);
+ const bool highlighted = (us->scale_highlighted_window_ == window->id());
- // get close button
- panel::Style& style = panel::Style::Instance();
+ ScalePosition const& pos = scale_win->getCurrentPosition();
+ auto const& border_rect = window->borderRect();
+ auto const& deco_ext = window->border();
- std::vector<std::string> files = style.GetWindowButtonFileNames (panel::WindowButtonType::CLOSE,
- panel::WindowState::NORMAL);
+ const unsigned decoration_height = deco_ext.top;
+ unsigned width = (border_rect.width() + deco_ext.left + deco_ext.right) * pos.scale;
+ unsigned height = decoration_height * pos.scale;
+ int x = pos.x() + border_rect.x();
+ int y = pos.y() + border_rect.y() + decoration_height - height - 1;
- CompString pName ("unityshell");
- foreach (std::string file, files)
- {
- CompString fileName (file.c_str ());
- CompSize size (CLOSE_ICON_SIZE, CLOSE_ICON_SIZE);
- close_icon_ = GLTexture::readImageToTexture (fileName,
- pName,
- size);
- if (close_icon_.size () != 0)
- break;
- }
+ // If window is highlighted, we draw the decoration at full size
+ if (highlighted)
+ height = decoration_height;
- if (close_icon_.size () == 0)
- {
- CompString fileName (PKGDATADIR"/close_dash.png");
- CompSize size (CLOSE_ICON_SIZE, CLOSE_ICON_SIZE);
- close_icon_ = GLTexture::readImageToTexture (fileName,
- pName,
- size);
- }
- }
+ DrawWindowDecoration(attrib, transform, mask, highlighted, x, y, width, height);
- // Make the windows header opaque to override the original
- GLWindowPaintAttrib sAttrib (attrib);
- sAttrib.opacity = OPAQUE;
+ if (highlighted)
+ {
+ x += SCALE_ITEMS_PADDING;
+ y += (height - SCALE_CLOSE_ICON_SIZE) / 2.0f;
+ int max_height = 0;
+ int max_width = 0;
+ mask |= PAINT_WINDOW_BLEND_MASK;
- ScalePosition pos = sWindow->getCurrentPosition ();
- int maxHeight, maxWidth;
- // Use "2" as margin to make sure to cover all originial decoration
- const float width = (window->width () + 4) * pos.scale;
- const float x = pos.x () + window->x () - (2 * pos.scale);
- const float y = pos.y () + window->y () - SCALE_WINDOW_TITLE_SIZE;
- const float iconX = x + CLOSE_ICON_SPACE;
- const float iconY = y + ((SCALE_WINDOW_TITLE_SIZE - CLOSE_ICON_SIZE) / 2.0);
+ switch(close_icon_state_)
+ {
+ case panel::WindowState::NORMAL:
+ default:
+ for (GLTexture *icon : close_normal_tex_)
+ DrawTexture(icon, attrib, transform, mask, x, y, max_width , max_height);
+ break;
- maxHeight = maxWidth = 0;
+ case panel::WindowState::PRELIGHT:
+ for (GLTexture *icon : close_prelight_tex_)
+ DrawTexture(icon, attrib, transform, mask, x, y, max_width , max_height);
+ break;
- DrawWindowTitle (sAttrib,
- transform,
- mask,
- x, y,
- x + width, y + SCALE_WINDOW_TITLE_SIZE);
+ case panel::WindowState::PRESSED:
+ for (GLTexture *icon : close_pressed_tex_)
+ DrawTexture(icon, attrib, transform, mask, x, y, max_width , max_height);
+ break;
+ }
- mask |= PAINT_WINDOW_BLEND_MASK;
- foreach(GLTexture *icon, close_icon_)
+ close_button_geo_.Set(x, y, max_height, max_width);
+ }
+ else if (!close_button_geo_.IsNull())
{
- DrawTexture (icon, sAttrib, transform, mask,
- iconX, iconY,
- maxWidth , maxHeight);
+ close_button_geo_.Set(0, 0, 0, 0);
}
-
- close_button_area_ = CompRect (iconX, iconY, maxWidth, maxHeight);
}
-void UnityWindow::scaleSelectWindow ()
+void UnityWindow::scaleSelectWindow()
{
+ ScaleWindow::get(window)->scaleSelectWindow();
+
UnityScreen* us = UnityScreen::get(screen);
- if (us->highlighted_window_ != window->id ())
- {
- CompositeWindow *cWindow = CompositeWindow::get (window);
- if (cWindow)
- cWindow->addDamage ();
+ if (us->scale_highlighted_window_ != window->id())
+ us->scale_highlighted_window_ = window->id();
+}
- cWindow = 0;
- CompWindow *old_window = screen->findWindow (us->highlighted_window_);
- if (old_window)
- cWindow = CompositeWindow::get (old_window);
+void UnityWindow::OnInitiateSpreed()
+{
+ auto const windows = screen->windows();
+ if (std::find(windows.begin(), windows.end(), window) == windows.end())
+ return;
- if (cWindow)
- cWindow->addDamage ();
+ close_icon_state_ = panel::WindowState::NORMAL;
+ SetupScaleHeaderStyle();
- us->highlighted_window_ = window->id ();
- }
+ WindowManager *wm = WindowManager::Default();
+ Window xid = window->id();
+
+ if (wm->IsWindowDecorated(xid))
+ wm->Decorate(xid);
+}
+
+void UnityWindow::OnTerminateSpreed()
+{
+ auto const windows = screen->windows();
+ if (std::find(windows.begin(), windows.end(), window) == windows.end())
+ return;
+
+ WindowManager *wm = WindowManager::Default();
+ Window xid = window->id();
- ScaleWindow *sWindow = ScaleWindow::get (window);
- if (sWindow)
- sWindow->scaleSelectWindow ();
+ if (wm->IsWindowDecorated(xid) && wm->IsWindowMaximized(xid))
+ wm->Undecorate(xid);
}
UnityWindow::~UnityWindow()
@@ -3821,18 +3708,12 @@ UnityWindow::~UnityWindow()
window->minimize ();
}
- if (window_header_style_)
- g_object_unref (window_header_style_);
-
ShowdesktopHandler::animating_windows.remove (static_cast <ShowdesktopHandlerWindowInterface *> (this));
- if (mShowdesktopHandler)
- delete mShowdesktopHandler;
-
if (window->state () & CompWindowStateFullscreenMask)
UnityScreen::get (screen)->fullscreen_windows_.remove(window);
- PluginAdapter::Default ()->OnWindowClosed (window);
+ PluginAdapter::Default ()->OnWindowClosed(window);
}
/* vtable init */
@@ -3863,85 +3744,6 @@ bool UnityPluginVTable::init()
return true;
}
-CompString UnityWindow::GetUtf8Property (Window id,
- Atom atom)
-{
- Atom type;
- int result, format;
- unsigned long nItems, bytesAfter;
- char *val;
- CompString retval;
- Atom utf8StringAtom;
-
- utf8StringAtom = XInternAtom (screen->dpy (), "UTF8_STRING", 0);
- result = XGetWindowProperty (screen->dpy (), id, atom, 0L, 65536, False,
- utf8StringAtom, &type, &format, &nItems,
- &bytesAfter, (unsigned char **) &val);
-
- if (result != Success)
- return retval;
-
- if (type == utf8StringAtom && format == 8 && val && nItems > 0)
- {
- char valueString[nItems + 1];
- strncpy (valueString, val, nItems);
- valueString[nItems] = 0;
- retval = valueString;
- }
- if (val)
- XFree (val);
-
- return retval;
-}
-
-CompString UnityWindow::GetTextProperty (Window id,
- Atom atom)
-{
- XTextProperty text;
- CompString retval;
-
- text.nitems = 0;
- if (XGetTextProperty (screen->dpy (), id, &text, atom))
- {
- if (text.value)
- {
- char valueString[text.nitems + 1];
-
- strncpy (valueString, (char *) text.value, text.nitems);
- valueString[text.nitems] = 0;
-
- retval = valueString;
-
- XFree (text.value);
- }
- }
-
- return retval;
-}
-
-
-CompString UnityWindow::GetWindowName (Window id)
-{
- CompString name;
- Atom visibleNameAtom;
-
- visibleNameAtom = XInternAtom (screen->dpy (), "_NET_WM_VISIBLE_NAME", 0);
- name = GetUtf8Property (id, visibleNameAtom);
- if (name.empty ())
- {
- Atom wmNameAtom = XInternAtom (screen->dpy (), "_NET_WM_NAME", 0);
- name = GetUtf8Property (id, wmNameAtom);
- }
-
-
- if (name.empty ())
- name = GetTextProperty (id, XA_WM_NAME);
-
- return name;
-}
-
-
-
namespace
{
diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h
index b9bea314a..a1de06832 100644
--- a/plugins/unityshell/src/unityshell.h
+++ b/plugins/unityshell/src/unityshell.h
@@ -55,9 +55,6 @@
#include "UnityshellPrivate.h"
#include "UnityShowdesktopHandler.h"
#include "ThumbnailGenerator.h"
-#ifndef USE_MODERN_COMPIZ_GL
-#include "ScreenEffectFramebufferObject.h"
-#endif
#include "compizminimizedwindowhandler.h"
#include "BGHash.h"
@@ -71,8 +68,6 @@
namespace unity
{
-class WindowCairoContext;
-
/* base screen class */
class UnityScreen :
public unity::debug::Introspectable,
@@ -99,11 +94,7 @@ public:
void nuxEpilogue();
/* nux draw wrapper */
-#ifdef USE_MODERN_COMPIZ_GL
void paintDisplay();
-#else
- void paintDisplay(const CompRegion& region, const GLMatrix& transform, unsigned int mask);
-#endif
void paintPanelShadow(const GLMatrix& matrix);
void setPanelShadowMatrix(const GLMatrix& matrix);
@@ -249,7 +240,11 @@ private:
void OnPanelStyleChanged();
void InitGesturesSupport();
-
+
+ void DrawTopPanelBackground();
+ bool TopPanelBackgroundTextureNeedsUpdate() const;
+ void UpdateTopPanelBackgroundTexture();
+
nux::animation::TickSource tick_source_;
nux::animation::AnimationController animation_controller_;
@@ -313,12 +308,7 @@ private:
BGHash _bghash;
-#ifdef USE_MODERN_COMPIZ_GL
::GLFramebufferObject *oldFbo;
-#else
- ScreenEffectFramebufferObject::Ptr _fbo;
- GLuint _active_fbo;
-#endif
bool queryForShader ();
@@ -339,15 +329,11 @@ private:
bool scale_just_activated_;
-#ifndef USE_MODERN_COMPIZ_GL
- ScreenEffectFramebufferObject::GLXGetProcAddressProc glXGetProcAddressP;
-#endif
-
UBusManager ubus_manager_;
glib::SourceManager sources_;
unity::ThumbnailGenerator thumb_generator;
- Window highlighted_window_;
+ Window scale_highlighted_window_;
WindowMinimizeSpeedController* minimize_speed_controller;
friend class UnityWindow;
@@ -388,11 +374,7 @@ public:
/* basic window draw function */
bool glDraw(const GLMatrix& matrix,
-#ifndef USE_MODERN_COMPIZ_GL
- GLFragment::Attrib& attrib,
-#else
const GLWindowPaintAttrib& attrib,
-#endif
const CompRegion& region,
unsigned intmask);
@@ -417,26 +399,25 @@ public:
void leaveShowDesktop ();
bool HandleAnimations (unsigned int ms);
- void handleEvent (XEvent *event);
-
- CompRect closeButtonArea ();
+ bool handleEvent(XEvent *event);
typedef compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>
UnityMinimizedHandler;
std::unique_ptr <UnityMinimizedHandler> mMinimizeHandler;
-
- ShowdesktopHandler *mShowdesktopHandler;
+ std::unique_ptr <ShowdesktopHandler> mShowdesktopHandler;
//! Emited when CompWindowNotifyBeforeDestroy is received
sigc::signal<void> being_destroyed;
- void scaleSelectWindow ();
- void scalePaintDecoration (const GLWindowPaintAttrib &,
- const GLMatrix &,
- const CompRegion &,
- unsigned int);
+ void scaleSelectWindow();
+ void scalePaintDecoration(const GLWindowPaintAttrib &,
+ const GLMatrix &,
+ const CompRegion &,
+ unsigned int);
private:
+ struct CairoContext;
+
void DoEnableFocus ();
void DoDisableFocus ();
@@ -456,6 +437,9 @@ private:
void DoShow ();
void DoNotifyShown ();
+ void OnInitiateSpreed();
+ void OnTerminateSpreed();
+
void DoAddDamage ();
ShowdesktopHandlerWindowInterface::PostPaintAction DoHandleAnimations (unsigned int ms);
@@ -467,32 +451,31 @@ private:
compiz::WindowInputRemoverLock::Ptr GetInputRemover ();
- void DrawWindowTitle (const GLWindowPaintAttrib& attrib,
- const GLMatrix& transform,
- unsigned int mask,
- float x, float y, float x2, float y2);
- void DrawTexture (GLTexture *icon,
- const GLWindowPaintAttrib& attrib,
- const GLMatrix& transform,
- unsigned int mask,
- float x, float y,
- int &maxWidth, int &maxHeight);
- void RenderText (WindowCairoContext *context,
+ void DrawWindowDecoration(GLWindowPaintAttrib const& attrib,
+ GLMatrix const& transform,
+ unsigned int mask,
+ bool highlighted,
+ int x, int y, unsigned width, unsigned height);
+ void DrawTexture(GLTexture *icon,
+ const GLWindowPaintAttrib& attrib,
+ const GLMatrix& transform,
+ unsigned int mask,
float x, float y,
- float maxWidth, float maxHeight);
- WindowCairoContext* CreateCairoContext (float width, float height);
+ int &maxWidth, int &maxHeight);
+ void RenderText(CairoContext const& context,
+ float x, float y,
+ float maxWidth, float maxHeight);
- // based on compiz text plugin
- CompString GetWindowName (Window id);
- CompString GetUtf8Property (Window id, Atom atom);
- CompString GetTextProperty (Window id, Atom atom);
+ void SetupScaleHeaderStyle();
+ void LoadCloseIcon(panel::WindowState state, GLTexture::List& texture);
+ static GLTexture::List close_normal_tex_;
+ static GLTexture::List close_prelight_tex_;
+ static GLTexture::List close_pressed_tex_;
compiz::WindowInputRemoverLock::Weak input_remover_;
+ panel::WindowState close_icon_state_;
+ nux::Geometry close_button_geo_;
glib::Source::UniquePtr focus_desktop_timeout_;
-
- GLTexture::List close_icon_;
- CompRect close_button_area_;
- GtkStyleContext* window_header_style_;
};