mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 15:12:26 +00:00
Merge pull request #488 from emersion/fractional-scaling
Add fractional scaling support
This commit is contained in:
commit
a6704fd16d
@ -59,14 +59,15 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
||||
&box.width, &box.height);
|
||||
box.x = wl_fixed_to_int(surface_x);
|
||||
box.y = wl_fixed_to_int(surface_y);
|
||||
struct wlr_box transformed;
|
||||
|
||||
struct wlr_box transformed;
|
||||
wlr_box_transform(&box, wlr_output->transform, &transformed);
|
||||
box.x /= wlr_output->scale;
|
||||
box.y /= wlr_output->scale;
|
||||
transformed.x /= wlr_output->scale;
|
||||
transformed.y /= wlr_output->scale;
|
||||
|
||||
struct wlr_box layout_box;
|
||||
wlr_wl_output_layout_get_box(wlr_wl_pointer->current_output->backend, &layout_box);
|
||||
wlr_wl_output_layout_get_box(wlr_wl_pointer->current_output->backend,
|
||||
&layout_box);
|
||||
|
||||
struct wlr_event_pointer_motion_absolute wlr_event;
|
||||
wlr_event.device = dev;
|
||||
|
@ -9,7 +9,7 @@ struct roots_output_config {
|
||||
char *name;
|
||||
enum wl_output_transform transform;
|
||||
int x, y;
|
||||
int scale;
|
||||
float scale;
|
||||
struct wl_list link;
|
||||
struct {
|
||||
int width, height;
|
||||
|
@ -68,7 +68,7 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
||||
*/
|
||||
void wlr_cursor_set_image(struct wlr_cursor *cur, const uint8_t *pixels,
|
||||
int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x,
|
||||
int32_t hotspot_y, uint32_t scale);
|
||||
int32_t hotspot_y, float scale);
|
||||
|
||||
/**
|
||||
* Set the cursor surface. The surface can be committed to update the cursor
|
||||
|
@ -45,7 +45,7 @@ struct wlr_output {
|
||||
char make[48];
|
||||
char model[16];
|
||||
char serial[16];
|
||||
uint32_t scale;
|
||||
float scale;
|
||||
int32_t width, height;
|
||||
int32_t phys_width, phys_height; // mm
|
||||
enum wl_output_subpixel subpixel;
|
||||
@ -92,7 +92,7 @@ bool wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
|
||||
void wlr_output_set_transform(struct wlr_output *output,
|
||||
enum wl_output_transform transform);
|
||||
void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly);
|
||||
void wlr_output_set_scale(struct wlr_output *output, uint32_t scale);
|
||||
void wlr_output_set_scale(struct wlr_output *output, float scale);
|
||||
void wlr_output_destroy(struct wlr_output *output);
|
||||
void wlr_output_effective_resolution(struct wlr_output *output,
|
||||
int *width, int *height);
|
||||
|
@ -9,7 +9,7 @@
|
||||
* A scaled XCursor theme.
|
||||
*/
|
||||
struct wlr_xcursor_manager_theme {
|
||||
uint32_t scale;
|
||||
float scale;
|
||||
struct wlr_xcursor_theme *theme;
|
||||
struct wl_list link;
|
||||
};
|
||||
@ -38,10 +38,10 @@ struct wlr_xcursor_manager *wlr_xcursor_manager_create(const char *name,
|
||||
void wlr_xcursor_manager_destroy(struct wlr_xcursor_manager *manager);
|
||||
|
||||
int wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
|
||||
uint32_t scale);
|
||||
float scale);
|
||||
|
||||
struct wlr_xcursor *wlr_xcursor_manager_get_xcursor(
|
||||
struct wlr_xcursor_manager *manager, const char *name, uint32_t scale);
|
||||
struct wlr_xcursor_manager *manager, const char *name, float scale);
|
||||
|
||||
/**
|
||||
* Set a `wlr_cursor` image. The manager uses all currently loaded scaled
|
||||
|
@ -270,7 +270,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
||||
} else if (strcmp(name, "y") == 0) {
|
||||
oc->y = strtol(value, NULL, 10);
|
||||
} else if (strcmp(name, "scale") == 0) {
|
||||
oc->scale = strtol(value, NULL, 10);
|
||||
oc->scale = strtof(value, NULL);
|
||||
assert(oc->scale >= 1);
|
||||
} else if (strcmp(name, "rotate") == 0) {
|
||||
if (strcmp(value, "normal") == 0) {
|
||||
|
@ -459,11 +459,10 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) {
|
||||
|
||||
struct roots_output *output;
|
||||
wl_list_for_each(output, &seat->input->server->desktop->outputs, link) {
|
||||
if (wlr_xcursor_manager_load(seat->cursor->xcursor_manager,
|
||||
output->wlr_output->scale)) {
|
||||
float scale = output->wlr_output->scale;
|
||||
if (wlr_xcursor_manager_load(seat->cursor->xcursor_manager, scale)) {
|
||||
wlr_log(L_ERROR, "Cannot load xcursor theme for output '%s' "
|
||||
"with scale %d", output->wlr_output->name,
|
||||
output->wlr_output->scale);
|
||||
"with scale %f", output->wlr_output->name, scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,11 +299,11 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
||||
|
||||
void wlr_cursor_set_image(struct wlr_cursor *cur, const uint8_t *pixels,
|
||||
int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x,
|
||||
int32_t hotspot_y, uint32_t scale) {
|
||||
int32_t hotspot_y, float scale) {
|
||||
struct wlr_cursor_output_cursor *output_cursor;
|
||||
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
|
||||
if (scale != 0 &&
|
||||
output_cursor->output_cursor->output->scale != scale) {
|
||||
float output_scale = output_cursor->output_cursor->output->scale;
|
||||
if (scale > 0 && output_scale != scale) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) {
|
||||
}
|
||||
}
|
||||
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION) {
|
||||
wl_output_send_scale(resource, output->scale);
|
||||
wl_output_send_scale(resource, (uint32_t)ceil(output->scale));
|
||||
}
|
||||
if (version >= WL_OUTPUT_DONE_SINCE_VERSION) {
|
||||
wl_output_send_done(resource);
|
||||
@ -240,7 +240,7 @@ void wlr_output_set_position(struct wlr_output *output, int32_t lx,
|
||||
}
|
||||
}
|
||||
|
||||
void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) {
|
||||
void wlr_output_set_scale(struct wlr_output *output, float scale) {
|
||||
if (output->scale == scale) {
|
||||
return;
|
||||
}
|
||||
@ -256,6 +256,10 @@ void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) {
|
||||
wl_signal_emit(&output->events.scale, output);
|
||||
}
|
||||
|
||||
uint32_t wlr_output_integral_scale(struct wlr_output *output) {
|
||||
return ceil(output->scale);
|
||||
}
|
||||
|
||||
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||
const struct wlr_output_impl *impl) {
|
||||
assert(impl->make_current && impl->swap_buffers && impl->transform);
|
||||
|
@ -33,7 +33,7 @@ void wlr_xcursor_manager_destroy(struct wlr_xcursor_manager *manager) {
|
||||
}
|
||||
|
||||
int wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
|
||||
uint32_t scale) {
|
||||
float scale) {
|
||||
struct wlr_xcursor_manager_theme *theme;
|
||||
wl_list_for_each(theme, &manager->scaled_themes, link) {
|
||||
if (theme->scale == scale) {
|
||||
@ -56,7 +56,7 @@ int wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
|
||||
}
|
||||
|
||||
struct wlr_xcursor *wlr_xcursor_manager_get_xcursor(
|
||||
struct wlr_xcursor_manager *manager, const char *name, uint32_t scale) {
|
||||
struct wlr_xcursor_manager *manager, const char *name, float scale) {
|
||||
struct wlr_xcursor_manager_theme *theme;
|
||||
wl_list_for_each(theme, &manager->scaled_themes, link) {
|
||||
if (theme->scale == scale) {
|
||||
|
Loading…
Reference in New Issue
Block a user