diff options
author | Dennis Kasprzyk <onestone@compiz-fusion.org> | 2008-08-21 00:51:03 +0200 |
---|---|---|
committer | Dennis kasprzyk <onestone@compiz-fusion.org> | 2008-08-21 00:51:03 +0200 |
commit | b0a83124e3668296b5db42ee5eff3ecf674d8d6a (patch) | |
tree | e7e7d686d3a4bb33f9a434c256ed742d493afca7 | |
parent | 3808dcc20b40c441f2c3b72bba151a6404d1f322 (diff) | |
download | compiz-with-glib-mainloop-b0a83124e3668296b5db42ee5eff3ecf674d8d6a.tar.gz compiz-with-glib-mainloop-b0a83124e3668296b5db42ee5eff3ecf674d8d6a.tar.bz2 |
Cleanup compiz[-core].h
-rw-r--r-- | include/compaction.h | 21 | ||||
-rw-r--r-- | include/compcore.h | 73 | ||||
-rw-r--r-- | include/compdisplay.h | 25 | ||||
-rw-r--r-- | include/compiz-core.h | 232 | ||||
-rw-r--r-- | include/compiz.h | 51 | ||||
-rw-r--r-- | include/compmatrix.h | 2 | ||||
-rw-r--r-- | include/compobject.h | 26 | ||||
-rw-r--r-- | include/compoption.h | 3 | ||||
-rw-r--r-- | include/compplugin.h | 3 | ||||
-rw-r--r-- | include/compscreen.h | 40 | ||||
-rw-r--r-- | include/compwindow.h | 16 | ||||
-rw-r--r-- | src/action.cpp | 4 | ||||
-rw-r--r-- | src/core.cpp | 23 | ||||
-rw-r--r-- | src/display.cpp | 12 | ||||
-rw-r--r-- | src/fragment.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 21 | ||||
-rw-r--r-- | src/match.cpp | 3 | ||||
-rw-r--r-- | src/matrix.cpp | 1 | ||||
-rw-r--r-- | src/metadata.cpp | 4 | ||||
-rw-r--r-- | src/object.cpp | 47 | ||||
-rw-r--r-- | src/plugin.cpp | 42 | ||||
-rw-r--r-- | src/privatecore.h | 9 | ||||
-rw-r--r-- | src/privatedisplay.h | 3 | ||||
-rw-r--r-- | src/privatefragment.h | 2 | ||||
-rw-r--r-- | src/privateobject.h | 2 | ||||
-rw-r--r-- | src/privateoption.h | 5 | ||||
-rw-r--r-- | src/privatescreen.h | 21 | ||||
-rw-r--r-- | src/privatewindow.h | 6 | ||||
-rw-r--r-- | src/screen.cpp | 25 | ||||
-rw-r--r-- | src/session.cpp | 11 | ||||
-rw-r--r-- | src/string.cpp | 3 | ||||
-rw-r--r-- | src/texture.cpp | 2 | ||||
-rw-r--r-- | src/window.cpp | 31 |
33 files changed, 328 insertions, 442 deletions
diff --git a/include/compaction.h b/include/compaction.h index 22f77fd..3f789cd 100644 --- a/include/compaction.h +++ b/include/compaction.h @@ -3,10 +3,31 @@ #include <boost/function.hpp> +#include <X11/Xlib-xcb.h> + #include <compoption.h> class PrivateAction; +#define CompModAlt 0 +#define CompModMeta 1 +#define CompModSuper 2 +#define CompModHyper 3 +#define CompModModeSwitch 4 +#define CompModNumLock 5 +#define CompModScrollLock 6 +#define CompModNum 7 + +#define CompAltMask (1 << 16) +#define CompMetaMask (1 << 17) +#define CompSuperMask (1 << 18) +#define CompHyperMask (1 << 19) +#define CompModeSwitchMask (1 << 20) +#define CompNumLockMask (1 << 21) +#define CompScrollLockMask (1 << 22) + +#define CompNoMask (1 << 25) + class CompAction { public: typedef enum { diff --git a/include/compcore.h b/include/compcore.h index eb508f2..a2a5258 100644 --- a/include/compcore.h +++ b/include/compcore.h @@ -3,67 +3,40 @@ #include <list> #include <boost/function.hpp> + #include "wrapable.h" #include <compoption.h> +#include <compobject.h> #include <compsession.h> - class PrivateCore; class CompCore; class CompDisplay; +class CompPlugin; +class CompMetadata; typedef std::list<CompDisplay *> CompDisplayList; +extern CompCore *core; +extern CompMetadata *coreMetadata; + #define NOTIFY_CREATE_MASK (1 << 0) #define NOTIFY_DELETE_MASK (1 << 1) #define NOTIFY_MOVE_MASK (1 << 2) #define NOTIFY_MODIFY_MASK (1 << 3) -typedef void (*FileWatchCallBackProc) (const char *name, - void *closure); +typedef boost::function<void ()> FdWatchCallBack; +typedef boost::function<void (const char *)> FileWatchCallBack; typedef int CompFileWatchHandle; +typedef int CompWatchFdHandle; -typedef struct _CompFileWatch { - char *path; - int mask; - FileWatchCallBackProc callBack; - void *closure; - CompFileWatchHandle handle; -} CompFileWatch; - -typedef struct _CompWatchFd { - int fd; - CallBackProc callBack; - void *closure; - CompWatchFdHandle handle; -} CompWatchFd; - -int -allocCoreObjectPrivateIndex (CompObject *parent); - -void -freeCoreObjectPrivateIndex (CompObject *parent, - int index); - -CompBool -forEachCoreObject (CompObject *parent, - ObjectCallBackProc proc, - void *closure); - -char * -nameCoreObject (CompObject *object); - -CompObject * -findCoreObject (CompObject *parent, - const char *name); - -int -allocateCorePrivateIndex (void); - -void -freeCorePrivateIndex (int index); - +struct CompFileWatch { + char *path; + int mask; + FileWatchCallBack callBack; + CompFileWatchHandle handle; +}; class CoreInterface : public WrapableInterface<CompCore> { public: @@ -145,19 +118,17 @@ class CompCore : public WrapableHandler<CoreInterface>, public CompObject { displays(); CompFileWatchHandle - addFileWatch (const char *path, - int mask, - FileWatchCallBackProc callBack, - void *closure); + addFileWatch (const char *path, + int mask, + FileWatchCallBack callBack); void removeFileWatch (CompFileWatchHandle handle); CompWatchFdHandle - addWatchFd (int fd, - short int events, - CallBackProc callBack, - void *closure); + addWatchFd (int fd, + short int events, + FdWatchCallBack callBack); void removeWatchFd (CompWatchFdHandle handle); diff --git a/include/compdisplay.h b/include/compdisplay.h index aace93b..e2fd1ac 100644 --- a/include/compdisplay.h +++ b/include/compdisplay.h @@ -3,14 +3,33 @@ #include <list> +#include <X11/Xlib-xcb.h> +#include <X11/Xutil.h> +#include <X11/Xregion.h> +#include <X11/extensions/Xinerama.h> + +#include <GL/gl.h> + +#include <compobject.h> #include <compmatch.h> +#include <compcore.h> +#include <compaction.h> #include "wrapable.h" class CompDisplay; class CompScreen; +class CompOutput; class PrivateDisplay; typedef std::list<CompScreen *> CompScreenList; +extern REGION emptyRegion; +extern REGION infiniteRegion; + +extern int lastPointerX; +extern int lastPointerY; +extern int pointerX; +extern int pointerY; + #define GET_CORE_DISPLAY(object) (dynamic_cast<CompDisplay *> (object)) #define CORE_DISPLAY(object) CompDisplay *d = GET_CORE_DISPLAY (object) @@ -256,10 +275,6 @@ class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject CompScreen * findScreen (Window root); - void - forEachWindow (ForEachWindowProc proc, - void *closure); - CompWindow * findWindow (Window id); @@ -356,6 +371,8 @@ class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject static int allocPrivateIndex (); static void freePrivateIndex (int index); + + static int checkForError (Display *dpy); // wrapable interface WRAPABLE_HND(void, handleEvent, XEvent *event) diff --git a/include/compiz-core.h b/include/compiz-core.h index bf57a8b..ba85f10 100644 --- a/include/compiz-core.h +++ b/include/compiz-core.h @@ -26,12 +26,9 @@ #ifndef _COMPIZ_CORE_H #define _COMPIZ_CORE_H -#include <compplugin.h> - #define CORE_ABIVERSION 20080618 #include <stdio.h> -#include <sys/time.h> #include <assert.h> #include <X11/Xlib-xcb.h> @@ -43,23 +40,21 @@ #include <X11/Xregion.h> #include <X11/XKBlib.h> - #include <GL/gl.h> #include <GL/glx.h> - -#define TIMEVALDIFF(tv1, tv2) \ - ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \ - ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \ - ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \ - ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \ - (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000 - - -#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR > 2 -#define USE_COW +// X11 Bool defination breaks BOOST_FOREACH. Convert it to a typedef */ +#ifdef Bool +typedef Bool XBool; +#undef Bool +typedef XBool Bool; #endif +#include <boost/function.hpp> +#include <boost/bind.hpp> +#include <boost/foreach.hpp> +#define foreach BOOST_FOREACH + /* * WORDS_BIGENDIAN should be defined before including this file for * IMAGE_BYTE_ORDER and BITMAP_BIT_ORDER to be set correctly. @@ -75,200 +70,25 @@ # define BITMAP_BIT_ORDER LSBFirst #endif -class CompTexture; -class CompIcon; -//typedef struct _CompWindowExtents CompWindowExtents; -class CompMatch; -class CompOutput; -typedef struct _CompWalker CompWalker; - -class CompDisplay; - -/* virtual modifiers */ - -#define CompModAlt 0 -#define CompModMeta 1 -#define CompModSuper 2 -#define CompModHyper 3 -#define CompModModeSwitch 4 -#define CompModNumLock 5 -#define CompModScrollLock 6 -#define CompModNum 7 - -#define CompAltMask (1 << 16) -#define CompMetaMask (1 << 17) -#define CompSuperMask (1 << 18) -#define CompHyperMask (1 << 19) -#define CompModeSwitchMask (1 << 20) -#define CompNumLockMask (1 << 21) -#define CompScrollLockMask (1 << 22) - -#define CompNoMask (1 << 25) - -#define OPAQUE 0xffff -#define COLOR 0xffff -#define BRIGHT 0xffff - -#define RED_SATURATION_WEIGHT 0.30f -#define GREEN_SATURATION_WEIGHT 0.59f -#define BLUE_SATURATION_WEIGHT 0.11f - -extern char *programName; -extern char **programArgv; -extern int programArgc; -extern char *backgroundImage; -extern REGION emptyRegion; -extern REGION infiniteRegion; -extern GLushort defaultColor[4]; -extern Window currentRoot; -extern Bool shutDown; -extern Bool restartSignal; -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 char *defaultTextureFilter; - -extern int lastPointerX; -extern int lastPointerY; -extern int pointerX; -extern int pointerY; - -extern CompCore *core; -extern CompMetadata *coreMetadata; - -#define RESTRICT_VALUE(value, min, max) \ - (((value) < (min)) ? (min): ((value) > (max)) ? (max) : (value)) - -#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) - - -/* privates.c */ - -#define WRAP(priv, real, func, wrapFunc) \ - (priv)->func = (real)->func; \ - (real)->func = (wrapFunc) - -#define UNWRAP(priv, real, func) \ - (real)->func = (priv)->func - - - -/* session.c */ - - - -/* option.c */ - - - -typedef CompOption *(*DisplayOptionsProc) (CompDisplay *display, int *count); -typedef CompOption *(*ScreenOptionsProc) (CompScreen *screen, int *count); - - - - - - -/* core.c */ - -/* display.c */ - - - -typedef void (*ForEachWindowProc) (CompWindow *window, - void *closure); - - - - -void -compLogMessage (CompDisplay *d, - const char *componentName, - CompLogLevel level, - const char *format, - ...); - -const char * -logLevelToString (CompLogLevel level); - -int -compCheckForError (Display *dpy); - -void -warpPointer (CompScreen *screen, - int dx, - int dy); - -/* event.c */ - - -void -handleSyncAlarm (CompWindow *w); - -Bool -eventMatches (CompDisplay *display, - XEvent *event, - CompOption *option); - -Bool -eventTerminates (CompDisplay *display, - XEvent *event, - CompOption *option); - -/* paint.c */ - -#define MULTIPLY_USHORT(us1, us2) \ - (((GLuint) (us1) * (GLuint) (us2)) / 0xffff) - -/* camera distance from screen, 0.5 * tan (FOV) */ -#define DEFAULT_Z_CAMERA 0.866025404f - -#define DEG2RAD (M_PI / 180.0f) - -/* screen.c */ - -/* window.c */ - - - -/* plugin.c */ - - - - -/* fragment.c */ - - -/* match.c */ - - -/* metadata.c */ - - - -#include <compaction.h> - - - - -CompString compPrintf (const char *format, ...); -CompString compPrintf (const char *format, va_list ap); - -#include <compmetadata.h> -#include <comprect.h> -#include <compoutput.h> #include <compobject.h> #include <compcore.h> #include <compdisplay.h> #include <compscreen.h> #include <compwindow.h> - +#include <compplugin.h> +#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/compiz.h b/include/compiz.h index 353bbba..22d37f6 100644 --- a/include/compiz.h +++ b/include/compiz.h @@ -29,35 +29,39 @@ #include <compiz-common.h> #include <string> -#include <vector> #include <list> -typedef std::string CompString; -typedef std::list<CompString> CompStringList; +#define RESTRICT_VALUE(value, min, max) \ + (((value) < (min)) ? (min): ((value) > (max)) ? (max) : (value)) + +#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) +#define TIMEVALDIFF(tv1, tv2) \ + ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \ + ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \ + ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \ + ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \ + (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000 -typedef int CompBool; -typedef int CompTimeoutHandle; -typedef int CompWatchFdHandle; +#define MULTIPLY_USHORT(us1, us2) \ + (((GLuint) (us1) * (GLuint) (us2)) / 0xffff) +#define DEG2RAD (M_PI / 180.0f) -class CompCore; class CompDisplay; -class CompScreen; -class CompWindow; -class CompObject; -class CompOption; -class CompMetadata; -typedef union _CompPrivate { +typedef std::string CompString; +typedef std::list<CompString> CompStringList; + +CompString compPrintf (const char *format, ...); +CompString compPrintf (const char *format, va_list ap); + +union CompPrivate { void *ptr; long val; unsigned long uval; void *(*fptr) (void); -} CompPrivate; - - -typedef bool (*CallBackProc) (void *closure); +}; typedef enum { CompLogLevelFatal = 0, @@ -67,9 +71,18 @@ typedef enum { CompLogLevelDebug } CompLogLevel; +void +compLogMessage (CompDisplay *d, + const char *componentName, + CompLogLevel level, + const char *format, + ...); +const char * +logLevelToString (CompLogLevel level); - - +extern char *programName; +extern char **programArgv; +extern int programArgc; #endif diff --git a/include/compmatrix.h b/include/compmatrix.h index 71db9ea..3f9962e 100644 --- a/include/compmatrix.h +++ b/include/compmatrix.h @@ -3,6 +3,8 @@ #include <compvector.h> +class CompOutput; + class CompMatrix { public: CompMatrix (); diff --git a/include/compobject.h b/include/compobject.h index 13f14ad..69a1ecf 100644 --- a/include/compobject.h +++ b/include/compobject.h @@ -1,10 +1,10 @@ #ifndef _COMPOBJECT_H #define _COMPOBJECT_H -#include <vector> - -typedef int CompObjectType; +#include <compiz.h> +#include <vector> +#include <boost/function.hpp> #define COMP_OBJECT_TYPE_ALL -1 #define COMP_OBJECT_TYPE_CORE 0 @@ -12,10 +12,6 @@ typedef int CompObjectType; #define COMP_OBJECT_TYPE_SCREEN 2 #define COMP_OBJECT_TYPE_WINDOW 3 - -typedef bool (*ObjectCallBackProc) (CompObject *object, - void *closure); - #define ARRAY_SIZE(array) \ (sizeof (array) / sizeof (array[0])) @@ -38,20 +34,21 @@ class CompObject { public: typedef std::vector<bool> indices; + typedef boost::function<bool (CompObject *)> CallBack; + typedef int Type; public: - CompObject (CompObjectType type, const char* typeName, + CompObject (Type type, const char* typeName, indices *iList = NULL); virtual ~CompObject (); const char *typeName (); - CompObjectType type (); + Type type (); void addChild (CompObject *); - bool forEachChild (ObjectCallBackProc proc, - void *closure = NULL, - int type = -1); + bool forEachChild (CallBack proc, + Type type = COMP_OBJECT_TYPE_ALL); virtual CompString name () = 0; @@ -60,9 +57,8 @@ class CompObject { std::vector<CompPrivate> privates; protected: - static int allocatePrivateIndex (CompObjectType type, indices *iList); - static void freePrivateIndex (CompObjectType type, - indices *iList, int idx); + static int allocatePrivateIndex (Type type, indices *iList); + static void freePrivateIndex (Type type, indices *iList, int idx); private: PrivateObject *priv; diff --git a/include/compoption.h b/include/compoption.h index 64e29bf..fd8f626 100644 --- a/include/compoption.h +++ b/include/compoption.h @@ -3,11 +3,14 @@ #include <compiz.h> +#include <vector> + class PrivateOption; class PrivateValue; class PrivateRestriction; class CompAction; class CompMatch; +class CompScreen; class CompOption { public: diff --git a/include/compplugin.h b/include/compplugin.h index 39f2e67..bc22a6a 100644 --- a/include/compplugin.h +++ b/include/compplugin.h @@ -29,6 +29,9 @@ #include <compiz.h> #include <compoption.h> +class CompObject; +class CompMetadata; + typedef bool (*InitPluginObjectProc) (CompObject *object); typedef void (*FiniPluginObjectProc) (CompObject *object); diff --git a/include/compscreen.h b/include/compscreen.h index 5124765..6300bf4 100644 --- a/include/compscreen.h +++ b/include/compscreen.h @@ -5,11 +5,26 @@ #include <comptexture.h> #include <compfragment.h> #include <compmatrix.h> +#include <compoutput.h> +#include <compsession.h> class CompScreen; class PrivateScreen; typedef std::list<CompWindow *> CompWindowList; +extern GLushort defaultColor[4]; + +#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR > 2 +#define USE_COW +#endif + +/* camera distance from screen, 0.5 * tan (FOV) */ +#define DEFAULT_Z_CAMERA 0.866025404f + +#define OPAQUE 0xffff +#define COLOR 0xffff +#define BRIGHT 0xffff + #define GET_CORE_SCREEN(object) (dynamic_cast<CompScreen *> (object)) #define CORE_SCREEN(object) CompScreen *s = GET_CORE_SCREEN (object) @@ -316,7 +331,7 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject { damagePending (); void - forEachWindow (ForEachWindowProc, void *); + forEachWindow (CompWindow::ForEach); void focusDefaultWindow (); @@ -643,27 +658,4 @@ class CompScreen : public WrapableHandler<ScreenInterface>, public CompObject { void *userData); }; -bool -paintTimeout (void *closure); - -int -getTimeToNextRedraw (CompScreen *s, - struct timeval *tv, - struct timeval *lastTv, - Bool idle); - -void -waitForVideoSync (CompScreen *s); - -Bool -initScreen (CompScreen *s, - CompDisplay *display, - int screenNum, - Window wmSnSelectionWindow, - Atom wmSnAtom, - Time wmSnTimestamp); - -void -finiScreen (CompScreen *s); - #endif diff --git a/include/compwindow.h b/include/compwindow.h index d0009bb..a48f55c 100644 --- a/include/compwindow.h +++ b/include/compwindow.h @@ -1,13 +1,27 @@ #ifndef _COMPWINDOW_H #define _COMPWINDOW_H +#include <boost/function.hpp> + +#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> + class CompWindow; +class CompIcon; class PrivateWindow; struct CompStartupSequence; @@ -246,6 +260,8 @@ class CompWindow : public WrapableHandler<WindowInterface>, public CompObject { }; static CompWindowPaintAttrib defaultPaintAttrib; + + typedef boost::function<void (CompWindow *)> ForEach; public: CompWindow *next; diff --git a/src/action.cpp b/src/action.cpp index 37b123e..90fd243 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -28,9 +28,11 @@ #include <string.h> #include <compiz.h> -#include <compiz-core.h> +#include <compoption.h> #include <compaction.h> +#include <compscreen.h> +#include <compdisplay.h> #include <privateaction.h> struct _Modifier { diff --git a/src/core.cpp b/src/core.cpp index 6fc98ca..51a90dc 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -25,6 +25,7 @@ #include <string.h> #include <sys/poll.h> +#include <sys/time.h> #include <assert.h> #include <algorithm> @@ -32,6 +33,8 @@ #define foreach BOOST_FOREACH #include <compiz-core.h> +#include <compplugin.h> +#include <compdisplay.h> #include "privatecore.h" CompCore *core; @@ -165,7 +168,7 @@ CompCore::eventLoop () foreach (CompDisplay *d, priv->displays) d->setWatchFdHandle (addWatchFd (ConnectionNumber (d->dpy()), - POLLIN, NULL, NULL)); + POLLIN, NULL)); for (;;) { @@ -213,10 +216,9 @@ CompCore::eventLoop () CompFileWatchHandle -CompCore::addFileWatch (const char *path, - int mask, - FileWatchCallBackProc callBack, - void *closure) +CompCore::addFileWatch (const char *path, + int mask, + FileWatchCallBack callBack) { CompFileWatch *fileWatch = new CompFileWatch(); if (!fileWatch) @@ -225,7 +227,6 @@ CompCore::addFileWatch (const char *path, fileWatch->path = strdup (path); fileWatch->mask = mask; fileWatch->callBack = callBack; - fileWatch->closure = closure; fileWatch->handle = priv->lastFileWatchHandle++; if (priv->lastFileWatchHandle == MAXSHORT) @@ -295,10 +296,9 @@ PrivateCore::removeTimer (CompCore::Timer *timer) } CompWatchFdHandle -CompCore::addWatchFd (int fd, - short int events, - CallBackProc callBack, - void *closure) +CompCore::addWatchFd (int fd, + short int events, + FdWatchCallBack callBack) { CompWatchFd *watchFd = new CompWatchFd(); @@ -307,7 +307,6 @@ CompCore::addWatchFd (int fd, watchFd->fd = fd; watchFd->callBack = callBack; - watchFd->closure = closure; watchFd->handle = priv->lastWatchFdHandle++; if (priv->lastWatchFdHandle == MAXSHORT) @@ -381,7 +380,7 @@ PrivateCore::doPoll (int timeout) for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end(); it++, i--) if (watchPollFds[i].revents != 0 && (*it)->callBack) - (*(*it)->callBack) ((*it)->closure); + (*it)->callBack (); } return rv; diff --git a/src/display.cpp b/src/display.cpp index 88a2f85..6f948c3 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -48,7 +48,7 @@ #include <boost/bind.hpp> - +#include "privatecore.h" #include "privatedisplay.h" #include "privatescreen.h" #include "privatewindow.h" @@ -679,7 +679,7 @@ errorHandler (Display *dpy, } int -compCheckForError (Display *dpy) +CompDisplay::checkForError (Display *dpy) { int e; @@ -1521,14 +1521,6 @@ CompDisplay::findScreen (Window root) return 0; } -void -CompDisplay::forEachWindow (ForEachWindowProc proc, - void *closure) -{ - foreach (CompScreen *s, priv->screens) - s->forEachWindow (proc, closure); -} - CompWindow * CompDisplay::findWindow (Window id) { diff --git a/src/fragment.cpp b/src/fragment.cpp index dcda2bf..abc2587 100644 --- a/src/fragment.cpp +++ b/src/fragment.cpp @@ -31,6 +31,7 @@ #include <compiz-core.h> #include <comptexture.h> #include <compfragment.h> +#include <compscreen.h> #include "privatefragment.h" #include <string.h> diff --git a/src/main.cpp b/src/main.cpp index 88e8804..ab8c749 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,8 @@ # include "../config.h" #endif +#include <compiz.h> + #include <stdio.h> #include <stdlib.h> #include <signal.h> @@ -37,6 +39,7 @@ #include <compiz-core.h> #include "privatedisplay.h" #include "privatescreen.h" +#include "privatecore.h" char *programName; char **programArgv; @@ -52,21 +55,21 @@ Window currentRoot = 0; int defaultRefreshRate = 50; char *defaultTextureFilter = "Good"; -Bool shutDown = FALSE; -Bool restartSignal = FALSE; +bool shutDown = false; +bool restartSignal = false; CompWindow *lastFoundWindow = 0; CompWindow *lastDamagedWindow = 0; -Bool replaceCurrentWm = FALSE; -Bool indirectRendering = FALSE; -Bool strictBinding = TRUE; -Bool noDetection = FALSE; -Bool useDesktopHints = TRUE; -Bool onlyCurrentScreen = FALSE; +bool replaceCurrentWm = false; +bool indirectRendering = false; +bool strictBinding = true; +bool noDetection = false; +bool useDesktopHints = true; +bool onlyCurrentScreen = false; #ifdef USE_COW -Bool useCow = TRUE; +bool useCow = true; #endif CompMetadata *coreMetadata = NULL; diff --git a/src/match.cpp b/src/match.cpp index d6d6bd7..12e1e68 100644 --- a/src/match.cpp +++ b/src/match.cpp @@ -32,7 +32,10 @@ #include <compiz-core.h> #include "privatedisplay.h" +#include <compscreen.h> #include <compmatch.h> +#include <compwindow.h> +#include <compplugin.h> #include "privatematch.h" class CoreExp : public CompMatch::Expression { diff --git a/src/matrix.cpp b/src/matrix.cpp index 7f1c74f..4718b69 100644 --- a/src/matrix.cpp +++ b/src/matrix.cpp @@ -21,6 +21,7 @@ * From Mesa 3-D graphics library. */ +#include <compiz.h> #include <string.h> #include <math.h> #include <compiz-core.h> diff --git a/src/metadata.cpp b/src/metadata.cpp index c9f319f..7b63efb 100644 --- a/src/metadata.cpp +++ b/src/metadata.cpp @@ -33,8 +33,10 @@ #include <boost/foreach.hpp> #define foreach BOOST_FOREACH -#include <compiz-core.h> +#include <compiz.h> #include <compmetadata.h> +#include <compdisplay.h> +#include <compscreen.h> #define HOME_METADATADIR ".compiz/metadata" #define EXTENSION ".xml" diff --git a/src/object.cpp b/src/object.cpp index 64b4d49..b310e17 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -23,9 +23,13 @@ * Author: David Reveman <davidr@novell.com> */ +#include <compiz.h> + #include <algorithm> +#include <boost/bind.hpp> #include <compiz-core.h> +#include <compcore.h> #include "privateobject.h" PrivateObject::PrivateObject () : @@ -36,7 +40,7 @@ PrivateObject::PrivateObject () : } -CompObject::CompObject (CompObjectType type, const char* typeName, +CompObject::CompObject (CompObject::Type type, const char* typeName, CompObject::indices *iList) : privates (0) { @@ -82,7 +86,7 @@ CompObject::typeName () return priv->typeName; } -CompObjectType +CompObject::Type CompObject::type () { return priv->type; @@ -99,9 +103,8 @@ CompObject::addChild (CompObject *object) } bool -CompObject::forEachChild (ObjectCallBackProc proc, - void *closure, - CompObjectType type) +CompObject::forEachChild (CompObject::CallBack proc, + CompObject::Type type) { bool rv = true; @@ -110,33 +113,26 @@ CompObject::forEachChild (ObjectCallBackProc proc, { if (type > 0 && (*it)->type () != type) continue; - rv &= (*proc) ((*it), closure); + rv &= proc ((*it)); } return rv; } -typedef struct _ResizeInfo { - CompObjectType type; - unsigned int size; -} ResizeInfo; - static bool -resizePrivates (CompObject *o, void * closure) +resizePrivates (CompObject *o, CompObject::Type type, unsigned int size) { - ResizeInfo *info = static_cast<ResizeInfo *> (closure); - - if (o->type () == info->type) + if (o->type () == type) { - o->privates.resize (info->size); + o->privates.resize (size); } - o->forEachChild (resizePrivates, info); + o->forEachChild (boost::bind (resizePrivates, _1, type, size)); return true; } int -CompObject::allocatePrivateIndex (CompObjectType type, +CompObject::allocatePrivateIndex (CompObject::Type type, CompObject::indices *iList) { if (!iList) @@ -154,18 +150,13 @@ CompObject::allocatePrivateIndex (CompObjectType type, iList->resize (i + 1); iList->at (i) = true; - ResizeInfo info; - info.type = type; - info.size = i + 1; - - - resizePrivates (core, static_cast<void *> (&info)); + resizePrivates (core, type, i + 1); return i; } void -CompObject::freePrivateIndex (CompObjectType type, +CompObject::freePrivateIndex (CompObject::Type type, CompObject::indices *iList, int idx) { @@ -181,10 +172,6 @@ CompObject::freePrivateIndex (CompObjectType type, unsigned int i = iList->size () - 1; iList->resize (i); - ResizeInfo info; - info.type = type; - info.size = i; - - resizePrivates (core, static_cast<void *> (&info)); + resizePrivates (core, type, i); } diff --git a/src/plugin.cpp b/src/plugin.cpp index c46b672..8a22f14 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -278,24 +278,23 @@ LoadPluginProc loaderLoadPlugin = dlloaderLoadPlugin; UnloadPluginProc loaderUnloadPlugin = dlloaderUnloadPlugin; ListPluginsProc loaderListPlugins = dlloaderListPlugins; -typedef struct _InitObjectContext { +struct InitObjectContext { CompPlugin *plugin; CompObject *object; -} InitObjectContext; +}; static bool -initObjectTree (CompObject *object, - void *closure); +initObjectTree (CompObject *object, + InitObjectContext *pCtx); static bool -finiObjectTree (CompObject *object, - void *closure); +finiObjectTree (CompObject *object, + InitObjectContext *pCtx); static bool -initObjectTree (CompObject *object, - void *closure) +initObjectTree (CompObject *object, + InitObjectContext *pCtx) { - InitObjectContext *pCtx = (InitObjectContext *) closure; CompPlugin *p = pCtx->plugin; InitObjectContext ctx; @@ -312,16 +311,16 @@ initObjectTree (CompObject *object, ctx.plugin = pCtx->plugin; ctx.object = NULL; - if (!object->forEachChild (initObjectTree, static_cast<void *> (&ctx))) + if (!object->forEachChild (boost::bind (initObjectTree, _1, &ctx))) { - object->forEachChild (finiObjectTree, static_cast<void *> (&ctx)); + object->forEachChild (boost::bind (finiObjectTree, _1, &ctx)); return false; } if (!core->initPluginForObject (p, object)) { - object->forEachChild (finiObjectTree, static_cast<void *> (&ctx)); + object->forEachChild (boost::bind (finiObjectTree, _1, &ctx)); p->vTable->finiObject (object); return false; @@ -331,10 +330,9 @@ initObjectTree (CompObject *object, } static bool -finiObjectTree (CompObject *object, - void *closure) +finiObjectTree (CompObject *object, + InitObjectContext *pCtx) { - InitObjectContext *pCtx = (InitObjectContext *) closure; CompPlugin *p = pCtx->plugin; InitObjectContext ctx; @@ -345,7 +343,7 @@ finiObjectTree (CompObject *object, ctx.plugin = p; ctx.object = NULL; - object->forEachChild (finiObjectTree, static_cast<void *> (&ctx)); + object->forEachChild (boost::bind (finiObjectTree, _1, &ctx)); p->vTable->finiObject (object); @@ -369,7 +367,7 @@ initPlugin (CompPlugin *p) ctx.plugin = p; ctx.object = NULL; - if (!initObjectTree (core, static_cast<void *> (&ctx))) + if (!initObjectTree (core, &ctx)) { p->vTable->fini (); return false; @@ -386,7 +384,7 @@ finiPlugin (CompPlugin *p) ctx.plugin = p; ctx.object = NULL; - finiObjectTree (core, (void *) &ctx); + finiObjectTree (core, &ctx); p->vTable->fini (); } @@ -405,7 +403,7 @@ CompPlugin::objectInitPlugins (CompObject *o) ctx.plugin = (*rit); - if (!initObjectTree (o, (void *) &ctx)) + if (!initObjectTree (o, &ctx)) { if (rit == plugins.rbegin ()) return false; @@ -414,12 +412,12 @@ CompPlugin::objectInitPlugins (CompObject *o) { ctx.plugin = (*rit); - finiObjectTree (o, (void *) &ctx); + finiObjectTree (o, &ctx); } ctx.plugin = (*rit); - finiObjectTree (o, (void *) &ctx); + finiObjectTree (o, &ctx); return false; } rit++; @@ -439,7 +437,7 @@ CompPlugin::objectFiniPlugins (CompObject *o) { ctx.plugin = p; - finiObjectTree (o, (void *) &ctx); + finiObjectTree (o, &ctx); } } diff --git a/src/privatecore.h b/src/privatecore.h index b21f483..8e1de6b 100644 --- a/src/privatecore.h +++ b/src/privatecore.h @@ -4,6 +4,15 @@ #include <compiz-core.h> #include <compcore.h> +extern bool shutDown; +extern bool restartSignal; + +typedef struct _CompWatchFd { + int fd; + FdWatchCallBack callBack; + CompWatchFdHandle handle; +} CompWatchFd; + class PrivateCore { public: diff --git a/src/privatedisplay.h b/src/privatedisplay.h index 70800d6..5a972f3 100644 --- a/src/privatedisplay.h +++ b/src/privatedisplay.h @@ -1,8 +1,11 @@ #ifndef _PRIVATEDISPLAY_H #define _PRIVATEDISPLAY_H +#include <X11/XKBlib.h> + #include <compiz-core.h> #include <compdisplay.h> +#include <compmetadata.h> #define COMP_DISPLAY_OPTION_ABI 0 #define COMP_DISPLAY_OPTION_ACTIVE_PLUGINS 1 diff --git a/src/privatefragment.h b/src/privatefragment.h index bab11bc..68c9e47 100644 --- a/src/privatefragment.h +++ b/src/privatefragment.h @@ -1,6 +1,8 @@ #ifndef _PRIVATEFRAGMENT_H #define _PRIVATEFRAGMENT_H +#include <vector> + #include <compfragment.h> namespace CompFragment { diff --git a/src/privateobject.h b/src/privateobject.h index a8f8eca..2678368 100644 --- a/src/privateobject.h +++ b/src/privateobject.h @@ -9,7 +9,7 @@ class PrivateObject { public : PrivateObject (); - CompObjectType type; + CompObject::Type type; const char *typeName; diff --git a/src/privateoption.h b/src/privateoption.h index c9fef36..bdbcad2 100644 --- a/src/privateoption.h +++ b/src/privateoption.h @@ -3,6 +3,11 @@ #include <vector> +#include <compaction.h> +#include <compmatch.h> +#include <compdisplay.h> +#include <compscreen.h> + typedef struct _CompOptionIntRestriction { int min; int max; diff --git a/src/privatescreen.h b/src/privatescreen.h index bf9dbb5..570b00f 100644 --- a/src/privatescreen.h +++ b/src/privatescreen.h @@ -9,6 +9,27 @@ #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 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 diff --git a/src/privatewindow.h b/src/privatewindow.h index a2857f6..52ff71f 100644 --- a/src/privatewindow.h +++ b/src/privatewindow.h @@ -107,7 +107,7 @@ class PrivateWindow { static void revealAncestors (CompWindow *w, - void *closure); + CompWindow *transient); bool constrainNewWindowSize (int width, @@ -117,11 +117,11 @@ class PrivateWindow { static void minimizeTransients (CompWindow *w, - void *closure); + CompWindow *ancestor); static void unminimizeTransients (CompWindow *w, - void *closure); + CompWindow *ancestor); bool getUsageTimestamp (Time *timestamp); diff --git a/src/screen.cpp b/src/screen.cpp index 2dbdbbf..408ebba 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -34,6 +34,7 @@ #include <dlfcn.h> #include <string.h> #include <sys/types.h> +#include <sys/time.h> #include <unistd.h> #include <assert.h> #include <limits.h> @@ -50,9 +51,11 @@ #include <X11/extensions/shape.h> #include <X11/cursorfont.h> + #include <compiz-core.h> #include <compscreen.h> +#include <compdisplay.h> #include <compicon.h> #include "privatescreen.h" @@ -1561,12 +1564,12 @@ CompScreen::init (CompDisplay *display, int screenNum) } while (event.type != DestroyNotify); } - compCheckForError (dpy); + CompDisplay::checkForError (dpy); XCompositeRedirectSubwindows (dpy, XRootWindow (dpy, screenNum), CompositeRedirectManual); - if (compCheckForError (dpy)) + if (CompDisplay::checkForError (dpy)) { compLogMessage (display, "core", CompLogLevelError, "Another composite manager is already " @@ -1603,7 +1606,7 @@ CompScreen::init (CompDisplay *display, int screenNum) FocusChangeMask | ExposureMask); - if (compCheckForError (dpy)) + if (CompDisplay::checkForError (dpy)) { compLogMessage (display, "core", CompLogLevelError, "Another window manager is " @@ -2314,10 +2317,10 @@ CompScreen::damagePending () } void -CompScreen::forEachWindow (ForEachWindowProc proc, void *closure) +CompScreen::forEachWindow (CompWindow::ForEach proc) { foreach (CompWindow *w, priv->windows) - (*proc) (w, closure); + proc (w); } void @@ -2646,7 +2649,7 @@ PrivateScreen::grabUngrabKeys (unsigned int modifiers, XModifierKeymap *modMap = display->modMap (); int ignore, mod, k; - compCheckForError (display->dpy ()); + CompDisplay::checkForError (display->dpy ()); for (ignore = 0; ignore <= display->ignoredModMask (); ignore++) { @@ -2679,7 +2682,7 @@ PrivateScreen::grabUngrabKeys (unsigned int modifiers, } } - if (compCheckForError (display->dpy ())) + if (CompDisplay::checkForError (display->dpy ())) return false; } @@ -3033,13 +3036,11 @@ isClientListWindow (CompWindow *w) static void countClientListWindow (CompWindow *w, - void *closure) + int *n) { if (isClientListWindow (w)) { - int *num = (int *) closure; - - *num = *num + 1; + *n = *n + 1; } } @@ -3060,7 +3061,7 @@ CompScreen::updateClientList () Bool updateClientListStacking = true; int i, n = 0; - forEachWindow (countClientListWindow, (void *) &n); + forEachWindow (boost::bind (countClientListWindow, _1, &n)); if (n == 0) { diff --git a/src/session.cpp b/src/session.cpp index 6efb27a..6c0a223 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -27,6 +27,8 @@ # include "../config.h" #endif +#include <compiz.h> + #include <stdlib.h> #include <stdio.h> #include <poll.h> @@ -36,6 +38,8 @@ #include <X11/SM/SMlib.h> #include <X11/ICE/ICElib.h> +#include <boost/bind.hpp> + #include <compsession.h> #include <compiz-core.h> @@ -303,9 +307,8 @@ CompSession::getSessionClientId (CompSession::ClientIdType type) /* This is called when data is available on an ICE connection. */ static bool -iceProcessMessages (void *data) +iceProcessMessages (IceConn connection) { - IceConn connection = (IceConn) data; IceProcessMessagesStatus status; SM_DEBUG (printf ("ICE connection process messages\n")); @@ -343,8 +346,8 @@ iceNewConnection (IceConn connection, F_GETFD,0) | FD_CLOEXEC); iceWatchFdHandle = core->addWatchFd (IceConnectionNumber (connection), - POLLIN | POLLPRI | POLLHUP | POLLERR, - iceProcessMessages, connection); + POLLIN | POLLPRI | POLLHUP | POLLERR, + boost::bind (iceProcessMessages, connection)); iceConnected = 1; } diff --git a/src/string.cpp b/src/string.cpp index 24efaf3..e35cd85 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -1,5 +1,6 @@ -#include <compiz-core.h> +#include <compiz.h> +#include <string.h> #include <stdarg.h> CompString compPrintf (const char *format, ...) diff --git a/src/texture.cpp b/src/texture.cpp index b5f8c0b..9fdf5a1 100644 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -27,6 +27,8 @@ # include "../config.h" #endif +#include <compiz.h> + #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/window.cpp b/src/window.cpp index b9d785f..98165a3 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -23,6 +23,8 @@ * Author: David Reveman <davidr@novell.com> */ +#include <compiz.h> + #include <X11/Xlib.h> #include <X11/Xatom.h> #include <X11/Xproto.h> @@ -1684,7 +1686,7 @@ PrivateWindow::initializeSyncCounter () values.events = TRUE; - compCheckForError (screen->display ()->dpy ()); + CompDisplay::checkForError (screen->display ()->dpy ()); /* Note that by default, the alarm increments the trigger value * when it fires until the condition (counter.value < trigger.value) @@ -1699,7 +1701,7 @@ PrivateWindow::initializeSyncCounter () XSyncCAEvents, &values); - if (!compCheckForError (screen->display ()->dpy ())) + if (CompDisplay::checkForError (screen->display ()->dpy ())) return true; XSyncDestroyAlarm (screen->display ()->dpy (), syncAlarm); @@ -3282,13 +3284,11 @@ PrivateWindow::reveal () void PrivateWindow::revealAncestors (CompWindow *w, - void *closure) + CompWindow *transient) { - CompWindow *transient = (CompWindow *) closure; - if (isAncestorTo (transient, w)) { - w->priv->screen->forEachWindow (revealAncestors, (void *) w); + w->priv->screen->forEachWindow (boost::bind (revealAncestors, _1, w)); w->priv->reveal (); } } @@ -3300,7 +3300,8 @@ CompWindow::activate () priv->screen->setCurrentDesktop (priv->desktop); - priv->screen->forEachWindow (PrivateWindow::revealAncestors, (void *) this); + priv->screen->forEachWindow ( + boost::bind (PrivateWindow::revealAncestors, _1, this)); priv->reveal (); if (priv->state & CompWindowStateHiddenMask) @@ -3571,10 +3572,8 @@ CompWindow::show () void PrivateWindow::minimizeTransients (CompWindow *w, - void *closure) + CompWindow *ancestor) { - CompWindow *ancestor = (CompWindow *) closure; - if (w->priv->transientFor == ancestor->priv->id || w->priv->isGroupTransient (ancestor->priv->clientLeader)) { @@ -3592,8 +3591,8 @@ CompWindow::minimize () { priv->minimized = true; - priv->screen->forEachWindow (PrivateWindow::minimizeTransients, - (void *) this); + priv->screen->forEachWindow ( + boost::bind (PrivateWindow::minimizeTransients, _1, this)); hide (); } @@ -3601,10 +3600,8 @@ CompWindow::minimize () void PrivateWindow::unminimizeTransients (CompWindow *w, - void *closure) + CompWindow *ancestor) { - CompWindow *ancestor = (CompWindow *) closure; - if (w->priv->transientFor == ancestor->priv->id || w->priv->isGroupTransient (ancestor->priv->clientLeader)) w->unminimize (); @@ -3619,8 +3616,8 @@ CompWindow::unminimize () show (); - priv->screen->forEachWindow (PrivateWindow::unminimizeTransients, - (void *) this); + priv->screen->forEachWindow ( + boost::bind (PrivateWindow::unminimizeTransients, _1, this)); } } |