Rethink HiDPI output layouts, fixes everything

Except for subsurfaces not rendering at the right scale. But that part
is (somewhat) easy.
master
Drew DeVault 7 years ago
parent ed74f473d6
commit ca8cf7d48d

@ -167,15 +167,14 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
continue; continue;
} }
int scale = view->wlr_surface->current->scale; double view_sx = lx - view->x;
double view_sx = (lx - view->x) / (double)scale; double view_sy = ly - view->y;
double view_sy = (ly - view->y) / (double)scale;
struct wlr_box box = { struct wlr_box box = {
.x = 0, .x = 0,
.y = 0, .y = 0,
.width = view->wlr_surface->current->buffer_width * scale, .width = view->wlr_surface->current->buffer_width,
.height = view->wlr_surface->current->buffer_height * scale, .height = view->wlr_surface->current->buffer_height,
}; };
if (view->rotation != 0.0) { if (view->rotation != 0.0) {
// Coordinates relative to the center of the view // Coordinates relative to the center of the view

@ -25,6 +25,8 @@ static void render_surface(struct wlr_surface *surface,
int height = surface->current->buffer_height * scale_factor; int height = surface->current->buffer_height * scale_factor;
double ox = lx, oy = ly; double ox = lx, oy = ly;
wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy); wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
ox *= wlr_output->scale;
oy *= wlr_output->scale;
if (wlr_output_layout_intersects(desktop->layout, wlr_output, if (wlr_output_layout_intersects(desktop->layout, wlr_output,
lx, ly, lx + width, ly + height)) { lx, ly, lx + width, ly + height)) {

@ -227,7 +227,6 @@ 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) {
// TODO: Scale factor
if (output->transform % 2 == 1) { if (output->transform % 2 == 1) {
*width = output->height; *width = output->height;
*height = output->width; *height = output->width;
@ -235,6 +234,8 @@ void wlr_output_effective_resolution(struct wlr_output *output,
*width = output->width; *width = output->width;
*height = output->height; *height = output->height;
} }
*width /= output->scale;
*height /= output->scale;
} }
void wlr_output_make_current(struct wlr_output *output) { void wlr_output_make_current(struct wlr_output *output) {
@ -450,6 +451,8 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
} }
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) { bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
x *= cursor->output->scale;
y *= cursor->output->scale;
cursor->x = x; cursor->x = x;
cursor->y = y; cursor->y = y;

Loading…
Cancel
Save