mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-20 06:47:19 -04:00
backend/wayland: handle scale
This commit is contained in:
parent
ecc3892808
commit
e7ee2a2442
3 changed files with 36 additions and 10 deletions
|
|
@ -447,6 +447,12 @@ static bool output_commit(struct wlr_output *wlr_output,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needs_commit = false;
|
||||||
|
if (state->committed & WLR_OUTPUT_STATE_SCALE) {
|
||||||
|
wl_surface_set_buffer_scale(output->surface, ceil(state->scale));
|
||||||
|
needs_commit = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
|
if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||||
if (output->requested.needs_ack) {
|
if (output->requested.needs_ack) {
|
||||||
output->requested.needs_ack = false;
|
output->requested.needs_ack = false;
|
||||||
|
|
@ -501,7 +507,7 @@ static bool output_commit(struct wlr_output *wlr_output,
|
||||||
output->surface);
|
output->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_commit(output->surface);
|
needs_commit = true;
|
||||||
|
|
||||||
if (wp_feedback != NULL) {
|
if (wp_feedback != NULL) {
|
||||||
struct wlr_wl_presentation_feedback *feedback =
|
struct wlr_wl_presentation_feedback *feedback =
|
||||||
|
|
@ -526,6 +532,10 @@ static bool output_commit(struct wlr_output *wlr_output,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needs_commit) {
|
||||||
|
wl_surface_commit(output->surface);
|
||||||
|
}
|
||||||
|
|
||||||
wl_display_flush(output->backend->remote_display);
|
wl_display_flush(output->backend->remote_display);
|
||||||
|
|
||||||
if (state->committed & WLR_OUTPUT_STATE_MODE) {
|
if (state->committed & WLR_OUTPUT_STATE_MODE) {
|
||||||
|
|
@ -630,16 +640,18 @@ void update_wl_output_cursor(struct wlr_wl_output *output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int scale = ceil(output->wlr_output.scale);
|
||||||
wl_surface_attach(surface, buffer->wl_buffer, 0, 0);
|
wl_surface_attach(surface, buffer->wl_buffer, 0, 0);
|
||||||
wl_surface_damage_buffer(surface, 0, 0, INT32_MAX, INT32_MAX);
|
wl_surface_damage_buffer(surface, 0, 0, INT32_MAX, INT32_MAX);
|
||||||
|
wl_surface_set_buffer_scale(surface, scale);
|
||||||
wl_surface_commit(surface);
|
wl_surface_commit(surface);
|
||||||
|
|
||||||
wl_display_flush(backend->remote_display);
|
wl_display_flush(backend->remote_display);
|
||||||
|
|
||||||
struct wlr_wl_seat *seat = pointer->seat;
|
struct wlr_wl_seat *seat = pointer->seat;
|
||||||
wl_pointer_set_cursor(seat->wl_pointer, output->enter_serial,
|
wl_pointer_set_cursor(seat->wl_pointer, output->enter_serial,
|
||||||
output->cursor.surface, output->cursor.hotspot_x,
|
output->cursor.surface, output->cursor.hotspot_x / scale,
|
||||||
output->cursor.hotspot_y);
|
output->cursor.hotspot_y / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
|
static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
|
||||||
|
|
@ -666,16 +678,28 @@ void surface_update(struct wlr_wl_output *output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t scale = 1;
|
||||||
|
|
||||||
|
struct wlr_wl_active_remote_output *active;
|
||||||
|
wl_list_for_each(active, &output->active_remote_outputs, link) {
|
||||||
|
struct wlr_wl_remote_output *output = active->remote_output;
|
||||||
|
if (scale < output->scale) {
|
||||||
|
scale = output->scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_output_state state = {
|
struct wlr_output_state state = {
|
||||||
.committed = WLR_OUTPUT_STATE_MODE,
|
.committed = WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_SCALE,
|
||||||
.mode_type = WLR_OUTPUT_STATE_MODE_CUSTOM,
|
.mode_type = WLR_OUTPUT_STATE_MODE_CUSTOM,
|
||||||
|
.scale = scale,
|
||||||
.custom_mode = {
|
.custom_mode = {
|
||||||
.width = output->requested.width,
|
.width = output->requested.width * scale,
|
||||||
.height = output->requested.height
|
.height = output->requested.height * scale
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
wlr_output_send_request_state(&output->wlr_output, &state);
|
wlr_output_send_request_state(&output->wlr_output, &state);
|
||||||
|
update_wl_output_cursor(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_surface_handle_configure(void *data,
|
static void xdg_surface_handle_configure(void *data,
|
||||||
|
|
|
||||||
|
|
@ -87,11 +87,12 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output *wlr_output = &pointer->output->wlr_output;
|
struct wlr_output *wlr_output = &pointer->output->wlr_output;
|
||||||
|
int scale = ceil(wlr_output->scale);
|
||||||
struct wlr_pointer_motion_absolute_event event = {
|
struct wlr_pointer_motion_absolute_event event = {
|
||||||
.pointer = &pointer->wlr_pointer,
|
.pointer = &pointer->wlr_pointer,
|
||||||
.time_msec = time,
|
.time_msec = time,
|
||||||
.x = wl_fixed_to_double(sx) / wlr_output->width,
|
.x = wl_fixed_to_double(sx) * scale / wlr_output->width,
|
||||||
.y = wl_fixed_to_double(sy) / wlr_output->height,
|
.y = wl_fixed_to_double(sy) * scale / wlr_output->height,
|
||||||
};
|
};
|
||||||
wl_signal_emit_mutable(&pointer->wlr_pointer.events.motion_absolute, &event);
|
wl_signal_emit_mutable(&pointer->wlr_pointer.events.motion_absolute, &event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,9 @@ static void touch_coordinates_to_absolute(struct wlr_wl_seat *seat,
|
||||||
*/
|
*/
|
||||||
struct wlr_wl_output *output, *tmp;
|
struct wlr_wl_output *output, *tmp;
|
||||||
wl_list_for_each_safe(output, tmp, &seat->backend->outputs, link) {
|
wl_list_for_each_safe(output, tmp, &seat->backend->outputs, link) {
|
||||||
*sx = wl_fixed_to_double(x) / output->wlr_output.width;
|
int scale = ceil(output->wlr_output.scale);
|
||||||
*sy = wl_fixed_to_double(y) / output->wlr_output.height;
|
*sx = wl_fixed_to_double(x) * scale / output->wlr_output.width;
|
||||||
|
*sy = wl_fixed_to_double(y) * scale / output->wlr_output.height;
|
||||||
return; // Choose the first output in the list
|
return; // Choose the first output in the list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue