app: [Wayland] scale pointer hotspot coordinates

This commit updates the way that we change cursors so that the
hotspot of the cursor is properly set to surface-local coordinates.
The previous raw hotspot coordinates are relative to the cursor
image buffer data, and do not take the buffer's scaling factor
into account.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-06-30 16:30:05 -04:00
committed by Elias Naur
parent 992f568ac7
commit a5f8aa35e1
+1 -1
View File
@@ -1143,7 +1143,7 @@ func (w *window) setCursor(pointer *C.struct_wl_pointer, serial C.uint32_t) {
if buf == nil {
return
}
C.wl_pointer_set_cursor(pointer, serial, w.cursor.surf, C.int32_t(img.hotspot_x), C.int32_t(img.hotspot_y))
C.wl_pointer_set_cursor(pointer, serial, w.cursor.surf, C.int32_t(img.hotspot_x/C.uint(w.scale)), C.int32_t(img.hotspot_y/C.uint(w.scale)))
C.wl_surface_attach(w.cursor.surf, buf, 0, 0)
C.wl_surface_damage(w.cursor.surf, 0, 0, C.int32_t(img.width), C.int32_t(img.height))
C.wl_surface_commit(w.cursor.surf)