summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-08-08 05:20:49 +0200
committerDennis kasprzyk <onestone@opencompositing.org>2008-08-08 05:20:49 +0200
commitc916c15253e74c3989fa5412e845146227d7cd32 (patch)
tree4a8704a7cd1723f1b1c1aceb4851ec7f2d4c7115 /src
parent51a6ee41ec7299191381de897f36d983ba12bdcc (diff)
downloadcompiz-with-glib-mainloop-c916c15253e74c3989fa5412e845146227d7cd32.tar.gz
compiz-with-glib-mainloop-c916c15253e74c3989fa5412e845146227d7cd32.tar.bz2
Added new object private handling system.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/core.cpp68
-rw-r--r--src/display.cpp78
-rw-r--r--src/object.cpp161
-rw-r--r--src/plugin.cpp99
-rw-r--r--src/privates.cpp68
-rw-r--r--src/screen.cpp82
-rw-r--r--src/window.cpp76
8 files changed, 140 insertions, 493 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8f687e9..6925765 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,7 +13,6 @@ compiz_LDADD = @COMPIZ_LIBS@ @GL_LIBS@ -lm
compiz_LDFLAGS = -export-dynamic
compiz_SOURCES = \
main.cpp \
- privates.cpp \
object.cpp \
core.cpp \
display.cpp \
diff --git a/src/core.cpp b/src/core.cpp
index 7743aa6..bf03ab9 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -32,74 +32,22 @@
CompCore *core;
-static char *corePrivateIndices = 0;
-static int corePrivateLen = 0;
-
-static int
-reallocCorePrivate (int size,
- void *closure)
-{
- void *privates;
-
- privates = realloc (core->privates, size * sizeof (CompPrivate));
- if (!privates)
- return FALSE;
-
- core->privates = (CompPrivate *) privates;
-
- return TRUE;
-}
+CompObject::indices corePrivateIndices (0);
int
-allocCoreObjectPrivateIndex (CompObject *parent)
+CompCore::allocPrivateIndex ()
{
- return allocatePrivateIndex (&corePrivateLen,
- &corePrivateIndices,
- reallocCorePrivate,
- 0);
+ return CompObject::allocatePrivateIndex (COMP_OBJECT_TYPE_CORE,
+ &corePrivateIndices);
}
void
-freeCoreObjectPrivateIndex (CompObject *parent,
- int index)
+CompCore::freePrivateIndex (int index)
{
- freePrivateIndex (corePrivateLen, corePrivateIndices, index);
+ CompObject::freePrivateIndex (COMP_OBJECT_TYPE_CORE,
+ &corePrivateIndices, index);
}
-CompBool
-forEachCoreObject (CompObject *parent,
- ObjectCallBackProc proc,
- void *closure)
-{
- return TRUE;
-}
-
-char *
-nameCoreObject (CompObject *object)
-{
- return NULL;
-}
-
-CompObject *
-findCoreObject (CompObject *parent,
- const char *name)
-{
- return NULL;
-}
-
-int
-allocateCorePrivateIndex (void)
-{
- return compObjectAllocatePrivateIndex (NULL, COMP_OBJECT_TYPE_CORE);
-}
-
-void
-freeCorePrivateIndex (int index)
-{
- compObjectFreePrivateIndex (NULL, COMP_OBJECT_TYPE_CORE, index);
-}
-
-
#define TIMEVALDIFF(tv1, tv2) \
((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
@@ -112,8 +60,6 @@ CompCore::CompCore () :
{
priv = new PrivateCore (this);
assert (priv);
-
- compObjectInit (this, 0, COMP_OBJECT_TYPE_CORE);
}
bool
diff --git a/src/display.cpp b/src/display.cpp
index 2305c5e..7495b54 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -76,54 +76,21 @@ typedef struct {
#define NUM_OPTIONS(d) (sizeof ((d)->priv->opt) / sizeof (CompOption))
-static char *displayPrivateIndices = 0;
-static int displayPrivateLen = 0;
-static int
-reallocDisplayPrivate (int size,
- void *closure)
-{
- CompDisplay *d;
- void *privates;
-
- for (d = core->displays(); d; d = d->next)
- {
- privates = realloc (d->privates, size * sizeof (CompPrivate));
- if (!privates)
- return FALSE;
-
- d->privates = (CompPrivate *) privates;
- }
-
- return TRUE;
-}
+CompObject::indices displayPrivateIndices (0);
int
-allocDisplayObjectPrivateIndex (CompObject *parent)
+CompDisplay::allocPrivateIndex ()
{
- return allocatePrivateIndex (&displayPrivateLen,
- &displayPrivateIndices,
- reallocDisplayPrivate,
- 0);
+ return CompObject::allocatePrivateIndex (COMP_OBJECT_TYPE_DISPLAY,
+ &displayPrivateIndices);
}
void
-freeDisplayObjectPrivateIndex (CompObject *parent,
- int index)
+CompDisplay::freePrivateIndex (int index)
{
- freePrivateIndex (displayPrivateLen, displayPrivateIndices, index);
-}
-
-int
-allocateDisplayPrivateIndex (void)
-{
- return compObjectAllocatePrivateIndex (NULL, COMP_OBJECT_TYPE_DISPLAY);
-}
-
-void
-freeDisplayPrivateIndex (int index)
-{
- compObjectFreePrivateIndex (NULL, COMP_OBJECT_TYPE_DISPLAY, index);
+ CompObject::freePrivateIndex (COMP_OBJECT_TYPE_DISPLAY,
+ &displayPrivateIndices, index);
}
bool
@@ -794,10 +761,8 @@ setDisplayAction (CompDisplay *display,
}
CompDisplay::CompDisplay () :
- CompObject (COMP_OBJECT_TYPE_DISPLAY, "display"),
- next (0),
- screenPrivateIndices (0),
- screenPrivateLen (0)
+ CompObject (COMP_OBJECT_TYPE_DISPLAY, "display", &displayPrivateIndices),
+ next (0)
{
WRAPABLE_INIT_HND(handleEvent);
WRAPABLE_INIT_HND(handleCompizEvent);
@@ -839,19 +804,12 @@ CompDisplay::~CompDisplay ()
if (priv->modMap)
XFreeModifiermap (priv->modMap);
- if (screenPrivateIndices)
- free (screenPrivateIndices);
-
- if (privates)
- free (privates);
-
delete priv;
}
bool
CompDisplay::init (const char *name)
{
- CompPrivate *privates;
Window focus;
int revertTo, i;
int compositeMajor, compositeMinor;
@@ -859,20 +817,6 @@ CompDisplay::init (const char *name)
int xkbOpcode;
int firstScreen, lastScreen;
- if (displayPrivateLen)
- {
- privates =
- (CompPrivate *) malloc (displayPrivateLen * sizeof (CompPrivate));
- if (!privates)
- {
- return false;
- }
- }
- else
- privates = 0;
-
- compObjectInit (this, privates, COMP_OBJECT_TYPE_DISPLAY);
-
mTmpRegion = XCreateRegion ();
if (!mTmpRegion)
return false;
@@ -1023,11 +967,11 @@ CompDisplay::init (const char *name)
priv->returnKeyCode =
XKeysymToKeycode (priv->dpy, XStringToKeysym ("Return"));
+ core->addChild (this);
+
/* TODO: bailout properly when objectInitPlugins fails */
assert (objectInitPlugins (this));
- core->addChild (this);
-
if (onlyCurrentScreen)
{
firstScreen = DefaultScreen (priv->dpy);
diff --git a/src/object.cpp b/src/object.cpp
index 7db8f37..64b4d49 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -28,89 +28,6 @@
#include <compiz-core.h>
#include "privateobject.h"
-typedef CompBool (*AllocObjectPrivateIndexProc) (CompObject *parent);
-
-typedef void (*FreeObjectPrivateIndexProc) (CompObject *parent,
- int index);
-
-typedef CompBool (*ForEachObjectProc) (CompObject *parent,
- ObjectCallBackProc proc,
- void *closure);
-
-typedef char *(*NameObjectProc) (CompObject *object);
-
-typedef CompObject *(*FindObjectProc) (CompObject *parent,
- const char *name);
-
-struct _CompObjectInfo {
- const char *name;
- AllocObjectPrivateIndexProc allocPrivateIndex;
- FreeObjectPrivateIndexProc freePrivateIndex;
-} objectInfo[] = {
- {
- "core",
- allocCoreObjectPrivateIndex,
- freeCoreObjectPrivateIndex
- }, {
- "display",
- allocDisplayObjectPrivateIndex,
- freeDisplayObjectPrivateIndex
- }, {
- "screen",
- allocScreenObjectPrivateIndex,
- freeScreenObjectPrivateIndex
- }, {
- "window",
- allocWindowObjectPrivateIndex,
- freeWindowObjectPrivateIndex
- }
-};
-
-void
-compObjectInit (CompObject *object,
- CompPrivate *privates,
- CompObjectType type)
-{
- object->privates = privates;
-}
-
-int
-compObjectAllocatePrivateIndex (CompObject *parent,
- CompObjectType type)
-{
- return (*objectInfo[type].allocPrivateIndex) (parent);
-}
-
-void
-compObjectFreePrivateIndex (CompObject *parent,
- CompObjectType type,
- int index)
-{
- (*objectInfo[type].freePrivateIndex) (parent, index);
-}
-
-
-const char *
-compObjectTypeName (CompObjectType type)
-{
- return objectInfo[type].name;
-}
-
-CompBool
-compObjectForEachType (CompObject *parent,
- ObjectTypeCallBackProc proc,
- void *closure)
-{
- int i;
-
- for (i = 0; i < sizeof (objectInfo) / sizeof (objectInfo[0]); i++)
- if (!(*proc) (i, parent, closure))
- return FALSE;
-
- return TRUE;
-}
-
-
PrivateObject::PrivateObject () :
typeName (0),
parent (NULL),
@@ -119,7 +36,8 @@ PrivateObject::PrivateObject () :
}
-CompObject::CompObject (CompObjectType type, const char* typeName) :
+CompObject::CompObject (CompObjectType type, const char* typeName,
+ CompObject::indices *iList) :
privates (0)
{
priv = new PrivateObject ();
@@ -127,6 +45,9 @@ CompObject::CompObject (CompObjectType type, const char* typeName) :
priv->type = type;
priv->typeName = typeName;
+
+ if (iList && iList->size() > 0)
+ privates.resize (iList->size ());
}
CompObject::~CompObject ()
@@ -195,3 +116,75 @@ CompObject::forEachChild (ObjectCallBackProc proc,
return rv;
}
+typedef struct _ResizeInfo {
+ CompObjectType type;
+ unsigned int size;
+} ResizeInfo;
+
+static bool
+resizePrivates (CompObject *o, void * closure)
+{
+ ResizeInfo *info = static_cast<ResizeInfo *> (closure);
+
+ if (o->type () == info->type)
+ {
+ o->privates.resize (info->size);
+ }
+ o->forEachChild (resizePrivates, info);
+
+ return true;
+}
+
+int
+CompObject::allocatePrivateIndex (CompObjectType type,
+ CompObject::indices *iList)
+{
+ if (!iList)
+ return -1;
+
+ for (unsigned int i = 0; i < iList->size(); i++)
+ {
+ if (!iList->at (i))
+ {
+ iList->at (i) = true;
+ return i;
+ }
+ }
+ unsigned int i = iList->size ();
+ iList->resize (i + 1);
+ iList->at (i) = true;
+
+ ResizeInfo info;
+ info.type = type;
+ info.size = i + 1;
+
+
+ resizePrivates (core, static_cast<void *> (&info));
+
+ return i;
+}
+
+void
+CompObject::freePrivateIndex (CompObjectType type,
+ CompObject::indices *iList,
+ int idx)
+{
+ if (!iList || idx < 0 || idx >= (int) iList->size())
+ return;
+
+ if (idx < (int) iList->size () - 1)
+ {
+ iList->at(idx) = false;
+ return;
+ }
+
+ unsigned int i = iList->size () - 1;
+ iList->resize (i);
+
+ ResizeInfo info;
+ info.type = type;
+ info.size = i;
+
+ resizePrivates (core, static_cast<void *> (&info));
+}
+
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 8762ad8..93c35fa 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -315,11 +315,6 @@ typedef struct _InitObjectContext {
CompObject *object;
} InitObjectContext;
-typedef struct _InitObjectTypeContext {
- CompPlugin *plugin;
- CompObjectType type;
-} InitObjectTypeContext;
-
static bool
initObjectTree (CompObject *object,
void *closure);
@@ -329,55 +324,12 @@ finiObjectTree (CompObject *object,
void *closure);
static bool
-initObjectsWithType (CompObjectType type,
- CompObject *parent,
- void *closure)
-{
- InitObjectTypeContext *pCtx = (InitObjectTypeContext *) closure;
- InitObjectContext ctx;
-
- pCtx->type = type;
-
- ctx.plugin = pCtx->plugin;
- ctx.object = NULL;
-
- if (!parent->forEachChild (initObjectTree, (void *) &ctx, type))
- {
- parent->forEachChild (finiObjectTree, (void *) &ctx, type);
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-static bool
-finiObjectsWithType (CompObjectType type,
- CompObject *parent,
- void *closure)
-{
- InitObjectTypeContext *pCtx = (InitObjectTypeContext *) closure;
- InitObjectContext ctx;
-
- /* pCtx->type is set to the object type that failed to be initialized */
- if (pCtx->type == type)
- return FALSE;
-
- ctx.plugin = pCtx->plugin;
- ctx.object = NULL;
-
- parent->forEachChild (finiObjectTree, (void *) &ctx, type);
-
- return TRUE;
-}
-
-static bool
initObjectTree (CompObject *object,
void *closure)
{
InitObjectContext *pCtx = (InitObjectContext *) closure;
CompPlugin *p = pCtx->plugin;
- InitObjectTypeContext ctx;
+ InitObjectContext ctx;
pCtx->object = object;
@@ -386,32 +338,28 @@ initObjectTree (CompObject *object,
{
compLogMessage (NULL, p->vTable->name (), CompLogLevelError,
"InitObject failed");
- return FALSE;
+ return false;
}
- ctx.plugin = p;
- ctx.type = 0;
+ ctx.plugin = pCtx->plugin;
+ ctx.object = NULL;
- /* initialize children */
- if (!compObjectForEachType (object, initObjectsWithType, (void *) &ctx))
+ if (!object->forEachChild (initObjectTree, static_cast<void *> (&ctx)))
{
- compObjectForEachType (object, finiObjectsWithType, (void *) &ctx);
-
- p->vTable->finiObject (object);
+ object->forEachChild (finiObjectTree, static_cast<void *> (&ctx));
- return FALSE;
+ return false;
}
if (!core->initPluginForObject (p, object))
{
- compObjectForEachType (object, finiObjectsWithType, (void *) &ctx);
-
+ object->forEachChild (finiObjectTree, static_cast<void *> (&ctx));
p->vTable->finiObject (object);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static bool
@@ -420,26 +368,25 @@ finiObjectTree (CompObject *object,
{
InitObjectContext *pCtx = (InitObjectContext *) closure;
CompPlugin *p = pCtx->plugin;
- InitObjectTypeContext ctx;
+ InitObjectContext ctx;
/* pCtx->object is set to the object that failed to be initialized */
if (pCtx->object == object)
- return FALSE;
+ return false;
ctx.plugin = p;
- ctx.type = ~0;
+ ctx.object = NULL;
- compObjectForEachType (object, finiObjectsWithType, (void *) &ctx);
+ object->forEachChild (finiObjectTree, static_cast<void *> (&ctx));
-
p->vTable->finiObject (object);
core->finiPluginForObject (p, object);
- return TRUE;
+ return true;
}
-static Bool
+static bool
initPlugin (CompPlugin *p)
{
InitObjectContext ctx;
@@ -448,19 +395,19 @@ initPlugin (CompPlugin *p)
{
compLogMessage (NULL, "core", CompLogLevelError,
"InitPlugin '%s' failed", p->vTable->name ());
- return FALSE;
+ return false;
}
ctx.plugin = p;
ctx.object = NULL;
- if (!initObjectTree (core, (void *) &ctx))
+ if (!initObjectTree (core, static_cast<void *> (&ctx)))
{
p->vTable->fini ();
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void
@@ -476,7 +423,7 @@ finiPlugin (CompPlugin *p)
p->vTable->fini ();
}
-CompBool
+bool
objectInitPlugins (CompObject *o)
{
InitObjectContext ctx;
@@ -505,11 +452,11 @@ objectInitPlugins (CompObject *o)
finiObjectTree (o, (void *) &ctx);
}
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
void
diff --git a/src/privates.cpp b/src/privates.cpp
deleted file mode 100644
index 56baa4b..0000000
--- a/src/privates.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: David Reveman <davidr@novell.com>
- */
-
-#include <stdlib.h>
-
-#include <compiz-core.h>
-
-int
-allocatePrivateIndex (int *len,
- char **indices,
- ReallocPrivatesProc reallocProc,
- void *closure)
-{
- char *newIndices;
- int i;
-
- for (i = 0; i < *len; i++)
- {
- if (!(*indices)[i])
- {
- (*indices)[i] = 1;
- return i;
- }
- }
-
- newIndices = (char *) realloc (*indices, (*len + 1) * sizeof (char));
- if (!newIndices)
- return -1;
-
- newIndices[*len] = 1;
- *indices = newIndices;
-
- if (!(*reallocProc) (*len + 1, closure))
- return -1;
-
- return (*len)++;
-}
-
-void
-freePrivateIndex (int len,
- char *indices,
- int index)
-{
- if (index < len)
- indices[index] = 0;
-}
diff --git a/src/screen.cpp b/src/screen.cpp
index edee063..80c61e4 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -53,59 +53,20 @@
#define NUM_OPTIONS(s) (sizeof ((s)->priv->opt) / sizeof (CompOption))
-static int
-reallocScreenPrivate (int size,
- void *closure)
-{
- CompDisplay *d = (CompDisplay *) closure;
- CompScreen *s;
- void *privates;
-
- for (s = d->screens(); s; s = s->next)
- {
- privates = realloc (s->privates, size * sizeof (CompPrivate));
- if (!privates)
- return FALSE;
-
- s->privates = (CompPrivate *) privates;
- }
-
- return TRUE;
-}
-
-int
-allocScreenObjectPrivateIndex (CompObject *parent)
-{
- CompDisplay *display = (CompDisplay *) parent;
-
- return allocatePrivateIndex (&display->screenPrivateLen,
- &display->screenPrivateIndices,
- reallocScreenPrivate,
- (void *) display);
-}
-
-void
-freeScreenObjectPrivateIndex (CompObject *parent,
- int index)
-{
- CompDisplay *display = (CompDisplay *) parent;
-
- freePrivateIndex (display->screenPrivateLen,
- display->screenPrivateIndices,
- index);
-}
+CompObject::indices screenPrivateIndices (0);
int
-allocateScreenPrivateIndex (CompDisplay *display)
+CompScreen::allocPrivateIndex ()
{
- return compObjectAllocatePrivateIndex (display, COMP_OBJECT_TYPE_SCREEN);
+ return CompObject::allocatePrivateIndex (COMP_OBJECT_TYPE_SCREEN,
+ &screenPrivateIndices);
}
void
-freeScreenPrivateIndex (CompDisplay *display,
- int index)
+CompScreen::freePrivateIndex (int index)
{
- compObjectFreePrivateIndex (display, COMP_OBJECT_TYPE_SCREEN, index);
+ CompObject::freePrivateIndex (COMP_OBJECT_TYPE_SCREEN,
+ &screenPrivateIndices, index);
}
@@ -1440,7 +1401,7 @@ CompScreen::initWindowWalker (CompWalker *walker)
}
CompScreen::CompScreen ():
- CompObject (COMP_OBJECT_TYPE_SCREEN, "screen")
+ CompObject (COMP_OBJECT_TYPE_SCREEN, "screen", &screenPrivateIndices)
{
WRAPABLE_INIT_HND(preparePaint);
WRAPABLE_INIT_HND(donePaint);
@@ -1731,7 +1692,6 @@ CompScreen::init (CompDisplay *display,
Atom wmSnAtom,
Time wmSnTimestamp)
{
- CompPrivate *privates;
Display *dpy = display->dpy ();
static char data = 0;
XColor black;
@@ -1751,20 +1711,6 @@ CompScreen::init (CompDisplay *display,
GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
CompWindow *w;
- if (display->screenPrivateLen)
- {
- privates = (CompPrivate *)
- malloc (display->screenPrivateLen * sizeof (CompPrivate));
- if (!privates)
- {
- return false;
- }
- }
- else
- privates = 0;
-
- compObjectInit (this, privates, COMP_OBJECT_TYPE_SCREEN);
-
priv->display = display;
if (!compInitScreenOptionsFromMetadata (this,
@@ -2276,10 +2222,12 @@ CompScreen::init (CompDisplay *display,
priv->getDesktopHints ();
+ display->addChild (this);
+
/* TODO: bailout properly when objectInitPlugins fails */
assert (objectInitPlugins (this));
- display->addChild (this);
+
XQueryTree (dpy, priv->root,
&rootReturn, &parentReturn,
@@ -2404,12 +2352,6 @@ CompScreen::~CompScreen ()
compFiniScreenOptions (this, priv->opt, COMP_SCREEN_OPTION_NUM);
- if (windowPrivateIndices)
- free (windowPrivateIndices);
-
- if (privates)
- free (privates);
-
delete priv;
}
@@ -2727,7 +2669,7 @@ CompScreen::removeGrab (CompScreen::grabHandle handle,
if (it != priv->grabs.end ())
{
priv->grabs.erase (it);
- delete handle;
+ delete (static_cast<PrivateScreen::Grab *> (handle));
}
if (!priv->grabs.empty ())
{
diff --git a/src/window.cpp b/src/window.cpp
index 854e08f..75b81fc 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -41,63 +41,20 @@
#include "privatewindow.h"
-
-
-
-
-static int
-reallocWindowPrivates (int size,
- void *closure)
-{
- CompScreen *s = (CompScreen *) closure;
- CompWindow *w;
- void *privates;
-
- for (w = s->windows (); w; w = w->next)
- {
- privates = realloc (w->privates, size * sizeof (CompPrivate));
- if (!privates)
- return FALSE;
-
- w->privates = (CompPrivate *) privates;
- }
-
- return TRUE;
-}
-
-int
-allocWindowObjectPrivateIndex (CompObject *parent)
-{
- CompScreen *screen = (CompScreen *) parent;
-
- return allocatePrivateIndex (&screen->windowPrivateLen,
- &screen->windowPrivateIndices,
- reallocWindowPrivates,
- (void *) screen);
-}
-
-void
-freeWindowObjectPrivateIndex (CompObject *parent,
- int index)
-{
- CompScreen *screen = (CompScreen *) parent;
-
- freePrivateIndex (screen->windowPrivateLen,
- screen->windowPrivateIndices,
- index);
-}
+CompObject::indices windowPrivateIndices (0);
int
-allocateWindowPrivateIndex (CompScreen *screen)
+CompWindow::allocPrivateIndex ()
{
- return compObjectAllocatePrivateIndex (screen, COMP_OBJECT_TYPE_WINDOW);
+ return CompObject::allocatePrivateIndex (COMP_OBJECT_TYPE_WINDOW,
+ &windowPrivateIndices);
}
void
-freeWindowPrivateIndex (CompScreen *screen,
- int index)
+CompWindow::freePrivateIndex (int index)
{
- compObjectFreePrivateIndex (screen, COMP_OBJECT_TYPE_WINDOW, index);
+ CompObject::freePrivateIndex (COMP_OBJECT_TYPE_WINDOW,
+ &windowPrivateIndices, index);
}
bool
@@ -4943,7 +4900,7 @@ CompWindow::paintAttrib ()
CompWindow::CompWindow (CompScreen *screen,
Window id,
Window aboveId) :
- CompObject (COMP_OBJECT_TYPE_WINDOW, "window")
+ CompObject (COMP_OBJECT_TYPE_WINDOW, "window", &windowPrivateIndices)
{
WRAPABLE_INIT_HND(paint);
WRAPABLE_INIT_HND(draw);
@@ -4972,19 +4929,8 @@ CompWindow::CompWindow (CompScreen *screen,
priv->screen = screen;
- CompPrivate *privates;
CompDisplay *d = screen->display ();
- if (screen->windowPrivateLen)
- {
- privates = (CompPrivate *) malloc (screen->windowPrivateLen * sizeof (CompPrivate));
- assert (privates);
- }
- else
- privates = 0;
-
- compObjectInit (this, privates, COMP_OBJECT_TYPE_WINDOW);
-
priv->region = XCreateRegion ();
assert (priv->region);
@@ -5189,10 +5135,11 @@ CompWindow::CompWindow (CompScreen *screen,
}
}
+ screen->addChild (this);
+
/* TODO: bailout properly when objectInitPlugins fails */
assert (objectInitPlugins (this));
- core->objectAdd (screen, this);
recalcActions ();
updateIconGeometry ();
@@ -5267,9 +5214,6 @@ CompWindow::~CompWindow ()
release ();
- if (privates)
- free (privates);
-
delete priv;
}