xwayland: fixup unfocus atom conditions

ref #6468
This commit is contained in:
Vaxry 2024-06-16 12:38:09 +02:00
parent 1f5fd7e64a
commit 2566d81884
3 changed files with 19 additions and 10 deletions

View file

@ -179,7 +179,7 @@ void CXWaylandSurface::configure(const CBox& box) {
void CXWaylandSurface::activate(bool activate) { void CXWaylandSurface::activate(bool activate) {
if (overrideRedirect && !activate) if (overrideRedirect && !activate)
return; return;
g_pXWayland->pWM->activateSurface(self.lock()); g_pXWayland->pWM->activateSurface(self.lock(), activate);
} }
void CXWaylandSurface::setFullscreen(bool fs) { void CXWaylandSurface::setFullscreen(bool fs) {

View file

@ -394,11 +394,16 @@ void CXWM::focusWindow(SP<CXWaylandSurface> surf) {
if (surf == focusedSurface) if (surf == focusedSurface)
return; return;
auto oldSurf = focusedSurface.lock();
focusedSurface = surf; focusedSurface = surf;
if (oldSurf) // send state to all surfaces, sometimes we might lose some
sendState(oldSurf); // that could still stick with the focused atom
for (auto& s : mappedSurfaces) {
if (!s)
continue;
sendState(s.lock());
}
if (!surf) { if (!surf) {
xcb_set_input_focus_checked(connection, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_NONE, XCB_CURRENT_TIME); xcb_set_input_focus_checked(connection, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_NONE, XCB_CURRENT_TIME);
@ -868,13 +873,17 @@ void CXWM::createWMWindow() {
xcb_set_selection_owner(connection, wmWindow, HYPRATOMS["_NET_WM_CM_S0"], XCB_CURRENT_TIME); xcb_set_selection_owner(connection, wmWindow, HYPRATOMS["_NET_WM_CM_S0"], XCB_CURRENT_TIME);
} }
void CXWM::activateSurface(SP<CXWaylandSurface> surf) { void CXWM::activateSurface(SP<CXWaylandSurface> surf, bool activate) {
if (surf == focusedSurface || (surf && surf->overrideRedirect)) if ((surf == focusedSurface && activate) || (surf && surf->overrideRedirect))
return; return;
if (!activate || !surf) {
setActiveWindow((uint32_t)XCB_WINDOW_NONE);
focusWindow(nullptr);
} else {
setActiveWindow(surf ? surf->xID : (uint32_t)XCB_WINDOW_NONE); setActiveWindow(surf ? surf->xID : (uint32_t)XCB_WINDOW_NONE);
focusWindow(surf); focusWindow(surf);
}
xcb_flush(connection); xcb_flush(connection);
} }

View file

@ -79,7 +79,7 @@ class CXWM {
void setActiveWindow(xcb_window_t window); void setActiveWindow(xcb_window_t window);
void sendState(SP<CXWaylandSurface> surf); void sendState(SP<CXWaylandSurface> surf);
void focusWindow(SP<CXWaylandSurface> surf); void focusWindow(SP<CXWaylandSurface> surf);
void activateSurface(SP<CXWaylandSurface> surf); void activateSurface(SP<CXWaylandSurface> surf, bool activate);
bool isWMWindow(xcb_window_t w); bool isWMWindow(xcb_window_t w);
void sendWMMessage(SP<CXWaylandSurface> surf, xcb_client_message_data_t* data, uint32_t mask); void sendWMMessage(SP<CXWaylandSurface> surf, xcb_client_message_data_t* data, uint32_t mask);