mirror of https://github.com/adamdruppe/arsd.git
terrible incremental paste code
This commit is contained in:
parent
d03a2d4a44
commit
037952925b
|
@ -9674,6 +9674,9 @@ version(X11) {
|
||||||
scope(exit) XLockDisplay(display);
|
scope(exit) XLockDisplay(display);
|
||||||
win.setSelectionHandler(e);
|
win.setSelectionHandler(e);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case EventType.PropertyNotify:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EventType.SelectionNotify:
|
case EventType.SelectionNotify:
|
||||||
if(auto win = e.xselection.requestor in SimpleWindow.nativeMapping)
|
if(auto win = e.xselection.requestor in SimpleWindow.nativeMapping)
|
||||||
|
@ -9694,11 +9697,11 @@ version(X11) {
|
||||||
e.xselection.property,
|
e.xselection.property,
|
||||||
0,
|
0,
|
||||||
100000 /* length */,
|
100000 /* length */,
|
||||||
false,
|
//false, /* don't erase it */
|
||||||
|
true, /* do erase it lol */
|
||||||
0 /*AnyPropertyType*/,
|
0 /*AnyPropertyType*/,
|
||||||
&target, &format, &length, &bytesafter, &value);
|
&target, &format, &length, &bytesafter, &value);
|
||||||
|
|
||||||
// FIXME: it might be sent in pieces...
|
|
||||||
// FIXME: I don't have to copy it now since it is in char[] instead of string
|
// FIXME: I don't have to copy it now since it is in char[] instead of string
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -9728,15 +9731,51 @@ version(X11) {
|
||||||
}
|
}
|
||||||
} else if(target == GetAtom!"UTF8_STRING"(display) || target == XA_STRING) {
|
} else if(target == GetAtom!"UTF8_STRING"(display) || target == XA_STRING) {
|
||||||
win.getSelectionHandler((cast(char[]) value[0 .. length]).idup);
|
win.getSelectionHandler((cast(char[]) value[0 .. length]).idup);
|
||||||
|
} else if(target == GetAtom!"INCR"(display)) {
|
||||||
|
// incremental
|
||||||
|
|
||||||
|
//sdpyGettingPaste = true; // FIXME: should prolly be separate for the different selections
|
||||||
|
|
||||||
|
// FIXME: handle other events while it goes so app doesn't lock up with big pastes
|
||||||
|
// can also be optimized if it chunks to the api somehow
|
||||||
|
|
||||||
|
char[] s;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
XEvent subevent;
|
||||||
|
do {
|
||||||
|
XMaskEvent(display, EventMask.PropertyChangeMask, &subevent);
|
||||||
|
} while(subevent.type != EventType.PropertyNotify || subevent.xproperty.atom != e.xselection.property || subevent.xproperty.state != PropertyNotification.PropertyNewValue);
|
||||||
|
|
||||||
|
void* subvalue;
|
||||||
|
XGetWindowProperty(
|
||||||
|
e.xselection.display,
|
||||||
|
e.xselection.requestor,
|
||||||
|
e.xselection.property,
|
||||||
|
0,
|
||||||
|
100000 /* length */,
|
||||||
|
true, /* erase it to signal we got it and want more */
|
||||||
|
0 /*AnyPropertyType*/,
|
||||||
|
&target, &format, &length, &bytesafter, &subvalue);
|
||||||
|
|
||||||
|
s ~= (cast(char*) subvalue)[0 .. length];
|
||||||
|
|
||||||
|
XFree(subvalue);
|
||||||
|
} while(length > 0);
|
||||||
|
|
||||||
|
win.getSelectionHandler(s);
|
||||||
} else {
|
} else {
|
||||||
// unsupported type
|
// unsupported type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree(value);
|
XFree(value);
|
||||||
|
/*
|
||||||
XDeleteProperty(
|
XDeleteProperty(
|
||||||
e.xselection.display,
|
e.xselection.display,
|
||||||
e.xselection.requestor,
|
e.xselection.requestor,
|
||||||
e.xselection.property);
|
e.xselection.property);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -10853,6 +10892,8 @@ int XNextEvent(
|
||||||
XEvent* /* event_return */
|
XEvent* /* event_return */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
int XMaskEvent(Display*, arch_long, XEvent*);
|
||||||
|
|
||||||
Bool XFilterEvent(XEvent *event, Window window);
|
Bool XFilterEvent(XEvent *event, Window window);
|
||||||
int XRefreshKeyboardMapping(XMappingEvent *event_map);
|
int XRefreshKeyboardMapping(XMappingEvent *event_map);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue