Qt 4.8
Classes | Macros | Typedefs | Functions | Variables
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>

Go to the source code of this file.

Classes

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

Macros

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

Typedefs

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

Functions

static ushort _DndIndexToTargets (Display *display, int index, Atom **targets)
 
static unsigned char DndByteOrder ()
 
static void DndFillClientMessage (Display *dpy, Window window, XClientMessageEvent *cm, DndData *dnd_data, char receiver)
 
static Qt::DropActions DndOperationsToQtDropActions (uchar op)
 
static Bool DndParseClientMessage (XClientMessageEvent *cm, DndData *dnd_data, char *receiver)
 
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 Window MotifWindow (Display *display)
 
void qt_x11_intern_atom (const char *, Atom *)
 
static uchar QtDropActionToDndOperation (Qt::DropAction action)
 
static DndTargetsTable TargetsTable (Display *display)
 

Variables

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

Macro Definition Documentation

◆ BYTE

#define BYTE   unsigned char

◆ CARD16

#define CARD16   unsigned short

Definition at line 164 of file qmotifdnd_x11.cpp.

Referenced by TargetsTable().

◆ CARD32

#define CARD32   unsigned int

Definition at line 163 of file qmotifdnd_x11.cpp.

Referenced by TargetsTable().

◆ DND_CLEAR_EVENT_TYPE

#define DND_CLEAR_EVENT_TYPE   ((BYTE)0x7F)

Definition at line 240 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

◆ DND_COMPLETION_MASK

#define DND_COMPLETION_MASK   ((CARD16) 0xF000)

Definition at line 258 of file qmotifdnd_x11.cpp.

◆ DND_COMPLETION_SHIFT

#define DND_COMPLETION_SHIFT   12

Definition at line 259 of file qmotifdnd_x11.cpp.

◆ DND_COPY

#define DND_COPY   (1L << 1)

Definition at line 123 of file qmotifdnd_x11.cpp.

Referenced by DndOperationsToQtDropActions(), and QtDropActionToDndOperation().

◆ DND_DRAG_DROP_ONLY

#define DND_DRAG_DROP_ONLY   1

Definition at line 108 of file qmotifdnd_x11.cpp.

◆ DND_DRAG_DROP_ONLY_EQUIV

#define DND_DRAG_DROP_ONLY_EQUIV   3

Definition at line 409 of file qmotifdnd_x11.cpp.

◆ DND_DRAG_DYNAMIC

#define DND_DRAG_DYNAMIC   5

Definition at line 109 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndEnable().

◆ DND_DRAG_DYNAMIC_EQUIV1

#define DND_DRAG_DYNAMIC_EQUIV1   2

Definition at line 410 of file qmotifdnd_x11.cpp.

◆ DND_DRAG_DYNAMIC_EQUIV2

#define DND_DRAG_DYNAMIC_EQUIV2   4

Definition at line 411 of file qmotifdnd_x11.cpp.

◆ DND_DRAG_MOTION

#define DND_DRAG_MOTION   2

◆ DND_DRAG_NONE

#define DND_DRAG_NONE   0

Definition at line 107 of file qmotifdnd_x11.cpp.

◆ DND_DROP

#define DND_DROP   0

Definition at line 158 of file qmotifdnd_x11.cpp.

◆ DND_DROP_CANCEL

#define DND_DROP_CANCEL   2

Definition at line 160 of file qmotifdnd_x11.cpp.

◆ DND_DROP_HELP

#define DND_DROP_HELP   1

Definition at line 159 of file qmotifdnd_x11.cpp.

◆ DND_DROP_SITE_ENTER

#define DND_DROP_SITE_ENTER   3

◆ DND_DROP_SITE_LEAVE

#define DND_DROP_SITE_LEAVE   4

◆ DND_DROP_START

#define DND_DROP_START   5

◆ DND_EVENT_TYPE_MASK

#define DND_EVENT_TYPE_MASK   ((BYTE)0x80)

Definition at line 238 of file qmotifdnd_x11.cpp.

◆ DND_EVENT_TYPE_SHIFT

#define DND_EVENT_TYPE_SHIFT   7

Definition at line 239 of file qmotifdnd_x11.cpp.

◆ DND_GET_COMPLETION

#define DND_GET_COMPLETION (   flags)
Value:
((unsigned char) \
#define DND_COMPLETION_MASK
#define DND_COMPLETION_SHIFT

Definition at line 285 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

◆ DND_GET_EVENT_TYPE

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

Definition at line 244 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

◆ DND_GET_OPERATION

#define DND_GET_OPERATION (   flags)
Value:
((unsigned char) \
#define DND_OPERATION_SHIFT
#define DND_OPERATION_MASK

Definition at line 261 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

◆ DND_GET_OPERATIONS

#define DND_GET_OPERATIONS (   flags)
Value:
((unsigned char) \
#define DND_OPERATIONS_MASK
#define DND_OPERATIONS_SHIFT

Definition at line 277 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

◆ DND_GET_STATUS

#define DND_GET_STATUS (   flags)
Value:
((unsigned char) \
#define DND_STATUS_MASK
#define DND_STATUS_SHIFT

Definition at line 269 of file qmotifdnd_x11.cpp.

Referenced by DndParseClientMessage().

◆ DND_INVALID_DROP_SITE

#define DND_INVALID_DROP_SITE   2

Definition at line 154 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

◆ DND_LINK

#define DND_LINK   (1L << 2)

Definition at line 124 of file qmotifdnd_x11.cpp.

Referenced by DndOperationsToQtDropActions(), and QtDropActionToDndOperation().

◆ DND_MOVE

#define DND_MOVE   (1L << 0)

Definition at line 122 of file qmotifdnd_x11.cpp.

Referenced by DndOperationsToQtDropActions(), and QtDropActionToDndOperation().

◆ DND_NO_DROP_SITE

#define DND_NO_DROP_SITE   1

Definition at line 153 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

◆ DND_NOOP

#define DND_NOOP   0L

Definition at line 121 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

◆ DND_OPERATION_CHANGED

#define DND_OPERATION_CHANGED   8

◆ DND_OPERATION_MASK

#define DND_OPERATION_MASK   ((CARD16) 0x000F)

Definition at line 252 of file qmotifdnd_x11.cpp.

◆ DND_OPERATION_SHIFT

#define DND_OPERATION_SHIFT   0

Definition at line 253 of file qmotifdnd_x11.cpp.

◆ DND_OPERATIONS_MASK

#define DND_OPERATIONS_MASK   ((CARD16) 0x0F00)

Definition at line 256 of file qmotifdnd_x11.cpp.

◆ DND_OPERATIONS_SHIFT

#define DND_OPERATIONS_SHIFT   8

Definition at line 257 of file qmotifdnd_x11.cpp.

◆ DND_PROTOCOL_VERSION

#define DND_PROTOCOL_VERSION   0

Definition at line 235 of file qmotifdnd_x11.cpp.

Referenced by DndWriteReceiverProperty(), and TargetsTable().

◆ DND_SET_COMPLETION

#define DND_SET_COMPLETION (   completion)
Value:
(((CARD16)(completion) << DND_COMPLETION_SHIFT)\
#define CARD16
#define DND_COMPLETION_MASK
#define DND_COMPLETION_SHIFT

Definition at line 289 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

◆ DND_SET_EVENT_TYPE

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

Definition at line 248 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

◆ DND_SET_OPERATION

#define DND_SET_OPERATION (   operation)
Value:
(((CARD16)(operation) << DND_OPERATION_SHIFT)\
#define DND_OPERATION_SHIFT
#define DND_OPERATION_MASK
#define CARD16

Definition at line 265 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

◆ DND_SET_OPERATIONS

#define DND_SET_OPERATIONS (   operation)
Value:
(((CARD16)(operation) << DND_OPERATIONS_SHIFT)\
#define DND_OPERATIONS_MASK
#define DND_OPERATIONS_SHIFT
#define CARD16

Definition at line 281 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

◆ DND_SET_STATUS

#define DND_SET_STATUS (   status)
Value:
#define DND_STATUS_MASK
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
#define DND_STATUS_SHIFT
#define CARD16

Definition at line 273 of file qmotifdnd_x11.cpp.

Referenced by DndFillClientMessage().

◆ DND_STATUS_MASK

#define DND_STATUS_MASK   ((CARD16) 0x00F0)

Definition at line 254 of file qmotifdnd_x11.cpp.

◆ DND_STATUS_SHIFT

#define DND_STATUS_SHIFT   4

Definition at line 255 of file qmotifdnd_x11.cpp.

◆ DND_TOP_LEVEL_ENTER

#define DND_TOP_LEVEL_ENTER   0

◆ DND_TOP_LEVEL_LEAVE

#define DND_TOP_LEVEL_LEAVE   1

◆ DND_VALID_DROP_SITE

#define DND_VALID_DROP_SITE   3

Definition at line 155 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

◆ DndIncludeVersion

#define DndIncludeVersion   (DndVersion * 10 + DndRevision)

Definition at line 102 of file qmotifdnd_x11.cpp.

◆ DndRevision

#define DndRevision   0

Definition at line 101 of file qmotifdnd_x11.cpp.

◆ DndVersion

#define DndVersion   1

Definition at line 100 of file qmotifdnd_x11.cpp.

◆ INT16

#define INT16   signed short

Definition at line 165 of file qmotifdnd_x11.cpp.

◆ SWAP2BYTES

#define SWAP2BYTES (   s)
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 303 of file qmotifdnd_x11.cpp.

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

◆ SWAP4BYTES

#define SWAP4BYTES (   l)
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;\
}
QFactoryLoader * l

Definition at line 294 of file qmotifdnd_x11.cpp.

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

Typedef Documentation

◆ DndMessage

typedef struct _DndMessage DndMessage

◆ DndPot

typedef struct _DndPot DndPot

◆ DndReceiverProp

◆ DndSrcProp

typedef struct _DndSrcProp DndSrcProp

◆ DndTargetsTable

◆ DndTargetsTableEntry

◆ DndTop

typedef struct _DndTop DndTop

Function Documentation

◆ _DndIndexToTargets()

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

Definition at line 662 of file qmotifdnd_x11.cpp.

Referenced by DndReadSourceProperty().

665 {
666  DndTargetsTable targets_table;
667  int i ;
668 
669  /* again, slow: no caching here, alloc/free each time */
670 
671  if (!(targets_table = TargetsTable (display)) ||
672  (index >= targets_table->num_entries)) {
673  if (targets_table)
674  XFree((char*)targets_table);
675  return 0;
676  }
677 
678  /* transfer the correct target list index */
679  *targets = (Atom*)malloc(sizeof(Atom)*targets_table->
680  entries[index].num_targets);
681  memcpy((char*)*targets,
682  (char*)targets_table->entries[index].targets,
683  sizeof(Atom)*targets_table->entries[index].num_targets);
684 
685  /* free the target table and its guts */
686  for (i=0 ; i < targets_table->num_entries; i++)
687  XFree((char*)targets_table->entries[i].targets);
688 
689  int tmp = targets_table->entries[index].num_targets;
690  XFree((char*)targets_table);
691 
692  return tmp; // targets_table->entries[index].num_targets;
693 }
DndTargetsTableEntry entries
static DndTargetsTable TargetsTable(Display *display)
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static const MacSpecialKey entries[NumEntries]
quint16 index

◆ DndByteOrder()

static unsigned char DndByteOrder ( )
static

Private extern functions

Definition at line 338 of file qmotifdnd_x11.cpp.

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

339 {
340  static unsigned char byte_order = 0;
341 
342  if (!byte_order) {
343  unsigned int endian = 1;
344  byte_order = (*((char *)&endian))?'l':'B';
345  }
346  return byte_order ;
347 }

◆ DndFillClientMessage()

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

Definition at line 415 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

419 {
420  DndMessage * dnd_message = (DndMessage*)&cm->data.b[0] ;
421 
422  cm->display = dpy;
423  cm->type = ClientMessage;
424  cm->serial = LastKnownRequestProcessed(dpy);
425  cm->send_event = True;
426  cm->window = window;
427  cm->format = 8;
428  cm->message_type = ATOM(_MOTIF_DRAG_AND_DROP_MESSAGE);
429 
430  dnd_message->reason = dnd_data->reason | DND_SET_EVENT_TYPE(receiver);
431 
432  dnd_message->byte_order = DndByteOrder();
433 
434  /* we're filling in flags with more stuff that necessary,
435  depending on the reason, but it doesn't matter */
436  dnd_message->flags = 0 ;
437  dnd_message->flags |= DND_SET_STATUS(dnd_data->status) ;
438  dnd_message->flags |= DND_SET_OPERATION(dnd_data->operation) ;
439  dnd_message->flags |= DND_SET_OPERATIONS(dnd_data->operations) ;
440  dnd_message->flags |= DND_SET_COMPLETION(dnd_data->completion) ;
441 
442  dnd_message->time = dnd_data->time ;
443 
444  switch(dnd_data->reason) {
445  case DND_DROP_SITE_LEAVE: break ;
446  case DND_TOP_LEVEL_ENTER:
447  case DND_TOP_LEVEL_LEAVE:
448  dnd_message->data.top.src_window = dnd_data->src_window ;
449  dnd_message->data.top.property = dnd_data->property ;
450  break ; /* cannot fall through since the byte layout is different in
451  both set of messages, see top and pot union stuff */
452 
453  case DND_DRAG_MOTION:
455  case DND_DROP_SITE_ENTER:
456  case DND_DROP_START:
457  dnd_message->data.pot.x = dnd_data->x ; /* mouse position */
458  dnd_message->data.pot.y = dnd_data->y ;
459  dnd_message->data.pot.src_window = dnd_data->src_window ;
460  dnd_message->data.pot.property = dnd_data->property ;
461  break ;
462  default:
463  break ;
464  }
465 
466 }
#define DND_DROP_SITE_ENTER
#define DND_SET_EVENT_TYPE(event_type)
#define DND_SET_OPERATION(operation)
Window src_window
#define DND_OPERATION_CHANGED
static unsigned char DndByteOrder()
#define ATOM(x)
Definition: qt_x11_p.h:723
#define DND_TOP_LEVEL_LEAVE
NSWindow * window
CARD32 src_window
unsigned char operation
#define DND_DROP_START
#define DND_SET_STATUS(status)
#define DND_SET_COMPLETION(completion)
CARD32 src_window
#define DND_SET_OPERATIONS(operation)
unsigned char reason
#define DND_TOP_LEVEL_ENTER
unsigned char status
unsigned char completion
#define DND_DROP_SITE_LEAVE
CARD32 property
#define DND_DRAG_MOTION
union _DndMessage::@205 data
CARD32 property
unsigned char operations

◆ DndOperationsToQtDropActions()

static Qt::DropActions DndOperationsToQtDropActions ( uchar  op)
static

Definition at line 126 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

127 {
128  Qt::DropActions actions = Qt::IgnoreAction;
129  if (op | DND_MOVE)
130  actions |= Qt::MoveAction;
131  if (op | DND_COPY)
132  actions |= Qt::CopyAction;
133  if (op | DND_LINK)
134  actions |= Qt::LinkAction;
135  return actions;
136 }
#define DND_COPY
#define DND_MOVE
#define DND_LINK

◆ DndParseClientMessage()

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

Definition at line 468 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

470 {
471  DndMessage * dnd_message = (DndMessage*)&cm->data.b[0] ;
472 
473  if (cm->message_type != ATOM(_MOTIF_DRAG_AND_DROP_MESSAGE)) {
474  return False ;
475  }
476 
477  if (dnd_message->byte_order != DndByteOrder()) {
478  SWAP2BYTES(dnd_message->flags);
479  SWAP4BYTES(dnd_message->time);
480  } /* do the rest in the switch */
481 
482  dnd_data->reason = dnd_message->reason ;
483  if (DND_GET_EVENT_TYPE(dnd_data->reason))
484  *receiver = 1 ;
485  else
486  *receiver = 0 ;
487  dnd_data->reason &= DND_CLEAR_EVENT_TYPE ;
488 
489  dnd_data->time = dnd_message->time ;
490 
491  /* we're reading in more stuff that necessary. but who cares */
492  dnd_data->status = DND_GET_STATUS(dnd_message->flags) ;
493  dnd_data->operation = DND_GET_OPERATION(dnd_message->flags) ;
494  dnd_data->operations = DND_GET_OPERATIONS(dnd_message->flags) ;
495  dnd_data->completion = DND_GET_COMPLETION(dnd_message->flags) ;
496 
497  switch(dnd_data->reason) {
498  case DND_TOP_LEVEL_ENTER:
499  case DND_TOP_LEVEL_LEAVE:
500  if (dnd_message->byte_order != DndByteOrder()) {
501  SWAP4BYTES(dnd_message->data.top.src_window);
502  SWAP4BYTES(dnd_message->data.top.property);
503  }
504  dnd_data->src_window = dnd_message->data.top.src_window ;
505  dnd_data->property = dnd_message->data.top.property ;
506  break ; /* cannot fall through, see above comment in write msg */
507 
508  case DND_DRAG_MOTION:
510  case DND_DROP_SITE_ENTER:
511  case DND_DROP_START:
512  if (dnd_message->byte_order != DndByteOrder()) {
513  SWAP2BYTES(dnd_message->data.pot.x);
514  SWAP2BYTES(dnd_message->data.pot.y);
515  SWAP4BYTES(dnd_message->data.pot.property);
516  SWAP4BYTES(dnd_message->data.pot.src_window);
517  }
518  dnd_data->x = dnd_message->data.pot.x ;
519  dnd_data->y = dnd_message->data.pot.y ;
520  dnd_data->property = dnd_message->data.pot.property ;
521  dnd_data->src_window = dnd_message->data.pot.src_window ;
522  break ;
523 
524  case DND_DROP_SITE_LEAVE:
525  break;
526  default:
527  break ;
528  }
529 
530  return True ;
531 }
#define DND_DROP_SITE_ENTER
Window src_window
#define DND_OPERATION_CHANGED
#define SWAP2BYTES(s)
#define DND_GET_COMPLETION(flags)
#define DND_GET_OPERATION(flags)
static unsigned char DndByteOrder()
#define ATOM(x)
Definition: qt_x11_p.h:723
#define DND_TOP_LEVEL_LEAVE
CARD32 src_window
unsigned char operation
#define DND_DROP_START
#define DND_GET_STATUS(flags)
CARD32 src_window
#define DND_GET_OPERATIONS(flags)
unsigned char reason
#define DND_TOP_LEVEL_ENTER
unsigned char status
if(void) toggleToolbarShown
unsigned char completion
#define DND_CLEAR_EVENT_TYPE
#define DND_DROP_SITE_LEAVE
#define DND_GET_EVENT_TYPE(message_type)
CARD32 property
#define SWAP4BYTES(l)
#define DND_DRAG_MOTION
union _DndMessage::@205 data
CARD32 property
unsigned char operations

◆ DndReadSourceProperty()

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

Definition at line 351 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

354 {
355  unsigned char *retval = 0;
356  Atom type ;
357  int format ;
358  unsigned long bytesafter, lengthRtn;
359 
360  if ((XGetWindowProperty (dpy, window, dnd_selection, 0L, 100000L,
361  False, ATOM(_MOTIF_DRAG_INITIATOR_INFO), &type,
362  &format, &lengthRtn, &bytesafter,
363  &retval) != Success)
364  || (type == XNone)) {
365  *num_targets = 0;
366  return ;
367  }
368 
369  DndSrcProp * src_prop = (DndSrcProp *)retval;
370 
371  if (src_prop->byte_order != DndByteOrder()) {
372  SWAP2BYTES(src_prop->target_index);
373  SWAP4BYTES(src_prop->selection);
374  }
375 
376  *num_targets = _DndIndexToTargets(dpy, src_prop->target_index, targets);
377 
378  XFree((char*)src_prop);
379 }
int type
Definition: qmetatype.cpp:239
#define SWAP2BYTES(s)
static unsigned char DndByteOrder()
#define ATOM(x)
Definition: qt_x11_p.h:723
NSWindow * window
static ushort _DndIndexToTargets(Display *display, int index, Atom **targets)
return(isPopup||isToolTip)
#define SWAP4BYTES(l)
CARD16 target_index

◆ DndWriteReceiverProperty()

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

Definition at line 385 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndEnable().

387 {
388  DndReceiverProp receiver_prop;
389 
390  // squelch potential valgrind errors about uninitialized reads
391  memset(&receiver_prop, 0, sizeof(receiver_prop));
392 
393  receiver_prop.byte_order = DndByteOrder() ;
394  receiver_prop.protocol_version = DND_PROTOCOL_VERSION;
395  receiver_prop.protocol_style = protocol_style ;
396  receiver_prop.proxy_window = XNone ;
397  receiver_prop.num_drop_sites = 0 ;
398  receiver_prop.total_size = sizeof(DndReceiverProp);
399 
400  /* write the buffer to the property */
402  8, PropModeReplace,
403  (unsigned char *)&receiver_prop,
404  sizeof(DndReceiverProp));
405 }
static unsigned char DndByteOrder()
#define ATOM(x)
Definition: qt_x11_p.h:723
NSWindow * window
#define DND_PROTOCOL_VERSION
struct _DndReceiverProp DndReceiverProp

◆ MotifWindow()

static Window MotifWindow ( Display display)
static

Definition at line 534 of file qmotifdnd_x11.cpp.

Referenced by TargetsTable().

535 {
536  Atom type;
537  int format;
538  unsigned long size;
539  unsigned long bytes_after;
540  unsigned char *property = 0;
541  Window motif_window ;
542 
543  /* this version does no caching, so it's slow: round trip each time */
544 
545  if ((XGetWindowProperty (display, RootWindow(display, 0),
547  0L, 100000L, False, AnyPropertyType,
548  &type, &format, &size, &bytes_after,
549  &property) == Success) &&
550  (type != XNone)) {
551  motif_window = *(Window *)property;
552  } else {
553  XSetWindowAttributes sAttributes;
554 
555  /* really, this should be done on a separate connection,
556  with XSetCloseDownMode (RetainPermanent), so that
557  others don't have to recreate it; hopefully, some real
558  Motif application will be around to do it */
559 
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),
567  &sAttributes);
568  XMapWindow (display, motif_window);
569  }
570 
571  if (property) {
572  XFree ((char *)property);
573  }
574 
575  return (motif_window);
576 }
int type
Definition: qmetatype.cpp:239
#define ATOM(x)
Definition: qt_x11_p.h:723
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
const char * property
Definition: qwizard.cpp:138

◆ qt_x11_intern_atom()

void qt_x11_intern_atom ( const char *  ,
Atom *   
)

◆ QtDropActionToDndOperation()

static uchar QtDropActionToDndOperation ( Qt::DropAction  action)
static

Definition at line 138 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

139 {
140  switch (action & Qt::ActionMask) {
141  case Qt::CopyAction:
142  default:
143  return DND_COPY;
144  case Qt::MoveAction:
145  return DND_MOVE;
146  case Qt::LinkAction:
147  return DND_LINK;
148  }
149 }
#define DND_COPY
#define DND_MOVE
#define DND_LINK

◆ TargetsTable()

static DndTargetsTable TargetsTable ( Display display)
static

Definition at line 579 of file qmotifdnd_x11.cpp.

Referenced by _DndIndexToTargets().

580 {
581  Atom type;
582  int format;
583  unsigned long size;
584  unsigned long bytes_after;
585  Window motif_window = MotifWindow(display) ;
586  unsigned char *retval;
587  DndTargetsTable targets_table ;
588  int i,j ;
589  char * target_data ;
590 
591  /* this version does no caching, so it's slow: round trip each time */
592  /* ideally, register for property notify on this target_list
593  atom and update when necessary only */
594 
595  if ((XGetWindowProperty (display, motif_window,
596  ATOM(_MOTIF_DRAG_TARGETS), 0L, 100000L,
597  False, ATOM(_MOTIF_DRAG_TARGETS),
598  &type, &format, &size, &bytes_after,
599  &retval) != Success) ||
600  type == XNone) {
601  qWarning("QMotifDND: Cannot get property on Motif window");
602  return 0;
603  }
604 
605  DndTargets * target_prop = (DndTargets *)retval;
606 
607  if (target_prop->protocol_version != DND_PROTOCOL_VERSION) {
608  qWarning("QMotifDND: Protocol mismatch");
609  }
610 
611  if (target_prop->byte_order != DndByteOrder()) {
612  /* need to swap num_target_lists and size */
613  SWAP2BYTES(target_prop->num_target_lists);
614  SWAP4BYTES(target_prop->data_size);
615  }
616 
617  /* now parse DndTarget prop data in a TargetsTable */
618 
619  targets_table = (DndTargetsTable)malloc(sizeof(DndTargetsTableRec));
620  targets_table->num_entries = target_prop->num_target_lists ;
621  targets_table->entries = (DndTargetsTableEntry)
622  malloc(sizeof(DndTargetsTableEntryRec) * target_prop->num_target_lists);
623 
624  target_data = (char*)target_prop + sizeof(*target_prop) ;
625 
626  for (i = 0 ; i < targets_table->num_entries; i++) {
627  CARD16 num_targets ;
628  CARD32 atom ;
629 
630  memcpy(&num_targets, target_data, 2);
631  target_data += 2;
632 
633  /* potential swap needed here */
634  if (target_prop->byte_order != DndByteOrder())
635  SWAP2BYTES(num_targets);
636 
637  targets_table->entries[i].num_targets = num_targets ;
638  targets_table->entries[i].targets = (Atom *)
639  malloc(sizeof(Atom) * targets_table->entries[i].num_targets);
640 
641 
642  for (j = 0; j < num_targets; j++) {
643  memcpy(&atom, target_data, 4);
644  target_data += 4;
645 
646  /* another potential swap needed here */
647  if (target_prop->byte_order != DndByteOrder())
648  SWAP4BYTES(atom);
649 
650  targets_table->entries[i].targets[j] = (Atom) atom ;
651  }
652  }
653 
654  if (target_prop) {
655  XFree((char *)target_prop);
656  }
657 
658  return targets_table ;
659 }
int type
Definition: qmetatype.cpp:239
BYTE protocol_version
static Window MotifWindow(Display *display)
DndTargetsTableEntry entries
#define SWAP2BYTES(s)
static unsigned char DndByteOrder()
#define ATOM(x)
Definition: qt_x11_p.h:723
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
#define DND_PROTOCOL_VERSION
#define CARD16
Q_CORE_EXPORT void qWarning(const char *,...)
#define CARD32
#define SWAP4BYTES(l)
CARD32 data_size
CARD16 num_target_lists
struct DndTargetsTableEntryRec * DndTargetsTableEntry
struct DndTargetsTableRec * DndTargetsTable

Variable Documentation

◆ Dnd_selection

Atom Dnd_selection = 0
static

Definition at line 93 of file qmotifdnd_x11.cpp.

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

◆ Dnd_selection_time

Time Dnd_selection_time
static

Definition at line 94 of file qmotifdnd_x11.cpp.

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

◆ dropWidget

QWidget* dropWidget = 0
static

◆ lastAcceptedAction

Qt::DropAction lastAcceptedAction = Qt::IgnoreAction
static

Definition at line 91 of file qmotifdnd_x11.cpp.

Referenced by QX11Data::motifdndHandle().

◆ num_src_targets

ushort num_src_targets
static

Definition at line 97 of file qmotifdnd_x11.cpp.

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

◆ sourceWindow

Window sourceWindow = XNone
static

Definition at line 89 of file qmotifdnd_x11.cpp.

Referenced by QWidgetPrivate::frameStrut(), and QX11Data::motifdndHandle().

◆ src_targets

Atom* src_targets
static

Definition at line 96 of file qmotifdnd_x11.cpp.

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