aboutsummaryrefslogtreecommitdiff
path: root/example/pointer.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-16 15:38:34 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-16 15:38:34 -0400
commit7e038a6110501a51e7f3d3366e8bc54a02766f22 (patch)
treea8734a451de1f98c446761e744fa275df01a72d7 /example/pointer.c
parentdef3d7c64f68d59c6daec5974afc3ca84fa4bda9 (diff)
Add (broken) DRM hardware cursors
Diffstat (limited to 'example/pointer.c')
-rw-r--r--example/pointer.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/example/pointer.c b/example/pointer.c
index a427f0f2..d97d253e 100644
--- a/example/pointer.c
+++ b/example/pointer.c
@@ -92,6 +92,18 @@ static void handle_pointer_axis(struct pointer_state *pstate,
sizeof(sample->clear_color));
}
+static void handle_output_add(struct output_state *ostate) {
+ struct wlr_output *wlr_output = ostate->output;
+ if (!wlr_output_set_cursor(wlr_output, cat_tex.pixel_data,
+ cat_tex.width * 4, cat_tex.width, cat_tex.height)) {
+ fprintf(stderr, "Failed to set cursor\n");
+ return;
+ }
+ if (!wlr_output_move_cursor(wlr_output, 0, 0)) {
+ fprintf(stderr, "Failed to move cursor\n");
+ }
+}
+
int main(int argc, char *argv[]) {
struct sample_state state = {
.default_color = { 0.25f, 0.25f, 0.25f, 1 },
@@ -100,6 +112,7 @@ int main(int argc, char *argv[]) {
struct compositor_state compositor;
compositor_init(&compositor);
+ compositor.output_add_cb = handle_output_add;
compositor.output_frame_cb = handle_output_frame;
compositor.keyboard_key_cb = handle_keyboard_key;
compositor.pointer_motion_cb = handle_pointer_motion;
@@ -108,7 +121,7 @@ int main(int argc, char *argv[]) {
state.renderer = wlr_gles3_renderer_init();
state.cat_texture = wlr_render_surface_init(state.renderer);
- wlr_surface_attach_pixels(state.cat_texture, GL_RGB,
+ wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
compositor.data = &state;