chase(output): support fractional scaling

manually notify scaling at some surfaces like xdg popups and xwayland
This commit is contained in:
nullableVoidPtr 2023-12-03 17:23:51 +08:00
parent e841d44b6f
commit 5825ee31cc
4 changed files with 28 additions and 0 deletions

View file

@ -17,6 +17,7 @@
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>

View file

@ -31,6 +31,7 @@
#include "xwayland.h"
#define LAB_WLR_COMPOSITOR_VERSION (5)
#define LAB_WLR_FRACTIONAL_SCALE_MANAGER_VERSION (1)
static struct wlr_compositor *compositor;
static struct wl_event_source *sighup_source;
@ -377,6 +378,8 @@ server_init(struct server *server)
wlr_data_control_manager_v1_create(server->wl_display);
wlr_viewporter_create(server->wl_display);
wlr_single_pixel_buffer_manager_v1_create(server->wl_display);
wlr_fractional_scale_manager_v1_create(
server->wl_display, LAB_WLR_FRACTIONAL_SCALE_MANAGER_VERSION);
idle_manager_create(server->wl_display, server->seat.seat);

View file

@ -125,6 +125,14 @@ handle_commit(struct wl_listener *listener, void *data)
}
if (update_required) {
wlr_fractional_scale_v1_notify_scale(
view->surface,
view->output->wlr_output->scale
);
wlr_surface_set_preferred_buffer_scale(
view->surface,
ceil(view->output->wlr_output->scale)
);
view_impl_apply_geometry(view, size.width, size.height);
}
}
@ -307,6 +315,14 @@ xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
* glitches during resize, we apply the same position
* adjustments here as in handle_commit().
*/
wlr_fractional_scale_v1_notify_scale(
view->surface,
view->output->wlr_output->scale
);
wlr_surface_set_preferred_buffer_scale(
view->surface,
ceil(view->output->wlr_output->scale)
);
view_impl_apply_geometry(view, view->current.width,
view->current.height);
}

View file

@ -199,6 +199,14 @@ handle_commit(struct wl_listener *listener, void *data)
* reducing visual glitches.
*/
if (current->width != state->width || current->height != state->height) {
wlr_fractional_scale_v1_notify_scale(
view->surface,
view->output->wlr_output->scale
);
wlr_surface_set_preferred_buffer_scale(
view->surface,
ceil(view->output->wlr_output->scale)
);
view_impl_apply_geometry(view, state->width, state->height);
}
}