Skip to content

Commit

Permalink
Fixed main popup positions under Wayland
Browse files Browse the repository at this point in the history
… for bottom and right panels.

The problem was that some Wayland compositors returned global coordinates when anchors were applied, while some others (perhaps KWin) didn't. So, the patch uses local coordinates and changes them to the global ones in the end.
  • Loading branch information
tsujan committed Aug 21, 2024
1 parent aac052c commit 9906eef
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions panel/lxqtpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,28 +1416,35 @@ Plugin* LXQtPanel::findPlugin(const ILXQtPanelPlugin* iPlugin) const
************************************************/
QRect LXQtPanel::calculatePopupWindowPos(QPoint const & absolutePos, QSize const & windowSize) const
{
int x = absolutePos.x(), y = absolutePos.y();
// Using of anchors makes coordinates be absolute under some Wayland compositors.
// Therefore, to cover both X11 and Wayland, we first use the local coordinates
// and then map them to the global coordinates.
QPoint localPos = mapFromGlobal(absolutePos);
int x = localPos.x(), y = localPos.y();

switch (position())
{
case ILXQtPanel::PositionTop:
y = mGeometry.bottom();
y = mGeometry.height();
break;

case ILXQtPanel::PositionBottom:
y = mGeometry.top() - windowSize.height();
y = -windowSize.height();
break;

case ILXQtPanel::PositionLeft:
x = mGeometry.right();
x = mGeometry.width();
break;

case ILXQtPanel::PositionRight:
x = mGeometry.left() - windowSize.width();
x = -windowSize.width();
break;
}

QRect res(QPoint(x, y), windowSize);
QRect res(mapToGlobal(QPoint(x, y)), windowSize);

if (qGuiApp->nativeInterface<QNativeInterface::QWaylandApplication>())
return res;

QRect panelScreen;
const auto screens = QApplication::screens();
Expand Down

0 comments on commit 9906eef

Please sign in to comment.