Fix a crash with setting title

This commit is contained in:
vaxerski 2022-03-22 17:31:19 +01:00
parent 8fe1cec87c
commit c58b15c6da
3 changed files with 28 additions and 11 deletions

View file

@ -89,6 +89,9 @@ void Events::listener_destroyWindow(wl_listener* listener, void* data) {
void Events::listener_setTitleWindow(wl_listener* listener, void* data) { void Events::listener_setTitleWindow(wl_listener* listener, void* data) {
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_setTitleWindow); CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_setTitleWindow);
if (!g_pCompositor->windowValidMapped(PWINDOW))
return;
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW); PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str()); Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str());

View file

@ -271,17 +271,18 @@ void CHyprDwindleLayout::onBeginDragWindow() {
m_vBeginDragSizeXY = Vector2D(); m_vBeginDragSizeXY = Vector2D();
if (DRAGGINGWINDOW->m_bIsFullscreen) {
Debug::log(LOG, "Rejecting drag on a fullscreen window.");
return;
}
// Window will be floating. Let's check if it's valid. It should be, but I don't like crashing. // Window will be floating. Let's check if it's valid. It should be, but I don't like crashing.
if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW)) { if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW)) {
Debug::log(ERR, "Dragging attempted on an invalid window!"); Debug::log(ERR, "Dragging attempted on an invalid window!");
return; return;
} }
if (DRAGGINGWINDOW->m_bIsFullscreen) {
Debug::log(LOG, "Rejecting drag on a fullscreen window.");
return;
}
m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal(); m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition; m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition;
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize; m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize;

View file

@ -49,10 +49,23 @@ void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox)
} }
std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) { std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) {
if (pWindow->m_bIsX11) if (pWindow->m_bIsX11) {
return pWindow->m_uSurface.xwayland->title; if (pWindow->m_uSurface.xwayland) {
return pWindow->m_uSurface.xwayland->title;
}
} else {
return "";
}
return pWindow->m_uSurface.xdg->toplevel->title; if (pWindow->m_uSurface.xdg) {
if (pWindow->m_uSurface.xdg->toplevel) {
return pWindow->m_uSurface.xdg->toplevel->title;
}
} else {
return "";
}
return "";
} }
void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) { void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) {