70 #include "qplatformdefs.h" 74 #ifndef QT_NO_DRAGANDDROP 101 #define DndRevision 0 102 #define DndIncludeVersion (DndVersion * 10 + DndRevision) 107 #define DND_DRAG_NONE 0 108 #define DND_DRAG_DROP_ONLY 1 109 #define DND_DRAG_DYNAMIC 5 112 #define DND_TOP_LEVEL_ENTER 0 113 #define DND_TOP_LEVEL_LEAVE 1 114 #define DND_DRAG_MOTION 2 115 #define DND_DROP_SITE_ENTER 3 116 #define DND_DROP_SITE_LEAVE 4 117 #define DND_DROP_START 5 118 #define DND_OPERATION_CHANGED 8 122 #define DND_MOVE (1L << 0) 123 #define DND_COPY (1L << 1) 124 #define DND_LINK (1L << 2) 153 #define DND_NO_DROP_SITE 1 154 #define DND_INVALID_DROP_SITE 2 155 #define DND_VALID_DROP_SITE 3 159 #define DND_DROP_HELP 1 160 #define DND_DROP_CANCEL 2 162 #define BYTE unsigned char 163 #define CARD32 unsigned int 164 #define CARD16 unsigned short 165 #define INT16 signed short 235 #define DND_PROTOCOL_VERSION 0 238 #define DND_EVENT_TYPE_MASK ((BYTE)0x80) 239 #define DND_EVENT_TYPE_SHIFT 7 240 #define DND_CLEAR_EVENT_TYPE ((BYTE)0x7F) 244 #define DND_GET_EVENT_TYPE(message_type) \ 245 ((char) (((message_type) & DND_EVENT_TYPE_MASK) >> DND_EVENT_TYPE_SHIFT)) 248 #define DND_SET_EVENT_TYPE(event_type) \ 249 (((BYTE)(event_type) << DND_EVENT_TYPE_SHIFT) & DND_EVENT_TYPE_MASK) 252 #define DND_OPERATION_MASK ((CARD16) 0x000F) 253 #define DND_OPERATION_SHIFT 0 254 #define DND_STATUS_MASK ((CARD16) 0x00F0) 255 #define DND_STATUS_SHIFT 4 256 #define DND_OPERATIONS_MASK ((CARD16) 0x0F00) 257 #define DND_OPERATIONS_SHIFT 8 258 #define DND_COMPLETION_MASK ((CARD16) 0xF000) 259 #define DND_COMPLETION_SHIFT 12 261 #define DND_GET_OPERATION(flags) \ 263 (((flags) & DND_OPERATION_MASK) >> DND_OPERATION_SHIFT)) 265 #define DND_SET_OPERATION(operation) \ 266 (((CARD16)(operation) << DND_OPERATION_SHIFT)\ 267 & DND_OPERATION_MASK) 269 #define DND_GET_STATUS(flags) \ 271 (((flags) & DND_STATUS_MASK) >> DND_STATUS_SHIFT)) 273 #define DND_SET_STATUS(status) \ 274 (((CARD16)(status) << DND_STATUS_SHIFT)\ 277 #define DND_GET_OPERATIONS(flags) \ 279 (((flags) & DND_OPERATIONS_MASK) >> DND_OPERATIONS_SHIFT)) 281 #define DND_SET_OPERATIONS(operation) \ 282 (((CARD16)(operation) << DND_OPERATIONS_SHIFT)\ 283 & DND_OPERATIONS_MASK) 285 #define DND_GET_COMPLETION(flags) \ 287 (((flags) & DND_COMPLETION_MASK) >> DND_COMPLETION_SHIFT)) 289 #define DND_SET_COMPLETION(completion) \ 290 (((CARD16)(completion) << DND_COMPLETION_SHIFT)\ 291 & DND_COMPLETION_MASK) 294 #define SWAP4BYTES(l) {\ 295 struct { unsigned t :32;} bit32;\ 296 char n, *tp = (char *) &bit32;\ 298 n = tp[0]; tp[0] = tp[3]; tp[3] = n;\ 299 n = tp[1]; tp[1] = tp[2]; tp[2] = n;\ 303 #define SWAP2BYTES(s) {\ 304 struct { unsigned t :16; } bit16;\ 305 char n, *tp = (char *) &bit16;\ 307 n = tp[0]; tp[0] = tp[1]; tp[1] = n;\ 343 unsigned int endian = 1;
344 byte_order = (*((
char *)&endian))?
'l':
'B';
353 Atom ** targets,
unsigned short * num_targets)
355 unsigned char *retval = 0;
358 unsigned long bytesafter, lengthRtn;
360 if ((XGetWindowProperty (dpy, window, dnd_selection, 0L, 100000L,
362 &format, &lengthRtn, &bytesafter,
364 || (type ==
XNone)) {
378 XFree((
char*)src_prop);
386 unsigned char protocol_style)
391 memset(&receiver_prop, 0,
sizeof(receiver_prop));
403 (
unsigned char *)&receiver_prop,
409 #define DND_DRAG_DROP_ONLY_EQUIV 3 410 #define DND_DRAG_DYNAMIC_EQUIV1 2 411 #define DND_DRAG_DYNAMIC_EQUIV2 4 416 XClientMessageEvent *cm,
423 cm->type = ClientMessage;
424 cm->serial = LastKnownRequestProcessed(dpy);
425 cm->send_event = True;
436 dnd_message->
flags = 0 ;
442 dnd_message->
time = dnd_data->
time ;
444 switch(dnd_data->
reason) {
489 dnd_data->
time = dnd_message->
time ;
497 switch(dnd_data->
reason) {
539 unsigned long bytes_after;
540 unsigned char *
property = 0;
545 if ((XGetWindowProperty (display, RootWindow(display, 0),
547 0L, 100000L, False, AnyPropertyType,
548 &type, &format, &size, &bytes_after,
553 XSetWindowAttributes sAttributes;
560 sAttributes.override_redirect = True;
561 sAttributes.event_mask = PropertyChangeMask;
562 motif_window = XCreateWindow (display,
563 RootWindow (display, 0),
564 -170, -560, 1, 1, 0, 0,
565 InputOnly, CopyFromParent,
566 (CWOverrideRedirect |CWEventMask),
568 XMapWindow (display, motif_window);
575 return (motif_window);
584 unsigned long bytes_after;
586 unsigned char *retval;
587 DndTargetsTable targets_table ;
595 if ((XGetWindowProperty (display, motif_window,
598 &type, &format, &size, &bytes_after,
601 qWarning(
"QMotifDND: Cannot get property on Motif window");
608 qWarning(
"QMotifDND: Protocol mismatch");
624 target_data = (
char*)target_prop +
sizeof(*target_prop) ;
626 for (i = 0 ; i < targets_table->
num_entries; i++) {
630 memcpy(&num_targets, target_data, 2);
642 for (j = 0; j < num_targets; j++) {
643 memcpy(&atom, target_data, 4);
655 XFree((
char *)target_prop);
658 return targets_table ;
666 DndTargetsTable targets_table;
674 XFree((
char*)targets_table);
679 *targets = (
Atom*)malloc(
sizeof(
Atom)*targets_table->
681 memcpy((
char*)*targets,
690 XFree((
char*)targets_table);
698 if (!motifdnd_active)
706 if (target == XA_STRING)
707 return "text/plain;charset=ISO-8859-1";
709 return "text/plain;charset=UTF-8";
715 return (
"x-motif-dnd/" +
X11->xdndAtomToString(target));
732 f = motifdndFormat(n);
739 if (f ==
"text/plain;charset=ISO-8859-1") {
740 conversion_type = XA_STRING;
741 }
else if (f ==
"text/plain;charset=UTF-8") {
745 }
else if (f ==
"text/plain") {
749 conversion_type =
X11->xdndStringToAtom(f.
remove(0, 12));
765 XFlush(
X11->display);
768 bool got=
X11->clipboardWaitForEvent(tw->
internalWinId(), SelectionNotify, &xevent, 5000);
781 X11->clipboardWaitForEvent(tw->
internalWinId(), SelectionNotify, &xevent, 5000);
800 XClientMessageEvent cm ;
805 &dnd_data, &receiver))) {
809 switch (dnd_data.
reason) {
842 if (dropWidget != c) {
851 const Qt::DropActions possibleActions =
872 const Qt::DropActions possibleActions =
908 motifdnd_active =
true;
923 if (XCheckTypedWindowEvent(
X11->display, widget->
winId(), ClientMessage, &nextEvent)) {
925 XPutBackEvent(
X11->display, &nextEvent);
944 motifdnd_active =
false;
976 motifdnd_active =
false;
1002 if (de.isAccepted()) {
1019 motifdnd_active =
false;
1031 #endif // QT_NO_DRAGANDDROP
The QVariant class acts like a union for the most common Qt data types.
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
#define DND_DROP_SITE_ENTER
#define DND_SET_EVENT_TYPE(event_type)
static Atom * src_targets
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
char * data()
Returns a pointer to the data stored in the byte array.
static Bool DndParseClientMessage(XClientMessageEvent *cm, DndData *dnd_data, char *receiver)
#define DND_SET_OPERATION(operation)
static Window MotifWindow(Display *display)
void motifdndEnable(QWidget *, bool)
#define DND_OPERATION_CHANGED
The QByteArray class provides an array of bytes.
void motifdndHandle(QWidget *, const XEvent *, bool)
static void DndReadSourceProperty(Display *dpy, Window window, Atom dnd_selection, Atom **targets, unsigned short *num_targets)
DndTargetsTableEntry entries
QVariant motifdndObtainData(const char *format)
void setDropAction(Qt::DropAction action)
Sets the action to be performed on the data by the target.
#define DND_GET_COMPLETION(flags)
Qt::DropAction dropAction() const
Returns the action to be performed on the data by the target.
void accept()
Calls QDropEvent::accept().
static DndTargetsTable TargetsTable(Display *display)
void qt_x11_intern_atom(const char *, Atom *)
#define DND_GET_OPERATION(flags)
#define DND_INVALID_DROP_SITE
static unsigned char DndByteOrder()
static uchar QtDropActionToDndOperation(Qt::DropAction action)
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
static Atom Dnd_selection
QByteArray motifdndFormat(int n)
static ushort num_src_targets
static Time Dnd_selection_time
#define DND_TOP_LEVEL_LEAVE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
#define DND_PROTOCOL_VERSION
#define DND_VALID_DROP_SITE
struct _DndSrcProp DndSrcProp
#define DND_SET_STATUS(status)
static Qt::DropActions DndOperationsToQtDropActions(uchar op)
#define DND_SET_COMPLETION(completion)
Q_CORE_EXPORT void qWarning(const char *,...)
#define DND_GET_STATUS(flags)
static const char * data(const QByteArray &arr)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
#define DND_SET_OPERATIONS(operation)
#define DND_GET_OPERATIONS(flags)
static QDragManager * self()
virtual QByteArray name() const =0
QTextCodec subclasses must reimplement this function.
struct _DndReceiverProp DndReceiverProp
static const MacSpecialKey entries[NumEntries]
static ushort _DndIndexToTargets(Display *display, int index, Atom **targets)
#define DND_TOP_LEVEL_ENTER
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static void DndFillClientMessage(Display *dpy, Window window, XClientMessageEvent *cm, DndData *dnd_data, char receiver)
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
The QPoint class defines a point in the plane using integer precision.
static void DndWriteReceiverProperty(Display *dpy, Window window, unsigned char protocol_style)
if(void) toggleToolbarShown
#define DND_CLEAR_EVENT_TYPE
#define DND_DROP_SITE_LEAVE
return(isPopup||isToolTip)
#define DND_GET_EVENT_TYPE(message_type)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
static Window sourceWindow
Q_CORE_EXPORT int qstricmp(const char *, const char *)
static Qt::DropAction lastAcceptedAction
struct _DndMessage DndMessage
union _DndMessage::@205 data
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...
static QWidget * dropWidget
struct DndTargetsTableEntryRec * DndTargetsTableEntry
struct DndTargetsTableRec * DndTargetsTable