[client] x11: process clipboard events early

Due to the logic in the event loop property events may get filtered out
that were clipboard related. This changes ensures the clipboard event
handler code gets to run first avoiding this issue.
This commit is contained in:
Geoffrey McRae 2021-04-29 12:24:23 +10:00
parent 9015706fcb
commit 3912d3411c
3 changed files with 14 additions and 10 deletions

View File

@ -59,30 +59,30 @@ static void x11CBSelectionIncr(const XPropertyEvent e);
static void x11CBSelectionNotify(const XSelectionEvent e); static void x11CBSelectionNotify(const XSelectionEvent e);
static void x11CBXFixesSelectionNotify(const XFixesSelectionNotifyEvent e); static void x11CBXFixesSelectionNotify(const XFixesSelectionNotifyEvent e);
void x11CBEventThread(const XEvent xe) bool x11CBEventThread(const XEvent xe)
{ {
switch(xe.type) switch(xe.type)
{ {
case SelectionRequest: case SelectionRequest:
x11CBSelectionRequest(xe.xselectionrequest); x11CBSelectionRequest(xe.xselectionrequest);
break; return true;
case SelectionClear: case SelectionClear:
x11CBSelectionClear(xe.xselectionclear); x11CBSelectionClear(xe.xselectionclear);
break; return true;
case SelectionNotify: case SelectionNotify:
x11CBSelectionNotify(xe.xselection); x11CBSelectionNotify(xe.xselection);
break; return true;
case PropertyNotify: case PropertyNotify:
if (xe.xproperty.atom == x11atoms.SEL_DATA) if (xe.xproperty.atom == x11atoms.SEL_DATA)
{ {
if (x11cb.lowerBound == 0) if (x11cb.lowerBound == 0)
break; return true;
x11CBSelectionIncr(xe.xproperty); x11CBSelectionIncr(xe.xproperty);
break; return true;
} }
break; break;
@ -91,9 +91,12 @@ void x11CBEventThread(const XEvent xe)
{ {
XFixesSelectionNotifyEvent * sne = (XFixesSelectionNotifyEvent *)&xe; XFixesSelectionNotifyEvent * sne = (XFixesSelectionNotifyEvent *)&xe;
x11CBXFixesSelectionNotify(*sne); x11CBXFixesSelectionNotify(*sne);
return true;
} }
break; break;
} }
return false;
} }
bool x11CBInit() bool x11CBInit()

View File

@ -25,7 +25,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "interface/displayserver.h" #include "interface/displayserver.h"
void x11CBEventThread(const XEvent xe); bool x11CBEventThread(const XEvent xe);
bool x11CBInit(); bool x11CBInit();
void x11CBNotice(LG_ClipboardData type); void x11CBNotice(LG_ClipboardData type);

View File

@ -558,6 +558,10 @@ static int x11EventThread(void * unused)
XEvent xe; XEvent xe;
XNextEvent(x11.display, &xe); XNextEvent(x11.display, &xe);
// call the clipboard handling code
if (x11CBEventThread(xe))
continue;
switch(xe.type) switch(xe.type)
{ {
case ClientMessage: case ClientMessage:
@ -666,9 +670,6 @@ static int x11EventThread(void * unused)
} }
break; break;
} }
// call the clipboard handling code
x11CBEventThread(xe);
} }
return 0; return 0;