Skip to content

Commit

Permalink
layerSurface: only kb focus if becoming exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed committed Jun 13, 2024
1 parent aba5a46 commit e6711bd
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/desktop/LayerSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,14 @@ void CLayerSurface::onCommit() {
else if (WASEXCLUSIVE && !ISEXCLUSIVE)
std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); });

auto interactivityRank = [](int interactivity) {
switch (interactivity) {
case ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE: return 0;
case ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND: return 1;
case ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE: return 2;
}
};

// if the surface was focused and interactive but now isn't, refocus
if (WASLASTFOCUS && !layerSurface->current.interactivity) {
// moveMouseUnified won't focus non interactive layers but it won't unfocus them either,
// so unfocus the surface here.
g_pCompositor->focusSurface(nullptr);
g_pInputManager->refocusLastWindow(g_pCompositor->getMonitorFromID(monitorID));
} else if (!WASLASTFOCUS && interactivityRank(layerSurface->current.interactivity) > interactivityRank(interactivity) &&
(ISEXCLUSIVE || (g_pSeatManager->mouse.expired() || !g_pInputManager->isConstrained()))) {
// if kb interactivity > last kb interactivity
} else if (!WASEXCLUSIVE && ISEXCLUSIVE) {
// if now exclusive and not previously
g_pSeatManager->setGrab(nullptr);
g_pInputManager->releaseAllMouseButtons();
g_pCompositor->focusSurface(surface->resource());
Expand Down

0 comments on commit e6711bd

Please sign in to comment.