summaryrefslogtreecommitdiff
path: root/xnap.c
diff options
context:
space:
mode:
authoruint <abhinav.prsai@gmail.com>2025-12-14 17:22:59 +0000
committeruint <abhinav.prsai@gmail.com>2025-12-14 17:22:59 +0000
commit61d0cff357389f5e6b7b729035b677d7ca9588c0 (patch)
tree07791cdc3d0b3a5796d00fbfff7dfe7deb0945cf /xnap.c
parentb1ac729f34756ed63323c76386e631fda94a2adb (diff)
add cursor fonts
Diffstat (limited to 'xnap.c')
-rw-r--r--xnap.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/xnap.c b/xnap.c
index d4c0c06..a6cc3b6 100644
--- a/xnap.c
+++ b/xnap.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <X11/X.h>
+#include <X11/cursorfont.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xutil.h>
@@ -13,7 +14,10 @@
struct pointer_t {
int ret;
+
Bool sel;
+ Cursor selcur;
+
int x0;
int y0;
int x1;
@@ -113,6 +117,7 @@ void mkppm(const char* path, XImage* img)
void quit(Bool ex)
{
XUngrabPointer(dpy, CurrentTime);
+ XFreeCursor(dpy, p.selcur);
XCloseDisplay(dpy);
if (ex)
exit(EXIT_SUCCESS);
@@ -156,10 +161,11 @@ void setup(void)
root = RootWindow(dpy, scr);
/* pointer */
+ p.selcur = XCreateFontCursor(dpy, cursor_font);
p.ret = XGrabPointer(
dpy, root, False,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
- GrabModeAsync, GrabModeAsync, None, None, CurrentTime
+ GrabModeAsync, GrabModeAsync, None, p.selcur, CurrentTime
);
if (p.ret != GrabSuccess)
die("XGrabPointer failed");