summaryrefslogtreecommitdiff
path: root/src/display.cpp
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/display.cpp
parent51a6ee41ec7299191381de897f36d983ba12bdcc (diff)
downloadzcomp-c916c15253e74c3989fa5412e845146227d7cd32.tar.gz
zcomp-c916c15253e74c3989fa5412e845146227d7cd32.tar.bz2
Added new object private handling system.
Diffstat (limited to 'src/display.cpp')
-rw-r--r--src/display.cpp78
1 files changed, 11 insertions, 67 deletions
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);