refocus when window closed

This commit is contained in:
vaxerski 2021-12-02 15:08:19 +01:00
parent 0cfe129ce4
commit bafa001f59
3 changed files with 18 additions and 0 deletions

View file

@ -79,12 +79,18 @@ void Events::eventDestroy(xcb_generic_event_t* event) {
const auto E = reinterpret_cast<xcb_destroy_notify_event_t*>(event); const auto E = reinterpret_cast<xcb_destroy_notify_event_t*>(event);
g_pWindowManager->closeWindowAllChecks(E->window); g_pWindowManager->closeWindowAllChecks(E->window);
// refocus on new window
g_pWindowManager->refocusWindowOnClosed();
} }
void Events::eventUnmapWindow(xcb_generic_event_t* event) { void Events::eventUnmapWindow(xcb_generic_event_t* event) {
const auto E = reinterpret_cast<xcb_unmap_notify_event_t*>(event); const auto E = reinterpret_cast<xcb_unmap_notify_event_t*>(event);
g_pWindowManager->closeWindowAllChecks(E->window); g_pWindowManager->closeWindowAllChecks(E->window);
// refocus on new window
g_pWindowManager->refocusWindowOnClosed();
} }
CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {

View file

@ -1379,3 +1379,14 @@ void CWindowManager::getICCCMWMProtocols(CWindow* pWindow) {
xcb_icccm_get_wm_protocols_reply_wipe(&WMProtocolsReply); xcb_icccm_get_wm_protocols_reply_wipe(&WMProtocolsReply);
} }
void CWindowManager::refocusWindowOnClosed() {
const auto PWINDOW = findWindowAtCursor();
if (!PWINDOW)
return;
LastWindow = PWINDOW->getDrawable();
setFocusedWindow(PWINDOW->getDrawable());
}

View file

@ -67,6 +67,7 @@ public:
void refreshDirtyWindows(); void refreshDirtyWindows();
void setFocusedWindow(xcb_drawable_t); void setFocusedWindow(xcb_drawable_t);
void refocusWindowOnClosed();
void calculateNewWindowParams(CWindow*); void calculateNewWindowParams(CWindow*);
void fixWindowOnClose(CWindow*); void fixWindowOnClose(CWindow*);