1270
1268
CompWindow::sendConfigureNotify ()
1272
1270
XConfigureEvent xev;
1273
XWindowAttributes attrib;
1274
unsigned int nchildren;
1275
Window rootRet, parentRet = 0;
1278
1272
xev.type = ConfigureNotify;
1279
1273
xev.event = priv->id;
1280
1274
xev.window = priv->id;
1282
/* in order to avoid race conditions we must use the current
1283
* server configuration */
1285
XGrabServer (screen->dpy ());
1286
XSync (screen->dpy (), false);
1288
if (XGetWindowAttributes (screen->dpy (), priv->id, &attrib))
1292
xev.width = attrib.width;
1293
xev.height = attrib.height;
1294
xev.border_width = attrib.border_width;
1297
/* Translate co-ordinates to root space */
1298
XTranslateCoordinates (screen->dpy (), priv->id, screen->root (), 0, 0,
1299
&xev.x, &xev.y, &parentRet);
1301
/* We need to ensure that the stacking order is
1302
* based on the current server stacking order so
1303
* find the sibling to this window's frame in the
1304
* server side stack and stack above that */
1305
XQueryTree (screen->dpy (), screen->root (), &rootRet, &parentRet, &children, &nchildren);
1309
for (unsigned int i = 0; i < nchildren; i++)
1311
if (i + 1 == nchildren ||
1312
children[i + 1] == ROOTPARENT (this))
1314
xev.above = children[i];
1324
xev.above = (serverPrev) ? ROOTPARENT (serverPrev) : None;
1325
xev.override_redirect = priv->attrib.override_redirect;
1327
XSendEvent (screen->dpy (), priv->id, false,
1328
StructureNotifyMask, (XEvent *) &xev);
1331
XUngrabServer (screen->dpy ());
1332
XSync (screen->dpy (), false);
1276
xev.x = priv->serverGeometry.x ();
1277
xev.y = priv->serverGeometry.y ();
1278
xev.width = priv->serverGeometry.width ();
1279
xev.height = priv->serverGeometry.height ();
1280
xev.border_width = priv->serverGeometry.border ();
1281
xev.override_redirect = priv->attrib.override_redirect;
1283
/* These used to be based on the actual sibling of the window
1284
* (eg, obtained using XQueryTree), but they are now zeroed out.
1286
* The ICCCM is a big unclear on what these should be - it
1287
* requires that after the client attempts to configure a window
1288
* we should issue a synthetic ConfigureNotify to work around
1289
* the change of co-ordinates due to reparenting:
1291
* "A client will receive a synthetic ConfigureNotify event
1292
* following the change that describes the new geometry of the window"
1294
* However there is an acknowledgement on stacking order:
1296
* "Not changing the size, location, border width,
1297
* or stacking order of the window at all."
1299
* Since there isn't any advice as to what to set the above and
1300
* detail members, the only choices are to either grab the server
1301
* and query it for the sibling to the window's parent, or to just
1304
* An evaluation of other window managers showed that they just set
1305
* these fields to zero. This is probably a safe option and justifies
1306
* the potential performance tradeoff that we get out of not having
1307
* to grab the server, query window attributes and children and
1308
* translate co-ordinates every time a window is moved
1313
XSendEvent (screen->dpy (), priv->id, false,
1314
StructureNotifyMask, (XEvent *) &xev);
4311
4290
CompWindowTypeUnknownMask))
4314
x1 = screen->workArea ().x () - screen->width () * screen->vp ().x ();
4315
y1 = screen->workArea ().y () - screen->height () * screen->vp ().y ();
4316
x2 = x1 + screen->workArea ().width () + screen->vpSize ().width () *
4293
int x1 = screen->workArea ().x () - screen->width () * screen->vp ().x ();
4294
int y1 = screen->workArea ().y () - screen->height () * screen->vp ().y ();
4295
int x2 = x1 + screen->workArea ().width () + screen->vpSize ().width () *
4317
4296
screen->width ();
4318
y2 = y1 + screen->workArea ().height () + screen->vpSize ().height () *
4297
int y2 = y1 + screen->workArea ().height () + screen->vpSize ().height () *
4319
4298
screen->height ();
4301
int width = serverGeometry.widthIncBorders ();
4321
4303
if (serverGeometry.x () - serverInput.left >= x2)
4322
4304
dx = (x2 - 25) - serverGeometry.x ();
4323
4305
else if (serverGeometry.x () + width + serverInput.right <= x1)
4324
4306
dx = (x1 + 25) - (serverGeometry.x () + width);
4309
int height = serverGeometry.heightIncBorders ();
4326
4311
if (serverGeometry.y () - serverInput.top >= y2)
4327
4312
dy = (y2 - 25) - serverGeometry.y ();
4328
4313
else if (serverGeometry.y () + height + serverInput.bottom <= y1)