@@ -239,11 +239,28 @@ void XPanelWindow::connectScreen() {
239239 this ,
240240 &XPanelWindow::updateDimensionsSlot
241241 );
242+
243+ QObject::connect (
244+ this ->mTrackedScreen ,
245+ &QScreen::virtualGeometryChanged,
246+ this ,
247+ &XPanelWindow::onScreenVirtualGeometryChanged
248+
249+ );
242250 }
243251
244252 this ->updateDimensions ();
245253}
246254
255+ // For some reason this gets sent multiple times with the same value.
256+ void XPanelWindow::onScreenVirtualGeometryChanged () {
257+ auto geometry = this ->mTrackedScreen ->virtualGeometry ();
258+ if (geometry != this ->lastScreenVirtualGeometry ) {
259+ this ->lastScreenVirtualGeometry = geometry;
260+ this ->updateStrut (false );
261+ }
262+ }
263+
247264void XPanelWindow::updateDimensionsSlot () { this ->updateDimensions (); }
248265
249266void XPanelWindow::updateDimensions (bool propagate) {
@@ -384,16 +401,22 @@ void XPanelWindow::updateStrut(bool propagate) {
384401 return ;
385402 }
386403
387- // Due to missing headers it isn't even possible to do this right.
388- // We assume a single xinerama monitor with a matching size root.
404+ auto rootGeometry = this ->window ->screen ()->virtualGeometry ();
389405 auto screenGeometry = this ->window ->screen ()->geometry ();
390406 auto horizontal = side == 0 || side == 1 ;
391407
408+ switch (side) {
409+ case 0 : exclusiveZone += screenGeometry.left (); break ;
410+ case 1 : exclusiveZone += rootGeometry.right () - screenGeometry.right (); break ;
411+ case 2 : exclusiveZone += screenGeometry.top (); break ;
412+ case 3 : exclusiveZone += rootGeometry.bottom () - screenGeometry.bottom (); break ;
413+ default : break ;
414+ }
415+
392416 auto data = std::array<quint32, 12 >();
393417 data[side] = exclusiveZone;
394418
395- auto start = horizontal ? screenGeometry.top () + this ->window ->y ()
396- : screenGeometry.left () + this ->window ->x ();
419+ auto start = horizontal ? this ->window ->y () : this ->window ->x ();
397420
398421 data[4 + side * 2 ] = start;
399422 data[5 + side * 2 ] = start + (horizontal ? this ->window ->height () : this ->window ->width ());
0 commit comments