summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp155
1 files changed, 85 insertions, 70 deletions
diff --git a/src/window.cpp b/src/window.cpp
index f30f28a..d182727 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -796,11 +796,11 @@ PrivateWindow::updateFrameWindow ()
xev.event = screen->root ();
xev.window = priv->frame;
- xev.x = x;
- xev.y = y;
- xev.width = width;
- xev.height = height;
- xev.border_width = window->priv->attrib.border_width;
+ xev.x = serverGeometry.x ();
+ xev.y = serverGeometry.y ();
+ xev.width = serverGeometry.width ();
+ xev.height = serverGeometry.height ();
+ xev.border_width = serverGeometry.border ();
xev.above = (window->prev) ? ROOTPARENT (window->prev) : None;
xev.override_redirect = window->priv->attrib.override_redirect;
@@ -901,8 +901,8 @@ PrivateWindow::rectsToRegion (unsigned int n, XRectangle *rects)
for (unsigned int i = 0; i < n; i++)
{
- x1 = rects[i].x + priv->attrib.border_width;
- y1 = rects[i].y + priv->attrib.border_width;
+ x1 = rects[i].x + priv->geometry.border ();
+ y1 = rects[i].y + priv->geometry.border ();
x2 = x1 + rects[i].width;
y2 = y1 + rects[i].height;
@@ -917,10 +917,10 @@ PrivateWindow::rectsToRegion (unsigned int n, XRectangle *rects)
if (y1 < y2 && x1 < x2)
{
- x1 += priv->attrib.x;
- y1 += priv->attrib.y;
- x2 += priv->attrib.x;
- y2 += priv->attrib.y;
+ x1 += priv->geometry.x ();
+ y1 += priv->geometry.y ();
+ x2 += priv->geometry.x ();
+ y2 += priv->geometry.y ();
ret += CompRect (x1, y1, x2 - x1, y2 - y1);
}
@@ -955,6 +955,7 @@ PrivateWindow::updateRegion ()
}
+ /* FIXME: That doesn't look right */
r.x = -priv->attrib.border_width;
r.y = -priv->attrib.border_width;
r.width = priv->width + priv->attrib.border_width;
@@ -1229,10 +1230,10 @@ CompWindow::sendConfigureNotify ()
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. */
+ * 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 (priv->attrib.override_redirect)
{
XWindowAttributes attrib;
@@ -1320,8 +1321,11 @@ CompWindow::map ()
{
/* been shaded */
if (!priv->height)
- resize (priv->attrib.x, priv->attrib.y, priv->attrib.width,
- ++priv->attrib.height - 1, priv->attrib.border_width);
+ {
+ priv->geometry.setHeight (priv->geometry.height () + 1);
+ resize (priv->geometry.x (), priv->geometry.y (), priv->geometry.width (),
+ priv->geometry.height () - 1, priv->geometry.border ());
+ }
}
}
@@ -1394,9 +1398,9 @@ CompWindow::unmap ()
priv->invisible = true;
if (priv->shaded && priv->height)
- resize (priv->attrib.x, priv->attrib.y,
- priv->attrib.width, ++priv->attrib.height - 1,
- priv->attrib.border_width);
+ resize (priv->geometry.x (), priv->geometry.y (),
+ priv->geometry.width (), priv->geometry.height () - 1,
+ priv->geometry.border ());
screen->priv->updateClientList ();
@@ -1475,20 +1479,14 @@ CompWindow::resize (CompWindow::Geometry gm)
if (priv->shaded)
ph = 0;
- dx = gm.x () - priv->attrib.x;
- dy = gm.y () - priv->attrib.y;
- dwidth = gm.width () - priv->attrib.width;
- dheight = gm.height () - priv->attrib.height;
-
- priv->attrib.x = gm.x ();
- priv->attrib.y = gm.y ();
- priv->attrib.width = gm.width ();
- priv->attrib.height = gm.height ();
- priv->attrib.border_width = gm.border ();
+ dx = gm.x () - priv->geometry.x ();
+ dy = gm.y () - priv->geometry.y ();
+ dwidth = gm.width () - priv->geometry.width ();
+ dheight = gm.height () - priv->geometry.height ();
- priv->geometry.set (priv->attrib.x, priv->attrib.y,
- priv->attrib.width, priv->attrib.height,
- priv->attrib.border_width);
+ priv->geometry.set (gm.x (), gm.y (),
+ gm.width (), gm.height (),
+ gm.border ());
priv->width = pw;
priv->height = ph;
@@ -1505,8 +1503,8 @@ CompWindow::resize (CompWindow::Geometry gm)
{
int dx, dy;
- dx = gm.x () - priv->attrib.x;
- dy = gm.y () - priv->attrib.y;
+ dx = gm.x () - priv->geometry.x ();
+ dy = gm.y () - priv->geometry.y ();
move (dx, dy);
}
@@ -1715,11 +1713,8 @@ CompWindow::move (int dx,
{
if (dx || dy)
{
- priv->attrib.x += dx;
- priv->attrib.y += dy;
-
- priv->geometry.setX (priv->attrib.x);
- priv->geometry.setY (priv->attrib.y);
+ priv->geometry.setX (priv->geometry.x () + dx);
+ priv->geometry.setY (priv->geometry.y () + dy);
priv->region.translate (dx, dy);
priv->inputRegion.translate (dx, dy);
@@ -1735,12 +1730,12 @@ CompWindow::move (int dx,
void
CompWindow::syncPosition ()
{
- priv->serverGeometry.setX (priv->attrib.x);
- priv->serverGeometry.setY (priv->attrib.y);
+ priv->serverGeometry.setX (priv->geometry.x ());
+ priv->serverGeometry.setY (priv->geometry.y ());
XMoveWindow (screen->dpy (), ROOTPARENT (this),
- priv->attrib.x - priv->input.left,
- priv->attrib.y - priv->input.top);
+ priv->geometry.x () - priv->input.left,
+ priv->geometry.y () - priv->input.top);
if (priv->frame)
{
@@ -1770,10 +1765,10 @@ CompWindow::focus ()
if (!priv->shaded && (priv->state & CompWindowStateHiddenMask))
return false;
- if (priv->attrib.x + priv->width <= 0 ||
- priv->attrib.y + priv->height <= 0 ||
- priv->attrib.x >= (int) screen->width ()||
- priv->attrib.y >= (int) screen->height ())
+ if (priv->geometry.x () + priv->width <= 0 ||
+ priv->geometry.y () + priv->height <= 0 ||
+ priv->geometry.x () >= (int) screen->width ()||
+ priv->geometry.y () >= (int) screen->height ())
return false;
return true;
@@ -3851,9 +3846,12 @@ PrivateWindow::show ()
XMapWindow (screen->dpy (), frame);
if (height)
- window->resize (attrib.x, attrib.y,
- attrib.width, ++attrib.height - 1,
- attrib.border_width);
+ {
+ priv->geometry.setHeight (priv->geometry.height () + 1);
+ window->resize (geometry.x (), geometry.y (),
+ geometry.width (), geometry.height () - 1,
+ geometry.border ());
+ }
return;
}
@@ -4509,7 +4507,7 @@ CompWindow::getMovementForOffset (CompPoint offset)
}
else
{
- m = priv->attrib.x + offX;
+ m = priv->geometry.x () + offX;
if (m - priv->input.left < (int) s->width () - vWidth)
rv.setX (offX + vWidth);
else if (m + priv->width + priv->input.right > vWidth)
@@ -4524,7 +4522,7 @@ CompWindow::getMovementForOffset (CompPoint offset)
}
else
{
- m = priv->attrib.y + offY;
+ m = priv->geometry.y () + offY;
if (m - priv->input.top < (int) s->height () - vHeight)
rv.setY (offY + vHeight);
else if (m + priv->height + priv->input.bottom > vHeight)
@@ -4756,6 +4754,7 @@ void
PrivateWindow::processMap ()
{
bool allowFocus;
+ bool initiallyMinimized;
CompStackingUpdateMode stackingMode;
priv->initialViewport = screen->vp ();
@@ -4798,6 +4797,9 @@ PrivateWindow::processMap ()
priv->placed = true;
}
+ initiallyMinimized = (priv->hints &&
+ priv->hints->initial_state == IconicState &&
+ !window->minimized ());
allowFocus = allowWindowFocus (NO_FOCUS_MASK, 0);
if (!allowFocus && (priv->type & ~NO_FOCUS_MASK))
@@ -4807,9 +4809,27 @@ PrivateWindow::processMap ()
window->updateAttributes (stackingMode);
- if (window->minimized ())
+ if (window->minimized () && !initiallyMinimized)
window->unminimize ();
+ if (!initiallyMinimized)
+ {
+ if (allowFocus && !window->onCurrentDesktop ());
+ screen->priv->setCurrentDesktop (priv->desktop);
+
+ if (!(priv->state & CompWindowStateHiddenMask))
+ show ();
+
+ if (allowFocus)
+ window->moveInputFocusTo ();
+ }
+ else
+ {
+ window->minimize ();
+ window->changeState (window->state () | CompWindowStateHiddenMask);
+ screen->priv->updateClientList ();
+ }
+
screen->leaveShowDesktopMode (window);
if (allowFocus && !window->onCurrentDesktop ())
@@ -5047,8 +5067,8 @@ CompWindow::moveToViewportPosition (int x,
y -= screen->vp ().y () * screen->height ();
}
- tx = x - priv->attrib.x;
- ty = y - priv->attrib.y;
+ tx = x - priv->geometry.x ();
+ ty = y - priv->geometry.y ();
if (tx || ty)
{
@@ -5068,7 +5088,7 @@ CompWindow::moveToViewportPosition (int x,
if (screen->vpSize ().width ()!= 1)
{
- m = priv->attrib.x + tx;
+ m = priv->geometry.x () + tx;
if (m - priv->output.left < (int) screen->width () - vWidth)
wx = tx + vWidth;
@@ -5078,7 +5098,7 @@ CompWindow::moveToViewportPosition (int x,
if (screen->vpSize ().height () != 1)
{
- m = priv->attrib.y + ty;
+ m = priv->geometry.y () + ty;
if (m - priv->output.top < (int) screen->height () - vHeight)
wy = ty + vHeight;
@@ -5327,7 +5347,7 @@ CompWindow::CompWindow (Window aboveId,
if (priv->attrib.c_class != InputOnly)
{
- priv->region = CompRegion (priv->attrib.x, priv->attrib.y,
+ priv->region = CompRegion (priv->geometry.x (), priv->geometry.y (),
priv->width, priv->height);
priv->inputRegion = priv->region;
@@ -5459,9 +5479,12 @@ CompWindow::CompWindow (Window aboveId,
priv->updateIconGeometry ();
if (priv->shaded)
- resize (priv->attrib.x, priv->attrib.y,
- priv->attrib.width, ++priv->attrib.height - 1,
- priv->attrib.border_width);
+ {
+ priv->geometry.setHeight (priv->geometry.height () + 1);
+ resize (priv->geometry.x (), priv->geometry.y (),
+ priv->geometry.width (), priv->geometry.height () - 1,
+ priv->geometry.border ());
+ }
if (priv->attrib.map_state == IsViewable)
{
@@ -5857,14 +5880,6 @@ PrivateWindow::reparent ()
return false;
}
- /* Since we have read directly to our XWindowAttributes
- * we need to update the size of a window since it might
- * have changed during the reparent
- */
-
- window->resize (attrib.x, attrib.y, attrib.width, attrib.height,
- attrib.border_width);
-
if (attrib.override_redirect)
return false;