layershell: restore focus to layer shell surface after popup is destroyed (#13225)
This commit is contained in:
parent
f68ac7ef75
commit
6507445787
1 changed files with 21 additions and 12 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../protocols/ExtDataDevice.hpp"
|
#include "../protocols/ExtDataDevice.hpp"
|
||||||
#include "../protocols/PrimarySelection.hpp"
|
#include "../protocols/PrimarySelection.hpp"
|
||||||
#include "../protocols/core/Compositor.hpp"
|
#include "../protocols/core/Compositor.hpp"
|
||||||
|
#include "../protocols/LayerShell.hpp"
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
#include "../desktop/state/FocusState.hpp"
|
#include "../desktop/state/FocusState.hpp"
|
||||||
#include "../devices/IKeyboard.hpp"
|
#include "../devices/IKeyboard.hpp"
|
||||||
|
|
@ -618,8 +619,9 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
||||||
if (m_seatGrab) {
|
if (m_seatGrab) {
|
||||||
auto oldGrab = m_seatGrab;
|
auto oldGrab = m_seatGrab;
|
||||||
|
|
||||||
// Try to find the parent window from the grab
|
// Try to find the parent window or layer surface from the grab
|
||||||
PHLWINDOW parentWindow;
|
PHLWINDOW parentWindow;
|
||||||
|
PHLLS parentLayer;
|
||||||
if (oldGrab && oldGrab->m_surfs.size()) {
|
if (oldGrab && oldGrab->m_surfs.size()) {
|
||||||
// Try to find the surface that had focus when the grab ended
|
// Try to find the surface that had focus when the grab ended
|
||||||
SP<CWLSurfaceResource> focusedSurf;
|
SP<CWLSurfaceResource> focusedSurf;
|
||||||
|
|
@ -645,8 +647,11 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
||||||
auto popup = Desktop::View::CPopup::fromView(hlSurface->view());
|
auto popup = Desktop::View::CPopup::fromView(hlSurface->view());
|
||||||
if (popup) {
|
if (popup) {
|
||||||
auto t1Owner = popup->getT1Owner();
|
auto t1Owner = popup->getT1Owner();
|
||||||
if (t1Owner)
|
if (t1Owner) {
|
||||||
parentWindow = Desktop::View::CWindow::fromView(t1Owner->view());
|
parentWindow = Desktop::View::CWindow::fromView(t1Owner->view());
|
||||||
|
if (!parentWindow)
|
||||||
|
parentLayer = Desktop::View::CLayerSurface::fromView(t1Owner->view());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -654,18 +659,22 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
||||||
|
|
||||||
m_seatGrab.reset();
|
m_seatGrab.reset();
|
||||||
|
|
||||||
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
if (parentLayer && parentLayer->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) {
|
||||||
if (*PFOLLOWMOUSE == 0 || *PFOLLOWMOUSE == 2 || *PFOLLOWMOUSE == 3) {
|
Desktop::focusState()->rawSurfaceFocus(parentLayer->wlSurface()->resource());
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
|
} else {
|
||||||
|
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
||||||
|
if (*PFOLLOWMOUSE == 0 || *PFOLLOWMOUSE == 2 || *PFOLLOWMOUSE == 3) {
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
|
||||||
|
|
||||||
// If this was a popup grab, focus its parent window to maintain context
|
// If this was a popup grab, focus its parent window to maintain context
|
||||||
if (validMapped(parentWindow)) {
|
if (validMapped(parentWindow)) {
|
||||||
Desktop::focusState()->rawWindowFocus(parentWindow);
|
Desktop::focusState()->rawWindowFocus(parentWindow);
|
||||||
Log::logger->log(Log::DEBUG, "[seatmgr] Refocused popup parent window {} (follow_mouse={})", parentWindow->m_title, *PFOLLOWMOUSE);
|
Log::logger->log(Log::DEBUG, "[seatmgr] Refocused popup parent window {} (follow_mouse={})", parentWindow->m_title, *PFOLLOWMOUSE);
|
||||||
|
} else
|
||||||
|
g_pInputManager->refocusLastWindow(PMONITOR);
|
||||||
} else
|
} else
|
||||||
g_pInputManager->refocusLastWindow(PMONITOR);
|
g_pInputManager->refocus();
|
||||||
} else
|
}
|
||||||
g_pInputManager->refocus();
|
|
||||||
|
|
||||||
auto currentFocus = m_state.keyboardFocus.lock();
|
auto currentFocus = m_state.keyboardFocus.lock();
|
||||||
auto refocus = !currentFocus;
|
auto refocus = !currentFocus;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue