diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 482524c98..8aebf19b4 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -116,14 +116,32 @@ static void handle_x11_event(struct wlr_x11_backend *x11, } break; } + case XCB_UNMAP_NOTIFY: { + xcb_unmap_notify_event_t *ev = (xcb_unmap_notify_event_t *)event; + struct wlr_x11_output *output = + get_x11_output_from_window_id(x11, ev->window); + if (output != NULL) { + wlr_log(WLR_DEBUG, "Window unmapped, stopping updates"); + output->mapped = false; + } + break; + } + case XCB_MAP_NOTIFY: { + xcb_unmap_notify_event_t *ev = (xcb_unmap_notify_event_t *)event; + struct wlr_x11_output *output = + get_x11_output_from_window_id(x11, ev->window); + if (output != NULL) { + wlr_log(WLR_DEBUG, "Window mapped, resuming updates"); + output->mapped = true; + wlr_output_send_frame(&output->wlr_output); + } + break; + } case 0: { xcb_value_error_t *ev = (xcb_value_error_t *)event; handle_x11_error(x11, ev); break; } - case XCB_UNMAP_NOTIFY: - case XCB_MAP_NOTIFY: - break; default: handle_x11_unknown_event(x11, event); break; diff --git a/backend/x11/output.c b/backend/x11/output.c index 73723fc4e..68bcc03b0 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -600,6 +600,8 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) { xcb_map_window(x11->xcb, output->win); xcb_flush(x11->xcb); + output->mapped = true; + wl_list_insert(&x11->outputs, &output->link); wlr_output_update_enabled(wlr_output, true); @@ -740,7 +742,8 @@ void handle_x11_present_event(struct wlr_x11_backend *x11, }; wlr_output_send_present(&output->wlr_output, &present_event); - wlr_output_send_frame(&output->wlr_output); + if (output->mapped) + wlr_output_send_frame(&output->wlr_output); break; default: wlr_log(WLR_DEBUG, "Unhandled Present event %"PRIu16, event->event_type); diff --git a/include/backend/x11.h b/include/backend/x11.h index 3dfe2fe8a..6349bece2 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -51,6 +51,7 @@ struct wlr_x11_output { pixman_region32_t exposed; uint64_t last_msc; + bool mapped; struct { struct wlr_swapchain *swapchain;