mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 01:05:59 +01:00
added misc:layers_hog_keyboard_focus
This commit is contained in:
parent
03f2e4d42a
commit
9eb750c00b
4 changed files with 32 additions and 4 deletions
|
@ -1574,3 +1574,16 @@ void CCompositor::closeWindow(CWindow* pWindow) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
SLayerSurface* CCompositor::getLayerSurfaceFromSurface(wlr_surface* pSurface) {
|
||||
for (auto& m : m_vMonitors) {
|
||||
for (auto& lsl : m->m_aLayerSurfaceLists) {
|
||||
for (auto& ls : lsl) {
|
||||
if (ls->layerSurface && ls->layerSurface->surface == pSurface)
|
||||
return ls.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
|
@ -156,6 +156,7 @@ public:
|
|||
CWindow* getWindowByRegex(const std::string&);
|
||||
void warpCursorTo(const Vector2D&);
|
||||
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
||||
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
||||
void closeWindow(CWindow*);
|
||||
|
||||
std::string explicitConfigPath;
|
||||
|
|
|
@ -55,6 +55,7 @@ void CConfigManager::setDefaultVars() {
|
|||
configValues["misc:damage_entire_on_snapshot"].intValue = 0;
|
||||
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
|
||||
configValues["misc:always_follow_on_dnd"].intValue = 1;
|
||||
configValues["misc:layers_hog_keyboard_focus"].intValue = 0;
|
||||
|
||||
configValues["debug:int"].intValue = 0;
|
||||
configValues["debug:log_damage"].intValue = 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||
static auto *const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
|
||||
static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
||||
static auto *const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
||||
|
||||
if (!g_pCompositor->m_bReadyToProcess)
|
||||
return;
|
||||
|
@ -229,11 +230,21 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
surfaceLocal = mouseCoords - surfacePos + Vector2D(geom.x, geom.y);
|
||||
}
|
||||
|
||||
bool allowKeyboardRefocus = true;
|
||||
|
||||
if (*PHOGFOCUS && !refocus && g_pCompositor->m_pLastFocus) {
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
|
||||
|
||||
if (PLS && PLS->layerSurface->current.keyboard_interactive) {
|
||||
allowKeyboardRefocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFoundWindow) {
|
||||
if (*PFOLLOWMOUSE != 1 && !refocus) {
|
||||
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) {
|
||||
// enter if change floating style
|
||||
if (*PFOLLOWMOUSE != 3)
|
||||
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||
} else if (*PFOLLOWMOUSE == 2) {
|
||||
|
@ -252,11 +263,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||
return; // don't enter any new surfaces
|
||||
} else {
|
||||
if (*PFOLLOWMOUSE != 3)
|
||||
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
}
|
||||
} else if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3)
|
||||
} else {
|
||||
if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||
g_pCompositor->focusSurface(foundSurface);
|
||||
}
|
||||
|
||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||
|
|
Loading…
Reference in a new issue