aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/idle-inhibit.c2
-rw-r--r--examples/idle.c6
-rw-r--r--examples/multi-pointer.c28
-rw-r--r--examples/output-layout.c38
-rw-r--r--examples/pointer.c28
-rw-r--r--examples/rotation.c27
-rw-r--r--examples/screenshot.c181
-rw-r--r--examples/simple.c6
-rw-r--r--examples/tablet.c43
-rw-r--r--examples/touch.c35
10 files changed, 132 insertions, 262 deletions
diff --git a/examples/idle-inhibit.c b/examples/idle-inhibit.c
index b7b9c21c..c09e6507 100644
--- a/examples/idle-inhibit.c
+++ b/examples/idle-inhibit.c
@@ -5,8 +5,8 @@
#include <wayland-client.h>
#include <wayland-egl.h>
#include <wlr/render/egl.h>
-#include "xdg-shell-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
+#include "xdg-shell-client-protocol.h"
#include <linux/input-event-codes.h>
diff --git a/examples/idle.c b/examples/idle.c
index 2b155c68..b65a81cf 100644
--- a/examples/idle.c
+++ b/examples/idle.c
@@ -1,11 +1,11 @@
+#include <getopt.h>
+#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <getopt.h>
-#include <pthread.h>
-#include <wayland-client.h>
#include <wayland-client-protocol.h>
+#include <wayland-client.h>
#include <wlr/util/log.h>
#include "idle-client-protocol.h"
diff --git a/examples/multi-pointer.c b/examples/multi-pointer.c
index d3d425f2..43ccdb66 100644
--- a/examples/multi-pointer.c
+++ b/examples/multi-pointer.c
@@ -1,30 +1,30 @@
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 500
+#include <assert.h>
+#include <GLES2/gl2.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
-#include <math.h>
-#include <assert.h>
-#include <wayland-server.h>
#include <wayland-server-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-#include <GLES2/gl2.h>
-#include <wlr/render/matrix.h>
-#include <wlr/render/gles2.h>
-#include <wlr/render.h>
+#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/gles2.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_keyboard.h>
+#include <wlr/types/wlr_list.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output_layout.h>
-#include <wlr/xcursor.h>
-#include <wlr/types/wlr_cursor.h>
#include <wlr/util/log.h>
-#include <wlr/types/wlr_list.h>
-#include "support/shared.h"
-#include "support/config.h"
+#include <wlr/xcursor.h>
+#include <xkbcommon/xkbcommon.h>
#include "support/cat.h"
+#include "support/config.h"
+#include "support/shared.h"
struct sample_state;
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 45257be9..45d896b0 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -1,29 +1,29 @@
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 700
+#include <GLES2/gl2.h>
+#include <limits.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <string.h>
#include <strings.h>
+#include <time.h>
#include <unistd.h>
-#include <limits.h>
-#include <wayland-server.h>
#include <wayland-server-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-#include <GLES2/gl2.h>
-#include <wlr/render/matrix.h>
-#include <wlr/render/gles2.h>
-#include <wlr/render.h>
-#include <wlr/util/log.h>
+#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/gles2.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_keyboard.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
-#include <wlr/types/wlr_keyboard.h>
-#include <math.h>
-#include "support/shared.h"
-#include "support/config.h"
+#include <wlr/util/log.h>
+#include <xkbcommon/xkbcommon.h>
#include "support/cat.h"
+#include "support/config.h"
+#include "support/shared.h"
struct sample_state {
struct example_config *config;
@@ -101,8 +101,8 @@ static void handle_output_frame(struct output_state *output,
struct wlr_output *wlr_output = output->output;
wlr_output_make_current(wlr_output, NULL);
- wlr_renderer_begin(sample->renderer, wlr_output);
- wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
+ wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
+ wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
animate_cat(sample, output->output);
@@ -111,18 +111,14 @@ static void handle_output_frame(struct output_state *output,
.width = 128, .height = 128,
};
if (wlr_output_layout_intersects(sample->layout, output->output, &box)) {
- float matrix[16];
-
// transform global coordinates to local coordinates
double local_x = sample->x_offs;
double local_y = sample->y_offs;
wlr_output_layout_output_coords(sample->layout, output->output,
&local_x, &local_y);
- wlr_texture_get_matrix(sample->cat_texture, &matrix,
- &wlr_output->transform_matrix, local_x, local_y);
- wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix, 1.0f);
+ wlr_render_texture(sample->renderer, sample->cat_texture,
+ wlr_output->transform_matrix, local_x, local_y, 1.0f);
}
wlr_renderer_end(sample->renderer);
diff --git a/examples/pointer.c b/examples/pointer.c
index 0dbd02d2..e8a0e892 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -1,30 +1,30 @@
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 500
+#include <assert.h>
+#include <GLES2/gl2.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
-#include <math.h>
-#include <assert.h>
-#include <wayland-server.h>
#include <wayland-server-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-#include <GLES2/gl2.h>
-#include <wlr/render/matrix.h>
-#include <wlr/render/gles2.h>
-#include <wlr/render.h>
+#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/gles2.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_keyboard.h>
+#include <wlr/types/wlr_list.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output_layout.h>
-#include <wlr/xcursor.h>
-#include <wlr/types/wlr_cursor.h>
#include <wlr/util/log.h>
-#include <wlr/types/wlr_list.h>
-#include "support/shared.h"
-#include "support/config.h"
+#include <wlr/xcursor.h>
+#include <xkbcommon/xkbcommon.h>
#include "support/cat.h"
+#include "support/config.h"
+#include "support/shared.h"
struct sample_state {
struct compositor_state *compositor;
diff --git a/examples/rotation.c b/examples/rotation.c
index 1158ccc4..cbff09a1 100644
--- a/examples/rotation.c
+++ b/examples/rotation.c
@@ -1,23 +1,23 @@
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 500
+#include <GLES2/gl2.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <string.h>
#include <strings.h>
+#include <time.h>
#include <unistd.h>
-#include <wayland-server.h>
#include <wayland-server-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-#include <GLES2/gl2.h>
-#include <wlr/render/matrix.h>
-#include <wlr/render/gles2.h>
-#include <wlr/render.h>
+#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/render/gles2.h>
#include <wlr/types/wlr_keyboard.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
-#include <math.h>
+#include <xkbcommon/xkbcommon.h>
#include "support/shared.h"
#include "support/config.h"
#include "support/cat.h"
@@ -43,16 +43,13 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_effective_resolution(wlr_output, &width, &height);
wlr_output_make_current(wlr_output, NULL);
- wlr_renderer_begin(sample->renderer, wlr_output);
- wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
+ wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
+ wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
- float matrix[16];
for (int y = -128 + (int)odata->y_offs; y < height; y += 128) {
for (int x = -128 + (int)odata->x_offs; x < width; x += 128) {
- wlr_texture_get_matrix(sample->cat_texture, &matrix,
- &wlr_output->transform_matrix, x, y);
- wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix, 1.0f);
+ wlr_render_texture(sample->renderer, sample->cat_texture,
+ wlr_output->transform_matrix, x, y, 1.0f);
}
}
diff --git a/examples/screenshot.c b/examples/screenshot.c
index e73989c6..fb37f32c 100644
--- a/examples/screenshot.c
+++ b/examples/screenshot.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -36,33 +37,22 @@
#include <wayland-client.h>
#include <wlr/util/log.h>
#include "screenshooter-client-protocol.h"
-#include "util/os-compatibility.h"
static struct wl_shm *shm = NULL;
static struct orbital_screenshooter *screenshooter = NULL;
static struct wl_list output_list;
-int min_x, min_y, max_x, max_y;
-int buffer_copy_done;
+static bool buffer_copy_done;
struct screenshooter_output {
struct wl_output *output;
- struct wl_buffer *buffer;
- int width, height, offset_x, offset_y;
- enum wl_output_transform transform;
- void *data;
+ int width, height;
struct wl_list link;
};
static void output_handle_geometry(void *data, struct wl_output *wl_output,
int x, int y, int physical_width, int physical_height, int subpixel,
const char *make, const char *model, int transform) {
- struct screenshooter_output *output = wl_output_get_user_data(wl_output);
-
- if (wl_output == output->output) {
- output->offset_x = x;
- output->offset_y = y;
- output->transform = transform;
- }
+ // No-op
}
static void output_handle_mode(void *data, struct wl_output *wl_output,
@@ -86,7 +76,7 @@ static const struct wl_output_listener output_listener = {
};
static void screenshot_done(void *data, struct orbital_screenshot *screenshot) {
- buffer_copy_done = 1;
+ buffer_copy_done = true;
}
static const struct orbital_screenshot_listener screenshot_listener = {
@@ -113,7 +103,7 @@ static void handle_global(void *data, struct wl_registry *registry,
static void handle_global_remove(void *data, struct wl_registry *registry,
uint32_t name) {
- // Unimplemented
+ // Who cares?
}
static const struct wl_registry_listener registry_listener = {
@@ -123,14 +113,15 @@ static const struct wl_registry_listener registry_listener = {
static int backingfile(off_t size) {
char template[] = "/tmp/wlroots-shared-XXXXXX";
- int fd, ret;
-
- fd = mkstemp(template);
+ int fd = mkstemp(template);
if (fd < 0) {
return -1;
}
- while ((ret = ftruncate(fd, size)) == EINTR) {}
+ int ret;
+ while ((ret = ftruncate(fd, size)) == EINTR) {
+ // No-op
+ }
if (ret < 0) {
close(fd);
return -1;
@@ -140,7 +131,6 @@ static int backingfile(off_t size) {
return fd;
}
-
static struct wl_buffer *create_shm_buffer(int width, int height,
void **data_out) {
int stride = width * 4;
@@ -170,91 +160,8 @@ static struct wl_buffer *create_shm_buffer(int width, int height,
return buffer;
}
-static void write_image(const char *filename, int width, int height) {
- int buffer_stride = width * 4;
-
- void *data = calloc(1, buffer_stride * height);
- if (!data) {
- return;
- }
-
- struct screenshooter_output *output, *next;
- wl_list_for_each_safe(output, next, &output_list, link) {
- int output_stride = output->width * 4;
- uint32_t *src = (uint32_t *)output->data;
- uint32_t *dst = (uint32_t *)(data +
- (output->offset_y - min_y) * buffer_stride +
- (output->offset_x - min_x) * 4);
-
- switch (output->transform) {
- case WL_OUTPUT_TRANSFORM_NORMAL:
- for (int i = 0; i < output->height; i++) {
- memcpy(dst, src, output_stride);
- dst += width;
- src += output->width;
- }
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED:
- for (int i = 0; i < output->height; ++i) {
- for (int j = 0; j < output->width; ++j) {
- dst[i * width + j] =
- src[i * output->width + output->width - 1 - j];
- }
- }
- break;
- case WL_OUTPUT_TRANSFORM_90:
- for (int i = 0; i < output->width; ++i) {
- for (int j = 0; j < output->height; ++j) {
- dst[i * width + j] =
- src[j * output->width + output->width - 1 - i];
- }
- }
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_90:
- for (int i = 0; i < output->width; ++i) {
- for (int j = 0; j < output->height; ++j) {
- dst[i * width + j] =
- src[(output->height - 1 - j) * output->width + output->width - 1 - i];
- }
- }
- break;
- case WL_OUTPUT_TRANSFORM_180:
- for (int i = 0; i < output->height; ++i) {
- for (int j = 0; j < output->width; ++j) {
- dst[i * width + j] =
- src[(output->height - 1 - i) * output->width + output->width - 1 - j];
- }
- }
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_180:
- for (int i = 0; i < output->height; ++i) {
- for (int j = 0; j < output->width; ++j) {
- dst[i * width + j] =
- src[(output->height - 1 - i) * output->width + j];
- }
- }
- break;
- case WL_OUTPUT_TRANSFORM_270:
- for (int i = 0; i < output->width; ++i) {
- for (int j = 0; j < output->height; ++j) {
- dst[i * width + j] =
- src[(output->height - 1 - j) * output->width + i];
- }
- }
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_270:
- for (int i = 0; i < output->width; ++i) {
- for (int j = 0; j < output->height; ++j) {
- dst[i * width + j] =
- src[j * output->width + i];
- }
- }
- break;
- }
-
- free(output);
- }
-
+static void write_image(const char *filename, int width, int height,
+ void *data) {
char size[10 + 1 + 10 + 2 + 1]; // int32_t are max 10 digits
sprintf(size, "%dx%d+0", width, height);
@@ -270,12 +177,11 @@ static void write_image(const char *filename, int width, int height) {
exit(EXIT_FAILURE);
} else if (child != 0) {
close(fd[0]);
- if (write(fd[1], data, buffer_stride * height) < 0) {
+ if (write(fd[1], data, 4 * width * height) < 0) {
fprintf(stderr, "write() failed: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
close(fd[1]);
- free(data);
waitpid(child, NULL, 0);
} else {
close(fd[1]);
@@ -293,38 +199,9 @@ static void write_image(const char *filename, int width, int height) {
}
}
-static int set_buffer_size(int *width, int *height) {
- int owidth, oheight;
- min_x = min_y = INT_MAX;
- max_x = max_y = INT_MIN;
-
- struct screenshooter_output *output;
- wl_list_for_each(output, &output_list, link) {
- if (output->transform & 0x1) {
- owidth = output->height;
- oheight = output->width;
- } else {
- owidth = output->width;
- oheight = output->height;
- }
- min_x = MIN(min_x, output->offset_x);
- min_y = MIN(min_y, output->offset_y);
- max_x = MAX(max_x, output->offset_x + owidth);
- max_y = MAX(max_y, output->offset_y + oheight);
- }
-
- if (max_x <= min_x || max_y <= min_y) {
- return -1;
- }
-
- *width = max_x - min_x;
- *height = max_y - min_y;
-
- return 0;
-}
-
int main(int argc, char *argv[]) {
wlr_log_init(L_DEBUG, NULL);
+
struct wl_display * display = wl_display_connect(NULL);
if (display == NULL) {
fprintf(stderr, "failed to create display: %m\n");
@@ -342,27 +219,31 @@ int main(int argc, char *argv[]) {
return -1;
}
- int width, height;
- if (set_buffer_size(&width, &height)) {
- fprintf(stderr, "cannot set buffer size\n");
- return -1;
- }
-
+ int i = 0;
struct screenshooter_output *output;
wl_list_for_each(output, &output_list, link) {
- output->buffer = create_shm_buffer(output->width, output->height, &output->data);
- if (output->buffer == NULL) {
+ void *data = NULL;
+ struct wl_buffer *buffer =
+ create_shm_buffer(output->width, output->height, &data);
+ if (buffer == NULL) {
return -1;
}
struct orbital_screenshot *screenshot = orbital_screenshooter_shoot(
- screenshooter, output->output, output->buffer);
- orbital_screenshot_add_listener(screenshot, &screenshot_listener, screenshot);
- buffer_copy_done = 0;
+ screenshooter, output->output, buffer);
+ orbital_screenshot_add_listener(screenshot, &screenshot_listener,
+ screenshot);
+ buffer_copy_done = false;
while (!buffer_copy_done) {
wl_display_roundtrip(display);
}
+
+ char filename[24 + 10]; // int32_t are max 10 digits
+ snprintf(filename, sizeof(filename), "wayland-screenshot-%d.png", i);
+
+ write_image(filename, output->width, output->height, data);
+ wl_buffer_destroy(buffer);
+ ++i;
}
- write_image("wayland-screenshot.png", width, height);
return EXIT_SUCCESS;
}
diff --git a/examples/simple.c b/examples/simple.c
index 90808b0f..79db4a0c 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -1,11 +1,11 @@
#define _POSIX_C_SOURCE 199309L
-#include <string.h>
+#include <GLES2/gl2.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
-#include <inttypes.h>
#include <wayland-server.h>
-#include <GLES2/gl2.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_output.h>
diff --git a/examples/tablet.c b/examples/tablet.c
index 5bfa1271..65c559cb 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -1,27 +1,27 @@
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 500
+#include <GLES2/gl2.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
-#include <wayland-server.h>
#include <wayland-server-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-#include <GLES2/gl2.h>
-#include <wlr/render/matrix.h>
-#include <wlr/render/gles2.h>
-#include <wlr/render.h>
+#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/gles2.h>
+#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h>
-#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_pad.h>
+#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/util/log.h>
-#include <math.h>
-#include "support/shared.h"
+#include <xkbcommon/xkbcommon.h>
#include "support/cat.h"
+#include "support/shared.h"
struct sample_state {
struct wlr_renderer *renderer;
@@ -46,10 +46,10 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_effective_resolution(wlr_output, &width, &height);
wlr_output_make_current(wlr_output, NULL);
- wlr_renderer_begin(sample->renderer, wlr_output);
- wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
+ wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
+ wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
- float matrix[16];
+ float matrix[9];
float distance = 0.8f * (1 - sample->distance);
float tool_color[4] = { distance, distance, distance, 1 };
for (size_t i = 0; sample->button && i < 4; ++i) {
@@ -65,9 +65,8 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
.x = left, .y = top,
.width = pad_width, .height = pad_height,
};
- wlr_matrix_project_box(&matrix, &box, 0, 0,
- &wlr_output->transform_matrix);
- wlr_render_colored_quad(sample->renderer, &sample->pad_color, &matrix);
+ wlr_matrix_project_box(matrix, &box, 0, 0, wlr_output->transform_matrix);
+ wlr_render_colored_quad(sample->renderer, sample->pad_color, matrix);
if (sample->proximity) {
struct wlr_box box = {
@@ -76,16 +75,16 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
.width = 16 * (sample->pressure + 1),
.height = 16 * (sample->pressure + 1),
};
- wlr_matrix_project_box(&matrix, &box, 0, sample->ring,
- &wlr_output->transform_matrix);
- wlr_render_colored_quad(sample->renderer, &tool_color, &matrix);
+ wlr_matrix_project_box(matrix, &box, 0, sample->ring,
+ wlr_output->transform_matrix);
+ wlr_render_colored_quad(sample->renderer, tool_color, matrix);
box.x += sample->x_tilt;
box.y += sample->y_tilt;
box.width /= 2;
box.height /= 2;
- wlr_matrix_project_box(&matrix, &box, 0, 0,
- &wlr_output->transform_matrix);
- wlr_render_colored_quad(sample->renderer, &tool_color, &matrix);
+ wlr_matrix_project_box(matrix, &box, 0, 0,
+ wlr_output->transform_matrix);
+ wlr_render_colored_quad(sample->renderer, tool_color, matrix);
}
wlr_renderer_end(sample->renderer);
diff --git a/examples/touch.c b/examples/touch.c
index 278252cc..f9c496cf 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -1,25 +1,25 @@
#define _POSIX_C_SOURCE 199309L
#define _XOPEN_SOURCE 500
+#include <GLES2/gl2.h>
+#include <math.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
-#include <stdint.h>
-#include <math.h>
-#include <wayland-server.h>
#include <wayland-server-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-#include <GLES2/gl2.h>
-#include <wlr/render/matrix.h>
-#include <wlr/render/gles2.h>
-#include <wlr/render.h>
+#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/gles2.h>
+#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_list.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
-#include "support/shared.h"
+#include <xkbcommon/xkbcommon.h>
#include "support/cat.h"
+#include "support/shared.h"
struct sample_state {
struct wlr_renderer *renderer;
@@ -42,18 +42,15 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_effective_resolution(wlr_output, &width, &height);
wlr_output_make_current(wlr_output, NULL);
- wlr_renderer_begin(sample->renderer, wlr_output);
- wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
+ wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
+ wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
- float matrix[16];
struct touch_point *p;
wl_list_for_each(p, &sample->touch_points, link) {
- wlr_texture_get_matrix(sample->cat_texture, &matrix,
- &wlr_output->transform_matrix,
- (int)(p->x * width) - sample->cat_texture->width / 2,
- (int)(p->y * height) - sample->cat_texture->height / 2);
- wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix, 1.0f);
+ int x = (int)(p->x * width) - sample->cat_texture->width / 2;
+ int y = (int)(p->y * height) - sample->cat_texture->height / 2;
+ wlr_render_texture(sample->renderer, sample->cat_texture,
+ wlr_output->transform_matrix, x, y, 1.0f);
}
wlr_renderer_end(sample->renderer);