mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-19 04:49:48 +01:00
xwaylandmgr: minor refactor to activateSurface
Make it more efficient now that we can + fix possible nullptr deref fixes #7514
This commit is contained in:
parent
b672118f92
commit
83ab3ae0af
1 changed files with 19 additions and 17 deletions
|
@ -28,28 +28,30 @@ void CHyprXWaylandManager::activateSurface(SP<CWLSurfaceResource> pSurface, bool
|
||||||
if (!pSurface)
|
if (!pSurface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO:
|
auto HLSurface = CWLSurface::fromResource(pSurface);
|
||||||
// this cannot be nicely done until we rewrite wlr_surface
|
if (!HLSurface) {
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
Debug::log(TRACE, "CHyprXWaylandManager::activateSurface on non-desktop surface, ignoring");
|
||||||
if (!w->m_bIsMapped)
|
return;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
if (w->m_pWLSurface->resource() != pSurface)
|
const auto PWINDOW = HLSurface->getWindow();
|
||||||
continue;
|
if (!PWINDOW) {
|
||||||
|
Debug::log(TRACE, "CHyprXWaylandManager::activateSurface on non-window surface, ignoring");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (w->m_bIsX11) {
|
if (PWINDOW->m_bIsX11 && PWINDOW->m_pXWaylandSurface) {
|
||||||
if (activate) {
|
if (activate) {
|
||||||
w->m_pXWaylandSurface->setMinimized(false);
|
PWINDOW->m_pXWaylandSurface->setMinimized(false);
|
||||||
w->m_pXWaylandSurface->restackToTop();
|
PWINDOW->m_pXWaylandSurface->restackToTop();
|
||||||
}
|
}
|
||||||
w->m_pXWaylandSurface->activate(activate);
|
PWINDOW->m_pXWaylandSurface->activate(activate);
|
||||||
} else {
|
} else if (!PWINDOW->m_bIsX11 && PWINDOW->m_pXDGSurface) {
|
||||||
w->m_pXDGSurface->toplevel->setActive(activate);
|
PWINDOW->m_pXDGSurface->toplevel->setActive(activate);
|
||||||
if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastWindow->m_bIsX11)
|
if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsX11)
|
||||||
activateSurface(g_pCompositor->m_pLastFocus.lock(), false);
|
activateSurface(g_pCompositor->m_pLastFocus.lock(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
|
void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
|
||||||
if (pWindow->m_bIsX11) {
|
if (pWindow->m_bIsX11) {
|
||||||
|
|
Loading…
Reference in a new issue