aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2012-03-09 06:21:28 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2012-03-13 20:38:55 (GMT)
commit4abba97f727faa6b801e7ceb73819e7f20cc59b8 (patch)
treef327731cae5f739cfaef9d305be5ad90136ed190
parentc63944ee67906b49b75856d394e580def609c64a (diff)
implement xrender support for snaphelper
REVIEW: 104203
-rw-r--r--kwin/effects/snaphelper/snaphelper.cpp76
-rw-r--r--kwin/effects/snaphelper/snaphelper.h2
2 files changed, 34 insertions, 44 deletions
diff --git a/kwin/effects/snaphelper/snaphelper.cpp b/kwin/effects/snaphelper/snaphelper.cpp
index a30cc60..9db88b1 100644
--- a/kwin/effects/snaphelper/snaphelper.cpp
+++ b/kwin/effects/snaphelper/snaphelper.cpp
@@ -21,13 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "snaphelper.h"
#include "kwinglutils.h"
-//#include "kwinxrenderutils.h"
+#include "kwinxrenderutils.h"
namespace KWin
{
KWIN_EFFECT(snaphelper, SnapHelperEffect)
-KWIN_EFFECT_SUPPORTED(snaphelper, SnapHelperEffect::supported())
SnapHelperEffect::SnapHelperEffect()
: m_active(false)
@@ -59,11 +58,6 @@ void SnapHelperEffect::reconfigure(ReconfigureFlags)
m_timeline.setDuration(animationTime(250));
}
-bool SnapHelperEffect::supported()
-{
- return effects->compositingType() == OpenGLCompositing;
-}
-
void SnapHelperEffect::prePaintScreen(ScreenPrePaintData &data, int time)
{
double oldValue = m_timeline.currentValue();
@@ -139,50 +133,48 @@ void SnapHelperEffect::postPaintScreen()
glPopAttrib();
#endif
}
- /*if ( effects->compositingType() == XRenderCompositing )
- { // TODO
- for ( int i = 0; i < effects->numScreens(); i++ )
- {
+ if ( effects->compositingType() == XRenderCompositing ) {
+ for ( int i = 0; i < effects->numScreens(); i++ ) {
const QRect& rect = effects->clientArea( ScreenArea, i, 0 );
int midX = rect.x() + rect.width() / 2;
int midY = rect.y() + rect.height() / 2 ;
int halfWidth = m_window->width() / 2;
int halfHeight = m_window->height() / 2;
- XSegment segments[6];
-
+ XRectangle rects[6];
// Center lines
- segments[0].x1 = rect.x() + rect.width() / 2;
- segments[0].y1 = rect.y();
- segments[0].x2 = rect.x() + rect.width() / 2;
- segments[0].y2 = rect.y() + rect.height();
- segments[1].x1 = rect.x();
- segments[1].y1 = rect.y() + rect.height() / 2;
- segments[1].x2 = rect.x() + rect.width();
- segments[1].y2 = rect.y() + rect.height() / 2;
+ rects[0].x = rect.x() + rect.width() / 2 - 2;
+ rects[0].y = rect.y();
+ rects[0].width = 4;
+ rects[0].height = rect.height();
+ rects[1].x = rect.x();
+ rects[1].y = rect.y() + rect.height() / 2 - 2;
+ rects[1].width = rect.width();
+ rects[1].height = 4;
// Window outline
- // The +/- 2 is to prevent line overlap
- segments[2].x1 = midX - halfWidth + 2;
- segments[2].y1 = midY - halfHeight;
- segments[2].x2 = midX + halfWidth + 2;
- segments[2].y2 = midY - halfHeight;
- segments[3].x1 = midX + halfWidth;
- segments[3].y1 = midY - halfHeight + 2;
- segments[3].x2 = midX + halfWidth;
- segments[3].y2 = midY + halfHeight + 2;
- segments[4].x1 = midX + halfWidth - 2;
- segments[4].y1 = midY + halfHeight;
- segments[4].x2 = midX - halfWidth - 2;
- segments[4].y2 = midY + halfHeight;
- segments[5].x1 = midX - halfWidth;
- segments[5].y1 = midY + halfHeight - 2;
- segments[5].x2 = midX - halfWidth;
- segments[5].y2 = midY - halfHeight - 2;
-
- XDrawSegments( display(), effects->xrenderBufferPicture(), m_gc, segments, 6 );
- }
- }*/
+ // The +/- 4 is to prevent line overlap
+ rects[2].x = midX - halfWidth + 4;
+ rects[2].y = midY - halfHeight;
+ rects[2].width = 2*halfWidth - 4;
+ rects[2].height = 4;
+ rects[3].x = midX + halfWidth - 4;
+ rects[3].y = midY - halfHeight + 4;
+ rects[3].width = 4;
+ rects[3].height = 2*halfHeight - 4;
+ rects[4].x = midX - halfWidth;
+ rects[4].y = midY + halfHeight - 4;
+ rects[4].width = 2*halfWidth - 4;
+ rects[4].height = 4;
+ rects[5].x = midX - halfWidth;
+ rects[5].y = midY - halfHeight;
+ rects[5].width = 4;
+ rects[5].height = 2*halfHeight - 4;
+
+ XRenderColor c = preMultiply(QColor(128, 128, 128, m_timeline.currentValue()*128));
+ XRenderFillRectangles(display(), PictOpOver, effects->xrenderBufferPicture(), &c, rects, 6);
+ }
+ }
} else if (m_window && !m_active) {
if (m_window->isDeleted())
m_window->unrefWindow();
diff --git a/kwin/effects/snaphelper/snaphelper.h b/kwin/effects/snaphelper/snaphelper.h
index ee60f8f..e9d773e 100644
--- a/kwin/effects/snaphelper/snaphelper.h
+++ b/kwin/effects/snaphelper/snaphelper.h
@@ -41,8 +41,6 @@ public:
virtual void postPaintScreen();
virtual bool isActive() const;
- static bool supported();
-
public Q_SLOTS:
void slotWindowClosed(EffectWindow *w);
void slotWindowStartUserMovedResized(EffectWindow *w);