From e4f9df54e6f6f7db493ac8e20fbcdac393bbd270 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 30 Aug 2024 14:33:12 +0000 Subject: [PATCH] inputmethod: Only align within availableGeometry if it fits An input panel in Overlay mode controls it's own size. If there's space we want to fit it centre aligned within the available space, but if it doesn't fit (i.e having a left panel and a full width keyboard) then centre aligning within the available space doesn't make sense. We would half overlap the panel and half go offscreen. This patch adjusts us to centre align to the output in that condition. BUG: 440571 --- src/inputpanelv1window.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/inputpanelv1window.cpp b/src/inputpanelv1window.cpp index 7fcf29689f..7b2b613fd7 100644 --- a/src/inputpanelv1window.cpp +++ b/src/inputpanelv1window.cpp @@ -98,7 +98,15 @@ void InputPanelV1Window::resetPosition() } QRectF geo = m_windowGeometry; - geo.moveLeft(availableArea.left() + (availableArea.width() - geo.width()) / 2); + + // if it fits, align within available area + if (geo.width() < availableArea.width()) { + geo.moveLeft(availableArea.left() + (availableArea.width() - geo.width()) / 2); + } else { // otherwise align to be centred within the screen + const QRectF outputArea = activeOutput->geometry(); + geo.moveLeft(outputArea.left() + (outputArea.width() - geo.width()) / 2); + } + geo.moveBottom(availableArea.bottom()); moveResize(geo);