mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-24 01:40:28 -05:00
scene: configure clients with the highest output scale
If a surface appears on two outputs with the same intersection area, or even if a surface appears on an output with a small intersection area, we want to use the highest scale. Fixes flip-flop when a surface is added to multiple scenes. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3901
This commit is contained in:
parent
95b2771bfd
commit
8713ac72fb
1 changed files with 17 additions and 6 deletions
|
|
@ -11,19 +11,30 @@
|
||||||
#include <wlr/util/transform.h>
|
#include <wlr/util/transform.h>
|
||||||
#include "types/wlr_scene.h"
|
#include "types/wlr_scene.h"
|
||||||
|
|
||||||
|
static double get_surface_preferred_buffer_scale(struct wlr_surface *surface) {
|
||||||
|
double scale = 1;
|
||||||
|
struct wlr_surface_output *surface_output;
|
||||||
|
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
||||||
|
if (surface_output->output->scale > scale) {
|
||||||
|
scale = surface_output->output->scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_scene_buffer_outputs_update(
|
static void handle_scene_buffer_outputs_update(
|
||||||
struct wl_listener *listener, void *data) {
|
struct wl_listener *listener, void *data) {
|
||||||
struct wlr_scene_surface *surface =
|
struct wlr_scene_surface *surface =
|
||||||
wl_container_of(listener, surface, outputs_update);
|
wl_container_of(listener, surface, outputs_update);
|
||||||
|
|
||||||
if (surface->buffer->primary_output == NULL) {
|
double scale = get_surface_preferred_buffer_scale(surface->surface);
|
||||||
return;
|
|
||||||
}
|
|
||||||
double scale = surface->buffer->primary_output->output->scale;
|
|
||||||
wlr_fractional_scale_v1_notify_scale(surface->surface, scale);
|
wlr_fractional_scale_v1_notify_scale(surface->surface, scale);
|
||||||
wlr_surface_set_preferred_buffer_scale(surface->surface, ceil(scale));
|
wlr_surface_set_preferred_buffer_scale(surface->surface, ceil(scale));
|
||||||
wlr_surface_set_preferred_buffer_transform(surface->surface,
|
|
||||||
surface->buffer->primary_output->output->transform);
|
if (surface->buffer->primary_output != NULL) {
|
||||||
|
wlr_surface_set_preferred_buffer_transform(surface->surface,
|
||||||
|
surface->buffer->primary_output->output->transform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_scene_buffer_output_enter(
|
static void handle_scene_buffer_output_enter(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue