Skip to content

Commit

Permalink
layerSurface: focus last exclusive ls on unmap only if focused
Browse files Browse the repository at this point in the history
Also focus the last instead of the first.
  • Loading branch information
outfoxxed committed Jun 10, 2024
1 parent 63a65df commit f612e14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/desktop/LayerSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ void CLayerSurface::onUnmap() {

std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); });

if (!g_pInputManager->m_dExclusiveLSes.empty())
g_pCompositor->focusSurface(g_pInputManager->m_dExclusiveLSes[0]->surface->resource());

if (!g_pCompositor->getMonitorFromID(monitorID) || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");

Expand Down Expand Up @@ -222,6 +219,10 @@ void CLayerSurface::onUnmap() {

g_pCompositor->m_pLastFocus.reset();

// try to focus the last exclusive ls first
if (!g_pInputManager->m_dExclusiveLSes.empty())
g_pCompositor->focusSurface(g_pInputManager->m_dExclusiveLSes[g_pInputManager->m_dExclusiveLSes.size() - 1]->surface->resource());

// find LS-es to focus
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
&surfaceCoords, &pFoundLayerSurface);
Expand Down

0 comments on commit f612e14

Please sign in to comment.