17 #define ROOTDND_PROTOCOL_VERSION 4 18 #define XA_ATOM ((Atom_t) 4) 19 #define XA_WINDOW ((Atom_t) 33) 71 TGFrame(p, 32, 32, options, back)
202 fTypelist =
new Atom_t[3];
217 fTargetIsDNDAware =
kFALSE;
220 fAcceptedAction =
kNone;
221 fLocalAction =
kNone;
252 gVirtualX->DeleteProperty(fMain->GetId(), fgDNDAware);
253 gVirtualX->DeleteProperty(fMain->GetId(), fgDNDTypeList);
255 if (fDropTimeout)
delete fDropTimeout;
259 fDragWin->DeleteWindow();
265 if (fDraggerTypes)
delete[] fDraggerTypes;
266 if (fTypelist)
delete[] fTypelist;
316 fgDNDActionPrivate =
gVirtualX->InternAtom(
"XdndActionPrivate",
kFALSE);
321 fgDNDActionDescrip =
gVirtualX->InternAtom(
"XdndActionDescription",
kFALSE);
334 for (n = 0; a[
n]; n++) { }
343 return gVirtualX->IsDNDAware(win, typelist);
351 if (maxd <= 0)
return kNone;
353 if (fDragWin && fDragWin->HasWindow(root))
return kNone;
355 return gVirtualX->FindRWindow(root, fDragWin ? fDragWin->GetId() : 0,
356 fDragWin ? fDragWin->GetInputId() : 0,
369 unsigned char *
data = 0;
382 &actual, &format, &count, &remaining, &
data);
384 if ((actual == XA_WINDOW) && (format == 32) && (count > 0) &&
data) {
391 gVirtualX->GetProperty(win, fgDNDProxy, 0, 1, kFALSE, XA_WINDOW,
392 &actual, &format, &count, &remaining, &data);
397 if ((actual == XA_WINDOW) && (format == 32) && (count > 0) && data) {
405 if (data)
delete[]
data;
415 if (event->
fHandle == fgDNDEnter) {
419 }
else if (event->
fHandle == fgDNDLeave) {
422 }
else if (event->
fHandle == fgDNDPosition) {
429 }
else if (event->
fHandle == fgDNDStatus) {
431 skip.
fX = (
event->fUser[2] >> 16) & 0xFFFF;
432 skip.
fY = (
event->fUser[2] & 0xFFFF);
433 skip.
fWidth = (
event->fUser[3] >> 16) & 0xFFFF;
434 skip.
fHeight = (
event->fUser[3] & 0xFFFF);
440 }
else if (event->
fHandle == fgDNDDrop) {
443 }
else if (event->
fHandle == fgDNDFinished) {
457 if (t == fDropTimeout) {
464 SendDNDLeave(fTarget);
467 if (fLocalSource) fLocalSource->HandleDNDFinished();
482 event.fWindow = target;
483 event.fHandle = fgDNDEnter;
486 event.fUser[0] = fMain->GetId();
490 event.fUser[1] = ((n > 3) ? 1
L : 0
L) | (fUseVersion << 24);
494 for (i = 0; i < 3; ++i)
495 event.
fUser[2+i] = (i < n) ? fTypelist[i] :
kNone;
503 dnddata = fLocalSource->GetDNDData(0);
505 event.fUser[2] = dataType;
506 event.fUser[3] =
kNone;
507 event.fUser[4] =
kNone;
521 event.fWindow = target;
522 event.fHandle = fgDNDLeave;
525 event.fUser[0] = fMain->GetId();
544 event.fWindow = target;
545 event.fHandle = fgDNDPosition;
548 event.fUser[0] = fMain->GetId();
551 event.fUser[2] = (x << 16) | y;
552 event.fUser[3] = timestamp;
553 event.fUser[4] = action;
566 event.fWindow = source;
567 event.fHandle = fgDNDStatus;
570 event.fUser[0] = fMain->GetId();
571 event.fUser[1] = (action ==
kNone) ? 0
L : 1
L;
575 event.fUser[4] = action;
588 event.fWindow = target;
589 event.fHandle = fgDNDDrop;
592 event.fUser[0] = fMain->GetId();
609 event.fWindow = source;
610 event.fHandle = fgDNDFinished;
613 event.fUser[0] = fMain->GetId();
629 if (fDraggerTypes)
delete[] fDraggerTypes;
635 unsigned char *
data = 0;
637 gVirtualX->GetProperty(src, fgDNDTypeList,
639 &type, &format, &count, &remaining, &data);
641 if (type !=
XA_ATOM || format != 32 || !data) {
645 fDraggerTypes =
new Atom_t[count+4];
648 for (i = 0; i < count; i++)
649 fDraggerTypes[i] = a[i];
651 fDraggerTypes[i] =
kNone;
653 if (data)
delete[]
data;
656 fDraggerTypes =
new Atom_t[4];
658 fDraggerTypes[0] = dataTypes[0];
659 fDraggerTypes[1] = dataTypes[1];
660 fDraggerTypes[2] = dataTypes[2];
662 fDraggerTypes[3] =
kNone;
667 if (fLocalTarget) fLocalTarget->HandleDNDLeave();
679 if (fLocalTarget) fLocalTarget->HandleDNDLeave();
682 if (fDraggerTypes)
delete[] fDraggerTypes;
700 wtarget = FindWindow(
gVirtualX->GetDefaultRootWindow(), x_root, y_root, 15);
704 wtarget, x_root, y_root,
x,
y, child);
705 w =
gClient->GetWindowById(wtarget);
707 f =
dynamic_cast<TGFrame *
>(w);
710 if (f != fLocalTarget) {
718 fDropType = fLocalTarget->HandleDNDEnter(fDraggerTypes);
725 fLocalTarget->HandleDNDPosition(x,
y, action, x_root, y_root);
726 }
else if (fProxyOurs) {
727 action = fMain->HandleDNDPosition(x,
y, action, x_root, y_root);
731 SendDNDStatus(source, fLocalAction = action);
744 fDropAccepted =
kTRUE;
745 fAcceptedAction = action;
747 gVirtualX->ChangeActivePointerGrab(fDragWin->GetId(),
748 fGrabEventMask,
kNone);
751 fAcceptedAction =
kNone;
753 gVirtualX->ChangeActivePointerGrab(fDragWin->GetId(),
760 SendDNDDrop(fTarget);
776 if (fMain && fDropType !=
kNone) {
777 gVirtualX->ChangeProperties(fMain->GetId(), fgXCDNDData, fDropType,
778 8, (
unsigned char *) 0, 0);
780 gVirtualX->ConvertSelection(fMain->GetId(), fgDNDSelection, fDropType,
781 fgXCDNDData, timestamp);
785 if (fMain) SendDNDFinished(source);
795 if (fLocalSource) fLocalSource->HandleDNDFinished();
812 dnddata = fLocalSource->GetDNDData(event->
fUser[2]);
814 data = dnddata ? (
char *) dnddata->
fData : (
char *)
"";
819 event->fUser[3] = fgXCDNDData;
824 (
unsigned char *) data, len);
827 xevent.
fTime =
event->fTime;
828 xevent.
fUser[0] =
event->fUser[0];
829 xevent.
fUser[1] =
event->fUser[1];
830 xevent.
fUser[2] =
event->fUser[2];
831 xevent.
fUser[3] =
event->fUser[3];
846 Atom_t actual = fDropType;
849 unsigned char *
data = 0;
854 &actual, &format, &count, &remaining, &data);
856 if ((actual != fDropType) || (format != 8) || (count == 0) || !data) {
857 if (data)
delete[]
data;
862 if (fSource !=
kNone) SendDNDFinished(fSource);
867 TDNDData dndData(actual, data, count, fLocalAction);
868 fLocalTarget->HandleDNDDrop(&dndData);
869 if (fDraggerTypes)
delete[] fDraggerTypes;
874 fLocalAction =
kNone;
889 int hot_x,
int hot_y)
903 if (fDragging)
return kTRUE;
911 if (!
gVirtualX->SetSelectionOwner(fMain->GetId(), fgDNDSelection)) {
916 if (grabWin ==
kNone) grabWin = fMain->GetId();
923 fTargetIsDNDAware =
kFALSE;
925 if (fDropTimeout)
delete fDropTimeout;
928 fAcceptedAction =
kNone;
929 fLocalAction =
kNone;
933 fDragWin->Move((x_root-fHotx)|1, (y_root-fHoty)|1);
934 fDragWin->MapSubwindows();
935 fDragWin->MapRaised();
945 if (!fDragging)
return kFALSE;
947 if (fTargetIsDNDAware) {
949 if (fStatusPending) {
950 if (fDropTimeout)
delete fDropTimeout;
951 fDropTimeout =
new TTimer(
this, 5000);
953 SendDNDDrop(fTarget);
956 SendDNDLeave(fTarget);
969 if (!fDragging)
return kFALSE;
974 SendDNDFinished(fSource);
976 fLocalSource->HandleDNDFinished();
980 fDragWin->DeleteWindow();
991 if (!fDragging)
return kFALSE;
996 if (newTarget ==
kNone) {
998 if (t !=
kNone) newTarget = t;
1001 if (fTarget != newTarget) {
1003 if (fTargetIsDNDAware) SendDNDLeave(fTarget);
1005 fTarget = newTarget;
1006 fTargetIsDNDAware = IsDNDAware(fTarget);
1009 fAcceptedAction =
kNone;
1011 if (fTargetIsDNDAware) SendDNDEnter(fTarget);
1014 gVirtualX->ChangeActivePointerGrab(fDragWin->GetId(), fGrabEventMask,
1018 if (fTargetIsDNDAware && !fStatusPending) {
1019 SendDNDPosition(fTarget, x_root, y_root, action, timestamp);
1023 fStatusPending =
kTRUE;
1027 fDragWin->RaiseWindow();
1028 fDragWin->Move((x_root-fHotx)|1, (y_root-fHoty)|1);
1041 if (GetRootProxy() ==
kNone) {
1044 (
unsigned char *) &mainw, 1);
1045 gVirtualX->ChangeProperties(mainw, fgDNDProxy, XA_WINDOW, 32,
1046 (
unsigned char *) &mainw, 1);
1061 if (!fProxyOurs)
return kFALSE;
1063 gVirtualX->DeleteProperty(fMain->GetId(), fgDNDProxy);
static Atom_t GetDNDFinished()
virtual void RaiseWindow()
Raise TGDragWindow.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Bool_t SetRootProxy()
Set root window proxy.
static Atom_t fgDNDActionDescrip
static Atom_t fgDNDActionMove
static Atom_t fgXCDNDData
static Atom_t GetDNDActionDescrip()
Bool_t HandleDNDDrop(Window_t src, Time_t timestamp)
Handle DND drop event.
Bool_t HandleSelection(Event_t *event)
Handle selection event.
static Atom_t fgDNDVersion
static Atom_t fgDNDActionCopy
virtual Bool_t HandleDNDDrop(TDNDData *)
Bool_t HandleTimer(TTimer *t)
Handle Drop timeout.
TGDNDManager(const TGDNDManager &)
const Mask_t kButtonMotionMask
static Atom_t GetDNDProxy()
static Atom_t GetDNDVersion()
virtual void MapRaised()
Map and Raise TGDragWindow.
static Atom_t GetDNDSelection()
static Atom_t fgDNDActionPrivate
static Atom_t GetDNDActionList()
static Atom_t fgDNDStatus
static int ArrayLength(Atom_t *a)
static Atom_t GetDNDTypeList()
static Cursor_t fgDefaultCursor
static Atom_t GetXCDNDData()
void SendDNDLeave(Window_t target)
Send DND leave message to target window.
void InitAtoms()
Initialize drag and drop atoms.
virtual void MapWindow()
Map TGDragWindow.
virtual Bool_t HandleDNDFinished()
static Atom_t GetDNDActionCopy()
TGDNDManager * gDNDManager
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
static Atom_t GetDNDAware()
virtual void LowerWindow()
static Atom_t fgDNDPosition
virtual Atom_t HandleDNDPosition(Int_t, Int_t, Atom_t, Int_t, Int_t)
Bool_t EndDrag()
End dragging.
void SendDNDPosition(Window_t target, int x, int y, Atom_t action, Time_t timestamp)
Send DND position message to target window.
virtual void UnmapWindow()
Unmap TGDragWindow.
void SendDNDFinished(Window_t src)
Send DND finished message to source window.
static Atom_t GetDNDPosition()
Bool_t HandleClientMessage(Event_t *event)
Handle DND related client messages.
Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp)
Handle DND position event.
static constexpr double L
int main(int argc, char **argv)
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
virtual void DoRedraw()
Redraw TGDragWindow.
const Mask_t kButtonPressMask
virtual ~TGDragWindow()
TGDragWindow destructor.
void SendDNDStatus(Window_t target, Atom_t action)
Send DND status message to source window.
virtual Atom_t HandleDNDEnter(Atom_t *)
static Atom_t fgDNDSelection
static Atom_t GetDNDDrop()
const Mask_t kWASaveUnder
Bool_t HandleDNDStatus(Window_t from, int accepted, Rectangle_t skip, Atom_t action)
Handle DND status event.
Bool_t HandleDNDFinished(Window_t target)
Handle DND finished event.
static Atom_t fgDNDTypeList
Bool_t RemoveRootProxy()
Remove root window proxy.
static Atom_t fgXAWMState
Handles synchronous and a-synchronous timer events.
void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y)
Set drag window pixmaps and hotpoint.
static Atom_t GetDNDLeave()
#define ROOTDND_PROTOCOL_VERSION
virtual ~TGDNDManager()
TGDNDManager destructor.
static Atom_t fgDNDFinished
static const double x1[5]
static Atom_t fgDNDActionLink
void SendDNDDrop(Window_t target)
Send DND drop message to target window.
static Atom_t GetDNDStatus()
const Mask_t kButtonReleaseMask
Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3])
Handle DND enter event.
virtual void RaiseWindow()
const Mask_t kWAOverrideRedirect
void SendDNDEnter(Window_t target)
Send DND enter message to target window.
static Atom_t GetDNDActionPrivate()
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
virtual void LowerWindow()
Lower TGDragWindow.
virtual void UnmapWindow()
Window_t FindWindow(Window_t root, Int_t x, Int_t y, Int_t maxd)
Search for DND aware window at position x,y.
static Atom_t GetDNDActionLink()
static Atom_t fgDNDActionAsk
static Atom_t GetDNDActionMove()
static Atom_t GetDNDActionAsk()
Bool_t IsDNDAware(Window_t win, Atom_t *typelist=0)
Check if window win is DND aware.
Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request event.
virtual void Layout()
Layout TGDragWindow.
Window_t GetRootProxy()
Get root window proxy.
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root, Window_t grabWin=kNone)
Start dragging.
Bool_t HandleDNDLeave(Window_t src)
Handle DND leave event.
static Atom_t GetDNDEnter()
static char * skip(char **buf, const char *delimiters)
TGDragWindow(const TGWindow *p, Pixmap_t pic, Pixmap_t mask, UInt_t options=kChildFrame, Pixel_t back=GetWhitePixel())
TGDragWindow constructor.
static const TGGC & GetBckgndGC()
Get background color graphics context.
virtual Bool_t HandleDNDLeave()
static Atom_t fgDNDActionList