Introduce fractional scaling
This commit is contained in:
parent
23fb663ea4
commit
51db087210
|
@ -66,7 +66,8 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
||||||
box.y /= wlr_output->scale;
|
box.y /= wlr_output->scale;
|
||||||
|
|
||||||
struct wlr_box layout_box;
|
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;
|
struct wlr_event_pointer_motion_absolute wlr_event;
|
||||||
wlr_event.device = dev;
|
wlr_event.device = dev;
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct roots_output_config {
|
||||||
char *name;
|
char *name;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
int x, y;
|
int x, y;
|
||||||
int scale;
|
float scale;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct {
|
struct {
|
||||||
int width, height;
|
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,
|
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 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
|
* Set the cursor surface. The surface can be committed to update the cursor
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct wlr_output {
|
||||||
char make[48];
|
char make[48];
|
||||||
char model[16];
|
char model[16];
|
||||||
char serial[16];
|
char serial[16];
|
||||||
uint32_t scale;
|
float scale;
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
int32_t phys_width, phys_height; // mm
|
int32_t phys_width, phys_height; // mm
|
||||||
enum wl_output_subpixel subpixel;
|
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,
|
void wlr_output_set_transform(struct wlr_output *output,
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly);
|
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_destroy(struct wlr_output *output);
|
||||||
void wlr_output_effective_resolution(struct wlr_output *output,
|
void wlr_output_effective_resolution(struct wlr_output *output,
|
||||||
int *width, int *height);
|
int *width, int *height);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* A scaled XCursor theme.
|
* A scaled XCursor theme.
|
||||||
*/
|
*/
|
||||||
struct wlr_xcursor_manager_theme {
|
struct wlr_xcursor_manager_theme {
|
||||||
uint32_t scale;
|
float scale;
|
||||||
struct wlr_xcursor_theme *theme;
|
struct wlr_xcursor_theme *theme;
|
||||||
struct wl_list link;
|
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);
|
void wlr_xcursor_manager_destroy(struct wlr_xcursor_manager *manager);
|
||||||
|
|
||||||
int wlr_xcursor_manager_load(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 *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
|
* 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) {
|
} else if (strcmp(name, "y") == 0) {
|
||||||
oc->y = strtol(value, NULL, 10);
|
oc->y = strtol(value, NULL, 10);
|
||||||
} else if (strcmp(name, "scale") == 0) {
|
} else if (strcmp(name, "scale") == 0) {
|
||||||
oc->scale = strtol(value, NULL, 10);
|
oc->scale = strtof(value, NULL);
|
||||||
assert(oc->scale >= 1);
|
assert(oc->scale >= 1);
|
||||||
} else if (strcmp(name, "rotate") == 0) {
|
} else if (strcmp(name, "rotate") == 0) {
|
||||||
if (strcmp(value, "normal") == 0) {
|
if (strcmp(value, "normal") == 0) {
|
||||||
|
|
|
@ -459,11 +459,10 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) {
|
||||||
|
|
||||||
struct roots_output *output;
|
struct roots_output *output;
|
||||||
wl_list_for_each(output, &seat->input->server->desktop->outputs, link) {
|
wl_list_for_each(output, &seat->input->server->desktop->outputs, link) {
|
||||||
if (wlr_xcursor_manager_load(seat->cursor->xcursor_manager,
|
float scale = output->wlr_output->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' "
|
wlr_log(L_ERROR, "Cannot load xcursor theme for output '%s' "
|
||||||
"with scale %d", output->wlr_output->name,
|
"with scale %f", output->wlr_output->name, scale);
|
||||||
output->wlr_output->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,
|
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 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;
|
struct wlr_cursor_output_cursor *output_cursor;
|
||||||
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
|
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
|
||||||
if (scale != 0 &&
|
float output_scale = output_cursor->output_cursor->output->scale;
|
||||||
output_cursor->output_cursor->output->scale != scale) {
|
if (scale > 0 && output_scale != scale) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION) {
|
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) {
|
if (version >= WL_OUTPUT_DONE_SINCE_VERSION) {
|
||||||
wl_output_send_done(resource);
|
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) {
|
if (output->scale == scale) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -256,6 +256,10 @@ void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) {
|
||||||
wl_signal_emit(&output->events.scale, output);
|
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,
|
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||||
const struct wlr_output_impl *impl) {
|
const struct wlr_output_impl *impl) {
|
||||||
assert(impl->make_current && impl->swap_buffers && impl->transform);
|
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,
|
int wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
|
||||||
uint32_t scale) {
|
float scale) {
|
||||||
struct wlr_xcursor_manager_theme *theme;
|
struct wlr_xcursor_manager_theme *theme;
|
||||||
wl_list_for_each(theme, &manager->scaled_themes, link) {
|
wl_list_for_each(theme, &manager->scaled_themes, link) {
|
||||||
if (theme->scale == scale) {
|
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 *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;
|
struct wlr_xcursor_manager_theme *theme;
|
||||||
wl_list_for_each(theme, &manager->scaled_themes, link) {
|
wl_list_for_each(theme, &manager->scaled_themes, link) {
|
||||||
if (theme->scale == scale) {
|
if (theme->scale == scale) {
|
||||||
|
|
Loading…
Reference in New Issue