summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-27 15:08:10 +0200
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-27 15:08:10 +0200
commitac82488c022665492713d633d832480063f67067 (patch)
treeab9e230bc8ad1055fe080506dfc784fc088c43cb
parentb92393878f81ec008ac7f383f63afe648bc5f80f (diff)
downloadzcomp-ac82488c022665492713d633d832480063f67067.tar.gz
zcomp-ac82488c022665492713d633d832480063f67067.tar.bz2
Moved composite handling and opengl painting into separate plugins.
-rw-r--r--configure.ac2
-rw-r--r--include/compdisplay.h7
-rw-r--r--include/compicon.h3
-rw-r--r--include/compiz-core.h9
-rw-r--r--include/compmatrix.h40
-rw-r--r--include/composite/composite.h181
-rw-r--r--include/compscreen.h317
-rw-r--r--include/compvector.h51
-rw-r--r--include/compwindow.h114
-rw-r--r--include/opengl/fragment.h (renamed from include/compfragment.h)25
-rw-r--r--include/opengl/matrix.h38
-rw-r--r--include/opengl/opengl.h345
-rw-r--r--include/opengl/texture.h (renamed from include/comptexture.h)39
-rw-r--r--include/opengl/vector.h51
-rw-r--r--metadata/Makefile.am4
-rw-r--r--metadata/composite.xml.in36
-rw-r--r--metadata/core.xml.in60
-rw-r--r--metadata/opengl.xml.in44
-rw-r--r--plugins/Makefile.am5
-rw-r--r--plugins/composite/Makefile.am26
-rw-r--r--plugins/composite/composite.cpp282
-rw-r--r--plugins/composite/display.cpp234
-rw-r--r--plugins/composite/privates.h148
-rw-r--r--plugins/composite/screen.cpp760
-rw-r--r--plugins/composite/window.cpp622
-rw-r--r--plugins/move.cpp69
-rw-r--r--plugins/opengl/Makefile.am36
-rw-r--r--plugins/opengl/display.cpp77
-rw-r--r--plugins/opengl/fragment.cpp (renamed from src/fragment.cpp)45
-rw-r--r--plugins/opengl/icon.cpp49
-rw-r--r--plugins/opengl/matrix.cpp (renamed from src/matrix.cpp)62
-rw-r--r--plugins/opengl/opengl.cpp264
-rw-r--r--plugins/opengl/paint.cpp (renamed from src/paint.cpp)406
-rw-r--r--plugins/opengl/privatefragment.h (renamed from src/privatefragment.h)4
-rw-r--r--plugins/opengl/privates.h184
-rw-r--r--plugins/opengl/privatetexture.h40
-rw-r--r--plugins/opengl/screen.cpp1138
-rw-r--r--plugins/opengl/texture.cpp (renamed from src/texture.cpp)139
-rw-r--r--plugins/opengl/vector.cpp (renamed from src/vector.cpp)84
-rw-r--r--plugins/opengl/window.cpp219
-rw-r--r--src/Makefile.am13
-rw-r--r--src/display.cpp91
-rw-r--r--src/event.cpp182
-rw-r--r--src/icon.cpp17
-rw-r--r--src/main.cpp75
-rw-r--r--src/option.cpp2
-rw-r--r--src/privatedisplay.h133
-rw-r--r--src/privatescreen.h125
-rw-r--r--src/privatetexture.h35
-rw-r--r--src/privatewindow.h43
-rw-r--r--src/screen.cpp1638
-rw-r--r--src/window.cpp609
52 files changed, 5479 insertions, 3743 deletions
diff --git a/configure.ac b/configure.ac
index 8588c49..79a9992 100644
--- a/configure.ac
+++ b/configure.ac
@@ -639,6 +639,8 @@ kde/window-decorator/Makefile
kde/window-decorator-kde4/Makefile
po/Makefile.in
metadata/Makefile
+plugins/composite/Makefile
+plugins/opengl/Makefile
])
echo ""
diff --git a/include/compdisplay.h b/include/compdisplay.h
index 2ef5a22..9d0a525 100644
--- a/include/compdisplay.h
+++ b/include/compdisplay.h
@@ -8,8 +8,6 @@
#include <X11/Xregion.h>
#include <X11/extensions/Xinerama.h>
-#include <GL/gl.h>
-
#include <compobject.h>
#include <compmatch.h>
#include <compcore.h>
@@ -211,9 +209,6 @@ class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject
CompScreenList &
screens();
- GLenum
- textureFilter ();
-
CompOption *
getOption (const char *);
@@ -282,8 +277,6 @@ class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject
findTopLevelWindow (Window id);
- void
- clearTargetOutput (unsigned int mask);
bool
readImageFromFile (const char *name,
diff --git a/include/compicon.h b/include/compicon.h
index 23b03e6..34cfce8 100644
--- a/include/compicon.h
+++ b/include/compicon.h
@@ -1,7 +1,6 @@
#ifndef _COMPICON_H
#define _COMPICON_H
-#include <comptexture.h>
class CompScreen;
class CompIcon {
@@ -9,13 +8,11 @@ class CompIcon {
CompIcon (CompScreen *screen, unsigned width, unsigned int height);
~CompIcon ();
- CompTexture & texture ();
unsigned int width ();
unsigned int height ();
unsigned char* data ();
private:
- CompTexture mTexture;
int mWidth;
unsigned int mHeight;
unsigned char *mData;
diff --git a/include/compiz-core.h b/include/compiz-core.h
index ba85f10..0b4f70f 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -34,15 +34,11 @@
#include <X11/Xlib-xcb.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xdamage.h>
-#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xinerama.h>
#include <X11/extensions/sync.h>
#include <X11/Xregion.h>
#include <X11/XKBlib.h>
-#include <GL/gl.h>
-#include <GL/glx.h>
-
// X11 Bool defination breaks BOOST_FOREACH. Convert it to a typedef */
#ifdef Bool
typedef Bool XBool;
@@ -79,16 +75,13 @@ typedef XBool Bool;
#include <compoption.h>
#include <compmetadata.h>
#include <compaction.h>
-#include <compfragment.h>
#include <compicon.h>
#include <compmatch.h>
-#include <compmatrix.h>
#include <compoutput.h>
#include <comppoint.h>
#include <comprect.h>
#include <compsession.h>
#include <compsize.h>
-#include <comptexture.h>
-#include <compvector.h>
+
#endif
diff --git a/include/compmatrix.h b/include/compmatrix.h
deleted file mode 100644
index 3f9962e..0000000
--- a/include/compmatrix.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef _COMPMATRIX_H
-#define _COMPMATRIX_H
-
-#include <compvector.h>
-
-class CompOutput;
-
-class CompMatrix {
- public:
- CompMatrix ();
-
- const float* getMatrix () const;
-
- CompMatrix& operator*= (const CompMatrix& rhs);
-
- void reset ();
- void toScreenSpace (CompOutput *output, float z);
-
- void rotate (const float angle, const float x,
- const float y, const float z);
- void rotate (const float angle, const CompVector& vector);
-
- void scale (const float x, const float y, const float z);
- void scale (const CompVector& vector);
-
- void translate (const float x, const float y, const float z);
- void translate (const CompVector& vector);
-
- private:
- friend CompMatrix operator* (const CompMatrix& lhs,
- const CompMatrix& rhs);
- friend CompVector operator* (const CompMatrix& lhs,
- const CompVector& rhs);
-
- float m[16];
-};
-
-typedef CompMatrix CompTransform;
-
-#endif
diff --git a/include/composite/composite.h b/include/composite/composite.h
new file mode 100644
index 0000000..67e45b7
--- /dev/null
+++ b/include/composite/composite.h
@@ -0,0 +1,181 @@
+#ifndef _COMPIZ_COMPOSITE_H
+#define _COMPIZ_COMPOSITE_H
+
+#include <X11/extensions/Xcomposite.h>
+
+#define COMPIZ_COMPOSITE_ABI 1
+
+#define PLUGIN Composite
+#include <compprivatehandler.h>
+#include <compiz-core.h>
+
+#define COMPOSITE_SCREEN_DAMAGE_PENDING_MASK (1 << 0)
+#define COMPOSITE_SCREEN_DAMAGE_REGION_MASK (1 << 1)
+#define COMPOSITE_SCREEN_DAMAGE_ALL_MASK (1 << 2)
+
+class PrivateCompositeDisplay;
+class PrivateCompositeScreen;
+class PrivateCompositeWindow;
+class CompositeScreen;
+class CompositeWindow;
+
+class CompositeDisplay :
+ public CompositePrivateHandler<CompositeDisplay, CompDisplay,
+ COMPIZ_COMPOSITE_ABI>
+{
+ public:
+ CompositeDisplay (CompDisplay *d);
+ ~CompositeDisplay ();
+
+ CompOption::Vector & getOptions ();
+ bool setOption (const char *name, CompOption::Value &value);
+
+ private:
+ PrivateCompositeDisplay *priv;
+};
+
+class CompositeScreenInterface : public WrapableInterface<CompositeScreen> {
+ public:
+ CompositeScreenInterface ();
+
+ WRAPABLE_DEF(void, preparePaint, int);
+ WRAPABLE_DEF(void, donePaint);
+ WRAPABLE_DEF(void, paint, CompOutput::ptrList &outputs, unsigned int);
+
+ WRAPABLE_DEF(CompWindowList, getWindowPaintList);
+};
+
+
+class CompositeScreen :
+ public WrapableHandler<CompositeScreenInterface>,
+ public CompositePrivateHandler<CompositeScreen, CompScreen,
+ COMPIZ_COMPOSITE_ABI>
+{
+ public:
+
+ class PaintHandler {
+ public:
+ virtual ~PaintHandler () {};
+
+ virtual void paintOutputs (CompOutput::ptrList &outputs,
+ unsigned int mask,
+ Region region) = 0;
+
+ virtual bool hasVSync () { return false; };
+
+ virtual void prepareDrawing () {};
+ };
+
+ public:
+ CompositeScreen (CompScreen *s);
+ ~CompositeScreen ();
+
+ CompOption::Vector & getOptions ();
+ bool setOption (const char *name, CompOption::Value &value);
+ CompOption * getOption (const char *name);
+
+ bool registerPaintHandler (PaintHandler *pHnd);
+ void unregisterPaintHandler ();
+
+ bool compositingActive ();
+
+
+ void damageScreen ();
+ void damageRegion (Region);
+ void damagePending ();
+ unsigned int damageMask ();
+
+ void showOutputWindow ();
+ void hideOutputWindow ();
+ void updateOutputWindow ();
+
+ Window overlay ();
+ Window output ();
+
+ int & overlayWindowCount ();
+
+ void setWindowPaintOffset (int x, int y);
+ CompPoint windowPaintOffset ();
+
+
+ void detectRefreshRate ();
+ int getTimeToNextRedraw (struct timeval *tv);
+
+ bool handlePaintTimeout ();
+
+ WRAPABLE_HND(void, preparePaint, int);
+ WRAPABLE_HND(void, donePaint);
+ WRAPABLE_HND(void, paint, CompOutput::ptrList &outputs, unsigned int);
+
+ WRAPABLE_HND(CompWindowList, getWindowPaintList);
+
+ friend class PrivateCompositeDisplay;
+
+ private:
+ PrivateCompositeScreen *priv;
+
+ public:
+ static bool toggleSlowAnimations (CompDisplay *d,
+ CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+};
+
+class CompositeWindowInterface : public WrapableInterface<CompositeWindow> {
+ public:
+ CompositeWindowInterface ();
+
+ WRAPABLE_DEF(bool, damageRect, bool, BoxPtr);
+};
+
+class CompositeWindow :
+ public WrapableHandler<CompositeWindowInterface>,
+ public CompositePrivateHandler<CompositeWindow, CompWindow,
+ COMPIZ_COMPOSITE_ABI>
+{
+ public:
+
+ CompositeWindow (CompWindow *w);
+ ~CompositeWindow ();
+
+ bool bind ();
+ void release ();
+ Pixmap pixmap ();
+
+ void redirect ();
+ void unredirect ();
+ bool redirected ();
+ bool overlayWindow ();
+
+ void damageTransformedRect (float xScale,
+ float yScale,
+ float xTranslate,
+ float yTranslate,
+ BoxPtr rect);
+
+ void damageOutputExtents ();
+ void addDamageRect (BoxPtr rect);
+ void addDamage ();
+
+ bool damaged ();
+
+ void processDamage (XDamageNotifyEvent *de);
+
+ void updateOpacity ();
+ void updateBrightness ();
+ void updateSaturation ();
+
+ unsigned short opacity ();
+ unsigned short brightness ();
+ unsigned short saturation ();
+
+ WRAPABLE_HND(bool, damageRect, bool, BoxPtr);
+
+ friend class PrivateCompositeWindow;
+ friend class CompositeScreen;
+
+ private:
+ PrivateCompositeWindow *priv;
+};
+
+#endif
diff --git a/include/compscreen.h b/include/compscreen.h
index 2a26765..db495a7 100644
--- a/include/compscreen.h
+++ b/include/compscreen.h
@@ -2,9 +2,6 @@
#define _COMPSCREEN_H
#include <compwindow.h>
-#include <comptexture.h>
-#include <compfragment.h>
-#include <compmatrix.h>
#include <compoutput.h>
#include <compsession.h>
@@ -12,11 +9,11 @@ class CompScreen;
class PrivateScreen;
typedef std::list<CompWindow *> CompWindowList;
-extern GLushort defaultColor[4];
-
-#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR > 2
-#define USE_COW
-#endif
+extern char *backgroundImage;
+extern bool replaceCurrentWm;
+extern bool indirectRendering;
+extern bool strictBinding;
+extern bool noDetection;
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
@@ -36,119 +33,7 @@ extern GLushort defaultColor[4];
#define PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK (1 << 5)
#define PAINT_SCREEN_NO_BACKGROUND_MASK (1 << 6)
-#ifndef GLX_EXT_texture_from_pixmap
-#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
-#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
-#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
-#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
-#define GLX_Y_INVERTED_EXT 0x20D4
-#define GLX_TEXTURE_FORMAT_EXT 0x20D5
-#define GLX_TEXTURE_TARGET_EXT 0x20D6
-#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
-#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
-#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
-#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
-#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
-#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
-#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
-#define GLX_TEXTURE_1D_EXT 0x20DB
-#define GLX_TEXTURE_2D_EXT 0x20DC
-#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
-#define GLX_FRONT_LEFT_EXT 0x20DE
-#endif
-
-typedef void (*FuncPtr) (void);
-typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
-
-typedef void (*GLXBindTexImageProc) (Display *display,
- GLXDrawable drawable,
- int buffer,
- int *attribList);
-typedef void (*GLXReleaseTexImageProc) (Display *display,
- GLXDrawable drawable,
- int buffer);
-typedef void (*GLXQueryDrawableProc) (Display *display,
- GLXDrawable drawable,
- int attribute,
- unsigned int *value);
-
-typedef void (*GLXCopySubBufferProc) (Display *display,
- GLXDrawable drawable,
- int x,
- int y,
- int width,
- int height);
-
-typedef int (*GLXGetVideoSyncProc) (unsigned int *count);
-typedef int (*GLXWaitVideoSyncProc) (int divisor,
- int remainder,
- unsigned int *count);
-
-#ifndef GLX_VERSION_1_3
-typedef struct __GLXFBConfigRec *GLXFBConfig;
-#endif
-typedef GLXFBConfig *(*GLXGetFBConfigsProc) (Display *display,
- int screen,
- int *nElements);
-typedef int (*GLXGetFBConfigAttribProc) (Display *display,
- GLXFBConfig config,
- int attribute,
- int *value);
-typedef GLXPixmap (*GLXCreatePixmapProc) (Display *display,
- GLXFBConfig config,
- Pixmap pixmap,
- const int *attribList);
-
-typedef void (*GLActiveTextureProc) (GLenum texture);
-typedef void (*GLClientActiveTextureProc) (GLenum texture);
-typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
-
-typedef void (*GLGenProgramsProc) (GLsizei n,
- GLuint *programs);
-typedef void (*GLDeleteProgramsProc) (GLsizei n,
- GLuint *programs);
-typedef void (*GLBindProgramProc) (GLenum target,
- GLuint program);
-typedef void (*GLProgramStringProc) (GLenum target,
- GLenum format,
- GLsizei len,
- const GLvoid *string);
-typedef void (*GLProgramParameter4fProc) (GLenum target,
- GLuint index,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w);
-typedef void (*GLGetProgramivProc) (GLenum target,
- GLenum pname,
- int *params);
-
-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);
-typedef void (*GLGenerateMipmapProc) (GLenum target);
-
-struct CompScreenPaintAttrib {
- GLfloat xRotate;
- GLfloat yRotate;
- GLfloat vRotate;
- GLfloat xTranslate;
- GLfloat yTranslate;
- GLfloat zTranslate;
- GLfloat zCamera;
-};
-
-extern CompScreenPaintAttrib defaultScreenPaintAttrib;
struct CompGroup {
unsigned int refCnt;
@@ -161,19 +46,6 @@ struct CompStartupSequence {
unsigned int viewportY;
};
-#define MAX_DEPTH 32
-
-struct CompFBConfig {
- GLXFBConfig fbConfig;
- int yInverted;
- int mipmap;
- int textureFormat;
- int textureTargets;
-};
-
-#define NOTHING_TRANS_FILTER 0
-#define SCREEN_TRANS_FILTER 1
-#define WINDOW_TRANS_FILTER 2
#define SCREEN_EDGE_LEFT 0
#define SCREEN_EDGE_RIGHT 1
@@ -205,30 +77,10 @@ class ScreenInterface : public WrapableInterface<CompScreen> {
public:
ScreenInterface ();
- WRAPABLE_DEF(void, preparePaint, int);
- WRAPABLE_DEF(void, donePaint);
- WRAPABLE_DEF(void, paint, CompOutput::ptrList &outputs, unsigned int);
-
- WRAPABLE_DEF(bool, paintOutput, const CompScreenPaintAttrib *,
- const CompTransform *, Region, CompOutput *,
- unsigned int);
- WRAPABLE_DEF(void, paintTransformedOutput,
- const CompScreenPaintAttrib *,
- const CompTransform *, Region, CompOutput *,
- unsigned int);
- WRAPABLE_DEF(void, applyTransform, const CompScreenPaintAttrib *,
- CompOutput *, CompTransform *);
-
- WRAPABLE_DEF(void, enableOutputClipping, const CompTransform *,
- Region, CompOutput *);
- WRAPABLE_DEF(void, disableOutputClipping);
-
WRAPABLE_DEF(void, enterShowDesktopMode);
WRAPABLE_DEF(void, leaveShowDesktopMode, CompWindow *);
WRAPABLE_DEF(void, outputChangeNotify);
-
- WRAPABLE_DEF(CompWindowList, getWindowPaintList);
};
@@ -255,6 +107,9 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
Window
root ();
+ XWindowAttributes
+ attrib ();
+
int
screenNum ();
@@ -268,9 +123,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
showingDesktopMask ();
bool
- handlePaintTimeout ();
-
- bool
setOption (const char *name,
CompOption::Value &value);
@@ -302,30 +154,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
updateWorkareaForScreen ();
void
- setDefaultViewport ();
-
- void
- damageScreen ();
-
- FuncPtr
- getProcAddress (const char *name);
-
- void
- showOutputWindow ();
-
- void
- hideOutputWindow ();
-
- void
- updateOutputWindow ();
-
- void
- damageRegion (Region);
-
- void
- damagePending ();
-
- void
forEachWindow (CompWindow::ForEach);
void
@@ -399,11 +227,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
void
sendWindowActivationRequest (Window id);
- void
- setTexEnvMode (GLenum mode);
-
- void
- setLighting (bool lighting);
void
enableEdge (int edge);
@@ -414,12 +237,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
Window
getTopWindow ();
- void
- makeCurrent ();
-
- void
- finishDrawing ();
-
int
outputDeviceForPoint (int x, int y);
@@ -435,8 +252,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
void
getWorkareaForOutput (int output, XRectangle *area);
- void
- clearOutput (CompOutput *output, unsigned int mask);
void
viewportForGeometry (CompWindow::Geometry gm,
@@ -455,21 +270,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
void
addToCurrentActiveWindowHistory (Window id);
- void
- setWindowPaintOffset (int x, int y);
-
- int
- getTimeToNextRedraw (struct timeval *tv);
-
- void
- waitForVideoSync ();
-
- int
- maxTextureSize ();
-
- unsigned int
- damageMask ();
-
CompPoint vp ();
CompSize vpSize ();
@@ -479,15 +279,15 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
unsigned int &
pendingDestroys ();
+ void
+ removeDestroyed ();
+
unsigned int &
mapNum ();
int &
desktopWindowCount ();
- int &
- overlayWindowCount ();
-
CompOutput::vector &
outputDevs ();
@@ -506,106 +306,23 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
CompScreenEdge &
screenEdge (int);
- Window
- overlay ();
-
unsigned int &
activeNum ();
- void
- handleExposeEvent (XExposeEvent *event);
-
- void
- detectRefreshRate ();
-
- void
- updateBackground ();
-
- bool
- textureNonPowerOfTwo ();
-
- bool
- textureCompression ();
-
- bool
- canDoSaturated ();
-
- bool
- canDoSlightlySaturated ();
-
- bool
- lighting ();
-
- CompTexture::Filter
- filter (int);
-
- CompFragment::Storage *
- fragmentStorage ();
+ Region region ();
- bool
- fragmentProgram ();
+ bool hasOverlappingOutputs ();
- bool
- framebufferObject ();
-
- CompFBConfig * glxPixmapFBConfig (unsigned int depth);
+ CompOutput & fullscreenOutput ();
static int allocPrivateIndex ();
static void freePrivateIndex (int index);
- WRAPABLE_HND(void, preparePaint, int);
- WRAPABLE_HND(void, donePaint);
- WRAPABLE_HND(void, paint, CompOutput::ptrList &outputs, unsigned int);
-
- WRAPABLE_HND(bool, paintOutput, const CompScreenPaintAttrib *,
- const CompTransform *, Region, CompOutput *,
- unsigned int);
- WRAPABLE_HND(void, paintTransformedOutput,
- const CompScreenPaintAttrib *,
- const CompTransform *, Region, CompOutput *,
- unsigned int);
- WRAPABLE_HND(void, applyTransform, const CompScreenPaintAttrib *,
- CompOutput *, CompTransform *);
-
- WRAPABLE_HND(void, enableOutputClipping, const CompTransform *,
- Region, CompOutput *);
- WRAPABLE_HND(void, disableOutputClipping);
-
WRAPABLE_HND(void, enterShowDesktopMode);
WRAPABLE_HND(void, leaveShowDesktopMode, CompWindow *);
WRAPABLE_HND(void, outputChangeNotify);
- WRAPABLE_HND(CompWindowList, getWindowPaintList);
-
- GLXBindTexImageProc bindTexImage;
- GLXReleaseTexImageProc releaseTexImage;
- GLXQueryDrawableProc queryDrawable;
- GLXCopySubBufferProc copySubBuffer;
- GLXGetVideoSyncProc getVideoSync;
- GLXWaitVideoSyncProc waitVideoSync;
- GLXGetFBConfigsProc getFBConfigs;
- GLXGetFBConfigAttribProc getFBConfigAttrib;
- GLXCreatePixmapProc createPixmap;
-
- GLActiveTextureProc activeTexture;
- GLClientActiveTextureProc clientActiveTexture;
- GLMultiTexCoord2fProc multiTexCoord2f;
-
- GLGenProgramsProc genPrograms;
- GLDeleteProgramsProc deletePrograms;
- GLBindProgramProc bindProgram;
- GLProgramStringProc programString;
- GLProgramParameter4fProc programEnvParameter4f;
- GLProgramParameter4fProc programLocalParameter4f;
- GLGetProgramivProc getProgramiv;
-
- GLGenFramebuffersProc genFramebuffers;
- GLDeleteFramebuffersProc deleteFramebuffers;
- GLBindFramebufferProc bindFramebuffer;
- GLCheckFramebufferStatusProc checkFramebufferStatus;
- GLFramebufferTexture2DProc framebufferTexture2D;
- GLGenerateMipmapProc generateMipmap;
private:
PrivateScreen *priv;
@@ -630,12 +347,6 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject {
CompOption::Vector &options);
static bool
- toggleSlowAnimations (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
windowMenu (CompDisplay *d,
CompAction *action,
CompAction::State state,
diff --git a/include/compvector.h b/include/compvector.h
deleted file mode 100644
index 17e9403..0000000
--- a/include/compvector.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef _COMPVECTOR_H
-#define _COMPVECTOR_H
-
-class CompVector {
- public:
- typedef enum {
- x,
- y,
- z,
- w
- } VectorCoordsEnum;
-
- CompVector ();
- CompVector (float x, float y, float z, float w);
-
- float& operator[] (int item);
- float& operator[] (VectorCoordsEnum coord);
-
- const float operator[] (int item) const;
- const float operator[] (VectorCoordsEnum coord) const;
-
- CompVector& operator+= (const CompVector& rhs);
- CompVector& operator-= (const CompVector& rhs);
- CompVector& operator*= (const float k);
- CompVector& operator/= (const float k);
- CompVector& operator^= (const CompVector& rhs);
-
- float norm ();
- CompVector& normalize ();
-
- private:
- friend CompVector operator+ (const CompVector& lhs,
- const CompVector& rhs);
- friend CompVector operator- (const CompVector& lhs,
- const CompVector& rhs);
- friend CompVector operator- (const CompVector& vector);
- friend float operator* (const CompVector& lhs,
- const CompVector& rhs);
- friend CompVector operator* (const float k,
- const CompVector& vector);
- friend CompVector operator* (const CompVector& vector,
- const float k);
- friend CompVector operator/ (const CompVector& lhs,
- const CompVector& rhs);
- friend CompVector operator^ (const CompVector& lhs,
- const CompVector& rhs);
-
- float v[4];
-};
-
-#endif
diff --git a/include/compwindow.h b/include/compwindow.h
index 56a6132..a76597d 100644
--- a/include/compwindow.h
+++ b/include/compwindow.h
@@ -3,20 +3,16 @@
#include <boost/function.hpp>
+#include <X11/Xlib-xcb.h>
+#include <X11/Xutil.h>
#include <X11/Xregion.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/sync.h>
-#include <GL/gl.h>
-#include <GL/glx.h>
-
#include <compaction.h>
#include <compobject.h>
#include <compsize.h>
#include <comppoint.h>
-#include <comptexture.h>
-#include <compfragment.h>
-#include <compmatrix.h>
#include <wrapable.h>
@@ -173,15 +169,7 @@ struct CompStartupSequence;
#define CompWindowGrabMoveMask (1 << 2)
#define CompWindowGrabResizeMask (1 << 3)
-struct CompWindowPaintAttrib {
- GLushort opacity;
- GLushort brightness;
- GLushort saturation;
- GLfloat xScale;
- GLfloat yScale;
- GLfloat xTranslate;
- GLfloat yTranslate;
-};
+
enum CompStackingUpdateMode {
CompStackingUpdateModeNone = 0,
@@ -191,6 +179,16 @@ enum CompStackingUpdateMode {
CompStackingUpdateModeInitialMapDeniedFocus
};
+enum CompWindowNotify {
+ CompWindowNotifyMap,
+ CompWindowNotifyUnmap,
+ CompWindowNotifyRestack,
+ CompWindowNotifyHide,
+ CompWindowNotifyShow,
+ CompWindowNotifyAliveChanged,
+ CompWindowNotifySyncAlarm
+};
+
struct CompWindowExtents {
int left;
int right;
@@ -209,17 +207,6 @@ class WindowInterface : public WrapableInterface<CompWindow> {
public:
WindowInterface ();
- WRAPABLE_DEF(bool, paint, const CompWindowPaintAttrib *,
- const CompTransform *, Region, unsigned int);
- WRAPABLE_DEF(bool, draw, const CompTransform *,
- CompFragment::Attrib &, Region, unsigned int);
- WRAPABLE_DEF(void, addGeometry, CompTexture::Matrix *matrix,
- int, Region, Region);
- WRAPABLE_DEF(void, drawTexture, CompTexture *texture,
- CompFragment::Attrib &, unsigned int);
- WRAPABLE_DEF(void, drawGeometry);
- WRAPABLE_DEF(bool, damageRect, bool, BoxPtr);
-
WRAPABLE_DEF(void, getOutputExtents, CompWindowExtents *);
WRAPABLE_DEF(void, getAllowedActions, unsigned int *,
unsigned int *);
@@ -232,6 +219,7 @@ class WindowInterface : public WrapableInterface<CompWindow> {
WRAPABLE_DEF(void, resizeNotify, int, int, int, int);
WRAPABLE_DEF(void, moveNotify, int, int, bool);
+ WRAPABLE_DEF(void, windowNotify, CompWindowNotify);
WRAPABLE_DEF(void, grabNotify, int, int,
unsigned int, unsigned int);
WRAPABLE_DEF(void, ungrabNotify);
@@ -259,7 +247,7 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
unsigned int mBorder;
};
- static CompWindowPaintAttrib defaultPaintAttrib;
+
typedef boost::function<void (CompWindow *)> ForEach;
@@ -312,8 +300,7 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
void
handlePing (int lastPing);
- bool
- overlayWindow ();
+
Region
region ();
@@ -399,28 +386,6 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
void
updateWindowOutputExtents ();
- bool
- bind ();
-
- void
- release ();
-
- void
- damageTransformedRect (float xScale,
- float yScale,
- float xTranslate,
- float yTranslate,
- BoxPtr rect);
-
- void
- damageOutputExtents ();
-
- void
- addDamageRect (BoxPtr rect);
-
- void
- addDamage ();
-
void
updateRegion ();
@@ -532,12 +497,6 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
Time timestamp);
void
- unredirect ();
-
- void
- redirect ();
-
- void
defaultViewport (int *vx, int *vy);
CompIcon *
@@ -591,17 +550,13 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
CompWindowExtents
input ();
+ CompWindowExtents
+ output ();
+
XSizeHints
sizeHints ();
- void
- updateOpacity ();
-
- void
- updateBrightness ();
- void
- updateSaturation ();
void
updateMwmHints ();
@@ -612,8 +567,7 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
void
processMap ();
- void
- processDamage (XDamageNotifyEvent *de);
+
XSyncAlarm
syncAlarm ();
@@ -621,26 +575,18 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
bool
destroyed ();
- bool
- damaged ();
bool
invisible ();
bool
- redirected ();
+ syncWait ();
- Region
- clip ();
+ bool alpha ();
- CompWindowPaintAttrib &
- paintAttrib ();
+ bool alive ();
- bool
- moreVertices (int newSize);
- bool
- moreIndices (int newSize);
static unsigned int
constrainWindowState (unsigned int state,
@@ -656,19 +602,6 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
static int allocPrivateIndex ();
static void freePrivateIndex (int index);
- WRAPABLE_HND(bool, paint, const CompWindowPaintAttrib *,
- const CompTransform *, Region, unsigned int);
- WRAPABLE_HND(bool, draw, const CompTransform *,
- CompFragment::Attrib &, Region, unsigned int);
- WRAPABLE_HND(void, addGeometry, CompTexture::Matrix *matrix,
- int, Region, Region);
- WRAPABLE_HND(void, drawTexture, CompTexture *texture,
- CompFragment::Attrib &, unsigned int);
- WRAPABLE_HND(void, drawGeometry);
-
-
- WRAPABLE_HND(bool, damageRect, bool, BoxPtr);
-
WRAPABLE_HND(void, getOutputExtents, CompWindowExtents *);
WRAPABLE_HND(void, getAllowedActions, unsigned int *,
unsigned int *);
@@ -681,6 +614,7 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject {
WRAPABLE_HND(void, resizeNotify, int, int, int, int);
WRAPABLE_HND(void, moveNotify, int, int, bool);
+ WRAPABLE_HND(void, windowNotify, CompWindowNotify);
WRAPABLE_HND(void, grabNotify, int, int,
unsigned int, unsigned int);
WRAPABLE_HND(void, ungrabNotify);
diff --git a/include/compfragment.h b/include/opengl/fragment.h
index fdeda74..04dda6f 100644
--- a/include/compfragment.h
+++ b/include/opengl/fragment.h
@@ -1,5 +1,5 @@
-#ifndef _COMPFRAGMENT_H
-#define _COMPFRAGMENT_H
+#ifndef _GLFRAGMENT_H
+#define _GLFRAGMENT_H
#define MAX_FRAGMENT_FUNCTIONS 16
@@ -7,9 +7,10 @@
#define COMP_FETCH_TARGET_RECT 1
#define COMP_FETCH_TARGET_NUM 2
-struct CompWindowPaintAttrib;
+struct GLWindowPaintAttrib;
+class GLScreen;
-namespace CompFragment {
+namespace GLFragment {
class Storage;
@@ -40,7 +41,7 @@ namespace CompFragment {
void addBlendOp (const char *str, ...);
- FunctionId createFragmentFunction (CompScreen *s,const char *name);
+ FunctionId createFragmentFunction (GLScreen *s,const char *name);
private:
PrivateFunctionData *priv;
@@ -48,7 +49,7 @@ namespace CompFragment {
class Attrib {
public:
- Attrib (const CompWindowPaintAttrib *paint);
+ Attrib (const GLWindowPaintAttrib &paint);
Attrib (const Attrib&);
~Attrib ();
@@ -58,8 +59,8 @@ namespace CompFragment {
void addFunction (FunctionId function);
- bool enable (CompScreen *s, bool *blending);
- void disable (CompScreen *s);
+ bool enable (GLScreen *s, bool *blending);
+ void disable (GLScreen *s);
unsigned short getSaturation ();
unsigned short getBrightness ();
@@ -75,11 +76,11 @@ namespace CompFragment {
PrivateAttrib *priv;
};
- void destroyFragmentFunction (CompScreen *s, FunctionId id);
+ void destroyFragmentFunction (GLScreen *s, FunctionId id);
- FunctionId getSaturateFragmentFunction (CompScreen *s,
- CompTexture *texture,
- int param);
+ FunctionId getSaturateFragmentFunction (GLScreen *s,
+ GLTexture *texture,
+ int param);
};
diff --git a/include/opengl/matrix.h b/include/opengl/matrix.h
new file mode 100644
index 0000000..8d3b801
--- /dev/null
+++ b/include/opengl/matrix.h
@@ -0,0 +1,38 @@
+#ifndef _GLMATRIX_H
+#define _GLMATRIX_H
+
+#include <opengl/vector.h>
+
+class CompOutput;
+
+class GLMatrix {
+ public:
+ GLMatrix ();
+
+ const float* getMatrix () const;
+
+ GLMatrix& operator*= (const GLMatrix& rhs);
+
+ void reset ();
+ void toScreenSpace (CompOutput *output, float z);
+
+ void rotate (const float angle, const float x,
+ const float y, const float z);
+ void rotate (const float angle, const GLVector& vector);
+
+ void scale (const float x, const float y, const float z);
+ void scale (const GLVector& vector);
+
+ void translate (const float x, const float y, const float z);
+ void translate (const GLVector& vector);
+
+ private:
+ friend GLMatrix operator* (const GLMatrix& lhs,
+ const GLMatrix& rhs);
+ friend GLVector operator* (const GLMatrix& lhs,
+ const GLVector& rhs);
+
+ float m[16];
+};
+
+#endif
diff --git a/include/opengl/opengl.h b/include/opengl/opengl.h
new file mode 100644
index 0000000..dcd8272
--- /dev/null
+++ b/include/opengl/opengl.h
@@ -0,0 +1,345 @@
+#ifndef _COMPIZ_OPENGL_H
+#define _COMPIZ_OPENGL_H
+
+#include <GL/gl.h>
+#include <GL/glx.h>
+
+#include <opengl/matrix.h>
+#include <opengl/texture.h>
+#include <opengl/fragment.h>
+
+#define COMPIZ_OPENGL_ABI 1
+
+#define PLUGIN OpenGL
+#include <compprivatehandler.h>
+
+class PrivateGLDisplay;
+class PrivateGLScreen;
+class PrivateGLWindow;
+
+class GLDisplay :
+ public OpenGLPrivateHandler<GLDisplay, CompDisplay, COMPIZ_OPENGL_ABI>
+{
+ public:
+ GLDisplay (CompDisplay *d);
+ ~GLDisplay ();
+
+ CompOption::Vector & getOptions ();
+ bool setOption (const char *name, CompOption::Value &value);
+
+ GLenum textureFilter ();
+
+ void clearTargetOutput (unsigned int mask);
+
+ private:
+ PrivateGLDisplay *priv;
+};
+
+
+extern GLushort defaultColor[4];
+
+#ifndef GLX_EXT_texture_from_pixmap
+#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
+#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
+#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
+#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
+#define GLX_Y_INVERTED_EXT 0x20D4
+#define GLX_TEXTURE_FORMAT_EXT 0x20D5
+#define GLX_TEXTURE_TARGET_EXT 0x20D6
+#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
+#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
+#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
+#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
+#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
+#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
+#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
+#define GLX_TEXTURE_1D_EXT 0x20DB
+#define GLX_TEXTURE_2D_EXT 0x20DC
+#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
+#define GLX_FRONT_LEFT_EXT 0x20DE
+#endif
+
+typedef void (*FuncPtr) (void);
+typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
+
+typedef void (*GLXBindTexImageProc) (Display *display,
+ GLXDrawable drawable,
+ int buffer,
+ int *attribList);
+typedef void (*GLXReleaseTexImageProc) (Display *display,
+ GLXDrawable drawable,
+ int buffer);
+typedef void (*GLXQueryDrawableProc) (Display *display,
+ GLXDrawable drawable,
+ int attribute,
+ unsigned int *value);
+
+typedef void (*GLXCopySubBufferProc) (Display *display,
+ GLXDrawable drawable,
+ int x,
+ int y,
+ int width,
+ int height);
+
+typedef int (*GLXGetVideoSyncProc) (unsigned int *count);
+typedef int (*GLXWaitVideoSyncProc) (int divisor,
+ int remainder,
+ unsigned int *count);
+
+#ifndef GLX_VERSION_1_3
+typedef struct __GLXFBConfigRec *GLXFBConfig;
+#endif
+
+typedef GLXFBConfig *(*GLXGetFBConfigsProc) (Display *display,
+ int screen,
+ int *nElements);
+typedef int (*GLXGetFBConfigAttribProc) (Display *display,
+ GLXFBConfig config,
+ int attribute,
+ int *value);
+typedef GLXPixmap (*GLXCreatePixmapProc) (Display *display,
+ GLXFBConfig config,
+ Pixmap pixmap,
+ const int *attribList);
+
+typedef void (*GLActiveTextureProc) (GLenum texture);
+typedef void (*GLClientActiveTextureProc) (GLenum texture);
+typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
+
+typedef void (*GLGenProgramsProc) (GLsizei n,
+ GLuint *programs);
+typedef void (*GLDeleteProgramsProc) (GLsizei n,
+ GLuint *programs);
+typedef void (*GLBindProgramProc) (GLenum target,
+ GLuint program);
+typedef void (*GLProgramStringProc) (GLenum target,
+ GLenum format,
+ GLsizei len,
+ const GLvoid *string);
+typedef void (*GLProgramParameter4fProc) (GLenum target,
+ GLuint index,
+ GLfloat x,
+ GLfloat y,
+ GLfloat z,
+ GLfloat w);
+typedef void (*GLGetProgramivProc) (GLenum target,
+ GLenum pname,
+ int *params);
+
+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);
+typedef void (*GLGenerateMipmapProc) (GLenum target);
+
+struct GLScreenPaintAttrib {
+ GLfloat xRotate;
+ GLfloat yRotate;
+ GLfloat vRotate;
+ GLfloat xTranslate;
+ GLfloat yTranslate;
+ GLfloat zTranslate;
+ GLfloat zCamera;
+};
+
+#define MAX_DEPTH 32
+
+struct GLFBConfig {
+ GLXFBConfig fbConfig;
+ int yInverted;
+ int mipmap;
+ int textureFormat;
+ int textureTargets;
+};
+
+#define NOTHING_TRANS_FILTER 0
+#define SCREEN_TRANS_FILTER 1
+#define WINDOW_TRANS_FILTER 2
+
+
+extern GLScreenPaintAttrib defaultScreenPaintAttrib;
+
+class GLScreen;
+
+class GLScreenInterface : public WrapableInterface<GLScreen> {
+ public:
+ GLScreenInterface ();
+
+ WRAPABLE_DEF(bool, glPaintOutput, const GLScreenPaintAttrib &,
+ const GLMatrix &, Region, CompOutput *,
+ unsigned int);
+ WRAPABLE_DEF(void, glPaintTransformedOutput,
+ const GLScreenPaintAttrib &,
+ const GLMatrix &, Region, CompOutput *,
+ unsigned int);
+ WRAPABLE_DEF(void, glApplyTransform, const GLScreenPaintAttrib &,
+ CompOutput *, GLMatrix *);
+
+ WRAPABLE_DEF(void, glEnableOutputClipping, const GLMatrix &,
+ Region, CompOutput *);
+ WRAPABLE_DEF(void, glDisableOutputClipping);
+
+};
+
+
+class GLScreen :
+ public WrapableHandler<GLScreenInterface>,
+ public OpenGLPrivateHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>
+{
+ public:
+ GLScreen (CompScreen *s);
+ ~GLScreen ();
+
+ CompOption::Vector & getOptions ();
+ bool setOption (const char *name, CompOption::Value &value);
+ CompOption * getOption (const char *name);
+
+ FuncPtr getProcAddress (const char *name);
+
+ void updateBackground ();
+
+ int maxTextureSize ();
+ bool textureNonPowerOfTwo ();
+ bool textureCompression ();
+ bool canDoSaturated ();
+ bool canDoSlightlySaturated ();
+ bool fragmentProgram ();
+ bool framebufferObject ();
+
+ GLTexture::Filter filter (int);
+
+ GLFragment::Storage * fragmentStorage ();
+
+ void setTexEnvMode (GLenum mode);
+ void setLighting (bool lighting);
+ bool lighting ();
+
+ void makeCurrent ();
+
+ void clearOutput (CompOutput *output, unsigned int mask);
+
+ void setDefaultViewport ();
+
+ GLFBConfig * glxPixmapFBConfig (unsigned int depth);
+
+ WRAPABLE_HND(bool, glPaintOutput, const GLScreenPaintAttrib &,
+ const GLMatrix &, Region, CompOutput *,
+ unsigned int);
+ WRAPABLE_HND(void, glPaintTransformedOutput,
+ const GLScreenPaintAttrib &,
+ const GLMatrix &, Region, CompOutput *,
+ unsigned int);
+ WRAPABLE_HND(void, glApplyTransform, const GLScreenPaintAttrib &,
+ CompOutput *, GLMatrix *);
+
+ WRAPABLE_HND(void, glEnableOutputClipping, const GLMatrix &,
+ Region, CompOutput *);
+ WRAPABLE_HND(void, glDisableOutputClipping);
+
+ GLXBindTexImageProc bindTexImage;
+ GLXReleaseTexImageProc releaseTexImage;
+ GLXQueryDrawableProc queryDrawable;
+ GLXCopySubBufferProc copySubBuffer;
+ GLXGetVideoSyncProc getVideoSync;
+ GLXWaitVideoSyncProc waitVideoSync;
+ GLXGetFBConfigsProc getFBConfigs;
+ GLXGetFBConfigAttribProc getFBConfigAttrib;
+ GLXCreatePixmapProc createPixmap;
+
+ GLActiveTextureProc activeTexture;
+ GLClientActiveTextureProc clientActiveTexture;
+ GLMultiTexCoord2fProc multiTexCoord2f;
+
+ GLGenProgramsProc genPrograms;
+ GLDeleteProgramsProc deletePrograms;
+ GLBindProgramProc bindProgram;
+ GLProgramStringProc programString;
+ GLProgramParameter4fProc programEnvParameter4f;
+ GLProgramParameter4fProc programLocalParameter4f;
+ GLGetProgramivProc getProgramiv;
+
+ GLGenFramebuffersProc genFramebuffers;
+ GLDeleteFramebuffersProc deleteFramebuffers;
+ GLBindFramebufferProc bindFramebuffer;
+ GLCheckFramebufferStatusProc checkFramebufferStatus;
+ GLFramebufferTexture2DProc framebufferTexture2D;
+ GLGenerateMipmapProc generateMipmap;
+
+ private:
+ PrivateGLScreen *priv;
+};
+
+struct GLWindowPaintAttrib {
+ GLushort opacity;
+ GLushort brightness;
+ GLushort saturation;
+ GLfloat xScale;
+ GLfloat yScale;
+ GLfloat xTranslate;
+ GLfloat yTranslate;
+};
+
+class GLWindow;
+
+class GLWindowInterface : public WrapableInterface<GLWindow> {
+ public:
+ GLWindowInterface ();
+
+ WRAPABLE_DEF(bool, glPaint, const GLWindowPaintAttrib &,
+ const GLMatrix &, Region, unsigned int);
+ WRAPABLE_DEF(bool, glDraw, const GLMatrix &,
+ GLFragment::Attrib &, Region, unsigned int);
+ WRAPABLE_DEF(void, glAddGeometry, GLTexture::Matrix *matrix,
+ int, Region, Region);
+ WRAPABLE_DEF(void, glDrawTexture, GLTexture *texture,
+ GLFragment::Attrib &, unsigned int);
+ WRAPABLE_DEF(void, glDrawGeometry);
+};
+
+class GLWindow :
+ public WrapableHandler<GLWindowInterface>,
+ public OpenGLPrivateHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
+{
+ public:
+ static GLWindowPaintAttrib defaultPaintAttrib;
+ public:
+
+ GLWindow (CompWindow *w);
+ ~GLWindow ();
+
+ Region clip ();
+
+ GLWindowPaintAttrib & paintAttrib ();
+
+ bool moreVertices (int newSize);
+
+ bool moreIndices (int newSize);
+
+ bool bind ();
+ void release ();
+
+ void updatePaintAttribs ();
+
+ WRAPABLE_HND(bool, glPaint, const GLWindowPaintAttrib &,
+ const GLMatrix &, Region, unsigned int);
+ WRAPABLE_HND(bool, glDraw, const GLMatrix &,
+ GLFragment::Attrib &, Region, unsigned int);
+ WRAPABLE_HND(void, glAddGeometry, GLTexture::Matrix *matrix,
+ int, Region, Region);
+ WRAPABLE_HND(void, glDrawTexture, GLTexture *texture,
+ GLFragment::Attrib &, unsigned int);
+ WRAPABLE_HND(void, glDrawGeometry);
+
+ private:
+ PrivateGLWindow *priv;
+};
+
+#endif
diff --git a/include/comptexture.h b/include/opengl/texture.h
index 7bc3ba5..ae8746c 100644
--- a/include/comptexture.h
+++ b/include/opengl/texture.h
@@ -1,5 +1,5 @@
-#ifndef _COMPTEXTURE_H
-#define _COMPTEXTURE_H
+#ifndef _GLTEXTURE_H
+#define _GLTEXTURE_H
#include <X11/Xlib-xcb.h>
@@ -21,7 +21,7 @@
class CompScreen;
class PrivateTexture;
-class CompTexture {
+class GLTexture {
public:
typedef enum {
@@ -36,46 +36,43 @@ class CompTexture {
} Matrix;
public:
- CompTexture (CompScreen *);
- ~CompTexture ();
+ GLTexture (CompScreen *);
+ ~GLTexture ();
+ void reset ();
+
GLuint name ();
GLenum target ();
- void damage ();
-
Matrix & matrix ();
-
- void reset ();
- bool bindPixmap (Pixmap pixmap, int width, int height, int depth);
+ void damage ();
+ bool bindPixmap (Pixmap pixmap, int width, int height, int depth);
void releasePixmap ();
-
+ bool hasPixmap ();
+
void enable (Filter filter);
-
void disable ();
- bool hasPixmap ();
- static bool imageBufferToTexture (CompTexture *texture,
+ static bool imageBufferToTexture (GLTexture *texture,
const char *image,
unsigned int width,
unsigned int height);
- static bool imageDataToTexture (CompTexture *texture,
+ static bool imageDataToTexture (GLTexture *texture,
const char *image,
unsigned int width,
unsigned int height,
GLenum format,
GLenum type);
- static bool
- readImageToTexture (CompScreen *screen,
- CompTexture *texture,
- const char *imageFileName,
- unsigned int *returnWidth,
- unsigned int *returnHeight);
+ static bool readImageToTexture (CompScreen *screen,
+ GLTexture *texture,
+ const char *imageFileName,
+ unsigned int *returnWidth,
+ unsigned int *returnHeight);
private:
diff --git a/include/opengl/vector.h b/include/opengl/vector.h
new file mode 100644
index 0000000..3a92c8e
--- /dev/null
+++ b/include/opengl/vector.h
@@ -0,0 +1,51 @@
+#ifndef _GLVECTOR_H
+#define _GLVECTOR_H
+
+class GLVector {
+ public:
+ typedef enum {
+ x,
+ y,
+ z,
+ w
+ } VectorCoordsEnum;
+
+ GLVector ();
+ GLVector (float x, float y, float z, float w);
+
+ float& operator[] (int item);
+ float& operator[] (VectorCoordsEnum coord);
+
+ const float operator[] (int item) const;
+ const float operator[] (VectorCoordsEnum coord) const;
+
+ GLVector& operator+= (const GLVector& rhs);
+ GLVector& operator-= (const GLVector& rhs);
+ GLVector& operator*= (const float k);
+ GLVector& operator/= (const float k);
+ GLVector& operator^= (const GLVector& rhs);
+
+ float norm ();
+ GLVector& normalize ();
+
+ private:
+ friend GLVector operator+ (const GLVector& lhs,
+ const GLVector& rhs);
+ friend GLVector operator- (const GLVector& lhs,
+ const GLVector& rhs);
+ friend GLVector operator- (const GLVector& vector);
+ friend float operator* (const GLVector& lhs,
+ const GLVector& rhs);
+ friend GLVector operator* (const float k,
+ const GLVector& vector);
+ friend GLVector operator* (const GLVector& vector,
+ const float k);
+ friend GLVector operator/ (const GLVector& lhs,
+ const GLVector& rhs);
+ friend GLVector operator^ (const GLVector& lhs,
+ const GLVector& rhs);
+
+ float v[4];
+};
+
+#endif
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index a73ac20..60066de 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -28,7 +28,9 @@ xml_in_files = \
video.xml.in \
water.xml.in \
wobbly.xml.in \
- zoom.xml.in
+ zoom.xml.in \
+ composite.xml.in \
+ opengl.xml.in
xml_files = $(xml_in_files:.xml.in=.xml)
xml_DATA = $(xml_files)
diff --git a/metadata/composite.xml.in b/metadata/composite.xml.in
new file mode 100644
index 0000000..4ab5d0b
--- /dev/null
+++ b/metadata/composite.xml.in
@@ -0,0 +1,36 @@
+<compiz>
+ <plugin name="composite">
+ <_short>Composite</_short>
+ <_long>Composite plugin</_long>
+ <display>
+ <option name="slow_animations_key" type="key">
+ <_short>Slow Animations</_short>
+ <_long>Toggle use of slow animations</_long>
+ </option>
+ </display>
+ <screen>
+ <option name="detect_refresh_rate" type="bool">
+ <_short>Detect Refresh Rate</_short>
+ <_long>Automatic detection of refresh rate</_long>
+ <default>true</default>
+ </option>
+ <option name="refresh_rate" type="int">
+ <_short>Refresh Rate</_short>
+ <_long>The rate at which the screen is redrawn (times/second)</_long>
+ <default>50</default>
+ <min>1</min>
+ <max>200</max>
+ </option>
+ <option name="unredirect_fullscreen_windows" type="bool">
+ <_short>Unredirect Fullscreen Windows</_short>
+ <_long>Allow drawing of fullscreen windows to not be redirected to offscreen pixmaps</_long>
+ <default>false</default>
+ </option>
+ <option name="force_independent_output_painting" type="bool">
+ <_short>Force independent output painting.</_short>
+ <_long>Paint each output device independly, even if the output devices overlap</_long>
+ <default>false</default>
+ </option>
+ </screen>
+ </plugin>
+</compiz>
diff --git a/metadata/core.xml.in b/metadata/core.xml.in
index 5b72bfb..61c0947 100644
--- a/metadata/core.xml.in
+++ b/metadata/core.xml.in
@@ -11,25 +11,6 @@
<value>core</value>
</default>
</option>
- <option name="texture_filter" type="int">
- <_short>Texture Filter</_short>
- <_long>Texture filtering</_long>
- <default>1</default>
- <min>0</min>
- <max>2</max>
- <desc>
- <value>0</value>
- <_name>Fast</_name>
- </desc>
- <desc>
- <value>1</value>
- <_name>Good</_name>
- </desc>
- <desc>
- <value>2</value>
- <_name>Best</_name>
- </desc>
- </option>
<option name="click_to_focus" type="bool">
<_short>Click To Focus</_short>
<_long>Click on window moves input focus to it</_long>
@@ -181,10 +162,6 @@
<_short>Run command 11</_short>
<_long>A keybinding that when invoked, will run the shell command identified by command11</_long>
</option>
- <option name="slow_animations_key" type="key">
- <_short>Slow Animations</_short>
- <_long>Toggle use of slow animations</_long>
- </option>
<option name="raise_window_key" type="key">
<_short>Raise Window</_short>
<_long>Raise window above other windows</_long>
@@ -329,23 +306,6 @@
</option>
</display>
<screen>
- <option name="detect_refresh_rate" type="bool">
- <_short>Detect Refresh Rate</_short>
- <_long>Automatic detection of refresh rate</_long>
- <default>true</default>
- </option>
- <option name="lighting" type="bool">
- <_short>Lighting</_short>
- <_long>Use diffuse light when screen is transformed</_long>
- <default>true</default>
- </option>
- <option name="refresh_rate" type="int">
- <_short>Refresh Rate</_short>
- <_long>The rate at which the screen is redrawn (times/second)</_long>
- <default>50</default>
- <min>1</min>
- <max>200</max>
- </option>
<option name="hsize" type="int">
<_short>Horizontal Virtual Size</_short>
<_long>Screen size multiplier for horizontal virtual size</_long>
@@ -360,21 +320,11 @@
<min>1</min>
<max>32</max>
</option>
- <option name="unredirect_fullscreen_windows" type="bool">
- <_short>Unredirect Fullscreen Windows</_short>
- <_long>Allow drawing of fullscreen windows to not be redirected to offscreen pixmaps</_long>
- <default>false</default>
- </option>
<option name="default_icon" type="string">
<_short>Default Icon</_short>
<_long>Default window icon image</_long>
<default>icon</default>
</option>
- <option name="sync_to_vblank" type="bool">
- <_short>Sync To VBlank</_short>
- <_long>Only perform screen updates during vertical blanking period</_long>
- <default>true</default>
- </option>
<option name="number_of_desktops" type="int">
<_short>Number of Desktops</_short>
<_long>Number of virtual desktops</_long>
@@ -414,11 +364,6 @@
<_name>Prefer smaller output</_name>
</desc>
</option>
- <option name="force_independent_output_painting" type="bool">
- <_short>Force independent output painting.</_short>
- <_long>Paint each output device independly, even if the output devices overlap</_long>
- <default>false</default>
- </option>
<option name="focus_prevention_level" type="int">
<_short>Focus Prevention Level</_short>
<_long>Level of focus stealing prevention</_long>
@@ -447,11 +392,6 @@
<_long>Focus prevention windows</_long>
<default>any</default>
</option>
- <option name="texture_compression" type="bool">
- <_short>Texture Compression</_short>
- <_long>If available use compression for textures converted from images</_long>
- <default>true</default>
- </option>
</screen>
</core>
</compiz>
diff --git a/metadata/opengl.xml.in b/metadata/opengl.xml.in
new file mode 100644
index 0000000..7ce29c9
--- /dev/null
+++ b/metadata/opengl.xml.in
@@ -0,0 +1,44 @@
+<compiz>
+ <plugin name="opengl">
+ <_short>OpenGL</_short>
+ <_long>OpenGL Plugin</_long>
+ <display>
+ <option name="texture_filter" type="int">
+ <_short>Texture Filter</_short>
+ <_long>Texture filtering</_long>
+ <default>1</default>
+ <min>0</min>
+ <max>2</max>
+ <desc>
+ <value>0</value>
+ <_name>Fast</_name>
+ </desc>
+ <desc>
+ <value>1</value>
+ <_name>Good</_name>
+ </desc>
+ <desc>
+ <value>2</value>
+ <_name>Best</_name>
+ </desc>
+ </option>
+ </display>
+ <screen>
+ <option name="lighting" type="bool">
+ <_short>Lighting</_short>
+ <_long>Use diffuse light when screen is transformed</_long>
+ <default>true</default>
+ </option>
+ <option name="sync_to_vblank" type="bool">
+ <_short>Sync To VBlank</_short>
+ <_long>Only perform screen updates during vertical blanking period</_long>
+ <default>true</default>
+ </option>
+ <option name="texture_compression" type="bool">
+ <_short>Texture Compression</_short>
+ <_long>If available use compression for textures converted from images</_long>
+ <default>true</default>
+ </option>
+ </screen>
+ </plugin>
+</compiz>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 94055f7..f0cfc24 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = composite opengl
+
# libfade_la_LDFLAGS = -module -avoid-version -no-undefined
# libfade_la_SOURCES = fade.cpp
#
@@ -20,6 +22,9 @@ libzoom_la_SOURCES = zoom.cpp
# libminimize_la_SOURCES = minimize.cpp
libmove_la_LDFLAGS = -module -avoid-version -no-undefined
+libmove_la_LIBADD = \
+ $(top_builddir)/plugins/composite/libcomposite.la \
+ $(top_builddir)/plugins/opengl/libopengl.la
libmove_la_SOURCES = move.cpp
libresize_la_LDFLAGS = -module -avoid-version -no-undefined
diff --git a/plugins/composite/Makefile.am b/plugins/composite/Makefile.am
new file mode 100644
index 0000000..eb49acc
--- /dev/null
+++ b/plugins/composite/Makefile.am
@@ -0,0 +1,26 @@
+libcomposite_la_LDFLAGS = -avoid-version -no-undefined
+libcomposite_la_SOURCES = composite.cpp display.cpp screen.cpp window.cpp
+
+INCLUDES = \
+ @COMPIZ_CFLAGS@ \
+ @LIBPNG_CFLAGS@ \
+ @LIBRSVG_CFLAGS@ \
+ @ANNOTATE_CFLAGS@ \
+ @GCONF_CFLAGS@ \
+ @KCONFIG_CFLAGS@ \
+ @DBUS_CFLAGS@ \
+ @GLIB_CFLAGS@ \
+ @FUSE_CFLAGS@ \
+ -DFUSE_USE_VERSION=26 \
+ -DALL_LINGUAS="\"@ALL_LINGUAS@\"" \
+ -DLOCALEDIR="\"@datadir@/locale\"" \
+ -DPLUGINDIR=\"$(plugindir)\" \
+ -DIMAGEDIR=\"$(imagedir)\" \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -DMETADATADIR=\"$(metadatadir)\"
+
+moduledir = $(plugindir)
+
+module_LTLIBRARIES = \
+ libcomposite.la
diff --git a/plugins/composite/composite.cpp b/plugins/composite/composite.cpp
new file mode 100644
index 0000000..e44d8bb
--- /dev/null
+++ b/plugins/composite/composite.cpp
@@ -0,0 +1,282 @@
+#include <compiz-core.h>
+#include <composite/composite.h>
+
+#include "privates.h"
+
+CompMetadata *compositeMetadata = NULL;
+
+class CompositePluginVTable : public CompPlugin::VTable
+{
+ public:
+
+ const char * name () { return "composite"; };
+
+ CompMetadata * getMetadata ();
+
+ bool init ();
+ void fini ();
+
+ bool initObject (CompObject *object);
+ void finiObject (CompObject *object);
+
+ CompOption::Vector & getObjectOptions (CompObject *object);
+
+ bool setObjectOption (CompObject *object,
+ const char *name,
+ CompOption::Value &value);
+};
+
+const CompMetadata::OptionInfo
+ compositeDisplayOptionInfo[COMPOSITE_DISPLAY_OPTION_NUM] = {
+ { "slow_animations_key", "key", 0,
+ CompositeScreen::toggleSlowAnimations, 0 }
+};
+
+const CompMetadata::OptionInfo
+ compositeScreenOptionInfo[COMPOSITE_SCREEN_OPTION_NUM] = {
+ { "detect_refresh_rate", "bool", 0, 0, 0 },
+ { "refresh_rate", "int", "<min>1</min>", 0, 0 },
+ { "unredirect_fullscreen_windows", "bool", 0, 0, 0 },
+ { "force_independent_output_painting", "bool", 0, 0, 0 }
+};
+
+CompOption::Vector &
+CompositeDisplay::getOptions ()
+{
+ return priv->opt;
+}
+
+CompOption::Vector &
+CompositeScreen::getOptions ()
+{
+ return priv->opt;
+}
+
+CompOption *
+CompositeScreen::getOption (const char *name)
+{
+ CompOption *o = CompOption::findOption (priv->opt, name);
+ return o;
+}
+
+bool
+CompositeDisplay::setOption (const char *name,
+ CompOption::Value &value)
+{
+ CompOption *o;
+ unsigned int index;
+
+ o = CompOption::findOption (priv->opt, name, &index);
+ if (!o)
+ return false;
+
+ return CompOption::setDisplayOption (priv->display, *o, value);
+}
+
+
+bool
+CompositeScreen::setOption (const char *name,
+ CompOption::Value &value)
+{
+ CompOption *o;
+ unsigned int index;
+
+ o = CompOption::findOption (priv->opt, name, &index);
+ if (!o)
+ return false;
+
+ switch (index) {
+ case COMPOSITE_SCREEN_OPTION_DETECT_REFRESH_RATE:
+ if (o->set (value))
+ {
+ if (value.b ())
+ detectRefreshRate ();
+
+ return true;
+ }
+ break;
+ case COMPOSITE_SCREEN_OPTION_REFRESH_RATE:
+ if (priv->opt[COMPOSITE_SCREEN_OPTION_DETECT_REFRESH_RATE].
+ value ().b ())
+ return false;
+ if (o->set (value))
+ {
+ priv->redrawTime = 1000 / o->value ().i ();
+ priv->optimalRedrawTime = priv->redrawTime;
+ return true;
+ }
+ break;
+ default:
+ if (CompOption::setScreenOption (priv->screen, *o, value))
+ return true;
+ break;
+ }
+
+ return false;
+}
+
+
+
+
+bool
+CompositePluginVTable::initObject (CompObject *o)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ {
+ CompositeDisplay *d =
+ new CompositeDisplay (GET_CORE_DISPLAY (o));
+ if (!d)
+ return false;
+ if (d->loadFailed ())
+ {
+ delete d;
+ return false;
+ }
+ return true;
+ }
+ break;
+ case COMP_OBJECT_TYPE_SCREEN:
+ {
+ CompositeScreen *s =
+ new CompositeScreen (GET_CORE_SCREEN (o));
+ if (!s)
+ return false;
+ if (s->loadFailed ())
+ {
+ delete s;
+ return false;
+ }
+ return true;
+ }
+ break;
+ case COMP_OBJECT_TYPE_WINDOW:
+ {
+ CompositeWindow *w =
+ new CompositeWindow (GET_CORE_WINDOW (o));
+ if (!w)
+ return false;
+ if (w->loadFailed ())
+ {
+ delete w;
+ return false;
+ }
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
+void
+CompositePluginVTable::finiObject (CompObject *o)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ {
+ CompositeDisplay *d =
+ CompositeDisplay::get (GET_CORE_DISPLAY (o));
+ if (d)
+ delete d;
+ }
+ break;
+ case COMP_OBJECT_TYPE_SCREEN:
+ {
+ CompositeScreen *s =
+ CompositeScreen::get (GET_CORE_SCREEN (o));
+ if (s)
+ delete s;
+ }
+ break;
+ case COMP_OBJECT_TYPE_WINDOW:
+ {
+ CompositeWindow *w =
+ CompositeWindow::get (GET_CORE_WINDOW (o));
+ if (w)
+ delete w;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+CompOption::Vector &
+CompositePluginVTable::getObjectOptions (CompObject *o)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ return CompositeDisplay::get (GET_CORE_DISPLAY (o))->getOptions ();
+ case COMP_OBJECT_TYPE_SCREEN:
+ return CompositeScreen::get (GET_CORE_SCREEN (o))->getOptions ();
+ default:
+ break;
+ }
+ return noOptions;
+}
+
+bool
+CompositePluginVTable::setObjectOption (CompObject *o,
+ const char *name,
+ CompOption::Value &value)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ return CompositeDisplay::get (GET_CORE_DISPLAY (o))->
+ setOption (name, value);
+ case COMP_OBJECT_TYPE_SCREEN:
+ return CompositeScreen::get (GET_CORE_SCREEN (o))->
+ setOption (name, value);
+ default:
+ break;
+ }
+ return false;
+}
+
+bool
+CompositePluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
+
+ CompPrivate p;
+ p.uval = COMPIZ_COMPOSITE_ABI;
+ core->storeValue ("composite_ABI", p);
+
+ compositeMetadata = new CompMetadata
+ (name (), compositeDisplayOptionInfo, COMPOSITE_DISPLAY_OPTION_NUM,
+ compositeScreenOptionInfo, COMPOSITE_SCREEN_OPTION_NUM);
+
+ if (!compositeMetadata)
+ return false;
+
+ compositeMetadata->addFromFile (name ());
+
+ return true;
+}
+
+void
+CompositePluginVTable::fini ()
+{
+ delete compositeMetadata;
+}
+
+CompMetadata *
+CompositePluginVTable::getMetadata ()
+{
+ return compositeMetadata;
+}
+
+CompositePluginVTable compositeVTable;
+
+CompPlugin::VTable *
+getCompPluginInfo20080805 (void)
+{
+ return &compositeVTable;
+}
diff --git a/plugins/composite/display.cpp b/plugins/composite/display.cpp
new file mode 100644
index 0000000..eee63d1
--- /dev/null
+++ b/plugins/composite/display.cpp
@@ -0,0 +1,234 @@
+#include "privates.h"
+
+#include <X11/extensions/shape.h>
+#include <X11/extensions/Xrandr.h>
+
+CompWindow *lastDamagedWindow = 0;
+
+
+CompositeDisplay::CompositeDisplay (CompDisplay *d) :
+ CompositePrivateHandler<CompositeDisplay, CompDisplay,
+ COMPIZ_COMPOSITE_ABI> (d),
+ priv (new PrivateCompositeDisplay (d, this))
+{
+ int compositeMajor, compositeMinor;
+
+ if (!compositeMetadata->initDisplayOptions
+ (d, compositeDisplayOptionInfo,
+ COMPOSITE_DISPLAY_OPTION_NUM, priv->opt))
+ {
+ setFailed ();
+ return;
+ }
+
+ if (!XQueryExtension (d->dpy (),
+ COMPOSITE_NAME,
+ &priv->compositeOpcode,
+ &priv->compositeEvent,
+ &priv->compositeError))
+ {
+ compLogMessage (d, "core", CompLogLevelFatal,
+ "No composite extension");
+ setFailed ();
+ return;
+ }
+
+ XCompositeQueryVersion (d->dpy (), &compositeMajor, &compositeMinor);
+ if (compositeMajor == 0 && compositeMinor < 2)
+ {
+ compLogMessage (d, "core", CompLogLevelFatal,
+ "Old composite extension");
+ setFailed ();
+ return;
+ }
+
+ if (!XDamageQueryExtension (d->dpy (), &priv->damageEvent,
+ &priv->damageError))
+ {
+ compLogMessage (d, "core", CompLogLevelFatal,
+ "No damage extension");
+ setFailed ();
+ return;
+ }
+
+ if (!XFixesQueryExtension (d->dpy (), &priv->fixesEvent, &priv->fixesError))
+ {
+ compLogMessage (d, "core", CompLogLevelFatal,
+ "No fixes extension");
+ setFailed ();
+ return;
+ }
+
+ priv->shapeExtension = XShapeQueryExtension (d->dpy (), &priv->shapeEvent,
+ &priv->shapeError);
+ priv->randrExtension = XRRQueryExtension (d->dpy (), &priv->randrEvent,
+ &priv->randrError);
+}
+
+CompositeDisplay::~CompositeDisplay ()
+{
+ delete priv;
+}
+
+PrivateCompositeDisplay::PrivateCompositeDisplay (CompDisplay *d,
+ CompositeDisplay *cd) :
+ display (d),
+ cDisplay (cd),
+ opt (COMPOSITE_DISPLAY_OPTION_NUM)
+{
+ // Wrap handleEvent
+ d->add (this);
+ DisplayInterface::setHandler (d);
+}
+
+PrivateCompositeDisplay::~PrivateCompositeDisplay ()
+{
+}
+
+void
+PrivateCompositeDisplay::handleEvent (XEvent *event)
+{
+ CompScreen *s;
+ CompWindow *w;
+
+ switch (event->type) {
+
+ case CreateNotify:
+ s = display->findScreen (event->xcreatewindow.parent);
+ if (s)
+ {
+ /* The first time some client asks for the composite
+ * overlay window, the X server creates it, which causes
+ * an errorneous CreateNotify event. We catch it and
+ * ignore it. */
+ if (CompositeScreen::get (s)->overlay () ==
+ event->xcreatewindow.window)
+ return;
+ }
+ break;
+ case PropertyNotify:
+ if (event->xproperty.atom == display->atoms ().winOpacity)
+ {
+ w = display->findWindow (event->xproperty.window);
+ if (w)
+ CompositeWindow::get (w)->updateOpacity ();
+ }
+ else if (event->xproperty.atom == display->atoms ().winBrightness)
+ {
+ w = display->findWindow (event->xproperty.window);
+ if (w)
+ CompositeWindow::get (w)->updateBrightness ();
+ }
+ else if (event->xproperty.atom == display->atoms ().winSaturation)
+ {
+ w = display->findWindow (event->xproperty.window);
+ if (w)
+ CompositeWindow::get (w)->updateSaturation ();
+ }
+ break;
+ default:
+ if (shapeExtension &&
+ event->type == shapeEvent + ShapeNotify)
+ {
+ w = display->findWindow (((XShapeEvent *) event)->window);
+ if (w)
+ {
+ if (w->mapNum ())
+ {
+ CompositeWindow::get (w)->addDamage ();
+ }
+ }
+ }
+ break;
+ }
+
+ display->handleEvent (event);
+
+ switch (event->type) {
+ case Expose:
+ foreach (s, display->screens ())
+ CompositeScreen::get (s)->priv->
+ handleExposeEvent (&event->xexpose);
+ break;
+ case ClientMessage:
+ if (event->xclient.message_type == display->atoms ().winOpacity)
+ {
+ w = display->findWindow (event->xclient.window);
+ if (w && (w->type () & CompWindowTypeDesktopMask) == 0)
+ {
+ unsigned short opacity = event->xclient.data.l[0] >> 16;
+
+ display->setWindowProp32 (w->id (),
+ display->atoms ().winOpacity, opacity);
+ }
+ }
+ else if (event->xclient.message_type ==
+ display->atoms ().winBrightness)
+ {
+ w = display->findWindow (event->xclient.window);
+ if (w)
+ {
+ unsigned short brightness = event->xclient.data.l[0] >> 16;
+
+ display->setWindowProp32 (w->id (),
+ display->atoms ().winBrightness, brightness);
+ }
+ }
+ else if (event->xclient.message_type ==
+ display->atoms ().winSaturation)
+ {
+ w = display->findWindow (event->xclient.window);
+ if (w)
+ {
+ unsigned short saturation = event->xclient.data.l[0] >> 16;
+
+ display->setWindowProp32 (w->id (),
+ display->atoms ().winSaturation, saturation);
+ }
+ }
+ break;
+ default:
+ if (event->type == damageEvent + XDamageNotify)
+ {
+ XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
+
+ if (lastDamagedWindow && de->drawable == lastDamagedWindow->id ())
+ {
+ w = lastDamagedWindow;
+ }
+ else
+ {
+ w = display->findWindow (de->drawable);
+ if (w)
+ lastDamagedWindow = w;
+ }
+
+ if (w)
+ CompositeWindow::get (w)->processDamage (de);
+ }
+ else if (shapeExtension &&
+ event->type == shapeEvent + ShapeNotify)
+ {
+ w = display->findWindow (((XShapeEvent *) event)->window);
+ if (w)
+ {
+ if (w->mapNum ())
+ {
+ CompositeWindow::get (w)->addDamage ();
+ }
+ }
+ }
+ else if (randrExtension &&
+ event->type == randrEvent + RRScreenChangeNotify)
+ {
+ XRRScreenChangeNotifyEvent *rre;
+
+ rre = (XRRScreenChangeNotifyEvent *) event;
+
+ s = display->findScreen (rre->root);
+ if (s)
+ CompositeScreen::get (s)->detectRefreshRate ();
+ }
+ break;
+ }
+}
diff --git a/plugins/composite/privates.h b/plugins/composite/privates.h
new file mode 100644
index 0000000..b376346
--- /dev/null
+++ b/plugins/composite/privates.h
@@ -0,0 +1,148 @@
+#ifndef _COMPOSITE_PRIVATES_H
+#define _COMPOSITE_PRIVATES_H
+
+#include <composite/composite.h>
+
+#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR > 2
+#define USE_COW
+extern bool useCow;
+#endif
+
+#define COMPOSITE_DISPLAY_OPTION_SLOW_ANIMATIONS_KEY 0
+#define COMPOSITE_DISPLAY_OPTION_NUM 1
+
+#define COMPOSITE_SCREEN_OPTION_DETECT_REFRESH_RATE 0
+#define COMPOSITE_SCREEN_OPTION_REFRESH_RATE 1
+#define COMPOSITE_SCREEN_OPTION_UNREDIRECT_FS 2
+#define COMPOSITE_SCREEN_OPTION_FORCE_INDEPENDENT 3
+#define COMPOSITE_SCREEN_OPTION_NUM 4
+
+extern CompMetadata *compositeMetadata;
+extern const CompMetadata::OptionInfo
+ compositeDisplayOptionInfo[COMPOSITE_DISPLAY_OPTION_NUM];
+
+extern const CompMetadata::OptionInfo
+ compositeScreenOptionInfo[COMPOSITE_SCREEN_OPTION_NUM];
+
+extern CompWindow *lastDamagedWindow;
+
+class PrivateCompositeDisplay : public DisplayInterface
+{
+ public:
+ PrivateCompositeDisplay (CompDisplay *d, CompositeDisplay *cd);
+ ~PrivateCompositeDisplay ();
+
+ void handleEvent (XEvent *event);
+
+ public:
+ CompDisplay *display;
+ CompositeDisplay *cDisplay;
+
+ int compositeEvent, compositeError, compositeOpcode;
+ int damageEvent, damageError;
+ int fixesEvent, fixesError, fixesVersion;
+
+ bool shapeExtension;
+ int shapeEvent, shapeError;
+
+ bool randrExtension;
+ int randrEvent, randrError;
+
+ CompOption::Vector opt;
+};
+
+class PrivateCompositeScreen : ScreenInterface
+{
+ public:
+ PrivateCompositeScreen (CompScreen *s, CompositeScreen *cs);
+ ~PrivateCompositeScreen ();
+
+ void outputChangeNotify ();
+
+ void makeOutputWindow ();
+
+ bool init ();
+
+ void handleExposeEvent (XExposeEvent *event);
+
+ public:
+ CompScreen *screen;
+ CompositeScreen *cScreen;
+
+ Region damage;
+ unsigned long damageMask;
+
+ Window overlay;
+ Window output;
+
+ std::list <CompRect> exposeRects;
+
+ CompPoint windowPaintOffset;
+
+ int overlayWindowCount;
+
+ struct timeval lastRedraw;
+ int nextRedraw;
+ int redrawTime;
+ int optimalRedrawTime;
+ int frameStatus;
+ int timeMult;
+ bool idle;
+ int timeLeft;
+
+ bool slowAnimations;
+
+ CompCore::Timer paintTimer;
+
+ Region tmpRegion;
+
+ bool active;
+ CompositeScreen::PaintHandler *pHnd;
+
+ CompOption::Vector opt;
+};
+
+class PrivateCompositeWindow : WindowInterface
+{
+ public:
+ PrivateCompositeWindow (CompWindow *w, CompositeWindow *cw);
+ ~PrivateCompositeWindow ();
+
+ void windowNotify (CompWindowNotify n);
+ void resizeNotify (int dx, int dy, int dwidth, int dheight);
+ void moveNotify (int dx, int dy, bool now);
+
+ static void handleDamageRect (CompositeWindow *w,
+ int x,
+ int y,
+ int width,
+ int height);
+
+ public:
+
+ CompWindow *window;
+ CompositeWindow *cWindow;
+ CompScreen *screen;
+ CompositeScreen *cScreen;
+
+ Pixmap pixmap;
+
+ Damage damage;
+
+ bool damaged;
+ bool redirected;
+ bool overlayWindow;
+ bool bindFailed;
+
+ unsigned short opacity;
+ unsigned short brightness;
+ unsigned short saturation;
+
+ XRectangle *damageRects;
+ int sizeDamage;
+ int nDamage;
+
+
+};
+
+#endif
diff --git a/plugins/composite/screen.cpp b/plugins/composite/screen.cpp
new file mode 100644
index 0000000..5a55f78
--- /dev/null
+++ b/plugins/composite/screen.cpp
@@ -0,0 +1,760 @@
+#ifdef HAVE_CONFIG_H
+# include "../config.h"
+#endif
+
+#include <sys/time.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/shape.h>
+
+#include "privates.h"
+
+CompositeScreen::CompositeScreen (CompScreen *s) :
+ CompositePrivateHandler<CompositeScreen, CompScreen,
+ COMPIZ_COMPOSITE_ABI> (s),
+ priv (new PrivateCompositeScreen (s, this))
+{
+ WRAPABLE_INIT_HND(preparePaint);
+ WRAPABLE_INIT_HND(donePaint);
+ WRAPABLE_INIT_HND(paint);
+ WRAPABLE_INIT_HND(getWindowPaintList);
+
+ priv->tmpRegion = XCreateRegion ();
+ if (!priv->tmpRegion)
+ {
+ setFailed ();
+ return;
+ }
+
+ priv->damage = XCreateRegion ();
+ if (!priv->damage)
+ {
+ setFailed ();
+ return;
+ }
+
+ if (!compositeMetadata->initScreenOptions
+ (s, compositeScreenOptionInfo, COMPOSITE_SCREEN_OPTION_NUM, priv->opt))
+ {
+ setFailed ();
+ return;
+ }
+
+ priv->makeOutputWindow ();
+
+ detectRefreshRate ();
+
+ priv->slowAnimations = false;
+
+ if (!priv->init ())
+ {
+ setFailed ();
+ }
+
+}
+
+CompositeScreen::~CompositeScreen ()
+{
+ priv->paintTimer.stop ();
+
+#ifdef USE_COW
+ if (useCow)
+ XCompositeReleaseOverlayWindow (priv->screen->display()->dpy (),
+ priv->screen->root ());
+#endif
+
+ if (priv->damage)
+ XDestroyRegion (priv->damage);
+
+ delete priv;
+}
+
+
+PrivateCompositeScreen::PrivateCompositeScreen (CompScreen *s,
+ CompositeScreen *cs) :
+ screen (s),
+ cScreen (cs),
+ damageMask (COMPOSITE_SCREEN_DAMAGE_ALL_MASK),
+ overlay (None),
+ output (None),
+ exposeRects (),
+ windowPaintOffset (0, 0),
+ overlayWindowCount (0),
+ nextRedraw (0),
+ redrawTime (1000 / 50),
+ optimalRedrawTime (1000 / 50),
+ frameStatus (0),
+ timeMult (1),
+ idle (true),
+ timeLeft (0),
+ slowAnimations (false),
+ tmpRegion (NULL),
+ active (false),
+ pHnd (NULL),
+ opt (COMPOSITE_SCREEN_OPTION_NUM)
+{
+ gettimeofday (&lastRedraw, 0);
+ // wrap outputChangeNotify
+ s->add (this);
+ ScreenInterface::setHandler (s);
+}
+
+PrivateCompositeScreen::~PrivateCompositeScreen ()
+{
+ if (tmpRegion)
+ XDestroyRegion (tmpRegion);
+}
+
+bool
+PrivateCompositeScreen::init ()
+{
+ Display *dpy = screen->display ()->dpy ();
+ Window newCmSnOwner = None;
+ Atom cmSnAtom = 0;
+ Time cmSnTimestamp = 0;
+ XEvent event;
+ XSetWindowAttributes attr;
+ Window currentCmSnOwner;
+ char buf[128];
+
+ sprintf (buf, "_NET_WM_CM_S%d", screen->screenNum ());
+ cmSnAtom = XInternAtom (dpy, buf, 0);
+
+ currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom);
+
+ if (currentCmSnOwner != None)
+ {
+ if (!replaceCurrentWm)
+ {
+ compLogMessage (screen->display (), "composite",
+ CompLogLevelError,
+ "Screen %d on display \"%s\" already "
+ "has a compositing manager; try using the "
+ "--replace option to replace the current "
+ "compositing manager.",
+ screen->screenNum (), DisplayString (dpy));
+
+ return false;
+ }
+ }
+
+ attr.override_redirect = TRUE;
+ attr.event_mask = PropertyChangeMask;
+
+ newCmSnOwner =
+ XCreateWindow (dpy, XRootWindow (dpy, screen->screenNum ()),
+ -100, -100, 1, 1, 0,
+ CopyFromParent, CopyFromParent,
+ CopyFromParent,
+ CWOverrideRedirect | CWEventMask,
+ &attr);
+
+ XChangeProperty (dpy,
+ newCmSnOwner,
+ screen->display ()->atoms ().wmName,
+ screen->display ()->atoms ().utf8String, 8,
+ PropModeReplace,
+ (unsigned char *) PACKAGE,
+ strlen (PACKAGE));
+
+ XWindowEvent (dpy, newCmSnOwner, PropertyChangeMask, &event);
+
+ cmSnTimestamp = event.xproperty.time;
+
+
+ XSetSelectionOwner (dpy, cmSnAtom, newCmSnOwner, cmSnTimestamp);
+
+ if (XGetSelectionOwner (dpy, cmSnAtom) != newCmSnOwner)
+ {
+ compLogMessage (screen->display (), "composite", CompLogLevelError,
+ "Could not acquire compositing manager "
+ "selection on screen %d display \"%s\"",
+ screen->screenNum (), DisplayString (dpy));
+
+ return false;
+ }
+
+ return true;
+}
+
+
+bool
+CompositeScreen::registerPaintHandler (PaintHandler *pHnd)
+{
+ Display *dpy = priv->screen->display ()->dpy ();
+
+ if (priv->active)
+ return false;
+
+ CompDisplay::checkForError (dpy);
+
+ XCompositeRedirectSubwindows (dpy, priv->screen->root (),
+ CompositeRedirectManual);
+
+ priv->overlayWindowCount = 0;
+
+ if (CompDisplay::checkForError (dpy))
+ {
+ compLogMessage (priv->screen->display (), "composite",
+ CompLogLevelError,
+ "Another composite manager is already "
+ "running on screen: %d", priv->screen->screenNum ());
+
+ return false;
+ }
+
+ foreach (CompWindow *w, priv->screen->windows ())
+ {
+ CompositeWindow *cw = CompositeWindow::get (w);
+ cw->priv->overlayWindow = false;
+ cw->priv->redirected = true;
+ }
+
+ priv->pHnd = pHnd;
+ priv->active = true;
+
+ showOutputWindow ();
+
+ priv->paintTimer.start
+ (boost::bind(&CompositeScreen::handlePaintTimeout, this),
+ priv->optimalRedrawTime, MAXSHORT);
+ return true;
+}
+
+void
+CompositeScreen::unregisterPaintHandler ()
+{
+ Display *dpy = priv->screen->display ()->dpy ();
+
+ foreach (CompWindow *w, priv->screen->windows ())
+ {
+ CompositeWindow *cw = CompositeWindow::get (w);
+ cw->priv->overlayWindow = false;
+ cw->priv->redirected = false;
+ cw->release ();
+ }
+
+ priv->overlayWindowCount = 0;
+
+ XCompositeUnredirectSubwindows (dpy, priv->screen->root (),
+ CompositeRedirectManual);
+
+ priv->pHnd = NULL;
+ priv->active = false;
+ priv->paintTimer.stop ();
+
+ hideOutputWindow ();
+}
+
+bool
+CompositeScreen::compositingActive ()
+{
+ return priv->active;
+}
+
+void
+CompositeScreen::damageScreen ()
+{
+ if (priv->damageMask == 0)
+ priv->paintTimer.setTimes (priv->paintTimer.minLeft ());
+
+ priv->damageMask |= COMPOSITE_SCREEN_DAMAGE_ALL_MASK;
+ priv->damageMask &= ~COMPOSITE_SCREEN_DAMAGE_REGION_MASK;
+}
+
+void
+CompositeScreen::damageRegion (Region region)
+{
+ if (priv->damageMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ return;
+
+ if (priv->damageMask == 0)
+ priv->paintTimer.setTimes (priv->paintTimer.minLeft ());
+
+ XUnionRegion (priv->damage, region, priv->damage);
+
+ priv->damageMask |= COMPOSITE_SCREEN_DAMAGE_REGION_MASK;
+
+}
+
+void
+CompositeScreen::damagePending ()
+{
+ if (priv->damageMask == 0)
+ priv->paintTimer.setTimes (priv->paintTimer.minLeft ());
+
+ priv->damageMask |= COMPOSITE_SCREEN_DAMAGE_PENDING_MASK;
+}
+
+unsigned int
+CompositeScreen::damageMask ()
+{
+ return priv->damageMask;
+}
+
+void
+CompositeScreen::showOutputWindow ()
+{
+#ifdef USE_COW
+ if (useCow && priv->active)
+ {
+ Display *dpy = priv->screen->display ()->dpy ();
+ XserverRegion region;
+
+ region = XFixesCreateRegion (dpy, NULL, 0);
+
+ XFixesSetWindowShapeRegion (dpy,
+ priv->output,
+ ShapeBounding,
+ 0, 0, 0);
+ XFixesSetWindowShapeRegion (dpy,
+ priv->output,
+ ShapeInput,
+ 0, 0, region);
+
+ XFixesDestroyRegion (dpy, region);
+
+ damageScreen ();
+ }
+#endif
+
+}
+
+void
+CompositeScreen::hideOutputWindow ()
+{
+#ifdef USE_COW
+ if (useCow)
+ {
+ Display *dpy = priv->screen->display ()->dpy ();
+ XserverRegion region;
+
+ region = XFixesCreateRegion (dpy, NULL, 0);
+
+ XFixesSetWindowShapeRegion (dpy,
+ priv->output,
+ ShapeBounding,
+ 0, 0, region);
+
+ XFixesDestroyRegion (dpy, region);
+ }
+#endif
+
+}
+
+void
+CompositeScreen::updateOutputWindow ()
+{
+#ifdef USE_COW
+ if (useCow && priv->active)
+ {
+ Display *dpy = priv->screen->display ()->dpy ();
+ XserverRegion region;
+ static Region tmpRegion = NULL;
+
+ if (!tmpRegion)
+ {
+ tmpRegion = XCreateRegion ();
+ if (!tmpRegion)
+ return;
+ }
+
+ XSubtractRegion (priv->screen->region (), &emptyRegion, tmpRegion);
+
+
+ for (CompWindowList::reverse_iterator rit =
+ priv->screen->windows ().rbegin ();
+ rit != priv->screen->windows ().rend (); rit++)
+ if (CompositeWindow::get (*rit)->overlayWindow ())
+ {
+ XSubtractRegion (tmpRegion, (*rit)->region (), tmpRegion);
+ }
+
+ XShapeCombineRegion (dpy, priv->output, ShapeBounding,
+ 0, 0, tmpRegion, ShapeSet);
+
+
+ region = XFixesCreateRegion (dpy, NULL, 0);
+
+ XFixesSetWindowShapeRegion (dpy,
+ priv->output,
+ ShapeInput,
+ 0, 0, region);
+
+ XFixesDestroyRegion (dpy, region);
+ }
+#endif
+
+}
+
+void
+PrivateCompositeScreen::makeOutputWindow ()
+{
+#ifdef USE_COW
+ if (useCow)
+ {
+ overlay = XCompositeGetOverlayWindow (screen->display ()->dpy (),
+ screen->root ());
+ output = overlay;
+
+ XSelectInput (screen->display ()->dpy (), output, ExposureMask);
+ }
+ else
+#endif
+ output = overlay = screen->root ();
+
+ cScreen->hideOutputWindow ();
+}
+
+Window
+CompositeScreen::output ()
+{
+ return priv->output;
+}
+
+Window
+CompositeScreen::overlay ()
+{
+ return priv->overlay;
+}
+
+int &
+CompositeScreen::overlayWindowCount ()
+{
+ return priv->overlayWindowCount;
+}
+
+void
+CompositeScreen::setWindowPaintOffset (int x, int y)
+{
+ priv->windowPaintOffset = CompPoint (x, y);
+}
+
+CompPoint
+CompositeScreen::windowPaintOffset ()
+{
+ return priv->windowPaintOffset;
+}
+
+void
+CompositeScreen::detectRefreshRate ()
+{
+ if (!noDetection &&
+ priv->opt[COMPOSITE_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().b ())
+ {
+ CompString name;
+ CompOption::Value value;
+
+ value.set ((int) 0);
+
+ if (priv->screen->display ()->XRandr())
+ {
+ XRRScreenConfiguration *config;
+
+ config = XRRGetScreenInfo (priv->screen->display ()->dpy (),
+ priv->screen->root ());
+ value.set ((int) XRRConfigCurrentRate (config));
+
+ XRRFreeScreenConfigInfo (config);
+ }
+
+ if (value.i () == 0)
+ value.set ((int) 50);
+
+ name = priv->opt[COMPOSITE_SCREEN_OPTION_REFRESH_RATE].name ();
+
+ priv->opt[COMPOSITE_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().set (false);
+ core->setOptionForPlugin (priv->screen, "composite", name.c_str (), value);
+ priv->opt[COMPOSITE_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().set (true);
+ }
+ else
+ {
+ priv->redrawTime = 1000 /
+ priv->opt[COMPOSITE_SCREEN_OPTION_REFRESH_RATE].value ().i ();
+ priv->optimalRedrawTime = priv->redrawTime;
+ }
+}
+
+int
+CompositeScreen::getTimeToNextRedraw (struct timeval *tv)
+{
+ int diff, next;
+
+ diff = TIMEVALDIFF (tv, &priv->lastRedraw);
+
+ /* handle clock rollback */
+ if (diff < 0)
+ diff = 0;
+
+ if (priv->idle || (priv->pHnd && priv->pHnd->hasVSync ()))
+ {
+ if (priv->timeMult > 1)
+ {
+ priv->frameStatus = -1;
+ priv->redrawTime = priv->optimalRedrawTime;
+ priv->timeMult--;
+ }
+ }
+ else
+ {
+ if (diff > priv->redrawTime)
+ {
+ if (priv->frameStatus > 0)
+ priv->frameStatus = 0;
+
+ next = priv->optimalRedrawTime * (priv->timeMult + 1);
+ if (diff > next)
+ {
+ priv->frameStatus--;
+ if (priv->frameStatus < -1)
+ {
+ priv->timeMult++;
+ priv->redrawTime = diff = next;
+ }
+ }
+ }
+ else if (diff < priv->redrawTime)
+ {
+ if (priv->frameStatus < 0)
+ priv->frameStatus = 0;
+
+ if (priv->timeMult > 1)
+ {
+ next = priv->optimalRedrawTime * (priv->timeMult - 1);
+ if (diff < next)
+ {
+ priv->frameStatus++;
+ if (priv->frameStatus > 4)
+ {
+ priv->timeMult--;
+ priv->redrawTime = next;
+ }
+ }
+ }
+ }
+ }
+ if (diff >= priv->redrawTime)
+ return 1;
+
+ return priv->redrawTime - diff;
+}
+
+bool
+CompositeScreen::handlePaintTimeout ()
+{
+ int timeDiff;
+ struct timeval tv;
+
+ gettimeofday (&tv, 0);
+
+ if (priv->damageMask)
+ {
+ if (priv->pHnd)
+ priv->pHnd->prepareDrawing ();
+
+ timeDiff = TIMEVALDIFF (&tv, &priv->lastRedraw);
+
+ /* handle clock rollback */
+ if (timeDiff < 0)
+ timeDiff = 0;
+
+ if (priv->slowAnimations)
+ {
+ preparePaint (priv->idle ? 2 : (timeDiff * 2) / priv->redrawTime);
+ }
+ else
+ preparePaint (priv->idle ? priv->redrawTime : timeDiff);
+
+ /* substract top most overlay window region */
+ if (priv->overlayWindowCount)
+ {
+ for (CompWindowList::reverse_iterator rit =
+ priv->screen->windows ().rbegin ();
+ rit != priv->screen->windows ().rend (); rit++)
+ {
+ CompWindow *w = (*rit);
+
+ if (w->destroyed () || w->invisible ())
+ continue;
+
+ if (!CompositeWindow::get (w)->redirected ())
+ XSubtractRegion (priv->damage, w->region (),
+ priv->damage);
+
+ break;
+ }
+
+ if (priv->damageMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ {
+ priv->damageMask &= ~COMPOSITE_SCREEN_DAMAGE_ALL_MASK;
+ priv->damageMask |= COMPOSITE_SCREEN_DAMAGE_REGION_MASK;
+ }
+ }
+
+ if (priv->damageMask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK)
+ {
+ XIntersectRegion (priv->damage, priv->screen->region (),
+ priv->tmpRegion);
+
+ if (priv->tmpRegion->numRects == 1 &&
+ priv->tmpRegion->rects->x1 == 0 &&
+ priv->tmpRegion->rects->y1 == 0 &&
+ priv->tmpRegion->rects->x2 ==
+ (int) priv->screen->size ().width () &&
+ priv->tmpRegion->rects->y2 ==
+ (int) priv->screen->size ().height ())
+ damageScreen ();
+ }
+
+ EMPTY_REGION (priv->damage);
+
+ int mask = priv->damageMask;
+ priv->damageMask = 0;
+
+ CompOutput::ptrList outputs (0);
+
+ if (priv->opt[COMPOSITE_SCREEN_OPTION_FORCE_INDEPENDENT].value ().b ()
+ || !priv->screen->hasOverlappingOutputs ())
+ {
+ foreach (CompOutput &o, priv->screen->outputDevs ())
+ outputs.push_back (&o);
+ }
+ else
+ outputs.push_back (&priv->screen->fullscreenOutput ());
+
+ paint (outputs, mask);
+
+ priv->lastRedraw = tv;
+
+ donePaint ();
+
+ foreach (CompWindow *w, priv->screen->windows ())
+ {
+ if (w->destroyed ())
+ {
+ CompositeWindow::get (w)->addDamage ();
+ break;
+ }
+ }
+
+ priv->idle = false;
+ }
+ else
+ {
+ priv->idle = true;
+ }
+
+ gettimeofday (&tv, 0);
+
+ priv->paintTimer.setTimes (getTimeToNextRedraw (&tv), MAXSHORT);
+ return true;
+}
+
+void
+CompositeScreen::preparePaint (int msSinceLastPaint)
+ WRAPABLE_HND_FUNC(preparePaint, msSinceLastPaint)
+
+void
+CompositeScreen::donePaint ()
+ WRAPABLE_HND_FUNC(donePaint)
+
+void
+CompositeScreen::paint (CompOutput::ptrList &outputs,
+ unsigned int mask)
+{
+ WRAPABLE_HND_FUNC(paint, outputs, mask)
+
+ if (priv->pHnd)
+ priv->pHnd->paintOutputs (outputs, mask, priv->tmpRegion);
+}
+
+CompWindowList
+CompositeScreen::getWindowPaintList ()
+{
+ WRAPABLE_HND_FUNC_RETURN (CompWindowList, getWindowPaintList)
+
+ return priv->screen->windows ();
+}
+
+void
+PrivateCompositeScreen::handleExposeEvent (XExposeEvent *event)
+{
+ if (output == event->window)
+ return;
+
+ exposeRects.push_back (CompRect (event->x, event->x + event->width,
+ event->y, event->y + event->height));
+
+ if (event->count == 0)
+ {
+ CompRect rect;
+ foreach (CompRect rect, exposeRects)
+ {
+ cScreen->damageRegion (rect.region ());
+ }
+ exposeRects.clear ();
+ }
+}
+
+void
+PrivateCompositeScreen::outputChangeNotify ()
+{
+ screen->outputChangeNotify ();
+#ifdef USE_COW
+ if (useCow)
+ XMoveResizeWindow (screen->display ()->dpy (), overlay, 0, 0,
+ screen->size ().width (), screen->size ().height ());
+#endif
+ cScreen->damageScreen ();
+}
+
+bool
+CompositeScreen::toggleSlowAnimations (CompDisplay *d,
+ CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompScreen *s;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "root");
+ s = d->findScreen (xid);
+ if (s)
+ {
+ CompositeScreen *cs = CompositeScreen::get (s);
+ if (cs)
+ cs->priv->slowAnimations = !cs->priv->slowAnimations;
+ }
+
+ return true;
+}
+
+CompositeScreenInterface::CompositeScreenInterface ()
+{
+ WRAPABLE_INIT_FUNC(preparePaint);
+ WRAPABLE_INIT_FUNC(donePaint);
+ WRAPABLE_INIT_FUNC(paint);
+
+ WRAPABLE_INIT_FUNC(getWindowPaintList);
+}
+
+void
+CompositeScreenInterface::preparePaint (int msSinceLastPaint)
+ WRAPABLE_DEF_FUNC(preparePaint, msSinceLastPaint)
+
+void
+CompositeScreenInterface::donePaint ()
+ WRAPABLE_DEF_FUNC(donePaint)
+
+void
+CompositeScreenInterface::paint (CompOutput::ptrList &outputs,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC(paint, outputs, mask)
+
+CompWindowList
+CompositeScreenInterface::getWindowPaintList ()
+ WRAPABLE_DEF_FUNC_WITH_RETURN(CompWindowList (), getWindowPaintList)
diff --git a/plugins/composite/window.cpp b/plugins/composite/window.cpp
new file mode 100644
index 0000000..463876b
--- /dev/null
+++ b/plugins/composite/window.cpp
@@ -0,0 +1,622 @@
+#include "privates.h"
+
+CompositeWindow::CompositeWindow (CompWindow *w) :
+ CompositePrivateHandler<CompositeWindow, CompWindow,
+ COMPIZ_COMPOSITE_ABI> (w),
+ priv (new PrivateCompositeWindow (w, this))
+{
+ WRAPABLE_INIT_HND(damageRect);
+
+ CompDisplay *d = w->screen ()->display ();
+
+ if (w->attrib ().c_class != InputOnly)
+ {
+ priv->damage = XDamageCreate (d->dpy (), w->id (),
+ XDamageReportRawRectangles);
+ }
+ else
+ {
+ priv->damage = None;
+ }
+
+ priv->opacity = OPAQUE;
+ if (!(w->type () & CompWindowTypeDesktopMask))
+ priv->opacity = d->getWindowProp32 (w->id (),
+ d->atoms ().winOpacity, OPAQUE);
+
+ priv->brightness = d->getWindowProp32 (w->id (),
+ d->atoms ().winBrightness, BRIGHT);
+
+ priv->saturation = d->getWindowProp32 (w->id (),
+ d->atoms ().winSaturation, COLOR);
+
+ if (w->attrib ().map_state == IsViewable)
+ {
+ priv->damaged = true;
+ }
+}
+
+CompositeWindow::~CompositeWindow ()
+{
+
+ if (priv->damage)
+ XDamageDestroy (priv->screen->display ()->dpy (), priv->damage);
+
+ if (!priv->redirected)
+ {
+ priv->cScreen->overlayWindowCount ()--;
+
+ if (priv->cScreen->overlayWindowCount () < 1)
+ priv->cScreen->showOutputWindow ();
+ }
+
+ release ();
+
+ if (lastDamagedWindow == priv->window)
+ lastDamagedWindow = NULL;
+
+ delete priv;
+}
+
+PrivateCompositeWindow::PrivateCompositeWindow (CompWindow *w,
+ CompositeWindow *cw) :
+ window (w),
+ cWindow (cw),
+ screen (w->screen ()),
+ cScreen (CompositeScreen::get (screen)),
+ pixmap (None),
+ damage (None),
+ damaged (false),
+ redirected (cScreen->compositingActive ()),
+ overlayWindow (false),
+ bindFailed (false),
+ opacity (OPAQUE),
+ brightness (BRIGHT),
+ saturation (COLOR),
+ damageRects (0),
+ sizeDamage (0),
+ nDamage (0)
+{
+ w->add (this);
+ WindowInterface::setHandler (w);
+}
+
+PrivateCompositeWindow::~PrivateCompositeWindow ()
+{
+
+ if (sizeDamage)
+ free (damageRects);
+}
+
+bool
+CompositeWindow::bind ()
+{
+ if (!priv->cScreen->compositingActive ())
+ return false;
+
+ redirect ();
+ if (!priv->pixmap)
+ {
+ XWindowAttributes attr;
+
+ /* don't try to bind window again if it failed previously */
+ if (priv->bindFailed)
+ return false;
+
+ /* We have to grab the server here to make sure that window
+ is mapped when getting the window pixmap */
+ XGrabServer (priv->screen->display ()->dpy ());
+ XGetWindowAttributes (priv->screen->display ()->dpy (),
+ priv->window->id (), &attr);
+ if (attr.map_state != IsViewable)
+ {
+ XUngrabServer (priv->screen->display ()->dpy ());
+ priv->bindFailed = true;
+ return false;
+ }
+
+ priv->pixmap = XCompositeNameWindowPixmap
+ (priv->screen->display ()->dpy (), priv->window->id ());
+
+ XUngrabServer (priv->screen->display ()->dpy ());
+ }
+ return true;
+}
+
+void
+CompositeWindow::release ()
+{
+ if (priv->pixmap)
+ {
+ XFreePixmap (priv->screen->display ()->dpy (), priv->pixmap);
+ priv->pixmap = None;
+ }
+}
+
+Pixmap
+CompositeWindow::pixmap ()
+{
+ return priv->pixmap;
+}
+
+void
+CompositeWindow::redirect ()
+{
+ if (priv->redirected || !priv->cScreen->compositingActive ())
+ return;
+
+ XCompositeRedirectWindow (priv->screen->display ()->dpy (),
+ priv->window->id (),
+ CompositeRedirectManual);
+
+ priv->redirected = true;
+
+ if (priv->overlayWindow)
+ {
+ priv->cScreen->overlayWindowCount ()--;
+ priv->overlayWindow = false;
+ }
+
+ if (priv->cScreen->overlayWindowCount () < 1)
+ priv->cScreen->showOutputWindow ();
+ else
+ priv->cScreen->updateOutputWindow ();
+}
+
+void
+CompositeWindow::unredirect ()
+{
+ if (!priv->redirected || !priv->cScreen->compositingActive ())
+ return;
+
+ release ();
+
+ XCompositeUnredirectWindow (priv->screen->display ()->dpy (),
+ priv->window->id (),
+ CompositeRedirectManual);
+
+ priv->redirected = false;
+ priv->overlayWindow = true;
+ priv->cScreen->overlayWindowCount ()++;
+
+ if (priv->cScreen->overlayWindowCount () > 0)
+ priv->cScreen->updateOutputWindow ();
+}
+
+bool
+CompositeWindow::redirected ()
+{
+ return priv->redirected;
+}
+
+bool
+CompositeWindow::overlayWindow ()
+{
+ return priv->overlayWindow;
+}
+
+void
+CompositeWindow::damageTransformedRect (float xScale,
+ float yScale,
+ float xTranslate,
+ float yTranslate,
+ BoxPtr rect)
+{
+ REGION reg;
+
+ reg.rects = &reg.extents;
+ reg.numRects = 1;
+
+ reg.extents.x1 = (short) (rect->x1 * xScale) - 1;
+ reg.extents.y1 = (short) (rect->y1 * yScale) - 1;
+ reg.extents.x2 = (short) (rect->x2 * xScale + 0.5f) + 1;
+ reg.extents.y2 = (short) (rect->y2 * yScale + 0.5f) + 1;
+
+ reg.extents.x1 += (short) xTranslate;
+ reg.extents.y1 += (short) yTranslate;
+ reg.extents.x2 += (short) (xTranslate + 0.5f);
+ reg.extents.y2 += (short) (yTranslate + 0.5f);
+
+ if (reg.extents.x2 > reg.extents.x1 && reg.extents.y2 > reg.extents.y1)
+ {
+ XWindowAttributes attrib = priv->window->attrib ();
+
+ reg.extents.x1 += attrib.x + attrib.border_width;
+ reg.extents.y1 += attrib.y + attrib.border_width;
+ reg.extents.x2 += attrib.x + attrib.border_width;
+ reg.extents.y2 += attrib.y + attrib.border_width;
+
+ priv->cScreen->damageRegion (&reg);
+ }
+}
+
+void
+CompositeWindow::damageOutputExtents ()
+{
+ if (priv->cScreen->damageMask () & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ return;
+
+ if (priv->window->shaded () ||
+ (priv->window->attrib ().map_state == IsViewable && priv->damaged))
+ {
+ BoxRec box;
+
+ XWindowAttributes attrib = priv->window->attrib ();
+ CompWindowExtents output = priv->window->output ();
+
+ /* top */
+ box.x1 = -output.left - attrib.border_width;
+ box.y1 = -output.top - attrib.border_width;
+ box.x2 = priv->window->width () + output.right - attrib.border_width;
+ box.y2 = -attrib.border_width;
+
+ if (box.x1 < box.x2 && box.y1 < box.y2)
+ addDamageRect (&box);
+
+ /* bottom */
+ box.y1 = priv->window->height () - attrib.border_width;
+ box.y2 = box.y1 + output.bottom - attrib.border_width;
+
+ if (box.x1 < box.x2 && box.y1 < box.y2)
+ addDamageRect (&box);
+
+ /* left */
+ box.x1 = -output.left - attrib.border_width;
+ box.y1 = -attrib.border_width;
+ box.x2 = -attrib.border_width;
+ box.y2 = priv->window->height () - attrib.border_width;
+
+ if (box.x1 < box.x2 && box.y1 < box.y2)
+ addDamageRect (&box);
+
+ /* right */
+ box.x1 = priv->window->width () - attrib.border_width;
+ box.x2 = box.x1 + output.right - attrib.border_width;
+
+ if (box.x1 < box.x2 && box.y1 < box.y2)
+ addDamageRect (&box);
+ }
+}
+
+void
+CompositeWindow::addDamageRect (BoxPtr rect)
+{
+ REGION region;
+
+ if (priv->cScreen->damageMask () & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ return;
+
+ region.extents = *rect;
+
+ if (!damageRect (false, &region.extents))
+ {
+ XWindowAttributes attrib = priv->window->attrib ();
+ region.extents.x1 += attrib.x + attrib.border_width;
+ region.extents.y1 += attrib.y + attrib.border_width;
+ region.extents.x2 += attrib.x + attrib.border_width;
+ region.extents.y2 += attrib.y + attrib.border_width;
+
+ region.rects = &region.extents;
+ region.numRects = region.size = 1;
+
+ priv->cScreen->damageRegion (&region);
+ }
+}
+
+void
+CompositeWindow::addDamage ()
+{
+ if (priv->cScreen->damageMask () & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ return;
+
+ if (priv->window->shaded () ||
+ (priv->window->attrib ().map_state == IsViewable && priv->damaged))
+ {
+ BoxRec box;
+
+ box.x1 = -priv->window->output ().left -
+ priv->window->attrib ().border_width;
+ box.y1 = -priv->window->output ().top -
+ priv->window->attrib ().border_width;
+ box.x2 = priv->window->width () +
+ priv->window->output ().right;
+ box.y2 = priv->window->height () + priv->window->output ().bottom;
+
+ addDamageRect (&box);
+ }
+}
+
+bool
+CompositeWindow::damaged ()
+{
+ return priv->damaged;
+}
+
+void
+CompositeWindow::processDamage (XDamageNotifyEvent *de)
+{
+ if (priv->window->syncWait ())
+ {
+ if (priv->nDamage == priv->sizeDamage)
+ {
+ priv->damageRects = (XRectangle *) realloc (priv->damageRects,
+ (priv->sizeDamage + 1) *
+ sizeof (XRectangle));
+ priv->sizeDamage += 1;
+ }
+
+ priv->damageRects[priv->nDamage].x = de->area.x;
+ priv->damageRects[priv->nDamage].y = de->area.y;
+ priv->damageRects[priv->nDamage].width = de->area.width;
+ priv->damageRects[priv->nDamage].height = de->area.height;
+ priv->nDamage++;
+ }
+ else
+ {
+ priv->handleDamageRect (this, de->area.x, de->area.y,
+ de->area.width, de->area.height);
+ }
+}
+
+void
+PrivateCompositeWindow::handleDamageRect (CompositeWindow *w,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ REGION region;
+ bool initial = false;
+
+ if (!w->priv->redirected)
+ return;
+
+ if (!w->priv->damaged)
+ {
+ w->priv->damaged = initial = true;
+ }
+
+ region.extents.x1 = x;
+ region.extents.y1 = y;
+ region.extents.x2 = region.extents.x1 + width;
+ region.extents.y2 = region.extents.y1 + height;
+
+ if (!w->damageRect (initial, &region.extents))
+ {
+ region.extents.x1 += w->priv->window->attrib ().x +
+ w->priv->window->attrib ().border_width;
+ region.extents.y1 += w->priv->window->attrib ().y +
+ w->priv->window->attrib ().border_width;
+ region.extents.x2 += w->priv->window->attrib ().x +
+ w->priv->window->attrib ().border_width;
+ region.extents.y2 += w->priv->window->attrib ().y +
+ w->priv->window->attrib ().border_width;
+
+ region.rects = &region.extents;
+ region.numRects = region.size = 1;
+
+ w->priv->cScreen->damageRegion (&region);
+ }
+
+ if (initial)
+ w->damageOutputExtents ();
+}
+
+void
+CompositeWindow::updateOpacity ()
+{
+ unsigned short opacity;
+
+ if (priv->window->type () & CompWindowTypeDesktopMask)
+ return;
+
+ opacity = priv->screen->display ()->getWindowProp32 (priv->window->id (),
+ priv->screen->display ()->atoms ().winOpacity, OPAQUE);
+
+ if (opacity != priv->opacity)
+ {
+ priv->opacity = opacity;
+ addDamage ();
+ }
+}
+
+void
+CompositeWindow::updateBrightness ()
+{
+ unsigned short brightness;
+
+ brightness = priv->screen->display ()->getWindowProp32 (priv->window->id (),
+ priv->screen->display ()->atoms ().winBrightness, BRIGHT);
+
+ if (brightness != priv->brightness)
+ {
+ priv->brightness = brightness;
+ addDamage ();
+ }
+}
+
+void
+CompositeWindow::updateSaturation ()
+{
+ unsigned short saturation;
+
+ saturation = priv->screen->display ()->getWindowProp32 (priv->window->id (),
+ priv->screen->display ()->atoms ().winSaturation, COLOR);
+
+ if (saturation != priv->saturation)
+ {
+ priv->saturation = saturation;
+ addDamage ();
+ }
+}
+
+unsigned short
+CompositeWindow::opacity ()
+{
+ return priv->opacity;
+}
+
+unsigned short
+CompositeWindow::brightness ()
+{
+ return priv->brightness;
+}
+
+unsigned short
+CompositeWindow::saturation ()
+{
+ return priv->saturation;
+}
+
+bool
+CompositeWindow::damageRect (bool initial,
+ BoxPtr rect)
+{
+ WRAPABLE_HND_FUNC_RETURN(bool, damageRect, initial, rect)
+ return false;
+}
+
+void
+PrivateCompositeWindow::windowNotify (CompWindowNotify n)
+{
+ switch (n)
+ {
+ case CompWindowNotifyMap:
+ bindFailed = false;
+ damaged = false;
+ break;
+ case CompWindowNotifyUnmap:
+ cWindow->addDamage ();
+ cWindow->release ();
+
+ if (!redirected && cScreen->compositingActive ())
+ cWindow->redirect ();
+ break;
+ case CompWindowNotifyRestack:
+ case CompWindowNotifyHide:
+ case CompWindowNotifyShow:
+ case CompWindowNotifyAliveChanged:
+ cWindow->addDamage ();
+ break;
+ case CompWindowNotifySyncAlarm:
+ {
+ XRectangle *rects;
+
+ rects = damageRects;
+ while (nDamage--)
+ {
+ PrivateCompositeWindow::handleDamageRect (cWindow,
+ rects[nDamage].x,
+ rects[nDamage].y,
+ rects[nDamage].width,
+ rects[nDamage].height);
+ }
+ break;
+ }
+ default:
+ break;
+
+ }
+
+ window->windowNotify (n);
+}
+
+void
+PrivateCompositeWindow::resizeNotify (int dx, int dy, int dwidth, int dheight)
+{
+ window->resizeNotify (dx, dy, dwidth, dheight);
+
+ Pixmap pixmap = None;
+
+ if (window->shaded () ||
+ (window->attrib ().map_state == IsViewable && damaged))
+ {
+ REGION region;
+
+ XWindowAttributes attrib = window->attrib ();
+ region.extents.x1 = attrib.x - window->output ().left - dx;
+ region.extents.y1 = attrib.y - window->output ().top - dy;
+ region.extents.x2 = attrib.x + window->width () +
+ window->output ().right - dx - dwidth;
+ region.extents.y2 = attrib.y + window->height () +
+ window->output ().bottom - dy - dheight;
+
+ region.rects = &region.extents;
+ region.numRects = region.size = 1;
+
+ cScreen->damageRegion (&region);
+ }
+
+ if (window->mapNum () && redirected)
+ {
+ unsigned int actualWidth, actualHeight, ui;
+ Window root;
+ Status result;
+ int i;
+
+ pixmap = XCompositeNameWindowPixmap (screen->display ()->dpy (),
+ window->id ());
+ result = XGetGeometry (screen->display ()->dpy (), pixmap, &root,
+ &i, &i, &actualWidth, &actualHeight,
+ &ui, &ui);
+
+ if (!result || (int) actualWidth != window->width () ||
+ (int) actualHeight != window->height ())
+ {
+ XFreePixmap (screen->display ()->dpy (), pixmap);
+ return;
+ }
+ }
+
+ cWindow->addDamage ();
+
+ cWindow->release ();
+ this->pixmap = pixmap;
+}
+
+void
+PrivateCompositeWindow::moveNotify (int dx, int dy, bool now)
+{
+ if (window->shaded () ||
+ (window->attrib ().map_state == IsViewable && damaged))
+ {
+ REGION region;
+
+ XWindowAttributes attrib = window->attrib ();
+ region.extents.x1 = attrib.x - window->output ().left - dx;
+ region.extents.y1 = attrib.y - window->output ().top - dy;
+ region.extents.x2 = attrib.x + window->width () +
+ window->output ().right - dx;
+ region.extents.y2 = attrib.y + window->height () +
+ window->output ().bottom - dy;
+
+
+
+ region.rects = &region.extents;
+ region.numRects = region.size = 1;
+
+ cScreen->damageRegion (&region);
+ }
+ cWindow->addDamage ();
+
+ window->moveNotify (dx, dy, now);
+}
+
+CompositeWindowInterface::CompositeWindowInterface ()
+{
+ WRAPABLE_INIT_FUNC(damageRect);
+}
+
+bool
+CompositeWindowInterface::damageRect (bool initial, BoxPtr rect)
+ WRAPABLE_DEF_FUNC_RETURN(damageRect, initial, rect)
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/move.cpp b/plugins/move.cpp
index 128ce82..ffa794c 100644
--- a/plugins/move.cpp
+++ b/plugins/move.cpp
@@ -32,6 +32,9 @@
#include <compiz-core.h>
#include <compprivatehandler.h>
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+
static CompMetadata *moveMetadata;
class MovePluginVTable : public CompPlugin::VTable
@@ -129,14 +132,16 @@ class MoveDisplay :
GLushort moveOpacity;
};
-
-
class MoveScreen : public PrivateHandler<MoveScreen,CompScreen> {
public:
MoveScreen (CompScreen *screen) :
PrivateHandler<MoveScreen,CompScreen> (screen),
- screen (screen) {};
+ screen (screen) {
+ if (CompositeScreen::get (screen))
+ hasCompositing =
+ CompositeScreen::get (screen)->compositingActive ();
+ };
CompScreen *screen;
CompScreen::grabHandle grab;
@@ -147,26 +152,34 @@ class MoveScreen : public PrivateHandler<MoveScreen,CompScreen> {
int snapOffY;
int snapBackY;
+
+ bool hasCompositing;
};
class MoveWindow :
- public WindowInterface,
+ public GLWindowInterface,
public PrivateHandler<MoveWindow,CompWindow>
{
public:
MoveWindow (CompWindow *window) :
PrivateHandler<MoveWindow,CompWindow> (window),
- window (window)
+ window (window),
+ gWindow (GLWindow::get (window)),
+ cWindow (CompositeWindow::get (window))
{
- window->add (this);
- WindowInterface::setHandler (window);
+ if (gWindow)
+ {
+ gWindow->add (this);
+ GLWindowInterface::setHandler (gWindow);
+ }
};
- bool
- paint (const CompWindowPaintAttrib *, const CompTransform *, Region,
- unsigned int);
+ bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &, Region,
+ unsigned int);
- CompWindow *window;
+ CompWindow *window;
+ GLWindow *gWindow;
+ CompositeWindow *cWindow;
};
#define MOVE_DISPLAY(d) \
@@ -277,7 +290,12 @@ moveInitiate (CompDisplay *d,
}
if (md->moveOpacity != OPAQUE)
- w->addDamage ();
+ {
+ MOVE_WINDOW (w);
+
+ if (mw->cWindow)
+ mw->cWindow->addDamage ();
+ }
}
}
@@ -317,7 +335,12 @@ moveTerminate (CompDisplay *d,
}
if (md->moveOpacity != OPAQUE)
- md->w->addDamage ();
+ {
+ MOVE_WINDOW (md->w);
+
+ if (mw->cWindow)
+ mw->cWindow->addDamage ();
+ }
md->w = 0;
md->releaseButton = 0;
@@ -606,7 +629,8 @@ moveHandleMotionEvent (CompScreen *s,
wY + dy - w->attrib ().y,
TRUE, FALSE);
- if (md->opt[MOVE_DISPLAY_OPTION_LAZY_POSITIONING].value ().b ())
+ if (md->opt[MOVE_DISPLAY_OPTION_LAZY_POSITIONING].value ().b () &&
+ MoveScreen::get (w->screen())->hasCompositing)
{
/* FIXME: This form of lazy positioning is broken and should
be replaced asap. Current code exists just to avoid a
@@ -788,13 +812,13 @@ MoveDisplay::handleEvent (XEvent *event)
}
bool
-MoveWindow::paint (const CompWindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
+MoveWindow::glPaint (const GLWindowPaintAttrib &attrib,
+ const GLMatrix &transform,
+ Region region,
+ unsigned int mask)
{
- CompWindowPaintAttrib sAttrib;
- bool status;
+ GLWindowPaintAttrib sAttrib = attrib;
+ bool status;
MOVE_SCREEN (window->screen ());
@@ -805,14 +829,11 @@ MoveWindow::paint (const CompWindowPaintAttrib *attrib,
if (md->w == window && md->moveOpacity != OPAQUE)
{
/* modify opacity of windows that are not active */
- sAttrib = *attrib;
- attrib = &sAttrib;
-
sAttrib.opacity = (sAttrib.opacity * md->moveOpacity) >> 16;
}
}
- status = window->paint (attrib, transform, region, mask);
+ status = gWindow->glPaint (sAttrib, transform, region, mask);
return status;
}
diff --git a/plugins/opengl/Makefile.am b/plugins/opengl/Makefile.am
new file mode 100644
index 0000000..f4b27f7
--- /dev/null
+++ b/plugins/opengl/Makefile.am
@@ -0,0 +1,36 @@
+libopengl_la_LDFLAGS = -avoid-version -no-undefined
+libopengl_la_LIBADD = $(top_builddir)/plugins/composite/libcomposite.la
+libopengl_la_SOURCES = \
+ opengl.cpp \
+ display.cpp \
+ screen.cpp \
+ window.cpp \
+ paint.cpp \
+ matrix.cpp \
+ vector.cpp \
+ texture.cpp \
+ fragment.cpp
+
+INCLUDES = \
+ @COMPIZ_CFLAGS@ \
+ @LIBPNG_CFLAGS@ \
+ @LIBRSVG_CFLAGS@ \
+ @ANNOTATE_CFLAGS@ \
+ @GCONF_CFLAGS@ \
+ @KCONFIG_CFLAGS@ \
+ @DBUS_CFLAGS@ \
+ @GLIB_CFLAGS@ \
+ @FUSE_CFLAGS@ \
+ -DFUSE_USE_VERSION=26 \
+ -DALL_LINGUAS="\"@ALL_LINGUAS@\"" \
+ -DLOCALEDIR="\"@datadir@/locale\"" \
+ -DPLUGINDIR=\"$(plugindir)\" \
+ -DIMAGEDIR=\"$(imagedir)\" \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -DMETADATADIR=\"$(metadatadir)\"
+
+moduledir = $(plugindir)
+
+module_LTLIBRARIES = \
+ libopengl.la
diff --git a/plugins/opengl/display.cpp b/plugins/opengl/display.cpp
new file mode 100644
index 0000000..e8ec03c
--- /dev/null
+++ b/plugins/opengl/display.cpp
@@ -0,0 +1,77 @@
+#include "privates.h"
+
+GLushort defaultColor[4] = { 0xffff, 0xffff, 0xffff, 0xffff };
+
+GLDisplay::GLDisplay (CompDisplay *d) :
+ OpenGLPrivateHandler<GLDisplay, CompDisplay, COMPIZ_OPENGL_ABI> (d),
+ priv (new PrivateGLDisplay (d, this))
+{
+ if (!glMetadata->initDisplayOptions (d, glDisplayOptionInfo,
+ GL_DISPLAY_OPTION_NUM, priv->opt))
+ {
+ setFailed ();
+ return;
+ }
+}
+
+GLDisplay::~GLDisplay ()
+{
+ delete priv;
+}
+
+PrivateGLDisplay::PrivateGLDisplay (CompDisplay *d,
+ GLDisplay *gd) :
+ display (d),
+ gDisplay (gd),
+ textureFilter (GL_LINEAR)
+{
+}
+
+PrivateGLDisplay::~PrivateGLDisplay ()
+{
+}
+
+GLenum
+GLDisplay::textureFilter ()
+{
+ return priv->textureFilter;
+}
+
+void
+PrivateGLDisplay::handleEvent (XEvent *event)
+{
+ CompScreen *s;
+ CompWindow *w;
+
+ display->handleEvent (event);
+
+ switch (event->type) {
+ case PropertyNotify:
+ if (event->xproperty.atom == display->atoms ().xBackground[0] ||
+ event->xproperty.atom == display->atoms ().xBackground[1])
+ {
+ s = display->findScreen (event->xproperty.window);
+ if (s)
+ GLScreen::get (s)->updateBackground ();
+ }
+ else if (event->xproperty.atom == display->atoms ().winOpacity ||
+ event->xproperty.atom == display->atoms ().winBrightness ||
+ event->xproperty.atom == display->atoms ().winSaturation)
+ {
+ w = display->findWindow (event->xproperty.window);
+ if (w)
+ GLWindow::get (w)->updatePaintAttribs ();
+ }
+ break;
+ break;
+ default:
+ break;
+ }
+}
+
+void
+GLDisplay::clearTargetOutput (unsigned int mask)
+{
+ if (targetScreen)
+ targetScreen->clearOutput (targetOutput, mask);
+}
diff --git a/src/fragment.cpp b/plugins/opengl/fragment.cpp
index f5ccb9a..e1f9349 100644
--- a/src/fragment.cpp
+++ b/plugins/opengl/fragment.cpp
@@ -29,10 +29,11 @@
#define foreach BOOST_FOREACH
#include <compiz-core.h>
-#include <comptexture.h>
-#include <compfragment.h>
+#include <opengl/texture.h>
+#include <opengl/fragment.h>
#include <compscreen.h>
#include "privatefragment.h"
+#include "privates.h"
#include <string.h>
#include <stdlib.h>
@@ -44,11 +45,11 @@
#define COMP_FUNCTION_ARB_MASK (1 << 0)
#define COMP_FUNCTION_MASK (COMP_FUNCTION_ARB_MASK)
-namespace CompFragment {
+namespace GLFragment {
class Program {
public:
- Program (CompScreen *s) :
+ Program (GLScreen *s) :
s (s),
signature (0),
blending (false),
@@ -62,7 +63,7 @@ namespace CompFragment {
};
public:
- CompScreen *s;
+ GLScreen *s;
std::list<FunctionId> signature;
@@ -189,7 +190,7 @@ namespace CompFragment {
static InitialLoadFunction initialLoadFunction;
static Function *
- findFragmentFunction (CompScreen *s,
+ findFragmentFunction (GLScreen *s,
FunctionId id)
{
foreach (Function *f, s->fragmentStorage ()->functions)
@@ -199,7 +200,7 @@ namespace CompFragment {
}
static Function *
- findFragmentFunctionWithName (CompScreen *s,
+ findFragmentFunctionWithName (GLScreen *s,
CompString name)
{
foreach (Function *f, s->fragmentStorage ()->functions)
@@ -209,9 +210,9 @@ namespace CompFragment {
}
static Program *
- findFragmentProgram (CompScreen *s,
- FunctionId *signature,
- unsigned int nSignature)
+ findFragmentProgram (GLScreen *s,
+ FunctionId *signature,
+ unsigned int nSignature)
{
unsigned int i;
@@ -510,7 +511,7 @@ namespace CompFragment {
}
static Program *
- buildFragmentProgram (CompScreen *s,
+ buildFragmentProgram (GLScreen *s,
PrivateAttrib *attrib)
{
Program *program;
@@ -594,7 +595,7 @@ namespace CompFragment {
}
static GLuint
- getFragmentProgram (CompScreen *s,
+ getFragmentProgram (GLScreen *s,
PrivateAttrib *attrib,
GLenum *type,
bool *blending)
@@ -822,7 +823,7 @@ namespace CompFragment {
}
FunctionId
- FunctionData::createFragmentFunction (CompScreen *s, const char *name)
+ FunctionData::createFragmentFunction (GLScreen *s, const char *name)
{
Function *function = new Function ();
CompString validName = name;
@@ -846,12 +847,12 @@ namespace CompFragment {
return function->id;
}
- Attrib::Attrib (const CompWindowPaintAttrib *paint) :
+ Attrib::Attrib (const GLWindowPaintAttrib &paint) :
priv (new PrivateAttrib ())
{
- priv->opacity = paint->opacity;
- priv->brightness = paint->brightness;
- priv->saturation = paint->saturation;
+ priv->opacity = paint.opacity;
+ priv->brightness = paint.brightness;
+ priv->saturation = paint.saturation;
priv->nTexture = 0;
priv->nFunction = 0;
priv->nParam = 0;
@@ -908,7 +909,7 @@ namespace CompFragment {
}
bool
- Attrib::enable (CompScreen *s, bool *blending)
+ Attrib::enable (GLScreen *s, bool *blending)
{
GLuint name;
GLenum type;
@@ -931,7 +932,7 @@ namespace CompFragment {
}
void
- Attrib::disable (CompScreen *s)
+ Attrib::disable (GLScreen *s)
{
glDisable (GL_FRAGMENT_PROGRAM_ARB);
}
@@ -979,7 +980,7 @@ namespace CompFragment {
return priv->nFunction > 0;
}
- void destroyFragmentFunction (CompScreen *s, FunctionId id)
+ void destroyFragmentFunction (GLScreen *s, FunctionId id)
{
Function *function;
Program *program;
@@ -1022,8 +1023,8 @@ namespace CompFragment {
}
FunctionId
- getSaturateFragmentFunction (CompScreen *s,
- CompTexture *texture,
+ getSaturateFragmentFunction (GLScreen *s,
+ GLTexture *texture,
int param)
{
int target;
diff --git a/plugins/opengl/icon.cpp b/plugins/opengl/icon.cpp
new file mode 100644
index 0000000..f15a278
--- /dev/null
+++ b/plugins/opengl/icon.cpp
@@ -0,0 +1,49 @@
+#include <compicon.h>
+
+CompIcon::CompIcon (CompScreen *screen, unsigned int width,
+ unsigned int height) :
+ mTexture (screen),
+ mWidth (width),
+ mHeight (height),
+ mData (new unsigned char[width * height * 4]),
+ mUpdateTex (true)
+{
+}
+
+CompIcon::~CompIcon ()
+{
+ free (mData);
+}
+
+CompTexture &
+CompIcon::texture ()
+{
+ if (mUpdateTex)
+ {
+ mUpdateTex = false;
+ mTexture.reset ();
+ if (!mTexture.imageBufferToTexture (&mTexture,
+ reinterpret_cast<const char *> (mData), mWidth, mHeight))
+ mTexture.reset ();
+ }
+ return mTexture;
+}
+
+unsigned int
+CompIcon::width ()
+{
+ return mWidth;
+}
+
+unsigned int
+CompIcon::height ()
+{
+ return mHeight;
+}
+
+unsigned char*
+CompIcon::data ()
+{
+ mUpdateTex = true;
+ return mData;
+}
diff --git a/src/matrix.cpp b/plugins/opengl/matrix.cpp
index 4718b69..02efb3c 100644
--- a/src/matrix.cpp
+++ b/plugins/opengl/matrix.cpp
@@ -25,7 +25,7 @@
#include <string.h>
#include <math.h>
#include <compiz-core.h>
-#include <compmatrix.h>
+#include <opengl/matrix.h>
/**
* Identity matrix.
@@ -72,47 +72,47 @@ matmul4 (float *product,
}
}
-CompMatrix::CompMatrix ()
+GLMatrix::GLMatrix ()
{
memcpy (m, identity, sizeof (m));
}
void
-CompMatrix::reset ()
+GLMatrix::reset ()
{
memcpy (m, identity, sizeof (m));
}
const float *
-CompMatrix::getMatrix () const
+GLMatrix::getMatrix () const
{
return m;
}
-CompMatrix&
-CompMatrix::operator*= (const CompMatrix& rhs)
+GLMatrix&
+GLMatrix::operator*= (const GLMatrix& rhs)
{
*this = *this * rhs;
return *this;
}
-CompMatrix
-operator* (const CompMatrix& lhs,
- const CompMatrix& rhs)
+GLMatrix
+operator* (const GLMatrix& lhs,
+ const GLMatrix& rhs)
{
- CompMatrix result;
+ GLMatrix result;
matmul4 (result.m, lhs.m, rhs.m);
return result;
}
-CompVector
-operator* (const CompMatrix& lhs,
- const CompVector& rhs)
+GLVector
+operator* (const GLMatrix& lhs,
+ const GLVector& rhs)
{
- CompVector result;
+ GLVector result;
const float *a = lhs.m;
int i;
@@ -138,7 +138,7 @@ operator* (const CompMatrix& lhs,
* Optimizations contributed by Rudolf Opalla (rudi@khm.de).
*/
void
-CompMatrix::rotate (const float angle,
+GLMatrix::rotate (const float angle,
const float xRot,
const float yRot,
const float zRot)
@@ -325,13 +325,13 @@ CompMatrix::rotate (const float angle,
}
void
-CompMatrix::rotate (const float angle,
- const CompVector& vector)
+GLMatrix::rotate (const float angle,
+ const GLVector& vector)
{
rotate (angle,
- vector[CompVector::x],
- vector[CompVector::y],
- vector[CompVector::z]);
+ vector[GLVector::x],
+ vector[GLVector::y],
+ vector[GLVector::z]);
}
/**
@@ -345,7 +345,7 @@ CompMatrix::rotate (const float angle,
* Multiplies in-place the elements of \p matrix by the scale factors.
*/
void
-CompMatrix::scale (const float x,
+GLMatrix::scale (const float x,
const float y,
const float z)
{
@@ -356,11 +356,11 @@ CompMatrix::scale (const float x,
}
void
-CompMatrix::scale (const CompVector& vector)
+GLMatrix::scale (const GLVector& vector)
{
- scale (vector[CompVector::x],
- vector[CompVector::y],
- vector[CompVector::z]);
+ scale (vector[GLVector::x],
+ vector[GLVector::y],
+ vector[GLVector::z]);
}
/**
@@ -374,7 +374,7 @@ CompMatrix::scale (const CompVector& vector)
* Adds the translation coordinates to the elements of \p matrix in-place.
*/
void
-CompMatrix::translate (const float x,
+GLMatrix::translate (const float x,
const float y,
const float z)
{
@@ -385,15 +385,15 @@ CompMatrix::translate (const float x,
}
void
-CompMatrix::translate (const CompVector& vector)
+GLMatrix::translate (const GLVector& vector)
{
- translate (vector[CompVector::x],
- vector[CompVector::y],
- vector[CompVector::z]);
+ translate (vector[GLVector::x],
+ vector[GLVector::y],
+ vector[GLVector::z]);
}
void
-CompMatrix::toScreenSpace (CompOutput *output,
+GLMatrix::toScreenSpace (CompOutput *output,
float z)
{
translate (-0.5f, -0.5f, z);
diff --git a/plugins/opengl/opengl.cpp b/plugins/opengl/opengl.cpp
new file mode 100644
index 0000000..48eaa4b
--- /dev/null
+++ b/plugins/opengl/opengl.cpp
@@ -0,0 +1,264 @@
+#include <compiz-core.h>
+#include <compprivatehandler.h>
+#include "privates.h"
+
+const CompMetadata::OptionInfo glDisplayOptionInfo[GL_DISPLAY_OPTION_NUM] = {
+ { "texture_filter", "int", RESTOSTRING (0, 2), 0, 0 },
+};
+
+const CompMetadata::OptionInfo glScreenOptionInfo[GL_SCREEN_OPTION_NUM] = {
+ { "lighting", "bool", 0, 0, 0 },
+ { "sync_to_vblank", "bool", 0, 0, 0 },
+ { "texture_compression", "bool", 0, 0, 0 },
+};
+
+CompOption::Vector &
+GLDisplay::getOptions ()
+{
+ return priv->opt;
+}
+
+CompOption::Vector &
+GLScreen::getOptions ()
+{
+ return priv->opt;
+}
+
+bool
+GLDisplay::setOption (const char *name,
+ CompOption::Value &value)
+{
+ CompOption *o;
+ unsigned int index;
+
+ o = CompOption::findOption (priv->opt, name, &index);
+ if (!o)
+ return false;
+
+ switch (index) {
+ case GL_DISPLAY_OPTION_TEXTURE_FILTER:
+ if (o->set (value))
+ {
+ foreach (CompScreen *s, priv->display->screens ())
+ CompositeScreen::get (s)->damageScreen ();
+
+ if (!o->value ().i ())
+ priv->textureFilter = GL_NEAREST;
+ else
+ priv->textureFilter = GL_LINEAR;
+
+ return true;
+ }
+ break;
+ default:
+ if (CompOption::setDisplayOption (priv->display, *o, value))
+ return true;
+ break;
+ }
+
+ return false;
+}
+
+bool
+GLScreen::setOption (const char *name,
+ CompOption::Value &value)
+{
+ CompOption *o;
+ unsigned int index;
+
+ o = CompOption::findOption (priv->opt, name, &index);
+ if (!o)
+ return false;
+
+ return CompOption::setScreenOption (priv->screen, *o, value);
+}
+
+CompMetadata *glMetadata;
+
+class OpenglPluginVTable : public CompPlugin::VTable
+{
+ public:
+
+ const char *
+ name () { return "opengl"; };
+
+ CompMetadata *
+ getMetadata ();
+
+ virtual bool
+ init ();
+
+ virtual void
+ fini ();
+
+ virtual bool
+ initObject (CompObject *object);
+
+ virtual void
+ finiObject (CompObject *object);
+
+ CompOption::Vector &
+ getObjectOptions (CompObject *object);
+
+ bool
+ setObjectOption (CompObject *object,
+ const char *name,
+ CompOption::Value &value);
+};
+
+bool
+OpenglPluginVTable::initObject (CompObject *o)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ {
+ GLDisplay *d = new GLDisplay (GET_CORE_DISPLAY (o));
+ if (!d)
+ return false;
+ if (d->loadFailed ())
+ {
+ delete d;
+ return false;
+ }
+ return true;
+ }
+ break;
+ case COMP_OBJECT_TYPE_SCREEN:
+ {
+ GLScreen *s = new GLScreen (GET_CORE_SCREEN (o));
+ if (!s)
+ return false;
+ if (s->loadFailed ())
+ {
+ delete s;
+ return false;
+ }
+ return true;
+ }
+ break;
+ case COMP_OBJECT_TYPE_WINDOW:
+ {
+ GLWindow *w = new GLWindow (GET_CORE_WINDOW (o));
+ if (!w)
+ return false;
+ if (w->loadFailed ())
+ {
+ delete w;
+ return false;
+ }
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
+void
+OpenglPluginVTable::finiObject (CompObject *o)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ {
+ GLDisplay *d = GLDisplay::get (GET_CORE_DISPLAY (o));
+ if (d)
+ delete d;
+ }
+ break;
+ case COMP_OBJECT_TYPE_SCREEN:
+ {
+ GLScreen *s = GLScreen::get (GET_CORE_SCREEN (o));
+ if (s)
+ delete s;
+ }
+ break;
+ case COMP_OBJECT_TYPE_WINDOW:
+ {
+ GLWindow *w = GLWindow::get (GET_CORE_WINDOW (o));
+ if (w)
+ delete w;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+CompOption::Vector &
+OpenglPluginVTable::getObjectOptions (CompObject *o)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ return GLDisplay::get (GET_CORE_DISPLAY (o))->getOptions ();
+ case COMP_OBJECT_TYPE_SCREEN:
+ return GLScreen::get (GET_CORE_SCREEN (o))->getOptions ();
+ default:
+ break;
+ }
+ return noOptions;
+}
+
+bool
+OpenglPluginVTable::setObjectOption (CompObject *o,
+ const char *name,
+ CompOption::Value &value)
+{
+ switch (o->objectType ())
+ {
+ case COMP_OBJECT_TYPE_DISPLAY:
+ return GLDisplay::get (GET_CORE_DISPLAY (o))->
+ setOption (name, value);
+ case COMP_OBJECT_TYPE_SCREEN:
+ return GLScreen::get (GET_CORE_SCREEN (o))->setOption (name, value);
+ default:
+ break;
+ }
+ return false;
+}
+
+bool
+OpenglPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
+ return false;
+
+ CompPrivate p;
+ p.uval = COMPIZ_OPENGL_ABI;
+ core->storeValue ("opengl_ABI", p);
+
+ glMetadata = new CompMetadata
+ (name (), glDisplayOptionInfo, GL_DISPLAY_OPTION_NUM,
+ glScreenOptionInfo, GL_SCREEN_OPTION_NUM);
+
+ if (!glMetadata)
+ return false;
+
+ glMetadata->addFromFile (name ());
+
+ return true;
+}
+
+void
+OpenglPluginVTable::fini ()
+{
+ delete glMetadata;
+}
+
+CompMetadata *
+OpenglPluginVTable::getMetadata ()
+{
+ return glMetadata;
+}
+
+OpenglPluginVTable openglVTable;
+
+CompPlugin::VTable *
+getCompPluginInfo20080805 (void)
+{
+ return &openglVTable;
+}
diff --git a/src/paint.cpp b/plugins/opengl/paint.cpp
index c2e6f4e..0953620 100644
--- a/src/paint.cpp
+++ b/plugins/opengl/paint.cpp
@@ -31,57 +31,50 @@
#define foreach BOOST_FOREACH
#include <compiz-core.h>
+#include <opengl/opengl.h>
-#include "privatescreen.h"
-#include "privatewindow.h"
+#include "privates.h"
-CompScreenPaintAttrib defaultScreenPaintAttrib = {
+
+GLScreenPaintAttrib defaultScreenPaintAttrib = {
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA
};
-CompWindowPaintAttrib defaultWindowPaintAttrib = {
+GLWindowPaintAttrib defaultWindowPaintAttrib = {
OPAQUE, BRIGHT, COLOR, 1.0f, 1.0f, 0.0f, 0.0f
};
void
-CompScreen::preparePaint (int msSinceLastPaint)
- WRAPABLE_HND_FUNC(preparePaint, msSinceLastPaint)
-
-void
-CompScreen::donePaint ()
- WRAPABLE_HND_FUNC(donePaint)
-
-void
-CompScreen::applyTransform (const CompScreenPaintAttrib *sAttrib,
- CompOutput *output,
- CompTransform *transform)
+GLScreen::glApplyTransform (const GLScreenPaintAttrib &sAttrib,
+ CompOutput *output,
+ GLMatrix *transform)
{
- WRAPABLE_HND_FUNC(applyTransform, sAttrib, output, transform)
-
- transform->translate (sAttrib->xTranslate,
- sAttrib->yTranslate,
- sAttrib->zTranslate + sAttrib->zCamera);
- transform->rotate (sAttrib->xRotate, 0.0f, 1.0f, 0.0f);
- transform->rotate (sAttrib->vRotate,
- cosf (sAttrib->xRotate * DEG2RAD),
+ WRAPABLE_HND_FUNC(glApplyTransform, sAttrib, output, transform)
+
+ transform->translate (sAttrib.xTranslate,
+ sAttrib.yTranslate,
+ sAttrib.zTranslate + sAttrib.zCamera);
+ transform->rotate (sAttrib.xRotate, 0.0f, 1.0f, 0.0f);
+ transform->rotate (sAttrib.vRotate,
+ cosf (sAttrib.xRotate * DEG2RAD),
0.0f,
- sinf (sAttrib->xRotate * DEG2RAD));
- transform->rotate (sAttrib->yRotate, 0.0f, 1.0f, 0.0f);
+ sinf (sAttrib.xRotate * DEG2RAD));
+ transform->rotate (sAttrib.yRotate, 0.0f, 1.0f, 0.0f);
}
void
-PrivateScreen::paintBackground (Region region,
- bool transformed)
+PrivateGLScreen::paintBackground (Region region,
+ bool transformed)
{
- CompTexture *bg = &backgroundTexture;
- BoxPtr pBox = region->rects;
- int n, nBox = region->numRects;
- GLfloat *d, *data;
+ GLTexture *bg = &backgroundTexture;
+ BoxPtr pBox = region->rects;
+ int n, nBox = region->numRects;
+ GLfloat *d, *data;
if (!nBox)
return;
- if (desktopWindowCount)
+ if (screen->desktopWindowCount ())
{
if (bg->name ())
{
@@ -141,9 +134,9 @@ PrivateScreen::paintBackground (Region region,
if (bg->name ())
{
if (transformed)
- bg->enable (CompTexture::Good);
+ bg->enable (GLTexture::Good);
else
- bg->enable (CompTexture::Fast);
+ bg->enable (GLTexture::Fast);
glDrawArrays (GL_QUADS, 0, nBox * 4);
@@ -168,24 +161,28 @@ PrivateScreen::paintBackground (Region region,
transformed screen case should be made optional for those who do
see a difference. */
void
-PrivateScreen::paintOutputRegion (const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
+PrivateGLScreen::paintOutputRegion (const GLMatrix &transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
static Region tmpRegion = NULL;
CompWindow *w;
+ GLWindow *gw;
int count, windowMask, odMask;
CompWindow *fullscreenWindow = NULL;
- bool status;
+ bool status, unredirectFS;
bool withOffset = false;
- CompTransform vTransform;
+ GLMatrix vTransform;
int offX, offY;
Region clip = region;
CompWindowList pl;
CompWindowList::reverse_iterator rit;
+ unredirectFS = CompositeScreen::get (screen)->
+ getOption("unredirect_fullscreen_windows")->value ().b ();
+
if (!tmpRegion)
{
tmpRegion = XCreateRegion ();
@@ -206,7 +203,7 @@ PrivateScreen::paintOutputRegion (const CompTransform *transform,
XSubtractRegion (region, &emptyRegion, tmpRegion);
- pl = screen->getWindowPaintList ();
+ pl = cScreen->getWindowPaintList ();
if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
{
@@ -214,44 +211,47 @@ PrivateScreen::paintOutputRegion (const CompTransform *transform,
for (rit = pl.rbegin (); rit != pl.rend(); rit++)
{
w = (*rit);
+ gw = GLWindow::get (w);
if (w->destroyed ())
continue;
if (!w->shaded ())
{
- if (w->attrib ().map_state != IsViewable || !w->damaged ())
+ if (w->attrib ().map_state != IsViewable ||
+ !CompositeWindow::get (w)->damaged ())
continue;
}
/* copy region */
- XSubtractRegion (tmpRegion, &emptyRegion, w->clip ());
+ XSubtractRegion (tmpRegion, &emptyRegion, gw->clip ());
odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;
- if ((windowPaintOffset.x () != 0 || windowPaintOffset.x () != 0) &&
+ if ((cScreen->windowPaintOffset ().x () != 0 ||
+ cScreen->windowPaintOffset ().x () != 0) &&
!w->onAllViewports ())
{
withOffset = true;
- w->getMovementForOffset (windowPaintOffset.x (),
- windowPaintOffset.y (),
+ w->getMovementForOffset (cScreen->windowPaintOffset ().x (),
+ cScreen->windowPaintOffset ().y (),
&offX, &offY);
- vTransform = *transform;
+ vTransform = transform;
vTransform.translate (offX, offY, 0);
- XOffsetRegion (w->clip (), -offX, -offY);
+ XOffsetRegion (gw->clip (), -offX, -offY);
odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
- status = w->paint (&w->paintAttrib (), &vTransform,
- tmpRegion, odMask);
+ status = gw->glPaint (gw->paintAttrib (), vTransform,
+ tmpRegion, odMask);
}
else
{
withOffset = false;
- status = w->paint (&w->paintAttrib (), transform, tmpRegion,
- odMask);
+ status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion,
+ odMask);
}
if (status)
@@ -266,19 +266,17 @@ PrivateScreen::paintOutputRegion (const CompTransform *transform,
XSubtractRegion (tmpRegion, w->region (), tmpRegion);
/* unredirect top most fullscreen windows. */
- if (count == 0 &&
- opt[COMP_SCREEN_OPTION_UNREDIRECT_FS].value ().b ())
+ if (count == 0 && unredirectFS)
{
- if (XEqualRegion (w->region (), &this->region) &&
+ if (XEqualRegion (w->region (), screen->region ()) &&
!REGION_NOT_EMPTY (tmpRegion))
{
fullscreenWindow = w;
}
else
{
- for (unsigned int i = 0; i < outputDevs.size (); i++)
- if (XEqualRegion (w->region (),
- outputDevs[i].region ()))
+ foreach (CompOutput &o, screen->outputDevs ())
+ if (XEqualRegion (w->region (), o.region ()))
fullscreenWindow = w;
}
}
@@ -289,7 +287,7 @@ PrivateScreen::paintOutputRegion (const CompTransform *transform,
}
if (fullscreenWindow)
- fullscreenWindow->unredirect ();
+ CompositeWindow::get (fullscreenWindow)->unredirect ();
if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
paintBackground (tmpRegion, (mask & PAINT_SCREEN_TRANSFORMED_MASK));
@@ -305,40 +303,44 @@ PrivateScreen::paintOutputRegion (const CompTransform *transform,
if (!w->shaded ())
{
- if (w->attrib ().map_state != IsViewable || !w->damaged ())
+ if (w->attrib ().map_state != IsViewable ||
+ !CompositeWindow::get (w)->damaged ())
continue;
}
+ gw = GLWindow::get (w);
+
if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
- clip = w->clip ();
+ clip = gw->clip ();
- if ((windowPaintOffset.x () != 0 || windowPaintOffset.y () != 0) &&
+ if ((cScreen->windowPaintOffset ().x () != 0 ||
+ cScreen->windowPaintOffset ().y () != 0) &&
!w->onAllViewports ())
{
- w->getMovementForOffset (windowPaintOffset.x (),
- windowPaintOffset.y (),
+ w->getMovementForOffset (cScreen->windowPaintOffset ().x (),
+ cScreen->windowPaintOffset ().y (),
&offX, &offY);
- vTransform = *transform;
+ vTransform = transform;
vTransform.translate (offX, offY, 0);
- w->paint (&w->paintAttrib (), &vTransform, clip,
- windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
+ gw->glPaint (gw->paintAttrib (), vTransform, clip,
+ windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
}
else
{
- w->paint (&w->paintAttrib (), transform, clip, windowMask);
+ gw->glPaint (gw->paintAttrib (), transform, clip, windowMask);
}
}
}
void
-CompScreen::enableOutputClipping (const CompTransform *transform,
- Region region,
- CompOutput *output)
+GLScreen::glEnableOutputClipping (const GLMatrix &transform,
+ Region region,
+ CompOutput *output)
{
- WRAPABLE_HND_FUNC(enableOutputClipping, transform, region, output)
+ WRAPABLE_HND_FUNC(glEnableOutputClipping, transform, region, output)
- GLdouble h = priv->size.height ();
+ GLdouble h = priv->screen->size ().height ();
GLdouble p1[2] = { region->extents.x1, h - region->extents.y2 };
GLdouble p2[2] = { region->extents.x2, h - region->extents.y1 };
@@ -355,7 +357,7 @@ CompScreen::enableOutputClipping (const CompTransform *transform,
GLdouble right[4] = { halfW / (cx - p2[0]), 0.0, 0.0, 0.5 };
glPushMatrix ();
- glLoadMatrixf (transform->getMatrix ());
+ glLoadMatrixf (transform.getMatrix ());
glClipPlane (GL_CLIP_PLANE0, top);
glClipPlane (GL_CLIP_PLANE1, bottom);
@@ -371,9 +373,9 @@ CompScreen::enableOutputClipping (const CompTransform *transform,
}
void
-CompScreen::disableOutputClipping ()
+GLScreen::glDisableOutputClipping ()
{
- WRAPABLE_HND_FUNC(disableOutputClipping)
+ WRAPABLE_HND_FUNC(glDisableOutputClipping)
glDisable (GL_CLIP_PLANE0);
glDisable (GL_CLIP_PLANE1);
@@ -385,63 +387,64 @@ CompScreen::disableOutputClipping ()
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
void
-CompScreen::paintTransformedOutput (const CompScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
+GLScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &sAttrib,
+ const GLMatrix &transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
- WRAPABLE_HND_FUNC(paintTransformedOutput, sAttrib, transform,
+ WRAPABLE_HND_FUNC(glPaintTransformedOutput, sAttrib, transform,
region, output, mask)
- CompTransform sTransform = *transform;
+ GLMatrix sTransform = transform;
if (mask & PAINT_SCREEN_CLEAR_MASK)
- priv->display->clearTargetOutput (GL_COLOR_BUFFER_BIT);
+ GLDisplay::get (priv->screen->display ())
+ ->clearTargetOutput (GL_COLOR_BUFFER_BIT);
setLighting (true);
- applyTransform (sAttrib, output, &sTransform);
+ glApplyTransform (sAttrib, output, &sTransform);
if ((mask & CLIP_PLANE_MASK) == CLIP_PLANE_MASK)
{
- enableOutputClipping (&sTransform, region, output);
+ glEnableOutputClipping (sTransform, region, output);
- sTransform.toScreenSpace (output, -sAttrib->zTranslate);
+ sTransform.toScreenSpace (output, -sAttrib.zTranslate);
glPushMatrix ();
glLoadMatrixf (sTransform.getMatrix ());
- priv->paintOutputRegion (&sTransform, region, output, mask);
+ priv->paintOutputRegion (sTransform, region, output, mask);
glPopMatrix ();
- disableOutputClipping ();
+ glDisableOutputClipping ();
}
else
{
- sTransform.toScreenSpace (output, -sAttrib->zTranslate);
+ sTransform.toScreenSpace (output, -sAttrib.zTranslate);
glPushMatrix ();
glLoadMatrixf (sTransform.getMatrix ());
- priv->paintOutputRegion (&sTransform, region, output, mask);
+ priv->paintOutputRegion (sTransform, region, output, mask);
glPopMatrix ();
}
}
bool
-CompScreen::paintOutput (const CompScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
+GLScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
+ const GLMatrix &transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
- WRAPABLE_HND_FUNC_RETURN(bool, paintOutput, sAttrib, transform,
+ WRAPABLE_HND_FUNC_RETURN(bool, glPaintOutput, sAttrib, transform,
region, output, mask)
- CompTransform sTransform = *transform;
+ GLMatrix sTransform = transform;
if (mask & PAINT_SCREEN_REGION_MASK)
{
@@ -450,8 +453,8 @@ CompScreen::paintOutput (const CompScreenPaintAttrib *sAttrib,
if (mask & PAINT_SCREEN_FULL_MASK)
{
region = output->region ();
- paintTransformedOutput (sAttrib, &sTransform, region,
- output, mask);
+ glPaintTransformedOutput (sAttrib, sTransform, region,
+ output, mask);
return true;
}
@@ -463,8 +466,8 @@ CompScreen::paintOutput (const CompScreenPaintAttrib *sAttrib,
}
else if (mask & PAINT_SCREEN_FULL_MASK)
{
- paintTransformedOutput (sAttrib, &sTransform, output->region (),
- output, mask);
+ glPaintTransformedOutput (sAttrib, sTransform, output->region (),
+ output, mask);
return true;
}
@@ -478,7 +481,7 @@ CompScreen::paintOutput (const CompScreenPaintAttrib *sAttrib,
glPushMatrix ();
glLoadMatrixf (sTransform.getMatrix ());
- priv->paintOutputRegion (&sTransform, region, output, mask);
+ priv->paintOutputRegion (sTransform, region, output, mask);
glPopMatrix ();
@@ -555,7 +558,7 @@ CompScreen::paintOutput (const CompScreenPaintAttrib *sAttrib,
bool
-CompWindow::moreVertices (int newSize)
+GLWindow::moreVertices (int newSize)
{
if (newSize > priv->vertexSize)
{
@@ -574,7 +577,7 @@ CompWindow::moreVertices (int newSize)
}
bool
-CompWindow::moreIndices (int newSize)
+GLWindow::moreIndices (int newSize)
{
if (newSize > priv->indexSize)
{
@@ -593,9 +596,9 @@ CompWindow::moreIndices (int newSize)
}
void
-CompWindow::drawGeometry ()
+GLWindow::glDrawGeometry ()
{
- WRAPABLE_HND_FUNC(drawGeometry)
+ WRAPABLE_HND_FUNC(glDrawGeometry)
int texUnit = priv->texUnits;
int currentTexUnit = 0;
@@ -610,7 +613,7 @@ CompWindow::drawGeometry ()
{
if (texUnit != currentTexUnit)
{
- (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
+ (*priv->gScreen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
currentTexUnit = texUnit;
}
@@ -626,21 +629,21 @@ CompWindow::drawGeometry ()
{
while (--texUnit)
{
- (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
+ (*priv->gScreen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
}
- (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB);
+ (*priv->gScreen->clientActiveTexture) (GL_TEXTURE0_ARB);
}
}
void
-CompWindow::addGeometry (CompTexture::Matrix *matrix,
- int nMatrix,
- Region region,
- Region clip)
+GLWindow::glAddGeometry (GLTexture::Matrix *matrix,
+ int nMatrix,
+ Region region,
+ Region clip)
{
- WRAPABLE_HND_FUNC(addGeometry, matrix, nMatrix, region, clip)
+ WRAPABLE_HND_FUNC(glAddGeometry, matrix, nMatrix, region, clip)
BoxRec full;
@@ -781,34 +784,34 @@ CompWindow::addGeometry (CompTexture::Matrix *matrix,
}
static bool
-enableFragmentProgramAndDrawGeometry (CompWindow *w,
- CompTexture *texture,
- CompFragment::Attrib &attrib,
- CompTexture::Filter filter,
- unsigned int mask)
+enableFragmentProgramAndDrawGeometry (GLScreen *gs,
+ GLWindow *w,
+ GLTexture *texture,
+ GLFragment::Attrib &attrib,
+ GLTexture::Filter filter,
+ unsigned int mask)
{
- CompFragment::Attrib fa (attrib);
- CompScreen *s = w->screen ();
- bool blending;
+ GLFragment::Attrib fa (attrib);
+ bool blending;
- if (s->canDoSaturated () && attrib.getSaturation () != COLOR)
+ if (gs->canDoSaturated () && attrib.getSaturation () != COLOR)
{
int param, function;
param = fa.allocParameters (1);
function =
- CompFragment::getSaturateFragmentFunction (s, texture, param);
+ GLFragment::getSaturateFragmentFunction (gs, texture, param);
fa.addFunction (function);
- (*s->programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
- RED_SATURATION_WEIGHT,
- GREEN_SATURATION_WEIGHT,
- BLUE_SATURATION_WEIGHT,
- attrib.getSaturation () / 65535.0f);
+ (*gs->programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
+ RED_SATURATION_WEIGHT,
+ GREEN_SATURATION_WEIGHT,
+ BLUE_SATURATION_WEIGHT,
+ attrib.getSaturation () / 65535.0f);
}
- if (!fa.enable (s, &blending))
+ if (!fa.enable (gs, &blending))
return false;
texture->enable (filter);
@@ -824,17 +827,17 @@ enableFragmentProgramAndDrawGeometry (CompWindow *w,
color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
- s->setTexEnvMode (GL_MODULATE);
+ gs->setTexEnvMode (GL_MODULATE);
glColor4us (color, color, color, attrib.getOpacity ());
- w->drawGeometry ();
+ w->glDrawGeometry ();
glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
+ gs->setTexEnvMode (GL_REPLACE);
}
else
{
- w->drawGeometry ();
+ w->glDrawGeometry ();
}
if (blending)
@@ -842,37 +845,36 @@ enableFragmentProgramAndDrawGeometry (CompWindow *w,
}
else if (attrib.getBrightness () != BRIGHT)
{
- s->setTexEnvMode (GL_MODULATE);
+ gs->setTexEnvMode (GL_MODULATE);
glColor4us (attrib.getBrightness (), attrib.getBrightness (),
attrib.getBrightness (), BRIGHT);
- w->drawGeometry ();
+ w->glDrawGeometry ();
glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
+ gs->setTexEnvMode (GL_REPLACE);
}
else
{
- w->drawGeometry ();
+ w->glDrawGeometry ();
}
texture->disable ();
- fa.disable (s);
+ fa.disable (gs);
return true;
}
static void
-enableFragmentOperationsAndDrawGeometry (CompWindow *w,
- CompTexture *texture,
- CompFragment::Attrib &attrib,
- CompTexture::Filter filter,
- unsigned int mask)
+enableFragmentOperationsAndDrawGeometry (GLScreen *gs,
+ GLWindow *w,
+ GLTexture *texture,
+ GLFragment::Attrib &attrib,
+ GLTexture::Filter filter,
+ unsigned int mask)
{
- CompScreen *s = w->screen ();
-
- if (s->canDoSaturated () && attrib.getSaturation () != COLOR)
+ if (gs->canDoSaturated () && attrib.getSaturation () != COLOR)
{
GLfloat constant[4];
@@ -897,7 +899,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glColor4f (1.0f, 1.0f, 1.0f, 0.5f);
- s->activeTexture (GL_TEXTURE1_ARB);
+ gs->activeTexture (GL_TEXTURE1_ARB);
texture->enable (filter);
@@ -909,7 +911,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- if (s->canDoSlightlySaturated () && attrib.getSaturation () > 0)
+ if (gs->canDoSlightlySaturated () && attrib.getSaturation () > 0)
{
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
@@ -922,7 +924,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
- s->activeTexture (GL_TEXTURE2_ARB);
+ gs->activeTexture (GL_TEXTURE2_ARB);
texture->enable (filter);
@@ -947,7 +949,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
if (attrib.getOpacity () < OPAQUE ||
attrib.getBrightness () != BRIGHT)
{
- s->activeTexture (GL_TEXTURE3_ARB);
+ gs->activeTexture (GL_TEXTURE3_ARB);
texture->enable (filter);
@@ -971,24 +973,24 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
- w->drawGeometry ();
+ w->glDrawGeometry ();
texture->disable ();
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- s->activeTexture (GL_TEXTURE2_ARB);
+ gs->activeTexture (GL_TEXTURE2_ARB);
}
else
{
- w->drawGeometry ();
+ w->glDrawGeometry ();
}
texture->disable ();
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- s->activeTexture (GL_TEXTURE1_ARB);
+ gs->activeTexture (GL_TEXTURE1_ARB);
}
else
{
@@ -1008,19 +1010,19 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
- w->drawGeometry ();
+ w->glDrawGeometry ();
}
texture->disable ();
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- s->activeTexture (GL_TEXTURE0_ARB);
+ gs->activeTexture (GL_TEXTURE0_ARB);
texture->disable ();
glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
+ gs->setTexEnvMode (GL_REPLACE);
if (mask & PAINT_WINDOW_BLEND_MASK)
glDisable (GL_BLEND);
@@ -1039,35 +1041,35 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
- s->setTexEnvMode (GL_MODULATE);
+ gs->setTexEnvMode (GL_MODULATE);
glColor4us (color, color, color, attrib.getOpacity ());
- w->drawGeometry ();
+ w->glDrawGeometry ();
glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
+ gs->setTexEnvMode (GL_REPLACE);
}
else
{
- w->drawGeometry ();
+ w->glDrawGeometry ();
}
glDisable (GL_BLEND);
}
else if (attrib.getBrightness () != BRIGHT)
{
- s->setTexEnvMode (GL_MODULATE);
+ gs->setTexEnvMode (GL_MODULATE);
glColor4us (attrib.getBrightness (), attrib.getBrightness (),
attrib.getBrightness (), BRIGHT);
- w->drawGeometry ();
+ w->glDrawGeometry ();
glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
+ gs->setTexEnvMode (GL_REPLACE);
}
else
{
- w->drawGeometry ();
+ w->glDrawGeometry ();
}
texture->disable ();
@@ -1075,43 +1077,37 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
}
void
-CompWindow::drawTexture (CompTexture *texture,
- CompFragment::Attrib &attrib,
- unsigned int mask)
+GLWindow::glDrawTexture (GLTexture *texture,
+ GLFragment::Attrib &attrib,
+ unsigned int mask)
{
- WRAPABLE_HND_FUNC(drawTexture, texture, attrib, mask)
+ WRAPABLE_HND_FUNC(glDrawTexture, texture, attrib, mask)
- CompTexture::Filter filter;
+ GLTexture::Filter filter;
if (mask & (PAINT_WINDOW_TRANSFORMED_MASK |
PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK))
- filter = priv->screen->filter (SCREEN_TRANS_FILTER);
+ filter = priv->gScreen->filter (SCREEN_TRANS_FILTER);
else
- filter = priv->screen->filter (NOTHING_TRANS_FILTER);
+ filter = priv->gScreen->filter (NOTHING_TRANS_FILTER);
- if ((!attrib.hasFunctions () && (!priv->screen->lighting () ||
+ if ((!attrib.hasFunctions () && (!priv->gScreen->lighting () ||
attrib.getSaturation () == COLOR || attrib.getSaturation () == 0)) ||
- !enableFragmentProgramAndDrawGeometry (this,
- texture,
- attrib,
- filter,
- mask))
+ !enableFragmentProgramAndDrawGeometry (priv->gScreen, this, texture,
+ attrib, filter, mask))
{
- enableFragmentOperationsAndDrawGeometry (this,
- texture,
- attrib,
- filter,
- mask);
+ enableFragmentOperationsAndDrawGeometry (priv->gScreen, this, texture,
+ attrib, filter, mask);
}
}
bool
-CompWindow::draw (const CompTransform *transform,
- CompFragment::Attrib &fragment,
- Region region,
- unsigned int mask)
+GLWindow::glDraw (const GLMatrix &transform,
+ GLFragment::Attrib &fragment,
+ Region region,
+ unsigned int mask)
{
- WRAPABLE_HND_FUNC_RETURN(bool, draw, transform, fragment, region, mask)
+ WRAPABLE_HND_FUNC_RETURN(bool, glDraw, transform, fragment, region, mask)
if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
region = &infiniteRegion;
@@ -1119,7 +1115,7 @@ CompWindow::draw (const CompTransform *transform,
if (!region->numRects)
return true;
- if (priv->attrib.map_state != IsViewable)
+ if (priv->window->attrib ().map_state != IsViewable)
return true;
if (!priv->texture.hasPixmap () && !bind ())
@@ -1129,27 +1125,27 @@ CompWindow::draw (const CompTransform *transform,
mask |= PAINT_WINDOW_BLEND_MASK;
priv->vCount = priv->indexCount = 0;
- addGeometry (&priv->matrix, 1, priv->region, region);
+ glAddGeometry (&priv->matrix, 1, priv->window->region (), region);
if (priv->vCount)
- drawTexture (&priv->texture, fragment, mask);
+ glDrawTexture (&priv->texture, fragment, mask);
return true;
}
bool
-CompWindow::paint (const CompWindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
+GLWindow::glPaint (const GLWindowPaintAttrib &attrib,
+ const GLMatrix &transform,
+ Region region,
+ unsigned int mask)
{
- WRAPABLE_HND_FUNC_RETURN(bool, paint, attrib, transform, region, mask)
+ WRAPABLE_HND_FUNC_RETURN(bool, glPaint, attrib, transform, region, mask)
- CompFragment::Attrib fragment (attrib);
- bool status;
+ GLFragment::Attrib fragment (attrib);
+ bool status;
- priv->lastPaint = *attrib;
+ priv->lastPaint = attrib;
- if (priv->alpha || attrib->opacity != OPAQUE)
+ if (priv->window->alpha () || attrib.opacity != OPAQUE)
mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
priv->lastMask = mask;
@@ -1165,7 +1161,7 @@ CompWindow::paint (const CompWindowPaintAttrib *attrib,
if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
return false;
- if (priv->shaded)
+ if (priv->window->shaded ())
return false;
return true;
@@ -1178,10 +1174,10 @@ CompWindow::paint (const CompWindowPaintAttrib *attrib,
mask & PAINT_WINDOW_WITH_OFFSET_MASK)
{
glPushMatrix ();
- glLoadMatrixf (transform->getMatrix ());
+ glLoadMatrixf (transform.getMatrix ());
}
- status = draw (transform, fragment, region, mask);
+ status = glDraw (transform, fragment, region, mask);
if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
mask & PAINT_WINDOW_WITH_OFFSET_MASK)
diff --git a/src/privatefragment.h b/plugins/opengl/privatefragment.h
index 68c9e47..a0d66fa 100644
--- a/src/privatefragment.h
+++ b/plugins/opengl/privatefragment.h
@@ -3,9 +3,9 @@
#include <vector>
-#include <compfragment.h>
+#include <opengl/fragment.h>
-namespace CompFragment {
+namespace GLFragment {
class Function;
class Program;
diff --git a/plugins/opengl/privates.h b/plugins/opengl/privates.h
new file mode 100644
index 0000000..b41b875
--- /dev/null
+++ b/plugins/opengl/privates.h
@@ -0,0 +1,184 @@
+#ifndef _COMPOSITE_PRIVATES_H
+#define _COMPOSITE_PRIVATES_H
+
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+
+#include "privatefragment.h"
+#include "privatetexture.h"
+
+#define GL_DISPLAY_OPTION_TEXTURE_FILTER 0
+#define GL_DISPLAY_OPTION_NUM 1
+
+#define GL_SCREEN_OPTION_LIGHTING 0
+#define GL_SCREEN_OPTION_SYNC_TO_VBLANK 1
+#define GL_SCREEN_OPTION_TEXTURE_COMPRESSION 2
+#define GL_SCREEN_OPTION_NUM 3
+
+extern CompMetadata *glMetadata;
+extern const CompMetadata::OptionInfo
+ glDisplayOptionInfo[GL_DISPLAY_OPTION_NUM];
+
+extern const CompMetadata::OptionInfo
+ glScreenOptionInfo[GL_SCREEN_OPTION_NUM];
+
+extern GLScreen *targetScreen;
+extern CompOutput *targetOutput;
+
+
+#define RED_SATURATION_WEIGHT 0.30f
+#define GREEN_SATURATION_WEIGHT 0.59f
+#define BLUE_SATURATION_WEIGHT 0.11f
+
+
+
+class PrivateGLDisplay : public DisplayInterface
+{
+ public:
+ PrivateGLDisplay (CompDisplay *d, GLDisplay *gd);
+ ~PrivateGLDisplay ();
+
+ void handleEvent (XEvent *event);
+
+ public:
+ CompDisplay *display;
+ GLDisplay *gDisplay;
+
+ GLenum textureFilter;
+
+ CompOption::Vector opt;
+};
+
+class PrivateGLScreen :
+ public ScreenInterface,
+ public CompositeScreen::PaintHandler
+{
+ public:
+ PrivateGLScreen (CompScreen *s, GLScreen *gs);
+ ~PrivateGLScreen ();
+
+ void outputChangeNotify ();
+
+ void paintOutputs (CompOutput::ptrList &outputs,
+ unsigned int mask,
+ Region region);
+
+ bool hasVSync ();
+
+ void prepareDrawing ();
+
+ void waitForVideoSync ();
+
+ void paintBackground (Region region,
+ bool transformed);
+
+ void paintOutputRegion (const GLMatrix &transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask);
+
+ void updateScreenBackground (GLTexture *texture);
+
+ void updateView ();
+
+ public:
+ CompScreen *screen;
+ GLScreen *gScreen;
+ CompositeScreen *cScreen;
+
+ GLFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1];
+
+ bool textureRectangle;
+ bool textureNonPowerOfTwo;
+ bool textureEnvCombine;
+ bool textureEnvCrossbar;
+ bool textureBorderClamp;
+ bool textureCompression;
+ GLint maxTextureSize;
+ bool fbo;
+ bool fragmentProgram;
+ GLint maxTextureUnits;
+
+ GLTexture backgroundTexture;
+ bool backgroundLoaded;
+
+ GLTexture::Filter filter[3];
+
+ bool canDoSaturated;
+ bool canDoSlightlySaturated;
+
+ CompPoint rasterPos;
+
+ GLFragment::Storage fragmentStorage;
+
+ GLfloat projection[16];
+
+ bool clearBuffers;
+ bool lighting;
+
+ GLXGetProcAddressProc getProcAddress;
+
+ GLXContext ctx;
+
+ Region tmpRegion;
+ Region outputRegion;
+
+ bool pendingCommands;
+
+ XRectangle lastViewport;
+
+ CompOption::Vector opt;
+};
+
+class PrivateGLWindow :
+ public WindowInterface,
+ public CompositeWindowInterface
+{
+ public:
+ PrivateGLWindow (CompWindow *w, GLWindow *gw);
+ ~PrivateGLWindow ();
+
+ void windowNotify (CompWindowNotify n);
+ void resizeNotify (int dx, int dy, int dwidth, int dheight);
+ void moveNotify (int dx, int dy, bool now);
+
+ bool damageRect (bool, BoxPtr);
+
+ void setWindowMatrix ();
+
+ CompWindow *window;
+ GLWindow *gWindow;
+ CompositeWindow *cWindow;
+ CompScreen *screen;
+ GLScreen *gScreen;
+
+ GLTexture texture;
+ GLTexture::Matrix matrix;
+
+ Region clip;
+
+ bool bindFailed;
+ bool overlayWindow;
+
+ GLushort opacity;
+ GLushort brightness;
+ GLushort saturation;
+
+ GLWindowPaintAttrib paint;
+ GLWindowPaintAttrib lastPaint;
+
+ unsigned int lastMask;
+
+ GLfloat *vertices;
+ int vertexSize;
+ int vertexStride;
+ GLushort *indices;
+ int indexSize;
+ int vCount;
+ int texUnits;
+ int texCoordSize;
+ int indexCount;
+};
+
+
+#endif
diff --git a/plugins/opengl/privatetexture.h b/plugins/opengl/privatetexture.h
new file mode 100644
index 0000000..7b8d814
--- /dev/null
+++ b/plugins/opengl/privatetexture.h
@@ -0,0 +1,40 @@
+#ifndef _PRIVATETEXTURE_H
+#define _PRIVATETEXTURE_H
+
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <opengl/texture.h>
+
+class GLScreen;
+class GLDisplay;
+
+class PrivateTexture {
+ public:
+ PrivateTexture (GLTexture *, CompScreen *);
+ ~PrivateTexture ();
+
+ bool loadImageData (const char *image,
+ unsigned int width,
+ unsigned int height,
+ GLenum format,
+ GLenum type);
+
+ public:
+ CompScreen *screen;
+ GLScreen *gScreen;
+ GLDisplay *gDisplay;
+ GLTexture *texture;
+ GLuint name;
+ GLenum target;
+ GLfloat dx, dy;
+ GLXPixmap pixmap;
+ GLenum filter;
+ GLenum wrap;
+ GLTexture::Matrix matrix;
+ bool damaged;
+ bool mipmap;
+ unsigned int width;
+ unsigned int height;
+};
+
+#endif
diff --git a/plugins/opengl/screen.cpp b/plugins/opengl/screen.cpp
new file mode 100644
index 0000000..5e8be2b
--- /dev/null
+++ b/plugins/opengl/screen.cpp
@@ -0,0 +1,1138 @@
+#include "privates.h"
+
+#include <dlfcn.h>
+#include <math.h>
+
+GLScreen *targetScreen = NULL;
+CompOutput *targetOutput = NULL;
+
+Window currentRoot = None;
+
+GLScreen::GLScreen (CompScreen *s) :
+ OpenGLPrivateHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI> (s),
+ priv (new PrivateGLScreen (s, this))
+{
+ CompDisplay *d = s->display ();
+ Display *dpy = d->dpy ();
+ XVisualInfo templ;
+ XVisualInfo *visinfo;
+ GLXFBConfig *fbConfigs;
+ int defaultDepth, nvisinfo, nElements, value, i;
+ const char *glxExtensions, *glExtensions;
+ GLfloat globalAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f };
+ GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
+ GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
+ XWindowAttributes attr;
+
+ WRAPABLE_INIT_HND(glPaintOutput);
+ WRAPABLE_INIT_HND(glPaintTransformedOutput);
+ WRAPABLE_INIT_HND(glApplyTransform);
+ WRAPABLE_INIT_HND(glEnableOutputClipping);
+ WRAPABLE_INIT_HND(glDisableOutputClipping);
+
+ priv->tmpRegion = XCreateRegion ();
+ if (!priv->tmpRegion)
+ {
+ setFailed ();
+ return;
+ }
+ priv->outputRegion = XCreateRegion ();
+ if (!priv->outputRegion)
+ {
+ setFailed ();
+ return;
+ }
+
+ if (!glMetadata->initScreenOptions (s, glScreenOptionInfo,
+ GL_SCREEN_OPTION_NUM, priv->opt))
+ {
+ setFailed ();
+ return;
+ }
+
+ if (!XGetWindowAttributes (dpy, s->root (), &attr))
+ {
+ setFailed ();
+ return;
+ }
+
+ templ.visualid = XVisualIDFromVisual (attr.visual);
+
+ visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
+ if (!nvisinfo)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "Couldn't get visual info for default visual");
+ setFailed ();
+ return;
+ }
+
+ defaultDepth = visinfo->depth;
+
+ glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);
+ if (!value)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "Root visual is not a GL visual");
+ XFree (visinfo);
+ setFailed ();
+ return;
+ }
+
+ glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);
+ if (!value)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "Root visual is not a double buffered GL visual");
+ XFree (visinfo);
+ setFailed ();
+ return;
+ }
+
+ priv->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering);
+ if (!priv->ctx)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "glXCreateContext failed");
+ XFree (visinfo);
+
+ setFailed ();
+ return;
+ }
+
+ glxExtensions = glXQueryExtensionsString (dpy, s->screenNum ());
+ if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap"))
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "GLX_EXT_texture_from_pixmap is missing");
+ XFree (visinfo);
+
+ setFailed ();
+ return;
+ }
+
+ XFree (visinfo);
+
+ if (!strstr (glxExtensions, "GLX_SGIX_fbconfig"))
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "GLX_SGIX_fbconfig is missing");
+ setFailed ();
+ return;
+ }
+
+ priv->getProcAddress = (GLXGetProcAddressProc)
+ getProcAddress ("glXGetProcAddressARB");
+ bindTexImage = (GLXBindTexImageProc)
+ getProcAddress ("glXBindTexImageEXT");
+ releaseTexImage = (GLXReleaseTexImageProc)
+ getProcAddress ("glXReleaseTexImageEXT");
+ queryDrawable = (GLXQueryDrawableProc)
+ getProcAddress ("glXQueryDrawable");
+ getFBConfigs = (GLXGetFBConfigsProc)
+ getProcAddress ("glXGetFBConfigs");
+ getFBConfigAttrib = (GLXGetFBConfigAttribProc)
+ getProcAddress ("glXGetFBConfigAttrib");
+ createPixmap = (GLXCreatePixmapProc)
+ getProcAddress ("glXCreatePixmap");
+
+ if (!bindTexImage)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "glXBindTexImageEXT is missing");
+ setFailed ();
+ return;
+ }
+
+ if (!releaseTexImage)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "glXReleaseTexImageEXT is missing");
+ setFailed ();
+ return;
+ }
+
+ if (!queryDrawable ||
+ !getFBConfigs ||
+ !getFBConfigAttrib ||
+ !createPixmap)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "fbconfig functions missing");
+ setFailed ();
+ return;
+ }
+
+ copySubBuffer = NULL;
+ if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer"))
+ copySubBuffer = (GLXCopySubBufferProc)
+ getProcAddress ("glXCopySubBufferMESA");
+
+ getVideoSync = NULL;
+ waitVideoSync = NULL;
+ if (strstr (glxExtensions, "GLX_SGI_video_sync"))
+ {
+ getVideoSync = (GLXGetVideoSyncProc)
+ getProcAddress ("glXGetVideoSyncSGI");
+
+ waitVideoSync = (GLXWaitVideoSyncProc)
+ getProcAddress ("glXWaitVideoSyncSGI");
+ }
+
+ glXMakeCurrent (dpy, CompositeScreen::get (s)->output (),
+ priv->ctx);
+ currentRoot = s->root ();
+
+ glExtensions = (const char *) glGetString (GL_EXTENSIONS);
+ if (!glExtensions)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "No valid GL extensions string found.");
+ setFailed ();
+ return;
+ }
+
+ priv->textureNonPowerOfTwo = false;
+ if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
+ priv->textureNonPowerOfTwo = true;
+
+ glGetIntegerv (GL_MAX_TEXTURE_SIZE, &priv->maxTextureSize);
+
+ priv->textureRectangle = false;
+ if (strstr (glExtensions, "GL_NV_texture_rectangle") ||
+ strstr (glExtensions, "GL_EXT_texture_rectangle") ||
+ strstr (glExtensions, "GL_ARB_texture_rectangle"))
+ {
+ priv->textureRectangle = true;
+
+ if (!priv->textureNonPowerOfTwo)
+ {
+ GLint maxTextureSize;
+
+ glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &maxTextureSize);
+ if (maxTextureSize > priv->maxTextureSize)
+ priv->maxTextureSize = maxTextureSize;
+ }
+ }
+
+ if (!(priv->textureRectangle || priv->textureNonPowerOfTwo))
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "Support for non power of two textures missing");
+ setFailed ();
+ return;
+ }
+
+ priv->textureEnvCombine = priv->textureEnvCrossbar = false;
+ if (strstr (glExtensions, "GL_ARB_texture_env_combine"))
+ {
+ priv->textureEnvCombine = true;
+
+ /* XXX: GL_NV_texture_env_combine4 need special code but it seams to
+ be working anyway for now... */
+ if (strstr (glExtensions, "GL_ARB_texture_env_crossbar") ||
+ strstr (glExtensions, "GL_NV_texture_env_combine4"))
+ priv->textureEnvCrossbar = true;
+ }
+
+ priv->textureBorderClamp = false;
+ if (strstr (glExtensions, "GL_ARB_texture_border_clamp") ||
+ strstr (glExtensions, "GL_SGIS_texture_border_clamp"))
+ priv->textureBorderClamp = true;
+
+ priv->maxTextureUnits = 1;
+ if (strstr (glExtensions, "GL_ARB_multitexture"))
+ {
+ activeTexture = (GLActiveTextureProc)
+ getProcAddress ("glActiveTexture");
+ clientActiveTexture = (GLClientActiveTextureProc)
+ getProcAddress ("glClientActiveTexture");
+ multiTexCoord2f = (GLMultiTexCoord2fProc)
+ getProcAddress ("glMultiTexCoord2f");
+
+ if (activeTexture && clientActiveTexture && multiTexCoord2f)
+ glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &priv->maxTextureUnits);
+ }
+
+ priv->fragmentProgram = false;
+ if (strstr (glExtensions, "GL_ARB_fragment_program"))
+ {
+ genPrograms = (GLGenProgramsProc)
+ getProcAddress ("glGenProgramsARB");
+ deletePrograms = (GLDeleteProgramsProc)
+ getProcAddress ("glDeleteProgramsARB");
+ bindProgram = (GLBindProgramProc)
+ getProcAddress ("glBindProgramARB");
+ programString = (GLProgramStringProc)
+ getProcAddress ("glProgramStringARB");
+ programEnvParameter4f = (GLProgramParameter4fProc)
+ getProcAddress ("glProgramEnvParameter4fARB");
+ programLocalParameter4f = (GLProgramParameter4fProc)
+ getProcAddress ("glProgramLocalParameter4fARB");
+ getProgramiv = (GLGetProgramivProc)
+ getProcAddress ("glGetProgramivARB");
+
+ if (genPrograms &&
+ deletePrograms &&
+ bindProgram &&
+ programString &&
+ programEnvParameter4f &&
+ programLocalParameter4f &&
+ getProgramiv)
+ priv->fragmentProgram = true;
+ }
+
+ priv->fbo = false;
+ if (strstr (glExtensions, "GL_EXT_framebuffer_object"))
+ {
+ genFramebuffers = (GLGenFramebuffersProc)
+ getProcAddress ("glGenFramebuffersEXT");
+ deleteFramebuffers = (GLDeleteFramebuffersProc)
+ getProcAddress ("glDeleteFramebuffersEXT");
+ bindFramebuffer = (GLBindFramebufferProc)
+ getProcAddress ("glBindFramebufferEXT");
+ checkFramebufferStatus = (GLCheckFramebufferStatusProc)
+ getProcAddress ("glCheckFramebufferStatusEXT");
+ framebufferTexture2D = (GLFramebufferTexture2DProc)
+ getProcAddress ("glFramebufferTexture2DEXT");
+ generateMipmap = (GLGenerateMipmapProc)
+ getProcAddress ("glGenerateMipmapEXT");
+
+ if (genFramebuffers &&
+ deleteFramebuffers &&
+ bindFramebuffer &&
+ checkFramebufferStatus &&
+ framebufferTexture2D &&
+ generateMipmap)
+ priv->fbo = true;
+ }
+
+ priv->textureCompression = false;
+ if (strstr (glExtensions, "GL_ARB_texture_compression"))
+ priv->textureCompression = true;
+
+ fbConfigs = (*getFBConfigs) (dpy, s->screenNum (), &nElements);
+
+ for (i = 0; i <= MAX_DEPTH; i++)
+ {
+ int j, db, stencil, depth, alpha, mipmap, rgba;
+
+ priv->glxPixmapFBConfigs[i].fbConfig = NULL;
+ priv->glxPixmapFBConfigs[i].mipmap = 0;
+ priv->glxPixmapFBConfigs[i].yInverted = 0;
+ priv->glxPixmapFBConfigs[i].textureFormat = 0;
+ priv->glxPixmapFBConfigs[i].textureTargets = 0;
+
+ db = MAXSHORT;
+ stencil = MAXSHORT;
+ depth = MAXSHORT;
+ mipmap = 0;
+ rgba = 0;
+
+ for (j = 0; j < nElements; j++)
+ {
+ XVisualInfo *vi;
+ int visualDepth;
+
+ vi = glXGetVisualFromFBConfig (dpy, fbConfigs[j]);
+ if (vi == NULL)
+ continue;
+
+ visualDepth = vi->depth;
+
+ XFree (vi);
+
+ if (visualDepth != i)
+ continue;
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_ALPHA_SIZE,
+ &alpha);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BUFFER_SIZE,
+ &value);
+ if (value != i && (value - alpha) != i)
+ continue;
+
+ value = 0;
+ if (i == 32)
+ {
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_TEXTURE_RGBA_EXT,
+ &value);
+
+ if (value)
+ {
+ rgba = 1;
+
+ priv->glxPixmapFBConfigs[i].textureFormat =
+ GLX_TEXTURE_FORMAT_RGBA_EXT;
+ }
+ }
+
+ if (!value)
+ {
+ if (rgba)
+ continue;
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_TEXTURE_RGB_EXT,
+ &value);
+ if (!value)
+ continue;
+
+ priv->glxPixmapFBConfigs[i].textureFormat =
+ GLX_TEXTURE_FORMAT_RGB_EXT;
+ }
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_DOUBLEBUFFER,
+ &value);
+ if (value > db)
+ continue;
+
+ db = value;
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_STENCIL_SIZE,
+ &value);
+ if (value > stencil)
+ continue;
+
+ stencil = value;
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_DEPTH_SIZE,
+ &value);
+ if (value > depth)
+ continue;
+
+ depth = value;
+
+ if (priv->fbo)
+ {
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
+ &value);
+ if (value < mipmap)
+ continue;
+
+ mipmap = value;
+ }
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_Y_INVERTED_EXT,
+ &value);
+
+ priv->glxPixmapFBConfigs[i].yInverted = value;
+
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_TEXTURE_TARGETS_EXT,
+ &value);
+
+ priv->glxPixmapFBConfigs[i].textureTargets = value;
+
+ priv->glxPixmapFBConfigs[i].fbConfig = fbConfigs[j];
+ priv->glxPixmapFBConfigs[i].mipmap = mipmap;
+ }
+ }
+
+ if (nElements)
+ XFree (fbConfigs);
+
+ if (!priv->glxPixmapFBConfigs[defaultDepth].fbConfig)
+ {
+ compLogMessage (d, "opengl", CompLogLevelFatal,
+ "No GLXFBConfig for default depth, "
+ "this isn't going to work.");
+ setFailed ();
+ return;
+ }
+
+ glClearColor (0.0, 0.0, 0.0, 1.0);
+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable (GL_CULL_FACE);
+ glDisable (GL_BLEND);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glColor4usv (defaultColor);
+ glEnableClientState (GL_VERTEX_ARRAY);
+ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+
+ priv->canDoSaturated = priv->canDoSlightlySaturated = false;
+ if (priv->textureEnvCombine && priv->maxTextureUnits >= 2)
+ {
+ priv->canDoSaturated = true;
+ if (priv->textureEnvCrossbar && priv->maxTextureUnits >= 4)
+ priv->canDoSlightlySaturated = true;
+ }
+
+ priv->updateView ();
+
+ glLightModelfv (GL_LIGHT_MODEL_AMBIENT, globalAmbient);
+
+ glEnable (GL_LIGHT0);
+ glLightfv (GL_LIGHT0, GL_AMBIENT, ambientLight);
+ glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseLight);
+ glLightfv (GL_LIGHT0, GL_POSITION, light0Position);
+
+ glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
+
+ glNormal3f (0.0f, 0.0f, -1.0f);
+
+ priv->lighting = false;
+
+
+ priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast;
+ priv->filter[SCREEN_TRANS_FILTER] = GLTexture::Good;
+ priv->filter[WINDOW_TRANS_FILTER] = GLTexture::Good;
+
+
+ if (!CompositeScreen::get (s)->registerPaintHandler (priv))
+ setFailed ();
+
+}
+
+GLScreen::~GLScreen ()
+{
+ CompositeScreen::get (priv->screen)->unregisterPaintHandler ();
+ glXDestroyContext (priv->screen->display ()->dpy (), priv->ctx);
+ delete priv;
+}
+
+PrivateGLScreen::PrivateGLScreen (CompScreen *s,
+ GLScreen *gs) :
+ screen (s),
+ gScreen (gs),
+ cScreen (CompositeScreen::get (s)),
+ textureRectangle (false),
+ textureNonPowerOfTwo (false),
+ textureEnvCombine (false),
+ textureEnvCrossbar (false),
+ textureBorderClamp (false),
+ textureCompression (false),
+ maxTextureSize (0),
+ fbo (false),
+ fragmentProgram (false),
+ maxTextureUnits (1),
+ backgroundTexture (screen),
+ backgroundLoaded (false),
+ canDoSaturated (false),
+ canDoSlightlySaturated (false),
+ rasterPos (0, 0),
+ fragmentStorage (),
+ clearBuffers (true),
+ lighting (false),
+ getProcAddress (0),
+ tmpRegion (NULL),
+ outputRegion (NULL)
+{
+}
+
+PrivateGLScreen::~PrivateGLScreen ()
+{
+ if (tmpRegion)
+ XDestroyRegion (tmpRegion);
+ if (outputRegion)
+ XDestroyRegion (outputRegion);
+}
+
+static void
+frustum (GLfloat *m,
+ GLfloat left,
+ GLfloat right,
+ GLfloat bottom,
+ GLfloat top,
+ GLfloat nearval,
+ GLfloat farval)
+{
+ GLfloat x, y, a, b, c, d;
+
+ x = (2.0 * nearval) / (right - left);
+ y = (2.0 * nearval) / (top - bottom);
+ a = (right + left) / (right - left);
+ b = (top + bottom) / (top - bottom);
+ c = -(farval + nearval) / ( farval - nearval);
+ d = -(2.0 * farval * nearval) / (farval - nearval);
+
+#define M(row,col) m[col*4+row]
+ M(0,0) = x; M(0,1) = 0.0f; M(0,2) = a; M(0,3) = 0.0f;
+ M(1,0) = 0.0f; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0f;
+ M(2,0) = 0.0f; M(2,1) = 0.0f; M(2,2) = c; M(2,3) = d;
+ M(3,0) = 0.0f; M(3,1) = 0.0f; M(3,2) = -1.0f; M(3,3) = 0.0f;
+#undef M
+
+}
+
+static void
+perspective (GLfloat *m,
+ GLfloat fovy,
+ GLfloat aspect,
+ GLfloat zNear,
+ GLfloat zFar)
+{
+ GLfloat xmin, xmax, ymin, ymax;
+
+ ymax = zNear * tan (fovy * M_PI / 360.0);
+ ymin = -ymax;
+ xmin = ymin * aspect;
+ xmax = ymax * aspect;
+
+ frustum (m, xmin, xmax, ymin, ymax, zNear, zFar);
+}
+
+void
+PrivateGLScreen::updateView ()
+{
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ glDepthRange (0, 1);
+ glViewport (-1, -1, 2, 2);
+ glRasterPos2f (0, 0);
+
+ rasterPos = CompPoint (0, 0);
+
+ perspective (projection, 60.0f, 1.0f, 0.1f, 100.0f);
+
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+ glMultMatrixf (projection);
+ glMatrixMode (GL_MODELVIEW);
+
+ Region region = XCreateRegion ();
+ if (region)
+ {
+ XSubtractRegion (screen->region (), &emptyRegion, region);
+ /* remove all output regions from visible screen region */
+ foreach (CompOutput &o, screen->outputDevs ())
+ XSubtractRegion (region, o.region (), region);
+
+ /* we should clear color buffers before swapping if we have visible
+ regions without output */
+ clearBuffers = REGION_NOT_EMPTY (region);
+
+ XDestroyRegion (region);
+ }
+ gScreen->setDefaultViewport ();
+}
+
+void
+PrivateGLScreen::outputChangeNotify ()
+{
+ screen->outputChangeNotify ();
+
+ updateView ();
+}
+
+FuncPtr
+GLScreen::getProcAddress (const char *name)
+{
+ static void *dlhand = NULL;
+ FuncPtr funcPtr = NULL;
+
+ if (priv->getProcAddress)
+ funcPtr = priv->getProcAddress ((GLubyte *) name);
+
+ if (!funcPtr)
+ {
+ if (!dlhand)
+ dlhand = dlopen (NULL, RTLD_LAZY);
+
+ if (dlhand)
+ {
+ dlerror ();
+ funcPtr = (FuncPtr) dlsym (dlhand, name);
+ if (dlerror () != NULL)
+ funcPtr = NULL;
+ }
+ }
+
+ return funcPtr;
+}
+
+void
+PrivateGLScreen::updateScreenBackground (GLTexture *texture)
+{
+ Display *dpy = screen->display ()->dpy ();
+ Atom pixmapAtom, actualType;
+ int actualFormat, i, status;
+ unsigned int width = 1, height = 1, depth = 0;
+ unsigned long nItems;
+ unsigned long bytesAfter;
+ unsigned char *prop;
+ Pixmap pixmap = 0;
+
+ pixmapAtom = XInternAtom (dpy, "PIXMAP", FALSE);
+
+ for (i = 0; pixmap == 0 && i < 2; i++)
+ {
+ status = XGetWindowProperty (dpy, screen->root (),
+ screen->display ()->atoms ().xBackground[i],
+ 0, 4, FALSE, AnyPropertyType,
+ &actualType, &actualFormat, &nItems,
+ &bytesAfter, &prop);
+
+ if (status == Success && nItems && prop)
+ {
+ if (actualType == pixmapAtom &&
+ actualFormat == 32 &&
+ nItems == 1)
+ {
+ Pixmap p;
+
+ memcpy (&p, prop, 4);
+
+ if (p)
+ {
+ unsigned int ui;
+ int i;
+ Window w;
+
+ if (XGetGeometry (dpy, p, &w, &i, &i,
+ &width, &height, &ui, &depth))
+ {
+ if ((int) depth == screen->attrib ().depth)
+ pixmap = p;
+ }
+ }
+ }
+
+ XFree (prop);
+ }
+ }
+
+ if (pixmap)
+ {
+/* FIXME:
+ if (pixmap == texture->pixmap)
+ return;
+*/
+ texture->reset ();
+
+ if (!texture->bindPixmap (pixmap, width, height, depth))
+ {
+ compLogMessage (NULL, "core", CompLogLevelWarn,
+ "Couldn't bind background pixmap 0x%x to "
+ "texture", (int) pixmap);
+ }
+ }
+ else
+ {
+ texture->reset ();
+ }
+
+ if (!texture->name () && backgroundImage)
+ GLTexture::readImageToTexture (screen, texture, backgroundImage,
+ &width, &height);
+
+ if (texture->target () == GL_TEXTURE_2D)
+ {
+ glBindTexture (texture->target (), texture->name ());
+ glTexParameteri (texture->target (), GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (texture->target (), GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glBindTexture (texture->target (), 0);
+ }
+}
+
+void
+GLScreen::setTexEnvMode (GLenum mode)
+{
+ if (priv->lighting)
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ else
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
+}
+
+void
+GLScreen::setLighting (bool lighting)
+{
+ if (priv->lighting != lighting)
+ {
+ if (!priv->opt[GL_SCREEN_OPTION_LIGHTING].value ().b ())
+ lighting = false;
+
+ if (lighting)
+ {
+ glEnable (GL_COLOR_MATERIAL);
+ glEnable (GL_LIGHTING);
+ }
+ else
+ {
+ glDisable (GL_COLOR_MATERIAL);
+ glDisable (GL_LIGHTING);
+ }
+
+ priv->lighting = lighting;
+
+ setTexEnvMode (GL_REPLACE);
+ }
+}
+
+void
+GLScreen::makeCurrent ()
+{
+ if (currentRoot != priv->screen->root ())
+ {
+ glXMakeCurrent (priv->screen->display ()->dpy (),
+ CompositeScreen::get (priv->screen)->output (),
+ priv->ctx);
+ currentRoot = priv->screen->root ();
+ }
+
+ priv->pendingCommands = true;
+}
+
+GLScreenInterface::GLScreenInterface ()
+{
+ WRAPABLE_INIT_FUNC(glPaintOutput);
+ WRAPABLE_INIT_FUNC(glPaintTransformedOutput);
+ WRAPABLE_INIT_FUNC(glEnableOutputClipping);
+ WRAPABLE_INIT_FUNC(glDisableOutputClipping);
+ WRAPABLE_INIT_FUNC(glApplyTransform);
+}
+
+
+bool
+GLScreenInterface::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
+ const GLMatrix &transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC_RETURN(glPaintOutput, sAttrib, transform, region,
+ output, mask)
+
+void
+GLScreenInterface::glPaintTransformedOutput (const GLScreenPaintAttrib &sAttrib,
+ const GLMatrix &transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC(glPaintTransformedOutput, sAttrib, transform, region,
+ output, mask)
+
+void
+GLScreenInterface::glApplyTransform (const GLScreenPaintAttrib &sAttrib,
+ CompOutput *output,
+ GLMatrix *transform)
+ WRAPABLE_DEF_FUNC(glApplyTransform, sAttrib, output, transform)
+
+void
+GLScreenInterface::glEnableOutputClipping (const GLMatrix &transform,
+ Region region,
+ CompOutput *output)
+ WRAPABLE_DEF_FUNC(glEnableOutputClipping, transform, region, output)
+
+void
+GLScreenInterface::glDisableOutputClipping ()
+ WRAPABLE_DEF_FUNC(glDisableOutputClipping)
+
+int
+GLScreen::maxTextureSize ()
+{
+ return priv->maxTextureSize;
+}
+
+void
+GLScreen::updateBackground ()
+{
+ priv->backgroundTexture.reset ();
+
+ if (priv->backgroundLoaded)
+ {
+ priv->backgroundLoaded = false;
+ CompositeScreen::get (priv->screen)->damageScreen ();
+ }
+}
+
+bool
+GLScreen::textureNonPowerOfTwo ()
+{
+ return priv->textureNonPowerOfTwo;
+}
+
+bool
+GLScreen::textureCompression ()
+{
+ return priv->textureCompression;
+}
+
+bool
+GLScreen::canDoSaturated ()
+{
+ return priv->canDoSaturated;
+}
+
+bool
+GLScreen::canDoSlightlySaturated ()
+{
+ return priv->canDoSlightlySaturated;
+}
+
+bool
+GLScreen::lighting ()
+{
+ return priv->lighting;
+}
+
+GLTexture::Filter
+GLScreen::filter (int filter)
+{
+ return priv->filter[filter];
+}
+
+GLFragment::Storage *
+GLScreen::fragmentStorage ()
+{
+ return &priv->fragmentStorage;
+}
+
+bool
+GLScreen::fragmentProgram ()
+{
+ return priv->fragmentProgram;
+}
+
+GLFBConfig*
+GLScreen::glxPixmapFBConfig (unsigned int depth)
+{
+ return &priv->glxPixmapFBConfigs[depth];
+}
+
+bool
+GLScreen::framebufferObject ()
+{
+ return priv->fbo;
+}
+
+void
+GLScreen::clearOutput (CompOutput *output,
+ unsigned int mask)
+{
+ BoxPtr pBox = &output->region ()->extents;
+
+ if (pBox->x1 != 0 ||
+ pBox->y1 != 0 ||
+ pBox->x2 != (int) priv->screen->size ().width () ||
+ pBox->y2 != (int) priv->screen->size ().height ())
+ {
+ glPushAttrib (GL_SCISSOR_BIT);
+
+ glEnable (GL_SCISSOR_TEST);
+ glScissor (pBox->x1,
+ priv->screen->size ().height () - pBox->y2,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ glClear (mask);
+
+ glPopAttrib ();
+ }
+ else
+ {
+ glClear (mask);
+ }
+}
+
+void
+GLScreen::setDefaultViewport ()
+{
+ priv->lastViewport.x = priv->screen->outputDevs ()[0].x1 ();
+ priv->lastViewport.y = priv->screen->size ().height () -
+ priv->screen->outputDevs ()[0].y2 ();
+ priv->lastViewport.width = priv->screen->outputDevs ()[0].width ();
+ priv->lastViewport.height = priv->screen->outputDevs ()[0].height ();
+
+ glViewport (priv->lastViewport.x,
+ priv->lastViewport.y,
+ priv->lastViewport.width,
+ priv->lastViewport.height);
+}
+
+void
+PrivateGLScreen::waitForVideoSync ()
+{
+ unsigned int sync;
+
+ if (!opt[GL_SCREEN_OPTION_SYNC_TO_VBLANK].value ().b ())
+ return;
+
+ if (gScreen->getVideoSync)
+ {
+ glFlush ();
+
+ (*gScreen->getVideoSync) (&sync);
+ (*gScreen->waitVideoSync) (2, (sync + 1) % 2, &sync);
+ }
+}
+
+CompOption *
+GLScreen::getOption (const char *name)
+{
+ CompOption *o = CompOption::findOption (priv->opt, name);
+ return o;
+}
+
+void
+PrivateGLScreen::paintOutputs (CompOutput::ptrList &outputs,
+ unsigned int mask,
+ Region region)
+{
+ XRectangle r;
+
+ if (clearBuffers)
+ {
+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ glClear (GL_COLOR_BUFFER_BIT);
+ }
+
+ XSubtractRegion (region, &emptyRegion, tmpRegion);
+
+ foreach (CompOutput *output, outputs)
+ {
+ targetScreen = gScreen;
+ targetOutput = output;
+
+ r.x = output->x1 ();
+ r.y = screen->size ().height () - output->y2 ();
+ r.width = output->width ();
+ r.height = output->height ();
+
+ if (lastViewport.x != r.x ||
+ lastViewport.y != r.y ||
+ lastViewport.width != r.width ||
+ lastViewport.height != r.height)
+ {
+ glViewport (r.x, r.y, r.width, r.height);
+ lastViewport = r;
+ }
+
+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ {
+ GLMatrix identity;
+
+ gScreen->glPaintOutput (defaultScreenPaintAttrib,
+ identity,
+ output->region (), output,
+ PAINT_SCREEN_REGION_MASK |
+ PAINT_SCREEN_FULL_MASK);
+ }
+ else if (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK)
+ {
+ GLMatrix identity;
+
+ XIntersectRegion (tmpRegion, output->region (), outputRegion);
+
+ if (!gScreen->glPaintOutput (defaultScreenPaintAttrib,
+ identity,
+ outputRegion, output,
+ PAINT_SCREEN_REGION_MASK))
+ {
+ identity.reset ();
+
+ gScreen->glPaintOutput (defaultScreenPaintAttrib,
+ identity,
+ output->region (), output,
+ PAINT_SCREEN_FULL_MASK);
+
+ XUnionRegion (tmpRegion, output->region (), tmpRegion);
+
+ }
+ }
+ }
+
+ targetScreen = NULL;
+ targetOutput = &screen->outputDevs ()[0];
+
+ waitForVideoSync ();
+
+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ {
+ glXSwapBuffers (screen->display ()->dpy (), cScreen->output ());
+ }
+ else
+ {
+ BoxPtr pBox;
+ int nBox, y;
+
+ pBox = tmpRegion->rects;
+ nBox = tmpRegion->numRects;
+
+ if (gScreen->copySubBuffer)
+ {
+ while (nBox--)
+ {
+ y = screen->size ().height () - pBox->y2;
+
+ (*gScreen->copySubBuffer) (screen->display ()->dpy (),
+ cScreen->output (),
+ pBox->x1, y,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+
+ pBox++;
+ }
+ }
+ else
+ {
+ glEnable (GL_SCISSOR_TEST);
+ glDrawBuffer (GL_FRONT);
+
+ while (nBox--)
+ {
+ y = screen->size ().height () - pBox->y2;
+
+ glBitmap (0, 0, 0, 0,
+ pBox->x1 - rasterPos.x (),
+ y - rasterPos.y (),
+ NULL);
+
+ rasterPos = CompPoint (pBox->x1, y);
+
+ glScissor (pBox->x1, y,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+
+ glCopyPixels (pBox->x1, y,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ GL_COLOR);
+
+ pBox++;
+ }
+
+ glDrawBuffer (GL_BACK);
+ glDisable (GL_SCISSOR_TEST);
+ glFlush ();
+ }
+ }
+}
+
+bool
+PrivateGLScreen::hasVSync ()
+{
+ return (gScreen->getVideoSync &&
+ opt[GL_SCREEN_OPTION_SYNC_TO_VBLANK].value ().b ());
+}
+
+void
+PrivateGLScreen::prepareDrawing ()
+{
+ gScreen->makeCurrent ();
+ if (pendingCommands)
+ {
+ glFinish ();
+ pendingCommands = false;
+ }
+ targetScreen = gScreen;
+}
diff --git a/src/texture.cpp b/plugins/opengl/texture.cpp
index 9fdf5a1..c58505f 100644
--- a/src/texture.cpp
+++ b/plugins/opengl/texture.cpp
@@ -34,27 +34,29 @@
#include <string.h>
#include <compiz-core.h>
-#include <comptexture.h>
+#include <opengl/texture.h>
#include <privatetexture.h>
-#include "privatescreen.h"
+#include "privates.h"
-static CompTexture::Matrix _identity_matrix = {
+static GLTexture::Matrix _identity_matrix = {
1.0f, 0.0f,
0.0f, 1.0f,
0.0f, 0.0f
};
-CompTexture::CompTexture (CompScreen *screen) :
+GLTexture::GLTexture (CompScreen *screen) :
priv (new PrivateTexture (this, screen))
{
}
-CompTexture::~CompTexture ()
+GLTexture::~GLTexture ()
{
}
-PrivateTexture::PrivateTexture (CompTexture *texture, CompScreen *screen) :
+PrivateTexture::PrivateTexture (GLTexture *texture, CompScreen *screen) :
screen (screen),
+ gScreen (GLScreen::get (screen)),
+ gDisplay (GLDisplay::get (screen->display ())),
texture (texture),
name (0),
target (GL_TEXTURE_2D),
@@ -71,8 +73,23 @@ PrivateTexture::~PrivateTexture ()
{
if (name)
{
- screen->makeCurrent ();
- texture->releasePixmap ();
+ gScreen->makeCurrent ();
+ if (pixmap)
+ {
+ glEnable (target);
+ if (!strictBinding)
+ {
+ glBindTexture (target, name);
+
+ (*gScreen->releaseTexImage) (screen->display ()->dpy (),
+ pixmap, GLX_FRONT_LEFT_EXT);
+ }
+
+ glBindTexture (target, 0);
+ glDisable (target);
+
+ glXDestroyGLXPixmap (screen->display ()->dpy (), pixmap);
+ }
glDeleteTextures (1, &name);
}
}
@@ -87,10 +104,10 @@ PrivateTexture::loadImageData (const char *image,
{
GLint internalFormat;
- screen->makeCurrent ();
+ gScreen->makeCurrent ();
texture->releasePixmap ();
- if (screen->textureNonPowerOfTwo () ||
+ if (gScreen->textureNonPowerOfTwo () ||
(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
{
target = GL_TEXTURE_2D;
@@ -117,8 +134,8 @@ PrivateTexture::loadImageData (const char *image,
glBindTexture (target, name);
internalFormat =
- (screen->getOption ("texture_compression")->value ().b () &&
- screen->textureCompression () ?
+ (gScreen->getOption ("texture_compression")->value ().b () &&
+ gScreen->textureCompression () ?
GL_COMPRESSED_RGBA_ARB : GL_RGBA);
glTexImage2D (target, 0, internalFormat, width, height, 0,
@@ -140,7 +157,7 @@ PrivateTexture::loadImageData (const char *image,
}
bool
-CompTexture::imageBufferToTexture (CompTexture *texture,
+GLTexture::imageBufferToTexture (GLTexture *texture,
const char *image,
unsigned int width,
unsigned int height)
@@ -155,7 +172,7 @@ CompTexture::imageBufferToTexture (CompTexture *texture,
}
bool
-CompTexture::imageDataToTexture (CompTexture *texture,
+GLTexture::imageDataToTexture (GLTexture *texture,
const char *image,
unsigned int width,
unsigned int height,
@@ -167,8 +184,8 @@ CompTexture::imageDataToTexture (CompTexture *texture,
bool
-CompTexture::readImageToTexture (CompScreen *screen,
- CompTexture *texture,
+GLTexture::readImageToTexture (CompScreen *screen,
+ GLTexture *texture,
const char *imageFileName,
unsigned int *returnWidth,
unsigned int *returnHeight)
@@ -181,7 +198,7 @@ CompTexture::readImageToTexture (CompScreen *screen,
&image))
return false;
- status = CompTexture::imageBufferToTexture (texture, (char *)image,
+ status = GLTexture::imageBufferToTexture (texture, (char *)image,
width, height);
free (image);
@@ -195,13 +212,13 @@ CompTexture::readImageToTexture (CompScreen *screen,
}
bool
-CompTexture::bindPixmap (Pixmap pixmap,
- int width,
- int height,
- int depth)
+GLTexture::bindPixmap (Pixmap pixmap,
+ int width,
+ int height,
+ int depth)
{
unsigned int target = 0;
- CompFBConfig *config = priv->screen->glxPixmapFBConfig (depth);
+ GLFBConfig *config = priv->gScreen->glxPixmapFBConfig (depth);
int attribs[7], i = 0;
if (!config->fbConfig)
@@ -222,7 +239,7 @@ CompTexture::bindPixmap (Pixmap pixmap,
TEXTURE_2D target is specified and GL_texture_non_power_of_two
is not supported, then allow the server to choose the texture target. */
if (config->textureTargets & GLX_TEXTURE_2D_BIT_EXT &&
- (priv->screen->textureNonPowerOfTwo () ||
+ (priv->gScreen->textureNonPowerOfTwo () ||
(POWER_OF_TWO (width) && POWER_OF_TWO (height))))
target = GLX_TEXTURE_2D_EXT;
else if (config->textureTargets & GLX_TEXTURE_RECTANGLE_BIT_EXT)
@@ -246,8 +263,8 @@ CompTexture::bindPixmap (Pixmap pixmap,
attribs[i++] = None;
- priv->screen->makeCurrent ();
- priv->pixmap = (*priv->screen->createPixmap) (
+ priv->gScreen->makeCurrent ();
+ priv->pixmap = (*priv->gScreen->createPixmap) (
priv->screen->display ()->dpy (), config->fbConfig, pixmap, attribs);
if (!priv->pixmap)
@@ -259,9 +276,9 @@ CompTexture::bindPixmap (Pixmap pixmap,
}
if (!target)
- (*priv->screen->queryDrawable) (priv->screen->display ()->dpy (),
- priv->pixmap,
- GLX_TEXTURE_TARGET_EXT, &target);
+ (*priv->gScreen->queryDrawable) (priv->screen->display ()->dpy (),
+ priv->pixmap,
+ GLX_TEXTURE_TARGET_EXT, &target);
switch (target) {
case GLX_TEXTURE_2D_EXT:
@@ -314,10 +331,10 @@ CompTexture::bindPixmap (Pixmap pixmap,
if (!strictBinding)
{
- (*priv->screen->bindTexImage) (priv->screen->display ()->dpy (),
- priv->pixmap,
- GLX_FRONT_LEFT_EXT,
- NULL);
+ (*priv->gScreen->bindTexImage) (priv->screen->display ()->dpy (),
+ priv->pixmap,
+ GLX_FRONT_LEFT_EXT,
+ NULL);
}
priv->filter = GL_NEAREST;
@@ -336,19 +353,19 @@ CompTexture::bindPixmap (Pixmap pixmap,
}
void
-CompTexture::releasePixmap ()
+GLTexture::releasePixmap ()
{
if (priv->pixmap)
{
- priv->screen->makeCurrent ();
+ priv->gScreen->makeCurrent ();
glEnable (priv->target);
if (!strictBinding)
{
glBindTexture (priv->target, priv->name);
- (*priv->screen->releaseTexImage) (priv->screen->display ()->dpy (),
- priv->pixmap,
- GLX_FRONT_LEFT_EXT);
+ (*priv->gScreen->releaseTexImage) (priv->screen->display ()->dpy (),
+ priv->pixmap,
+ GLX_FRONT_LEFT_EXT);
}
glBindTexture (priv->target, 0);
@@ -361,17 +378,17 @@ CompTexture::releasePixmap ()
}
void
-CompTexture::enable (CompTexture::Filter filter)
+GLTexture::enable (GLTexture::Filter filter)
{
- priv->screen->makeCurrent ();
+ priv->gScreen->makeCurrent ();
glEnable (priv->target);
glBindTexture (priv->target, priv->name);
if (strictBinding && priv->pixmap)
{
- (*priv->screen->bindTexImage) (priv->screen->display ()->dpy (),
- priv->pixmap,
- GLX_FRONT_LEFT_EXT, NULL);
+ (*priv->gScreen->bindTexImage) (priv->screen->display ()->dpy (),
+ priv->pixmap,
+ GLX_FRONT_LEFT_EXT, NULL);
}
if (filter == Fast)
@@ -388,13 +405,13 @@ CompTexture::enable (CompTexture::Filter filter)
priv->filter = GL_NEAREST;
}
}
- else if (priv->filter != priv->screen->display ()->textureFilter ())
+ else if (priv->filter != priv->gDisplay->textureFilter ())
{
- if (priv->screen->display ()->textureFilter () ==
+ if (priv->gDisplay->textureFilter () ==
GL_LINEAR_MIPMAP_LINEAR)
{
- if (priv->screen->textureNonPowerOfTwo () &&
- priv->screen->framebufferObject () && priv->mipmap)
+ if (priv->gScreen->textureNonPowerOfTwo () &&
+ priv->gScreen->framebufferObject () && priv->mipmap)
{
glTexParameteri (priv->target,
GL_TEXTURE_MIN_FILTER,
@@ -423,12 +440,12 @@ CompTexture::enable (CompTexture::Filter filter)
{
glTexParameteri (priv->target,
GL_TEXTURE_MIN_FILTER,
- priv->screen->display ()->textureFilter ());
+ priv->gDisplay->textureFilter ());
glTexParameteri (priv->target,
GL_TEXTURE_MAG_FILTER,
- priv->screen->display ()->textureFilter ());
+ priv->gDisplay->textureFilter ());
- priv->filter = priv->screen->display ()->textureFilter ();
+ priv->filter = priv->gDisplay->textureFilter ();
}
}
@@ -436,22 +453,22 @@ CompTexture::enable (CompTexture::Filter filter)
{
if (priv->damaged)
{
- (*priv->screen->generateMipmap) (priv->target);
+ (*priv->gScreen->generateMipmap) (priv->target);
priv->damaged = false;
}
}
}
void
-CompTexture::disable ()
+GLTexture::disable ()
{
- priv->screen->makeCurrent ();
+ priv->gScreen->makeCurrent ();
if (strictBinding && priv->pixmap)
{
glBindTexture (priv->target, priv->name);
- (*priv->screen->releaseTexImage) (priv->screen->display ()->dpy (),
- priv->pixmap, GLX_FRONT_LEFT_EXT);
+ (*priv->gScreen->releaseTexImage) (priv->screen->display ()->dpy (),
+ priv->pixmap, GLX_FRONT_LEFT_EXT);
}
glBindTexture (priv->target, 0);
@@ -459,38 +476,38 @@ CompTexture::disable ()
}
GLuint
-CompTexture::name ()
+GLTexture::name ()
{
return priv->name;
}
GLenum
-CompTexture::target ()
+GLTexture::target ()
{
return priv->target;
}
void
-CompTexture::damage ()
+GLTexture::damage ()
{
priv->damaged = true;
}
-CompTexture::Matrix &
-CompTexture::matrix ()
+GLTexture::Matrix &
+GLTexture::matrix ()
{
return priv->matrix;
}
void
-CompTexture::reset ()
+GLTexture::reset ()
{
priv = boost::shared_ptr <PrivateTexture>
(new PrivateTexture (this, priv->screen));
}
bool
-CompTexture::hasPixmap ()
+GLTexture::hasPixmap ()
{
return (priv->pixmap != None);
}
diff --git a/src/vector.cpp b/plugins/opengl/vector.cpp
index e61a5ff..2de0f4d 100644
--- a/src/vector.cpp
+++ b/plugins/opengl/vector.cpp
@@ -23,14 +23,14 @@
#include <string.h>
#include <math.h>
-#include <compvector.h>
+#include <opengl/vector.h>
-CompVector::CompVector ()
+GLVector::GLVector ()
{
memset (v, 0, sizeof (v));
}
-CompVector::CompVector (float x,
+GLVector::GLVector (float x,
float y,
float z,
float w)
@@ -42,33 +42,33 @@ CompVector::CompVector (float x,
}
float&
-CompVector::operator[] (int item)
+GLVector::operator[] (int item)
{
return v[item];
}
float&
-CompVector::operator[] (VectorCoordsEnum coord)
+GLVector::operator[] (VectorCoordsEnum coord)
{
int item = (int) coord;
return v[item];
}
const float
-CompVector::operator[] (int item) const
+GLVector::operator[] (int item) const
{
return v[item];
}
const float
-CompVector::operator[] (VectorCoordsEnum coord) const
+GLVector::operator[] (VectorCoordsEnum coord) const
{
int item = (int) coord;
return v[item];
}
-CompVector&
-CompVector::operator+= (const CompVector& rhs)
+GLVector&
+GLVector::operator+= (const GLVector& rhs)
{
int i;
@@ -78,11 +78,11 @@ CompVector::operator+= (const CompVector& rhs)
return *this;
}
-CompVector
-operator+ (const CompVector& lhs,
- const CompVector& rhs)
+GLVector
+operator+ (const GLVector& lhs,
+ const GLVector& rhs)
{
- CompVector result;
+ GLVector result;
int i;
for (i = 0; i < 4; i++)
@@ -91,8 +91,8 @@ operator+ (const CompVector& lhs,
return result;
}
-CompVector&
-CompVector::operator-= (const CompVector& rhs)
+GLVector&
+GLVector::operator-= (const GLVector& rhs)
{
int i;
@@ -102,11 +102,11 @@ CompVector::operator-= (const CompVector& rhs)
return *this;
}
-CompVector
-operator- (const CompVector& lhs,
- const CompVector& rhs)
+GLVector
+operator- (const GLVector& lhs,
+ const GLVector& rhs)
{
- CompVector result;
+ GLVector result;
int i;
for (i = 0; i < 4; i++)
@@ -115,10 +115,10 @@ operator- (const CompVector& lhs,
return result;
}
-CompVector
-operator- (const CompVector& vector)
+GLVector
+operator- (const GLVector& vector)
{
- CompVector result;
+ GLVector result;
int i;
for (i = 0; i < 4; i++)
@@ -127,8 +127,8 @@ operator- (const CompVector& vector)
return result;
}
-CompVector&
-CompVector::operator*= (const float k)
+GLVector&
+GLVector::operator*= (const float k)
{
int i;
@@ -139,8 +139,8 @@ CompVector::operator*= (const float k)
}
float
-operator* (const CompVector& lhs,
- const CompVector& rhs)
+operator* (const GLVector& lhs,
+ const GLVector& rhs)
{
float result = 0;
int i;
@@ -151,11 +151,11 @@ operator* (const CompVector& lhs,
return result;
}
-CompVector
+GLVector
operator* (const float k,
- const CompVector& vector)
+ const GLVector& vector)
{
- CompVector result;
+ GLVector result;
int i;
for (i = 0; i < 4; i++)
@@ -164,15 +164,15 @@ operator* (const float k,
return result;
}
-CompVector
-operator* (const CompVector& vector,
+GLVector
+operator* (const GLVector& vector,
const float k)
{
return k * vector;
}
-CompVector&
-CompVector::operator/= (const float k)
+GLVector&
+GLVector::operator/= (const float k)
{
int i;
@@ -182,11 +182,11 @@ CompVector::operator/= (const float k)
return *this;
}
-CompVector
-operator/ (const CompVector& vector,
+GLVector
+operator/ (const GLVector& vector,
const float k)
{
- CompVector result;
+ GLVector result;
int i;
for (i = 0; i < 4; i++)
@@ -195,18 +195,18 @@ operator/ (const CompVector& vector,
return result;
}
-CompVector&
-CompVector::operator^= (const CompVector& vector)
+GLVector&
+GLVector::operator^= (const GLVector& vector)
{
*this = *this ^ vector;
return *this;
}
-CompVector
-operator^ (const CompVector& lhs,
- const CompVector& rhs)
+GLVector
+operator^ (const GLVector& lhs,
+ const GLVector& rhs)
{
- CompVector result;
+ GLVector result;
result[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1];
result[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2];
diff --git a/plugins/opengl/window.cpp b/plugins/opengl/window.cpp
new file mode 100644
index 0000000..40a9cca
--- /dev/null
+++ b/plugins/opengl/window.cpp
@@ -0,0 +1,219 @@
+#include "privates.h"
+
+GLWindow::GLWindow (CompWindow *w) :
+ OpenGLPrivateHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI> (w),
+ priv (new PrivateGLWindow (w, this))
+{
+ WRAPABLE_INIT_HND(glPaint);
+ WRAPABLE_INIT_HND(glDraw);
+ WRAPABLE_INIT_HND(glAddGeometry);
+ WRAPABLE_INIT_HND(glDrawTexture);
+ WRAPABLE_INIT_HND(glDrawGeometry);
+
+ priv->clip = XCreateRegion ();
+ assert (priv->clip);
+
+ CompositeWindow *cw = CompositeWindow::get (w);
+
+ priv->paint.opacity = cw->opacity ();
+ priv->paint.brightness = cw->brightness ();
+ priv->paint.saturation = cw->saturation ();
+
+ priv->lastPaint = priv->paint;
+
+}
+
+GLWindow::~GLWindow ()
+{
+ delete priv;
+}
+
+PrivateGLWindow::PrivateGLWindow (CompWindow *w,
+ GLWindow *gw) :
+ window (w),
+ gWindow (gw),
+ cWindow (CompositeWindow::get (w)),
+ screen (w->screen ()),
+ gScreen (GLScreen::get (screen)),
+ texture (screen),
+ clip (0),
+ bindFailed (false),
+ vertices (0),
+ vertexSize (0),
+ vertexStride (0),
+ indices (0),
+ indexSize (0),
+ vCount (0),
+ texUnits (0),
+ texCoordSize (2),
+ indexCount (0)
+{
+ paint.xScale = 1.0f;
+ paint.yScale = 1.0f;
+ paint.xTranslate = 0.0f;
+ paint.yTranslate = 0.0f;
+
+ w->add (this);
+ WindowInterface::setHandler (w);
+
+ cWindow->add (this);
+ CompositeWindowInterface::setHandler (cWindow);
+}
+
+PrivateGLWindow::~PrivateGLWindow ()
+{
+
+ if (clip)
+ XDestroyRegion (clip);
+ if (vertices)
+ free (vertices);
+
+ if (indices)
+ free (indices);
+}
+
+void
+PrivateGLWindow::setWindowMatrix ()
+{
+ matrix = texture.matrix ();
+ matrix.x0 -= (window->attrib ().x * matrix.xx);
+ matrix.y0 -= (window->attrib ().y * matrix.yy);
+}
+
+bool
+GLWindow::bind ()
+{
+
+ if (!priv->cWindow->pixmap () && !priv->cWindow->bind ())
+ return false;
+
+ if (!priv->texture.bindPixmap (priv->cWindow->pixmap (),
+ priv->window->width (),
+ priv->window->height (),
+ priv->window->attrib ().depth))
+ {
+ compLogMessage (priv->screen->display (), "opengl", CompLogLevelInfo,
+ "Couldn't bind redirected window 0x%x to "
+ "texture\n", (int) priv->window->id ());
+ }
+
+ priv->setWindowMatrix ();
+
+ return true;
+}
+
+void
+GLWindow::release ()
+{
+ if (priv->cWindow->pixmap ())
+ {
+ priv->texture = GLTexture (priv->screen);
+ priv->cWindow->release ();
+ }
+}
+
+GLWindowInterface::GLWindowInterface ()
+{
+ WRAPABLE_INIT_FUNC(glPaint);
+ WRAPABLE_INIT_FUNC(glDraw);
+ WRAPABLE_INIT_FUNC(glAddGeometry);
+ WRAPABLE_INIT_FUNC(glDrawTexture);
+ WRAPABLE_INIT_FUNC(glDrawGeometry);
+
+}
+
+
+bool
+GLWindowInterface::glPaint (const GLWindowPaintAttrib &attrib,
+ const GLMatrix &transform,
+ Region region,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC_RETURN(glPaint, attrib, transform, region, mask)
+
+bool
+GLWindowInterface::glDraw (const GLMatrix &transform,
+ GLFragment::Attrib &fragment,
+ Region region,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC_RETURN(glDraw, transform, fragment, region, mask)
+
+void
+GLWindowInterface::glAddGeometry (GLTexture::Matrix *matrix,
+ int nMatrix,
+ Region region,
+ Region clip)
+ WRAPABLE_DEF_FUNC(glAddGeometry, matrix, nMatrix, region, clip)
+
+void
+GLWindowInterface::glDrawTexture (GLTexture *texture,
+ GLFragment::Attrib &fragment,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC(glDrawTexture, texture, fragment, mask)
+
+void
+GLWindowInterface::glDrawGeometry ()
+ WRAPABLE_DEF_FUNC(glDrawGeometry)
+
+Region
+GLWindow::clip ()
+{
+ return priv->clip;
+}
+
+GLWindowPaintAttrib &
+GLWindow::paintAttrib ()
+{
+ return priv->paint;
+}
+
+void
+PrivateGLWindow::resizeNotify (int dx, int dy, int dwidth, int dheight)
+{
+ window->resizeNotify (dx, dy, dwidth, dheight);
+ setWindowMatrix ();
+ gWindow->release ();
+}
+
+void
+PrivateGLWindow::moveNotify (int dx, int dy, bool now)
+{
+ window->moveNotify (dx, dy, now);
+ setWindowMatrix ();
+}
+
+void
+PrivateGLWindow::windowNotify (CompWindowNotify n)
+{
+ if (n == CompWindowNotifyAliveChanged)
+ {
+ gWindow->updatePaintAttribs ();
+ }
+
+ window->windowNotify (n);
+}
+
+void
+GLWindow::updatePaintAttribs ()
+{
+ CompositeWindow *cw = CompositeWindow::get (priv->window);
+
+ if (priv->window->alive ())
+ {
+ priv->paint.opacity = cw->opacity ();
+ priv->paint.brightness = cw->brightness ();
+ priv->paint.saturation = cw->saturation ();
+ }
+ else
+ {
+ priv->paint.opacity = cw->opacity ();
+ priv->paint.brightness = 0xa8a8;
+ priv->paint.saturation = 0;
+ }
+}
+
+bool
+PrivateGLWindow::damageRect (bool initial, BoxPtr box)
+{
+ texture.damage ();
+ return cWindow->damageRect (initial, box);
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 4696106..715647d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,28 +12,23 @@ bin_PROGRAMS = compiz
compiz_LDADD = @COMPIZ_LIBS@ @GL_LIBS@ -lm
compiz_LDFLAGS = -export-dynamic
compiz_SOURCES = \
+ display.cpp \
+ screen.cpp \
+ window.cpp \
metadata.cpp \
action.cpp \
option.cpp \
string.cpp \
- fragment.cpp \
match.cpp \
main.cpp \
object.cpp \
core.cpp \
- display.cpp \
- screen.cpp \
- window.cpp \
event.cpp \
- texture.cpp \
- paint.cpp \
plugin.cpp \
session.cpp \
- matrix.cpp \
output.cpp \
rect.cpp \
size.cpp \
point.cpp \
windowgeometry.cpp \
- icon.cpp \
- vector.cpp
+ icon.cpp
diff --git a/src/display.cpp b/src/display.cpp
index 5553030..cde39da 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -42,7 +42,6 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>
-#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/shape.h>
@@ -273,24 +272,6 @@ CompScreen::showDesktop (CompDisplay *d,
}
bool
-CompScreen::toggleSlowAnimations (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- s->priv->slowAnimations = !s->priv->slowAnimations;
-
- return true;
-}
-
-bool
CompWindow::raiseInitiate (CompDisplay *d,
CompAction *action,
CompAction::State state,
@@ -531,7 +512,6 @@ CompWindow::shade (CompDisplay *d,
const CompMetadata::OptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
{ "active_plugins", "list", "<type>string</type>", 0, 0 },
- { "texture_filter", "int", RESTOSTRING (0, 2), 0, 0 },
{ "click_to_focus", "bool", 0, 0, 0 },
{ "autoraise", "bool", 0, 0, 0 },
{ "autoraise_delay", "int", 0, 0, 0 },
@@ -563,7 +543,6 @@ const CompMetadata::OptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] =
{ "run_command9_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
{ "run_command10_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
{ "run_command11_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "slow_animations_key", "key", 0, CompScreen::toggleSlowAnimations, 0 },
{ "raise_window_key", "key", 0, CompWindow::raiseInitiate, 0 },
{ "raise_window_button", "button", 0, CompWindow::raiseInitiate, 0 },
{ "lower_window_key", "key", 0, CompWindow::lowerInitiate, 0 },
@@ -745,8 +724,6 @@ CompDisplay::init (const char *name)
{
Window focus;
int revertTo, i;
- int compositeMajor, compositeMinor;
- int fixesMinor;
int xkbOpcode;
int firstScreen, lastScreen;
@@ -789,33 +766,6 @@ CompDisplay::init (const char *name)
priv->lastPing = 1;
- if (!XQueryExtension (priv->dpy,
- COMPOSITE_NAME,
- &priv->compositeOpcode,
- &priv->compositeEvent,
- &priv->compositeError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No composite extension");
- return false;
- }
-
- XCompositeQueryVersion (priv->dpy, &compositeMajor, &compositeMinor);
- if (compositeMajor == 0 && compositeMinor < 2)
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "Old composite extension");
- return false;
- }
-
- if (!XDamageQueryExtension (priv->dpy, &priv->damageEvent,
- &priv->damageError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No damage extension");
- return false;
- }
-
if (!XSyncQueryExtension (priv->dpy, &priv->syncEvent, &priv->syncError))
{
compLogMessage (this, "core", CompLogLevelFatal,
@@ -823,15 +773,6 @@ CompDisplay::init (const char *name)
return false;
}
- if (!XFixesQueryExtension (priv->dpy, &priv->fixesEvent, &priv->fixesError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No fixes extension");
- return false;
- }
-
- XFixesQueryVersion (priv->dpy, &priv->fixesVersion, &fixesMinor);
-
priv->randrExtension = XRRQueryExtension (priv->dpy, &priv->randrEvent,
&priv->randrError);
@@ -956,12 +897,6 @@ CompDisplay::screens ()
return priv->screens;
}
-GLenum
-CompDisplay::textureFilter ()
-{
- return priv->textureFilter;
-}
-
CompOption *
CompDisplay::getOption (const char *name)
{
@@ -1169,20 +1104,6 @@ CompDisplay::setOption (const char *name,
return true;
}
break;
- case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
- if (o->set (value))
- {
- foreach (CompScreen *s, priv->screens)
- s->damageScreen ();
-
- if (!o->value ().i ())
- priv->textureFilter = GL_NEAREST;
- else
- priv->textureFilter = GL_LINEAR;
-
- return true;
- }
- break;
case COMP_DISPLAY_OPTION_PING_DELAY:
if (o->set (value))
{
@@ -1348,6 +1269,10 @@ CompDisplay::processEvents ()
{
XEvent event;
+ /* remove destroyed windows */
+ foreach (CompScreen *s, priv->screens)
+ s->removeDestroyed ();
+
if (priv->dirtyPluginList)
priv->updatePlugins ();
@@ -1670,13 +1595,6 @@ PrivateDisplay::handleSelectionClear (XEvent *event)
}
-void
-CompDisplay::clearTargetOutput (unsigned int mask)
-{
- if (targetScreen)
- targetScreen->clearOutput (targetOutput, mask);
-}
-
#define HOME_IMAGEDIR ".compiz/images"
bool
@@ -2459,7 +2377,6 @@ PrivateDisplay::PrivateDisplay (CompDisplay *display) :
screens (),
watchFdHandle (0),
screenInfo (0),
- textureFilter (GL_LINEAR),
activeWindow (0),
below (None),
modMap (0),
diff --git a/src/event.cpp b/src/event.cpp
index b2eb09c..b83a86b 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -44,46 +44,7 @@
static Window xdndWindow = None;
static Window edgeWindow = None;
-void
-PrivateWindow::handleDamageRect (CompWindow *w,
- int x,
- int y,
- int width,
- int height)
-{
- REGION region;
- bool initial = false;
-
- if (!w->priv->redirected || w->priv->bindFailed)
- return;
- if (!w->priv->damaged)
- {
- w->priv->damaged = initial = true;
- w->priv->invisible = WINDOW_INVISIBLE (w->priv);
- }
-
- region.extents.x1 = x;
- region.extents.y1 = y;
- region.extents.x2 = region.extents.x1 + width;
- region.extents.y2 = region.extents.y1 + height;
-
- if (!w->damageRect (initial, &region.extents))
- {
- region.extents.x1 += w->priv->attrib.x + w->priv->attrib.border_width;
- region.extents.y1 += w->priv->attrib.y + w->priv->attrib.border_width;
- region.extents.x2 += w->priv->attrib.x + w->priv->attrib.border_width;
- region.extents.y2 += w->priv->attrib.y + w->priv->attrib.border_width;
-
- region.rects = &region.extents;
- region.numRects = region.size = 1;
-
- w->priv->screen->damageRegion (&region);
- }
-
- if (initial)
- w->damageOutputExtents ();
-}
bool
CompWindow::handleSyncAlarm ()
@@ -94,21 +55,7 @@ CompWindow::handleSyncAlarm ()
if (resize (priv->syncGeometry))
{
- XRectangle *rects;
- int nDamage;
-
- nDamage = priv->nDamage;
- rects = priv->damageRects;
- while (nDamage--)
- {
- PrivateWindow::handleDamageRect (this,
- rects[nDamage].x,
- rects[nDamage].y,
- rects[nDamage].width,
- rects[nDamage].height);
- }
-
- priv->nDamage = 0;
+ windowNotify (CompWindowNotifySyncAlarm);
}
else
{
@@ -1012,28 +959,6 @@ PrivateDisplay::handleActionEvent (XEvent *event)
}
void
-CompScreen::handleExposeEvent (XExposeEvent *event)
-{
- if (priv->output == event->window)
- return;
-
- priv->exposeRects.push_back (CompRect (event->x, event->x + event->width,
- event->y, event->y + event->height));
-
- if (event->count == 0)
- {
- CompRect rect;
- while (!priv->exposeRects.empty())
- {
- rect = priv->exposeRects.front ();
- priv->exposeRects.pop_front ();
-
- damageRegion (rect.region ());
- }
- }
-}
-
-void
CompDisplay::handleCompizEvent (const char *plugin,
const char *event,
CompOption *option,
@@ -1080,10 +1005,6 @@ CompDisplay::handleEvent (XEvent *event)
}
switch (event->type) {
- case Expose:
- foreach (s, priv->screens)
- s->handleExposeEvent (&event->xexpose);
- break;
case SelectionRequest:
priv->handleSelectionRequest (event);
break;
@@ -1107,13 +1028,8 @@ CompDisplay::handleEvent (XEvent *event)
s = findScreen (event->xcreatewindow.parent);
if (s)
{
- /* The first time some client asks for the composite
- * overlay window, the X server creates it, which causes
- * an errorneous CreateNotify event. We catch it and
- * ignore it. */
- if (s->overlay () != event->xcreatewindow.window)
- new CompWindow (s, event->xcreatewindow.window,
- s->getTopWindow ());
+ new CompWindow (s, event->xcreatewindow.window,
+ s->getTopWindow ());
}
break;
case DestroyNotify:
@@ -1320,31 +1236,6 @@ CompDisplay::handleEvent (XEvent *event)
if (w)
w->updateIconGeometry ();
}
- else if (event->xproperty.atom == priv->atoms.winOpacity)
- {
- w = findWindow (event->xproperty.window);
- if (w)
- w->updateOpacity ();
- }
- else if (event->xproperty.atom == priv->atoms.winBrightness)
- {
- w = findWindow (event->xproperty.window);
- if (w)
- w->updateBrightness ();
- }
- else if (event->xproperty.atom == priv->atoms.winSaturation)
- {
- w = findWindow (event->xproperty.window);
- if (w)
- w->updateSaturation ();
- }
- else if (event->xproperty.atom == priv->atoms.xBackground[0] ||
- event->xproperty.atom == priv->atoms.xBackground[1])
- {
- s = findScreen (event->xproperty.window);
- if (s)
- s->updateBackground ();
- }
else if (event->xproperty.atom == priv->atoms.wmStrut ||
event->xproperty.atom == priv->atoms.wmStrutPartial)
{
@@ -1403,38 +1294,6 @@ CompDisplay::handleEvent (XEvent *event)
}
}
}
- else if (event->xclient.message_type == priv->atoms.winOpacity)
- {
- w = findWindow (event->xclient.window);
- if (w && (w->type () & CompWindowTypeDesktopMask) == 0)
- {
- GLushort opacity = event->xclient.data.l[0] >> 16;
-
- setWindowProp32 (w->id (), priv->atoms.winOpacity, opacity);
- }
- }
- else if (event->xclient.message_type == priv->atoms.winBrightness)
- {
- w = findWindow (event->xclient.window);
- if (w)
- {
- GLushort brightness = event->xclient.data.l[0] >> 16;
-
- setWindowProp32 (w->id (), priv->atoms.winBrightness,
- brightness);
- }
- }
- else if (event->xclient.message_type == priv->atoms.winSaturation)
- {
- w = findWindow (event->xclient.window);
- if (w)
- {
- GLushort saturation = event->xclient.data.l[0] >> 16;
-
- setWindowProp32 (w->id (), priv->atoms.winSaturation,
- saturation);
- }
- }
else if (event->xclient.message_type == priv->atoms.winState)
{
w = findWindow (event->xclient.window);
@@ -1865,49 +1724,16 @@ CompDisplay::handleEvent (XEvent *event)
}
break;
default:
- if (event->type == priv->damageEvent + XDamageNotify)
- {
- XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
-
- if (lastDamagedWindow && de->drawable == lastDamagedWindow->id ())
- {
- w = lastDamagedWindow;
- }
- else
- {
- w = findWindow (de->drawable);
- if (w)
- lastDamagedWindow = w;
- }
-
- if (w)
- w->processDamage (de);
- }
- else if (priv->shapeExtension &&
+ if (priv->shapeExtension &&
event->type == priv->shapeEvent + ShapeNotify)
{
w = findWindow (((XShapeEvent *) event)->window);
if (w)
{
if (w->mapNum ())
- {
- w->addDamage ();
w->updateRegion ();
- w->addDamage ();
- }
}
}
- else if (priv->randrExtension &&
- event->type == priv->randrEvent + RRScreenChangeNotify)
- {
- XRRScreenChangeNotifyEvent *rre;
-
- rre = (XRRScreenChangeNotifyEvent *) event;
-
- s = findScreen (rre->root);
- if (s)
- s->detectRefreshRate ();
- }
else if (event->type == priv->syncEvent + XSyncAlarmNotify)
{
XSyncAlarmNotifyEvent *sa;
diff --git a/src/icon.cpp b/src/icon.cpp
index f15a278..5dcdd0d 100644
--- a/src/icon.cpp
+++ b/src/icon.cpp
@@ -2,7 +2,6 @@
CompIcon::CompIcon (CompScreen *screen, unsigned int width,
unsigned int height) :
- mTexture (screen),
mWidth (width),
mHeight (height),
mData (new unsigned char[width * height * 4]),
@@ -12,21 +11,7 @@ CompIcon::CompIcon (CompScreen *screen, unsigned int width,
CompIcon::~CompIcon ()
{
- free (mData);
-}
-
-CompTexture &
-CompIcon::texture ()
-{
- if (mUpdateTex)
- {
- mUpdateTex = false;
- mTexture.reset ();
- if (!mTexture.imageBufferToTexture (&mTexture,
- reinterpret_cast<const char *> (mData), mWidth, mHeight))
- mTexture.reset ();
- }
- return mTexture;
+ delete mData;
}
unsigned int
diff --git a/src/main.cpp b/src/main.cpp
index bc27859..cb7c675 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -49,17 +49,11 @@ char *backgroundImage = NULL;
REGION emptyRegion;
REGION infiniteRegion;
-GLushort defaultColor[4] = { 0xffff, 0xffff, 0xffff, 0xffff };
-Window currentRoot = 0;
-
-int defaultRefreshRate = 50;
-const char *defaultTextureFilter = "Good";
bool shutDown = false;
bool restartSignal = false;
CompWindow *lastFoundWindow = 0;
-CompWindow *lastDamagedWindow = 0;
bool replaceCurrentWm = false;
bool indirectRendering = false;
@@ -68,9 +62,7 @@ bool noDetection = false;
bool useDesktopHints = true;
bool onlyCurrentScreen = false;
-#ifdef USE_COW
bool useCow = true;
-#endif
CompMetadata *coreMetadata = NULL;
@@ -80,8 +72,6 @@ usage (void)
printf ("Usage: %s "
"[--display DISPLAY] "
"[--bg-image PNG] "
- "[--refresh-rate RATE]\n "
- "[--fast-filter] "
"[--indirect-rendering] "
"[--loose-binding] "
"[--replace]\n "
@@ -90,13 +80,7 @@ usage (void)
"[--no-detection]\n "
"[--ignore-desktop-hints] "
"[--only-current-screen]"
-
-#ifdef USE_COW
" [--use-root-window]\n "
-#else
- "\n "
-#endif
-
"[--version] "
"[--help] "
"[PLUGIN]...\n",
@@ -127,8 +111,6 @@ signalHandler (int sig)
typedef struct _CompIOCtx {
unsigned int offset;
char *pluginData;
- char *textureFilterData;
- char *refreshRateData;
} CompIOCtx;
static int
@@ -152,9 +134,6 @@ readCoreXmlCallback (void *context,
if (ctx->pluginData)
info.data = ctx->pluginData;
break;
- case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
- if (ctx->textureFilterData)
- info.data = ctx->textureFilterData;
default:
break;
}
@@ -163,28 +142,9 @@ readCoreXmlCallback (void *context,
buffer + i, length - i);
}
- i += CompMetadata::readXmlChunk ("</display><screen>", &offset,
+ i += CompMetadata::readXmlChunk ("</display></core></compiz>", &offset,
buffer + i, length - 1);
- for (j = 0; j < COMP_SCREEN_OPTION_NUM; j++)
- {
- CompMetadata::OptionInfo info = coreScreenOptionInfo[j];
-
- switch (j) {
- case COMP_SCREEN_OPTION_REFRESH_RATE:
- if (ctx->refreshRateData)
- info.data = ctx->refreshRateData;
- default:
- break;
- }
-
- i += CompMetadata::readXmlChunkFromOptionInfo (&info, &offset,
- buffer + i, length - i);
- }
-
- i += CompMetadata::readXmlChunk ("</screen></core></compiz>", &offset,
- buffer + i, length - i);
-
if (!offset && length > (int)i)
buffer[i++] = '\0';
@@ -202,7 +162,6 @@ main (int argc, char **argv)
int i, nPlugin = 0;
Bool disableSm = FALSE;
char *clientId = NULL;
- char *refreshRateArg = NULL;
programName = argv[0];
programArgc = argc;
@@ -247,22 +206,6 @@ main (int argc, char **argv)
if (i + 1 < argc)
displayName = argv[++i];
}
- else if (!strcmp (argv[i], "--refresh-rate"))
- {
- if (i + 1 < argc)
- {
- refreshRateArg = programArgv[++i];
- defaultRefreshRate = atoi (refreshRateArg);
- defaultRefreshRate = RESTRICT_VALUE (defaultRefreshRate,
- 1, 1000);
- }
- }
- else if (!strcmp (argv[i], "--fast-filter"))
- {
- ctx.textureFilterData =
- const_cast<char *> ("<default>Fast</default>");
- defaultTextureFilter = "Fast";
- }
else if (!strcmp (argv[i], "--indirect-rendering"))
{
indirectRendering = TRUE;
@@ -279,14 +222,10 @@ main (int argc, char **argv)
{
onlyCurrentScreen = TRUE;
}
-
-#ifdef USE_COW
else if (!strcmp (argv[i], "--use-root-window"))
{
useCow = FALSE;
}
-#endif
-
else if (!strcmp (argv[i], "--replace"))
{
replaceCurrentWm = TRUE;
@@ -321,15 +260,6 @@ main (int argc, char **argv)
}
}
- if (refreshRateArg)
- {
- ctx.refreshRateData = (char *) malloc (strlen (refreshRateArg) + 256);
- if (ctx.refreshRateData)
- sprintf (ctx.refreshRateData,
- "<min>1</min><default>%s</default>",
- refreshRateArg);
- }
-
if (nPlugin)
{
int size = 256;
@@ -360,9 +290,6 @@ main (int argc, char **argv)
if (!coreMetadata->addFromIO (readCoreXmlCallback, NULL, &ctx))
return 1;
- if (ctx.refreshRateData)
- free (ctx.refreshRateData);
-
if (ctx.pluginData)
free (ctx.pluginData);
diff --git a/src/option.cpp b/src/option.cpp
index 4178756..d100a8c 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -210,6 +210,8 @@ CompOption::Value::f ()
return priv->value.f;
}
+static unsigned short defaultColor[4] = { 0x0, 0x0, 0x0, 0xffff};
+
unsigned short*
CompOption::Value::c ()
{
diff --git a/src/privatedisplay.h b/src/privatedisplay.h
index aaf3f3c..8a852b2 100644
--- a/src/privatedisplay.h
+++ b/src/privatedisplay.h
@@ -8,71 +8,69 @@
#include <compmetadata.h>
#define COMP_DISPLAY_OPTION_ACTIVE_PLUGINS 0
-#define COMP_DISPLAY_OPTION_TEXTURE_FILTER 1
-#define COMP_DISPLAY_OPTION_CLICK_TO_FOCUS 2
-#define COMP_DISPLAY_OPTION_AUTORAISE 3
-#define COMP_DISPLAY_OPTION_AUTORAISE_DELAY 4
-#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_KEY 5
-#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_BUTTON 6
-#define COMP_DISPLAY_OPTION_MAIN_MENU_KEY 7
-#define COMP_DISPLAY_OPTION_RUN_DIALOG_KEY 8
-#define COMP_DISPLAY_OPTION_COMMAND0 9
-#define COMP_DISPLAY_OPTION_COMMAND1 10
-#define COMP_DISPLAY_OPTION_COMMAND2 11
-#define COMP_DISPLAY_OPTION_COMMAND3 12
-#define COMP_DISPLAY_OPTION_COMMAND4 13
-#define COMP_DISPLAY_OPTION_COMMAND5 14
-#define COMP_DISPLAY_OPTION_COMMAND6 15
-#define COMP_DISPLAY_OPTION_COMMAND7 16
-#define COMP_DISPLAY_OPTION_COMMAND8 17
-#define COMP_DISPLAY_OPTION_COMMAND9 18
-#define COMP_DISPLAY_OPTION_COMMAND10 19
-#define COMP_DISPLAY_OPTION_COMMAND11 20
-#define COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY 21
-#define COMP_DISPLAY_OPTION_RUN_COMMAND1_KEY 22
-#define COMP_DISPLAY_OPTION_RUN_COMMAND2_KEY 23
-#define COMP_DISPLAY_OPTION_RUN_COMMAND3_KEY 24
-#define COMP_DISPLAY_OPTION_RUN_COMMAND4_KEY 25
-#define COMP_DISPLAY_OPTION_RUN_COMMAND5_KEY 26
-#define COMP_DISPLAY_OPTION_RUN_COMMAND6_KEY 27
-#define COMP_DISPLAY_OPTION_RUN_COMMAND7_KEY 28
-#define COMP_DISPLAY_OPTION_RUN_COMMAND8_KEY 29
-#define COMP_DISPLAY_OPTION_RUN_COMMAND9_KEY 30
-#define COMP_DISPLAY_OPTION_RUN_COMMAND10_KEY 31
-#define COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY 32
-#define COMP_DISPLAY_OPTION_SLOW_ANIMATIONS_KEY 33
-#define COMP_DISPLAY_OPTION_RAISE_WINDOW_KEY 34
-#define COMP_DISPLAY_OPTION_RAISE_WINDOW_BUTTON 35
-#define COMP_DISPLAY_OPTION_LOWER_WINDOW_KEY 36
-#define COMP_DISPLAY_OPTION_LOWER_WINDOW_BUTTON 37
-#define COMP_DISPLAY_OPTION_UNMAXIMIZE_WINDOW_KEY 38
-#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_KEY 39
-#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_BUTTON 40
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_KEY 41
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 42
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_VERT_KEY 43
-#define COMP_DISPLAY_OPTION_SCREENSHOT 44
-#define COMP_DISPLAY_OPTION_RUN_SCREENSHOT_KEY 45
-#define COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT 46
-#define COMP_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY 47
-#define COMP_DISPLAY_OPTION_WINDOW_MENU_BUTTON 48
-#define COMP_DISPLAY_OPTION_WINDOW_MENU_KEY 49
-#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_KEY 50
-#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_EDGE 51
-#define COMP_DISPLAY_OPTION_RAISE_ON_CLICK 52
-#define COMP_DISPLAY_OPTION_AUDIBLE_BELL 53
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 54
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 55
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 56
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 57
-#define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 58
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED_KEY 59
-#define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 60
-#define COMP_DISPLAY_OPTION_TERMINAL 61
-#define COMP_DISPLAY_OPTION_RUN_TERMINAL_KEY 62
-#define COMP_DISPLAY_OPTION_PING_DELAY 63
-#define COMP_DISPLAY_OPTION_EDGE_DELAY 64
-#define COMP_DISPLAY_OPTION_NUM 65
+#define COMP_DISPLAY_OPTION_CLICK_TO_FOCUS 1
+#define COMP_DISPLAY_OPTION_AUTORAISE 2
+#define COMP_DISPLAY_OPTION_AUTORAISE_DELAY 3
+#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_KEY 4
+#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_BUTTON 5
+#define COMP_DISPLAY_OPTION_MAIN_MENU_KEY 6
+#define COMP_DISPLAY_OPTION_RUN_DIALOG_KEY 7
+#define COMP_DISPLAY_OPTION_COMMAND0 8
+#define COMP_DISPLAY_OPTION_COMMAND1 9
+#define COMP_DISPLAY_OPTION_COMMAND2 10
+#define COMP_DISPLAY_OPTION_COMMAND3 11
+#define COMP_DISPLAY_OPTION_COMMAND4 12
+#define COMP_DISPLAY_OPTION_COMMAND5 13
+#define COMP_DISPLAY_OPTION_COMMAND6 14
+#define COMP_DISPLAY_OPTION_COMMAND7 15
+#define COMP_DISPLAY_OPTION_COMMAND8 16
+#define COMP_DISPLAY_OPTION_COMMAND9 17
+#define COMP_DISPLAY_OPTION_COMMAND10 18
+#define COMP_DISPLAY_OPTION_COMMAND11 19
+#define COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY 20
+#define COMP_DISPLAY_OPTION_RUN_COMMAND1_KEY 21
+#define COMP_DISPLAY_OPTION_RUN_COMMAND2_KEY 22
+#define COMP_DISPLAY_OPTION_RUN_COMMAND3_KEY 23
+#define COMP_DISPLAY_OPTION_RUN_COMMAND4_KEY 24
+#define COMP_DISPLAY_OPTION_RUN_COMMAND5_KEY 25
+#define COMP_DISPLAY_OPTION_RUN_COMMAND6_KEY 26
+#define COMP_DISPLAY_OPTION_RUN_COMMAND7_KEY 27
+#define COMP_DISPLAY_OPTION_RUN_COMMAND8_KEY 28
+#define COMP_DISPLAY_OPTION_RUN_COMMAND9_KEY 29
+#define COMP_DISPLAY_OPTION_RUN_COMMAND10_KEY 30
+#define COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY 31
+#define COMP_DISPLAY_OPTION_RAISE_WINDOW_KEY 32
+#define COMP_DISPLAY_OPTION_RAISE_WINDOW_BUTTON 33
+#define COMP_DISPLAY_OPTION_LOWER_WINDOW_KEY 34
+#define COMP_DISPLAY_OPTION_LOWER_WINDOW_BUTTON 35
+#define COMP_DISPLAY_OPTION_UNMAXIMIZE_WINDOW_KEY 36
+#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_KEY 37
+#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_BUTTON 38
+#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_KEY 39
+#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 40
+#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_VERT_KEY 41
+#define COMP_DISPLAY_OPTION_SCREENSHOT 42
+#define COMP_DISPLAY_OPTION_RUN_SCREENSHOT_KEY 43
+#define COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT 44
+#define COMP_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY 45
+#define COMP_DISPLAY_OPTION_WINDOW_MENU_BUTTON 46
+#define COMP_DISPLAY_OPTION_WINDOW_MENU_KEY 47
+#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_KEY 48
+#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_EDGE 49
+#define COMP_DISPLAY_OPTION_RAISE_ON_CLICK 50
+#define COMP_DISPLAY_OPTION_AUDIBLE_BELL 51
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 52
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 53
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 54
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 55
+#define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 56
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED_KEY 57
+#define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 58
+#define COMP_DISPLAY_OPTION_TERMINAL 59
+#define COMP_DISPLAY_OPTION_RUN_TERMINAL_KEY 60
+#define COMP_DISPLAY_OPTION_PING_DELAY 61
+#define COMP_DISPLAY_OPTION_EDGE_DELAY 62
+#define COMP_DISPLAY_OPTION_NUM 63
extern const CompMetadata::OptionInfo
coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM];
@@ -161,10 +159,7 @@ class PrivateDisplay {
CompWatchFdHandle watchFdHandle;
- int compositeEvent, compositeError, compositeOpcode;
- int damageEvent, damageError;
int syncEvent, syncError;
- int fixesEvent, fixesError, fixesVersion;
bool randrExtension;
int randrEvent, randrError;
@@ -185,8 +180,6 @@ class PrivateDisplay {
unsigned int lastPing;
CompCore::Timer pingTimer;
- GLenum textureFilter;
-
Window activeWindow;
Window below;
diff --git a/src/privatescreen.h b/src/privatescreen.h
index d2c1660..028af17 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -5,49 +5,25 @@
#include <compscreen.h>
#include <compsize.h>
#include <comppoint.h>
-#include <comptexture.h>
-#include <compfragment.h>
-#include "privatefragment.h"
-
-extern char *backgroundImage;
-
-extern Window currentRoot;
extern CompWindow *lastFoundWindow;
extern CompWindow *lastDamagedWindow;
-extern bool replaceCurrentWm;
-extern bool indirectRendering;
-extern bool strictBinding;
-extern bool useCow;
-extern bool noDetection;
extern bool useDesktopHints;
extern bool onlyCurrentScreen;
extern int defaultRefreshRate;
extern const char *defaultTextureFilter;
-#define RED_SATURATION_WEIGHT 0.30f
-#define GREEN_SATURATION_WEIGHT 0.59f
-#define BLUE_SATURATION_WEIGHT 0.11f
-
-#define COMP_SCREEN_OPTION_DETECT_REFRESH_RATE 0
-#define COMP_SCREEN_OPTION_LIGHTING 1
-#define COMP_SCREEN_OPTION_REFRESH_RATE 2
-#define COMP_SCREEN_OPTION_HSIZE 3
-#define COMP_SCREEN_OPTION_VSIZE 4
-#define COMP_SCREEN_OPTION_OPACITY_STEP 5
-#define COMP_SCREEN_OPTION_UNREDIRECT_FS 6
-#define COMP_SCREEN_OPTION_DEFAULT_ICON 7
-#define COMP_SCREEN_OPTION_SYNC_TO_VBLANK 8
-#define COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS 9
-#define COMP_SCREEN_OPTION_DETECT_OUTPUTS 10
-#define COMP_SCREEN_OPTION_OUTPUTS 11
-#define COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS 12
-#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_LEVEL 13
-#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_MATCH 14
-#define COMP_SCREEN_OPTION_TEXTURE_COMPRESSION 15
-#define COMP_SCREEN_OPTION_FORCE_INDEPENDENT 16
-#define COMP_SCREEN_OPTION_NUM 17
+#define COMP_SCREEN_OPTION_HSIZE 0
+#define COMP_SCREEN_OPTION_VSIZE 1
+#define COMP_SCREEN_OPTION_DEFAULT_ICON 2
+#define COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS 3
+#define COMP_SCREEN_OPTION_DETECT_OUTPUTS 4
+#define COMP_SCREEN_OPTION_OUTPUTS 5
+#define COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS 6
+#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_LEVEL 7
+#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_MATCH 8
+#define COMP_SCREEN_OPTION_NUM 9
#define OUTPUT_OVERLAP_MODE_SMART 0
#define OUTPUT_OVERLAP_MODE_PREFER_LARGER 1
@@ -60,10 +36,6 @@ extern const char *defaultTextureFilter;
#define FOCUS_PREVENTION_LEVEL_VERYHIGH 3
#define FOCUS_PREVENTION_LEVEL_LAST FOCUS_PREVENTION_LEVEL_VERYHIGH
-#define COMP_SCREEN_DAMAGE_PENDING_MASK (1 << 0)
-#define COMP_SCREEN_DAMAGE_REGION_MASK (1 << 1)
-#define COMP_SCREEN_DAMAGE_ALL_MASK (1 << 2)
-
extern const CompMetadata::OptionInfo
coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM];
@@ -124,9 +96,6 @@ class PrivateScreen {
void
reshape (int w, int h);
- void
- updateScreenBackground (CompTexture *texture);
-
bool
handleStartupSequenceTimeout();
@@ -146,9 +115,6 @@ class PrivateScreen {
getDesktopHints ();
void
- makeOutputWindow ();
-
- void
grabUngrabOneKey (unsigned int modifiers,
int keycode,
bool grab);
@@ -177,15 +143,7 @@ class PrivateScreen {
void
computeWorkareaForBox (BoxPtr pBox, XRectangle *area);
- void
- paintBackground (Region region,
- bool transformed);
- void
- paintOutputRegion (const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask);
public:
@@ -202,29 +160,14 @@ class PrivateScreen {
unsigned int nDesktop;
unsigned int currentDesktop;
REGION region;
- Region damage;
- unsigned long damageMask;
+
Window root;
- Window overlay;
- Window output;
+
XWindowAttributes attrib;
Window grabWindow;
- CompFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1];
- int textureRectangle;
- int textureNonPowerOfTwo;
- int textureEnvCombine;
- int textureEnvCrossbar;
- int textureBorderClamp;
- int textureCompression;
- GLint maxTextureSize;
- int fbo;
- int fragmentProgram;
- int maxTextureUnits;
+
Cursor invisibleCursor;
- std::list <CompRect> exposeRects;
- CompTexture backgroundTexture;
- Bool backgroundLoaded;
- unsigned int pendingDestroys;
+
int desktopWindowCount;
unsigned int mapNum;
unsigned int activeNum;
@@ -234,31 +177,21 @@ class PrivateScreen {
CompOutput fullscreenOutput;
bool hasOverlappingOutputs;
-
- CompPoint windowPaintOffset;
-
XRectangle lastViewport;
CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
int currentHistory;
- int overlayWindowCount;
-
CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
SnMonitorContext *snContext;
std::list<CompStartupSequence *> startupSequences;
CompCore::Timer startupSequenceTimer;
- CompTexture::Filter filter[3];
-
std::list<CompGroup *> groups;
CompIcon *defaultIcon;
- Bool canDoSaturated;
- Bool canDoSlightlySaturated;
-
Window wmSnSelectionWindow;
Atom wmSnAtom;
Time wmSnTimestamp;
@@ -274,25 +207,8 @@ class PrivateScreen {
std::list<Grab *> grabs;
- CompPoint rasterPos;
- struct timeval lastRedraw;
- int nextRedraw;
- int redrawTime;
- int optimalRedrawTime;
- int frameStatus;
- int timeMult;
- Bool idle;
- int timeLeft;
- Bool pendingCommands;
-
- CompFragment::Storage fragmentStorage;
-
- GLfloat projection[16];
-
- Bool clearBuffers;
-
- Bool lighting;
- Bool slowAnimations;
+ unsigned int pendingDestroys;
+
XRectangle workArea;
@@ -301,17 +217,10 @@ class PrivateScreen {
unsigned long *desktopHintData;
int desktopHintSize;
- GLXContext ctx;
-
- CompOption::Vector opt;
-
- CompCore::Timer paintTimer;
- GLXGetProcAddressProc getProcAddress;
+ CompOption::Vector opt;
- Region tmpRegion;
- Region outputRegion;
};
#endif
diff --git a/src/privatetexture.h b/src/privatetexture.h
deleted file mode 100644
index 809925f..0000000
--- a/src/privatetexture.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _PRIVATETEXTURE_H
-#define _PRIVATETEXTURE_H
-
-#include <comptexture.h>
-
-class CompScreen;
-
-class PrivateTexture {
- public:
- PrivateTexture (CompTexture *, CompScreen *);
- ~PrivateTexture ();
-
- bool loadImageData (const char *image,
- unsigned int width,
- unsigned int height,
- GLenum format,
- GLenum type);
-
- public:
- CompScreen *screen;
- CompTexture *texture;
- GLuint name;
- GLenum target;
- GLfloat dx, dy;
- GLXPixmap pixmap;
- GLenum filter;
- GLenum wrap;
- CompTexture::Matrix matrix;
- Bool damaged;
- Bool mipmap;
- unsigned int width;
- unsigned int height;
-};
-
-#endif
diff --git a/src/privatewindow.h b/src/privatewindow.h
index 12da68a..1111f4e 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -4,11 +4,9 @@
#include <compiz-core.h>
#include <compwindow.h>
#include <comppoint.h>
-#include <comptexture.h>
#define WINDOW_INVISIBLE(w) \
((w)->attrib.map_state != IsViewable || \
- (!(w)->damaged) || \
(w)->attrib.x + (w)->width + (w)->output.right <= 0 || \
(w)->attrib.y + (w)->height + (w)->output.bottom <= 0 || \
(w)->attrib.x - (w)->output.left >= (int) (w)->screen->size().width () || \
@@ -152,16 +150,13 @@ class PrivateWindow {
Window transientFor;
Window clientLeader;
XSizeHints sizeHints;
- Pixmap pixmap;
- CompTexture texture;
- CompTexture::Matrix matrix;
- Damage damage;
+
bool inputHint;
bool alpha;
- GLint width;
- GLint height;
+ int width;
+ int height;
Region region;
- Region clip;
+
unsigned int wmType;
unsigned int type;
unsigned int state;
@@ -171,11 +166,9 @@ class PrivateWindow {
unsigned int mwmFunc;
bool invisible;
bool destroyed;
- bool damaged;
- bool redirected;
+
bool managed;
- bool bindFailed;
- bool overlayWindow;
+
int destroyRefCnt;
int unmapRefCnt;
@@ -205,14 +198,6 @@ class PrivateWindow {
unsigned int lastPong;
bool alive;
- GLushort opacity;
- GLushort brightness;
- GLushort saturation;
-
- CompWindowPaintAttrib paint;
- CompWindowPaintAttrib lastPaint;
-
- unsigned int lastMask;
CompWindowExtents input;
CompWindowExtents output;
@@ -240,19 +225,9 @@ class PrivateWindow {
bool closeRequests;
Time lastCloseRequestTime;
- XRectangle *damageRects;
- int sizeDamage;
- int nDamage;
-
- GLfloat *vertices;
- int vertexSize;
- int vertexStride;
- GLushort *indices;
- int indexSize;
- int vCount;
- int texUnits;
- int texCoordSize;
- int indexCount;
+
+
+
};
#endif
diff --git a/src/screen.cpp b/src/screen.cpp
index 069c3a7..d37e236 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -192,7 +192,6 @@ PrivateScreen::updateOutputDevices ()
int x, y, bits;
unsigned int width, height;
int x1, y1, x2, y2;
- Region region;
char str[10];
foreach (CompOption::Value &value, list)
@@ -261,61 +260,6 @@ PrivateScreen::updateOutputDevices ()
screen->updateWorkarea ();
- screen->setDefaultViewport ();
- screen->damageScreen ();
-
- region = XCreateRegion ();
- if (region)
- {
- REGION r;
-
- r.rects = &r.extents;
- r.numRects = 1;
-
- for (unsigned int i = 0; i < outputDevs.size () - 1; i++)
- for (unsigned int j = i + 1; j < outputDevs.size (); j++)
- {
- XIntersectRegion (outputDevs[i].region (),
- outputDevs[j].region (),
- region);
- if (REGION_NOT_EMPTY (region))
- hasOverlappingOutputs = true;
- }
- XSubtractRegion (&emptyRegion, &emptyRegion, region);
-
- if (display->screenInfo ().size ())
- {
- for (unsigned int i = 0; i < display->screenInfo ().size (); i++)
- {
- r.extents.x1 = display->screenInfo ()[i].x_org;
- r.extents.y1 = display->screenInfo ()[i].y_org;
- r.extents.x2 = r.extents.x1 + display->screenInfo ()[i].width;
- r.extents.y2 = r.extents.y1 + display->screenInfo ()[i].height;
-
- XUnionRegion (region, &r, region);
- }
- }
- else
- {
- r.extents.x1 = 0;
- r.extents.y1 = 0;
- r.extents.x2 = size.width ();
- r.extents.y2 = size.height ();
-
- XUnionRegion (region, &r, region);
- }
-
- /* remove all output regions from visible screen region */
- for (unsigned int i = 0; i < outputDevs.size (); i++)
- XSubtractRegion (region, outputDevs[i].region (), region);
-
- /* we should clear color buffers before swapping if we have visible
- regions without output */
- clearBuffers = REGION_NOT_EMPTY (region);
-
- XDestroyRegion (region);
- }
-
screen->outputChangeNotify ();
}
@@ -391,15 +335,7 @@ CompScreen::setOption (const char *name,
return false;
switch (index) {
- case COMP_SCREEN_OPTION_DETECT_REFRESH_RATE:
- if (o->set (value))
- {
- if (value.b ())
- detectRefreshRate ();
- return true;
- }
- break;
case COMP_SCREEN_OPTION_DETECT_OUTPUTS:
if (o->set (value))
{
@@ -409,17 +345,6 @@ CompScreen::setOption (const char *name,
return true;
}
break;
- case COMP_SCREEN_OPTION_REFRESH_RATE:
- if (priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().b ())
- return false;
-
- if (o->set (value))
- {
- priv->redrawTime = 1000 / o->value ().i ();
- priv->optimalRedrawTime = priv->redrawTime;
- return true;
- }
- break;
case COMP_SCREEN_OPTION_HSIZE:
if (o->set (value))
{
@@ -476,13 +401,6 @@ CompScreen::setOption (const char *name,
return true;
}
break;
- case COMP_SCREEN_OPTION_FORCE_INDEPENDENT:
- if (o->set (value))
- {
- priv->updateOutputDevices ();
- return true;
- }
- break;
default:
if (CompOption::setScreenOption (this, *o, value))
return true;
@@ -493,15 +411,9 @@ CompScreen::setOption (const char *name,
}
const CompMetadata::OptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
- { "detect_refresh_rate", "bool", 0, 0, 0 },
- { "lighting", "bool", 0, 0, 0 },
- { "refresh_rate", "int", "<min>1</min>", 0, 0 },
{ "hsize", "int", "<min>1</min><max>32</max>", 0, 0 },
{ "vsize", "int", "<min>1</min><max>32</max>", 0, 0 },
- { "opacity_step", "int", "<min>1</min>", 0, 0 },
- { "unredirect_fullscreen_windows", "bool", 0, 0, 0 },
{ "default_icon", "string", 0, 0, 0 },
- { "sync_to_vblank", "bool", 0, 0, 0 },
{ "number_of_desktops", "int", "<min>1</min>", 0, 0 },
{ "detect_outputs", "bool", 0, 0, 0 },
{ "outputs", "list", "<type>string</type>", 0, 0 },
@@ -510,8 +422,6 @@ const CompMetadata::OptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
{ "focus_prevention_level", "int",
RESTOSTRING (0, FOCUS_PREVENTION_LEVEL_LAST), 0, 0 },
{ "focus_prevention_match", "match", 0, 0, 0 },
- { "texture_compression", "bool", 0, 0, 0 },
- { "force_independent_output_painting", "bool", 0, 0, 0 }
};
void
@@ -656,49 +566,6 @@ PrivateScreen::updateScreenEdges ()
}
}
-static void
-frustum (GLfloat *m,
- GLfloat left,
- GLfloat right,
- GLfloat bottom,
- GLfloat top,
- GLfloat nearval,
- GLfloat farval)
-{
- GLfloat x, y, a, b, c, d;
-
- x = (2.0 * nearval) / (right - left);
- y = (2.0 * nearval) / (top - bottom);
- a = (right + left) / (right - left);
- b = (top + bottom) / (top - bottom);
- c = -(farval + nearval) / ( farval - nearval);
- d = -(2.0 * farval * nearval) / (farval - nearval);
-
-#define M(row,col) m[col*4+row]
- M(0,0) = x; M(0,1) = 0.0f; M(0,2) = a; M(0,3) = 0.0f;
- M(1,0) = 0.0f; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0f;
- M(2,0) = 0.0f; M(2,1) = 0.0f; M(2,2) = c; M(2,3) = d;
- M(3,0) = 0.0f; M(3,1) = 0.0f; M(3,2) = -1.0f; M(3,3) = 0.0f;
-#undef M
-
-}
-
-static void
-perspective (GLfloat *m,
- GLfloat fovy,
- GLfloat aspect,
- GLfloat zNear,
- GLfloat zFar)
-{
- GLfloat xmin, xmax, ymin, ymax;
-
- ymax = zNear * tan (fovy * M_PI / 360.0);
- ymin = -ymax;
- xmin = ymin * aspect;
- xmax = ymax * aspect;
-
- frustum (m, xmin, xmax, ymin, ymax, zNear, zFar);
-}
void
CompScreen::setCurrentOutput (unsigned int outputNum)
@@ -712,31 +579,8 @@ CompScreen::setCurrentOutput (unsigned int outputNum)
void
PrivateScreen::reshape (int w, int h)
{
-
-#ifdef USE_COW
- if (useCow)
- XMoveResizeWindow (display->dpy (), overlay, 0, 0, w, h);
-#endif
-
display->updateScreenInfo();
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- glMatrixMode (GL_MODELVIEW);
- glLoadIdentity ();
- glDepthRange (0, 1);
- glViewport (-1, -1, 2, 2);
- glRasterPos2f (0, 0);
-
- rasterPos = CompPoint (0, 0);
-
- perspective (projection, 60.0f, 1.0f, 0.1f, 100.0f);
-
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- glMultMatrixf (projection);
- glMatrixMode (GL_MODELVIEW);
-
region.rects = &region.extents;
region.numRects = 1;
region.extents.x1 = 0;
@@ -766,158 +610,10 @@ CompScreen::configure (XConfigureEvent *ce)
priv->reshape (ce->width, ce->height);
priv->detectOutputDevices ();
-
- damageScreen ();
}
}
-FuncPtr
-CompScreen::getProcAddress (const char *name)
-{
- static void *dlhand = NULL;
- FuncPtr funcPtr = NULL;
-
- if (priv->getProcAddress)
- funcPtr = priv->getProcAddress ((GLubyte *) name);
-
- if (!funcPtr)
- {
- if (!dlhand)
- dlhand = dlopen (NULL, RTLD_LAZY);
-
- if (dlhand)
- {
- dlerror ();
- funcPtr = (FuncPtr) dlsym (dlhand, name);
- if (dlerror () != NULL)
- funcPtr = NULL;
- }
- }
- return funcPtr;
-}
-
-void
-PrivateScreen::updateScreenBackground (CompTexture *texture)
-{
- Display *dpy = display->dpy ();
- Atom pixmapAtom, actualType;
- int actualFormat, i, status;
- unsigned int width = 1, height = 1, depth = 0;
- unsigned long nItems;
- unsigned long bytesAfter;
- unsigned char *prop;
- Pixmap pixmap = 0;
-
- pixmapAtom = XInternAtom (dpy, "PIXMAP", FALSE);
-
- for (i = 0; pixmap == 0 && i < 2; i++)
- {
- status = XGetWindowProperty (dpy, root,
- display->atoms ().xBackground[i],
- 0, 4, FALSE, AnyPropertyType,
- &actualType, &actualFormat, &nItems,
- &bytesAfter, &prop);
-
- if (status == Success && nItems && prop)
- {
- if (actualType == pixmapAtom &&
- actualFormat == 32 &&
- nItems == 1)
- {
- Pixmap p;
-
- memcpy (&p, prop, 4);
-
- if (p)
- {
- unsigned int ui;
- int i;
- Window w;
-
- if (XGetGeometry (dpy, p, &w, &i, &i,
- &width, &height, &ui, &depth))
- {
- if ((int) depth == attrib.depth)
- pixmap = p;
- }
- }
- }
-
- XFree (prop);
- }
- }
-
- if (pixmap)
- {
-/* FIXME:
- if (pixmap == texture->pixmap)
- return;
-*/
- texture->reset ();
-
- if (!texture->bindPixmap (pixmap, width, height, depth))
- {
- compLogMessage (NULL, "core", CompLogLevelWarn,
- "Couldn't bind background pixmap 0x%x to "
- "texture", (int) pixmap);
- }
- }
- else
- {
- texture->reset ();
- }
-
- if (!texture->name () && backgroundImage)
- CompTexture::readImageToTexture (screen, texture, backgroundImage,
- &width, &height);
-
- if (texture->target () == GL_TEXTURE_2D)
- {
- glBindTexture (texture->target (), texture->name ());
- glTexParameteri (texture->target (), GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri (texture->target (), GL_TEXTURE_WRAP_T, GL_REPEAT);
- glBindTexture (texture->target (), 0);
- }
-}
-
-void
-CompScreen::detectRefreshRate ()
-{
- if (!noDetection &&
- priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().b ())
- {
- CompString name;
- CompOption::Value value;
-
- value.set ((int) 0);
-
- if (priv->display->XRandr())
- {
- XRRScreenConfiguration *config;
-
- config = XRRGetScreenInfo (priv->display->dpy (), priv->root);
- value.set ((int) XRRConfigCurrentRate (config));
-
- XRRFreeScreenConfigInfo (config);
- }
-
- if (value.i () == 0)
- value.set ((int) defaultRefreshRate);
-
- name = priv->opt[COMP_SCREEN_OPTION_REFRESH_RATE].name ();
-
- priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().set (false);
- core->setOptionForPlugin (this, "core", name.c_str (), value);
- priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().set (true);
- }
- else
- {
- priv->redrawTime = 1000 /
- priv->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value ().i ();
- priv->optimalRedrawTime = priv->redrawTime;
- }
-}
void
PrivateScreen::setSupportingWmCheck ()
@@ -1003,11 +699,14 @@ PrivateScreen::setSupported ()
data[i++] = display->atoms ().winOpacity;
data[i++] = display->atoms ().winBrightness;
+#warning fixme
+#if 0
if (canDoSaturated)
{
data[i++] = display->atoms ().winSaturation;
data[i++] = display->atoms ().winStateDisplayModal;
}
+#endif
data[i++] = display->atoms ().wmAllowedActions;
@@ -1131,123 +830,6 @@ PrivateScreen::getDesktopHints ()
}
void
-CompScreen::showOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- Display *dpy = priv->display->dpy ();
- XserverRegion region;
-
- region = XFixesCreateRegion (dpy, NULL, 0);
-
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeBounding,
- 0, 0, 0);
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeInput,
- 0, 0, region);
-
- XFixesDestroyRegion (dpy, region);
-
- damageScreen ();
- }
-#endif
-
-}
-
-void
-CompScreen::hideOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- Display *dpy = priv->display->dpy ();
- XserverRegion region;
-
- region = XFixesCreateRegion (dpy, NULL, 0);
-
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeBounding,
- 0, 0, region);
-
- XFixesDestroyRegion (dpy, region);
- }
-#endif
-
-}
-
-void
-CompScreen::updateOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- Display *dpy = priv->display->dpy ();
- XserverRegion region;
- static Region tmpRegion = NULL;
-
- if (!tmpRegion)
- {
- tmpRegion = XCreateRegion ();
- if (!tmpRegion)
- return;
- }
-
- XSubtractRegion (&priv->region, &emptyRegion, tmpRegion);
-
-
- for (CompWindowList::reverse_iterator rit = priv->windows.rbegin ();
- rit != priv->windows.rend (); rit++)
- if ((*rit)->overlayWindow ())
- {
- XSubtractRegion (tmpRegion, (*rit)->region (), tmpRegion);
- }
-
- XShapeCombineRegion (dpy, priv->output, ShapeBounding,
- 0, 0, tmpRegion, ShapeSet);
-
-
- region = XFixesCreateRegion (dpy, NULL, 0);
-
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeInput,
- 0, 0, region);
-
- XFixesDestroyRegion (dpy, region);
- }
-#endif
-
-}
-
-void
-PrivateScreen::makeOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- overlay = XCompositeGetOverlayWindow (display->dpy (), root);
- output = overlay;
-
- XSelectInput (display->dpy (), output, ExposureMask);
- }
- else
-#endif
-
- output = overlay = root;
-
- screen->showOutputWindow ();
-}
-
-void
CompScreen::enterShowDesktopMode ()
{
WRAPABLE_HND_FUNC(enterShowDesktopMode)
@@ -1336,33 +918,16 @@ CompScreen::leaveShowDesktopMode (CompWindow *window)
(unsigned char *) &data, 1);
}
-CompWindowList
-CompScreen::getWindowPaintList ()
-{
- WRAPABLE_HND_FUNC_RETURN (CompWindowList, getWindowPaintList)
- return priv->windows;
-}
CompScreen::CompScreen ():
CompObject (COMP_OBJECT_TYPE_SCREEN, "screen", &screenPrivateIndices)
{
- WRAPABLE_INIT_HND(preparePaint);
- WRAPABLE_INIT_HND(donePaint);
- WRAPABLE_INIT_HND(paint);
- WRAPABLE_INIT_HND(paintOutput);
- WRAPABLE_INIT_HND(paintTransformedOutput);
- WRAPABLE_INIT_HND(enableOutputClipping);
- WRAPABLE_INIT_HND(disableOutputClipping);
- WRAPABLE_INIT_HND(applyTransform);
-
WRAPABLE_INIT_HND(enterShowDesktopMode);
WRAPABLE_INIT_HND(leaveShowDesktopMode);
WRAPABLE_INIT_HND(outputChangeNotify);
- WRAPABLE_INIT_HND(getWindowPaintList);
-
priv = new PrivateScreen (this);
assert (priv);
}
@@ -1376,103 +941,52 @@ PrivateScreen::PrivateScreen (CompScreen *screen) :
vpSize (1, 1),
nDesktop (1),
currentDesktop (0),
- damageMask (COMP_SCREEN_DAMAGE_ALL_MASK),
root (None),
- overlay (None),
- output (None),
grabWindow (None),
- textureRectangle (false),
- textureNonPowerOfTwo (false),
- textureEnvCombine (false),
- textureEnvCrossbar (false),
- textureBorderClamp (false),
- textureCompression (false),
- maxTextureSize (0),
- fbo (false),
- fragmentProgram (false),
- maxTextureUnits (1),
- exposeRects (0),
- backgroundTexture (screen),
- backgroundLoaded (false),
- pendingDestroys (0),
desktopWindowCount (0),
mapNum (1),
activeNum (1),
outputDevs (0),
currentOutputDev (0),
hasOverlappingOutputs (false),
- windowPaintOffset (0, 0),
currentHistory (0),
- overlayWindowCount (0),
snContext (0),
startupSequences (0),
startupSequenceTimer (),
groups (0),
defaultIcon (0),
- canDoSaturated (false),
- canDoSlightlySaturated (false),
clientList (0),
nClientList (0),
buttonGrabs (0),
keyGrabs (0),
grabs (0),
- rasterPos (0, 0),
- nextRedraw (0),
- redrawTime (1000 / defaultRefreshRate),
- optimalRedrawTime (1000 / defaultRefreshRate),
- frameStatus (0),
- timeMult (1),
- idle (true),
- timeLeft (0),
- pendingCommands (true),
- fragmentStorage (),
- clearBuffers (true),
- lighting (false),
- slowAnimations (false),
+ pendingDestroys (0),
showingDesktopMask (0),
desktopHintData (0),
desktopHintSize (0),
- opt (COMP_SCREEN_OPTION_NUM),
- paintTimer (),
- getProcAddress (0),
- tmpRegion (NULL),
- outputRegion (NULL)
+ opt (COMP_SCREEN_OPTION_NUM)
{
memset (history, 0, sizeof (history));
- gettimeofday (&lastRedraw, 0);
}
PrivateScreen::~PrivateScreen ()
{
CompOption::finiScreenOptions (screen, opt);
-
- if (outputRegion)
- XDestroyRegion (outputRegion);
- if (tmpRegion)
- XDestroyRegion (tmpRegion);
}
bool
CompScreen::init (CompDisplay *display, int screenNum)
{
Display *dpy = display->dpy ();
- Window newWmSnOwner = None, newCmSnOwner = None;
- Atom wmSnAtom = 0, cmSnAtom = 0;
+ Window newWmSnOwner = None;
+ Atom wmSnAtom = 0;
Time wmSnTimestamp = 0;
XEvent event;
XSetWindowAttributes attr;
- Window currentWmSnOwner, currentCmSnOwner;
+ Window currentWmSnOwner;
char buf[128];
bool rv;
- priv->tmpRegion = XCreateRegion ();
- if (!priv->tmpRegion)
- return false;
-
- priv->outputRegion = XCreateRegion ();
- if (!priv->outputRegion)
- return false;
-
sprintf (buf, "WM_S%d", screenNum);
wmSnAtom = XInternAtom (dpy, buf, 0);
@@ -1495,30 +1009,10 @@ CompScreen::init (CompDisplay *display, int screenNum)
XSelectInput (dpy, currentWmSnOwner, StructureNotifyMask);
}
- sprintf (buf, "_NET_WM_CM_S%d", screenNum);
- cmSnAtom = XInternAtom (dpy, buf, 0);
-
- currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom);
-
- if (currentCmSnOwner != None)
- {
- if (!replaceCurrentWm)
- {
- compLogMessage (display, "core", CompLogLevelError,
- "Screen %d on display \"%s\" already "
- "has a compositing manager; try using the "
- "--replace option to replace the current "
- "compositing manager.",
- screenNum, DisplayString (dpy));
-
- return false;
- }
- }
-
attr.override_redirect = TRUE;
attr.event_mask = PropertyChangeMask;
- newCmSnOwner = newWmSnOwner =
+ newWmSnOwner =
XCreateWindow (dpy, XRootWindow (dpy, screenNum),
-100, -100, 1, 1, 0,
CopyFromParent, CopyFromParent,
@@ -1577,30 +1071,6 @@ CompScreen::init (CompDisplay *display, int screenNum)
CompDisplay::checkForError (dpy);
- XCompositeRedirectSubwindows (dpy, XRootWindow (dpy, screenNum),
- CompositeRedirectManual);
-
- if (CompDisplay::checkForError (dpy))
- {
- compLogMessage (display, "core", CompLogLevelError,
- "Another composite manager is already "
- "running on screen: %d", screenNum);
-
- return false;
- }
-
- XSetSelectionOwner (dpy, cmSnAtom, newCmSnOwner, wmSnTimestamp);
-
- if (XGetSelectionOwner (dpy, cmSnAtom) != newCmSnOwner)
- {
- compLogMessage (display, "core", CompLogLevelError,
- "Could not acquire compositing manager "
- "selection on screen %d display \"%s\"",
- screenNum, DisplayString (dpy));
-
- return false;
- }
-
XGrabServer (dpy);
XSelectInput (dpy, XRootWindow (dpy, screenNum),
@@ -1647,17 +1117,11 @@ CompScreen::init (CompDisplay *display,
Pixmap bitmap;
XVisualInfo templ;
XVisualInfo *visinfo;
- GLXFBConfig *fbConfigs;
Window rootReturn, parentReturn;
Window *children;
unsigned int nchildren;
- int defaultDepth, nvisinfo, nElements, value, i;
- const char *glxExtensions, *glExtensions;
+ int defaultDepth, nvisinfo, i;
XSetWindowAttributes attrib;
- GLfloat globalAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f };
- GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };
- GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
- GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
priv->display = display;
@@ -1665,10 +1129,6 @@ CompScreen::init (CompDisplay *display,
COMP_SCREEN_OPTION_NUM, priv->opt))
return false;
- priv->damage = XCreateRegion ();
- if (!priv->damage)
- return false;
-
priv->vpSize.setWidth (priv->opt[COMP_SCREEN_OPTION_HSIZE].value ().i ());
priv->vpSize.setHeight (priv->opt[COMP_SCREEN_OPTION_VSIZE].value ().i ());
@@ -1700,8 +1160,6 @@ CompScreen::init (CompDisplay *display,
priv->workArea.height = priv->attrib.height;
priv->grabWindow = None;
- priv->makeOutputWindow ();
-
templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
@@ -1746,421 +1204,13 @@ CompScreen::init (CompDisplay *display,
XFreePixmap (dpy, bitmap);
XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
- glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);
- if (!value)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Root visual is not a GL visual");
- XFree (visinfo);
- return false;
- }
-
- glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);
- if (!value)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Root visual is not a double buffered GL visual");
- XFree (visinfo);
- return false;
- }
-
- priv->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering);
- if (!priv->ctx)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "glXCreateContext failed");
- XFree (visinfo);
-
- return false;
- }
-
- glxExtensions = glXQueryExtensionsString (dpy, screenNum);
- if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap"))
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "GLX_EXT_texture_from_pixmap is missing");
- XFree (visinfo);
-
- return false;
- }
-
XFree (visinfo);
- if (!strstr (glxExtensions, "GLX_SGIX_fbconfig"))
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "GLX_SGIX_fbconfig is missing");
- return false;
- }
-
- priv->getProcAddress = (GLXGetProcAddressProc)
- getProcAddress ("glXGetProcAddressARB");
- bindTexImage = (GLXBindTexImageProc)
- getProcAddress ("glXBindTexImageEXT");
- releaseTexImage = (GLXReleaseTexImageProc)
- getProcAddress ("glXReleaseTexImageEXT");
- queryDrawable = (GLXQueryDrawableProc)
- getProcAddress ("glXQueryDrawable");
- getFBConfigs = (GLXGetFBConfigsProc)
- getProcAddress ("glXGetFBConfigs");
- getFBConfigAttrib = (GLXGetFBConfigAttribProc)
- getProcAddress ("glXGetFBConfigAttrib");
- createPixmap = (GLXCreatePixmapProc)
- getProcAddress ("glXCreatePixmap");
-
- if (!bindTexImage)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "glXBindTexImageEXT is missing");
- return false;
- }
-
- if (!releaseTexImage)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "glXReleaseTexImageEXT is missing");
- return false;
- }
-
- if (!queryDrawable ||
- !getFBConfigs ||
- !getFBConfigAttrib ||
- !createPixmap)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "fbconfig functions missing");
- return false;
- }
-
- copySubBuffer = NULL;
- if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer"))
- copySubBuffer = (GLXCopySubBufferProc)
- getProcAddress ("glXCopySubBufferMESA");
-
- getVideoSync = NULL;
- waitVideoSync = NULL;
- if (strstr (glxExtensions, "GLX_SGI_video_sync"))
- {
- getVideoSync = (GLXGetVideoSyncProc)
- getProcAddress ("glXGetVideoSyncSGI");
-
- waitVideoSync = (GLXWaitVideoSyncProc)
- getProcAddress ("glXWaitVideoSyncSGI");
- }
-
- glXMakeCurrent (dpy, priv->output, priv->ctx);
- currentRoot = priv->root;
-
- glExtensions = (const char *) glGetString (GL_EXTENSIONS);
- if (!glExtensions)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "No valid GL extensions string found.");
- return false;
- }
-
- priv->textureNonPowerOfTwo = false;
- if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
- priv->textureNonPowerOfTwo = true;
-
- glGetIntegerv (GL_MAX_TEXTURE_SIZE, &priv->maxTextureSize);
-
- priv->textureRectangle = false;
- if (strstr (glExtensions, "GL_NV_texture_rectangle") ||
- strstr (glExtensions, "GL_EXT_texture_rectangle") ||
- strstr (glExtensions, "GL_ARB_texture_rectangle"))
- {
- priv->textureRectangle = true;
-
- if (!priv->textureNonPowerOfTwo)
- {
- GLint maxTextureSize;
-
- glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &maxTextureSize);
- if (maxTextureSize > priv->maxTextureSize)
- priv->maxTextureSize = maxTextureSize;
- }
- }
-
- if (!(priv->textureRectangle || priv->textureNonPowerOfTwo))
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Support for non power of two textures missing");
- return false;
- }
-
- priv->textureEnvCombine = priv->textureEnvCrossbar = false;
- if (strstr (glExtensions, "GL_ARB_texture_env_combine"))
- {
- priv->textureEnvCombine = true;
-
- /* XXX: GL_NV_texture_env_combine4 need special code but it seams to
- be working anyway for now... */
- if (strstr (glExtensions, "GL_ARB_texture_env_crossbar") ||
- strstr (glExtensions, "GL_NV_texture_env_combine4"))
- priv->textureEnvCrossbar = true;
- }
-
- priv->textureBorderClamp = false;
- if (strstr (glExtensions, "GL_ARB_texture_border_clamp") ||
- strstr (glExtensions, "GL_SGIS_texture_border_clamp"))
- priv->textureBorderClamp = true;
-
- priv->maxTextureUnits = 1;
- if (strstr (glExtensions, "GL_ARB_multitexture"))
- {
- activeTexture = (GLActiveTextureProc)
- getProcAddress ("glActiveTexture");
- clientActiveTexture = (GLClientActiveTextureProc)
- getProcAddress ("glClientActiveTexture");
- multiTexCoord2f = (GLMultiTexCoord2fProc)
- getProcAddress ("glMultiTexCoord2f");
-
- if (activeTexture && clientActiveTexture && multiTexCoord2f)
- glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &priv->maxTextureUnits);
- }
-
- priv->fragmentProgram = false;
- if (strstr (glExtensions, "GL_ARB_fragment_program"))
- {
- genPrograms = (GLGenProgramsProc)
- getProcAddress ("glGenProgramsARB");
- deletePrograms = (GLDeleteProgramsProc)
- getProcAddress ("glDeleteProgramsARB");
- bindProgram = (GLBindProgramProc)
- getProcAddress ("glBindProgramARB");
- programString = (GLProgramStringProc)
- getProcAddress ("glProgramStringARB");
- programEnvParameter4f = (GLProgramParameter4fProc)
- getProcAddress ("glProgramEnvParameter4fARB");
- programLocalParameter4f = (GLProgramParameter4fProc)
- getProcAddress ("glProgramLocalParameter4fARB");
- getProgramiv = (GLGetProgramivProc)
- getProcAddress ("glGetProgramivARB");
-
- if (genPrograms &&
- deletePrograms &&
- bindProgram &&
- programString &&
- programEnvParameter4f &&
- programLocalParameter4f &&
- getProgramiv)
- priv->fragmentProgram = true;
- }
-
- priv->fbo = false;
- if (strstr (glExtensions, "GL_EXT_framebuffer_object"))
- {
- genFramebuffers = (GLGenFramebuffersProc)
- getProcAddress ("glGenFramebuffersEXT");
- deleteFramebuffers = (GLDeleteFramebuffersProc)
- getProcAddress ("glDeleteFramebuffersEXT");
- bindFramebuffer = (GLBindFramebufferProc)
- getProcAddress ("glBindFramebufferEXT");
- checkFramebufferStatus = (GLCheckFramebufferStatusProc)
- getProcAddress ("glCheckFramebufferStatusEXT");
- framebufferTexture2D = (GLFramebufferTexture2DProc)
- getProcAddress ("glFramebufferTexture2DEXT");
- generateMipmap = (GLGenerateMipmapProc)
- getProcAddress ("glGenerateMipmapEXT");
-
- if (genFramebuffers &&
- deleteFramebuffers &&
- bindFramebuffer &&
- checkFramebufferStatus &&
- framebufferTexture2D &&
- generateMipmap)
- priv->fbo = true;
- }
-
- priv->textureCompression = false;
- if (strstr (glExtensions, "GL_ARB_texture_compression"))
- priv->textureCompression = true;
-
- fbConfigs = (*getFBConfigs) (dpy, screenNum, &nElements);
-
- for (i = 0; i <= MAX_DEPTH; i++)
- {
- int j, db, stencil, depth, alpha, mipmap, rgba;
-
- priv->glxPixmapFBConfigs[i].fbConfig = NULL;
- priv->glxPixmapFBConfigs[i].mipmap = 0;
- priv->glxPixmapFBConfigs[i].yInverted = 0;
- priv->glxPixmapFBConfigs[i].textureFormat = 0;
- priv->glxPixmapFBConfigs[i].textureTargets = 0;
-
- db = MAXSHORT;
- stencil = MAXSHORT;
- depth = MAXSHORT;
- mipmap = 0;
- rgba = 0;
-
- for (j = 0; j < nElements; j++)
- {
- XVisualInfo *vi;
- int visualDepth;
-
- vi = glXGetVisualFromFBConfig (dpy, fbConfigs[j]);
- if (vi == NULL)
- continue;
-
- visualDepth = vi->depth;
-
- XFree (vi);
-
- if (visualDepth != i)
- continue;
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_ALPHA_SIZE,
- &alpha);
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BUFFER_SIZE,
- &value);
- if (value != i && (value - alpha) != i)
- continue;
-
- value = 0;
- if (i == 32)
- {
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_TEXTURE_RGBA_EXT,
- &value);
-
- if (value)
- {
- rgba = 1;
-
- priv->glxPixmapFBConfigs[i].textureFormat =
- GLX_TEXTURE_FORMAT_RGBA_EXT;
- }
- }
-
- if (!value)
- {
- if (rgba)
- continue;
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_TEXTURE_RGB_EXT,
- &value);
- if (!value)
- continue;
-
- priv->glxPixmapFBConfigs[i].textureFormat =
- GLX_TEXTURE_FORMAT_RGB_EXT;
- }
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_DOUBLEBUFFER,
- &value);
- if (value > db)
- continue;
-
- db = value;
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_STENCIL_SIZE,
- &value);
- if (value > stencil)
- continue;
-
- stencil = value;
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_DEPTH_SIZE,
- &value);
- if (value > depth)
- continue;
-
- depth = value;
-
- if (priv->fbo)
- {
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
- &value);
- if (value < mipmap)
- continue;
-
- mipmap = value;
- }
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_Y_INVERTED_EXT,
- &value);
-
- priv->glxPixmapFBConfigs[i].yInverted = value;
-
- (*getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_TEXTURE_TARGETS_EXT,
- &value);
-
- priv->glxPixmapFBConfigs[i].textureTargets = value;
-
- priv->glxPixmapFBConfigs[i].fbConfig = fbConfigs[j];
- priv->glxPixmapFBConfigs[i].mipmap = mipmap;
- }
- }
-
- if (nElements)
- XFree (fbConfigs);
-
- if (!priv->glxPixmapFBConfigs[defaultDepth].fbConfig)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "No GLXFBConfig for default depth, "
- "this isn't going to work.");
- return false;
- }
-
- glClearColor (0.0, 0.0, 0.0, 1.0);
- glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glEnable (GL_CULL_FACE);
- glDisable (GL_BLEND);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glColor4usv (defaultColor);
- glEnableClientState (GL_VERTEX_ARRAY);
- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
-
- priv->canDoSaturated = priv->canDoSlightlySaturated = false;
- if (priv->textureEnvCombine && priv->maxTextureUnits >= 2)
- {
- priv->canDoSaturated = true;
- if (priv->textureEnvCrossbar && priv->maxTextureUnits >= 4)
- priv->canDoSlightlySaturated = true;
- }
-
priv->reshape (priv->attrib.width, priv->attrib.height);
- detectRefreshRate ();
priv->detectOutputDevices ();
priv->updateOutputDevices ();
- glLightModelfv (GL_LIGHT_MODEL_AMBIENT, globalAmbient);
-
- glEnable (GL_LIGHT0);
- glLightfv (GL_LIGHT0, GL_AMBIENT, ambientLight);
- glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseLight);
- glLightfv (GL_LIGHT0, GL_POSITION, light0Position);
-
- glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
-
- glNormal3f (0.0f, 0.0f, -1.0f);
-
- priv->lighting = false;
- priv->slowAnimations = false;
-
priv->display->addScreenActions (this);
priv->getDesktopHints ();
@@ -2230,19 +1280,11 @@ CompScreen::init (CompDisplay *display,
XDefineCursor (dpy, priv->root, priv->normalCursor);
- priv->filter[NOTHING_TRANS_FILTER] = CompTexture::Fast;
- priv->filter[SCREEN_TRANS_FILTER] = CompTexture::Good;
- priv->filter[WINDOW_TRANS_FILTER] = CompTexture::Good;
-
- priv->paintTimer.start (boost::bind(&CompScreen::handlePaintTimeout, this),
- priv->optimalRedrawTime, MAXSHORT);
return true;
}
CompScreen::~CompScreen ()
{
- priv->paintTimer.stop ();
-
while (!priv->windows.empty ())
delete priv->windows.front ();
@@ -2258,15 +1300,8 @@ CompScreen::~CompScreen ()
if (priv->defaultIcon)
delete priv->defaultIcon;
- glXDestroyContext (priv->display->dpy (), priv->ctx);
-
XFreeCursor (priv->display->dpy (), priv->invisibleCursor);
-#ifdef USE_COW
- if (useCow)
- XCompositeReleaseOverlayWindow (priv->display->dpy (), priv->root);
-#endif
-
if (priv->clientList)
free (priv->clientList);
@@ -2276,9 +1311,6 @@ CompScreen::~CompScreen ()
if (priv->snContext)
sn_monitor_context_unref (priv->snContext);
- if (priv->damage)
- XDestroyRegion (priv->damage);
-
delete priv;
}
@@ -2293,39 +1325,6 @@ CompScreen::objectName ()
}
-void
-CompScreen::damageRegion (Region region)
-{
- if (priv->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
- return;
-
- if (priv->damageMask == 0)
- priv->paintTimer.setTimes (priv->paintTimer.minLeft ());
-
- XUnionRegion (priv->damage, region, priv->damage);
-
- priv->damageMask |= COMP_SCREEN_DAMAGE_REGION_MASK;
-
-}
-
-void
-CompScreen::damageScreen ()
-{
- if (priv->damageMask == 0)
- priv->paintTimer.setTimes (priv->paintTimer.minLeft ());
-
- priv->damageMask |= COMP_SCREEN_DAMAGE_ALL_MASK;
- priv->damageMask &= ~COMP_SCREEN_DAMAGE_REGION_MASK;
-}
-
-void
-CompScreen::damagePending ()
-{
- if (priv->damageMask == 0)
- priv->paintTimer.setTimes (priv->paintTimer.minLeft ());
-
- priv->damageMask |= COMP_SCREEN_DAMAGE_PENDING_MASK;
-}
void
CompScreen::forEachWindow (CompWindow::ForEach proc)
@@ -2500,8 +1499,6 @@ CompScreen::unhookWindow (CompWindow *w)
if (w == lastFoundWindow)
lastFoundWindow = NULL;
- if (w == lastDamagedWindow)
- lastDamagedWindow = NULL;
}
#define POINTER_GRAB_MASK (ButtonReleaseMask | \
@@ -3392,39 +2389,6 @@ CompScreen::sendWindowActivationRequest (Window id)
&xev);
}
-void
-CompScreen::setTexEnvMode (GLenum mode)
-{
- if (priv->lighting)
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- else
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
-}
-
-void
-CompScreen::setLighting (bool lighting)
-{
- if (priv->lighting != lighting)
- {
- if (!priv->opt[COMP_SCREEN_OPTION_LIGHTING].value ().b ())
- lighting = false;
-
- if (lighting)
- {
- glEnable (GL_COLOR_MATERIAL);
- glEnable (GL_LIGHTING);
- }
- else
- {
- glDisable (GL_COLOR_MATERIAL);
- glDisable (GL_LIGHTING);
- }
-
- priv->lighting = lighting;
-
- setTexEnvMode (GL_REPLACE);
- }
-}
void
CompScreen::enableEdge (int edge)
@@ -3456,29 +2420,9 @@ CompScreen::getTopWindow ()
return None;
}
-void
-CompScreen::makeCurrent ()
-{
- if (currentRoot != priv->root)
- {
- glXMakeCurrent (priv->display->dpy (), priv->output, priv->ctx);
- currentRoot = priv->root;
- }
- priv->pendingCommands = true;
-}
-void
-CompScreen::finishDrawing ()
-{
- if (priv->pendingCommands)
- {
- makeCurrent ();
- glFinish ();
- priv->pendingCommands = true;
- }
-}
int
CompScreen::outputDeviceForPoint (int x, int y)
@@ -3566,51 +2510,13 @@ CompScreen::getWorkareaForOutput (int output, XRectangle *area)
*area = priv->outputDevs[output].workArea ();
}
-void
-CompScreen::setDefaultViewport ()
-{
- priv->lastViewport.x = priv->outputDevs[0].x1 ();
- priv->lastViewport.y = priv->size.height () - priv->outputDevs[0].y2 ();
- priv->lastViewport.width = priv->outputDevs[0].width ();
- priv->lastViewport.height = priv->outputDevs[0].height ();
-
- glViewport (priv->lastViewport.x,
- priv->lastViewport.y,
- priv->lastViewport.width,
- priv->lastViewport.height);
-}
+
void
CompScreen::outputChangeNotify ()
WRAPABLE_HND_FUNC(outputChangeNotify)
-void
-CompScreen::clearOutput (CompOutput *output,
- unsigned int mask)
-{
- BoxPtr pBox = &output->region ()->extents;
- if (pBox->x1 != 0 ||
- pBox->y1 != 0 ||
- pBox->x2 != (int) priv->size.width () ||
- pBox->y2 != (int) priv->size.height ())
- {
- glPushAttrib (GL_SCISSOR_BIT);
-
- glEnable (GL_SCISSOR_TEST);
- glScissor (pBox->x1,
- priv->size.height () - pBox->y2,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1);
- glClear (mask);
-
- glPopAttrib ();
- }
- else
- {
- glClear (mask);
- }
-}
/* Returns default viewport for some window geometry. If the window spans
more than one viewport the most appropriate viewport is returned. How the
@@ -3862,79 +2768,15 @@ CompScreen::addToCurrentActiveWindowHistory (Window id)
history->activeNum = priv->activeNum;
}
-void
-CompScreen::setWindowPaintOffset (int x, int y)
-{
- priv->windowPaintOffset = CompPoint (x, y);
-}
ScreenInterface::ScreenInterface ()
{
- WRAPABLE_INIT_FUNC(preparePaint);
- WRAPABLE_INIT_FUNC(donePaint);
- WRAPABLE_INIT_FUNC(paint);
- WRAPABLE_INIT_FUNC(paintOutput);
- WRAPABLE_INIT_FUNC(paintTransformedOutput);
- WRAPABLE_INIT_FUNC(enableOutputClipping);
- WRAPABLE_INIT_FUNC(disableOutputClipping);
- WRAPABLE_INIT_FUNC(applyTransform);
-
WRAPABLE_INIT_FUNC(enterShowDesktopMode);
WRAPABLE_INIT_FUNC(leaveShowDesktopMode);
WRAPABLE_INIT_FUNC(outputChangeNotify);
-
- WRAPABLE_INIT_FUNC(getWindowPaintList);
}
-
-void
-ScreenInterface::preparePaint (int msSinceLastPaint)
- WRAPABLE_DEF_FUNC(preparePaint, msSinceLastPaint)
-
-void
-ScreenInterface::donePaint ()
- WRAPABLE_DEF_FUNC(donePaint)
-
-void
-ScreenInterface::paint (CompOutput::ptrList &outputs,
- unsigned int mask)
- WRAPABLE_DEF_FUNC(paint, outputs, mask)
-
-bool
-ScreenInterface::paintOutput (const CompScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
- WRAPABLE_DEF_FUNC_RETURN(paintOutput, sAttrib, transform, region,
- output, mask)
-
-void
-ScreenInterface::paintTransformedOutput (const CompScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
- WRAPABLE_DEF_FUNC(paintTransformedOutput, sAttrib, transform, region,
- output, mask)
-
-void
-ScreenInterface::applyTransform (const CompScreenPaintAttrib *sAttrib,
- CompOutput *output,
- CompTransform *transform)
- WRAPABLE_DEF_FUNC(applyTransform, sAttrib, output, transform)
-
-void
-ScreenInterface::enableOutputClipping (const CompTransform *transform,
- Region region,
- CompOutput *output)
- WRAPABLE_DEF_FUNC(enableOutputClipping, transform, region, output)
-
-void
-ScreenInterface::disableOutputClipping ()
- WRAPABLE_DEF_FUNC(disableOutputClipping)
-
void
ScreenInterface::enterShowDesktopMode ()
WRAPABLE_DEF_FUNC(enterShowDesktopMode)
@@ -3947,9 +2789,6 @@ void
ScreenInterface::outputChangeNotify ()
WRAPABLE_DEF_FUNC(outputChangeNotify)
-CompWindowList
-ScreenInterface::getWindowPaintList ()
- WRAPABLE_DEF_FUNC_WITH_RETURN(CompWindowList (), getWindowPaintList)
CompDisplay *
CompScreen::display ()
@@ -3982,164 +2821,9 @@ CompScreen::showingDesktopMask ()
return priv->showingDesktopMask;
}
-bool
-paintTimeout (void *closure)
-{
- CompScreen *s = (CompScreen *) closure;
- return s->handlePaintTimeout ();
-}
-
-int
-CompScreen::getTimeToNextRedraw (struct timeval *tv)
-{
- int diff, next;
- diff = TIMEVALDIFF (tv, &priv->lastRedraw);
- /* handle clock rollback */
- if (diff < 0)
- diff = 0;
-
- if (priv->idle || (getVideoSync &&
- priv->opt[COMP_SCREEN_OPTION_SYNC_TO_VBLANK].value ().b ()))
- {
- if (priv->timeMult > 1)
- {
- priv->frameStatus = -1;
- priv->redrawTime = priv->optimalRedrawTime;
- priv->timeMult--;
- }
- }
- else
- {
- if (diff > priv->redrawTime)
- {
- if (priv->frameStatus > 0)
- priv->frameStatus = 0;
-
- next = priv->optimalRedrawTime * (priv->timeMult + 1);
- if (diff > next)
- {
- priv->frameStatus--;
- if (priv->frameStatus < -1)
- {
- priv->timeMult++;
- priv->redrawTime = diff = next;
- }
- }
- }
- else if (diff < priv->redrawTime)
- {
- if (priv->frameStatus < 0)
- priv->frameStatus = 0;
-
- if (priv->timeMult > 1)
- {
- next = priv->optimalRedrawTime * (priv->timeMult - 1);
- if (diff < next)
- {
- priv->frameStatus++;
- if (priv->frameStatus > 4)
- {
- priv->timeMult--;
- priv->redrawTime = next;
- }
- }
- }
- }
- }
- if (diff >= priv->redrawTime)
- return 1;
-
- return priv->redrawTime - diff;
-}
-
-void
-CompScreen::waitForVideoSync ()
-{
- unsigned int sync;
-
- if (!priv->opt[COMP_SCREEN_OPTION_SYNC_TO_VBLANK].value ().b ())
- return;
-
- if (getVideoSync)
- {
- glFlush ();
-
- (*getVideoSync) (&sync);
- (*waitVideoSync) (2, (sync + 1) % 2, &sync);
- }
-}
-
-void
-CompScreen::paint (CompOutput::ptrList &outputs,
- unsigned int mask)
-{
- WRAPABLE_HND_FUNC(paint, outputs, mask)
-
- XRectangle r;
- CompOutput::ptrList::iterator it;
- CompOutput *output;
-
- for (it = outputs.begin (); it != outputs.end (); it++)
- {
- output = (*it);
- targetScreen = this;
- targetOutput = output;
-
- r.x = output->x1 ();
- r.y = priv->size.height () - output->y2 ();
- r.width = output->width ();
- r.height = output->height ();
-
- if (priv->lastViewport.x != r.x ||
- priv->lastViewport.y != r.y ||
- priv->lastViewport.width != r.width ||
- priv->lastViewport.height != r.height)
- {
- glViewport (r.x, r.y, r.width, r.height);
- priv->lastViewport = r;
- }
-
- if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
- {
- CompMatrix identity;
-
- paintOutput (&defaultScreenPaintAttrib,
- &identity,
- output->region (), output,
- PAINT_SCREEN_REGION_MASK |
- PAINT_SCREEN_FULL_MASK);
- }
- else if (mask & COMP_SCREEN_DAMAGE_REGION_MASK)
- {
- CompMatrix identity;
-
- XIntersectRegion (priv->tmpRegion,
- output->region (),
- priv->outputRegion);
-
- if (!paintOutput (&defaultScreenPaintAttrib,
- &identity,
- priv->outputRegion, output,
- PAINT_SCREEN_REGION_MASK))
- {
- identity.reset ();
-
- paintOutput (&defaultScreenPaintAttrib,
- &identity,
- output->region (), output,
- PAINT_SCREEN_FULL_MASK);
-
- XUnionRegion (priv->tmpRegion,
- output->region (),
- priv->tmpRegion);
-
- }
- }
- }
-}
void
CompScreen::warpPointer (int dx, int dy)
@@ -4225,209 +2909,6 @@ CompScreen::screenNum ()
return priv->screenNum;
}
-bool
-CompScreen::handlePaintTimeout ()
-{
- int timeDiff;
- struct timeval tv;
- CompDisplay *d = priv->display;
-
- gettimeofday (&tv, 0);
-
- if (priv->damageMask)
- {
- finishDrawing ();
-
- targetScreen = this;
-
- timeDiff = TIMEVALDIFF (&tv, &priv->lastRedraw);
-
- /* handle clock rollback */
- if (timeDiff < 0)
- timeDiff = 0;
-
- makeCurrent ();
-
- if (priv->slowAnimations)
- {
- preparePaint (priv->idle ? 2 : (timeDiff * 2) / priv->redrawTime);
- }
- else
- preparePaint (priv->idle ? priv->redrawTime : timeDiff);
-
- /* substract top most overlay window region */
- if (priv->overlayWindowCount)
- {
- for (CompWindowList::reverse_iterator rit = priv->windows.rbegin ();
- rit != priv->windows.rend (); rit++)
- {
- CompWindow *w = (*rit);
-
- if (w->destroyed () || w->invisible ())
- continue;
-
- if (!w->redirected ())
- XSubtractRegion (priv->damage, w->region (),
- priv->damage);
-
- break;
- }
-
- if (priv->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
- {
- priv->damageMask &= ~COMP_SCREEN_DAMAGE_ALL_MASK;
- priv->damageMask |= COMP_SCREEN_DAMAGE_REGION_MASK;
- }
- }
-
- if (priv->damageMask & COMP_SCREEN_DAMAGE_REGION_MASK)
- {
- XIntersectRegion (priv->damage, &priv->region,
- priv->tmpRegion);
-
- if (priv->tmpRegion->numRects == 1 &&
- priv->tmpRegion->rects->x1 == 0 &&
- priv->tmpRegion->rects->y1 == 0 &&
- priv->tmpRegion->rects->x2 == (int) priv->size.width () &&
- priv->tmpRegion->rects->y2 == (int) priv->size.height ())
- damageScreen ();
- }
-
- EMPTY_REGION (priv->damage);
-
- int mask = priv->damageMask;
- priv->damageMask = 0;
-
- if (priv->clearBuffers)
- {
- if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
- glClear (GL_COLOR_BUFFER_BIT);
- }
-
- CompOutput::ptrList outputs (0);
-
- if (priv->opt[COMP_SCREEN_OPTION_FORCE_INDEPENDENT].value ().b ()
- || !priv->hasOverlappingOutputs)
- {
- for (unsigned int i = 0; i < priv->outputDevs.size (); i++)
- outputs.push_back (&priv->outputDevs[i]);
- }
- else
- outputs.push_back (&priv->fullscreenOutput);
-
- paint (outputs, mask);
-
- targetScreen = NULL;
- targetOutput = &priv->outputDevs[0];
-
- waitForVideoSync ();
-
- if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
- {
- glXSwapBuffers (d->dpy (), priv->output);
- }
- else
- {
- BoxPtr pBox;
- int nBox, y;
-
- pBox = priv->tmpRegion->rects;
- nBox = priv->tmpRegion->numRects;
-
- if (copySubBuffer)
- {
- while (nBox--)
- {
- y = priv->size.height () - pBox->y2;
-
- (*copySubBuffer) (d->dpy (),
- priv->output,
- pBox->x1, y,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1);
-
- pBox++;
- }
- }
- else
- {
- glEnable (GL_SCISSOR_TEST);
- glDrawBuffer (GL_FRONT);
-
- while (nBox--)
- {
- y = priv->size.height () - pBox->y2;
-
- glBitmap (0, 0, 0, 0,
- pBox->x1 - priv->rasterPos.x (),
- y - priv->rasterPos.y (),
- NULL);
-
- priv->rasterPos = CompPoint (pBox->x1, y);
-
- glScissor (pBox->x1, y,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1);
-
- glCopyPixels (pBox->x1, y,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1,
- GL_COLOR);
-
- pBox++;
- }
-
- glDrawBuffer (GL_BACK);
- glDisable (GL_SCISSOR_TEST);
- glFlush ();
- }
- }
-
- priv->lastRedraw = tv;
-
- donePaint ();
-
- /* remove destroyed windows */
- while (priv->pendingDestroys)
- {
- foreach (CompWindow *w, priv->windows)
- {
- if (w->destroyed ())
- {
- w->addDamage ();
- delete w;
- break;
- }
- }
-
- priv->pendingDestroys--;
- }
-
- priv->idle = false;
- }
- else
- {
- priv->idle = true;
- }
-
- gettimeofday (&tv, 0);
-
- priv->paintTimer.setTimes (getTimeToNextRedraw (&tv), MAXSHORT);
- return true;
-}
-
-int
-CompScreen::maxTextureSize ()
-{
- return priv->maxTextureSize;
-}
-
-unsigned int
-CompScreen::damageMask ()
-{
- return priv->damageMask;
-}
-
CompPoint
CompScreen::vp ()
{
@@ -4447,12 +2928,6 @@ CompScreen::size ()
}
unsigned int &
-CompScreen::pendingDestroys ()
-{
- return priv->pendingDestroys;
-}
-
-unsigned int &
CompScreen::mapNum ()
{
return priv->mapNum;
@@ -4464,12 +2939,6 @@ CompScreen::desktopWindowCount ()
return priv->desktopWindowCount;
}
-int &
-CompScreen::overlayWindowCount ()
-{
- return priv->overlayWindowCount;
-}
-
CompOutput::vector &
CompScreen::outputDevs ()
{
@@ -4507,86 +2976,57 @@ CompScreen::screenEdge (int edge)
return priv->screenEdge[edge];
}
-Window
-CompScreen::overlay ()
-{
- return priv->overlay;
-}
-
unsigned int &
CompScreen::activeNum ()
{
return priv->activeNum;
}
-void
-CompScreen::updateBackground ()
-{
- priv->backgroundTexture.reset ();
-
- if (priv->backgroundLoaded)
- {
- priv->backgroundLoaded = false;
- damageScreen ();
- }
-}
-
-bool
-CompScreen::textureNonPowerOfTwo ()
+unsigned int &
+CompScreen::pendingDestroys ()
{
- return priv->textureNonPowerOfTwo;
+ return priv->pendingDestroys;
}
-bool
-CompScreen::textureCompression ()
+void
+CompScreen::removeDestroyed ()
{
- return priv->textureCompression;
-}
+ while (priv->pendingDestroys)
+ {
+ foreach (CompWindow *w, priv->windows)
+ {
+ if (w->destroyed ())
+ {
+ delete w;
+ break;
+ }
+ }
-bool
-CompScreen::canDoSaturated ()
-{
- return priv->canDoSaturated;
+ priv->pendingDestroys--;
+ }
}
-bool
-CompScreen::canDoSlightlySaturated ()
+Region
+CompScreen::region ()
{
- return priv->canDoSlightlySaturated;
+ return &priv->region;
}
bool
-CompScreen::lighting ()
+CompScreen::hasOverlappingOutputs ()
{
- return priv->lighting;
+ return priv->hasOverlappingOutputs;
}
-CompTexture::Filter
-CompScreen::filter (int filter)
+CompOutput &
+CompScreen::fullscreenOutput ()
{
- return priv->filter[filter];
+ return priv->fullscreenOutput;
}
-CompFragment::Storage *
-CompScreen::fragmentStorage ()
-{
- return &priv->fragmentStorage;
-}
-
-bool
-CompScreen::fragmentProgram ()
-{
- return priv->fragmentProgram;
-}
-CompFBConfig*
-CompScreen::glxPixmapFBConfig (unsigned int depth)
-{
- return &priv->glxPixmapFBConfigs[depth];
-}
-
-bool
-CompScreen::framebufferObject ()
+XWindowAttributes
+CompScreen::attrib ()
{
- return priv->fbo;
+ return priv->attrib;
}
diff --git a/src/window.cpp b/src/window.cpp
index 23b3f3b..783aa86 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -29,7 +29,6 @@
#include <X11/Xatom.h>
#include <X11/Xproto.h>
#include <X11/extensions/shape.h>
-#include <X11/extensions/Xcomposite.h>
#include <stdio.h>
#include <string.h>
@@ -42,7 +41,6 @@
#include <boost/bind.hpp>
#include <compiz-core.h>
-#include <comptexture.h>
#include <compicon.h>
#include "privatewindow.h"
#include "privatescreen.h"
@@ -87,7 +85,8 @@ PrivateWindow::recalcNormalHints ()
{
int maxSize;
- maxSize = screen->maxTextureSize ();
+#warning fixme to max Texture size
+ maxSize = MAXSHORT;
maxSize -= serverGeometry.border () * 2;
sizeHints.x = serverGeometry.x ();
@@ -665,9 +664,6 @@ CompWindow::recalcType ()
(priv->state & CompWindowStateModalMask))
type = CompWindowTypeModalDialogMask;
- if (type & CompWindowTypeDesktopMask)
- priv->paint.opacity = OPAQUE;
-
priv->type = type;
}
@@ -829,180 +825,6 @@ CompWindow::updateWindowOutputExtents ()
}
void
-PrivateWindow::setWindowMatrix ()
-{
- matrix = texture.matrix ();
- matrix.x0 -= (attrib.x * matrix.xx);
- matrix.y0 -= (attrib.y * matrix.yy);
-}
-
-bool
-CompWindow::bind ()
-{
- redirect ();
-
- if (!priv->pixmap)
- {
- XWindowAttributes attr;
-
- /* don't try to bind window again if it failed previously */
- if (priv->bindFailed)
- return false;
-
- /* We have to grab the server here to make sure that window
- is mapped when getting the window pixmap */
- XGrabServer (priv->screen->display ()->dpy ());
- XGetWindowAttributes (priv->screen->display ()->dpy (), priv->id, &attr);
- if (attr.map_state != IsViewable)
- {
- XUngrabServer (priv->screen->display ()->dpy ());
- priv->texture.reset ();
- priv->bindFailed = true;
- return false;
- }
-
- priv->pixmap = XCompositeNameWindowPixmap (priv->screen->display ()->dpy (),
- priv->id);
-
- XUngrabServer (priv->screen->display ()->dpy ());
- }
-
- if (!priv->texture.bindPixmap (priv->pixmap, priv->width, priv->height,
- priv->attrib.depth))
- {
- compLogMessage (priv->screen->display (), "core", CompLogLevelInfo,
- "Couldn't bind redirected window 0x%x to "
- "texture\n", (int) priv->id);
- }
-
- priv->setWindowMatrix ();
-
- return true;
-}
-
-void
-CompWindow::release ()
-{
- if (priv->pixmap)
- {
- priv->texture = CompTexture (priv->screen);
-
- XFreePixmap (priv->screen->display ()->dpy (), priv->pixmap);
-
- priv->pixmap = None;
- }
-}
-
-void
-CompWindow::damageTransformedRect (float xScale,
- float yScale,
- float xTranslate,
- float yTranslate,
- BoxPtr rect)
-{
- REGION reg;
-
- reg.rects = &reg.extents;
- reg.numRects = 1;
-
- reg.extents.x1 = (short) (rect->x1 * xScale) - 1;
- reg.extents.y1 = (short) (rect->y1 * yScale) - 1;
- reg.extents.x2 = (short) (rect->x2 * xScale + 0.5f) + 1;
- reg.extents.y2 = (short) (rect->y2 * yScale + 0.5f) + 1;
-
- reg.extents.x1 += (short) xTranslate;
- reg.extents.y1 += (short) yTranslate;
- reg.extents.x2 += (short) (xTranslate + 0.5f);
- reg.extents.y2 += (short) (yTranslate + 0.5f);
-
- if (reg.extents.x2 > reg.extents.x1 && reg.extents.y2 > reg.extents.y1)
- {
- reg.extents.x1 += priv->attrib.x + priv->attrib.border_width;
- reg.extents.y1 += priv->attrib.y + priv->attrib.border_width;
- reg.extents.x2 += priv->attrib.x + priv->attrib.border_width;
- reg.extents.y2 += priv->attrib.y + priv->attrib.border_width;
-
- priv->screen->damageRegion (&reg);
- }
-}
-
-void
-CompWindow::damageOutputExtents ()
-{
- if (priv->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
- return;
-
- if (priv->shaded || (priv->attrib.map_state == IsViewable && priv->damaged))
- {
- BoxRec box;
-
- /* top */
- box.x1 = -priv->output.left - priv->attrib.border_width;
- box.y1 = -priv->output.top - priv->attrib.border_width;
- box.x2 = priv->width + priv->output.right - priv->attrib.border_width;
- box.y2 = -priv->attrib.border_width;
-
- if (box.x1 < box.x2 && box.y1 < box.y2)
- addDamageRect (&box);
-
- /* bottom */
- box.y1 = priv->height - priv->attrib.border_width;
- box.y2 = box.y1 + priv->output.bottom - priv->attrib.border_width;
-
- if (box.x1 < box.x2 && box.y1 < box.y2)
- addDamageRect (&box);
-
- /* left */
- box.x1 = -priv->output.left - priv->attrib.border_width;
- box.y1 = -priv->attrib.border_width;
- box.x2 = -priv->attrib.border_width;
- box.y2 = priv->height - priv->attrib.border_width;
-
- if (box.x1 < box.x2 && box.y1 < box.y2)
- addDamageRect (&box);
-
- /* right */
- box.x1 = priv->width - priv->attrib.border_width;
- box.x2 = box.x1 + priv->output.right - priv->attrib.border_width;
-
- if (box.x1 < box.x2 && box.y1 < box.y2)
- addDamageRect (&box);
- }
-}
-
-bool
-CompWindow::damageRect (bool initial,
- BoxPtr rect)
-{
- WRAPABLE_HND_FUNC_RETURN(bool, damageRect, initial, rect)
- return false;
-}
-
-void
-CompWindow::addDamageRect (BoxPtr rect)
-{
- REGION region;
-
- if (priv->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
- return;
-
- region.extents = *rect;
-
- if (!damageRect (false, &region.extents))
- {
- region.extents.x1 += priv->attrib.x + priv->attrib.border_width;
- region.extents.y1 += priv->attrib.y + priv->attrib.border_width;
- region.extents.x2 += priv->attrib.x + priv->attrib.border_width;
- region.extents.y2 += priv->attrib.y + priv->attrib.border_width;
-
- region.rects = &region.extents;
- region.numRects = region.size = 1;
-
- priv->screen->damageRegion (&region);
- }
-}
-
-void
CompWindow::getOutputExtents (CompWindowExtents *output)
{
WRAPABLE_HND_FUNC(getOutputExtents, output)
@@ -1013,25 +835,6 @@ CompWindow::getOutputExtents (CompWindowExtents *output)
}
void
-CompWindow::addDamage ()
-{
- if (priv->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
- return;
-
- if (priv->shaded || (priv->attrib.map_state == IsViewable && priv->damaged))
- {
- BoxRec box;
-
- box.x1 = -priv->output.left - priv->attrib.border_width;
- box.y1 = -priv->output.top - priv->attrib.border_width;
- box.x2 = priv->width + priv->output.right;
- box.y2 = priv->height + priv->output.bottom;
-
- addDamageRect (&box);
- }
-}
-
-void
CompWindow::updateRegion ()
{
REGION rect;
@@ -1435,9 +1238,7 @@ CompWindow::map ()
priv->screen->display ()->setWmState (NormalState, priv->id);
priv->invisible = true;
- priv->damaged = false;
priv->alive = true;
- priv->bindFailed = false;
priv->lastPong = priv->screen->display ()->lastPing ();
@@ -1465,6 +1266,8 @@ CompWindow::map ()
resize (priv->attrib.x, priv->attrib.y, priv->attrib.width,
++priv->attrib.height - 1, priv->attrib.border_width);
}
+
+ windowNotify (CompWindowNotifyMap);
}
void
@@ -1491,13 +1294,10 @@ CompWindow::unmap ()
if (priv->type == CompWindowTypeDesktopMask)
priv->screen->desktopWindowCount ()--;
- addDamage ();
-
priv->attrib.map_state = IsUnmapped;
priv->invisible = true;
- release ();
if (priv->shaded && priv->height)
resize (priv->attrib.x, priv->attrib.y,
@@ -1506,8 +1306,7 @@ CompWindow::unmap ()
priv->screen->updateClientList ();
- if (!priv->redirected)
- redirect ();
+ windowNotify (CompWindowNotifyUnmap);
}
bool
@@ -1526,6 +1325,8 @@ PrivateWindow::restack (Window aboveId)
screen->updateClientList ();
+ window->windowNotify (CompWindowNotifyRestack);
+
return true;
}
@@ -1550,38 +1351,17 @@ CompWindow::resize (CompWindow::Geometry gm)
priv->attrib.height != (int) gm.height () ||
priv->attrib.border_width != (int) gm.border ())
{
- unsigned int pw, ph, actualWidth, actualHeight, ui;
+ unsigned int pw, ph;
int dx, dy, dwidth, dheight;
- Pixmap pixmap = None;
- Window root;
- Status result;
- int i;
pw = gm.width () + gm.border () * 2;
ph = gm.height () + gm.border () * 2;
- if (priv->mapNum && priv->redirected)
- {
- pixmap = XCompositeNameWindowPixmap (priv->screen->display ()->dpy (),
- priv->id);
- result = XGetGeometry (priv->screen->display ()->dpy (), pixmap, &root,
- &i, &i, &actualWidth, &actualHeight,
- &ui, &ui);
-
- if (!result || actualWidth != pw || actualHeight != ph)
- {
- XFreePixmap (priv->screen->display ()->dpy (), pixmap);
-
- return false;
- }
- }
- else if (priv->shaded)
+ if (priv->shaded)
{
ph = 0;
}
- addDamage ();
-
dx = gm.x () - priv->attrib.x;
dy = gm.y () - priv->attrib.y;
dwidth = gm.width () - priv->attrib.width;
@@ -1596,17 +1376,11 @@ CompWindow::resize (CompWindow::Geometry gm)
priv->width = pw;
priv->height = ph;
- release ();
-
- priv->pixmap = pixmap;
-
if (priv->mapNum)
updateRegion ();
resizeNotify (dx, dy, dwidth, dheight);
- addDamage ();
-
priv->invisible = WINDOW_INVISIBLE (priv);
priv->updateFrameWindow ();
@@ -1766,8 +1540,7 @@ CompWindow::configure (XConfigureEvent *ce)
priv->attrib.override_redirect = ce->override_redirect;
- if (priv->restack (ce->above))
- addDamage ();
+ priv->restack (ce->above);
}
void
@@ -1780,8 +1553,7 @@ CompWindow::circulate (XCirculateEvent *ce)
else
newAboveId = 0;
- if (priv->restack (newAboveId))
- addDamage ();
+ priv->restack (newAboveId);
}
void
@@ -1789,22 +1561,14 @@ CompWindow::move (int dx, int dy, Bool damage, Bool immediate)
{
if (dx || dy)
{
- if (damage)
- addDamage ();
-
priv->attrib.x += dx;
priv->attrib.y += dy;
XOffsetRegion (priv->region, dx, dy);
- priv->setWindowMatrix ();
-
priv->invisible = WINDOW_INVISIBLE (priv);
moveNotify (dx, dy, immediate);
-
- if (damage)
- addDamage ();
}
}
@@ -1878,6 +1642,10 @@ CompWindow::moveNotify (int dx,
WRAPABLE_HND_FUNC(moveNotify, dx, dy, immediate)
void
+CompWindow::windowNotify (CompWindowNotify n)
+ WRAPABLE_HND_FUNC (windowNotify, n)
+
+void
CompWindow::grabNotify (int x,
int y,
unsigned int state,
@@ -3500,12 +3268,12 @@ CompWindow::hide ()
}
else
{
- addDamage ();
-
priv->shaded = false;
if ((priv->state & CompWindowStateShadedMask) && priv->frame)
XUnmapWindow (priv->screen->display ()->dpy (), priv->frame);
+
+ windowNotify (CompWindowNotifyHide);
}
if (!priv->pendingMaps && priv->attrib.map_state != IsViewable)
@@ -3554,8 +3322,7 @@ CompWindow::show ()
priv->attrib.width, ++priv->attrib.height - 1,
priv->attrib.border_width);
- addDamage ();
-
+ windowNotify (CompWindowNotifyShow);
return;
}
else
@@ -3830,48 +3597,6 @@ CompWindow::allowWindowFocus (unsigned int noFocusMask,
}
void
-CompWindow::unredirect ()
-{
- if (!priv->redirected)
- return;
-
- release ();
-
- XCompositeUnredirectWindow (priv->screen->display ()->dpy (), priv->id,
- CompositeRedirectManual);
-
- priv->redirected = false;
- priv->overlayWindow = true;
- priv->screen->overlayWindowCount ()++;
-
- if (priv->screen->overlayWindowCount () > 0)
- priv->screen->updateOutputWindow ();
-}
-
-void
-CompWindow::redirect ()
-{
- if (priv->redirected)
- return;
-
- XCompositeRedirectWindow (priv->screen->display ()->dpy (), priv->id,
- CompositeRedirectManual);
-
- priv->redirected = true;
-
- if (priv->overlayWindow)
- {
- priv->screen->overlayWindowCount ()--;
- priv->overlayWindow = false;
- }
-
- if (priv->screen->overlayWindowCount () < 1)
- priv->screen->showOutputWindow ();
- else
- priv->screen->updateOutputWindow ();
-}
-
-void
CompWindow::defaultViewport (int *vx, int *vy)
{
priv->screen->viewportForGeometry (priv->serverGeometry, vx, vy);
@@ -4145,13 +3870,6 @@ CompWindow::getMovementForOffset (int offX,
WindowInterface::WindowInterface ()
{
- WRAPABLE_INIT_FUNC(paint);
- WRAPABLE_INIT_FUNC(draw);
- WRAPABLE_INIT_FUNC(addGeometry);
- WRAPABLE_INIT_FUNC(drawTexture);
- WRAPABLE_INIT_FUNC(drawGeometry);
-
- WRAPABLE_INIT_FUNC(damageRect);
WRAPABLE_INIT_FUNC(getOutputExtents);
WRAPABLE_INIT_FUNC(getAllowedActions);
@@ -4162,48 +3880,13 @@ WindowInterface::WindowInterface ()
WRAPABLE_INIT_FUNC(resizeNotify);
WRAPABLE_INIT_FUNC(moveNotify);
+ WRAPABLE_INIT_FUNC(windowNotify);
WRAPABLE_INIT_FUNC(grabNotify);
WRAPABLE_INIT_FUNC(ungrabNotify);
WRAPABLE_INIT_FUNC(stateChangeNotify);
}
-
-bool
-WindowInterface::paint (const CompWindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
- WRAPABLE_DEF_FUNC_RETURN(paint, attrib, transform, region, mask)
-
-bool
-WindowInterface::draw (const CompTransform *transform,
- CompFragment::Attrib &fragment,
- Region region,
- unsigned int mask)
- WRAPABLE_DEF_FUNC_RETURN(draw, transform, fragment, region, mask)
-
-void
-WindowInterface::addGeometry (CompTexture::Matrix *matrix,
- int nMatrix,
- Region region,
- Region clip)
- WRAPABLE_DEF_FUNC(addGeometry, matrix, nMatrix, region, clip)
-
-void
-WindowInterface::drawTexture (CompTexture *texture,
- CompFragment::Attrib &fragment,
- unsigned int mask)
- WRAPABLE_DEF_FUNC(drawTexture, texture, fragment, mask)
-
-void
-WindowInterface::drawGeometry ()
- WRAPABLE_DEF_FUNC(drawGeometry)
-
-bool
-WindowInterface::damageRect (bool initial, BoxPtr rect)
- WRAPABLE_DEF_FUNC_RETURN(damageRect, initial, rect)
-
void
WindowInterface::getOutputExtents (CompWindowExtents *output)
WRAPABLE_DEF_FUNC(getOutputExtents, output)
@@ -4239,6 +3922,11 @@ WindowInterface::moveNotify (int dx, int dy, bool immediate)
WRAPABLE_DEF_FUNC(moveNotify, dx, dy, immediate)
void
+WindowInterface::windowNotify (CompWindowNotify n)
+ WRAPABLE_DEF_FUNC(windowNotify, n)
+
+
+void
WindowInterface::grabNotify (int x,
int y,
unsigned int state,
@@ -4351,9 +4039,9 @@ CompWindow::handlePingTimeout (unsigned int lastPing)
{
if (priv->alive)
{
- priv->alive = false;
- priv->paint.brightness = 0xa8a8;
- priv->paint.saturation = 0;
+ priv->alive = false;
+
+ windowNotify (CompWindowNotifyAliveChanged);
if (priv->closeRequests)
{
@@ -4365,8 +4053,6 @@ CompWindow::handlePingTimeout (unsigned int lastPing)
priv->closeRequests = 0;
}
-
- addDamage ();
}
}
@@ -4380,9 +4066,9 @@ CompWindow::handlePing (int lastPing)
{
if (!priv->alive)
{
- priv->alive = true;
- priv->paint.saturation = priv->saturation;
- priv->paint.brightness = priv->brightness;
+ priv->alive = true;
+
+ windowNotify (CompWindowNotifyAliveChanged);
if (priv->lastCloseRequestTime)
{
@@ -4396,8 +4082,6 @@ CompWindow::handlePing (int lastPing)
priv->lastCloseRequestTime = 0;
}
-
- addDamage ();
}
priv->lastPong = lastPing;
}
@@ -4467,11 +4151,6 @@ CompWindow::processMap ()
moveInputFocusTo ();
}
-bool
-CompWindow::overlayWindow ()
-{
- return priv->overlayWindow;
-}
Region
CompWindow::region ()
@@ -4710,70 +4389,16 @@ CompWindow::input ()
return priv->input;
}
-XSizeHints
-CompWindow::sizeHints ()
-{
- return priv->sizeHints;
-}
-
-void
-CompWindow::updateOpacity ()
-{
- GLushort opacity;
-
- if (priv->type & CompWindowTypeDesktopMask)
- return;
-
- opacity = priv->screen->display ()->getWindowProp32 (priv->id,
- priv->screen->display ()->atoms ().winOpacity, OPAQUE);
-
- if (opacity != priv->opacity)
- {
- priv->opacity = opacity;
- if (priv->alive)
- {
- priv->paint.opacity = priv->opacity;
- addDamage ();
- }
- }
-}
-
-void
-CompWindow::updateBrightness ()
+CompWindowExtents
+CompWindow::output ()
{
- GLushort brightness;
-
- brightness = priv->screen->display ()->getWindowProp32 (priv->id,
- priv->screen->display ()->atoms ().winBrightness, BRIGHT);
-
- if (brightness != priv->brightness)
- {
- priv->brightness = brightness;
- if (priv->alive)
- {
- priv->paint.brightness = priv->brightness;
- addDamage ();
- }
- }
+ return priv->output;
}
-void
-CompWindow::updateSaturation ()
+XSizeHints
+CompWindow::sizeHints ()
{
- GLushort saturation;
-
- saturation = priv->screen->display ()->getWindowProp32 (priv->id,
- priv->screen->display ()->atoms ().winSaturation, COLOR);
-
- if (saturation != priv->saturation)
- {
- priv->saturation = saturation;
- if (priv->alive)
- {
- priv->paint.saturation = priv->saturation;
- addDamage ();
- }
- }
+ return priv->sizeHints;
}
void
@@ -4794,34 +4419,6 @@ CompWindow::updateStartupId ()
priv->startupId = getStartupId ();
}
-void
-CompWindow::processDamage (XDamageNotifyEvent *de)
-{
- priv->texture.damage ();
-
- if (priv->syncWait)
- {
- if (priv->nDamage == priv->sizeDamage)
- {
- priv->damageRects = (XRectangle *) realloc (priv->damageRects,
- (priv->sizeDamage + 1) *
- sizeof (XRectangle));
- priv->sizeDamage += 1;
- }
-
- priv->damageRects[priv->nDamage].x = de->area.x;
- priv->damageRects[priv->nDamage].y = de->area.y;
- priv->damageRects[priv->nDamage].width = de->area.width;
- priv->damageRects[priv->nDamage].height = de->area.height;
- priv->nDamage++;
- }
- else
- {
- priv->handleDamageRect (this, de->area.x, de->area.y,
- de->area.width, de->area.height);
- }
-}
-
XSyncAlarm
CompWindow::syncAlarm ()
{
@@ -4835,34 +4432,11 @@ CompWindow::destroyed ()
}
bool
-CompWindow::damaged ()
-{
- return priv->damaged;
-}
-
-bool
CompWindow::invisible ()
{
return priv->invisible;
}
-bool
-CompWindow::redirected ()
-{
- return priv->redirected;
-}
-
-Region
-CompWindow::clip ()
-{
- return priv->clip;
-}
-
-CompWindowPaintAttrib &
-CompWindow::paintAttrib ()
-{
- return priv->paint;
-}
CompWindow::CompWindow (CompScreen *screen,
@@ -4870,13 +4444,7 @@ CompWindow::CompWindow (CompScreen *screen,
Window aboveId) :
CompObject (COMP_OBJECT_TYPE_WINDOW, "window", &windowPrivateIndices)
{
- WRAPABLE_INIT_HND(paint);
- WRAPABLE_INIT_HND(draw);
- WRAPABLE_INIT_HND(addGeometry);
- WRAPABLE_INIT_HND(drawTexture);
- WRAPABLE_INIT_HND(drawGeometry);
- WRAPABLE_INIT_HND(damageRect);
WRAPABLE_INIT_HND(getOutputExtents);
WRAPABLE_INIT_HND(getAllowedActions);
@@ -4887,6 +4455,7 @@ CompWindow::CompWindow (CompScreen *screen,
WRAPABLE_INIT_HND(resizeNotify);
WRAPABLE_INIT_HND(moveNotify);
+ WRAPABLE_INIT_HND(windowNotify);
WRAPABLE_INIT_HND(grabNotify);
WRAPABLE_INIT_HND(ungrabNotify);
@@ -4900,8 +4469,7 @@ CompWindow::CompWindow (CompScreen *screen,
priv->region = XCreateRegion ();
assert (priv->region);
- priv->clip = XCreateRegion ();
- assert (priv->clip);
+
/* Failure means that window has been destroyed. We still have to add the
window to the window list as we might get configure requests which
@@ -4963,9 +4531,6 @@ CompWindow::CompWindow (CompScreen *screen,
XUnionRegion (&rect, priv->region, priv->region);
- priv->damage = XDamageCreate (d->dpy (), id,
- XDamageReportRawRectangles);
-
/* need to check for DisplayModal state on all windows */
priv->state = d->getWindowState (priv->id);
@@ -4973,7 +4538,6 @@ CompWindow::CompWindow (CompScreen *screen,
}
else
{
- priv->damage = None;
priv->attrib.map_state = IsUnmapped;
}
@@ -5011,23 +4575,6 @@ CompWindow::CompWindow (CompScreen *screen,
recalcType ();
}
- priv->opacity = OPAQUE;
- if (!(priv->type & CompWindowTypeDesktopMask))
- priv->opacity = d->getWindowProp32 (priv->id,
- d->atoms ().winOpacity, OPAQUE);
-
- priv->brightness = d->getWindowProp32 (priv->id,
- d->atoms ().winBrightness, BRIGHT);
-
- priv->saturation = d->getWindowProp32 (priv->id,
- d->atoms ().winSaturation, COLOR);
-
- priv->paint.opacity = priv->opacity;
- priv->paint.brightness = priv->brightness;
- priv->paint.saturation = priv->saturation;
-
- priv->lastPaint = priv->paint;
-
if (priv->attrib.map_state == IsViewable)
{
priv->placed = true;
@@ -5113,7 +4660,6 @@ CompWindow::CompWindow (CompScreen *screen,
if (priv->attrib.map_state == IsViewable)
{
- priv->damaged = true;
priv->invisible = WINDOW_INVISIBLE (priv);
}
}
@@ -5139,9 +4685,6 @@ CompWindow::~CompWindow ()
}
}
- if (priv->damage)
- XDamageDestroy (d->dpy (), priv->damage);
-
if (d->XShape ())
XShapeSelectInput (d->dpy (), priv->id, NoEventMask);
@@ -5150,7 +4693,7 @@ CompWindow::~CompWindow ()
XUngrabButton (d->dpy (), AnyButton, AnyModifier, priv->id);
}
- if (priv->attrib.map_state == IsViewable && priv->damaged)
+ if (priv->attrib.map_state == IsViewable)
{
if (priv->type == CompWindowTypeDesktopMask)
priv->screen->desktopWindowCount ()--;
@@ -5162,20 +4705,10 @@ CompWindow::~CompWindow ()
if (priv->destroyed)
priv->screen->updateClientList ();
- if (!priv->redirected)
- {
- priv->screen->overlayWindowCount ()--;
-
- if (priv->screen->overlayWindowCount () < 1)
- priv->screen->showOutputWindow ();
- }
-
core->objectRemove (priv->screen, this);
CompPlugin::objectFiniPlugins (this);
- release ();
-
delete priv;
}
@@ -5189,15 +4722,11 @@ PrivateWindow::PrivateWindow (CompWindow *window, CompScreen *screen) :
activeNum (0),
transientFor (None),
clientLeader (None),
- pixmap (None),
- texture (screen),
- damage (None),
inputHint (true),
alpha (false),
width (0),
height (0),
region (0),
- clip (0),
wmType (0),
type (CompWindowTypeUnknownMask),
state (0),
@@ -5207,11 +4736,7 @@ PrivateWindow::PrivateWindow (CompWindow *window, CompScreen *screen) :
mwmFunc (MwmFuncAll),
invisible (true),
destroyed (false),
- damaged (false),
- redirected (true),
managed (false),
- bindFailed (false),
- overlayWindow (false),
destroyRefCnt (1),
unmapRefCnt (1),
@@ -5241,12 +4766,6 @@ PrivateWindow::PrivateWindow (CompWindow *window, CompScreen *screen) :
lastPong (0),
alive (true),
- opacity (OPAQUE),
- brightness (BRIGHT),
- saturation (COLOR),
-
- lastMask (0),
-
struts (0),
icons (0),
@@ -5261,19 +4780,7 @@ PrivateWindow::PrivateWindow (CompWindow *window, CompScreen *screen) :
syncWait (false),
closeRequests (false),
- lastCloseRequestTime (0),
- damageRects (0),
- sizeDamage (0),
- nDamage (0),
- vertices (0),
- vertexSize (0),
- vertexStride (0),
- indices (0),
- indexSize (0),
- vCount (0),
- texUnits (0),
- texCoordSize (2),
- indexCount (0)
+ lastCloseRequestTime (0)
{
iconGeometry.x = 0;
iconGeometry.y = 0;
@@ -5290,11 +4797,6 @@ PrivateWindow::PrivateWindow (CompWindow *window, CompScreen *screen) :
output.right = 0;
output.top = 0;
output.bottom = 0;
-
- paint.xScale = 1.0f;
- paint.yScale = 1.0f;
- paint.xTranslate = 0.0f;
- paint.yTranslate = 0.0f;
}
PrivateWindow::~PrivateWindow ()
@@ -5307,21 +4809,9 @@ PrivateWindow::~PrivateWindow ()
if (frame)
XDestroyWindow (screen->display ()->dpy (), frame);
- if (clip)
- XDestroyRegion (clip);
-
if (region)
XDestroyRegion (region);
- if (sizeDamage)
- free (damageRects);
-
- if (vertices)
- free (vertices);
-
- if (indices)
- free (indices);
-
if (struts)
free (struts);
@@ -5348,3 +4838,22 @@ CompWindow::objectName ()
return CompString (tmp);
}
+
+bool
+CompWindow::syncWait ()
+{
+ return priv->syncWait;
+}
+
+bool
+CompWindow::alpha ()
+{
+ return priv->alpha;
+}
+
+bool
+CompWindow::alive ()
+{
+ return priv->alive;
+}
+