Don't use buffer size

This commit is contained in:
emersion 2017-11-14 15:33:29 +01:00
parent 94b20da3ce
commit 2f44140f4a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 15 additions and 24 deletions

View File

@ -17,16 +17,6 @@ static inline int64_t timespec_to_msec(const struct timespec *a) {
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
} }
/**
* Computes the surface size homogeneous to the global compositor coordinates.
*/
static void get_surface_size(struct wlr_surface *surface, double *width,
double *height) {
double surface_scale = surface->current->scale;
*width = (double)surface->current->buffer_width / surface_scale;
*height = (double)surface->current->buffer_height / surface_scale;
}
/** /**
* Rotate a child's position relative to a parent. The parent size is (pw, ph), * Rotate a child's position relative to a parent. The parent size is (pw, ph),
* the child position is (*sx, *sy) and its size is (sw, sh). * the child position is (*sx, *sy) and its size is (sw, sh).
@ -49,8 +39,9 @@ static void render_surface(struct wlr_surface *surface,
struct roots_desktop *desktop, struct wlr_output *wlr_output, struct roots_desktop *desktop, struct wlr_output *wlr_output,
struct timespec *when, double lx, double ly, float rotation) { struct timespec *when, double lx, double ly, float rotation) {
if (surface->texture->valid) { if (surface->texture->valid) {
double width, height; double surface_scale = surface->current->scale;
get_surface_size(surface, &width, &height); double width = (double)surface->current->buffer_width / surface_scale;
double height = (double)surface->current->buffer_height / surface_scale;
int render_width = width * wlr_output->scale; int render_width = width * wlr_output->scale;
int render_height = height * wlr_output->scale; int render_height = height * wlr_output->scale;
double ox = lx, oy = ly; double ox = lx, oy = ly;
@ -113,8 +104,8 @@ static void render_surface(struct wlr_surface *surface,
static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface, static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface,
struct roots_desktop *desktop, struct wlr_output *wlr_output, struct roots_desktop *desktop, struct wlr_output *wlr_output,
struct timespec *when, double base_x, double base_y, float rotation) { struct timespec *when, double base_x, double base_y, float rotation) {
double width, height; double width = surface->surface->current->width;
get_surface_size(surface->surface, &width, &height); double height = surface->surface->current->height;
struct wlr_xdg_surface_v6 *popup; struct wlr_xdg_surface_v6 *popup;
wl_list_for_each(popup, &surface->popups, popup_link) { wl_list_for_each(popup, &surface->popups, popup_link) {
@ -122,15 +113,15 @@ static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface,
continue; continue;
} }
double sw, sh; double popup_width = popup->surface->current->width;
get_surface_size(popup->surface, &sw, &sh); double popup_height = popup->surface->current->height;
double popup_x = surface->geometry->x + popup->popup_state->geometry.x - double popup_x = surface->geometry->x + popup->popup_state->geometry.x -
popup->geometry->x; popup->geometry->x;
double popup_y = surface->geometry->y + popup->popup_state->geometry.y - double popup_y = surface->geometry->y + popup->popup_state->geometry.y -
popup->geometry->y; popup->geometry->y;
rotate_child_position(&popup_x, &popup_y, sw, sh, width, height, rotate_child_position(&popup_x, &popup_y, popup_width, popup_height,
rotation); width, height, rotation);
render_surface(popup->surface, desktop, wlr_output, when, render_surface(popup->surface, desktop, wlr_output, when,
base_x + popup_x, base_y + popup_y, rotation); base_x + popup_x, base_y + popup_y, rotation);
@ -147,18 +138,18 @@ static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface,
render_surface(surface->surface, desktop, wlr_output, when, render_surface(surface->surface, desktop, wlr_output, when,
lx, ly, rotation); lx, ly, rotation);
double width, height; double width = surface->surface->current->width;
get_surface_size(surface->surface, &width, &height); double height = surface->surface->current->height;
struct wlr_wl_shell_surface *popup; struct wlr_wl_shell_surface *popup;
wl_list_for_each(popup, &surface->popups, popup_link) { wl_list_for_each(popup, &surface->popups, popup_link) {
double sw, sh; double popup_width = popup->surface->current->width;
get_surface_size(popup->surface, &sw, &sh); double popup_height = popup->surface->current->height;
double popup_x = popup->transient_state->x; double popup_x = popup->transient_state->x;
double popup_y = popup->transient_state->y; double popup_y = popup->transient_state->y;
rotate_child_position(&popup_x, &popup_y, sw, sh, width, height, rotate_child_position(&popup_x, &popup_y, popup_width, popup_height,
rotation); width, height, rotation);
render_wl_shell_surface(popup, desktop, wlr_output, when, render_wl_shell_surface(popup, desktop, wlr_output, when,
lx + popup_x, ly + popup_y, rotation, true); lx + popup_x, ly + popup_y, rotation, true);