summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-02-26 22:25:29 +0100
committerDanny Baumann <dannybaumann@web.de>2009-02-26 22:25:29 +0100
commit49a9447c12edc4894d90286547a35d689fc614ad (patch)
treef4a1928dbc5e897cb20daa28b1795d11a69dfa40 /src
parentbbca80e1bcb157eb82f74e338ab83019375659e5 (diff)
downloadmobileperf-49a9447c12edc4894d90286547a35d689fc614ad.tar.gz
mobileperf-49a9447c12edc4894d90286547a35d689fc614ad.tar.bz2
Coding style, optimizations.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp16
-rw-r--r--src/privates.cpp39
-rw-r--r--src/privatewindow.h7
-rw-r--r--src/screen.cpp247
-rw-r--r--src/window.cpp402
-rw-r--r--src/windowgeometry.cpp21
6 files changed, 364 insertions, 368 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 22b6cca..8554ac1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -55,7 +55,6 @@ bool indirectRendering = false;
bool noDetection = false;
bool useDesktopHints = false;
bool debugOutput = false;
-
bool useCow = true;
CompMetadata *coreMetadata = NULL;
@@ -82,7 +81,6 @@ usage (void)
programName);
}
-
static void
signalHandler (int sig)
{
@@ -93,11 +91,11 @@ signalHandler (int sig)
waitpid (-1, &status, WNOHANG | WUNTRACED);
break;
case SIGHUP:
- restartSignal = TRUE;
+ restartSignal = true;
break;
case SIGINT:
case SIGTERM:
- shutDown = TRUE;
+ shutDown = true;
default:
break;
}
@@ -192,7 +190,7 @@ main (int argc, char **argv)
}
else if (!strcmp (argv[i], "--indirect-rendering"))
{
- indirectRendering = TRUE;
+ indirectRendering = true;
}
else if (!strcmp (argv[i], "--keep-desktop-hints"))
{
@@ -204,15 +202,15 @@ main (int argc, char **argv)
}
else if (!strcmp (argv[i], "--use-root-window"))
{
- useCow = FALSE;
+ useCow = false;
}
else if (!strcmp (argv[i], "--replace"))
{
- replaceCurrentWm = TRUE;
+ replaceCurrentWm = true;
}
else if (!strcmp (argv[i], "--sm-disable"))
{
- disableSm = TRUE;
+ disableSm = true;
}
else if (!strcmp (argv[i], "--sm-client-id"))
{
@@ -221,7 +219,7 @@ main (int argc, char **argv)
}
else if (!strcmp (argv[i], "--no-detection"))
{
- noDetection = TRUE;
+ noDetection = true;
}
else if (!strcmp (argv[i], "--bg-image"))
{
diff --git a/src/privates.cpp b/src/privates.cpp
index 9d5b51c..1d7b6ef 100644
--- a/src/privates.cpp
+++ b/src/privates.cpp
@@ -27,47 +27,48 @@
#include <core/privates.h>
-CompPrivateStorage::CompPrivateStorage (CompPrivateStorage::Indices *iList) :
+CompPrivateStorage::CompPrivateStorage (CompPrivateStorage::Indices& iList) :
privates (0)
{
- if (iList->size() > 0)
- privates.resize (iList->size ());
+ if (iList.size() > 0)
+ privates.resize (iList.size ());
}
int
-CompPrivateStorage::allocatePrivateIndex (CompPrivateStorage::Indices *iList)
+CompPrivateStorage::allocatePrivateIndex (CompPrivateStorage::Indices& iList)
{
- if (!iList)
- return -1;
+ unsigned int i;
- for (unsigned int i = 0; i < iList->size(); i++)
+ for (i = 0; i < iList.size (); i++)
{
- if (!iList->at (i))
+ if (!iList.at (i))
{
- iList->at (i) = true;
+ iList.at (i) = true;
return i;
}
}
- unsigned int i = iList->size ();
- iList->resize (i + 1);
- iList->at (i) = true;
+
+ i = iList.size ();
+ iList.resize (i + 1);
+ iList.at (i) = true;
return i;
}
void
-CompPrivateStorage::freePrivateIndex (CompPrivateStorage::Indices *iList,
- int idx)
+CompPrivateStorage::freePrivateIndex (CompPrivateStorage::Indices& iList,
+ int idx)
{
- if (!iList || idx < 0 || idx >= (int) iList->size())
+ int size = iList.size ();
+
+ if (idx < 0 || idx >= size)
return;
- if (idx < (int) iList->size () - 1)
+ if (idx < size - 1)
{
- iList->at(idx) = false;
+ iList.at (idx) = false;
return;
}
- unsigned int i = iList->size () - 1;
- iList->resize (i);
+ iList.resize (size - 1);
}
diff --git a/src/privatewindow.h b/src/privatewindow.h
index 8bd38f0..e141019 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -117,7 +117,7 @@ class PrivateWindow {
static void unminimizeTransients (CompWindow *w,
CompWindow *ancestor);
- bool getUsageTimestamp (Time *timestamp);
+ bool getUsageTimestamp (Time& timestamp);
bool isWindowFocusAllowed (Time timestamp);
@@ -169,8 +169,7 @@ class PrivateWindow {
void updateSize ();
- bool getUserTime (Time *time);
-
+ bool getUserTime (Time& time);
void setUserTime (Time time);
bool allowWindowFocus (unsigned int noFocusMask,
@@ -238,7 +237,7 @@ class PrivateWindow {
CompPoint initialViewport;
Time initialTimestamp;
- Bool initialTimestampSet;
+ bool initialTimestampSet;
bool fullscreenMonitorsSet;
CompRect fullscreenMonitorRect;
diff --git a/src/screen.cpp b/src/screen.cpp
index a5c7b7f..7d73cd6 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -97,22 +97,23 @@ CompPrivateStorage::Indices screenPrivateIndices (0);
int
CompScreen::allocPrivateIndex ()
{
- int i = CompPrivateStorage::allocatePrivateIndex (&screenPrivateIndices);
+ int i = CompPrivateStorage::allocatePrivateIndex (screenPrivateIndices);
+
if (screenPrivateIndices.size () != screen->privates.size ())
screen->privates.resize (screenPrivateIndices.size ());
+
return i;
}
void
CompScreen::freePrivateIndex (int index)
{
- CompPrivateStorage::freePrivateIndex (&screenPrivateIndices, index);
+ CompPrivateStorage::freePrivateIndex (screenPrivateIndices, index);
+
if (screenPrivateIndices.size () != screen->privates.size ())
screen->privates.resize (screenPrivateIndices.size ());
}
-
-
#define TIMEVALDIFF(tv1, tv2) \
((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
@@ -120,7 +121,6 @@ CompScreen::freePrivateIndex (int index)
((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
(1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
-
void
CompScreen::eventLoop ()
{
@@ -158,10 +158,12 @@ CompScreen::eventLoop ()
time = t->mMaxLeft;
it++;
}
+
if (time < 5)
usleep (time * 1000);
else
priv->doPoll (time);
+
gettimeofday (&tv, 0);
priv->handleTimers (&tv);
}
@@ -300,8 +302,10 @@ CompScreen::removeWatchFd (CompWatchFdHandle handle)
for (it = priv->watchFds.begin(), i = priv->nWatchFds - 1;
it != priv->watchFds.end(); it++, i--)
+ {
if ((*it)->handle == handle)
break;
+ }
if (it == priv->watchFds.end())
return;
@@ -322,7 +326,9 @@ void
CompScreen::storeValue (CompString key, CompPrivate value)
{
std::map<CompString,CompPrivate>::iterator it;
+
it = priv->valueMap.find (key);
+
if (it != priv->valueMap.end ())
{
it->second = value;
@@ -397,8 +403,10 @@ PrivateScreen::doPoll (int timeout)
for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
it++, i--)
+ {
if (watchPollFds[i].revents != 0 && (*it)->callBack)
(*it)->callBack ();
+ }
}
return rv;
@@ -455,8 +463,8 @@ CompScreen::setOptionForPlugin (const char *plugin,
const char *name,
CompOption::Value &value)
{
- WRAPABLE_HND_FUNC_RETURN(4, bool, setOptionForPlugin,
- plugin, name, value)
+ WRAPABLE_HND_FUNC_RETURN (4, bool, setOptionForPlugin,
+ plugin, name, value)
CompPlugin *p = CompPlugin::find (plugin);
if (p)
@@ -467,8 +475,8 @@ CompScreen::setOptionForPlugin (const char *plugin,
void
CompScreen::sessionEvent (CompSession::Event event,
- CompOption::Vector &arguments)
- WRAPABLE_HND_FUNC(5, sessionEvent, event, arguments)
+ CompOption::Vector &arguments)
+ WRAPABLE_HND_FUNC (5, sessionEvent, event, arguments)
void
ScreenInterface::fileWatchAdded (CompFileWatch *watch)
@@ -489,7 +497,7 @@ ScreenInterface::finiPluginForScreen (CompPlugin *plugin)
bool
ScreenInterface::setOptionForPlugin (const char *plugin,
- const char *name,
+ const char *name,
CompOption::Value &value)
WRAPABLE_DEF (setOptionForPlugin, plugin, name, value)
@@ -498,8 +506,6 @@ ScreenInterface::sessionEvent (CompSession::Event event,
CompOption::Vector &arguments)
WRAPABLE_DEF (sessionEvent, event, arguments)
-
-
const CompMetadata::OptionInfo coreOptionInfo[COMP_OPTION_NUM] = {
{ "active_plugins", "list", "<type>string</type>", 0, 0 },
{ "click_to_focus", "bool", 0, 0, 0 },
@@ -619,7 +625,6 @@ CompScreen::dpy ()
return priv->dpy;
}
-
CompOption *
CompScreen::getOption (const char *name)
{
@@ -657,7 +662,6 @@ CompScreen::syncEvent ()
return priv->syncEvent;
}
-
SnDisplay *
CompScreen::snDisplay ()
{
@@ -697,8 +701,6 @@ PrivateScreen::updateScreenInfo ()
}
}
-
-
void
PrivateScreen::setAudibleBell (bool audible)
{
@@ -803,7 +805,8 @@ CompScreen::setOption (const char *name,
if (o->value ().i () * width () > MAXSHORT)
return false;
- priv->setVirtualScreenSize (o->value ().i (), vsize->value ().i ());
+ priv->setVirtualScreenSize (o->value ().i (),
+ vsize->value ().i ());
return true;
}
break;
@@ -820,7 +823,8 @@ CompScreen::setOption (const char *name,
if (o->value ().i () * height () > MAXSHORT)
return false;
- priv->setVirtualScreenSize (hsize->value ().i (), o->value ().i ());
+ priv->setVirtualScreenSize (hsize->value ().i (),
+ o->value ().i ());
return true;
}
break;
@@ -865,38 +869,36 @@ PrivateScreen::updateModifierMappings ()
for (i = 0; i < CompModNum; i++)
modMask[i] = 0;
- XDisplayKeycodes (this->dpy, &minKeycode, &maxKeycode);
- key = XGetKeyboardMapping (this->dpy,
- minKeycode, (maxKeycode - minKeycode + 1),
+ XDisplayKeycodes (dpy, &minKeycode, &maxKeycode);
+ key = XGetKeyboardMapping (dpy, minKeycode, maxKeycode - minKeycode + 1,
&keysymsPerKeycode);
- if (this->modMap)
- XFreeModifiermap (this->modMap);
+ if (modMap)
+ XFreeModifiermap (modMap);
- this->modMap = XGetModifierMapping (this->dpy);
- if (this->modMap && this->modMap->max_keypermod > 0)
+ modMap = XGetModifierMapping (dpy);
+ if (modMap && modMap->max_keypermod > 0)
{
KeySym keysym;
int index, size, mask;
- size = maskTableSize * this->modMap->max_keypermod;
+ size = maskTableSize * modMap->max_keypermod;
for (i = 0; i < size; i++)
{
- if (!this->modMap->modifiermap[i])
+ if (!modMap->modifiermap[i])
continue;
index = 0;
do
{
- keysym = XKeycodeToKeysym (this->dpy,
- this->modMap->modifiermap[i],
+ keysym = XKeycodeToKeysym (dpy, modMap->modifiermap[i],
index++);
} while (!keysym && index < keysymsPerKeycode);
if (keysym)
{
- mask = maskTable[i / this->modMap->max_keypermod];
+ mask = maskTable[i / modMap->max_keypermod];
if (keysym == XK_Alt_L ||
keysym == XK_Alt_R)
@@ -943,11 +945,11 @@ PrivateScreen::updateModifierMappings ()
{
memcpy (this->modMask, modMask, sizeof (modMask));
- this->ignoredModMask = LockMask |
+ ignoredModMask = LockMask |
(modMask[CompModNumLock] & ~CompNoMask) |
(modMask[CompModScrollLock] & ~CompNoMask);
- this->updatePassiveKeyGrabs ();
+ updatePassiveKeyGrabs ();
}
}
@@ -1139,11 +1141,11 @@ PrivateScreen::updatePlugins ()
/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
static bool
-convertProperty (Display *dpy,
- Time time,
- Window w,
- Atom target,
- Atom property)
+convertProperty (Display *dpy,
+ Time time,
+ Window w,
+ Atom target,
+ Atom property)
{
#define N_TARGETS 4
@@ -1268,7 +1270,6 @@ PrivateScreen::handleSelectionClear (XEvent *event)
shutDown = TRUE;
}
-
#define HOME_IMAGEDIR ".compiz/images"
bool
@@ -1338,14 +1339,13 @@ PrivateScreen::getActiveWindow (Window root)
return w;
}
-
bool
CompScreen::fileToImage (CompString &name,
CompSize &size,
int &stride,
void *&data)
{
- WRAPABLE_HND_FUNC_RETURN(8, bool, fileToImage, name, size, stride, data);
+ WRAPABLE_HND_FUNC_RETURN (8, bool, fileToImage, name, size, stride, data);
return false;
}
@@ -1356,8 +1356,8 @@ CompScreen::imageToFile (CompString &path,
int stride,
void *data)
{
- WRAPABLE_HND_FUNC_RETURN(9, bool, imageToFile, path, format, size,
- stride, data)
+ WRAPABLE_HND_FUNC_RETURN (9, bool, imageToFile, path, format, size,
+ stride, data)
return false;
}
@@ -1405,7 +1405,7 @@ CompScreen::logMessage (const char *componentName,
}
void
-compLogMessage (const char *componentName,
+compLogMessage (const char *componentName,
CompLogLevel level,
const char *format,
...)
@@ -1961,14 +1961,12 @@ PrivateScreen::setVirtualScreenSize (int newh, int newv)
void
PrivateScreen::updateOutputDevices ()
{
- CompOption::Value::Vector &list =
- opt[COMP_OPTION_OUTPUTS].value ().list ();
-
- unsigned int nOutput = 0;
- int x, y, bits;
- unsigned int width, height;
- int x1, y1, x2, y2;
- char str[10];
+ CompOption::Value::Vector &list = opt[COMP_OPTION_OUTPUTS].value ().list ();
+ unsigned int nOutput = 0;
+ int x, y, bits;
+ unsigned int width, height;
+ int x1, y1, x2, y2;
+ char str[10];
foreach (CompOption::Value &value, list)
{
@@ -2138,9 +2136,7 @@ PrivateScreen::addSequence (SnStartupSequence *sequence)
startupSequences.push_front (s);
if (!startupSequenceTimer.active ())
- startupSequenceTimer.start (
- boost::bind (&PrivateScreen::handleStartupSequenceTimeout, this),
- 1000, 1500);
+ startupSequenceTimer.start ();
updateStartupFeedback ();
}
@@ -2188,7 +2184,7 @@ CompScreen::compScreenSnEvent (SnMonitorEvent *event,
screen->priv->addSequence (sequence);
break;
case SN_MONITOR_EVENT_COMPLETED:
- screen->priv->removeSequence (sn_monitor_event_get_startup_sequence (event));
+ screen->priv->removeSequence (sequence);
break;
case SN_MONITOR_EVENT_CHANGED:
case SN_MONITOR_EVENT_CANCELED:
@@ -2220,14 +2216,17 @@ PrivateScreen::updateScreenEdges ()
{
if (screenEdge[i].id)
XMoveResizeWindow (dpy, screenEdge[i].id,
- geometry[i].xw * screen->width () + geometry[i].x0,
- geometry[i].yh * screen->height () + geometry[i].y0,
- geometry[i].ww * screen->width () + geometry[i].w0,
- geometry[i].hh * screen->height () + geometry[i].h0);
+ geometry[i].xw * screen->width () +
+ geometry[i].x0,
+ geometry[i].yh * screen->height () +
+ geometry[i].y0,
+ geometry[i].ww * screen->width () +
+ geometry[i].w0,
+ geometry[i].hh * screen->height () +
+ geometry[i].h0);
}
}
-
void
PrivateScreen::setCurrentOutput (unsigned int outputNum)
{
@@ -2268,8 +2267,6 @@ PrivateScreen::configure (XConfigureEvent *ce)
}
}
-
-
void
PrivateScreen::setSupportingWmCheck ()
{
@@ -2747,8 +2744,11 @@ CompScreen::insertWindow (CompWindow *w, Window aboveId)
while (it != priv->windows.end ())
{
- if ((*it)->id () == aboveId || ((*it)->frame () && (*it)->frame () == aboveId))
+ if ((*it)->id () == aboveId ||
+ ((*it)->frame () && (*it)->frame () == aboveId))
+ {
break;
+ }
it++;
}
@@ -2892,12 +2892,12 @@ CompScreen::removeGrab (CompScreen::GrabHandle handle,
}
else
{
- if (restorePointer)
- warpPointer (restorePointer->x () - pointerX,
- restorePointer->y () - pointerY);
+ if (restorePointer)
+ warpPointer (restorePointer->x () - pointerX,
+ restorePointer->y () - pointerY);
- XUngrabPointer (priv->dpy, CurrentTime);
- XUngrabKeyboard (priv->dpy, CurrentTime);
+ XUngrabPointer (priv->dpy, CurrentTime);
+ XUngrabKeyboard (priv->dpy, CurrentTime);
}
}
@@ -3726,7 +3726,6 @@ CompScreen::sendWindowActivationRequest (Window id)
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
-
void
PrivateScreen::enableEdge (int edge)
{
@@ -3842,8 +3841,6 @@ CompScreen::getWorkareaForOutput (int output, XRectangle *area)
*area = priv->outputDevs[output].workArea ();
}
-
-
void
CompScreen::outputChangeNotify ()
WRAPABLE_HND_FUNC(16, outputChangeNotify)
@@ -3857,8 +3854,7 @@ CompScreen::outputChangeNotify ()
located. */
void
CompScreen::viewportForGeometry (CompWindow::Geometry gm,
- int *viewportX,
- int *viewportY)
+ CompPoint& viewport)
{
int centerX;
int centerY;
@@ -3866,40 +3862,34 @@ CompScreen::viewportForGeometry (CompWindow::Geometry gm,
gm.setWidth (gm.width () + (gm.border () * 2));
gm.setHeight (gm.height () + (gm.border () * 2));
- if (viewportX)
- {
- centerX = gm.x () + (gm.width () >> 1);
- if (centerX < 0)
- *viewportX = priv->vp.x () + ((centerX / width ()) - 1) %
- priv->vpSize.width ();
- else
- *viewportX = priv->vp.x () + (centerX / width ()) %
- priv->vpSize.width ();
- }
+ centerX = gm.x () + (gm.width () >> 1);
+ if (centerX < 0)
+ viewport.setX (priv->vp.x () + ((centerX / width ()) - 1) %
+ priv->vpSize.width ());
+ else
+ viewport.setX (priv->vp.x () + (centerX / width ()) %
+ priv->vpSize.width ());
- if (viewportY)
- {
- centerY = gm.y () + (gm.height () >> 1);
- if (centerY < 0)
- *viewportY = priv->vp.y () +
- ((centerY / height ()) - 1) % priv->vpSize.height ();
- else
- *viewportY = priv->vp.y () + (centerY / height ()) %
- priv->vpSize.height ();
- }
+ centerY = gm.y () + (gm.height () >> 1);
+ if (centerY < 0)
+ viewport.setY (priv->vp.y () +
+ ((centerY / height ()) - 1) % priv->vpSize.height ());
+ else
+ viewport.setY (priv->vp.y () + (centerY / height ()) %
+ priv->vpSize.height ());
}
static int
-rectangleOverlapArea (BOX *rect1,
- BOX *rect2)
+rectangleOverlapArea (BOX& rect1,
+ BOX& rect2)
{
int left, right, top, bottom;
/* extents of overlapping rectangle */
- left = MAX (rect1->x1, rect2->x1);
- right = MIN (rect1->x2, rect2->x2);
- top = MAX (rect1->y1, rect2->y1);
- bottom = MIN (rect1->y2, rect2->y2);
+ left = MAX (rect1.x1, rect2.x1);
+ right = MIN (rect1.x2, rect2.x2);
+ top = MAX (rect1.y1, rect2.y1);
+ bottom = MIN (rect1.y2, rect2.y2);
if (left > right || top > bottom)
{
@@ -3968,16 +3958,19 @@ CompScreen::outputDeviceForGeometry (CompWindow::Geometry gm)
/* get amount of overlap on all output devices */
for (i = 0; i < priv->outputDevs.size (); i++)
overlapAreas[i] =
- rectangleOverlapArea (&priv->outputDevs[i].region ()->extents,
- &geomRect);
+ rectangleOverlapArea (priv->outputDevs[i].region ()->extents,
+ geomRect);
/* find output with largest overlap */
- for (i = 0, highest = 0, highestScore = 0; i < priv->outputDevs.size (); i++)
+ for (i = 0, highest = 0, highestScore = 0;
+ i < priv->outputDevs.size (); i++)
+ {
if (overlapAreas[i] > highestScore)
{
highest = i;
highestScore = overlapAreas[i];
}
+ }
/* look if the highest score is unique */
for (i = 0, seen = 0; i < priv->outputDevs.size (); i++)
@@ -4128,7 +4121,8 @@ CompScreen::xkbEvent ()
}
void
-CompScreen::warpPointer (int dx, int dy)
+CompScreen::warpPointer (int dx,
+ int dy)
{
XEvent event;
@@ -4240,7 +4234,6 @@ CompScreen::workArea ()
return priv->workArea;
}
-
unsigned int
CompScreen::currentDesktop ()
{
@@ -4309,7 +4302,7 @@ CompScreen::screenInfo ()
}
CompScreen::CompScreen ():
- CompPrivateStorage (&screenPrivateIndices)
+ CompPrivateStorage (screenPrivateIndices)
{
priv = new PrivateScreen (this);
assert (priv);
@@ -4432,22 +4425,10 @@ CompScreen::init (const char *name)
&priv->xineramaEvent,
&priv->xineramaError);
-
priv->updateScreenInfo();
- priv->escapeKeyCode =
- XKeysymToKeycode (dpy, XStringToKeysym ("Escape"));
- priv->returnKeyCode =
- XKeysymToKeycode (dpy, XStringToKeysym ("Return"));
-
-
-
-
-
-
-
-
-
+ priv->escapeKeyCode = XKeysymToKeycode (dpy, XStringToKeysym ("Escape"));
+ priv->returnKeyCode = XKeysymToKeycode (dpy, XStringToKeysym ("Return"));
sprintf (buf, "WM_S%d", DefaultScreen (dpy));
wmSnAtom = XInternAtom (dpy, buf, 0);
@@ -4667,9 +4648,11 @@ CompScreen::init (const char *name)
{
long xdndVersion = 3;
- priv->screenEdge[i].id = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
+ priv->screenEdge[i].id = XCreateWindow (dpy, priv->root,
+ -100, -100, 1, 1, 0,
CopyFromParent, InputOnly,
- CopyFromParent, CWOverrideRedirect,
+ CopyFromParent,
+ CWOverrideRedirect,
&attrib);
XChangeProperty (dpy, priv->screenEdge[i].id, Atoms::xdndAware,
@@ -4697,15 +4680,13 @@ CompScreen::init (const char *name)
XUngrabServer (dpy);
- priv->setAudibleBell (
- priv->opt[COMP_OPTION_AUDIBLE_BELL].value ().b ());
+ priv->setAudibleBell (priv->opt[COMP_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, priv->root,
- RevertToPointerRoot, CurrentTime);
+ XSetInputFocus (dpy, priv->root, RevertToPointerRoot, CurrentTime);
if (focus == None || focus == PointerRoot)
{
@@ -4717,17 +4698,12 @@ CompScreen::init (const char *name)
w = findWindow (focus);
if (w)
- {
w->moveInputFocusTo ();
- }
else
focusDefaultWindow ();
}
- priv->pingTimer.start (
- boost::bind(&PrivateScreen::handlePingTimeout, priv),
- priv->opt[COMP_OPTION_PING_DELAY].value ().i (),
- priv->opt[COMP_OPTION_PING_DELAY].value ().i () + 500);
+ priv->pingTimer.start ();
priv->initialized = true;
priv->addScreenActions ();
@@ -4841,6 +4817,15 @@ PrivateScreen::PrivateScreen (CompScreen *screen) :
modMask[i] = CompNoMask;
memset (history, 0, sizeof (history));
gettimeofday (&lastTimeout, 0);
+
+ pingTimer.setCallback (
+ boost::bind(&PrivateScreen::handlePingTimeout, this));
+ pingTimer.setTimes (opt[COMP_OPTION_PING_DELAY].value ().i (),
+ opt[COMP_OPTION_PING_DELAY].value ().i () + 500);
+
+ startupSequenceTimer.setCallback (
+ boost::bind (&PrivateScreen::handleStartupSequenceTimeout, this));
+ startupSequenceTimer.setTimes (1000, 1500);
}
PrivateScreen::~PrivateScreen ()
diff --git a/src/window.cpp b/src/window.cpp
index 8207fb2..406bdfc 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -46,23 +46,25 @@
#include "privatewindow.h"
#include "privatescreen.h"
-
CompPrivateStorage::Indices windowPrivateIndices (0);
int
CompWindow::allocPrivateIndex ()
{
- int i = CompPrivateStorage::allocatePrivateIndex (&windowPrivateIndices);
- foreach (CompWindow *w, ::screen->windows ())
+ int i = CompPrivateStorage::allocatePrivateIndex (windowPrivateIndices);
+
+ foreach (CompWindow *w, screen->windows ())
if (windowPrivateIndices.size () != w->privates.size ())
w->privates.resize (windowPrivateIndices.size ());
+
return i;
}
void
CompWindow::freePrivateIndex (int index)
{
- CompPrivateStorage::freePrivateIndex (&windowPrivateIndices, index);
+ CompPrivateStorage::freePrivateIndex (windowPrivateIndices, index);
+
foreach (CompWindow *w, ::screen->windows ())
if (windowPrivateIndices.size () != w->privates.size ())
w->privates.resize (windowPrivateIndices.size ());
@@ -91,7 +93,7 @@ PrivateWindow::recalcNormalHints ()
int maxSize;
#warning fixme to max Texture size
- maxSize = MAXSHORT;
+ maxSize = MAXSHORT;
maxSize -= serverGeometry.border () * 2;
sizeHints.x = serverGeometry.x ();
@@ -325,7 +327,7 @@ PrivateWindow::updateIconGeometry ()
priv->iconGeometry.width = geometry[2];
priv->iconGeometry.height = geometry[3];
- priv->iconGeometrySet = TRUE;
+ priv->iconGeometrySet = true;
}
XFree (data);
@@ -628,7 +630,8 @@ void
CompWindow::getAllowedActions (unsigned int &setActions,
unsigned int &clearActions)
{
- WRAPABLE_HND_FUNC(1, getAllowedActions, setActions, clearActions)
+ WRAPABLE_HND_FUNC (1, getAllowedActions, setActions, clearActions)
+
setActions = 0;
clearActions = 0;
}
@@ -714,12 +717,17 @@ CompWindow::recalcType ()
type = CompWindowTypeDialogMask;
}
- if (type == CompWindowTypeDockMask && (priv->state & CompWindowStateBelowMask))
+ if (type == CompWindowTypeDockMask &&
+ (priv->state & CompWindowStateBelowMask))
+ {
type = CompWindowTypeNormalMask;
+ }
if ((type & (CompWindowTypeNormalMask | CompWindowTypeDialogMask)) &&
(priv->state & CompWindowStateModalMask))
+ {
type = CompWindowTypeModalDialogMask;
+ }
priv->type = type;
}
@@ -774,7 +782,7 @@ CompWindow::updateWindowOutputExtents ()
{
CompWindowExtents output;
- getOutputExtents (&output);
+ getOutputExtents (output);
if (output.left != priv->output.left ||
output.right != priv->output.right ||
@@ -788,13 +796,14 @@ CompWindow::updateWindowOutputExtents ()
}
void
-CompWindow::getOutputExtents (CompWindowExtents *output)
+CompWindow::getOutputExtents (CompWindowExtents& output)
{
- WRAPABLE_HND_FUNC(0, getOutputExtents, output)
- output->left = 0;
- output->right = 0;
- output->top = 0;
- output->bottom = 0;
+ WRAPABLE_HND_FUNC (0, getOutputExtents, output)
+
+ output.left = 0;
+ output.right = 0;
+ output.top = 0;
+ output.bottom = 0;
}
void
@@ -870,16 +879,16 @@ PrivateWindow::updateStruts ()
unsigned long n, left;
unsigned char *data;
bool hasOld, hasNew;
- CompStruts old, c_new;
+ CompStruts oldStrut, newStrut;
if (priv->struts)
{
hasOld = true;
- old.left = priv->struts->left;
- old.right = priv->struts->right;
- old.top = priv->struts->top;
- old.bottom = priv->struts->bottom;
+ oldStrut.left = priv->struts->left;
+ oldStrut.right = priv->struts->right;
+ oldStrut.top = priv->struts->top;
+ oldStrut.bottom = priv->struts->bottom;
}
else
{
@@ -888,25 +897,25 @@ PrivateWindow::updateStruts ()
hasNew = true;
- c_new.left.x = 0;
- c_new.left.y = 0;
- c_new.left.width = 0;
- c_new.left.height = screen->height ();
+ newStrut.left.x = 0;
+ newStrut.left.y = 0;
+ newStrut.left.width = 0;
+ newStrut.left.height = screen->height ();
- c_new.right.x = screen->width ();
- c_new.right.y = 0;
- c_new.right.width = 0;
- c_new.right.height = screen->height ();
+ newStrut.right.x = screen->width ();
+ newStrut.right.y = 0;
+ newStrut.right.width = 0;
+ newStrut.right.height = screen->height ();
- c_new.top.x = 0;
- c_new.top.y = 0;
- c_new.top.width = screen->width ();
- c_new.top.height = 0;
+ newStrut.top.x = 0;
+ newStrut.top.y = 0;
+ newStrut.top.width = screen->width ();
+ newStrut.top.height = 0;
- c_new.bottom.x = 0;
- c_new.bottom.y = screen->height ();
- c_new.bottom.width = screen->width ();
- c_new.bottom.height = 0;
+ newStrut.bottom.x = 0;
+ newStrut.bottom.y = screen->height ();
+ newStrut.bottom.width = screen->width ();
+ newStrut.bottom.height = 0;
result = XGetWindowProperty (screen->dpy (), priv->id,
Atoms::wmStrutPartial,
@@ -921,23 +930,23 @@ PrivateWindow::updateStruts ()
{
hasNew = true;
- c_new.left.y = struts[4];
- c_new.left.width = struts[0];
- c_new.left.height = struts[5] - c_new.left.y + 1;
+ newStrut.left.y = struts[4];
+ newStrut.left.width = struts[0];
+ newStrut.left.height = struts[5] - newStrut.left.y + 1;
- c_new.right.width = struts[1];
- c_new.right.x = screen->width () - c_new.right.width;
- c_new.right.y = struts[6];
- c_new.right.height = struts[7] - c_new.right.y + 1;
+ newStrut.right.width = struts[1];
+ newStrut.right.x = screen->width () - newStrut.right.width;
+ newStrut.right.y = struts[6];
+ newStrut.right.height = struts[7] - newStrut.right.y + 1;
- c_new.top.x = struts[8];
- c_new.top.width = struts[9] - c_new.top.x + 1;
- c_new.top.height = struts[2];
+ newStrut.top.x = struts[8];
+ newStrut.top.width = struts[9] - newStrut.top.x + 1;
+ newStrut.top.height = struts[2];
- c_new.bottom.x = struts[10];
- c_new.bottom.width = struts[11] - c_new.bottom.x + 1;
- c_new.bottom.height = struts[3];
- c_new.bottom.y = screen->height () - c_new.bottom.height;
+ newStrut.bottom.x = struts[10];
+ newStrut.bottom.width = struts[11] - newStrut.bottom.x + 1;
+ newStrut.bottom.height = struts[3];
+ newStrut.bottom.y = screen->height () - newStrut.bottom.height;
}
XFree (data);
@@ -958,17 +967,17 @@ PrivateWindow::updateStruts ()
{
hasNew = true;
- c_new.left.x = 0;
- c_new.left.width = struts[0];
+ newStrut.left.x = 0;
+ newStrut.left.width = struts[0];
- c_new.right.width = struts[1];
- c_new.right.x = screen->width () - c_new.right.width;
+ newStrut.right.width = struts[1];
+ newStrut.right.x = screen->width () - newStrut.right.width;
- c_new.top.y = 0;
- c_new.top.height = struts[2];
+ newStrut.top.y = 0;
+ newStrut.top.height = struts[2];
- c_new.bottom.height = struts[3];
- c_new.bottom.y = screen->height () - c_new.bottom.height;
+ newStrut.bottom.height = struts[3];
+ newStrut.bottom.y = screen->height () - newStrut.bottom.height;
}
XFree (data);
@@ -989,58 +998,59 @@ PrivateWindow::updateStruts ()
x2 = x1 + screen->screenInfo ()[i].width;
y2 = y1 + screen->screenInfo ()[i].height;
- strutX1 = c_new.left.x;
- strutX2 = strutX1 + c_new.left.width;
- strutY1 = c_new.left.y;
- strutY2 = strutY1 + c_new.left.height;
+ strutX1 = newStrut.left.x;
+ strutX2 = strutX1 + newStrut.left.width;
+ strutY1 = newStrut.left.y;
+ strutY2 = strutY1 + newStrut.left.height;
if (strutX2 > x1 && strutX2 <= x2 &&
strutY1 < y2 && strutY2 > y1)
{
- c_new.left.x = x1;
- c_new.left.width = strutX2 - x1;
+ newStrut.left.x = x1;
+ newStrut.left.width = strutX2 - x1;
}
- strutX1 = c_new.right.x;
- strutX2 = strutX1 + c_new.right.width;
- strutY1 = c_new.right.y;
- strutY2 = strutY1 + c_new.right.height;
+ strutX1 = newStrut.right.x;
+ strutX2 = strutX1 + newStrut.right.width;
+ strutY1 = newStrut.right.y;
+ strutY2 = strutY1 + newStrut.right.height;
if (strutX1 > x1 && strutX1 <= x2 &&
strutY1 < y2 && strutY2 > y1)
{
- c_new.right.x = strutX1;
- c_new.right.width = x2 - strutX1;
+ newStrut.right.x = strutX1;
+ newStrut.right.width = x2 - strutX1;
}
- strutX1 = c_new.top.x;
- strutX2 = strutX1 + c_new.top.width;
- strutY1 = c_new.top.y;
- strutY2 = strutY1 + c_new.top.height;
+ strutX1 = newStrut.top.x;
+ strutX2 = strutX1 + newStrut.top.width;
+ strutY1 = newStrut.top.y;
+ strutY2 = strutY1 + newStrut.top.height;
if (strutX1 < x2 && strutX2 > x1 &&
strutY2 > y1 && strutY2 <= y2)
{
- c_new.top.y = y1;
- c_new.top.height = strutY2 - y1;
+ newStrut.top.y = y1;
+ newStrut.top.height = strutY2 - y1;
}
- strutX1 = c_new.bottom.x;
- strutX2 = strutX1 + c_new.bottom.width;
- strutY1 = c_new.bottom.y;
- strutY2 = strutY1 + c_new.bottom.height;
+ strutX1 = newStrut.bottom.x;
+ strutX2 = strutX1 + newStrut.bottom.width;
+ strutY1 = newStrut.bottom.y;
+ strutY2 = strutY1 + newStrut.bottom.height;
if (strutX1 < x2 && strutX2 > x1 &&
strutY1 > y1 && strutY1 <= y2)
{
- c_new.bottom.y = strutY1;
- c_new.bottom.height = y2 - strutY1;
+ newStrut.bottom.y = strutY1;
+ newStrut.bottom.height = y2 - strutY1;
}
}
}
- if (hasOld != hasNew || (hasNew && hasOld &&
- memcmp (&c_new, &old, sizeof (CompStruts))))
+ if (hasOld != hasNew ||
+ (hasNew && hasOld &&
+ memcmp (&newStrut, &oldStrut, sizeof (CompStruts))))
{
if (hasNew)
{
@@ -1051,7 +1061,7 @@ PrivateWindow::updateStruts ()
return false;
}
- *priv->struts = c_new;
+ *priv->struts = newStrut;
}
else
{
@@ -1093,8 +1103,6 @@ setDefaultWindowAttributes (XWindowAttributes *wa)
wa->screen = NULL;
}
-
-
void
CompWindow::destroy ()
{
@@ -1290,7 +1298,10 @@ CompWindow::resize (XWindowAttributes attr)
}
bool
-CompWindow::resize (int x, int y, unsigned int width, unsigned int height,
+CompWindow::resize (int x,
+ int y,
+ unsigned int width,
+ unsigned int height,
unsigned int border)
{
return resize (Geometry (x, y, width, height, border));
@@ -1310,9 +1321,7 @@ CompWindow::resize (CompWindow::Geometry gm)
ph = gm.height () + gm.border () * 2;
if (priv->shaded)
- {
ph = 0;
- }
dx = gm.x () - priv->attrib.x;
dy = gm.y () - priv->attrib.y;
@@ -1461,15 +1470,13 @@ CompWindow::sendSyncRequest ()
syncValueIncrement (&priv->syncValue);
- XSendEvent (screen->dpy (), priv->id, FALSE, 0,
- (XEvent *) &xev);
+ XSendEvent (screen->dpy (), priv->id, FALSE, 0, (XEvent *) &xev);
- priv->syncWait = TRUE;
+ priv->syncWait = true;
priv->syncGeometry = priv->serverGeometry;
if (!priv->syncWaitTimer.active ())
- priv->syncWaitTimer.start (
- boost::bind (&PrivateWindow::handleSyncAlarm, priv), 1000, 1200);
+ priv->syncWaitTimer.start ();
}
void
@@ -1544,7 +1551,9 @@ PrivateWindow::circulate (XCirculateEvent *ce)
}
void
-CompWindow::move (int dx, int dy, bool immediate)
+CompWindow::move (int dx,
+ int dy,
+ bool immediate)
{
if (dx || dy)
{
@@ -1585,7 +1594,7 @@ CompWindow::syncPosition ()
bool
CompWindow::focus ()
{
- WRAPABLE_HND_FUNC_RETURN(2, bool, focus)
+ WRAPABLE_HND_FUNC_RETURN (2, bool, focus)
if (overrideRedirect ())
return false;
@@ -1611,7 +1620,7 @@ CompWindow::focus ()
bool
CompWindow::place (CompPoint &pos)
{
- WRAPABLE_HND_FUNC_RETURN(4, bool, place, pos)
+ WRAPABLE_HND_FUNC_RETURN (4, bool, place, pos)
return false;
}
@@ -1619,45 +1628,45 @@ void
CompWindow::validateResizeRequest (unsigned int &mask,
XWindowChanges *xwc,
unsigned int source)
- WRAPABLE_HND_FUNC(5, validateResizeRequest, mask, xwc, source)
+ WRAPABLE_HND_FUNC (5, validateResizeRequest, mask, xwc, source)
void
CompWindow::resizeNotify (int dx,
int dy,
int dwidth,
int dheight)
- WRAPABLE_HND_FUNC(6, resizeNotify, dx, dy, dwidth, dheight)
+ WRAPABLE_HND_FUNC (6, resizeNotify, dx, dy, dwidth, dheight)
void
CompWindow::moveNotify (int dx,
int dy,
bool immediate)
- WRAPABLE_HND_FUNC(7, moveNotify, dx, dy, immediate)
+ WRAPABLE_HND_FUNC (7, moveNotify, dx, dy, immediate)
void
CompWindow::windowNotify (CompWindowNotify n)
WRAPABLE_HND_FUNC (8, windowNotify, n)
void
-CompWindow::grabNotify (int x,
- int y,
+CompWindow::grabNotify (int x,
+ int y,
unsigned int state,
unsigned int mask)
{
- WRAPABLE_HND_FUNC(9, grabNotify, x, y, state, mask)
+ WRAPABLE_HND_FUNC (9, grabNotify, x, y, state, mask)
priv->grabbed = true;
}
void
CompWindow::ungrabNotify ()
{
- WRAPABLE_HND_FUNC(10, ungrabNotify)
+ WRAPABLE_HND_FUNC (10, ungrabNotify)
priv->grabbed = false;
}
void
CompWindow::stateChangeNotify (unsigned int lastState)
- WRAPABLE_HND_FUNC(11, stateChangeNotify, lastState);
+ WRAPABLE_HND_FUNC (11, stateChangeNotify, lastState);
bool
PrivateWindow::isGroupTransient (Window clientLeader)
@@ -1751,7 +1760,8 @@ CompWindow::moveInputFocusTo ()
if (priv->state & CompWindowStateHiddenMask)
{
- XSetInputFocus (s->dpy (), priv->frame, RevertToPointerRoot, CurrentTime);
+ XSetInputFocus (s->dpy (), priv->frame,
+ RevertToPointerRoot, CurrentTime);
XChangeProperty (s->dpy (), s->root (), Atoms::winActive,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &priv->id, 1);
@@ -2196,18 +2206,19 @@ PrivateWindow::reconfigureXWindow (unsigned int valueMask,
if (frame)
{
XWindowChanges wc = *xwc;
+
wc.x -= input.left;
wc.y -= input.top;
wc.width += input.left + input.right;
wc.height += input.top + input.bottom;
- XConfigureWindow (screen->dpy (), frame,
- valueMask, &wc);
+ XConfigureWindow (screen->dpy (), frame, valueMask, &wc);
valueMask &= ~(CWSibling | CWStackMode);
+
xwc->x = input.left;
xwc->y = input.top;
- XConfigureWindow (screen->dpy (), wrapper,
- valueMask, xwc);
+ XConfigureWindow (screen->dpy (), wrapper, valueMask, xwc);
+
xwc->x = 0;
xwc->y = 0;
}
@@ -2258,10 +2269,13 @@ PrivateWindow::stackAncestors (CompWindow *w,
XWindowChanges *xwc)
{
CompWindow *transient = NULL;
+
if (w->priv->transientFor)
transient = screen->findWindow (w->priv->transientFor);
- if (transient && (xwc->sibling != transient->priv->id &&
- (!transient->priv->frame || xwc->sibling != transient->priv->frame)))
+
+ if (transient &&
+ xwc->sibling != transient->priv->id &&
+ (!transient->priv->frame || xwc->sibling != transient->priv->frame))
{
CompWindow *ancestor;
@@ -2292,7 +2306,7 @@ PrivateWindow::stackAncestors (CompWindow *w,
for (a = screen->windows ().back (); a; a = a->prev)
{
if (a->priv->clientLeader == w->priv->clientLeader &&
- a->priv->transientFor == None &&
+ a->priv->transientFor == None &&
!a->priv->isGroupTransient (w->priv->clientLeader))
{
if (xwc->sibling == a->priv->id ||
@@ -2310,8 +2324,7 @@ PrivateWindow::stackAncestors (CompWindow *w,
break;
if (a->priv->mapNum || a->priv->pendingMaps)
- a->priv->reconfigureXWindow (CWSibling | CWStackMode,
- xwc);
+ a->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
}
}
}
@@ -2345,13 +2358,13 @@ PrivateWindow::addWindowSizeChanges (XWindowChanges *xwc,
XRectangle workArea;
int mask = 0;
int x, y;
- int vx, vy;
int output;
+ CompPoint viewport;
- screen->viewportForGeometry (old, &vx, &vy);
+ screen->viewportForGeometry (old, viewport);
- x = (vx - screen->vp ().x ()) * screen->width ();
- y = (vy - screen->vp ().y ()) * screen->height ();
+ x = (viewport.x () - screen->vp ().x ()) * screen->width ();
+ y = (viewport.y () - screen->vp ().y ()) * screen->height ();
output = screen->outputDeviceForGeometry (old);
screen->getWorkareaForOutput (output, &workArea);
@@ -2669,7 +2682,7 @@ CompWindow::moveResize (XWindowChanges *xwc,
xwcm |= priv->adjustConfigureRequestForGravity (xwc, xwcm, gravity);
- if (!(priv->type & (CompWindowTypeDockMask |
+ if (!(priv->type & (CompWindowTypeDockMask |
CompWindowTypeFullscreenMask |
CompWindowTypeUnknownMask)))
{
@@ -3047,9 +3060,9 @@ PrivateWindow::ensureWindowVisibility ()
if (struts || attrib.override_redirect)
return;
- if (type & (CompWindowTypeDockMask |
- CompWindowTypeFullscreenMask |
- CompWindowTypeUnknownMask))
+ if (type & (CompWindowTypeDockMask |
+ CompWindowTypeFullscreenMask |
+ CompWindowTypeUnknownMask))
return;
x1 = screen->workArea ().x - screen->width () * screen->vp ().x ();
@@ -3341,7 +3354,7 @@ CompWindow::show ()
return;
if (priv->minimized || priv->inShowDesktopMode ||
- priv->hidden || !onDesktop)
+ priv->hidden || !onDesktop)
{
/* no longer hidden but not on current desktop */
if (!priv->minimized && !priv->inShowDesktopMode && !priv->hidden)
@@ -3457,7 +3470,7 @@ CompWindow::maximize (unsigned int state)
}
bool
-PrivateWindow::getUserTime (Time *time)
+PrivateWindow::getUserTime (Time& time)
{
Atom actual;
int result, format;
@@ -3478,7 +3491,7 @@ PrivateWindow::getUserTime (Time *time)
memcpy (&value, data, sizeof (CARD32));
retval = true;
- *time = (Time) value;
+ time = (Time) value;
}
XFree ((void *) data);
@@ -3527,14 +3540,14 @@ PrivateWindow::setUserTime (Time time)
)
bool
-PrivateWindow::getUsageTimestamp (Time *timestamp)
+PrivateWindow::getUsageTimestamp (Time& timestamp)
{
if (getUserTime (timestamp))
return true;
if (initialTimestampSet)
{
- *timestamp = initialTimestamp;
+ timestamp = initialTimestamp;
return true;
}
@@ -3565,7 +3578,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
}
else
{
- gotTimestamp = getUsageTimestamp (&wUserTime);
+ gotTimestamp = getUsageTimestamp (wUserTime);
}
/* if we got no timestamp for the window, try to get at least a timestamp
@@ -3576,8 +3589,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
parent = screen->findWindow (transientFor);
if (parent)
- gotTimestamp =
- parent->priv->getUsageTimestamp (&wUserTime);
+ gotTimestamp = parent->priv->getUsageTimestamp (wUserTime);
}
if (gotTimestamp && !wUserTime)
@@ -3627,7 +3639,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
}
/* can't get user time for active window */
- if (!active->priv->getUserTime (&aUserTime))
+ if (!active->priv->getUserTime (aUserTime))
return true;
if (XSERVER_TIME_IS_BEFORE (wUserTime, aUserTime))
@@ -3650,11 +3662,13 @@ PrivateWindow::allowWindowFocus (unsigned int noFocusMask,
return false;
/* window doesn't take focus */
- if (!priv->inputHint && !(priv->protocols & CompWindowProtocolTakeFocusMask))
+ if (!priv->inputHint &&
+ !(priv->protocols & CompWindowProtocolTakeFocusMask))
+ {
return false;
+ }
retval = priv->isWindowFocusAllowed (timestamp);
-
if (!retval)
{
/* add demands attention state if focus was prevented */
@@ -3667,22 +3681,19 @@ PrivateWindow::allowWindowFocus (unsigned int noFocusMask,
CompPoint
CompWindow::defaultViewport ()
{
- int vx, vy;
+ CompPoint viewport;
- if (priv->serverGeometry.x () < (int) screen->width () &&
+ if (priv->serverGeometry.x () < (int) screen->width () &&
priv->serverGeometry.x () + priv->serverGeometry.width () > 0 &&
- priv->serverGeometry.y () < (int) screen->height () &&
+ priv->serverGeometry.y () < (int) screen->height () &&
priv->serverGeometry.y ()+ priv->serverGeometry.height () > 0)
{
- vx = screen->vp ().x ();
- vy = screen->vp ().y ();
- }
- else
- {
- screen->viewportForGeometry (priv->serverGeometry, &vx, &vy);
+ return screen->vp ();
}
- return CompPoint (vx, vy);
+ screen->viewportForGeometry (priv->serverGeometry, viewport);
+
+ return viewport;
}
CompPoint &
@@ -3694,7 +3705,8 @@ CompWindow::initialViewport () const
/* returns icon with dimensions as close as possible to width and height
but never greater. */
CompIcon *
-CompWindow::getIcon (int width, int height)
+CompWindow::getIcon (int width,
+ int height)
{
CompIcon *icon;
int wh, diff, oldDiff;
@@ -3708,12 +3720,9 @@ CompWindow::getIcon (int width, int height)
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (screen->dpy (), priv->id,
- Atoms::wmIcon,
- 0L, 65536L,
- FALSE, XA_CARDINAL,
- &actual, &format, &n,
- &left, &data);
+ result = XGetWindowProperty (screen->dpy (), priv->id, Atoms::wmIcon,
+ 0L, 65536L, FALSE, XA_CARDINAL,
+ &actual, &format, &n, &left, &data);
if (result == Success && data)
{
@@ -3806,9 +3815,7 @@ void
PrivateWindow::freeIcons ()
{
for (unsigned int i = 0; i < priv->icons.size (); i++)
- {
delete priv->icons[i];
- }
priv->icons.resize (0);
priv->noIcons = false;
@@ -3823,9 +3830,11 @@ CompWindow::outputDevice ()
bool
CompWindow::onCurrentDesktop ()
{
- if (priv->desktop == 0xffffffff || priv->desktop ==
- screen->currentDesktop ())
+ if (priv->desktop == 0xffffffff ||
+ priv->desktop == screen->currentDesktop ())
+ {
return true;
+ }
return false;
}
@@ -3950,7 +3959,7 @@ CompWindow::getMovementForOffset (CompPoint offset)
}
void
-WindowInterface::getOutputExtents (CompWindowExtents *output)
+WindowInterface::getOutputExtents (CompWindowExtents& output)
WRAPABLE_DEF (getOutputExtents, output)
void
@@ -3977,11 +3986,16 @@ WindowInterface::validateResizeRequest (unsigned int &mask,
WRAPABLE_DEF (validateResizeRequest, mask, xwc, source)
void
-WindowInterface::resizeNotify (int dx, int dy, int dwidth, int dheight)
+WindowInterface::resizeNotify (int dx,
+ int dy,
+ int dwidth,
+ int dheight)
WRAPABLE_DEF (resizeNotify, dx, dy, dwidth, dheight)
void
-WindowInterface::moveNotify (int dx, int dy, bool immediate)
+WindowInterface::moveNotify (int dx,
+ int dy,
+ bool immediate)
WRAPABLE_DEF (moveNotify, dx, dy, immediate)
void
@@ -3990,8 +4004,8 @@ WindowInterface::windowNotify (CompWindowNotify n)
void
-WindowInterface::grabNotify (int x,
- int y,
+WindowInterface::grabNotify (int x,
+ int y,
unsigned int state,
unsigned int mask)
WRAPABLE_DEF (grabNotify, x, y, state, mask)
@@ -4060,8 +4074,7 @@ CompWindow::close (Time serverTime)
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
- XSendEvent (screen->dpy (), priv->id, false,
- NoEventMask, &ev);
+ XSendEvent (screen->dpy (), priv->id, false, NoEventMask, &ev);
}
else
{
@@ -4103,10 +4116,9 @@ PrivateWindow::handlePingTimeout (unsigned int lastPing)
if (priv->closeRequests)
{
- screen->toolkitAction (
- Atoms::toolkitActionForceQuitDialog,
- priv->lastCloseRequestTime,
- priv->id, true, 0, 0);
+ screen->toolkitAction (Atoms::toolkitActionForceQuitDialog,
+ priv->lastCloseRequestTime,
+ priv->id, true, 0, 0);
priv->closeRequests = 0;
}
@@ -4129,10 +4141,9 @@ PrivateWindow::handlePing (int lastPing)
if (priv->lastCloseRequestTime)
{
- screen->toolkitAction (
- Atoms::toolkitActionForceQuitDialog,
- priv->lastCloseRequestTime,
- priv->id, false, 0, 0);
+ screen->toolkitAction (Atoms::toolkitActionForceQuitDialog,
+ priv->lastCloseRequestTime,
+ priv->id, false, 0, 0);
priv->lastCloseRequestTime = 0;
}
@@ -4146,8 +4157,7 @@ PrivateWindow::processMap ()
bool allowFocus;
CompStackingUpdateMode stackingMode;
- priv->initialViewport.setX (screen->vp ().x ());
- priv->initialViewport.setY (screen->vp ().y ());
+ priv->initialViewport = screen->vp ();
priv->initialTimestampSet = false;
@@ -4290,12 +4300,13 @@ CompWindow::saveWc ()
}
void
-CompWindow::moveToViewportPosition (int x, int y, bool sync)
+CompWindow::moveToViewportPosition (int x,
+ int y,
+ bool sync)
{
- int tx, vWidth = screen->width () *
- screen->vpSize ().width ();
- int ty, vHeight = screen->height () *
- screen->vpSize ().height ();
+ int tx, ty;
+ int vWidth = screen->width () * screen->vpSize ().width ();
+ int vHeight = screen->height () * screen->vpSize ().height ();
if (screen->vpSize ().width () != 1)
{
@@ -4334,8 +4345,7 @@ CompWindow::moveToViewportPosition (int x, int y, bool sync)
{
m = priv->attrib.x + tx;
- if (m - priv->output.left <
- (int) screen->width () - vWidth)
+ if (m - priv->output.left < (int) screen->width () - vWidth)
wx = tx + vWidth;
else if (m + priv->width + priv->output.right > vWidth)
wx = tx - vWidth;
@@ -4345,8 +4355,7 @@ CompWindow::moveToViewportPosition (int x, int y, bool sync)
{
m = priv->attrib.y + ty;
- if (m - priv->output.top <
- (int) screen->height () - vHeight)
+ if (m - priv->output.top < (int) screen->height () - vHeight)
wy = ty + vHeight;
else if (m + priv->height + priv->output.bottom > vHeight)
wy = ty - vHeight;
@@ -4451,9 +4460,7 @@ CompWindow::sizeHints () const
void
PrivateWindow::updateMwmHints ()
{
- screen->priv->getMwmHints (priv->id, &priv->mwmFunc,
- &priv->mwmDecor);
-
+ screen->priv->getMwmHints (priv->id, &priv->mwmFunc, &priv->mwmDecor);
window->recalcActions ();
}
@@ -4514,9 +4521,9 @@ CompWindow::syncAlarm ()
}
-CompWindow::CompWindow (Window id,
- Window aboveId) :
- CompPrivateStorage (&windowPrivateIndices)
+CompWindow::CompWindow (Window id,
+ Window aboveId) :
+ CompPrivateStorage (windowPrivateIndices)
{
priv = new PrivateWindow (this);
assert (priv);
@@ -4839,6 +4846,10 @@ PrivateWindow::PrivateWindow (CompWindow *window) :
output.right = 0;
output.top = 0;
output.bottom = 0;
+
+ syncWaitTimer.setTimes (1000, 1200);
+ syncWaitTimer.setCallback (boost::bind (&PrivateWindow::handleSyncAlarm,
+ this));
}
PrivateWindow::~PrivateWindow ()
@@ -4965,7 +4976,7 @@ CompWindow::updateFrameRegion ()
int x, y;
if ((priv->input.left || priv->input.right ||
- priv->input.top || priv->input.bottom) && priv->frame)
+ priv->input.top || priv->input.bottom) && priv->frame)
{
priv->frameRegion = CompRegion ();
@@ -5020,7 +5031,7 @@ CompWindow::setWindowFrameExtents (CompWindowExtents *i)
}
void
-CompWindow::updateFrameRegion (CompRegion & region)
+CompWindow::updateFrameRegion (CompRegion& region)
WRAPABLE_HND_FUNC(12, updateFrameRegion, region)
bool
@@ -5031,7 +5042,6 @@ PrivateWindow::reparent ()
int mask;
XEvent e;
CompWindow::Geometry sg = serverGeometry;
-
Display *dpy = screen->dpy ();
if (frame)
@@ -5095,7 +5105,9 @@ PrivateWindow::reparent ()
XSync (dpy, FALSE);
if (XCheckTypedWindowEvent (dpy, id, FocusIn, &e) ||
screen->activeWindow () == id)
+ {
window->moveInputFocusTo ();
+ }
pendingUnmaps++;
pendingMaps++;
}
@@ -5108,11 +5120,10 @@ PrivateWindow::reparent ()
void
PrivateWindow::unreparent ()
{
- Display *dpy = screen->dpy ();
+ Display *dpy = screen->dpy ();
XEvent e;
XWindowChanges xwc;
-
- bool alive = true;
+ bool alive = true;
if (!frame)
return;
@@ -5152,5 +5163,4 @@ PrivateWindow::unreparent ()
wrapper = None;
frame = None;
- window->windowNotify (CompWindowNotifyUnreparent);
-}
+ window->windowNotify (CompWindowNotifyUnreparent);}
diff --git a/src/windowgeometry.cpp b/src/windowgeometry.cpp
index 5a236f7..ab3546b 100644
--- a/src/windowgeometry.cpp
+++ b/src/windowgeometry.cpp
@@ -33,7 +33,8 @@ CompWindow::Geometry::Geometry () :
{
}
-CompWindow::Geometry::Geometry (int x, int y,
+CompWindow::Geometry::Geometry (int x,
+ int y,
unsigned int width,
unsigned int height,
unsigned int border) :
@@ -56,7 +57,8 @@ CompWindow::Geometry::setBorder (unsigned int border)
}
void
-CompWindow::Geometry::set (int x, int y,
+CompWindow::Geometry::set (int x,
+ int y,
unsigned int width,
unsigned int height,
unsigned int border)
@@ -80,7 +82,6 @@ CompWindow::geometry () const
return priv->geometry;
}
-
int
CompWindow::x () const
{
@@ -118,7 +119,6 @@ CompWindow::size () const
return CompSize (priv->width, priv->height);
}
-
int
CompWindow::serverX () const
{
@@ -141,19 +141,22 @@ CompWindow::serverPos () const
unsigned int
CompWindow::serverWidth () const
{
- return priv->serverGeometry.width () + (2 * priv->serverGeometry.border ());
+ return priv->serverGeometry.width () +
+ 2 * priv->serverGeometry.border ();
}
unsigned int
CompWindow::serverHeight () const
{
- return priv->serverGeometry.height () + (2 * priv->serverGeometry.border ());
+ return priv->serverGeometry.height () +
+ 2 * priv->serverGeometry.border ();
}
const CompSize
CompWindow::serverSize () const
{
- return CompSize (
- priv->serverGeometry.width () + (2 * priv->serverGeometry.border ()),
- priv->serverGeometry.height () + (2 * priv->serverGeometry.border ()));
+ return CompSize (priv->serverGeometry.width () +
+ 2 * priv->serverGeometry.border (),
+ priv->serverGeometry.height () +
+ 2 * priv->serverGeometry.border ());
}