src/gui/kernel/qmotifdnd_x11.cpp File Reference

#include "qplatformdefs.h"
#include "qapplication.h"
#include "qdebug.h"
#include "qtextcodec.h"
#include "qwidget.h"
#include "qevent.h"
#include "qt_x11_p.h"
#include "qx11info_x11.h"
#include "qiodevice.h"
#include "qdnd_p.h"
#include <stdlib.h>

Include dependency graph for qmotifdnd_x11.cpp:

Go to the source code of this file.

Classes

struct  DndData
struct  _DndSrcProp
struct  _DndReceiverProp
struct  _DndTop
struct  _DndPot
struct  _DndMessage
struct  DndTargets
struct  DndTargetsTableEntryRec
struct  DndTargetsTableRec

Defines

#define DndVersion   1
#define DndRevision   0
#define DndIncludeVersion   (DndVersion * 10 + DndRevision)
#define DND_DRAG_NONE   0
#define DND_DRAG_DROP_ONLY   1
#define DND_DRAG_DYNAMIC   5
#define DND_TOP_LEVEL_ENTER   0
#define DND_TOP_LEVEL_LEAVE   1
#define DND_DRAG_MOTION   2
#define DND_DROP_SITE_ENTER   3
#define DND_DROP_SITE_LEAVE   4
#define DND_DROP_START   5
#define DND_OPERATION_CHANGED   8
#define DND_NOOP   0L
#define DND_MOVE   (1L << 0)
#define DND_COPY   (1L << 1)
#define DND_LINK   (1L << 2)
#define DND_NO_DROP_SITE   1
#define DND_INVALID_DROP_SITE   2
#define DND_VALID_DROP_SITE   3
#define DND_DROP   0
#define DND_DROP_HELP   1
#define DND_DROP_CANCEL   2
#define BYTE   unsigned char
#define CARD32   unsigned int
#define CARD16   unsigned short
#define INT16   signed short
#define DND_PROTOCOL_VERSION   0
#define DND_EVENT_TYPE_MASK   ((BYTE)0x80)
#define DND_EVENT_TYPE_SHIFT   7
#define DND_CLEAR_EVENT_TYPE   ((BYTE)0x7F)
#define DND_GET_EVENT_TYPE(message_type)   ((char) (((message_type) & DND_EVENT_TYPE_MASK) >> DND_EVENT_TYPE_SHIFT))
#define DND_SET_EVENT_TYPE(event_type)   (((BYTE)(event_type) << DND_EVENT_TYPE_SHIFT) & DND_EVENT_TYPE_MASK)
#define DND_OPERATION_MASK   ((CARD16) 0x000F)
#define DND_OPERATION_SHIFT   0
#define DND_STATUS_MASK   ((CARD16) 0x00F0)
#define DND_STATUS_SHIFT   4
#define DND_OPERATIONS_MASK   ((CARD16) 0x0F00)
#define DND_OPERATIONS_SHIFT   8
#define DND_COMPLETION_MASK   ((CARD16) 0xF000)
#define DND_COMPLETION_SHIFT   12
#define DND_GET_OPERATION(flags)
#define DND_SET_OPERATION(operation)
#define DND_GET_STATUS(flags)
#define DND_SET_STATUS(status)
#define DND_GET_OPERATIONS(flags)
#define DND_SET_OPERATIONS(operation)
#define DND_GET_COMPLETION(flags)
#define DND_SET_COMPLETION(completion)
#define SWAP4BYTES(l)
#define SWAP2BYTES(s)
#define DND_DRAG_DROP_ONLY_EQUIV   3
#define DND_DRAG_DYNAMIC_EQUIV1   2
#define DND_DRAG_DYNAMIC_EQUIV2   4

Typedefs

typedef _DndSrcProp DndSrcProp
typedef _DndReceiverProp DndReceiverProp
typedef _DndTop DndTop
typedef _DndPot DndPot
typedef _DndMessage DndMessage
typedef struct DndTargetsTableEntryRecDndTargetsTableEntry
typedef struct DndTargetsTableRecDndTargetsTable

Functions

Qt::DropActions DndOperationsToQtDropActions (uchar op)
uchar QtDropActionToDndOperation (Qt::DropAction action)
static unsigned char DndByteOrder ()
static int _DndIndexToTargets (Display *display, int index, Atom **targets)
void qt_x11_intern_atom (const char *, Atom *)
static void DndReadSourceProperty (Display *dpy, Window window, Atom dnd_selection, Atom **targets, unsigned short *num_targets)
static void DndWriteReceiverProperty (Display *dpy, Window window, unsigned char protocol_style)
static void DndFillClientMessage (Display *dpy, Window window, XClientMessageEvent *cm, DndData *dnd_data, char receiver)
static Bool DndParseClientMessage (XClientMessageEvent *cm, DndData *dnd_data, char *receiver)
static Window MotifWindow (Display *display)
static DndTargetsTable TargetsTable (Display *display)

Variables

static Window sourceWindow = XNone
static QWidgetdropWidget = 0
static Qt::DropAction lastAcceptedAction = Qt::IgnoreAction
static Atom Dnd_selection = 0
static Time Dnd_selection_time
static Atom * src_targets
static ushort num_src_targets


Define Documentation

#define BYTE   unsigned char

Definition at line 147 of file qmotifdnd_x11.cpp.

#define CARD16   unsigned short

Definition at line 149 of file qmotifdnd_x11.cpp.

Referenced by TargetsTable().

#define CARD32   unsigned int

Definition at line 148 of file qmotifdnd_x11.cpp.

Referenced by TargetsTable().

#define DND_CLEAR_EVENT_TYPE   ((BYTE)0x7F)

Definition at line 225 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

#define DND_COMPLETION_MASK   ((CARD16) 0xF000)

Definition at line 243 of file qmotifdnd_x11.cpp.

#define DND_COMPLETION_SHIFT   12

Definition at line 244 of file qmotifdnd_x11.cpp.

#define DND_COPY   (1L << 1)

Definition at line 108 of file qmotifdnd_x11.cpp.

Referenced by DndOperationsToQtDropActions(), and QtDropActionToDndOperation().

#define DND_DRAG_DROP_ONLY   1

Definition at line 93 of file qmotifdnd_x11.cpp.

#define DND_DRAG_DROP_ONLY_EQUIV   3

Definition at line 389 of file qmotifdnd_x11.cpp.

#define DND_DRAG_DYNAMIC   5

Definition at line 94 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndEnable().

#define DND_DRAG_DYNAMIC_EQUIV1   2

Definition at line 390 of file qmotifdnd_x11.cpp.

#define DND_DRAG_DYNAMIC_EQUIV2   4

Definition at line 391 of file qmotifdnd_x11.cpp.

#define DND_DRAG_MOTION   2

Definition at line 99 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_DRAG_NONE   0

Definition at line 92 of file qmotifdnd_x11.cpp.

#define DND_DROP   0

Definition at line 143 of file qmotifdnd_x11.cpp.

#define DND_DROP_CANCEL   2

Definition at line 145 of file qmotifdnd_x11.cpp.

#define DND_DROP_HELP   1

Definition at line 144 of file qmotifdnd_x11.cpp.

#define DND_DROP_SITE_ENTER   3

Definition at line 100 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_DROP_SITE_LEAVE   4

Definition at line 101 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_DROP_START   5

Definition at line 102 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_EVENT_TYPE_MASK   ((BYTE)0x80)

Definition at line 223 of file qmotifdnd_x11.cpp.

#define DND_EVENT_TYPE_SHIFT   7

Definition at line 224 of file qmotifdnd_x11.cpp.

#define DND_GET_COMPLETION ( flags   ) 

Value:

((unsigned char) \
(((flags) & DND_COMPLETION_MASK) >> DND_COMPLETION_SHIFT))

Definition at line 270 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

#define DND_GET_EVENT_TYPE ( message_type   )     ((char) (((message_type) & DND_EVENT_TYPE_MASK) >> DND_EVENT_TYPE_SHIFT))

Definition at line 229 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

#define DND_GET_OPERATION ( flags   ) 

Value:

((unsigned char) \
(((flags) & DND_OPERATION_MASK) >> DND_OPERATION_SHIFT))

Definition at line 246 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

#define DND_GET_OPERATIONS ( flags   ) 

Value:

((unsigned char) \
(((flags) & DND_OPERATIONS_MASK) >> DND_OPERATIONS_SHIFT))

Definition at line 262 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

#define DND_GET_STATUS ( flags   ) 

Value:

((unsigned char) \
(((flags) & DND_STATUS_MASK) >> DND_STATUS_SHIFT))

Definition at line 254 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

#define DND_INVALID_DROP_SITE   2

Definition at line 139 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

#define DND_LINK   (1L << 2)

Definition at line 109 of file qmotifdnd_x11.cpp.

Referenced by DndOperationsToQtDropActions(), and QtDropActionToDndOperation().

#define DND_MOVE   (1L << 0)

Definition at line 107 of file qmotifdnd_x11.cpp.

Referenced by DndOperationsToQtDropActions(), and QtDropActionToDndOperation().

#define DND_NO_DROP_SITE   1

Definition at line 138 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

#define DND_NOOP   0L

Definition at line 106 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

#define DND_OPERATION_CHANGED   8

Definition at line 103 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_OPERATION_MASK   ((CARD16) 0x000F)

Definition at line 237 of file qmotifdnd_x11.cpp.

#define DND_OPERATION_SHIFT   0

Definition at line 238 of file qmotifdnd_x11.cpp.

#define DND_OPERATIONS_MASK   ((CARD16) 0x0F00)

Definition at line 241 of file qmotifdnd_x11.cpp.

#define DND_OPERATIONS_SHIFT   8

Definition at line 242 of file qmotifdnd_x11.cpp.

#define DND_PROTOCOL_VERSION   0

Definition at line 220 of file qmotifdnd_x11.cpp.

Referenced by DndWriteReceiverProperty(), and TargetsTable().

#define DND_SET_COMPLETION ( completion   ) 

Value:

Definition at line 274 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

#define DND_SET_EVENT_TYPE ( event_type   )     (((BYTE)(event_type) << DND_EVENT_TYPE_SHIFT) & DND_EVENT_TYPE_MASK)

Definition at line 233 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

#define DND_SET_OPERATION ( operation   ) 

Value:

Definition at line 250 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

#define DND_SET_OPERATIONS ( operation   ) 

Value:

Definition at line 266 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

#define DND_SET_STATUS ( status   ) 

Value:

Definition at line 258 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

#define DND_STATUS_MASK   ((CARD16) 0x00F0)

Definition at line 239 of file qmotifdnd_x11.cpp.

#define DND_STATUS_SHIFT   4

Definition at line 240 of file qmotifdnd_x11.cpp.

#define DND_TOP_LEVEL_ENTER   0

Definition at line 97 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_TOP_LEVEL_LEAVE   1

Definition at line 98 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), and QX11Data::motifdndHandle().

#define DND_VALID_DROP_SITE   3

Definition at line 140 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

#define DndIncludeVersion   (DndVersion * 10 + DndRevision)

Definition at line 87 of file qmotifdnd_x11.cpp.

#define DndRevision   0

Definition at line 86 of file qmotifdnd_x11.cpp.

#define DndVersion   1

Definition at line 85 of file qmotifdnd_x11.cpp.

#define INT16   signed short

Definition at line 150 of file qmotifdnd_x11.cpp.

#define SWAP2BYTES (  ) 

Value:

{\
struct { unsigned t :16; } bit16;\
char n, *tp = (char *) &bit16;\
bit16.t = s;\
n = tp[0]; tp[0] = tp[1]; tp[1] = n;\
s = bit16.t;\
}

Definition at line 288 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage(), DndReadSourceProperty(), and TargetsTable().

#define SWAP4BYTES (  ) 

Value:

{\
struct { unsigned t :32;} bit32;\
char n, *tp = (char *) &bit32;\
bit32.t = l;\
n = tp[0]; tp[0] = tp[3]; tp[3] = n;\
n = tp[1]; tp[1] = tp[2]; tp[2] = n;\
l = bit32.t;\
}

Definition at line 279 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage(), DndReadSourceProperty(), and TargetsTable().


Typedef Documentation

typedef struct _DndMessage DndMessage

typedef struct _DndPot DndPot

typedef struct _DndReceiverProp DndReceiverProp

typedef struct _DndSrcProp DndSrcProp

typedef struct DndTargetsTableRec * DndTargetsTable

typedef struct DndTargetsTableEntryRec * DndTargetsTableEntry

typedef struct _DndTop DndTop


Function Documentation

static int _DndIndexToTargets ( Display display,
int  index,
Atom **  targets 
) [static]

Definition at line 640 of file qmotifdnd_x11.cpp.

References DndTargetsTableRec::entries, entries, i, DndTargetsTableRec::num_entries, DndTargetsTableEntryRec::num_targets, DndTargetsTableEntryRec::targets, and TargetsTable().

Referenced by DndReadSourceProperty().

00643 {
00644     DndTargetsTable        targets_table;
00645     int i ;
00646 
00647     /* again, slow: no caching here, alloc/free each time */
00648 
00649     if (!(targets_table = TargetsTable (display)) ||
00650         (index >= targets_table->num_entries)) {
00651         if (targets_table)
00652             XFree((char*)targets_table);
00653         return -1;
00654     }
00655 
00656     /* transfer the correct target list index */
00657     *targets = (Atom*)malloc(sizeof(Atom)*targets_table->
00658                              entries[index].num_targets);
00659     memcpy((char*)*targets,
00660            (char*)targets_table->entries[index].targets,
00661            sizeof(Atom)*targets_table->entries[index].num_targets);
00662 
00663     /* free the target table and its guts */
00664     for (i=0 ; i < targets_table->num_entries; i++)
00665         XFree((char*)targets_table->entries[i].targets);
00666 
00667     int tmp = targets_table->entries[index].num_targets;
00668     XFree((char*)targets_table);
00669 
00670     return tmp; // targets_table->entries[index].num_targets;
00671 }

Here is the call graph for this function:

static unsigned char DndByteOrder (  )  [static]

Private extern functions

Definition at line 323 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage(), DndParseClientMessage(), DndReadSourceProperty(), DndWriteReceiverProperty(), and TargetsTable().

00324 {
00325     static unsigned char byte_order = 0;
00326 
00327     if (!byte_order) {
00328         unsigned int endian = 1;
00329         byte_order = (*((char *)&endian))?'l':'B';
00330     }
00331     return byte_order ;
00332 }

static void DndFillClientMessage ( Display dpy,
Window  window,
XClientMessageEvent *  cm,
DndData dnd_data,
char  receiver 
) [static]

Definition at line 395 of file qmotifdnd_x11.cpp.

References ATOM, _DndMessage::byte_order, DndData::completion, _DndMessage::data, DND_DRAG_MOTION, DND_DROP_SITE_ENTER, DND_DROP_SITE_LEAVE, DND_DROP_START, DND_OPERATION_CHANGED, DND_SET_COMPLETION, DND_SET_EVENT_TYPE, DND_SET_OPERATION, DND_SET_OPERATIONS, DND_SET_STATUS, DND_TOP_LEVEL_ENTER, DND_TOP_LEVEL_LEAVE, DndByteOrder(), _DndMessage::flags, DndData::operation, DndData::operations, _DndMessage::pot, DndData::property, _DndTop::property, _DndPot::property, _DndMessage::reason, DndData::reason, _DndPot::src_window, DndData::src_window, _DndTop::src_window, DndData::status, DndData::time, _DndMessage::time, _DndMessage::top, DndData::x, _DndPot::x, DndData::y, and _DndPot::y.

Referenced by QX11Data::motifdndHandle().

00399 {
00400     DndMessage * dnd_message = (DndMessage*)&cm->data.b[0] ;
00401 
00402     cm->display = dpy;
00403     cm->type = ClientMessage;
00404     cm->serial = LastKnownRequestProcessed(dpy);
00405     cm->send_event = True;
00406     cm->window = window;
00407     cm->format = 8;
00408     cm->message_type = ATOM(_MOTIF_DRAG_AND_DROP_MESSAGE);
00409 
00410     dnd_message->reason = dnd_data->reason | DND_SET_EVENT_TYPE(receiver);
00411 
00412     dnd_message->byte_order = DndByteOrder();
00413 
00414     /* we're filling in flags with more stuff that necessary,
00415        depending on the reason, but it doesn't matter */
00416     dnd_message->flags = 0 ;
00417     dnd_message->flags |= DND_SET_STATUS(dnd_data->status) ;
00418     dnd_message->flags |= DND_SET_OPERATION(dnd_data->operation) ;
00419     dnd_message->flags |= DND_SET_OPERATIONS(dnd_data->operations) ;
00420     dnd_message->flags |= DND_SET_COMPLETION(dnd_data->completion) ;
00421 
00422     dnd_message->time = dnd_data->time ;
00423 
00424     switch(dnd_data->reason) {
00425     case DND_DROP_SITE_LEAVE: break ;
00426     case DND_TOP_LEVEL_ENTER:
00427     case DND_TOP_LEVEL_LEAVE:
00428         dnd_message->data.top.src_window = dnd_data->src_window ;
00429         dnd_message->data.top.property = dnd_data->property ;
00430         break ; /* cannot fall thru since the byte layout is different in
00431                    both set of messages, see top and pot union stuff */
00432 
00433     case DND_DRAG_MOTION:
00434     case DND_OPERATION_CHANGED:
00435     case DND_DROP_SITE_ENTER:
00436     case DND_DROP_START:
00437         dnd_message->data.pot.x = dnd_data->x ; /* mouse position */
00438         dnd_message->data.pot.y = dnd_data->y ;
00439         dnd_message->data.pot.src_window = dnd_data->src_window ;
00440         dnd_message->data.pot.property = dnd_data->property ;
00441         break ;
00442     default:
00443         break ;
00444     }
00445 
00446 }

Here is the call graph for this function:

Qt::DropActions DndOperationsToQtDropActions ( uchar  op  ) 

Definition at line 111 of file qmotifdnd_x11.cpp.

References Qt::CopyAction, DND_COPY, DND_LINK, DND_MOVE, Qt::IgnoreAction, Qt::LinkAction, and Qt::MoveAction.

Referenced by QX11Data::motifdndHandle().

00112 {
00113     Qt::DropActions actions = Qt::IgnoreAction;
00114     if (op | DND_MOVE)
00115         actions |= Qt::MoveAction;
00116     if (op | DND_COPY)
00117         actions |= Qt::CopyAction;
00118     if (op | DND_LINK)
00119         actions |= Qt::LinkAction;
00120     return actions;
00121 }

static Bool DndParseClientMessage ( XClientMessageEvent *  cm,
DndData dnd_data,
char *  receiver 
) [static]

Definition at line 448 of file qmotifdnd_x11.cpp.

References ATOM, _DndMessage::byte_order, DndData::completion, _DndMessage::data, DND_CLEAR_EVENT_TYPE, DND_DRAG_MOTION, DND_DROP_SITE_ENTER, DND_DROP_SITE_LEAVE, DND_DROP_START, DND_GET_COMPLETION, DND_GET_EVENT_TYPE, DND_GET_OPERATION, DND_GET_OPERATIONS, DND_GET_STATUS, DND_OPERATION_CHANGED, DND_TOP_LEVEL_ENTER, DND_TOP_LEVEL_LEAVE, DndByteOrder(), _DndMessage::flags, DndData::operation, DndData::operations, _DndMessage::pot, DndData::property, _DndTop::property, _DndPot::property, _DndMessage::reason, DndData::reason, _DndPot::src_window, DndData::src_window, _DndTop::src_window, DndData::status, SWAP2BYTES, SWAP4BYTES, DndData::time, _DndMessage::time, _DndMessage::top, DndData::x, _DndPot::x, DndData::y, and _DndPot::y.

Referenced by QX11Data::motifdndHandle().

00450 {
00451     DndMessage * dnd_message = (DndMessage*)&cm->data.b[0] ;
00452 
00453     if (cm->message_type != ATOM(_MOTIF_DRAG_AND_DROP_MESSAGE)) {
00454         return False ;
00455     }
00456 
00457     if (dnd_message->byte_order != DndByteOrder()) {
00458         SWAP2BYTES(dnd_message->flags);
00459         SWAP4BYTES(dnd_message->time);
00460     } /* do the rest in the switch */
00461 
00462     dnd_data->reason = dnd_message->reason  ;
00463     if (DND_GET_EVENT_TYPE(dnd_data->reason))
00464         *receiver = 1 ;
00465     else
00466         *receiver = 0 ;
00467     dnd_data->reason &= DND_CLEAR_EVENT_TYPE ;
00468 
00469     dnd_data->time = dnd_message->time ;
00470 
00471     /* we're reading in more stuff that necessary. but who cares */
00472     dnd_data->status = DND_GET_STATUS(dnd_message->flags) ;
00473     dnd_data->operation = DND_GET_OPERATION(dnd_message->flags) ;
00474     dnd_data->operations = DND_GET_OPERATIONS(dnd_message->flags) ;
00475     dnd_data->completion = DND_GET_COMPLETION(dnd_message->flags) ;
00476 
00477     switch(dnd_data->reason) {
00478     case DND_TOP_LEVEL_ENTER:
00479     case DND_TOP_LEVEL_LEAVE:
00480         if (dnd_message->byte_order != DndByteOrder()) {
00481             SWAP4BYTES(dnd_message->data.top.src_window);
00482             SWAP4BYTES(dnd_message->data.top.property);
00483         }
00484         dnd_data->src_window = dnd_message->data.top.src_window ;
00485         dnd_data->property = dnd_message->data.top.property ;
00486         break ; /* cannot fall thru, see above comment in write msg */
00487 
00488     case DND_DRAG_MOTION:
00489     case DND_OPERATION_CHANGED:
00490     case DND_DROP_SITE_ENTER:
00491     case DND_DROP_START:
00492         if (dnd_message->byte_order != DndByteOrder()) {
00493             SWAP2BYTES(dnd_message->data.pot.x);
00494             SWAP2BYTES(dnd_message->data.pot.y);
00495             SWAP4BYTES(dnd_message->data.pot.property);
00496             SWAP4BYTES(dnd_message->data.pot.src_window);
00497         }
00498         dnd_data->x = dnd_message->data.pot.x ;
00499         dnd_data->y = dnd_message->data.pot.y ;
00500         dnd_data->property = dnd_message->data.pot.property ;
00501         dnd_data->src_window = dnd_message->data.pot.src_window ;
00502         break ;
00503 
00504     case DND_DROP_SITE_LEAVE:
00505         break;
00506     default:
00507         break ;
00508     }
00509 
00510     return True ;
00511 }

Here is the call graph for this function:

static void DndReadSourceProperty ( Display dpy,
Window  window,
Atom  dnd_selection,
Atom **  targets,
unsigned short *  num_targets 
) [static]

Definition at line 336 of file qmotifdnd_x11.cpp.

References _DndIndexToTargets(), ATOM, DndByteOrder(), L, Success, SWAP2BYTES, SWAP4BYTES, type, and XNone.

Referenced by QX11Data::motifdndHandle().

00339 {
00340     DndSrcProp * src_prop = 0;
00341     Atom type ;
00342     int format ;
00343     unsigned long bytesafter, lengthRtn;
00344 
00345     if ((XGetWindowProperty (dpy, window, dnd_selection, 0L, 100000L,
00346                              False, ATOM(_MOTIF_DRAG_INITIATOR_INFO), &type,
00347                              &format, &lengthRtn, &bytesafter,
00348                              (unsigned char **) &src_prop) != Success)
00349         || (type == XNone)) {
00350         *num_targets = 0;
00351         return ;
00352     }
00353 
00354     if (src_prop->byte_order != DndByteOrder()) {
00355         SWAP2BYTES(src_prop->target_index);
00356         SWAP4BYTES(src_prop->selection);
00357     }
00358 
00359     *num_targets = _DndIndexToTargets(dpy, src_prop->target_index, targets);
00360 
00361     XFree((char*)src_prop);
00362 }

Here is the call graph for this function:

static void DndWriteReceiverProperty ( Display dpy,
Window  window,
unsigned char  protocol_style 
) [static]

Definition at line 368 of file qmotifdnd_x11.cpp.

References ATOM, _DndReceiverProp::byte_order, DND_PROTOCOL_VERSION, DndByteOrder(), _DndReceiverProp::num_drop_sites, _DndReceiverProp::protocol_style, _DndReceiverProp::protocol_version, _DndReceiverProp::proxy_window, _DndReceiverProp::total_size, and XNone.

Referenced by QX11Data::motifdndEnable().

00370 {
00371     DndReceiverProp receiver_prop ;
00372 
00373     receiver_prop.byte_order = DndByteOrder() ;
00374     receiver_prop.protocol_version = DND_PROTOCOL_VERSION;
00375     receiver_prop.protocol_style = protocol_style ;
00376     receiver_prop.proxy_window =  XNone ;
00377     receiver_prop.num_drop_sites = 0 ;
00378     receiver_prop.total_size = sizeof(DndReceiverProp);
00379 
00380     /* write the buffer to the property */
00381     XChangeProperty (dpy, window, ATOM(_MOTIF_DRAG_RECEIVER_INFO), ATOM(_MOTIF_DRAG_RECEIVER_INFO),
00382                      8, PropModeReplace,
00383                      (unsigned char *)&receiver_prop,
00384                      sizeof(DndReceiverProp));
00385 }

Here is the call graph for this function:

static Window MotifWindow ( Display display  )  [static]

Definition at line 514 of file qmotifdnd_x11.cpp.

References ATOM, L, size, Success, type, and XNone.

Referenced by TargetsTable().

00515 {
00516     Atom            type;
00517     int             format;
00518     unsigned long   size;
00519     unsigned long   bytes_after;
00520     Window         *property = 0;
00521     Window            motif_window ;
00522 
00523     /* this version does no caching, so it's slow: round trip each time */
00524 
00525     if ((XGetWindowProperty (display, DefaultRootWindow(display),
00526                              ATOM(_MOTIF_DRAG_WINDOW),
00527                              0L, 100000L, False, AnyPropertyType,
00528                              &type, &format, &size, &bytes_after,
00529                              (unsigned char **) &property) == Success) &&
00530         (type != XNone)) {
00531         motif_window = *property;
00532     } else {
00533         XSetWindowAttributes sAttributes;
00534 
00535         /* really, this should be done on a separate connection,
00536            with XSetCloseDownMode (RetainPermanent), so that
00537            others don't have to recreate it; hopefully, some real
00538            Motif application will be around to do it */
00539 
00540         sAttributes.override_redirect = True;
00541         sAttributes.event_mask = PropertyChangeMask;
00542         motif_window = XCreateWindow (display,
00543                                       DefaultRootWindow (display),
00544                                       -170, -560, 1, 1, 0, 0,
00545                                       InputOnly, CopyFromParent,
00546                                       (CWOverrideRedirect |CWEventMask),
00547                                       &sAttributes);
00548         XMapWindow (display, motif_window);
00549     }
00550 
00551     if (property) {
00552         XFree ((char *)property);
00553     }
00554 
00555     return (motif_window);
00556 }

void qt_x11_intern_atom ( const char *  ,
Atom *   
)

uchar QtDropActionToDndOperation ( Qt::DropAction  action  ) 

Definition at line 123 of file qmotifdnd_x11.cpp.

References Qt::ActionMask, Qt::CopyAction, DND_COPY, DND_LINK, DND_MOVE, Qt::LinkAction, and Qt::MoveAction.

Referenced by QX11Data::motifdndHandle().

00124 {
00125     switch (action & Qt::ActionMask) {
00126     case Qt::CopyAction:
00127     default:
00128         return DND_COPY;
00129     case Qt::MoveAction:
00130         return DND_MOVE;
00131     case Qt::LinkAction:
00132         return DND_LINK;
00133     }
00134 }

static DndTargetsTable TargetsTable ( Display display  )  [static]

Definition at line 559 of file qmotifdnd_x11.cpp.

References ATOM, CARD16, CARD32, DND_PROTOCOL_VERSION, DndByteOrder(), DndTargetsTableRec::entries, i, j, L, MotifWindow(), DndTargetsTableRec::num_entries, DndTargetsTableEntryRec::num_targets, qWarning(), size, Success, SWAP2BYTES, SWAP4BYTES, DndTargetsTableEntryRec::targets, type, and XNone.

Referenced by _DndIndexToTargets().

00560 {
00561     Atom            type;
00562     int             format;
00563     unsigned long   size;
00564     unsigned long   bytes_after;
00565     Window motif_window = MotifWindow(display) ;
00566     DndTargets * target_prop;
00567     DndTargetsTable targets_table ;
00568     int i,j ;
00569     char * target_data ;
00570 
00571     /* this version does no caching, so it's slow: round trip each time */
00572     /* ideally, register for property notify on this target_list
00573        atom and update when necessary only */
00574 
00575     if ((XGetWindowProperty (display, motif_window,
00576                              ATOM(_MOTIF_DRAG_TARGETS), 0L, 100000L,
00577                              False, ATOM(_MOTIF_DRAG_TARGETS),
00578                              &type, &format, &size, &bytes_after,
00579                              (unsigned char **) &target_prop) != Success) ||
00580         type == XNone) {
00581         qWarning("QMotifDND: Cannot get property on Motif window");
00582         return 0;
00583     }
00584 
00585     if (target_prop->protocol_version != DND_PROTOCOL_VERSION) {
00586         qWarning("QMotifDND: Protocol mismatch");
00587     }
00588 
00589     if (target_prop->byte_order != DndByteOrder()) {
00590         /* need to swap num_target_lists and size */
00591         SWAP2BYTES(target_prop->num_target_lists);
00592         SWAP4BYTES(target_prop->data_size);
00593     }
00594 
00595     /* now parse DndTarget prop data in a TargetsTable */
00596 
00597     targets_table = (DndTargetsTable)malloc(sizeof(DndTargetsTableRec));
00598     targets_table->num_entries = target_prop->num_target_lists ;
00599     targets_table->entries = (DndTargetsTableEntry)
00600                              malloc(sizeof(DndTargetsTableEntryRec) * target_prop->num_target_lists);
00601 
00602     target_data = (char*)target_prop + sizeof(*target_prop) ;
00603 
00604     for (i = 0 ; i < targets_table->num_entries; i++) {
00605         CARD16 num_targets ;
00606         CARD32 atom ;
00607 
00608         memcpy(&num_targets, target_data, 2);
00609         target_data += 2;
00610 
00611         /* potential swap needed here */
00612         if (target_prop->byte_order != DndByteOrder())
00613             SWAP2BYTES(num_targets);
00614 
00615         targets_table->entries[i].num_targets = num_targets ;
00616         targets_table->entries[i].targets = (Atom *)
00617                                             malloc(sizeof(Atom) * targets_table->entries[i].num_targets);
00618 
00619 
00620         for (j = 0; j < num_targets; j++) {
00621             memcpy(&atom, target_data, 4);
00622             target_data += 4;
00623 
00624             /* another potential swap needed here */
00625             if (target_prop->byte_order != DndByteOrder())
00626                 SWAP4BYTES(atom);
00627 
00628             targets_table->entries[i].targets[j] = (Atom) atom ;
00629         }
00630     }
00631 
00632     if (target_prop) {
00633         XFree((char *)target_prop);
00634     }
00635 
00636     return targets_table ;
00637 }

Here is the call graph for this function:


Variable Documentation

Atom Dnd_selection = 0 [static]

Definition at line 78 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle(), and QX11Data::motifdndObtainData().

Time Dnd_selection_time [static]

Definition at line 79 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle(), and QX11Data::motifdndObtainData().

QWidget* dropWidget = 0 [static]

Definition at line 70 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle(), and QX11Data::motifdndObtainData().

Qt::DropAction lastAcceptedAction = Qt::IgnoreAction [static]

Definition at line 71 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

ushort num_src_targets [static]

Definition at line 82 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndFormat(), and QX11Data::motifdndHandle().

Window sourceWindow = XNone [static]

Definition at line 69 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

Atom* src_targets [static]

Definition at line 81 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndFormat(), and QX11Data::motifdndHandle().


Generated on Thu Mar 15 13:28:15 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1