From 7cb4b51d5e6c9c5c5a609146868352b9c0df158a Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 4 Jan 2023 12:22:31 +0100 Subject: [PATCH] inputpanel: ignore requested output While there's specific hardware where the IM could benefit from requesting to be shown on a specific output, it effectively never has enough information to choose a useful output - and the protocol doesn't allow setting a null output to indicate that the compositor should do the choice. To avoid showing the OSK on the wrong output, always put it on the active output and ignore what the IM client requests. --- src/inputpanelv1window.cpp | 32 +++++++------------------------- src/inputpanelv1window.h | 2 -- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/inputpanelv1window.cpp b/src/inputpanelv1window.cpp index d438b12a13..8673faa36d 100644 --- a/src/inputpanelv1window.cpp +++ b/src/inputpanelv1window.cpp @@ -41,12 +41,13 @@ InputPanelV1Window::InputPanelV1Window(InputPanelSurfaceV1Interface *panelSurfac connect(panelSurface, &InputPanelSurfaceV1Interface::overlayPanel, this, &InputPanelV1Window::showOverlayPanel); connect(panelSurface, &InputPanelSurfaceV1Interface::destroyed, this, &InputPanelV1Window::destroyWindow); + connect(workspace(), &Workspace::outputsChanged, this, &InputPanelV1Window::reposition); + kwinApp()->inputMethod()->setPanel(this); } void InputPanelV1Window::showOverlayPanel() { - setOutput(nullptr); m_mode = Mode::Overlay; maybeShow(); } @@ -54,7 +55,6 @@ void InputPanelV1Window::showOverlayPanel() void InputPanelV1Window::showTopLevel(OutputInterface *output, InputPanelSurfaceV1Interface::Position position) { m_mode = Mode::VirtualKeyboard; - setOutput(output); maybeShow(); } @@ -94,18 +94,13 @@ void KWin::InputPanelV1Window::reposition() return; } + const auto activeOutput = workspace()->activeOutput(); + const QRectF outputArea = activeOutput->geometry(); QRectF availableArea; - QRectF outputArea; - if (m_output) { - outputArea = m_output->geometry(); - if (waylandServer()->isScreenLocked()) { - availableArea = outputArea; - } else { - availableArea = workspace()->clientArea(MaximizeArea, this, m_output); - } + if (waylandServer()->isScreenLocked()) { + availableArea = outputArea; } else { - availableArea = workspace()->clientArea(MaximizeArea, this); - outputArea = workspace()->clientArea(FullScreenArea, this); + availableArea = workspace()->clientArea(MaximizeArea, this, activeOutput); } panelSize = panelSize.boundedTo(availableArea.size()); @@ -180,19 +175,6 @@ QRectF InputPanelV1Window::inputGeometry() const return readyForPainting() ? QRectF(surface()->input().boundingRect()).translated(pos()) : QRectF(); } -void InputPanelV1Window::setOutput(OutputInterface *outputIface) -{ - if (m_output) { - disconnect(m_output, &Output::geometryChanged, this, &InputPanelV1Window::reposition); - } - - m_output = outputIface ? outputIface->handle() : nullptr; - - if (m_output) { - connect(m_output, &Output::geometryChanged, this, &InputPanelV1Window::reposition); - } -} - void InputPanelV1Window::moveResizeInternal(const QRectF &rect, MoveResizeMode mode) { updateGeometry(rect); diff --git a/src/inputpanelv1window.h b/src/inputpanelv1window.h index 7fba3d7af3..54d013f697 100644 --- a/src/inputpanelv1window.h +++ b/src/inputpanelv1window.h @@ -88,11 +88,9 @@ private: void showTopLevel(KWaylandServer::OutputInterface *output, KWaylandServer::InputPanelSurfaceV1Interface::Position position); void showOverlayPanel(); void reposition(); - void setOutput(KWaylandServer::OutputInterface *output); void handleMapped(); void maybeShow(); - QPointer m_output; Mode m_mode = Mode::None; bool m_allowed = false; bool m_virtualKeyboardShouldBeShown = false;