forked from enlightenment/efl
it does pastes out of entry boxes (code needs some smartening up - but it
works!) SVN revision: 4323
This commit is contained in:
parent
fdb204a52e
commit
902bd035d4
|
@ -275,6 +275,7 @@ void e_keyboard_grab(Window win);
|
|||
void e_keyboard_ungrab(void);
|
||||
|
||||
Window e_selection_request(void);
|
||||
Window e_selection_set(char *string);
|
||||
|
||||
typedef struct _eev Eevent;
|
||||
typedef struct _ev_fd_handler Ev_Fd_Handler;
|
||||
|
|
|
@ -892,10 +892,12 @@ e_ev_x_handle_selection_request(XEvent * xevent)
|
|||
{
|
||||
static Atom atom_xdndselection = 0;
|
||||
static Atom atom_text_plain = 0;
|
||||
static Atom atom_text_selection = 0;
|
||||
Ev_Dnd_Data_Request *e;
|
||||
|
||||
E_ATOM(atom_xdndselection, "XdndSelection");
|
||||
E_ATOM(atom_text_plain, "text/plain");
|
||||
E_ATOM(atom_text_selection, "TEXT_SELECTION");
|
||||
if (xevent->xselectionrequest.selection == atom_xdndselection)
|
||||
{
|
||||
e = NEW(Ev_Dnd_Data_Request, 1);
|
||||
|
@ -909,6 +911,67 @@ e_ev_x_handle_selection_request(XEvent * xevent)
|
|||
e->destination_atom = xevent->xselectionrequest.property;
|
||||
e_add_event(EV_DND_DATA_REQUEST, e, e_ev_generic_free);
|
||||
}
|
||||
else
|
||||
{
|
||||
XEvent ev;
|
||||
Atom target_list[2];
|
||||
static Atom xa_targets = None;
|
||||
|
||||
if (xa_targets == None)
|
||||
xa_targets = XInternAtom(xevent->xselectionrequest.display,
|
||||
"TARGETS", False);
|
||||
ev.xselection.type = SelectionNotify;
|
||||
ev.xselection.property = None;
|
||||
ev.xselection.display = xevent->xselectionrequest.display;
|
||||
ev.xselection.requestor = xevent->xselectionrequest.requestor;
|
||||
ev.xselection.selection = xevent->xselectionrequest.selection;
|
||||
ev.xselection.target = xevent->xselectionrequest.target;
|
||||
ev.xselection.time = xevent->xselectionrequest.time;
|
||||
if (xevent->xselectionrequest.target == xa_targets)
|
||||
{
|
||||
target_list[0] = (Atom) xa_targets;
|
||||
target_list[1] = (Atom) XA_STRING;
|
||||
XChangeProperty(xevent->xselectionrequest.display,
|
||||
xevent->xselectionrequest.requestor,
|
||||
xevent->xselectionrequest.property,
|
||||
xevent->xselectionrequest.target,
|
||||
(8 * sizeof(target_list[0])),
|
||||
PropModeReplace,
|
||||
(unsigned char *) target_list,
|
||||
(sizeof(target_list) / sizeof(target_list[0])));
|
||||
ev.xselection.property = xevent->xselectionrequest.property;
|
||||
}
|
||||
else if (xevent->xselectionrequest.target == XA_STRING)
|
||||
{
|
||||
void *data;
|
||||
int size;
|
||||
|
||||
data = e_window_property_get(xevent->xselectionrequest.owner,
|
||||
atom_text_selection, XA_STRING,
|
||||
&size);
|
||||
if (data)
|
||||
{
|
||||
XChangeProperty(xevent->xselectionrequest.display,
|
||||
xevent->xselectionrequest.requestor,
|
||||
xevent->xselectionrequest.property,
|
||||
xevent->xselectionrequest.target,
|
||||
8,
|
||||
PropModeReplace,
|
||||
data, size);
|
||||
FREE(data);
|
||||
}
|
||||
ev.xselection.property = xevent->xselectionrequest.property;
|
||||
}
|
||||
XSendEvent(xevent->xselectionrequest.display,
|
||||
xevent->xselectionrequest.requestor, False, 0, &ev);
|
||||
printf("%i %i %i : %i, %i (%x %x %x)\n",
|
||||
xevent->xselectionrequest.selection, /* XA_PRIMARY */
|
||||
xevent->xselectionrequest.target, /* XA_STRING */
|
||||
xevent->xselectionrequest.property, /* the destination atiom */
|
||||
atom_text_selection, XA_STRING,
|
||||
xevent->xselectionrequest.owner, /* the window we put it on */
|
||||
xevent->xselectionrequest.requestor /* where to put the prop */);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -2899,17 +2899,41 @@ e_keyboard_ungrab(void)
|
|||
#define X_CLIPBOARD_PROP XA_CUT_BUFFER0
|
||||
#endif
|
||||
|
||||
Window
|
||||
e_selection_set(char *string)
|
||||
{
|
||||
Window target = 0;
|
||||
static Atom dest = 0;
|
||||
Atom selection;
|
||||
|
||||
selection = X_CLIPBOARD_SELECTION;
|
||||
E_ATOM(dest, "TEXT_SELECTION");
|
||||
target = e_window_new(0, 0, 0, 77, 7);
|
||||
e_window_add_events(target, XEV_CONFIGURE | XEV_PROPERTY);
|
||||
XSetSelectionOwner(disp, selection, target, CurrentTime);
|
||||
if (XGetSelectionOwner(disp, XA_PRIMARY) != target)
|
||||
{
|
||||
e_window_destroy(target);
|
||||
return 0;
|
||||
}
|
||||
XChangeProperty(disp, target, dest,
|
||||
XA_STRING, 8, PropModeReplace,
|
||||
string, strlen(string));
|
||||
printf("window %x\n", target);
|
||||
return target;
|
||||
}
|
||||
|
||||
Window
|
||||
e_selection_request(void)
|
||||
{
|
||||
Atom selection, dest = 0;
|
||||
static Window target = 0;
|
||||
static Atom dest = 0;
|
||||
Atom selection;
|
||||
Window target = 0;
|
||||
|
||||
selection = X_CLIPBOARD_SELECTION;
|
||||
E_ATOM(dest, "TEXT_SELECTION");
|
||||
target = e_window_new(0, 0, 0, 7, 77);
|
||||
e_window_add_events(target,
|
||||
XEV_CONFIGURE | XEV_PROPERTY);
|
||||
e_window_add_events(target, XEV_CONFIGURE | XEV_PROPERTY);
|
||||
XConvertSelection(disp, XA_PRIMARY,
|
||||
XA_STRING, dest,
|
||||
target,
|
||||
|
|
Loading…
Reference in New Issue