summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-08-06 14:39:07 +0200
committerDennis Kasprzyk <onestone@opencompositing.org>2008-08-06 14:39:07 +0200
commit9c76f36894f1f825aa01f519e2b364b979c32a26 (patch)
treeeec49bb1794ee6570acb47a30a9ddc695198e57e /src
parent0e942665257980878d6271cbcad4647d04204093 (diff)
downloadzcomp-9c76f36894f1f825aa01f519e2b364b979c32a26.tar.gz
zcomp-9c76f36894f1f825aa01f519e2b364b979c32a26.tar.bz2
Conversion ob main classes to C++.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/core.cpp599
-rw-r--r--src/cursor.cpp36
-rw-r--r--src/display.cpp3903
-rw-r--r--src/event.cpp1465
-rw-r--r--src/fragment.cpp40
-rw-r--r--src/main.cpp66
-rw-r--r--src/match.cpp43
-rw-r--r--src/metadata.cpp20
-rw-r--r--src/option.cpp4
-rw-r--r--src/paint.cpp521
-rw-r--r--src/plugin.cpp178
-rw-r--r--src/privatecore.h42
-rw-r--r--src/privatedisplay.h138
-rw-r--r--src/privatescreen.h251
-rw-r--r--src/privatewindow.h269
-rw-r--r--src/screen.cpp4023
-rw-r--r--src/session.cpp22
-rw-r--r--src/texture.cpp127
-rw-r--r--src/window.cpp5012
20 files changed, 9147 insertions, 7614 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ee74639..a59866c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,11 +16,11 @@ compiz_SOURCES = \
privates.cpp \
object.cpp \
core.cpp \
- texture.cpp \
display.cpp \
screen.cpp \
window.cpp \
event.cpp \
+ texture.cpp \
paint.cpp \
option.cpp \
plugin.cpp \
diff --git a/src/core.cpp b/src/core.cpp
index 5e6f893..9e88618 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -24,10 +24,13 @@
*/
#include <string.h>
+#include <sys/poll.h>
+#include <assert.h>
#include <compiz-core.h>
+#include "privatecore.h"
-CompCore core;
+CompCore *core;
static char *corePrivateIndices = 0;
static int corePrivateLen = 0;
@@ -38,11 +41,11 @@ reallocCorePrivate (int size,
{
void *privates;
- privates = realloc (core.base.privates, size * sizeof (CompPrivate));
+ privates = realloc (core->privates, size * sizeof (CompPrivate));
if (!privates)
return FALSE;
- core.base.privates = (CompPrivate *) privates;
+ core->privates = (CompPrivate *) privates;
return TRUE;
}
@@ -96,209 +99,545 @@ freeCorePrivateIndex (int index)
compObjectFreePrivateIndex (NULL, COMP_OBJECT_TYPE_CORE, index);
}
-static CompBool
-initCorePluginForObject (CompPlugin *p,
- CompObject *o)
+
+#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
+
+CompCore::CompCore ()
{
- return TRUE;
+ priv = new PrivateCore (this);
+ assert (priv);
+
+ compObjectInit (this, 0, COMP_OBJECT_TYPE_CORE);
}
-static void
-finiCorePluginForObject (CompPlugin *p,
- CompObject *o)
+bool
+CompCore::init ()
{
+ WRAPABLE_INIT_HND(fileWatchAdded);
+ WRAPABLE_INIT_HND(fileWatchRemoved);
+ WRAPABLE_INIT_HND(initPluginForObject);
+ WRAPABLE_INIT_HND(finiPluginForObject);
+ WRAPABLE_INIT_HND(setOptionForPlugin);
+ WRAPABLE_INIT_HND(objectAdd);
+ WRAPABLE_INIT_HND(objectRemove);
+ WRAPABLE_INIT_HND(sessionEvent);
+
+ CompPlugin *corePlugin = loadPlugin ("core");
+ if (!corePlugin)
+ {
+ compLogMessage (0, "core", CompLogLevelFatal,
+ "Couldn't load core plugin");
+ return false;
+ }
+
+ if (!pushPlugin (corePlugin))
+ {
+ compLogMessage (0, "core", CompLogLevelFatal,
+ "Couldn't activate core plugin");
+ return false;
+ }
+
+ return true;
}
-static CompBool
-setOptionForPlugin (CompObject *object,
- const char *plugin,
- const char *name,
- CompOptionValue *value)
+CompCore::~CompCore ()
{
CompPlugin *p;
- p = findActivePlugin (plugin);
- if (p && p->vTable->setObjectOption)
- return (*p->vTable->setObjectOption) (p, object, name, value);
+ while (priv->displays)
+ removeDisplay (priv->displays);
+
+ if (priv->watchPollFds)
+ free (priv->watchPollFds);
+
+ while ((p = popPlugin ()))
+ unloadPlugin (p);
- return FALSE;
}
-static void
-coreObjectAdd (CompObject *parent,
- CompObject *object)
+CompDisplay *
+CompCore::displays()
{
- object->parent = parent;
+ return priv->displays;
}
-static void
-coreObjectRemove (CompObject *parent,
- CompObject *object)
+bool
+CompCore::addDisplay (const char *name)
{
- object->parent = NULL;
+
+ CompDisplay *prev;
+ CompDisplay *d = new CompDisplay();
+
+ if (!d)
+ return false;
+
+ for (prev = priv->displays; prev && prev->next; prev = prev->next);
+
+ if (prev)
+ prev->next = d;
+ else
+ priv->displays = d;
+
+ if (!d->init (name))
+ {
+ if (prev)
+ prev->next = NULL;
+ else
+ priv->displays = NULL;
+ delete d;
+ return false;
+ }
+ return true;
}
-static void
-fileWatchAdded (CompCore *core,
- CompFileWatch *fileWatch)
+void
+CompCore::removeDisplay (CompDisplay *d)
{
+ CompDisplay *p;
+
+ for (p = priv->displays; p; p = p->next)
+ if (p->next == d)
+ break;
+
+ if (p)
+ p->next = d->next;
+ else
+ priv->displays = NULL;
+
+ delete d;
}
-static void
-fileWatchRemoved (CompCore *core,
- CompFileWatch *fileWatch)
+void
+CompCore::eventLoop ()
{
+ struct timeval tv;
+ CompDisplay *d;
+ CompTimeout *t;
+ int time;
+
+ for (d = priv->displays; d; d = d->next)
+ d->setWatchFdHandle (addWatchFd (ConnectionNumber (d->dpy()),
+ POLLIN, NULL, NULL));
+
+ for (;;)
+ {
+ if (restartSignal || shutDown)
+ break;
+
+ for (d = priv->displays; d; d = d->next)
+ {
+ d->processEvents ();
+ }
+
+ if (!priv->timeouts.empty())
+ {
+ gettimeofday (&tv, 0);
+ priv->handleTimeouts (&tv);
+
+ if ((*priv->timeouts.begin())->minLeft > 0)
+ {
+ std::list<CompTimeout *>::iterator it = priv->timeouts.begin();
+
+ t = (*it);
+ time = t->maxLeft;
+ while (it != priv->timeouts.end())
+ {
+ t = (*it);
+ if (t->minLeft <= time)
+ break;
+ if (t->maxLeft < time)
+ time = t->maxLeft;
+ it++;
+ }
+ priv->doPoll (time);
+ }
+ }
+ else
+ {
+ priv->doPoll (-1);
+ }
+ }
+
+ for (d = priv->displays; d; d = d->next)
+ removeWatchFd (d->getWatchFdHandle());
}
-CompBool
-initCore (void)
-{
- CompPlugin *corePlugin;
- compObjectInit (&core.base, 0, COMP_OBJECT_TYPE_CORE);
- core.displays = NULL;
+CompFileWatchHandle
+CompCore::addFileWatch (const char *path,
+ int mask,
+ FileWatchCallBackProc callBack,
+ void *closure)
+{
+ CompFileWatch *fileWatch = new CompFileWatch();
+ if (!fileWatch)
+ return 0;
- core.tmpRegion = XCreateRegion ();
- if (!core.tmpRegion)
- return FALSE;
+ fileWatch->path = strdup (path);
+ fileWatch->mask = mask;
+ fileWatch->callBack = callBack;
+ fileWatch->closure = closure;
+ fileWatch->handle = priv->lastFileWatchHandle++;
- core.outputRegion = XCreateRegion ();
- if (!core.outputRegion)
- {
- XDestroyRegion (core.tmpRegion);
- return FALSE;
- }
+ if (priv->lastFileWatchHandle == MAXSHORT)
+ priv->lastFileWatchHandle = 1;
- core.fileWatch = NULL;
- core.lastFileWatchHandle = 1;
+ priv->fileWatch.push_front(fileWatch);
- core.timeouts = NULL;
- core.lastTimeoutHandle = 1;
+ fileWatchAdded (fileWatch);
- core.watchFds = NULL;
- core.lastWatchFdHandle = 1;
- core.watchPollFds = NULL;
- core.nWatchFds = 0;
+ return fileWatch->handle;
+}
- gettimeofday (&core.lastTimeout, 0);
+void
+CompCore::removeFileWatch (CompFileWatchHandle handle)
+{
+ std::list<CompFileWatch *>::iterator it;
+ CompFileWatch *w;
- core.initPluginForObject = initCorePluginForObject;
- core.finiPluginForObject = finiCorePluginForObject;
+ for (it = priv->fileWatch.begin(); it != priv->fileWatch.end(); it++)
+ if ((*it)->handle == handle)
+ break;
- core.setOptionForPlugin = setOptionForPlugin;
+ if (it == priv->fileWatch.end())
+ return;
- core.objectAdd = coreObjectAdd;
- core.objectRemove = coreObjectRemove;
+ w = (*it);
+ priv->fileWatch.erase (it);
- core.fileWatchAdded = fileWatchAdded;
- core.fileWatchRemoved = fileWatchRemoved;
+ fileWatchRemoved (w);
- core.sessionEvent = sessionEvent;
+ delete w;
+}
- corePlugin = loadPlugin ("core");
- if (!corePlugin)
- {
- compLogMessage (0, "core", CompLogLevelFatal,
- "Couldn't load core plugin");
- return FALSE;
- }
+void
+PrivateCore::addTimeout (CompTimeout *timeout)
+{
+ std::list<CompTimeout *>::iterator it;
- if (!pushPlugin (corePlugin))
+ for (it = timeouts.begin(); it != timeouts.end(); it++)
{
- compLogMessage (0, "core", CompLogLevelFatal,
- "Couldn't activate core plugin");
- return FALSE;
+ if (timeout->minTime < (*it)->minLeft)
+ break;
}
- return TRUE;
+ timeout->minLeft = timeout->minTime;
+ timeout->maxLeft = timeout->maxTime;
+
+ timeouts.insert (it, timeout);
}
-void
-finiCore (void)
+CompTimeoutHandle
+CompCore::addTimeout (int minTime,
+ int maxTime,
+ CallBackProc callBack,
+ void *closure)
{
- CompPlugin *p;
+ CompTimeout *timeout = new CompTimeout();
- while (core.displays)
- removeDisplay (core.displays);
+ if (!timeout)
+ return 0;
- if (core.watchPollFds)
- free (core.watchPollFds);
+ timeout->minTime = minTime;
+ timeout->maxTime = (maxTime >= minTime) ? maxTime : minTime;
+ timeout->callBack = callBack;
+ timeout->closure = closure;
+ timeout->handle = priv->lastTimeoutHandle++;
- while ((p = popPlugin ()))
- unloadPlugin (p);
+ if (priv->lastTimeoutHandle == MAXSHORT)
+ priv->lastTimeoutHandle = 1;
+
+ priv->addTimeout (timeout);
- XDestroyRegion (core.outputRegion);
- XDestroyRegion (core.tmpRegion);
+ return timeout->handle;
}
-void
-addDisplayToCore (CompDisplay *d)
+void *
+CompCore::removeTimeout (CompTimeoutHandle handle)
{
- CompDisplay *prev;
+ std::list<CompTimeout *>::iterator it;
+ CompTimeout *t;
+ void *closure = NULL;
- for (prev = core.displays; prev && prev->next; prev = prev->next);
+ for (it = priv->timeouts.begin(); it != priv->timeouts.end(); it++)
+ if ((*it)->handle == handle)
+ break;
- if (prev)
- prev->next = d;
- else
- core.displays = d;
+ if (it == priv->timeouts.end())
+ return NULL;
+
+ t = (*it);
+ priv->timeouts.erase (it);
+
+ closure = t->closure;
+
+ delete t;
+
+ return closure;
}
-CompFileWatchHandle
-addFileWatch (const char *path,
- int mask,
- FileWatchCallBackProc callBack,
- void *closure)
+CompWatchFdHandle
+CompCore::addWatchFd (int fd,
+ short int events,
+ CallBackProc callBack,
+ void *closure)
{
- CompFileWatch *fileWatch;
+ CompWatchFd *watchFd = new CompWatchFd();
- fileWatch = (CompFileWatch *) malloc (sizeof (CompFileWatch));
- if (!fileWatch)
+ if (!watchFd)
return 0;
- fileWatch->path = strdup (path);
- fileWatch->mask = mask;
- fileWatch->callBack = callBack;
- fileWatch->closure = closure;
- fileWatch->handle = core.lastFileWatchHandle++;
+ watchFd->fd = fd;
+ watchFd->callBack = callBack;
+ watchFd->closure = closure;
+ watchFd->handle = priv->lastWatchFdHandle++;
- if (core.lastFileWatchHandle == MAXSHORT)
- core.lastFileWatchHandle = 1;
+ if (priv->lastWatchFdHandle == MAXSHORT)
+ priv->lastWatchFdHandle = 1;
- fileWatch->next = core.fileWatch;
- core.fileWatch = fileWatch;
+ priv->watchFds.push_front (watchFd);
- (*core.fileWatchAdded) (&core, fileWatch);
+ priv->nWatchFds++;
- return fileWatch->handle;
+ priv->watchPollFds = (struct pollfd *) realloc (priv->watchPollFds,
+ priv->nWatchFds * sizeof (struct pollfd));
+
+ priv->watchPollFds[priv->nWatchFds - 1].fd = fd;
+ priv->watchPollFds[priv->nWatchFds - 1].events = events;
+
+ return watchFd->handle;
}
void
-removeFileWatch (CompFileWatchHandle handle)
+CompCore::removeWatchFd (CompWatchFdHandle handle)
{
- CompFileWatch *p = 0, *w;
+ std::list<CompWatchFd *>::iterator it;
+ CompWatchFd *w;
+ int i;
- for (w = core.fileWatch; w; w = w->next)
- {
- if (w->handle == handle)
+ for (it = priv->watchFds.begin(), i = priv->nWatchFds - 1;
+ it != priv->watchFds.end(); it++, i--)
+ if ((*it)->handle == handle)
break;
- p = w;
+ if (it == priv->watchFds.end())
+ return;
+
+ w = (*it);
+ priv->watchFds.erase (it);
+
+ priv->nWatchFds--;
+
+ if (i < priv->nWatchFds)
+ memmove (&priv->watchPollFds[i], &priv->watchPollFds[i + 1],
+ (priv->nWatchFds - i) * sizeof (struct pollfd));
+
+ delete w;
+}
+
+short int
+PrivateCore::watchFdEvents (CompWatchFdHandle handle)
+{
+ std::list<CompWatchFd *>::iterator it;
+ int i;
+
+ for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
+ it++, i--)
+ if ((*it)->handle == handle)
+ return watchPollFds[i].revents;
+
+ return 0;
+}
+
+int
+PrivateCore::doPoll (int timeout)
+{
+ int rv;
+
+ rv = poll (watchPollFds, nWatchFds, timeout);
+ if (rv)
+ {
+ std::list<CompWatchFd *>::iterator it;
+ int i;
+
+ for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
+ it++, i--)
+ if (watchPollFds[i].revents != 0 && (*it)->callBack)
+ (*(*it)->callBack) ((*it)->closure);
}
- if (w)
+ return rv;
+}
+
+void
+PrivateCore::handleTimeouts (struct timeval *tv)
+{
+ CompTimeout *t;
+ int timeDiff;
+ std::list<CompTimeout *>::iterator it;
+
+ timeDiff = TIMEVALDIFF (tv, &lastTimeout);
+
+ /* handle clock rollback */
+ if (timeDiff < 0)
+ timeDiff = 0;
+
+ for (it = timeouts.begin(); it != timeouts.end(); it++)
{
- if (p)
- p->next = w->next;
+ t = (*it);
+ t->minLeft -= timeDiff;
+ t->maxLeft -= timeDiff;
+ }
+
+ while (timeouts.begin() != timeouts.end() &&
+ (*timeouts.begin())->minLeft <= 0)
+ {
+ t = (*timeouts.begin());
+ timeouts.pop_front();
+
+ if ((*t->callBack) (t->closure))
+ {
+ addTimeout (t);
+ }
else
- core.fileWatch = w->next;
+ {
+ delete t;
+ }
+ }
- (*core.fileWatchRemoved) (&core, w);
+ lastTimeout = *tv;
+}
- if (w->path)
- free (w->path);
- free (w);
- }
+void
+CompCore::fileWatchAdded (CompFileWatch *watch)
+ WRAPABLE_HND_FUNC(fileWatchAdded, watch)
+
+void
+CompCore::fileWatchRemoved (CompFileWatch *watch)
+ WRAPABLE_HND_FUNC(fileWatchRemoved, watch)
+
+bool
+CompCore::initPluginForObject (CompPlugin *plugin, CompObject *object)
+{
+ WRAPABLE_HND_FUNC_RETURN(bool, initPluginForObject, plugin, object)
+ return true;
+}
+
+void
+CompCore::finiPluginForObject (CompPlugin *plugin, CompObject *object)
+ WRAPABLE_HND_FUNC(finiPluginForObject, plugin, object)
+
+
+bool
+CompCore::setOptionForPlugin (CompObject *object,
+ const char *plugin,
+ const char *name,
+ CompOptionValue *value)
+{
+ WRAPABLE_HND_FUNC_RETURN(bool, setOptionForPlugin,
+ object, plugin, name, value)
+
+ CompPlugin *p = findActivePlugin (plugin);
+ if (p)
+ return p->vTable->setObjectOption (object, name, value);
+
+ return false;
+}
+
+void
+CompCore::objectAdd (CompObject *parent, CompObject *object)
+{
+ WRAPABLE_HND_FUNC(objectAdd, parent, object)
+ object->parent = parent;
+}
+
+void
+CompCore::objectRemove (CompObject *parent, CompObject *object)
+{
+ WRAPABLE_HND_FUNC(objectRemove, parent, object)
+ object->parent = NULL;
+}
+
+void
+CompCore::sessionEvent (CompSessionEvent event,
+ CompOption *arguments,
+ unsigned int nArguments)
+ WRAPABLE_HND_FUNC(sessionEvent, event, arguments, nArguments)
+
+CoreInterface::CoreInterface ()
+{
+ WRAPABLE_INIT_FUNC(fileWatchAdded);
+ WRAPABLE_INIT_FUNC(fileWatchRemoved);
+ WRAPABLE_INIT_FUNC(initPluginForObject);
+ WRAPABLE_INIT_FUNC(finiPluginForObject);
+ WRAPABLE_INIT_FUNC(setOptionForPlugin);
+ WRAPABLE_INIT_FUNC(objectAdd);
+ WRAPABLE_INIT_FUNC(objectRemove);
+ WRAPABLE_INIT_FUNC(sessionEvent);
+}
+
+void
+CoreInterface::fileWatchAdded (CompFileWatch *watch)
+ WRAPABLE_DEF_FUNC(fileWatchAdded, watch)
+
+void
+CoreInterface::fileWatchRemoved (CompFileWatch *watch)
+ WRAPABLE_DEF_FUNC(fileWatchRemoved, watch)
+
+bool
+CoreInterface::initPluginForObject (CompPlugin *plugin, CompObject *object)
+ WRAPABLE_DEF_FUNC_RETURN(initPluginForObject, plugin, object)
+
+void
+CoreInterface::finiPluginForObject (CompPlugin *plugin, CompObject *object)
+ WRAPABLE_DEF_FUNC(finiPluginForObject, plugin, object)
+
+
+bool
+CoreInterface::setOptionForPlugin (CompObject *object,
+ const char *plugin,
+ const char *name,
+ CompOptionValue *value)
+ WRAPABLE_DEF_FUNC_RETURN(setOptionForPlugin,
+ object, plugin, name, value)
+
+void
+CoreInterface::objectAdd (CompObject *parent, CompObject *object)
+ WRAPABLE_DEF_FUNC(objectAdd, parent, object)
+
+void
+CoreInterface::objectRemove (CompObject *parent, CompObject *object)
+ WRAPABLE_DEF_FUNC(objectRemove, parent, object)
+
+void
+CoreInterface::sessionEvent (CompSessionEvent event,
+ CompOption *arguments,
+ unsigned int nArguments)
+ WRAPABLE_DEF_FUNC(sessionEvent, event, arguments, nArguments)
+
+
+PrivateCore::PrivateCore (CompCore *core) :
+ core (core),
+ displays (0),
+ fileWatch (0),
+ lastFileWatchHandle (1),
+ timeouts (0),
+ lastTimeoutHandle (1),
+ watchFds (0),
+ lastWatchFdHandle (1),
+ watchPollFds (0),
+ nWatchFds (0)
+{
+ gettimeofday (&lastTimeout, 0);
+}
+
+PrivateCore::~PrivateCore ()
+{
}
diff --git a/src/cursor.cpp b/src/cursor.cpp
index baca1c3..a2f398b 100644
--- a/src/cursor.cpp
+++ b/src/cursor.cpp
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <compiz-core.h>
+#include "privatescreen.h"
static void
setCursorMatrix (CompCursor *c)
@@ -36,20 +37,20 @@ setCursorMatrix (CompCursor *c)
}
void
-addCursor (CompScreen *s)
+CompScreen::addCursor ()
{
CompCursor *c;
c = (CompCursor *) malloc (sizeof (CompCursor));
if (c)
{
- c->screen = s;
+ c->screen = this;
c->image = NULL;
c->x = 0;
c->y = 0;
- c->next = s->cursors;
- s->cursors = c;
+ c->next = priv->cursors;
+ priv->cursors = c;
updateCursor (c, 0, 0, 0);
@@ -57,12 +58,13 @@ addCursor (CompScreen *s)
}
}
-Bool
-damageCursorRect (CompCursor *c,
- Bool initial,
- BoxPtr rect)
+bool
+CompScreen::damageCursorRect (CompCursor *c,
+ bool initial,
+ BoxPtr rect)
{
- return FALSE;
+ WRAPABLE_HND_FUNC_RETURN(bool, damageCursorRect, c, initial, rect)
+ return false;
}
void
@@ -71,12 +73,12 @@ addCursorDamageRect (CompCursor *c,
{
REGION region;
- if (c->screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ if (c->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
return;
region.extents = *rect;
- if (!(*c->screen->damageCursorRect) (c, FALSE, &region.extents))
+ if (!c->screen->damageCursorRect (c, false, &region.extents))
{
region.extents.x1 += c->x;
region.extents.y1 += c->y;
@@ -86,7 +88,7 @@ addCursorDamageRect (CompCursor *c,
region.rects = &region.extents;
region.numRects = region.size = 1;
- damageScreenRegion (c->screen, &region);
+ c->screen->damageRegion (&region);
}
}
@@ -95,7 +97,7 @@ addCursorDamage (CompCursor *c)
{
BoxRec box;
- if (c->screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ if (c->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
return;
box.x1 = 0;
@@ -117,10 +119,10 @@ updateCursor (CompCursor *c,
{
CompCursorImage *cursorImage;
- cursorImage = findCursorImageAtScreen (c->screen, serial);
+ cursorImage = c->screen->findCursorImage (serial);
if (!cursorImage)
{
- Display *dpy = c->screen->display->display;
+ Display *dpy = c->screen->display ()->dpy ();
XFixesCursorImage *image;
image = XFixesGetCursorImage (dpy);
@@ -158,8 +160,8 @@ updateCursor (CompCursor *c,
XFree (image);
- cursorImage->next = c->screen->cursorImages;
- c->screen->cursorImages = cursorImage;
+ cursorImage->next = c->screen->cursorImages ();
+ c->screen->cursorImages () = cursorImage;
}
if (c->image)
diff --git a/src/display.cpp b/src/display.cpp
index 09223fb..0efe8d5 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -38,37 +38,43 @@
#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 <compiz-core.h>
+#include "privatedisplay.h"
+#include "privatescreen.h"
+#include "privatewindow.h"
static unsigned int virtualModMask[] = {
CompAltMask, CompMetaMask, CompSuperMask, CompHyperMask,
CompModeSwitchMask, CompNumLockMask, CompScrollLockMask
};
-static CompScreen *targetScreen = NULL;
-static CompOutput *targetOutput;
+CompScreen *targetScreen = NULL;
+CompOutput *targetOutput;
-static Bool inHandleEvent = FALSE;
+Bool inHandleEvent = FALSE;
-static const CompTransform identity = {
- {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
- }
-};
int lastPointerX = 0;
int lastPointerY = 0;
int pointerX = 0;
int pointerY = 0;
-#define NUM_OPTIONS(d) (sizeof ((d)->opt) / sizeof (CompOption))
+#define MwmHintsFunctions (1L << 0)
+#define MwmHintsDecorations (1L << 1)
+#define PropMotifWmHintElements 3
+
+typedef struct {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+} MwmHints;
+
+#define NUM_OPTIONS(d) (sizeof ((d)->priv->opt) / sizeof (CompOption))
static char *displayPrivateIndices = 0;
static int displayPrivateLen = 0;
@@ -80,13 +86,13 @@ reallocDisplayPrivate (int size,
CompDisplay *d;
void *privates;
- for (d = core.displays; d; d = d->next)
+ for (d = core->displays(); d; d = d->next)
{
- privates = realloc (d->base.privates, size * sizeof (CompPrivate));
+ privates = realloc (d->privates, size * sizeof (CompPrivate));
if (!privates)
return FALSE;
- d->base.privates = (CompPrivate *) privates;
+ d->privates = (CompPrivate *) privates;
}
return TRUE;
@@ -117,9 +123,9 @@ forEachDisplayObject (CompObject *parent,
{
CompDisplay *d;
- for (d = core.displays; d; d = d->next)
+ for (d = core->displays(); d; d = d->next)
{
- if (!(*proc) (&d->base, closure))
+ if (!(*proc) (d, closure))
return FALSE;
}
}
@@ -140,7 +146,7 @@ findDisplayObject (CompObject *parent,
if (parent->type == COMP_OBJECT_TYPE_CORE)
{
if (!name || !name[0])
- return &core.displays->base;
+ return core->displays ();
}
return NULL;
@@ -158,12 +164,12 @@ freeDisplayPrivateIndex (int index)
compObjectFreePrivateIndex (NULL, COMP_OBJECT_TYPE_DISPLAY, index);
}
-static Bool
-closeWin (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::closeWin (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
@@ -172,19 +178,19 @@ closeWin (CompDisplay *d,
xid = getIntOptionNamed (option, nOption, "window", 0);
time = getIntOptionNamed (option, nOption, "time", CurrentTime);
- w = findTopLevelWindowAtDisplay (d, xid);
- if (w && (w->actions & CompWindowActionCloseMask))
- closeWindow (w, time);
+ w = d->findTopLevelWindow (xid);
+ if (w && (w->priv->actions & CompWindowActionCloseMask))
+ w->close (time);
- return TRUE;
+ return true;
}
-static Bool
-mainMenu (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompScreen::mainMenu (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
@@ -193,20 +199,20 @@ mainMenu (CompDisplay *d,
xid = getIntOptionNamed (option, nOption, "root", 0);
time = getIntOptionNamed (option, nOption, "time", CurrentTime);
- s = findScreenAtDisplay (d, xid);
- if (s && !s->maxGrab)
- toolkitAction (s, s->display->toolkitActionMainMenuAtom, time, s->root,
- 0, 0, 0);
+ s = d->findScreen (xid);
+ if (s && !s->priv->maxGrab)
+ s->toolkitAction (s->display ()->atoms().toolkitActionMainMenu, time,
+ s->priv->root, 0, 0, 0);
- return TRUE;
+ return true;
}
-static Bool
-runDialog (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompScreen::runDialog (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
@@ -215,274 +221,203 @@ runDialog (CompDisplay *d,
xid = getIntOptionNamed (option, nOption, "root", 0);
time = getIntOptionNamed (option, nOption, "time", CurrentTime);
- s = findScreenAtDisplay (d, xid);
- if (s && !s->maxGrab)
- toolkitAction (s, s->display->toolkitActionRunDialogAtom, time, s->root,
- 0, 0, 0);
+ s = d->findScreen (xid);
+ if (s && !s->priv->maxGrab)
+ s->toolkitAction (s->display ()->atoms().toolkitActionRunDialog, time,
+ s->priv->root , 0, 0, 0);
- return TRUE;
+ return true;
}
-static Bool
-unmaximize (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::unmaximize (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- maximizeWindow (w, 0);
+ w->maximize (0);
- return TRUE;
+ return true;
}
-static Bool
-minimize (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::minimize (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
- if (w && (w->actions & CompWindowActionMinimizeMask))
- minimizeWindow (w);
+ w = d->findTopLevelWindow (xid);
+ if (w && (w->actions () & CompWindowActionMinimizeMask))
+ w->minimize ();
- return TRUE;
+ return true;
}
-static Bool
-maximize (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::maximize (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- maximizeWindow (w, MAXIMIZE_STATE);
+ w->maximize (MAXIMIZE_STATE);
- return TRUE;
+ return true;
}
-static Bool
-maximizeHorizontally (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::maximizeHorizontally (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- maximizeWindow (w, w->state | CompWindowStateMaximizedHorzMask);
+ w->maximize (w->state () | CompWindowStateMaximizedHorzMask);
- return TRUE;
+ return true;
}
-static Bool
-maximizeVertically (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::maximizeVertically (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- maximizeWindow (w, w->state | CompWindowStateMaximizedVertMask);
+ w->maximize (w->state () | CompWindowStateMaximizedVertMask);
- return TRUE;
+ return true;
}
-static Bool
-showDesktop (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompScreen::showDesktop (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
xid = getIntOptionNamed (option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
+ s = d->findScreen (xid);
if (s)
{
- if (s->showingDesktopMask == 0)
- (*s->enterShowDesktopMode) (s);
+ if (s->priv->showingDesktopMask == 0)
+ s->enterShowDesktopMode ();
else
- (*s->leaveShowDesktopMode) (s, NULL);
+ s->leaveShowDesktopMode (NULL);
}
- return TRUE;
+ return true;
}
-static Bool
-toggleSlowAnimations (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompScreen::toggleSlowAnimations (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
xid = getIntOptionNamed (option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
+ s = d->findScreen (xid);
if (s)
- s->slowAnimations = !s->slowAnimations;
-
- return TRUE;
-}
-
-static Bool
-raiseInitiate (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
-{
- CompWindow *w;
- Window xid;
-
- xid = getIntOptionNamed (option, nOption, "window", 0);
-
- w = findTopLevelWindowAtDisplay (d, xid);
- if (w)
- raiseWindow (w);
-
- return TRUE;
-}
-
-static Bool
-lowerInitiate (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
-{
- CompWindow *w;
- Window xid;
-
- xid = getIntOptionNamed (option, nOption, "window", 0);
-
- w = findTopLevelWindowAtDisplay (d, xid);
- if (w)
- lowerWindow (w);
-
- return TRUE;
-}
-
-static void
-changeWindowOpacity (CompWindow *w,
- int direction)
-{
- CompScreen *s = w->screen;
- int step, opacity;
-
- if (w->attrib.override_redirect)
- return;
-
- if (w->type & CompWindowTypeDesktopMask)
- return;
-
- step = (0xff * s->opt[COMP_SCREEN_OPTION_OPACITY_STEP].value.i) / 100;
-
- w->opacityFactor = w->opacityFactor + step * direction;
- if (w->opacityFactor > 0xff)
- {
- w->opacityFactor = 0xff;
- }
- else if (w->opacityFactor < step)
- {
- w->opacityFactor = step;
- }
+ s->priv->slowAnimations = !s->priv->slowAnimations;
- opacity = (w->opacity * w->opacityFactor) / 0xff;
- if (opacity != w->paint.opacity)
- {
- w->paint.opacity = opacity;
- addWindowDamage (w);
- }
+ return true;
}
-static Bool
-increaseOpacity (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::raiseInitiate (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- changeWindowOpacity (w, 1);
+ w->raise ();
- return TRUE;
+ return true;
}
-static Bool
-decreaseOpacity (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::lowerInitiate (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- changeWindowOpacity (w, -1);
+ w->lower ();
- return TRUE;
+ return true;
}
-static Bool
-runCommandDispatch (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompDisplay::runCommandDispatch (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
xid = getIntOptionNamed (option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
+ s = d->findScreen (xid);
if (s)
{
int index = -1;
@@ -490,7 +425,7 @@ runCommandDispatch (CompDisplay *d,
while (i <= COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY)
{
- if (action == &d->opt[i].value.action)
+ if (action == &d->priv->opt[i].value.action)
{
index = i - COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY +
COMP_DISPLAY_OPTION_COMMAND0;
@@ -501,186 +436,183 @@ runCommandDispatch (CompDisplay *d,
}
if (index > 0)
- runCommand (s, d->opt[index].value.s);
+ s->runCommand (d->priv->opt[index].value.s);
}
- return TRUE;
+ return true;
}
-static Bool
-runCommandScreenshot (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompDisplay::runCommandScreenshot (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
xid = getIntOptionNamed (option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
+ s = d->findScreen (xid);
if (s)
- runCommand (s, d->opt[COMP_DISPLAY_OPTION_SCREENSHOT].value.s);
+ s->runCommand (d->priv->opt[COMP_DISPLAY_OPTION_SCREENSHOT].value.s);
- return TRUE;
+ return true;
}
-static Bool
-runCommandWindowScreenshot (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompDisplay::runCommandWindowScreenshot (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
xid = getIntOptionNamed (option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
+ s = d->findScreen (xid);
if (s)
- runCommand (s, d->opt[COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT].value.s);
+ s->runCommand (
+ d->priv->opt[COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT].value.s);
- return TRUE;
+ return true;
}
-static Bool
-runCommandTerminal (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompDisplay::runCommandTerminal (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompScreen *s;
Window xid;
xid = getIntOptionNamed (option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
+ s = d->findScreen (xid);
if (s)
- runCommand (s, d->opt[COMP_DISPLAY_OPTION_TERMINAL].value.s);
+ s->runCommand (d->priv->opt[COMP_DISPLAY_OPTION_TERMINAL].value.s);
- return TRUE;
+ return true;
}
-static Bool
-windowMenu (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompScreen::windowMenu (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
- if (w && !w->screen->maxGrab)
+ w = d->findTopLevelWindow (xid);
+ if (w && !w->screen ()->priv->maxGrab)
{
int x, y, button;
Time time;
time = getIntOptionNamed (option, nOption, "time", CurrentTime);
button = getIntOptionNamed (option, nOption, "button", 0);
- x = getIntOptionNamed (option, nOption, "x", w->attrib.x);
- y = getIntOptionNamed (option, nOption, "y", w->attrib.y);
-
- toolkitAction (w->screen,
- w->screen->display->toolkitActionWindowMenuAtom,
- time,
- w->id,
- button,
- x,
- y);
+ x = getIntOptionNamed (option, nOption, "x", w->attrib ().x);
+ y = getIntOptionNamed (option, nOption, "y", w->attrib ().y);
+
+ w->screen ()->toolkitAction (
+ w->screen ()->display ()->atoms().toolkitActionWindowMenu,
+ time, w->id (), button, x, y);
}
- return TRUE;
+ return true;
}
-static Bool
-toggleMaximized (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::toggleMaximized (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
{
- if ((w->state & MAXIMIZE_STATE) == MAXIMIZE_STATE)
- maximizeWindow (w, 0);
+ if ((w->priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE)
+ w->maximize (0);
else
- maximizeWindow (w, MAXIMIZE_STATE);
+ w->maximize (MAXIMIZE_STATE);
}
- return TRUE;
+ return true;
}
-static Bool
-toggleMaximizedHorizontally (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::toggleMaximizedHorizontally (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- maximizeWindow (w, w->state ^ CompWindowStateMaximizedHorzMask);
+ w->maximize (w->priv->state ^ CompWindowStateMaximizedHorzMask);
- return TRUE;
+ return true;
}
-static Bool
-toggleMaximizedVertically (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::toggleMaximizedVertically (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
+ w = d->findTopLevelWindow (xid);
if (w)
- maximizeWindow (w, w->state ^ CompWindowStateMaximizedVertMask);
+ w->maximize (w->priv->state ^ CompWindowStateMaximizedVertMask);
- return TRUE;
+ return true;
}
-static Bool
-shade (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+bool
+CompWindow::shade (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
CompWindow *w;
Window xid;
xid = getIntOptionNamed (option, nOption, "window", 0);
- w = findTopLevelWindowAtDisplay (d, xid);
- if (w && (w->actions & CompWindowActionShadeMask))
+ w = d->findTopLevelWindow (xid);
+ if (w && (w->priv->actions & CompWindowActionShadeMask))
{
- w->state ^= CompWindowStateShadedMask;
- updateWindowAttributes (w, CompStackingUpdateModeNone);
+ w->priv->state ^= CompWindowStateShadedMask;
+ w->updateAttributes (CompStackingUpdateModeNone);
}
- return TRUE;
+ return true;
}
const CompMetadataOptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
@@ -690,10 +622,10 @@ const CompMetadataOptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
{ "click_to_focus", "bool", 0, 0, 0 },
{ "autoraise", "bool", 0, 0, 0 },
{ "autoraise_delay", "int", 0, 0, 0 },
- { "close_window_key", "key", 0, closeWin, 0 },
- { "close_window_button", "button", 0, closeWin, 0 },
- { "main_menu_key", "key", 0, mainMenu, 0 },
- { "run_key", "key", 0, runDialog, 0 },
+ { "close_window_key", "key", 0, CompWindow::closeWin, 0 },
+ { "close_window_button", "button", 0, CompWindow::closeWin, 0 },
+ { "main_menu_key", "key", 0, CompScreen::mainMenu, 0 },
+ { "run_key", "key", 0, CompScreen::runDialog, 0 },
{ "command0", "string", 0, 0, 0 },
{ "command1", "string", 0, 0, 0 },
{ "command2", "string", 0, 0, 0 },
@@ -706,564 +638,795 @@ const CompMetadataOptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
{ "command9", "string", 0, 0, 0 },
{ "command10", "string", 0, 0, 0 },
{ "command11", "string", 0, 0, 0 },
- { "run_command0_key", "key", 0, runCommandDispatch, 0 },
- { "run_command1_key", "key", 0, runCommandDispatch, 0 },
- { "run_command2_key", "key", 0, runCommandDispatch, 0 },
- { "run_command3_key", "key", 0, runCommandDispatch, 0 },
- { "run_command4_key", "key", 0, runCommandDispatch, 0 },
- { "run_command5_key", "key", 0, runCommandDispatch, 0 },
- { "run_command6_key", "key", 0, runCommandDispatch, 0 },
- { "run_command7_key", "key", 0, runCommandDispatch, 0 },
- { "run_command8_key", "key", 0, runCommandDispatch, 0 },
- { "run_command9_key", "key", 0, runCommandDispatch, 0 },
- { "run_command10_key", "key", 0, runCommandDispatch, 0 },
- { "run_command11_key", "key", 0, runCommandDispatch, 0 },
- { "slow_animations_key", "key", 0, toggleSlowAnimations, 0 },
- { "raise_window_key", "key", 0, raiseInitiate, 0 },
- { "raise_window_button", "button", 0, raiseInitiate, 0 },
- { "lower_window_key", "key", 0, lowerInitiate, 0 },
- { "lower_window_button", "button", 0, lowerInitiate, 0 },
- { "unmaximize_window_key", "key", 0, unmaximize, 0 },
- { "minimize_window_key", "key", 0, minimize, 0 },
- { "minimize_window_button", "button", 0, minimize, 0 },
- { "maximize_window_key", "key", 0, maximize, 0 },
- { "maximize_window_horizontally_key", "key", 0, maximizeHorizontally, 0 },
- { "maximize_window_vertically_key", "key", 0, maximizeVertically, 0 },
- { "opacity_increase_button", "button", 0, increaseOpacity, 0 },
- { "opacity_decrease_button", "button", 0, decreaseOpacity, 0 },
+ { "run_command0_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command1_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command2_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command3_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command4_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command5_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command6_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command7_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "run_command8_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
+ { "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 },
+ { "lower_window_button", "button", 0, CompWindow::lowerInitiate, 0 },
+ { "unmaximize_window_key", "key", 0, CompWindow::unmaximize, 0 },
+ { "minimize_window_key", "key", 0, CompWindow::minimize, 0 },
+ { "minimize_window_button", "button", 0, CompWindow::minimize, 0 },
+ { "maximize_window_key", "key", 0, CompWindow::maximize, 0 },
+ { "maximize_window_horizontally_key", "key", 0,
+ CompWindow::maximizeHorizontally, 0 },
+ { "maximize_window_vertically_key", "key", 0,
+ CompWindow::maximizeVertically, 0 },
{ "command_screenshot", "string", 0, 0, 0 },
- { "run_command_screenshot_key", "key", 0, runCommandScreenshot, 0 },
+ { "run_command_screenshot_key", "key", 0,
+ CompDisplay::runCommandScreenshot, 0 },
{ "command_window_screenshot", "string", 0, 0, 0 },
{ "run_command_window_screenshot_key", "key", 0,
- runCommandWindowScreenshot, 0 },
- { "window_menu_button", "button", 0, windowMenu, 0 },
- { "window_menu_key", "key", 0, windowMenu, 0 },
- { "show_desktop_key", "key", 0, showDesktop, 0 },
- { "show_desktop_edge", "edge", 0, showDesktop, 0 },
+ CompDisplay::runCommandWindowScreenshot, 0 },
+ { "window_menu_button", "button", 0, CompScreen::windowMenu, 0 },
+ { "window_menu_key", "key", 0, CompScreen::windowMenu, 0 },
+ { "show_desktop_key", "key", 0, CompScreen::showDesktop, 0 },
+ { "show_desktop_edge", "edge", 0, CompScreen::showDesktop, 0 },
{ "raise_on_click", "bool", 0, 0, 0 },
{ "audible_bell", "bool", 0, 0, 0 },
- { "toggle_window_maximized_key", "key", 0, toggleMaximized, 0 },
- { "toggle_window_maximized_button", "button", 0, toggleMaximized, 0 },
+ { "toggle_window_maximized_key", "key", 0,
+ CompWindow::toggleMaximized, 0 },
+ { "toggle_window_maximized_button", "button", 0,
+ CompWindow::toggleMaximized, 0 },
{ "toggle_window_maximized_horizontally_key", "key", 0,
- toggleMaximizedHorizontally, 0 },
+ CompWindow::toggleMaximizedHorizontally, 0 },
{ "toggle_window_maximized_vertically_key", "key", 0,
- toggleMaximizedVertically, 0 },
+ CompWindow::toggleMaximizedVertically, 0 },
{ "hide_skip_taskbar_windows", "bool", 0, 0, 0 },
- { "toggle_window_shaded_key", "key", 0, shade, 0 },
+ { "toggle_window_shaded_key", "key", 0, CompWindow::shade, 0 },
{ "ignore_hints_when_maximized", "bool", 0, 0, 0 },
{ "command_terminal", "string", 0, 0, 0 },
- { "run_command_terminal_key", "key", 0, runCommandTerminal, 0 },
+ { "run_command_terminal_key", "key", 0,
+ CompDisplay::runCommandTerminal, 0 },
{ "ping_delay", "int", "<min>1000</min>", 0, 0 },
{ "edge_delay", "int", "<min>0</min>", 0, 0 }
};
CompOption *
-getDisplayOptions (CompPlugin *plugin,
- CompDisplay *display,
- int *count)
+CompDisplay::getDisplayOptions (CompObject *object,
+ int *count)
{
+ CompDisplay *display = (CompDisplay *) object;
*count = NUM_OPTIONS (display);
- return display->opt;
+ return display->priv->opt;
}
-static void
-setAudibleBell (CompDisplay *display,
- Bool audible)
+bool
+CompDisplay::pingTimeout (void *closure)
{
- if (display->xkbExtension)
- XkbChangeEnabledControls (display->display,
- XkbUseCoreKbd,
- XkbAudibleBellMask,
- audible ? XkbAudibleBellMask : 0);
+ CompDisplay *d = (CompDisplay *) closure;
+ d->priv->handlePingTimeout();
+ return true;
}
-static Bool
-pingTimeout (void *closure)
+
+bool
+setDisplayOption (CompObject *object,
+ const char *name,
+ CompOptionValue *value)
{
- CompDisplay *d = (CompDisplay *) closure;
- CompScreen *s;
- CompWindow *w;
- XEvent ev;
- int ping = d->lastPing + 1;
+ return ((CompDisplay *) object)->setOption (name, value);
+}
- ev.type = ClientMessage;
- ev.xclient.window = 0;
- ev.xclient.message_type = d->wmProtocolsAtom;
- ev.xclient.format = 32;
- ev.xclient.data.l[0] = d->wmPingAtom;
- ev.xclient.data.l[1] = ping;
- ev.xclient.data.l[2] = 0;
- ev.xclient.data.l[3] = 0;
- ev.xclient.data.l[4] = 0;
- for (s = d->screens; s; s = s->next)
- {
- for (w = s->windows; w; w = w->next)
- {
- if (w->attrib.map_state != IsViewable)
- continue;
+static const int maskTable[] = {
+ ShiftMask, LockMask, ControlMask, Mod1Mask,
+ Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
+};
+static const int maskTableSize = sizeof (maskTable) / sizeof (int);
- if (!(w->type & CompWindowTypeNormalMask))
- continue;
+static int errors = 0;
- if (w->protocols & CompWindowProtocolPingMask)
- {
- if (w->transientFor)
- continue;
+static int
+errorHandler (Display *dpy,
+ XErrorEvent *e)
+{
- if (w->lastPong < d->lastPing)
- {
- if (w->alive)
- {
- w->alive = FALSE;
- w->paint.brightness = 0xa8a8;
- w->paint.saturation = 0;
-
- if (w->closeRequests)
- {
- toolkitAction (s,
- d->toolkitActionForceQuitDialogAtom,
- w->lastCloseRequestTime,
- w->id,
- TRUE,
- 0,
- 0);
-
- w->closeRequests = 0;
- }
-
- addWindowDamage (w);
- }
- }
+#ifdef DEBUG
+ char str[128];
+#endif
- ev.xclient.window = w->id;
- ev.xclient.data.l[2] = w->id;
+ errors++;
- XSendEvent (d->display, w->id, FALSE, NoEventMask, &ev);
- }
- }
- }
+#ifdef DEBUG
+ XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);
+ fprintf (stderr, "%s", str);
- d->lastPing = ping;
+ XGetErrorText (dpy, e->error_code, str, 128);
+ fprintf (stderr, ": %s\n ", str);
- return TRUE;
+ XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "%d", str, 128);
+ fprintf (stderr, str, e->request_code);
+
+ sprintf (str, "%d", e->request_code);
+ XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);
+ if (strcmp (str, ""))
+ fprintf (stderr, " (%s)", str);
+ fprintf (stderr, "\n ");
+
+ XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);
+ fprintf (stderr, str, e->minor_code);
+ fprintf (stderr, "\n ");
+
+ XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "%d", str, 128);
+ fprintf (stderr, str, e->resourceid);
+ fprintf (stderr, "\n");
+
+ /* abort (); */
+#endif
+
+ return 0;
}
-Bool
-setDisplayOption (CompPlugin *plugin,
- CompDisplay *display,
- const char *name,
- CompOptionValue *value)
+int
+compCheckForError (Display *dpy)
{
- CompOption *o;
- int index;
+ int e;
- o = compFindOption (display->opt, NUM_OPTIONS (display), name, &index);
- if (!o)
- return FALSE;
+ XSync (dpy, FALSE);
- switch (index) {
- case COMP_DISPLAY_OPTION_ABI:
- break;
- case COMP_DISPLAY_OPTION_ACTIVE_PLUGINS:
- if (compSetOptionList (o, value))
- {
- display->dirtyPluginList = TRUE;
- return TRUE;
- }
- break;
- case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
- if (compSetIntOption (o, value))
- {
- CompScreen *s;
+ e = errors;
+ errors = 0;
- for (s = display->screens; s; s = s->next)
- damageScreen (s);
+ return e;
+}
- if (!o->value.i)
- display->textureFilter = GL_NEAREST;
- else
- display->textureFilter = GL_LINEAR;
+/* add actions that should be automatically added as no screens
+ existed when they were initialized. */
+void
+CompDisplay::addScreenActions (CompScreen *s)
+{
+ int i;
- return TRUE;
- }
- break;
- case COMP_DISPLAY_OPTION_PING_DELAY:
- if (compSetIntOption (o, value))
- {
- if (display->pingHandle)
- compRemoveTimeout (display->pingHandle);
+ for (i = 0; i < COMP_DISPLAY_OPTION_NUM; i++)
+ {
+ if (!isActionOption (&priv->opt[i]))
+ continue;
- display->pingHandle =
- compAddTimeout (o->value.i, o->value.i + 500,
- pingTimeout, display);
- return TRUE;
- }
- break;
- case COMP_DISPLAY_OPTION_AUDIBLE_BELL:
- if (compSetBoolOption (o, value))
- {
- setAudibleBell (display, o->value.b);
- return TRUE;
- }
- break;
- default:
- if (compSetDisplayOption (display, o, value))
- return TRUE;
- break;
+ if (priv->opt[i].value.action.state & CompActionStateAutoGrab)
+ s->addAction (&priv->opt[i].value.action);
}
-
- return FALSE;
}
-static void
-updatePlugins (CompDisplay *d)
+Bool
+setDisplayAction (CompDisplay *display,
+ CompOption *o,
+ CompOptionValue *value)
{
- CompOption *o;
- CompPlugin *p, **pop = 0;
- int nPop, i, j;
+ CompScreen *s;
- d->dirtyPluginList = FALSE;
+ for (s = display->screens (); s; s = s->next)
+ if (!s->addAction (&value->action))
+ break;
- o = &d->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS];
+ if (s)
+ {
+ CompScreen *failed = s;
- /* The old plugin list always begins with the core plugin. To make sure
- we don't unnecessarily unload plugins if the new plugin list does not
- contain the core plugin, we have to use an offset */
- if (o->value.list.nValue > 0 && strcmp (o->value.list.value[0].s, "core"))
- i = 0;
- else
- i = 1;
+ for (s = display->screens (); s && s != failed; s = s->next)
+ s->removeAction (&value->action);
- /* j is initialized to 1 to make sure we never pop the core plugin */
- for (j = 1; j < d->plugin.list.nValue && i < o->value.list.nValue; i++, j++)
+ return FALSE;
+ }
+ else
{
- if (strcmp (d->plugin.list.value[j].s, o->value.list.value[i].s))
- break;
+ for (s = display->screens (); s; s = s->next)
+ s->removeAction (&o->value.action);
}
- nPop = d->plugin.list.nValue - j;
+ if (compSetActionOption (o, value))
+ return TRUE;
- if (nPop)
+ return FALSE;
+}
+
+CompDisplay::CompDisplay () :
+ next (0),
+ screenPrivateIndices (0),
+ screenPrivateLen (0)
+{
+ WRAPABLE_INIT_HND(handleEvent);
+ WRAPABLE_INIT_HND(handleCompizEvent);
+ WRAPABLE_INIT_HND(fileToImage);
+ WRAPABLE_INIT_HND(imageToFile);
+ WRAPABLE_INIT_HND(matchInitExp);
+ WRAPABLE_INIT_HND(matchExpHandlerChanged);
+ WRAPABLE_INIT_HND(matchPropertyChanged);
+ WRAPABLE_INIT_HND(logMessage);
+
+ priv = new PrivateDisplay (this);
+ assert (priv);
+}
+
+
+CompDisplay::~CompDisplay ()
+{
+ while (priv->screens)
+ removeScreen (priv->screens);
+
+ core->objectRemove (core, this);
+
+ objectFiniPlugins (this);
+
+ core->removeTimeout (priv->pingHandle);
+
+ if (priv->snDisplay)
+ sn_display_unref (priv->snDisplay);
+
+ XSync (priv->dpy, False);
+ XCloseDisplay (priv->dpy);
+
+ XDestroyRegion (mOutputRegion);
+ XDestroyRegion (mTmpRegion);
+
+
+ compFiniDisplayOptions (this, priv->opt, COMP_DISPLAY_OPTION_NUM);
+
+ compFiniOptionValue (&priv->plugin, CompOptionTypeList);
+
+ if (priv->modMap)
+ XFreeModifiermap (priv->modMap);
+
+ if (priv->screenInfo)
+ XFree (priv->screenInfo);
+
+ 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;
+ int fixesMinor;
+ int xkbOpcode;
+ int firstScreen, lastScreen;
+
+ if (displayPrivateLen)
{
- pop = (CompPlugin **) malloc (sizeof (CompPlugin *) * nPop);
- if (!pop)
+ privates =
+ (CompPrivate *) malloc (displayPrivateLen * sizeof (CompPrivate));
+ if (!privates)
{
- (*core.setOptionForPlugin) (&d->base, "core", o->name, &d->plugin);
- return;
+ return false;
}
}
+ else
+ privates = 0;
- for (j = 0; j < nPop; j++)
+ compObjectInit (this, privates, COMP_OBJECT_TYPE_DISPLAY);
+
+ mTmpRegion = XCreateRegion ();
+ if (!mTmpRegion)
+ return false;
+
+ mOutputRegion = XCreateRegion ();
+ if (!mOutputRegion)
{
- pop[j] = popPlugin ();
- d->plugin.list.nValue--;
- free (d->plugin.list.value[d->plugin.list.nValue].s);
+ XDestroyRegion (mTmpRegion);
+ return false;
}
- for (; i < o->value.list.nValue; i++)
+ priv->plugin.list.type = CompOptionTypeString;
+ priv->plugin.list.nValue = 1;
+ priv->plugin.list.value =
+ (CompOptionValue *) malloc (sizeof (CompOptionValue));
+
+ if (!priv->plugin.list.value) {
+ return false;
+ }
+
+ priv->plugin.list.value->s = strdup ("core");
+ if (!priv->plugin.list.value->s) {
+ free (priv->plugin.list.value);
+ return false;
+ }
+
+ priv->dpy = XOpenDisplay (name);
+ if (!priv->dpy)
{
- p = 0;
- for (j = 0; j < nPop; j++)
- {
- if (pop[j] && strcmp (pop[j]->vTable->name,
- o->value.list.value[i].s) == 0)
- {
- if (pushPlugin (pop[j]))
- {
- p = pop[j];
- pop[j] = 0;
- break;
- }
- }
- }
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "Couldn't open display %s", XDisplayName (name));
+ return false;
+ }
- if (p == 0)
- {
- p = loadPlugin (o->value.list.value[i].s);
- if (p)
- {
- if (!pushPlugin (p))
- {
- unloadPlugin (p);
- p = 0;
- }
- }
- }
+// priv->connection = XGetXCBConnection (priv->dpy);
- if (p)
- {
- CompOptionValue *value;
+ if (!compInitDisplayOptionsFromMetadata (this,
+ &coreMetadata,
+ coreDisplayOptionInfo,
+ priv->opt,
+ COMP_DISPLAY_OPTION_NUM))
+ return true;
- value = (CompOptionValue *) realloc (d->plugin.list.value, sizeof (CompOptionValue) *
- (d->plugin.list.nValue + 1));
- if (value)
- {
- value[d->plugin.list.nValue].s = strdup (p->vTable->name);
+ priv->opt[COMP_DISPLAY_OPTION_ABI].value.i = CORE_ABIVERSION;
- d->plugin.list.value = value;
- d->plugin.list.nValue++;
- }
- else
- {
- p = popPlugin ();
- unloadPlugin (p);
- }
- }
- }
+ snprintf (priv->displayString, 255, "DISPLAY=%s",
+ DisplayString (priv->dpy));
- for (j = 0; j < nPop; j++)
+#ifdef DEBUG
+ XSynchronize (priv->dpy, TRUE);
+#endif
+
+ priv->initAtoms ();
+
+ XSetErrorHandler (errorHandler);
+
+ updateModifierMappings ();
+
+ priv->snDisplay = sn_display_new (priv->dpy, NULL, NULL);
+ if (!priv->snDisplay)
+ return true;
+
+ priv->lastPing = 1;
+
+ if (!XQueryExtension (priv->dpy,
+ COMPOSITE_NAME,
+ &priv->compositeOpcode,
+ &priv->compositeEvent,
+ &priv->compositeError))
{
- if (pop[j])
- unloadPlugin (pop[j]);
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "No composite extension");
+ return false;
}
- if (nPop)
- free (pop);
+ XCompositeQueryVersion (priv->dpy, &compositeMajor, &compositeMinor);
+ if (compositeMajor == 0 && compositeMinor < 2)
+ {
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "Old composite extension");
+ return false;
+ }
- (*core.setOptionForPlugin) (&d->base, "core", o->name, &d->plugin);
-}
+ if (!XDamageQueryExtension (priv->dpy, &priv->damageEvent,
+ &priv->damageError))
+ {
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "No damage extension");
+ return false;
+ }
-static void
-addTimeout (CompTimeout *timeout)
-{
- CompTimeout *p = 0, *t;
+ if (!XSyncQueryExtension (priv->dpy, &priv->syncEvent, &priv->syncError))
+ {
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "No sync extension");
+ return false;
+ }
- for (t = core.timeouts; t; t = t->next)
+ if (!XFixesQueryExtension (priv->dpy, &priv->fixesEvent, &priv->fixesError))
{
- if (timeout->minTime < t->minLeft)
- break;
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "No fixes extension");
+ return false;
+ }
- p = t;
+ XFixesQueryVersion (priv->dpy, &priv->fixesVersion, &fixesMinor);
+ /*
+ if (d->fixesVersion < 5)
+ {
+ fprintf (stderr, "%s: Need fixes extension version 5 or later "
+ "for client-side cursor\n", programName);
}
+ */
- timeout->next = t;
- timeout->minLeft = timeout->minTime;
- timeout->maxLeft = timeout->maxTime;
+ priv->randrExtension = XRRQueryExtension (priv->dpy, &priv->randrEvent,
+ &priv->randrError);
- if (p)
- p->next = timeout;
+ priv->shapeExtension = XShapeQueryExtension (priv->dpy, &priv->shapeEvent,
+ &priv->shapeError);
+
+ priv->xkbExtension = XkbQueryExtension (priv->dpy, &xkbOpcode,
+ &priv->xkbEvent, &priv->xkbError,
+ NULL, NULL);
+ if (priv->xkbExtension)
+ {
+ XkbSelectEvents (priv->dpy,
+ XkbUseCoreKbd,
+ XkbBellNotifyMask | XkbStateNotifyMask,
+ XkbAllEventsMask);
+ }
else
- core.timeouts = timeout;
-}
+ {
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "No XKB extension");
-CompTimeoutHandle
-compAddTimeout (int minTime,
- int maxTime,
- CallBackProc callBack,
- void *closure)
-{
- CompTimeout *timeout;
+ priv->xkbEvent = priv->xkbError = -1;
+ }
- timeout = (CompTimeout *) malloc (sizeof (CompTimeout));
- if (!timeout)
- return 0;
+ priv->xineramaExtension = XineramaQueryExtension (priv->dpy,
+ &priv->xineramaEvent,
+ &priv->xineramaError);
- timeout->minTime = minTime;
- timeout->maxTime = (maxTime >= minTime) ? maxTime : minTime;
- timeout->callBack = callBack;
- timeout->closure = closure;
- timeout->handle = core.lastTimeoutHandle++;
- if (core.lastTimeoutHandle == MAXSHORT)
- core.lastTimeoutHandle = 1;
+ updateScreenInfo();
- addTimeout (timeout);
+ priv->escapeKeyCode =
+ XKeysymToKeycode (priv->dpy, XStringToKeysym ("Escape"));
+ priv->returnKeyCode =
+ XKeysymToKeycode (priv->dpy, XStringToKeysym ("Return"));
- return timeout->handle;
-}
+ /* TODO: bailout properly when objectInitPlugins fails */
+ assert (objectInitPlugins (this));
-void *
-compRemoveTimeout (CompTimeoutHandle handle)
-{
- CompTimeout *p = 0, *t;
- void *closure = NULL;
+ core->objectAdd (core, this);
- for (t = core.timeouts; t; t = t->next)
+ if (onlyCurrentScreen)
{
- if (t->handle == handle)
- break;
+ firstScreen = DefaultScreen (priv->dpy);
+ lastScreen = DefaultScreen (priv->dpy);
+ }
+ else
+ {
+ firstScreen = 0;
+ lastScreen = ScreenCount (priv->dpy) - 1;
+ }
- p = t;
+ for (i = firstScreen; i <= lastScreen; i++)
+ {
+ addScreen (i);
}
- if (t)
+ if (!priv->screens)
{
- if (p)
- p->next = t->next;
- else
- core.timeouts = t->next;
+ compLogMessage (this, "core", CompLogLevelFatal,
+ "No manageable screens found on display %s",
+ XDisplayName (name));
+ return false;
+ }
+
+ priv->setAudibleBell (priv->opt[COMP_DISPLAY_OPTION_AUDIBLE_BELL].value.b);
+
+ XGetInputFocus (priv->dpy, &focus, &revertTo);
+
+ /* move input focus to root window so that we get a FocusIn event when
+ moving it to the default window */
+ XSetInputFocus (priv->dpy, priv->screens->root (), RevertToPointerRoot,
+ CurrentTime);
- closure = t->closure;
+ if (focus == None || focus == PointerRoot)
+ {
+ priv->screens->focusDefaultWindow ();
+ }
+ else
+ {
+ CompWindow *w;
- free (t);
+ w = findWindow (focus);
+ if (w)
+ {
+ w->moveInputFocusTo ();
+ }
+ else
+ priv->screens->focusDefaultWindow ();
}
- return closure;
+ priv->pingHandle =
+ core->addTimeout (priv->opt[COMP_DISPLAY_OPTION_PING_DELAY].value.i,
+ priv->opt[COMP_DISPLAY_OPTION_PING_DELAY].value.i +
+ 500, CompDisplay::pingTimeout, this);
+
+ return true;
}
-CompWatchFdHandle
-compAddWatchFd (int fd,
- short int events,
- CallBackProc callBack,
- void *closure)
+CompDisplay::Atoms
+CompDisplay::atoms ()
+{
+ return priv->atoms;
+}
+
+Display *
+CompDisplay::dpy ()
+{
+ return priv->dpy;
+}
+
+CompScreen *
+CompDisplay::screens ()
+{
+ return priv->screens;
+}
+
+GLenum
+CompDisplay::textureFilter ()
+{
+ return priv->textureFilter;
+}
+
+CompOption *
+CompDisplay::getOption (const char *name)
+{
+ int index;
+ CompOption *o = compFindOption (priv->opt, NUM_OPTIONS (this),
+ name, &index);
+ return o;
+}
+
+XineramaScreenInfo *
+CompDisplay::screenInfo ()
{
- CompWatchFd *watchFd;
+ return priv->screenInfo;
+}
- watchFd = (CompWatchFd *) malloc (sizeof (CompWatchFd));
- if (!watchFd)
- return 0;
+int
+CompDisplay::nScreenInfo ()
+{
+ return priv->nScreenInfo;
+}
+
+bool
+CompDisplay::XRandr ()
+{
+ return priv->randrExtension;
+}
- watchFd->fd = fd;
- watchFd->callBack = callBack;
- watchFd->closure = closure;
- watchFd->handle = core.lastWatchFdHandle++;
+bool
+CompDisplay::XShape ()
+{
+ return priv->shapeExtension;
+}
+
+SnDisplay *
+CompDisplay::snDisplay ()
+{
+ return priv->snDisplay;
+}
+
+Window
+CompDisplay::below ()
+{
+ return priv->below;
+}
+
+Window
+CompDisplay::activeWindow ()
+{
+ return priv->activeWindow;
+}
- if (core.lastWatchFdHandle == MAXSHORT)
- core.lastWatchFdHandle = 1;
+Window
+CompDisplay::autoRaiseWindow ()
+{
+ return priv->autoRaiseWindow;
+}
- watchFd->next = core.watchFds;
- core.watchFds = watchFd;
+XModifierKeymap *
+CompDisplay::modMap ()
+{
+ return priv->modMap;
+}
- core.nWatchFds++;
+unsigned int
+CompDisplay::ignoredModMask ()
+{
+ return priv->ignoredModMask;
+}
- core.watchPollFds = (struct pollfd *) realloc (core.watchPollFds,
- core.nWatchFds * sizeof (struct pollfd));
+const char *
+CompDisplay::displayString ()
+{
+ return priv->displayString;
+}
- core.watchPollFds[core.nWatchFds - 1].fd = fd;
- core.watchPollFds[core.nWatchFds - 1].events = events;
+unsigned int
+CompDisplay::lastPing ()
+{
+ return priv->lastPing;
+}
- return watchFd->handle;
+CompWatchFdHandle
+CompDisplay::getWatchFdHandle ()
+{
+ return priv->watchFdHandle;
}
void
-compRemoveWatchFd (CompWatchFdHandle handle)
+CompDisplay::setWatchFdHandle (CompWatchFdHandle handle)
{
- CompWatchFd *p = 0, *w;
- int i;
+ priv->watchFdHandle = handle;
+}
- for (i = core.nWatchFds - 1, w = core.watchFds; w; i--, w = w->next)
+void
+CompDisplay::updateScreenInfo ()
+{
+ if (priv->xineramaExtension)
{
- if (w->handle == handle)
- break;
+ if (priv->screenInfo)
+ XFree (priv->screenInfo);
- p = w;
+ priv->nScreenInfo = 0;
+ priv->screenInfo = XineramaQueryScreens (priv->dpy, &priv->nScreenInfo);
}
+}
- if (w)
- {
- if (p)
- p->next = w->next;
- else
- core.watchFds = w->next;
+bool
+CompDisplay::addScreen (int screenNum)
+{
+ CompScreen *s, *prev;
+ Window rootDummy, childDummy;
+ int x, y, dummy;
+ unsigned int uDummy;
- core.nWatchFds--;
+ s = new CompScreen ();
+ if (!s)
+ return false;
- if (i < core.nWatchFds)
- memmove (&core.watchPollFds[i], &core.watchPollFds[i + 1],
- (core.nWatchFds - i) * sizeof (struct pollfd));
+ for (prev = priv->screens; prev && prev->next; prev = prev->next);
- free (w);
+ if (prev)
+ prev->next = s;
+ else
+ priv->screens = s;
+
+ if (!s->init (this, screenNum))
+ {
+ compLogMessage (this, "core", CompLogLevelError,
+ "Failed to manage screen: %d", screenNum);
+ if (prev)
+ prev->next = NULL;
+ else
+ priv->screens = NULL;
}
+
+ if (XQueryPointer (priv->dpy, XRootWindow (priv->dpy, screenNum),
+ &rootDummy, &childDummy,
+ &x, &y, &dummy, &dummy, &uDummy))
+ {
+ lastPointerX = pointerX = x;
+ lastPointerY = pointerY = y;
+ }
+ return true;
}
-short int
-compWatchFdEvents (CompWatchFdHandle handle)
+void
+CompDisplay::removeScreen (CompScreen *s)
{
- CompWatchFd *w;
- int i;
+ CompScreen *p;
+
+ for (p = priv->screens; p; p = p->next)
+ if (p->next == s)
+ break;
- for (i = core.nWatchFds - 1, w = core.watchFds; w; i--, w = w->next)
- if (w->handle == handle)
- return core.watchPollFds[i].revents;
+ if (p)
+ p->next = s->next;
+ else
+ priv->screens = NULL;
- return 0;
+ delete s;
}
-#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
-
-static int
-getTimeToNextRedraw (CompScreen *s,
- struct timeval *tv,
- struct timeval *lastTv,
- Bool idle)
+void
+PrivateDisplay::setAudibleBell (bool audible)
{
- int diff, next;
+ if (xkbExtension)
+ XkbChangeEnabledControls (dpy,
+ XkbUseCoreKbd,
+ XkbAudibleBellMask,
+ audible ? XkbAudibleBellMask : 0);
+}
- diff = TIMEVALDIFF (tv, lastTv);
+void
+PrivateDisplay::handlePingTimeout ()
+{
+ CompScreen *s;
+ CompWindow *w;
+ XEvent ev;
+ int ping = lastPing + 1;
- /* handle clock rollback */
- if (diff < 0)
- diff = 0;
+ ev.type = ClientMessage;
+ ev.xclient.window = 0;
+ ev.xclient.message_type = atoms.wmProtocols;
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = atoms.wmPing;
+ ev.xclient.data.l[1] = ping;
+ ev.xclient.data.l[2] = 0;
+ ev.xclient.data.l[3] = 0;
+ ev.xclient.data.l[4] = 0;
- if (idle ||
- (s->getVideoSync && s->opt[COMP_SCREEN_OPTION_SYNC_TO_VBLANK].value.b))
+ for (s = screens; s; s = s->next)
{
- if (s->timeMult > 1)
+ for (w = s->windows (); w; w = w->next)
{
- s->frameStatus = -1;
- s->redrawTime = s->optimalRedrawTime;
- s->timeMult--;
+ if (w->handlePingTimeout (lastPing))
+ {
+ ev.xclient.window = w->id ();
+ ev.xclient.data.l[2] = w->id ();
+
+ XSendEvent (dpy, w->id (), false, NoEventMask, &ev);
+ }
}
}
- else
- {
- if (diff > s->redrawTime)
+
+ lastPing = ping;
+}
+
+bool
+CompDisplay::setOption (const char *name,
+ CompOptionValue *value)
+{
+ CompOption *o;
+ int index;
+
+ o = compFindOption (priv->opt, NUM_OPTIONS (this),
+ name, &index);
+ if (!o)
+ return false;
+
+ switch (index) {
+ case COMP_DISPLAY_OPTION_ABI:
+ break;
+ case COMP_DISPLAY_OPTION_ACTIVE_PLUGINS:
+ if (compSetOptionList (o, value))
+ {
+ priv->dirtyPluginList = true;
+ return true;
+ }
+ break;
+ case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
+ if (compSetIntOption (o, value))
{
- if (s->frameStatus > 0)
- s->frameStatus = 0;
+ CompScreen *s;
- next = s->optimalRedrawTime * (s->timeMult + 1);
- if (diff > next)
- {
- s->frameStatus--;
- if (s->frameStatus < -1)
- {
- s->timeMult++;
- s->redrawTime = diff = next;
- }
- }
+ for (s = priv->screens; s; s = s->next)
+ s->damageScreen ();
+
+ if (!o->value.i)
+ priv->textureFilter = GL_NEAREST;
+ else
+ priv->textureFilter = GL_LINEAR;
+
+ return true;
}
- else if (diff < s->redrawTime)
+ break;
+ case COMP_DISPLAY_OPTION_PING_DELAY:
+ if (compSetIntOption (o, value))
{
- if (s->frameStatus < 0)
- s->frameStatus = 0;
+ if (priv->pingHandle)
+ core->removeTimeout (priv->pingHandle);
- if (s->timeMult > 1)
- {
- next = s->optimalRedrawTime * (s->timeMult - 1);
- if (diff < next)
- {
- s->frameStatus++;
- if (s->frameStatus > 4)
- {
- s->timeMult--;
- s->redrawTime = next;
- }
- }
- }
+ priv->pingHandle =
+ core->addTimeout (o->value.i, o->value.i + 500,
+ CompDisplay::pingTimeout, priv->dpy);
+ return true;
+ }
+ break;
+ case COMP_DISPLAY_OPTION_AUDIBLE_BELL:
+ if (compSetBoolOption (o, value))
+ {
+ priv->setAudibleBell (o->value.b);
+ return true;
}
+ break;
+ default:
+ if (compSetDisplayOption (this, o, value))
+ return true;
+ break;
}
- if (diff > s->redrawTime)
- return 0;
-
- return s->redrawTime - diff;
+ return false;
}
-static const int maskTable[] = {
- ShiftMask, LockMask, ControlMask, Mod1Mask,
- Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
-};
-static const int maskTableSize = sizeof (maskTable) / sizeof (int);
-
void
-updateModifierMappings (CompDisplay *d)
+CompDisplay::updateModifierMappings ()
{
unsigned int modMask[CompModNum];
int i, minKeycode, maxKeycode, keysymsPerKeycode = 0;
@@ -1272,38 +1435,38 @@ updateModifierMappings (CompDisplay *d)
for (i = 0; i < CompModNum; i++)
modMask[i] = 0;
- XDisplayKeycodes (d->display, &minKeycode, &maxKeycode);
- key = XGetKeyboardMapping (d->display,
+ XDisplayKeycodes (priv->dpy, &minKeycode, &maxKeycode);
+ key = XGetKeyboardMapping (priv->dpy,
minKeycode, (maxKeycode - minKeycode + 1),
&keysymsPerKeycode);
- if (d->modMap)
- XFreeModifiermap (d->modMap);
+ if (priv->modMap)
+ XFreeModifiermap (priv->modMap);
- d->modMap = XGetModifierMapping (d->display);
- if (d->modMap && d->modMap->max_keypermod > 0)
+ priv->modMap = XGetModifierMapping (priv->dpy);
+ if (priv->modMap && priv->modMap->max_keypermod > 0)
{
KeySym keysym;
int index, size, mask;
- size = maskTableSize * d->modMap->max_keypermod;
+ size = maskTableSize * priv->modMap->max_keypermod;
for (i = 0; i < size; i++)
{
- if (!d->modMap->modifiermap[i])
+ if (!priv->modMap->modifiermap[i])
continue;
index = 0;
do
{
- keysym = XKeycodeToKeysym (d->display,
- d->modMap->modifiermap[i],
+ keysym = XKeycodeToKeysym (priv->dpy,
+ priv->modMap->modifiermap[i],
index++);
} while (!keysym && index < keysymsPerKeycode);
if (keysym)
{
- mask = maskTable[i / d->modMap->max_keypermod];
+ mask = maskTable[i / priv->modMap->max_keypermod];
if (keysym == XK_Alt_L ||
keysym == XK_Alt_R)
@@ -1346,18 +1509,18 @@ updateModifierMappings (CompDisplay *d)
modMask[i] = CompNoMask;
}
- if (memcmp (modMask, d->modMask, sizeof (modMask)))
+ if (memcmp (modMask, priv->modMask, sizeof (modMask)))
{
CompScreen *s;
- memcpy (d->modMask, modMask, sizeof (modMask));
+ memcpy (priv->modMask, modMask, sizeof (modMask));
- d->ignoredModMask = LockMask |
+ priv->ignoredModMask = LockMask |
(modMask[CompModNumLock] & ~CompNoMask) |
(modMask[CompModScrollLock] & ~CompNoMask);
- for (s = d->screens; s; s = s->next)
- updatePassiveGrabs (s);
+ for (s = priv->screens; s; s = s->next)
+ s->updatePassiveGrabs ();
}
}
@@ -1366,8 +1529,7 @@ updateModifierMappings (CompDisplay *d)
}
unsigned int
-virtualToRealModMask (CompDisplay *d,
- unsigned int modMask)
+CompDisplay::virtualToRealModMask (unsigned int modMask)
{
int i;
@@ -1376,7 +1538,7 @@ virtualToRealModMask (CompDisplay *d,
if (modMask & virtualModMask[i])
{
modMask &= ~virtualModMask[i];
- modMask |= d->modMask[i];
+ modMask |= priv->modMask[i];
}
}
@@ -1384,18 +1546,17 @@ virtualToRealModMask (CompDisplay *d,
}
unsigned int
-keycodeToModifiers (CompDisplay *d,
- int keycode)
+CompDisplay::keycodeToModifiers (int keycode)
{
unsigned int mods = 0;
int mod, k;
for (mod = 0; mod < maskTableSize; mod++)
{
- for (k = 0; k < d->modMap->max_keypermod; k++)
+ for (k = 0; k < priv->modMap->max_keypermod; k++)
{
- if (d->modMap->modifiermap[mod * d->modMap->max_keypermod + k] ==
- keycode)
+ if (priv->modMap->modifiermap[mod *
+ priv->modMap->max_keypermod + k] == keycode)
mods |= maskTable[mod];
}
}
@@ -1403,1655 +1564,1197 @@ keycodeToModifiers (CompDisplay *d,
return mods;
}
-static int
-doPoll (int timeout)
+void
+CompDisplay::processEvents ()
{
- int rv;
-
- rv = poll (core.watchPollFds, core.nWatchFds, timeout);
- if (rv)
- {
- CompWatchFd *w;
- int i;
-
- for (i = core.nWatchFds - 1, w = core.watchFds; w; i--, w = w->next)
- {
- if (core.watchPollFds[i].revents != 0 && w->callBack)
- (*w->callBack) (w->closure);
- }
- }
+ XEvent event;
- return rv;
-}
+ if (priv->dirtyPluginList)
+ priv->updatePlugins ();
-static void
-handleTimeouts (struct timeval *tv)
-{
- CompTimeout *t;
- int timeDiff;
+ while (XPending (priv->dpy))
+ {
+ XNextEvent (priv->dpy, &event);
- timeDiff = TIMEVALDIFF (tv, &core.lastTimeout);
+ switch (event.type) {
+ case ButtonPress:
+ case ButtonRelease:
+ pointerX = event.xbutton.x_root;
+ pointerY = event.xbutton.y_root;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ pointerX = event.xkey.x_root;
+ pointerY = event.xkey.y_root;
+ break;
+ case MotionNotify:
+ pointerX = event.xmotion.x_root;
+ pointerY = event.xmotion.y_root;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ pointerX = event.xcrossing.x_root;
+ pointerY = event.xcrossing.y_root;
+ break;
+ case ClientMessage:
+ if (event.xclient.message_type == priv->atoms.xdndPosition)
+ {
+ pointerX = event.xclient.data.l[2] >> 16;
+ pointerY = event.xclient.data.l[2] & 0xffff;
+ }
+ default:
+ break;
+ }
- /* handle clock rollback */
- if (timeDiff < 0)
- timeDiff = 0;
+ sn_display_process_event (priv->snDisplay, &event);
- for (t = core.timeouts; t; t = t->next)
- {
- t->minLeft -= timeDiff;
- t->maxLeft -= timeDiff;
- }
+ inHandleEvent = true;
+ handleEvent (&event);
+ inHandleEvent = false;
- while (core.timeouts && core.timeouts->minLeft <= 0)
- {
- t = core.timeouts;
- if ((*t->callBack) (t->closure))
- {
- core.timeouts = t->next;
- addTimeout (t);
- }
- else
- {
- core.timeouts = t->next;
- free (t);
- }
+ lastPointerX = pointerX;
+ lastPointerY = pointerY;
}
-
- core.lastTimeout = *tv;
}
-static void
-waitForVideoSync (CompScreen *s)
+void
+PrivateDisplay::updatePlugins ()
{
- unsigned int sync;
+ CompOption *o;
+ CompPlugin *p, **pop = 0;
+ int nPop, i, j;
- if (!s->opt[COMP_SCREEN_OPTION_SYNC_TO_VBLANK].value.b)
- return;
+ dirtyPluginList = false;
- if (s->getVideoSync)
- {
- glFlush ();
+ o = &opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS];
- (*s->getVideoSync) (&sync);
- (*s->waitVideoSync) (2, (sync + 1) % 2, &sync);
- }
-}
+ /* The old plugin list always begins with the core plugin. To make sure
+ we don't unnecessarily unload plugins if the new plugin list does not
+ contain the core plugin, we have to use an offset */
+ if (o->value.list.nValue > 0 && strcmp (o->value.list.value[0].s, "core"))
+ i = 0;
+ else
+ i = 1;
+ /* j is initialized to 1 to make sure we never pop the core plugin */
+ for (j = 1; j < plugin.list.nValue &&
+ i < o->value.list.nValue; i++, j++)
+ {
+ if (strcmp (plugin.list.value[j].s, o->value.list.value[i].s))
+ break;
+ }
-void
-paintScreen (CompScreen *s,
- CompOutput *outputs,
- int numOutput,
- unsigned int mask)
-{
- XRectangle r;
- int i;
+ nPop = plugin.list.nValue - j;
- for (i = 0; i < numOutput; i++)
+ if (nPop)
{
- targetScreen = s;
- targetOutput = &outputs[i];
-
- r.x = outputs[i].region.extents.x1;
- r.y = s->height - outputs[i].region.extents.y2;
- r.width = outputs[i].width;
- r.height = outputs[i].height;
-
- if (s->lastViewport.x != r.x ||
- s->lastViewport.y != r.y ||
- s->lastViewport.width != r.width ||
- s->lastViewport.height != r.height)
- {
- glViewport (r.x, r.y, r.width, r.height);
- s->lastViewport = r;
- }
-
- if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
- {
- (*s->paintOutput) (s,
- &defaultScreenPaintAttrib,
- &identity,
- &outputs[i].region, &outputs[i],
- PAINT_SCREEN_REGION_MASK |
- PAINT_SCREEN_FULL_MASK);
- }
- else if (mask & COMP_SCREEN_DAMAGE_REGION_MASK)
+ pop = (CompPlugin **) malloc (sizeof (CompPlugin *) * nPop);
+ if (!pop)
{
- XIntersectRegion (core.tmpRegion,
- &outputs[i].region,
- core.outputRegion);
-
- if (!(*s->paintOutput) (s,
- &defaultScreenPaintAttrib,
- &identity,
- core.outputRegion, &outputs[i],
- PAINT_SCREEN_REGION_MASK))
- {
- (*s->paintOutput) (s,
- &defaultScreenPaintAttrib,
- &identity,
- &outputs[i].region, &outputs[i],
- PAINT_SCREEN_FULL_MASK);
-
- XUnionRegion (core.tmpRegion,
- &outputs[i].region,
- core.tmpRegion);
-
- }
+ core->setOptionForPlugin (display, "core", o->name, &plugin);
+ return;
}
}
-}
-void
-eventLoop (void)
-{
- XEvent event;
- int timeDiff;
- struct timeval tv;
- CompDisplay *d;
- CompScreen *s;
- CompWindow *w;
- CompTimeout *t;
- int time, timeToNextRedraw = 0;
- unsigned int damageMask, mask;
-
- for (d = core.displays; d; d = d->next)
- d->watchFdHandle =
- compAddWatchFd (ConnectionNumber (d->display), POLLIN, NULL, NULL);
-
- for (;;)
+ for (j = 0; j < nPop; j++)
{
- if (restartSignal || shutDown)
- break;
-
- for (d = core.displays; d; d = d->next)
- {
- if (d->dirtyPluginList)
- updatePlugins (d);
-
- while (XPending (d->display))
- {
- XNextEvent (d->display, &event);
-
- switch (event.type) {
- case ButtonPress:
- case ButtonRelease:
- pointerX = event.xbutton.x_root;
- pointerY = event.xbutton.y_root;
- break;
- case KeyPress:
- case KeyRelease:
- pointerX = event.xkey.x_root;
- pointerY = event.xkey.y_root;
- break;
- case MotionNotify:
- pointerX = event.xmotion.x_root;
- pointerY = event.xmotion.y_root;
- break;
- case EnterNotify:
- case LeaveNotify:
- pointerX = event.xcrossing.x_root;
- pointerY = event.xcrossing.y_root;
- break;
- case ClientMessage:
- if (event.xclient.message_type == d->xdndPositionAtom)
- {
- pointerX = event.xclient.data.l[2] >> 16;
- pointerY = event.xclient.data.l[2] & 0xffff;
- }
- default:
- break;
- }
-
- sn_display_process_event (d->snDisplay, &event);
-
- inHandleEvent = TRUE;
-
- (*d->handleEvent) (d, &event);
-
- inHandleEvent = FALSE;
-
- lastPointerX = pointerX;
- lastPointerY = pointerY;
- }
- }
+ pop[j] = popPlugin ();
+ plugin.list.nValue--;
+ free (plugin.list.value[plugin.list.nValue].s);
+ }
- for (d = core.displays; d; d = d->next)
+ for (; i < o->value.list.nValue; i++)
+ {
+ p = 0;
+ for (j = 0; j < nPop; j++)
{
- for (s = d->screens; s; s = s->next)
+ if (pop[j] && strcmp (pop[j]->vTable->name (),
+ o->value.list.value[i].s) == 0)
{
- if (s->damageMask)
- {
- finishScreenDrawing (s);
- }
- else
+ if (pushPlugin (pop[j]))
{
- s->idle = TRUE;
+ p = pop[j];
+ pop[j] = 0;
+ break;
}
}
}
- damageMask = 0;
- timeToNextRedraw = MAXSHORT;
-
- for (d = core.displays; d; d = d->next)
+ if (p == 0)
{
- for (s = d->screens; s; s = s->next)
+ p = loadPlugin (o->value.list.value[i].s);
+ if (p)
{
- if (!s->damageMask)
- continue;
-
- if (!damageMask)
+ if (!pushPlugin (p))
{
- gettimeofday (&tv, 0);
- damageMask |= s->damageMask;
+ unloadPlugin (p);
+ p = 0;
}
-
- s->timeLeft = getTimeToNextRedraw (s, &tv, &s->lastRedraw,
- s->idle);
- if (s->timeLeft < timeToNextRedraw)
- timeToNextRedraw = s->timeLeft;
}
}
- if (damageMask)
+ if (p)
{
- time = timeToNextRedraw;
- if (time)
- time = doPoll (time);
-
- if (time == 0)
- {
- gettimeofday (&tv, 0);
-
- if (core.timeouts)
- handleTimeouts (&tv);
+ CompOptionValue *value;
- for (d = core.displays; d; d = d->next)
- {
- for (s = d->screens; s; s = s->next)
- {
- if (!s->damageMask || s->timeLeft > timeToNextRedraw)
- continue;
-
- targetScreen = s;
-
- timeDiff = TIMEVALDIFF (&tv, &s->lastRedraw);
-
- /* handle clock rollback */
- if (timeDiff < 0)
- timeDiff = 0;
-
- makeScreenCurrent (s);
-
- if (s->slowAnimations)
- {
- (*s->preparePaintScreen) (s,
- s->idle ? 2 :
- (timeDiff * 2) /
- s->redrawTime);
- }
- else
- (*s->preparePaintScreen) (s,
- s->idle ? s->redrawTime :
- timeDiff);
-
- /* substract top most overlay window region */
- if (s->overlayWindowCount)
- {
- for (w = s->reverseWindows; w; w = w->prev)
- {
- if (w->destroyed || w->invisible)
- continue;
-
- if (!w->redirected)
- XSubtractRegion (s->damage, w->region,
- s->damage);
-
- break;
- }
-
- if (s->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
- {
- s->damageMask &= ~COMP_SCREEN_DAMAGE_ALL_MASK;
- s->damageMask |=
- COMP_SCREEN_DAMAGE_REGION_MASK;
- }
- }
-
- if (s->damageMask & COMP_SCREEN_DAMAGE_REGION_MASK)
- {
- XIntersectRegion (s->damage, &s->region,
- core.tmpRegion);
-
- if (core.tmpRegion->numRects == 1 &&
- core.tmpRegion->rects->x1 == 0 &&
- core.tmpRegion->rects->y1 == 0 &&
- core.tmpRegion->rects->x2 == s->width &&
- core.tmpRegion->rects->y2 == s->height)
- damageScreen (s);
- }
-
- EMPTY_REGION (s->damage);
-
- mask = s->damageMask;
- s->damageMask = 0;
-
- if (s->clearBuffers)
- {
- if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
- glClear (GL_COLOR_BUFFER_BIT);
- }
-
- if (s->opt[COMP_SCREEN_OPTION_FORCE_INDEPENDENT].value.b
- || !s->hasOverlappingOutputs)
- (*s->paintScreen) (s, s->outputDev,
- s->nOutputDev,
- mask);
- else
- (*s->paintScreen) (s, &s->fullscreenOutput, 1,
- mask);
-
- targetScreen = NULL;
- targetOutput = &s->outputDev[0];
-
- waitForVideoSync (s);
-
- if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
- {
- glXSwapBuffers (d->display, s->output);
- }
- else
- {
- BoxPtr pBox;
- int nBox, y;
-
- pBox = core.tmpRegion->rects;
- nBox = core.tmpRegion->numRects;
-
- if (s->copySubBuffer)
- {
- while (nBox--)
- {
- y = s->height - pBox->y2;
-
- (*s->copySubBuffer) (d->display,
- s->output,
- pBox->x1, y,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1);
-
- pBox++;
- }
- }
- else
- {
- glEnable (GL_SCISSOR_TEST);
- glDrawBuffer (GL_FRONT);
-
- while (nBox--)
- {
- y = s->height - pBox->y2;
-
- glBitmap (0, 0, 0, 0,
- pBox->x1 - s->rasterX,
- y - s->rasterY,
- NULL);
-
- s->rasterX = pBox->x1;
- s->rasterY = 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 ();
- }
- }
-
- s->lastRedraw = tv;
-
- (*s->donePaintScreen) (s);
-
- /* remove destroyed windows */
- while (s->pendingDestroys)
- {
- CompWindow *w;
-
- for (w = s->windows; w; w = w->next)
- {
- if (w->destroyed)
- {
- addWindowDamage (w);
- removeWindow (w);
- break;
- }
- }
-
- s->pendingDestroys--;
- }
-
- s->idle = FALSE;
- }
- }
- }
- }
- else
- {
- if (core.timeouts)
+ value = (CompOptionValue *)
+ realloc (plugin.list.value, sizeof (CompOptionValue) *
+ (plugin.list.nValue + 1));
+ if (value)
{
- if (core.timeouts->minLeft > 0)
- {
- t = core.timeouts;
- time = t->maxLeft;
- while (t && t->minLeft <= time)
- {
- if (t->maxLeft < time)
- time = t->maxLeft;
- t = t->next;
- }
- doPoll (time);
- }
-
- gettimeofday (&tv, 0);
+ value[plugin.list.nValue].s = strdup (p->vTable->name ());
- handleTimeouts (&tv);
+ plugin.list.value = value;
+ plugin.list.nValue++;
}
else
{
- doPoll (-1);
+ p = popPlugin ();
+ unloadPlugin (p);
}
}
}
- for (d = core.displays; d; d = d->next)
- compRemoveWatchFd (d->watchFdHandle);
-}
-
-static int errors = 0;
-
-static int
-errorHandler (Display *dpy,
- XErrorEvent *e)
-{
-
-#ifdef DEBUG
- char str[128];
-#endif
-
- errors++;
-
-#ifdef DEBUG
- XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);
- fprintf (stderr, "%s", str);
-
- XGetErrorText (dpy, e->error_code, str, 128);
- fprintf (stderr, ": %s\n ", str);
-
- XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "%d", str, 128);
- fprintf (stderr, str, e->request_code);
+ for (j = 0; j < nPop; j++)
+ {
+ if (pop[j])
+ unloadPlugin (pop[j]);
+ }
- sprintf (str, "%d", e->request_code);
- XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);
- if (strcmp (str, ""))
- fprintf (stderr, " (%s)", str);
- fprintf (stderr, "\n ");
+ if (nPop)
+ free (pop);
- XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);
- fprintf (stderr, str, e->minor_code);
- fprintf (stderr, "\n ");
+ core->setOptionForPlugin (display, "core", o->name, &plugin);
+}
- XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "%d", str, 128);
- fprintf (stderr, str, e->resourceid);
- fprintf (stderr, "\n");
+CompScreen *
+CompDisplay::findScreen (Window root)
+{
+ CompScreen *s;
- /* abort (); */
-#endif
+ for (s = priv->screens; s; s = s->next)
+ {
+ if (s->root () == root)
+ return s;
+ }
return 0;
}
-int
-compCheckForError (Display *dpy)
+void
+CompDisplay::forEachWindow (ForEachWindowProc proc,
+ void *closure)
{
- int e;
+ CompScreen *s;
- XSync (dpy, FALSE);
+ for (s = priv->screens; s; s = s->next)
+ s->forEachWindow (proc, closure);
+}
- e = errors;
- errors = 0;
+CompWindow *
+CompDisplay::findWindow (Window id)
+{
+ CompScreen *s;
+ CompWindow *w;
- return e;
+ for (s = priv->screens; s; s = s->next)
+ {
+ w = s->findWindow (id);
+ if (w)
+ return w;
+ }
+
+ return 0;
}
-/* add actions that should be automatically added as no screens
- existed when they were initialized. */
-static void
-addScreenActions (CompScreen *s)
+CompWindow *
+CompDisplay::findTopLevelWindow (Window id)
{
- int i;
+ CompScreen *s;
+ CompWindow *w;
- for (i = 0; i < COMP_DISPLAY_OPTION_NUM; i++)
+ for (s = priv->screens; s; s = s->next)
{
- if (!isActionOption (&s->display->opt[i]))
- continue;
-
- if (s->display->opt[i].value.action.state & CompActionStateAutoGrab)
- addScreenAction (s, &s->display->opt[i].value.action);
+ w = s->findTopLevelWindow (id);
+ if (w)
+ return w;
}
+
+ return 0;
}
-void
-addScreenToDisplay (CompDisplay *display,
- CompScreen *s)
+static CompScreen *
+findScreenForSelection (CompDisplay *display,
+ Window owner,
+ Atom selection)
{
- CompScreen *prev;
-
- for (prev = display->screens; prev && prev->next; prev = prev->next);
+ CompScreen *s;
- if (prev)
- prev->next = s;
- else
- display->screens = s;
+ for (s = display->screens(); s; s = s->next)
+ {
+ if (s->selectionWindow () == owner && s->selectionAtom () == selection)
+ return s;
+ }
- addScreenActions (s);
+ return NULL;
}
-static void
-freeDisplay (CompDisplay *d)
+/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
+static bool
+convertProperty (CompDisplay *display,
+ CompScreen *screen,
+ Window w,
+ Atom target,
+ Atom property)
{
- compFiniDisplayOptions (d, d->opt, COMP_DISPLAY_OPTION_NUM);
- compFiniOptionValue (&d->plugin, CompOptionTypeList);
+#define N_TARGETS 4
- if (d->modMap)
- XFreeModifiermap (d->modMap);
+ Atom conversionTargets[N_TARGETS];
+ long icccmVersion[] = { 2, 0 };
+ Time time = screen->selectionTimestamp ();
- if (d->screenInfo)
- XFree (d->screenInfo);
+ conversionTargets[0] = display->atoms().targets;
+ conversionTargets[1] = display->atoms().multiple;
+ conversionTargets[2] = display->atoms().timestamp;
+ conversionTargets[3] = display->atoms().version;
- if (d->screenPrivateIndices)
- free (d->screenPrivateIndices);
+ if (target == display->atoms().targets)
+ XChangeProperty (display->dpy(), w, property,
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) conversionTargets, N_TARGETS);
+ else if (target == display->atoms().timestamp)
+ XChangeProperty (display->dpy(), w, property,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &time, 1);
+ else if (target == display->atoms().version)
+ XChangeProperty (display->dpy(), w, property,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) icccmVersion, 2);
+ else
+ return false;
- if (d->base.privates)
- free (d->base.privates);
+ /* Be sure the PropertyNotify has arrived so we
+ * can send SelectionNotify
+ */
+ XSync (display->dpy (), FALSE);
- free (d);
+ return true;
}
-Bool
-addDisplay (const char *name)
+/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
+void
+PrivateDisplay::handleSelectionRequest (XEvent *event)
{
- CompDisplay *d;
- CompPrivate *privates;
- Display *dpy;
- Window focus;
- int revertTo, i;
- int compositeMajor, compositeMinor;
- int fixesMinor;
- int xkbOpcode;
- int firstScreen, lastScreen;
+ XSelectionEvent reply;
+ CompScreen *screen;
- d = (CompDisplay *) malloc (sizeof (CompDisplay));
- if (!d)
- return FALSE;
+ screen = findScreenForSelection (display,
+ event->xselectionrequest.owner,
+ event->xselectionrequest.selection);
+ if (!screen)
+ return;
- if (displayPrivateLen)
+ reply.type = SelectionNotify;
+ reply.display = dpy;
+ reply.requestor = event->xselectionrequest.requestor;
+ reply.selection = event->xselectionrequest.selection;
+ reply.target = event->xselectionrequest.target;
+ reply.property = None;
+ reply.time = event->xselectionrequest.time;
+
+ if (event->xselectionrequest.target == atoms.multiple)
{
- privates = (CompPrivate *) malloc (displayPrivateLen * sizeof (CompPrivate));
- if (!privates)
+ if (event->xselectionrequest.property != None)
{
- free (d);
- return FALSE;
- }
- }
- else
- privates = 0;
+ Atom type, *adata;
+ int i, format;
+ unsigned long num, rest;
+ unsigned char *data;
+
+ if (XGetWindowProperty (dpy,
+ event->xselectionrequest.requestor,
+ event->xselectionrequest.property,
+ 0, 256, FALSE,
+ atoms.atomPair,
+ &type, &format, &num, &rest,
+ &data) != Success)
+ return;
- compObjectInit (&d->base, privates, COMP_OBJECT_TYPE_DISPLAY);
+ /* FIXME: to be 100% correct, should deal with rest > 0,
+ * but since we have 4 possible targets, we will hardly ever
+ * meet multiple requests with a length > 8
+ */
+ adata = (Atom *) data;
+ i = 0;
+ while (i < (int) num)
+ {
+ if (!convertProperty (display, screen,
+ event->xselectionrequest.requestor,
+ adata[i], adata[i + 1]))
+ adata[i + 1] = None;
- d->next = NULL;
- d->screens = NULL;
+ i += 2;
+ }
- d->watchFdHandle = 0;
+ XChangeProperty (dpy,
+ event->xselectionrequest.requestor,
+ event->xselectionrequest.property,
+ atoms.atomPair,
+ 32, PropModeReplace, data, num);
+ }
+ }
+ else
+ {
+ if (event->xselectionrequest.property == None)
+ event->xselectionrequest.property = event->xselectionrequest.target;
- d->screenPrivateIndices = 0;
- d->screenPrivateLen = 0;
+ if (convertProperty (display, screen,
+ event->xselectionrequest.requestor,
+ event->xselectionrequest.target,
+ event->xselectionrequest.property))
+ reply.property = event->xselectionrequest.property;
+ }
- d->edgeDelayHandle = 0;
+ XSendEvent (dpy,
+ event->xselectionrequest.requestor,
+ FALSE, 0L, (XEvent *) &reply);
+}
- d->logMessage = logMessage;
+void
+PrivateDisplay::handleSelectionClear (XEvent *event)
+{
+ /* We need to unmanage the screen on which we lost the selection */
+ CompScreen *screen;
- d->modMap = 0;
+ screen = findScreenForSelection (display,
+ event->xselectionclear.window,
+ event->xselectionclear.selection);
- for (i = 0; i < CompModNum; i++)
- d->modMask[i] = CompNoMask;
+ if (screen)
+ shutDown = TRUE;
+}
- d->ignoredModMask = LockMask;
- compInitOptionValue (&d->plugin);
+void
+CompDisplay::clearTargetOutput (unsigned int mask)
+{
+ if (targetScreen)
+ targetScreen->clearOutput (targetOutput, mask);
+}
- d->plugin.list.type = CompOptionTypeString;
- d->plugin.list.nValue = 1;
- d->plugin.list.value = (CompOptionValue *) malloc (sizeof (CompOptionValue));
+#define HOME_IMAGEDIR ".compiz/images"
- if (!d->plugin.list.value) {
- free (d);
- return FALSE;
- }
+bool
+CompDisplay::readImageFromFile (const char *name,
+ int *width,
+ int *height,
+ void **data)
+{
+ Bool status;
+ int stride;
- d->plugin.list.value->s = strdup ("core");
- if (!d->plugin.list.value->s) {
- free (d->plugin.list.value);
- free (d);
- return FALSE;
- }
+ status = fileToImage (NULL, name, width, height, &stride, data);
+ if (!status)
+ {
+ char *home;
- d->dirtyPluginList = TRUE;
+ home = getenv ("HOME");
+ if (home)
+ {
+ char *path;
- d->textureFilter = GL_LINEAR;
- d->below = None;
+ path = (char *) malloc (strlen (home) + strlen (HOME_IMAGEDIR) + 2);
+ if (path)
+ {
+ sprintf (path, "%s/%s", home, HOME_IMAGEDIR);
+ status = fileToImage (path, name, width, height, &stride, data);
- d->activeWindow = 0;
+ free (path);
- d->autoRaiseHandle = 0;
- d->autoRaiseWindow = None;
+ if (status)
+ return TRUE;
+ }
+ }
- d->display = dpy = XOpenDisplay (name);
- if (!d->display)
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "Couldn't open display %s", XDisplayName (name));
- return FALSE;
+ status = fileToImage (IMAGEDIR, name, width, height, &stride, data);
}
- // d->connection = XGetXCBConnection (dpy);
+ return status;
+}
- if (!compInitDisplayOptionsFromMetadata (d,
- &coreMetadata,
- coreDisplayOptionInfo,
- d->opt,
- COMP_DISPLAY_OPTION_NUM))
- return FALSE;
+bool
+CompDisplay::writeImageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ void *data)
+{
+ return imageToFile (path, name, format, width, height, width * 4, data);
+}
- d->opt[COMP_DISPLAY_OPTION_ABI].value.i = CORE_ABIVERSION;
- snprintf (d->displayString, 255, "DISPLAY=%s", DisplayString (dpy));
+CompCursor *
+CompDisplay::findCursor ()
+{
+ CompScreen *s;
-#ifdef DEBUG
- XSynchronize (dpy, TRUE);
-#endif
+ for (s = priv->screens; s; s = s->next)
+ if (s->cursors ())
+ return s->cursors ();
- XSetErrorHandler (errorHandler);
+ return NULL;
+}
- updateModifierMappings (d);
+Window
+CompDisplay::getActiveWindow (Window root)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+ Window w = None;
- d->handleEvent = handleEvent;
- d->handleCompizEvent = handleCompizEvent;
+ result = XGetWindowProperty (priv->dpy, root,
+ priv->atoms.winActive, 0L, 1L, FALSE,
+ XA_WINDOW, &actual, &format,
+ &n, &left, &data);
- d->fileToImage = fileToImage;
- d->imageToFile = imageToFile;
+ if (result == Success && n && data)
+ {
+ memcpy (&w, data, sizeof (Window));
+ XFree (data);
+ }
- d->matchInitExp = matchInitExp;
- d->matchExpHandlerChanged = matchExpHandlerChanged;
- d->matchPropertyChanged = matchPropertyChanged;
+ return w;
+}
- d->supportedAtom = XInternAtom (dpy, "_NET_SUPPORTED", 0);
- d->supportingWmCheckAtom = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", 0);
+void
+PrivateDisplay::initAtoms ()
+{
+ atoms.supported = XInternAtom (dpy, "_NET_SUPPORTED", 0);
+ atoms.supportingWmCheck = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", 0);
- d->utf8StringAtom = XInternAtom (dpy, "UTF8_STRING", 0);
+ atoms.utf8String = XInternAtom (dpy, "UTF8_STRING", 0);
- d->wmNameAtom = XInternAtom (dpy, "_NET_WM_NAME", 0);
+ atoms.wmName = XInternAtom (dpy, "_NET_WM_NAME", 0);
- d->winTypeAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", 0);
- d->winTypeDesktopAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DESKTOP",
+ atoms.winType = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", 0);
+ atoms.winTypeDesktop = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DESKTOP",
0);
- d->winTypeDockAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", 0);
- d->winTypeToolbarAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR",
+ atoms.winTypeDock = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", 0);
+ atoms.winTypeToolbar = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR",
0);
- d->winTypeMenuAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_MENU", 0);
- d->winTypeUtilAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_UTILITY",
+ atoms.winTypeMenu = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_MENU", 0);
+ atoms.winTypeUtil = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_UTILITY",
0);
- d->winTypeSplashAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_SPLASH", 0);
- d->winTypeDialogAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DIALOG", 0);
- d->winTypeNormalAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NORMAL", 0);
+ atoms.winTypeSplash = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_SPLASH", 0);
+ atoms.winTypeDialog = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DIALOG", 0);
+ atoms.winTypeNormal = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NORMAL", 0);
- d->winTypeDropdownMenuAtom =
+ atoms.winTypeDropdownMenu =
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", 0);
- d->winTypePopupMenuAtom =
+ atoms.winTypePopupMenu =
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_POPUP_MENU", 0);
- d->winTypeTooltipAtom =
+ atoms.winTypeTooltip =
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLTIP", 0);
- d->winTypeNotificationAtom =
+ atoms.winTypeNotification =
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NOTIFICATION", 0);
- d->winTypeComboAtom =
+ atoms.winTypeCombo =
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_COMBO", 0);
- d->winTypeDndAtom =
+ atoms.winTypeDnd =
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DND", 0);
- d->winOpacityAtom = XInternAtom (dpy, "_NET_WM_WINDOW_OPACITY", 0);
- d->winBrightnessAtom = XInternAtom (dpy, "_NET_WM_WINDOW_BRIGHTNESS", 0);
- d->winSaturationAtom = XInternAtom (dpy, "_NET_WM_WINDOW_SATURATION", 0);
-
- d->winActiveAtom = XInternAtom (dpy, "_NET_ACTIVE_WINDOW", 0);
-
- d->winDesktopAtom = XInternAtom (dpy, "_NET_WM_DESKTOP", 0);
+ atoms.winOpacity = XInternAtom (dpy, "_NET_WM_WINDOW_OPACITY", 0);
+ atoms.winBrightness = XInternAtom (dpy, "_NET_WM_WINDOW_BRIGHTNESS", 0);
+ atoms.winSaturation = XInternAtom (dpy, "_NET_WM_WINDOW_SATURATION", 0);
- d->workareaAtom = XInternAtom (dpy, "_NET_WORKAREA", 0);
+ atoms.winActive = XInternAtom (dpy, "_NET_ACTIVE_WINDOW", 0);
+ atoms.winDesktop = XInternAtom (dpy, "_NET_WM_DESKTOP", 0);
+ atoms.workarea = XInternAtom (dpy, "_NET_WORKAREA", 0);
- d->desktopViewportAtom = XInternAtom (dpy, "_NET_DESKTOP_VIEWPORT", 0);
- d->desktopGeometryAtom = XInternAtom (dpy, "_NET_DESKTOP_GEOMETRY", 0);
- d->currentDesktopAtom = XInternAtom (dpy, "_NET_CURRENT_DESKTOP", 0);
- d->numberOfDesktopsAtom = XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", 0);
+ atoms.desktopViewport = XInternAtom (dpy, "_NET_DESKTOP_VIEWPORT", 0);
+ atoms.desktopGeometry = XInternAtom (dpy, "_NET_DESKTOP_GEOMETRY", 0);
+ atoms.currentDesktop = XInternAtom (dpy, "_NET_CURRENT_DESKTOP", 0);
+ atoms.numberOfDesktops = XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", 0);
- d->winStateAtom = XInternAtom (dpy, "_NET_WM_STATE", 0);
- d->winStateModalAtom =
+ atoms.winState = XInternAtom (dpy, "_NET_WM_STATE", 0);
+ atoms.winStateModal =
XInternAtom (dpy, "_NET_WM_STATE_MODAL", 0);
- d->winStateStickyAtom =
+ atoms.winStateSticky =
XInternAtom (dpy, "_NET_WM_STATE_STICKY", 0);
- d->winStateMaximizedVertAtom =
+ atoms.winStateMaximizedVert =
XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_VERT", 0);
- d->winStateMaximizedHorzAtom =
+ atoms.winStateMaximizedHorz =
XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", 0);
- d->winStateShadedAtom =
+ atoms.winStateShaded =
XInternAtom (dpy, "_NET_WM_STATE_SHADED", 0);
- d->winStateSkipTaskbarAtom =
+ atoms.winStateSkipTaskbar =
XInternAtom (dpy, "_NET_WM_STATE_SKIP_TASKBAR", 0);
- d->winStateSkipPagerAtom =
+ atoms.winStateSkipPager =
XInternAtom (dpy, "_NET_WM_STATE_SKIP_PAGER", 0);
- d->winStateHiddenAtom =
+ atoms.winStateHidden =
XInternAtom (dpy, "_NET_WM_STATE_HIDDEN", 0);
- d->winStateFullscreenAtom =
+ atoms.winStateFullscreen =
XInternAtom (dpy, "_NET_WM_STATE_FULLSCREEN", 0);
- d->winStateAboveAtom =
+ atoms.winStateAbove =
XInternAtom (dpy, "_NET_WM_STATE_ABOVE", 0);
- d->winStateBelowAtom =
+ atoms.winStateBelow =
XInternAtom (dpy, "_NET_WM_STATE_BELOW", 0);
- d->winStateDemandsAttentionAtom =
+ atoms.winStateDemandsAttention =
XInternAtom (dpy, "_NET_WM_STATE_DEMANDS_ATTENTION", 0);
- d->winStateDisplayModalAtom =
+ atoms.winStateDisplayModal =
XInternAtom (dpy, "_NET_WM_STATE_DISPLAY_MODAL", 0);
- d->winActionMoveAtom = XInternAtom (dpy, "_NET_WM_ACTION_MOVE", 0);
- d->winActionResizeAtom =
+ atoms.winActionMove = XInternAtom (dpy, "_NET_WM_ACTION_MOVE", 0);
+ atoms.winActionResize =
XInternAtom (dpy, "_NET_WM_ACTION_RESIZE", 0);
- d->winActionStickAtom =
+ atoms.winActionStick =
XInternAtom (dpy, "_NET_WM_ACTION_STICK", 0);
- d->winActionMinimizeAtom =
+ atoms.winActionMinimize =
XInternAtom (dpy, "_NET_WM_ACTION_MINIMIZE", 0);
- d->winActionMaximizeHorzAtom =
+ atoms.winActionMaximizeHorz =
XInternAtom (dpy, "_NET_WM_ACTION_MAXIMIZE_HORZ", 0);
- d->winActionMaximizeVertAtom =
+ atoms.winActionMaximizeVert =
XInternAtom (dpy, "_NET_WM_ACTION_MAXIMIZE_VERT", 0);
- d->winActionFullscreenAtom =
+ atoms.winActionFullscreen =
XInternAtom (dpy, "_NET_WM_ACTION_FULLSCREEN", 0);
- d->winActionCloseAtom =
+ atoms.winActionClose =
XInternAtom (dpy, "_NET_WM_ACTION_CLOSE", 0);
- d->winActionShadeAtom =
+ atoms.winActionShade =
XInternAtom (dpy, "_NET_WM_ACTION_SHADE", 0);
- d->winActionChangeDesktopAtom =
+ atoms.winActionChangeDesktop =
XInternAtom (dpy, "_NET_WM_ACTION_CHANGE_DESKTOP", 0);
- d->winActionAboveAtom =
+ atoms.winActionAbove =
XInternAtom (dpy, "_NET_WM_ACTION_ABOVE", 0);
- d->winActionBelowAtom =
+ atoms.winActionBelow =
XInternAtom (dpy, "_NET_WM_ACTION_BELOW", 0);
- d->wmAllowedActionsAtom = XInternAtom (dpy, "_NET_WM_ALLOWED_ACTIONS", 0);
+ atoms.wmAllowedActions = XInternAtom (dpy, "_NET_WM_ALLOWED_ACTIONS", 0);
- d->wmStrutAtom = XInternAtom (dpy, "_NET_WM_STRUT", 0);
- d->wmStrutPartialAtom = XInternAtom (dpy, "_NET_WM_STRUT_PARTIAL", 0);
+ atoms.wmStrut = XInternAtom (dpy, "_NET_WM_STRUT", 0);
+ atoms.wmStrutPartial = XInternAtom (dpy, "_NET_WM_STRUT_PARTIAL", 0);
- d->wmUserTimeAtom = XInternAtom (dpy, "_NET_WM_USER_TIME", 0);
+ atoms.wmUserTime = XInternAtom (dpy, "_NET_WM_USER_TIME", 0);
- d->wmIconAtom = XInternAtom (dpy,"_NET_WM_ICON", 0);
- d->wmIconGeometryAtom = XInternAtom (dpy, "_NET_WM_ICON_GEOMETRY", 0);
+ atoms.wmIcon = XInternAtom (dpy,"_NET_WM_ICON", 0);
+ atoms.wmIconGeometry = XInternAtom (dpy, "_NET_WM_ICON_GEOMETRY", 0);
- d->clientListAtom = XInternAtom (dpy, "_NET_CLIENT_LIST", 0);
- d->clientListStackingAtom =
+ atoms.clientList = XInternAtom (dpy, "_NET_CLIENT_LIST", 0);
+ atoms.clientListStacking =
XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", 0);
- d->frameExtentsAtom = XInternAtom (dpy, "_NET_FRAME_EXTENTS", 0);
- d->frameWindowAtom = XInternAtom (dpy, "_NET_FRAME_WINDOW", 0);
+ atoms.frameExtents = XInternAtom (dpy, "_NET_FRAME_EXTENTS", 0);
+ atoms.frameWindow = XInternAtom (dpy, "_NET_FRAME_WINDOW", 0);
- d->wmStateAtom = XInternAtom (dpy, "WM_STATE", 0);
- d->wmChangeStateAtom = XInternAtom (dpy, "WM_CHANGE_STATE", 0);
- d->wmProtocolsAtom = XInternAtom (dpy, "WM_PROTOCOLS", 0);
- d->wmClientLeaderAtom = XInternAtom (dpy, "WM_CLIENT_LEADER", 0);
+ atoms.wmState = XInternAtom (dpy, "WM_STATE", 0);
+ atoms.wmChangeState = XInternAtom (dpy, "WM_CHANGE_STATE", 0);
+ atoms.wmProtocols = XInternAtom (dpy, "WM_PROTOCOLS", 0);
+ atoms.wmClientLeader = XInternAtom (dpy, "WM_CLIENT_LEADER", 0);
- d->wmDeleteWindowAtom = XInternAtom (dpy, "WM_DELETE_WINDOW", 0);
- d->wmTakeFocusAtom = XInternAtom (dpy, "WM_TAKE_FOCUS", 0);
- d->wmPingAtom = XInternAtom (dpy, "_NET_WM_PING", 0);
- d->wmSyncRequestAtom = XInternAtom (dpy, "_NET_WM_SYNC_REQUEST", 0);
+ atoms.wmDeleteWindow = XInternAtom (dpy, "WM_DELETE_WINDOW", 0);
+ atoms.wmTakeFocus = XInternAtom (dpy, "WM_TAKE_FOCUS", 0);
+ atoms.wmPing = XInternAtom (dpy, "_NET_WM_PING", 0);
+ atoms.wmSyncRequest = XInternAtom (dpy, "_NET_WM_SYNC_REQUEST", 0);
- d->wmSyncRequestCounterAtom =
+ atoms.wmSyncRequestCounter =
XInternAtom (dpy, "_NET_WM_SYNC_REQUEST_COUNTER", 0);
- d->closeWindowAtom = XInternAtom (dpy, "_NET_CLOSE_WINDOW", 0);
- d->wmMoveResizeAtom = XInternAtom (dpy, "_NET_WM_MOVERESIZE", 0);
- d->moveResizeWindowAtom = XInternAtom (dpy, "_NET_MOVERESIZE_WINDOW", 0);
- d->restackWindowAtom = XInternAtom (dpy, "_NET_RESTACK_WINDOW", 0);
+ atoms.closeWindow = XInternAtom (dpy, "_NET_CLOSE_WINDOW", 0);
+ atoms.wmMoveResize = XInternAtom (dpy, "_NET_WM_MOVERESIZE", 0);
+ atoms.moveResizeWindow = XInternAtom (dpy, "_NET_MOVERESIZE_WINDOW", 0);
+ atoms.restackWindow = XInternAtom (dpy, "_NET_RESTACK_WINDOW", 0);
- d->showingDesktopAtom = XInternAtom (dpy, "_NET_SHOWING_DESKTOP", 0);
+ atoms.showingDesktop = XInternAtom (dpy, "_NET_SHOWING_DESKTOP", 0);
- d->xBackgroundAtom[0] = XInternAtom (dpy, "_XSETROOT_ID", 0);
- d->xBackgroundAtom[1] = XInternAtom (dpy, "_XROOTPMAP_ID", 0);
+ atoms.xBackground[0] = XInternAtom (dpy, "_XSETROOT_ID", 0);
+ atoms.xBackground[1] = XInternAtom (dpy, "_XROOTPMAP_ID", 0);
- d->toolkitActionAtom =
+ atoms.toolkitAction =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", 0);
- d->toolkitActionMainMenuAtom =
+ atoms.toolkitActionMainMenu =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_MAIN_MENU", 0);
- d->toolkitActionRunDialogAtom =
+ atoms.toolkitActionRunDialog =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_RUN_DIALOG", 0);
- d->toolkitActionWindowMenuAtom =
+ atoms.toolkitActionWindowMenu =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", 0);
- d->toolkitActionForceQuitDialogAtom =
+ atoms.toolkitActionForceQuitDialog =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG", 0);
- d->mwmHintsAtom = XInternAtom (dpy, "_MOTIF_WM_HINTS", 0);
-
- d->xdndAwareAtom = XInternAtom (dpy, "XdndAware", 0);
- d->xdndEnterAtom = XInternAtom (dpy, "XdndEnter", 0);
- d->xdndLeaveAtom = XInternAtom (dpy, "XdndLeave", 0);
- d->xdndPositionAtom = XInternAtom (dpy, "XdndPosition", 0);
- d->xdndStatusAtom = XInternAtom (dpy, "XdndStatus", 0);
- d->xdndDropAtom = XInternAtom (dpy, "XdndDrop", 0);
-
- d->managerAtom = XInternAtom (dpy, "MANAGER", 0);
- d->targetsAtom = XInternAtom (dpy, "TARGETS", 0);
- d->multipleAtom = XInternAtom (dpy, "MULTIPLE", 0);
- d->timestampAtom = XInternAtom (dpy, "TIMESTAMP", 0);
- d->versionAtom = XInternAtom (dpy, "VERSION", 0);
- d->atomPairAtom = XInternAtom (dpy, "ATOM_PAIR", 0);
+ atoms.mwmHints = XInternAtom (dpy, "_MOTIF_WM_HINTS", 0);
- d->startupIdAtom = XInternAtom (dpy, "_NET_STARTUP_ID", 0);
+ atoms.xdndAware = XInternAtom (dpy, "XdndAware", 0);
+ atoms.xdndEnter = XInternAtom (dpy, "XdndEnter", 0);
+ atoms.xdndLeave = XInternAtom (dpy, "XdndLeave", 0);
+ atoms.xdndPosition = XInternAtom (dpy, "XdndPosition", 0);
+ atoms.xdndStatus = XInternAtom (dpy, "XdndStatus", 0);
+ atoms.xdndDrop = XInternAtom (dpy, "XdndDrop", 0);
- d->snDisplay = sn_display_new (dpy, NULL, NULL);
- if (!d->snDisplay)
- return FALSE;
+ atoms.manager = XInternAtom (dpy, "MANAGER", 0);
+ atoms.targets = XInternAtom (dpy, "TARGETS", 0);
+ atoms.multiple = XInternAtom (dpy, "MULTIPLE", 0);
+ atoms.timestamp = XInternAtom (dpy, "TIMESTAMP", 0);
+ atoms.version = XInternAtom (dpy, "VERSION", 0);
+ atoms.atomPair = XInternAtom (dpy, "ATOM_PAIR", 0);
- d->lastPing = 1;
+ atoms.startupId = XInternAtom (dpy, "_NET_STARTUP_ID", 0);
+}
- if (!XQueryExtension (dpy,
- COMPOSITE_NAME,
- &d->compositeOpcode,
- &d->compositeEvent,
- &d->compositeError))
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "No composite extension");
- return FALSE;
- }
+bool
+CompDisplay::fileToImage (const char *path,
+ const char *name,
+ int *width,
+ int *height,
+ int *stride,
+ void **data)
+{
+ WRAPABLE_HND_FUNC_RETURN(bool, fileToImage, path, name, width, height,
+ stride, data)
+ return false;
+}
- XCompositeQueryVersion (dpy, &compositeMajor, &compositeMinor);
- if (compositeMajor == 0 && compositeMinor < 2)
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "Old composite extension");
- return FALSE;
- }
+bool
+CompDisplay::imageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ int stride,
+ void *data)
+{
+ WRAPABLE_HND_FUNC_RETURN(bool, imageToFile, path, name, format, width,
+ height, stride, data)
+ return false;
+}
- if (!XDamageQueryExtension (dpy, &d->damageEvent, &d->damageError))
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "No damage extension");
- return FALSE;
+void
+CompDisplay::logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+{
+ WRAPABLE_HND_FUNC(logMessage, componentName, level, message)
+ compLogMessage (NULL, componentName, level, message);
+}
+
+const char *
+logLevelToString (CompLogLevel level)
+{
+ switch (level) {
+ case CompLogLevelFatal:
+ return "Fatal";
+ case CompLogLevelError:
+ return "Error";
+ case CompLogLevelWarn:
+ return "Warn";
+ case CompLogLevelInfo:
+ return "Info";
+ case CompLogLevelDebug:
+ return "Debug";
+ default:
+ break;
}
- if (!XSyncQueryExtension (dpy, &d->syncEvent, &d->syncError))
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "No sync extension");
- return FALSE;
- }
+ return "Unknown";
+}
- if (!XFixesQueryExtension (dpy, &d->fixesEvent, &d->fixesError))
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "No fixes extension");
- return FALSE;
- }
+static void
+logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+{
+ fprintf (stderr, "%s (%s) - %s: %s\n",
+ programName, componentName,
+ logLevelToString (level), message);
+}
- XFixesQueryVersion (dpy, &d->fixesVersion, &fixesMinor);
- /*
- if (d->fixesVersion < 5)
- {
- fprintf (stderr, "%s: Need fixes extension version 5 or later "
- "for client-side cursor\n", programName);
- }
- */
+void
+compLogMessage (CompDisplay *d,
+ const char *componentName,
+ CompLogLevel level,
+ const char *format,
+ ...)
+{
+ va_list args;
+ char message[2048];
- d->randrExtension = XRRQueryExtension (dpy,
- &d->randrEvent,
- &d->randrError);
+ va_start (args, format);
- d->shapeExtension = XShapeQueryExtension (dpy,
- &d->shapeEvent,
- &d->shapeError);
+ vsnprintf (message, 2048, format, args);
- d->xkbExtension = XkbQueryExtension (dpy,
- &xkbOpcode,
- &d->xkbEvent,
- &d->xkbError,
- NULL, NULL);
- if (d->xkbExtension)
- {
- XkbSelectEvents (dpy,
- XkbUseCoreKbd,
- XkbBellNotifyMask | XkbStateNotifyMask,
- XkbAllEventsMask);
- }
+ if (d)
+ d->logMessage (componentName, level, message);
else
- {
- compLogMessage (d, "core", CompLogLevelFatal,
- "No XKB extension");
-
- d->xkbEvent = d->xkbError = -1;
- }
-
- d->screenInfo = NULL;
- d->nScreenInfo = 0;
-
- d->xineramaExtension = XineramaQueryExtension (dpy,
- &d->xineramaEvent,
- &d->xineramaError);
+ logMessage (componentName, level, message);
- if (d->xineramaExtension)
- d->screenInfo = XineramaQueryScreens (dpy, &d->nScreenInfo);
-
- d->escapeKeyCode = XKeysymToKeycode (dpy, XStringToKeysym ("Escape"));
- d->returnKeyCode = XKeysymToKeycode (dpy, XStringToKeysym ("Return"));
-
- addDisplayToCore (d);
+ va_end (args);
+}
- /* TODO: bailout properly when objectInitPlugins fails */
- assert (objectInitPlugins (&d->base));
+int
+CompDisplay::getWmState (Window id)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+ unsigned long state = NormalState;
- (*core.objectAdd) (&core.base, &d->base);
+ result = XGetWindowProperty (priv->dpy, id,
+ priv->atoms.wmState, 0L, 2L, FALSE,
+ priv->atoms.wmState, &actual, &format,
+ &n, &left, &data);
- if (onlyCurrentScreen)
- {
- firstScreen = DefaultScreen (dpy);
- lastScreen = DefaultScreen (dpy);
- }
- else
+ if (result == Success && n && data)
{
- firstScreen = 0;
- lastScreen = ScreenCount (dpy) - 1;
+ memcpy (&state, data, sizeof (unsigned long));
+ XFree ((void *) data);
}
- for (i = firstScreen; i <= lastScreen; i++)
- {
- Window newWmSnOwner = None, newCmSnOwner = None;
- Atom wmSnAtom = 0, cmSnAtom = 0;
- Time wmSnTimestamp = 0;
- XEvent event;
- XSetWindowAttributes attr;
- Window currentWmSnOwner, currentCmSnOwner;
- char buf[128];
- Window rootDummy, childDummy;
- unsigned int uDummy;
- int x, y, dummy;
-
- sprintf (buf, "WM_S%d", i);
- wmSnAtom = XInternAtom (dpy, buf, 0);
-
- currentWmSnOwner = XGetSelectionOwner (dpy, wmSnAtom);
-
- if (currentWmSnOwner != None)
- {
- if (!replaceCurrentWm)
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Screen %d on display \"%s\" already "
- "has a window manager; try using the "
- "--replace option to replace the current "
- "window manager.",
- i, DisplayString (dpy));
-
- continue;
- }
-
- XSelectInput (dpy, currentWmSnOwner,
- StructureNotifyMask);
- }
-
- sprintf (buf, "_NET_WM_CM_S%d", i);
- cmSnAtom = XInternAtom (dpy, buf, 0);
-
- currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom);
-
- if (currentCmSnOwner != None)
- {
- if (!replaceCurrentWm)
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Screen %d on display \"%s\" already "
- "has a compositing manager; try using the "
- "--replace option to replace the current "
- "compositing manager.",
- i, DisplayString (dpy));
-
- continue;
- }
- }
-
- attr.override_redirect = TRUE;
- attr.event_mask = PropertyChangeMask;
-
- newCmSnOwner = newWmSnOwner =
- XCreateWindow (dpy, XRootWindow (dpy, i),
- -100, -100, 1, 1, 0,
- CopyFromParent, CopyFromParent,
- CopyFromParent,
- CWOverrideRedirect | CWEventMask,
- &attr);
-
- XChangeProperty (dpy,
- newWmSnOwner,
- d->wmNameAtom,
- d->utf8StringAtom, 8,
- PropModeReplace,
- (unsigned char *) PACKAGE,
- strlen (PACKAGE));
-
- XWindowEvent (dpy,
- newWmSnOwner,
- PropertyChangeMask,
- &event);
-
- wmSnTimestamp = event.xproperty.time;
-
- XSetSelectionOwner (dpy, wmSnAtom, newWmSnOwner, wmSnTimestamp);
-
- if (XGetSelectionOwner (dpy, wmSnAtom) != newWmSnOwner)
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Could not acquire window manager "
- "selection on screen %d display \"%s\"",
- i, DisplayString (dpy));
-
- XDestroyWindow (dpy, newWmSnOwner);
-
- continue;
- }
-
- /* Send client message indicating that we are now the WM */
- event.xclient.type = ClientMessage;
- event.xclient.window = XRootWindow (dpy, i);
- event.xclient.message_type = d->managerAtom;
- event.xclient.format = 32;
- event.xclient.data.l[0] = wmSnTimestamp;
- event.xclient.data.l[1] = wmSnAtom;
- event.xclient.data.l[2] = 0;
- event.xclient.data.l[3] = 0;
- event.xclient.data.l[4] = 0;
-
- XSendEvent (dpy, XRootWindow (dpy, i), FALSE,
- StructureNotifyMask, &event);
-
- /* Wait for old window manager to go away */
- if (currentWmSnOwner != None)
- {
- do {
- XWindowEvent (dpy, currentWmSnOwner,
- StructureNotifyMask, &event);
- } while (event.type != DestroyNotify);
- }
-
- compCheckForError (dpy);
-
- XCompositeRedirectSubwindows (dpy, XRootWindow (dpy, i),
- CompositeRedirectManual);
-
- if (compCheckForError (dpy))
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Another composite manager is already "
- "running on screen: %d", i);
+ return state;
+}
- continue;
- }
+void
+CompDisplay::setWmState (int state, Window id)
+{
+ unsigned long data[2];
- XSetSelectionOwner (dpy, cmSnAtom, newCmSnOwner, wmSnTimestamp);
+ data[0] = state;
+ data[1] = None;
- if (XGetSelectionOwner (dpy, cmSnAtom) != newCmSnOwner)
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Could not acquire compositing manager "
- "selection on screen %d display \"%s\"",
- i, DisplayString (dpy));
+ XChangeProperty (priv->dpy, id,
+ priv->atoms.wmState, priv->atoms.wmState,
+ 32, PropModeReplace, (unsigned char *) data, 2);
+}
- continue;
- }
+unsigned int
+CompDisplay::windowStateMask (Atom state)
+{
+ if (state == priv->atoms.winStateModal)
+ return CompWindowStateModalMask;
+ else if (state == priv->atoms.winStateSticky)
+ return CompWindowStateStickyMask;
+ else if (state == priv->atoms.winStateMaximizedVert)
+ return CompWindowStateMaximizedVertMask;
+ else if (state == priv->atoms.winStateMaximizedHorz)
+ return CompWindowStateMaximizedHorzMask;
+ else if (state == priv->atoms.winStateShaded)
+ return CompWindowStateShadedMask;
+ else if (state == priv->atoms.winStateSkipTaskbar)
+ return CompWindowStateSkipTaskbarMask;
+ else if (state == priv->atoms.winStateSkipPager)
+ return CompWindowStateSkipPagerMask;
+ else if (state == priv->atoms.winStateHidden)
+ return CompWindowStateHiddenMask;
+ else if (state == priv->atoms.winStateFullscreen)
+ return CompWindowStateFullscreenMask;
+ else if (state == priv->atoms.winStateAbove)
+ return CompWindowStateAboveMask;
+ else if (state == priv->atoms.winStateBelow)
+ return CompWindowStateBelowMask;
+ else if (state == priv->atoms.winStateDemandsAttention)
+ return CompWindowStateDemandsAttentionMask;
+ else if (state == priv->atoms.winStateDisplayModal)
+ return CompWindowStateDisplayModalMask;
- XGrabServer (dpy);
-
- XSelectInput (dpy, XRootWindow (dpy, i),
- SubstructureRedirectMask |
- SubstructureNotifyMask |
- StructureNotifyMask |
- PropertyChangeMask |
- LeaveWindowMask |
- EnterWindowMask |
- KeyPressMask |
- KeyReleaseMask |
- ButtonPressMask |
- ButtonReleaseMask |
- FocusChangeMask |
- ExposureMask);
-
- if (compCheckForError (dpy))
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Another window manager is "
- "already running on screen: %d", i);
+ return 0;
+}
- XUngrabServer (dpy);
- continue;
- }
+unsigned int
+CompDisplay::windowStateFromString (const char *str)
+{
+ if (strcasecmp (str, "modal") == 0)
+ return CompWindowStateModalMask;
+ else if (strcasecmp (str, "sticky") == 0)
+ return CompWindowStateStickyMask;
+ else if (strcasecmp (str, "maxvert") == 0)
+ return CompWindowStateMaximizedVertMask;
+ else if (strcasecmp (str, "maxhorz") == 0)
+ return CompWindowStateMaximizedHorzMask;
+ else if (strcasecmp (str, "shaded") == 0)
+ return CompWindowStateShadedMask;
+ else if (strcasecmp (str, "skiptaskbar") == 0)
+ return CompWindowStateSkipTaskbarMask;
+ else if (strcasecmp (str, "skippager") == 0)
+ return CompWindowStateSkipPagerMask;
+ else if (strcasecmp (str, "hidden") == 0)
+ return CompWindowStateHiddenMask;
+ else if (strcasecmp (str, "fullscreen") == 0)
+ return CompWindowStateFullscreenMask;
+ else if (strcasecmp (str, "above") == 0)
+ return CompWindowStateAboveMask;
+ else if (strcasecmp (str, "below") == 0)
+ return CompWindowStateBelowMask;
+ else if (strcasecmp (str, "demandsattention") == 0)
+ return CompWindowStateDemandsAttentionMask;
- if (!addScreen (d, i, newWmSnOwner, wmSnAtom, wmSnTimestamp))
- {
- compLogMessage (d, "core", CompLogLevelError,
- "Failed to manage screen: %d", i);
- }
+ return 0;
+}
- if (XQueryPointer (dpy, XRootWindow (dpy, i),
- &rootDummy, &childDummy,
- &x, &y, &dummy, &dummy, &uDummy))
- {
- lastPointerX = pointerX = x;
- lastPointerY = pointerY = y;
- }
+unsigned int
+CompDisplay::getWindowState (Window id)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+ unsigned int state = 0;
- XUngrabServer (dpy);
- }
+ result = XGetWindowProperty (priv->dpy, id,
+ priv->atoms.winState,
+ 0L, 1024L, FALSE, XA_ATOM, &actual, &format,
+ &n, &left, &data);
- if (!d->screens)
+ if (result == Success && data)
{
- compLogMessage (d, "core", CompLogLevelFatal,
- "No manageable screens found on display %s",
- XDisplayName (name));
- return FALSE;
- }
-
- setAudibleBell (d, d->opt[COMP_DISPLAY_OPTION_AUDIBLE_BELL].value.b);
-
- XGetInputFocus (dpy, &focus, &revertTo);
-
- /* move input focus to root window so that we get a FocusIn event when
- moving it to the default window */
- XSetInputFocus (dpy, d->screens->root, RevertToPointerRoot, CurrentTime);
+ Atom *a = (Atom *) data;
- if (focus == None || focus == PointerRoot)
- {
- focusDefaultWindow (d->screens);
- }
- else
- {
- CompWindow *w;
+ while (n--)
+ state |= windowStateMask (*a++);
- w = findWindowAtDisplay (d, focus);
- if (w)
- {
- moveInputFocusToWindow (w);
- }
- else
- focusDefaultWindow (d->screens);
+ XFree ((void *) data);
}
- d->pingHandle =
- compAddTimeout (d->opt[COMP_DISPLAY_OPTION_PING_DELAY].value.i,
- d->opt[COMP_DISPLAY_OPTION_PING_DELAY].value.i + 500,
- pingTimeout, d);
-
- return TRUE;
+ return state;
}
void
-removeDisplay (CompDisplay *d)
-{
- CompDisplay *p;
-
- for (p = core.displays; p; p = p->next)
- if (p->next == d)
- break;
-
- if (p)
- p->next = d->next;
- else
- core.displays = NULL;
-
- while (d->screens)
- removeScreen (d->screens);
-
- (*core.objectRemove) (&core.base, &d->base);
-
- objectFiniPlugins (&d->base);
-
- compRemoveTimeout (d->pingHandle);
-
- if (d->snDisplay)
- sn_display_unref (d->snDisplay);
-
- XSync (d->display, False);
- XCloseDisplay (d->display);
-
- freeDisplay (d);
+CompDisplay::setWindowState (unsigned int state,
+ Window id)
+{
+ Atom data[32];
+ int i = 0;
+
+ if (state & CompWindowStateModalMask)
+ data[i++] = priv->atoms.winStateModal;
+ if (state & CompWindowStateStickyMask)
+ data[i++] = priv->atoms.winStateSticky;
+ if (state & CompWindowStateMaximizedVertMask)
+ data[i++] = priv->atoms.winStateMaximizedVert;
+ if (state & CompWindowStateMaximizedHorzMask)
+ data[i++] = priv->atoms.winStateMaximizedHorz;
+ if (state & CompWindowStateShadedMask)
+ data[i++] = priv->atoms.winStateShaded;
+ if (state & CompWindowStateSkipTaskbarMask)
+ data[i++] = priv->atoms.winStateSkipTaskbar;
+ if (state & CompWindowStateSkipPagerMask)
+ data[i++] = priv->atoms.winStateSkipPager;
+ if (state & CompWindowStateHiddenMask)
+ data[i++] = priv->atoms.winStateHidden;
+ if (state & CompWindowStateFullscreenMask)
+ data[i++] = priv->atoms.winStateFullscreen;
+ if (state & CompWindowStateAboveMask)
+ data[i++] = priv->atoms.winStateAbove;
+ if (state & CompWindowStateBelowMask)
+ data[i++] = priv->atoms.winStateBelow;
+ if (state & CompWindowStateDemandsAttentionMask)
+ data[i++] = priv->atoms.winStateDemandsAttention;
+ if (state & CompWindowStateDisplayModalMask)
+ data[i++] = priv->atoms.winStateDisplayModal;
+
+ XChangeProperty (priv->dpy, id, priv->atoms.winState,
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) data, i);
}
-Time
-getCurrentTimeFromDisplay (CompDisplay *d)
+unsigned int
+CompDisplay::getWindowType (Window id)
{
- XEvent event;
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
- XChangeProperty (d->display, d->screens->grabWindow,
- XA_PRIMARY, XA_STRING, 8,
- PropModeAppend, NULL, 0);
- XWindowEvent (d->display, d->screens->grabWindow,
- PropertyChangeMask,
- &event);
+ result = XGetWindowProperty (priv->dpy , id,
+ priv->atoms.winType,
+ 0L, 1L, FALSE, XA_ATOM, &actual, &format,
+ &n, &left, &data);
- return event.xproperty.time;
-}
-
-CompScreen *
-findScreenAtDisplay (CompDisplay *d,
- Window root)
-{
- CompScreen *s;
-
- for (s = d->screens; s; s = s->next)
+ if (result == Success && n && data)
{
- if (s->root == root)
- return s;
- }
-
- return 0;
+ Atom a;
+
+ memcpy (&a, data, sizeof (Atom));
+ XFree ((void *) data);
+
+ if (a == priv->atoms.winTypeNormal)
+ return CompWindowTypeNormalMask;
+ else if (a == priv->atoms.winTypeMenu)
+ return CompWindowTypeMenuMask;
+ else if (a == priv->atoms.winTypeDesktop)
+ return CompWindowTypeDesktopMask;
+ else if (a == priv->atoms.winTypeDock)
+ return CompWindowTypeDockMask;
+ else if (a == priv->atoms.winTypeToolbar)
+ return CompWindowTypeToolbarMask;
+ else if (a == priv->atoms.winTypeUtil)
+ return CompWindowTypeUtilMask;
+ else if (a == priv->atoms.winTypeSplash)
+ return CompWindowTypeSplashMask;
+ else if (a == priv->atoms.winTypeDialog)
+ return CompWindowTypeDialogMask;
+ else if (a == priv->atoms.winTypeDropdownMenu)
+ return CompWindowTypeDropdownMenuMask;
+ else if (a == priv->atoms.winTypePopupMenu)
+ return CompWindowTypePopupMenuMask;
+ else if (a == priv->atoms.winTypeTooltip)
+ return CompWindowTypeTooltipMask;
+ else if (a == priv->atoms.winTypeNotification)
+ return CompWindowTypeNotificationMask;
+ else if (a == priv->atoms.winTypeCombo)
+ return CompWindowTypeComboMask;
+ else if (a == priv->atoms.winTypeDnd)
+ return CompWindowTypeDndMask;
+ }
+
+ return CompWindowTypeUnknownMask;
}
void
-forEachWindowOnDisplay (CompDisplay *display,
- ForEachWindowProc proc,
- void *closure)
+CompDisplay::getMwmHints (Window id,
+ unsigned int *func,
+ unsigned int *decor)
{
- CompScreen *s;
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
- for (s = display->screens; s; s = s->next)
- forEachWindowOnScreen (s, proc, closure);
-}
+ *func = MwmFuncAll;
+ *decor = MwmDecorAll;
-CompWindow *
-findWindowAtDisplay (CompDisplay *d,
- Window id)
-{
- CompScreen *s;
- CompWindow *w;
+ result = XGetWindowProperty (priv->dpy, id,
+ priv->atoms.mwmHints,
+ 0L, 20L, FALSE, priv->atoms.mwmHints,
+ &actual, &format, &n, &left, &data);
- for (s = d->screens; s; s = s->next)
+ if (result == Success && n && data)
{
- w = findWindowAtScreen (s, id);
- if (w)
- return w;
- }
+ MwmHints *mwmHints = (MwmHints *) data;
- return 0;
-}
+ if (n >= PropMotifWmHintElements)
+ {
+ if (mwmHints->flags & MwmHintsDecorations)
+ *decor = mwmHints->decorations;
-CompWindow *
-findTopLevelWindowAtDisplay (CompDisplay *d,
- Window id)
-{
- CompScreen *s;
- CompWindow *w;
+ if (mwmHints->flags & MwmHintsFunctions)
+ *func = mwmHints->functions;
+ }
- for (s = d->screens; s; s = s->next)
- {
- w = findTopLevelWindowAtScreen (s, id);
- if (w)
- return w;
+ XFree (data);
}
-
- return 0;
}
-static CompScreen *
-findScreenForSelection (CompDisplay *display,
- Window owner,
- Atom selection)
+unsigned int
+CompDisplay::getProtocols (Window id)
{
- CompScreen *s;
+ Atom *protocol;
+ int count;
+ unsigned int protocols = 0;
- for (s = display->screens; s; s = s->next)
+ if (XGetWMProtocols (priv->dpy, id, &protocol, &count))
{
- if (s->wmSnSelectionWindow == owner && s->wmSnAtom == selection)
- return s;
- }
+ int i;
- return NULL;
-}
-
-/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
-static Bool
-convertProperty (CompDisplay *display,
- CompScreen *screen,
- Window w,
- Atom target,
- Atom property)
-{
-
-#define N_TARGETS 4
-
- Atom conversionTargets[N_TARGETS];
- long icccmVersion[] = { 2, 0 };
-
- conversionTargets[0] = display->targetsAtom;
- conversionTargets[1] = display->multipleAtom;
- conversionTargets[2] = display->timestampAtom;
- conversionTargets[3] = display->versionAtom;
-
- if (target == display->targetsAtom)
- XChangeProperty (display->display, w, property,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) conversionTargets, N_TARGETS);
- else if (target == display->timestampAtom)
- XChangeProperty (display->display, w, property,
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) &screen->wmSnTimestamp, 1);
- else if (target == display->versionAtom)
- XChangeProperty (display->display, w, property,
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) icccmVersion, 2);
- else
- return FALSE;
+ for (i = 0; i < count; i++)
+ {
+ if (protocol[i] == priv->atoms.wmDeleteWindow)
+ protocols |= CompWindowProtocolDeleteMask;
+ else if (protocol[i] == priv->atoms.wmTakeFocus)
+ protocols |= CompWindowProtocolTakeFocusMask;
+ else if (protocol[i] == priv->atoms.wmPing)
+ protocols |= CompWindowProtocolPingMask;
+ else if (protocol[i] == priv->atoms.wmSyncRequest)
+ protocols |= CompWindowProtocolSyncRequestMask;
+ }
- /* Be sure the PropertyNotify has arrived so we
- * can send SelectionNotify
- */
- XSync (display->display, FALSE);
+ XFree (protocol);
+ }
- return TRUE;
+ return protocols;
}
-/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
-void
-handleSelectionRequest (CompDisplay *display,
- XEvent *event)
+unsigned int
+CompDisplay::getWindowProp (Window id,
+ Atom property,
+ unsigned int defaultValue)
{
- XSelectionEvent reply;
- CompScreen *screen;
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
- screen = findScreenForSelection (display,
- event->xselectionrequest.owner,
- event->xselectionrequest.selection);
- if (!screen)
- return;
+ result = XGetWindowProperty (priv->dpy, id, property,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
+ &n, &left, &data);
- reply.type = SelectionNotify;
- reply.display = display->display;
- reply.requestor = event->xselectionrequest.requestor;
- reply.selection = event->xselectionrequest.selection;
- reply.target = event->xselectionrequest.target;
- reply.property = None;
- reply.time = event->xselectionrequest.time;
-
- if (event->xselectionrequest.target == display->multipleAtom)
+ if (result == Success && n && data)
{
- if (event->xselectionrequest.property != None)
- {
- Atom type, *adata;
- int i, format;
- unsigned long num, rest;
- unsigned char *data;
-
- if (XGetWindowProperty (display->display,
- event->xselectionrequest.requestor,
- event->xselectionrequest.property,
- 0, 256, FALSE,
- display->atomPairAtom,
- &type, &format, &num, &rest,
- &data) != Success)
- return;
+ unsigned long value;
- /* FIXME: to be 100% correct, should deal with rest > 0,
- * but since we have 4 possible targets, we will hardly ever
- * meet multiple requests with a length > 8
- */
- adata = (Atom *) data;
- i = 0;
- while (i < (int) num)
- {
- if (!convertProperty (display, screen,
- event->xselectionrequest.requestor,
- adata[i], adata[i + 1]))
- adata[i + 1] = None;
+ memcpy (&value, data, sizeof (unsigned long));
- i += 2;
- }
-
- XChangeProperty (display->display,
- event->xselectionrequest.requestor,
- event->xselectionrequest.property,
- display->atomPairAtom,
- 32, PropModeReplace, data, num);
- }
- }
- else
- {
- if (event->xselectionrequest.property == None)
- event->xselectionrequest.property = event->xselectionrequest.target;
+ XFree (data);
- if (convertProperty (display, screen,
- event->xselectionrequest.requestor,
- event->xselectionrequest.target,
- event->xselectionrequest.property))
- reply.property = event->xselectionrequest.property;
+ return (unsigned int) value;
}
- XSendEvent (display->display,
- event->xselectionrequest.requestor,
- FALSE, 0L, (XEvent *) &reply);
+ return defaultValue;
}
void
-handleSelectionClear (CompDisplay *display,
- XEvent *event)
+CompDisplay::setWindowProp (Window id,
+ Atom property,
+ unsigned int value)
{
- /* We need to unmanage the screen on which we lost the selection */
- CompScreen *screen;
+ unsigned long data = value;
- screen = findScreenForSelection (display,
- event->xselectionclear.window,
- event->xselectionclear.selection);
-
- if (screen)
- shutDown = TRUE;
+ XChangeProperty (priv->dpy, id, property,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &data, 1);
}
-void
-warpPointer (CompScreen *s,
- int dx,
- int dy)
+bool
+CompDisplay::readWindowProp32 (Window id,
+ Atom property,
+ unsigned short *returnValue)
{
- CompDisplay *display = s->display;
- XEvent event;
-
- pointerX += dx;
- pointerY += dy;
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
- if (pointerX >= s->width)
- pointerX = s->width - 1;
- else if (pointerX < 0)
- pointerX = 0;
+ result = XGetWindowProperty (priv->dpy, id, property,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
+ &n, &left, &data);
- if (pointerY >= s->height)
- pointerY = s->height - 1;
- else if (pointerY < 0)
- pointerY = 0;
+ if (result == Success && n && data)
+ {
+ CARD32 value;
- XWarpPointer (display->display,
- None, s->root,
- 0, 0, 0, 0,
- pointerX, pointerY);
+ memcpy (&value, data, sizeof (CARD32));
- XSync (display->display, FALSE);
+ XFree (data);
- while (XCheckMaskEvent (display->display,
- LeaveWindowMask |
- EnterWindowMask |
- PointerMotionMask,
- &event));
+ *returnValue = value >> 16;
- if (!inHandleEvent)
- {
- lastPointerX = pointerX;
- lastPointerY = pointerY;
+ return true;
}
+
+ return false;
}
-Bool
-setDisplayAction (CompDisplay *display,
- CompOption *o,
- CompOptionValue *value)
+unsigned short
+CompDisplay::getWindowProp32 (Window id,
+ Atom property,
+ unsigned short defaultValue)
{
- CompScreen *s;
-
- for (s = display->screens; s; s = s->next)
- if (!addScreenAction (s, &value->action))
- break;
-
- if (s)
- {
- CompScreen *failed = s;
-
- for (s = display->screens; s && s != failed; s = s->next)
- removeScreenAction (s, &value->action);
-
- return FALSE;
- }
- else
- {
- for (s = display->screens; s; s = s->next)
- removeScreenAction (s, &o->value.action);
- }
+ unsigned short result;
- if (compSetActionOption (o, value))
- return TRUE;
+ if (readWindowProp32 (id, property, &result))
+ return result;
- return FALSE;
+ return defaultValue;
}
void
-clearTargetOutput (CompDisplay *display,
- unsigned int mask)
+CompDisplay::setWindowProp32 (Window id,
+ Atom property,
+ unsigned short value)
{
- if (targetScreen)
- clearScreenOutput (targetScreen,
- targetOutput,
- mask);
-}
+ CARD32 value32;
-#define HOME_IMAGEDIR ".compiz/images"
+ value32 = value << 16 | value;
-Bool
-readImageFromFile (CompDisplay *display,
- const char *name,
- int *width,
- int *height,
- void **data)
-{
- Bool status;
- int stride;
-
- status = (*display->fileToImage) (display, NULL, name, width, height,
- &stride, data);
- if (!status)
- {
- char *home;
-
- home = getenv ("HOME");
- if (home)
- {
- char *path;
-
- path = (char *) malloc (strlen (home) + strlen (HOME_IMAGEDIR) + 2);
- if (path)
- {
- sprintf (path, "%s/%s", home, HOME_IMAGEDIR);
- status = (*display->fileToImage) (display, path, name,
- width, height, &stride,
- data);
-
- free (path);
-
- if (status)
- return TRUE;
- }
- }
-
- status = (*display->fileToImage) (display, IMAGEDIR, name,
- width, height, &stride, data);
- }
-
- return status;
+ XChangeProperty (priv->dpy, id, property,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &value32, 1);
}
-Bool
-writeImageToFile (CompDisplay *display,
- const char *path,
- const char *name,
- const char *format,
- int width,
- int height,
- void *data)
-{
- return (*display->imageToFile) (display, path, name, format, width, height,
- width * 4, data);
-}
-Bool
-fileToImage (CompDisplay *display,
- const char *path,
- const char *name,
- int *width,
- int *height,
- int *stride,
- void **data)
+DisplayInterface::DisplayInterface ()
{
- return FALSE;
+ WRAPABLE_INIT_FUNC(handleEvent);
+ WRAPABLE_INIT_FUNC(handleCompizEvent);
+ WRAPABLE_INIT_FUNC(fileToImage);
+ WRAPABLE_INIT_FUNC(imageToFile);
+ WRAPABLE_INIT_FUNC(matchInitExp);
+ WRAPABLE_INIT_FUNC(matchExpHandlerChanged);
+ WRAPABLE_INIT_FUNC(matchPropertyChanged);
+ WRAPABLE_INIT_FUNC(logMessage);
}
-Bool
-imageToFile (CompDisplay *display,
- const char *path,
- const char *name,
- const char *format,
- int width,
- int height,
- int stride,
- void *data)
-{
- return FALSE;
-}
+void
+DisplayInterface::handleEvent (XEvent *event)
+ WRAPABLE_DEF_FUNC(handleEvent, event)
-CompCursor *
-findCursorAtDisplay (CompDisplay *display)
-{
- CompScreen *s;
+void
+DisplayInterface::handleCompizEvent (const char *plugin,
+ const char *event,
+ CompOption *option,
+ int nOption)
+ WRAPABLE_DEF_FUNC(handleCompizEvent, plugin, event, option, nOption)
+
+bool
+DisplayInterface::fileToImage (const char *path,
+ const char *name,
+ int *width,
+ int *height,
+ int *stride,
+ void **data)
+ WRAPABLE_DEF_FUNC_RETURN(fileToImage, path, name, width, height,
+ stride, data)
+
+bool
+DisplayInterface::imageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ int stride,
+ void *data)
+ WRAPABLE_DEF_FUNC_RETURN(imageToFile, path, name, format, width, height,
+ stride, data)
- for (s = display->screens; s; s = s->next)
- if (s->cursors)
- return s->cursors;
+void
+DisplayInterface::matchInitExp (CompMatchExp *exp, const char *value)
+ WRAPABLE_DEF_FUNC(matchInitExp, exp, value)
- return NULL;
+void
+DisplayInterface::matchExpHandlerChanged ()
+ WRAPABLE_DEF_FUNC(matchExpHandlerChanged)
+
+void
+DisplayInterface::matchPropertyChanged (CompWindow *window)
+ WRAPABLE_DEF_FUNC(matchPropertyChanged, window)
+
+void
+DisplayInterface::logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+ WRAPABLE_DEF_FUNC(logMessage, componentName, level, message)
+
+PrivateDisplay::PrivateDisplay (CompDisplay *display) :
+ display (display),
+ screens (0),
+ watchFdHandle (0),
+ screenInfo (NULL),
+ nScreenInfo (0),
+ textureFilter (GL_LINEAR),
+ activeWindow (0),
+ below (None),
+ modMap (0),
+ ignoredModMask (LockMask),
+ autoRaiseHandle (0),
+ autoRaiseWindow (0),
+ edgeDelayHandle (0),
+ dirtyPluginList (true)
+{
+ for (int i = 0; i < CompModNum; i++)
+ modMask[i] = CompNoMask;
+
+ compInitOptionValue (&plugin);
+}
+
+PrivateDisplay::~PrivateDisplay ()
+{
}
diff --git a/src/event.cpp b/src/event.cpp
index ea4e781..9a97932 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -33,27 +33,30 @@
#include <X11/extensions/Xfixes.h>
#include <compiz-core.h>
+#include "privatedisplay.h"
+#include "privatescreen.h"
+#include "privatewindow.h"
static Window xdndWindow = None;
static Window edgeWindow = None;
-static void
-handleWindowDamageRect (CompWindow *w,
- int x,
- int y,
- int width,
- int height)
+void
+PrivateWindow::handleDamageRect (CompWindow *w,
+ int x,
+ int y,
+ int width,
+ int height)
{
REGION region;
- Bool initial = FALSE;
+ bool initial = false;
- if (!w->redirected || w->bindFailed)
+ if (!w->priv->redirected || w->priv->bindFailed)
return;
- if (!w->damaged)
+ if (!w->priv->damaged)
{
- w->damaged = initial = TRUE;
- w->invisible = WINDOW_INVISIBLE (w);
+ w->priv->damaged = initial = true;
+ w->priv->invisible = WINDOW_INVISIBLE (w->priv);
}
region.extents.x1 = x;
@@ -61,208 +64,150 @@ handleWindowDamageRect (CompWindow *w,
region.extents.x2 = region.extents.x1 + width;
region.extents.y2 = region.extents.y1 + height;
- if (!(*w->screen->damageWindowRect) (w, initial, &region.extents))
+ if (!w->damageRect (initial, &region.extents))
{
- region.extents.x1 += w->attrib.x + w->attrib.border_width;
- region.extents.y1 += w->attrib.y + w->attrib.border_width;
- region.extents.x2 += w->attrib.x + w->attrib.border_width;
- region.extents.y2 += w->attrib.y + w->attrib.border_width;
+ 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;
- damageScreenRegion (w->screen, &region);
+ w->priv->screen->damageRegion (&region);
}
if (initial)
- damageWindowOutputExtents (w);
+ w->damageOutputExtents ();
}
-void
-handleSyncAlarm (CompWindow *w)
+bool
+CompWindow::handleSyncAlarm ()
{
- if (w->syncWait)
+ if (priv->syncWait)
{
- if (w->syncWaitHandle)
+ if (priv->syncWaitHandle)
{
- compRemoveTimeout (w->syncWaitHandle);
- w->syncWaitHandle = 0;
+ core->removeTimeout (priv->syncWaitHandle);
+ priv->syncWaitHandle = 0;
}
- w->syncWait = FALSE;
+ priv->syncWait = FALSE;
- if (resizeWindow (w,
- w->syncX, w->syncY,
- w->syncWidth, w->syncHeight,
- w->syncBorderWidth))
+ if (resize (priv->syncX, priv->syncY,
+ priv->syncWidth, priv->syncHeight,
+ priv->syncBorderWidth))
{
XRectangle *rects;
int nDamage;
- nDamage = w->nDamage;
- rects = w->damageRects;
+ nDamage = priv->nDamage;
+ rects = priv->damageRects;
while (nDamage--)
{
- handleWindowDamageRect (w,
- rects[nDamage].x,
- rects[nDamage].y,
- rects[nDamage].width,
- rects[nDamage].height);
+ PrivateWindow::handleDamageRect (this,
+ rects[nDamage].x,
+ rects[nDamage].y,
+ rects[nDamage].width,
+ rects[nDamage].height);
}
- w->nDamage = 0;
+ priv->nDamage = 0;
}
else
{
/* resizeWindow failing means that there is another pending
resize and we must send a new sync request to the client */
- sendSyncRequest (w);
+ sendSyncRequest ();
}
}
-}
-
-static void
-moveInputFocusToOtherWindow (CompWindow *w)
-{
- CompDisplay *display = w->screen->display;
-
- if (w->id == display->activeWindow)
- {
- CompWindow *ancestor;
-
- if (w->transientFor && w->transientFor != w->screen->root)
- {
- ancestor = findWindowAtDisplay (display, w->transientFor);
- if (ancestor && !(ancestor->type & (CompWindowTypeDesktopMask |
- CompWindowTypeDockMask)))
- {
- moveInputFocusToWindow (ancestor);
- }
- else
- focusDefaultWindow (w->screen);
- }
- else if (w->type & (CompWindowTypeDialogMask |
- CompWindowTypeModalDialogMask))
- {
- CompWindow *a, *focus = NULL;
- for (a = w->screen->reverseWindows; a; a = a->prev)
- {
- if (a->clientLeader == w->clientLeader)
- {
- if ((*w->screen->focusWindow) (a))
- {
- if (focus)
- {
- if (a->type & (CompWindowTypeNormalMask |
- CompWindowTypeDialogMask |
- CompWindowTypeModalDialogMask))
- {
- if (compareWindowActiveness (focus, a) < 0)
- focus = a;
- }
- }
- else
- focus = a;
- }
- }
- }
-
- if (focus && !(focus->type & (CompWindowTypeDesktopMask |
- CompWindowTypeDockMask)))
- {
- moveInputFocusToWindow (focus);
- }
- else
- focusDefaultWindow (w->screen);
- }
- else
- focusDefaultWindow (w->screen);
- }
+ priv->syncWaitHandle = 0;
+ return false;
}
-static Bool
+
+static bool
autoRaiseTimeout (void *closure)
{
CompDisplay *display = (CompDisplay *) closure;
- CompWindow *w = findWindowAtDisplay (display, display->activeWindow);
+ CompWindow *w = display->findWindow (display->activeWindow ());
- if (display->autoRaiseWindow == display->activeWindow ||
- (w && (display->autoRaiseWindow == w->transientFor)))
+ if (display->autoRaiseWindow () == display->activeWindow () ||
+ (w && (display->autoRaiseWindow () == w->transientFor ())))
{
- w = findWindowAtDisplay (display, display->autoRaiseWindow);
+ w = display->findWindow (display->autoRaiseWindow ());
if (w)
- updateWindowAttributes (w, CompStackingUpdateModeNormal);
+ w->updateAttributes (CompStackingUpdateModeNormal);
}
- return FALSE;
+ return false;
}
#define REAL_MOD_MASK (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | \
Mod3Mask | Mod4Mask | Mod5Mask | CompNoMask)
-static Bool
+static bool
isCallBackBinding (CompOption *option,
CompBindingType type,
CompActionState state)
{
if (!isActionOption (option))
- return FALSE;
+ return false;
if (!(option->value.action.type & type))
- return FALSE;
+ return false;
if (!(option->value.action.state & state))
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
-static Bool
+static bool
isInitiateBinding (CompOption *option,
CompBindingType type,
CompActionState state,
CompAction **action)
{
if (!isCallBackBinding (option, type, state))
- return FALSE;
+ return false;
if (!option->value.action.initiate)
- return FALSE;
+ return false;
*action = &option->value.action;
- return TRUE;
+ return true;
}
-static Bool
+static bool
isTerminateBinding (CompOption *option,
CompBindingType type,
CompActionState state,
CompAction **action)
{
if (!isCallBackBinding (option, type, state))
- return FALSE;
+ return false;
if (!option->value.action.terminate)
- return FALSE;
+ return false;
*action = &option->value.action;
- return TRUE;
+ return true;
}
-static Bool
-triggerButtonPressBindings (CompDisplay *d,
- CompOption *option,
- int nOption,
- XEvent *event,
- CompOption *argument,
- int nArgument)
+bool
+PrivateDisplay::triggerButtonPressBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument)
{
CompActionState state = CompActionStateInitButton;
CompAction *action;
- unsigned int modMask = REAL_MOD_MASK & ~d->ignoredModMask;
+ unsigned int modMask = REAL_MOD_MASK & ~ignoredModMask;
unsigned int bindMods;
unsigned int edge = 0;
@@ -271,22 +216,22 @@ triggerButtonPressBindings (CompDisplay *d,
CompScreen *s;
unsigned int i;
- s = findScreenAtDisplay (d, event->xbutton.root);
+ s = display->findScreen (event->xbutton.root);
if (!s)
- return FALSE;
+ return false;
if (event->xbutton.window != edgeWindow)
{
- if (!s->maxGrab || event->xbutton.window != s->root)
- return FALSE;
+ if (!s->maxGrab () || event->xbutton.window != s->root ())
+ return false;
}
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (edgeWindow == s->screenEdge[i].id)
+ if (edgeWindow == s->screenEdge (i).id)
{
edge = 1 << i;
- argument[1].value.i = d->activeWindow;
+ argument[1].value.i = display->activeWindow ();
break;
}
}
@@ -298,12 +243,13 @@ triggerButtonPressBindings (CompDisplay *d,
{
if (action->button.button == event->xbutton.button)
{
- bindMods = virtualToRealModMask (d, action->button.modifiers);
+ bindMods =
+ display->virtualToRealModMask (action->button.modifiers);
if ((bindMods & modMask) == (event->xbutton.state & modMask))
- if ((*action->initiate) (d, action, state,
+ if ((*action->initiate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
}
@@ -315,15 +261,15 @@ triggerButtonPressBindings (CompDisplay *d,
if ((action->button.button == event->xbutton.button) &&
(action->edgeMask & edge))
{
- bindMods = virtualToRealModMask (d,
- action->button.modifiers);
+ bindMods =
+ display->virtualToRealModMask (action->button.modifiers);
if ((bindMods & modMask) ==
(event->xbutton.state & modMask))
- if ((*action->initiate) (d, action, state |
+ if ((*action->initiate) (display, action, state |
CompActionStateInitEdge,
argument, nArgument))
- return TRUE;
+ return true;
}
}
}
@@ -331,16 +277,15 @@ triggerButtonPressBindings (CompDisplay *d,
option++;
}
- return FALSE;
+ return false;
}
-static Bool
-triggerButtonReleaseBindings (CompDisplay *d,
- CompOption *option,
- int nOption,
- XEvent *event,
- CompOption *argument,
- int nArgument)
+bool
+PrivateDisplay::triggerButtonReleaseBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument)
{
CompActionState state = CompActionStateTermButton;
CompBindingType type = CompBindingTypeButton | CompBindingTypeEdgeButton;
@@ -352,34 +297,33 @@ triggerButtonReleaseBindings (CompDisplay *d,
{
if (action->button.button == event->xbutton.button)
{
- if ((*action->terminate) (d, action, state,
+ if ((*action->terminate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
}
option++;
}
- return FALSE;
+ return false;
}
-static Bool
-triggerKeyPressBindings (CompDisplay *d,
- CompOption *option,
- int nOption,
- XEvent *event,
- CompOption *argument,
- int nArgument)
+bool
+PrivateDisplay::triggerKeyPressBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument)
{
CompActionState state = 0;
CompAction *action;
- unsigned int modMask = REAL_MOD_MASK & ~d->ignoredModMask;
+ unsigned int modMask = REAL_MOD_MASK & ~ignoredModMask;
unsigned int bindMods;
- if (event->xkey.keycode == d->escapeKeyCode)
+ if (event->xkey.keycode == escapeKeyCode)
state = CompActionStateCancel;
- else if (event->xkey.keycode == d->returnKeyCode)
+ else if (event->xkey.keycode == returnKeyCode)
state = CompActionStateCommit;
if (state)
@@ -392,7 +336,7 @@ triggerKeyPressBindings (CompDisplay *d,
if (isActionOption (o))
{
if (o->value.action.terminate)
- (*o->value.action.terminate) (d, &o->value.action,
+ (*o->value.action.terminate) (display, &o->value.action,
state, NULL, 0);
}
@@ -400,7 +344,7 @@ triggerKeyPressBindings (CompDisplay *d,
}
if (state == CompActionStateCancel)
- return FALSE;
+ return false;
}
state = CompActionStateInitKey;
@@ -408,61 +352,61 @@ triggerKeyPressBindings (CompDisplay *d,
{
if (isInitiateBinding (option, CompBindingTypeKey, state, &action))
{
- bindMods = virtualToRealModMask (d, action->key.modifiers);
+ bindMods = display->virtualToRealModMask (action->key.modifiers);
if (action->key.keycode == event->xkey.keycode)
{
if ((bindMods & modMask) == (event->xkey.state & modMask))
- if ((*action->initiate) (d, action, state,
+ if ((*action->initiate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
- else if (!d->xkbEvent && action->key.keycode == 0)
+ else if (!xkbEvent && action->key.keycode == 0)
{
if (bindMods == (event->xkey.state & modMask))
- if ((*action->initiate) (d, action, state,
+ if ((*action->initiate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
}
option++;
}
- return FALSE;
+ return false;
}
-static Bool
-triggerKeyReleaseBindings (CompDisplay *d,
- CompOption *option,
- int nOption,
- XEvent *event,
- CompOption *argument,
- int nArgument)
+bool
+PrivateDisplay::triggerKeyReleaseBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument)
{
- if (!d->xkbEvent)
+ if (!xkbEvent)
{
CompActionState state = CompActionStateTermKey;
CompAction *action;
- unsigned int modMask = REAL_MOD_MASK & ~d->ignoredModMask;
+ unsigned int modMask = REAL_MOD_MASK & ~ignoredModMask;
unsigned int bindMods;
unsigned int mods;
- mods = keycodeToModifiers (d, event->xkey.keycode);
+ mods = display->keycodeToModifiers (event->xkey.keycode);
if (mods == 0)
- return FALSE;
+ return false;
while (nOption--)
{
if (isTerminateBinding (option, CompBindingTypeKey, state, &action))
{
- bindMods = virtualToRealModMask (d, action->key.modifiers);
+ bindMods =
+ display->virtualToRealModMask (action->key.modifiers);
if ((mods & modMask & bindMods) != bindMods)
{
- if ((*action->terminate) (d, action, state,
+ if ((*action->terminate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
}
@@ -470,20 +414,19 @@ triggerKeyReleaseBindings (CompDisplay *d,
}
}
- return FALSE;
+ return false;
}
-static Bool
-triggerStateNotifyBindings (CompDisplay *d,
- CompOption *option,
- int nOption,
- XkbStateNotifyEvent *event,
- CompOption *argument,
- int nArgument)
+bool
+PrivateDisplay::triggerStateNotifyBindings (CompOption *option,
+ int nOption,
+ XkbStateNotifyEvent *event,
+ CompOption *argument,
+ int nArgument)
{
CompActionState state;
CompAction *action;
- unsigned int modMask = REAL_MOD_MASK & ~d->ignoredModMask;
+ unsigned int modMask = REAL_MOD_MASK & ~ignoredModMask;
unsigned int bindMods;
if (event->event_type == KeyPress)
@@ -496,13 +439,14 @@ triggerStateNotifyBindings (CompDisplay *d,
{
if (action->key.keycode == 0)
{
- bindMods = virtualToRealModMask (d, action->key.modifiers);
+ bindMods =
+ display->virtualToRealModMask (action->key.modifiers);
if ((event->mods & modMask & bindMods) == bindMods)
{
- if ((*action->initiate) (d, action, state,
+ if ((*action->initiate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
}
}
@@ -518,13 +462,14 @@ triggerStateNotifyBindings (CompDisplay *d,
{
if (isTerminateBinding (option, CompBindingTypeKey, state, &action))
{
- bindMods = virtualToRealModMask (d, action->key.modifiers);
+ bindMods =
+ display->virtualToRealModMask (action->key.modifiers);
if ((event->mods & modMask & bindMods) != bindMods)
{
- if ((*action->terminate) (d, action, state,
+ if ((*action->terminate) (display, action, state,
argument, nArgument))
- return TRUE;
+ return true;
}
}
@@ -532,33 +477,33 @@ triggerStateNotifyBindings (CompDisplay *d,
}
}
- return FALSE;
+ return false;
}
-static Bool
+static bool
isBellAction (CompOption *option,
CompActionState state,
CompAction **action)
{
if (option->type != CompOptionTypeAction &&
option->type != CompOptionTypeBell)
- return FALSE;
+ return false;
if (!option->value.action.bell)
- return FALSE;
+ return false;
if (!(option->value.action.state & state))
- return FALSE;
+ return false;
if (!option->value.action.initiate)
- return FALSE;
+ return false;
*action = &option->value.action;
- return TRUE;
+ return true;
}
-static Bool
+static bool
triggerBellNotifyBindings (CompDisplay *d,
CompOption *option,
int nOption,
@@ -573,16 +518,16 @@ triggerBellNotifyBindings (CompDisplay *d,
if (isBellAction (option, state, &action))
{
if ((*action->initiate) (d, action, state, argument, nArgument))
- return TRUE;
+ return true;
}
option++;
}
- return FALSE;
+ return false;
}
-static Bool
+static bool
isEdgeAction (CompOption *option,
CompActionState state,
unsigned int edge)
@@ -590,18 +535,18 @@ isEdgeAction (CompOption *option,
if (option->type != CompOptionTypeAction &&
option->type != CompOptionTypeButton &&
option->type != CompOptionTypeEdge)
- return FALSE;
+ return false;
if (!(option->value.action.edgeMask & edge))
- return FALSE;
+ return false;
if (!(option->value.action.state & state))
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
-static Bool
+static bool
isEdgeEnterAction (CompOption *option,
CompActionState state,
CompActionState delayState,
@@ -609,13 +554,13 @@ isEdgeEnterAction (CompOption *option,
CompAction **action)
{
if (!isEdgeAction (option, state, edge))
- return FALSE;
+ return false;
if (option->value.action.type & CompBindingTypeEdgeButton)
- return FALSE;
+ return false;
if (!option->value.action.initiate)
- return FALSE;
+ return false;
if (delayState)
{
@@ -624,34 +569,34 @@ isEdgeEnterAction (CompOption *option,
{
/* ignore edge actions which shouldn't be delayed when invoking
undelayed edges (or vice versa) */
- return FALSE;
+ return false;
}
}
*action = &option->value.action;
- return TRUE;
+ return true;
}
-static Bool
+static bool
isEdgeLeaveAction (CompOption *option,
CompActionState state,
unsigned int edge,
CompAction **action)
{
if (!isEdgeAction (option, state, edge))
- return FALSE;
+ return false;
if (!option->value.action.terminate)
- return FALSE;
+ return false;
*action = &option->value.action;
- return TRUE;
+ return true;
}
-static Bool
+static bool
triggerEdgeEnterBindings (CompDisplay *d,
CompOption *option,
int nOption,
@@ -668,16 +613,16 @@ triggerEdgeEnterBindings (CompDisplay *d,
if (isEdgeEnterAction (option, state, delayState, edge, &action))
{
if ((*action->initiate) (d, action, state, argument, nArgument))
- return TRUE;
+ return true;
}
option++;
}
- return FALSE;
+ return false;
}
-static Bool
+static bool
triggerEdgeLeaveBindings (CompDisplay *d,
CompOption *option,
int nOption,
@@ -693,16 +638,16 @@ triggerEdgeLeaveBindings (CompDisplay *d,
if (isEdgeLeaveAction (option, state, edge, &action))
{
if ((*action->terminate) (d, action, state, argument, nArgument))
- return TRUE;
+ return true;
}
option++;
}
- return FALSE;
+ return false;
}
-static Bool
+static bool
triggerAllEdgeEnterBindings (CompDisplay *d,
CompActionState state,
CompActionState delayState,
@@ -716,22 +661,19 @@ triggerAllEdgeEnterBindings (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (p->vTable->getObjectOptions)
+ option = p->vTable->getObjectOptions (d, &nOption);
+ if (triggerEdgeEnterBindings (d,
+ option, nOption,
+ state, delayState, edge,
+ argument, nArgument))
{
- option = (*p->vTable->getObjectOptions) (p, &d->base, &nOption);
- if (triggerEdgeEnterBindings (d,
- option, nOption,
- state, delayState, edge,
- argument, nArgument))
- {
- return TRUE;
- }
+ return true;
}
}
- return FALSE;
+ return false;
}
-static Bool
+static bool
delayedEdgeTimeout (void *closure)
{
CompDelayedEdgeSettings *settings = (CompDelayedEdgeSettings *) closure;
@@ -745,30 +687,30 @@ delayedEdgeTimeout (void *closure)
free (settings);
- return FALSE;
+ return false;
}
-static Bool
-triggerEdgeEnter (CompDisplay *d,
- unsigned int edge,
- CompActionState state,
- CompOption *argument,
- unsigned int nArgument)
+bool
+PrivateDisplay::triggerEdgeEnter (unsigned int edge,
+ CompActionState state,
+ CompOption *argument,
+ unsigned int nArgument)
{
int delay;
CompDelayedEdgeSettings *delayedSettings = NULL;
- delay = d->opt[COMP_DISPLAY_OPTION_EDGE_DELAY].value.i;
+ delay = opt[COMP_DISPLAY_OPTION_EDGE_DELAY].value.i;
if (nArgument > 7)
nArgument = 7;
if (delay > 0)
{
- delayedSettings = (CompDelayedEdgeSettings *) malloc (sizeof (CompDelayedEdgeSettings));
+ delayedSettings = (CompDelayedEdgeSettings *)
+ malloc (sizeof (CompDelayedEdgeSettings));
if (delayedSettings)
{
- delayedSettings->d = d;
+ delayedSettings->d = display;
delayedSettings->edge = edge;
delayedSettings->state = state;
delayedSettings->nOption = nArgument;
@@ -783,30 +725,29 @@ triggerEdgeEnter (CompDisplay *d,
for (i = 0; i < nArgument; i++)
delayedSettings->option[i] = argument[i];
- d->edgeDelayHandle = compAddTimeout (delay, (float) delay * 1.2,
- delayedEdgeTimeout,
- delayedSettings);
+ edgeDelayHandle = core->addTimeout (delay, (float) delay * 1.2,
+ delayedEdgeTimeout,
+ delayedSettings);
delayState = CompActionStateNoEdgeDelay;
- if (triggerAllEdgeEnterBindings (d, state, delayState,
+ if (triggerAllEdgeEnterBindings (display, state, delayState,
edge, argument, nArgument))
- return TRUE;
+ return true;
}
else
{
- if (triggerAllEdgeEnterBindings (d, state, 0, edge,
+ if (triggerAllEdgeEnterBindings (display, state, 0, edge,
argument, nArgument))
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-static Bool
-handleActionEvent (CompDisplay *d,
- XEvent *event)
+bool
+PrivateDisplay::handleActionEvent (XEvent *event)
{
- CompObject *obj = &d->base;
+ CompObject *obj = display;
CompOption *option;
int nOption;
CompPlugin *p;
@@ -849,12 +790,9 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerButtonPressBindings (d, option, nOption, event, o, 8))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerButtonPressBindings (option, nOption, event, o, 8))
+ return true;
}
break;
case ButtonRelease:
@@ -875,17 +813,14 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerButtonReleaseBindings (d, option, nOption, event, o, 8))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerButtonReleaseBindings (option, nOption, event, o, 8))
+ return true;
}
break;
case KeyPress:
o[0].value.i = event->xkey.window;
- o[1].value.i = d->activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = event->xkey.state;
o[3].value.i = event->xkey.x_root;
o[4].value.i = event->xkey.y_root;
@@ -901,17 +836,14 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerKeyPressBindings (d, option, nOption, event, o, 8))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerKeyPressBindings (option, nOption, event, o, 8))
+ return true;
}
break;
case KeyRelease:
o[0].value.i = event->xkey.window;
- o[1].value.i = d->activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = event->xkey.state;
o[3].value.i = event->xkey.x_root;
o[4].value.i = event->xkey.y_root;
@@ -927,11 +859,9 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerKeyReleaseBindings (d, option, nOption, event, o, 8))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerKeyReleaseBindings (option, nOption, event, o, 8))
+ return true;
}
break;
case EnterNotify:
@@ -943,18 +873,18 @@ handleActionEvent (CompDisplay *d,
unsigned int edge, i;
CompActionState state;
- s = findScreenAtDisplay (d, event->xcrossing.root);
+ s = display->findScreen (event->xcrossing.root);
if (!s)
- return FALSE;
+ return false;
- if (d->edgeDelayHandle)
+ if (edgeDelayHandle)
{
void *closure;
- closure = compRemoveTimeout (d->edgeDelayHandle);
+ closure = core->removeTimeout (edgeDelayHandle);
if (closure)
free (closure);
- d->edgeDelayHandle = 0;
+ edgeDelayHandle = 0;
}
if (edgeWindow && edgeWindow != event->xcrossing.window)
@@ -964,7 +894,7 @@ handleActionEvent (CompDisplay *d,
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (edgeWindow == s->screenEdge[i].id)
+ if (edgeWindow == s->screenEdge (i).id)
{
edge = 1 << i;
break;
@@ -974,7 +904,7 @@ handleActionEvent (CompDisplay *d,
edgeWindow = None;
o[0].value.i = event->xcrossing.window;
- o[1].value.i = d->activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = event->xcrossing.state;
o[3].value.i = event->xcrossing.x_root;
o[4].value.i = event->xcrossing.y_root;
@@ -986,13 +916,10 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerEdgeLeaveBindings (d, option, nOption, state,
- edge, o, 7))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerEdgeLeaveBindings (display, option, nOption,
+ state, edge, o, 7))
+ return true;
}
}
@@ -1000,7 +927,7 @@ handleActionEvent (CompDisplay *d,
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (event->xcrossing.window == s->screenEdge[i].id)
+ if (event->xcrossing.window == s->screenEdge (i).id)
{
edge = 1 << i;
break;
@@ -1014,7 +941,7 @@ handleActionEvent (CompDisplay *d,
edgeWindow = event->xcrossing.window;
o[0].value.i = event->xcrossing.window;
- o[1].value.i = d->activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = event->xcrossing.state;
o[3].value.i = event->xcrossing.x_root;
o[4].value.i = event->xcrossing.y_root;
@@ -1024,17 +951,17 @@ handleActionEvent (CompDisplay *d,
o[6].name = "time";
o[6].value.i = event->xcrossing.time;
- if (triggerEdgeEnter (d, edge, state, o, 7))
- return TRUE;
+ if (triggerEdgeEnter (edge, state, o, 7))
+ return true;
}
}
break;
case ClientMessage:
- if (event->xclient.message_type == d->xdndEnterAtom)
+ if (event->xclient.message_type == atoms.xdndEnter)
{
xdndWindow = event->xclient.window;
}
- else if (event->xclient.message_type == d->xdndLeaveAtom)
+ else if (event->xclient.message_type == atoms.xdndLeave)
{
unsigned int edge = 0;
CompActionState state;
@@ -1044,18 +971,18 @@ handleActionEvent (CompDisplay *d,
{
CompWindow *w;
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = display->findWindow (event->xclient.window);
if (w)
{
- CompScreen *s = w->screen;
+ CompScreen *s = w->screen ();
unsigned int i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (event->xclient.window == s->screenEdge[i].id)
+ if (event->xclient.window == s->screenEdge (i).id)
{
edge = 1 << i;
- root = s->root;
+ root = s->root ();
break;
}
}
@@ -1067,7 +994,7 @@ handleActionEvent (CompDisplay *d,
state = CompActionStateTermEdgeDnd;
o[0].value.i = event->xclient.window;
- o[1].value.i = d->activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = 0; /* fixme */
o[3].value.i = 0; /* fixme */
o[4].value.i = 0; /* fixme */
@@ -1075,17 +1002,14 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerEdgeLeaveBindings (d, option, nOption, state,
- edge, o, 6))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerEdgeLeaveBindings (display, option, nOption,
+ state, edge, o, 6))
+ return true;
}
}
}
- else if (event->xclient.message_type == d->xdndPositionAtom)
+ else if (event->xclient.message_type == atoms.xdndPosition)
{
unsigned int edge = 0;
CompActionState state;
@@ -1095,18 +1019,18 @@ handleActionEvent (CompDisplay *d,
{
CompWindow *w;
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = display->findWindow (event->xclient.window);
if (w)
{
- CompScreen *s = w->screen;
+ CompScreen *s = w->screen ();
unsigned int i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (xdndWindow == s->screenEdge[i].id)
+ if (xdndWindow == s->screenEdge (i).id)
{
edge = 1 << i;
- root = s->root;
+ root = s->root ();
break;
}
}
@@ -1118,21 +1042,21 @@ handleActionEvent (CompDisplay *d,
state = CompActionStateInitEdgeDnd;
o[0].value.i = event->xclient.window;
- o[1].value.i = d->activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = 0; /* fixme */
o[3].value.i = event->xclient.data.l[2] >> 16;
o[4].value.i = event->xclient.data.l[2] & 0xffff;
o[5].value.i = root;
- if (triggerEdgeEnter (d, edge, state, o, 6))
- return TRUE;
+ if (triggerEdgeEnter (edge, state, o, 6))
+ return true;
}
xdndWindow = None;
}
break;
default:
- if (event->type == d->fixesEvent + XFixesCursorNotify)
+ if (event->type == fixesEvent + XFixesCursorNotify)
{
/*
XFixesCursorNotifyEvent *ce = (XFixesCursorNotifyEvent *) event;
@@ -1143,7 +1067,7 @@ handleActionEvent (CompDisplay *d,
updateCursor (cursor, ce->x, ce->y, ce->cursor_serial);
*/
}
- else if (event->type == d->xkbEvent)
+ else if (event->type == xkbEvent)
{
XkbAnyEvent *xkbEvent = (XkbAnyEvent *) event;
@@ -1151,8 +1075,8 @@ handleActionEvent (CompDisplay *d,
{
XkbStateNotifyEvent *stateEvent = (XkbStateNotifyEvent *) event;
- o[0].value.i = d->activeWindow;
- o[1].value.i = d->activeWindow;
+ o[0].value.i = activeWindow;
+ o[1].value.i = activeWindow;
o[2].value.i = stateEvent->mods;
o[3].type = CompOptionTypeInt;
@@ -1161,19 +1085,16 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerStateNotifyBindings (d, option, nOption,
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerStateNotifyBindings (option, nOption,
stateEvent, o, 4))
- return TRUE;
+ return true;
}
}
else if (xkbEvent->xkb_type == XkbBellNotify)
{
- o[0].value.i = d->activeWindow;
- o[1].value.i = d->activeWindow;
+ o[0].value.i = activeWindow;
+ o[1].value.i = activeWindow;
o[2].type = CompOptionTypeInt;
o[2].name = "time";
@@ -1181,535 +1102,477 @@ handleActionEvent (CompDisplay *d,
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, obj, &nOption);
- if (triggerBellNotifyBindings (d, option, nOption, o, 3))
- return TRUE;
+ option = p->vTable->getObjectOptions (obj, &nOption);
+ if (triggerBellNotifyBindings (display, option,
+ nOption, o, 3))
+ return true;
}
}
}
break;
}
- return FALSE;
+ return false;
}
void
-handleCompizEvent (CompDisplay *d,
- const char *pluginName,
- const char *eventName,
- CompOption *option,
- int nOption)
+CompScreen::handleExposeEvent (XExposeEvent *event)
{
+ if (priv->output == event->window)
+ return;
+
+ int more = event->count + 1;
+
+ if (priv->nExpose == priv->sizeExpose)
+ {
+ priv->exposeRects = (XRectangle *)
+ realloc (priv->exposeRects, (priv->sizeExpose + more) *
+ sizeof (XRectangle));
+ priv->sizeExpose += more;
+ }
+
+ priv->exposeRects[priv->nExpose].x = event->x;
+ priv->exposeRects[priv->nExpose].y = event->y;
+ priv->exposeRects[priv->nExpose].width = event->width;
+ priv->exposeRects[priv->nExpose].height = event->height;
+ priv->nExpose++;
+
+ if (event->count == 0)
+ {
+ REGION rect;
+
+ rect.rects = &rect.extents;
+ rect.numRects = rect.size = 1;
+
+ while (priv->nExpose--)
+ {
+ rect.extents.x1 = priv->exposeRects[priv->nExpose].x;
+ rect.extents.y1 = priv->exposeRects[priv->nExpose].y;
+ rect.extents.x2 = rect.extents.x1 +
+ priv->exposeRects[priv->nExpose].width;
+ rect.extents.y2 = rect.extents.y1 +
+ priv->exposeRects[priv->nExpose].height;
+
+ damageRegion (&rect);
+ }
+ priv->nExpose = 0;
+ }
}
void
-handleEvent (CompDisplay *d,
- XEvent *event)
+CompDisplay::handleCompizEvent (const char *plugin,
+ const char *event,
+ CompOption *option,
+ int nOption)
+ WRAPABLE_HND_FUNC(handleCompizEvent, plugin, event, option, nOption)
+
+void
+CompDisplay::handleEvent (XEvent *event)
{
+ WRAPABLE_HND_FUNC(handleEvent, event)
+
CompScreen *s;
CompWindow *w;
switch (event->type) {
case ButtonPress:
- s = findScreenAtDisplay (d, event->xbutton.root);
+ s = findScreen (event->xbutton.root);
if (s)
- setCurrentOutput (s, outputDeviceForPoint (s,
- event->xbutton.x_root,
- event->xbutton.y_root));
+ s->setCurrentOutput (
+ s->outputDeviceForPoint (event->xbutton.x_root,
+ event->xbutton.y_root));
break;
case MotionNotify:
- s = findScreenAtDisplay (d, event->xmotion.root);
+ s = findScreen (event->xmotion.root);
if (s)
- setCurrentOutput (s, outputDeviceForPoint (s,
- event->xmotion.x_root,
- event->xmotion.y_root));
+ s->setCurrentOutput (
+ s->outputDeviceForPoint (event->xmotion.x_root,
+ event->xmotion.y_root));
break;
case KeyPress:
- w = findWindowAtDisplay (d, d->activeWindow);
+ w = findWindow (priv->activeWindow);
if (w)
- setCurrentOutput (w->screen, outputDeviceForWindow (w));
+ w->screen ()->setCurrentOutput (w->outputDevice ());
default:
break;
}
- if (handleActionEvent (d, event))
+ if (priv->handleActionEvent (event))
{
- if (!d->screens->maxGrab)
- XAllowEvents (d->display, AsyncPointer, event->xbutton.time);
+ if (!priv->screens->maxGrab ())
+ XAllowEvents (priv->dpy, AsyncPointer, event->xbutton.time);
return;
}
switch (event->type) {
case Expose:
- for (s = d->screens; s; s = s->next)
- if (s->output == event->xexpose.window)
- break;
-
- if (s)
- {
- int more = event->xexpose.count + 1;
-
- if (s->nExpose == s->sizeExpose)
- {
- s->exposeRects = (XRectangle *) realloc (s->exposeRects,
- (s->sizeExpose + more) *
- sizeof (XRectangle));
- s->sizeExpose += more;
- }
-
- s->exposeRects[s->nExpose].x = event->xexpose.x;
- s->exposeRects[s->nExpose].y = event->xexpose.y;
- s->exposeRects[s->nExpose].width = event->xexpose.width;
- s->exposeRects[s->nExpose].height = event->xexpose.height;
- s->nExpose++;
-
- if (event->xexpose.count == 0)
- {
- REGION rect;
-
- rect.rects = &rect.extents;
- rect.numRects = rect.size = 1;
-
- while (s->nExpose--)
- {
- rect.extents.x1 = s->exposeRects[s->nExpose].x;
- rect.extents.y1 = s->exposeRects[s->nExpose].y;
- rect.extents.x2 = rect.extents.x1 +
- s->exposeRects[s->nExpose].width;
- rect.extents.y2 = rect.extents.y1 +
- s->exposeRects[s->nExpose].height;
-
- damageScreenRegion (s, &rect);
- }
- s->nExpose = 0;
- }
- }
+ for (s = priv->screens; s; s = s->next)
+ s->handleExposeEvent (&event->xexpose);
break;
case SelectionRequest:
- handleSelectionRequest (d, event);
+ priv->handleSelectionRequest (event);
break;
case SelectionClear:
- handleSelectionClear (d, event);
+ priv->handleSelectionClear (event);
break;
case ConfigureNotify:
- w = findWindowAtDisplay (d, event->xconfigure.window);
+ w = findWindow (event->xconfigure.window);
if (w)
{
- configureWindow (w, &event->xconfigure);
+ w->configure (&event->xconfigure);
}
else
{
- s = findScreenAtDisplay (d, event->xconfigure.window);
+ s = findScreen (event->xconfigure.window);
if (s)
- configureScreen (s, &event->xconfigure);
+ s->configure (&event->xconfigure);
}
break;
case CreateNotify:
- s = findScreenAtDisplay (d, event->xcreatewindow.parent);
+ 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)
- addWindow (s, event->xcreatewindow.window, getTopWindow (s));
+ if (s->overlay () != event->xcreatewindow.window)
+ new CompWindow (s, event->xcreatewindow.window,
+ s->getTopWindow ());
}
break;
case DestroyNotify:
- w = findWindowAtDisplay (d, event->xdestroywindow.window);
+ w = findWindow (event->xdestroywindow.window);
if (w)
{
- moveInputFocusToOtherWindow (w);
- destroyWindow (w);
+ w->moveInputFocusToOtherWindow ();
+ w->destroy ();
}
break;
case MapNotify:
- w = findWindowAtDisplay (d, event->xmap.window);
+ w = findWindow (event->xmap.window);
if (w)
{
- if (!w->attrib.override_redirect)
- w->managed = TRUE;
+ if (!w->attrib ().override_redirect)
+ w->managed () = true;
/* been shaded */
- if (w->height == 0)
+ if (w->height () == 0)
{
- if (w->id == d->activeWindow)
- moveInputFocusToWindow (w);
+ if (w->id () == priv->activeWindow)
+ w->moveInputFocusTo ();
}
- mapWindow (w);
+ w->map ();
}
break;
case UnmapNotify:
- w = findWindowAtDisplay (d, event->xunmap.window);
+ w = findWindow (event->xunmap.window);
if (w)
{
/* Normal -> Iconic */
- if (w->pendingUnmaps)
+ if (w->pendingUnmaps ())
{
- setWmState (d, IconicState, w->id);
- w->pendingUnmaps--;
+ setWmState (IconicState, w->id ());
+ w->pendingUnmaps ()--;
}
else /* X -> Withdrawn */
{
/* Iconic -> Withdrawn */
- if (w->state & CompWindowStateHiddenMask)
+ if (w->state () & CompWindowStateHiddenMask)
{
- w->minimized = FALSE;
+ w->minimized () = false;
- changeWindowState (w,
- w->state & ~CompWindowStateHiddenMask);
+ w->changeState (w->state () & ~CompWindowStateHiddenMask);
- updateClientListForScreen (w->screen);
+ w->screen () ->updateClientList ();
}
- if (!w->attrib.override_redirect)
- setWmState (d, WithdrawnState, w->id);
+ if (!w->attrib ().override_redirect)
+ setWmState (WithdrawnState, w->id ());
- w->placed = FALSE;
- w->managed = FALSE;
+ w->placed () = false;
+ w->managed () = false;
}
- unmapWindow (w);
+ w->unmap ();
- if (!w->shaded)
- moveInputFocusToOtherWindow (w);
+ if (!w->shaded ())
+ w->moveInputFocusToOtherWindow ();
}
break;
case ReparentNotify:
- w = findWindowAtDisplay (d, event->xreparent.window);
- s = findScreenAtDisplay (d, event->xreparent.parent);
+ w = findWindow (event->xreparent.window);
+ s = findScreen (event->xreparent.parent);
if (s && !w)
{
- addWindow (s, event->xreparent.window, getTopWindow (s));
+ new CompWindow (s, event->xreparent.window, s->getTopWindow ());
}
else if (w)
{
/* This is the only case where a window is removed but not
destroyed. We must remove our event mask and all passive
grabs. */
- XSelectInput (d->display, w->id, NoEventMask);
- XShapeSelectInput (d->display, w->id, NoEventMask);
- XUngrabButton (d->display, AnyButton, AnyModifier, w->id);
+ XSelectInput (priv->dpy, w->id (), NoEventMask);
+ XShapeSelectInput (priv->dpy, w->id (), NoEventMask);
+ XUngrabButton (priv->dpy, AnyButton, AnyModifier, w->id ());
- moveInputFocusToOtherWindow (w);
+ w->moveInputFocusToOtherWindow ();
- destroyWindow (w);
+ w->destroy ();
}
break;
case CirculateNotify:
- w = findWindowAtDisplay (d, event->xcirculate.window);
+ w = findWindow (event->xcirculate.window);
if (w)
- circulateWindow (w, &event->xcirculate);
+ w->circulate (&event->xcirculate);
break;
case ButtonPress:
- s = findScreenAtDisplay (d, event->xbutton.root);
+ s = findScreen (event->xbutton.root);
if (s)
{
if (event->xbutton.button == Button1 ||
event->xbutton.button == Button2 ||
event->xbutton.button == Button3)
{
- w = findTopLevelWindowAtScreen (s, event->xbutton.window);
+ w = s->findTopLevelWindow (event->xbutton.window);
if (w)
{
- if (d->opt[COMP_DISPLAY_OPTION_RAISE_ON_CLICK].value.b)
- updateWindowAttributes (w,
+ if (priv->opt[COMP_DISPLAY_OPTION_RAISE_ON_CLICK].value.b)
+ w->updateAttributes (
CompStackingUpdateModeAboveFullscreen);
- if (w->id != d->activeWindow)
- if (!(w->type & CompWindowTypeDockMask))
- moveInputFocusToWindow (w);
+ if (w->id () != priv->activeWindow)
+ if (!(w->type () & CompWindowTypeDockMask))
+ w->moveInputFocusTo ();
}
}
- if (!s->maxGrab)
- XAllowEvents (d->display, ReplayPointer, event->xbutton.time);
+ if (!s->maxGrab ())
+ XAllowEvents (priv->dpy, ReplayPointer, event->xbutton.time);
}
break;
case PropertyNotify:
- if (event->xproperty.atom == d->winTypeAtom)
+ if (event->xproperty.atom == priv->atoms.winType)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
{
unsigned int type;
- type = getWindowType (d, w->id);
+ type = getWindowType (w->id ());
- if (type != w->wmType)
+ if (type != w->wmType ())
{
- if (w->attrib.map_state == IsViewable)
+ if (w->attrib ().map_state == IsViewable)
{
- if (w->type == CompWindowTypeDesktopMask)
- w->screen->desktopWindowCount--;
+ if (w->type () == CompWindowTypeDesktopMask)
+ w->screen ()->desktopWindowCount ()--;
else if (type == CompWindowTypeDesktopMask)
- w->screen->desktopWindowCount++;
+ w->screen ()->desktopWindowCount ()++;
}
- w->wmType = type;
+ w->wmType () = type;
- recalcWindowType (w);
- recalcWindowActions (w);
-
- if (w->type & CompWindowTypeDesktopMask)
- w->paint.opacity = OPAQUE;
+ w->recalcType ();
+ w->recalcActions ();
if (type & (CompWindowTypeDockMask |
CompWindowTypeDesktopMask))
- setDesktopForWindow (w, 0xffffffff);
+ w->setDesktop (0xffffffff);
- updateClientListForScreen (w->screen);
+ w->screen ()->updateClientList ();
- (*d->matchPropertyChanged) (d, w);
+ matchPropertyChanged (w);
}
}
}
- else if (event->xproperty.atom == d->winStateAtom)
+ else if (event->xproperty.atom == priv->atoms.winState)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w && !w->managed)
+ w = findWindow (event->xproperty.window);
+ if (w && !w->managed ())
{
unsigned int state;
- state = getWindowState (d, w->id);
- state = constrainWindowState (state, w->actions);
+ state = getWindowState (w->id ());
+ state = CompWindow::constrainWindowState (state, w->actions ());
- if (state != w->state)
+ if (state != w->state ())
{
- w->state = state;
-
- recalcWindowType (w);
- recalcWindowActions (w);
+ w->state () = state;
- if (w->type & CompWindowTypeDesktopMask)
- w->paint.opacity = OPAQUE;
+ w->recalcType ();
+ w->recalcActions ();
- (*d->matchPropertyChanged) (d, w);
+ matchPropertyChanged (w);
}
}
}
else if (event->xproperty.atom == XA_WM_NORMAL_HINTS)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
{
- updateNormalHints (w);
- recalcWindowActions (w);
+ w->updateNormalHints ();
+ w->recalcActions ();
}
}
else if (event->xproperty.atom == XA_WM_HINTS)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- updateWmHints (w);
+ w->updateWmHints ();
}
else if (event->xproperty.atom == XA_WM_TRANSIENT_FOR)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
{
- updateTransientHint (w);
- recalcWindowActions (w);
+ w->updateTransientHint ();
+ w->recalcActions ();
}
}
- else if (event->xproperty.atom == d->wmClientLeaderAtom)
+ else if (event->xproperty.atom == priv->atoms.wmClientLeader)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- w->clientLeader = getClientLeader (w);
+ w->clientLeader () = w->getClientLeader ();
}
- else if (event->xproperty.atom == d->wmIconGeometryAtom)
+ else if (event->xproperty.atom == priv->atoms.wmIconGeometry)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- updateIconGeometry (w);
+ w->updateIconGeometry ();
}
- else if (event->xproperty.atom == d->winOpacityAtom)
+ else if (event->xproperty.atom == priv->atoms.winOpacity)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w && (w->type & CompWindowTypeDesktopMask) == 0)
- {
- w->opacity = OPAQUE;
- w->opacityPropSet =
- readWindowProp32 (d, w->id, d->winOpacityAtom, &w->opacity);
-
- updateWindowOpacity (w);
- }
+ w = findWindow (event->xproperty.window);
+ if (w)
+ w->updateOpacity ();
}
- else if (event->xproperty.atom == d->winBrightnessAtom)
+ else if (event->xproperty.atom == priv->atoms.winBrightness)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- {
- GLushort brightness;
-
- brightness = getWindowProp32 (d, w->id,
- d->winBrightnessAtom,
- BRIGHT);
- if (brightness != w->brightness)
- {
- w->brightness = brightness;
- if (w->alive)
- {
- w->paint.brightness = w->brightness;
- addWindowDamage (w);
- }
- }
- }
+ w->updateBrightness ();
}
- else if (event->xproperty.atom == d->winSaturationAtom)
+ else if (event->xproperty.atom == priv->atoms.winSaturation)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w && w->screen->canDoSaturated)
- {
- GLushort saturation;
-
- saturation = getWindowProp32 (d, w->id,
- d->winSaturationAtom,
- COLOR);
- if (saturation != w->saturation)
- {
- w->saturation = saturation;
- if (w->alive)
- {
- w->paint.saturation = w->saturation;
- addWindowDamage (w);
- }
- }
- }
+ w = findWindow (event->xproperty.window);
+ if (w)
+ w->updateSaturation ();
}
- else if (event->xproperty.atom == d->xBackgroundAtom[0] ||
- event->xproperty.atom == d->xBackgroundAtom[1])
+ else if (event->xproperty.atom == priv->atoms.xBackground[0] ||
+ event->xproperty.atom == priv->atoms.xBackground[1])
{
- s = findScreenAtDisplay (d, event->xproperty.window);
+ s = findScreen (event->xproperty.window);
if (s)
- {
- finiTexture (s, &s->backgroundTexture);
- initTexture (s, &s->backgroundTexture);
-
- if (s->backgroundLoaded)
- {
- s->backgroundLoaded = FALSE;
- damageScreen (s);
- }
- }
+ s->updateBackground ();
}
- else if (event->xproperty.atom == d->wmStrutAtom ||
- event->xproperty.atom == d->wmStrutPartialAtom)
+ else if (event->xproperty.atom == priv->atoms.wmStrut ||
+ event->xproperty.atom == priv->atoms.wmStrutPartial)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
{
- if (updateWindowStruts (w))
- updateWorkareaForScreen (w->screen);
+ if (w->updateStruts ())
+ w->screen ()->updateWorkarea ();
}
}
- else if (event->xproperty.atom == d->mwmHintsAtom)
+ else if (event->xproperty.atom == priv->atoms.mwmHints)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- {
- getMwmHints (d, w->id, &w->mwmFunc, &w->mwmDecor);
-
- recalcWindowActions (w);
- }
+ w->updateMwmHints ();
}
- else if (event->xproperty.atom == d->wmProtocolsAtom)
+ else if (event->xproperty.atom == priv->atoms.wmProtocols)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- w->protocols = getProtocols (d, w->id);
+ w->protocols () = getProtocols (w->id ());
}
- else if (event->xproperty.atom == d->wmIconAtom)
+ else if (event->xproperty.atom == priv->atoms.wmIcon)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- freeWindowIcons (w);
+ w->freeIcons ();
}
- else if (event->xproperty.atom == d->startupIdAtom)
+ else if (event->xproperty.atom == priv->atoms.startupId)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- {
- if (w->startupId)
- free (w->startupId);
-
- w->startupId = getStartupId (w);
- }
+ w->updateStartupId ();
}
else if (event->xproperty.atom == XA_WM_CLASS)
{
- w = findWindowAtDisplay (d, event->xproperty.window);
+ w = findWindow (event->xproperty.window);
if (w)
- updateWindowClassHints (w);
+ w->updateClassHints ();
}
break;
case MotionNotify:
break;
case ClientMessage:
- if (event->xclient.message_type == d->winActiveAtom)
+ if (event->xclient.message_type == priv->atoms.winActive)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
{
/* use focus stealing prevention if request came from an
application (which means data.l[0] is 1 */
if (event->xclient.data.l[0] != 1 ||
- allowWindowFocus (w, 0, event->xclient.data.l[1]))
+ w->allowWindowFocus (0, event->xclient.data.l[1]))
{
- (*w->screen->activateWindow) (w);
+ w->activate ();
}
}
}
- else if (event->xclient.message_type == d->winOpacityAtom)
+ else if (event->xclient.message_type == priv->atoms.winOpacity)
{
- w = findWindowAtDisplay (d, event->xclient.window);
- if (w && (w->type & CompWindowTypeDesktopMask) == 0)
+ w = findWindow (event->xclient.window);
+ if (w && (w->type () & CompWindowTypeDesktopMask) == 0)
{
GLushort opacity = event->xclient.data.l[0] >> 16;
- setWindowProp32 (d, w->id, d->winOpacityAtom, opacity);
+ setWindowProp32 (w->id (), priv->atoms.winOpacity, opacity);
}
}
- else if (event->xclient.message_type == d->winBrightnessAtom)
+ else if (event->xclient.message_type == priv->atoms.winBrightness)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
{
GLushort brightness = event->xclient.data.l[0] >> 16;
- setWindowProp32 (d, w->id, d->winBrightnessAtom, brightness);
+ setWindowProp32 (w->id (), priv->atoms.winBrightness,
+ brightness);
}
}
- else if (event->xclient.message_type == d->winSaturationAtom)
+ else if (event->xclient.message_type == priv->atoms.winSaturation)
{
- w = findWindowAtDisplay (d, event->xclient.window);
- if (w && w->screen->canDoSaturated)
+ w = findWindow (event->xclient.window);
+ if (w)
{
GLushort saturation = event->xclient.data.l[0] >> 16;
- setWindowProp32 (d, w->id, d->winSaturationAtom, saturation);
+ setWindowProp32 (w->id (), priv->atoms.winSaturation,
+ saturation);
}
}
- else if (event->xclient.message_type == d->winStateAtom)
+ else if (event->xclient.message_type == priv->atoms.winState)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
{
unsigned long wState, state;
int i;
- wState = w->state;
+ wState = w->state ();
for (i = 1; i < 3; i++)
{
- state = windowStateMask (d, event->xclient.data.l[i]);
+ state = windowStateMask (event->xclient.data.l[i]);
if (state & ~CompWindowStateHiddenMask)
{
@@ -1731,14 +1594,15 @@ handleEvent (CompDisplay *d,
}
}
- wState = constrainWindowState (wState, w->actions);
- if (w->id == d->activeWindow)
+ wState = CompWindow::constrainWindowState (wState,
+ w->actions ());
+ if (w->id () == priv->activeWindow)
wState &= ~CompWindowStateDemandsAttentionMask;
- if (wState != w->state)
+ if (wState != w->state ())
{
CompStackingUpdateMode stackingUpdateMode;
- unsigned long dState = wState ^ w->state;
+ unsigned long dState = wState ^ w->state ();
stackingUpdateMode = CompStackingUpdateModeNone;
@@ -1751,69 +1615,46 @@ handleEvent (CompDisplay *d,
CompWindowStateMaximizedVertMask))
stackingUpdateMode = CompStackingUpdateModeNormal;
- changeWindowState (w, wState);
+ w->changeState (wState);
- updateWindowAttributes (w, stackingUpdateMode);
+ w->updateAttributes (stackingUpdateMode);
}
}
}
- else if (event->xclient.message_type == d->wmProtocolsAtom)
+ else if (event->xclient.message_type == priv->atoms.wmProtocols)
{
- if (event->xclient.data.l[0] == d->wmPingAtom)
+ if (event->xclient.data.l[0] == priv->atoms.wmPing)
{
- w = findWindowAtDisplay (d, event->xclient.data.l[2]);
+ w = findWindow (event->xclient.data.l[2]);
if (w)
- {
- if (!w->alive)
- {
- w->alive = TRUE;
- w->paint.saturation = w->saturation;
- w->paint.brightness = w->brightness;
-
- if (w->lastCloseRequestTime)
- {
- toolkitAction (w->screen,
- d->toolkitActionForceQuitDialogAtom,
- w->lastCloseRequestTime,
- w->id,
- FALSE,
- 0,
- 0);
-
- w->lastCloseRequestTime = 0;
- }
-
- addWindowDamage (w);
- }
- w->lastPong = d->lastPing;
- }
+ w->handlePing (priv->lastPing);
}
}
- else if (event->xclient.message_type == d->closeWindowAtom)
+ else if (event->xclient.message_type == priv->atoms.closeWindow)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
- closeWindow (w, event->xclient.data.l[0]);
+ w->close (event->xclient.data.l[0]);
}
- else if (event->xclient.message_type == d->desktopGeometryAtom)
+ else if (event->xclient.message_type == priv->atoms.desktopGeometry)
{
- s = findScreenAtDisplay (d, event->xclient.window);
+ s = findScreen (event->xclient.window);
if (s)
{
CompOptionValue value;
- value.i = event->xclient.data.l[0] / s->width;
+ value.i = event->xclient.data.l[0] / s->width ();
- (*core.setOptionForPlugin) (&s->base, "core", "hsize", &value);
+ core->setOptionForPlugin (s, "core", "hsize", &value);
- value.i = event->xclient.data.l[1] / s->height;
+ value.i = event->xclient.data.l[1] / s->height ();
- (*core.setOptionForPlugin) (&s->base, "core", "vsize", &value);
+ core->setOptionForPlugin (s, "core", "vsize", &value);
}
}
- else if (event->xclient.message_type == d->moveResizeWindowAtom)
+ else if (event->xclient.message_type == priv->atoms.moveResizeWindow)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
{
unsigned int xwcm = 0;
@@ -1848,12 +1689,12 @@ handleEvent (CompDisplay *d,
gravity = event->xclient.data.l[0] & 0xFF;
- moveResizeWindow (w, &xwc, xwcm, gravity);
+ w->moveResize (&xwc, xwcm, gravity);
}
}
- else if (event->xclient.message_type == d->restackWindowAtom)
+ else if (event->xclient.message_type == priv->atoms.restackWindow)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
{
/* TODO: other stack modes than Above and Below */
@@ -1861,186 +1702,121 @@ handleEvent (CompDisplay *d,
{
CompWindow *sibling;
- sibling = findWindowAtDisplay (d, event->xclient.data.l[1]);
+ sibling = findWindow (event->xclient.data.l[1]);
if (sibling)
{
if (event->xclient.data.l[2] == Above)
- restackWindowAbove (w, sibling);
+ w->restackAbove (sibling);
else if (event->xclient.data.l[2] == Below)
- restackWindowBelow (w, sibling);
+ w->restackBelow (sibling);
}
}
else
{
if (event->xclient.data.l[2] == Above)
- raiseWindow (w);
+ w->raise ();
else if (event->xclient.data.l[2] == Below)
- lowerWindow (w);
+ w->lower ();
}
}
}
- else if (event->xclient.message_type == d->wmChangeStateAtom)
+ else if (event->xclient.message_type == priv->atoms.wmChangeState)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
{
if (event->xclient.data.l[0] == IconicState)
{
- if (w->actions & CompWindowActionMinimizeMask)
- minimizeWindow (w);
+ if (w->actions () & CompWindowActionMinimizeMask)
+ w->minimize ();
}
else if (event->xclient.data.l[0] == NormalState)
- unminimizeWindow (w);
+ w->unminimize ();
}
}
- else if (event->xclient.message_type == d->showingDesktopAtom)
+ else if (event->xclient.message_type == priv->atoms.showingDesktop)
{
- for (s = d->screens; s; s = s->next)
+ for (s = priv->screens; s; s = s->next)
{
- if (event->xclient.window == s->root ||
+ if (event->xclient.window == s->root () ||
event->xclient.window == None)
{
if (event->xclient.data.l[0])
- (*s->enterShowDesktopMode) (s);
+ s->enterShowDesktopMode ();
else
- (*s->leaveShowDesktopMode) (s, NULL);
+ s->leaveShowDesktopMode (NULL);
}
}
}
- else if (event->xclient.message_type == d->numberOfDesktopsAtom)
+ else if (event->xclient.message_type == priv->atoms.numberOfDesktops)
{
- s = findScreenAtDisplay (d, event->xclient.window);
+ s = findScreen (event->xclient.window);
if (s)
{
CompOptionValue value;
value.i = event->xclient.data.l[0];
- (*core.setOptionForPlugin) (&s->base,
- "core", "number_of_desktops",
- &value);
+ core->setOptionForPlugin (s, "core", "number_of_desktops",
+ &value);
}
}
- else if (event->xclient.message_type == d->currentDesktopAtom)
+ else if (event->xclient.message_type == priv->atoms.currentDesktop)
{
- s = findScreenAtDisplay (d, event->xclient.window);
+ s = findScreen (event->xclient.window);
if (s)
- setCurrentDesktop (s, event->xclient.data.l[0]);
+ s->setCurrentDesktop (event->xclient.data.l[0]);
}
- else if (event->xclient.message_type == d->winDesktopAtom)
+ else if (event->xclient.message_type == priv->atoms.winDesktop)
{
- w = findWindowAtDisplay (d, event->xclient.window);
+ w = findWindow (event->xclient.window);
if (w)
- setDesktopForWindow (w, event->xclient.data.l[0]);
+ w->setDesktop (event->xclient.data.l[0]);
}
break;
case MappingNotify:
- updateModifierMappings (d);
+ updateModifierMappings ();
break;
case MapRequest:
- w = findWindowAtDisplay (d, event->xmaprequest.window);
+ w = findWindow (event->xmaprequest.window);
if (w)
{
XWindowAttributes attr;
- Bool doMapProcessing = TRUE;
+ bool doMapProcessing = true;
/* We should check the override_redirect flag here, because the
client might have changed it while being unmapped. */
- if (XGetWindowAttributes (d->display, w->id, &attr))
+ if (XGetWindowAttributes (priv->dpy, w->id (), &attr))
{
- if (w->attrib.override_redirect != attr.override_redirect)
+ if (w->attrib ().override_redirect != attr.override_redirect)
{
- w->attrib.override_redirect = attr.override_redirect;
- recalcWindowType (w);
- recalcWindowActions (w);
+ w->attrib ().override_redirect = attr.override_redirect;
+ w->recalcType ();
+ w->recalcActions ();
- (*d->matchPropertyChanged) (d, w);
+ matchPropertyChanged (w);
}
}
- w->managed = TRUE;
+ w->managed () = true;
- if (w->state & CompWindowStateHiddenMask)
- if (!w->minimized && !w->inShowDesktopMode)
- doMapProcessing = FALSE;
+ if (w->state () & CompWindowStateHiddenMask)
+ if (!w->minimized () && !w->inShowDesktopMode ())
+ doMapProcessing = false;
if (doMapProcessing)
- {
- Bool allowFocus;
- CompStackingUpdateMode stackingMode;
-
- w->initialViewportX = w->screen->x;
- w->initialViewportY = w->screen->y;
-
- w->initialTimestampSet = FALSE;
-
- applyStartupProperties (w->screen, w);
-
- if (!w->placed)
- {
- int newX, newY;
- int gravity = w->sizeHints.win_gravity;
- XWindowChanges xwc;
- unsigned int xwcm;
-
- /* adjust for gravity */
- xwc.x = w->serverX;
- xwc.y = w->serverY;
- xwc.width = w->serverWidth;
- xwc.height = w->serverHeight;
-
- xwcm = adjustConfigureRequestForGravity (w, &xwc,
- CWX | CWY,
- gravity);
-
- if ((*w->screen->placeWindow) (w, xwc.x, xwc.y,
- &newX, &newY))
- {
- xwc.x = newX;
- xwc.y = newY;
- xwcm |= CWX | CWY;
- }
-
- if (xwcm)
- configureXWindow (w, xwcm, &xwc);
-
- w->placed = TRUE;
- }
-
- allowFocus = allowWindowFocus (w, NO_FOCUS_MASK, 0);
-
- if (!allowFocus && (w->type & ~NO_FOCUS_MASK))
- stackingMode = CompStackingUpdateModeInitialMapDeniedFocus;
- else
- stackingMode = CompStackingUpdateModeInitialMap;
+ w->processMap ();
- updateWindowAttributes (w, stackingMode);
-
- if (w->minimized)
- unminimizeWindow (w);
-
- (*w->screen->leaveShowDesktopMode) (w->screen, w);
-
- if (!(w->state & CompWindowStateHiddenMask))
- {
- w->pendingMaps++;
- XMapWindow (d->display, w->id);
- }
-
- if (allowFocus)
- moveInputFocusToWindow (w);
- }
-
- setWindowProp (d, w->id, d->winDesktopAtom, w->desktop);
+ setWindowProp (w->id (), priv->atoms.winDesktop, w->desktop ());
}
else
{
- XMapWindow (d->display, event->xmaprequest.window);
+ XMapWindow (priv->dpy, event->xmaprequest.window);
}
break;
case ConfigureRequest:
- w = findWindowAtDisplay (d, event->xconfigurerequest.window);
- if (w && w->managed)
+ w = findWindow (event->xconfigurerequest.window);
+ if (w && w->managed ())
{
XWindowChanges xwc;
@@ -2052,7 +1828,7 @@ handleEvent (CompDisplay *d,
xwc.height = event->xconfigurerequest.height;
xwc.border_width = event->xconfigurerequest.border_width;
- moveResizeWindow (w, &xwc, event->xconfigurerequest.value_mask, 0);
+ w->moveResize (&xwc, event->xconfigurerequest.value_mask, 0);
if (event->xconfigurerequest.value_mask & CWStackMode)
{
@@ -2062,30 +1838,30 @@ handleEvent (CompDisplay *d,
if (event->xconfigurerequest.value_mask & CWSibling)
{
above = event->xconfigurerequest.above;
- sibling = findTopLevelWindowAtDisplay (d, above);
+ sibling = findTopLevelWindow (above);
}
switch (event->xconfigurerequest.detail) {
case Above:
- if (allowWindowFocus (w, NO_FOCUS_MASK, 0))
+ if (w->allowWindowFocus (NO_FOCUS_MASK, 0))
{
if (above)
{
if (sibling)
- restackWindowAbove (w, sibling);
+ w->restackAbove (sibling);
}
else
- raiseWindow (w);
+ w->raise ();
}
break;
case Below:
if (above)
{
if (sibling)
- restackWindowBelow (w, sibling);
+ w->restackBelow (sibling);
}
else
- lowerWindow (w);
+ w->lower ();
break;
default:
/* no handling of the TopIf, BottomIf, Opposite cases -
@@ -2109,9 +1885,9 @@ handleEvent (CompDisplay *d,
xwc.border_width = event->xconfigurerequest.border_width;
if (w)
- configureXWindow (w, xwcm, &xwc);
+ w->configureXWindow (xwcm, &xwc);
else
- XConfigureWindow (d->display, event->xconfigurerequest.window,
+ XConfigureWindow (priv->dpy, event->xconfigurerequest.window,
xwcm, &xwc);
}
break;
@@ -2120,31 +1896,31 @@ handleEvent (CompDisplay *d,
case FocusIn:
if (event->xfocus.mode != NotifyGrab)
{
- w = findTopLevelWindowAtDisplay (d, event->xfocus.window);
- if (w && w->managed)
+ w = findTopLevelWindow (event->xfocus.window);
+ if (w && w->managed ())
{
- unsigned int state = w->state;
+ unsigned int state = w->state ();
- if (w->id != d->activeWindow)
+ if (w->id () != priv->activeWindow)
{
- d->activeWindow = w->id;
- w->activeNum = w->screen->activeNum++;
+ priv->activeWindow = w->id ();
+ w->activeNum () = w->screen ()->activeNum ()++;
- addToCurrentActiveWindowHistory (w->screen, w->id);
+ w->screen ()->addToCurrentActiveWindowHistory (w->id ());
- XChangeProperty (d->display, w->screen->root,
- d->winActiveAtom,
+ XChangeProperty (priv->dpy , w->screen ()->root (),
+ priv->atoms.winActive,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) &w->id, 1);
+ (unsigned char *) &priv->activeWindow, 1);
}
state &= ~CompWindowStateDemandsAttentionMask;
- changeWindowState (w, state);
+ w->changeState (state);
}
}
break;
case EnterNotify:
- if (!d->screens->maxGrab &&
+ if (!priv->screens->maxGrab () &&
event->xcrossing.mode != NotifyGrab &&
event->xcrossing.mode != NotifyUngrab &&
event->xcrossing.detail != NotifyInferior)
@@ -2152,50 +1928,50 @@ handleEvent (CompDisplay *d,
Bool raise;
int delay;
- raise = d->opt[COMP_DISPLAY_OPTION_AUTORAISE].value.b;
- delay = d->opt[COMP_DISPLAY_OPTION_AUTORAISE_DELAY].value.i;
+ raise = priv->opt[COMP_DISPLAY_OPTION_AUTORAISE].value.b;
+ delay = priv->opt[COMP_DISPLAY_OPTION_AUTORAISE_DELAY].value.i;
- s = findScreenAtDisplay (d, event->xcrossing.root);
+ s = findScreen (event->xcrossing.root);
if (s)
{
- w = findTopLevelWindowAtScreen (s, event->xcrossing.window);
+ w = s->findTopLevelWindow (event->xcrossing.window);
}
else
w = NULL;
- if (w && w->id != d->below)
+ if (w && w->id () != priv->below)
{
- d->below = w->id;
+ priv->below = w->id ();
- if (!d->opt[COMP_DISPLAY_OPTION_CLICK_TO_FOCUS].value.b)
+ if (!priv->opt[COMP_DISPLAY_OPTION_CLICK_TO_FOCUS].value.b)
{
- if (d->autoRaiseHandle &&
- d->autoRaiseWindow != w->id)
+ if (priv->autoRaiseHandle &&
+ priv->autoRaiseWindow != w->id ())
{
- compRemoveTimeout (d->autoRaiseHandle);
- d->autoRaiseHandle = 0;
+ core->removeTimeout (priv->autoRaiseHandle);
+ priv->autoRaiseHandle = 0;
}
- if (w->type & ~(CompWindowTypeDockMask |
- CompWindowTypeDesktopMask))
+ if (w->type () & ~(CompWindowTypeDockMask |
+ CompWindowTypeDesktopMask))
{
- moveInputFocusToWindow (w);
+ w->moveInputFocusTo ();
if (raise)
{
if (delay > 0)
{
- d->autoRaiseWindow = w->id;
- d->autoRaiseHandle =
- compAddTimeout (delay, (float) delay * 1.2,
- autoRaiseTimeout, d);
+ priv->autoRaiseWindow = w->id ();
+ priv->autoRaiseHandle =
+ core->addTimeout (delay, (float) delay * 1.2,
+ autoRaiseTimeout, this);
}
else
{
CompStackingUpdateMode mode =
CompStackingUpdateModeNormal;
- updateWindowAttributes (w, mode);
+ w->updateAttributes (mode);
}
}
}
@@ -2206,82 +1982,55 @@ handleEvent (CompDisplay *d,
case LeaveNotify:
if (event->xcrossing.detail != NotifyInferior)
{
- if (event->xcrossing.window == d->below)
- d->below = None;
+ if (event->xcrossing.window == priv->below)
+ priv->below = None;
}
break;
default:
- if (event->type == d->damageEvent + XDamageNotify)
+ if (event->type == priv->damageEvent + XDamageNotify)
{
XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
- if (lastDamagedWindow && de->drawable == lastDamagedWindow->id)
+ if (lastDamagedWindow && de->drawable == lastDamagedWindow->id ())
{
w = lastDamagedWindow;
}
else
{
- w = findWindowAtDisplay (d, de->drawable);
+ w = findWindow (de->drawable);
if (w)
lastDamagedWindow = w;
}
if (w)
- {
- w->texture->oldMipmaps = TRUE;
-
- if (w->syncWait)
- {
- if (w->nDamage == w->sizeDamage)
- {
- w->damageRects = (XRectangle *) realloc (w->damageRects,
- (w->sizeDamage + 1) *
- sizeof (XRectangle));
- w->sizeDamage += 1;
- }
-
- w->damageRects[w->nDamage].x = de->area.x;
- w->damageRects[w->nDamage].y = de->area.y;
- w->damageRects[w->nDamage].width = de->area.width;
- w->damageRects[w->nDamage].height = de->area.height;
- w->nDamage++;
- }
- else
- {
- handleWindowDamageRect (w,
- de->area.x,
- de->area.y,
- de->area.width,
- de->area.height);
- }
- }
+ w->processDamage (de);
}
- else if (d->shapeExtension &&
- event->type == d->shapeEvent + ShapeNotify)
+ else if (priv->shapeExtension &&
+ event->type == priv->shapeEvent + ShapeNotify)
{
- w = findWindowAtDisplay (d, ((XShapeEvent *) event)->window);
+ w = findWindow (((XShapeEvent *) event)->window);
if (w)
{
- if (w->mapNum)
+ if (w->mapNum ())
{
- addWindowDamage (w);
- updateWindowRegion (w);
- addWindowDamage (w);
+ w->addDamage ();
+ w->updateRegion ();
+ w->addDamage ();
}
}
}
- else if (d->randrExtension &&
- event->type == d->randrEvent + RRScreenChangeNotify)
+ else if (priv->randrExtension &&
+ event->type == priv->randrEvent + RRScreenChangeNotify)
{
XRRScreenChangeNotifyEvent *rre;
rre = (XRRScreenChangeNotifyEvent *) event;
- s = findScreenAtDisplay (d, rre->root);
+ s = findScreen (rre->root);
if (s)
- detectRefreshRateOfScreen (s);
+ s->detectRefreshRate ();
}
- else if (event->type == d->syncEvent + XSyncAlarmNotify)
+ else if (event->type == priv->syncEvent + XSyncAlarmNotify)
{
XSyncAlarmNotifyEvent *sa;
@@ -2289,13 +2038,13 @@ handleEvent (CompDisplay *d,
w = NULL;
- for (s = d->screens; s; s = s->next)
- for (w = s->windows; w; w = w->next)
- if (w->syncAlarm == sa->alarm)
+ for (s = priv->screens; s; s = s->next)
+ for (w = s->windows (); w; w = w->next)
+ if (w->syncAlarm () == sa->alarm)
break;
if (w)
- handleSyncAlarm (w);
+ w->handleSyncAlarm ();
}
break;
}
diff --git a/src/fragment.cpp b/src/fragment.cpp
index 99c38cc..32794ef 100644
--- a/src/fragment.cpp
+++ b/src/fragment.cpp
@@ -160,7 +160,7 @@ findFragmentFunction (CompScreen *s,
{
CompFunction *function;
- for (function = s->fragmentFunctions; function; function = function->next)
+ for (function = s->fragmentFunctions (); function; function = function->next)
{
if (function->id == id)
return function;
@@ -175,7 +175,7 @@ findFragmentFunctionWithName (CompScreen *s,
{
CompFunction *function;
- for (function = s->fragmentFunctions; function; function = function->next)
+ for (function = s->fragmentFunctions (); function; function = function->next)
{
if (strcmp (function->name, name) == 0)
return function;
@@ -192,7 +192,7 @@ findFragmentProgram (CompScreen *s,
CompProgram *program;
int i;
- for (program = s->fragmentPrograms; program; program = program->next)
+ for (program = s->fragmentPrograms (); program; program = program->next)
{
if (nSignature != program->nSignature)
continue;
@@ -671,8 +671,8 @@ getFragmentProgram (CompScreen *s,
program = buildFragmentProgram (s, attrib);
if (program)
{
- program->next = s->fragmentPrograms;
- s->fragmentPrograms = program;
+ program->next = s->fragmentPrograms ();
+ s->fragmentPrograms () = program;
}
}
@@ -1140,7 +1140,7 @@ addBlendOpToFunctionData (CompFunctionData *data,
static int
allocFunctionId (CompScreen *s)
{
- return ++s->lastFunctionId;
+ return ++s->lastFunctionId ();
}
int
@@ -1190,8 +1190,8 @@ createFragmentFunction (CompScreen *s,
function->mask = COMP_FUNCTION_ARB_MASK;
function->id = allocFunctionId (s);
- function->next = s->fragmentFunctions;
- s->fragmentFunctions = function;
+ function->next = s->fragmentFunctions ();
+ s->fragmentFunctions () = function;
if (nameBuffer)
free (nameBuffer);
@@ -1207,7 +1207,7 @@ destroyFragmentFunction (CompScreen *s,
CompProgram *program, *prevProgram = NULL;
int i;
- for (function = s->fragmentFunctions; function; function = function->next)
+ for (function = s->fragmentFunctions (); function; function = function->next)
{
if (function->id == id)
break;
@@ -1218,7 +1218,7 @@ destroyFragmentFunction (CompScreen *s,
if (!function)
return;
- program = s->fragmentPrograms;
+ program = s->fragmentPrograms ();
while (program)
{
for (i = 0; i < program->nSignature; i++)
@@ -1234,7 +1234,7 @@ destroyFragmentFunction (CompScreen *s,
if (prevProgram)
prevProgram->next = program->next;
else
- s->fragmentPrograms = program->next;
+ s->fragmentPrograms () = program->next;
program = program->next;
@@ -1253,7 +1253,7 @@ destroyFragmentFunction (CompScreen *s,
if (prevFunction)
prevFunction->next = function->next;
else
- s->fragmentFunctions = function->next;
+ s->fragmentFunctions () = function->next;
finiFunctionData (&function->data[COMP_FUNCTION_TYPE_ARB]);
free (function->name);
@@ -1275,7 +1275,7 @@ getSaturateFragmentFunction (CompScreen *s,
else
target = COMP_FETCH_TARGET_RECT;
- if (!s->saturateFunction[target][param])
+ if (!s->getSaturateFunction (target, param))
{
static const char *saturateData =
"MUL temp, output, { 1.0, 1.0, 1.0, 0.0 };"
@@ -1314,14 +1314,14 @@ getSaturateFragmentFunction (CompScreen *s,
return 0;
}
- s->saturateFunction[target][param] =
+ s->getSaturateFunction (target, param) =
createFragmentFunction (s, "__core_saturate", data);
destroyFunctionData (data);
}
}
- return s->saturateFunction[target][param];
+ return s->getSaturateFunction (target, param);
}
int
@@ -1369,7 +1369,7 @@ initFragmentAttrib (FragmentAttrib *attrib,
memset (attrib->function, 0, sizeof (attrib->function));
}
-Bool
+bool
enableFragmentAttrib (CompScreen *s,
FragmentAttrib *attrib,
Bool *blending)
@@ -1378,12 +1378,12 @@ enableFragmentAttrib (CompScreen *s,
GLenum type;
Bool programBlending;
- if (!s->fragmentProgram)
- return FALSE;
+ if (!s->fragmentProgram ())
+ return false;
name = getFragmentProgram (s, attrib, &type, &programBlending);
if (!name)
- return FALSE;
+ return false;
*blending = !programBlending;
@@ -1391,7 +1391,7 @@ enableFragmentAttrib (CompScreen *s,
(*s->bindProgram) (type, name);
- return TRUE;
+ return true;
}
void
diff --git a/src/main.cpp b/src/main.cpp
index 6ca3bb4..3629c88 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -98,59 +98,6 @@ usage (void)
programName);
}
-void
-compLogMessage (CompDisplay *d,
- const char *componentName,
- CompLogLevel level,
- const char *format,
- ...)
-{
- va_list args;
- char message[2048];
-
- va_start (args, format);
-
- vsnprintf (message, 2048, format, args);
-
- if (d)
- (*d->logMessage) (d, componentName, level, message);
- else
- logMessage (d, componentName, level, message);
-
- va_end (args);
-}
-
-void
-logMessage (CompDisplay *d,
- const char *componentName,
- CompLogLevel level,
- const char *message)
-{
- fprintf (stderr, "%s (%s) - %s: %s\n",
- programName, componentName,
- logLevelToString (level), message);
-}
-
-const char *
-logLevelToString (CompLogLevel level)
-{
- switch (level) {
- case CompLogLevelFatal:
- return "Fatal";
- case CompLogLevelError:
- return "Error";
- case CompLogLevelWarn:
- return "Warn";
- case CompLogLevelInfo:
- return "Info";
- case CompLogLevelDebug:
- return "Debug";
- default:
- break;
- }
-
- return "Unknown";
-}
static void
signalHandler (int sig)
@@ -425,21 +372,26 @@ main (int argc, char **argv)
compAddMetadataFromFile (&coreMetadata, "core");
- if (!initCore ())
+ core = new CompCore();
+
+ if (!core)
+ return 1;
+
+ if (!core->init ())
return 1;
if (!disableSm)
initSession (clientId);
- if (!addDisplay (displayName))
+ if (!core->addDisplay (displayName))
return 1;
- eventLoop ();
+ core->eventLoop ();
if (!disableSm)
closeSession ();
- finiCore ();
+ delete core;
compFiniMetadata (&coreMetadata);
xmlCleanupParser ();
diff --git a/src/match.cpp b/src/match.cpp
index 935ec50..e8697df 100644
--- a/src/match.cpp
+++ b/src/match.cpp
@@ -27,6 +27,7 @@
#include <string.h>
#include <compiz-core.h>
+#include "privatedisplay.h"
static void
matchResetOps (CompDisplay *display,
@@ -563,7 +564,7 @@ matchUpdateOps (CompDisplay *display,
matchUpdateOps (display, op->group.op, op->group.nOp);
break;
case CompMatchOpTypeExp:
- (*display->matchInitExp) (display, &op->exp.e, op->exp.value);
+ display->matchInitExp (&op->exp.e, op->exp.value);
break;
}
@@ -643,7 +644,7 @@ matchEvalTypeExp (CompDisplay *display,
CompWindow *window,
CompPrivate c_private)
{
- return (c_private.uval & window->wmType);
+ return (c_private.uval & window->wmType ());
}
static Bool
@@ -651,7 +652,7 @@ matchEvalStateExp (CompDisplay *display,
CompWindow *window,
CompPrivate c_private)
{
- return (c_private.uval & window->state);
+ return (c_private.uval & window->state ());
}
static Bool
@@ -659,7 +660,7 @@ matchEvalIdExp (CompDisplay *display,
CompWindow *window,
CompPrivate c_private)
{
- return (c_private.val == window->id);
+ return (c_private.val == window->id ());
}
static Bool
@@ -667,16 +668,16 @@ matchEvalOverrideRedirectExp (CompDisplay *display,
CompWindow *window,
CompPrivate c_private)
{
- Bool overrideRedirect = window->attrib.override_redirect;
+ Bool overrideRedirect = window->attrib ().override_redirect;
return ((c_private.val == 1 && overrideRedirect) ||
(c_private.val == 0 && !overrideRedirect));
}
void
-matchInitExp (CompDisplay *display,
- CompMatchExp *exp,
- const char *value)
+CompDisplay::matchInitExp (CompMatchExp *exp, const char *value)
{
+ WRAPABLE_HND_FUNC(matchInitExp, exp, value)
+
if (strncmp (value, "xid=", 4) == 0)
{
exp->eval = matchEvalIdExp;
@@ -698,7 +699,7 @@ matchInitExp (CompDisplay *display,
value += 5;
exp->eval = matchEvalTypeExp;
- exp->priv.uval = windowTypeFromString (value);
+ exp->priv.uval = CompWindow::windowTypeFromString (value);
}
}
@@ -732,8 +733,10 @@ matchUpdateMatchOptions (CompOption *option,
}
void
-matchExpHandlerChanged (CompDisplay *display)
+CompDisplay::matchExpHandlerChanged ()
{
+ WRAPABLE_HND_FUNC(matchExpHandlerChanged)
+
CompOption *option;
int nOption;
CompPlugin *p;
@@ -742,32 +745,22 @@ matchExpHandlerChanged (CompDisplay *display)
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, &display->base, &nOption);
+ option = p->vTable->getObjectOptions (this, &nOption);
matchUpdateMatchOptions (option, nOption);
}
- for (s = display->screens; s; s = s->next)
+ for (s = priv->screens; s; s = s->next)
{
for (p = getPlugins (); p; p = p->next)
{
- if (!p->vTable->getObjectOptions)
- continue;
-
- option = (*p->vTable->getObjectOptions) (p, &s->base, &nOption);
+ option = p->vTable->getObjectOptions (s, &nOption);
matchUpdateMatchOptions (option, nOption);
}
-
- for (w = s->windows; w; w = w->next)
- updateWindowOpacity (w);
}
}
void
-matchPropertyChanged (CompDisplay *display,
- CompWindow *w)
+CompDisplay::matchPropertyChanged (CompWindow *w)
{
- updateWindowOpacity (w);
+ WRAPABLE_HND_FUNC(matchPropertyChanged, w)
}
diff --git a/src/metadata.cpp b/src/metadata.cpp
index 5e7d365..88bdce6 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -597,8 +597,8 @@ initKeyValue (CompDisplay *d,
{
CompScreen *s;
- for (s = d->screens; s; s = s->next)
- addScreenAction (s, &v->action);
+ for (s = d->screens (); s; s = s->next)
+ s->addAction (&v->action);
}
}
@@ -634,8 +634,8 @@ initButtonValue (CompDisplay *d,
{
CompScreen *s;
- for (s = d->screens; s; s = s->next)
- addScreenAction (s, &v->action);
+ for (s = d->screens (); s; s = s->next)
+ s->addAction (&v->action);
}
}
@@ -675,8 +675,8 @@ initEdgeValue (CompDisplay *d,
{
CompScreen *s;
- for (s = d->screens; s; s = s->next)
- addScreenAction (s, &v->action);
+ for (s = d->screens (); s; s = s->next)
+ s->addAction (&v->action);
}
}
@@ -1106,7 +1106,7 @@ compInitScreenOptionFromMetadata (CompScreen *s,
sprintf (str, "/compiz/%s/screen//option[@name=\"%s\"]", m->path, name);
- return initOptionFromMetadataPath (s->display, m, o, BAD_CAST str);
+ return initOptionFromMetadataPath (s->display (), m, o, BAD_CAST str);
}
static void
@@ -1123,7 +1123,7 @@ finiScreenOptionValue (CompScreen *s,
case CompOptionTypeEdge:
case CompOptionTypeBell:
if (v->action.state & CompActionStateAutoGrab)
- removeScreenAction (s, &v->action);
+ s->removeAction (&v->action);
break;
case CompOptionTypeList:
for (i = 0; i < v->list.nValue; i++)
@@ -1219,8 +1219,8 @@ finiDisplayOptionValue (CompDisplay *d,
case CompOptionTypeEdge:
case CompOptionTypeBell:
if (v->action.state & CompActionStateAutoGrab)
- for (s = d->screens; s; s = s->next)
- removeScreenAction (s, &v->action);
+ for (s = d->screens (); s; s = s->next)
+ s->removeAction (&v->action);
break;
case CompOptionTypeList:
for (i = 0; i < v->list.nValue; i++)
diff --git a/src/option.cpp b/src/option.cpp
index 1c704fc..c976b70 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -605,7 +605,7 @@ keyBindingToString (CompDisplay *d,
KeySym keysym;
char *keyname;
- keysym = XKeycodeToKeysym (d->display, key->keycode, 0);
+ keysym = XKeycodeToKeysym (d->dpy (), key->keycode, 0);
keyname = XKeysymToString (keysym);
if (keyname)
@@ -743,7 +743,7 @@ stringToKeyBinding (CompDisplay *d,
{
KeyCode keycode;
- keycode = XKeysymToKeycode (d->display, keysym);
+ keycode = XKeysymToKeycode (d->dpy (), keysym);
if (keycode)
{
key->keycode = keycode;
diff --git a/src/paint.cpp b/src/paint.cpp
index 30b492e..a4d1453 100644
--- a/src/paint.cpp
+++ b/src/paint.cpp
@@ -29,6 +29,9 @@
#include <compiz-core.h>
+#include "privatescreen.h"
+#include "privatewindow.h"
+
ScreenPaintAttrib defaultScreenPaintAttrib = {
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA
};
@@ -38,22 +41,20 @@ WindowPaintAttrib defaultWindowPaintAttrib = {
};
void
-preparePaintScreen (CompScreen *screen,
- int msSinceLastPaint)
-{
-}
+CompScreen::preparePaint (int msSinceLastPaint)
+ WRAPABLE_HND_FUNC(preparePaint, msSinceLastPaint)
void
-donePaintScreen (CompScreen *screen)
-{
-}
+CompScreen::donePaint ()
+ WRAPABLE_HND_FUNC(donePaint)
void
-applyScreenTransform (CompScreen *screen,
- const ScreenPaintAttrib *sAttrib,
- CompOutput *output,
- CompTransform *transform)
+CompScreen::applyTransform (const ScreenPaintAttrib *sAttrib,
+ CompOutput *output,
+ CompTransform *transform)
{
+ WRAPABLE_HND_FUNC(applyTransform, sAttrib, output, transform)
+
matrixTranslate (transform,
sAttrib->xTranslate,
sAttrib->yTranslate,
@@ -101,11 +102,13 @@ prepareXCoords (CompScreen *screen,
}
void
-paintCursor (CompCursor *c,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
+CompScreen::paintCursor (CompCursor *c,
+ const CompTransform *transform,
+ Region region,
+ unsigned int mask)
{
+ WRAPABLE_HND_FUNC(paintCursor, c, transform, region, mask)
+
int x1, y1, x2, y2;
if (!c->image)
@@ -119,7 +122,7 @@ paintCursor (CompCursor *c,
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
glEnable (GL_BLEND);
- enableTexture (c->screen, &c->image->texture, COMP_TEXTURE_FILTER_FAST);
+ c->screen->enableTexture (&c->image->texture, COMP_TEXTURE_FILTER_FAST);
glBegin (GL_QUADS);
@@ -138,18 +141,17 @@ paintCursor (CompCursor *c,
glEnd ();
- disableTexture (c->screen, &c->image->texture);
+ c->screen->disableTexture (&c->image->texture);
glDisable (GL_BLEND);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
}
-static void
-paintBackground (CompScreen *s,
- Region region,
- Bool transformed)
+void
+PrivateScreen::paintBackground (Region region,
+ bool transformed)
{
- CompTexture *bg = &s->backgroundTexture;
+ CompTexture *bg = &backgroundTexture;
BoxPtr pBox = region->rects;
int n, nBox = region->numRects;
GLfloat *d, *data;
@@ -157,24 +159,24 @@ paintBackground (CompScreen *s,
if (!nBox)
return;
- if (s->desktopWindowCount)
+ if (desktopWindowCount)
{
if (bg->name)
{
- finiTexture (s, bg);
- initTexture (s, bg);
+ finiTexture (screen, bg);
+ initTexture (screen, bg);
}
- s->backgroundLoaded = FALSE;
+ backgroundLoaded = false;
return;
}
else
{
- if (!s->backgroundLoaded)
- updateScreenBackground (s, bg);
+ if (!backgroundLoaded)
+ updateScreenBackground (bg);
- s->backgroundLoaded = TRUE;
+ backgroundLoaded = true;
}
data = (GLfloat *) malloc (sizeof (GLfloat) * nBox * 16);
@@ -218,13 +220,13 @@ paintBackground (CompScreen *s,
if (bg->name)
{
if (transformed)
- enableTexture (s, bg, COMP_TEXTURE_FILTER_GOOD);
+ screen->enableTexture (bg, COMP_TEXTURE_FILTER_GOOD);
else
- enableTexture (s, bg, COMP_TEXTURE_FILTER_FAST);
+ screen->enableTexture (bg, COMP_TEXTURE_FILTER_FAST);
glDrawArrays (GL_QUADS, 0, nBox * 4);
- disableTexture (s, bg);
+ screen->disableTexture (bg);
}
else
{
@@ -244,12 +246,11 @@ paintBackground (CompScreen *s,
difference with most hardware but occlusion detection in the
transformed screen case should be made optional for those who do
see a difference. */
-static void
-paintOutputRegion (CompScreen *screen,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
+void
+PrivateScreen::paintOutputRegion (const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
static Region tmpRegion = NULL;
CompWindow *w;
@@ -257,8 +258,8 @@ paintOutputRegion (CompScreen *screen,
int count, windowMask, odMask, i;
CompWindow *fullscreenWindow = NULL;
CompWalker walk;
- Bool status;
- Bool withOffset = FALSE;
+ bool status;
+ bool withOffset = false;
CompTransform vTransform;
int offX, offY;
Region clip = region;
@@ -283,77 +284,77 @@ paintOutputRegion (CompScreen *screen,
XSubtractRegion (region, &emptyRegion, tmpRegion);
- (*screen->initWindowWalker) (screen, &walk);
+ screen->initWindowWalker (&walk);
if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
{
/* detect occlusions */
for (w = (*walk.last) (screen); w; w = (*walk.prev) (w))
{
- if (w->destroyed)
+ if (w->destroyed ())
continue;
- if (!w->shaded)
+ if (!w->shaded ())
{
- if (w->attrib.map_state != IsViewable || !w->damaged)
+ if (w->attrib ().map_state != IsViewable || !w->damaged ())
continue;
}
/* copy region */
- XSubtractRegion (tmpRegion, &emptyRegion, w->clip);
+ XSubtractRegion (tmpRegion, &emptyRegion, w->clip ());
odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;
- if ((screen->windowOffsetX != 0 || screen->windowOffsetY != 0) &&
- !windowOnAllViewports (w))
+ if ((windowOffsetX != 0 || windowOffsetY != 0) &&
+ !w->onAllViewports ())
{
- withOffset = TRUE;
+ withOffset = true;
- getWindowMovementForOffset (w, screen->windowOffsetX,
- screen->windowOffsetY,
- &offX, &offY);
+ w->getMovementForOffset (windowOffsetX,
+ windowOffsetY,
+ &offX, &offY);
vTransform = *transform;
matrixTranslate (&vTransform, offX, offY, 0);
- XOffsetRegion (w->clip, -offX, -offY);
+ XOffsetRegion (w->clip (), -offX, -offY);
odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
- status = (*screen->paintWindow) (w, &w->paint, &vTransform,
- tmpRegion, odMask);
+ status = w->paint (&w->paintAttrib (), &vTransform,
+ tmpRegion, odMask);
}
else
{
- withOffset = FALSE;
- status = (*screen->paintWindow) (w, &w->paint, transform, tmpRegion,
- odMask);
+ withOffset = false;
+ status = w->paint (&w->paintAttrib (), transform, tmpRegion,
+ odMask);
}
if (status)
{
if (withOffset)
{
- XOffsetRegion (w->region, offX, offY);
- XSubtractRegion (tmpRegion, w->region, tmpRegion);
- XOffsetRegion (w->region, -offX, -offY);
+ XOffsetRegion (w->region (), offX, offY);
+ XSubtractRegion (tmpRegion, w->region (), tmpRegion);
+ XOffsetRegion (w->region (), -offX, -offY);
}
else
- XSubtractRegion (tmpRegion, w->region, tmpRegion);
+ XSubtractRegion (tmpRegion, w->region (), tmpRegion);
/* unredirect top most fullscreen windows. */
if (count == 0 &&
- screen->opt[COMP_SCREEN_OPTION_UNREDIRECT_FS].value.b)
+ opt[COMP_SCREEN_OPTION_UNREDIRECT_FS].value.b)
{
- if (XEqualRegion (w->region, &screen->region) &&
+ if (XEqualRegion (w->region (), &this->region) &&
!REGION_NOT_EMPTY (tmpRegion))
{
fullscreenWindow = w;
}
else
{
- for (i = 0; i < screen->nOutputDev; i++)
- if (XEqualRegion (w->region,
- &screen->outputDev[i].region))
+ for (i = 0; i < nOutputDev; i++)
+ if (XEqualRegion (w->region (),
+ &outputDev[i].region))
fullscreenWindow = w;
}
}
@@ -364,45 +365,43 @@ paintOutputRegion (CompScreen *screen,
}
if (fullscreenWindow)
- unredirectWindow (fullscreenWindow);
+ fullscreenWindow->unredirect ();
if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
- paintBackground (screen, tmpRegion,
- (mask & PAINT_SCREEN_TRANSFORMED_MASK));
+ paintBackground (tmpRegion, (mask & PAINT_SCREEN_TRANSFORMED_MASK));
/* paint all windows from bottom to top */
for (w = (*walk.first) (screen); w; w = (*walk.next) (w))
{
- if (w->destroyed)
+ if (w->destroyed ())
continue;
if (w == fullscreenWindow)
continue;
- if (!w->shaded)
+ if (!w->shaded ())
{
- if (w->attrib.map_state != IsViewable || !w->damaged)
+ if (w->attrib ().map_state != IsViewable || !w->damaged ())
continue;
}
if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
- clip = w->clip;
+ clip = w->clip ();
- if ((screen->windowOffsetX != 0 || screen->windowOffsetY != 0) &&
- !windowOnAllViewports (w))
+ if ((windowOffsetX != 0 || windowOffsetY != 0) &&
+ !w->onAllViewports ())
{
- getWindowMovementForOffset (w, screen->windowOffsetX,
- screen->windowOffsetY, &offX, &offY);
+ w->getMovementForOffset (windowOffsetX,
+ windowOffsetY, &offX, &offY);
vTransform = *transform;
matrixTranslate (&vTransform, offX, offY, 0);
- (*screen->paintWindow) (w, &w->paint, &vTransform, clip,
- windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
+ w->paint (&w->paintAttrib (), &vTransform, clip,
+ windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
}
else
{
- (*screen->paintWindow) (w, &w->paint, transform, clip,
- windowMask);
+ w->paint (&w->paintAttrib (), transform, clip, windowMask);
}
}
@@ -410,17 +409,18 @@ paintOutputRegion (CompScreen *screen,
(*walk.fini) (screen, &walk);
/* paint cursors */
- for (c = screen->cursors; c; c = c->next)
- (*screen->paintCursor) (c, transform, tmpRegion, 0);
+ for (c = cursors; c; c = c->next)
+ screen->paintCursor (c, transform, tmpRegion, 0);
}
void
-enableOutputClipping (CompScreen *screen,
- const CompTransform *transform,
- Region region,
- CompOutput *output)
+CompScreen::enableOutputClipping (const CompTransform *transform,
+ Region region,
+ CompOutput *output)
{
- GLdouble h = screen->height;
+ WRAPABLE_HND_FUNC(enableOutputClipping, transform, region, output)
+
+ GLdouble h = priv->height;
GLdouble p1[2] = { region->extents.x1, h - region->extents.y2 };
GLdouble p2[2] = { region->extents.x2, h - region->extents.y1 };
@@ -453,8 +453,10 @@ enableOutputClipping (CompScreen *screen,
}
void
-disableOutputClipping (CompScreen *screen)
+CompScreen::disableOutputClipping ()
{
+ WRAPABLE_HND_FUNC(disableOutputClipping)
+
glDisable (GL_CLIP_PLANE0);
glDisable (GL_CLIP_PLANE1);
glDisable (GL_CLIP_PLANE2);
@@ -465,60 +467,64 @@ disableOutputClipping (CompScreen *screen)
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
void
-paintTransformedOutput (CompScreen *screen,
- const ScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
+CompScreen::paintTransformedOutput (const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
+ WRAPABLE_HND_FUNC(paintTransformedOutput, sAttrib, transform,
+ region, output, mask)
+
CompTransform sTransform = *transform;
if (mask & PAINT_SCREEN_CLEAR_MASK)
- clearTargetOutput (screen->display, GL_COLOR_BUFFER_BIT);
+ priv->display->clearTargetOutput (GL_COLOR_BUFFER_BIT);
- screenLighting (screen, TRUE);
+ setLighting (true);
- (*screen->applyScreenTransform) (screen, sAttrib, output, &sTransform);
+ applyTransform (sAttrib, output, &sTransform);
if ((mask & CLIP_PLANE_MASK) == CLIP_PLANE_MASK)
{
- screen->enableOutputClipping (screen, &sTransform, region, output);
+ enableOutputClipping (&sTransform, region, output);
- transformToScreenSpace (screen, output, -sAttrib->zTranslate,
+ transformToScreenSpace (this, output, -sAttrib->zTranslate,
&sTransform);
glPushMatrix ();
glLoadMatrixf (sTransform.m);
- paintOutputRegion (screen, &sTransform, region, output, mask);
+ priv->paintOutputRegion (&sTransform, region, output, mask);
glPopMatrix ();
- screen->disableOutputClipping (screen);
+ disableOutputClipping ();
}
else
{
- transformToScreenSpace (screen, output, -sAttrib->zTranslate,
+ transformToScreenSpace (this, output, -sAttrib->zTranslate,
&sTransform);
glPushMatrix ();
glLoadMatrixf (sTransform.m);
- paintOutputRegion (screen, &sTransform, region, output, mask);
+ priv->paintOutputRegion (&sTransform, region, output, mask);
glPopMatrix ();
}
}
-Bool
-paintOutput (CompScreen *screen,
- const ScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
+bool
+CompScreen::paintOutput (const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
+ WRAPABLE_HND_FUNC_RETURN(bool, paintOutput, sAttrib, transform,
+ region, output, mask)
+
CompTransform sTransform = *transform;
if (mask & PAINT_SCREEN_REGION_MASK)
@@ -529,41 +535,39 @@ paintOutput (CompScreen *screen,
{
region = &output->region;
- (*screen->paintTransformedOutput) (screen, sAttrib,
- &sTransform, region,
- output, mask);
+ paintTransformedOutput (sAttrib, &sTransform, region,
+ output, mask);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/* fall through and redraw region */
}
else if (mask & PAINT_SCREEN_FULL_MASK)
{
- (*screen->paintTransformedOutput) (screen, sAttrib, &sTransform,
- &output->region,
- output, mask);
+ paintTransformedOutput (sAttrib, &sTransform, &output->region,
+ output, mask);
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
- screenLighting (screen, FALSE);
+ setLighting (false);
- transformToScreenSpace (screen, output, -DEFAULT_Z_CAMERA, &sTransform);
+ transformToScreenSpace (this, output, -DEFAULT_Z_CAMERA, &sTransform);
glPushMatrix ();
glLoadMatrixf (sTransform.m);
- paintOutputRegion (screen, &sTransform, region, output, mask);
+ priv->paintOutputRegion (&sTransform, region, output, mask);
glPopMatrix ();
- return TRUE;
+ return true;
}
#define ADD_RECT(data, m, n, x1, y1, x2, y2) \
@@ -635,51 +639,53 @@ paintOutput (CompScreen *screen,
*(data)++ = 0.0;
-Bool
-moreWindowVertices (CompWindow *w,
- int newSize)
+bool
+CompWindow::moreVertices (int newSize)
{
- if (newSize > w->vertexSize)
+ if (newSize > priv->vertexSize)
{
GLfloat *vertices;
- vertices = (GLfloat *) realloc (w->vertices, sizeof (GLfloat) * newSize);
+ vertices = (GLfloat *)
+ realloc (priv->vertices, sizeof (GLfloat) * newSize);
if (!vertices)
- return FALSE;
+ return false;
- w->vertices = vertices;
- w->vertexSize = newSize;
+ priv->vertices = vertices;
+ priv->vertexSize = newSize;
}
- return TRUE;
+ return true;
}
-Bool
-moreWindowIndices (CompWindow *w,
- int newSize)
+bool
+CompWindow::moreIndices (int newSize)
{
- if (newSize > w->indexSize)
+ if (newSize > priv->indexSize)
{
GLushort *indices;
- indices = (GLushort *) realloc (w->indices, sizeof (GLushort) * newSize);
+ indices = (GLushort *)
+ realloc (priv->indices, sizeof (GLushort) * newSize);
if (!indices)
- return FALSE;
+ return false;
- w->indices = indices;
- w->indexSize = newSize;
+ priv->indices = indices;
+ priv->indexSize = newSize;
}
- return TRUE;
+ return true;
}
-static void
-drawWindowGeometry (CompWindow *w)
+void
+CompWindow::drawGeometry ()
{
- int texUnit = w->texUnits;
+ WRAPABLE_HND_FUNC(drawGeometry)
+
+ int texUnit = priv->texUnits;
int currentTexUnit = 0;
- int stride = w->vertexStride;
- GLfloat *vertices = w->vertices + (stride - 3);
+ int stride = priv->vertexStride;
+ GLfloat *vertices = priv->vertices + (stride - 3);
stride *= sizeof (GLfloat);
@@ -689,40 +695,41 @@ drawWindowGeometry (CompWindow *w)
{
if (texUnit != currentTexUnit)
{
- (*w->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
+ (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
currentTexUnit = texUnit;
}
- vertices -= w->texCoordSize;
- glTexCoordPointer (w->texCoordSize, GL_FLOAT, stride, vertices);
+ vertices -= priv->texCoordSize;
+ glTexCoordPointer (priv->texCoordSize, GL_FLOAT, stride, vertices);
}
- glDrawArrays (GL_QUADS, 0, w->vCount);
+ glDrawArrays (GL_QUADS, 0, priv->vCount);
/* disable all texture coordinate arrays except 0 */
- texUnit = w->texUnits;
+ texUnit = priv->texUnits;
if (texUnit > 1)
{
while (--texUnit)
{
- (*w->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
+ (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
}
- (*w->screen->clientActiveTexture) (GL_TEXTURE0_ARB);
+ (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB);
}
}
void
-addWindowGeometry (CompWindow *w,
- CompMatrix *matrix,
- int nMatrix,
- Region region,
- Region clip)
+CompWindow::addGeometry (CompMatrix *matrix,
+ int nMatrix,
+ Region region,
+ Region clip)
{
+ WRAPABLE_HND_FUNC(addGeometry, matrix, nMatrix, region, clip)
+
BoxRec full;
- w->texUnits = nMatrix;
+ priv->texUnits = nMatrix;
full = clip->extents;
if (region->extents.x1 > full.x1)
@@ -744,13 +751,13 @@ addWindowGeometry (CompWindow *w,
int vSize;
int n, it, x1, y1, x2, y2;
GLfloat *d;
- Bool rect = TRUE;
+ bool rect = true;
for (it = 0; it < nMatrix; it++)
{
if (matrix[it].xy != 0.0f || matrix[it].yx != 0.0f)
{
- rect = FALSE;
+ rect = false;
break;
}
}
@@ -760,15 +767,15 @@ addWindowGeometry (CompWindow *w,
vSize = 3 + nMatrix * 2;
- n = w->vCount / 4;
+ n = priv->vCount / 4;
- if ((n + nBox) * vSize * 4 > w->vertexSize)
+ if ((n + nBox) * vSize * 4 > priv->vertexSize)
{
- if (!moreWindowVertices (w, (n + nBox) * vSize * 4))
+ if (!moreVertices ((n + nBox) * vSize * 4))
return;
}
- d = w->vertices + (w->vCount * vSize);
+ d = priv->vertices + (priv->vCount * vSize);
while (nBox--)
{
@@ -809,12 +816,12 @@ addWindowGeometry (CompWindow *w,
{
pClip = clip->rects;
- if (((n + nClip) * vSize * 4) > w->vertexSize)
+ if (((n + nClip) * vSize * 4) > priv->vertexSize)
{
- if (!moreWindowVertices (w, (n + nClip) * vSize * 4))
+ if (!moreVertices ((n + nClip) * vSize * 4))
return;
- d = w->vertices + (n * vSize * 4);
+ d = priv->vertices + (n * vSize * 4);
}
while (nClip--)
@@ -852,14 +859,13 @@ addWindowGeometry (CompWindow *w,
}
}
- w->vCount = n * 4;
- w->vertexStride = vSize;
- w->texCoordSize = 2;
- w->drawWindowGeometry = drawWindowGeometry;
+ priv->vCount = n * 4;
+ priv->vertexStride = vSize;
+ priv->texCoordSize = 2;
}
}
-static Bool
+static bool
enableFragmentProgramAndDrawGeometry (CompWindow *w,
CompTexture *texture,
const FragmentAttrib *attrib,
@@ -867,10 +873,10 @@ enableFragmentProgramAndDrawGeometry (CompWindow *w,
unsigned int mask)
{
FragmentAttrib fa = *attrib;
- CompScreen *s = w->screen;
+ CompScreen *s = w->screen ();
Bool blending;
- if (s->canDoSaturated && attrib->saturation != COLOR)
+ if (s->canDoSaturated () && attrib->saturation != COLOR)
{
int param, function;
@@ -887,9 +893,9 @@ enableFragmentProgramAndDrawGeometry (CompWindow *w,
}
if (!enableFragmentAttrib (s, &fa, &blending))
- return FALSE;
+ return false;
- enableTexture (s, texture, filter);
+ s->enableTexture (texture, filter);
if (mask & PAINT_WINDOW_BLEND_MASK)
{
@@ -902,17 +908,17 @@ enableFragmentProgramAndDrawGeometry (CompWindow *w,
color = (attrib->opacity * attrib->brightness) >> 16;
- screenTexEnvMode (s, GL_MODULATE);
+ s->setTexEnvMode (GL_MODULATE);
glColor4us (color, color, color, attrib->opacity);
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
glColor4usv (defaultColor);
- screenTexEnvMode (s, GL_REPLACE);
+ s->setTexEnvMode (GL_REPLACE);
}
else
{
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
}
if (blending)
@@ -920,25 +926,25 @@ enableFragmentProgramAndDrawGeometry (CompWindow *w,
}
else if (attrib->brightness != BRIGHT)
{
- screenTexEnvMode (s, GL_MODULATE);
+ s->setTexEnvMode (GL_MODULATE);
glColor4us (attrib->brightness, attrib->brightness,
attrib->brightness, BRIGHT);
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
glColor4usv (defaultColor);
- screenTexEnvMode (s, GL_REPLACE);
+ s->setTexEnvMode (GL_REPLACE);
}
else
{
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
}
- disableTexture (w->screen, texture);
+ s->disableTexture (texture);
disableFragmentAttrib (s, &fa);
- return TRUE;
+ return true;
}
static void
@@ -948,16 +954,16 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
int filter,
unsigned int mask)
{
- CompScreen *s = w->screen;
+ CompScreen *s = w->screen ();
- if (s->canDoSaturated && attrib->saturation != COLOR)
+ if (s->canDoSaturated () && attrib->saturation != COLOR)
{
GLfloat constant[4];
if (mask & PAINT_WINDOW_BLEND_MASK)
glEnable (GL_BLEND);
- enableTexture (s, texture, filter);
+ s->enableTexture (texture, filter);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
@@ -977,7 +983,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
s->activeTexture (GL_TEXTURE1_ARB);
- enableTexture (s, texture, filter);
+ s->enableTexture (texture, filter);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
@@ -987,7 +993,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->saturation > 0)
+ if (s->canDoSlightlySaturated () && attrib->saturation > 0)
{
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
@@ -1002,7 +1008,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
s->activeTexture (GL_TEXTURE2_ARB);
- enableTexture (s, texture, filter);
+ s->enableTexture (texture, filter);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
@@ -1026,7 +1032,7 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
{
s->activeTexture (GL_TEXTURE3_ARB);
- enableTexture (s, texture, filter);
+ s->enableTexture (texture, filter);
constant[3] = attrib->opacity / 65535.0f;
constant[0] = constant[1] = constant[2] = constant[3] *
@@ -1048,9 +1054,9 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
- disableTexture (s, texture);
+ s->disableTexture (texture);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -1058,10 +1064,10 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
}
else
{
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
}
- disableTexture (s, texture);
+ s->disableTexture (texture);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -1085,26 +1091,26 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
}
- disableTexture (s, texture);
+ s->disableTexture (texture);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
s->activeTexture (GL_TEXTURE0_ARB);
- disableTexture (s, texture);
+ s->disableTexture (texture);
glColor4usv (defaultColor);
- screenTexEnvMode (s, GL_REPLACE);
+ s->setTexEnvMode (GL_REPLACE);
if (mask & PAINT_WINDOW_BLEND_MASK)
glDisable (GL_BLEND);
}
else
{
- enableTexture (s, texture, filter);
+ s->enableTexture (texture, filter);
if (mask & PAINT_WINDOW_BLEND_MASK)
{
@@ -1115,64 +1121,65 @@ enableFragmentOperationsAndDrawGeometry (CompWindow *w,
color = (attrib->opacity * attrib->brightness) >> 16;
- screenTexEnvMode (s, GL_MODULATE);
+ s->setTexEnvMode (GL_MODULATE);
glColor4us (color, color, color, attrib->opacity);
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
glColor4usv (defaultColor);
- screenTexEnvMode (s, GL_REPLACE);
+ s->setTexEnvMode (GL_REPLACE);
}
else
{
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
}
glDisable (GL_BLEND);
}
else if (attrib->brightness != BRIGHT)
{
- screenTexEnvMode (s, GL_MODULATE);
+ s->setTexEnvMode (GL_MODULATE);
glColor4us (attrib->brightness, attrib->brightness,
attrib->brightness, BRIGHT);
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
glColor4usv (defaultColor);
- screenTexEnvMode (s, GL_REPLACE);
+ s->setTexEnvMode (GL_REPLACE);
}
else
{
- (*w->drawWindowGeometry) (w);
+ w->drawGeometry ();
}
- disableTexture (w->screen, texture);
+ s->disableTexture (texture);
}
}
void
-drawWindowTexture (CompWindow *w,
- CompTexture *texture,
- const FragmentAttrib *attrib,
- unsigned int mask)
+CompWindow::drawTexture (CompTexture *texture,
+ const FragmentAttrib *attrib,
+ unsigned int mask)
{
+ WRAPABLE_HND_FUNC(drawTexture, texture, attrib, mask)
+
int filter;
if (mask & (PAINT_WINDOW_TRANSFORMED_MASK |
PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK))
- filter = w->screen->filter[SCREEN_TRANS_FILTER];
+ filter = priv->screen->filter (SCREEN_TRANS_FILTER);
else
- filter = w->screen->filter[NOTHING_TRANS_FILTER];
+ filter = priv->screen->filter (NOTHING_TRANS_FILTER);
- if ((!attrib->nFunction && (!w->screen->lighting ||
+ if ((!attrib->nFunction && (!priv->screen->lighting () ||
attrib->saturation == COLOR || attrib->saturation == 0)) ||
- !enableFragmentProgramAndDrawGeometry (w,
+ !enableFragmentProgramAndDrawGeometry (this,
texture,
attrib,
filter,
mask))
{
- enableFragmentOperationsAndDrawGeometry (w,
+ enableFragmentOperationsAndDrawGeometry (this,
texture,
attrib,
filter,
@@ -1180,72 +1187,74 @@ drawWindowTexture (CompWindow *w,
}
}
-Bool
-drawWindow (CompWindow *w,
- const CompTransform *transform,
- const FragmentAttrib *fragment,
- Region region,
- unsigned int mask)
+bool
+CompWindow::draw (const CompTransform *transform,
+ const FragmentAttrib *fragment,
+ Region region,
+ unsigned int mask)
{
+ WRAPABLE_HND_FUNC_RETURN(bool, draw, transform, fragment, region, mask)
+
if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
region = &infiniteRegion;
if (!region->numRects)
- return TRUE;
+ return true;
- if (w->attrib.map_state != IsViewable)
- return TRUE;
+ if (priv->attrib.map_state != IsViewable)
+ return true;
- if (!w->texture->pixmap && !bindWindow (w))
- return FALSE;
+ if (!priv->texture->pixmap && !bind ())
+ return false;
if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
mask |= PAINT_WINDOW_BLEND_MASK;
- w->vCount = w->indexCount = 0;
- (*w->screen->addWindowGeometry) (w, &w->matrix, 1, w->region, region);
- if (w->vCount)
- (*w->screen->drawWindowTexture) (w, w->texture, fragment, mask);
+ priv->vCount = priv->indexCount = 0;
+ addGeometry (&priv->matrix, 1, priv->region, region);
+ if (priv->vCount)
+ drawTexture (priv->texture, fragment, mask);
- return TRUE;
+ return true;
}
-Bool
-paintWindow (CompWindow *w,
- const WindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
+bool
+CompWindow::paint (const WindowPaintAttrib *attrib,
+ const CompTransform *transform,
+ Region region,
+ unsigned int mask)
{
+ WRAPABLE_HND_FUNC_RETURN(bool, paint, attrib, transform, region, mask)
+
FragmentAttrib fragment;
Bool status;
- w->lastPaint = *attrib;
+ priv->lastPaint = *attrib;
- if (w->alpha || attrib->opacity != OPAQUE)
+ if (priv->alpha || attrib->opacity != OPAQUE)
mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
- w->lastMask = mask;
+ priv->lastMask = mask;
if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
{
if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
- return FALSE;
+ return false;
if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
- return FALSE;
+ return false;
if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
- return FALSE;
+ return false;
- if (w->shaded)
- return FALSE;
+ if (priv->shaded)
+ return false;
- return TRUE;
+ return true;
}
if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
- return TRUE;
+ return true;
initFragmentAttrib (&fragment, attrib);
@@ -1256,7 +1265,7 @@ paintWindow (CompWindow *w,
glLoadMatrixf (transform->m);
}
- status = (*w->screen->drawWindow) (w, transform, &fragment, region, mask);
+ status = draw (transform, &fragment, region, mask);
if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
mask & PAINT_WINDOW_WITH_OFFSET_MASK)
diff --git a/src/plugin.cpp b/src/plugin.cpp
index d545240..d81b320 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -33,43 +33,66 @@
CompPlugin *plugins = 0;
-static Bool
-coreInit (CompPlugin *p)
+class CorePluginVTable : public CompPluginVTable
{
- return TRUE;
+ public:
+
+ const char *
+ name () { return "core"; };
+
+ CompMetadata *
+ getMetadata ();
+
+ virtual bool
+ init ();
+
+ virtual void
+ fini ();
+
+ CompOption *
+ getObjectOptions (CompObject *object, int *count);
+
+ bool
+ setObjectOption (CompObject *object,
+ const char *name,
+ CompOptionValue *value);
+};
+
+bool
+CorePluginVTable::init ()
+{
+ return true;
}
-static void
-coreFini (CompPlugin *p)
+void
+CorePluginVTable::fini ()
{
}
-static CompMetadata *
-coreGetMetadata (CompPlugin *plugin)
+CompMetadata *
+CorePluginVTable::getMetadata ()
{
return &coreMetadata;
}
-static CompOption *
-coreGetObjectOptions (CompPlugin *plugin,
- CompObject *object,
- int *count)
+CompOption *
+CorePluginVTable::getObjectOptions (CompObject *object,
+ int *count)
{
static GetPluginObjectOptionsProc dispTab[] = {
(GetPluginObjectOptionsProc) 0, /* GetCoreOptions */
- (GetPluginObjectOptionsProc) getDisplayOptions,
- (GetPluginObjectOptionsProc) getScreenOptions
+ (GetPluginObjectOptionsProc) CompDisplay::getDisplayOptions,
+ (GetPluginObjectOptionsProc) CompScreen::getScreenOptions
};
RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
- (CompOption *) (*count = 0), (plugin, object, count));
+ (CompOption *) (*count = 0), (object, count));
}
-static Bool
-coreSetObjectOption (CompPlugin *plugin,
- CompObject *object,
- const char *name,
- CompOptionValue *value)
+bool
+CorePluginVTable::setObjectOption (CompObject *object,
+ const char *name,
+ CompOptionValue *value)
{
static SetPluginObjectOptionProc dispTab[] = {
(SetPluginObjectOptionProc) 0, /* SetCoreOption */
@@ -78,19 +101,12 @@ coreSetObjectOption (CompPlugin *plugin,
};
RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), FALSE,
- (plugin, object, name, value));
-}
-
-static CompPluginVTable coreVTable = {
- "core",
- coreGetMetadata,
- coreInit,
- coreFini,
- 0, /* InitObject */
- 0, /* FiniObject */
- coreGetObjectOptions,
- coreSetObjectOption
-};
+ (object, name, value));
+}
+
+
+
+CorePluginVTable coreVTable;
static Bool
cloaderLoadPlugin (CompPlugin *p,
@@ -100,7 +116,7 @@ cloaderLoadPlugin (CompPlugin *p,
if (path)
return FALSE;
- if (strcmp (name, coreVTable.name))
+ if (strcmp (name, coreVTable.name ()))
return FALSE;
p->vTable = &coreVTable;
@@ -128,7 +144,7 @@ cloaderListPlugins (const char *path,
if (!list)
return 0;
- *list = strdup (coreVTable.name);
+ *list = strdup (coreVTable.name ());
if (!*list)
{
free (list);
@@ -166,7 +182,7 @@ dlloaderLoadPlugin (CompPlugin *p,
dlerror ();
getInfo = (PluginGetInfoProc)
- dlsym (dlhand, "getCompPluginInfo20070830");
+ dlsym (dlhand, "getCompPluginInfo20080805");
error = dlerror ();
if (error)
@@ -364,14 +380,12 @@ initObjectTree (CompObject *object,
pCtx->object = object;
- if (p->vTable->initObject)
+
+ if (!p->vTable->initObject (object))
{
- if (!(*p->vTable->initObject) (p, object))
- {
- compLogMessage (NULL, p->vTable->name, CompLogLevelError,
- "InitObject failed");
- return FALSE;
- }
+ compLogMessage (NULL, p->vTable->name (), CompLogLevelError,
+ "InitObject failed");
+ return FALSE;
}
ctx.plugin = p;
@@ -382,18 +396,16 @@ initObjectTree (CompObject *object,
{
compObjectForEachType (object, finiObjectsWithType, (void *) &ctx);
- if (p->vTable->initObject && p->vTable->finiObject)
- (*p->vTable->finiObject) (p, object);
+ p->vTable->finiObject (object);
return FALSE;
}
- if (!(*core.initPluginForObject) (p, object))
+ if (!core->initPluginForObject (p, object))
{
compObjectForEachType (object, finiObjectsWithType, (void *) &ctx);
- if (p->vTable->initObject && p->vTable->finiObject)
- (*p->vTable->finiObject) (p, object);
+ p->vTable->finiObject (object);
return FALSE;
}
@@ -418,10 +430,10 @@ finiObjectTree (CompObject *object,
compObjectForEachType (object, finiObjectsWithType, (void *) &ctx);
- if (p->vTable->initObject && p->vTable->finiObject)
- (*p->vTable->finiObject) (p, object);
+
+ p->vTable->finiObject (object);
- (*core.finiPluginForObject) (p, object);
+ core->finiPluginForObject (p, object);
return TRUE;
}
@@ -431,19 +443,19 @@ initPlugin (CompPlugin *p)
{
InitObjectContext ctx;
- if (!(*p->vTable->init) (p))
+ if (!p->vTable->init ())
{
compLogMessage (NULL, "core", CompLogLevelError,
- "InitPlugin '%s' failed", p->vTable->name);
+ "InitPlugin '%s' failed", p->vTable->name ());
return FALSE;
}
ctx.plugin = p;
ctx.object = NULL;
- if (!initObjectTree (&core.base, (void *) &ctx))
+ if (!initObjectTree (core, (void *) &ctx))
{
- (*p->vTable->fini) (p);
+ p->vTable->fini ();
return FALSE;
}
@@ -458,9 +470,9 @@ finiPlugin (CompPlugin *p)
ctx.plugin = p;
ctx.object = NULL;
- finiObjectTree (&core.base, (void *) &ctx);
+ finiObjectTree (core, (void *) &ctx);
- (*p->vTable->fini) (p);
+ p->vTable->fini ();
}
CompBool
@@ -522,7 +534,7 @@ findActivePlugin (const char *name)
for (p = plugins; p; p = p->next)
{
- if (strcmp (p->vTable->name, name) == 0)
+ if (strcmp (p->vTable->name (), name) == 0)
return p;
}
@@ -584,11 +596,11 @@ loadPlugin (const char *name)
Bool
pushPlugin (CompPlugin *p)
{
- if (findActivePlugin (p->vTable->name))
+ if (findActivePlugin (p->vTable->name ()))
{
compLogMessage (NULL, "core", CompLogLevelWarn,
"Plugin '%s' already active",
- p->vTable->name);
+ p->vTable->name ());
return FALSE;
}
@@ -599,7 +611,7 @@ pushPlugin (CompPlugin *p)
if (!initPlugin (p))
{
compLogMessage (NULL, "core", CompLogLevelError,
- "Couldn't activate plugin '%s'", p->vTable->name);
+ "Couldn't activate plugin '%s'", p->vTable->name ());
plugins = p->next;
return FALSE;
@@ -721,11 +733,11 @@ getPluginABI (const char *name)
CompOption *option;
int nOption;
- if (!p || !p->vTable->getObjectOptions)
+ if (!p)
return 0;
/* MULTIDPYERROR: ABI options should be moved into core */
- option = (*p->vTable->getObjectOptions) (p, &core.displays->base,
+ option = p->vTable->getObjectOptions (core->displays(),
&nOption);
return getIntOptionNamed (option, nOption, "abi", 0);
@@ -765,10 +777,10 @@ getPluginDisplayIndex (CompDisplay *d,
CompOption *option;
int nOption, value;
- if (!p || !p->vTable->getObjectOptions)
+ if (!p)
return FALSE;
- option = (*p->vTable->getObjectOptions) (p, &d->base, &nOption);
+ option = p->vTable->getObjectOptions (d, &nOption);
value = getIntOptionNamed (option, nOption, "index", -1);
if (value < 0)
@@ -778,3 +790,41 @@ getPluginDisplayIndex (CompDisplay *d,
return TRUE;
}
+
+
+CompPluginVTable::~CompPluginVTable ()
+{
+}
+
+CompMetadata *
+CompPluginVTable::getMetadata ()
+{
+ return NULL;
+}
+
+
+bool
+CompPluginVTable::initObject (CompObject *object)
+{
+ return true;
+}
+
+void
+CompPluginVTable::finiObject (CompObject *object)
+{
+}
+
+CompOption *
+CompPluginVTable::getObjectOptions (CompObject *object, int *count)
+{
+ (*count) = 0;
+ return NULL;
+}
+
+bool
+CompPluginVTable::setObjectOption (CompObject *object,
+ const char *name,
+ CompOptionValue *value)
+{
+ return false;
+}
diff --git a/src/privatecore.h b/src/privatecore.h
new file mode 100644
index 0000000..c6b4764
--- /dev/null
+++ b/src/privatecore.h
@@ -0,0 +1,42 @@
+#ifndef _PRIVATECORE_H
+#define _PRIVATECORE_H
+
+#include <compiz-core.h>
+#include <compcore.h>
+
+class PrivateCore {
+
+ public:
+ PrivateCore (CompCore *core);
+ ~PrivateCore ();
+
+ void
+ addTimeout(CompTimeout *);
+
+ short int
+ watchFdEvents (CompWatchFdHandle handle);
+
+ int
+ doPoll (int timeout);
+
+ void
+ handleTimeouts (struct timeval *tv);
+
+ public:
+ CompCore *core;
+ CompDisplay *displays;
+
+ std::list<CompFileWatch *> fileWatch;
+ CompFileWatchHandle lastFileWatchHandle;
+
+ std::list<CompTimeout *> timeouts;
+ struct timeval lastTimeout;
+ CompTimeoutHandle lastTimeoutHandle;
+
+ std::list<CompWatchFd *> watchFds;
+ CompWatchFdHandle lastWatchFdHandle;
+ struct pollfd *watchPollFds;
+ int nWatchFds;
+};
+
+#endif
diff --git a/src/privatedisplay.h b/src/privatedisplay.h
new file mode 100644
index 0000000..7068f45
--- /dev/null
+++ b/src/privatedisplay.h
@@ -0,0 +1,138 @@
+#ifndef _PRIVATEDISPLAY_H
+#define _PRIVATEDISPLAY_H
+
+#include <compiz-core.h>
+#include <compdisplay.h>
+
+class PrivateDisplay {
+
+ public:
+ PrivateDisplay (CompDisplay *display);
+ ~PrivateDisplay ();
+
+ void
+ updatePlugins ();
+
+ bool
+ triggerButtonPressBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument);
+
+ bool
+ triggerButtonReleaseBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument);
+
+ bool
+ triggerKeyPressBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument);
+
+ bool
+ triggerKeyReleaseBindings (CompOption *option,
+ int nOption,
+ XEvent *event,
+ CompOption *argument,
+ int nArgument);
+
+ bool
+ triggerStateNotifyBindings (CompOption *option,
+ int nOption,
+ XkbStateNotifyEvent *event,
+ CompOption *argument,
+ int nArgument);
+
+ bool
+ triggerEdgeEnter (unsigned int edge,
+ CompActionState state,
+ CompOption *argument,
+ unsigned int nArgument);
+
+ void
+ setAudibleBell (bool audible);
+
+ void
+ handlePingTimeout ();
+
+ bool
+ handleActionEvent (XEvent *event);
+
+ void
+ handleSelectionRequest (XEvent *event);
+
+ void
+ handleSelectionClear (XEvent *event);
+
+ void
+ initAtoms ();
+
+ public:
+
+ CompDisplay *display;
+
+ xcb_connection_t *connection;
+
+ Display *dpy;
+ CompScreen *screens;
+
+ CompWatchFdHandle watchFdHandle;
+
+ int compositeEvent, compositeError, compositeOpcode;
+ int damageEvent, damageError;
+ int syncEvent, syncError;
+ int fixesEvent, fixesError, fixesVersion;
+
+ bool randrExtension;
+ int randrEvent, randrError;
+
+ bool shapeExtension;
+ int shapeEvent, shapeError;
+
+ bool xkbExtension;
+ int xkbEvent, xkbError;
+
+ bool xineramaExtension;
+ int xineramaEvent, xineramaError;
+
+ XineramaScreenInfo *screenInfo;
+ int nScreenInfo;
+
+ SnDisplay *snDisplay;
+
+ unsigned int lastPing;
+ CompTimeoutHandle pingHandle;
+
+ GLenum textureFilter;
+
+ Window activeWindow;
+
+ Window below;
+ char displayString[256];
+
+ XModifierKeymap *modMap;
+ unsigned int modMask[CompModNum];
+ unsigned int ignoredModMask;
+
+ KeyCode escapeKeyCode;
+ KeyCode returnKeyCode;
+
+ CompOption opt[COMP_DISPLAY_OPTION_NUM];
+
+ CompTimeoutHandle autoRaiseHandle;
+ Window autoRaiseWindow;
+
+ CompTimeoutHandle edgeDelayHandle;
+
+ CompOptionValue plugin;
+ bool dirtyPluginList;
+
+ CompDisplay::Atoms atoms;
+};
+
+#endif
diff --git a/src/privatescreen.h b/src/privatescreen.h
new file mode 100644
index 0000000..a0dabc6
--- /dev/null
+++ b/src/privatescreen.h
@@ -0,0 +1,251 @@
+#ifndef _PRIVATESCREEN_H
+#define _PRIVATESCREEN_H
+
+#include <compiz-core.h>
+#include <compscreen.h>
+
+class PrivateScreen {
+
+ public:
+ PrivateScreen (CompScreen *screen);
+ ~PrivateScreen ();
+
+ bool
+ desktopHintEqual (unsigned long *data,
+ int size,
+ int offset,
+ int hintSize);
+
+ void
+ setDesktopHints ();
+
+ void
+ setVirtualScreenSize (int hsize, int vsize);
+
+ void
+ updateOutputDevices ();
+
+ void
+ detectOutputDevices ();
+
+ void
+ updateStartupFeedback ();
+
+ void
+ updateScreenEdges ();
+
+ void
+ reshape (int w, int h);
+
+ void
+ updateScreenBackground (CompTexture *texture);
+
+ void
+ handleStartupSequenceTimeout();
+
+ void
+ addSequence (SnStartupSequence *sequence);
+
+ void
+ removeSequence (SnStartupSequence *sequence);
+
+ void
+ setSupportingWmCheck ();
+
+ void
+ setSupported ();
+
+ void
+ getDesktopHints ();
+
+ void
+ makeOutputWindow ();
+
+ void
+ grabUngrabOneKey (unsigned int modifiers,
+ int keycode,
+ bool grab);
+
+
+ bool
+ grabUngrabKeys (unsigned int modifiers,
+ int keycode,
+ bool grab);
+
+ bool
+ addPassiveKeyGrab (CompKeyBinding *key);
+
+ void
+ removePassiveKeyGrab (CompKeyBinding *key);
+
+ void
+ updatePassiveKeyGrabs ();
+
+ bool
+ addPassiveButtonGrab (CompButtonBinding *button);
+
+ void
+ removePassiveButtonGrab (CompButtonBinding *button);
+
+ void
+ computeWorkareaForBox (BoxPtr pBox, XRectangle *area);
+
+ void
+ paintBackground (Region region,
+ bool transformed);
+
+ void
+ paintOutputRegion (const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask);
+
+ static bool
+ paintTimeout (void *closure);
+
+ public:
+
+ CompScreen *screen;
+ CompDisplay *display;
+ CompWindow *windows;
+ CompWindow *reverseWindows;
+
+
+ Colormap colormap;
+ int screenNum;
+ int width;
+ int height;
+ int x;
+ int y;
+ int hsize; /* Number of horizontal viewports */
+ int vsize; /* Number of vertical viewports */
+ 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;
+ XRectangle *exposeRects;
+ int sizeExpose;
+ int nExpose;
+ CompTexture backgroundTexture;
+ Bool backgroundLoaded;
+ unsigned int pendingDestroys;
+ int desktopWindowCount;
+ unsigned int mapNum;
+ unsigned int activeNum;
+
+ CompOutput *outputDev;
+ int nOutputDev;
+ int currentOutputDev;
+ CompOutput fullscreenOutput;
+ Bool hasOverlappingOutputs;
+
+ int windowOffsetX;
+ int windowOffsetY;
+
+ XRectangle lastViewport;
+
+ CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
+ int currentHistory;
+
+ int overlayWindowCount;
+
+ CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
+
+ SnMonitorContext *snContext;
+ CompStartupSequence *startupSequences;
+ unsigned int startupSequenceTimeoutHandle;
+
+ int filter[3];
+
+ CompGroup *groups;
+
+ CompIcon *defaultIcon;
+
+ Bool canDoSaturated;
+ Bool canDoSlightlySaturated;
+
+ Window wmSnSelectionWindow;
+ Atom wmSnAtom;
+ Time wmSnTimestamp;
+
+ Cursor normalCursor;
+ Cursor busyCursor;
+
+ CompWindow **clientList;
+ int nClientList;
+
+ CompButtonGrab *buttonGrab;
+ int nButtonGrab;
+ CompKeyGrab *keyGrab;
+ int nKeyGrab;
+
+ CompGrab *grabs;
+ int grabSize;
+ int maxGrab;
+
+ int rasterX;
+ int rasterY;
+ struct timeval lastRedraw;
+ int nextRedraw;
+ int redrawTime;
+ int optimalRedrawTime;
+ int frameStatus;
+ int timeMult;
+ Bool idle;
+ int timeLeft;
+ Bool pendingCommands;
+
+ int lastFunctionId;
+
+ CompFunction *fragmentFunctions;
+ CompProgram *fragmentPrograms;
+
+ int saturateFunction[2][64];
+
+ GLfloat projection[16];
+
+ Bool clearBuffers;
+
+ Bool lighting;
+ Bool slowAnimations;
+
+ XRectangle workArea;
+
+ unsigned int showingDesktopMask;
+
+ unsigned long *desktopHintData;
+ int desktopHintSize;
+
+ CompCursor *cursors;
+ CompCursorImage *cursorImages;
+
+ GLXContext ctx;
+
+ CompOption opt[COMP_SCREEN_OPTION_NUM];
+
+
+ CompTimeoutHandle paintHandle;
+
+ GLXGetProcAddressProc getProcAddress;
+
+};
+
+#endif
diff --git a/src/privatewindow.h b/src/privatewindow.h
new file mode 100644
index 0000000..0befa96
--- /dev/null
+++ b/src/privatewindow.h
@@ -0,0 +1,269 @@
+#ifndef _PRIVATEWINDOW_H
+#define _PRIVATEWINDOW_H
+
+#include <compiz-core.h>
+#include <compwindow.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 >= (w)->screen->width () || \
+ (w)->attrib.y - (w)->output.top >= (w)->screen->height () )
+
+
+class PrivateWindow {
+
+ public:
+ PrivateWindow (CompWindow *window);
+ ~PrivateWindow ();
+
+ void
+ recalcNormalHints ();
+
+ void
+ updateFrameWindow ();
+
+ void
+ setWindowMatrix ();
+
+ bool
+ restack (Window aboveId);
+
+ bool
+ initializeSyncCounter ();
+
+ bool
+ isGroupTransient (Window clientLeader);
+
+
+ static bool
+ stackLayerCheck (CompWindow *w,
+ Window clientLeader,
+ CompWindow *below);
+
+ static bool
+ avoidStackingRelativeTo (CompWindow *w);
+
+ static CompWindow *
+ findSiblingBelow (CompWindow *w,
+ bool aboveFs);
+
+ static CompWindow *
+ findLowestSiblingBelow (CompWindow *w);
+
+ static bool
+ validSiblingBelow (CompWindow *w,
+ CompWindow *sibling);
+
+ void
+ saveGeometry (int mask);
+
+ int
+ restoreGeometry (XWindowChanges *xwc, int mask);
+
+ void
+ reconfigureXWindow (unsigned int valueMask,
+ XWindowChanges *xwc);
+
+ static bool
+ stackTransients (CompWindow *w,
+ CompWindow *avoid,
+ XWindowChanges *xwc);
+
+ static void
+ stackAncestors (CompWindow *w, XWindowChanges *xwc);
+
+ static bool
+ isAncestorTo (CompWindow *transient,
+ CompWindow *ancestor);
+
+ Window
+ getClientLeaderOfAncestor ();
+
+ CompWindow *
+ getModalTransient ();
+
+ int
+ addWindowSizeChanges (XWindowChanges *xwc,
+ int oldX,
+ int oldY,
+ int oldWidth,
+ int oldHeight,
+ int oldBorderWidth);
+
+ int
+ addWindowStackChanges (XWindowChanges *xwc,
+ CompWindow *sibling);
+
+ static CompWindow *
+ findValidStackSiblingBelow (CompWindow *w,
+ CompWindow *sibling);
+
+ void
+ ensureWindowVisibility ();
+
+ void
+ reveal ();
+
+ static void
+ revealAncestors (CompWindow *w,
+ void *closure);
+
+ bool
+ constrainNewWindowSize (int width,
+ int height,
+ int *newWidth,
+ int *newHeight);
+
+ static void
+ minimizeTransients (CompWindow *w,
+ void *closure);
+
+ static void
+ unminimizeTransients (CompWindow *w,
+ void *closure);
+
+ bool
+ getUsageTimestamp (Time *timestamp);
+
+ bool
+ isWindowFocusAllowed (Time timestamp);
+
+ static void
+ handleDamageRect (CompWindow *w,
+ int x,
+ int y,
+ int width,
+ int height);
+
+
+ public:
+
+ CompWindow *window;
+ CompScreen *screen;
+
+ int refcnt;
+ Window id;
+ Window frame;
+ unsigned int mapNum;
+ unsigned int activeNum;
+ XWindowAttributes attrib;
+ int serverX;
+ int serverY;
+ int serverWidth;
+ int serverHeight;
+ int serverBorderWidth;
+ Window transientFor;
+ Window clientLeader;
+ XSizeHints sizeHints;
+ Pixmap pixmap;
+ CompTexture *texture;
+ CompMatrix matrix;
+ Damage damage;
+ bool inputHint;
+ bool alpha;
+ GLint width;
+ GLint height;
+ Region region;
+ Region clip;
+ unsigned int wmType;
+ unsigned int type;
+ unsigned int state;
+ unsigned int actions;
+ unsigned int protocols;
+ unsigned int mwmDecor;
+ unsigned int mwmFunc;
+ bool invisible;
+ bool destroyed;
+ bool damaged;
+ bool redirected;
+ bool managed;
+ bool bindFailed;
+ bool overlayWindow;
+ int destroyRefCnt;
+ int unmapRefCnt;
+
+ unsigned int initialViewportX;
+ unsigned int initialViewportY;
+
+ Time initialTimestamp;
+ Bool initialTimestampSet;
+
+ bool placed;
+ bool minimized;
+ bool inShowDesktopMode;
+ bool shaded;
+ bool hidden;
+ bool grabbed;
+
+ unsigned int desktop;
+
+ int pendingUnmaps;
+ int pendingMaps;
+
+ char *startupId;
+ char *resName;
+ char *resClass;
+
+ CompGroup *group;
+
+ unsigned int lastPong;
+ bool alive;
+
+ GLushort opacity;
+ GLushort brightness;
+ GLushort saturation;
+
+ WindowPaintAttrib paint;
+ WindowPaintAttrib lastPaint;
+
+ unsigned int lastMask;
+
+ CompWindowExtents input;
+ CompWindowExtents output;
+
+ CompStruts *struts;
+
+ CompIcon **icon;
+ int nIcon;
+
+ XRectangle iconGeometry;
+ bool iconGeometrySet;
+
+ XWindowChanges saveWc;
+ int saveMask;
+
+ XSyncCounter syncCounter;
+ XSyncValue syncValue;
+ XSyncAlarm syncAlarm;
+ unsigned long syncAlarmConnection;
+ unsigned int syncWaitHandle;
+
+ bool syncWait;
+ int syncX;
+ int syncY;
+ int syncWidth;
+ int syncHeight;
+ int syncBorderWidth;
+
+ 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 c1b8594..b10f915 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -47,7 +47,10 @@
#include <compiz-core.h>
-#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
+#include <compscreen.h>
+#include "privatescreen.h"
+
+#define NUM_OPTIONS(s) (sizeof ((s)->priv->opt) / sizeof (CompOption))
static int
reallocScreenPrivate (int size,
@@ -57,13 +60,13 @@ reallocScreenPrivate (int size,
CompScreen *s;
void *privates;
- for (s = d->screens; s; s = s->next)
+ for (s = d->screens(); s; s = s->next)
{
- privates = realloc (s->base.privates, size * sizeof (CompPrivate));
+ privates = realloc (s->privates, size * sizeof (CompPrivate));
if (!privates)
return FALSE;
- s->base.privates = (CompPrivate *) privates;
+ s->privates = (CompPrivate *) privates;
}
return TRUE;
@@ -102,9 +105,9 @@ forEachScreenObject (CompObject *parent,
CORE_DISPLAY (parent);
- for (s = d->screens; s; s = s->next)
+ for (s = d->screens(); s; s = s->next)
{
- if (!(*proc) (&s->base, closure))
+ if (!(*proc) (s, closure))
return FALSE;
}
}
@@ -119,7 +122,7 @@ nameScreenObject (CompObject *object)
CORE_SCREEN (object);
- snprintf (tmp, 256, "%d", s->screenNum);
+ snprintf (tmp, 256, "%d", s->screenNum ());
return strdup (tmp);
}
@@ -135,9 +138,9 @@ findScreenObject (CompObject *parent,
CORE_DISPLAY (parent);
- for (s = d->screens; s; s = s->next)
- if (s->screenNum == screenNum)
- return &s->base;
+ for (s = d->screens(); s; s = s->next)
+ if (s->screenNum () == screenNum)
+ return s;
}
return NULL;
@@ -146,126 +149,125 @@ findScreenObject (CompObject *parent,
int
allocateScreenPrivateIndex (CompDisplay *display)
{
- return compObjectAllocatePrivateIndex (&display->base,
- COMP_OBJECT_TYPE_SCREEN);
+ return compObjectAllocatePrivateIndex (display, COMP_OBJECT_TYPE_SCREEN);
}
void
freeScreenPrivateIndex (CompDisplay *display,
int index)
{
- compObjectFreePrivateIndex (&display->base,
- COMP_OBJECT_TYPE_SCREEN,
- index);
+ compObjectFreePrivateIndex (display, COMP_OBJECT_TYPE_SCREEN, index);
}
-static Bool
-desktopHintEqual (CompScreen *s,
- unsigned long *data,
- int size,
- int offset,
- int hintSize)
+
+bool
+PrivateScreen::desktopHintEqual (unsigned long *data,
+ int size,
+ int offset,
+ int hintSize)
{
- if (size != s->desktopHintSize)
- return FALSE;
+ if (size != desktopHintSize)
+ return false;
if (memcmp (data + offset,
- s->desktopHintData + offset,
+ desktopHintData + offset,
hintSize * sizeof (unsigned long)) == 0)
- return TRUE;
+ return true;
- return FALSE;
+ return false;
}
-static void
-setDesktopHints (CompScreen *s)
+void
+PrivateScreen::setDesktopHints ()
{
- CompDisplay *d = s->display;
unsigned long *data;
- int size, offset, hintSize, i;
+ int size, offset, hintSize;
+ unsigned int i;
- size = s->nDesktop * 2 + s->nDesktop * 2 + s->nDesktop * 4 + 1;
+ size = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1;
data = (unsigned long *) malloc (sizeof (unsigned long) * size);
if (!data)
return;
offset = 0;
- hintSize = s->nDesktop * 2;
+ hintSize = nDesktop * 2;
- for (i = 0; i < s->nDesktop; i++)
+ for (i = 0; i < nDesktop; i++)
{
- data[offset + i * 2 + 0] = s->x * s->width;
- data[offset + i * 2 + 1] = s->y * s->height;
+ data[offset + i * 2 + 0] = x * width;
+ data[offset + i * 2 + 1] = y * height;
}
- if (!desktopHintEqual (s, data, size, offset, hintSize))
- XChangeProperty (d->display, s->root, d->desktopViewportAtom,
+ if (!desktopHintEqual (data, size, offset, hintSize))
+ XChangeProperty (display->dpy (), root,
+ display->atoms ().desktopViewport,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
offset += hintSize;
- for (i = 0; i < s->nDesktop; i++)
+ for (i = 0; i < nDesktop; i++)
{
- data[offset + i * 2 + 0] = s->width * s->hsize;
- data[offset + i * 2 + 1] = s->height * s->vsize;
+ data[offset + i * 2 + 0] = width * hsize;
+ data[offset + i * 2 + 1] = height * vsize;
}
- if (!desktopHintEqual (s, data, size, offset, hintSize))
- XChangeProperty (d->display, s->root, d->desktopGeometryAtom,
+ if (!desktopHintEqual (data, size, offset, hintSize))
+ XChangeProperty (display->dpy (), root,
+ display->atoms ().desktopGeometry,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
offset += hintSize;
- hintSize = s->nDesktop * 4;
+ hintSize = nDesktop * 4;
- for (i = 0; i < s->nDesktop; i++)
+ for (i = 0; i < nDesktop; i++)
{
- data[offset + i * 4 + 0] = s->workArea.x;
- data[offset + i * 4 + 1] = s->workArea.y;
- data[offset + i * 4 + 2] = s->workArea.width;
- data[offset + i * 4 + 3] = s->workArea.height;
+ data[offset + i * 4 + 0] = workArea.x;
+ data[offset + i * 4 + 1] = workArea.y;
+ data[offset + i * 4 + 2] = workArea.width;
+ data[offset + i * 4 + 3] = workArea.height;
}
- if (!desktopHintEqual (s, data, size, offset, hintSize))
- XChangeProperty (d->display, s->root, d->workareaAtom,
+ if (!desktopHintEqual (data, size, offset, hintSize))
+ XChangeProperty (display->dpy (), root,
+ display->atoms ().workarea,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
offset += hintSize;
- data[offset] = s->nDesktop;
+ data[offset] = nDesktop;
hintSize = 1;
- if (!desktopHintEqual (s, data, size, offset, hintSize))
- XChangeProperty (d->display, s->root, d->numberOfDesktopsAtom,
+ if (!desktopHintEqual (data, size, offset, hintSize))
+ XChangeProperty (display->dpy (), root,
+ display->atoms ().numberOfDesktops,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
- if (s->desktopHintData)
- free (s->desktopHintData);
+ if (desktopHintData)
+ free (desktopHintData);
- s->desktopHintData = data;
- s->desktopHintSize = size;
+ desktopHintData = data;
+ desktopHintSize = size;
}
-static void
-setVirtualScreenSize (CompScreen *screen,
- int hsize,
- int vsize)
+void
+PrivateScreen::setVirtualScreenSize (int newh, int newv)
{
- screen->hsize = hsize;
- screen->vsize = vsize;
+ hsize = newh;
+ vsize = newv;
- setDesktopHints (screen);
+ setDesktopHints ();
}
-static void
-updateOutputDevices (CompScreen *s)
+void
+PrivateScreen::updateOutputDevices ()
{
CompOutput *o, *output = NULL;
- CompListValue *list = &s->opt[COMP_SCREEN_OPTION_OUTPUTS].value.list;
+ CompListValue *list = &opt[COMP_SCREEN_OPTION_OUTPUTS].value.list;
int nOutput = 0;
int x, y, i, j, bits;
unsigned int width, height;
@@ -279,16 +281,16 @@ updateOutputDevices (CompScreen *s)
x = 0;
y = 0;
- width = s->width;
- height = s->height;
+ width = this->width;
+ height = this->height;
bits = XParseGeometry (list->value[i].s, &x, &y, &width, &height);
if (bits & XNegative)
- x = s->width + x - width;
+ x = this->width + x - width;
if (bits & YNegative)
- y = s->height + y - height;
+ y = this->height + y - height;
x1 = x;
y1 = y;
@@ -299,10 +301,10 @@ updateOutputDevices (CompScreen *s)
x1 = 0;
if (y1 < 0)
y1 = 0;
- if (x2 > s->width)
- x2 = s->width;
- if (y2 > s->height)
- y2 = s->height;
+ if (x2 > this->width)
+ x2 = this->width;
+ if (y2 > this->height)
+ y2 = this->height;
if (x1 < x2 && y1 < y2)
{
@@ -329,8 +331,8 @@ updateOutputDevices (CompScreen *s)
output->region.extents.x1 = 0;
output->region.extents.y1 = 0;
- output->region.extents.x2 = s->width;
- output->region.extents.y2 = s->height;
+ output->region.extents.x2 = this->width;
+ output->region.extents.y2 = this->height;
nOutput = 1;
}
@@ -358,25 +360,25 @@ updateOutputDevices (CompScreen *s)
output[i].id = i;
}
- if (s->outputDev)
+ if (outputDev)
{
- for (i = 0; i < s->nOutputDev; i++)
- if (s->outputDev[i].name)
- free (s->outputDev[i].name);
+ for (i = 0; i < nOutputDev; i++)
+ if (outputDev[i].name)
+ free (outputDev[i].name);
- free (s->outputDev);
+ free (outputDev);
}
- s->outputDev = output;
- s->nOutputDev = nOutput;
- s->hasOverlappingOutputs = FALSE;
+ outputDev = output;
+ nOutputDev = nOutput;
+ hasOverlappingOutputs = false;
- setCurrentOutput (s, s->currentOutputDev);
+ screen->setCurrentOutput (currentOutputDev);
- updateWorkareaForScreen (s);
+ screen->updateWorkarea ();
- setDefaultViewport (s);
- damageScreen (s);
+ screen->setDefaultViewport ();
+ screen->damageScreen ();
region = XCreateRegion ();
if (region)
@@ -393,18 +395,18 @@ updateOutputDevices (CompScreen *s)
&output[j].region,
region);
if (REGION_NOT_EMPTY (region))
- s->hasOverlappingOutputs = TRUE;
+ hasOverlappingOutputs = true;
}
XSubtractRegion (&emptyRegion, &emptyRegion, region);
- if (s->display->nScreenInfo)
+ if (display->nScreenInfo())
{
- for (i = 0; i < s->display->nScreenInfo; i++)
+ for (i = 0; i < display->nScreenInfo(); i++)
{
- r.extents.x1 = s->display->screenInfo[i].x_org;
- r.extents.y1 = s->display->screenInfo[i].y_org;
- r.extents.x2 = r.extents.x1 + s->display->screenInfo[i].width;
- r.extents.y2 = r.extents.y1 + s->display->screenInfo[i].height;
+ 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);
}
@@ -413,52 +415,53 @@ updateOutputDevices (CompScreen *s)
{
r.extents.x1 = 0;
r.extents.y1 = 0;
- r.extents.x2 = s->width;
- r.extents.y2 = s->height;
+ r.extents.x2 = this->width;
+ r.extents.y2 = this->height;
XUnionRegion (region, &r, region);
}
/* remove all output regions from visible screen region */
- for (i = 0; i < s->nOutputDev; i++)
- XSubtractRegion (region, &s->outputDev[i].region, region);
+ for (i = 0; i < nOutputDev; i++)
+ XSubtractRegion (region, &outputDev[i].region, region);
/* we should clear color buffers before swapping if we have visible
regions without output */
- s->clearBuffers = REGION_NOT_EMPTY (region);
+ clearBuffers = REGION_NOT_EMPTY (region);
XDestroyRegion (region);
}
- (*s->outputChangeNotify) (s);
+ screen->outputChangeNotify ();
}
-static void
-detectOutputDevices (CompScreen *s)
+void
+PrivateScreen::detectOutputDevices ()
{
- if (!noDetection && s->opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b)
+ if (!noDetection && opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b)
{
char *name;
CompOptionValue value;
char output[1024];
int i, size = sizeof (output);
- if (s->display->nScreenInfo)
+ if (display->nScreenInfo())
{
- int n = s->display->nScreenInfo;
+ int n = display->nScreenInfo();
value.list.nValue = n;
- value.list.value = (CompOptionValue *) malloc (sizeof (CompOptionValue) * n);
+ value.list.value = (CompOptionValue *)
+ malloc (sizeof (CompOptionValue) * n);
if (!value.list.value)
return;
for (i = 0; i < n; i++)
{
snprintf (output, size, "%dx%d+%d+%d",
- s->display->screenInfo[i].width,
- s->display->screenInfo[i].height,
- s->display->screenInfo[i].x_org,
- s->display->screenInfo[i].y_org);
+ display->screenInfo()[i].width,
+ display->screenInfo()[i].height,
+ display->screenInfo()[i].x_org,
+ display->screenInfo()[i].y_org);
value.list.value[i].s = strdup (output);
}
@@ -470,16 +473,16 @@ detectOutputDevices (CompScreen *s)
if (!value.list.value)
return;
- snprintf (output, size, "%dx%d+%d+%d", s->width, s->height, 0, 0);
+ snprintf (output, size, "%dx%d+%d+%d", width, height, 0, 0);
value.list.value->s = strdup (output);
}
- name = s->opt[COMP_SCREEN_OPTION_OUTPUTS].name;
+ name = opt[COMP_SCREEN_OPTION_OUTPUTS].name;
- s->opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b = FALSE;
- (*core.setOptionForPlugin) (&s->base, "core", name, &value);
- s->opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b = TRUE;
+ opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b = false;
+ core->setOptionForPlugin (screen, "core", name, &value);
+ opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b = true;
for (i = 0; i < value.list.nValue; i++)
if (value.list.value[i].s)
@@ -489,60 +492,66 @@ detectOutputDevices (CompScreen *s)
}
else
{
- updateOutputDevices (s);
+ updateOutputDevices ();
}
}
CompOption *
-getScreenOptions (CompPlugin *plugin,
- CompScreen *screen,
- int *count)
+CompScreen::getScreenOptions (CompObject *object,
+ int *count)
{
+ CompScreen *screen = (CompScreen *) object;
*count = NUM_OPTIONS (screen);
- return screen->opt;
+ return screen->priv->opt;
}
-Bool
-setScreenOption (CompPlugin *plugin,
- CompScreen *screen,
+bool
+setScreenOption (CompObject *object,
const char *name,
CompOptionValue *value)
{
+ return ((CompScreen *) object)->setOption (name, value);
+}
+
+bool
+CompScreen::setOption (const char *name,
+ CompOptionValue *value)
+{
CompOption *o;
int index;
- o = compFindOption (screen->opt, NUM_OPTIONS (screen), name, &index);
+ o = compFindOption (priv->opt, NUM_OPTIONS (this), name, &index);
if (!o)
- return FALSE;
+ return false;
switch (index) {
case COMP_SCREEN_OPTION_DETECT_REFRESH_RATE:
if (compSetBoolOption (o, value))
{
if (value->b)
- detectRefreshRateOfScreen (screen);
+ detectRefreshRate ();
- return TRUE;
+ return true;
}
break;
case COMP_SCREEN_OPTION_DETECT_OUTPUTS:
if (compSetBoolOption (o, value))
{
if (value->b)
- detectOutputDevices (screen);
+ priv->detectOutputDevices ();
- return TRUE;
+ return true;
}
break;
case COMP_SCREEN_OPTION_REFRESH_RATE:
- if (screen->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b)
- return FALSE;
+ if (priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b)
+ return false;
if (compSetIntOption (o, value))
{
- screen->redrawTime = 1000 / o->value.i;
- screen->optimalRedrawTime = screen->redrawTime;
- return TRUE;
+ priv->redrawTime = 1000 / o->value.i;
+ priv->optimalRedrawTime = priv->redrawTime;
+ return true;
}
break;
case COMP_SCREEN_OPTION_HSIZE:
@@ -550,17 +559,17 @@ setScreenOption (CompPlugin *plugin,
{
CompOption *vsize;
- vsize = compFindOption (screen->opt, NUM_OPTIONS (screen),
+ vsize = compFindOption (priv->opt, NUM_OPTIONS (this),
"vsize", NULL);
if (!vsize)
- return FALSE;
+ return false;
- if (o->value.i * screen->width > MAXSHORT)
- return FALSE;
+ if (o->value.i * priv->width > MAXSHORT)
+ return false;
- setVirtualScreenSize (screen, o->value.i, vsize->value.i);
- return TRUE;
+ priv->setVirtualScreenSize (o->value.i, vsize->value.i);
+ return true;
}
break;
case COMP_SCREEN_OPTION_VSIZE:
@@ -568,81 +577,55 @@ setScreenOption (CompPlugin *plugin,
{
CompOption *hsize;
- hsize = compFindOption (screen->opt, NUM_OPTIONS (screen),
+ hsize = compFindOption (priv->opt, NUM_OPTIONS (this),
"hsize", NULL);
if (!hsize)
- return FALSE;
+ return false;
- if (o->value.i * screen->height > MAXSHORT)
- return FALSE;
+ if (o->value.i * priv->height > MAXSHORT)
+ return false;
- setVirtualScreenSize (screen, hsize->value.i, o->value.i);
- return TRUE;
+ priv->setVirtualScreenSize (hsize->value.i, o->value.i);
+ return true;
}
break;
case COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS:
if (compSetIntOption (o, value))
{
- setNumberOfDesktops (screen, o->value.i);
- return TRUE;
+ setNumberOfDesktops (o->value.i);
+ return true;
}
break;
case COMP_SCREEN_OPTION_DEFAULT_ICON:
if (compSetStringOption (o, value))
- return updateDefaultIcon (screen);
+ return updateDefaultIcon ();
break;
case COMP_SCREEN_OPTION_OUTPUTS:
if (!noDetection &&
- screen->opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b)
- return FALSE;
-
- if (compSetOptionList (o, value))
- {
- updateOutputDevices (screen);
- return TRUE;
- }
- break;
- case COMP_SCREEN_OPTION_OPACITY_MATCHES:
- if (compSetOptionList (o, value))
- {
- CompWindow *w;
- int i;
+ priv->opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value.b)
+ return false;
- for (i = 0; i < o->value.list.nValue; i++)
- matchUpdate (screen->display, &o->value.list.value[i].match);
-
- for (w = screen->windows; w; w = w->next)
- updateWindowOpacity (w);
-
- return TRUE;
- }
- break;
- case COMP_SCREEN_OPTION_OPACITY_VALUES:
if (compSetOptionList (o, value))
{
- CompWindow *w;
-
- for (w = screen->windows; w; w = w->next)
- updateWindowOpacity (w);
-
- return TRUE;
+ priv->updateOutputDevices ();
+ return true;
}
break;
case COMP_SCREEN_OPTION_FORCE_INDEPENDENT:
if (compSetBoolOption (o, value))
{
- updateOutputDevices (screen);
- return TRUE;
+ priv->updateOutputDevices ();
+ return true;
}
break;
default:
- if (compSetScreenOption (screen, o, value))
- return TRUE;
+ if (compSetScreenOption (this, o, value))
+ return true;
break;
}
- return FALSE;
+ return false;
}
const CompMetadataOptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
@@ -663,34 +646,40 @@ const CompMetadataOptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
{ "focus_prevention_level", "int",
RESTOSTRING (0, FOCUS_PREVENTION_LEVEL_LAST), 0, 0 },
{ "focus_prevention_match", "match", 0, 0, 0 },
- { "opacity_matches", "list", "<type>match</type>", 0, 0 },
- { "opacity_values", "list", "<type>int</type>", 0, 0 },
{ "texture_compression", "bool", 0, 0, 0 },
{ "force_independent_output_painting", "bool", 0, 0, 0 }
};
-static void
-updateStartupFeedback (CompScreen *s)
+void
+PrivateScreen::updateStartupFeedback ()
{
- if (s->startupSequences)
- XDefineCursor (s->display->display, s->root, s->busyCursor);
+ if (startupSequences)
+ XDefineCursor (display->dpy (), root, busyCursor);
else
- XDefineCursor (s->display->display, s->root, s->normalCursor);
+ XDefineCursor (display->dpy (), root, normalCursor);
}
#define STARTUP_TIMEOUT_DELAY 15000
-static Bool
-startupSequenceTimeout (void *data)
+bool
+CompScreen::startupSequenceTimeout (void *data)
+{
+ CompScreen *screen = (CompScreen *) data;
+
+ screen->priv->handleStartupSequenceTimeout ();
+ return true;
+}
+
+void
+PrivateScreen::handleStartupSequenceTimeout()
{
- CompScreen *screen = (CompScreen *) data;
CompStartupSequence *s;
struct timeval now, active;
double elapsed;
gettimeofday (&now, NULL);
- for (s = screen->startupSequences; s; s = s->next)
+ for (s = startupSequences; s; s = s->next)
{
sn_startup_sequence_get_last_active_time (s->sequence,
&active.tv_sec,
@@ -702,13 +691,10 @@ startupSequenceTimeout (void *data)
if (elapsed > STARTUP_TIMEOUT_DELAY)
sn_startup_sequence_complete (s->sequence);
}
-
- return TRUE;
}
-static void
-addSequence (CompScreen *screen,
- SnStartupSequence *sequence)
+void
+PrivateScreen::addSequence (SnStartupSequence *sequence)
{
CompStartupSequence *s;
@@ -718,28 +704,27 @@ addSequence (CompScreen *screen,
sn_startup_sequence_ref (sequence);
- s->next = screen->startupSequences;
+ s->next = startupSequences;
s->sequence = sequence;
- s->viewportX = screen->x;
- s->viewportY = screen->y;
+ s->viewportX = x;
+ s->viewportY = y;
- screen->startupSequences = s;
+ startupSequences = s;
- if (!screen->startupSequenceTimeoutHandle)
- compAddTimeout (1000, 1500,
- startupSequenceTimeout,
- screen);
+ if (!startupSequenceTimeoutHandle)
+ core->addTimeout (1000, 1500,
+ CompScreen::startupSequenceTimeout,
+ this);
- updateStartupFeedback (screen);
+ updateStartupFeedback ();
}
-static void
-removeSequence (CompScreen *screen,
- SnStartupSequence *sequence)
+void
+PrivateScreen::removeSequence (SnStartupSequence *sequence)
{
CompStartupSequence *s, *p = NULL;
- for (s = screen->startupSequences; s; s = s->next)
+ for (s = startupSequences; s; s = s->next)
{
if (s->sequence == sequence)
break;
@@ -755,22 +740,22 @@ removeSequence (CompScreen *screen,
if (p)
p->next = s->next;
else
- screen->startupSequences = NULL;
+ startupSequences = NULL;
free (s);
- if (!screen->startupSequences && screen->startupSequenceTimeoutHandle)
+ if (!startupSequences && startupSequenceTimeoutHandle)
{
- compRemoveTimeout (screen->startupSequenceTimeoutHandle);
- screen->startupSequenceTimeoutHandle = 0;
+ core->removeTimeout (startupSequenceTimeoutHandle);
+ startupSequenceTimeoutHandle = 0;
}
- updateStartupFeedback (screen);
+ updateStartupFeedback ();
}
-static void
-compScreenSnEvent (SnMonitorEvent *event,
- void *userData)
+void
+CompScreen::compScreenSnEvent (SnMonitorEvent *event,
+ void *userData)
{
CompScreen *screen = (CompScreen *) userData;
SnStartupSequence *sequence;
@@ -779,10 +764,10 @@ compScreenSnEvent (SnMonitorEvent *event,
switch (sn_monitor_event_get_type (event)) {
case SN_MONITOR_EVENT_INITIATED:
- addSequence (screen, sequence);
+ screen->priv->addSequence (sequence);
break;
case SN_MONITOR_EVENT_COMPLETED:
- removeSequence (screen, sn_monitor_event_get_startup_sequence (event));
+ screen->priv->removeSequence (sn_monitor_event_get_startup_sequence (event));
break;
case SN_MONITOR_EVENT_CHANGED:
case SN_MONITOR_EVENT_CANCELED:
@@ -790,8 +775,8 @@ compScreenSnEvent (SnMonitorEvent *event,
}
}
-static void
-updateScreenEdges (CompScreen *s)
+void
+PrivateScreen::updateScreenEdges ()
{
struct screenEdgeGeometry {
int xw, x0;
@@ -812,12 +797,12 @@ updateScreenEdges (CompScreen *s)
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (s->screenEdge[i].id)
- XMoveResizeWindow (s->display->display, s->screenEdge[i].id,
- geometry[i].xw * s->width + geometry[i].x0,
- geometry[i].yh * s->height + geometry[i].y0,
- geometry[i].ww * s->width + geometry[i].w0,
- geometry[i].hh * s->height + geometry[i].h0);
+ if (screenEdge[i].id)
+ XMoveResizeWindow (display->dpy (), screenEdge[i].id,
+ geometry[i].xw * width + geometry[i].x0,
+ geometry[i].yh * height + geometry[i].y0,
+ geometry[i].ww * width + geometry[i].w0,
+ geometry[i].hh * height + geometry[i].h0);
}
}
@@ -866,36 +851,24 @@ perspective (GLfloat *m,
}
void
-setCurrentOutput (CompScreen *s,
- int outputNum)
+CompScreen::setCurrentOutput (int outputNum)
{
- if (outputNum >= s->nOutputDev)
+ if (outputNum >= priv->nOutputDev)
outputNum = 0;
- s->currentOutputDev = outputNum;
+ priv->currentOutputDev = outputNum;
}
-static void
-reshape (CompScreen *s,
- int w,
- int h)
+void
+PrivateScreen::reshape (int w, int h)
{
#ifdef USE_COW
if (useCow)
- XMoveResizeWindow (s->display->display, s->overlay, 0, 0, w, h);
+ XMoveResizeWindow (display->dpy (), overlay, 0, 0, w, h);
#endif
- if (s->display->xineramaExtension)
- {
- CompDisplay *d = s->display;
-
- if (d->screenInfo)
- XFree (d->screenInfo);
-
- d->nScreenInfo = 0;
- d->screenInfo = XineramaQueryScreens (d->display, &d->nScreenInfo);
- }
+ display->updateScreenInfo();
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
@@ -905,66 +878,64 @@ reshape (CompScreen *s,
glViewport (-1, -1, 2, 2);
glRasterPos2f (0, 0);
- s->rasterX = s->rasterY = 0;
+ rasterX = rasterY = 0;
- perspective (s->projection, 60.0f, 1.0f, 0.1f, 100.0f);
+ perspective (projection, 60.0f, 1.0f, 0.1f, 100.0f);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
- glMultMatrixf (s->projection);
+ glMultMatrixf (projection);
glMatrixMode (GL_MODELVIEW);
- s->region.rects = &s->region.extents;
- s->region.numRects = 1;
- s->region.extents.x1 = 0;
- s->region.extents.y1 = 0;
- s->region.extents.x2 = w;
- s->region.extents.y2 = h;
- s->region.size = 1;
-
- s->width = w;
- s->height = h;
-
- s->fullscreenOutput.name = "fullscreen";
- s->fullscreenOutput.id = ~0;
- s->fullscreenOutput.width = w;
- s->fullscreenOutput.height = h;
- s->fullscreenOutput.region = s->region;
- s->fullscreenOutput.workArea.x = 0;
- s->fullscreenOutput.workArea.y = 0;
- s->fullscreenOutput.workArea.width = w;
- s->fullscreenOutput.workArea.height = h;
+ region.rects = &region.extents;
+ region.numRects = 1;
+ region.extents.x1 = 0;
+ region.extents.y1 = 0;
+ region.extents.x2 = w;
+ region.extents.y2 = h;
+ region.size = 1;
+
+ width = w;
+ height = h;
+
+ fullscreenOutput.name = "fullscreen";
+ fullscreenOutput.id = ~0;
+ fullscreenOutput.width = w;
+ fullscreenOutput.height = h;
+ fullscreenOutput.region = region;
+ fullscreenOutput.workArea.x = 0;
+ fullscreenOutput.workArea.y = 0;
+ fullscreenOutput.workArea.width = w;
+ fullscreenOutput.workArea.height = h;
- updateScreenEdges (s);
+ updateScreenEdges ();
}
void
-configureScreen (CompScreen *s,
- XConfigureEvent *ce)
+CompScreen::configure (XConfigureEvent *ce)
{
- if (s->attrib.width != ce->width ||
- s->attrib.height != ce->height)
+ if (priv->attrib.width != ce->width ||
+ priv->attrib.height != ce->height)
{
- s->attrib.width = ce->width;
- s->attrib.height = ce->height;
+ priv->attrib.width = ce->width;
+ priv->attrib.height = ce->height;
- reshape (s, ce->width, ce->height);
+ priv->reshape (ce->width, ce->height);
- detectOutputDevices (s);
+ priv->detectOutputDevices ();
- damageScreen (s);
+ damageScreen ();
}
}
-static FuncPtr
-getProcAddress (CompScreen *s,
- const char *name)
+FuncPtr
+CompScreen::getProcAddress (const char *name)
{
static void *dlhand = NULL;
FuncPtr funcPtr = NULL;
- if (s->getProcAddress)
- funcPtr = s->getProcAddress ((GLubyte *) name);
+ if (priv->getProcAddress)
+ funcPtr = priv->getProcAddress ((GLubyte *) name);
if (!funcPtr)
{
@@ -984,10 +955,9 @@ getProcAddress (CompScreen *s,
}
void
-updateScreenBackground (CompScreen *screen,
- CompTexture *texture)
+PrivateScreen::updateScreenBackground (CompTexture *texture)
{
- Display *dpy = screen->display->display;
+ Display *dpy = display->dpy ();
Atom pixmapAtom, actualType;
int actualFormat, i, status;
unsigned int width = 1, height = 1, depth = 0;
@@ -1000,8 +970,8 @@ updateScreenBackground (CompScreen *screen,
for (i = 0; pixmap == 0 && i < 2; i++)
{
- status = XGetWindowProperty (dpy, screen->root,
- screen->display->xBackgroundAtom[i],
+ status = XGetWindowProperty (dpy, root,
+ display->atoms ().xBackground[i],
0, 4, FALSE, AnyPropertyType,
&actualType, &actualFormat, &nItems,
&bytesAfter, &prop);
@@ -1025,7 +995,7 @@ updateScreenBackground (CompScreen *screen,
if (XGetGeometry (dpy, p, &w, &i, &i,
&width, &height, &ui, &depth))
{
- if (depth == screen->attrib.depth)
+ if (depth == attrib.depth)
pixmap = p;
}
}
@@ -1043,8 +1013,7 @@ updateScreenBackground (CompScreen *screen,
finiTexture (screen, texture);
initTexture (screen, texture);
- if (!bindPixmapToTexture (screen, texture, pixmap,
- width, height, depth))
+ if (!screen->bindPixmapToTexture (texture, pixmap, width, height, depth))
{
compLogMessage (NULL, "core", CompLogLevelWarn,
"Couldn't bind background pixmap 0x%x to "
@@ -1070,20 +1039,21 @@ updateScreenBackground (CompScreen *screen,
}
void
-detectRefreshRateOfScreen (CompScreen *s)
+CompScreen::detectRefreshRate ()
{
- if (!noDetection && s->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b)
+ if (!noDetection &&
+ priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b)
{
char *name;
CompOptionValue value;
value.i = 0;
- if (s->display->randrExtension)
+ if (priv->display->XRandr())
{
XRRScreenConfiguration *config;
- config = XRRGetScreenInfo (s->display->display, s->root);
+ config = XRRGetScreenInfo (priv->display->dpy (), priv->root);
value.i = (int) XRRConfigCurrentRate (config);
XRRFreeScreenConfigInfo (config);
@@ -1092,159 +1062,158 @@ detectRefreshRateOfScreen (CompScreen *s)
if (value.i == 0)
value.i = defaultRefreshRate;
- name = s->opt[COMP_SCREEN_OPTION_REFRESH_RATE].name;
+ name = priv->opt[COMP_SCREEN_OPTION_REFRESH_RATE].name;
- s->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b = FALSE;
- (*core.setOptionForPlugin) (&s->base, "core", name, &value);
- s->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b = TRUE;
+ priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b = false;
+ core->setOptionForPlugin (this, "core", name, &value);
+ priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value.b = true;
}
else
{
- s->redrawTime = 1000 / s->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value.i;
- s->optimalRedrawTime = s->redrawTime;
+ priv->redrawTime = 1000 /
+ priv->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value.i;
+ priv->optimalRedrawTime = priv->redrawTime;
}
}
-static void
-setSupportingWmCheck (CompScreen *s)
+void
+PrivateScreen::setSupportingWmCheck ()
{
- CompDisplay *d = s->display;
-
- XChangeProperty (d->display, s->grabWindow, d->supportingWmCheckAtom,
+ XChangeProperty (display->dpy (), grabWindow,
+ display->atoms ().supportingWmCheck,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) &s->grabWindow, 1);
+ (unsigned char *) &grabWindow, 1);
- XChangeProperty (d->display, s->grabWindow, d->wmNameAtom,
- d->utf8StringAtom, 8, PropModeReplace,
+ XChangeProperty (display->dpy (), grabWindow, display->atoms ().wmName,
+ display->atoms ().utf8String, 8, PropModeReplace,
(unsigned char *) PACKAGE, strlen (PACKAGE));
- XChangeProperty (d->display, s->grabWindow, d->winStateAtom,
+ XChangeProperty (display->dpy (), grabWindow, display->atoms ().winState,
XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &d->winStateSkipTaskbarAtom, 1);
- XChangeProperty (d->display, s->grabWindow, d->winStateAtom,
+ (unsigned char *) &display->atoms ().winStateSkipTaskbar,
+ 1);
+ XChangeProperty (display->dpy (), grabWindow, display->atoms ().winState,
XA_ATOM, 32, PropModeAppend,
- (unsigned char *) &d->winStateSkipPagerAtom, 1);
- XChangeProperty (d->display, s->grabWindow, d->winStateAtom,
+ (unsigned char *) &display->atoms ().winStateSkipPager, 1);
+ XChangeProperty (display->dpy (), grabWindow, display->atoms ().winState,
XA_ATOM, 32, PropModeAppend,
- (unsigned char *) &d->winStateHiddenAtom, 1);
+ (unsigned char *) &display->atoms ().winStateHidden, 1);
- XChangeProperty (d->display, s->root, d->supportingWmCheckAtom,
+ XChangeProperty (display->dpy (), root, display->atoms ().supportingWmCheck,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) &s->grabWindow, 1);
+ (unsigned char *) &grabWindow, 1);
}
-static void
-setSupported (CompScreen *s)
+void
+PrivateScreen::setSupported ()
{
- CompDisplay *d = s->display;
Atom data[256];
int i = 0;
- data[i++] = d->supportedAtom;
- data[i++] = d->supportingWmCheckAtom;
+ data[i++] = display->atoms ().supported;
+ data[i++] = display->atoms ().supportingWmCheck;
- data[i++] = d->utf8StringAtom;
+ data[i++] = display->atoms ().utf8String;
- data[i++] = d->clientListAtom;
- data[i++] = d->clientListStackingAtom;
+ data[i++] = display->atoms ().clientList;
+ data[i++] = display->atoms ().clientListStacking;
- data[i++] = d->winActiveAtom;
+ data[i++] = display->atoms ().winActive;
- data[i++] = d->desktopViewportAtom;
- data[i++] = d->desktopGeometryAtom;
- data[i++] = d->currentDesktopAtom;
- data[i++] = d->numberOfDesktopsAtom;
- data[i++] = d->showingDesktopAtom;
+ data[i++] = display->atoms ().desktopViewport;
+ data[i++] = display->atoms ().desktopGeometry;
+ data[i++] = display->atoms ().currentDesktop;
+ data[i++] = display->atoms ().numberOfDesktops;
+ data[i++] = display->atoms ().showingDesktop;
- data[i++] = d->workareaAtom;
+ data[i++] = display->atoms ().workarea;
- data[i++] = d->wmNameAtom;
+ data[i++] = display->atoms ().wmName;
/*
- data[i++] = d->wmVisibleNameAtom;
+ data[i++] = display->atoms ().wmVisibleName;
*/
- data[i++] = d->wmStrutAtom;
- data[i++] = d->wmStrutPartialAtom;
+ data[i++] = display->atoms ().wmStrut;
+ data[i++] = display->atoms ().wmStrutPartial;
/*
- data[i++] = d->wmPidAtom;
+ data[i++] = display->atoms ().wmPid;
*/
- data[i++] = d->wmUserTimeAtom;
- data[i++] = d->frameExtentsAtom;
- data[i++] = d->frameWindowAtom;
-
- data[i++] = d->winStateAtom;
- data[i++] = d->winStateModalAtom;
- data[i++] = d->winStateStickyAtom;
- data[i++] = d->winStateMaximizedVertAtom;
- data[i++] = d->winStateMaximizedHorzAtom;
- data[i++] = d->winStateShadedAtom;
- data[i++] = d->winStateSkipTaskbarAtom;
- data[i++] = d->winStateSkipPagerAtom;
- data[i++] = d->winStateHiddenAtom;
- data[i++] = d->winStateFullscreenAtom;
- data[i++] = d->winStateAboveAtom;
- data[i++] = d->winStateBelowAtom;
- data[i++] = d->winStateDemandsAttentionAtom;
-
- data[i++] = d->winOpacityAtom;
- data[i++] = d->winBrightnessAtom;
-
- if (s->canDoSaturated)
- {
- data[i++] = d->winSaturationAtom;
- data[i++] = d->winStateDisplayModalAtom;
- }
-
- data[i++] = d->wmAllowedActionsAtom;
-
- data[i++] = d->winActionMoveAtom;
- data[i++] = d->winActionResizeAtom;
- data[i++] = d->winActionStickAtom;
- data[i++] = d->winActionMinimizeAtom;
- data[i++] = d->winActionMaximizeHorzAtom;
- data[i++] = d->winActionMaximizeVertAtom;
- data[i++] = d->winActionFullscreenAtom;
- data[i++] = d->winActionCloseAtom;
- data[i++] = d->winActionShadeAtom;
- data[i++] = d->winActionChangeDesktopAtom;
- data[i++] = d->winActionAboveAtom;
- data[i++] = d->winActionBelowAtom;
-
- data[i++] = d->winTypeAtom;
- data[i++] = d->winTypeDesktopAtom;
- data[i++] = d->winTypeDockAtom;
- data[i++] = d->winTypeToolbarAtom;
- data[i++] = d->winTypeMenuAtom;
- data[i++] = d->winTypeSplashAtom;
- data[i++] = d->winTypeDialogAtom;
- data[i++] = d->winTypeUtilAtom;
- data[i++] = d->winTypeNormalAtom;
-
- data[i++] = d->wmDeleteWindowAtom;
- data[i++] = d->wmPingAtom;
-
- data[i++] = d->wmMoveResizeAtom;
- data[i++] = d->moveResizeWindowAtom;
- data[i++] = d->restackWindowAtom;
-
- XChangeProperty (d->display, s->root, d->supportedAtom, XA_ATOM, 32,
- PropModeReplace, (unsigned char *) data, i);
+ data[i++] = display->atoms ().wmUserTime;
+ data[i++] = display->atoms ().frameExtents;
+ data[i++] = display->atoms ().frameWindow;
+
+ data[i++] = display->atoms ().winState;
+ data[i++] = display->atoms ().winStateModal;
+ data[i++] = display->atoms ().winStateSticky;
+ data[i++] = display->atoms ().winStateMaximizedVert;
+ data[i++] = display->atoms ().winStateMaximizedHorz;
+ data[i++] = display->atoms ().winStateShaded;
+ data[i++] = display->atoms ().winStateSkipTaskbar;
+ data[i++] = display->atoms ().winStateSkipPager;
+ data[i++] = display->atoms ().winStateHidden;
+ data[i++] = display->atoms ().winStateFullscreen;
+ data[i++] = display->atoms ().winStateAbove;
+ data[i++] = display->atoms ().winStateBelow;
+ data[i++] = display->atoms ().winStateDemandsAttention;
+
+ data[i++] = display->atoms ().winOpacity;
+ data[i++] = display->atoms ().winBrightness;
+
+ if (canDoSaturated)
+ {
+ data[i++] = display->atoms ().winSaturation;
+ data[i++] = display->atoms ().winStateDisplayModal;
+ }
+
+ data[i++] = display->atoms ().wmAllowedActions;
+
+ data[i++] = display->atoms ().winActionMove;
+ data[i++] = display->atoms ().winActionResize;
+ data[i++] = display->atoms ().winActionStick;
+ data[i++] = display->atoms ().winActionMinimize;
+ data[i++] = display->atoms ().winActionMaximizeHorz;
+ data[i++] = display->atoms ().winActionMaximizeVert;
+ data[i++] = display->atoms ().winActionFullscreen;
+ data[i++] = display->atoms ().winActionClose;
+ data[i++] = display->atoms ().winActionShade;
+ data[i++] = display->atoms ().winActionChangeDesktop;
+ data[i++] = display->atoms ().winActionAbove;
+ data[i++] = display->atoms ().winActionBelow;
+
+ data[i++] = display->atoms ().winType;
+ data[i++] = display->atoms ().winTypeDesktop;
+ data[i++] = display->atoms ().winTypeDock;
+ data[i++] = display->atoms ().winTypeToolbar;
+ data[i++] = display->atoms ().winTypeMenu;
+ data[i++] = display->atoms ().winTypeSplash;
+ data[i++] = display->atoms ().winTypeDialog;
+ data[i++] = display->atoms ().winTypeUtil;
+ data[i++] = display->atoms ().winTypeNormal;
+
+ data[i++] = display->atoms ().wmDeleteWindow;
+ data[i++] = display->atoms ().wmPing;
+
+ data[i++] = display->atoms ().wmMoveResize;
+ data[i++] = display->atoms ().moveResizeWindow;
+ data[i++] = display->atoms ().restackWindow;
+
+ XChangeProperty (display->dpy (), root, display->atoms ().supported,
+ XA_ATOM, 32, PropModeReplace, (unsigned char *) data, i);
}
-static void
-getDesktopHints (CompScreen *s)
+void
+PrivateScreen::getDesktopHints ()
{
- CompDisplay *d = s->display;
unsigned long data[2];
Atom actual;
int result, format;
unsigned long n, left;
unsigned char *propData;
- result = XGetWindowProperty (s->display->display, s->root,
- d->numberOfDesktopsAtom, 0L, 1L, FALSE,
- XA_CARDINAL, &actual, &format,
+ result = XGetWindowProperty (display->dpy (), root,
+ display->atoms ().numberOfDesktops,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
if (result == Success && n && propData && useDesktopHints)
@@ -1253,11 +1222,11 @@ getDesktopHints (CompScreen *s)
XFree (propData);
if (data[0] > 0 && data[0] < 0xffffffff)
- s->nDesktop = data[0];
+ nDesktop = data[0];
}
- result = XGetWindowProperty (s->display->display, s->root,
- d->desktopViewportAtom, 0L, 2L,
+ result = XGetWindowProperty (display->dpy (), root,
+ display->atoms ().desktopViewport, 0L, 2L,
FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
@@ -1267,19 +1236,19 @@ getDesktopHints (CompScreen *s)
{
memcpy (data, propData, sizeof (unsigned long) * 2);
- if (data[0] / s->width < s->hsize - 1)
- s->x = data[0] / s->width;
+ if (data[0] / width < hsize - 1)
+ x = data[0] / width;
- if (data[1] / s->height < s->vsize - 1)
- s->y = data[1] / s->height;
+ if (data[1] / height < vsize - 1)
+ y = data[1] / height;
}
XFree (propData);
}
- result = XGetWindowProperty (s->display->display, s->root,
- d->currentDesktopAtom, 0L, 1L, FALSE,
- XA_CARDINAL, &actual, &format,
+ result = XGetWindowProperty (display->dpy (), root,
+ display->atoms ().currentDesktop,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
if (result == Success && n && propData && useDesktopHints)
@@ -1287,13 +1256,13 @@ getDesktopHints (CompScreen *s)
memcpy (data, propData, sizeof (unsigned long));
XFree (propData);
- if (data[0] < s->nDesktop)
- s->currentDesktop = data[0];
+ if (data[0] < nDesktop)
+ currentDesktop = data[0];
}
- result = XGetWindowProperty (s->display->display, s->root,
- d->showingDesktopAtom, 0L, 1L, FALSE,
- XA_CARDINAL, &actual, &format,
+ result = XGetWindowProperty (display->dpy (), root,
+ display->atoms ().showingDesktop,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
if (result == Success && n && propData)
@@ -1302,65 +1271,65 @@ getDesktopHints (CompScreen *s)
XFree (propData);
if (data[0])
- (*s->enterShowDesktopMode) (s);
+ screen->enterShowDesktopMode ();
}
- data[0] = s->currentDesktop;
+ data[0] = currentDesktop;
- XChangeProperty (d->display, s->root, d->currentDesktopAtom,
+ XChangeProperty (display->dpy (), root, display->atoms ().currentDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) data, 1);
- data[0] = s->showingDesktopMask ? TRUE : FALSE;
+ data[0] = showingDesktopMask ? TRUE : FALSE;
- XChangeProperty (d->display, s->root, d->showingDesktopAtom,
+ XChangeProperty (display->dpy (), root, display->atoms ().showingDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) data, 1);
}
void
-showOutputWindow (CompScreen *s)
+CompScreen::showOutputWindow ()
{
#ifdef USE_COW
if (useCow)
{
- Display *dpy = s->display->display;
+ Display *dpy = priv->display->dpy ();
XserverRegion region;
region = XFixesCreateRegion (dpy, NULL, 0);
XFixesSetWindowShapeRegion (dpy,
- s->output,
+ priv->output,
ShapeBounding,
0, 0, 0);
XFixesSetWindowShapeRegion (dpy,
- s->output,
+ priv->output,
ShapeInput,
0, 0, region);
XFixesDestroyRegion (dpy, region);
- damageScreen (s);
+ damageScreen ();
}
#endif
}
void
-hideOutputWindow (CompScreen *s)
+CompScreen::hideOutputWindow ()
{
#ifdef USE_COW
if (useCow)
{
- Display *dpy = s->display->display;
+ Display *dpy = priv->display->dpy ();
XserverRegion region;
region = XFixesCreateRegion (dpy, NULL, 0);
XFixesSetWindowShapeRegion (dpy,
- s->output,
+ priv->output,
ShapeBounding,
0, 0, region);
@@ -1371,13 +1340,13 @@ hideOutputWindow (CompScreen *s)
}
void
-updateOutputWindow (CompScreen *s)
+CompScreen::updateOutputWindow ()
{
#ifdef USE_COW
if (useCow)
{
- Display *dpy = s->display->display;
+ Display *dpy = priv->display->dpy ();
XserverRegion region;
static Region tmpRegion = NULL;
CompWindow *w;
@@ -1389,22 +1358,22 @@ updateOutputWindow (CompScreen *s)
return;
}
- XSubtractRegion (&s->region, &emptyRegion, tmpRegion);
+ XSubtractRegion (&priv->region, &emptyRegion, tmpRegion);
- for (w = s->reverseWindows; w; w = w->prev)
- if (w->overlayWindow)
+ for (w = priv->reverseWindows; w; w = w->prev)
+ if (w->overlayWindow ())
{
- XSubtractRegion (tmpRegion, w->region, tmpRegion);
+ XSubtractRegion (tmpRegion, w->region (), tmpRegion);
}
- XShapeCombineRegion (dpy, s->output, ShapeBounding,
+ XShapeCombineRegion (dpy, priv->output, ShapeBounding,
0, 0, tmpRegion, ShapeSet);
region = XFixesCreateRegion (dpy, NULL, 0);
XFixesSetWindowShapeRegion (dpy,
- s->output,
+ priv->output,
ShapeInput,
0, 0, region);
@@ -1414,109 +1383,113 @@ updateOutputWindow (CompScreen *s)
}
-static void
-makeOutputWindow (CompScreen *s)
+void
+PrivateScreen::makeOutputWindow ()
{
#ifdef USE_COW
if (useCow)
{
- s->overlay = XCompositeGetOverlayWindow (s->display->display, s->root);
- s->output = s->overlay;
+ overlay = XCompositeGetOverlayWindow (display->dpy (), root);
+ output = overlay;
- XSelectInput (s->display->display, s->output, ExposureMask);
+ XSelectInput (display->dpy (), output, ExposureMask);
}
else
#endif
- s->output = s->overlay = s->root;
+ output = overlay = root;
- showOutputWindow (s);
+ screen->showOutputWindow ();
}
-static void
-enterShowDesktopMode (CompScreen *s)
+void
+CompScreen::enterShowDesktopMode ()
{
- CompDisplay *d = s->display;
+ WRAPABLE_HND_FUNC(enterShowDesktopMode)
+
+ CompDisplay *d = priv->display;
CompWindow *w;
unsigned long data = 1;
int count = 0;
- CompOption *st = &d->opt[COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS];
+ CompOption *st = d->getOption ("hide_skip_taskbar_windows");
- s->showingDesktopMask = ~(CompWindowTypeDesktopMask |
- CompWindowTypeDockMask);
+ priv->showingDesktopMask = ~(CompWindowTypeDesktopMask |
+ CompWindowTypeDockMask);
- for (w = s->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
{
- if ((s->showingDesktopMask & w->wmType) &&
- (!(w->state & CompWindowStateSkipTaskbarMask) || st->value.b))
+ if ((priv->showingDesktopMask & w->wmType ()) &&
+ (!(w->state () & CompWindowStateSkipTaskbarMask) ||
+ (st && st->value.b)))
{
- if (!w->inShowDesktopMode && !w->grabbed &&
- w->managed && (*s->focusWindow) (w))
+ if (!w->inShowDesktopMode () && !w->grabbed () &&
+ w->managed () && w->focus ())
{
- w->inShowDesktopMode = TRUE;
- hideWindow (w);
+ w->setShowDesktopMode (true);
+ w->hide ();
}
}
- if (w->inShowDesktopMode)
+ if (w->inShowDesktopMode ())
count++;
}
if (!count)
{
- s->showingDesktopMask = 0;
+ priv->showingDesktopMask = 0;
data = 0;
}
- XChangeProperty (s->display->display, s->root,
- s->display->showingDesktopAtom,
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().showingDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data, 1);
}
-static void
-leaveShowDesktopMode (CompScreen *s,
- CompWindow *window)
+void
+CompScreen::leaveShowDesktopMode (CompWindow *window)
{
+ WRAPABLE_HND_FUNC(leaveShowDesktopMode, window)
+
CompWindow *w;
unsigned long data = 0;
if (window)
{
- if (!window->inShowDesktopMode)
+ if (!window->inShowDesktopMode ())
return;
- window->inShowDesktopMode = FALSE;
- showWindow (window);
+ window->setShowDesktopMode (false);
+ window->show ();
/* return if some other window is still in show desktop mode */
- for (w = s->windows; w; w = w->next)
- if (w->inShowDesktopMode)
+ for (w = priv->windows; w; w = w->next)
+ if (w->inShowDesktopMode ())
return;
- s->showingDesktopMask = 0;
+ priv->showingDesktopMask = 0;
}
else
{
- s->showingDesktopMask = 0;
+ priv->showingDesktopMask = 0;
- for (w = s->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
{
- if (!w->inShowDesktopMode)
+ if (!w->inShowDesktopMode ())
continue;
- w->inShowDesktopMode = FALSE;
- showWindow (w);
+ w->setShowDesktopMode (false);
+ w->show ();
}
/* focus default window - most likely this will be the window
which had focus before entering showdesktop mode */
- focusDefaultWindow (s);
+ focusDefaultWindow ();
}
- XChangeProperty (s->display->display, s->root,
- s->display->showingDesktopAtom,
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().showingDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data, 1);
}
@@ -1524,13 +1497,13 @@ leaveShowDesktopMode (CompScreen *s,
static CompWindow *
walkFirst (CompScreen *s)
{
- return s->windows;
+ return s->windows ();
}
static CompWindow *
walkLast (CompScreen *s)
{
- return s->reverseWindows;
+ return s->reverseWindows ();
}
static CompWindow *
@@ -1545,10 +1518,11 @@ walkPrev (CompWindow *w)
return w->prev;
}
-static void
-initWindowWalker (CompScreen *screen,
- CompWalker *walker)
+void
+CompScreen::initWindowWalker (CompWalker *walker)
{
+ WRAPABLE_HND_FUNC(initWindowWalker, walker)
+
walker->fini = NULL;
walker->first = walkFirst;
walker->last = walkLast;
@@ -1556,69 +1530,309 @@ initWindowWalker (CompScreen *screen,
walker->prev = walkPrev;
}
-static void
-freeScreen (CompScreen *s)
+CompScreen::CompScreen ()
{
- int i, j;
+ 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(initWindowWalker);
+
+ WRAPABLE_INIT_HND(paintCursor);
+ WRAPABLE_INIT_HND(damageCursorRect);
+
+ priv = new PrivateScreen (this);
+ assert (priv);
+ next = NULL;
+
+ windowPrivateIndices = 0;
+ windowPrivateLen = 0;
+}
- if (s->outputDev)
+PrivateScreen::PrivateScreen (CompScreen *screen) :
+ screen(screen),
+ display (0),
+ windows (0),
+ reverseWindows (0),
+ width (0),
+ height (0),
+ x (0),
+ y (0),
+ 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),
+ sizeExpose (0),
+ nExpose (0),
+ backgroundLoaded (false),
+ pendingDestroys (0),
+ desktopWindowCount (0),
+ mapNum (1),
+ activeNum (1),
+ outputDev (0),
+ nOutputDev (0),
+ currentOutputDev (0),
+ hasOverlappingOutputs (false),
+ windowOffsetX (0),
+ windowOffsetY (0),
+ currentHistory (0),
+ overlayWindowCount (0),
+ snContext (0),
+ startupSequences (0),
+ startupSequenceTimeoutHandle (0),
+ groups (0),
+ defaultIcon (0),
+ canDoSaturated (false),
+ canDoSlightlySaturated (false),
+ clientList (0),
+ nClientList (0),
+ buttonGrab (0),
+ nButtonGrab (0),
+ keyGrab (0),
+ nKeyGrab (0),
+ grabs (0),
+ grabSize (0),
+ maxGrab (0),
+ rasterX (0),
+ rasterY (0),
+ nextRedraw (0),
+ redrawTime (1000 / defaultRefreshRate),
+ optimalRedrawTime (1000 / defaultRefreshRate),
+ frameStatus (0),
+ timeMult (1),
+ idle (true),
+ timeLeft (0),
+ pendingCommands (true),
+ lastFunctionId (0),
+ fragmentFunctions (0),
+ fragmentPrograms (0),
+ clearBuffers (true),
+ lighting (false),
+ slowAnimations (false),
+ showingDesktopMask (0),
+ desktopHintData (0),
+ desktopHintSize (0),
+ cursors (0),
+ cursorImages (0),
+ paintHandle (0),
+ getProcAddress (0)
+{
+ memset (saturateFunction, 0, sizeof (saturateFunction));
+ memset (history, 0, sizeof (history));
+ gettimeofday (&lastRedraw, 0);
+}
+
+PrivateScreen::~PrivateScreen ()
+{
+}
+
+bool
+CompScreen::init (CompDisplay *display, int screenNum)
+{
+ Display *dpy = display->dpy ();
+ Window newWmSnOwner = None, newCmSnOwner = None;
+ Atom wmSnAtom = 0, cmSnAtom = 0;
+ Time wmSnTimestamp = 0;
+ XEvent event;
+ XSetWindowAttributes attr;
+ Window currentWmSnOwner, currentCmSnOwner;
+ char buf[128];
+ bool rv;
+
+ sprintf (buf, "WM_S%d", screenNum);
+ wmSnAtom = XInternAtom (dpy, buf, 0);
+
+ currentWmSnOwner = XGetSelectionOwner (dpy, wmSnAtom);
+
+ if (currentWmSnOwner != None)
{
- for (i = 0; i < s->nOutputDev; i++)
- if (s->outputDev[i].name)
- free (s->outputDev[i].name);
+ if (!replaceCurrentWm)
+ {
+ compLogMessage (display, "core", CompLogLevelError,
+ "Screen %d on display \"%s\" already "
+ "has a window manager; try using the "
+ "--replace option to replace the current "
+ "window manager.",
+ screenNum, DisplayString (dpy));
+
+ return false;
+ }
- free (s->outputDev);
+ XSelectInput (dpy, currentWmSnOwner, StructureNotifyMask);
}
- if (s->clientList)
- free (s->clientList);
+ sprintf (buf, "_NET_WM_CM_S%d", screenNum);
+ cmSnAtom = XInternAtom (dpy, buf, 0);
+
+ currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom);
- if (s->desktopHintData)
- free (s->desktopHintData);
+ 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;
+ }
+ }
- if (s->buttonGrab)
- free (s->buttonGrab);
+ attr.override_redirect = TRUE;
+ attr.event_mask = PropertyChangeMask;
- if (s->keyGrab)
- free (s->keyGrab);
+ newCmSnOwner = newWmSnOwner =
+ XCreateWindow (dpy, XRootWindow (dpy, screenNum),
+ -100, -100, 1, 1, 0,
+ CopyFromParent, CopyFromParent,
+ CopyFromParent,
+ CWOverrideRedirect | CWEventMask,
+ &attr);
- if (s->snContext)
- sn_monitor_context_unref (s->snContext);
+ XChangeProperty (dpy,
+ newWmSnOwner,
+ display->atoms ().wmName,
+ display->atoms ().utf8String, 8,
+ PropModeReplace,
+ (unsigned char *) PACKAGE,
+ strlen (PACKAGE));
- if (s->damage)
- XDestroyRegion (s->damage);
+ XWindowEvent (dpy, newWmSnOwner, PropertyChangeMask, &event);
- if (s->grabs)
- free (s->grabs);
+ wmSnTimestamp = event.xproperty.time;
- /* XXX: Maybe we should free all fragment functions here? But
- the definition of CompFunction is private to fragment.c ... */
- for (i = 0; i < 2; i++)
- for (j = 0; j < 64; j++)
- if (s->saturateFunction[i][j])
- destroyFragmentFunction (s, s->saturateFunction[i][j]);
+ XSetSelectionOwner (dpy, wmSnAtom, newWmSnOwner, wmSnTimestamp);
- compFiniScreenOptions (s, s->opt, COMP_SCREEN_OPTION_NUM);
+ if (XGetSelectionOwner (dpy, wmSnAtom) != newWmSnOwner)
+ {
+ compLogMessage (display, "core", CompLogLevelError,
+ "Could not acquire window manager "
+ "selection on screen %d display \"%s\"",
+ screenNum, DisplayString (dpy));
- if (s->windowPrivateIndices)
- free (s->windowPrivateIndices);
+ XDestroyWindow (dpy, newWmSnOwner);
- if (s->base.privates)
- free (s->base.privates);
+ return false;
+ }
- free (s);
+ /* Send client message indicating that we are now the WM */
+ event.xclient.type = ClientMessage;
+ event.xclient.window = XRootWindow (dpy, screenNum);
+ event.xclient.message_type = display->atoms ().manager;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = wmSnTimestamp;
+ event.xclient.data.l[1] = wmSnAtom;
+ event.xclient.data.l[2] = 0;
+ event.xclient.data.l[3] = 0;
+ event.xclient.data.l[4] = 0;
+
+ XSendEvent (dpy, XRootWindow (dpy, screenNum), FALSE,
+ StructureNotifyMask, &event);
+
+ /* Wait for old window manager to go away */
+ if (currentWmSnOwner != None)
+ {
+ do {
+ XWindowEvent (dpy, currentWmSnOwner,
+ StructureNotifyMask, &event);
+ } while (event.type != DestroyNotify);
+ }
+
+ compCheckForError (dpy);
+
+ XCompositeRedirectSubwindows (dpy, XRootWindow (dpy, screenNum),
+ CompositeRedirectManual);
+
+ if (compCheckForError (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),
+ SubstructureRedirectMask |
+ SubstructureNotifyMask |
+ StructureNotifyMask |
+ PropertyChangeMask |
+ LeaveWindowMask |
+ EnterWindowMask |
+ KeyPressMask |
+ KeyReleaseMask |
+ ButtonPressMask |
+ ButtonReleaseMask |
+ FocusChangeMask |
+ ExposureMask);
+
+ if (compCheckForError (dpy))
+ {
+ compLogMessage (display, "core", CompLogLevelError,
+ "Another window manager is "
+ "already running on screen: %d", screenNum);
+
+ XUngrabServer (dpy);
+ return false;
+ }
+
+ rv = init (display, screenNum, newWmSnOwner, wmSnAtom, wmSnTimestamp);
+
+ XUngrabServer (dpy);
+ return rv;
}
-Bool
-addScreen (CompDisplay *display,
- int screenNum,
- Window wmSnSelectionWindow,
- Atom wmSnAtom,
- Time wmSnTimestamp)
+
+bool
+CompScreen::init (CompDisplay *display,
+ int screenNum,
+ Window wmSnSelectionWindow,
+ Atom wmSnAtom,
+ Time wmSnTimestamp)
{
- CompScreen *s;
CompPrivate *privates;
- Display *dpy = display->display;
+ Display *dpy = display->dpy ();
static char data = 0;
XColor black;
Pixmap bitmap;
@@ -1637,235 +1851,109 @@ addScreen (CompDisplay *display,
GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
CompWindow *w;
- s = (CompScreen *) malloc (sizeof (CompScreen));
- if (!s)
- return FALSE;
-
- s->windowPrivateIndices = 0;
- s->windowPrivateLen = 0;
-
if (display->screenPrivateLen)
{
- privates = (CompPrivate *) malloc (display->screenPrivateLen * sizeof (CompPrivate));
+ privates = (CompPrivate *)
+ malloc (display->screenPrivateLen * sizeof (CompPrivate));
if (!privates)
{
- free (s);
- return FALSE;
+ return false;
}
}
else
privates = 0;
- compObjectInit (&s->base, privates, COMP_OBJECT_TYPE_SCREEN);
+ compObjectInit (this, privates, COMP_OBJECT_TYPE_SCREEN);
- s->display = display;
+ priv->display = display;
- if (!compInitScreenOptionsFromMetadata (s,
+ if (!compInitScreenOptionsFromMetadata (this,
&coreMetadata,
coreScreenOptionInfo,
- s->opt,
+ priv->opt,
COMP_SCREEN_OPTION_NUM))
- return FALSE;
-
- s->snContext = NULL;
+ return false;
- s->damage = XCreateRegion ();
- if (!s->damage)
- return FALSE;
+ priv->damage = XCreateRegion ();
+ if (!priv->damage)
+ return false;
- s->x = 0;
- s->y = 0;
- s->hsize = s->opt[COMP_SCREEN_OPTION_HSIZE].value.i;
- s->vsize = s->opt[COMP_SCREEN_OPTION_VSIZE].value.i;
-
- s->windowOffsetX = 0;
- s->windowOffsetY = 0;
-
- s->nDesktop = 1;
- s->currentDesktop = 0;
+ priv->hsize = priv->opt[COMP_SCREEN_OPTION_HSIZE].value.i;
+ priv->vsize = priv->opt[COMP_SCREEN_OPTION_VSIZE].value.i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- s->screenEdge[i].id = None;
- s->screenEdge[i].count = 0;
+ priv->screenEdge[i].id = None;
+ priv->screenEdge[i].count = 0;
}
- s->buttonGrab = 0;
- s->nButtonGrab = 0;
- s->keyGrab = 0;
- s->nKeyGrab = 0;
-
- s->grabs = 0;
- s->grabSize = 0;
- s->maxGrab = 0;
-
- s->pendingDestroys = 0;
-
- s->clientList = 0;
- s->nClientList = 0;
-
- s->screenNum = screenNum;
- s->colormap = DefaultColormap (dpy, screenNum);
- s->root = XRootWindow (dpy, screenNum);
-
- s->mapNum = 1;
- s->activeNum = 1;
-
- s->groups = NULL;
-
- s->snContext = sn_monitor_context_new (display->snDisplay,
- screenNum,
- compScreenSnEvent, s,
- NULL);
-
- s->startupSequences = NULL;
- s->startupSequenceTimeoutHandle = 0;
-
- s->wmSnSelectionWindow = wmSnSelectionWindow;
- s->wmSnAtom = wmSnAtom;
- s->wmSnTimestamp = wmSnTimestamp;
-
- s->damageMask = COMP_SCREEN_DAMAGE_ALL_MASK;
- s->next = 0;
- s->exposeRects = 0;
- s->sizeExpose = 0;
- s->nExpose = 0;
-
- s->rasterX = 0;
- s->rasterY = 0;
-
- s->outputDev = NULL;
- s->nOutputDev = 0;
- s->currentOutputDev = 0;
-
- s->windows = 0;
- s->reverseWindows = 0;
-
- s->nextRedraw = 0;
- s->frameStatus = 0;
- s->timeMult = 1;
- s->idle = TRUE;
- s->timeLeft = 0;
-
- s->pendingCommands = TRUE;
-
- s->lastFunctionId = 0;
-
- s->fragmentFunctions = NULL;
- s->fragmentPrograms = NULL;
-
- memset (s->saturateFunction, 0, sizeof (s->saturateFunction));
-
- s->showingDesktopMask = 0;
-
- memset (s->history, 0, sizeof (s->history));
- s->currentHistory = 0;
-
- s->overlayWindowCount = 0;
-
- s->desktopHintData = NULL;
- s->desktopHintSize = 0;
-
- s->cursors = NULL;
-
- s->clearBuffers = TRUE;
-
- gettimeofday (&s->lastRedraw, 0);
-
- s->preparePaintScreen = preparePaintScreen;
- s->donePaintScreen = donePaintScreen;
- s->paintScreen = paintScreen;
- s->paintOutput = paintOutput;
- s->paintTransformedOutput = paintTransformedOutput;
- s->enableOutputClipping = enableOutputClipping;
- s->disableOutputClipping = disableOutputClipping;
- s->applyScreenTransform = applyScreenTransform;
- s->paintWindow = paintWindow;
- s->drawWindow = drawWindow;
- s->addWindowGeometry = addWindowGeometry;
- s->drawWindowTexture = drawWindowTexture;
- s->damageWindowRect = damageWindowRect;
- s->getOutputExtentsForWindow = getOutputExtentsForWindow;
- s->getAllowedActionsForWindow = getAllowedActionsForWindow;
- s->focusWindow = focusWindow;
- s->activateWindow = activateWindow;
- s->placeWindow = placeWindow;
- s->validateWindowResizeRequest = validateWindowResizeRequest;
-
- s->paintCursor = paintCursor;
- s->damageCursorRect = damageCursorRect;
-
- s->windowResizeNotify = windowResizeNotify;
- s->windowMoveNotify = windowMoveNotify;
- s->windowGrabNotify = windowGrabNotify;
- s->windowUngrabNotify = windowUngrabNotify;
+ priv->screenNum = screenNum;
+ priv->colormap = DefaultColormap (dpy, screenNum);
+ priv->root = XRootWindow (dpy, screenNum);
- s->enterShowDesktopMode = enterShowDesktopMode;
- s->leaveShowDesktopMode = leaveShowDesktopMode;
+ priv->snContext = sn_monitor_context_new (display->snDisplay (),
+ screenNum,
+ compScreenSnEvent, this,
+ NULL);
- s->windowStateChangeNotify = windowStateChangeNotify;
+ priv->wmSnSelectionWindow = wmSnSelectionWindow;
+ priv->wmSnAtom = wmSnAtom;
+ priv->wmSnTimestamp = wmSnTimestamp;
- s->outputChangeNotify = outputChangeNotify;
+ if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
+ return false;
- s->initWindowWalker = initWindowWalker;
+ priv->workArea.x = 0;
+ priv->workArea.y = 0;
+ priv->workArea.width = priv->attrib.width;
+ priv->workArea.height = priv->attrib.height;
+ priv->grabWindow = None;
- s->getProcAddress = 0;
+ priv->makeOutputWindow ();
- if (!XGetWindowAttributes (dpy, s->root, &s->attrib))
- return FALSE;
-
- s->workArea.x = 0;
- s->workArea.y = 0;
- s->workArea.width = s->attrib.width;
- s->workArea.height = s->attrib.height;
-
- s->grabWindow = None;
-
- makeOutputWindow (s);
-
- templ.visualid = XVisualIDFromVisual (s->attrib.visual);
+ templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
if (!nvisinfo)
{
compLogMessage (display, "core", CompLogLevelFatal,
"Couldn't get visual info for default visual");
- return FALSE;
+ return false;
}
defaultDepth = visinfo->depth;
black.red = black.green = black.blue = 0;
- if (!XAllocColor (dpy, s->colormap, &black))
+ if (!XAllocColor (dpy, priv->colormap, &black))
{
compLogMessage (display, "core", CompLogLevelFatal,
"Couldn't allocate color");
XFree (visinfo);
- return FALSE;
+ return false;
}
- bitmap = XCreateBitmapFromData (dpy, s->root, &data, 1, 1);
+ bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
if (!bitmap)
{
compLogMessage (display, "core", CompLogLevelFatal,
"Couldn't create bitmap");
XFree (visinfo);
- return FALSE;
+ return false;
}
- s->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
- &black, &black, 0, 0);
- if (!s->invisibleCursor)
+ priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
+ &black, &black, 0, 0);
+ if (!priv->invisibleCursor)
{
compLogMessage (display, "core", CompLogLevelFatal,
"Couldn't create invisible cursor");
XFree (visinfo);
- return FALSE;
+ return false;
}
XFreePixmap (dpy, bitmap);
- XFreeColors (dpy, s->colormap, &black.pixel, 1, 0);
+ XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);
if (!value)
@@ -1873,7 +1961,7 @@ addScreen (CompDisplay *display,
compLogMessage (display, "core", CompLogLevelFatal,
"Root visual is not a GL visual");
XFree (visinfo);
- return FALSE;
+ return false;
}
glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);
@@ -1882,17 +1970,17 @@ addScreen (CompDisplay *display,
compLogMessage (display, "core", CompLogLevelFatal,
"Root visual is not a double buffered GL visual");
XFree (visinfo);
- return FALSE;
+ return false;
}
- s->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering);
- if (!s->ctx)
+ priv->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering);
+ if (!priv->ctx)
{
compLogMessage (display, "core", CompLogLevelFatal,
"glXCreateContext failed");
XFree (visinfo);
- return FALSE;
+ return false;
}
glxExtensions = glXQueryExtensionsString (dpy, screenNum);
@@ -1902,7 +1990,7 @@ addScreen (CompDisplay *display,
"GLX_EXT_texture_from_pixmap is missing");
XFree (visinfo);
- return FALSE;
+ return false;
}
XFree (visinfo);
@@ -1911,206 +1999,204 @@ addScreen (CompDisplay *display,
{
compLogMessage (display, "core", CompLogLevelFatal,
"GLX_SGIX_fbconfig is missing");
- return FALSE;
- }
-
- s->getProcAddress = (GLXGetProcAddressProc)
- getProcAddress (s, "glXGetProcAddressARB");
- s->bindTexImage = (GLXBindTexImageProc)
- getProcAddress (s, "glXBindTexImageEXT");
- s->releaseTexImage = (GLXReleaseTexImageProc)
- getProcAddress (s, "glXReleaseTexImageEXT");
- s->queryDrawable = (GLXQueryDrawableProc)
- getProcAddress (s, "glXQueryDrawable");
- s->getFBConfigs = (GLXGetFBConfigsProc)
- getProcAddress (s, "glXGetFBConfigs");
- s->getFBConfigAttrib = (GLXGetFBConfigAttribProc)
- getProcAddress (s, "glXGetFBConfigAttrib");
- s->createPixmap = (GLXCreatePixmapProc)
- getProcAddress (s, "glXCreatePixmap");
-
- if (!s->bindTexImage)
+ 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;
+ return false;
}
- if (!s->releaseTexImage)
+ if (!releaseTexImage)
{
compLogMessage (display, "core", CompLogLevelFatal,
"glXReleaseTexImageEXT is missing");
- return FALSE;
+ return false;
}
- if (!s->queryDrawable ||
- !s->getFBConfigs ||
- !s->getFBConfigAttrib ||
- !s->createPixmap)
+ if (!queryDrawable ||
+ !getFBConfigs ||
+ !getFBConfigAttrib ||
+ !createPixmap)
{
compLogMessage (display, "core", CompLogLevelFatal,
"fbconfig functions missing");
- return FALSE;
+ return false;
}
- s->copySubBuffer = NULL;
+ copySubBuffer = NULL;
if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer"))
- s->copySubBuffer = (GLXCopySubBufferProc)
- getProcAddress (s, "glXCopySubBufferMESA");
+ copySubBuffer = (GLXCopySubBufferProc)
+ getProcAddress ("glXCopySubBufferMESA");
- s->getVideoSync = NULL;
- s->waitVideoSync = NULL;
+ getVideoSync = NULL;
+ waitVideoSync = NULL;
if (strstr (glxExtensions, "GLX_SGI_video_sync"))
{
- s->getVideoSync = (GLXGetVideoSyncProc)
- getProcAddress (s, "glXGetVideoSyncSGI");
+ getVideoSync = (GLXGetVideoSyncProc)
+ getProcAddress ("glXGetVideoSyncSGI");
- s->waitVideoSync = (GLXWaitVideoSyncProc)
- getProcAddress (s, "glXWaitVideoSyncSGI");
+ waitVideoSync = (GLXWaitVideoSyncProc)
+ getProcAddress ("glXWaitVideoSyncSGI");
}
- glXMakeCurrent (dpy, s->output, s->ctx);
- currentRoot = s->root;
+ 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;
+ return false;
}
- s->textureNonPowerOfTwo = 0;
+ priv->textureNonPowerOfTwo = false;
if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
- s->textureNonPowerOfTwo = 1;
+ priv->textureNonPowerOfTwo = true;
- glGetIntegerv (GL_MAX_TEXTURE_SIZE, &s->maxTextureSize);
+ glGetIntegerv (GL_MAX_TEXTURE_SIZE, &priv->maxTextureSize);
- s->textureRectangle = 0;
+ priv->textureRectangle = false;
if (strstr (glExtensions, "GL_NV_texture_rectangle") ||
strstr (glExtensions, "GL_EXT_texture_rectangle") ||
strstr (glExtensions, "GL_ARB_texture_rectangle"))
{
- s->textureRectangle = 1;
+ priv->textureRectangle = true;
- if (!s->textureNonPowerOfTwo)
+ if (!priv->textureNonPowerOfTwo)
{
GLint maxTextureSize;
glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &maxTextureSize);
- if (maxTextureSize > s->maxTextureSize)
- s->maxTextureSize = maxTextureSize;
+ if (maxTextureSize > priv->maxTextureSize)
+ priv->maxTextureSize = maxTextureSize;
}
}
- if (!(s->textureRectangle || s->textureNonPowerOfTwo))
+ if (!(priv->textureRectangle || priv->textureNonPowerOfTwo))
{
compLogMessage (display, "core", CompLogLevelFatal,
"Support for non power of two textures missing");
- return FALSE;
+ return false;
}
- s->textureEnvCombine = s->textureEnvCrossbar = 0;
+ priv->textureEnvCombine = priv->textureEnvCrossbar = false;
if (strstr (glExtensions, "GL_ARB_texture_env_combine"))
{
- s->textureEnvCombine = 1;
+ 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"))
- s->textureEnvCrossbar = 1;
+ priv->textureEnvCrossbar = true;
}
- s->textureBorderClamp = 0;
+ priv->textureBorderClamp = false;
if (strstr (glExtensions, "GL_ARB_texture_border_clamp") ||
strstr (glExtensions, "GL_SGIS_texture_border_clamp"))
- s->textureBorderClamp = 1;
+ priv->textureBorderClamp = true;
- s->maxTextureUnits = 1;
+ priv->maxTextureUnits = 1;
if (strstr (glExtensions, "GL_ARB_multitexture"))
{
- s->activeTexture = (GLActiveTextureProc)
- getProcAddress (s, "glActiveTexture");
- s->clientActiveTexture = (GLClientActiveTextureProc)
- getProcAddress (s, "glClientActiveTexture");
- s->multiTexCoord2f = (GLMultiTexCoord2fProc)
- getProcAddress (s, "glMultiTexCoord2f");
+ activeTexture = (GLActiveTextureProc)
+ getProcAddress ("glActiveTexture");
+ clientActiveTexture = (GLClientActiveTextureProc)
+ getProcAddress ("glClientActiveTexture");
+ multiTexCoord2f = (GLMultiTexCoord2fProc)
+ getProcAddress ("glMultiTexCoord2f");
- if (s->activeTexture && s->clientActiveTexture && s->multiTexCoord2f)
- glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &s->maxTextureUnits);
+ if (activeTexture && clientActiveTexture && multiTexCoord2f)
+ glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &priv->maxTextureUnits);
}
- s->fragmentProgram = 0;
+ priv->fragmentProgram = false;
if (strstr (glExtensions, "GL_ARB_fragment_program"))
{
- s->genPrograms = (GLGenProgramsProc)
- getProcAddress (s, "glGenProgramsARB");
- s->deletePrograms = (GLDeleteProgramsProc)
- getProcAddress (s, "glDeleteProgramsARB");
- s->bindProgram = (GLBindProgramProc)
- getProcAddress (s, "glBindProgramARB");
- s->programString = (GLProgramStringProc)
- getProcAddress (s, "glProgramStringARB");
- s->programEnvParameter4f = (GLProgramParameter4fProc)
- getProcAddress (s, "glProgramEnvParameter4fARB");
- s->programLocalParameter4f = (GLProgramParameter4fProc)
- getProcAddress (s, "glProgramLocalParameter4fARB");
- s->getProgramiv = (GLGetProgramivProc)
- getProcAddress (s, "glGetProgramivARB");
-
- if (s->genPrograms &&
- s->deletePrograms &&
- s->bindProgram &&
- s->programString &&
- s->programEnvParameter4f &&
- s->programLocalParameter4f &&
- s->getProgramiv)
- s->fragmentProgram = 1;
- }
-
- s->fbo = 0;
+ 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"))
{
- s->genFramebuffers = (GLGenFramebuffersProc)
- getProcAddress (s, "glGenFramebuffersEXT");
- s->deleteFramebuffers = (GLDeleteFramebuffersProc)
- getProcAddress (s, "glDeleteFramebuffersEXT");
- s->bindFramebuffer = (GLBindFramebufferProc)
- getProcAddress (s, "glBindFramebufferEXT");
- s->checkFramebufferStatus = (GLCheckFramebufferStatusProc)
- getProcAddress (s, "glCheckFramebufferStatusEXT");
- s->framebufferTexture2D = (GLFramebufferTexture2DProc)
- getProcAddress (s, "glFramebufferTexture2DEXT");
- s->generateMipmap = (GLGenerateMipmapProc)
- getProcAddress (s, "glGenerateMipmapEXT");
-
- if (s->genFramebuffers &&
- s->deleteFramebuffers &&
- s->bindFramebuffer &&
- s->checkFramebufferStatus &&
- s->framebufferTexture2D &&
- s->generateMipmap)
- s->fbo = 1;
- }
-
- s->textureCompression = 0;
+ 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"))
- s->textureCompression = 1;
+ priv->textureCompression = true;
- fbConfigs = (*s->getFBConfigs) (dpy,
- screenNum,
- &nElements);
+ fbConfigs = (*getFBConfigs) (dpy, screenNum, &nElements);
for (i = 0; i <= MAX_DEPTH; i++)
{
int j, db, stencil, depth, alpha, mipmap, rgba;
- s->glxPixmapFBConfigs[i].fbConfig = NULL;
- s->glxPixmapFBConfigs[i].mipmap = 0;
- s->glxPixmapFBConfigs[i].yInverted = 0;
- s->glxPixmapFBConfigs[i].textureFormat = 0;
- s->glxPixmapFBConfigs[i].textureTargets = 0;
+ 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;
@@ -2134,30 +2220,30 @@ addScreen (CompDisplay *display,
if (visualDepth != i)
continue;
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_ALPHA_SIZE,
- &alpha);
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BUFFER_SIZE,
- &value);
+ (*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)
{
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_TEXTURE_RGBA_EXT,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_TEXTURE_RGBA_EXT,
+ &value);
if (value)
{
rgba = 1;
- s->glxPixmapFBConfigs[i].textureFormat =
+ priv->glxPixmapFBConfigs[i].textureFormat =
GLX_TEXTURE_FORMAT_RGBA_EXT;
}
}
@@ -2167,92 +2253,87 @@ addScreen (CompDisplay *display,
if (rgba)
continue;
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_TEXTURE_RGB_EXT,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_TEXTURE_RGB_EXT,
+ &value);
if (!value)
continue;
- s->glxPixmapFBConfigs[i].textureFormat =
+ priv->glxPixmapFBConfigs[i].textureFormat =
GLX_TEXTURE_FORMAT_RGB_EXT;
}
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_DOUBLEBUFFER,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_DOUBLEBUFFER,
+ &value);
if (value > db)
continue;
db = value;
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_STENCIL_SIZE,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_STENCIL_SIZE,
+ &value);
if (value > stencil)
continue;
stencil = value;
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_DEPTH_SIZE,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_DEPTH_SIZE,
+ &value);
if (value > depth)
continue;
depth = value;
- if (s->fbo)
+ if (priv->fbo)
{
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
+ &value);
if (value < mipmap)
continue;
mipmap = value;
}
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_Y_INVERTED_EXT,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_Y_INVERTED_EXT,
+ &value);
- s->glxPixmapFBConfigs[i].yInverted = value;
+ priv->glxPixmapFBConfigs[i].yInverted = value;
- (*s->getFBConfigAttrib) (dpy,
- fbConfigs[j],
- GLX_BIND_TO_TEXTURE_TARGETS_EXT,
- &value);
+ (*getFBConfigAttrib) (dpy,
+ fbConfigs[j],
+ GLX_BIND_TO_TEXTURE_TARGETS_EXT,
+ &value);
- s->glxPixmapFBConfigs[i].textureTargets = value;
+ priv->glxPixmapFBConfigs[i].textureTargets = value;
- s->glxPixmapFBConfigs[i].fbConfig = fbConfigs[j];
- s->glxPixmapFBConfigs[i].mipmap = mipmap;
+ priv->glxPixmapFBConfigs[i].fbConfig = fbConfigs[j];
+ priv->glxPixmapFBConfigs[i].mipmap = mipmap;
}
}
if (nElements)
XFree (fbConfigs);
- if (!s->glxPixmapFBConfigs[defaultDepth].fbConfig)
+ if (!priv->glxPixmapFBConfigs[defaultDepth].fbConfig)
{
compLogMessage (display, "core", CompLogLevelFatal,
"No GLXFBConfig for default depth, "
"this isn't going to work.");
- return FALSE;
+ return false;
}
- initTexture (s, &s->backgroundTexture);
- s->backgroundLoaded = FALSE;
-
- s->defaultIcon = NULL;
-
- s->desktopWindowCount = 0;
+ initTexture (this, &priv->backgroundTexture);
glClearColor (0.0, 0.0, 0.0, 1.0);
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -2263,22 +2344,19 @@ addScreen (CompDisplay *display,
glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
- s->canDoSaturated = s->canDoSlightlySaturated = FALSE;
- if (s->textureEnvCombine && s->maxTextureUnits >= 2)
+ priv->canDoSaturated = priv->canDoSlightlySaturated = false;
+ if (priv->textureEnvCombine && priv->maxTextureUnits >= 2)
{
- s->canDoSaturated = TRUE;
- if (s->textureEnvCrossbar && s->maxTextureUnits >= 4)
- s->canDoSlightlySaturated = TRUE;
+ priv->canDoSaturated = true;
+ if (priv->textureEnvCrossbar && priv->maxTextureUnits >= 4)
+ priv->canDoSlightlySaturated = true;
}
- s->redrawTime = 1000 / defaultRefreshRate;
- s->optimalRedrawTime = s->redrawTime;
+ priv->reshape (priv->attrib.width, priv->attrib.height);
- reshape (s, s->attrib.width, s->attrib.height);
-
- detectRefreshRateOfScreen (s);
- detectOutputDevices (s);
- updateOutputDevices (s);
+ detectRefreshRate ();
+ priv->detectOutputDevices ();
+ priv->updateOutputDevices ();
glLightModelfv (GL_LIGHT_MODEL_AMBIENT, globalAmbient);
@@ -2291,32 +2369,30 @@ addScreen (CompDisplay *display,
glNormal3f (0.0f, 0.0f, -1.0f);
- s->lighting = FALSE;
- s->slowAnimations = FALSE;
+ priv->lighting = false;
+ priv->slowAnimations = false;
- addScreenToDisplay (display, s);
+ priv->display->addScreenActions (this);
- getDesktopHints (s);
+ priv->getDesktopHints ();
/* TODO: bailout properly when objectInitPlugins fails */
- assert (objectInitPlugins (&s->base));
+ assert (objectInitPlugins (this));
- (*core.objectAdd) (&display->base, &s->base);
+ core->objectAdd (display, this);
- XQueryTree (dpy, s->root,
+ XQueryTree (dpy, priv->root,
&rootReturn, &parentReturn,
&children, &nchildren);
for (i = 0; i < nchildren; i++)
- addWindow (s, children[i], i ? children[i - 1] : 0);
+ new CompWindow (this, children[i], i ? children[i - 1] : 0);
- for (w = s->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
{
- if (w->attrib.map_state == IsViewable)
+ if (w->attrib ().map_state == IsViewable)
{
- w->activeNum = s->activeNum++;
- w->damaged = TRUE;
- w->invisible = WINDOW_INVISIBLE (w);
+ w->setActiveNum (priv->activeNum++);
}
}
@@ -2325,26 +2401,26 @@ addScreen (CompDisplay *display,
attrib.override_redirect = 1;
attrib.event_mask = PropertyChangeMask;
- s->grabWindow = XCreateWindow (dpy, s->root, -100, -100, 1, 1, 0,
- CopyFromParent, InputOnly, CopyFromParent,
- CWOverrideRedirect | CWEventMask,
- &attrib);
- XMapWindow (dpy, s->grabWindow);
+ priv->grabWindow = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
+ CopyFromParent, InputOnly, CopyFromParent,
+ CWOverrideRedirect | CWEventMask,
+ &attrib);
+ XMapWindow (dpy, priv->grabWindow);
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
long xdndVersion = 3;
- s->screenEdge[i].id = XCreateWindow (dpy, s->root, -100, -100, 1, 1, 0,
- CopyFromParent, InputOnly,
- CopyFromParent, CWOverrideRedirect,
- &attrib);
+ priv->screenEdge[i].id = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
+ CopyFromParent, InputOnly,
+ CopyFromParent, CWOverrideRedirect,
+ &attrib);
- XChangeProperty (dpy, s->screenEdge[i].id, display->xdndAwareAtom,
+ XChangeProperty (dpy, priv->screenEdge[i].id, display->atoms ().xdndAware,
XA_ATOM, 32, PropModeReplace,
(unsigned char *) &xdndVersion, 1);
- XSelectInput (dpy, s->screenEdge[i].id,
+ XSelectInput (dpy, priv->screenEdge[i].id,
EnterWindowMask |
LeaveWindowMask |
ButtonPressMask |
@@ -2352,144 +2428,178 @@ addScreen (CompDisplay *display,
PointerMotionMask);
}
- updateScreenEdges (s);
+ priv->updateScreenEdges ();
- setDesktopHints (s);
- setSupportingWmCheck (s);
- setSupported (s);
+ priv->setDesktopHints ();
+ priv->setSupportingWmCheck ();
+ priv->setSupported ();
- s->normalCursor = XCreateFontCursor (dpy, XC_left_ptr);
- s->busyCursor = XCreateFontCursor (dpy, XC_watch);
+ priv->normalCursor = XCreateFontCursor (dpy, XC_left_ptr);
+ priv->busyCursor = XCreateFontCursor (dpy, XC_watch);
- XDefineCursor (dpy, s->root, s->normalCursor);
+ XDefineCursor (dpy, priv->root, priv->normalCursor);
- s->filter[NOTHING_TRANS_FILTER] = COMP_TEXTURE_FILTER_FAST;
- s->filter[SCREEN_TRANS_FILTER] = COMP_TEXTURE_FILTER_GOOD;
- s->filter[WINDOW_TRANS_FILTER] = COMP_TEXTURE_FILTER_GOOD;
+ priv->filter[NOTHING_TRANS_FILTER] = COMP_TEXTURE_FILTER_FAST;
+ priv->filter[SCREEN_TRANS_FILTER] = COMP_TEXTURE_FILTER_GOOD;
+ priv->filter[WINDOW_TRANS_FILTER] = COMP_TEXTURE_FILTER_GOOD;
- return TRUE;
+ priv->paintHandle = core->addTimeout (priv->optimalRedrawTime, MAXSHORT,
+ PrivateScreen::paintTimeout, this);
+ return true;
}
-void
-removeScreen (CompScreen *s)
+CompScreen::~CompScreen ()
{
- CompDisplay *d = s->display;
- CompScreen *p;
- int i;
+ core->removeTimeout (priv->paintHandle);
- for (p = d->screens; p; p = p->next)
- if (p->next == s)
- break;
+ while (priv->windows)
+ delete priv->windows;
- if (p)
- p->next = s->next;
- else
- d->screens = NULL;
-
- while (s->windows)
- removeWindow (s->windows);
+ core->objectRemove (priv->display, this);
- (*core.objectRemove) (&d->base, &s->base);
+ objectFiniPlugins (this);
- objectFiniPlugins (&s->base);
+ XUngrabKey (priv->display->dpy (), AnyKey, AnyModifier, priv->root);
- XUngrabKey (d->display, AnyKey, AnyModifier, s->root);
-
- for (i = 0; i < SCREEN_EDGE_NUM; i++)
- XDestroyWindow (d->display, s->screenEdge[i].id);
+ for (int i = 0; i < SCREEN_EDGE_NUM; i++)
+ XDestroyWindow (priv->display->dpy (), priv->screenEdge[i].id);
- XDestroyWindow (d->display, s->grabWindow);
+ XDestroyWindow (priv->display->dpy (), priv->grabWindow);
- finiTexture (s, &s->backgroundTexture);
+ finiTexture (this, &priv->backgroundTexture);
- if (s->defaultIcon)
+ if (priv->defaultIcon)
{
- finiTexture (s, &s->defaultIcon->texture);
- free (s->defaultIcon);
+ finiTexture (this, &priv->defaultIcon->texture);
+ free (priv->defaultIcon);
}
- glXDestroyContext (d->display, s->ctx);
+ glXDestroyContext (priv->display->dpy (), priv->ctx);
- XFreeCursor (d->display, s->invisibleCursor);
+ XFreeCursor (priv->display->dpy (), priv->invisibleCursor);
#ifdef USE_COW
if (useCow)
- XCompositeReleaseOverlayWindow (s->display->display, s->root);
+ XCompositeReleaseOverlayWindow (priv->display->dpy (), priv->root);
#endif
- freeScreen (s);
+ int i, j;
+
+ if (priv->outputDev)
+ {
+ for (i = 0; i < priv->nOutputDev; i++)
+ if (priv->outputDev[i].name)
+ free (priv->outputDev[i].name);
+
+ free (priv->outputDev);
+ }
+
+ if (priv->clientList)
+ free (priv->clientList);
+
+ if (priv->desktopHintData)
+ free (priv->desktopHintData);
+
+ if (priv->buttonGrab)
+ free (priv->buttonGrab);
+
+ if (priv->keyGrab)
+ free (priv->keyGrab);
+
+ if (priv->snContext)
+ sn_monitor_context_unref (priv->snContext);
+
+ if (priv->damage)
+ XDestroyRegion (priv->damage);
+
+ if (priv->grabs)
+ free (priv->grabs);
+
+ /* XXX: Maybe we should free all fragment functions here? But
+ the definition of CompFunction is private to fragment.c ... */
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 64; j++)
+ if (priv->saturateFunction[i][j])
+ destroyFragmentFunction (this, priv->saturateFunction[i][j]);
+
+ compFiniScreenOptions (this, priv->opt, COMP_SCREEN_OPTION_NUM);
+
+ if (windowPrivateIndices)
+ free (windowPrivateIndices);
+
+ if (privates)
+ free (privates);
+
+ delete priv;
}
void
-damageScreenRegion (CompScreen *screen,
- Region region)
+CompScreen::damageRegion (Region region)
{
- if (screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ if (priv->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
return;
- XUnionRegion (screen->damage, region, screen->damage);
+ XUnionRegion (priv->damage, region, priv->damage);
- screen->damageMask |= COMP_SCREEN_DAMAGE_REGION_MASK;
+ priv->damageMask |= COMP_SCREEN_DAMAGE_REGION_MASK;
}
void
-damageScreen (CompScreen *s)
+CompScreen::damageScreen ()
{
- s->damageMask |= COMP_SCREEN_DAMAGE_ALL_MASK;
- s->damageMask &= ~COMP_SCREEN_DAMAGE_REGION_MASK;
+ priv->damageMask |= COMP_SCREEN_DAMAGE_ALL_MASK;
+ priv->damageMask &= ~COMP_SCREEN_DAMAGE_REGION_MASK;
}
void
-damagePendingOnScreen (CompScreen *s)
+CompScreen::damagePending ()
{
- s->damageMask |= COMP_SCREEN_DAMAGE_PENDING_MASK;
+ priv->damageMask |= COMP_SCREEN_DAMAGE_PENDING_MASK;
}
void
-forEachWindowOnScreen (CompScreen *screen,
- ForEachWindowProc proc,
- void *closure)
+CompScreen::forEachWindow (ForEachWindowProc proc, void *closure)
{
CompWindow *w;
- for (w = screen->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
(*proc) (w, closure);
}
void
-focusDefaultWindow (CompScreen *s)
+CompScreen::focusDefaultWindow ()
{
- CompDisplay *d = s->display;
+ CompDisplay *d = priv->display;
CompWindow *w;
CompWindow *focus = NULL;
- if (!d->opt[COMP_DISPLAY_OPTION_CLICK_TO_FOCUS].value.b)
+ if (!d->getOption ("click_to_focus")->value.b)
{
- w = findTopLevelWindowAtDisplay (d, d->below);
- if (w && !(w->type & (CompWindowTypeDesktopMask |
- CompWindowTypeDockMask)))
+ w = d->findTopLevelWindow (d->below ());
+ if (w && !(w->type () & (CompWindowTypeDesktopMask |
+ CompWindowTypeDockMask)))
{
- if ((*w->screen->focusWindow) (w))
+ if (w->focus ())
focus = w;
}
}
if (!focus)
{
- for (w = s->reverseWindows; w; w = w->prev)
+ for (w = priv->reverseWindows; w; w = w->prev)
{
- if (w->type & CompWindowTypeDockMask)
+ if (w->type () & CompWindowTypeDockMask)
continue;
- if ((*s->focusWindow) (w))
+ if (w->focus ())
{
if (focus)
{
- if (w->type & (CompWindowTypeNormalMask |
- CompWindowTypeDialogMask |
- CompWindowTypeModalDialogMask))
+ if (w->type () & (CompWindowTypeNormalMask |
+ CompWindowTypeDialogMask |
+ CompWindowTypeModalDialogMask))
{
- if (compareWindowActiveness (focus, w) < 0)
+ if (CompWindow::compareWindowActiveness (focus, w) < 0)
focus = w;
}
}
@@ -2501,21 +2611,20 @@ focusDefaultWindow (CompScreen *s)
if (focus)
{
- if (focus->id != d->activeWindow)
- moveInputFocusToWindow (focus);
+ if (focus->id () != d->activeWindow ())
+ focus->moveInputFocusTo ();
}
else
{
- XSetInputFocus (d->display, s->root, RevertToPointerRoot,
+ XSetInputFocus (d->dpy (), priv->root, RevertToPointerRoot,
CurrentTime);
}
}
CompWindow *
-findWindowAtScreen (CompScreen *s,
- Window id)
+CompScreen::findWindow (Window id)
{
- if (lastFoundWindow && lastFoundWindow->id == id)
+ if (lastFoundWindow && lastFoundWindow->id () == id)
{
return lastFoundWindow;
}
@@ -2523,8 +2632,8 @@ findWindowAtScreen (CompScreen *s,
{
CompWindow *w;
- for (w = s->windows; w; w = w->next)
- if (w->id == id)
+ for (w = priv->windows; w; w = w->next)
+ if (w->id () == id)
return (lastFoundWindow = w);
}
@@ -2532,22 +2641,21 @@ findWindowAtScreen (CompScreen *s,
}
CompWindow *
-findTopLevelWindowAtScreen (CompScreen *s,
- Window id)
+CompScreen::findTopLevelWindow (Window id)
{
CompWindow *w;
- w = findWindowAtScreen (s, id);
+ w = findWindow (id);
if (!w)
return NULL;
- if (w->attrib.override_redirect)
+ if (w->attrib ().override_redirect)
{
/* likely a frame window */
- if (w->attrib.c_class == InputOnly)
+ if (w->attrib ().c_class == InputOnly)
{
- for (w = s->windows; w; w = w->next)
- if (w->frame == id)
+ for (w = priv->windows; w; w = w->next)
+ if (w->frame () == id)
return w;
}
@@ -2558,26 +2666,24 @@ findTopLevelWindowAtScreen (CompScreen *s,
}
void
-insertWindowIntoScreen (CompScreen *s,
- CompWindow *w,
- Window aboveId)
+CompScreen::insertWindow (CompWindow *w, Window aboveId)
{
CompWindow *p;
- if (s->windows)
+ if (priv->windows)
{
if (!aboveId)
{
- w->next = s->windows;
+ w->next = priv->windows;
w->prev = NULL;
- s->windows->prev = w;
- s->windows = w;
+ priv->windows->prev = w;
+ priv->windows = w;
}
else
{
- for (p = s->windows; p; p = p->next)
+ for (p = priv->windows; p; p = p->next)
{
- if (p->id == aboveId)
+ if (p->id () == aboveId)
{
if (p->next)
{
@@ -2591,7 +2697,7 @@ insertWindowIntoScreen (CompScreen *s,
p->next = w;
w->next = NULL;
w->prev = p;
- s->reverseWindows = w;
+ priv->reverseWindows = w;
}
break;
}
@@ -2606,14 +2712,13 @@ insertWindowIntoScreen (CompScreen *s,
}
else
{
- s->reverseWindows = s->windows = w;
+ priv->reverseWindows = priv->windows = w;
w->prev = w->next = NULL;
}
}
void
-unhookWindowFromScreen (CompScreen *s,
- CompWindow *w)
+CompScreen::unhookWindow (CompWindow *w)
{
CompWindow *next, *prev;
@@ -2630,7 +2735,7 @@ unhookWindowFromScreen (CompScreen *s,
}
else
{
- s->windows = next;
+ priv->windows = next;
next->prev = NULL;
}
}
@@ -2643,14 +2748,14 @@ unhookWindowFromScreen (CompScreen *s,
}
else
{
- s->reverseWindows = prev;
+ priv->reverseWindows = prev;
prev->next = NULL;
}
}
}
else
{
- s->windows = s->reverseWindows = NULL;
+ priv->windows = priv->reverseWindows = NULL;
}
if (w == lastFoundWindow)
@@ -2663,29 +2768,27 @@ unhookWindowFromScreen (CompScreen *s,
ButtonPressMask | \
PointerMotionMask)
int
-pushScreenGrab (CompScreen *s,
- Cursor cursor,
- const char *name)
+CompScreen::pushGrab (Cursor cursor, const char *name)
{
- if (s->maxGrab == 0)
+ if (priv->maxGrab == 0)
{
int status;
- status = XGrabPointer (s->display->display, s->grabWindow, TRUE,
+ status = XGrabPointer (priv->display->dpy (), priv->grabWindow, TRUE,
POINTER_GRAB_MASK,
GrabModeAsync, GrabModeAsync,
- s->root, cursor,
+ priv->root, cursor,
CurrentTime);
if (status == GrabSuccess)
{
- status = XGrabKeyboard (s->display->display,
- s->grabWindow, TRUE,
+ status = XGrabKeyboard (priv->display->dpy (),
+ priv->grabWindow, TRUE,
GrabModeAsync, GrabModeAsync,
CurrentTime);
if (status != GrabSuccess)
{
- XUngrabPointer (s->display->display, CurrentTime);
+ XUngrabPointer (priv->display->dpy (), CurrentTime);
return 0;
}
}
@@ -2694,88 +2797,84 @@ pushScreenGrab (CompScreen *s,
}
else
{
- XChangeActivePointerGrab (s->display->display, POINTER_GRAB_MASK,
+ XChangeActivePointerGrab (priv->display->dpy (), POINTER_GRAB_MASK,
cursor, CurrentTime);
}
- if (s->grabSize <= s->maxGrab)
+ if (priv->grabSize <= priv->maxGrab)
{
- s->grabs = (CompGrab *) realloc (s->grabs, sizeof (CompGrab) * (s->maxGrab + 1));
- if (!s->grabs)
+ priv->grabs = (CompGrab *)
+ realloc (priv->grabs, sizeof (CompGrab) * (priv->maxGrab + 1));
+ if (!priv->grabs)
return 0;
- s->grabSize = s->maxGrab + 1;
+ priv->grabSize = priv->maxGrab + 1;
}
- s->grabs[s->maxGrab].cursor = cursor;
- s->grabs[s->maxGrab].active = TRUE;
- s->grabs[s->maxGrab].name = name;
+ priv->grabs[priv->maxGrab].cursor = cursor;
+ priv->grabs[priv->maxGrab].active = TRUE;
+ priv->grabs[priv->maxGrab].name = name;
- s->maxGrab++;
+ priv->maxGrab++;
- return s->maxGrab;
+ return priv->maxGrab;
}
void
-updateScreenGrab (CompScreen *s,
- int index,
- Cursor cursor)
+CompScreen::updateGrab (int index, Cursor cursor)
{
index--;
#ifdef DEBUG
- if (index < 0 || index >= s->maxGrab)
+ if (index < 0 || index >= priv->maxGrab)
abort ();
#endif
- XChangeActivePointerGrab (s->display->display, POINTER_GRAB_MASK,
+ XChangeActivePointerGrab (priv->display->dpy (), POINTER_GRAB_MASK,
cursor, CurrentTime);
- s->grabs[index].cursor = cursor;
+ priv->grabs[index].cursor = cursor;
}
void
-removeScreenGrab (CompScreen *s,
- int index,
- XPoint *restorePointer)
+CompScreen::removeGrab (int index, XPoint *restorePointer)
{
int maxGrab;
index--;
#ifdef DEBUG
- if (index < 0 || index >= s->maxGrab)
+ if (index < 0 || index >= priv->maxGrab)
abort ();
#endif
- s->grabs[index].cursor = None;
- s->grabs[index].active = FALSE;
+ priv->grabs[index].cursor = None;
+ priv->grabs[index].active = FALSE;
- for (maxGrab = s->maxGrab; maxGrab; maxGrab--)
- if (s->grabs[maxGrab - 1].active)
+ for (maxGrab = priv->maxGrab; maxGrab; maxGrab--)
+ if (priv->grabs[maxGrab - 1].active)
break;
- if (maxGrab != s->maxGrab)
+ if (maxGrab != priv->maxGrab)
{
if (maxGrab)
{
- XChangeActivePointerGrab (s->display->display,
+ XChangeActivePointerGrab (priv->display->dpy (),
POINTER_GRAB_MASK,
- s->grabs[maxGrab - 1].cursor,
+ priv->grabs[maxGrab - 1].cursor,
CurrentTime);
}
else
{
if (restorePointer)
- warpPointer (s,
- restorePointer->x - pointerX,
+ warpPointer (restorePointer->x - pointerX,
restorePointer->y - pointerY);
- XUngrabPointer (s->display->display, CurrentTime);
- XUngrabKeyboard (s->display->display, CurrentTime);
+ XUngrabPointer (priv->display->dpy (), CurrentTime);
+ XUngrabKeyboard (priv->display->dpy (), CurrentTime);
}
- s->maxGrab = maxGrab;
+ priv->maxGrab = maxGrab;
}
}
@@ -2783,82 +2882,80 @@ removeScreenGrab (CompScreen *s,
It returns TRUE if a grab exists but it is NOT held by one of the
plugins listed, returns FALSE otherwise. */
-Bool
-otherScreenGrabExist (CompScreen *s, ...)
+bool
+CompScreen::otherGrabExist (const char *first, ...)
{
- va_list ap;
- char *name;
- int i;
+ va_list ap;
+ const char *name;
+ int i;
- for (i = 0; i < s->maxGrab; i++)
+ for (i = 0; i < priv->maxGrab; i++)
{
- if (s->grabs[i].active)
+ if (priv->grabs[i].active)
{
- va_start (ap, s);
+ va_start (ap, first);
- name = va_arg (ap, char *);
+ name = first;
while (name)
{
- if (strcmp (name, s->grabs[i].name) == 0)
+ if (strcmp (name, priv->grabs[i].name) == 0)
break;
- name = va_arg (ap, char *);
+ name = va_arg (ap, const char *);
}
va_end (ap);
if (!name)
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
-static void
-grabUngrabOneKey (CompScreen *s,
- unsigned int modifiers,
- int keycode,
- Bool grab)
+void
+PrivateScreen::grabUngrabOneKey (unsigned int modifiers,
+ int keycode,
+ bool grab)
{
if (grab)
{
- XGrabKey (s->display->display,
+ XGrabKey (display->dpy (),
keycode,
modifiers,
- s->root,
+ root,
TRUE,
GrabModeAsync,
GrabModeAsync);
}
else
{
- XUngrabKey (s->display->display,
+ XUngrabKey (display->dpy (),
keycode,
modifiers,
- s->root);
+ root);
}
}
-static Bool
-grabUngrabKeys (CompScreen *s,
- unsigned int modifiers,
- int keycode,
- Bool grab)
+bool
+PrivateScreen::grabUngrabKeys (unsigned int modifiers,
+ int keycode,
+ bool grab)
{
- XModifierKeymap *modMap = s->display->modMap;
+ XModifierKeymap *modMap = display->modMap ();
int ignore, mod, k;
- compCheckForError (s->display->display);
+ compCheckForError (display->dpy ());
- for (ignore = 0; ignore <= s->display->ignoredModMask; ignore++)
+ for (ignore = 0; ignore <= display->ignoredModMask (); ignore++)
{
- if (ignore & ~s->display->ignoredModMask)
+ if (ignore & ~display->ignoredModMask ())
continue;
if (keycode != 0)
{
- grabUngrabOneKey (s, modifiers | ignore, keycode, grab);
+ grabUngrabOneKey (modifiers | ignore, keycode, grab);
}
else
{
@@ -2872,188 +2969,184 @@ grabUngrabKeys (CompScreen *s,
{
if (modMap->modifiermap[k])
{
- grabUngrabOneKey (
- s,
- (modifiers & ~(1 << mod)) | ignore,
- modMap->modifiermap[k],
- grab);
+ grabUngrabOneKey ((modifiers & ~(1 << mod)) |
+ ignore,
+ modMap->modifiermap[k],
+ grab);
}
}
}
}
}
- if (compCheckForError (s->display->display))
- return FALSE;
+ if (compCheckForError (display->dpy ()))
+ return false;
}
- return TRUE;
+ return true;
}
-static Bool
-addPassiveKeyGrab (CompScreen *s,
- CompKeyBinding *key)
+bool
+PrivateScreen::addPassiveKeyGrab (CompKeyBinding *key)
{
- CompKeyGrab *keyGrab;
+ CompKeyGrab *newKeyGrab;
unsigned int mask;
int i;
- mask = virtualToRealModMask (s->display, key->modifiers);
+ mask = display->virtualToRealModMask (key->modifiers);
- for (i = 0; i < s->nKeyGrab; i++)
+ for (i = 0; i < nKeyGrab; i++)
{
- if (key->keycode == s->keyGrab[i].keycode &&
- mask == s->keyGrab[i].modifiers)
+ if (key->keycode == keyGrab[i].keycode &&
+ mask == keyGrab[i].modifiers)
{
- s->keyGrab[i].count++;
- return TRUE;
+ keyGrab[i].count++;
+ return true;
}
}
- keyGrab = (CompKeyGrab *) realloc (s->keyGrab, sizeof (CompKeyGrab) * (s->nKeyGrab + 1));
+ newKeyGrab = (CompKeyGrab *)
+ realloc (keyGrab, sizeof (CompKeyGrab) * (nKeyGrab + 1));
if (!keyGrab)
- return FALSE;
+ return false;
- s->keyGrab = keyGrab;
+ keyGrab = newKeyGrab;
if (!(mask & CompNoMask))
{
- if (!grabUngrabKeys (s, mask, key->keycode, TRUE))
- return FALSE;
+ if (!grabUngrabKeys (mask, key->keycode, true))
+ return false;
}
- s->keyGrab[s->nKeyGrab].keycode = key->keycode;
- s->keyGrab[s->nKeyGrab].modifiers = mask;
- s->keyGrab[s->nKeyGrab].count = 1;
+ keyGrab[nKeyGrab].keycode = key->keycode;
+ keyGrab[nKeyGrab].modifiers = mask;
+ keyGrab[nKeyGrab].count = 1;
- s->nKeyGrab++;
+ nKeyGrab++;
- return TRUE;
+ return true;
}
-static void
-removePassiveKeyGrab (CompScreen *s,
- CompKeyBinding *key)
+void
+PrivateScreen::removePassiveKeyGrab (CompKeyBinding *key)
{
unsigned int mask;
int i;
- for (i = 0; i < s->nKeyGrab; i++)
+ for (i = 0; i < nKeyGrab; i++)
{
- mask = virtualToRealModMask (s->display, key->modifiers);
- if (key->keycode == s->keyGrab[i].keycode &&
- mask == s->keyGrab[i].modifiers)
+ mask = display->virtualToRealModMask (key->modifiers);
+ if (key->keycode == keyGrab[i].keycode &&
+ mask == keyGrab[i].modifiers)
{
- s->keyGrab[i].count--;
- if (s->keyGrab[i].count)
+ keyGrab[i].count--;
+ if (keyGrab[i].count)
return;
- memmove (s->keyGrab + i, s->keyGrab + i + 1,
- (s->nKeyGrab - (i + 1)) * sizeof (CompKeyGrab));
+ memmove (keyGrab + i, keyGrab + i + 1,
+ (nKeyGrab - (i + 1)) * sizeof (CompKeyGrab));
- s->nKeyGrab--;
- s->keyGrab = (CompKeyGrab *) realloc (s->keyGrab,
- sizeof (CompKeyGrab) * s->nKeyGrab);
+ nKeyGrab--;
+ keyGrab = (CompKeyGrab *) realloc (keyGrab,
+ sizeof (CompKeyGrab) * nKeyGrab);
if (!(mask & CompNoMask))
- grabUngrabKeys (s, mask, key->keycode, FALSE);
+ grabUngrabKeys (mask, key->keycode, false);
}
}
}
-static void
-updatePassiveKeyGrabs (CompScreen *s)
+void
+PrivateScreen::updatePassiveKeyGrabs ()
{
int i;
- XUngrabKey (s->display->display, AnyKey, AnyModifier, s->root);
+ XUngrabKey (display->dpy (), AnyKey, AnyModifier, root);
- for (i = 0; i < s->nKeyGrab; i++)
+ for (i = 0; i < nKeyGrab; i++)
{
- if (!(s->keyGrab[i].modifiers & CompNoMask))
+ if (!(keyGrab[i].modifiers & CompNoMask))
{
- grabUngrabKeys (s, s->keyGrab[i].modifiers,
- s->keyGrab[i].keycode, TRUE);
+ grabUngrabKeys (keyGrab[i].modifiers,
+ keyGrab[i].keycode, true);
}
}
}
-static Bool
-addPassiveButtonGrab (CompScreen *s,
- CompButtonBinding *button)
+bool
+PrivateScreen::addPassiveButtonGrab (CompButtonBinding *button)
{
- CompButtonGrab *buttonGrab;
+ CompButtonGrab *newButtonGrab;
int i;
- for (i = 0; i < s->nButtonGrab; i++)
+ for (i = 0; i < nButtonGrab; i++)
{
- if (button->button == s->buttonGrab[i].button &&
- button->modifiers == s->buttonGrab[i].modifiers)
+ if (button->button == buttonGrab[i].button &&
+ button->modifiers == buttonGrab[i].modifiers)
{
- s->buttonGrab[i].count++;
- return TRUE;
+ buttonGrab[i].count++;
+ return true;
}
}
- buttonGrab = (CompButtonGrab *) realloc (s->buttonGrab,
- sizeof (CompButtonGrab) * (s->nButtonGrab + 1));
+ newButtonGrab = (CompButtonGrab *)
+ realloc (buttonGrab, sizeof (CompButtonGrab) * (nButtonGrab + 1));
+
if (!buttonGrab)
- return FALSE;
+ return false;
- s->buttonGrab = buttonGrab;
+ buttonGrab = newButtonGrab;
- s->buttonGrab[s->nButtonGrab].button = button->button;
- s->buttonGrab[s->nButtonGrab].modifiers = button->modifiers;
- s->buttonGrab[s->nButtonGrab].count = 1;
+ buttonGrab[nButtonGrab].button = button->button;
+ buttonGrab[nButtonGrab].modifiers = button->modifiers;
+ buttonGrab[nButtonGrab].count = 1;
- s->nButtonGrab++;
+ nButtonGrab++;
- return TRUE;
+ return true;
}
-static void
-removePassiveButtonGrab (CompScreen *s,
- CompButtonBinding *button)
+void
+PrivateScreen::removePassiveButtonGrab (CompButtonBinding *button)
{
int i;
- for (i = 0; i < s->nButtonGrab; i++)
+ for (i = 0; i < nButtonGrab; i++)
{
- if (button->button == s->buttonGrab[i].button &&
- button->modifiers == s->buttonGrab[i].modifiers)
+ if (button->button == buttonGrab[i].button &&
+ button->modifiers == buttonGrab[i].modifiers)
{
- s->buttonGrab[i].count--;
- if (s->buttonGrab[i].count)
+ buttonGrab[i].count--;
+ if (buttonGrab[i].count)
return;
- memmove (s->buttonGrab + i, s->buttonGrab + i + 1,
- (s->nButtonGrab - (i + 1)) * sizeof (CompButtonGrab));
+ memmove (buttonGrab + i, buttonGrab + i + 1,
+ (nButtonGrab - (i + 1)) * sizeof (CompButtonGrab));
- s->nButtonGrab--;
- s->buttonGrab = (CompButtonGrab *) realloc (s->buttonGrab,
- sizeof (CompButtonGrab) * s->nButtonGrab);
+ nButtonGrab--;
+ buttonGrab = (CompButtonGrab *)
+ realloc (buttonGrab, sizeof (CompButtonGrab) * nButtonGrab);
}
}
}
-Bool
-addScreenAction (CompScreen *s,
- CompAction *action)
+bool
+CompScreen::addAction (CompAction *action)
{
if (action->type & CompBindingTypeKey)
{
- if (!addPassiveKeyGrab (s, &action->key))
- return FALSE;
+ if (!priv->addPassiveKeyGrab (&action->key))
+ return true;
}
if (action->type & CompBindingTypeButton)
{
- if (!addPassiveButtonGrab (s, &action->button))
+ if (!priv->addPassiveButtonGrab (&action->button))
{
if (action->type & CompBindingTypeKey)
- removePassiveKeyGrab (s, &action->key);
+ priv->removePassiveKeyGrab (&action->key);
- return FALSE;
+ return true;
}
}
@@ -3063,21 +3156,20 @@ addScreenAction (CompScreen *s,
for (i = 0; i < SCREEN_EDGE_NUM; i++)
if (action->edgeMask & (1 << i))
- enableScreenEdge (s, i);
+ enableEdge (i);
}
- return TRUE;
+ return true;
}
void
-removeScreenAction (CompScreen *s,
- CompAction *action)
+CompScreen::removeAction (CompAction *action)
{
if (action->type & CompBindingTypeKey)
- removePassiveKeyGrab (s, &action->key);
+ priv->removePassiveKeyGrab (&action->key);
if (action->type & CompBindingTypeButton)
- removePassiveButtonGrab (s, &action->button);
+ priv->removePassiveButtonGrab (&action->button);
if (action->edgeMask)
{
@@ -3085,20 +3177,19 @@ removeScreenAction (CompScreen *s,
for (i = 0; i < SCREEN_EDGE_NUM; i++)
if (action->edgeMask & (1 << i))
- disableScreenEdge (s, i);
+ disableEdge (i);
}
}
void
-updatePassiveGrabs (CompScreen *s)
+CompScreen::updatePassiveGrabs ()
{
- updatePassiveKeyGrabs (s);
+ priv->updatePassiveKeyGrabs ();
}
-static void
-computeWorkareaForBox (CompScreen *s,
- BoxPtr pBox,
- XRectangle *area)
+void
+PrivateScreen::computeWorkareaForBox (BoxPtr pBox,
+ XRectangle *area)
{
CompWindow *w;
Region region;
@@ -3122,20 +3213,20 @@ computeWorkareaForBox (CompScreen *s,
XUnionRegion (&r, region, region);
- for (w = s->windows; w; w = w->next)
+ for (w = windows; w; w = w->next)
{
- if (!w->mapNum)
+ if (!w->mapNum ())
continue;
- if (w->struts)
+ if (w->struts ())
{
r.extents.y1 = pBox->y1;
r.extents.y2 = pBox->y2;
- x1 = w->struts->left.x;
- y1 = w->struts->left.y;
- x2 = x1 + w->struts->left.width;
- y2 = y1 + w->struts->left.height;
+ x1 = w->struts ()->left.x;
+ y1 = w->struts ()->left.y;
+ x2 = x1 + w->struts ()->left.width;
+ y2 = y1 + w->struts ()->left.height;
if (y1 < pBox->y2 && y2 > pBox->y1)
{
@@ -3145,10 +3236,10 @@ computeWorkareaForBox (CompScreen *s,
XSubtractRegion (region, &r, region);
}
- x1 = w->struts->right.x;
- y1 = w->struts->right.y;
- x2 = x1 + w->struts->right.width;
- y2 = y1 + w->struts->right.height;
+ x1 = w->struts ()->right.x;
+ y1 = w->struts ()->right.y;
+ x2 = x1 + w->struts ()->right.width;
+ y2 = y1 + w->struts ()->right.height;
if (y1 < pBox->y2 && y2 > pBox->y1)
{
@@ -3161,10 +3252,10 @@ computeWorkareaForBox (CompScreen *s,
r.extents.x1 = pBox->x1;
r.extents.x2 = pBox->x2;
- x1 = w->struts->top.x;
- y1 = w->struts->top.y;
- x2 = x1 + w->struts->top.width;
- y2 = y1 + w->struts->top.height;
+ x1 = w->struts ()->top.x;
+ y1 = w->struts ()->top.y;
+ x2 = x1 + w->struts ()->top.width;
+ y2 = y1 + w->struts ()->top.height;
if (x1 < pBox->x2 && x2 > pBox->x1)
{
@@ -3174,10 +3265,10 @@ computeWorkareaForBox (CompScreen *s,
XSubtractRegion (region, &r, region);
}
- x1 = w->struts->bottom.x;
- y1 = w->struts->bottom.y;
- x2 = x1 + w->struts->bottom.width;
- y2 = y1 + w->struts->bottom.height;
+ x1 = w->struts ()->bottom.x;
+ y1 = w->struts ()->bottom.y;
+ x2 = x1 + w->struts ()->bottom.width;
+ y2 = y1 + w->struts ()->bottom.height;
if (x1 < pBox->x2 && x2 > pBox->x1)
{
@@ -3198,58 +3289,57 @@ computeWorkareaForBox (CompScreen *s,
}
void
-updateWorkareaForScreen (CompScreen *s)
+CompScreen::updateWorkarea ()
{
XRectangle workArea;
BoxRec box;
int i;
- for (i = 0; i < s->nOutputDev; i++)
- computeWorkareaForBox (s,
- &s->outputDev[i].region.extents,
- &s->outputDev[i].workArea);
+ for (i = 0; i < priv->nOutputDev; i++)
+ priv->computeWorkareaForBox (&priv->outputDev[i].region.extents,
+ &priv->outputDev[i].workArea);
box.x1 = 0;
box.y1 = 0;
- box.x2 = s->width;
- box.y2 = s->height;
+ box.x2 = priv->width;
+ box.y2 = priv->height;
- computeWorkareaForBox (s, &box, &workArea);
+ priv->computeWorkareaForBox (&box, &workArea);
- if (memcmp (&workArea, &s->workArea, sizeof (XRectangle)))
+ if (memcmp (&workArea, &priv->workArea, sizeof (XRectangle)))
{
CompWindow *w;
- s->workArea = workArea;
+ priv->workArea = workArea;
- setDesktopHints (s);
+ priv->setDesktopHints ();
/* as work area changed, update all maximized windows on this
screen to snap to the new work area */
- for (w = s->windows; w; w = w->next)
- updateWindowSize (w);
+ for (w = priv->windows; w; w = w->next)
+ w->updateSize ();
}
}
-static Bool
+static bool
isClientListWindow (CompWindow *w)
{
/* windows with client id less than 2 have been destroyed and only exists
because some plugin keeps a reference to them. they should not be in
client lists */
- if (w->id < 2)
- return FALSE;
+ if (w->id () < 2)
+ return false;
- if (w->attrib.override_redirect)
- return FALSE;
+ if (w->attrib ().override_redirect)
+ return false;
- if (w->attrib.map_state != IsViewable)
+ if (w->attrib ().map_state != IsViewable)
{
- if (!(w->state & CompWindowStateHiddenMask))
- return FALSE;
+ if (!(w->state () & CompWindowStateHiddenMask))
+ return false;
}
- return TRUE;
+ return true;
}
static void
@@ -3264,156 +3354,126 @@ countClientListWindow (CompWindow *w,
}
}
-static void
-addClientListWindow (CompWindow *w,
- void *closure)
-{
- if (isClientListWindow (w))
- {
- int *num = (int *) closure;
-
- w->screen->clientList[*num] = w;
- *num = *num + 1;
- }
-}
-
static int
compareMappingOrder (const void *w1,
const void *w2)
{
- return (*((CompWindow **) w1))->mapNum - (*((CompWindow **) w2))->mapNum;
+ return (*((CompWindow **) w1))->mapNum () -
+ (*((CompWindow **) w2))->mapNum ();
}
void
-updateClientListForScreen (CompScreen *s)
+CompScreen::updateClientList ()
{
Window *clientList;
Window *clientListStacking;
- Bool updateClientList = FALSE;
- Bool updateClientListStacking = FALSE;
+ Bool updateClientList = true;
+ Bool updateClientListStacking = true;
int i, n = 0;
- forEachWindowOnScreen (s, countClientListWindow, (void *) &n);
+ forEachWindow (countClientListWindow, (void *) &n);
if (n == 0)
{
- if (n != s->nClientList)
+ if (n != priv->nClientList)
{
- free (s->clientList);
+ free (priv->clientList);
- s->clientList = NULL;
- s->nClientList = 0;
+ priv->clientList = NULL;
+ priv->nClientList = 0;
- XChangeProperty (s->display->display, s->root,
- s->display->clientListAtom,
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().clientList,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) &s->grabWindow, 1);
- XChangeProperty (s->display->display, s->root,
- s->display->clientListStackingAtom,
+ (unsigned char *) &priv->grabWindow, 1);
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().clientListStacking,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) &s->grabWindow, 1);
+ (unsigned char *) &priv->grabWindow, 1);
}
return;
}
- if (n != s->nClientList)
+ if (n != priv->nClientList)
{
CompWindow **list;
- list = (CompWindow **) realloc (s->clientList,
- (sizeof (CompWindow *) + sizeof (Window) * 2) * n);
+ list = (CompWindow **)
+ realloc (priv->clientList, (sizeof (CompWindow *) +
+ sizeof (Window) * 2) * n);
if (!list)
return;
- s->clientList = list;
- s->nClientList = n;
+ priv->clientList = list;
+ priv->nClientList = n;
- updateClientList = updateClientListStacking = TRUE;
+ updateClientList = updateClientListStacking = true;
}
- clientList = (Window *) (s->clientList + n);
+ clientList = (Window *) (priv->clientList + n);
clientListStacking = clientList + n;
i = 0;
- forEachWindowOnScreen (s, addClientListWindow, (void *) &i);
+ for (CompWindow *w = priv->windows; w; w = w->next)
+ if (isClientListWindow (w))
+ {
+ priv->clientList[i] = w;
+ i++;
+ }
for (i = 0; i < n; i++)
{
if (!updateClientListStacking)
{
- if (clientListStacking[i] != s->clientList[i]->id)
- updateClientListStacking = TRUE;
+ if (clientListStacking[i] != priv->clientList[i]->id ())
+ updateClientListStacking = true;
}
- clientListStacking[i] = s->clientList[i]->id;
+ clientListStacking[i] = priv->clientList[i]->id ();
}
/* sort window list in mapping order */
- qsort (s->clientList, n, sizeof (CompWindow *), compareMappingOrder);
+ qsort (priv->clientList, n, sizeof (CompWindow *), compareMappingOrder);
for (i = 0; i < n; i++)
{
if (!updateClientList)
{
- if (clientList[i] != s->clientList[i]->id)
- updateClientList = TRUE;
+ if (clientList[i] != priv->clientList[i]->id ())
+ updateClientList = true;
}
- clientList[i] = s->clientList[i]->id;
+ clientList[i] = priv->clientList[i]->id ();
}
if (updateClientList)
- XChangeProperty (s->display->display, s->root,
- s->display->clientListAtom,
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().clientList,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) clientList, s->nClientList);
+ (unsigned char *) clientList, priv->nClientList);
if (updateClientListStacking)
- XChangeProperty (s->display->display, s->root,
- s->display->clientListStackingAtom,
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().clientListStacking,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) clientListStacking, s->nClientList);
-}
-
-Window
-getActiveWindow (CompDisplay *display,
- Window root)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
- Window w = None;
-
- result = XGetWindowProperty (display->display, root,
- display->winActiveAtom, 0L, 1L, FALSE,
- XA_WINDOW, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- memcpy (&w, data, sizeof (Window));
- XFree (data);
- }
-
- return w;
+ (unsigned char *) clientListStacking,
+ priv->nClientList);
}
void
-toolkitAction (CompScreen *s,
- Atom toolkitAction,
- Time eventTime,
- Window window,
- long data0,
- long data1,
- long data2)
+CompScreen::toolkitAction (Atom toolkitAction,
+ Time eventTime,
+ Window window,
+ long data0,
+ long data1,
+ long data2)
{
XEvent ev;
ev.type = ClientMessage;
ev.xclient.window = window;
- ev.xclient.message_type = s->display->toolkitActionAtom;
+ ev.xclient.message_type = priv->display->atoms ().toolkitAction;
ev.xclient.format = 32;
ev.xclient.data.l[0] = toolkitAction;
ev.xclient.data.l[1] = eventTime;
@@ -3421,15 +3481,15 @@ toolkitAction (CompScreen *s,
ev.xclient.data.l[3] = data1;
ev.xclient.data.l[4] = data2;
- XUngrabPointer (s->display->display, CurrentTime);
- XUngrabKeyboard (s->display->display, CurrentTime);
+ XUngrabPointer (priv->display->dpy (), CurrentTime);
+ XUngrabKeyboard (priv->display->dpy (), CurrentTime);
- XSendEvent (s->display->display, s->root, FALSE, StructureNotifyMask, &ev);
+ XSendEvent (priv->display->dpy (), priv->root, FALSE,
+ StructureNotifyMask, &ev);
}
void
-runCommand (CompScreen *s,
- const char *command)
+CompScreen::runCommand (const char *command)
{
if (*command == '\0')
return;
@@ -3438,13 +3498,13 @@ runCommand (CompScreen *s,
{
/* build a display string that uses the right screen number */
/* 5 extra chars should be enough for pretty much every situation */
- int stringLen = strlen (s->display->displayString) + 5;
+ int stringLen = strlen (priv->display->displayString ()) + 5;
char screenString[stringLen];
char *pos, *delimiter, *colon;
setsid ();
- strcpy (screenString, s->display->displayString);
+ strcpy (screenString, priv->display->displayString ());
delimiter = strrchr (screenString, ':');
if (delimiter)
{
@@ -3461,7 +3521,7 @@ runCommand (CompScreen *s,
pos = screenString + strlen (screenString);
snprintf (pos, stringLen - (pos - screenString),
- "%s.%d", colon, s->screenNum);
+ "%s.%d", colon, priv->screenNum);
putenv (screenString);
@@ -3470,150 +3530,71 @@ runCommand (CompScreen *s,
}
void
-moveScreenViewport (CompScreen *s,
- int tx,
- int ty,
- Bool sync)
+CompScreen::moveViewport (int tx, int ty, bool sync)
{
CompWindow *w;
int wx, wy;
- tx = s->x - tx;
- tx = MOD (tx, s->hsize);
- tx -= s->x;
+ tx = priv->x - tx;
+ tx = MOD (tx, priv->hsize);
+ tx -= priv->x;
- ty = s->y - ty;
- ty = MOD (ty, s->vsize);
- ty -= s->y;
+ ty = priv->y - ty;
+ ty = MOD (ty, priv->vsize);
+ ty -= priv->y;
if (!tx && !ty)
return;
- s->x += tx;
- s->y += ty;
+ priv->x += tx;
+ priv->y += ty;
- tx *= -s->width;
- ty *= -s->height;
+ tx *= -priv->width;
+ ty *= -priv->height;
- for (w = s->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
{
- if (windowOnAllViewports (w))
+ if (w->onAllViewports ())
continue;
- getWindowMovementForOffset (w, tx, ty, &wx, &wy);
+ w->getMovementForOffset (tx, ty, &wx, &wy);
- if (w->saveMask & CWX)
- w->saveWc.x += wx;
+ if (w->saveMask () & CWX)
+ w->saveWc ().x += wx;
- if (w->saveMask & CWY)
- w->saveWc.y += wy;
+ if (w->saveMask () & CWY)
+ w->saveWc ().y += wy;
/* move */
- moveWindow (w, wx, wy, sync, TRUE);
+ w->move (wx, wy, sync, true);
if (sync)
- syncWindowPosition (w);
+ w->syncPosition ();
}
if (sync)
{
- setDesktopHints (s);
+ priv->setDesktopHints ();
- setCurrentActiveWindowHistory (s, s->x, s->y);
+ setCurrentActiveWindowHistory (priv->x, priv->y);
- w = findWindowAtDisplay (s->display, s->display->activeWindow);
+ w = priv->display->findWindow (priv->display->activeWindow ());
if (w)
{
int x, y;
- defaultViewportForWindow (w, &x, &y);
+ w->defaultViewport (&x, &y);
/* add window to current history if it's default viewport is
still the current one. */
- if (s->x == x && s->y == y)
- addToCurrentActiveWindowHistory (s, w->id);
+ if (priv->x == x && priv->y == y)
+ addToCurrentActiveWindowHistory (w->id ());
}
}
}
-void
-moveWindowToViewportPosition (CompWindow *w,
- int x,
- int y,
- Bool sync)
-{
- int tx, vWidth = w->screen->width * w->screen->hsize;
- int ty, vHeight = w->screen->height * w->screen->vsize;
-
- if (w->screen->hsize != 1)
- {
- x += w->screen->x * w->screen->width;
- x = MOD (x, vWidth);
- x -= w->screen->x * w->screen->width;
- }
-
- if (w->screen->vsize != 1)
- {
- y += w->screen->y * w->screen->height;
- y = MOD (y, vHeight);
- y -= w->screen->y * w->screen->height;
- }
-
- tx = x - w->attrib.x;
- ty = y - w->attrib.y;
-
- if (tx || ty)
- {
- int m, wx, wy;
-
- if (!w->managed)
- return;
-
- if (w->type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask))
- return;
-
- if (w->state & CompWindowStateStickyMask)
- return;
-
- wx = tx;
- wy = ty;
-
- if (w->screen->hsize != 1)
- {
- m = w->attrib.x + tx;
-
- if (m - w->output.left < w->screen->width - vWidth)
- wx = tx + vWidth;
- else if (m + w->width + w->output.right > vWidth)
- wx = tx - vWidth;
- }
-
- if (w->screen->vsize != 1)
- {
- m = w->attrib.y + ty;
-
- if (m - w->output.top < w->screen->height - vHeight)
- wy = ty + vHeight;
- else if (m + w->height + w->output.bottom > vHeight)
- wy = ty - vHeight;
- }
-
- if (w->saveMask & CWX)
- w->saveWc.x += wx;
-
- if (w->saveMask & CWY)
- w->saveWc.y += wy;
-
- moveWindow (w, wx, wy, sync, TRUE);
-
- if (sync)
- syncWindowPosition (w);
- }
-}
-
CompGroup *
-addGroupToScreen (CompScreen *s,
- Window id)
+CompScreen::addGroup (Window id)
{
CompGroup *group;
@@ -3621,32 +3602,31 @@ addGroupToScreen (CompScreen *s,
if (!group)
return NULL;
- group->next = s->groups;
+ group->next = priv->groups;
group->refCnt = 1;
group->id = id;
- s->groups = group;
+ priv->groups = group;
return group;
}
void
-removeGroupFromScreen (CompScreen *s,
- CompGroup *group)
+CompScreen::removeGroup (CompGroup *group)
{
group->refCnt--;
if (group->refCnt)
return;
- if (group == s->groups)
+ if (group == priv->groups)
{
- s->groups = group->next;
+ priv->groups = group->next;
}
else
{
CompGroup *g;
- for (g = s->groups; g; g = g->next)
+ for (g = priv->groups; g; g = g->next)
{
if (g->next == group)
{
@@ -3660,12 +3640,11 @@ removeGroupFromScreen (CompScreen *s,
}
CompGroup *
-findGroupAtScreen (CompScreen *s,
- Window id)
+CompScreen::findGroup (Window id)
{
CompGroup *g;
- for (g = s->groups; g; g = g->next)
+ for (g = priv->groups; g; g = g->next)
if (g->id == id)
return g;
@@ -3673,25 +3652,24 @@ findGroupAtScreen (CompScreen *s,
}
void
-applyStartupProperties (CompScreen *screen,
- CompWindow *window)
+CompScreen::applyStartupProperties (CompWindow *window)
{
CompStartupSequence *s;
- const char *startupId = window->startupId;
+ const char *startupId = window->startupId ();
if (!startupId)
{
CompWindow *leader;
- leader = findWindowAtScreen (screen, window->clientLeader);
+ leader = findWindow (window->clientLeader ());
if (leader)
- startupId = leader->startupId;
+ startupId = leader->startupId ();
if (!startupId)
return;
}
- for (s = screen->startupSequences; s; s = s->next)
+ for (s = priv->startupSequences; s; s = s->next)
{
const char *id;
@@ -3701,33 +3679,19 @@ applyStartupProperties (CompScreen *screen,
}
if (s)
- {
- int workspace;
-
- window->initialViewportX = s->viewportX;
- window->initialViewportY = s->viewportY;
-
- workspace = sn_startup_sequence_get_workspace (s->sequence);
- if (workspace >= 0)
- window->desktop = workspace;
-
- window->initialTimestamp =
- sn_startup_sequence_get_timestamp (s->sequence);
- window->initialTimestampSet = TRUE;
- }
+ window->applyStartupProperties (s);
}
void
-sendWindowActivationRequest (CompScreen *s,
- Window id)
+CompScreen::sendWindowActivationRequest (Window id)
{
XEvent xev;
xev.xclient.type = ClientMessage;
- xev.xclient.display = s->display->display;
+ xev.xclient.display = priv->display->dpy ();
xev.xclient.format = 32;
- xev.xclient.message_type = s->display->winActiveAtom;
+ xev.xclient.message_type = priv->display->atoms ().winActive;
xev.xclient.window = id;
xev.xclient.data.l[0] = 2;
@@ -3736,31 +3700,29 @@ sendWindowActivationRequest (CompScreen *s,
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
- XSendEvent (s->display->display,
- s->root,
+ XSendEvent (priv->display->dpy (),
+ priv->root,
FALSE,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
void
-screenTexEnvMode (CompScreen *s,
- GLenum mode)
+CompScreen::setTexEnvMode (GLenum mode)
{
- if (s->lighting)
+ if (priv->lighting)
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
else
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
}
void
-screenLighting (CompScreen *s,
- Bool lighting)
+CompScreen::setLighting (bool lighting)
{
- if (s->lighting != lighting)
+ if (priv->lighting != lighting)
{
- if (!s->opt[COMP_SCREEN_OPTION_LIGHTING].value.b)
- lighting = FALSE;
+ if (!priv->opt[COMP_SCREEN_OPTION_LIGHTING].value.b)
+ lighting = false;
if (lighting)
{
@@ -3773,204 +3735,190 @@ screenLighting (CompScreen *s,
glDisable (GL_LIGHTING);
}
- s->lighting = lighting;
+ priv->lighting = lighting;
- screenTexEnvMode (s, GL_REPLACE);
+ setTexEnvMode (GL_REPLACE);
}
}
void
-enableScreenEdge (CompScreen *s,
- int edge)
+CompScreen::enableEdge (int edge)
{
- s->screenEdge[edge].count++;
- if (s->screenEdge[edge].count == 1)
- XMapRaised (s->display->display, s->screenEdge[edge].id);
+ priv->screenEdge[edge].count++;
+ if (priv->screenEdge[edge].count == 1)
+ XMapRaised (priv->display->dpy (), priv->screenEdge[edge].id);
}
void
-disableScreenEdge (CompScreen *s,
- int edge)
+CompScreen::disableEdge (int edge)
{
- s->screenEdge[edge].count--;
- if (s->screenEdge[edge].count == 0)
- XUnmapWindow (s->display->display, s->screenEdge[edge].id);
+ priv->screenEdge[edge].count--;
+ if (priv->screenEdge[edge].count == 0)
+ XUnmapWindow (priv->display->dpy (), priv->screenEdge[edge].id);
}
Window
-getTopWindow (CompScreen *s)
+CompScreen::getTopWindow ()
{
CompWindow *w;
/* return first window that has not been destroyed */
- for (w = s->reverseWindows; w; w = w->prev)
+ for (w = priv->reverseWindows; w; w = w->prev)
{
- if (w->id > 1)
- return w->id;
+ if (w->id () > 1)
+ return w->id ();
}
return None;
}
void
-makeScreenCurrent (CompScreen *s)
+CompScreen::makeCurrent ()
{
- if (currentRoot != s->root)
+ if (currentRoot != priv->root)
{
- glXMakeCurrent (s->display->display, s->output, s->ctx);
- currentRoot = s->root;
+ glXMakeCurrent (priv->display->dpy (), priv->output, priv->ctx);
+ currentRoot = priv->root;
}
- s->pendingCommands = TRUE;
+ priv->pendingCommands = true;
}
void
-finishScreenDrawing (CompScreen *s)
+CompScreen::finishDrawing ()
{
- if (s->pendingCommands)
+ if (priv->pendingCommands)
{
- makeScreenCurrent (s);
+ makeCurrent ();
glFinish ();
- s->pendingCommands = FALSE;
+ priv->pendingCommands = true;
}
}
int
-outputDeviceForPoint (CompScreen *s,
- int x,
- int y)
+CompScreen::outputDeviceForPoint (int x, int y)
{
- return outputDeviceForGeometry (s, x, y, 1, 1, 0);
+ return outputDeviceForGeometry (x, y, 1, 1, 0);
}
void
-getCurrentOutputExtents (CompScreen *s,
- int *x1,
- int *y1,
- int *x2,
- int *y2)
+CompScreen::getCurrentOutputExtents (int *x1, int *y1, int *x2, int *y2)
{
if (x1)
- *x1 = s->outputDev[s->currentOutputDev].region.extents.x1;
+ *x1 = priv->outputDev[priv->currentOutputDev].region.extents.x1;
if (y1)
- *y1 = s->outputDev[s->currentOutputDev].region.extents.y1;
+ *y1 = priv->outputDev[priv->currentOutputDev].region.extents.y1;
if (x2)
- *x2 = s->outputDev[s->currentOutputDev].region.extents.x2;
+ *x2 = priv->outputDev[priv->currentOutputDev].region.extents.x2;
if (y2)
- *y2 = s->outputDev[s->currentOutputDev].region.extents.y2;
+ *y2 = priv->outputDev[priv->currentOutputDev].region.extents.y2;
}
void
-setNumberOfDesktops (CompScreen *s,
- unsigned int nDesktop)
+CompScreen::setNumberOfDesktops (unsigned int nDesktop)
{
CompWindow *w;
if (nDesktop < 1 || nDesktop >= 0xffffffff)
return;
- if (nDesktop == s->nDesktop)
+ if (nDesktop == priv->nDesktop)
return;
- if (s->currentDesktop >= nDesktop)
- s->currentDesktop = nDesktop - 1;
+ if (priv->currentDesktop >= nDesktop)
+ priv->currentDesktop = nDesktop - 1;
- for (w = s->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
{
- if (w->desktop == 0xffffffff)
+ if (w->desktop () == 0xffffffff)
continue;
- if (w->desktop >= nDesktop)
- setDesktopForWindow (w, nDesktop - 1);
+ if (w->desktop () >= nDesktop)
+ w->setDesktop (nDesktop - 1);
}
- s->nDesktop = nDesktop;
+ priv->nDesktop = nDesktop;
- setDesktopHints (s);
+ priv->setDesktopHints ();
}
void
-setCurrentDesktop (CompScreen *s,
- unsigned int desktop)
+CompScreen::setCurrentDesktop (unsigned int desktop)
{
unsigned long data;
CompWindow *w;
- if (desktop >= s->nDesktop)
+ if (desktop >= priv->nDesktop)
return;
- if (desktop == s->currentDesktop)
+ if (desktop == priv->currentDesktop)
return;
- s->currentDesktop = desktop;
+ priv->currentDesktop = desktop;
- for (w = s->windows; w; w = w->next)
+ for (w = priv->windows; w; w = w->next)
{
- if (w->desktop == 0xffffffff)
+ if (w->desktop () == 0xffffffff)
continue;
- if (w->desktop == desktop)
- showWindow (w);
+ if (w->desktop () == desktop)
+ w->show ();
else
- hideWindow (w);
+ w->hide ();
}
data = desktop;
- XChangeProperty (s->display->display, s->root,
- s->display->currentDesktopAtom,
+ XChangeProperty (priv->display->dpy (), priv->root,
+ priv->display->atoms ().currentDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data, 1);
}
void
-getWorkareaForOutput (CompScreen *s,
- int output,
- XRectangle *area)
+CompScreen::getWorkareaForOutput (int output, XRectangle *area)
{
- *area = s->outputDev[output].workArea;
+ *area = priv->outputDev[output].workArea;
}
void
-setDefaultViewport (CompScreen *s)
+CompScreen::setDefaultViewport ()
{
- s->lastViewport.x = s->outputDev->region.extents.x1;
- s->lastViewport.y = s->height - s->outputDev->region.extents.y2;
- s->lastViewport.width = s->outputDev->width;
- s->lastViewport.height = s->outputDev->height;
-
- glViewport (s->lastViewport.x,
- s->lastViewport.y,
- s->lastViewport.width,
- s->lastViewport.height);
+ priv->lastViewport.x = priv->outputDev->region.extents.x1;
+ priv->lastViewport.y = priv->height - priv->outputDev->region.extents.y2;
+ priv->lastViewport.width = priv->outputDev->width;
+ priv->lastViewport.height = priv->outputDev->height;
+
+ glViewport (priv->lastViewport.x,
+ priv->lastViewport.y,
+ priv->lastViewport.width,
+ priv->lastViewport.height);
}
void
-outputChangeNotify (CompScreen *s)
-{
-}
+CompScreen::outputChangeNotify ()
+ WRAPABLE_HND_FUNC(outputChangeNotify)
void
-clearScreenOutput (CompScreen *s,
- CompOutput *output,
- unsigned int mask)
+CompScreen::clearOutput (CompOutput *output,
+ unsigned int mask)
{
BoxPtr pBox = &output->region.extents;
if (pBox->x1 != 0 ||
pBox->y1 != 0 ||
- pBox->x2 != s->width ||
- pBox->y2 != s->height)
+ pBox->x2 != priv->width ||
+ pBox->y2 != priv->height)
{
glPushAttrib (GL_SCISSOR_BIT);
glEnable (GL_SCISSOR_TEST);
glScissor (pBox->x1,
- s->height - pBox->y2,
+ priv->height - pBox->y2,
pBox->x2 - pBox->x1,
pBox->y2 - pBox->y1);
glClear (mask);
@@ -3990,14 +3938,13 @@ clearScreenOutput (CompScreen *s,
located, except for when the window is visible in the current viewport as
the current viewport is then always returned. */
void
-viewportForGeometry (CompScreen *s,
- int x,
- int y,
- int width,
- int height,
- int borderWidth,
- int *viewportX,
- int *viewportY)
+CompScreen::viewportForGeometry (int x,
+ int y,
+ int width,
+ int height,
+ int borderWidth,
+ int *viewportX,
+ int *viewportY)
{
int centerX;
int centerY;
@@ -4005,14 +3952,14 @@ viewportForGeometry (CompScreen *s,
width += borderWidth * 2;
height += borderWidth * 2;
- if ((x < s->width && x + width > 0) &&
- (y < s->height && y + height > 0))
+ if ((x < priv->width && x + width > 0) &&
+ (y < priv->height && y + height > 0))
{
if (viewportX)
- *viewportX = s->x;
+ *viewportX = priv->x;
if (viewportY)
- *viewportY = s->y;
+ *viewportY = priv->y;
return;
}
@@ -4021,18 +3968,18 @@ viewportForGeometry (CompScreen *s,
{
centerX = x + (width >> 1);
if (centerX < 0)
- *viewportX = s->x + ((centerX / s->width) - 1) % s->hsize;
+ *viewportX = priv->x + ((centerX / priv->width) - 1) % priv->hsize;
else
- *viewportX = s->x + (centerX / s->width) % s->hsize;
+ *viewportX = priv->x + (centerX / priv->width) % priv->hsize;
}
if (viewportY)
{
centerY = y + (height >> 1);
if (centerY < 0)
- *viewportY = s->y + ((centerY / s->height) - 1) % s->vsize;
+ *viewportY = priv->y + ((centerY / priv->height) - 1) % priv->vsize;
else
- *viewportY = s->y + (centerY / s->height) % s->vsize;
+ *viewportY = priv->y + (centerY / priv->height) % priv->vsize;
}
}
@@ -4058,22 +4005,21 @@ rectangleOverlapArea (BOX *rect1,
}
int
-outputDeviceForGeometry (CompScreen *s,
- int x,
- int y,
- int width,
- int height,
- int borderWidth)
-{
- int overlapAreas[s->nOutputDev];
+CompScreen::outputDeviceForGeometry (int x,
+ int y,
+ int width,
+ int height,
+ int borderWidth)
+{
+ int overlapAreas[priv->nOutputDev];
int i, highest, seen, highestScore;
int strategy;
BOX geomRect;
- if (s->nOutputDev == 1)
+ if (priv->nOutputDev == 1)
return 0;
- strategy = s->opt[COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS].value.i;
+ strategy = priv->opt[COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS].value.i;
if (strategy == OUTPUT_OVERLAP_MODE_SMART)
{
@@ -4082,12 +4028,12 @@ outputDeviceForGeometry (CompScreen *s,
geomRect.x2 = width + 2 * borderWidth;
geomRect.y2 = height + 2 * borderWidth;
- geomRect.x1 = x % s->width;
+ geomRect.x1 = x % priv->width;
if ((geomRect.x1 + geomRect.x2 / 2) < 0)
- geomRect.x1 += s->width;
- geomRect.y1 = y % s->height;
+ geomRect.x1 += priv->width;
+ geomRect.y1 = y % priv->height;
if ((geomRect.y1 + geomRect.y2 / 2) < 0)
- geomRect.y1 += s->height;
+ geomRect.y1 += priv->height;
geomRect.x2 += geomRect.x1;
geomRect.y2 += geomRect.y1;
@@ -4096,24 +4042,25 @@ outputDeviceForGeometry (CompScreen *s,
{
/* for biggest/smallest modes, only use the window center to determine
the correct output device */
- geomRect.x1 = (x + (width / 2) + borderWidth) % s->width;
+ geomRect.x1 = (x + (width / 2) + borderWidth) % priv->width;
if (geomRect.x1 < 0)
- geomRect.x1 += s->width;
- geomRect.y1 = (y + (height / 2) + borderWidth) % s->height;
+ geomRect.x1 += priv->width;
+ geomRect.y1 = (y + (height / 2) + borderWidth) % priv->height;
if (geomRect.y1 < 0)
- geomRect.y1 += s->height;
+ geomRect.y1 += priv->height;
geomRect.x2 = geomRect.x1 + 1;
geomRect.y2 = geomRect.y1 + 1;
}
/* get amount of overlap on all output devices */
- for (i = 0; i < s->nOutputDev; i++)
- overlapAreas[i] = rectangleOverlapArea (&s->outputDev[i].region.extents,
- &geomRect);
+ for (i = 0; i < priv->nOutputDev; i++)
+ overlapAreas[i] =
+ rectangleOverlapArea (&priv->outputDev[i].region.extents,
+ &geomRect);
/* find output with largest overlap */
- for (i = 0, highest = 0, highestScore = 0; i < s->nOutputDev; i++)
+ for (i = 0, highest = 0, highestScore = 0; i < priv->nOutputDev; i++)
if (overlapAreas[i] > highestScore)
{
highest = i;
@@ -4121,7 +4068,7 @@ outputDeviceForGeometry (CompScreen *s,
}
/* look if the highest score is unique */
- for (i = 0, seen = 0; i < s->nOutputDev; i++)
+ for (i = 0, seen = 0; i < priv->nOutputDev; i++)
if (overlapAreas[i] == highestScore)
seen++;
@@ -4138,10 +4085,10 @@ outputDeviceForGeometry (CompScreen *s,
else
bestOutputSize = UINT_MAX;
- for (i = 0, highest = 0; i < s->nOutputDev; i++)
+ for (i = 0, highest = 0; i < priv->nOutputDev; i++)
if (overlapAreas[i] == highestScore)
{
- BOX *box = &s->outputDev[i].region.extents;
+ BOX *box = &priv->outputDev[i].region.extents;
Bool bestFit;
currentSize = (box->x2 - box->x1) * (box->y2 - box->y1);
@@ -4158,62 +4105,61 @@ outputDeviceForGeometry (CompScreen *s,
}
}
}
-
+
return highest;
}
-Bool
-updateDefaultIcon (CompScreen *screen)
+bool
+CompScreen::updateDefaultIcon ()
{
CompIcon *icon;
- char *file = screen->opt[COMP_SCREEN_OPTION_DEFAULT_ICON].value.s;
+ char *file = priv->opt[COMP_SCREEN_OPTION_DEFAULT_ICON].value.s;
void *data;
int width, height;
- if (screen->defaultIcon)
+ if (priv->defaultIcon)
{
- finiTexture (screen, &screen->defaultIcon->texture);
- free (screen->defaultIcon);
- screen->defaultIcon = NULL;
+ finiTexture (this, &priv->defaultIcon->texture);
+ free (priv->defaultIcon);
+ priv->defaultIcon = NULL;
}
- if (!readImageFromFile (screen->display, file, &width, &height, &data))
- return FALSE;
+ if (!priv->display->readImageFromFile (file, &width, &height, &data))
+ return false;
icon = (CompIcon *) malloc (sizeof (CompIcon) + width * height * sizeof (CARD32));
if (!icon)
{
free (data);
- return FALSE;
+ return false;
}
- initTexture (screen, &icon->texture);
+ initTexture (this, &icon->texture);
icon->width = width;
icon->height = height;
memcpy (icon + 1, data, + width * height * sizeof (CARD32));
- screen->defaultIcon = icon;
+ priv->defaultIcon = icon;
free (data);
- return TRUE;
+ return true;
}
CompCursor *
-findCursorAtScreen (CompScreen *screen)
+CompScreen::findCursor ()
{
- return screen->cursors;
+ return priv->cursors;
}
CompCursorImage *
-findCursorImageAtScreen (CompScreen *screen,
- unsigned long serial)
+CompScreen::findCursorImage (unsigned long serial)
{
CompCursorImage *image;
- for (image = screen->cursorImages; image; image = image->next)
+ for (image = priv->cursorImages; image; image = image->next)
if (image->serial == serial)
return image;
@@ -4221,39 +4167,36 @@ findCursorImageAtScreen (CompScreen *screen,
}
void
-setCurrentActiveWindowHistory (CompScreen *s,
- int x,
- int y)
+CompScreen::setCurrentActiveWindowHistory (int x, int y)
{
int i, min = 0;
for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; i++)
{
- if (s->history[i].x == x && s->history[i].y == y)
+ if (priv->history[i].x == x && priv->history[i].y == y)
{
- s->currentHistory = i;
+ priv->currentHistory = i;
return;
}
}
for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; i++)
- if (s->history[i].activeNum < s->history[min].activeNum)
+ if (priv->history[i].activeNum < priv->history[min].activeNum)
min = i;
- s->currentHistory = min;
+ priv->currentHistory = min;
- s->history[min].activeNum = s->activeNum;
- s->history[min].x = x;
- s->history[min].y = y;
+ priv->history[min].activeNum = priv->activeNum;
+ priv->history[min].x = x;
+ priv->history[min].y = y;
- memset (s->history[min].id, 0, sizeof (s->history[min].id));
+ memset (priv->history[min].id, 0, sizeof (priv->history[min].id));
}
void
-addToCurrentActiveWindowHistory (CompScreen *s,
- Window id)
+CompScreen::addToCurrentActiveWindowHistory (Window id)
{
- CompActiveWindowHistory *history = &s->history[s->currentHistory];
+ CompActiveWindowHistory *history = &priv->history[priv->currentHistory];
Window tmp, next = id;
int i;
@@ -4269,14 +4212,808 @@ addToCurrentActiveWindowHistory (CompScreen *s,
break;
}
- history->activeNum = s->activeNum;
+ history->activeNum = priv->activeNum;
+}
+
+void
+CompScreen::setWindowPaintOffset (int x, int y)
+{
+ priv->windowOffsetX = x;
+ priv->windowOffsetY = 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(initWindowWalker);
+
+ WRAPABLE_INIT_FUNC(paintCursor);
+ WRAPABLE_INIT_FUNC(damageCursorRect);
+}
+
+void
+ScreenInterface::preparePaint (int msSinceLastPaint)
+ WRAPABLE_DEF_FUNC(preparePaint, msSinceLastPaint)
+
+void
+ScreenInterface::donePaint ()
+ WRAPABLE_DEF_FUNC(donePaint)
+
+void
+ScreenInterface::paint (CompOutput *outputs,
+ int numOutput,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC(paint, outputs, numOutput, mask)
+
+bool
+ScreenInterface::paintOutput (const ScreenPaintAttrib *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 ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC(paintTransformedOutput, sAttrib, transform, region,
+ output, mask)
+
+void
+ScreenInterface::applyTransform (const ScreenPaintAttrib *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::paintCursor (CompCursor *cursor,
+ const CompTransform *transform,
+ Region region,
+ unsigned int mask)
+ WRAPABLE_DEF_FUNC(paintCursor, cursor, transform, region, mask)
+
+void
+ScreenInterface::enterShowDesktopMode ()
+ WRAPABLE_DEF_FUNC(enterShowDesktopMode)
+
+void
+ScreenInterface::leaveShowDesktopMode (CompWindow *window)
+ WRAPABLE_DEF_FUNC(leaveShowDesktopMode, window)
+
+void
+ScreenInterface::outputChangeNotify ()
+ WRAPABLE_DEF_FUNC(outputChangeNotify)
+
+void
+ScreenInterface::initWindowWalker (CompWalker *walker)
+ WRAPABLE_DEF_FUNC(initWindowWalker, walker)
+
+bool
+ScreenInterface::damageCursorRect (CompCursor *c,
+ bool initial,
+ BoxPtr rect)
+ WRAPABLE_DEF_FUNC_RETURN(damageCursorRect, c, initial, rect)
+
+CompDisplay *
+CompScreen::display ()
+{
+ return priv->display;
+}
+
+Window
+CompScreen::root ()
+{
+ return priv->root;
+}
+
+CompOption *
+CompScreen::getOption (const char *name)
+{
+ int index;
+ CompOption *o = compFindOption (priv->opt, NUM_OPTIONS (this),
+ name, &index);
+ return o;
+}
+
+int
+CompScreen::maxGrab ()
+{
+ return priv->maxGrab;
+}
+
+unsigned int
+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);
+ }
+}
+
+static const CompTransform identity = {
+ {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ }
+};
+
+void
+CompScreen::paint (CompOutput *outputs,
+ int numOutput,
+ unsigned int mask)
+{
+ WRAPABLE_HND_FUNC(paint, outputs, numOutput, mask)
+
+ XRectangle r;
+ int i;
+
+ for (i = 0; i < numOutput; i++)
+ {
+ targetScreen = this;
+ targetOutput = &outputs[i];
+
+ r.x = outputs[i].region.extents.x1;
+ r.y = priv->height - outputs[i].region.extents.y2;
+ r.width = outputs[i].width;
+ r.height = outputs[i].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)
+ {
+ paintOutput (&defaultScreenPaintAttrib,
+ &identity,
+ &outputs[i].region, &outputs[i],
+ PAINT_SCREEN_REGION_MASK |
+ PAINT_SCREEN_FULL_MASK);
+ }
+ else if (mask & COMP_SCREEN_DAMAGE_REGION_MASK)
+ {
+ XIntersectRegion (priv->display->mTmpRegion,
+ &outputs[i].region,
+ priv->display->mOutputRegion);
+
+ if (!paintOutput (&defaultScreenPaintAttrib,
+ &identity,
+ priv->display->mOutputRegion, &outputs[i],
+ PAINT_SCREEN_REGION_MASK))
+ {
+ paintOutput (&defaultScreenPaintAttrib,
+ &identity,
+ &outputs[i].region, &outputs[i],
+ PAINT_SCREEN_FULL_MASK);
+
+ XUnionRegion (priv->display->mTmpRegion,
+ &outputs[i].region,
+ priv->display->mTmpRegion);
+
+ }
+ }
+ }
+}
+
+void
+CompScreen::warpPointer (int dx, int dy)
+{
+ CompDisplay *display = priv->display;
+ XEvent event;
+
+ pointerX += dx;
+ pointerY += dy;
+
+ if (pointerX >= priv->width)
+ pointerX = priv->width - 1;
+ else if (pointerX < 0)
+ pointerX = 0;
+
+ if (pointerY >= priv->height)
+ pointerY = priv->height - 1;
+ else if (pointerY < 0)
+ pointerY = 0;
+
+ XWarpPointer (display->dpy (),
+ None, priv->root,
+ 0, 0, 0, 0,
+ pointerX, pointerY);
+
+ XSync (display->dpy (), FALSE);
+
+ while (XCheckMaskEvent (display->dpy (),
+ LeaveWindowMask |
+ EnterWindowMask |
+ PointerMotionMask,
+ &event));
+
+ if (!inHandleEvent)
+ {
+ lastPointerX = pointerX;
+ lastPointerY = pointerY;
+ }
+}
+
+CompWindow *
+CompScreen::windows ()
+{
+ return priv->windows;
+}
+
+CompWindow *
+CompScreen::reverseWindows ()
+{
+ return priv->reverseWindows;
+}
+
+Time
+CompScreen::getCurrentTime ()
+{
+ XEvent event;
+
+ XChangeProperty (priv->display->dpy (), priv->grabWindow,
+ XA_PRIMARY, XA_STRING, 8,
+ PropModeAppend, NULL, 0);
+ XWindowEvent (priv->display->dpy (), priv->grabWindow,
+ PropertyChangeMask,
+ &event);
+
+ return event.xproperty.time;
+}
+
+Atom
+CompScreen::selectionAtom ()
+{
+ return priv->wmSnAtom;
+}
+
+Window
+CompScreen::selectionWindow ()
+{
+ return priv->wmSnSelectionWindow;
+}
+
+Time
+CompScreen::selectionTimestamp ()
+{
+ return priv->wmSnTimestamp;
+}
+
+CompCursor *
+CompScreen::cursors ()
+{
+ return priv->cursors;
+}
+
+int
+CompScreen::screenNum ()
+{
+ return priv->screenNum;
+}
+
+bool
+PrivateScreen::paintTimeout (void *closure)
+{
+ CompScreen *s = (CompScreen *) closure;
+ return s->handlePaintTimeout ();
+}
+
+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 (CompWindow *w = priv->reverseWindows; w; w = w->prev)
+ {
+ 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,
+ d->mTmpRegion);
+
+ if (d->mTmpRegion->numRects == 1 &&
+ d->mTmpRegion->rects->x1 == 0 &&
+ d->mTmpRegion->rects->y1 == 0 &&
+ d->mTmpRegion->rects->x2 == priv->width &&
+ d->mTmpRegion->rects->y2 == priv->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);
+ }
+
+ if (priv->opt[COMP_SCREEN_OPTION_FORCE_INDEPENDENT].value.b
+ || !priv->hasOverlappingOutputs)
+ paint (priv->outputDev, priv->nOutputDev, mask);
+ else
+ paint (&priv->fullscreenOutput, 1, mask);
+
+ targetScreen = NULL;
+ targetOutput = &priv->outputDev[0];
+
+ waitForVideoSync ();
+
+ if (mask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ {
+ glXSwapBuffers (d->dpy (), priv->output);
+ }
+ else
+ {
+ BoxPtr pBox;
+ int nBox, y;
+
+ pBox = d->mTmpRegion->rects;
+ nBox = d->mTmpRegion->numRects;
+
+ if (copySubBuffer)
+ {
+ while (nBox--)
+ {
+ y = priv->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->height - pBox->y2;
+
+ glBitmap (0, 0, 0, 0,
+ pBox->x1 - priv->rasterX,
+ y - priv->rasterY,
+ NULL);
+
+ priv->rasterX = pBox->x1;
+ priv->rasterY = 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)
+ {
+ CompWindow *w;
+
+ for (w = priv->windows; w; w = w->next)
+ {
+ if (w->destroyed ())
+ {
+ w->addDamage ();
+ delete w;
+ break;
+ }
+ }
+
+ priv->pendingDestroys--;
+ }
+
+ priv->idle = false;
+ }
+ else
+ {
+ priv->idle = true;
+ }
+
+ gettimeofday (&tv, 0);
+
+ core->addTimeout (getTimeToNextRedraw (&tv), MAXSHORT,
+ PrivateScreen::paintTimeout, this);
+ return false;
+}
+
+int
+CompScreen::maxTextureSize ()
+{
+ return priv->maxTextureSize;
+}
+
+unsigned int
+CompScreen::damageMask ()
+{
+ return priv->damageMask;
+}
+
+int
+CompScreen::x ()
+{
+ return priv->x;
+}
+
+int
+CompScreen::y ()
+{
+ return priv->y;
+}
+
+int
+CompScreen::vsize ()
+{
+ return priv->vsize;
+}
+
+int
+CompScreen::hsize ()
+{
+ return priv->hsize;
+}
+
+int
+CompScreen::width ()
+{
+ return priv->width;
+}
+
+int
+CompScreen::height ()
+{
+ return priv->height;
+}
+
+unsigned int &
+CompScreen::pendingDestroys ()
+{
+ return priv->pendingDestroys;
+}
+
+unsigned int &
+CompScreen::mapNum ()
+{
+ return priv->mapNum;
+}
+
+int &
+CompScreen::desktopWindowCount ()
+{
+ return priv->desktopWindowCount;
+}
+
+int &
+CompScreen::overlayWindowCount ()
+{
+ return priv->overlayWindowCount;
+}
+
+CompOutput *
+CompScreen::outputDev ()
+{
+ return priv->outputDev;
+}
+
+int
+CompScreen::nOutputDev ()
+{
+ return priv->nOutputDev;
+}
+
+XRectangle
+CompScreen::workArea ()
+{
+ return priv->workArea;
+}
+
+
+unsigned int
+CompScreen::currentDesktop ()
+{
+ return priv->currentDesktop;
+}
+
+unsigned int
+CompScreen::nDesktop ()
+{
+ return priv->nDesktop;
+}
+
+CompActiveWindowHistory *
+CompScreen::currentHistory ()
+{
+ return &priv->history[priv->currentHistory];
+}
+
+CompScreenEdge &
+CompScreen::screenEdge (int edge)
+{
+ return priv->screenEdge[edge];
+}
+
+Window
+CompScreen::overlay ()
+{
+ return priv->overlay;
+}
+
+unsigned int &
+CompScreen::activeNum ()
+{
+ return priv->activeNum;
}
void
-setWindowPaintOffset (CompScreen *s,
- int x,
- int y)
+CompScreen::updateBackground ()
{
- s->windowOffsetX = x;
- s->windowOffsetY = y;
+ finiTexture (this, &priv->backgroundTexture);
+ initTexture (this, &priv->backgroundTexture);
+
+ if (priv->backgroundLoaded)
+ {
+ priv->backgroundLoaded = false;
+ damageScreen ();
+ }
+}
+
+bool
+CompScreen::textureNonPowerOfTwo ()
+{
+ return priv->textureNonPowerOfTwo;
}
+
+bool
+CompScreen::textureCompression ()
+{
+ return priv->textureCompression;
+}
+
+bool
+CompScreen::canDoSaturated ()
+{
+ return priv->canDoSaturated;
+}
+
+bool
+CompScreen::canDoSlightlySaturated ()
+{
+ return priv->canDoSlightlySaturated;
+}
+
+bool
+CompScreen::lighting ()
+{
+ return priv->lighting;
+}
+
+int
+CompScreen::filter (int filter)
+{
+ return priv->filter[filter];
+}
+
+CompFunction *&
+CompScreen::fragmentFunctions ()
+{
+ return priv->fragmentFunctions;
+}
+
+CompProgram *&
+CompScreen::fragmentPrograms ()
+{
+ return priv->fragmentPrograms;
+}
+
+int &
+CompScreen::lastFunctionId ()
+{
+ return priv->lastFunctionId;
+}
+
+int &
+CompScreen::getSaturateFunction (int target, int param)
+{
+ return priv->saturateFunction[target][param];
+}
+
+bool
+CompScreen::fragmentProgram ()
+{
+ return priv->fragmentProgram;
+}
+
+CompCursorImage *&
+CompScreen::cursorImages ()
+{
+ return priv->cursorImages;
+}
+
diff --git a/src/session.cpp b/src/session.cpp
index 28f60cd..3ab90da 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -180,7 +180,7 @@ saveYourselfCallback (SmcConn connection,
args[3].name = "fast";
args[3].value.b = fast;
- (*core.sessionEvent) (&core, CompSessionEventSaveYourself, args, 4);
+ core->sessionEvent (CompSessionEventSaveYourself, args, 4);
setCloneRestartCommands (connection);
setRestartStyle (connection, SmRestartImmediately);
@@ -192,7 +192,7 @@ static void
dieCallback (SmcConn connection,
SmPointer clientData)
{
- (*core.sessionEvent) (&core, CompSessionEventDie, NULL, 0);
+ core->sessionEvent (CompSessionEventDie, NULL, 0);
closeSession ();
exit (0);
@@ -202,14 +202,14 @@ static void
saveCompleteCallback (SmcConn connection,
SmPointer clientData)
{
- (*core.sessionEvent) (&core, CompSessionEventSaveComplete, NULL, 0);
+ core->sessionEvent (CompSessionEventSaveComplete, NULL, 0);
}
static void
shutdownCancelledCallback (SmcConn connection,
SmPointer clientData)
{
- (*core.sessionEvent) (&core, CompSessionEventShutdownCancelled, NULL, 0);
+ core->sessionEvent (CompSessionEventShutdownCancelled, NULL, 0);
}
void
@@ -283,14 +283,6 @@ closeSession (void)
}
}
-void
-sessionEvent (CompCore *c,
- CompSessionEvent event,
- CompOption *arguments,
- unsigned int nArguments)
-{
-}
-
char *
getSessionClientId (CompSessionClientIdType type)
{
@@ -316,7 +308,7 @@ getSessionClientId (CompSessionClientIdType type)
*/
/* This is called when data is available on an ICE connection. */
-static Bool
+static bool
iceProcessMessages (void *data)
{
IceConn connection = (IceConn) data;
@@ -356,7 +348,7 @@ iceNewConnection (IceConn connection,
fcntl (IceConnectionNumber (connection),
F_GETFD,0) | FD_CLOEXEC);
- iceWatchFdHandle = compAddWatchFd (IceConnectionNumber (connection),
+ iceWatchFdHandle = core->addWatchFd (IceConnectionNumber (connection),
POLLIN | POLLPRI | POLLHUP | POLLERR,
iceProcessMessages, connection);
@@ -368,7 +360,7 @@ iceNewConnection (IceConn connection,
if (iceConnected)
{
- compRemoveWatchFd (iceWatchFdHandle);
+ core->removeWatchFd (iceWatchFdHandle);
iceWatchFdHandle = 0;
iceConnected = 0;
diff --git a/src/texture.cpp b/src/texture.cpp
index 78a838b..304cb36 100644
--- a/src/texture.cpp
+++ b/src/texture.cpp
@@ -32,6 +32,7 @@
#include <string.h>
#include <compiz-core.h>
+#include "privatescreen.h"
static CompMatrix _identity_matrix = {
1.0f, 0.0f,
@@ -60,8 +61,8 @@ finiTexture (CompScreen *screen,
{
if (texture->name)
{
- makeScreenCurrent (screen);
- releasePixmapFromTexture (screen, texture);
+ screen->makeCurrent ();
+ screen->releasePixmapFromTexture (texture);
glDeleteTextures (1, &texture->name);
}
}
@@ -115,10 +116,10 @@ imageToTexture (CompScreen *screen,
&image[(height - i - 1) * width * 4],
width * 4);
- makeScreenCurrent (screen);
- releasePixmapFromTexture (screen, texture);
+ screen->makeCurrent ();
+ screen->releasePixmapFromTexture (texture);
- if (screen->textureNonPowerOfTwo ||
+ if (screen->textureNonPowerOfTwo () ||
(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
{
texture->target = GL_TEXTURE_2D;
@@ -142,8 +143,8 @@ imageToTexture (CompScreen *screen,
glBindTexture (texture->target, texture->name);
internalFormat =
- (screen->opt[COMP_SCREEN_OPTION_TEXTURE_COMPRESSION].value.b &&
- screen->textureCompression ?
+ (screen->getOption ("texture_compression")->value.b &&
+ screen->textureCompression () ?
GL_COMPRESSED_RGBA_ARB : GL_RGBA);
glTexImage2D (texture->target, 0, internalFormat, width, height, 0,
@@ -206,9 +207,9 @@ readImageToTexture (CompScreen *screen,
int width, height;
Bool status;
- if (!readImageFromFile (screen->display, imageFileName,
- &width, &height, &image))
- return FALSE;
+ if (screen->display ()->readImageFromFile (imageFileName, &width, &height,
+ &image))
+ return false;
status = imageBufferToTexture (screen, texture, (char *)image, width, height);
@@ -232,16 +233,15 @@ iconToTexture (CompScreen *screen,
icon->height);
}
-Bool
-bindPixmapToTexture (CompScreen *screen,
- CompTexture *texture,
- Pixmap pixmap,
- int width,
- int height,
- int depth)
+bool
+CompScreen::bindPixmapToTexture (CompTexture *texture,
+ Pixmap pixmap,
+ int width,
+ int height,
+ int depth)
{
unsigned int target = 0;
- CompFBConfig *config = &screen->glxPixmapFBConfigs[depth];
+ CompFBConfig *config = &priv->glxPixmapFBConfigs[depth];
int attribs[7], i = 0;
if (!config->fbConfig)
@@ -250,7 +250,7 @@ bindPixmapToTexture (CompScreen *screen,
"No GLXFBConfig for depth %d",
depth);
- return FALSE;
+ return false;
}
attribs[i++] = GLX_TEXTURE_FORMAT_EXT;
@@ -262,7 +262,7 @@ bindPixmapToTexture (CompScreen *screen,
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 &&
- (screen->textureNonPowerOfTwo ||
+ (priv->textureNonPowerOfTwo ||
(POWER_OF_TWO (width) && POWER_OF_TWO (height))))
target = GLX_TEXTURE_2D_EXT;
else if (config->textureTargets & GLX_TEXTURE_RECTANGLE_BIT_EXT)
@@ -286,23 +286,23 @@ bindPixmapToTexture (CompScreen *screen,
attribs[i++] = None;
- makeScreenCurrent (screen);
- texture->pixmap = (*screen->createPixmap) (screen->display->display,
- config->fbConfig, pixmap,
- attribs);
+ makeCurrent ();
+ texture->pixmap = (*createPixmap) (priv->display->dpy (),
+ config->fbConfig, pixmap,
+ attribs);
if (!texture->pixmap)
{
compLogMessage (NULL, "core", CompLogLevelWarn,
"glXCreatePixmap failed");
- return FALSE;
+ return false;
}
if (!target)
- (*screen->queryDrawable) (screen->display->display,
- texture->pixmap,
- GLX_TEXTURE_TARGET_EXT,
- &target);
+ (*queryDrawable) (priv->display->dpy (),
+ texture->pixmap,
+ GLX_TEXTURE_TARGET_EXT,
+ &target);
switch (target) {
case GLX_TEXTURE_2D_EXT:
@@ -335,17 +335,17 @@ bindPixmapToTexture (CompScreen *screen,
texture->matrix.yy = -1.0f;
texture->matrix.y0 = height;
}
- texture->mipmap = FALSE;
+ texture->mipmap = false;
break;
default:
compLogMessage (NULL, "core", CompLogLevelWarn,
"pixmap 0x%x can't be bound to texture",
(int) pixmap);
- glXDestroyGLXPixmap (screen->display->display, texture->pixmap);
+ glXDestroyGLXPixmap (priv->display->dpy (), texture->pixmap);
texture->pixmap = None;
- return FALSE;
+ return false;
}
if (!texture->name)
@@ -355,10 +355,10 @@ bindPixmapToTexture (CompScreen *screen,
if (!strictBinding)
{
- (*screen->bindTexImage) (screen->display->display,
- texture->pixmap,
- GLX_FRONT_LEFT_EXT,
- NULL);
+ (*bindTexImage) (priv->display->dpy (),
+ texture->pixmap,
+ GLX_FRONT_LEFT_EXT,
+ NULL);
}
texture->filter = GL_NEAREST;
@@ -373,50 +373,48 @@ bindPixmapToTexture (CompScreen *screen,
glBindTexture (texture->target, 0);
- return TRUE;
+ return true;
}
void
-releasePixmapFromTexture (CompScreen *screen,
- CompTexture *texture)
+CompScreen::releasePixmapFromTexture (CompTexture *texture)
{
if (texture->pixmap)
{
- makeScreenCurrent (screen);
+ makeCurrent ();
glEnable (texture->target);
if (!strictBinding)
{
glBindTexture (texture->target, texture->name);
- (*screen->releaseTexImage) (screen->display->display,
- texture->pixmap,
- GLX_FRONT_LEFT_EXT);
+ (*releaseTexImage) (priv->display->dpy (),
+ texture->pixmap,
+ GLX_FRONT_LEFT_EXT);
}
glBindTexture (texture->target, 0);
glDisable (texture->target);
- glXDestroyGLXPixmap (screen->display->display, texture->pixmap);
+ glXDestroyGLXPixmap (priv->display->dpy (), texture->pixmap);
texture->pixmap = None;
}
}
void
-enableTexture (CompScreen *screen,
- CompTexture *texture,
- CompTextureFilter filter)
+CompScreen::enableTexture (CompTexture *texture,
+ CompTextureFilter filter)
{
- makeScreenCurrent (screen);
+ makeCurrent ();
glEnable (texture->target);
glBindTexture (texture->target, texture->name);
if (strictBinding && texture->pixmap)
{
- (*screen->bindTexImage) (screen->display->display,
- texture->pixmap,
- GLX_FRONT_LEFT_EXT,
- NULL);
+ (*bindTexImage) (priv->display->dpy (),
+ texture->pixmap,
+ GLX_FRONT_LEFT_EXT,
+ NULL);
}
if (filter == COMP_TEXTURE_FILTER_FAST)
@@ -433,11 +431,11 @@ enableTexture (CompScreen *screen,
texture->filter = GL_NEAREST;
}
}
- else if (texture->filter != screen->display->textureFilter)
+ else if (texture->filter != priv->display->textureFilter ())
{
- if (screen->display->textureFilter == GL_LINEAR_MIPMAP_LINEAR)
+ if (priv->display->textureFilter () == GL_LINEAR_MIPMAP_LINEAR)
{
- if (screen->textureNonPowerOfTwo && screen->fbo && texture->mipmap)
+ if (priv->textureNonPowerOfTwo && priv->fbo && texture->mipmap)
{
glTexParameteri (texture->target,
GL_TEXTURE_MIN_FILTER,
@@ -466,12 +464,12 @@ enableTexture (CompScreen *screen,
{
glTexParameteri (texture->target,
GL_TEXTURE_MIN_FILTER,
- screen->display->textureFilter);
+ priv->display->textureFilter ());
glTexParameteri (texture->target,
GL_TEXTURE_MAG_FILTER,
- screen->display->textureFilter);
+ priv->display->textureFilter ());
- texture->filter = screen->display->textureFilter;
+ texture->filter = priv->display->textureFilter ();
}
}
@@ -479,24 +477,23 @@ enableTexture (CompScreen *screen,
{
if (texture->oldMipmaps)
{
- (*screen->generateMipmap) (texture->target);
+ (*generateMipmap) (texture->target);
texture->oldMipmaps = FALSE;
}
}
}
void
-disableTexture (CompScreen *screen,
- CompTexture *texture)
+CompScreen::disableTexture (CompTexture *texture)
{
- makeScreenCurrent (screen);
+ makeCurrent ();
if (strictBinding && texture->pixmap)
{
glBindTexture (texture->target, texture->name);
- (*screen->releaseTexImage) (screen->display->display,
- texture->pixmap,
- GLX_FRONT_LEFT_EXT);
+ (*releaseTexImage) (priv->display->dpy (),
+ texture->pixmap,
+ GLX_FRONT_LEFT_EXT);
}
glBindTexture (texture->target, 0);
diff --git a/src/window.cpp b/src/window.cpp
index 378b10e..f8849c4 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -35,19 +35,15 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
+#include <math.h>
#include <compiz-core.h>
+#include "privatewindow.h"
+
+
-#define MwmHintsFunctions (1L << 0)
-#define MwmHintsDecorations (1L << 1)
-#define PropMotifWmHintElements 3
-typedef struct {
- unsigned long flags;
- unsigned long functions;
- unsigned long decorations;
-} MwmHints;
static int
reallocWindowPrivates (int size,
@@ -57,13 +53,13 @@ reallocWindowPrivates (int size,
CompWindow *w;
void *privates;
- for (w = s->windows; w; w = w->next)
+ for (w = s->windows (); w; w = w->next)
{
- privates = realloc (w->base.privates, size * sizeof (CompPrivate));
+ privates = realloc (w->privates, size * sizeof (CompPrivate));
if (!privates)
return FALSE;
- w->base.privates = (CompPrivate *) privates;
+ w->privates = (CompPrivate *) privates;
}
return TRUE;
@@ -102,9 +98,9 @@ forEachWindowObject (CompObject *parent,
CORE_SCREEN (parent);
- for (w = s->windows; w; w = w->next)
+ for (w = s->windows (); w; w = w->next)
{
- if (!(*proc) (&w->base, closure))
+ if (!(*proc) (w, closure))
return FALSE;
}
}
@@ -119,7 +115,7 @@ nameWindowObject (CompObject *object)
CORE_WINDOW (object);
- snprintf (tmp, 256, "0x%lu", w->id);
+ snprintf (tmp, 256, "0x%lu", w->id ());
return strdup (tmp);
}
@@ -135,9 +131,9 @@ findWindowObject (CompObject *parent,
CORE_SCREEN (parent);
- for (w = s->windows; w; w = w->next)
- if (w->id == id)
- return &w->base;
+ for (w = s->windows (); w; w = w->next)
+ if (w->id () == id)
+ return w;
}
return NULL;
@@ -146,262 +142,261 @@ findWindowObject (CompObject *parent,
int
allocateWindowPrivateIndex (CompScreen *screen)
{
- return compObjectAllocatePrivateIndex (&screen->base,
- COMP_OBJECT_TYPE_WINDOW);
+ return compObjectAllocatePrivateIndex (screen, COMP_OBJECT_TYPE_WINDOW);
}
void
freeWindowPrivateIndex (CompScreen *screen,
int index)
{
- compObjectFreePrivateIndex (&screen->base,
- COMP_OBJECT_TYPE_WINDOW,
- index);
+ compObjectFreePrivateIndex (screen, COMP_OBJECT_TYPE_WINDOW, index);
}
-static Bool
-isAncestorTo (CompWindow *transient,
- CompWindow *ancestor)
+bool
+PrivateWindow::isAncestorTo (CompWindow *transient,
+ CompWindow *ancestor)
{
- if (transient->transientFor)
+ if (transient->priv->transientFor)
{
- if (transient->transientFor == ancestor->id)
- return TRUE;
+ if (transient->priv->transientFor == ancestor->priv->id)
+ return true;
- transient = findWindowAtScreen (transient->screen,
- transient->transientFor);
+ transient =
+ transient->priv->screen->findWindow (transient->priv->transientFor);
if (transient)
return isAncestorTo (transient, ancestor);
}
- return FALSE;
+ return false;
}
-static void
-recalcNormalHints (CompWindow *window)
+void
+PrivateWindow::recalcNormalHints ()
{
int maxSize;
- maxSize = window->screen->maxTextureSize;
- maxSize -= window->serverBorderWidth * 2;
+ maxSize = screen->maxTextureSize ();
+ maxSize -= serverBorderWidth * 2;
- window->sizeHints.x = window->serverX;
- window->sizeHints.y = window->serverY;
- window->sizeHints.width = window->serverWidth;
- window->sizeHints.height = window->serverHeight;
+ sizeHints.x = serverX;
+ sizeHints.y = serverY;
+ sizeHints.width = serverWidth;
+ sizeHints.height = serverHeight;
- if (!(window->sizeHints.flags & PBaseSize))
+ if (!(sizeHints.flags & PBaseSize))
{
- if (window->sizeHints.flags & PMinSize)
+ if (sizeHints.flags & PMinSize)
{
- window->sizeHints.base_width = window->sizeHints.min_width;
- window->sizeHints.base_height = window->sizeHints.min_height;
+ sizeHints.base_width = sizeHints.min_width;
+ sizeHints.base_height = sizeHints.min_height;
}
else
{
- window->sizeHints.base_width = 0;
- window->sizeHints.base_height = 0;
+ sizeHints.base_width = 0;
+ sizeHints.base_height = 0;
}
- window->sizeHints.flags |= PBaseSize;
+ sizeHints.flags |= PBaseSize;
}
- if (!(window->sizeHints.flags & PMinSize))
+ if (!(sizeHints.flags & PMinSize))
{
- window->sizeHints.min_width = window->sizeHints.base_width;
- window->sizeHints.min_height = window->sizeHints.base_height;
- window->sizeHints.flags |= PMinSize;
+ sizeHints.min_width = sizeHints.base_width;
+ sizeHints.min_height = sizeHints.base_height;
+ sizeHints.flags |= PMinSize;
}
- if (!(window->sizeHints.flags & PMaxSize))
+ if (!(sizeHints.flags & PMaxSize))
{
- window->sizeHints.max_width = 65535;
- window->sizeHints.max_height = 65535;
- window->sizeHints.flags |= PMaxSize;
+ sizeHints.max_width = 65535;
+ sizeHints.max_height = 65535;
+ sizeHints.flags |= PMaxSize;
}
- if (window->sizeHints.max_width < window->sizeHints.min_width)
- window->sizeHints.max_width = window->sizeHints.min_width;
+ if (sizeHints.max_width < sizeHints.min_width)
+ sizeHints.max_width = sizeHints.min_width;
- if (window->sizeHints.max_height < window->sizeHints.min_height)
- window->sizeHints.max_height = window->sizeHints.min_height;
+ if (sizeHints.max_height < sizeHints.min_height)
+ sizeHints.max_height = sizeHints.min_height;
- if (window->sizeHints.min_width < 1)
- window->sizeHints.min_width = 1;
+ if (sizeHints.min_width < 1)
+ sizeHints.min_width = 1;
- if (window->sizeHints.max_width < 1)
- window->sizeHints.max_width = 1;
+ if (sizeHints.max_width < 1)
+ sizeHints.max_width = 1;
- if (window->sizeHints.min_height < 1)
- window->sizeHints.min_height = 1;
+ if (sizeHints.min_height < 1)
+ sizeHints.min_height = 1;
- if (window->sizeHints.max_height < 1)
- window->sizeHints.max_height = 1;
+ if (sizeHints.max_height < 1)
+ sizeHints.max_height = 1;
- if (window->sizeHints.max_width > maxSize)
- window->sizeHints.max_width = maxSize;
+ if (sizeHints.max_width > maxSize)
+ sizeHints.max_width = maxSize;
- if (window->sizeHints.max_height > maxSize)
- window->sizeHints.max_height = maxSize;
+ if (sizeHints.max_height > maxSize)
+ sizeHints.max_height = maxSize;
- if (window->sizeHints.min_width > maxSize)
- window->sizeHints.min_width = maxSize;
+ if (sizeHints.min_width > maxSize)
+ sizeHints.min_width = maxSize;
- if (window->sizeHints.min_height > maxSize)
- window->sizeHints.min_height = maxSize;
+ if (sizeHints.min_height > maxSize)
+ sizeHints.min_height = maxSize;
- if (window->sizeHints.base_width > maxSize)
- window->sizeHints.base_width = maxSize;
+ if (sizeHints.base_width > maxSize)
+ sizeHints.base_width = maxSize;
- if (window->sizeHints.base_height > maxSize)
- window->sizeHints.base_height = maxSize;
+ if (sizeHints.base_height > maxSize)
+ sizeHints.base_height = maxSize;
- if (window->sizeHints.flags & PResizeInc)
+ if (sizeHints.flags & PResizeInc)
{
- if (window->sizeHints.width_inc == 0)
- window->sizeHints.width_inc = 1;
+ if (sizeHints.width_inc == 0)
+ sizeHints.width_inc = 1;
- if (window->sizeHints.height_inc == 0)
- window->sizeHints.height_inc = 1;
+ if (sizeHints.height_inc == 0)
+ sizeHints.height_inc = 1;
}
else
{
- window->sizeHints.width_inc = 1;
- window->sizeHints.height_inc = 1;
- window->sizeHints.flags |= PResizeInc;
+ sizeHints.width_inc = 1;
+ sizeHints.height_inc = 1;
+ sizeHints.flags |= PResizeInc;
}
- if (window->sizeHints.flags & PAspect)
+ if (sizeHints.flags & PAspect)
{
/* don't divide by 0 */
- if (window->sizeHints.min_aspect.y < 1)
- window->sizeHints.min_aspect.y = 1;
+ if (sizeHints.min_aspect.y < 1)
+ sizeHints.min_aspect.y = 1;
- if (window->sizeHints.max_aspect.y < 1)
- window->sizeHints.max_aspect.y = 1;
+ if (sizeHints.max_aspect.y < 1)
+ sizeHints.max_aspect.y = 1;
}
else
{
- window->sizeHints.min_aspect.x = 1;
- window->sizeHints.min_aspect.y = 65535;
- window->sizeHints.max_aspect.x = 65535;
- window->sizeHints.max_aspect.y = 1;
- window->sizeHints.flags |= PAspect;
+ sizeHints.min_aspect.x = 1;
+ sizeHints.min_aspect.y = 65535;
+ sizeHints.max_aspect.x = 65535;
+ sizeHints.max_aspect.y = 1;
+ sizeHints.flags |= PAspect;
}
- if (!(window->sizeHints.flags & PWinGravity))
+ if (!(sizeHints.flags & PWinGravity))
{
- window->sizeHints.win_gravity = NorthWestGravity;
- window->sizeHints.flags |= PWinGravity;
+ sizeHints.win_gravity = NorthWestGravity;
+ sizeHints.flags |= PWinGravity;
}
}
void
-updateNormalHints (CompWindow *w)
+CompWindow::updateNormalHints ()
{
Status status;
long supplied;
- status = XGetWMNormalHints (w->screen->display->display, w->id,
- &w->sizeHints, &supplied);
+ status = XGetWMNormalHints (priv->screen->display ()->dpy (), priv->id,
+ &priv->sizeHints, &supplied);
if (!status)
- w->sizeHints.flags = 0;
+ priv->sizeHints.flags = 0;
- recalcNormalHints (w);
+ priv->recalcNormalHints ();
}
void
-updateWmHints (CompWindow *w)
+CompWindow::updateWmHints ()
{
XWMHints *hints;
- hints = XGetWMHints (w->screen->display->display, w->id);
+ hints = XGetWMHints (priv->screen->display ()->dpy (), priv->id);
if (hints)
{
if (hints->flags & InputHint)
- w->inputHint = hints->input;
+ priv->inputHint = hints->input;
XFree (hints);
}
}
void
-updateWindowClassHints (CompWindow *w)
+CompWindow::updateClassHints ()
{
XClassHint classHint;
int status;
- if (w->resName)
+ if (priv->resName)
{
- free (w->resName);
- w->resName = NULL;
+ free (priv->resName);
+ priv->resName = NULL;
}
- if (w->resClass)
+ if (priv->resClass)
{
- free (w->resClass);
- w->resClass = NULL;
+ free (priv->resClass);
+ priv->resClass = NULL;
}
- status = XGetClassHint (w->screen->display->display, w->id, &classHint);
+ status = XGetClassHint (priv->screen->display ()->dpy (),
+ priv->id, &classHint);
if (status)
{
if (classHint.res_name)
{
- w->resName = strdup (classHint.res_name);
+ priv->resName = strdup (classHint.res_name);
XFree (classHint.res_name);
}
if (classHint.res_class)
{
- w->resClass = strdup (classHint.res_class);
+ priv->resClass = strdup (classHint.res_class);
XFree (classHint.res_class);
}
}
}
void
-updateTransientHint (CompWindow *w)
+CompWindow::updateTransientHint ()
{
Window transientFor;
Status status;
- w->transientFor = None;
+ priv->transientFor = None;
- status = XGetTransientForHint (w->screen->display->display,
- w->id, &transientFor);
+ status = XGetTransientForHint (priv->screen->display ()->dpy (),
+ priv->id, &transientFor);
if (status)
{
CompWindow *ancestor;
- ancestor = findWindowAtScreen (w->screen, transientFor);
+ ancestor = priv->screen->findWindow (transientFor);
if (!ancestor)
return;
/* protect against circular transient dependencies */
- if (transientFor == w->id || isAncestorTo (ancestor, w))
+ if (transientFor == priv->id ||
+ PrivateWindow::isAncestorTo (ancestor, this))
return;
- w->transientFor = transientFor;
+ priv->transientFor = transientFor;
}
}
void
-updateIconGeometry (CompWindow *w)
+CompWindow::updateIconGeometry ()
{
Atom actual;
int result, format;
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (w->screen->display->display, w->id,
- w->screen->display->wmIconGeometryAtom,
+ result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
+ priv->screen->display ()->atoms ().wmIconGeometry,
0L, 1024L, False, XA_CARDINAL,
&actual, &format, &n, &left, &data);
- w->iconGeometrySet = FALSE;
+ priv->iconGeometrySet = false;
if (result == Success && data)
{
@@ -409,30 +404,30 @@ updateIconGeometry (CompWindow *w)
{
unsigned long *geometry = (unsigned long *) data;
- w->iconGeometry.x = geometry[0];
- w->iconGeometry.y = geometry[1];
- w->iconGeometry.width = geometry[2];
- w->iconGeometry.height = geometry[3];
+ priv->iconGeometry.x = geometry[0];
+ priv->iconGeometry.y = geometry[1];
+ priv->iconGeometry.width = geometry[2];
+ priv->iconGeometry.height = geometry[3];
- w->iconGeometrySet = TRUE;
+ priv->iconGeometrySet = TRUE;
}
XFree (data);
}
}
-static Window
-getClientLeaderOfAncestor (CompWindow *w)
+Window
+PrivateWindow::getClientLeaderOfAncestor ()
{
- if (w->transientFor)
+ if (transientFor)
{
- w = findWindowAtScreen (w->screen, w->transientFor);
+ CompWindow *w = screen->findWindow (transientFor);
if (w)
{
- if (w->clientLeader)
- return w->clientLeader;
+ if (w->priv->clientLeader)
+ return w->priv->clientLeader;
- return getClientLeaderOfAncestor (w);
+ return w->priv->getClientLeaderOfAncestor ();
}
}
@@ -440,15 +435,15 @@ getClientLeaderOfAncestor (CompWindow *w)
}
Window
-getClientLeader (CompWindow *w)
+CompWindow::getClientLeader ()
{
Atom actual;
int result, format;
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (w->screen->display->display, w->id,
- w->screen->display->wmClientLeaderAtom,
+ result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
+ priv->screen->display ()->atoms ().wmClientLeader,
0L, 1L, False, XA_WINDOW, &actual, &format,
&n, &left, &data);
@@ -463,21 +458,21 @@ getClientLeader (CompWindow *w)
return win;
}
- return getClientLeaderOfAncestor (w);
+ return priv->getClientLeaderOfAncestor ();
}
char *
-getStartupId (CompWindow *w)
+CompWindow::getStartupId ()
{
Atom actual;
int result, format;
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (w->screen->display->display, w->id,
- w->screen->display->startupIdAtom,
+ result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
+ priv->screen->display ()->atoms ().startupId,
0L, 1024L, False,
- w->screen->display->utf8StringAtom,
+ priv->screen->display ()->atoms ().utf8String,
&actual, &format,
&n, &left, &data);
@@ -494,197 +489,25 @@ getStartupId (CompWindow *w)
return NULL;
}
-int
-getWmState (CompDisplay *display,
- Window id)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
- unsigned long state = NormalState;
-
- result = XGetWindowProperty (display->display, id,
- display->wmStateAtom, 0L, 2L, FALSE,
- display->wmStateAtom, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- memcpy (&state, data, sizeof (unsigned long));
- XFree ((void *) data);
- }
-
- return state;
-}
-
-void
-setWmState (CompDisplay *display,
- int state,
- Window id)
-{
- unsigned long data[2];
-
- data[0] = state;
- data[1] = None;
-
- XChangeProperty (display->display, id,
- display->wmStateAtom, display->wmStateAtom,
- 32, PropModeReplace, (unsigned char *) data, 2);
-}
-
-unsigned int
-windowStateMask (CompDisplay *display,
- Atom state)
-{
- if (state == display->winStateModalAtom)
- return CompWindowStateModalMask;
- else if (state == display->winStateStickyAtom)
- return CompWindowStateStickyMask;
- else if (state == display->winStateMaximizedVertAtom)
- return CompWindowStateMaximizedVertMask;
- else if (state == display->winStateMaximizedHorzAtom)
- return CompWindowStateMaximizedHorzMask;
- else if (state == display->winStateShadedAtom)
- return CompWindowStateShadedMask;
- else if (state == display->winStateSkipTaskbarAtom)
- return CompWindowStateSkipTaskbarMask;
- else if (state == display->winStateSkipPagerAtom)
- return CompWindowStateSkipPagerMask;
- else if (state == display->winStateHiddenAtom)
- return CompWindowStateHiddenMask;
- else if (state == display->winStateFullscreenAtom)
- return CompWindowStateFullscreenMask;
- else if (state == display->winStateAboveAtom)
- return CompWindowStateAboveMask;
- else if (state == display->winStateBelowAtom)
- return CompWindowStateBelowMask;
- else if (state == display->winStateDemandsAttentionAtom)
- return CompWindowStateDemandsAttentionMask;
- else if (state == display->winStateDisplayModalAtom)
- return CompWindowStateDisplayModalMask;
-
- return 0;
-}
-
-unsigned int
-windowStateFromString (const char *str)
-{
- if (strcasecmp (str, "modal") == 0)
- return CompWindowStateModalMask;
- else if (strcasecmp (str, "sticky") == 0)
- return CompWindowStateStickyMask;
- else if (strcasecmp (str, "maxvert") == 0)
- return CompWindowStateMaximizedVertMask;
- else if (strcasecmp (str, "maxhorz") == 0)
- return CompWindowStateMaximizedHorzMask;
- else if (strcasecmp (str, "shaded") == 0)
- return CompWindowStateShadedMask;
- else if (strcasecmp (str, "skiptaskbar") == 0)
- return CompWindowStateSkipTaskbarMask;
- else if (strcasecmp (str, "skippager") == 0)
- return CompWindowStateSkipPagerMask;
- else if (strcasecmp (str, "hidden") == 0)
- return CompWindowStateHiddenMask;
- else if (strcasecmp (str, "fullscreen") == 0)
- return CompWindowStateFullscreenMask;
- else if (strcasecmp (str, "above") == 0)
- return CompWindowStateAboveMask;
- else if (strcasecmp (str, "below") == 0)
- return CompWindowStateBelowMask;
- else if (strcasecmp (str, "demandsattention") == 0)
- return CompWindowStateDemandsAttentionMask;
-
- return 0;
-}
-
-unsigned int
-getWindowState (CompDisplay *display,
- Window id)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
- unsigned int state = 0;
-
- result = XGetWindowProperty (display->display, id, display->winStateAtom,
- 0L, 1024L, FALSE, XA_ATOM, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && data)
- {
- Atom *a = (Atom *) data;
-
- while (n--)
- state |= windowStateMask (display, *a++);
-
- XFree ((void *) data);
- }
-
- return state;
-}
-
-void
-setWindowState (CompDisplay *display,
- unsigned int state,
- Window id)
-{
- Atom data[32];
- int i = 0;
-
- if (state & CompWindowStateModalMask)
- data[i++] = display->winStateModalAtom;
- if (state & CompWindowStateStickyMask)
- data[i++] = display->winStateStickyAtom;
- if (state & CompWindowStateMaximizedVertMask)
- data[i++] = display->winStateMaximizedVertAtom;
- if (state & CompWindowStateMaximizedHorzMask)
- data[i++] = display->winStateMaximizedHorzAtom;
- if (state & CompWindowStateShadedMask)
- data[i++] = display->winStateShadedAtom;
- if (state & CompWindowStateSkipTaskbarMask)
- data[i++] = display->winStateSkipTaskbarAtom;
- if (state & CompWindowStateSkipPagerMask)
- data[i++] = display->winStateSkipPagerAtom;
- if (state & CompWindowStateHiddenMask)
- data[i++] = display->winStateHiddenAtom;
- if (state & CompWindowStateFullscreenMask)
- data[i++] = display->winStateFullscreenAtom;
- if (state & CompWindowStateAboveMask)
- data[i++] = display->winStateAboveAtom;
- if (state & CompWindowStateBelowMask)
- data[i++] = display->winStateBelowAtom;
- if (state & CompWindowStateDemandsAttentionMask)
- data[i++] = display->winStateDemandsAttentionAtom;
- if (state & CompWindowStateDisplayModalMask)
- data[i++] = display->winStateDisplayModalAtom;
-
- XChangeProperty (display->display, id, display->winStateAtom,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) data, i);
-}
-
void
-changeWindowState (CompWindow *w,
- unsigned int newState)
+CompWindow::changeState (unsigned int newState)
{
- CompDisplay *d = w->screen->display;
+ CompDisplay *d = priv->screen->display ();
unsigned int oldState;
- if (w->state == newState)
+ if (priv->state == newState)
return;
- oldState = w->state;
- w->state = newState;
+ oldState = priv->state;
+ priv->state = newState;
- recalcWindowType (w);
- recalcWindowActions (w);
+ recalcType ();
+ recalcActions ();
- setWindowState (d, w->state, w->id);
+ d->setWindowState (priv->state, priv->id);
- (*w->screen->windowStateChangeNotify) (w, oldState);
- (*d->matchPropertyChanged) (d, w);
+ stateChangeNotify (oldState);
+ d->matchPropertyChanged (this);
}
static void
@@ -696,42 +519,42 @@ setWindowActions (CompDisplay *display,
int i = 0;
if (actions & CompWindowActionMoveMask)
- data[i++] = display->winActionMoveAtom;
+ data[i++] = display->atoms ().winActionMove;
if (actions & CompWindowActionResizeMask)
- data[i++] = display->winActionResizeAtom;
+ data[i++] = display->atoms ().winActionResize;
if (actions & CompWindowActionStickMask)
- data[i++] = display->winActionStickAtom;
+ data[i++] = display->atoms ().winActionStick;
if (actions & CompWindowActionMinimizeMask)
- data[i++] = display->winActionMinimizeAtom;
+ data[i++] = display->atoms ().winActionMinimize;
if (actions & CompWindowActionMaximizeHorzMask)
- data[i++] = display->winActionMaximizeHorzAtom;
+ data[i++] = display->atoms ().winActionMaximizeHorz;
if (actions & CompWindowActionMaximizeVertMask)
- data[i++] = display->winActionMaximizeVertAtom;
+ data[i++] = display->atoms ().winActionMaximizeVert;
if (actions & CompWindowActionFullscreenMask)
- data[i++] = display->winActionFullscreenAtom;
+ data[i++] = display->atoms ().winActionFullscreen;
if (actions & CompWindowActionCloseMask)
- data[i++] = display->winActionCloseAtom;
+ data[i++] = display->atoms ().winActionClose;
if (actions & CompWindowActionShadeMask)
- data[i++] = display->winActionShadeAtom;
+ data[i++] = display->atoms ().winActionShade;
if (actions & CompWindowActionChangeDesktopMask)
- data[i++] = display->winActionChangeDesktopAtom;
+ data[i++] = display->atoms ().winActionChangeDesktop;
if (actions & CompWindowActionAboveMask)
- data[i++] = display->winActionAboveAtom;
+ data[i++] = display->atoms ().winActionAbove;
if (actions & CompWindowActionBelowMask)
- data[i++] = display->winActionBelowAtom;
+ data[i++] = display->atoms ().winActionBelow;
- XChangeProperty (display->display, id, display->wmAllowedActionsAtom,
+ XChangeProperty (display->dpy (), id, display->atoms ().wmAllowedActions,
XA_ATOM, 32, PropModeReplace,
(unsigned char *) data, i);
}
void
-recalcWindowActions (CompWindow *w)
+CompWindow::recalcActions ()
{
unsigned int actions = 0;
unsigned int setActions, clearActions;
- switch (w->type) {
+ switch (priv->type) {
case CompWindowTypeFullscreenMask:
case CompWindowTypeNormalMask:
actions =
@@ -772,8 +595,8 @@ recalcWindowActions (CompWindow *w)
b) don't have the skip taskbar hint set (as those
have no target to be minimized to)
*/
- if (!w->transientFor &&
- !(w->state & CompWindowStateSkipTaskbarMask))
+ if (!priv->transientFor &&
+ !(priv->state & CompWindowStateSkipTaskbarMask))
{
actions |= CompWindowActionMinimizeMask;
}
@@ -781,12 +604,12 @@ recalcWindowActions (CompWindow *w)
break;
}
- if (w->input.top)
+ if (priv->input.top)
actions |= CompWindowActionShadeMask;
actions |= (CompWindowActionAboveMask | CompWindowActionBelowMask);
- switch (w->wmType) {
+ switch (priv->wmType) {
case CompWindowTypeNormalMask:
actions |= CompWindowActionFullscreenMask |
CompWindowActionMinimizeMask;
@@ -794,57 +617,57 @@ recalcWindowActions (CompWindow *w)
break;
}
- if (w->sizeHints.min_width == w->sizeHints.max_width &&
- w->sizeHints.min_height == w->sizeHints.max_height)
+ if (priv->sizeHints.min_width == priv->sizeHints.max_width &&
+ priv->sizeHints.min_height == priv->sizeHints.max_height)
actions &= ~(CompWindowActionResizeMask |
CompWindowActionMaximizeHorzMask |
CompWindowActionMaximizeVertMask |
CompWindowActionFullscreenMask);
- if (!(w->mwmFunc & MwmFuncAll))
+ if (!(priv->mwmFunc & MwmFuncAll))
{
- if (!(w->mwmFunc & MwmFuncResize))
+ if (!(priv->mwmFunc & MwmFuncResize))
actions &= ~(CompWindowActionResizeMask |
CompWindowActionMaximizeHorzMask |
CompWindowActionMaximizeVertMask |
CompWindowActionFullscreenMask);
- if (!(w->mwmFunc & MwmFuncMove))
+ if (!(priv->mwmFunc & MwmFuncMove))
actions &= ~(CompWindowActionMoveMask |
CompWindowActionMaximizeHorzMask |
CompWindowActionMaximizeVertMask |
CompWindowActionFullscreenMask);
- if (!(w->mwmFunc & MwmFuncIconify))
+ if (!(priv->mwmFunc & MwmFuncIconify))
actions &= ~CompWindowActionMinimizeMask;
- if (!(w->mwmFunc & MwmFuncClose))
+ if (!(priv->mwmFunc & MwmFuncClose))
actions &= ~CompWindowActionCloseMask;
}
- (*w->screen->getAllowedActionsForWindow) (w, &setActions, &clearActions);
+ getAllowedActions (&setActions, &clearActions);
actions &= ~clearActions;
actions |= setActions;
- if (actions != w->actions)
+ if (actions != priv->actions)
{
- w->actions = actions;
- setWindowActions (w->screen->display, actions, w->id);
+ priv->actions = actions;
+ setWindowActions (priv->screen->display (), actions, priv->id);
}
}
void
-getAllowedActionsForWindow (CompWindow *w,
- unsigned int *setActions,
- unsigned int *clearActions)
+CompWindow::getAllowedActions (unsigned int *setActions,
+ unsigned int *clearActions)
{
+ WRAPABLE_HND_FUNC(getAllowedActions, setActions, clearActions)
*setActions = 0;
*clearActions = 0;
}
unsigned int
-constrainWindowState (unsigned int state,
- unsigned int actions)
+CompWindow::constrainWindowState (unsigned int state,
+ unsigned int actions)
{
if (!(actions & CompWindowActionMaximizeHorzMask))
state &= ~CompWindowStateMaximizedHorzMask;
@@ -862,7 +685,7 @@ constrainWindowState (unsigned int state,
}
unsigned int
-windowTypeFromString (const char *str)
+CompWindow::windowTypeFromString (const char *str)
{
if (strcasecmp (str, "desktop") == 0)
return CompWindowTypeDesktopMask;
@@ -904,308 +727,60 @@ windowTypeFromString (const char *str)
return 0;
}
-unsigned int
-getWindowType (CompDisplay *display,
- Window id)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- result = XGetWindowProperty (display->display, id, display->winTypeAtom,
- 0L, 1L, FALSE, XA_ATOM, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- Atom a;
-
- memcpy (&a, data, sizeof (Atom));
- XFree ((void *) data);
-
- if (a == display->winTypeNormalAtom)
- return CompWindowTypeNormalMask;
- else if (a == display->winTypeMenuAtom)
- return CompWindowTypeMenuMask;
- else if (a == display->winTypeDesktopAtom)
- return CompWindowTypeDesktopMask;
- else if (a == display->winTypeDockAtom)
- return CompWindowTypeDockMask;
- else if (a == display->winTypeToolbarAtom)
- return CompWindowTypeToolbarMask;
- else if (a == display->winTypeUtilAtom)
- return CompWindowTypeUtilMask;
- else if (a == display->winTypeSplashAtom)
- return CompWindowTypeSplashMask;
- else if (a == display->winTypeDialogAtom)
- return CompWindowTypeDialogMask;
- else if (a == display->winTypeDropdownMenuAtom)
- return CompWindowTypeDropdownMenuMask;
- else if (a == display->winTypePopupMenuAtom)
- return CompWindowTypePopupMenuMask;
- else if (a == display->winTypeTooltipAtom)
- return CompWindowTypeTooltipMask;
- else if (a == display->winTypeNotificationAtom)
- return CompWindowTypeNotificationMask;
- else if (a == display->winTypeComboAtom)
- return CompWindowTypeComboMask;
- else if (a == display->winTypeDndAtom)
- return CompWindowTypeDndMask;
- }
-
- return CompWindowTypeUnknownMask;
-}
-
void
-recalcWindowType (CompWindow *w)
+CompWindow::recalcType ()
{
unsigned int type;
- type = w->wmType;
+ type = priv->wmType;
- if (!w->attrib.override_redirect && w->wmType == CompWindowTypeUnknownMask)
+ if (!priv->attrib.override_redirect && priv->wmType == CompWindowTypeUnknownMask)
type = CompWindowTypeNormalMask;
- if (w->state & CompWindowStateFullscreenMask)
+ if (priv->state & CompWindowStateFullscreenMask)
type = CompWindowTypeFullscreenMask;
if (type == CompWindowTypeNormalMask)
{
- if (w->transientFor)
+ if (priv->transientFor)
type = CompWindowTypeDialogMask;
}
- if (type == CompWindowTypeDockMask && (w->state & CompWindowStateBelowMask))
+ if (type == CompWindowTypeDockMask && (priv->state & CompWindowStateBelowMask))
type = CompWindowTypeNormalMask;
if ((type & (CompWindowTypeNormalMask | CompWindowTypeDialogMask)) &&
- (w->state & CompWindowStateModalMask))
+ (priv->state & CompWindowStateModalMask))
type = CompWindowTypeModalDialogMask;
- w->type = type;
-}
-
-void
-getMwmHints (CompDisplay *display,
- Window id,
- unsigned int *func,
- unsigned int *decor)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- *func = MwmFuncAll;
- *decor = MwmDecorAll;
-
- result = XGetWindowProperty (display->display, id, display->mwmHintsAtom,
- 0L, 20L, FALSE, display->mwmHintsAtom,
- &actual, &format, &n, &left, &data);
-
- if (result == Success && n && data)
- {
- MwmHints *mwmHints = (MwmHints *) data;
-
- if (n >= PropMotifWmHintElements)
- {
- if (mwmHints->flags & MwmHintsDecorations)
- *decor = mwmHints->decorations;
-
- if (mwmHints->flags & MwmHintsFunctions)
- *func = mwmHints->functions;
- }
-
- XFree (data);
- }
-}
-
-unsigned int
-getProtocols (CompDisplay *display,
- Window id)
-{
- Atom *protocol;
- int count;
- unsigned int protocols = 0;
-
- if (XGetWMProtocols (display->display, id, &protocol, &count))
- {
- int i;
-
- for (i = 0; i < count; i++)
- {
- if (protocol[i] == display->wmDeleteWindowAtom)
- protocols |= CompWindowProtocolDeleteMask;
- else if (protocol[i] == display->wmTakeFocusAtom)
- protocols |= CompWindowProtocolTakeFocusMask;
- else if (protocol[i] == display->wmPingAtom)
- protocols |= CompWindowProtocolPingMask;
- else if (protocol[i] == display->wmSyncRequestAtom)
- protocols |= CompWindowProtocolSyncRequestMask;
- }
-
- XFree (protocol);
- }
-
- return protocols;
-}
-
-unsigned int
-getWindowProp (CompDisplay *display,
- Window id,
- Atom property,
- unsigned int defaultValue)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- result = XGetWindowProperty (display->display, id, property,
- 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- unsigned long value;
-
- memcpy (&value, data, sizeof (unsigned long));
-
- XFree (data);
-
- return (unsigned int) value;
- }
-
- return defaultValue;
-}
-
-void
-setWindowProp (CompDisplay *display,
- Window id,
- Atom property,
- unsigned int value)
-{
- unsigned long data = value;
-
- XChangeProperty (display->display, id, property,
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) &data, 1);
-}
-
-Bool
-readWindowProp32 (CompDisplay *display,
- Window id,
- Atom property,
- unsigned short *returnValue)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- result = XGetWindowProperty (display->display, id, property,
- 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- CARD32 value;
-
- memcpy (&value, data, sizeof (CARD32));
-
- XFree (data);
+ if (type & CompWindowTypeDesktopMask)
+ priv->paint.opacity = OPAQUE;
- *returnValue = value >> 16;
-
- return TRUE;
- }
-
- return FALSE;
+ priv->type = type;
}
-unsigned short
-getWindowProp32 (CompDisplay *display,
- Window id,
- Atom property,
- unsigned short defaultValue)
-{
- unsigned short result;
-
- if (readWindowProp32 (display, id, property, &result))
- return result;
-
- return defaultValue;
-}
void
-setWindowProp32 (CompDisplay *display,
- Window id,
- Atom property,
- unsigned short value)
+PrivateWindow::updateFrameWindow ()
{
- CARD32 value32;
-
- value32 = value << 16 | value;
+ CompDisplay *d = screen->display ();
- XChangeProperty (display->display, id, property,
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) &value32, 1);
-}
-
-void
-updateWindowOpacity (CompWindow *w)
-{
- CompScreen *s = w->screen;
- int opacity = w->opacity;
-
- if (!w->opacityPropSet && !(w->type & CompWindowTypeDesktopMask))
- {
- CompOption *matches = &s->opt[COMP_SCREEN_OPTION_OPACITY_MATCHES];
- CompOption *values = &s->opt[COMP_SCREEN_OPTION_OPACITY_VALUES];
- int i, min;
-
- min = MIN (matches->value.list.nValue, values->value.list.nValue);
-
- for (i = 0; i < min; i++)
- {
- if (matchEval (&matches->value.list.value[i].match, w))
- {
- opacity = (values->value.list.value[i].i * OPAQUE) / 100;
- break;
- }
- }
- }
-
- opacity = (opacity * w->opacityFactor) / 0xff;
- if (opacity != w->paint.opacity)
- {
- w->paint.opacity = opacity;
- addWindowDamage (w);
- }
-}
-
-static void
-updateFrameWindow (CompWindow *w)
-{
- CompDisplay *d = w->screen->display;
-
- if (w->input.left || w->input.right || w->input.top || w->input.bottom)
+ if (input.left || input.right || input.top || input.bottom)
{
XRectangle rects[4];
int x, y, width, height;
int i = 0;
- int bw = w->serverBorderWidth * 2;
+ int bw = serverBorderWidth * 2;
- x = w->serverX - w->input.left;
- y = w->serverY - w->input.top;
- width = w->serverWidth + w->input.left + w->input.right + bw;
- height = w->serverHeight + w->input.top + w->input.bottom + bw;
+ x = serverX - input.left;
+ y = serverY - input.top;
+ width = serverWidth + input.left + input.right + bw;
+ height = serverHeight + input.top + input.bottom + bw;
- if (w->shaded)
- height = w->input.top + w->input.bottom;
+ if (shaded)
+ height = input.top + input.bottom;
- if (!w->frame)
+ if (!frame)
{
XSetWindowAttributes attr;
XWindowChanges xwc;
@@ -1213,67 +788,67 @@ updateFrameWindow (CompWindow *w)
attr.event_mask = 0;
attr.override_redirect = TRUE;
- w->frame = XCreateWindow (d->display, w->screen->root,
- x, y, width, height, 0,
- CopyFromParent,
- InputOnly,
- CopyFromParent,
- CWOverrideRedirect | CWEventMask, &attr);
+ frame = XCreateWindow (d->dpy (), screen->root (),
+ x, y, width, height, 0,
+ CopyFromParent,
+ InputOnly,
+ CopyFromParent,
+ CWOverrideRedirect | CWEventMask, &attr);
- XGrabButton (d->display, AnyButton, AnyModifier, w->frame, TRUE,
+ XGrabButton (d->dpy (), AnyButton, AnyModifier, frame, TRUE,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
GrabModeSync, GrabModeSync, None, None);
xwc.stack_mode = Below;
- xwc.sibling = w->id;
+ xwc.sibling = id;
- XConfigureWindow (d->display, w->frame,
+ XConfigureWindow (d->dpy (), frame,
CWSibling | CWStackMode, &xwc);
- if (w->mapNum || w->shaded)
- XMapWindow (d->display, w->frame);
+ if (mapNum || shaded)
+ XMapWindow (d->dpy (), frame);
- XChangeProperty (d->display, w->id, d->frameWindowAtom,
+ XChangeProperty (d->dpy (), id, d->atoms ().frameWindow,
XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) &w->frame, 1);
+ (unsigned char *) &frame, 1);
}
- XMoveResizeWindow (d->display, w->frame, x, y, width, height);
+ XMoveResizeWindow (d->dpy (), frame, x, y, width, height);
rects[i].x = 0;
rects[i].y = 0;
rects[i].width = width;
- rects[i].height = w->input.top;
+ rects[i].height = input.top;
if (rects[i].width && rects[i].height)
i++;
rects[i].x = 0;
- rects[i].y = w->input.top;
- rects[i].width = w->input.left;
- rects[i].height = height - w->input.top - w->input.bottom;
+ rects[i].y = input.top;
+ rects[i].width = input.left;
+ rects[i].height = height - input.top - input.bottom;
if (rects[i].width && rects[i].height)
i++;
- rects[i].x = width - w->input.right;
- rects[i].y = w->input.top;
- rects[i].width = w->input.right;
- rects[i].height = height - w->input.top - w->input.bottom;
+ rects[i].x = width - input.right;
+ rects[i].y = input.top;
+ rects[i].width = input.right;
+ rects[i].height = height - input.top - input.bottom;
if (rects[i].width && rects[i].height)
i++;
rects[i].x = 0;
- rects[i].y = height - w->input.bottom;
+ rects[i].y = height - input.bottom;
rects[i].width = width;
- rects[i].height = w->input.bottom;
+ rects[i].height = input.bottom;
if (rects[i].width && rects[i].height)
i++;
- XShapeCombineRectangles (d->display,
- w->frame,
+ XShapeCombineRectangles (d->dpy (),
+ frame,
ShapeInput,
0,
0,
@@ -1284,305 +859,250 @@ updateFrameWindow (CompWindow *w)
}
else
{
- if (w->frame)
+ if (frame)
{
- XDeleteProperty (d->display, w->id, d->frameWindowAtom);
- XDestroyWindow (d->display, w->frame);
- w->frame = None;
+ XDeleteProperty (d->dpy (), id, d->atoms ().frameWindow);
+ XDestroyWindow (d->dpy (), frame);
+ frame = None;
}
}
- recalcWindowActions (w);
+ window->recalcActions ();
}
void
-setWindowFrameExtents (CompWindow *w,
- CompWindowExtents *input)
+CompWindow::setWindowFrameExtents (CompWindowExtents *input)
{
- if (input->left != w->input.left ||
- input->right != w->input.right ||
- input->top != w->input.top ||
- input->bottom != w->input.bottom)
+ if (input->left != priv->input.left ||
+ input->right != priv->input.right ||
+ input->top != priv->input.top ||
+ input->bottom != priv->input.bottom)
{
unsigned long data[4];
- w->input = *input;
+ priv->input = *input;
data[0] = input->left;
data[1] = input->right;
data[2] = input->top;
data[3] = input->bottom;
- updateWindowSize (w);
- updateFrameWindow (w);
- recalcWindowActions (w);
+ updateSize ();
+ priv->updateFrameWindow ();
+ recalcActions ();
- XChangeProperty (w->screen->display->display, w->id,
- w->screen->display->frameExtentsAtom,
+ XChangeProperty (priv->screen->display ()->dpy (), priv->id,
+ priv->screen->display ()->atoms ().frameExtents,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) data, 4);
}
}
void
-updateWindowOutputExtents (CompWindow *w)
+CompWindow::updateWindowOutputExtents ()
{
CompWindowExtents output;
- (*w->screen->getOutputExtentsForWindow) (w, &output);
+ getOutputExtents (&output);
- if (output.left != w->output.left ||
- output.right != w->output.right ||
- output.top != w->output.top ||
- output.bottom != w->output.bottom)
+ if (output.left != priv->output.left ||
+ output.right != priv->output.right ||
+ output.top != priv->output.top ||
+ output.bottom != priv->output.bottom)
{
- w->output = output;
+ priv->output = output;
- (*w->screen->windowResizeNotify) (w, 0, 0, 0, 0);
+ resizeNotify (0, 0, 0, 0);
}
}
-static void
-setWindowMatrix (CompWindow *w)
+void
+PrivateWindow::setWindowMatrix ()
{
- w->matrix = w->texture->matrix;
- w->matrix.x0 -= (w->attrib.x * w->matrix.xx);
- w->matrix.y0 -= (w->attrib.y * w->matrix.yy);
+ matrix = texture->matrix;
+ matrix.x0 -= (attrib.x * matrix.xx);
+ matrix.y0 -= (attrib.y * matrix.yy);
}
-Bool
-bindWindow (CompWindow *w)
+bool
+CompWindow::bind ()
{
- redirectWindow (w);
+ redirect ();
- if (!w->pixmap)
+ if (!priv->pixmap)
{
XWindowAttributes attr;
/* don't try to bind window again if it failed previously */
- if (w->bindFailed)
- return FALSE;
+ 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 (w->screen->display->display);
- XGetWindowAttributes (w->screen->display->display, w->id, &attr);
+ XGrabServer (priv->screen->display ()->dpy ());
+ XGetWindowAttributes (priv->screen->display ()->dpy (), priv->id, &attr);
if (attr.map_state != IsViewable)
{
- XUngrabServer (w->screen->display->display);
- finiTexture (w->screen, w->texture);
- w->bindFailed = TRUE;
- return FALSE;
+ XUngrabServer (priv->screen->display ()->dpy ());
+ finiTexture (priv->screen, priv->texture);
+ priv->bindFailed = true;
+ return false;
}
- w->pixmap = XCompositeNameWindowPixmap (w->screen->display->display,
- w->id);
+ priv->pixmap = XCompositeNameWindowPixmap (priv->screen->display ()->dpy (),
+ priv->id);
- XUngrabServer (w->screen->display->display);
+ XUngrabServer (priv->screen->display ()->dpy ());
}
- if (!bindPixmapToTexture (w->screen, w->texture, w->pixmap,
- w->width, w->height,
- w->attrib.depth))
+ if (!priv->screen->bindPixmapToTexture (priv->texture, priv->pixmap,
+ priv->width, priv->height,
+ priv->attrib.depth))
{
- compLogMessage (w->screen->display, "core", CompLogLevelInfo,
+ compLogMessage (priv->screen->display (), "core", CompLogLevelInfo,
"Couldn't bind redirected window 0x%x to "
- "texture\n", (int) w->id);
+ "texture\n", (int) priv->id);
}
- setWindowMatrix (w);
+ priv->setWindowMatrix ();
- return TRUE;
+ return true;
}
void
-releaseWindow (CompWindow *w)
+CompWindow::release ()
{
- if (w->pixmap)
+ if (priv->pixmap)
{
CompTexture *texture;
- texture = createTexture (w->screen);
+ texture = createTexture (priv->screen);
if (texture)
{
- destroyTexture (w->screen, w->texture);
+ destroyTexture (priv->screen, priv->texture);
- w->texture = texture;
+ priv->texture = texture;
}
- XFreePixmap (w->screen->display->display, w->pixmap);
+ XFreePixmap (priv->screen->display ()->dpy (), priv->pixmap);
- w->pixmap = None;
+ priv->pixmap = None;
}
}
-static void
-freeWindow (CompWindow *w)
-{
- releaseWindow (w);
-
- if (w->syncAlarm)
- XSyncDestroyAlarm (w->screen->display->display, w->syncAlarm);
-
- if (w->syncWaitHandle)
- compRemoveTimeout (w->syncWaitHandle);
-
- destroyTexture (w->screen, w->texture);
-
- if (w->frame)
- XDestroyWindow (w->screen->display->display, w->frame);
-
- if (w->clip)
- XDestroyRegion (w->clip);
-
- if (w->region)
- XDestroyRegion (w->region);
-
- if (w->base.privates)
- free (w->base.privates);
-
- if (w->sizeDamage)
- free (w->damageRects);
-
- if (w->vertices)
- free (w->vertices);
-
- if (w->indices)
- free (w->indices);
-
- if (w->struts)
- free (w->struts);
-
- if (w->icon)
- freeWindowIcons (w);
-
- if (w->startupId)
- free (w->startupId);
-
- if (w->resName)
- free (w->resName);
-
- if (w->resClass)
- free (w->resClass);
-
- free (w);
-}
-
void
-damageTransformedWindowRect (CompWindow *w,
- float xScale,
- float yScale,
- float xTranslate,
- float yTranslate,
- BoxPtr rect)
+CompWindow::damageTransformedRect (float xScale,
+ float yScale,
+ float xTranslate,
+ float yTranslate,
+ BoxPtr rect)
{
REGION reg;
reg.rects = &reg.extents;
reg.numRects = 1;
- reg.extents.x1 = (rect->x1 * xScale) - 1;
- reg.extents.y1 = (rect->y1 * yScale) - 1;
- reg.extents.x2 = (rect->x2 * xScale + 0.5f) + 1;
- reg.extents.y2 = (rect->y2 * yScale + 0.5f) + 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 += xTranslate;
- reg.extents.y1 += yTranslate;
- reg.extents.x2 += (xTranslate + 0.5f);
- reg.extents.y2 += (yTranslate + 0.5f);
+ 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 += w->attrib.x + w->attrib.border_width;
- reg.extents.y1 += w->attrib.y + w->attrib.border_width;
- reg.extents.x2 += w->attrib.x + w->attrib.border_width;
- reg.extents.y2 += w->attrib.y + w->attrib.border_width;
+ 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;
- damageScreenRegion (w->screen, &reg);
+ priv->screen->damageRegion (&reg);
}
}
void
-damageWindowOutputExtents (CompWindow *w)
+CompWindow::damageOutputExtents ()
{
- if (w->screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ if (priv->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
return;
- if (w->shaded || (w->attrib.map_state == IsViewable && w->damaged))
+ if (priv->shaded || (priv->attrib.map_state == IsViewable && priv->damaged))
{
BoxRec box;
/* top */
- box.x1 = -w->output.left - w->attrib.border_width;
- box.y1 = -w->output.top - w->attrib.border_width;
- box.x2 = w->width + w->output.right - w->attrib.border_width;
- box.y2 = -w->attrib.border_width;
+ 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)
- addWindowDamageRect (w, &box);
+ addDamageRect (&box);
/* bottom */
- box.y1 = w->height - w->attrib.border_width;
- box.y2 = box.y1 + w->output.bottom - w->attrib.border_width;
+ 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)
- addWindowDamageRect (w, &box);
+ addDamageRect (&box);
/* left */
- box.x1 = -w->output.left - w->attrib.border_width;
- box.y1 = -w->attrib.border_width;
- box.x2 = -w->attrib.border_width;
- box.y2 = w->height - w->attrib.border_width;
+ 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)
- addWindowDamageRect (w, &box);
+ addDamageRect (&box);
/* right */
- box.x1 = w->width - w->attrib.border_width;
- box.x2 = box.x1 + w->output.right - w->attrib.border_width;
+ 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)
- addWindowDamageRect (w, &box);
+ addDamageRect (&box);
}
}
-Bool
-damageWindowRect (CompWindow *w,
- Bool initial,
- BoxPtr rect)
+bool
+CompWindow::damageRect (bool initial,
+ BoxPtr rect)
{
- return FALSE;
+ WRAPABLE_HND_FUNC_RETURN(bool, damageRect, initial, rect)
+ return false;
}
void
-addWindowDamageRect (CompWindow *w,
- BoxPtr rect)
+CompWindow::addDamageRect (BoxPtr rect)
{
REGION region;
- if (w->screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ if (priv->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
return;
region.extents = *rect;
- if (!(*w->screen->damageWindowRect) (w, FALSE, &region.extents))
+ if (!damageRect (false, &region.extents))
{
- region.extents.x1 += w->attrib.x + w->attrib.border_width;
- region.extents.y1 += w->attrib.y + w->attrib.border_width;
- region.extents.x2 += w->attrib.x + w->attrib.border_width;
- region.extents.y2 += w->attrib.y + w->attrib.border_width;
+ 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;
- damageScreenRegion (w->screen, &region);
+ priv->screen->damageRegion (&region);
}
}
void
-getOutputExtentsForWindow (CompWindow *w,
- CompWindowExtents *output)
+CompWindow::getOutputExtents (CompWindowExtents *output)
{
+ WRAPABLE_HND_FUNC(getOutputExtents, output)
output->left = 0;
output->right = 0;
output->top = 0;
@@ -1590,47 +1110,47 @@ getOutputExtentsForWindow (CompWindow *w,
}
void
-addWindowDamage (CompWindow *w)
+CompWindow::addDamage ()
{
- if (w->screen->damageMask & COMP_SCREEN_DAMAGE_ALL_MASK)
+ if (priv->screen->damageMask () & COMP_SCREEN_DAMAGE_ALL_MASK)
return;
- if (w->shaded || (w->attrib.map_state == IsViewable && w->damaged))
+ if (priv->shaded || (priv->attrib.map_state == IsViewable && priv->damaged))
{
BoxRec box;
- box.x1 = -w->output.left - w->attrib.border_width;
- box.y1 = -w->output.top - w->attrib.border_width;
- box.x2 = w->width + w->output.right;
- box.y2 = w->height + w->output.bottom;
+ 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;
- addWindowDamageRect (w, &box);
+ addDamageRect (&box);
}
}
void
-updateWindowRegion (CompWindow *w)
+CompWindow::updateRegion ()
{
REGION rect;
XRectangle r, *rects, *shapeRects = 0;
int i, n = 0;
- EMPTY_REGION (w->region);
+ EMPTY_REGION (priv->region);
- if (w->screen->display->shapeExtension)
+ if (priv->screen->display ()->XShape ())
{
int order;
- shapeRects = XShapeGetRectangles (w->screen->display->display, w->id,
+ shapeRects = XShapeGetRectangles (priv->screen->display ()->dpy (), priv->id,
ShapeBounding, &n, &order);
}
if (n < 2)
{
- r.x = -w->attrib.border_width;
- r.y = -w->attrib.border_width;
- r.width = w->width;
- r.height = w->height;
+ r.x = -priv->attrib.border_width;
+ r.y = -priv->attrib.border_width;
+ r.width = priv->width;
+ r.height = priv->height;
rects = &r;
n = 1;
@@ -1645,8 +1165,8 @@ updateWindowRegion (CompWindow *w)
for (i = 0; i < n; i++)
{
- rect.extents.x1 = rects[i].x + w->attrib.border_width;
- rect.extents.y1 = rects[i].y + w->attrib.border_width;
+ rect.extents.x1 = rects[i].x + priv->attrib.border_width;
+ rect.extents.y1 = rects[i].y + priv->attrib.border_width;
rect.extents.x2 = rect.extents.x1 + rects[i].width;
rect.extents.y2 = rect.extents.y1 + rects[i].height;
@@ -1654,20 +1174,20 @@ updateWindowRegion (CompWindow *w)
rect.extents.x1 = 0;
if (rect.extents.y1 < 0)
rect.extents.y1 = 0;
- if (rect.extents.x2 > w->width)
- rect.extents.x2 = w->width;
- if (rect.extents.y2 > w->height)
- rect.extents.y2 = w->height;
+ if (rect.extents.x2 > priv->width)
+ rect.extents.x2 = priv->width;
+ if (rect.extents.y2 > priv->height)
+ rect.extents.y2 = priv->height;
if (rect.extents.y1 < rect.extents.y2 &&
rect.extents.x1 < rect.extents.x2)
{
- rect.extents.x1 += w->attrib.x;
- rect.extents.y1 += w->attrib.y;
- rect.extents.x2 += w->attrib.x;
- rect.extents.y2 += w->attrib.y;
+ rect.extents.x1 += priv->attrib.x;
+ rect.extents.y1 += priv->attrib.y;
+ rect.extents.x2 += priv->attrib.x;
+ rect.extents.y2 += priv->attrib.y;
- XUnionRegion (&rect, w->region, w->region);
+ XUnionRegion (&rect, priv->region, priv->region);
}
}
@@ -1675,56 +1195,56 @@ updateWindowRegion (CompWindow *w)
XFree (shapeRects);
}
-Bool
-updateWindowStruts (CompWindow *w)
+bool
+CompWindow::updateStruts ()
{
Atom actual;
int result, format;
unsigned long n, left;
unsigned char *data;
- Bool hasOld, hasNew;
+ bool hasOld, hasNew;
CompStruts old, c_new;
#define MIN_EMPTY 76
- if (w->struts)
+ if (priv->struts)
{
- hasOld = TRUE;
+ hasOld = true;
- old.left = w->struts->left;
- old.right = w->struts->right;
- old.top = w->struts->top;
- old.bottom = w->struts->bottom;
+ old.left = priv->struts->left;
+ old.right = priv->struts->right;
+ old.top = priv->struts->top;
+ old.bottom = priv->struts->bottom;
}
else
{
- hasOld = FALSE;
+ hasOld = false;
}
- hasNew = FALSE;
+ hasNew = true;
c_new.left.x = 0;
c_new.left.y = 0;
c_new.left.width = 0;
- c_new.left.height = w->screen->height;
+ c_new.left.height = priv->screen->height ();
- c_new.right.x = w->screen->width;
+ c_new.right.x = priv->screen->width ();
c_new.right.y = 0;
c_new.right.width = 0;
- c_new.right.height = w->screen->height;
+ c_new.right.height = priv->screen->height ();
c_new.top.x = 0;
c_new.top.y = 0;
- c_new.top.width = w->screen->width;
+ c_new.top.width = priv->screen->width ();
c_new.top.height = 0;
c_new.bottom.x = 0;
- c_new.bottom.y = w->screen->height;
- c_new.bottom.width = w->screen->width;
+ c_new.bottom.y = priv->screen->height ();
+ c_new.bottom.width = priv->screen->width ();
c_new.bottom.height = 0;
- result = XGetWindowProperty (w->screen->display->display, w->id,
- w->screen->display->wmStrutPartialAtom,
+ result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
+ priv->screen->display ()->atoms ().wmStrutPartial,
0L, 12L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &data);
@@ -1736,22 +1256,22 @@ updateWindowStruts (CompWindow *w)
{
int gap;
- hasNew = TRUE;
+ hasNew = true;
- gap = w->screen->width - struts[0] - struts[1];
+ gap = priv->screen->width () - struts[0] - struts[1];
gap -= MIN_EMPTY;
c_new.left.width = (int) struts[0] + MIN (0, gap / 2);
c_new.right.width = (int) struts[1] + MIN (0, gap / 2);
- gap = w->screen->height - struts[2] - struts[3];
+ gap = priv->screen->height () - struts[2] - struts[3];
gap -= MIN_EMPTY;
c_new.top.height = (int) struts[2] + MIN (0, gap / 2);
c_new.bottom.height = (int) struts[3] + MIN (0, gap / 2);
- c_new.right.x = w->screen->width - c_new.right.width;
- c_new.bottom.y = w->screen->height - c_new.bottom.height;
+ c_new.right.x = priv->screen->width () - c_new.right.width;
+ c_new.bottom.y = priv->screen->height () - c_new.bottom.height;
c_new.left.y = struts[4];
c_new.left.height = struts[5] - c_new.left.y + 1;
@@ -1769,8 +1289,8 @@ updateWindowStruts (CompWindow *w)
if (!hasNew)
{
- result = XGetWindowProperty (w->screen->display->display, w->id,
- w->screen->display->wmStrutAtom,
+ result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
+ priv->screen->display ()->atoms ().wmStrut,
0L, 4L, FALSE, XA_CARDINAL,
&actual, &format, &n, &left, &data);
@@ -1782,25 +1302,25 @@ updateWindowStruts (CompWindow *w)
{
int gap;
- hasNew = TRUE;
+ hasNew = true;
- gap = w->screen->width - struts[0] - struts[1];
+ gap = priv->screen->width () - struts[0] - struts[1];
gap -= MIN_EMPTY;
c_new.left.width = (int) struts[0] + MIN (0, gap / 2);
c_new.right.width = (int) struts[1] + MIN (0, gap / 2);
- gap = w->screen->height - struts[2] - struts[3];
+ gap = priv->screen->height () - struts[2] - struts[3];
gap -= MIN_EMPTY;
c_new.top.height = (int) struts[2] + MIN (0, gap / 2);
c_new.bottom.height = (int) struts[3] + MIN (0, gap / 2);
c_new.left.x = 0;
- c_new.right.x = w->screen->width - c_new.right.width;
+ c_new.right.x = priv->screen->width () - c_new.right.width;
c_new.top.y = 0;
- c_new.bottom.y = w->screen->height - c_new.bottom.height;
+ c_new.bottom.y = priv->screen->height () - c_new.bottom.height;
}
XFree (data);
@@ -1814,12 +1334,12 @@ updateWindowStruts (CompWindow *w)
int i;
/* applications expect us to clip struts to xinerama edges */
- for (i = 0; i < w->screen->display->nScreenInfo; i++)
+ for (i = 0; i < priv->screen->display ()->nScreenInfo (); i++)
{
- x1 = w->screen->display->screenInfo[i].x_org;
- y1 = w->screen->display->screenInfo[i].y_org;
- x2 = x1 + w->screen->display->screenInfo[i].width;
- y2 = y1 + w->screen->display->screenInfo[i].height;
+ x1 = priv->screen->display ()->screenInfo ()[i].x_org;
+ y1 = priv->screen->display ()->screenInfo ()[i].y_org;
+ x2 = x1 + priv->screen->display ()->screenInfo ()[i].width;
+ y2 = y1 + priv->screen->display ()->screenInfo ()[i].height;
strutX1 = c_new.left.x;
strutX2 = strutX1 + c_new.left.width;
@@ -1864,25 +1384,25 @@ updateWindowStruts (CompWindow *w)
{
if (hasNew)
{
- if (!w->struts)
+ if (!priv->struts)
{
- w->struts = (CompStruts *) malloc (sizeof (CompStruts));
- if (!w->struts)
- return FALSE;
+ priv->struts = (CompStruts *) malloc (sizeof (CompStruts));
+ if (!priv->struts)
+ return false;
}
- *w->struts = c_new;
+ *priv->struts = c_new;
}
else
{
- free (w->struts);
- w->struts = NULL;
+ free (priv->struts);
+ priv->struts = NULL;
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
static void
@@ -1913,480 +1433,46 @@ setDefaultWindowAttributes (XWindowAttributes *wa)
wa->screen = NULL;
}
-void
-addWindow (CompScreen *screen,
- Window id,
- Window aboveId)
-{
- CompWindow *w;
- CompPrivate *privates;
- CompDisplay *d = screen->display;
-
- w = (CompWindow *) malloc (sizeof (CompWindow));
- if (!w)
- return;
-
- w->next = NULL;
- w->prev = NULL;
-
- w->mapNum = 0;
- w->activeNum = 0;
-
- w->frame = None;
-
- w->placed = FALSE;
- w->minimized = FALSE;
- w->inShowDesktopMode = FALSE;
- w->shaded = FALSE;
- w->hidden = FALSE;
- w->grabbed = FALSE;
-
- w->desktop = screen->currentDesktop;
-
- w->initialViewportX = screen->x;
- w->initialViewportY = screen->y;
-
- w->initialTimestamp = 0;
- w->initialTimestampSet = FALSE;
-
- w->pendingUnmaps = 0;
- w->pendingMaps = 0;
-
- w->startupId = NULL;
- w->resName = NULL;
- w->resClass = NULL;
-
- w->texture = createTexture (screen);
- if (!w->texture)
- {
- free (w);
- return;
- }
-
- w->screen = screen;
- w->pixmap = None;
- w->destroyed = FALSE;
- w->damaged = FALSE;
- w->redirected = TRUE;
- w->managed = FALSE;
- w->bindFailed = FALSE;
-
- w->destroyRefCnt = 1;
- w->unmapRefCnt = 1;
- w->group = NULL;
-
- w->damageRects = 0;
- w->sizeDamage = 0;
- w->nDamage = 0;
-
- w->vertices = 0;
- w->vertexSize = 0;
- w->vertexStride = 0;
- w->indices = 0;
- w->indexSize = 0;
- w->vCount = 0;
- w->indexCount = 0;
- w->texCoordSize = 2;
-
- w->drawWindowGeometry = NULL;
-
- w->struts = 0;
-
- w->icon = 0;
- w->nIcon = 0;
-
- w->iconGeometry.x = 0;
- w->iconGeometry.y = 0;
- w->iconGeometry.width = 0;
- w->iconGeometry.height = 0;
- w->iconGeometrySet = FALSE;
-
- w->input.left = 0;
- w->input.right = 0;
- w->input.top = 0;
- w->input.bottom = 0;
-
- w->output.left = 0;
- w->output.right = 0;
- w->output.top = 0;
- w->output.bottom = 0;
-
- w->paint.xScale = 1.0f;
- w->paint.yScale = 1.0f;
- w->paint.xTranslate = 0.0f;
- w->paint.yTranslate = 0.0f;
-
- w->opacityFactor = 0xff;
-
- w->opacityPropSet = FALSE;
-
- w->lastPaint = w->paint;
-
- w->alive = TRUE;
-
- w->mwmDecor = MwmDecorAll;
- w->mwmFunc = MwmFuncAll;
-
- w->syncAlarm = None;
- w->syncCounter = 0;
- w->syncWaitHandle = 0;
-
- w->closeRequests = 0;
- w->lastCloseRequestTime = 0;
-
- w->overlayWindow = FALSE;
-
- if (screen->windowPrivateLen)
- {
- privates = (CompPrivate *) malloc (screen->windowPrivateLen * sizeof (CompPrivate));
- if (!privates)
- {
- destroyTexture (screen, w->texture);
- free (w);
- return;
- }
- }
- else
- privates = 0;
-
- compObjectInit (&w->base, privates, COMP_OBJECT_TYPE_WINDOW);
-
- w->region = XCreateRegion ();
- if (!w->region)
- {
- freeWindow (w);
- return;
- }
-
- w->clip = XCreateRegion ();
- if (!w->clip)
- {
- freeWindow (w);
- return;
- }
-
- /* 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
- require us to stack other windows relative to it. Setting some default
- values if this is the case. */
- if (!XGetWindowAttributes (d->display, id, &w->attrib))
- setDefaultWindowAttributes (&w->attrib);
-
- w->serverWidth = w->attrib.width;
- w->serverHeight = w->attrib.height;
- w->serverBorderWidth = w->attrib.border_width;
-
- w->width = w->attrib.width + w->attrib.border_width * 2;
- w->height = w->attrib.height + w->attrib.border_width * 2;
-
- w->sizeHints.flags = 0;
-
- recalcNormalHints (w);
-
- w->transientFor = None;
- w->clientLeader = None;
-
- w->serverX = w->attrib.x;
- w->serverY = w->attrib.y;
-
- w->syncWait = FALSE;
- w->syncX = w->attrib.x;
- w->syncY = w->attrib.y;
- w->syncWidth = w->attrib.width;
- w->syncHeight = w->attrib.height;
- w->syncBorderWidth = w->attrib.border_width;
-
- w->saveMask = 0;
-
- XSelectInput (d->display, id,
- PropertyChangeMask |
- EnterWindowMask |
- FocusChangeMask);
-
- w->id = id;
-
- XGrabButton (d->display, AnyButton, AnyModifier, w->id, TRUE,
- ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
- GrabModeSync, GrabModeSync, None, None);
-
- w->inputHint = TRUE;
- w->alpha = (w->attrib.depth == 32);
- w->wmType = 0;
- w->state = 0;
- w->actions = 0;
- w->protocols = 0;
- w->type = CompWindowTypeUnknownMask;
- w->lastPong = d->lastPing;
-
- if (d->shapeExtension)
- XShapeSelectInput (d->display, id, ShapeNotifyMask);
-
- insertWindowIntoScreen (screen, w, aboveId);
-
- EMPTY_REGION (w->region);
-
- if (w->attrib.c_class != InputOnly)
- {
- REGION rect;
-
- rect.rects = &rect.extents;
- rect.numRects = rect.size = 1;
-
- rect.extents.x1 = w->attrib.x;
- rect.extents.y1 = w->attrib.y;
- rect.extents.x2 = w->attrib.x + w->width;
- rect.extents.y2 = w->attrib.y + w->height;
-
- XUnionRegion (&rect, w->region, w->region);
-
- w->damage = XDamageCreate (d->display, id,
- XDamageReportRawRectangles);
-
- /* need to check for DisplayModal state on all windows */
- w->state = getWindowState (d, w->id);
-
- updateWindowClassHints (w);
- }
- else
- {
- w->damage = None;
- w->attrib.map_state = IsUnmapped;
- }
-
- w->invisible = TRUE;
-
- w->wmType = getWindowType (d, w->id);
- w->protocols = getProtocols (d, w->id);
-
- if (!w->attrib.override_redirect)
- {
- updateNormalHints (w);
- updateWindowStruts (w);
- updateWmHints (w);
- updateTransientHint (w);
-
- w->clientLeader = getClientLeader (w);
- if (!w->clientLeader)
- w->startupId = getStartupId (w);
-
- recalcWindowType (w);
-
- getMwmHints (d, w->id, &w->mwmFunc, &w->mwmDecor);
-
- if (!(w->type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask)))
- {
- w->desktop = getWindowProp (d, w->id, d->winDesktopAtom,
- w->desktop);
- if (w->desktop != 0xffffffff)
- {
- if (w->desktop >= screen->nDesktop)
- w->desktop = screen->currentDesktop;
- }
- }
- }
- else
- {
- recalcWindowType (w);
- }
-
- w->opacity = OPAQUE;
- if (!(w->type & CompWindowTypeDesktopMask))
- w->opacityPropSet = readWindowProp32 (d, w->id, d->winOpacityAtom,
- &w->opacity);
-
- w->brightness = getWindowProp32 (d, w->id, d->winBrightnessAtom, BRIGHT);
-
- if (screen->canDoSaturated)
- w->saturation = getWindowProp32 (d, w->id, d->winSaturationAtom, COLOR);
- else
- w->saturation = COLOR;
-
- w->paint.opacity = w->opacity;
- w->paint.brightness = w->brightness;
- w->paint.saturation = w->saturation;
-
- if (w->attrib.map_state == IsViewable)
- {
- w->placed = TRUE;
-
- if (!w->attrib.override_redirect)
- {
- w->managed = TRUE;
-
- if (getWmState (d, w->id) == IconicState)
- {
- if (w->state & CompWindowStateShadedMask)
- w->shaded = TRUE;
- else
- w->minimized = TRUE;
- }
- else
- {
- if (w->wmType & (CompWindowTypeDockMask |
- CompWindowTypeDesktopMask))
- {
- setDesktopForWindow (w, 0xffffffff);
- }
- else
- {
- if (w->desktop != 0xffffffff)
- w->desktop = screen->currentDesktop;
-
- setWindowProp (d, w->id, d->winDesktopAtom, w->desktop);
- }
- }
- }
-
- w->attrib.map_state = IsUnmapped;
- w->pendingMaps++;
-
- mapWindow (w);
-
- updateWindowAttributes (w, CompStackingUpdateModeNormal);
-
- if (w->minimized || w->inShowDesktopMode || w->hidden || w->shaded)
- {
- w->state |= CompWindowStateHiddenMask;
-
- w->pendingUnmaps++;
-
- XUnmapWindow (d->display, w->id);
-
- setWindowState (d, w->state, w->id);
- }
- }
- else if (!w->attrib.override_redirect)
- {
- if (getWmState (d, w->id) == IconicState)
- {
- w->managed = TRUE;
- w->placed = TRUE;
-
- if (w->state & CompWindowStateHiddenMask)
- {
- if (w->state & CompWindowStateShadedMask)
- w->shaded = TRUE;
- else
- w->minimized = TRUE;
- }
- }
- }
-
- /* TODO: bailout properly when objectInitPlugins fails */
- assert (objectInitPlugins (&w->base));
-
- (*core.objectAdd) (&screen->base, &w->base);
-
- recalcWindowActions (w);
- updateWindowOpacity (w);
- updateIconGeometry (w);
-
- if (w->shaded)
- resizeWindow (w,
- w->attrib.x, w->attrib.y,
- w->attrib.width, ++w->attrib.height - 1,
- w->attrib.border_width);
-}
void
-removeWindow (CompWindow *w)
+CompWindow::destroy ()
{
- unhookWindowFromScreen (w->screen, w);
-
- if (!w->destroyed)
- {
- CompDisplay *d = w->screen->display;
-
- /* restore saved geometry and map if hidden */
- if (!w->attrib.override_redirect)
- {
- if (w->saveMask)
- XConfigureWindow (d->display, w->id, w->saveMask, &w->saveWc);
-
- if (!w->hidden)
- {
- if (w->state & CompWindowStateHiddenMask)
- XMapWindow (d->display, w->id);
- }
- }
-
- if (w->damage)
- XDamageDestroy (d->display, w->damage);
-
- if (d->shapeExtension)
- XShapeSelectInput (d->display, w->id, NoEventMask);
-
- XSelectInput (d->display, w->id, NoEventMask);
-
- XUngrabButton (d->display, AnyButton, AnyModifier, w->id);
- }
-
- if (w->attrib.map_state == IsViewable && w->damaged)
- {
- if (w->type == CompWindowTypeDesktopMask)
- w->screen->desktopWindowCount--;
-
- if (w->destroyed && w->struts)
- updateWorkareaForScreen (w->screen);
- }
-
- if (w->destroyed)
- updateClientListForScreen (w->screen);
-
- if (!w->redirected)
- {
- w->screen->overlayWindowCount--;
-
- if (w->screen->overlayWindowCount < 1)
- showOutputWindow (w->screen);
- }
-
- (*core.objectRemove) (&w->screen->base, &w->base);
+ priv->id = 1;
+ priv->mapNum = 0;
- objectFiniPlugins (&w->base);
-
- freeWindow (w);
-}
-
-void
-destroyWindow (CompWindow *w)
-{
- w->id = 1;
- w->mapNum = 0;
-
- w->destroyRefCnt--;
- if (w->destroyRefCnt)
+ priv->destroyRefCnt--;
+ if (priv->destroyRefCnt)
return;
- if (!w->destroyed)
+ if (!priv->destroyed)
{
- w->destroyed = TRUE;
- w->screen->pendingDestroys++;
+ priv->destroyed = true;
+ priv->screen->pendingDestroys ()++;
}
}
void
-sendConfigureNotify (CompWindow *w)
+CompWindow::sendConfigureNotify ()
{
XConfigureEvent xev;
xev.type = ConfigureNotify;
- xev.event = w->id;
- xev.window = w->id;
+ xev.event = priv->id;
+ xev.window = priv->id;
/* normally we should never send configure notify events to override
redirect windows but if they support the _NET_WM_SYNC_REQUEST
protocol we need to do this when the window is mapped. however the
only way we can make sure that the attributes we send are correct
and is to grab the server. */
- if (w->attrib.override_redirect)
+ if (priv->attrib.override_redirect)
{
XWindowAttributes attrib;
- XGrabServer (w->screen->display->display);
+ XGrabServer (priv->screen->display ()->dpy ());
- if (XGetWindowAttributes (w->screen->display->display, w->id, &attrib))
+ if (XGetWindowAttributes (priv->screen->display ()->dpy (), priv->id, &attrib))
{
xev.x = attrib.x;
xev.y = attrib.y;
@@ -2394,164 +1480,155 @@ sendConfigureNotify (CompWindow *w)
xev.height = attrib.height;
xev.border_width = attrib.border_width;
- xev.above = (w->prev) ? w->prev->id : None;
+ xev.above = (prev) ? prev->priv->id : None;
xev.override_redirect = TRUE;
- XSendEvent (w->screen->display->display, w->id, FALSE,
+ XSendEvent (priv->screen->display ()->dpy (), priv->id, FALSE,
StructureNotifyMask, (XEvent *) &xev);
}
- XUngrabServer (w->screen->display->display);
+ XUngrabServer (priv->screen->display ()->dpy ());
}
else
{
- xev.x = w->serverX;
- xev.y = w->serverY;
- xev.width = w->serverWidth;
- xev.height = w->serverHeight;
- xev.border_width = w->serverBorderWidth;
+ xev.x = priv->serverX;
+ xev.y = priv->serverY;
+ xev.width = priv->serverWidth;
+ xev.height = priv->serverHeight;
+ xev.border_width = priv->serverBorderWidth;
- xev.above = (w->prev) ? w->prev->id : None;
- xev.override_redirect = w->attrib.override_redirect;
+ xev.above = (prev) ? prev->priv->id : None;
+ xev.override_redirect = priv->attrib.override_redirect;
- XSendEvent (w->screen->display->display, w->id, FALSE,
+ XSendEvent (priv->screen->display ()->dpy (), priv->id, FALSE,
StructureNotifyMask, (XEvent *) &xev);
}
}
void
-mapWindow (CompWindow *w)
+CompWindow::map ()
{
- if (w->attrib.map_state == IsViewable)
+ if (priv->attrib.map_state == IsViewable)
return;
- w->pendingMaps--;
+ priv->pendingMaps--;
- w->mapNum = w->screen->mapNum++;
+ priv->mapNum = priv->screen->mapNum ()++;
- if (w->struts)
- updateWorkareaForScreen (w->screen);
+ if (priv->struts)
+ priv->screen->updateWorkarea ();
- if (w->attrib.c_class == InputOnly)
+ if (priv->attrib.c_class == InputOnly)
return;
- w->unmapRefCnt = 1;
+ priv->unmapRefCnt = 1;
- w->attrib.map_state = IsViewable;
+ priv->attrib.map_state = IsViewable;
- if (!w->attrib.override_redirect)
- setWmState (w->screen->display, NormalState, w->id);
+ if (!priv->attrib.override_redirect)
+ priv->screen->display ()->setWmState (NormalState, priv->id);
- w->invisible = TRUE;
- w->damaged = FALSE;
- w->alive = TRUE;
- w->bindFailed = FALSE;
+ priv->invisible = true;
+ priv->damaged = false;
+ priv->alive = true;
+ priv->bindFailed = false;
- w->lastPong = w->screen->display->lastPing;
+ priv->lastPong = priv->screen->display ()->lastPing ();
- updateWindowRegion (w);
- updateWindowSize (w);
+ updateRegion ();
+ updateSize ();
- if (w->frame)
- XMapWindow (w->screen->display->display, w->frame);
+ if (priv->frame)
+ XMapWindow (priv->screen->display ()->dpy (), priv->frame);
- updateClientListForScreen (w->screen);
+ priv->screen->updateClientList ();
- if (w->type & CompWindowTypeDesktopMask)
- w->screen->desktopWindowCount++;
+ if (priv->type & CompWindowTypeDesktopMask)
+ priv->screen->desktopWindowCount ()++;
- if (w->protocols & CompWindowProtocolSyncRequestMask)
+ if (priv->protocols & CompWindowProtocolSyncRequestMask)
{
- sendSyncRequest (w);
- sendConfigureNotify (w);
+ sendSyncRequest ();
+ sendConfigureNotify ();
}
- if (!w->attrib.override_redirect)
+ if (!priv->attrib.override_redirect)
{
/* been shaded */
- if (!w->height)
- resizeWindow (w,
- w->attrib.x, w->attrib.y,
- w->attrib.width, ++w->attrib.height - 1,
- w->attrib.border_width);
+ if (!priv->height)
+ resize (priv->attrib.x, priv->attrib.y, priv->attrib.width,
+ ++priv->attrib.height - 1, priv->attrib.border_width);
}
}
void
-unmapWindow (CompWindow *w)
+CompWindow::unmap ()
{
- if (w->mapNum)
+ if (priv->mapNum)
{
- if (w->frame && !w->shaded)
- XUnmapWindow (w->screen->display->display, w->frame);
+ if (priv->frame && !priv->shaded)
+ XUnmapWindow (priv->screen->display ()->dpy (), priv->frame);
- w->mapNum = 0;
+ priv->mapNum = 0;
}
- w->unmapRefCnt--;
- if (w->unmapRefCnt > 0)
+ priv->unmapRefCnt--;
+ if (priv->unmapRefCnt > 0)
return;
- if (w->struts)
- updateWorkareaForScreen (w->screen);
+ if (priv->struts)
+ priv->screen->updateWorkarea ();
- if (w->attrib.map_state != IsViewable)
+ if (priv->attrib.map_state != IsViewable)
return;
- if (w->type == CompWindowTypeDesktopMask)
- w->screen->desktopWindowCount--;
+ if (priv->type == CompWindowTypeDesktopMask)
+ priv->screen->desktopWindowCount ()--;
- addWindowDamage (w);
+ addDamage ();
- w->attrib.map_state = IsUnmapped;
+ priv->attrib.map_state = IsUnmapped;
- w->invisible = TRUE;
+ priv->invisible = true;
- releaseWindow (w);
+ release ();
- if (w->shaded && w->height)
- resizeWindow (w,
- w->attrib.x, w->attrib.y,
- w->attrib.width, ++w->attrib.height - 1,
- w->attrib.border_width);
+ if (priv->shaded && priv->height)
+ resize (priv->attrib.x, priv->attrib.y,
+ priv->attrib.width, ++priv->attrib.height - 1,
+ priv->attrib.border_width);
- updateClientListForScreen (w->screen);
+ priv->screen->updateClientList ();
- if (!w->redirected)
- redirectWindow (w);
+ if (!priv->redirected)
+ redirect ();
}
-static int
-restackWindow (CompWindow *w,
- Window aboveId)
+bool
+PrivateWindow::restack (Window aboveId)
{
- if (w->prev)
+ if (window->prev)
{
- if (aboveId && aboveId == w->prev->id)
- return 0;
+ if (aboveId && aboveId == window->prev->id ())
+ return false;
}
- else if (aboveId == None && !w->next)
- return 0;
+ else if (aboveId == None && !window->next)
+ return false;
- unhookWindowFromScreen (w->screen, w);
- insertWindowIntoScreen (w->screen, w, aboveId);
+ screen->unhookWindow (window);
+ screen->insertWindow (window, aboveId);
- updateClientListForScreen (w->screen);
+ screen->updateClientList ();
- return 1;
+ return true;
}
-Bool
-resizeWindow (CompWindow *w,
- int x,
- int y,
- int width,
- int height,
- int borderWidth)
+bool
+CompWindow::resize (int x,int y, int width, int height, int borderWidth)
{
- if (w->attrib.width != width ||
- w->attrib.height != height ||
- w->attrib.border_width != borderWidth)
+ if (priv->attrib.width != width ||
+ priv->attrib.height != height ||
+ priv->attrib.border_width != borderWidth)
{
unsigned int pw, ph, actualWidth, actualHeight, ui;
int dx, dy, dwidth, dheight;
@@ -2563,73 +1640,73 @@ resizeWindow (CompWindow *w,
pw = width + borderWidth * 2;
ph = height + borderWidth * 2;
- if (w->mapNum && w->redirected)
+ if (priv->mapNum && priv->redirected)
{
- pixmap = XCompositeNameWindowPixmap (w->screen->display->display,
- w->id);
- result = XGetGeometry (w->screen->display->display, pixmap, &root,
+ 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 (w->screen->display->display, pixmap);
+ XFreePixmap (priv->screen->display ()->dpy (), pixmap);
- return FALSE;
+ return false;
}
}
- else if (w->shaded)
+ else if (priv->shaded)
{
ph = 0;
}
- addWindowDamage (w);
+ addDamage ();
- dx = x - w->attrib.x;
- dy = y - w->attrib.y;
- dwidth = width - w->attrib.width;
- dheight = height - w->attrib.height;
+ dx = x - priv->attrib.x;
+ dy = y - priv->attrib.y;
+ dwidth = width - priv->attrib.width;
+ dheight = height - priv->attrib.height;
- w->attrib.x = x;
- w->attrib.y = y;
- w->attrib.width = width;
- w->attrib.height = height;
- w->attrib.border_width = borderWidth;
+ priv->attrib.x = x;
+ priv->attrib.y = y;
+ priv->attrib.width = width;
+ priv->attrib.height = height;
+ priv->attrib.border_width = borderWidth;
- w->width = pw;
- w->height = ph;
+ priv->width = pw;
+ priv->height = ph;
- releaseWindow (w);
+ release ();
- w->pixmap = pixmap;
+ priv->pixmap = pixmap;
- if (w->mapNum)
- updateWindowRegion (w);
+ if (priv->mapNum)
+ updateRegion ();
- (*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight);
+ resizeNotify (dx, dy, dwidth, dheight);
- addWindowDamage (w);
+ addDamage ();
- w->invisible = WINDOW_INVISIBLE (w);
+ priv->invisible = WINDOW_INVISIBLE (priv);
- updateFrameWindow (w);
+ priv->updateFrameWindow ();
}
- else if (w->attrib.x != x || w->attrib.y != y)
+ else if (priv->attrib.x != x || priv->attrib.y != y)
{
int dx, dy;
- dx = x - w->attrib.x;
- dy = y - w->attrib.y;
+ dx = x - priv->attrib.x;
+ dy = y - priv->attrib.y;
- moveWindow (w, dx, dy, TRUE, TRUE);
+ move (dx, dy, true, true);
- if (w->frame)
- XMoveWindow (w->screen->display->display, w->frame,
- w->attrib.x - w->input.left,
- w->attrib.y - w->input.top);
+ if (priv->frame)
+ XMoveWindow (priv->screen->display ()->dpy (), priv->frame,
+ priv->attrib.x - priv->input.left,
+ priv->attrib.y - priv->input.top);
}
- return TRUE;
+ return true;
}
static void
@@ -2642,8 +1719,8 @@ syncValueIncrement (XSyncValue *value)
XSyncValueAdd (value, *value, one, &overflow);
}
-static Bool
-initializeSyncCounter (CompWindow *w)
+bool
+PrivateWindow::initializeSyncCounter ()
{
XSyncAlarmAttributes values;
Atom actual;
@@ -2651,14 +1728,14 @@ initializeSyncCounter (CompWindow *w)
unsigned long n, left;
unsigned char *data;
- if (w->syncCounter)
- return w->syncAlarm != None;
+ if (syncCounter)
+ return syncAlarm != None;
- if (!(w->protocols & CompWindowProtocolSyncRequestMask))
- return FALSE;
+ if (!(protocols & CompWindowProtocolSyncRequestMask))
+ return false;
- result = XGetWindowProperty (w->screen->display->display, w->id,
- w->screen->display->wmSyncRequestCounterAtom,
+ result = XGetWindowProperty (screen->display ()->dpy (), id,
+ screen->display ()->atoms ().wmSyncRequestCounter,
0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &data);
@@ -2666,21 +1743,21 @@ initializeSyncCounter (CompWindow *w)
{
unsigned long *counter = (unsigned long *) data;
- w->syncCounter = *counter;
+ syncCounter = *counter;
XFree (data);
- XSyncIntsToValue (&w->syncValue, (unsigned int) rand (), 0);
- XSyncSetCounter (w->screen->display->display,
- w->syncCounter,
- w->syncValue);
+ XSyncIntsToValue (&syncValue, (unsigned int) rand (), 0);
+ XSyncSetCounter (screen->display ()->dpy (),
+ syncCounter,
+ syncValue);
- syncValueIncrement (&w->syncValue);
+ syncValueIncrement (&syncValue);
values.events = TRUE;
- values.trigger.counter = w->syncCounter;
- values.trigger.wait_value = w->syncValue;
+ values.trigger.counter = syncCounter;
+ values.trigger.wait_value = syncValue;
values.trigger.value_type = XSyncAbsolute;
values.trigger.test_type = XSyncPositiveComparison;
@@ -2689,286 +1766,272 @@ initializeSyncCounter (CompWindow *w)
values.events = TRUE;
- compCheckForError (w->screen->display->display);
+ compCheckForError (screen->display ()->dpy ());
/* Note that by default, the alarm increments the trigger value
* when it fires until the condition (counter.value < trigger.value)
* is FALSE again.
*/
- w->syncAlarm = XSyncCreateAlarm (w->screen->display->display,
- XSyncCACounter |
- XSyncCAValue |
- XSyncCAValueType |
- XSyncCATestType |
- XSyncCADelta |
- XSyncCAEvents,
- &values);
+ syncAlarm = XSyncCreateAlarm (screen->display ()->dpy (),
+ XSyncCACounter |
+ XSyncCAValue |
+ XSyncCAValueType |
+ XSyncCATestType |
+ XSyncCADelta |
+ XSyncCAEvents,
+ &values);
- if (!compCheckForError (w->screen->display->display))
- return TRUE;
+ if (!compCheckForError (screen->display ()->dpy ()))
+ return true;
- XSyncDestroyAlarm (w->screen->display->display, w->syncAlarm);
- w->syncAlarm = None;
+ XSyncDestroyAlarm (screen->display ()->dpy (), syncAlarm);
+ syncAlarm = None;
}
- return FALSE;
+ return false;
}
-static Bool
+static bool
syncWaitTimeout (void *closure)
{
CompWindow *w = (CompWindow *) closure;
- w->syncWaitHandle = 0;
- handleSyncAlarm (w);
-
- return FALSE;
+ return w->handleSyncAlarm ();
}
void
-sendSyncRequest (CompWindow *w)
+CompWindow::sendSyncRequest ()
{
XClientMessageEvent xev;
- if (w->syncWait)
+ if (priv->syncWait)
return;
- if (!initializeSyncCounter (w))
+ if (!priv->initializeSyncCounter ())
return;
xev.type = ClientMessage;
- xev.window = w->id;
- xev.message_type = w->screen->display->wmProtocolsAtom;
+ xev.window = priv->id;
+ xev.message_type = priv->screen->display ()->atoms ().wmProtocols;
xev.format = 32;
- xev.data.l[0] = w->screen->display->wmSyncRequestAtom;
+ xev.data.l[0] = priv->screen->display ()->atoms ().wmSyncRequest;
xev.data.l[1] = CurrentTime;
- xev.data.l[2] = XSyncValueLow32 (w->syncValue);
- xev.data.l[3] = XSyncValueHigh32 (w->syncValue);
+ xev.data.l[2] = XSyncValueLow32 (priv->syncValue);
+ xev.data.l[3] = XSyncValueHigh32 (priv->syncValue);
xev.data.l[4] = 0;
- syncValueIncrement (&w->syncValue);
+ syncValueIncrement (&priv->syncValue);
- XSendEvent (w->screen->display->display, w->id, FALSE, 0, (XEvent *) &xev);
+ XSendEvent (priv->screen->display ()->dpy (), priv->id, FALSE, 0,
+ (XEvent *) &xev);
- w->syncWait = TRUE;
- w->syncX = w->serverX;
- w->syncY = w->serverY;
- w->syncWidth = w->serverWidth;
- w->syncHeight = w->serverHeight;
- w->syncBorderWidth = w->serverBorderWidth;
+ priv->syncWait = TRUE;
+ priv->syncX = priv->serverX;
+ priv->syncY = priv->serverY;
+ priv->syncWidth = priv->serverWidth;
+ priv->syncHeight = priv->serverHeight;
+ priv->syncBorderWidth = priv->serverBorderWidth;
- if (!w->syncWaitHandle)
- w->syncWaitHandle = compAddTimeout (1000, 1200, syncWaitTimeout, w);
+ if (!priv->syncWaitHandle)
+ priv->syncWaitHandle =
+ core->addTimeout (1000, 1200, syncWaitTimeout, this);
}
void
-configureWindow (CompWindow *w,
- XConfigureEvent *ce)
+CompWindow::configure (XConfigureEvent *ce)
{
- if (w->syncWait)
+ if (priv->syncWait)
{
- w->syncX = ce->x;
- w->syncY = ce->y;
- w->syncWidth = ce->width;
- w->syncHeight = ce->height;
- w->syncBorderWidth = ce->border_width;
+ priv->syncX = ce->x;
+ priv->syncY = ce->y;
+ priv->syncWidth = ce->width;
+ priv->syncHeight = ce->height;
+ priv->syncBorderWidth = ce->border_width;
}
else
{
if (ce->override_redirect)
{
- w->serverX = ce->x;
- w->serverY = ce->y;
- w->serverWidth = ce->width;
- w->serverHeight = ce->height;
- w->serverBorderWidth = ce->border_width;
+ priv->serverX = ce->x;
+ priv->serverY = ce->y;
+ priv->serverWidth = ce->width;
+ priv->serverHeight = ce->height;
+ priv->serverBorderWidth = ce->border_width;
}
- resizeWindow (w, ce->x, ce->y, ce->width, ce->height,
- ce->border_width);
+ resize (ce->x, ce->y, ce->width, ce->height, ce->border_width);
}
- w->attrib.override_redirect = ce->override_redirect;
+ priv->attrib.override_redirect = ce->override_redirect;
- if (restackWindow (w, ce->above))
- addWindowDamage (w);
+ if (priv->restack (ce->above))
+ addDamage ();
}
void
-circulateWindow (CompWindow *w,
- XCirculateEvent *ce)
+CompWindow::circulate (XCirculateEvent *ce)
{
Window newAboveId;
if (ce->place == PlaceOnTop)
- newAboveId = getTopWindow (w->screen);
+ newAboveId = priv->screen->getTopWindow ();
else
newAboveId = 0;
- if (restackWindow (w, newAboveId))
- addWindowDamage (w);
+ if (priv->restack (newAboveId))
+ addDamage ();
}
void
-moveWindow (CompWindow *w,
- int dx,
- int dy,
- Bool damage,
- Bool immediate)
+CompWindow::move (int dx, int dy, Bool damage, Bool immediate)
{
if (dx || dy)
{
if (damage)
- addWindowDamage (w);
+ addDamage ();
- w->attrib.x += dx;
- w->attrib.y += dy;
+ priv->attrib.x += dx;
+ priv->attrib.y += dy;
- XOffsetRegion (w->region, dx, dy);
+ XOffsetRegion (priv->region, dx, dy);
- setWindowMatrix (w);
+ priv->setWindowMatrix ();
- w->invisible = WINDOW_INVISIBLE (w);
+ priv->invisible = WINDOW_INVISIBLE (priv);
- (*w->screen->windowMoveNotify) (w, dx, dy, immediate);
+ moveNotify (dx, dy, immediate);
if (damage)
- addWindowDamage (w);
+ addDamage ();
}
}
void
-syncWindowPosition (CompWindow *w)
+CompWindow::syncPosition ()
{
- w->serverX = w->attrib.x;
- w->serverY = w->attrib.y;
+ priv->serverX = priv->attrib.x;
+ priv->serverY = priv->attrib.y;
- XMoveWindow (w->screen->display->display, w->id, w->attrib.x, w->attrib.y);
+ XMoveWindow (priv->screen->display ()->dpy (), priv->id, priv->attrib.x, priv->attrib.y);
- if (w->frame)
- XMoveWindow (w->screen->display->display, w->frame,
- w->serverX - w->input.left,
- w->serverY - w->input.top);
+ if (priv->frame)
+ XMoveWindow (priv->screen->display ()->dpy (), priv->frame,
+ priv->serverX - priv->input.left,
+ priv->serverY - priv->input.top);
}
-Bool
-focusWindow (CompWindow *w)
+bool
+CompWindow::focus ()
{
- if (w->attrib.override_redirect)
- return FALSE;
+ WRAPABLE_HND_FUNC_RETURN(bool, focus)
- if (!w->managed)
- return FALSE;
+ if (priv->attrib.override_redirect)
+ return false;
- if (!onCurrentDesktop (w))
- return FALSE;
+ if (!priv->managed)
+ return false;
- if (!w->shaded && (w->state & CompWindowStateHiddenMask))
- return FALSE;
+ if (!onCurrentDesktop ())
+ return false;
- if (w->attrib.x + w->width <= 0 ||<