From 68e408d22646c4d2a093029a907341d2943c5866 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 13 Apr 2023 17:03:17 +0200 Subject: set cursor position to "text" --- swt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'swt.c') diff --git a/swt.c b/swt.c index c05f997..e50fa04 100644 --- a/swt.c +++ b/swt.c @@ -267,6 +267,19 @@ void wdrawline(Line line, int x1, int y1, int x2) { win.fontcache->box.height, colors[line[x].bg] ); + + if (line[x].mode & ATTR_UNDERLINE) { + fprintf(stderr, "DRAWING %c\n", line[x].u); + draw_rect( + win.canvas, + borderpx + x * win.fontcache->box.width, + borderpx + (y1 + 1) * win.fontcache->box.height - 1, + win.fontcache->box.width - 2, + 1, + colors[line[x].fg] + ); + } + draw_char( win.canvas, win.fontcache, @@ -639,6 +652,7 @@ handle_keyboard_event() void pointer_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { + wl_pointer_set_cursor(client.pointer.pointer, serial, client.pointer.surface, client.pointer.image->hotspot_x, client.pointer.image->hotspot_y); } @@ -651,6 +665,7 @@ pointer_leave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl void pointer_motion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y) { + wl_surface_commit(client.pointer.surface); } @@ -692,6 +707,14 @@ setup() xdg_toplevel_add_listener(win.surface.toplevel, &toplevel_listener, &win); xdg_toplevel_set_title(win.surface.toplevel, "swt"); wl_surface_commit(win.surface.wl); + + client.pointer.theme = wl_cursor_theme_load(0, 24, client.shm); + client.pointer.cursor = wl_cursor_theme_get_cursor(client.pointer.theme, "text"); + client.pointer.image = client.pointer.cursor->images[0]; + client.pointer.buffer = wl_cursor_image_get_buffer(client.pointer.image); + client.pointer.surface = wl_compositor_create_surface(client.compositor); + wl_surface_attach(client.pointer.surface, client.pointer.buffer, 0, 0); + wl_surface_commit(client.pointer.surface); } -- cgit v1.2.3-70-g09d2