glfw/x11_window/selection: timeout if no answer for two seconds
This prevents kitty to hang forever if a bad client does not give selection
This commit is contained in:
parent
019e6efeda
commit
d8a74e8a3c
12
glfw/x11_window.c
vendored
12
glfw/x11_window.c
vendored
@ -873,6 +873,7 @@ static const char* getSelectionString(Atom selection)
|
|||||||
Atom actualType;
|
Atom actualType;
|
||||||
int actualFormat;
|
int actualFormat;
|
||||||
unsigned long itemCount, bytesAfter;
|
unsigned long itemCount, bytesAfter;
|
||||||
|
double start = glfwGetTime();
|
||||||
XEvent notification, dummy;
|
XEvent notification, dummy;
|
||||||
|
|
||||||
XConvertSelection(_glfw.x11.display,
|
XConvertSelection(_glfw.x11.display,
|
||||||
@ -887,7 +888,10 @@ static const char* getSelectionString(Atom selection)
|
|||||||
SelectionNotify,
|
SelectionNotify,
|
||||||
¬ification))
|
¬ification))
|
||||||
{
|
{
|
||||||
waitForX11Event(-1);
|
double time = glfwGetTime();
|
||||||
|
if (time - start > 2)
|
||||||
|
return "";
|
||||||
|
waitForX11Event(2.0 - (time - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification.xselection.property == None)
|
if (notification.xselection.property == None)
|
||||||
@ -918,12 +922,16 @@ static const char* getSelectionString(Atom selection)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
start = glfwGetTime();
|
||||||
while (!XCheckIfEvent(_glfw.x11.display,
|
while (!XCheckIfEvent(_glfw.x11.display,
|
||||||
&dummy,
|
&dummy,
|
||||||
isSelPropNewValueNotify,
|
isSelPropNewValueNotify,
|
||||||
(XPointer) ¬ification))
|
(XPointer) ¬ification))
|
||||||
{
|
{
|
||||||
waitForX11Event(-1);
|
double time = glfwGetTime();
|
||||||
|
if (time - start > 2)
|
||||||
|
return "";
|
||||||
|
waitForX11Event(2.0 - (time - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(data);
|
XFree(data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user