mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -04:00
meson: add -Wfloat-conversion
This commit is contained in:
parent
2ad25b1460
commit
cf857ecf7b
31 changed files with 220 additions and 204 deletions
|
|
@ -23,7 +23,7 @@
|
||||||
#include "backend/drm/cvt.h"
|
#include "backend/drm/cvt.h"
|
||||||
|
|
||||||
/* top/bottom margin size (% of height) - default: 1.8 */
|
/* top/bottom margin size (% of height) - default: 1.8 */
|
||||||
#define CVT_MARGIN_PERCENTAGE 1.8
|
#define CVT_MARGIN_PERCENTAGE 1.8f
|
||||||
|
|
||||||
/* character cell horizontal granularity (pixels) - default 8 */
|
/* character cell horizontal granularity (pixels) - default 8 */
|
||||||
#define CVT_H_GRANULARITY 8
|
#define CVT_H_GRANULARITY 8
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
/* Minimum time of vertical sync + back porch interval (µs)
|
/* Minimum time of vertical sync + back porch interval (µs)
|
||||||
* default 550.0 */
|
* default 550.0 */
|
||||||
#define CVT_MIN_VSYNC_BP 550.0
|
#define CVT_MIN_VSYNC_BP 550
|
||||||
|
|
||||||
/* Nominal hsync width (% of line period) - default 8 */
|
/* Nominal hsync width (% of line period) - default 8 */
|
||||||
#define CVT_HSYNC_PERCENTAGE 8
|
#define CVT_HSYNC_PERCENTAGE 8
|
||||||
|
|
@ -57,18 +57,18 @@
|
||||||
/* Scaling factor weighting - default 20 */
|
/* Scaling factor weighting - default 20 */
|
||||||
#define CVT_J_FACTOR 20
|
#define CVT_J_FACTOR 20
|
||||||
|
|
||||||
#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256
|
#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256.0f
|
||||||
#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \
|
#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256.0f + \
|
||||||
CVT_J_FACTOR
|
CVT_J_FACTOR
|
||||||
|
|
||||||
/* Minimum vertical blanking interval time (µs) - default 460 */
|
/* Minimum vertical blanking interval time (µs) - default 460 */
|
||||||
#define CVT_RB_MIN_VBLANK 460.0
|
#define CVT_RB_MIN_VBLANK 460
|
||||||
|
|
||||||
/* Fixed number of clocks for horizontal sync */
|
/* Fixed number of clocks for horizontal sync */
|
||||||
#define CVT_RB_H_SYNC 32.0
|
#define CVT_RB_H_SYNC 32
|
||||||
|
|
||||||
/* Fixed number of clocks for horizontal blanking */
|
/* Fixed number of clocks for horizontal blanking */
|
||||||
#define CVT_RB_H_BLANK 160.0
|
#define CVT_RB_H_BLANK 160
|
||||||
|
|
||||||
/* Fixed number of lines for vertical front porch - default 3 */
|
/* Fixed number of lines for vertical front porch - default 3 */
|
||||||
#define CVT_RB_VFPORCH 3
|
#define CVT_RB_VFPORCH 3
|
||||||
|
|
@ -98,8 +98,8 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
float interlace; /* Please rename this */
|
float interlace; /* Please rename this */
|
||||||
|
|
||||||
/* CVT default is 60.0Hz */
|
/* CVT default is 60.0Hz */
|
||||||
if (!vrefresh) {
|
if (vrefresh != 0.0f) {
|
||||||
vrefresh = 60.0;
|
vrefresh = 60.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. Required field rate */
|
/* 1. Required field rate */
|
||||||
|
|
@ -115,7 +115,7 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
/* 3. Determine left and right borders */
|
/* 3. Determine left and right borders */
|
||||||
if (margins) {
|
if (margins) {
|
||||||
/* right margin is actually exactly the same as left */
|
/* right margin is actually exactly the same as left */
|
||||||
hmargin = (((float) hdisplay_rnd) * CVT_MARGIN_PERCENTAGE / 100.0);
|
hmargin = (int)(((float)hdisplay_rnd) * CVT_MARGIN_PERCENTAGE / 100.0f);
|
||||||
hmargin -= hmargin % CVT_H_GRANULARITY;
|
hmargin -= hmargin % CVT_H_GRANULARITY;
|
||||||
} else {
|
} else {
|
||||||
hmargin = 0;
|
hmargin = 0;
|
||||||
|
|
@ -135,7 +135,7 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
/* nope. */
|
/* nope. */
|
||||||
if (margins) {
|
if (margins) {
|
||||||
/* top and bottom margins are equal again. */
|
/* top and bottom margins are equal again. */
|
||||||
vmargin = (((float) vdisplay_rnd) * CVT_MARGIN_PERCENTAGE / 100.0);
|
vmargin = (int)(((float)vdisplay_rnd) * CVT_MARGIN_PERCENTAGE / 100.0f);
|
||||||
} else {
|
} else {
|
||||||
vmargin = 0;
|
vmargin = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -186,18 +186,17 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
(void) vblank_porch;
|
(void) vblank_porch;
|
||||||
|
|
||||||
/* 11. Find total number of lines in vertical field */
|
/* 11. Find total number of lines in vertical field */
|
||||||
mode->vtotal = vdisplay_rnd + 2 * vmargin + vsync_and_back_porch + interlace
|
mode->vtotal = vdisplay_rnd + 2 * vmargin + vsync_and_back_porch + CVT_MIN_V_PORCH;
|
||||||
+ CVT_MIN_V_PORCH;
|
|
||||||
|
|
||||||
/* 12. Find ideal blanking duty cycle from formula */
|
/* 12. Find ideal blanking duty cycle from formula */
|
||||||
hblank_percentage = CVT_C_PRIME - CVT_M_PRIME * hperiod / 1000.0;
|
hblank_percentage = CVT_C_PRIME - CVT_M_PRIME * hperiod / 1000.0f;
|
||||||
|
|
||||||
/* 13. Blanking time */
|
/* 13. Blanking time */
|
||||||
if (hblank_percentage < 20) {
|
if (hblank_percentage < 20) {
|
||||||
hblank_percentage = 20;
|
hblank_percentage = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
hblank = mode->hdisplay * hblank_percentage / (100.0 - hblank_percentage);
|
hblank = (int)(mode->hdisplay * hblank_percentage / (100.0f - hblank_percentage));
|
||||||
hblank -= hblank % (2 * CVT_H_GRANULARITY);
|
hblank -= hblank % (2 * CVT_H_GRANULARITY);
|
||||||
|
|
||||||
/* 14. Find total number of pixels in a line. */
|
/* 14. Find total number of pixels in a line. */
|
||||||
|
|
@ -218,11 +217,11 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
int vbi_lines;
|
int vbi_lines;
|
||||||
|
|
||||||
/* 8. Estimate Horizontal period. */
|
/* 8. Estimate Horizontal period. */
|
||||||
hperiod = ((float) (1000000.0 / vfield_rate - CVT_RB_MIN_VBLANK)) /
|
hperiod = ((float)(1000000.0 / vfield_rate - CVT_RB_MIN_VBLANK)) /
|
||||||
(vdisplay_rnd + 2 * vmargin);
|
(vdisplay_rnd + 2 * vmargin);
|
||||||
|
|
||||||
/* 9. Find number of lines in vertical blanking */
|
/* 9. Find number of lines in vertical blanking */
|
||||||
vbi_lines = ((float) CVT_RB_MIN_VBLANK) / hperiod + 1;
|
vbi_lines = (int)((float)CVT_RB_MIN_VBLANK / hperiod) + 1;
|
||||||
|
|
||||||
/* 10. Check if vertical blanking is sufficient */
|
/* 10. Check if vertical blanking is sufficient */
|
||||||
if (vbi_lines < (CVT_RB_VFPORCH + vsync + CVT_MIN_V_BPORCH)) {
|
if (vbi_lines < (CVT_RB_VFPORCH + vsync + CVT_MIN_V_BPORCH)) {
|
||||||
|
|
@ -230,7 +229,7 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 11. Find total number of lines in vertical field */
|
/* 11. Find total number of lines in vertical field */
|
||||||
mode->vtotal = vdisplay_rnd + 2 * vmargin + interlace + vbi_lines;
|
mode->vtotal = vdisplay_rnd + 2 * vmargin + vbi_lines;
|
||||||
|
|
||||||
/* 12. Find total number of pixels in a line */
|
/* 12. Find total number of pixels in a line */
|
||||||
mode->htotal = mode->hdisplay + CVT_RB_H_BLANK;
|
mode->htotal = mode->hdisplay + CVT_RB_H_BLANK;
|
||||||
|
|
@ -245,12 +244,12 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 15/13. Find pixel clock frequency (kHz for xf86) */
|
/* 15/13. Find pixel clock frequency (kHz for xf86) */
|
||||||
mode->clock = mode->htotal * 1000.0 / hperiod;
|
mode->clock = (uint32_t)(mode->htotal * 1000.0f / hperiod);
|
||||||
mode->clock -= mode->clock % CVT_CLOCK_STEP;
|
mode->clock -= mode->clock % CVT_CLOCK_STEP;
|
||||||
|
|
||||||
/* 17/15. Find actual Field rate */
|
/* 17/15. Find actual Field rate */
|
||||||
mode->vrefresh = (1000.0 * ((float) mode->clock)) /
|
mode->vrefresh = (uint32_t)((1000.0f * mode->clock) /
|
||||||
((float) (mode->htotal * mode->vtotal));
|
(mode->htotal * mode->vtotal));
|
||||||
|
|
||||||
/* 18/16. Find actual vertical frame frequency */
|
/* 18/16. Find actual vertical frame frequency */
|
||||||
/* ignore - just set the mode flag for interlaced */
|
/* ignore - just set the mode flag for interlaced */
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ void handle_pointer_axis(struct libinput_event *event,
|
||||||
wlr_event.delta =
|
wlr_event.delta =
|
||||||
libinput_event_pointer_get_axis_value(pevent, axes[i]);
|
libinput_event_pointer_get_axis_value(pevent, axes[i]);
|
||||||
wlr_event.delta_discrete =
|
wlr_event.delta_discrete =
|
||||||
libinput_event_pointer_get_axis_value_discrete(pevent, axes[i]);
|
(int)libinput_event_pointer_get_axis_value_discrete(pevent, axes[i]);
|
||||||
wlr_event.delta_discrete *= WLR_POINTER_AXIS_DISCRETE_STEP;
|
wlr_event.delta_discrete *= WLR_POINTER_AXIS_DISCRETE_STEP;
|
||||||
wl_signal_emit_mutable(&pointer->events.axis, &wlr_event);
|
wl_signal_emit_mutable(&pointer->events.axis, &wlr_event);
|
||||||
}
|
}
|
||||||
|
|
@ -155,7 +155,7 @@ void handle_pointer_axis_value120(struct libinput_event *event,
|
||||||
libinput_event_pointer_get_scroll_value(pevent, axes[i]);
|
libinput_event_pointer_get_scroll_value(pevent, axes[i]);
|
||||||
if (source == WLR_AXIS_SOURCE_WHEEL) {
|
if (source == WLR_AXIS_SOURCE_WHEEL) {
|
||||||
wlr_event.delta_discrete =
|
wlr_event.delta_discrete =
|
||||||
libinput_event_pointer_get_scroll_value_v120(pevent, axes[i]);
|
(int)libinput_event_pointer_get_scroll_value_v120(pevent, axes[i]);
|
||||||
}
|
}
|
||||||
wl_signal_emit_mutable(&pointer->events.axis, &wlr_event);
|
wl_signal_emit_mutable(&pointer->events.axis, &wlr_event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -633,7 +633,7 @@ static int init_encoding(struct capture_context *ctx) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
ctx->avctx->opaque = ctx;
|
ctx->avctx->opaque = ctx;
|
||||||
ctx->avctx->bit_rate = (int)ctx->out_bitrate*1000000.0f;
|
ctx->avctx->bit_rate = (int)(ctx->out_bitrate * 1000000.0f);
|
||||||
ctx->avctx->pix_fmt = ctx->software_format;
|
ctx->avctx->pix_fmt = ctx->software_format;
|
||||||
ctx->avctx->time_base = (AVRational){ 1, 1000 };
|
ctx->avctx->time_base = (AVRational){ 1, 1000 };
|
||||||
ctx->avctx->compression_level = 7;
|
ctx->avctx->compression_level = 7;
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,10 @@ static void render_surface(struct wlr_surface *surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = sx * output->scale,
|
.x = (int)(sx * output->scale),
|
||||||
.y = sy * output->scale,
|
.y = (int)(sy * output->scale),
|
||||||
.width = surface->current.width * output->scale,
|
.width = (int)(surface->current.width * output->scale),
|
||||||
.height = surface->current.height * output->scale,
|
.height = (int)(surface->current.height * output->scale),
|
||||||
};
|
};
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
|
|
@ -95,7 +95,7 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
wlr_renderer_begin(renderer, width, height);
|
wlr_renderer_begin(renderer, width, height);
|
||||||
|
|
||||||
float color[4] = {0.3, 0.3, 0.3, 1.0};
|
float color[4] = {0.3f, 0.3f, 0.3f, 1.0f};
|
||||||
wlr_renderer_clear(renderer, color);
|
wlr_renderer_clear(renderer, color);
|
||||||
|
|
||||||
if (output->surface != NULL) {
|
if (output->surface != NULL) {
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ static void render_frame(void) {
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
if (keys) {
|
if (keys) {
|
||||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
glClearColor(0.8, 0.4, 1.0, 1.0);
|
glClearColor(0.8f, 0.4f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ struct wl_egl_window *popup_egl_window;
|
||||||
static uint32_t popup_width = 256, popup_height = 256;
|
static uint32_t popup_width = 256, popup_height = 256;
|
||||||
struct wlr_egl_surface *popup_egl_surface;
|
struct wlr_egl_surface *popup_egl_surface;
|
||||||
struct wl_callback *popup_frame_callback;
|
struct wl_callback *popup_frame_callback;
|
||||||
float popup_alpha = 1.0, popup_red = 0.5f;
|
float popup_alpha = 1.0f, popup_red = 0.5f;
|
||||||
|
|
||||||
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||||
static uint32_t anchor = 0;
|
static uint32_t anchor = 0;
|
||||||
static uint32_t width = 256, height = 256;
|
static uint32_t width = 256, height = 256;
|
||||||
static int32_t margin_top = 0;
|
static int32_t margin_top = 0;
|
||||||
static double alpha = 1.0;
|
static float alpha = 1.0f;
|
||||||
static bool run_display = true;
|
static bool run_display = true;
|
||||||
static bool animate = false;
|
static bool animate = false;
|
||||||
static enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive =
|
static enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive =
|
||||||
|
|
@ -148,15 +148,15 @@ static void draw(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_popup(void) {
|
static void draw_popup(void) {
|
||||||
static float alpha_mod = -0.01;
|
static float alpha_mod = -0.01f;
|
||||||
|
|
||||||
eglMakeCurrent(egl_display, popup_egl_surface, popup_egl_surface, egl_context);
|
eglMakeCurrent(egl_display, popup_egl_surface, popup_egl_surface, egl_context);
|
||||||
glViewport(0, 0, popup_width, popup_height);
|
glViewport(0, 0, popup_width, popup_height);
|
||||||
glClearColor(popup_red * popup_alpha, 0.5f * popup_alpha,
|
glClearColor(popup_red * popup_alpha, 0.5f * popup_alpha,
|
||||||
0.5f * popup_alpha, popup_alpha);
|
0.5f * popup_alpha, popup_alpha);
|
||||||
popup_alpha += alpha_mod;
|
popup_alpha += alpha_mod;
|
||||||
if (popup_alpha < 0.01 || popup_alpha >= 1.0f) {
|
if (popup_alpha < 0.01f || popup_alpha >= 1.0f) {
|
||||||
alpha_mod *= -1.0;
|
alpha_mod *= -1.0f;
|
||||||
}
|
}
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
@ -324,9 +324,9 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
} else if (input_surface == popup_wl_surface) {
|
} else if (input_surface == popup_wl_surface) {
|
||||||
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||||
if (button == BTN_LEFT && popup_red <= 0.9f) {
|
if (button == BTN_LEFT && popup_red <= 0.9f) {
|
||||||
popup_red += 0.1;
|
popup_red += 0.1f;
|
||||||
} else if (button == BTN_RIGHT && popup_red >= 0.1f) {
|
} else if (button == BTN_RIGHT && popup_red >= 0.1f) {
|
||||||
popup_red -= 0.1;
|
popup_red -= 0.1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -541,7 +541,7 @@ int main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 't':
|
case 't':
|
||||||
alpha = atof(optarg);
|
alpha = (float)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 'm': {
|
case 'm': {
|
||||||
char *endptr = optarg;
|
char *endptr = optarg;
|
||||||
|
|
|
||||||
|
|
@ -82,25 +82,25 @@ static void animate_cat(struct sample_state *sample,
|
||||||
sample->x_offs = l_output->x + 20;
|
sample->x_offs = l_output->x + 20;
|
||||||
sample->y_offs = l_output->y + 20;
|
sample->y_offs = l_output->y + 20;
|
||||||
} else if (ur_collision && ul_collision) {
|
} else if (ur_collision && ul_collision) {
|
||||||
sample->y_vel = fabs(sample->y_vel);
|
sample->y_vel = fabsf(sample->y_vel);
|
||||||
} else if (lr_collision && ll_collision) {
|
} else if (lr_collision && ll_collision) {
|
||||||
sample->y_vel = -fabs(sample->y_vel);
|
sample->y_vel = -fabsf(sample->y_vel);
|
||||||
} else if (ll_collision && ul_collision) {
|
} else if (ll_collision && ul_collision) {
|
||||||
sample->x_vel = fabs(sample->x_vel);
|
sample->x_vel = fabsf(sample->x_vel);
|
||||||
} else if (ur_collision && lr_collision) {
|
} else if (ur_collision && lr_collision) {
|
||||||
sample->x_vel = -fabs(sample->x_vel);
|
sample->x_vel = -fabsf(sample->x_vel);
|
||||||
} else {
|
} else {
|
||||||
if (ur_collision || lr_collision) {
|
if (ur_collision || lr_collision) {
|
||||||
sample->x_vel = -fabs(sample->x_vel);
|
sample->x_vel = -fabsf(sample->x_vel);
|
||||||
}
|
}
|
||||||
if (ul_collision || ll_collision) {
|
if (ul_collision || ll_collision) {
|
||||||
sample->x_vel = fabs(sample->x_vel);
|
sample->x_vel = fabsf(sample->x_vel);
|
||||||
}
|
}
|
||||||
if (ul_collision || ur_collision) {
|
if (ul_collision || ur_collision) {
|
||||||
sample->y_vel = fabs(sample->y_vel);
|
sample->y_vel = fabsf(sample->y_vel);
|
||||||
}
|
}
|
||||||
if (ll_collision || lr_collision) {
|
if (ll_collision || lr_collision) {
|
||||||
sample->y_vel = -fabs(sample->y_vel);
|
sample->y_vel = -fabsf(sample->y_vel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,12 +119,12 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
wlr_output_attach_render(wlr_output, NULL);
|
wlr_output_attach_render(wlr_output, NULL);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
|
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
|
||||||
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1.0f});
|
||||||
|
|
||||||
animate_cat(sample, output->output);
|
animate_cat(sample, output->output);
|
||||||
|
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = sample->x_offs, .y = sample->y_offs,
|
.x = (int)sample->x_offs, .y = (int)sample->y_offs,
|
||||||
.width = 128, .height = 128,
|
.width = 128, .height = 128,
|
||||||
};
|
};
|
||||||
if (wlr_output_layout_intersects(sample->layout, output->output, &box)) {
|
if (wlr_output_layout_intersects(sample->layout, output->output, &box)) {
|
||||||
|
|
@ -135,7 +135,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
&local_x, &local_y);
|
&local_x, &local_y);
|
||||||
|
|
||||||
wlr_render_texture(sample->renderer, sample->cat_texture,
|
wlr_render_texture(sample->renderer, sample->cat_texture,
|
||||||
wlr_output->transform_matrix, local_x, local_y, 1.0f);
|
wlr_output->transform_matrix,
|
||||||
|
(int)local_x, (int)local_y, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_renderer_end(sample->renderer);
|
wlr_renderer_end(sample->renderer);
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_output_commit(wlr_output);
|
wlr_output_commit(wlr_output);
|
||||||
|
|
||||||
//TODO rotate with a delta time
|
//TODO rotate with a delta time
|
||||||
rotation += 0.05;
|
rotation += 0.05f;
|
||||||
if (rotation > 2 * M_PI) {
|
if (rotation > 2 * M_PI) {
|
||||||
rotation = 0.f;
|
rotation = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
sample->last_frame = now;
|
sample->last_frame = now;
|
||||||
|
|
|
||||||
|
|
@ -91,17 +91,17 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
|
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
|
||||||
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
|
||||||
|
|
||||||
float distance = 0.8f * (1 - sample->distance);
|
float distance = 0.8f * (float)(1.0 - sample->distance);
|
||||||
float tool_color[4] = { distance, distance, distance, 1 };
|
float tool_color[4] = { distance, distance, distance, 1 };
|
||||||
for (size_t i = 0; sample->button && i < 4; ++i) {
|
for (size_t i = 0; sample->button && i < 4; ++i) {
|
||||||
tool_color[i] = sample->tool_color[i];
|
tool_color[i] = sample->tool_color[i];
|
||||||
}
|
}
|
||||||
float scale = 4;
|
float scale = 4;
|
||||||
|
|
||||||
float pad_width = sample->width_mm * scale;
|
int pad_width = (int)(sample->width_mm * scale);
|
||||||
float pad_height = sample->height_mm * scale;
|
int pad_height = (int)(sample->height_mm * scale);
|
||||||
float left = width / 2.0f - pad_width / 2.0f;
|
int left = (int)(width / 2.0f - pad_width / 2.0f);
|
||||||
float top = height / 2.0f - pad_height / 2.0f;
|
int top = (int)(height / 2.0f - pad_height / 2.0f);
|
||||||
const struct wlr_box box = {
|
const struct wlr_box box = {
|
||||||
.x = left, .y = top,
|
.x = left, .y = top,
|
||||||
.width = pad_width, .height = pad_height,
|
.width = pad_width, .height = pad_height,
|
||||||
|
|
@ -111,18 +111,18 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
if (sample->proximity) {
|
if (sample->proximity) {
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = (sample->x * pad_width) - 8 * (sample->pressure + 1) + left,
|
.x = (int)((sample->x * pad_width) - 8 * (sample->pressure + 1) + left),
|
||||||
.y = (sample->y * pad_height) - 8 * (sample->pressure + 1) + top,
|
.y = (int)((sample->y * pad_height) - 8 * (sample->pressure + 1) + top),
|
||||||
.width = 16 * (sample->pressure + 1),
|
.width = (int)(16 * (sample->pressure + 1)),
|
||||||
.height = 16 * (sample->pressure + 1),
|
.height = (int)(16 * (sample->pressure + 1)),
|
||||||
};
|
};
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
sample->ring, wlr_output->transform_matrix);
|
(float)sample->ring, wlr_output->transform_matrix);
|
||||||
wlr_render_quad_with_matrix(sample->renderer, tool_color, matrix);
|
wlr_render_quad_with_matrix(sample->renderer, tool_color, matrix);
|
||||||
|
|
||||||
box.x += sample->x_tilt;
|
box.x += (int)sample->x_tilt;
|
||||||
box.y += sample->y_tilt;
|
box.y += (int)sample->y_tilt;
|
||||||
box.width /= 2;
|
box.width /= 2;
|
||||||
box.height /= 2;
|
box.height /= 2;
|
||||||
wlr_render_rect(sample->renderer, &box, tool_color,
|
wlr_render_rect(sample->renderer, &box, tool_color,
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,9 @@ struct wlr_egl_surface *egl_surface;
|
||||||
static void draw(void) {
|
static void draw(void) {
|
||||||
eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
|
eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
|
||||||
|
|
||||||
float color[] = {1.0, 1.0, 0.0, 1.0};
|
float color[] = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||||
color[0] = enabled * 1.0;
|
color[0] = enabled * 1.0f;
|
||||||
color[1] = entered * 1.0;
|
color[1] = entered * 1.0f;
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glClearColor(color[0], color[1], color[2], 1.0);
|
glClearColor(color[0], color[1], color[2], 1.0);
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ add_project_arguments(cc.get_supported_arguments([
|
||||||
'-Wno-missing-braces',
|
'-Wno-missing-braces',
|
||||||
'-Wno-missing-field-initializers',
|
'-Wno-missing-field-initializers',
|
||||||
'-Wno-unused-parameter',
|
'-Wno-unused-parameter',
|
||||||
|
|
||||||
|
'-Wfloat-conversion',
|
||||||
]), language: 'c')
|
]), language: 'c')
|
||||||
|
|
||||||
# Compute the relative path used by compiler invocations.
|
# Compute the relative path used by compiler invocations.
|
||||||
|
|
|
||||||
|
|
@ -305,10 +305,10 @@ static bool gles2_render_subtexture_with_matrix(
|
||||||
glUniform1i(shader->tex, 0);
|
glUniform1i(shader->tex, 0);
|
||||||
glUniform1f(shader->alpha, alpha);
|
glUniform1f(shader->alpha, alpha);
|
||||||
|
|
||||||
const GLfloat x1 = box->x / wlr_texture->width;
|
const GLfloat x1 = (GLfloat)(box->x / wlr_texture->width);
|
||||||
const GLfloat y1 = box->y / wlr_texture->height;
|
const GLfloat y1 = (GLfloat)(box->y / wlr_texture->height);
|
||||||
const GLfloat x2 = (box->x + box->width) / wlr_texture->width;
|
const GLfloat x2 = (GLfloat)((box->x + box->width) / wlr_texture->width);
|
||||||
const GLfloat y2 = (box->y + box->height) / wlr_texture->height;
|
const GLfloat y2 = (GLfloat)((box->y + box->height) / wlr_texture->height);
|
||||||
const GLfloat texcoord[] = {
|
const GLfloat texcoord[] = {
|
||||||
x2, y1, // top right
|
x2, y1, // top right
|
||||||
x1, y1, // top left
|
x1, y1, // top left
|
||||||
|
|
|
||||||
|
|
@ -169,10 +169,10 @@ static void pixman_clear(struct wlr_renderer *wlr_renderer,
|
||||||
struct wlr_pixman_buffer *buffer = renderer->current_buffer;
|
struct wlr_pixman_buffer *buffer = renderer->current_buffer;
|
||||||
|
|
||||||
const struct pixman_color colour = {
|
const struct pixman_color colour = {
|
||||||
.red = color[0] * 0xFFFF,
|
.red = (uint16_t)(color[0] * 0xFFFF),
|
||||||
.green = color[1] * 0xFFFF,
|
.green = (uint16_t)(color[1] * 0xFFFF),
|
||||||
.blue = color[2] * 0xFFFF,
|
.blue = (uint16_t)(color[2] * 0xFFFF),
|
||||||
.alpha = color[3] * 0xFFFF,
|
.alpha = (uint16_t)(color[3] * 0xFFFF),
|
||||||
};
|
};
|
||||||
|
|
||||||
pixman_image_t *fill = pixman_image_create_solid_fill(&colour);
|
pixman_image_t *fill = pixman_image_create_solid_fill(&colour);
|
||||||
|
|
@ -247,12 +247,12 @@ static bool pixman_render_subtexture_with_matrix(
|
||||||
|
|
||||||
// TODO: don't create a mask if alpha == 1.0
|
// TODO: don't create a mask if alpha == 1.0
|
||||||
struct pixman_color mask_colour = {0};
|
struct pixman_color mask_colour = {0};
|
||||||
mask_colour.alpha = 0xFFFF * alpha;
|
mask_colour.alpha = (uint16_t)(0xFFFF * alpha);
|
||||||
pixman_image_t *mask = pixman_image_create_solid_fill(&mask_colour);
|
pixman_image_t *mask = pixman_image_create_solid_fill(&mask_colour);
|
||||||
|
|
||||||
float m[9];
|
float m[9];
|
||||||
memcpy(m, matrix, sizeof(m));
|
memcpy(m, matrix, sizeof(m));
|
||||||
wlr_matrix_scale(m, 1.0 / fbox->width, 1.0 / fbox->height);
|
wlr_matrix_scale(m, 1.0f / (float)fbox->width, 1.0f / (float)fbox->height);
|
||||||
|
|
||||||
struct pixman_transform transform = {0};
|
struct pixman_transform transform = {0};
|
||||||
matrix_to_pixman_transform(&transform, m);
|
matrix_to_pixman_transform(&transform, m);
|
||||||
|
|
@ -279,11 +279,11 @@ static void pixman_render_quad_with_matrix(struct wlr_renderer *wlr_renderer,
|
||||||
struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
|
struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
|
||||||
struct wlr_pixman_buffer *buffer = renderer->current_buffer;
|
struct wlr_pixman_buffer *buffer = renderer->current_buffer;
|
||||||
|
|
||||||
struct pixman_color colour = {
|
const struct pixman_color colour = {
|
||||||
.red = color[0] * 0xFFFF,
|
.red = (uint16_t)(color[0] * 0xFFFF),
|
||||||
.green = color[1] * 0xFFFF,
|
.green = (uint16_t)(color[1] * 0xFFFF),
|
||||||
.blue = color[2] * 0xFFFF,
|
.blue = (uint16_t)(color[2] * 0xFFFF),
|
||||||
.alpha = color[3] * 0xFFFF,
|
.alpha = (uint16_t)(color[3] * 0xFFFF),
|
||||||
};
|
};
|
||||||
|
|
||||||
pixman_image_t *fill = pixman_image_create_solid_fill(&colour);
|
pixman_image_t *fill = pixman_image_create_solid_fill(&colour);
|
||||||
|
|
@ -294,21 +294,21 @@ static void pixman_render_quad_with_matrix(struct wlr_renderer *wlr_renderer,
|
||||||
// TODO get the width/height from the caller instead of extracting them
|
// TODO get the width/height from the caller instead of extracting them
|
||||||
float width, height;
|
float width, height;
|
||||||
if (matrix[1] == 0.0 && matrix[3] == 0.0) {
|
if (matrix[1] == 0.0 && matrix[3] == 0.0) {
|
||||||
width = fabs(matrix[0]);
|
width = fabsf(matrix[0]);
|
||||||
height = fabs(matrix[4]);
|
height = fabsf(matrix[4]);
|
||||||
} else {
|
} else {
|
||||||
width = sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1]);
|
width = sqrtf(matrix[0] * matrix[0] + matrix[1] * matrix[1]);
|
||||||
height = sqrt(matrix[3] * matrix[3] + matrix[4] * matrix[4]);
|
height = sqrtf(matrix[3] * matrix[3] + matrix[4] * matrix[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_matrix_scale(m, 1.0 / width, 1.0 / height);
|
wlr_matrix_scale(m, 1.0f / width, 1.0f / height);
|
||||||
|
|
||||||
pixman_image_t *image = pixman_image_create_bits(PIXMAN_a8r8g8b8, width,
|
pixman_image_t *image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
|
||||||
height, NULL, 0);
|
(int)width, (int)height, NULL, 0);
|
||||||
|
|
||||||
// TODO find a way to fill the image without allocating 2 images
|
// TODO find a way to fill the image without allocating 2 images
|
||||||
pixman_image_composite32(PIXMAN_OP_SRC, fill, NULL, image,
|
pixman_image_composite32(PIXMAN_OP_SRC, fill, NULL, image,
|
||||||
0, 0, 0, 0, 0, 0, width, height);
|
0, 0, 0, 0, 0, 0, (int)width, (int)height);
|
||||||
pixman_image_unref(fill);
|
pixman_image_unref(fill);
|
||||||
|
|
||||||
struct pixman_transform transform = {0};
|
struct pixman_transform transform = {0};
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ struct vert_pcr_data {
|
||||||
|
|
||||||
// https://www.w3.org/Graphics/Color/srgb
|
// https://www.w3.org/Graphics/Color/srgb
|
||||||
static float color_to_linear(float non_linear) {
|
static float color_to_linear(float non_linear) {
|
||||||
return (non_linear > 0.04045) ?
|
return (non_linear > 0.04045f) ?
|
||||||
pow((non_linear + 0.055) / 1.055, 2.4) :
|
powf((non_linear + 0.055f) / 1.055f, 2.4f) :
|
||||||
non_linear / 12.92;
|
non_linear / 12.92f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// renderer
|
// renderer
|
||||||
|
|
@ -776,10 +776,10 @@ static bool vulkan_render_subtexture_with_matrix(struct wlr_renderer *wlr_render
|
||||||
struct vert_pcr_data vert_pcr_data;
|
struct vert_pcr_data vert_pcr_data;
|
||||||
mat3_to_mat4(final_matrix, vert_pcr_data.mat4);
|
mat3_to_mat4(final_matrix, vert_pcr_data.mat4);
|
||||||
|
|
||||||
vert_pcr_data.uv_off[0] = box->x / wlr_texture->width;
|
vert_pcr_data.uv_off[0] = (float)(box->x / wlr_texture->width);
|
||||||
vert_pcr_data.uv_off[1] = box->y / wlr_texture->height;
|
vert_pcr_data.uv_off[1] = (float)(box->y / wlr_texture->height);
|
||||||
vert_pcr_data.uv_size[0] = box->width / wlr_texture->width;
|
vert_pcr_data.uv_size[0] = (float)(box->width / wlr_texture->width);
|
||||||
vert_pcr_data.uv_size[1] = box->height / wlr_texture->height;
|
vert_pcr_data.uv_size[1] = (float)(box->height / wlr_texture->height);
|
||||||
|
|
||||||
vkCmdPushConstants(cb, renderer->pipe_layout,
|
vkCmdPushConstants(cb, renderer->pipe_layout,
|
||||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(vert_pcr_data), &vert_pcr_data);
|
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(vert_pcr_data), &vert_pcr_data);
|
||||||
|
|
|
||||||
|
|
@ -366,8 +366,8 @@ static struct tinywl_view *desktop_view_at(
|
||||||
static void process_cursor_move(struct tinywl_server *server, uint32_t time) {
|
static void process_cursor_move(struct tinywl_server *server, uint32_t time) {
|
||||||
/* Move the grabbed view to the new position. */
|
/* Move the grabbed view to the new position. */
|
||||||
struct tinywl_view *view = server->grabbed_view;
|
struct tinywl_view *view = server->grabbed_view;
|
||||||
view->x = server->cursor->x - server->grab_x;
|
view->x = (int)(server->cursor->x - server->grab_x);
|
||||||
view->y = server->cursor->y - server->grab_y;
|
view->y = (int)(server->cursor->y - server->grab_y);
|
||||||
wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y);
|
wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,8 +383,8 @@ static void process_cursor_resize(struct tinywl_server *server, uint32_t time) {
|
||||||
* commit any movement that was prepared.
|
* commit any movement that was prepared.
|
||||||
*/
|
*/
|
||||||
struct tinywl_view *view = server->grabbed_view;
|
struct tinywl_view *view = server->grabbed_view;
|
||||||
double border_x = server->cursor->x - server->grab_x;
|
int border_x = (int)(server->cursor->x - server->grab_x);
|
||||||
double border_y = server->cursor->y - server->grab_y;
|
int border_y = (int)(server->cursor->y - server->grab_y);
|
||||||
int new_left = server->grab_geobox.x;
|
int new_left = server->grab_geobox.x;
|
||||||
int new_right = server->grab_geobox.x + server->grab_geobox.width;
|
int new_right = server->grab_geobox.x + server->grab_geobox.width;
|
||||||
int new_top = server->grab_geobox.y;
|
int new_top = server->grab_geobox.y;
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,8 @@ static void output_scissor(struct wlr_output *output, pixman_box32_t *rect) {
|
||||||
*/
|
*/
|
||||||
static void output_cursor_get_box(struct wlr_output_cursor *cursor,
|
static void output_cursor_get_box(struct wlr_output_cursor *cursor,
|
||||||
struct wlr_box *box) {
|
struct wlr_box *box) {
|
||||||
box->x = cursor->x - cursor->hotspot_x;
|
box->x = (int)(cursor->x - cursor->hotspot_x);
|
||||||
box->y = cursor->y - cursor->hotspot_y;
|
box->y = (int)(cursor->y - cursor->hotspot_y);
|
||||||
box->width = cursor->width;
|
box->width = cursor->width;
|
||||||
box->height = cursor->height;
|
box->height = cursor->height;
|
||||||
}
|
}
|
||||||
|
|
@ -287,8 +287,8 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_box cursor_box = {
|
struct wlr_box cursor_box = {
|
||||||
.width = texture->width * output->scale / scale,
|
.width = (int)(texture->width * output->scale / scale),
|
||||||
.height = texture->height * output->scale / scale,
|
.height = (int)(texture->height * output->scale / scale),
|
||||||
};
|
};
|
||||||
|
|
||||||
float output_matrix[9];
|
float output_matrix[9];
|
||||||
|
|
@ -300,11 +300,11 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
|
||||||
};
|
};
|
||||||
wlr_box_transform(&tr_size, &tr_size, output->transform, 0, 0);
|
wlr_box_transform(&tr_size, &tr_size, output->transform, 0, 0);
|
||||||
|
|
||||||
wlr_matrix_translate(output_matrix, buffer->width / 2.0,
|
wlr_matrix_translate(output_matrix, buffer->width / 2.0f,
|
||||||
buffer->height / 2.0);
|
buffer->height / 2.0f);
|
||||||
wlr_matrix_transform(output_matrix, output->transform);
|
wlr_matrix_transform(output_matrix, output->transform);
|
||||||
wlr_matrix_translate(output_matrix, - tr_size.width / 2.0,
|
wlr_matrix_translate(output_matrix, - tr_size.width / 2.0f,
|
||||||
- tr_size.height / 2.0);
|
- tr_size.height / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
|
|
@ -446,12 +446,12 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor,
|
||||||
|
|
||||||
// Some clients commit a cursor surface with a NULL buffer to hide it.
|
// Some clients commit a cursor surface with a NULL buffer to hide it.
|
||||||
cursor->enabled = wlr_surface_has_buffer(surface);
|
cursor->enabled = wlr_surface_has_buffer(surface);
|
||||||
cursor->width = surface->current.width * cursor->output->scale;
|
cursor->width = (int)(surface->current.width * cursor->output->scale);
|
||||||
cursor->height = surface->current.height * cursor->output->scale;
|
cursor->height = (int)(surface->current.height * cursor->output->scale);
|
||||||
output_cursor_update_visible(cursor);
|
output_cursor_update_visible(cursor);
|
||||||
if (update_hotspot) {
|
if (update_hotspot) {
|
||||||
cursor->hotspot_x -= surface->current.dx * cursor->output->scale;
|
cursor->hotspot_x -= (int32_t)(surface->current.dx * cursor->output->scale);
|
||||||
cursor->hotspot_y -= surface->current.dy * cursor->output->scale;
|
cursor->hotspot_y -= (int32_t)(surface->current.dy * cursor->output->scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_cursor_attempt_hardware(cursor)) {
|
if (output_cursor_attempt_hardware(cursor)) {
|
||||||
|
|
@ -478,8 +478,8 @@ static void output_cursor_handle_destroy(struct wl_listener *listener,
|
||||||
|
|
||||||
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
||||||
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
|
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
hotspot_x *= cursor->output->scale;
|
hotspot_x = (int32_t)(hotspot_x * cursor->output->scale);
|
||||||
hotspot_y *= cursor->output->scale;
|
hotspot_y = (int32_t)(hotspot_y * cursor->output->scale);
|
||||||
|
|
||||||
if (surface && surface == cursor->surface) {
|
if (surface && surface == cursor->surface) {
|
||||||
// Only update the hotspot: surface hasn't changed
|
// Only update the hotspot: surface hasn't changed
|
||||||
|
|
|
||||||
|
|
@ -197,10 +197,10 @@ static void output_update_matrix(struct wlr_output *output) {
|
||||||
wlr_output_transformed_resolution(output, &tr_width, &tr_height);
|
wlr_output_transformed_resolution(output, &tr_width, &tr_height);
|
||||||
|
|
||||||
wlr_matrix_translate(output->transform_matrix,
|
wlr_matrix_translate(output->transform_matrix,
|
||||||
output->width / 2.0, output->height / 2.0);
|
output->width / 2.0f, output->height / 2.0f);
|
||||||
wlr_matrix_transform(output->transform_matrix, output->transform);
|
wlr_matrix_transform(output->transform_matrix, output->transform);
|
||||||
wlr_matrix_translate(output->transform_matrix,
|
wlr_matrix_translate(output->transform_matrix,
|
||||||
- tr_width / 2.0, - tr_height / 2.0);
|
- tr_width / 2.0f, - tr_height / 2.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,8 +439,8 @@ void wlr_output_transformed_resolution(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) {
|
||||||
wlr_output_transformed_resolution(output, width, height);
|
wlr_output_transformed_resolution(output, width, height);
|
||||||
*width /= output->scale;
|
*width = (int)(*width / output->scale);
|
||||||
*height /= output->scale;
|
*height = (int)(*height / output->scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) {
|
struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) {
|
||||||
|
|
|
||||||
|
|
@ -601,7 +601,8 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff
|
||||||
wlr_region_transform(&trans_damage, damage,
|
wlr_region_transform(&trans_damage, damage,
|
||||||
scene_buffer->transform, buffer->width, buffer->height);
|
scene_buffer->transform, buffer->width, buffer->height);
|
||||||
pixman_region32_intersect_rect(&trans_damage, &trans_damage,
|
pixman_region32_intersect_rect(&trans_damage, &trans_damage,
|
||||||
box.x, box.y, box.width, box.height);
|
(int)box.x, (int)box.y,
|
||||||
|
(unsigned int)box.width, (unsigned int)box.height);
|
||||||
|
|
||||||
struct wlr_scene *scene = scene_node_get_root(&scene_buffer->node);
|
struct wlr_scene *scene = scene_node_get_root(&scene_buffer->node);
|
||||||
struct wlr_scene_output *scene_output;
|
struct wlr_scene_output *scene_output;
|
||||||
|
|
@ -610,18 +611,21 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff
|
||||||
pixman_region32_t output_damage;
|
pixman_region32_t output_damage;
|
||||||
pixman_region32_init(&output_damage);
|
pixman_region32_init(&output_damage);
|
||||||
wlr_region_scale_xy(&output_damage, &trans_damage,
|
wlr_region_scale_xy(&output_damage, &trans_damage,
|
||||||
output_scale * scale_x, output_scale * scale_y);
|
(float)(output_scale * scale_x),
|
||||||
|
(float)(output_scale * scale_y));
|
||||||
|
|
||||||
pixman_region32_t cull_region;
|
pixman_region32_t cull_region;
|
||||||
pixman_region32_init(&cull_region);
|
pixman_region32_init(&cull_region);
|
||||||
wlr_region_scale(&cull_region, &scene_buffer->node.visible, output_scale);
|
wlr_region_scale(&cull_region, &scene_buffer->node.visible, output_scale);
|
||||||
pixman_region32_translate(&cull_region, -lx * output_scale, -ly * output_scale);
|
pixman_region32_translate(&cull_region,
|
||||||
|
(int)(-lx * output_scale),
|
||||||
|
(int)(-ly * output_scale));
|
||||||
pixman_region32_intersect(&output_damage, &output_damage, &cull_region);
|
pixman_region32_intersect(&output_damage, &output_damage, &cull_region);
|
||||||
pixman_region32_fini(&cull_region);
|
pixman_region32_fini(&cull_region);
|
||||||
|
|
||||||
pixman_region32_translate(&output_damage,
|
pixman_region32_translate(&output_damage,
|
||||||
(lx - scene_output->x) * output_scale,
|
(int)((lx - scene_output->x) * output_scale),
|
||||||
(ly - scene_output->y) * output_scale);
|
(int)((ly - scene_output->y) * output_scale));
|
||||||
if (wlr_damage_ring_add(&scene_output->damage_ring, &output_damage)) {
|
if (wlr_damage_ring_add(&scene_output->damage_ring, &output_damage)) {
|
||||||
wlr_output_schedule_frame(scene_output->output);
|
wlr_output_schedule_frame(scene_output->output);
|
||||||
}
|
}
|
||||||
|
|
@ -740,14 +744,14 @@ static void scene_node_get_size(struct wlr_scene_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scale_length(int length, int offset, float scale) {
|
static int scale_length(int length, int offset, float scale) {
|
||||||
return round((offset + length) * scale) - round(offset * scale);
|
return (int)(round((offset + length) * scale) - round(offset * scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scale_box(struct wlr_box *box, float scale) {
|
static void scale_box(struct wlr_box *box, float scale) {
|
||||||
box->width = scale_length(box->width, box->x, scale);
|
box->width = scale_length(box->width, box->x, scale);
|
||||||
box->height = scale_length(box->height, box->y, scale);
|
box->height = scale_length(box->height, box->y, scale);
|
||||||
box->x = round(box->x * scale);
|
box->x = (int)round(box->x * scale);
|
||||||
box->y = round(box->y * scale);
|
box->y = (int)round(box->y * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled) {
|
void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled) {
|
||||||
|
|
@ -900,8 +904,8 @@ void wlr_scene_node_for_each_buffer(struct wlr_scene_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct node_at_data {
|
struct node_at_data {
|
||||||
double lx, ly;
|
int lx, ly;
|
||||||
double rx, ry;
|
int rx, ry;
|
||||||
struct wlr_scene_node *node;
|
struct wlr_scene_node *node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -909,8 +913,8 @@ static bool scene_node_at_iterator(struct wlr_scene_node *node,
|
||||||
int lx, int ly, void *data) {
|
int lx, int ly, void *data) {
|
||||||
struct node_at_data *at_data = data;
|
struct node_at_data *at_data = data;
|
||||||
|
|
||||||
double rx = at_data->lx - lx;
|
int rx = at_data->lx - lx;
|
||||||
double ry = at_data->ly - ly;
|
int ry = at_data->ly - ly;
|
||||||
|
|
||||||
if (node->type == WLR_SCENE_NODE_BUFFER) {
|
if (node->type == WLR_SCENE_NODE_BUFFER) {
|
||||||
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
|
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
|
||||||
|
|
@ -930,15 +934,15 @@ static bool scene_node_at_iterator(struct wlr_scene_node *node,
|
||||||
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
||||||
double lx, double ly, double *nx, double *ny) {
|
double lx, double ly, double *nx, double *ny) {
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = floor(lx),
|
.x = (int)floor(lx),
|
||||||
.y = floor(ly),
|
.y = (int)floor(ly),
|
||||||
.width = 1,
|
.width = 1,
|
||||||
.height = 1
|
.height = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
struct node_at_data data = {
|
struct node_at_data data = {
|
||||||
.lx = lx,
|
.lx = (int)lx,
|
||||||
.ly = ly
|
.ly = (int)ly
|
||||||
};
|
};
|
||||||
|
|
||||||
if (scene_nodes_in_box(node, &box, scene_node_at_iterator, &data)) {
|
if (scene_nodes_in_box(node, &box, scene_node_at_iterator, &data)) {
|
||||||
|
|
@ -1545,7 +1549,7 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) {
|
||||||
struct timespec time_diff;
|
struct timespec time_diff;
|
||||||
timespec_sub(&time_diff, &now, &damage->when);
|
timespec_sub(&time_diff, &now, &damage->when);
|
||||||
int64_t time_diff_ms = timespec_to_msec(&time_diff);
|
int64_t time_diff_ms = timespec_to_msec(&time_diff);
|
||||||
float alpha = 1.0 - (double)time_diff_ms / HIGHLIGHT_DAMAGE_FADEOUT_TIME;
|
float alpha = 1.0f - (float)time_diff_ms / HIGHLIGHT_DAMAGE_FADEOUT_TIME;
|
||||||
|
|
||||||
int nrects;
|
int nrects;
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage->region, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(&damage->region, &nrects);
|
||||||
|
|
@ -1557,7 +1561,7 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) {
|
||||||
.height = rects[i].y2 - rects[i].y1,
|
.height = rects[i].y2 - rects[i].y1,
|
||||||
};
|
};
|
||||||
|
|
||||||
float color[4] = { alpha * .5, 0.0, 0.0, alpha * .5 };
|
float color[4] = { alpha * 0.5f, 0.0f, 0.0f, alpha * 0.5f };
|
||||||
wlr_render_rect(renderer, &box, color, output->transform_matrix);
|
wlr_render_rect(renderer, &box, color, output->transform_matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,8 +350,8 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
if (send_source && version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION) {
|
if (send_source && version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION) {
|
||||||
wl_pointer_send_axis_source(resource, source);
|
wl_pointer_send_axis_source(resource, source);
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value != 0.0) {
|
||||||
if (value_discrete) {
|
if (value_discrete != 0) {
|
||||||
if (version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) {
|
if (version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) {
|
||||||
// High resolution discrete scrolling
|
// High resolution discrete scrolling
|
||||||
wl_pointer_send_axis_value120(resource, orientation,
|
wl_pointer_send_axis_value120(resource, orientation,
|
||||||
|
|
|
||||||
|
|
@ -505,7 +505,7 @@ void wlr_send_tablet_v2_tablet_pad_strip(struct wlr_tablet_v2_tablet_pad *pad,
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
zwp_tablet_pad_strip_v2_send_stop(resource);
|
zwp_tablet_pad_strip_v2_send_stop(resource);
|
||||||
} else {
|
} else {
|
||||||
zwp_tablet_pad_strip_v2_send_position(resource, position * 65535);
|
zwp_tablet_pad_strip_v2_send_position(resource, (int)(position * 65535));
|
||||||
}
|
}
|
||||||
zwp_tablet_pad_strip_v2_send_frame(resource, time);
|
zwp_tablet_pad_strip_v2_send_frame(resource, time);
|
||||||
}
|
}
|
||||||
|
|
@ -526,7 +526,8 @@ void wlr_send_tablet_v2_tablet_pad_ring(struct wlr_tablet_v2_tablet_pad *pad,
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
zwp_tablet_pad_ring_v2_send_stop(resource);
|
zwp_tablet_pad_ring_v2_send_stop(resource);
|
||||||
} else {
|
} else {
|
||||||
zwp_tablet_pad_ring_v2_send_angle(resource, position);
|
zwp_tablet_pad_ring_v2_send_angle(resource,
|
||||||
|
wl_fixed_from_double(position));
|
||||||
}
|
}
|
||||||
zwp_tablet_pad_ring_v2_send_frame(resource, time);
|
zwp_tablet_pad_ring_v2_send_frame(resource, time);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ void wlr_send_tablet_v2_tablet_tool_pressure(
|
||||||
struct wlr_tablet_v2_tablet_tool *tool, double pressure) {
|
struct wlr_tablet_v2_tablet_tool *tool, double pressure) {
|
||||||
if (tool->current_client) {
|
if (tool->current_client) {
|
||||||
zwp_tablet_tool_v2_send_pressure(tool->current_client->resource,
|
zwp_tablet_tool_v2_send_pressure(tool->current_client->resource,
|
||||||
pressure * 65535);
|
(uint32_t)(pressure * 65535));
|
||||||
|
|
||||||
queue_tool_frame(tool->current_client);
|
queue_tool_frame(tool->current_client);
|
||||||
}
|
}
|
||||||
|
|
@ -425,7 +425,7 @@ void wlr_send_tablet_v2_tablet_tool_distance(
|
||||||
struct wlr_tablet_v2_tablet_tool *tool, double distance) {
|
struct wlr_tablet_v2_tablet_tool *tool, double distance) {
|
||||||
if (tool->current_client) {
|
if (tool->current_client) {
|
||||||
zwp_tablet_tool_v2_send_distance(tool->current_client->resource,
|
zwp_tablet_tool_v2_send_distance(tool->current_client->resource,
|
||||||
distance * 65535);
|
(uint32_t)(distance * 65535));
|
||||||
|
|
||||||
queue_tool_frame(tool->current_client);
|
queue_tool_frame(tool->current_client);
|
||||||
}
|
}
|
||||||
|
|
@ -462,7 +462,7 @@ void wlr_send_tablet_v2_tablet_tool_slider(
|
||||||
}
|
}
|
||||||
|
|
||||||
zwp_tablet_tool_v2_send_slider(tool->current_client->resource,
|
zwp_tablet_tool_v2_send_slider(tool->current_client->resource,
|
||||||
position * 65535);
|
(uint32_t)(position * 65535));
|
||||||
|
|
||||||
queue_tool_frame(tool->current_client);
|
queue_tool_frame(tool->current_client);
|
||||||
}
|
}
|
||||||
|
|
@ -489,7 +489,7 @@ void wlr_send_tablet_v2_tablet_tool_wheel(
|
||||||
struct wlr_tablet_v2_tablet_tool *tool, double degrees, int32_t clicks) {
|
struct wlr_tablet_v2_tablet_tool *tool, double degrees, int32_t clicks) {
|
||||||
if (tool->current_client) {
|
if (tool->current_client) {
|
||||||
zwp_tablet_tool_v2_send_wheel(tool->current_client->resource,
|
zwp_tablet_tool_v2_send_wheel(tool->current_client->resource,
|
||||||
clicks, degrees);
|
wl_fixed_from_double(degrees), clicks);
|
||||||
|
|
||||||
queue_tool_frame(tool->current_client);
|
queue_tool_frame(tool->current_client);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,8 @@ static void surface_state_viewport_src_size(struct wlr_surface_state *state,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->viewport.has_src) {
|
if (state->viewport.has_src) {
|
||||||
*out_width = state->viewport.src.width;
|
*out_width = (int)state->viewport.src.width;
|
||||||
*out_height = state->viewport.src.height;
|
*out_height = (int)state->viewport.src.height;
|
||||||
} else {
|
} else {
|
||||||
surface_state_transformed_buffer_size(state,
|
surface_state_transformed_buffer_size(state,
|
||||||
out_width, out_height);
|
out_width, out_height);
|
||||||
|
|
@ -248,13 +248,13 @@ static void surface_update_damage(pixman_region32_t *buffer_damage,
|
||||||
float scale_x = (float)pending->viewport.dst_width / src_width;
|
float scale_x = (float)pending->viewport.dst_width / src_width;
|
||||||
float scale_y = (float)pending->viewport.dst_height / src_height;
|
float scale_y = (float)pending->viewport.dst_height / src_height;
|
||||||
wlr_region_scale_xy(&surface_damage, &surface_damage,
|
wlr_region_scale_xy(&surface_damage, &surface_damage,
|
||||||
1.0 / scale_x, 1.0 / scale_y);
|
1.0f / scale_x, 1.0f / scale_y);
|
||||||
}
|
}
|
||||||
if (pending->viewport.has_src) {
|
if (pending->viewport.has_src) {
|
||||||
// This is lossy: do a best-effort conversion
|
// This is lossy: do a best-effort conversion
|
||||||
pixman_region32_translate(&surface_damage,
|
pixman_region32_translate(&surface_damage,
|
||||||
floor(pending->viewport.src.x),
|
(int)floor(pending->viewport.src.x),
|
||||||
floor(pending->viewport.src.y));
|
(int)floor(pending->viewport.src.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_region_scale(&surface_damage, &surface_damage, pending->scale);
|
wlr_region_scale(&surface_damage, &surface_damage, pending->scale);
|
||||||
|
|
@ -795,7 +795,8 @@ bool wlr_surface_point_accepts_input(struct wlr_surface *surface,
|
||||||
double sx, double sy) {
|
double sx, double sy) {
|
||||||
return sx >= 0 && sx < surface->current.width &&
|
return sx >= 0 && sx < surface->current.width &&
|
||||||
sy >= 0 && sy < surface->current.height &&
|
sy >= 0 && sy < surface->current.height &&
|
||||||
pixman_region32_contains_point(&surface->current.input, floor(sx), floor(sy), NULL);
|
pixman_region32_contains_point(&surface->current.input,
|
||||||
|
(int)floor(sx), (int)floor(sy), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
|
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
|
||||||
|
|
@ -1018,14 +1019,14 @@ void wlr_surface_get_effective_damage(struct wlr_surface *surface,
|
||||||
wlr_region_transform(damage, &surface->buffer_damage,
|
wlr_region_transform(damage, &surface->buffer_damage,
|
||||||
surface->current.transform, surface->current.buffer_width,
|
surface->current.transform, surface->current.buffer_width,
|
||||||
surface->current.buffer_height);
|
surface->current.buffer_height);
|
||||||
wlr_region_scale(damage, damage, 1.0 / (float)surface->current.scale);
|
wlr_region_scale(damage, damage, 1.0f / (float)surface->current.scale);
|
||||||
|
|
||||||
if (surface->current.viewport.has_src) {
|
if (surface->current.viewport.has_src) {
|
||||||
struct wlr_box src_box = {
|
struct wlr_box src_box = {
|
||||||
.x = floor(surface->current.viewport.src.x),
|
.x = (int)floor(surface->current.viewport.src.x),
|
||||||
.y = floor(surface->current.viewport.src.y),
|
.y = (int)floor(surface->current.viewport.src.y),
|
||||||
.width = ceil(surface->current.viewport.src.width),
|
.width = (int)ceil(surface->current.viewport.src.width),
|
||||||
.height = ceil(surface->current.viewport.src.height),
|
.height = (int)ceil(surface->current.viewport.src.height),
|
||||||
};
|
};
|
||||||
crop_region(damage, damage, &src_box);
|
crop_region(damage, damage, &src_box);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
||||||
result = wlr_box_contains_point(&mapping, lx, ly);
|
result = wlr_box_contains_point(&mapping, lx, ly);
|
||||||
} else {
|
} else {
|
||||||
result = wlr_output_layout_contains_point(cur->state->layout, NULL,
|
result = wlr_output_layout_contains_point(cur->state->layout, NULL,
|
||||||
lx, ly);
|
(int)lx, (int)ly);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
@ -818,8 +818,8 @@ static void handle_layout_change(struct wl_listener *listener, void *data) {
|
||||||
wl_container_of(listener, state, layout_change);
|
wl_container_of(listener, state, layout_change);
|
||||||
struct wlr_output_layout *layout = data;
|
struct wlr_output_layout *layout = data;
|
||||||
|
|
||||||
if (!wlr_output_layout_contains_point(layout, NULL, state->cursor->x,
|
if (!wlr_output_layout_contains_point(layout, NULL,
|
||||||
state->cursor->y)) {
|
(int)state->cursor->x, (int)state->cursor->y)) {
|
||||||
// the output we were on has gone away so go to the closest boundary
|
// the output we were on has gone away so go to the closest boundary
|
||||||
// point
|
// point
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
|
||||||
|
|
@ -558,7 +558,7 @@ void wlr_layer_surface_v1_for_each_popup_surface(struct wlr_layer_surface_v1 *su
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double popup_sx, popup_sy;
|
int popup_sx, popup_sy;
|
||||||
popup_sx = popup->current.geometry.x - popup->base->current.geometry.x;
|
popup_sx = popup->current.geometry.x - popup->base->current.geometry.x;
|
||||||
popup_sy = popup->current.geometry.y - popup->base->current.geometry.y;
|
popup_sy = popup->current.geometry.y - popup->base->current.geometry.y;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@ void wlr_matrix_scale(float mat[static 9], float x, float y) {
|
||||||
|
|
||||||
void wlr_matrix_rotate(float mat[static 9], float rad) {
|
void wlr_matrix_rotate(float mat[static 9], float rad) {
|
||||||
float rotate[9] = {
|
float rotate[9] = {
|
||||||
cos(rad), -sin(rad), 0.0f,
|
cosf(rad), -sinf(rad), 0.0f,
|
||||||
sin(rad), cos(rad), 0.0f,
|
sinf(rad), cosf(rad), 0.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
};
|
};
|
||||||
wlr_matrix_multiply(mat, mat, rotate);
|
wlr_matrix_multiply(mat, mat, rotate);
|
||||||
}
|
}
|
||||||
|
|
@ -133,8 +133,8 @@ void matrix_projection(float mat[static 9], int width, int height,
|
||||||
mat[4] = y * -t[4];
|
mat[4] = y * -t[4];
|
||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
mat[2] = -copysign(1.0f, mat[0] + mat[1]);
|
mat[2] = -copysignf(1.0f, mat[0] + mat[1]);
|
||||||
mat[5] = -copysign(1.0f, mat[3] + mat[4]);
|
mat[5] = -copysignf(1.0f, mat[3] + mat[4]);
|
||||||
|
|
||||||
// Identity
|
// Identity
|
||||||
mat[8] = 1.0f;
|
mat[8] = 1.0f;
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ static void config_head_handle_set_scale(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale = wl_fixed_to_double(scale_fixed);
|
float scale = (float)wl_fixed_to_double(scale_fixed);
|
||||||
if (scale <= 0) {
|
if (scale <= 0) {
|
||||||
wl_resource_post_error(config_head_resource,
|
wl_resource_post_error(config_head_resource,
|
||||||
ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_SCALE,
|
ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_SCALE,
|
||||||
|
|
|
||||||
|
|
@ -570,10 +570,10 @@ static void capture_output(struct wl_client *wl_client,
|
||||||
buffer_box = *box;
|
buffer_box = *box;
|
||||||
|
|
||||||
wlr_box_transform(&buffer_box, &buffer_box, output->transform, ow, oh);
|
wlr_box_transform(&buffer_box, &buffer_box, output->transform, ow, oh);
|
||||||
buffer_box.x *= output->scale;
|
buffer_box.x = (int)(buffer_box.x * output->scale);
|
||||||
buffer_box.y *= output->scale;
|
buffer_box.y = (int)(buffer_box.y * output->scale);
|
||||||
buffer_box.width *= output->scale;
|
buffer_box.width = (int)(buffer_box.width * output->scale);
|
||||||
buffer_box.height *= output->scale;
|
buffer_box.height = (int)(buffer_box.height * output->scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->box = buffer_box;
|
frame->box = buffer_box;
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ bool wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
theme->scale = scale;
|
theme->scale = scale;
|
||||||
theme->theme = wlr_xcursor_theme_load(manager->name, manager->size * scale);
|
theme->theme = wlr_xcursor_theme_load(manager->name,
|
||||||
|
(int)(manager->size * scale));
|
||||||
if (theme->theme == NULL) {
|
if (theme->theme == NULL) {
|
||||||
free(theme);
|
free(theme);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -528,16 +528,19 @@ static void xdg_surface_for_each_popup_surface(struct wlr_xdg_surface *surface,
|
||||||
double popup_sx, popup_sy;
|
double popup_sx, popup_sy;
|
||||||
wlr_xdg_popup_get_position(popup, &popup_sx, &popup_sy);
|
wlr_xdg_popup_get_position(popup, &popup_sx, &popup_sy);
|
||||||
|
|
||||||
|
int sx = x + (int)popup_sx, sy = y + (int)popup_sy;
|
||||||
|
|
||||||
struct xdg_surface_iterator_data data = {
|
struct xdg_surface_iterator_data data = {
|
||||||
.user_iterator = iterator,
|
.user_iterator = iterator,
|
||||||
.user_data = user_data,
|
.user_data = user_data,
|
||||||
.x = x + popup_sx, .y = y + popup_sy,
|
.x = sx,
|
||||||
|
.y = sy,
|
||||||
};
|
};
|
||||||
wlr_surface_for_each_surface(popup->base->surface,
|
wlr_surface_for_each_surface(popup->base->surface,
|
||||||
xdg_surface_iterator, &data);
|
xdg_surface_iterator, &data);
|
||||||
|
|
||||||
xdg_surface_for_each_popup_surface(popup->base,
|
xdg_surface_for_each_popup_surface(popup->base,
|
||||||
x + popup_sx, y + popup_sy, iterator, user_data);
|
sx, sy, iterator, user_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
util/box.c
11
util/box.c
|
|
@ -50,10 +50,13 @@ bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x1 = fmax(box_a->x, box_b->x);
|
int x1 = box_a->x > box_b->x ? box_a->x : box_b->x;
|
||||||
int y1 = fmax(box_a->y, box_b->y);
|
int y1 = box_a->y > box_b->y ? box_a->y : box_b->y;
|
||||||
int x2 = fmin(box_a->x + box_a->width, box_b->x + box_b->width);
|
|
||||||
int y2 = fmin(box_a->y + box_a->height, box_b->y + box_b->height);
|
int x2a = box_a->x + box_a->width, x2b = box_b->x + box_b->width;
|
||||||
|
int y2a = box_a->y + box_a->height, y2b = box_b->y + box_b->height;
|
||||||
|
int x2 = x2a < x2b ? x2a : x2b;
|
||||||
|
int y2 = y2a < y2b ? y2a : y2b;
|
||||||
|
|
||||||
dest->x = x1;
|
dest->x = x1;
|
||||||
dest->y = y1;
|
dest->y = y1;
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ void wlr_region_scale_xy(pixman_region32_t *dst, pixman_region32_t *src,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
dst_rects[i].x1 = floor(src_rects[i].x1 * scale_x);
|
dst_rects[i].x1 = (int)floorf(src_rects[i].x1 * scale_x);
|
||||||
dst_rects[i].x2 = ceil(src_rects[i].x2 * scale_x);
|
dst_rects[i].x2 = (int)ceilf(src_rects[i].x2 * scale_x);
|
||||||
dst_rects[i].y1 = floor(src_rects[i].y1 * scale_y);
|
dst_rects[i].y1 = (int)floorf(src_rects[i].y1 * scale_y);
|
||||||
dst_rects[i].y2 = ceil(src_rects[i].y2 * scale_y);
|
dst_rects[i].y2 = (int)ceilf(src_rects[i].y2 * scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(dst);
|
pixman_region32_fini(dst);
|
||||||
|
|
@ -152,32 +152,32 @@ void wlr_region_rotated_bounds(pixman_region32_t *dst, pixman_region32_t *src,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
double x1 = src_rects[i].x1 - ox;
|
float x1 = src_rects[i].x1 - ox;
|
||||||
double y1 = src_rects[i].y1 - oy;
|
float y1 = src_rects[i].y1 - oy;
|
||||||
double x2 = src_rects[i].x2 - ox;
|
float x2 = src_rects[i].x2 - ox;
|
||||||
double y2 = src_rects[i].y2 - oy;
|
float y2 = src_rects[i].y2 - oy;
|
||||||
|
|
||||||
double rx1 = x1 * cos(rotation) - y1 * sin(rotation);
|
float rx1 = x1 * cosf(rotation) - y1 * sinf(rotation);
|
||||||
double ry1 = x1 * sin(rotation) + y1 * cos(rotation);
|
float ry1 = x1 * sinf(rotation) + y1 * cosf(rotation);
|
||||||
|
|
||||||
double rx2 = x2 * cos(rotation) - y1 * sin(rotation);
|
float rx2 = x2 * cosf(rotation) - y1 * sinf(rotation);
|
||||||
double ry2 = x2 * sin(rotation) + y1 * cos(rotation);
|
float ry2 = x2 * sinf(rotation) + y1 * cosf(rotation);
|
||||||
|
|
||||||
double rx3 = x2 * cos(rotation) - y2 * sin(rotation);
|
float rx3 = x2 * cosf(rotation) - y2 * sinf(rotation);
|
||||||
double ry3 = x2 * sin(rotation) + y2 * cos(rotation);
|
float ry3 = x2 * sinf(rotation) + y2 * cosf(rotation);
|
||||||
|
|
||||||
double rx4 = x1 * cos(rotation) - y2 * sin(rotation);
|
float rx4 = x1 * cosf(rotation) - y2 * sinf(rotation);
|
||||||
double ry4 = x1 * sin(rotation) + y2 * cos(rotation);
|
float ry4 = x1 * sinf(rotation) + y2 * cosf(rotation);
|
||||||
|
|
||||||
x1 = fmin(fmin(rx1, rx2), fmin(rx3, rx4));
|
x1 = fminf(fminf(rx1, rx2), fminf(rx3, rx4));
|
||||||
y1 = fmin(fmin(ry1, ry2), fmin(ry3, ry4));
|
y1 = fminf(fminf(ry1, ry2), fminf(ry3, ry4));
|
||||||
x2 = fmax(fmax(rx1, rx2), fmax(rx3, rx4));
|
x2 = fmaxf(fmaxf(rx1, rx2), fmaxf(rx3, rx4));
|
||||||
y2 = fmax(fmax(ry1, ry2), fmax(ry3, ry4));
|
y2 = fmaxf(fmaxf(ry1, ry2), fmaxf(ry3, ry4));
|
||||||
|
|
||||||
dst_rects[i].x1 = floor(ox + x1);
|
dst_rects[i].x1 = (int)floorf(ox + x1);
|
||||||
dst_rects[i].x2 = ceil(ox + x2);
|
dst_rects[i].x2 = (int)ceilf(ox + x2);
|
||||||
dst_rects[i].y1 = floor(oy + y1);
|
dst_rects[i].y1 = (int)floorf(oy + y1);
|
||||||
dst_rects[i].y2 = ceil(oy + y2);
|
dst_rects[i].y2 = (int)ceilf(oy + y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(dst);
|
pixman_region32_fini(dst);
|
||||||
|
|
@ -210,8 +210,8 @@ static void region_confine(pixman_region32_t *region, double x1, double y1, doub
|
||||||
double y = fmax(fmin(delta * dy + y1, box.y2 - 1), box.y1);
|
double y = fmax(fmin(delta * dy + y1, box.y2 - 1), box.y1);
|
||||||
|
|
||||||
// Go one unit past the boundary to find an adjacent box.
|
// Go one unit past the boundary to find an adjacent box.
|
||||||
int x_ext = floor(x) + (dx == 0 ? 0 : dx > 0 ? 1 : -1);
|
int x_ext = (int)floor(x) + (dx == 0 ? 0 : dx > 0 ? 1 : -1);
|
||||||
int y_ext = floor(y) + (dy == 0 ? 0 : dy > 0 ? 1 : -1);
|
int y_ext = (int)floor(y) + (dy == 0 ? 0 : dy > 0 ? 1 : -1);
|
||||||
|
|
||||||
if (pixman_region32_contains_point(region, x_ext, y_ext, &box)) {
|
if (pixman_region32_contains_point(region, x_ext, y_ext, &box)) {
|
||||||
return region_confine(region, x, y, x2, y2, x2_out, y2_out, box);
|
return region_confine(region, x, y, x2, y2, x2_out, y2_out, box);
|
||||||
|
|
@ -245,7 +245,8 @@ static void region_confine(pixman_region32_t *region, double x1, double y1, doub
|
||||||
bool wlr_region_confine(pixman_region32_t *region, double x1, double y1, double x2,
|
bool wlr_region_confine(pixman_region32_t *region, double x1, double y1, double x2,
|
||||||
double y2, double *x2_out, double *y2_out) {
|
double y2, double *x2_out, double *y2_out) {
|
||||||
pixman_box32_t box;
|
pixman_box32_t box;
|
||||||
if (pixman_region32_contains_point(region, floor(x1), floor(y1), &box)) {
|
if (pixman_region32_contains_point(region,
|
||||||
|
(int)floor(x1), (int)floor(y1), &box)) {
|
||||||
region_confine(region, x1, y1, x2, y2, x2_out, y2_out, box);
|
region_confine(region, x1, y1, x2, y2, x2_out, y2_out, box);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue