fix crashes

This commit is contained in:
vaxerski 2022-03-18 23:16:15 +01:00
parent dbf566c78a
commit 7f8648fc8b
4 changed files with 23 additions and 3 deletions

View file

@ -151,7 +151,8 @@ SMonitor* CCompositor::getMonitorFromCursor() {
} }
void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) { void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) {
m_lWindows.remove(*pWindow); if (windowExists(pWindow))
m_lWindows.remove(*pWindow);
} }
bool CCompositor::windowExists(CWindow* pWindow) { bool CCompositor::windowExists(CWindow* pWindow) {
@ -189,10 +190,23 @@ void CCompositor::focusWindow(CWindow* pWindow) {
wlr_seat_keyboard_notify_enter(m_sWLRSeat, PWINDOWSURFACE, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers); wlr_seat_keyboard_notify_enter(m_sWLRSeat, PWINDOWSURFACE, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers);
g_pXWaylandManager->activateSurface(PWINDOWSURFACE, true); g_pXWaylandManager->activateSurface(PWINDOWSURFACE, true);
if (m_pLastFocus && windowExists(m_pLastFocus)) if (m_pLastFocus && windowValidMapped(m_pLastFocus))
g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(m_pLastFocus), false); g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(m_pLastFocus), false);
m_pLastFocus = pWindow; m_pLastFocus = pWindow;
Debug::log(LOG, "Set focus to %x", pWindow); Debug::log(LOG, "Set focus to %x", pWindow);
} }
bool CCompositor::windowValidMapped(CWindow* pWindow) {
if (!windowExists(pWindow))
return false;
if (pWindow->m_bIsX11 && !pWindow->m_bMappedX11)
return false;
if (!g_pXWaylandManager->getWindowSurface(pWindow))
return false;
return true;
}

View file

@ -60,6 +60,7 @@ public:
void removeWindowFromVectorSafe(CWindow*); void removeWindowFromVectorSafe(CWindow*);
void focusWindow(CWindow*); void focusWindow(CWindow*);
bool windowExists(CWindow*); bool windowExists(CWindow*);
bool windowValidMapped(CWindow*);
CWindow* vectorToWindow(const Vector2D&); CWindow* vectorToWindow(const Vector2D&);
}; };

View file

@ -41,6 +41,7 @@ public:
// XWayland stuff // XWayland stuff
bool m_bIsX11 = false; bool m_bIsX11 = false;
bool m_bMappedX11 = false;
uint64_t m_iX11Type = 0; uint64_t m_iX11Type = 0;
DYNLISTENER(activateX11); DYNLISTENER(activateX11);
DYNLISTENER(configureX11); DYNLISTENER(configureX11);

View file

@ -200,6 +200,7 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iMonitorID = PMONITOR->ID;
PWINDOW->m_bMappedX11 = true;
// test // test
g_pXWaylandManager->setWindowSize(PWINDOW, PMONITOR->vecSize); g_pXWaylandManager->setWindowSize(PWINDOW, PMONITOR->vecSize);
@ -395,7 +396,10 @@ void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
} }
void Events::listener_requestMouse(wl_listener* listener, void* data) { void Events::listener_requestMouse(wl_listener* listener, void* data) {
const auto EVENT = (wlr_seat_pointer_request_set_cursor_event*)data;
if (EVENT->seat_client == g_pCompositor->m_sWLRSeat->pointer_state.focused_client)
wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, EVENT->surface, EVENT->hotspot_x, EVENT->hotspot_y);
} }
void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) { void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) {