| @@ -7,10 +7,12 @@ · 6 unmodified lines |
| 7 | #include <sys/mman.h> | 7 | #include <sys/mman.h> |
| 8 | #include <sys/stat.h> | 8 | #include <sys/stat.h> |
| 9 | #include <fcntl.h> | 9 | #include <fcntl.h> |
| | 10 | #include <time.h> |
| 10 | #include <xkbcommon/xkbcommon.h> | 11 | #include <xkbcommon/xkbcommon.h> |
| 11 | #include "xdg-shell-protocol.h" | 12 | #include "xdg-shell-protocol.h" |
| 12 | #include "xdg-decoration-protocol.h" | 13 | #include "xdg-decoration-protocol.h" |
| 13 | #include "xdg-primary-selection-protocol.h" | 14 | #include "xdg-primary-selection-protocol.h" |
| | 15 | #include "wlr-virtual-pointer.h" |
| 14 | | 16 | |
| 15 | #include "u.h" | 17 | #include "u.h" |
| 16 | #include "lib.h" | 18 | #include "lib.h" |
| @@ -29,6 +31,7 @@ · 12 unmodified lines |
| 29 | #undef pipe | 31 | #undef pipe |
| 30 | #undef write | 32 | #undef write |
| 31 | #undef read | 33 | #undef read |
| | 34 | #undef time |
| 32 | | 35 | |
| 33 | static void | 36 | static void |
| 34 | xdg_surface_handle_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) | 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 | wl->decoman = wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, 1); | 663 | wl->decoman = wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, 1); |
| 661 | } else if(strcmp(interface, zwp_primary_selection_device_manager_v1_interface.name) == 0) { | 664 | } else if(strcmp(interface, zwp_primary_selection_device_manager_v1_interface.name) == 0) { |
| 662 | wl->primsel = wl_registry_bind(registry, name, &zwp_primary_selection_device_manager_v1_interface, 1); | 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 | if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->decoman == nil || wl->primsel == nil) | 701 | if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->decoman == nil || wl->primsel == nil) |
| 697 | sysfatal("registration fell short"); | 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 | wlallocbuffer(wl); | 707 | wlallocbuffer(wl); |
| 700 | wl->surface = wl_compositor_create_surface(wl->compositor); | 708 | wl->surface = wl_compositor_create_surface(wl->compositor); |
| 701 | | 709 | |
| @@ -761,3 +769,17 @@ wlgetsnarf(Wlwin *wl) · 59 unmodified lines |
| 761 | qunlock(&wl->clip.lk); | 769 | qunlock(&wl->clip.lk); |
| 762 | return s; | 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 | } |