backend/x11: use request_state when window is resized

This commit is contained in:
Simon Ser 2021-01-28 18:10:56 +01:00
parent 5d8dd29d99
commit 246e5b5833
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -57,6 +57,22 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
return false; return false;
} }
if (output->swapchain->width != width ||
output->swapchain->height != height) {
struct wlr_swapchain *swapchain = wlr_swapchain_create(
output->x11->allocator, width, height, output->x11->drm_format);
if (!swapchain) {
return false;
}
wlr_swapchain_destroy(output->swapchain);
output->swapchain = swapchain;
}
wlr_output_update_custom_mode(&output->wlr_output, width, height, 0);
// Move the pointer to its new location
update_x11_pointer_position(output, output->x11->time);
return true; return true;
} }
@ -457,7 +473,6 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
void handle_x11_configure_notify(struct wlr_x11_output *output, void handle_x11_configure_notify(struct wlr_x11_output *output,
xcb_configure_notify_event_t *ev) { xcb_configure_notify_event_t *ev) {
// ignore events that set an invalid size:
if (ev->width == 0 || ev->height == 0) { if (ev->width == 0 || ev->height == 0) {
wlr_log(WLR_DEBUG, wlr_log(WLR_DEBUG,
"Ignoring X11 configure event for height=%d, width=%d", "Ignoring X11 configure event for height=%d, width=%d",
@ -465,23 +480,17 @@ void handle_x11_configure_notify(struct wlr_x11_output *output,
return; return;
} }
if (output->swapchain->width != ev->width || if (ev->width == output->wlr_output.width &&
output->swapchain->height != ev->height) { ev->height == output->wlr_output.height) {
struct wlr_swapchain *swapchain = wlr_swapchain_create( return;
output->x11->allocator, ev->width, ev->height,
output->x11->drm_format);
if (!swapchain) {
return;
}
wlr_swapchain_destroy(output->swapchain);
output->swapchain = swapchain;
} }
wlr_output_update_custom_mode(&output->wlr_output, ev->width, struct wlr_output_state state = {
ev->height, 0); .committed = WLR_OUTPUT_STATE_MODE,
.mode_type = WLR_OUTPUT_STATE_MODE_CUSTOM,
// Move the pointer to its new location .custom_mode = { .width = ev->width, .height = ev->height },
update_x11_pointer_position(output, output->x11->time); };
wlr_output_send_request_state(&output->wlr_output, &state);
} }
bool wlr_output_is_x11(struct wlr_output *wlr_output) { bool wlr_output_is_x11(struct wlr_output *wlr_output) {