Finish up client message handling for Xdnd. Still has a couple of
unresolved cases that will be filled out when the actual dnd process loop is written. SVN revision: 9059
This commit is contained in:
parent
4eb39a4eb9
commit
999135b7e8
|
@ -125,7 +125,7 @@ typedef struct _Ecore_X_Event_Xdnd_Enter Ecore_X_Event_Xdnd_Enter;
|
|||
typedef struct _Ecore_X_Event_Xdnd_Position Ecore_X_Event_Xdnd_Position;
|
||||
typedef struct _Ecore_X_Event_Xdnd_Status Ecore_X_Event_Xdnd_Status;
|
||||
typedef struct _Ecore_X_Event_Xdnd_Leave Ecore_X_Event_Xdnd_Leave;
|
||||
typedef struct _Ecore_X_Event_Xdnd_Drop Ecore_X_Event_Xdnd_Stop;
|
||||
typedef struct _Ecore_X_Event_Xdnd_Drop Ecore_X_Event_Xdnd_Drop;
|
||||
typedef struct _Ecore_X_Event_Xdnd_Finished Ecore_X_Event_Xdnd_Finished;
|
||||
typedef struct _Ecore_X_Event_Client_Message Ecore_X_Event_Client_Message;
|
||||
typedef struct _Ecore_X_Event_Window_Shape Ecore_X_Event_Window_Shape;
|
||||
|
|
|
@ -46,6 +46,7 @@ Atom _ecore_x_atom_selection_prop_secondary = 0;
|
|||
Atom _ecore_x_atom_selection_prop_clipboard = 0;
|
||||
|
||||
Atom _ecore_x_atom_selection_xdnd = 0;
|
||||
Atom _ecore_x_atom_selection_prop_xdnd = 0;
|
||||
Atom _ecore_x_atom_xdnd_aware = 0;
|
||||
Atom _ecore_x_atom_xdnd_enter = 0;
|
||||
Atom _ecore_x_atom_xdnd_type_list = 0;
|
||||
|
@ -369,6 +370,7 @@ ecore_x_init(const char *name)
|
|||
_ecore_x_atom_selection_prop_primary = XInternAtom(_ecore_x_disp, "_ECORE_SELECTION_PRIMARY", False);
|
||||
_ecore_x_atom_selection_prop_secondary = XInternAtom(_ecore_x_disp, "_ECORE_SELECTION_SECONDARY", False);
|
||||
_ecore_x_atom_selection_prop_clipboard = XInternAtom(_ecore_x_disp, "_ECORE_SELECTION_CLIPBOARD", False);
|
||||
_ecore_x_atom_selection_prop_xdnd = XInternAtom(_ecore_x_disp, "_ECORE_SELECTION_XDND", False);
|
||||
_ecore_x_atom_selection_xdnd = XInternAtom(_ecore_x_disp, "XdndSelection", False);
|
||||
_ecore_x_atom_xdnd_aware = XInternAtom(_ecore_x_disp, "XdndAware", False);
|
||||
_ecore_x_atom_xdnd_type_list = XInternAtom(_ecore_x_disp, "XdndTypeList", False);
|
||||
|
|
|
@ -78,6 +78,7 @@ ecore_x_dnd_begin (Ecore_X_Window source, unsigned char *data, int size)
|
|||
|
||||
_xdnd->source = source;
|
||||
_xdnd->state = ECORE_X_DND_DRAGGING;
|
||||
_xdnd->time = _ecore_x_event_last_time;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1038,7 +1038,9 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
|
|||
e->time = _ecore_x_event_last_time;
|
||||
ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, _ecore_x_event_free_generic, NULL);
|
||||
}
|
||||
/* Xdnd Client Message Handling */
|
||||
|
||||
/* Xdnd Client Message Handling Begin */
|
||||
/* Message Type: XdndEnter */
|
||||
else if (xevent->xclient.message_type == _ecore_x_atom_xdnd_enter)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Enter *e;
|
||||
|
@ -1095,9 +1097,11 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
|
|||
e->win = _xdnd->dest;
|
||||
e->source = _xdnd->source;
|
||||
e->time = CurrentTime;
|
||||
_ecore_x_event_last_time = e->time;
|
||||
ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e, _ecore_x_event_free_generic, NULL);
|
||||
}
|
||||
|
||||
/* Message Type: XdndPosition */
|
||||
else if (xevent->xclient.message_type == _ecore_x_atom_xdnd_position)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Position *e;
|
||||
|
@ -1124,6 +1128,8 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
|
|||
e->action = _xdnd->action;
|
||||
ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, _ecore_x_event_free_generic, NULL);
|
||||
}
|
||||
|
||||
/* Message Type: XdndStatus */
|
||||
else if (xevent->xclient.message_type == _ecore_x_atom_xdnd_status)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Status *e;
|
||||
|
@ -1157,6 +1163,108 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
|
|||
|
||||
ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, _ecore_x_event_free_generic, NULL);
|
||||
}
|
||||
|
||||
/* Message Type: XdndLeave */
|
||||
/* Pretend the whole thing never happened, sort of */
|
||||
else if (xevent->xclient.message_type == _ecore_x_atom_xdnd_leave)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Leave *e;
|
||||
Ecore_X_DND_Protocol *_xdnd;
|
||||
|
||||
_xdnd = _ecore_x_dnd_protocol_get();
|
||||
/* Match source/target */
|
||||
if (_xdnd->source != xevent->xclient.data.l[0]
|
||||
|| _xdnd->dest != xevent->xclient.window)
|
||||
return;
|
||||
if (_xdnd->types)
|
||||
free(_xdnd->types);
|
||||
_xdnd->num_types = 0;
|
||||
/* XXX: May need to reset event handler callbacks as well */
|
||||
_xdnd->state = ECORE_X_DND_IDLE;
|
||||
|
||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave));
|
||||
if (!e) return;
|
||||
e->win = _xdnd->dest;
|
||||
e->source = _xdnd->source;
|
||||
ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e, _ecore_x_event_free_generic, NULL);
|
||||
}
|
||||
else if (xevent->xclient.message_type == _ecore_x_atom_xdnd_drop)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Drop *e;
|
||||
Ecore_X_DND_Protocol *_xdnd;
|
||||
Ecore_X_Time timestamp;
|
||||
|
||||
_xdnd = _ecore_x_dnd_protocol_get();
|
||||
/* Match source/target */
|
||||
if (_xdnd->source != xevent->xclient.data.l[0]
|
||||
|| _xdnd->dest != xevent->xclient.window)
|
||||
return;
|
||||
|
||||
timestamp = (_xdnd->version >= 1) ?
|
||||
xevent->xclient.data.l[2] : _ecore_x_event_last_time;
|
||||
|
||||
XConvertSelection(_ecore_x_disp, _ecore_x_atom_selection_xdnd,
|
||||
_xdnd->dest, _ecore_x_atom_selection_prop_xdnd, _xdnd->dest,
|
||||
timestamp);
|
||||
|
||||
/* FIXME: Have to wait for SelectionNotify before we can send
|
||||
* XdndFinished. Stupid, retarded protocols, gah! */
|
||||
|
||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
|
||||
if (!e) return;
|
||||
e->win = _xdnd->dest;
|
||||
e->source = _xdnd->source;
|
||||
e->time = timestamp;
|
||||
e->action = _xdnd->action;
|
||||
e->position.x = _xdnd->pos.x;
|
||||
e->position.y = _xdnd->pos.y;
|
||||
ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, _ecore_x_event_free_generic, NULL);
|
||||
}
|
||||
|
||||
/* Message Type: XdndFinished */
|
||||
else if (xevent->xclient.message_type == _ecore_x_atom_xdnd_finished)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Finished *e;
|
||||
Ecore_X_DND_Protocol *_xdnd;
|
||||
int completed = 1;
|
||||
|
||||
_xdnd = _ecore_x_dnd_protocol_get();
|
||||
/* Match source/target */
|
||||
if (_xdnd->source != xevent->xclient.window
|
||||
|| _xdnd->dest != xevent->xclient.data.l[0])
|
||||
return;
|
||||
|
||||
if (_xdnd->version >= 5 && (xevent->xclient.data.l[1] & 0x1UL))
|
||||
{
|
||||
/* Target successfully performed drop action */
|
||||
_xdnd->state = ECORE_X_DND_IDLE;
|
||||
} else {
|
||||
completed = 0;
|
||||
_xdnd->state = ECORE_X_DND_TARGET_CONVERTING;
|
||||
|
||||
/* FIXME: Probably need to add a timer to switch back to idle
|
||||
* and discard the selection data */
|
||||
}
|
||||
|
||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished));
|
||||
if (!e) return;
|
||||
e->win = _xdnd->source;
|
||||
e->target = _xdnd->dest;
|
||||
e->completed = completed;
|
||||
if (_xdnd->version >= 5)
|
||||
{
|
||||
_xdnd->accepted_action = xevent->xclient.data.l[2];
|
||||
e->action = _xdnd->accepted_action;
|
||||
}
|
||||
else
|
||||
{
|
||||
_xdnd->accepted_action = 0;
|
||||
e->action = _xdnd->action;
|
||||
}
|
||||
|
||||
ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, _ecore_x_event_free_generic, NULL);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: handle this event type */
|
||||
|
|
|
@ -78,6 +78,8 @@ typedef struct _Ecore_X_DND_Protocol
|
|||
int x, y;
|
||||
} pos;
|
||||
|
||||
Time time;
|
||||
|
||||
Atom *types;
|
||||
Atom action, accepted_action;
|
||||
int num_types;
|
||||
|
@ -186,6 +188,7 @@ extern Atom _ecore_x_atom_selection_prop_secondary;
|
|||
extern Atom _ecore_x_atom_selection_prop_clipboard;
|
||||
|
||||
extern Atom _ecore_x_atom_selection_xdnd;
|
||||
extern Atom _ecore_x_atom_selection_prop_xdnd;
|
||||
extern Atom _ecore_x_atom_xdnd_aware;
|
||||
extern Atom _ecore_x_atom_xdnd_enter;
|
||||
extern Atom _ecore_x_atom_xdnd_type_list;
|
||||
|
@ -196,6 +199,7 @@ extern Atom _ecore_x_atom_xdnd_action_ask;
|
|||
extern Atom _ecore_x_atom_xdnd_action_list;
|
||||
extern Atom _ecore_x_atom_xdnd_action_description;
|
||||
extern Atom _ecore_x_atom_xdnd_status;
|
||||
extern Atom _ecore_x_atom_xdnd_leave;
|
||||
extern Atom _ecore_x_atom_xdnd_drop;
|
||||
extern Atom _ecore_x_atom_xdnd_finished;
|
||||
|
||||
|
|
Loading…
Reference in New Issue