84
84
PrivateWindow::isInvisible() const
86
return attrib.map_state != IsViewable ||
87
attrib.x + geometry.width () + output.right <= 0 ||
88
attrib.y + geometry.height () + output.bottom <= 0 ||
89
attrib.x - output.left >= (int) screen->width () ||
90
attrib.y - output.top >= (int) screen->height ();
86
return attrib.map_state != IsViewable ||
87
attrib.x + geometry.width () + output.right <= 0 ||
88
attrib.y + geometry.height () + output.bottom <= 0 ||
89
attrib.x - output.left >= (int) screen->width () ||
90
attrib.y - output.top >= (int) screen->height ();
356
346
PrivateWindow::updateIconGeometry ()
360
350
unsigned long n, left;
361
351
unsigned char *data;
363
353
priv->iconGeometry.setGeometry (0, 0, 0, 0);
365
result = XGetWindowProperty (screen->dpy (), priv->id,
366
Atoms::wmIconGeometry,
367
0L, 1024L, False, XA_CARDINAL,
368
&actual, &format, &n, &left, &data);
355
int result = XGetWindowProperty (screen->dpy (), priv->id,
356
Atoms::wmIconGeometry,
357
0L, 1024L, False, XA_CARDINAL,
358
&actual, &format, &n, &left, &data);
370
360
if (result == Success && data)
405
396
PrivateWindow::getClientLeader ()
409
400
unsigned long n, left;
410
401
unsigned char *data;
412
result = XGetWindowProperty (screen->dpy (), priv->id,
413
Atoms::wmClientLeader,
414
0L, 1L, False, XA_WINDOW, &actual, &format,
403
int result = XGetWindowProperty (screen->dpy (), priv->id,
404
Atoms::wmClientLeader,
405
0L, 1L, False, XA_WINDOW, &actual, &format,
417
408
if (result == Success && data)
463
455
PrivateWindow::setFullscreenMonitors (CompFullscreenMonitorSet *monitors)
465
457
bool hadFsMonitors = fullscreenMonitorsSet;
466
unsigned int outputs = screen->outputDevs ().size ();
458
unsigned int outputs = screen->outputDevs ().size ();
468
460
fullscreenMonitorsSet = false;
471
(unsigned int) monitors->left < outputs &&
472
(unsigned int) monitors->right < outputs &&
473
(unsigned int) monitors->top < outputs &&
463
(unsigned int) monitors->left < outputs &&
464
(unsigned int) monitors->right < outputs &&
465
(unsigned int) monitors->top < outputs &&
474
466
(unsigned int) monitors->bottom < outputs)
476
468
CompRect fsRect (screen->outputDevs ()[monitors->left].x1 (),
538
528
if (actions & CompWindowActionMoveMask)
539
529
data[i++] = Atoms::winActionMove;
540
531
if (actions & CompWindowActionResizeMask)
541
532
data[i++] = Atoms::winActionResize;
542
534
if (actions & CompWindowActionStickMask)
543
535
data[i++] = Atoms::winActionStick;
544
537
if (actions & CompWindowActionMinimizeMask)
545
538
data[i++] = Atoms::winActionMinimize;
546
540
if (actions & CompWindowActionMaximizeHorzMask)
547
541
data[i++] = Atoms::winActionMaximizeHorz;
548
543
if (actions & CompWindowActionMaximizeVertMask)
549
544
data[i++] = Atoms::winActionMaximizeVert;
550
546
if (actions & CompWindowActionFullscreenMask)
551
547
data[i++] = Atoms::winActionFullscreen;
552
549
if (actions & CompWindowActionCloseMask)
553
550
data[i++] = Atoms::winActionClose;
554
552
if (actions & CompWindowActionShadeMask)
555
553
data[i++] = Atoms::winActionShade;
556
555
if (actions & CompWindowActionChangeDesktopMask)
557
556
data[i++] = Atoms::winActionChangeDesktop;
558
558
if (actions & CompWindowActionAboveMask)
559
559
data[i++] = Atoms::winActionAbove;
560
561
if (actions & CompWindowActionBelowMask)
561
562
data[i++] = Atoms::winActionBelow;
571
572
unsigned int actions = 0;
572
573
unsigned int setActions, clearActions;
574
switch (priv->type) {
575
case CompWindowTypeFullscreenMask:
576
case CompWindowTypeNormalMask:
578
CompWindowActionMaximizeHorzMask |
579
CompWindowActionMaximizeVertMask |
580
CompWindowActionFullscreenMask |
581
CompWindowActionMoveMask |
582
CompWindowActionResizeMask |
583
CompWindowActionStickMask |
584
CompWindowActionMinimizeMask |
585
CompWindowActionCloseMask |
586
CompWindowActionChangeDesktopMask;
588
case CompWindowTypeUtilMask:
589
case CompWindowTypeMenuMask:
590
case CompWindowTypeToolbarMask:
592
CompWindowActionMoveMask |
593
CompWindowActionResizeMask |
594
CompWindowActionStickMask |
595
CompWindowActionCloseMask |
596
CompWindowActionChangeDesktopMask;
598
case CompWindowTypeDialogMask:
599
case CompWindowTypeModalDialogMask:
601
CompWindowActionMaximizeHorzMask |
602
CompWindowActionMaximizeVertMask |
603
CompWindowActionMoveMask |
604
CompWindowActionResizeMask |
605
CompWindowActionStickMask |
606
CompWindowActionCloseMask |
607
CompWindowActionChangeDesktopMask;
609
/* allow minimization for dialog windows if they
610
a) are not a transient (transients can be minimized
612
b) don't have the skip taskbar hint set (as those
613
have no target to be minimized to)
615
if (!priv->transientFor &&
616
!(priv->state & CompWindowStateSkipTaskbarMask))
618
actions |= CompWindowActionMinimizeMask;
577
case CompWindowTypeFullscreenMask:
578
case CompWindowTypeNormalMask:
580
CompWindowActionMaximizeHorzMask |
581
CompWindowActionMaximizeVertMask |
582
CompWindowActionFullscreenMask |
583
CompWindowActionMoveMask |
584
CompWindowActionResizeMask |
585
CompWindowActionStickMask |
586
CompWindowActionMinimizeMask |
587
CompWindowActionCloseMask |
588
CompWindowActionChangeDesktopMask;
591
case CompWindowTypeUtilMask:
592
case CompWindowTypeMenuMask:
593
case CompWindowTypeToolbarMask:
595
CompWindowActionMoveMask |
596
CompWindowActionResizeMask |
597
CompWindowActionStickMask |
598
CompWindowActionCloseMask |
599
CompWindowActionChangeDesktopMask;
602
case CompWindowTypeDialogMask:
603
case CompWindowTypeModalDialogMask:
605
CompWindowActionMaximizeHorzMask |
606
CompWindowActionMaximizeVertMask |
607
CompWindowActionMoveMask |
608
CompWindowActionResizeMask |
609
CompWindowActionStickMask |
610
CompWindowActionCloseMask |
611
CompWindowActionChangeDesktopMask;
613
/* allow minimization for dialog windows if they:
614
* a) are not a transient (transients can be minimized
616
* b) don't have the skip taskbar hint set (as those
617
* have no target to be minimized to)
619
if (!priv->transientFor &&
620
!(priv->state & CompWindowStateSkipTaskbarMask))
621
actions |= CompWindowActionMinimizeMask;
624
629
if (priv->serverInput.top)
787
793
if (priv->state & CompWindowStateFullscreenMask)
788
794
type = CompWindowTypeFullscreenMask;
790
if (type == CompWindowTypeNormalMask)
792
if (priv->transientFor)
793
type = CompWindowTypeDialogMask;
796
if (type == CompWindowTypeNormalMask &&
798
type = CompWindowTypeDialogMask;
796
800
if (type == CompWindowTypeDockMask &&
797
801
(priv->state & CompWindowStateBelowMask))
799
802
type = CompWindowTypeNormalMask;
802
804
if ((type & (CompWindowTypeNormalMask | CompWindowTypeDialogMask)) &&
803
805
(priv->state & CompWindowStateModalMask))
805
806
type = CompWindowTypeModalDialogMask;
808
808
priv->type = type;
814
814
if (!serverFrame)
817
XWindowChanges xwc = XWINDOWCHANGES_INIT;
817
XWindowChanges xwc = XWINDOWCHANGES_INIT;
818
818
unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
820
xwc.x = serverGeometry.x ();
821
xwc.y = serverGeometry.y ();
822
xwc.width = serverGeometry.width ();
823
xwc.height = serverGeometry.height ();
820
xwc.x = serverGeometry.x ();
821
xwc.y = serverGeometry.y ();
822
xwc.width = serverGeometry.width ();
823
xwc.height = serverGeometry.height ();
824
824
xwc.border_width = serverGeometry.border ();
826
826
window->configureXWindow (valueMask, &xwc);
907
910
PrivateWindow::updateRegion ()
909
XRectangle r, *boundingShapeRects = NULL;
910
XRectangle *inputShapeRects = NULL;
911
int nBounding = 0, nInput = 0;
912
const CompWindow::Geometry &geom = attrib.override_redirect ? priv->geometry : priv->serverGeometry;
912
XRectangle r, *boundingShapeRects = NULL;
913
XRectangle *inputShapeRects = NULL;
914
int nBounding = 0, nInput = 0;
915
const CompWindow::Geometry &geom = attrib.override_redirect ?
916
priv->geometry : priv->serverGeometry;
914
918
priv->region = priv->inputRegion = emptyRegion;
976
981
oldStrut.bottom = priv->struts->bottom;
987
newStrut.left.width = 0;
988
newStrut.left.height = screen->height ();
990
newStrut.right.x = screen->width ();
991
newStrut.right.y = 0;
992
newStrut.right.width = 0;
993
newStrut.right.height = screen->height ();
997
newStrut.top.width = screen->width ();
998
newStrut.top.height = 0;
990
newStrut.left.width = 0;
991
newStrut.left.height = screen->height ();
993
newStrut.right.x = screen->width ();
994
newStrut.right.y = 0;
995
newStrut.right.width = 0;
996
newStrut.right.height = screen->height ();
1000
newStrut.top.width = screen->width ();
1001
newStrut.top.height = 0;
1000
1003
newStrut.bottom.x = 0;
1001
1004
newStrut.bottom.y = screen->height ();
1002
1005
newStrut.bottom.width = screen->width ();
1003
1006
newStrut.bottom.height = 0;
1005
result = XGetWindowProperty (screen->dpy (), priv->id,
1006
Atoms::wmStrutPartial,
1007
0L, 12L, false, XA_CARDINAL, &actual, &format,
1008
int result = XGetWindowProperty (screen->dpy (), priv->id,
1009
Atoms::wmStrutPartial,
1010
0L, 12L, false, XA_CARDINAL, &actual, &format,
1010
1013
if (result == Success && data)
1283
1285
xev.event = priv->id;
1284
1286
xev.window = priv->id;
1286
xev.x = priv->serverGeometry.x ();
1287
xev.y = priv->serverGeometry.y ();
1288
xev.width = priv->serverGeometry.width ();
1289
xev.height = priv->serverGeometry.height ();
1290
xev.border_width = priv->serverGeometry.border ();
1288
xev.x = priv->serverGeometry.x ();
1289
xev.y = priv->serverGeometry.y ();
1290
xev.width = priv->serverGeometry.width ();
1291
xev.height = priv->serverGeometry.height ();
1292
xev.border_width = priv->serverGeometry.border ();
1291
1293
xev.override_redirect = priv->attrib.override_redirect;
1293
1295
/* These used to be based on the actual sibling of the window
1411
1410
if (!priv->shaded)
1412
1411
XUnmapWindow (screen->dpy (), priv->serverFrame);
1414
priv->unmapRefCnt--;
1413
--priv->unmapRefCnt;
1415
1415
if (priv->unmapRefCnt > 0)
1418
1418
if (priv->unmanaging)
1420
XWindowChanges xwc = XWINDOWCHANGES_INIT;
1420
XWindowChanges xwc = XWINDOWCHANGES_INIT;
1421
1421
unsigned int xwcm;
1422
int gravity = priv->sizeHints.win_gravity;
1422
int gravity = priv->sizeHints.win_gravity;
1424
1424
/* revert gravity adjustment made at MapNotify time */
1425
xwc.x = priv->serverGeometry.x ();
1426
xwc.y = priv->serverGeometry.y ();
1425
xwc.x = priv->serverGeometry.x ();
1426
xwc.y = priv->serverGeometry.y ();
1430
1430
xwcm = priv->adjustConfigureRequestForGravity (&xwc,
1552
1550
priv->geometry.height () != gm.height () ||
1553
1551
priv->geometry.border () != gm.border ())
1555
int dx, dy, dwidth, dheight;
1557
dx = gm.x () - priv->geometry.x ();
1558
dy = gm.y () - priv->geometry.y ();
1559
dwidth = gm.width () - priv->geometry.width ();
1560
dheight = gm.height () - priv->geometry.height ();
1553
int dx = gm.x () - priv->geometry.x ();
1554
int dy = gm.y () - priv->geometry.y ();
1555
int dwidth = gm.width () - priv->geometry.width ();
1556
int dheight = gm.height () - priv->geometry.height ();
1562
1558
priv->geometry.set (gm.x (), gm.y (),
1563
1559
gm.width (), gm.height (),
1633
1628
PrivateWindow::initializeSyncCounter ()
1635
XSyncAlarmAttributes values;
1638
unsigned long n, left;
1639
unsigned char *data;
1641
1630
if (syncCounter)
1642
1631
return syncAlarm != None;
1644
1633
if (!(protocols & CompWindowProtocolSyncRequestMask))
1647
result = XGetWindowProperty (screen->dpy (), id,
1648
Atoms::wmSyncRequestCounter,
1649
0L, 1L, false, XA_CARDINAL, &actual, &format,
1638
unsigned long n, left;
1639
unsigned char *data;
1641
int result = XGetWindowProperty (screen->dpy (), id,
1642
Atoms::wmSyncRequestCounter,
1643
0L, 1L, false, XA_CARDINAL, &actual, &format,
1652
1646
if (result == Success && n && data)
1843
1827
* re-sync the input extents and extents last
1844
1828
* sent to server on resize () */
1846
x = ce->x + priv->serverInput.left;
1847
y = ce->y + priv->serverInput.top;
1848
width = ce->width - priv->serverGeometry.border () * 2 - priv->serverInput.left - priv->serverInput.right;
1830
int x = ce->x + priv->serverInput.left;
1831
int y = ce->y + priv->serverInput.top;
1832
int width = ce->width - priv->serverGeometry.border () * 2 -
1833
priv->serverInput.left - priv->serverInput.right;
1850
1835
/* Don't use the server side frame geometry
1851
1836
* to determine the geometry of shaded
1852
1837
* windows since we didn't resize them
1853
1838
* on configureXWindow */
1854
1839
if (priv->shaded)
1855
height = priv->serverGeometry.heightIncBorders () - priv->serverInput.top - priv->serverInput.bottom;
1840
height = priv->serverGeometry.heightIncBorders () -
1841
priv->serverInput.top - priv->serverInput.bottom;
1857
height = ce->height + priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
1843
height = ce->height + priv->serverGeometry.border () * 2 -
1844
priv->serverInput.top - priv->serverInput.bottom;
1859
1846
/* set the frame geometry */
1860
1847
priv->frameGeometry.set (ce->x, ce->y, ce->width, ce->height, ce->border_width);
1863
1849
if (priv->syncWait)
1864
1850
priv->syncGeometry.set (x, y, width, height, ce->border_width);
2071
compiz::X11::PendingConfigureEvent::matchRequest (XWindowChanges &xwc, unsigned int valueMask)
2055
compiz::X11::PendingConfigureEvent::matchRequest (XWindowChanges &xwc,
2056
unsigned int valueMask)
2073
2058
if (matchVM (valueMask))
2075
if (valueMask & CWX)
2076
if (xwc.x != mXwc.x)
2079
if (valueMask & CWY)
2080
if (xwc.y != mXwc.y)
2083
if (valueMask & CWWidth)
2084
if (xwc.width != mXwc.width)
2087
if (valueMask & CWHeight)
2088
if (xwc.height != mXwc.height)
2091
if (valueMask & CWBorderWidth)
2092
if (xwc.border_width != mXwc.border_width)
2095
if (valueMask & (CWStackMode | CWSibling))
2096
if (xwc.sibling != mXwc.sibling)
2060
if ((valueMask & CWX && xwc.x != mXwc.x) ||
2061
(valueMask & CWY && xwc.y != mXwc.y) ||
2062
(valueMask & CWWidth && xwc.width != mXwc.width) ||
2063
(valueMask & CWHeight && xwc.height != mXwc.height) ||
2064
(valueMask & CWBorderWidth && xwc.border_width != mXwc.border_width) ||
2065
(valueMask & (CWStackMode | CWSibling) && xwc.sibling != mXwc.sibling))
2131
2100
compLogMessage ("core", CompLogLevelWarn, "no exact match for ConfigureNotify on 0x%x!", mWindow);
2132
2101
compLogMessage ("core", CompLogLevelWarn, "expected the following changes:");
2133
2103
if (mValueMask & CWX)
2134
2104
compLogMessage ("core", CompLogLevelWarn, "x: %i", mXwc.x);
2135
2106
if (mValueMask & CWY)
2136
2107
compLogMessage ("core", CompLogLevelWarn, "y: %i", mXwc.y);
2137
2109
if (mValueMask & CWWidth)
2138
2110
compLogMessage ("core", CompLogLevelWarn, "width: %i", mXwc.width);
2139
2112
if (mValueMask & CWHeight)
2140
2113
compLogMessage ("core", CompLogLevelWarn, "height: %i", mXwc.height);
2141
2115
if (mValueMask & CWBorderWidth)
2142
2116
compLogMessage ("core", CompLogLevelWarn, "border: %i", mXwc.border_width);
2143
2118
if (mValueMask & (CWStackMode | CWSibling))
2144
2119
compLogMessage ("core", CompLogLevelWarn, "sibling: 0x%x", mXwc.sibling);
2176
2151
WRAPABLE_HND_FUNCTN_RETURN (bool, focus)
2178
if (overrideRedirect ())
2181
if (!priv->managed || priv->unmanaging)
2184
if (!onCurrentDesktop ())
2187
if (priv->destroyed)
2190
if (!priv->shaded && (priv->state & CompWindowStateHiddenMask))
2193
if (priv->serverGeometry.x () + priv->serverGeometry.width () <= 0 ||
2153
if (overrideRedirect () ||
2156
!onCurrentDesktop () ||
2158
(!priv->shaded && (priv->state & CompWindowStateHiddenMask)) ||
2159
priv->serverGeometry.x () + priv->serverGeometry.width () <= 0 ||
2194
2160
priv->serverGeometry.y () + priv->serverGeometry.height () <= 0 ||
2195
priv->serverGeometry.x () >= (int) screen->width ()||
2161
priv->serverGeometry.x () >= (int) screen->width () ||
2196
2162
priv->serverGeometry.y () >= (int) screen->height ())
2214
2180
WRAPABLE_HND_FUNCTN (validateResizeRequest, mask, xwc, source)
2216
if (!(priv->type & (CompWindowTypeDockMask |
2217
CompWindowTypeFullscreenMask |
2218
CompWindowTypeUnknownMask)))
2182
if (!(priv->type & (CompWindowTypeDockMask |
2183
CompWindowTypeFullscreenMask |
2184
CompWindowTypeUnknownMask)))
2220
2186
if (mask & CWY)
2224
min = screen->workArea ().y () + priv->input.top;
2225
max = screen->workArea ().bottom ();
2188
int min = screen->workArea ().y () + priv->input.top;
2189
int max = screen->workArea ().bottom ();
2227
2191
if (priv->state & CompWindowStateStickyMask &&
2228
(xwc->y < min || xwc->y > max))
2192
(xwc->y < min || xwc->y > max))
2230
2193
xwc->y = priv->serverGeometry.y ();
2234
2196
min -= screen->vp ().y () * screen->height ();
2312
2270
if (!(lastState & CompWindowStateStickyMask) &&
2313
2271
(priv->state & CompWindowStateStickyMask))
2315
CompPoint vp; /* index of the window's vp */
2317
2273
/* Find which viewport the window falls in,
2318
2274
and check if it's the current viewport */
2319
vp = defaultViewport ();
2275
CompPoint vp = defaultViewport (); /* index of the window's vp */
2320
2277
if (screen->vp () != vp)
2322
2279
unsigned int valueMask = CWX | CWY;
2323
XWindowChanges xwc = XWINDOWCHANGES_INIT;
2280
XWindowChanges xwc = XWINDOWCHANGES_INIT;
2325
2282
xwc.x = serverGeometry ().x () + (screen->vp ().x () - vp.x ()) * screen->width ();
2326
2283
xwc.y = serverGeometry ().y () + (screen->vp ().y () - vp.y ()) * screen->height ();
2335
2291
PrivateWindow::isGroupTransient (Window clientLeader)
2337
2293
if (!clientLeader)
2340
if (transientFor == None || transientFor == screen->root ())
2342
if (type & (CompWindowTypeUtilMask |
2343
CompWindowTypeToolbarMask |
2344
CompWindowTypeMenuMask |
2345
CompWindowTypeDialogMask |
2346
CompWindowTypeModalDialogMask))
2348
if (this->clientLeader == clientLeader)
2296
if ((transientFor == None || transientFor == screen->root ()) &&
2297
(type & (CompWindowTypeUtilMask |
2298
CompWindowTypeToolbarMask |
2299
CompWindowTypeMenuMask |
2300
CompWindowTypeDialogMask |
2301
CompWindowTypeModalDialogMask) &&
2302
this->clientLeader == clientLeader))
2385
2335
for (w = screen->windows ().back (); w; w = w->prev)
2387
if (w == modalTransient || w->priv->mapNum == 0)
2390
if (isAncestorTo (modalTransient, w))
2393
if (w->priv->isGroupTransient (modalTransient->priv->clientLeader))
2337
if (w == modalTransient ||
2338
w->priv->mapNum == 0 ||
2339
isAncestorTo (modalTransient, w))
2342
if (w->priv->isGroupTransient (modalTransient->priv->clientLeader) &&
2343
w->priv->state & CompWindowStateModalMask)
2395
if (w->priv->state & CompWindowStateModalMask)
2346
w = w->priv->getModalTransient ();
2397
2349
modalTransient = w;
2398
w = w->priv->getModalTransient ();
2493
2440
if (priv->id == screen->activeWindow () ||
2494
2441
priv->id == screen->getNextActiveWindow())
2496
CompWindow *nextActive = screen->findWindow (screen->getNextActiveWindow());
2443
CompWindow *nextActive = screen->findWindow (screen->getNextActiveWindow ());
2498
/* Window pending focus */
2499
if (priv->id != screen->getNextActiveWindow() &&
2445
/* Window pending focus */
2446
if (priv->id != screen->getNextActiveWindow () &&
2501
2448
nextActive->focus ())
2503
2449
nextActive->moveInputFocusTo ();
2505
else if (priv->transientFor && priv->transientFor != screen->root ())
2450
else if (priv->transientFor &&
2451
priv->transientFor != screen->root ())
2507
CompWindow *ancestor;
2508
ancestor = screen->findWindow (priv->transientFor);
2510
ancestor->focus () &&
2453
CompWindow *ancestor = screen->findWindow (priv->transientFor);
2456
ancestor->focus () &&
2511
2457
!(ancestor->priv->type & (CompWindowTypeDesktopMask |
2512
2458
CompWindowTypeDockMask)))
2514
2459
ancestor->moveInputFocusTo ();
2517
2461
screen->focusDefaultWindow ();
2709
2639
if (below->priv->type & CompWindowTypeDesktopMask)
2713
case CompWindowTypeDesktopMask:
2714
/* desktop window layer */
2716
case CompWindowTypeFullscreenMask:
2719
/* otherwise fall-through */
2720
case CompWindowTypeDockMask:
2721
/* fullscreen and dock layer */
2722
if (below->priv->type & (CompWindowTypeFullscreenMask |
2723
CompWindowTypeDockMask))
2725
if (stackLayerCheck (w, clientLeader, below, lock) &&
2726
existsOnServer (below, lock))
2736
bool allowedRelativeToLayer = !(below->priv->type & belowMask);
2738
if (aboveFs && below->priv->type & CompWindowTypeFullscreenMask)
2739
if (!below->focus ())
2644
case CompWindowTypeDesktopMask:
2645
/* desktop window layer */
2648
case CompWindowTypeFullscreenMask:
2651
/* otherwise fall-through */
2652
case CompWindowTypeDockMask:
2653
/* fullscreen and dock layer */
2654
if (below->priv->type & (CompWindowTypeFullscreenMask |
2655
CompWindowTypeDockMask))
2657
if (stackLayerCheck (w, clientLeader, below, lock) &&
2658
existsOnServer (below, lock))
2668
bool allowedRelativeToLayer = !(below->priv->type & belowMask);
2670
if (aboveFs && below->priv->type & CompWindowTypeFullscreenMask &&
2742
t = screen->findWindow (below->transientFor ());
2744
while (t && allowedRelativeToLayer)
2746
/* dock stacking of transients for docks */
2747
allowedRelativeToLayer = !(t->priv->type & belowMask);
2749
t = screen->findWindow (t->transientFor ());
2752
/* fullscreen and normal layer */
2753
if (allowedRelativeToLayer)
2755
if (stackLayerCheck (w, clientLeader, below, lock) &&
2674
t = screen->findWindow (below->transientFor ());
2676
while (t && allowedRelativeToLayer)
2678
/* dock stacking of transients for docks */
2679
allowedRelativeToLayer = !(t->priv->type & belowMask);
2681
t = screen->findWindow (t->transientFor ());
2684
/* fullscreen and normal layer */
2685
if (allowedRelativeToLayer &&
2686
stackLayerCheck (w, clientLeader, below, lock) &&
2756
2687
existsOnServer (below, lock))
2771
2702
const ServerLock &lock)
2773
2704
CompWindow *below, *lowest = screen->serverWindows ().back ();
2774
CompWindow *t = screen->findWindow (w->transientFor ());
2775
Window clientLeader = w->priv->clientLeader;
2776
unsigned int type = w->priv->type;
2705
CompWindow *t = screen->findWindow (w->transientFor ());
2706
Window clientLeader = w->priv->clientLeader;
2707
unsigned int type = w->priv->type;
2778
2709
/* normal stacking fullscreen windows with below state */
2779
if ((type & CompWindowTypeFullscreenMask) &&
2780
(w->priv->state & CompWindowStateBelowMask))
2710
if (type & CompWindowTypeFullscreenMask &&
2711
w->priv->state & CompWindowStateBelowMask)
2781
2712
type = CompWindowTypeNormalMask;
2783
2714
while (t && type != CompWindowTypeDockMask)
2802
2732
/* always above desktop windows */
2803
if ((below->priv->type & CompWindowTypeDesktopMask) &&
2733
if (below->priv->type & CompWindowTypeDesktopMask &&
2804
2734
existsOnServer (below, lock))
2808
case CompWindowTypeDesktopMask:
2809
/* desktop window layer - desktop windows always should be
2739
case CompWindowTypeDesktopMask:
2740
/* desktop window layer - desktop windows always should be
2810
2741
stacked at the bottom; no other window should be below them */
2813
case CompWindowTypeFullscreenMask:
2814
case CompWindowTypeDockMask:
2815
/* fullscreen and dock layer */
2816
if (below->priv->type & (CompWindowTypeFullscreenMask |
2817
CompWindowTypeDockMask))
2819
if (!stackLayerCheck (below, clientLeader, w, lock) &&
2820
existsOnServer (lowest, lock))
2823
else if (existsOnServer (lowest, lock))
2828
bool allowedRelativeToLayer = !(below->priv->type & CompWindowTypeDockMask);
2830
t = screen->findWindow (below->transientFor ());
2832
while (t && allowedRelativeToLayer)
2834
/* dock stacking of transients for docks */
2835
allowedRelativeToLayer = !(t->priv->type & CompWindowTypeDockMask);
2837
t = screen->findWindow (t->transientFor ());
2840
/* fullscreen and normal layer */
2841
if (allowedRelativeToLayer)
2843
if (!stackLayerCheck (below, clientLeader, w, lock) &&
2844
existsOnServer (lowest, lock))
2745
case CompWindowTypeFullscreenMask:
2746
case CompWindowTypeDockMask:
2747
/* fullscreen and dock layer */
2748
if (below->priv->type & (CompWindowTypeFullscreenMask |
2749
CompWindowTypeDockMask))
2751
if (!stackLayerCheck (below, clientLeader, w, lock) &&
2752
existsOnServer (lowest, lock))
2755
else if (existsOnServer (lowest, lock))
2762
bool allowedRelativeToLayer = !(below->priv->type & CompWindowTypeDockMask);
2764
t = screen->findWindow (below->transientFor ());
2766
while (t && allowedRelativeToLayer)
2768
/* dock stacking of transients for docks */
2769
allowedRelativeToLayer = !(t->priv->type & CompWindowTypeDockMask);
2771
t = screen->findWindow (t->transientFor ());
2774
/* fullscreen and normal layer */
2775
if (allowedRelativeToLayer &&
2776
!stackLayerCheck (below, clientLeader, w, lock) &&
2777
existsOnServer (lowest, lock))
2851
2784
lowest = below;
2895
2827
if (sibling->priv->type & CompWindowTypeDesktopMask)
2899
case CompWindowTypeDesktopMask:
2900
/* desktop window layer */
2902
case CompWindowTypeFullscreenMask:
2903
case CompWindowTypeDockMask:
2904
/* fullscreen and dock layer */
2905
if (sibling->priv->type & (CompWindowTypeFullscreenMask |
2906
CompWindowTypeDockMask))
2908
if (stackLayerCheck (w, clientLeader, sibling, lock) &&
2909
existsOnServer (sibling, lock))
2912
else if (existsOnServer (sibling, lock))
2917
bool allowedRelativeToLayer = !(sibling->priv->type & CompWindowTypeDockMask);
2919
t = screen->findWindow (sibling->transientFor ());
2921
while (t && allowedRelativeToLayer)
2923
/* dock stacking of transients for docks */
2924
allowedRelativeToLayer = !(t->priv->type & CompWindowTypeDockMask);
2926
t = screen->findWindow (t->transientFor ());
2929
/* fullscreen and normal layer */
2930
if (allowedRelativeToLayer)
2932
if (stackLayerCheck (w, clientLeader, sibling, lock) &&
2832
case CompWindowTypeDesktopMask:
2833
/* desktop window layer */
2836
case CompWindowTypeFullscreenMask:
2837
case CompWindowTypeDockMask:
2838
/* fullscreen and dock layer */
2839
if (sibling->priv->type & (CompWindowTypeFullscreenMask |
2840
CompWindowTypeDockMask))
2842
if (stackLayerCheck (w, clientLeader, sibling, lock) &&
2843
existsOnServer (sibling, lock))
2846
else if (existsOnServer (sibling, lock))
2853
bool allowedRelativeToLayer = !(sibling->priv->type & CompWindowTypeDockMask);
2855
t = screen->findWindow (sibling->transientFor ());
2857
while (t && allowedRelativeToLayer)
2859
/* dock stacking of transients for docks */
2860
allowedRelativeToLayer = !(t->priv->type & CompWindowTypeDockMask);
2862
t = screen->findWindow (t->transientFor ());
2865
/* fullscreen and normal layer */
2866
if (allowedRelativeToLayer &&
2867
stackLayerCheck (w, clientLeader, sibling, lock) &&
2933
2868
existsOnServer (sibling, lock))
3122
3063
/* Remove redundant bits */
3124
xwc->x = valueMask & CWX ? xwc->x : serverGeometry.x ();
3125
xwc->y = valueMask & CWY ? xwc->y : serverGeometry.y ();
3126
xwc->width = valueMask & CWWidth ? xwc->width : serverGeometry.width ();
3127
xwc->height = valueMask & CWHeight ? xwc->height : serverGeometry.height ();
3065
xwc->x = valueMask & CWX ? xwc->x : serverGeometry.x ();
3066
xwc->y = valueMask & CWY ? xwc->y : serverGeometry.y ();
3067
xwc->width = valueMask & CWWidth ? xwc->width : serverGeometry.width ();
3068
xwc->height = valueMask & CWHeight ? xwc->height : serverGeometry.height ();
3128
3069
xwc->border_width = valueMask & CWBorderWidth ? xwc->border_width : serverGeometry.border ();
3130
3071
/* Don't allow anything that might generate a BadValue */
3163
3104
if (valueMask & CWBorderWidth && serverGeometry.border () == xwc->border_width)
3164
3105
valueMask &= ~(CWBorderWidth);
3166
if (valueMask & CWSibling && window->serverPrev)
3107
/* check if the sibling is also pending a restack,
3108
* if not, then setting this bit is useless */
3109
if (valueMask & CWSibling && window->serverPrev &&
3110
ROOTPARENT (window->serverPrev) == xwc->sibling)
3168
/* check if the sibling is also pending a restack,
3169
* if not, then setting this bit is useless */
3170
if (ROOTPARENT (window->serverPrev) == xwc->sibling)
3172
bool matchingRequest = priv->pendingConfigures.forEachIf (boost::bind (isExistingRequest, _1, *xwc, valueMask));
3173
bool restackPending = window->serverPrev->priv->pendingConfigures.forEachIf (boost::bind (isPendingRestack, _1));
3174
bool remove = matchingRequest;
3177
remove = !restackPending;
3180
valueMask &= ~(CWSibling | CWStackMode);
3112
bool matchingRequest = priv->pendingConfigures.forEachIf (boost::bind (isExistingRequest, _1, *xwc, valueMask));
3113
bool restackPending = window->serverPrev->priv->pendingConfigures.forEachIf (boost::bind (isPendingRestack, _1));
3114
bool remove = matchingRequest;
3117
remove = !restackPending;
3120
valueMask &= ~(CWSibling | CWStackMode);
3184
3123
if (valueMask & CWBorderWidth)
3235
if (serverFrameGeometry.height () == serverGeometry.border () * 2
3236
+ serverInput.top + serverInput.bottom)
3174
if (serverFrameGeometry.height () == serverGeometry.border () * 2 +
3175
serverInput.top + serverInput.bottom)
3237
3176
frameValueMask &= ~(CWHeight);
3241
if (serverFrameGeometry.height () == xwc->height + serverGeometry.border () * 2
3242
+ serverInput.top + serverInput.bottom)
3180
if (serverFrameGeometry.height () == xwc->height + serverGeometry.border () * 2 +
3181
serverInput.top + serverInput.bottom)
3243
3182
frameValueMask &= ~(CWHeight);
3247
if (valueMask & CWStackMode &&
3248
((xwc->stack_mode != TopIf) && (xwc->stack_mode != BottomIf) && (xwc->stack_mode != Opposite) &&
3249
(xwc->stack_mode != Above) && (xwc->stack_mode != Below)))
3186
if (valueMask & CWStackMode &&
3187
xwc->stack_mode != TopIf &&
3188
xwc->stack_mode != BottomIf &&
3189
xwc->stack_mode != Opposite &&
3190
xwc->stack_mode != Above &&
3191
xwc->stack_mode != Below)
3251
3193
compLogMessage ("core", CompLogLevelWarn, "Invalid stack mode %i", xwc->stack_mode);
3252
3194
valueMask &= ~(CWStackMode | CWSibling);
3300
3242
serverFrameGeometry.setY (xwc->y -serverGeometry.border () - serverInput.top);
3302
3244
if (frameValueMask & CWWidth)
3303
serverFrameGeometry.setWidth (xwc->width + serverGeometry.border () * 2
3304
+ serverInput.left + serverInput.right);
3245
serverFrameGeometry.setWidth (xwc->width + serverGeometry.border () * 2 +
3246
serverInput.left + serverInput.right);
3308
3250
if (frameValueMask & CWHeight)
3309
serverFrameGeometry.setHeight (serverGeometry.border () * 2
3310
+ serverInput.top + serverInput.bottom);
3314
if (frameValueMask & CWHeight)
3315
serverFrameGeometry.setHeight (xwc->height + serverGeometry.border () * 2
3316
+ serverInput.top + serverInput.bottom);
3251
serverFrameGeometry.setHeight (serverGeometry.border () * 2 +
3252
serverInput.top + serverInput.bottom);
3254
else if (frameValueMask & CWHeight)
3255
serverFrameGeometry.setHeight (xwc->height + serverGeometry.border () * 2 +
3256
serverInput.top + serverInput.bottom);
3319
3258
if (serverFrame)
3328
3267
* update the client and wrapper position */
3329
3268
if (lastServerInput.left != serverInput.left)
3330
3269
valueMask |= CWX;
3331
3271
if (lastServerInput.top != serverInput.top)
3332
3272
valueMask |= CWY;
3334
3274
/* Calculate frame extents and protect against underflow */
3335
const unsigned int lastWrapperWidth = std::max (0, serverFrameGeometry.width () -
3336
(lastServerInput.right + lastServerInput.left));
3275
const unsigned int lastWrapperWidth = std::max (0, serverFrameGeometry.width () -
3276
(lastServerInput.right + lastServerInput.left));
3337
3277
const unsigned int lastWrapperHeight = std::max (0, serverFrameGeometry.height () -
3338
(lastServerInput.bottom + lastServerInput.top));
3339
const unsigned int wrapperWidth = std::max (0, serverFrameGeometry.width () -
3340
(serverInput.right + serverInput.left));
3341
const unsigned int wrapperHeight = std::max (0, serverFrameGeometry.height () -
3342
(serverInput.bottom + serverInput.top));
3278
(lastServerInput.bottom + lastServerInput.top));
3279
const unsigned int wrapperWidth = std::max (0, serverFrameGeometry.width () -
3280
(serverInput.right + serverInput.left));
3281
const unsigned int wrapperHeight = std::max (0, serverFrameGeometry.height () -
3282
(serverInput.bottom + serverInput.top));
3344
3284
if (lastWrapperWidth != wrapperWidth)
3345
3285
valueMask |= CWWidth;
3346
3287
if (lastWrapperHeight != wrapperHeight)
3347
3288
valueMask |= CWHeight;
3411
3356
const ServerLock &lock)
3413
3358
CompWindow *firstFullscreenWindow = NULL;
3414
CompWindow *belowDocks = NULL;
3359
CompWindow *belowDocks = NULL;
3360
bool currentlyManaged, visible, ancestorToClient, acceptableType;
3416
3362
foreach (CompWindow *dw, screen->serverWindows ())
3418
/* fullscreen window found */
3419
if (firstFullscreenWindow)
3364
/* fullscreen window found */
3365
if (firstFullscreenWindow)
3367
currentlyManaged = dw->priv->managed && !dw->priv->unmanaging;
3368
visible = !(dw->state () & CompWindowStateHiddenMask);
3369
ancestorToClient = PrivateWindow::isAncestorTo (w, dw);
3370
acceptableType = !(dw->type () & (CompWindowTypeFullscreenMask |
3371
CompWindowTypeDockMask));
3421
3373
/* If there is another toplevel window above the fullscreen one
3422
3374
* then we need to stack above that */
3423
bool currentlyManaged = dw->priv->managed && !dw->priv->unmanaging;
3424
bool visible = !(dw->state () & CompWindowStateHiddenMask);
3425
bool ancestorToClient = PrivateWindow::isAncestorTo (w, dw);
3426
bool acceptableType = !(dw->type () & (CompWindowTypeFullscreenMask |
3427
CompWindowTypeDockMask));
3428
if (currentlyManaged &&
3431
!ancestorToClient &&
3432
!dw->overrideRedirect () &&
3435
if (existsOnServer (dw, lock))
3439
else if (dw->type () & CompWindowTypeFullscreenMask)
3375
if (currentlyManaged &&
3378
!ancestorToClient &&
3379
!dw->overrideRedirect () &&
3380
dw->isViewable () &&
3381
existsOnServer (dw, lock))
3384
else if (dw->type () & CompWindowTypeFullscreenMask)
3441
3386
/* First fullscreen window found when checking up the stack
3442
3387
* now go back down to find a suitable candidate client
3443
3388
* window to put the docks above */
3444
firstFullscreenWindow = dw;
3389
firstFullscreenWindow = dw;
3445
3391
for (CompWindow *dww = dw->serverPrev; dww; dww = dww->serverPrev)
3447
bool currentlyManaged = dw->priv->managed && !dw->priv->unmanaging;
3448
bool visible = !(dw->priv->state & CompWindowStateHiddenMask);
3449
bool acceptableType = !(dww->type () & (CompWindowTypeFullscreenMask |
3450
CompWindowTypeDockMask));
3451
if (currentlyManaged &&
3454
!dww->overrideRedirect () &&
3457
if (existsOnServer (dww, lock))
3393
currentlyManaged = dw->priv->managed && !dw->priv->unmanaging;
3394
visible = !(dw->state () & CompWindowStateHiddenMask);
3395
acceptableType = !(dw->type () & (CompWindowTypeFullscreenMask |
3396
CompWindowTypeDockMask));
3398
if (currentlyManaged &&
3401
!dww->overrideRedirect () &&
3402
dww->isViewable () &&
3403
existsOnServer (dww, lock))
3467
3412
if (belowDocks)
3469
*mask = CWSibling | CWStackMode;
3470
xwc->sibling = ROOTPARENT (belowDocks);
3414
*mask = CWSibling | CWStackMode;
3415
xwc->sibling = ROOTPARENT (belowDocks);
3472
/* Collect all dock windows first */
3417
/* Collect all dock windows first */
3473
3418
foreach (CompWindow *dw, screen->serverWindows ())
3474
if (dw->priv->type & CompWindowTypeDockMask)
3475
updateList.push_front (dw);
3419
if (dw->priv->type & CompWindowTypeDockMask)
3420
updateList.push_front (dw);
3484
PrivateWindow::stackTransients (CompWindow *w,
3429
PrivateWindow::stackTransients (CompWindow *w,
3486
3431
XWindowChanges *xwc,
3487
3432
CompWindowList &updateList,
3488
3433
const ServerLock &lock)
3491
Window clientLeader = w->priv->clientLeader;
3435
Window clientLeader = w->priv->clientLeader;
3493
3437
if (w->priv->transientFor || w->priv->isGroupTransient (clientLeader))
3494
3438
clientLeader = None;
3496
for (t = screen->serverWindows ().back (); t; t = t->serverPrev)
3440
for (CompWindow *t = screen->serverWindows ().back (); t; t = t->serverPrev)
3498
3442
if (t == w || t == avoid)
3501
3445
if (t->priv->transientFor == w->priv->id ||
3502
3446
t->priv->isGroupTransient (clientLeader))
3504
if (!stackTransients (t, avoid, xwc, updateList, lock))
3507
if (xwc->sibling == t->priv->id ||
3448
if (!stackTransients (t, avoid, xwc, updateList, lock) ||
3449
xwc->sibling == t->priv->id ||
3508
3450
(t->priv->serverFrame && xwc->sibling == t->priv->serverFrame))
3511
if (t->priv->mapNum || t->priv->pendingMaps)
3513
if (existsOnServer (t, lock))
3514
updateList.push_back (t);
3453
if ((t->priv->mapNum || t->priv->pendingMaps) &&
3454
existsOnServer (t, lock))
3455
updateList.push_back (t);
3534
3474
xwc->sibling != transient->priv->id &&
3535
3475
(!transient->priv->serverFrame || xwc->sibling != transient->priv->serverFrame))
3537
CompWindow *ancestor;
3477
CompWindow *ancestor = screen->findWindow (w->priv->transientFor);
3539
ancestor = screen->findWindow (w->priv->transientFor);
3542
if (!stackTransients (ancestor, w, xwc, updateList, lock))
3545
if (ancestor->priv->type & CompWindowTypeDesktopMask)
3548
if (ancestor->priv->type & CompWindowTypeDockMask)
3549
if (!(w->priv->type & CompWindowTypeDockMask))
3552
if (ancestor->priv->mapNum || ancestor->priv->pendingMaps)
3553
if (existsOnServer (ancestor, lock))
3554
updateList.push_back (ancestor);
3481
if (!stackTransients (ancestor, w, xwc, updateList, lock) ||
3482
ancestor->priv->type & CompWindowTypeDesktopMask ||
3483
(ancestor->priv->type & CompWindowTypeDockMask && !(w->priv->type & CompWindowTypeDockMask)))
3486
if ((ancestor->priv->mapNum || ancestor->priv->pendingMaps) &&
3487
existsOnServer (ancestor, lock))
3488
updateList.push_back (ancestor);
3556
3490
stackAncestors (ancestor, xwc, updateList, lock);
3559
3493
else if (w->priv->isGroupTransient (w->priv->clientLeader))
3563
for (a = screen->serverWindows ().back (); a; a = a->serverPrev)
3495
for (CompWindow *a = screen->serverWindows ().back (); a; a = a->serverPrev)
3565
3497
if (a->priv->clientLeader == w->priv->clientLeader &&
3566
3498
a->priv->transientFor == None &&
3567
3499
!a->priv->isGroupTransient (w->priv->clientLeader))
3569
3501
if (xwc->sibling == a->priv->id ||
3570
(a->priv->serverFrame && xwc->sibling == a->priv->serverFrame))
3573
if (!stackTransients (a, w, xwc, updateList, lock))
3502
(a->priv->serverFrame && xwc->sibling == a->priv->serverFrame) ||
3503
!stackTransients (a, w, xwc, updateList, lock))
3576
3506
if (a->priv->type & CompWindowTypeDesktopMask)
3579
if (a->priv->type & CompWindowTypeDockMask)
3580
if (!(w->priv->type & CompWindowTypeDockMask))
3509
if (a->priv->type & CompWindowTypeDockMask &&
3510
!(w->priv->type & CompWindowTypeDockMask))
3583
if (a->priv->mapNum || a->priv->pendingMaps)
3584
if (existsOnServer (a, lock))
3585
updateList.push_back (a);
3513
if ((a->priv->mapNum || a->priv->pendingMaps) &&
3514
existsOnServer (a, lock))
3515
updateList.push_back (a);
3651
3581
Window sibling = xwc->sibling;
3652
3582
xwc->stack_mode = Above;
3654
/* Then update the dock windows */
3655
foreach (CompWindow *dw, docks)
3657
xwc->sibling = sibling;
3658
dw->priv->reconfigureXWindow (valueMask, xwc);
3584
/* Then update the dock windows */
3585
foreach (CompWindow *dw, docks)
3587
xwc->sibling = sibling;
3588
dw->priv->reconfigureXWindow (valueMask, xwc);
3663
3593
else if (priv->id)
3665
3594
priv->reconfigureXWindow (valueMask, xwc);
3670
3598
PrivateWindow::addWindowSizeChanges (XWindowChanges *xwc,
3671
3599
CompWindow::Geometry old)
3677
3602
CompPoint viewport;
3679
3604
screen->viewportForGeometry (old, viewport);
3681
x = (viewport.x () - screen->vp ().x ()) * screen->width ();
3682
y = (viewport.y () - screen->vp ().y ()) * screen->height ();
3606
int x = (viewport.x () - screen->vp ().x ()) * screen->width ();
3607
int y = (viewport.y () - screen->vp ().y ()) * screen->height ();
3684
/* Try to select and output device that the window is on first
3685
* and make sure if we are fullscreening or maximizing that the
3686
* window is actually able to fit on this output ... otherwise
3687
* we're going to have to use another output device which sucks
3688
* but at least the user will be able to see all of the window */
3689
output = &screen->outputDevs ().at (screen->outputDeviceForGeometry (old));
3609
CompOutput *output = &screen->outputDevs ().at (screen->outputDeviceForGeometry (old));
3692
3612
* output is now the correct output for the given geometry.
3919
3838
PrivateWindow::adjustConfigureRequestForGravity (XWindowChanges *xwc,
3920
3839
unsigned int xwcm,
3925
3843
unsigned int mask = 0;
3930
3847
if (xwcm & (CWX | CWWidth))
3933
case NorthWestGravity:
3935
case SouthWestGravity:
3937
newX += priv->border.left * direction;
3944
newX -= (xwc->width / 2 - priv->border.left +
3945
(priv->border.left + priv->border.right) / 2) * direction;
3947
newX -= (xwc->width - priv->serverGeometry.width ()) * direction;
3950
case NorthEastGravity:
3952
case SouthEastGravity:
3954
newX -= xwc->width + priv->border.right * direction;
3956
newX -= (xwc->width - priv->serverGeometry.width ()) * direction;
3851
case NorthWestGravity:
3853
case SouthWestGravity:
3855
newX += priv->border.left * direction;
3862
newX -= (xwc->width / 2 - priv->border.left +
3863
(priv->border.left + priv->border.right) / 2) * direction;
3865
newX -= (xwc->width - priv->serverGeometry.width ()) * direction;
3869
case NorthEastGravity:
3871
case SouthEastGravity:
3873
newX -= xwc->width + priv->border.right * direction;
3875
newX -= (xwc->width - priv->serverGeometry.width ()) * direction;
3965
3885
if (xwcm & (CWY | CWHeight))
3968
case NorthWestGravity:
3970
case NorthEastGravity:
3972
newY = xwc->y + priv->border.top * direction;
3979
newY -= (xwc->height / 2 - priv->border.top +
3980
(priv->border.top + priv->border.bottom) / 2) * direction;
3982
newY -= ((xwc->height - priv->serverGeometry.height ()) / 2) * direction;
3985
case SouthWestGravity:
3987
case SouthEastGravity:
3989
newY -= xwc->height + priv->border.bottom * direction;
3991
newY -= (xwc->height - priv->serverGeometry.height ()) * direction;
3889
case NorthWestGravity:
3891
case NorthEastGravity:
3893
newY = xwc->y + priv->border.top * direction;
3901
newY -= (xwc->height / 2 - priv->border.top +
3902
(priv->border.top + priv->border.bottom) / 2) * direction;
3904
newY -= ((xwc->height - priv->serverGeometry.height ()) / 2) * direction;
3908
case SouthWestGravity:
3910
case SouthEastGravity:
3912
newY -= xwc->height + priv->border.bottom * direction;
3914
newY -= (xwc->height - priv->serverGeometry.height ()) * direction;
4210
4135
CompWindow::raise ()
4212
XWindowChanges xwc = XWINDOWCHANGES_INIT;
4214
bool aboveFs = false;
4137
XWindowChanges xwc = XWINDOWCHANGES_INIT;
4139
bool aboveFs = false;
4216
4141
/* an active fullscreen window should be raised over all other
4217
4142
windows in its layer */
4218
if (priv->type & CompWindowTypeFullscreenMask)
4219
if (priv->id == screen->activeWindow ())
4143
if (priv->type & CompWindowTypeFullscreenMask &&
4144
priv->id == screen->activeWindow ())
4222
4147
for (CompWindow *pw = serverPrev; pw; pw = pw->serverPrev)
4224
if (pw->priv->type & CompWindowTypeFullscreenMask)
4226
if (priv->id == screen->activeWindow ())
4148
if (pw->priv->type & CompWindowTypeFullscreenMask &&
4149
priv->id == screen->activeWindow ())
4233
4154
ServerLock lock (screen->serverGrabInterface ());
4277
4198
CompWindow::lower ()
4279
4200
XWindowChanges xwc = XWINDOWCHANGES_INIT;
4282
4202
ServerLock lock (screen->serverGrabInterface ());
4284
mask = priv->addWindowStackChanges (&xwc,
4204
int mask = priv->addWindowStackChanges (&xwc,
4285
4205
PrivateWindow::findLowestSiblingBelow (this, lock), lock);
4287
4208
restackAndConfigureXWindow (mask, &xwc, lock);
4289
4210
/* when lowering a window, focus the topmost window if
4290
4211
the click-to-focus option is on */
4291
if ((screen->getCoreOptions().optionGetClickToFocus ()))
4212
if ((screen->getCoreOptions ().optionGetClickToFocus ()))
4293
4214
CompWindow *focusedWindow = screen->focusTopMostWindow ();
4420
4332
if (overrideRedirect () || !priv->managed)
4423
XWindowChanges xwc = XWINDOWCHANGES_INIT;
4335
XWindowChanges xwc = XWINDOWCHANGES_INIT;
4426
4338
if (priv->state & CompWindowStateShadedMask && !priv->shaded)
4428
4340
windowNotify (CompWindowNotifyShade);
4432
4343
else if (priv->shaded)
4434
4345
windowNotify (CompWindowNotifyUnshade);
4439
4349
if (stackingMode != CompStackingUpdateModeNone)
4442
4351
CompWindow *sibling;
4444
aboveFs = (stackingMode == CompStackingUpdateModeAboveFullscreen);
4445
if (priv->type & CompWindowTypeFullscreenMask)
4353
bool aboveFs = (stackingMode == CompStackingUpdateModeAboveFullscreen);
4355
if (priv->type & CompWindowTypeFullscreenMask &&
4447
4356
/* put active or soon-to-be-active fullscreen windows over
4448
4357
all others in their layer */
4449
if (priv->id == screen->activeWindow () ||
4450
priv->id == screen->getNextActiveWindow())
4358
(priv->id == screen->activeWindow () ||
4359
priv->id == screen->getNextActiveWindow ()))
4456
4362
/* put windows that are just mapped, over fullscreen windows */
4457
4363
if (stackingMode == CompStackingUpdateModeInitialMap)
4506
4406
if (struts || attrib.override_redirect)
4509
if (type & (CompWindowTypeDockMask |
4409
if (type & (CompWindowTypeDockMask |
4510
4410
CompWindowTypeFullscreenMask |
4511
4411
CompWindowTypeUnknownMask))
4514
int x1 = screen->workArea ().x () - screen->width () * screen->vp ().x ();
4515
int y1 = screen->workArea ().y () - screen->height () * screen->vp ().y ();
4516
int x2 = x1 + screen->workArea ().width () + screen->vpSize ().width () *
4518
int y2 = y1 + screen->workArea ().height () + screen->vpSize ().height () *
4522
int width = serverGeometry.widthIncBorders ();
4414
int x1 = screen->workArea ().x () - screen->width () * screen->vp ().x ();
4415
int y1 = screen->workArea ().y () - screen->height () * screen->vp ().y ();
4416
int x2 = x1 + screen->workArea ().width () + screen->vpSize ().width () *
4418
int y2 = y1 + screen->workArea ().height () + screen->vpSize ().height () *
4422
int width = serverGeometry.widthIncBorders ();
4424
// TODO: Eliminate those magic numbers below
4524
4425
if (serverGeometry.x () - serverInput.left >= x2)
4525
4426
dx = (x2 - 25) - serverGeometry.x ();
4526
4427
else if (serverGeometry.x () + width + serverInput.right <= x1)
4527
4428
dx = (x1 + 25) - (serverGeometry.x () + width);
4530
4431
int height = serverGeometry.heightIncBorders ();
4532
4433
if (serverGeometry.y () - serverInput.top >= y2)
4594
4493
moveInputFocusTo ();
4598
4496
#define PVertResizeInc (1 << 0)
4599
4497
#define PHorzResizeInc (1 << 1)
4602
CompWindow::constrainNewWindowSize (int width,
4500
CompWindow::constrainNewWindowSize (int width,
4607
CompSize size (width, height);
4608
long ignoredHints = 0;
4609
long ignoredResizeHints = 0;
4505
CompSize size (width, height);
4506
long ignoredHints = 0;
4507
long ignoredResizeHints = 0;
4611
if (screen->getCoreOptions().optionGetIgnoreHintsWhenMaximized ())
4509
if (screen->getCoreOptions ().optionGetIgnoreHintsWhenMaximized ())
4613
4511
ignoredHints |= PAspect;
4818
4711
PrivateWindow::getUserTime (Time& time)
4822
4715
unsigned long n, left;
4823
4716
unsigned char *data;
4824
4717
bool retval = false;
4826
result = XGetWindowProperty (screen->dpy (), priv->id,
4828
0L, 1L, False, XA_CARDINAL, &actual, &format,
4719
int result = XGetWindowProperty (screen->dpy (), priv->id,
4721
0L, 1L, False, XA_CARDINAL, &actual, &format,
4831
4724
if (result == Success && data)
4919
4811
/* the caller passed a timestamp, so use that
4920
4812
instead of the window's user time */
4921
wUserTime = timestamp;
4813
wUserTime = timestamp;
4922
4814
gotTimestamp = true;
4926
4817
gotTimestamp = getUsageTimestamp (wUserTime);
4929
4819
/* if we got no timestamp for the window, try to get at least a timestamp
4930
4820
for its transient parent, if any */
4931
4821
if (!gotTimestamp && transientFor)
4823
CompWindow *parent = screen->findWindow (transientFor);
4935
parent = screen->findWindow (transientFor);
4937
4826
gotTimestamp = parent->priv->getUsageTimestamp (wUserTime);
4940
4829
if (gotTimestamp && !wUserTime)
4942
4830
/* window explicitly requested no focus */
4946
4833
/* allow focus for excluded windows */
4947
CompMatch &match = s->getCoreOptions().optionGetFocusPreventionMatch ();
4834
CompMatch &match = s->getCoreOptions ().optionGetFocusPreventionMatch ();
4948
4836
if (!match.evaluate (window))
4954
4842
active = s->findWindow (s->activeWindow ());
4956
4844
/* no active window */
4957
if (!active || (active->type () & CompWindowTypeDesktopMask))
4845
if (!active || (active->type () & CompWindowTypeDesktopMask) ||
4846
/* active window belongs to same application */
4847
window->clientLeader () == active->clientLeader ())
4960
/* active window belongs to same application */
4961
if (window->clientLeader () == active->clientLeader ())
4964
4850
if (level == CoreOptions::FocusPreventionLevelHigh)
4967
4853
/* not in current viewport or desktop */
4968
4854
if (!window->onCurrentDesktop ())
4971
4857
dvp = window->defaultViewport ();
4972
4859
if (dvp.x () != s->vp ().x () || dvp.y () != s->vp ().y ())
4996
4883
PrivateWindow::allowWindowFocus (unsigned int noFocusMask,
4997
4884
Time timestamp)
5001
4886
if (priv->id == screen->activeWindow ())
5004
4889
/* do not focus windows of these types */
5005
if (priv->type & noFocusMask)
5008
/* window doesn't take focus */
5009
if (!priv->inputHint &&
5010
!(priv->protocols & CompWindowProtocolTakeFocusMask))
5015
retval = priv->isWindowFocusAllowed (timestamp);
4890
if (priv->type & noFocusMask ||
4891
/* window doesn't take focus */
4892
!(priv->inputHint ||
4893
priv->protocols & CompWindowProtocolTakeFocusMask))
4896
bool retval = priv->isWindowFocusAllowed (timestamp);
4898
/* add demands attention state if focus was prevented */
5018
/* add demands attention state if focus was prevented */
5019
4900
window->changeState (priv->state | CompWindowStateDemandsAttentionMask);
5050
4928
PrivateWindow::readIconHint ()
5052
XImage *image, *maskImage = NULL;
5053
Display *dpy = screen->dpy ();
4930
XImage *maskImage = NULL;
4931
Display *dpy = screen->dpy ();
5054
4932
unsigned int width, height, dummy;
5055
unsigned int i, j, k;
5061
4937
if (!XGetGeometry (dpy, hints->icon_pixmap, &wDummy, &iDummy,
5062
4938
&iDummy, &width, &height, &dummy, &dummy))
5065
image = XGetImage (dpy, hints->icon_pixmap, 0, 0, width, height,
5066
AllPlanes, ZPixmap);
4941
XImage *image = XGetImage (dpy, hints->icon_pixmap, 0, 0, width, height,
4942
AllPlanes, ZPixmap);
5078
for (j = 0; j < height; j++)
5079
for (i = 0; i < width; i++)
4956
for (j = 0; j < height; ++j)
4957
for (i = 0; i < width; ++i)
5080
4958
colors[k++].pixel = XGetPixel (image, i, j);
5082
4960
for (i = 0; i < k; i += 256)
5083
XQueryColors (dpy, screen->colormap(),
4961
XQueryColors (dpy, screen->colormap (),
5084
4962
&colors[i], MIN (k - i, 256));
5086
4964
XDestroyImage (image);
5088
icon = new CompIcon (width, height);
4966
CompIcon *icon = new CompIcon (width, height);
5094
4971
if (hints->flags & IconMaskHint)
5095
4972
maskImage = XGetImage (dpy, hints->icon_mask, 0, 0,
5096
4973
width, height, AllPlanes, ZPixmap);
5099
p = (CARD32 *) icon->data ();
4976
CARD32 *p = (CARD32 *) icon->data ();
5101
for (j = 0; j < height; j++)
4978
for (j = 0; j < height; ++j)
5103
for (i = 0; i < width; i++)
4980
for (i = 0; i < width; ++i)
5105
4982
if (maskImage && !XGetPixel (maskImage, i, j))
5135
5012
/* need to fetch icon property */
5136
5013
if (priv->icons.size () == 0 && !priv->noIcons)
5140
5017
unsigned long n, left;
5141
5018
unsigned char *data;
5143
result = XGetWindowProperty (screen->dpy (), priv->id, Atoms::wmIcon,
5144
0L, 65536L, false, XA_CARDINAL,
5145
&actual, &format, &n, &left, &data);
5020
int result = XGetWindowProperty (screen->dpy (), priv->id, Atoms::wmIcon,
5021
0L, 65536L, false, XA_CARDINAL,
5022
&actual, &format, &n, &left, &data);
5147
5024
if (result == Success && data)
5150
5027
CARD32 alpha, red, green, blue;
5151
5028
unsigned long iw, ih;
5029
unsigned long *idata;
5153
5031
for (i = 0; i + 2 < n; i += iw * ih + 2)
5155
unsigned long *idata = (unsigned long *) data;
5033
idata = (unsigned long *) data;
5158
5036
ih = idata[i + 1];
5932
int vWidth = screen->width () * screen->vpSize ().width ();
5781
int vWidth = screen->width () * screen->vpSize ().width ();
5933
5782
int vHeight = screen->height () * screen->vpSize ().height ();
5935
5784
if (screen->vpSize ().width () != 1)
5937
5786
x += screen->vp ().x () * screen->width ();
5938
x = compiz::core::screen::wraparound_mod (x, vWidth);
5787
x = compiz::core::screen::wraparound_mod (x, vWidth);
5939
5788
x -= screen->vp ().x () * screen->width ();
5942
5791
if (screen->vpSize ().height () != 1)
5944
5793
y += screen->vp ().y () * screen->height ();
5945
y = compiz::core::screen::wraparound_mod (y, vHeight);
5794
y = compiz::core::screen::wraparound_mod (y, vHeight);
5946
5795
y -= screen->vp ().y () * screen->height ();
5949
tx = x - priv->serverGeometry.x ();
5950
ty = y - priv->serverGeometry.y ();
5798
int tx = x - priv->serverGeometry.x ();
5799
int ty = y - priv->serverGeometry.y ();
5954
5803
unsigned int valueMask = CWX | CWY;
5955
5804
XWindowChanges xwc = XWINDOWCHANGES_INIT;
5960
if (priv->type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask))
5963
if (priv->state & CompWindowStateStickyMask)
5806
if (!priv->managed ||
5807
priv->type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask) ||
5808
priv->state & CompWindowStateStickyMask)
6134
5971
notification, assume the client changing the ID
6135
5972
wanted to activate the window on the current viewport */
6137
vp = window->defaultViewport ();
6138
svp = screen->vp ();
5974
CompPoint vp = window->defaultViewport ();
5975
CompPoint svp = screen->vp ();
5976
CompSize size = *screen;
6141
x = window->serverGeometry ().x () + (svp.x () - vp.x ()) * size.width ();
6142
y = window->serverGeometry ().y () + (svp.y () - vp.y ()) * size.height ();
5978
int x = window->serverGeometry ().x () + (svp.x () - vp.x ()) * size.width ();
5979
int y = window->serverGeometry ().y () + (svp.y () - vp.y ()) * size.height ();
6143
5980
window->moveToViewportPosition (x, y, true);
6145
5982
if (allowWindowFocus (0, timestamp))
6146
5983
window->activate ();
6231
6067
if (priv->attrib.c_class != InputOnly)
6233
priv->region = CompRegion (priv->serverGeometry);
6069
priv->region = CompRegion (priv->serverGeometry);
6234
6070
priv->inputRegion = priv->region;
6236
6072
/* need to check for DisplayModal state on all windows */
6237
priv->state = screen->getWindowState (priv->id);
6073
priv->state = screen->getWindowState (priv->id);
6239
6075
priv->updateClassHints ();
6243
6078
priv->attrib.map_state = IsUnmapped;
6246
6080
priv->wmType = screen->getWindowType (priv->id);
6247
6081
priv->protocols = screen->getProtocols (priv->id);
6334
6163
screen->setWindowState (priv->state, priv->id);
6337
else if (!overrideRedirect ())
6166
else if (!overrideRedirect () &&
6167
screen->getWmState (priv->id) == IconicState)
6339
if (screen->getWmState (priv->id) == IconicState)
6169
// before everything else in maprequest
6170
if (!priv->serverFrame)
6173
priv->managed = true;
6174
priv->placed = true;
6176
if (priv->state & CompWindowStateHiddenMask)
6341
// before everything else in maprequest
6342
if (!priv->serverFrame)
6344
priv->managed = true;
6345
priv->placed = true;
6347
if (priv->state & CompWindowStateHiddenMask)
6349
if (priv->state & CompWindowStateShadedMask)
6350
priv->shaded = true;
6352
priv->minimized = true;
6178
if (priv->state & CompWindowStateShadedMask)
6179
priv->shaded = true;
6181
priv->minimized = true;
6357
6185
/* TODO: bailout properly when objectInitPlugins fails */
6358
6186
bool init_succeeded = CompPlugin::windowInitPlugins (this);
6359
6187
assert (init_succeeded);
6360
6189
if (!init_succeeded)
6363
6192
recalcActions ();
6364
6193
priv->updateIconGeometry ();
6727
6551
if (priv->serverFrame)
6732
6553
priv->frameRegion = emptyRegion;
6734
6555
updateFrameRegion (priv->frameRegion);
6736
6557
if (!shaded ())
6738
r = priv->region.boundingRect ();
6559
CompRect r = priv->region.boundingRect ();
6739
6560
priv->frameRegion -= r;
6741
6562
r.setGeometry (r.x1 () - priv->serverInput.left,
6742
r.y1 () - priv->serverInput.top,
6743
r.width () + priv->serverInput.right + priv->serverInput.left,
6744
r.height () + priv->serverInput.bottom + priv->serverInput.top);
6563
r.y1 () - priv->serverInput.top,
6564
r.width () + priv->serverInput.right + priv->serverInput.left,
6565
r.height () + priv->serverInput.bottom + priv->serverInput.top);
6746
6567
priv->frameRegion &= CompRegion (r);
6749
x = priv->serverGeometry.x () - priv->serverInput.left;
6750
y = priv->serverGeometry.y () - priv->serverInput.top;
6570
int x = priv->serverGeometry.x () - priv->serverInput.left;
6571
int y = priv->serverGeometry.y () - priv->serverInput.top;
6752
6573
XShapeCombineRegion (screen->dpy (), priv->serverFrame,
6753
6574
ShapeBounding, -x, -y,
6772
6593
/* Input extents are used for frame size,
6773
6594
* Border extents used for placement.
6779
if (priv->serverInput.left != i->left ||
6780
priv->serverInput.right != i->right ||
6781
priv->serverInput.top != i->top ||
6782
priv->serverInput.bottom != i->bottom ||
6783
priv->border.left != b->left ||
6784
priv->border.right != b->right ||
6785
priv->border.top != b->top ||
6599
if (priv->serverInput.left != i->left ||
6600
priv->serverInput.right != i->right ||
6601
priv->serverInput.top != i->top ||
6602
priv->serverInput.bottom != i->bottom ||
6603
priv->border.left != b->left ||
6604
priv->border.right != b->right ||
6605
priv->border.top != b->top ||
6786
6606
priv->border.bottom != b->bottom)
6788
6608
priv->serverInput = *i;
6791
6611
recalcActions ();
6848
6668
PrivateWindow::reparent ()
6850
6673
XSetWindowAttributes attr;
6851
6674
XWindowAttributes wa;
6852
XWindowChanges xwc = XWINDOWCHANGES_INIT;
6675
XWindowChanges xwc = XWINDOWCHANGES_INIT;
6854
6676
unsigned int nchildren;
6855
Window *children, root_return, parent_return;
6856
Display *dpy = screen->dpy ();
6857
Visual *visual = DefaultVisual (screen->dpy (),
6677
Window *children, root_return, parent_return;
6678
Display *dpy = screen->dpy ();
6679
Visual *visual = DefaultVisual (screen->dpy (),
6858
6680
screen->screenNum ());
6859
Colormap cmap = DefaultColormap (screen->dpy (),
6860
screen->screenNum ());
6681
Colormap cmap = DefaultColormap (screen->dpy (),
6682
screen->screenNum ());
6865
6684
XSync (dpy, false);
6866
6685
XGrabServer (dpy);
6994
6814
/* We don't care about client events on the frame, and listening for them
6995
6815
* will probably end up fighting the client anyways, so disable them */
6997
attr.do_not_propagate_mask = KeyPressMask | KeyReleaseMask |
6998
ButtonPressMask | ButtonReleaseMask |
6999
EnterWindowMask | LeaveWindowMask |
7000
PointerMotionMask | PointerMotionHintMask |
7001
Button1MotionMask | Button2MotionMask |
7002
Button3MotionMask | Button4MotionMask |
7003
Button5MotionMask | ButtonMotionMask |
7004
KeymapStateMask | ExposureMask |
7005
VisibilityChangeMask | StructureNotifyMask |
7006
ResizeRedirectMask | SubstructureNotifyMask |
7007
SubstructureRedirectMask | FocusChangeMask |
7008
PropertyChangeMask | ColormapChangeMask |
6817
attr.do_not_propagate_mask = KeyPressMask | KeyReleaseMask |
6818
ButtonPressMask | ButtonReleaseMask |
6819
EnterWindowMask | LeaveWindowMask |
6820
PointerMotionMask | PointerMotionHintMask |
6821
Button1MotionMask | Button2MotionMask |
6822
Button3MotionMask | Button4MotionMask |
6823
Button5MotionMask | ButtonMotionMask |
6824
KeymapStateMask | ExposureMask |
6825
VisibilityChangeMask | StructureNotifyMask |
6826
ResizeRedirectMask | SubstructureNotifyMask |
6827
SubstructureRedirectMask | FocusChangeMask |
6828
PropertyChangeMask | ColormapChangeMask |
7009
6829
OwnerGrabButtonMask;
7011
6831
XChangeWindowAttributes (dpy, id, CWEventMask | CWDontPropagate, &attr);
7051
6870
PrivateWindow::unreparent ()
7053
Display *dpy = screen->dpy ();
7056
XWindowChanges xwc = XWINDOWCHANGES_INIT;
7057
unsigned int nchildren;
7058
Window *children = NULL, root_return, parent_return;
7059
XWindowAttributes wa;
7060
StackDebugger *dbg = StackDebugger::Default ();
7062
6872
if (!serverFrame)
6875
Display *dpy = screen->dpy ();
6878
XWindowChanges xwc = XWINDOWCHANGES_INIT;
6879
unsigned int nchildren;
6880
Window *children = NULL, root_return, parent_return;
6881
XWindowAttributes wa;
6882
StackDebugger *dbg = StackDebugger::Default ();
7065
6884
XSync (dpy, false);
7067
6886
if (XCheckTypedWindowEvent (dpy, id, DestroyNotify, &e))