ICCCM mandates the use of real timestamps to interact with the
selection, to rule out race conditions if the clients are run at
different speeds. I have implemented the low hanging fruit, putting the
timestamps into text selection. Also, ICCCM mandates a check for whether
XSetSelectionOwner() worked. Not sure my version is correct, though.
static void xresettitle(void);
static void xsetpointermotion(int);
static void xseturgency(int);
static void xresettitle(void);
static void xsetpointermotion(int);
static void xseturgency(int);
-static void xsetsel(char *);
+static void xsetsel(char *, Time);
static void xtermclear(int, int, int, int);
static void xunloadfont(Font *);
static void xunloadfonts(void);
static void xtermclear(int, int, int, int);
static void xunloadfont(Font *);
static void xunloadfonts(void);
static void selnormalize(void);
static inline bool selected(int, int);
static char *getsel(void);
static void selnormalize(void);
static inline bool selected(int, int);
static char *getsel(void);
-static void selcopy(void);
+static void selcopy(Time);
static void selscroll(int, int);
static void selsnap(int, int *, int *, int);
static int x2col(int);
static void selscroll(int, int);
static void selsnap(int, int *, int *, int);
static int x2col(int);
-selcopy(void) {
- xsetsel(getsel());
+selcopy(Time t) {
+ xsetsel(getsel(), t);
XSelectionEvent *xsev;
ofs = 0;
XSelectionEvent *xsev;
ofs = 0;
- xsev = (XSelectionEvent *)e;
if (xsev->property == None)
return;
do {
if (xsev->property == None)
return;
do {
xev.selection = xsre->selection;
xev.target = xsre->target;
xev.time = xsre->time;
xev.selection = xsre->selection;
xev.target = xsre->target;
xev.time = xsre->time;
+ if (xsre->property == None)
+ xsre->property = xsre->target;
+
/* reject */
xev.property = None;
/* reject */
xev.property = None;
+xsetsel(char *str, Time t) {
free(sel.primary);
sel.primary = str;
free(sel.primary);
sel.primary = str;
- XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, CurrentTime);
+ XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
+ if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
+ selclear(0);
selclear(NULL);
} else {
getbuttoninfo(e);
selclear(NULL);
} else {
getbuttoninfo(e);
+ selcopy(e->xbutton.time);
}
sel.mode = 0;
tsetdirt(sel.nb.y, sel.ne.y);
}
sel.mode = 0;
tsetdirt(sel.nb.y, sel.ne.y);