2019-09-25 16:35:41 +02:00
|
|
|
#define _POSIX_C_SOURCE 200112L
|
2019-10-09 15:06:30 +02:00
|
|
|
#include <stdlib.h>
|
2022-01-13 11:15:39 +01:00
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2023-02-10 18:07:26 +01:00
|
|
|
#include <wlr/types/wlr_fractional_scale_v1.h>
|
2019-10-09 15:06:30 +02:00
|
|
|
#include "sway/server.h"
|
|
|
|
#include "sway/surface.h"
|
2023-02-08 15:25:14 +01:00
|
|
|
#include "sway/output.h"
|
2019-10-09 15:06:30 +02:00
|
|
|
|
2023-12-04 12:33:57 +01:00
|
|
|
static void surface_update_outputs(struct wlr_surface *surface) {
|
2023-02-10 18:07:26 +01:00
|
|
|
float 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wlr_fractional_scale_v1_notify_scale(surface, scale);
|
2023-02-08 15:28:20 +01:00
|
|
|
wlr_surface_set_preferred_buffer_scale(surface, ceil(scale));
|
2023-02-10 18:07:26 +01:00
|
|
|
}
|
|
|
|
|
2023-02-08 15:25:14 +01:00
|
|
|
void surface_enter_output(struct wlr_surface *surface,
|
|
|
|
struct sway_output *output) {
|
|
|
|
wlr_surface_send_enter(surface, output->wlr_output);
|
2023-02-10 18:07:26 +01:00
|
|
|
surface_update_outputs(surface);
|
2023-02-08 15:25:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void surface_leave_output(struct wlr_surface *surface,
|
|
|
|
struct sway_output *output) {
|
|
|
|
wlr_surface_send_leave(surface, output->wlr_output);
|
2023-02-10 18:07:26 +01:00
|
|
|
surface_update_outputs(surface);
|
2023-02-08 15:25:14 +01:00
|
|
|
}
|