| @@ -7,10 +7,12 @@ · 6 unmodified lines |
| 7 | 7 | #include <sys/mman.h> |
| 8 | 8 | #include <sys/stat.h> |
| 9 | 9 | #include <fcntl.h> |
| 10 | +#include <time.h> |
| 10 | 11 | #include <xkbcommon/xkbcommon.h> |
| 11 | 12 | #include "xdg-shell-protocol.h" |
| 12 | 13 | #include "xdg-decoration-protocol.h" |
| 13 | 14 | #include "xdg-primary-selection-protocol.h" |
| 15 | +#include "wlr-virtual-pointer.h" |
| 14 | 16 | |
| 15 | 17 | #include "u.h" |
| 16 | 18 | #include "lib.h" |
| @@ -29,6 +31,7 @@ · 12 unmodified lines |
| 29 | 31 | #undef pipe |
| 30 | 32 | #undef write |
| 31 | 33 | #undef read |
| 34 | +#undef time |
| 32 | 35 | |
| 33 | 36 | static void |
| 34 | 37 | xdg_surface_handle_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) |
| @@ -660,6 +663,8 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name, const cha · 625 unmodified lines |
| 660 | 663 | wl->decoman = wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, 1); |
| 661 | 664 | } else if(strcmp(interface, zwp_primary_selection_device_manager_v1_interface.name) == 0) { |
| 662 | 665 | wl->primsel = wl_registry_bind(registry, name, &zwp_primary_selection_device_manager_v1_interface, 1); |
| 666 | + } else if(strcmp(interface, zwlr_virtual_pointer_manager_v1_interface.name) == 0) { |
| 667 | + wl->vpmgr = wl_registry_bind(registry, name, &zwlr_virtual_pointer_manager_v1_interface, 1); |
| 663 | 668 | } |
| 664 | 669 | } |
| 665 | 670 | |
| @@ -696,6 +701,9 @@ wlsetcb(Wlwin *wl) · 30 unmodified lines |
| 696 | 701 | if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->decoman == nil || wl->primsel == nil) |
| 697 | 702 | sysfatal("registration fell short"); |
| 698 | 703 | |
| 704 | + if(wl->vpmgr != nil) |
| 705 | + wl->vpointer = zwlr_virtual_pointer_manager_v1_create_virtual_pointer(wl->vpmgr, wl->seat); |
| 706 | + |
| 699 | 707 | wlallocbuffer(wl); |
| 700 | 708 | wl->surface = wl_compositor_create_surface(wl->compositor); |
| 701 | 709 | |
| @@ -761,3 +769,17 @@ wlgetsnarf(Wlwin *wl) · 59 unmodified lines |
| 761 | 769 | qunlock(&wl->clip.lk); |
| 762 | 770 | return s; |
| 763 | 771 | } |
| 772 | + |
| 773 | +void |
| 774 | +wlsetmouse(Wlwin *wl, Point p) |
| 775 | +{ |
| 776 | + Point delta; |
| 777 | + if (wl->vpointer == nil) |
| 778 | + return; |
| 779 | + |
| 780 | + delta.x = p.x - wl->mouse.xy.x; |
| 781 | + delta.y = p.y - wl->mouse.xy.y; |
| 782 | + wl->mouse.xy = p; |
| 783 | + zwlr_virtual_pointer_v1_motion(wl->vpointer, time(nil) * 1000, delta.x * 256, delta.y * 256); |
| 784 | + zwlr_virtual_pointer_v1_frame(wl->vpointer); |
| 785 | +} |