Created
October 24, 2021 22:45
-
-
Save dyeo/98d47ca9e43a2605d720129bed1137a2 to your computer and use it in GitHub Desktop.
nosel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <X11/Xlib.h> | |
#include <X11/Xatom.h> | |
#include <X11/extensions/Xfixes.h> | |
int main() { | |
Display *dpy; | |
Window root; | |
int ev_base, err_base; | |
XEvent ev; | |
if (!(dpy=XOpenDisplay(0x0))) | |
return 1; | |
root = DefaultRootWindow(dpy); | |
XFixesQueryExtension(dpy, &ev_base, &err_base); | |
XFixesSelectSelectionInput(dpy, root, XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask); | |
int ignore = 0; | |
while (!XNextEvent(dpy, &ev)) { | |
if (ev.type == ev_base + XFixesSelectionNotify) { | |
if (ignore) { | |
ignore = 0; | |
} else { | |
ignore = 1; | |
XSetSelectionOwner(dpy, XA_PRIMARY, None, CurrentTime); | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment