Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix xwayland black window bug after losing focus #6966

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/xwayland/XWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,20 @@ void CXWM::handleFocusIn(xcb_focus_in_event_t* e) {
focusWindow(focusedSurface.lock());
}

void CXWM::handleFocusOut(xcb_focus_out_event_t* e) {
Debug::log(TRACE, "[xwm] focusOut mode={}, detail={}, event={}", e->mode, e->detail, e->event);

const auto XSURF = windowForXID(e->event);

if (!XSURF)
return;

Debug::log(TRACE, "[xwm] focusOut for {} {} {} surface {}", XSURF->mapped ? "mapped" : "unmapped", XSURF->fullscreen ? "fullscreen" : "windowed",
XSURF == focusedSurface ? "focused" : "unfocused", XSURF->state.title);

// do something?
}

void CXWM::sendWMMessage(SP<CXWaylandSurface> surf, xcb_client_message_data_t* data, uint32_t mask) {
xcb_client_message_event_t event = {
.response_type = XCB_CLIENT_MESSAGE,
Expand Down Expand Up @@ -674,9 +688,10 @@ int CXWM::onEvent(int fd, uint32_t mask) {
case XCB_PROPERTY_NOTIFY: handlePropertyNotify((xcb_property_notify_event_t*)event); break;
case XCB_CLIENT_MESSAGE: handleClientMessage((xcb_client_message_event_t*)event); break;
case XCB_FOCUS_IN: handleFocusIn((xcb_focus_in_event_t*)event); break;
case XCB_FOCUS_OUT: handleFocusOut((xcb_focus_out_event_t*)event); break;
case 0: handleError((xcb_value_error_t*)event); break;
default: {
;
Debug::log(TRACE, "[xwm] unhandled event {}", event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK);
}
}
free(event);
Expand Down Expand Up @@ -891,6 +906,11 @@ void CXWM::activateSurface(SP<CXWaylandSurface> surf, bool activate) {
}

void CXWM::sendState(SP<CXWaylandSurface> surf) {
Debug::log(TRACE, "[xwm] sendState for {} {} {} surface {}", surf->mapped ? "mapped" : "unmapped", surf->fullscreen ? "fullscreen" : "windowed",
surf == focusedSurface ? "focused" : "unfocused", surf->state.title);
if (surf->fullscreen && surf->mapped && surf == focusedSurface)
surf->setWithdrawn(false); // resend normal state

if (surf->withdrawn) {
xcb_delete_property(connection, surf->xID, HYPRATOMS["_NET_WM_STATE"]);
return;
Expand Down
1 change: 1 addition & 0 deletions src/xwayland/XWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class CXWM {
void handlePropertyNotify(xcb_property_notify_event_t* e);
void handleClientMessage(xcb_client_message_event_t* e);
void handleFocusIn(xcb_focus_in_event_t* e);
void handleFocusOut(xcb_focus_out_event_t* e);
void handleError(xcb_value_error_t* e);

bool handleSelectionEvent(xcb_generic_event_t* e);
Expand Down
Loading