ROOT logo
// @(#)root/gui:$Id$
// Author: Bertrand Bellenot   19/04/07

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGFrame.h"
#include "TTimer.h"
#include "TGDNDManager.h"
#include "TRootCanvas.h"

#define ROOTDND_PROTOCOL_VERSION      4
#define XA_ATOM ((Atom_t) 4)
#define XA_WINDOW ((Atom_t) 33)

Atom_t TGDNDManager::fgDNDAware         = kNone;
Atom_t TGDNDManager::fgDNDSelection     = kNone;
Atom_t TGDNDManager::fgDNDProxy         = kNone;

Atom_t TGDNDManager::fgDNDEnter         = kNone;
Atom_t TGDNDManager::fgDNDLeave         = kNone;
Atom_t TGDNDManager::fgDNDPosition      = kNone;
Atom_t TGDNDManager::fgDNDStatus        = kNone;
Atom_t TGDNDManager::fgDNDDrop          = kNone;
Atom_t TGDNDManager::fgDNDFinished      = kNone;
Atom_t TGDNDManager::fgDNDVersion       = kNone;

Atom_t TGDNDManager::fgDNDActionCopy    = kNone;
Atom_t TGDNDManager::fgDNDActionMove    = kNone;
Atom_t TGDNDManager::fgDNDActionLink    = kNone;
Atom_t TGDNDManager::fgDNDActionAsk     = kNone;
Atom_t TGDNDManager::fgDNDActionPrivate = kNone;

Atom_t TGDNDManager::fgDNDTypeList      = kNone;
Atom_t TGDNDManager::fgDNDActionList    = kNone;
Atom_t TGDNDManager::fgDNDActionDescrip = kNone;

Atom_t TGDNDManager::fgXAWMState     = kNone;
Atom_t TGDNDManager::fgXCDNDData     = kNone;

Bool_t TGDNDManager::fgInit = kFALSE;

// TODO:
// - add an TGFrame::HandleDNDStatus event handler?
// - implement INCR protocol
// - cache several requests?

TGDNDManager *gDNDManager = 0;

Cursor_t TGDragWindow::fgDefaultCursor = kNone;

//_____________________________________________________________________________
//
// TGDragWindow
//
// Window used as drag icon during drag and drop operations.
//_____________________________________________________________________________

ClassImp(TGDragWindow)

//______________________________________________________________________________
TGDragWindow::TGDragWindow(const TGWindow *p, Pixmap_t pic, Pixmap_t mask,
                           UInt_t options, Pixel_t back) :
   TGFrame(p, 32, 32, options, back)
{
   // TGDragWindow constructor.

   if (fgDefaultCursor == kNone) {
      fgDefaultCursor = gVirtualX->CreateCursor(kTopLeft);
   }

   fPic = pic;
   fMask = mask;

   SetWindowAttributes_t wattr;

   wattr.fMask = kWAOverrideRedirect | kWASaveUnder;
   wattr.fSaveUnder = kTRUE;
   wattr.fOverrideRedirect = kTRUE;

   gVirtualX->ChangeWindowAttributes(fId, &wattr);

   int x, y;

   gVirtualX->GetWindowSize(fPic, x, y, fPw, fPh);

   wattr.fMask = kWAOverrideRedirect;
   wattr.fOverrideRedirect = kTRUE;

   // This input window is used to make the dragging smoother when using
   // highly complicated shapped windows (like labels and semitransparent
   // icons), for some obscure reason most of the motion events get lost
   // while the pointer is over the shaped window.

   //fInput = gVirtualX->CreateWindow(fParent->GetId(), 0, 0, fWidth,
   //                                 fHeight, 0, 0, 0, 0, &wattr, 0);
   fInput = fId;

   Resize(GetDefaultSize());

   gVirtualX->ShapeCombineMask(fId, 0, 0, fMask);

   gVirtualX->SetCursor(fId, fgDefaultCursor);
}

//______________________________________________________________________________
TGDragWindow::~TGDragWindow()
{
   // TGDragWindow destructor.

   //gVirtualX->DestroyWindow(fInput);
}

//______________________________________________________________________________
void TGDragWindow::MapWindow()
{
   // Map TGDragWindow.

   TGFrame::MapWindow();
   //gVirtualX->MapWindow(fInput);
}

//______________________________________________________________________________
void TGDragWindow::UnmapWindow()
{
   // Unmap TGDragWindow.

   TGFrame::UnmapWindow();
   //gVirtualX->UnmapWindow(fInput);
}

//______________________________________________________________________________
void TGDragWindow::RaiseWindow()
{
   // Raise TGDragWindow.

   TGFrame::RaiseWindow();
   //gVirtualX->RaiseWindow(fInput);
}

//______________________________________________________________________________
void TGDragWindow::LowerWindow()
{
   // Lower TGDragWindow.

   //gVirtualX->LowerWindow(fInput);
   TGFrame::LowerWindow();
}

//______________________________________________________________________________
void TGDragWindow::MapRaised()
{
   // Map and Raise TGDragWindow.

   TGFrame::MapRaised();
   //gVirtualX->MapRaised(fInput);
}

//______________________________________________________________________________
void TGDragWindow::Layout()
{
   // Layout TGDragWindow.

   gVirtualX->ShapeCombineMask(fId, 0, 0, fMask);
}

//______________________________________________________________________________
void TGDragWindow::DoRedraw()
{
   // Redraw TGDragWindow.

   gVirtualX->CopyArea(fPic, fId, GetBckgndGC()(), 0, 0, fWidth, fHeight, 0, 0);
}

//_____________________________________________________________________________
//
// TGDNDManager
//
// Central Drag and Drop manager for ROOT.
//_____________________________________________________________________________

ClassImp(TGDNDManager)

//______________________________________________________________________________
TGDNDManager::TGDNDManager(TGFrame *toplevel, Atom_t * /*typelist*/)
{
   // TGDNDManager constructor.

   if (gDNDManager)
      // coverity[uninit_member]: already done
      return;

   fMain = toplevel;
   fVersion = ROOTDND_PROTOCOL_VERSION;
   fUseVersion = kTRUE;
   //fTypelist = typelist;
   fTypelist = new Atom_t[3];
   fTypelist[0] = gVirtualX->InternAtom("application/root", kFALSE);
   fTypelist[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
   fTypelist[2] = 0;

   if (!fgInit) {
      InitAtoms();
      fgInit = kTRUE;
   }

   //Reset();
   fDropTimeout = 0;

   fSource = kNone;
   fTarget = kNone;
   fTargetIsDNDAware = kFALSE;
   fStatusPending = kFALSE;
   fDropAccepted = kFALSE;  // this would become obsoleted by _acceptedAction
   fAcceptedAction = kNone; // target's accepted action
   fLocalAction = kNone;    // our last specified action when we act as source
   fDragging = kFALSE;
   fDragWin = 0;
   fLocalSource = 0;
   fLocalTarget = 0;
   fPic = fMask = kNone;
   fDraggerTypes = 0;
   fDropType = kNone;
   fHotx = fHoty = 0;

   fGrabEventMask = kButtonPressMask | kButtonReleaseMask | kButtonMotionMask;

   fDNDNoDropCursor = gVirtualX->CreateCursor(kNoDrop); // kNoDrop

   // set the aware prop

   fProxyOurs = kFALSE;
   gDNDManager = this;
}

//______________________________________________________________________________
TGDNDManager::~TGDNDManager()
{
   // TGDNDManager destructor.

   // remove the proxy prop if we own it
   if (fProxyOurs)
      RemoveRootProxy();

   // remove the aware prop ant the types list, if any
   if (fMain) {
      gVirtualX->DeleteProperty(fMain->GetId(), fgDNDAware);
      gVirtualX->DeleteProperty(fMain->GetId(), fgDNDTypeList);
   }
   if (fDropTimeout) delete fDropTimeout;

   // delete the drag pixmap, if any
   if (fDragWin) {
      fDragWin->DeleteWindow();
      fDragWin = 0;
   }
   if (fPic != kNone) gVirtualX->DeletePixmap(fPic);
   if (fMask != kNone) gVirtualX->DeletePixmap(fMask);

   if (fDraggerTypes) delete[] fDraggerTypes;
   if (fTypelist) delete[] fTypelist;
}

Atom_t TGDNDManager::GetDNDAware() { return fgDNDAware; }
Atom_t TGDNDManager::GetDNDSelection() { return fgDNDSelection; }
Atom_t TGDNDManager::GetDNDProxy() { return fgDNDProxy; }
Atom_t TGDNDManager::GetDNDEnter() { return fgDNDEnter; }
Atom_t TGDNDManager::GetDNDLeave() { return fgDNDLeave; }
Atom_t TGDNDManager::GetDNDPosition() { return fgDNDPosition; }
Atom_t TGDNDManager::GetDNDStatus() { return fgDNDStatus; }
Atom_t TGDNDManager::GetDNDDrop() { return fgDNDDrop; }
Atom_t TGDNDManager::GetDNDFinished() { return fgDNDFinished; }
Atom_t TGDNDManager::GetDNDVersion() { return fgDNDVersion; }
Atom_t TGDNDManager::GetDNDActionCopy() { return fgDNDActionCopy; }
Atom_t TGDNDManager::GetDNDActionMove() { return fgDNDActionMove; }
Atom_t TGDNDManager::GetDNDActionLink() { return fgDNDActionLink; }
Atom_t TGDNDManager::GetDNDActionAsk() { return fgDNDActionAsk; }
Atom_t TGDNDManager::GetDNDActionPrivate() { return fgDNDActionPrivate; }
Atom_t TGDNDManager::GetDNDTypeList() { return fgDNDTypeList; }
Atom_t TGDNDManager::GetDNDActionList() { return fgDNDActionList; }
Atom_t TGDNDManager::GetDNDActionDescrip() { return fgDNDActionDescrip; }
Atom_t TGDNDManager::GetXCDNDData() { return fgXCDNDData; }

//______________________________________________________________________________
void TGDNDManager::InitAtoms()
{
   // Initialize drag and drop atoms.

   // awareness
   fgDNDAware = gVirtualX->InternAtom("XdndAware", kFALSE);

   // selection
   fgDNDSelection = gVirtualX->InternAtom("XdndSelection", kFALSE);

   // proxy window
   fgDNDProxy = gVirtualX->InternAtom("XdndProxy", kFALSE);

   // messages
   fgDNDEnter    = gVirtualX->InternAtom("XdndEnter", kFALSE);
   fgDNDLeave    = gVirtualX->InternAtom("XdndLeave", kFALSE);
   fgDNDPosition = gVirtualX->InternAtom("XdndPosition", kFALSE);
   fgDNDStatus   = gVirtualX->InternAtom("XdndStatus", kFALSE);
   fgDNDDrop     = gVirtualX->InternAtom("XdndDrop", kFALSE);
   fgDNDFinished = gVirtualX->InternAtom("XdndFinished", kFALSE);

   // actions
   fgDNDActionCopy    = gVirtualX->InternAtom("XdndActionCopy", kFALSE);
   fgDNDActionMove    = gVirtualX->InternAtom("XdndActionMove", kFALSE);
   fgDNDActionLink    = gVirtualX->InternAtom("XdndActionLink", kFALSE);
   fgDNDActionAsk     = gVirtualX->InternAtom("XdndActionAsk", kFALSE);
   fgDNDActionPrivate = gVirtualX->InternAtom("XdndActionPrivate", kFALSE);

   // types list
   fgDNDTypeList      = gVirtualX->InternAtom("XdndTypeList", kFALSE);
   fgDNDActionList    = gVirtualX->InternAtom("XdndActionList", kFALSE);
   fgDNDActionDescrip = gVirtualX->InternAtom("XdndActionDescription", kFALSE);

   // misc
   fgXAWMState = gVirtualX->InternAtom("WM_STATE", kFALSE);
   fgXCDNDData = gVirtualX->InternAtom("_XC_DND_DATA", kFALSE);
}

static int ArrayLength(Atom_t *a)
{
   // Returns length of array a.

   int n;

   for (n = 0; a[n]; n++) { }
   return n;
}

//______________________________________________________________________________
Bool_t TGDNDManager::IsDNDAware(Window_t win, Atom_t *typelist)
{
   // Check if window win is DND aware.

   return gVirtualX->IsDNDAware(win, typelist);
}

//______________________________________________________________________________
Window_t TGDNDManager::FindWindow(Window_t root, int x, int y, int maxd)
{
   // Search for DND aware window at position x,y.

   if (maxd <= 0) return kNone;

   if (fDragWin && fDragWin->HasWindow(root)) return kNone;

   return gVirtualX->FindRWindow(root, fDragWin ? fDragWin->GetId() : 0,
                                 fDragWin ? fDragWin->GetInputId() : 0,
                                 x, y, maxd);
}


//______________________________________________________________________________
Window_t TGDNDManager::GetRootProxy()
{
   // Get root window proxy.

   Atom_t actual;
   Int_t format = 32;
   ULong_t count, remaining;
   unsigned char *data = 0;
   Window_t win, proxy = kNone;

   // search for XdndProxy property on the root window...

   // XSync(_dpy, kFALSE);      // get to known state...
   gVirtualX->UpdateWindow(0);

   //oldhandler = XSetErrorHandler(TGDNDManager::CatchXError);
   //target_error = kFALSE;

   gVirtualX->GetProperty(gVirtualX->GetDefaultRootWindow(),
                          fgDNDProxy, 0, 1, kFALSE, XA_WINDOW,
                          &actual, &format, &count, &remaining, &data);

   if ((actual == XA_WINDOW) && (format == 32) && (count > 0) && data) {

      // found the XdndProxy property, now check for the proxy window...
      win = *((Window_t *) data);
      delete[] data;
      data = 0;

      gVirtualX->GetProperty(win, fgDNDProxy, 0, 1, kFALSE, XA_WINDOW,
                             &actual, &format, &count, &remaining, &data);

      // XSync(_dpy, kFALSE);      // force the error...
      gVirtualX->UpdateWindow(0);

      if ((actual == XA_WINDOW) && (format == 32) && (count > 0) && data) {
         if (*((Window_t *) data) == win) {

            // proxy window exists and is correct
            proxy = win;
         }
      }
   }
   if (data) delete[] data;
   //oldhandler = XSetErrorHandler(oldhandler);
   return proxy;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleClientMessage(Event_t *event)
{
   // Handle DND related client messages.

   if (event->fHandle == fgDNDEnter) {
      HandleDNDEnter((Window_t) event->fUser[0], event->fUser[1],
                     (Atom_t *) &event->fUser[2]);

   } else if (event->fHandle == fgDNDLeave) {
      HandleDNDLeave((Window_t) event->fUser[0]);

   } else if (event->fHandle == fgDNDPosition) {
      HandleDNDPosition((Window_t) event->fUser[0],
                       (Int_t) (event->fUser[2] >> 16) & 0xFFFF,  // x_root
                       (Int_t) (event->fUser[2] & 0xFFFF),        // y_root
                       (Atom_t) event->fUser[4],                  // action
                       (Time_t) event->fUser[3]);                 // timestamp

   } else if (event->fHandle == fgDNDStatus) {
      Rectangle_t skip;
      skip.fX      = (event->fUser[2] >> 16) & 0xFFFF;
      skip.fY      = (event->fUser[2] & 0xFFFF);
      skip.fWidth  = (event->fUser[3] >> 16) & 0xFFFF;
      skip.fHeight = (event->fUser[3] & 0xFFFF);

      HandleDNDStatus((Window_t) event->fUser[0],
                      (int) (event->fUser[1] & 0x1),
                       skip, (Atom_t) event->fUser[4]);

   } else if (event->fHandle == fgDNDDrop) {
      HandleDNDDrop((Window_t) event->fUser[0], (Time_t) event->fUser[2]);

   } else if (event->fHandle == fgDNDFinished) {
      HandleDNDFinished((Window_t) event->fUser[0]);

   } else {
      return kFALSE;  // not for us...
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleTimer(TTimer *t)
{
   // Handle Drop timeout.

   if (t == fDropTimeout) {
      // The drop operation timed out without receiving
      // status confirmation from the target. Send a
      // leave message instead (and notify the user or widget).
      delete fDropTimeout;
      fDropTimeout = 0;

      SendDNDLeave(fTarget);
      fStatusPending = kFALSE;

      if (fLocalSource) fLocalSource->HandleDNDFinished();
      return kTRUE;
   }
   return kFALSE;
}

//______________________________________________________________________________
void TGDNDManager::SendDNDEnter(Window_t target)
{
   // Send DND enter message to target window.

   Int_t i, n;
   Event_t event;

   event.fType   = kClientMessage;
   event.fWindow = target;
   event.fHandle = fgDNDEnter;
   event.fFormat = 32;

   event.fUser[0] = fMain->GetId();  // from;

   n = ArrayLength(fTypelist);

   event.fUser[1] = ((n > 3) ? 1L : 0L) | (fUseVersion << 24);

   // set the first 1-3 data types

   for (i = 0; i < 3; ++i)
      event.fUser[2+i] = (i < n) ? fTypelist[i] : kNone;

   if (fLocalSource) {
      TDNDData *dnddata = 0;
      Atom_t dataType;

      // get the data type from the drag source widget
      if (fLocalSource)
         dnddata = fLocalSource->GetDNDData(0);
      dataType = dnddata ? (Atom_t) dnddata->fDataType : (Atom_t) kNone;
      event.fUser[2] = dataType;
      event.fUser[3] = kNone;
      event.fUser[4] = kNone;
   }
   
   gVirtualX->SendEvent(target, &event);
}

//______________________________________________________________________________
void TGDNDManager::SendDNDLeave(Window_t target)
{
   // Send DND leave message to target window.

   Event_t event;

   event.fType    = kClientMessage;
   event.fWindow  = target;
   event.fHandle  = fgDNDLeave;
   event.fFormat  = 32;

   event.fUser[0] = fMain->GetId();  // from;
   event.fUser[1] = 0L;

   event.fUser[2] = 0L;
   event.fUser[3] = 0L;
   event.fUser[4] = 0L;

   gVirtualX->SendEvent(target, &event);
}

//______________________________________________________________________________
void TGDNDManager::SendDNDPosition(Window_t target, int x, int y,
                                  Atom_t action, Time_t timestamp)
{
   // Send DND position message to target window.

   Event_t event;

   event.fType    = kClientMessage;
   event.fWindow  = target;
   event.fHandle  = fgDNDPosition;
   event.fFormat  = 32;

   event.fUser[0] = fMain->GetId();  // from;
   event.fUser[1] = 0L;

   event.fUser[2] = (x << 16) | y;   // root coodinates
   event.fUser[3] = timestamp;       // timestamp for retrieving data
   event.fUser[4] = action;          // requested action

   gVirtualX->SendEvent(target, &event);
}

//______________________________________________________________________________
void TGDNDManager::SendDNDStatus(Window_t source, Atom_t action)
{
   // Send DND status message to source window.

   Event_t event;

   event.fType    = kClientMessage;
   event.fWindow  = source;
   event.fHandle  = fgDNDStatus;
   event.fFormat  = 32;

   event.fUser[0] = fMain->GetId();    // from;
   event.fUser[1] = (action == kNone) ? 0L : 1L;

   event.fUser[2] = 0L;                // empty rectangle
   event.fUser[3] = 0L;
   event.fUser[4] = action;            // accepted action

   gVirtualX->SendEvent(source, &event);
}

//______________________________________________________________________________
void TGDNDManager::SendDNDDrop(Window_t target)
{
   // Send DND drop message to target window.

   Event_t event;

   event.fType    = kClientMessage;
   event.fWindow  = target;
   event.fHandle  = fgDNDDrop;
   event.fFormat  = 32;

   event.fUser[0] = fMain->GetId();    // from;
   event.fUser[1] = 0L;                // reserved
   event.fUser[2] = 0L; //CurrentTime;       // timestamp
   event.fUser[3] = 0L;
   event.fUser[4] = 0L;

   gVirtualX->SendEvent(target, &event);
}

//______________________________________________________________________________
void TGDNDManager::SendDNDFinished(Window_t source)
{
   // Send DND finished message to source window.

   Event_t event;

   event.fType    = kClientMessage;
   event.fWindow  = source;
   event.fHandle  = fgDNDFinished;
   event.fFormat  = 32;

   event.fUser[0] = fMain->GetId();    // from;
   event.fUser[1] = 0L;                // reserved
   event.fUser[2] = 0L;
   event.fUser[3] = 0L;
   event.fUser[4] = 0L;

   gVirtualX->SendEvent(source, &event);
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleDNDEnter(Window_t src, Long_t vers, Atom_t dataTypes[3])
{
   // Handle DND enter event.

   fSource = src;

   if (fDraggerTypes) delete[] fDraggerTypes;

   if (vers & 1) {  // more than 3 data types?
      Atom_t type, *a;
      Int_t format = 32;
      ULong_t i, count, remaining;
      unsigned char *data = 0;

      gVirtualX->GetProperty(src, fgDNDTypeList,
                             0, 0x8000000L, kFALSE, XA_ATOM,
                             &type, &format, &count, &remaining, &data);

      if (type != XA_ATOM || format != 32 || !data) {
         count = 0;
      }

      fDraggerTypes = new Atom_t[count+4];

      a = (Atom_t *) data;
      for (i = 0; i < count; i++)
         fDraggerTypes[i] = a[i];

      fDraggerTypes[i] = kNone;

      if (data) delete[] data;

   } else {
      fDraggerTypes = new Atom_t[4];

      fDraggerTypes[0] = dataTypes[0];
      fDraggerTypes[1] = dataTypes[1];
      fDraggerTypes[2] = dataTypes[2];

      fDraggerTypes[3] = kNone;
   }

   // the following is not strictly neccessary, unless the previous
   // dragging application crashed without sending XdndLeave
   if (fLocalTarget) fLocalTarget->HandleDNDLeave();
   fLocalTarget = 0;

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleDNDLeave(Window_t /*src*/)
{
   // Handle DND leave event.

   fSource = kNone;
   if (fLocalTarget) fLocalTarget->HandleDNDLeave();
   fLocalTarget = 0;

   if (fDraggerTypes) delete[] fDraggerTypes;
   fDraggerTypes = 0;

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleDNDPosition(Window_t source, Int_t x_root, Int_t y_root,
                                      Atom_t action, Time_t /*timestamp*/)
{
   // Handle DND position event.

   Int_t x = 0, y = 0;
   Window_t child;
   TGFrame *f = 0, *main = 0;
   TGWindow *w = 0;
   Window_t wtarget = 0;

   wtarget = FindWindow(gVirtualX->GetDefaultRootWindow(), x_root, y_root, 15);

   if (wtarget) {
      gVirtualX->TranslateCoordinates(gVirtualX->GetDefaultRootWindow(),
                                      wtarget, x_root, y_root, x, y, child);
      w = gClient->GetWindowById(wtarget);
      if (w)
         f = dynamic_cast<TGFrame *>(w);
   }

   if (f != fLocalTarget) {
      if (fLocalTarget) fLocalTarget->HandleDNDLeave();
      fLocalTarget = f;
      if (fLocalTarget) {
         main = (TGFrame *)fLocalTarget->GetMainFrame();
         main->RaiseWindow();
         if (fMain == 0)
            fMain = main;
         fDropType = fLocalTarget->HandleDNDEnter(fDraggerTypes);
      }
   }
   // query the target widget to determine whether it accepts the
   // required action
   if (fLocalTarget) {
      action = (fDropType == kNone) ? kNone :
              fLocalTarget->HandleDNDPosition(x, y, action, x_root, y_root);
   } else if (fProxyOurs) {
      action = fMain->HandleDNDPosition(x, y, action, x_root, y_root);
   } else {
      action = kNone;
   }
   SendDNDStatus(source, fLocalAction = action);
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleDNDStatus(Window_t target, Int_t accepted,
                                    Rectangle_t /*area*/, Atom_t action)
{
   // Handle DND status event.

   if (target) {
      fStatusPending = kFALSE;
      if (accepted) {
         fDropAccepted = kTRUE;
         fAcceptedAction = action;
         if (fDragWin)
            gVirtualX->ChangeActivePointerGrab(fDragWin->GetId(),
                                               fGrabEventMask, kNone);
      } else {
         fDropAccepted = kFALSE;
         fAcceptedAction = kNone;
         if (fDragWin)
            gVirtualX->ChangeActivePointerGrab(fDragWin->GetId(),
                                               fGrabEventMask,
                                               fDNDNoDropCursor);
      }
      if (fDropTimeout) {   // were we waiting for this to do the drop?
         delete fDropTimeout;
         fDropTimeout = 0;
         SendDNDDrop(fTarget);
      }
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleDNDDrop(Window_t source, Time_t timestamp)
{
   // Handle DND drop event.

   // to get the data, we must call XConvertSelection with
   // the timestamp in XdndDrop, wait for SelectionNotify
   // to arrive to retrieve the data, and when we are finished,
   // send a XdndFinished message to the source.

   if (fMain && fDropType != kNone) {
      gVirtualX->ChangeProperties(fMain->GetId(), fgXCDNDData, fDropType,
                                  8, (unsigned char *) 0, 0);

      gVirtualX->ConvertSelection(fMain->GetId(), fgDNDSelection, fDropType,
                                  fgXCDNDData, timestamp);
   }

   fSource = source;
   if (fMain) SendDNDFinished(source);

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleDNDFinished(Window_t /*target*/)
{
   // Handle DND finished event.

   if (fLocalSource) fLocalSource->HandleDNDFinished();
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleSelectionRequest(Event_t *event)
{
   // Handle selection request event.

   if ((Atom_t)event->fUser[1] == fgDNDSelection) {
      Event_t xevent;
      TDNDData *dnddata = 0;
      char *data;
      int len;

      // get the data from the drag source widget
      if (fLocalSource)
         dnddata = fLocalSource->GetDNDData(event->fUser[2]);

      data = dnddata ? (char *) dnddata->fData : (char *) "";
      len  = dnddata ? dnddata->fDataLength : 0;

      if ((Atom_t)event->fUser[3] == kNone) {
         //printf("warning: kNone property specified in SelectionRequest\n");
         event->fUser[3] = fgXCDNDData;
      }

      gVirtualX->ChangeProperties(event->fUser[0], event->fUser[3],
                                  event->fUser[2], 8,
                                  (unsigned char *) data, len);

      xevent.fType    = kSelectionNotify;
      xevent.fTime    = event->fTime;
      xevent.fUser[0] = event->fUser[0]; // requestor
      xevent.fUser[1] = event->fUser[1]; // selection
      xevent.fUser[2] = event->fUser[2]; // target;
      xevent.fUser[3] = event->fUser[3]; // property;
      gVirtualX->SendEvent(event->fUser[0], &xevent);

      return kTRUE;

   } else {
      return kFALSE;  // not for us...
   }
}

//______________________________________________________________________________
Bool_t TGDNDManager::HandleSelection(Event_t *event)
{
   // Handle selection event.

   if ((Atom_t)event->fUser[1] == fgDNDSelection) {
      Atom_t actual = fDropType;
      Int_t format = 8;
      ULong_t count, remaining;
      unsigned char *data = 0;

      gVirtualX->GetProperty(event->fUser[0], event->fUser[3],
                             0, 0x8000000L, kTRUE, event->fUser[2],
                             &actual, &format, &count, &remaining, &data);

      if ((actual != fDropType) || (format != 8) || (count == 0) || !data) {
         if (data) delete[] data;
         return kFALSE;
      }

      if (fSource != kNone) SendDNDFinished(fSource);

      // send the data to the target widget

      if (fLocalTarget) {
         TDNDData dndData(actual, data, count, fLocalAction);
         fLocalTarget->HandleDNDDrop(&dndData);
         if (fDraggerTypes) delete[] fDraggerTypes;
         fDraggerTypes = 0;
      }

      fSource = kNone;
      fLocalAction = kNone;

//      delete[] data;

      return kTRUE;

   } else {
      return kFALSE;  // not for us...
   }
}

//______________________________________________________________________________
void TGDNDManager::SetDragPixmap(Pixmap_t pic, Pixmap_t mask,
                                int hot_x, int hot_y)
{
   // Set drag window pixmaps and hotpoint.

   fPic  = pic;
   fMask = mask;
   fHotx = hot_x;
   fHoty = hot_y;
}

//______________________________________________________________________________
Bool_t TGDNDManager::StartDrag(TGFrame *src, int x_root, int y_root,
                              Window_t grabWin)
{
   // Start dragging.

   if (fDragging) return kTRUE;

   fLocalSource = src;

   if ((TGWindow *)fMain != src->GetMainFrame()) {
      fMain = (TGFrame *)src->GetMainFrame();
   }

   if (!gVirtualX->SetSelectionOwner(fMain->GetId(), fgDNDSelection)) {
      // hmmm... failed to acquire ownership of XdndSelection!
      return kFALSE;
   }

   if (grabWin == kNone) grabWin = fMain->GetId();

   gVirtualX->GrabPointer(grabWin, fGrabEventMask, kNone, fDNDNoDropCursor, kTRUE, kFALSE);

   fLocalTarget = 0;
   fDragging = kTRUE;
   fTarget = kNone;
   fTargetIsDNDAware = kFALSE;
   fStatusPending = kFALSE;
   if (fDropTimeout) delete fDropTimeout;
   fDropTimeout = 0;
   fDropAccepted = kFALSE;
   fAcceptedAction = kNone;
   fLocalAction = kNone;

   if (!fDragWin && fPic != kNone && fMask != kNone) {
      fDragWin = new TGDragWindow(gClient->GetDefaultRoot(), fPic, fMask);
      fDragWin->Move((x_root-fHotx)|1, (y_root-fHoty)|1);
      fDragWin->MapSubwindows();
      fDragWin->MapRaised();
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::Drop()
{
   // Drop.

   if (!fDragging) return kFALSE;

   if (fTargetIsDNDAware) {
      if (fDropAccepted) {
         if (fStatusPending) {
            if (fDropTimeout) delete fDropTimeout;
            fDropTimeout = new TTimer(this, 5000);
         } else {
            SendDNDDrop(fTarget);
         }
      } else {
         SendDNDLeave(fTarget);
         fStatusPending = kFALSE;
      }
   }
   EndDrag();
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::EndDrag()
{
   // End dragging.

   if (!fDragging) return kFALSE;

   gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);

   if (fSource)
      SendDNDFinished(fSource);
   if (fLocalSource)
      fLocalSource->HandleDNDFinished();

   fDragging = kFALSE;
   if (fDragWin) {
      fDragWin->DeleteWindow();
      fDragWin = 0;
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::Drag(int x_root, int y_root, Atom_t action, Time_t timestamp)
{
   // Process drag event.

   if (!fDragging) return kFALSE;

   Window_t newTarget = FindWindow(gVirtualX->GetDefaultRootWindow(),
                                   x_root, y_root, 15);

   if (newTarget == kNone) {
      Window_t t = GetRootProxy();
      if (t != kNone) newTarget = t;
   }

   if (fTarget != newTarget) {

      if (fTargetIsDNDAware) SendDNDLeave(fTarget);

      fTarget = newTarget;
      fTargetIsDNDAware = IsDNDAware(fTarget);
      fStatusPending = kFALSE;
      fDropAccepted = kFALSE;
      fAcceptedAction = kNone;

      if (fTargetIsDNDAware) SendDNDEnter(fTarget);

      if (fDragWin)
         gVirtualX->ChangeActivePointerGrab(fDragWin->GetId(), fGrabEventMask,
                                            fDNDNoDropCursor);
   }

   if (fTargetIsDNDAware && !fStatusPending) {
      SendDNDPosition(fTarget, x_root, y_root, action, timestamp);

      // this is to avoid sending XdndPosition messages over and over
      // if the target is not responding
      fStatusPending = kTRUE;
   }

   if (fDragWin) {
      fDragWin->RaiseWindow();
      fDragWin->Move((x_root-fHotx)|1, (y_root-fHoty)|1);
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGDNDManager::SetRootProxy()
{
   // Set root window proxy.

   Window_t mainw = fMain->GetId();
   int result = kFALSE;

   if (GetRootProxy() == kNone) {
      gVirtualX->ChangeProperties(gVirtualX->GetDefaultRootWindow(),
                                  fgDNDProxy, XA_WINDOW, 32,
                                  (unsigned char *) &mainw, 1);
      gVirtualX->ChangeProperties(mainw, fgDNDProxy, XA_WINDOW, 32,
                                  (unsigned char *) &mainw, 1);

      fProxyOurs = kTRUE;
      result = kTRUE;
   }
   // XSync(_dpy, kFALSE);
   gVirtualX->UpdateWindow(0);
   return result;
}

//______________________________________________________________________________
Bool_t TGDNDManager::RemoveRootProxy()
{
   // Remove root window proxy.

   if (!fProxyOurs) return kFALSE;

   gVirtualX->DeleteProperty(fMain->GetId(), fgDNDProxy);
   gVirtualX->DeleteProperty(gVirtualX->GetDefaultRootWindow(), fgDNDProxy);
   // the following is to ensure that the properties
   // (specially the one on the root window) are deleted
   // in case the application is exiting...

   // XSync(_dpy, kFALSE);
   gVirtualX->UpdateWindow(0);

   fProxyOurs = kFALSE;

   return kTRUE;
}
 TGDNDManager.cxx:1
 TGDNDManager.cxx:2
 TGDNDManager.cxx:3
 TGDNDManager.cxx:4
 TGDNDManager.cxx:5
 TGDNDManager.cxx:6
 TGDNDManager.cxx:7
 TGDNDManager.cxx:8
 TGDNDManager.cxx:9
 TGDNDManager.cxx:10
 TGDNDManager.cxx:11
 TGDNDManager.cxx:12
 TGDNDManager.cxx:13
 TGDNDManager.cxx:14
 TGDNDManager.cxx:15
 TGDNDManager.cxx:16
 TGDNDManager.cxx:17
 TGDNDManager.cxx:18
 TGDNDManager.cxx:19
 TGDNDManager.cxx:20
 TGDNDManager.cxx:21
 TGDNDManager.cxx:22
 TGDNDManager.cxx:23
 TGDNDManager.cxx:24
 TGDNDManager.cxx:25
 TGDNDManager.cxx:26
 TGDNDManager.cxx:27
 TGDNDManager.cxx:28
 TGDNDManager.cxx:29
 TGDNDManager.cxx:30
 TGDNDManager.cxx:31
 TGDNDManager.cxx:32
 TGDNDManager.cxx:33
 TGDNDManager.cxx:34
 TGDNDManager.cxx:35
 TGDNDManager.cxx:36
 TGDNDManager.cxx:37
 TGDNDManager.cxx:38
 TGDNDManager.cxx:39
 TGDNDManager.cxx:40
 TGDNDManager.cxx:41
 TGDNDManager.cxx:42
 TGDNDManager.cxx:43
 TGDNDManager.cxx:44
 TGDNDManager.cxx:45
 TGDNDManager.cxx:46
 TGDNDManager.cxx:47
 TGDNDManager.cxx:48
 TGDNDManager.cxx:49
 TGDNDManager.cxx:50
 TGDNDManager.cxx:51
 TGDNDManager.cxx:52
 TGDNDManager.cxx:53
 TGDNDManager.cxx:54
 TGDNDManager.cxx:55
 TGDNDManager.cxx:56
 TGDNDManager.cxx:57
 TGDNDManager.cxx:58
 TGDNDManager.cxx:59
 TGDNDManager.cxx:60
 TGDNDManager.cxx:61
 TGDNDManager.cxx:62
 TGDNDManager.cxx:63
 TGDNDManager.cxx:64
 TGDNDManager.cxx:65
 TGDNDManager.cxx:66
 TGDNDManager.cxx:67
 TGDNDManager.cxx:68
 TGDNDManager.cxx:69
 TGDNDManager.cxx:70
 TGDNDManager.cxx:71
 TGDNDManager.cxx:72
 TGDNDManager.cxx:73
 TGDNDManager.cxx:74
 TGDNDManager.cxx:75
 TGDNDManager.cxx:76
 TGDNDManager.cxx:77
 TGDNDManager.cxx:78
 TGDNDManager.cxx:79
 TGDNDManager.cxx:80
 TGDNDManager.cxx:81
 TGDNDManager.cxx:82
 TGDNDManager.cxx:83
 TGDNDManager.cxx:84
 TGDNDManager.cxx:85
 TGDNDManager.cxx:86
 TGDNDManager.cxx:87
 TGDNDManager.cxx:88
 TGDNDManager.cxx:89
 TGDNDManager.cxx:90
 TGDNDManager.cxx:91
 TGDNDManager.cxx:92
 TGDNDManager.cxx:93
 TGDNDManager.cxx:94
 TGDNDManager.cxx:95
 TGDNDManager.cxx:96
 TGDNDManager.cxx:97
 TGDNDManager.cxx:98
 TGDNDManager.cxx:99
 TGDNDManager.cxx:100
 TGDNDManager.cxx:101
 TGDNDManager.cxx:102
 TGDNDManager.cxx:103
 TGDNDManager.cxx:104
 TGDNDManager.cxx:105
 TGDNDManager.cxx:106
 TGDNDManager.cxx:107
 TGDNDManager.cxx:108
 TGDNDManager.cxx:109
 TGDNDManager.cxx:110
 TGDNDManager.cxx:111
 TGDNDManager.cxx:112
 TGDNDManager.cxx:113
 TGDNDManager.cxx:114
 TGDNDManager.cxx:115
 TGDNDManager.cxx:116
 TGDNDManager.cxx:117
 TGDNDManager.cxx:118
 TGDNDManager.cxx:119
 TGDNDManager.cxx:120
 TGDNDManager.cxx:121
 TGDNDManager.cxx:122
 TGDNDManager.cxx:123
 TGDNDManager.cxx:124
 TGDNDManager.cxx:125
 TGDNDManager.cxx:126
 TGDNDManager.cxx:127
 TGDNDManager.cxx:128
 TGDNDManager.cxx:129
 TGDNDManager.cxx:130
 TGDNDManager.cxx:131
 TGDNDManager.cxx:132
 TGDNDManager.cxx:133
 TGDNDManager.cxx:134
 TGDNDManager.cxx:135
 TGDNDManager.cxx:136
 TGDNDManager.cxx:137
 TGDNDManager.cxx:138
 TGDNDManager.cxx:139
 TGDNDManager.cxx:140
 TGDNDManager.cxx:141
 TGDNDManager.cxx:142
 TGDNDManager.cxx:143
 TGDNDManager.cxx:144
 TGDNDManager.cxx:145
 TGDNDManager.cxx:146
 TGDNDManager.cxx:147
 TGDNDManager.cxx:148
 TGDNDManager.cxx:149
 TGDNDManager.cxx:150
 TGDNDManager.cxx:151
 TGDNDManager.cxx:152
 TGDNDManager.cxx:153
 TGDNDManager.cxx:154
 TGDNDManager.cxx:155
 TGDNDManager.cxx:156
 TGDNDManager.cxx:157
 TGDNDManager.cxx:158
 TGDNDManager.cxx:159
 TGDNDManager.cxx:160
 TGDNDManager.cxx:161
 TGDNDManager.cxx:162
 TGDNDManager.cxx:163
 TGDNDManager.cxx:164
 TGDNDManager.cxx:165
 TGDNDManager.cxx:166
 TGDNDManager.cxx:167
 TGDNDManager.cxx:168
 TGDNDManager.cxx:169
 TGDNDManager.cxx:170
 TGDNDManager.cxx:171
 TGDNDManager.cxx:172
 TGDNDManager.cxx:173
 TGDNDManager.cxx:174
 TGDNDManager.cxx:175
 TGDNDManager.cxx:176
 TGDNDManager.cxx:177
 TGDNDManager.cxx:178
 TGDNDManager.cxx:179
 TGDNDManager.cxx:180
 TGDNDManager.cxx:181
 TGDNDManager.cxx:182
 TGDNDManager.cxx:183
 TGDNDManager.cxx:184
 TGDNDManager.cxx:185
 TGDNDManager.cxx:186
 TGDNDManager.cxx:187
 TGDNDManager.cxx:188
 TGDNDManager.cxx:189
 TGDNDManager.cxx:190
 TGDNDManager.cxx:191
 TGDNDManager.cxx:192
 TGDNDManager.cxx:193
 TGDNDManager.cxx:194
 TGDNDManager.cxx:195
 TGDNDManager.cxx:196
 TGDNDManager.cxx:197
 TGDNDManager.cxx:198
 TGDNDManager.cxx:199
 TGDNDManager.cxx:200
 TGDNDManager.cxx:201
 TGDNDManager.cxx:202
 TGDNDManager.cxx:203
 TGDNDManager.cxx:204
 TGDNDManager.cxx:205
 TGDNDManager.cxx:206
 TGDNDManager.cxx:207
 TGDNDManager.cxx:208
 TGDNDManager.cxx:209
 TGDNDManager.cxx:210
 TGDNDManager.cxx:211
 TGDNDManager.cxx:212
 TGDNDManager.cxx:213
 TGDNDManager.cxx:214
 TGDNDManager.cxx:215
 TGDNDManager.cxx:216
 TGDNDManager.cxx:217
 TGDNDManager.cxx:218
 TGDNDManager.cxx:219
 TGDNDManager.cxx:220
 TGDNDManager.cxx:221
 TGDNDManager.cxx:222
 TGDNDManager.cxx:223
 TGDNDManager.cxx:224
 TGDNDManager.cxx:225
 TGDNDManager.cxx:226
 TGDNDManager.cxx:227
 TGDNDManager.cxx:228
 TGDNDManager.cxx:229
 TGDNDManager.cxx:230
 TGDNDManager.cxx:231
 TGDNDManager.cxx:232
 TGDNDManager.cxx:233
 TGDNDManager.cxx:234
 TGDNDManager.cxx:235
 TGDNDManager.cxx:236
 TGDNDManager.cxx:237
 TGDNDManager.cxx:238
 TGDNDManager.cxx:239
 TGDNDManager.cxx:240
 TGDNDManager.cxx:241
 TGDNDManager.cxx:242
 TGDNDManager.cxx:243
 TGDNDManager.cxx:244
 TGDNDManager.cxx:245
 TGDNDManager.cxx:246
 TGDNDManager.cxx:247
 TGDNDManager.cxx:248
 TGDNDManager.cxx:249
 TGDNDManager.cxx:250
 TGDNDManager.cxx:251
 TGDNDManager.cxx:252
 TGDNDManager.cxx:253
 TGDNDManager.cxx:254
 TGDNDManager.cxx:255
 TGDNDManager.cxx:256
 TGDNDManager.cxx:257
 TGDNDManager.cxx:258
 TGDNDManager.cxx:259
 TGDNDManager.cxx:260
 TGDNDManager.cxx:261
 TGDNDManager.cxx:262
 TGDNDManager.cxx:263
 TGDNDManager.cxx:264
 TGDNDManager.cxx:265
 TGDNDManager.cxx:266
 TGDNDManager.cxx:267
 TGDNDManager.cxx:268
 TGDNDManager.cxx:269
 TGDNDManager.cxx:270
 TGDNDManager.cxx:271
 TGDNDManager.cxx:272
 TGDNDManager.cxx:273
 TGDNDManager.cxx:274
 TGDNDManager.cxx:275
 TGDNDManager.cxx:276
 TGDNDManager.cxx:277
 TGDNDManager.cxx:278
 TGDNDManager.cxx:279
 TGDNDManager.cxx:280
 TGDNDManager.cxx:281
 TGDNDManager.cxx:282
 TGDNDManager.cxx:283
 TGDNDManager.cxx:284
 TGDNDManager.cxx:285
 TGDNDManager.cxx:286
 TGDNDManager.cxx:287
 TGDNDManager.cxx:288
 TGDNDManager.cxx:289
 TGDNDManager.cxx:290
 TGDNDManager.cxx:291
 TGDNDManager.cxx:292
 TGDNDManager.cxx:293
 TGDNDManager.cxx:294
 TGDNDManager.cxx:295
 TGDNDManager.cxx:296
 TGDNDManager.cxx:297
 TGDNDManager.cxx:298
 TGDNDManager.cxx:299
 TGDNDManager.cxx:300
 TGDNDManager.cxx:301
 TGDNDManager.cxx:302
 TGDNDManager.cxx:303
 TGDNDManager.cxx:304
 TGDNDManager.cxx:305
 TGDNDManager.cxx:306
 TGDNDManager.cxx:307
 TGDNDManager.cxx:308
 TGDNDManager.cxx:309
 TGDNDManager.cxx:310
 TGDNDManager.cxx:311
 TGDNDManager.cxx:312
 TGDNDManager.cxx:313
 TGDNDManager.cxx:314
 TGDNDManager.cxx:315
 TGDNDManager.cxx:316
 TGDNDManager.cxx:317
 TGDNDManager.cxx:318
 TGDNDManager.cxx:319
 TGDNDManager.cxx:320
 TGDNDManager.cxx:321
 TGDNDManager.cxx:322
 TGDNDManager.cxx:323
 TGDNDManager.cxx:324
 TGDNDManager.cxx:325
 TGDNDManager.cxx:326
 TGDNDManager.cxx:327
 TGDNDManager.cxx:328
 TGDNDManager.cxx:329
 TGDNDManager.cxx:330
 TGDNDManager.cxx:331
 TGDNDManager.cxx:332
 TGDNDManager.cxx:333
 TGDNDManager.cxx:334
 TGDNDManager.cxx:335
 TGDNDManager.cxx:336
 TGDNDManager.cxx:337
 TGDNDManager.cxx:338
 TGDNDManager.cxx:339
 TGDNDManager.cxx:340
 TGDNDManager.cxx:341
 TGDNDManager.cxx:342
 TGDNDManager.cxx:343
 TGDNDManager.cxx:344
 TGDNDManager.cxx:345
 TGDNDManager.cxx:346
 TGDNDManager.cxx:347
 TGDNDManager.cxx:348
 TGDNDManager.cxx:349
 TGDNDManager.cxx:350
 TGDNDManager.cxx:351
 TGDNDManager.cxx:352
 TGDNDManager.cxx:353
 TGDNDManager.cxx:354
 TGDNDManager.cxx:355
 TGDNDManager.cxx:356
 TGDNDManager.cxx:357
 TGDNDManager.cxx:358
 TGDNDManager.cxx:359
 TGDNDManager.cxx:360
 TGDNDManager.cxx:361
 TGDNDManager.cxx:362
 TGDNDManager.cxx:363
 TGDNDManager.cxx:364
 TGDNDManager.cxx:365
 TGDNDManager.cxx:366
 TGDNDManager.cxx:367
 TGDNDManager.cxx:368
 TGDNDManager.cxx:369
 TGDNDManager.cxx:370
 TGDNDManager.cxx:371
 TGDNDManager.cxx:372
 TGDNDManager.cxx:373
 TGDNDManager.cxx:374
 TGDNDManager.cxx:375
 TGDNDManager.cxx:376
 TGDNDManager.cxx:377
 TGDNDManager.cxx:378
 TGDNDManager.cxx:379
 TGDNDManager.cxx:380
 TGDNDManager.cxx:381
 TGDNDManager.cxx:382
 TGDNDManager.cxx:383
 TGDNDManager.cxx:384
 TGDNDManager.cxx:385
 TGDNDManager.cxx:386
 TGDNDManager.cxx:387
 TGDNDManager.cxx:388
 TGDNDManager.cxx:389
 TGDNDManager.cxx:390
 TGDNDManager.cxx:391
 TGDNDManager.cxx:392
 TGDNDManager.cxx:393
 TGDNDManager.cxx:394
 TGDNDManager.cxx:395
 TGDNDManager.cxx:396
 TGDNDManager.cxx:397
 TGDNDManager.cxx:398
 TGDNDManager.cxx:399
 TGDNDManager.cxx:400
 TGDNDManager.cxx:401
 TGDNDManager.cxx:402
 TGDNDManager.cxx:403
 TGDNDManager.cxx:404
 TGDNDManager.cxx:405
 TGDNDManager.cxx:406
 TGDNDManager.cxx:407
 TGDNDManager.cxx:408
 TGDNDManager.cxx:409
 TGDNDManager.cxx:410
 TGDNDManager.cxx:411
 TGDNDManager.cxx:412
 TGDNDManager.cxx:413
 TGDNDManager.cxx:414
 TGDNDManager.cxx:415
 TGDNDManager.cxx:416
 TGDNDManager.cxx:417
 TGDNDManager.cxx:418
 TGDNDManager.cxx:419
 TGDNDManager.cxx:420
 TGDNDManager.cxx:421
 TGDNDManager.cxx:422
 TGDNDManager.cxx:423
 TGDNDManager.cxx:424
 TGDNDManager.cxx:425
 TGDNDManager.cxx:426
 TGDNDManager.cxx:427
 TGDNDManager.cxx:428
 TGDNDManager.cxx:429
 TGDNDManager.cxx:430
 TGDNDManager.cxx:431
 TGDNDManager.cxx:432
 TGDNDManager.cxx:433
 TGDNDManager.cxx:434
 TGDNDManager.cxx:435
 TGDNDManager.cxx:436
 TGDNDManager.cxx:437
 TGDNDManager.cxx:438
 TGDNDManager.cxx:439
 TGDNDManager.cxx:440
 TGDNDManager.cxx:441
 TGDNDManager.cxx:442
 TGDNDManager.cxx:443
 TGDNDManager.cxx:444
 TGDNDManager.cxx:445
 TGDNDManager.cxx:446
 TGDNDManager.cxx:447
 TGDNDManager.cxx:448
 TGDNDManager.cxx:449
 TGDNDManager.cxx:450
 TGDNDManager.cxx:451
 TGDNDManager.cxx:452
 TGDNDManager.cxx:453
 TGDNDManager.cxx:454
 TGDNDManager.cxx:455
 TGDNDManager.cxx:456
 TGDNDManager.cxx:457
 TGDNDManager.cxx:458
 TGDNDManager.cxx:459
 TGDNDManager.cxx:460
 TGDNDManager.cxx:461
 TGDNDManager.cxx:462
 TGDNDManager.cxx:463
 TGDNDManager.cxx:464
 TGDNDManager.cxx:465
 TGDNDManager.cxx:466
 TGDNDManager.cxx:467
 TGDNDManager.cxx:468
 TGDNDManager.cxx:469
 TGDNDManager.cxx:470
 TGDNDManager.cxx:471
 TGDNDManager.cxx:472
 TGDNDManager.cxx:473
 TGDNDManager.cxx:474
 TGDNDManager.cxx:475
 TGDNDManager.cxx:476
 TGDNDManager.cxx:477
 TGDNDManager.cxx:478
 TGDNDManager.cxx:479
 TGDNDManager.cxx:480
 TGDNDManager.cxx:481
 TGDNDManager.cxx:482
 TGDNDManager.cxx:483
 TGDNDManager.cxx:484
 TGDNDManager.cxx:485
 TGDNDManager.cxx:486
 TGDNDManager.cxx:487
 TGDNDManager.cxx:488
 TGDNDManager.cxx:489
 TGDNDManager.cxx:490
 TGDNDManager.cxx:491
 TGDNDManager.cxx:492
 TGDNDManager.cxx:493
 TGDNDManager.cxx:494
 TGDNDManager.cxx:495
 TGDNDManager.cxx:496
 TGDNDManager.cxx:497
 TGDNDManager.cxx:498
 TGDNDManager.cxx:499
 TGDNDManager.cxx:500
 TGDNDManager.cxx:501
 TGDNDManager.cxx:502
 TGDNDManager.cxx:503
 TGDNDManager.cxx:504
 TGDNDManager.cxx:505
 TGDNDManager.cxx:506
 TGDNDManager.cxx:507
 TGDNDManager.cxx:508
 TGDNDManager.cxx:509
 TGDNDManager.cxx:510
 TGDNDManager.cxx:511
 TGDNDManager.cxx:512
 TGDNDManager.cxx:513
 TGDNDManager.cxx:514
 TGDNDManager.cxx:515
 TGDNDManager.cxx:516
 TGDNDManager.cxx:517
 TGDNDManager.cxx:518
 TGDNDManager.cxx:519
 TGDNDManager.cxx:520
 TGDNDManager.cxx:521
 TGDNDManager.cxx:522
 TGDNDManager.cxx:523
 TGDNDManager.cxx:524
 TGDNDManager.cxx:525
 TGDNDManager.cxx:526
 TGDNDManager.cxx:527
 TGDNDManager.cxx:528
 TGDNDManager.cxx:529
 TGDNDManager.cxx:530
 TGDNDManager.cxx:531
 TGDNDManager.cxx:532
 TGDNDManager.cxx:533
 TGDNDManager.cxx:534
 TGDNDManager.cxx:535
 TGDNDManager.cxx:536
 TGDNDManager.cxx:537
 TGDNDManager.cxx:538
 TGDNDManager.cxx:539
 TGDNDManager.cxx:540
 TGDNDManager.cxx:541
 TGDNDManager.cxx:542
 TGDNDManager.cxx:543
 TGDNDManager.cxx:544
 TGDNDManager.cxx:545
 TGDNDManager.cxx:546
 TGDNDManager.cxx:547
 TGDNDManager.cxx:548
 TGDNDManager.cxx:549
 TGDNDManager.cxx:550
 TGDNDManager.cxx:551
 TGDNDManager.cxx:552
 TGDNDManager.cxx:553
 TGDNDManager.cxx:554
 TGDNDManager.cxx:555
 TGDNDManager.cxx:556
 TGDNDManager.cxx:557
 TGDNDManager.cxx:558
 TGDNDManager.cxx:559
 TGDNDManager.cxx:560
 TGDNDManager.cxx:561
 TGDNDManager.cxx:562
 TGDNDManager.cxx:563
 TGDNDManager.cxx:564
 TGDNDManager.cxx:565
 TGDNDManager.cxx:566
 TGDNDManager.cxx:567
 TGDNDManager.cxx:568
 TGDNDManager.cxx:569
 TGDNDManager.cxx:570
 TGDNDManager.cxx:571
 TGDNDManager.cxx:572
 TGDNDManager.cxx:573
 TGDNDManager.cxx:574
 TGDNDManager.cxx:575
 TGDNDManager.cxx:576
 TGDNDManager.cxx:577
 TGDNDManager.cxx:578
 TGDNDManager.cxx:579
 TGDNDManager.cxx:580
 TGDNDManager.cxx:581
 TGDNDManager.cxx:582
 TGDNDManager.cxx:583
 TGDNDManager.cxx:584
 TGDNDManager.cxx:585
 TGDNDManager.cxx:586
 TGDNDManager.cxx:587
 TGDNDManager.cxx:588
 TGDNDManager.cxx:589
 TGDNDManager.cxx:590
 TGDNDManager.cxx:591
 TGDNDManager.cxx:592
 TGDNDManager.cxx:593
 TGDNDManager.cxx:594
 TGDNDManager.cxx:595
 TGDNDManager.cxx:596
 TGDNDManager.cxx:597
 TGDNDManager.cxx:598
 TGDNDManager.cxx:599
 TGDNDManager.cxx:600
 TGDNDManager.cxx:601
 TGDNDManager.cxx:602
 TGDNDManager.cxx:603
 TGDNDManager.cxx:604
 TGDNDManager.cxx:605
 TGDNDManager.cxx:606
 TGDNDManager.cxx:607
 TGDNDManager.cxx:608
 TGDNDManager.cxx:609
 TGDNDManager.cxx:610
 TGDNDManager.cxx:611
 TGDNDManager.cxx:612
 TGDNDManager.cxx:613
 TGDNDManager.cxx:614
 TGDNDManager.cxx:615
 TGDNDManager.cxx:616
 TGDNDManager.cxx:617
 TGDNDManager.cxx:618
 TGDNDManager.cxx:619
 TGDNDManager.cxx:620
 TGDNDManager.cxx:621
 TGDNDManager.cxx:622
 TGDNDManager.cxx:623
 TGDNDManager.cxx:624
 TGDNDManager.cxx:625
 TGDNDManager.cxx:626
 TGDNDManager.cxx:627
 TGDNDManager.cxx:628
 TGDNDManager.cxx:629
 TGDNDManager.cxx:630
 TGDNDManager.cxx:631
 TGDNDManager.cxx:632
 TGDNDManager.cxx:633
 TGDNDManager.cxx:634
 TGDNDManager.cxx:635
 TGDNDManager.cxx:636
 TGDNDManager.cxx:637
 TGDNDManager.cxx:638
 TGDNDManager.cxx:639
 TGDNDManager.cxx:640
 TGDNDManager.cxx:641
 TGDNDManager.cxx:642
 TGDNDManager.cxx:643
 TGDNDManager.cxx:644
 TGDNDManager.cxx:645
 TGDNDManager.cxx:646
 TGDNDManager.cxx:647
 TGDNDManager.cxx:648
 TGDNDManager.cxx:649
 TGDNDManager.cxx:650
 TGDNDManager.cxx:651
 TGDNDManager.cxx:652
 TGDNDManager.cxx:653
 TGDNDManager.cxx:654
 TGDNDManager.cxx:655
 TGDNDManager.cxx:656
 TGDNDManager.cxx:657
 TGDNDManager.cxx:658
 TGDNDManager.cxx:659
 TGDNDManager.cxx:660
 TGDNDManager.cxx:661
 TGDNDManager.cxx:662
 TGDNDManager.cxx:663
 TGDNDManager.cxx:664
 TGDNDManager.cxx:665
 TGDNDManager.cxx:666
 TGDNDManager.cxx:667
 TGDNDManager.cxx:668
 TGDNDManager.cxx:669
 TGDNDManager.cxx:670
 TGDNDManager.cxx:671
 TGDNDManager.cxx:672
 TGDNDManager.cxx:673
 TGDNDManager.cxx:674
 TGDNDManager.cxx:675
 TGDNDManager.cxx:676
 TGDNDManager.cxx:677
 TGDNDManager.cxx:678
 TGDNDManager.cxx:679
 TGDNDManager.cxx:680
 TGDNDManager.cxx:681
 TGDNDManager.cxx:682
 TGDNDManager.cxx:683
 TGDNDManager.cxx:684
 TGDNDManager.cxx:685
 TGDNDManager.cxx:686
 TGDNDManager.cxx:687
 TGDNDManager.cxx:688
 TGDNDManager.cxx:689
 TGDNDManager.cxx:690
 TGDNDManager.cxx:691
 TGDNDManager.cxx:692
 TGDNDManager.cxx:693
 TGDNDManager.cxx:694
 TGDNDManager.cxx:695
 TGDNDManager.cxx:696
 TGDNDManager.cxx:697
 TGDNDManager.cxx:698
 TGDNDManager.cxx:699
 TGDNDManager.cxx:700
 TGDNDManager.cxx:701
 TGDNDManager.cxx:702
 TGDNDManager.cxx:703
 TGDNDManager.cxx:704
 TGDNDManager.cxx:705
 TGDNDManager.cxx:706
 TGDNDManager.cxx:707
 TGDNDManager.cxx:708
 TGDNDManager.cxx:709
 TGDNDManager.cxx:710
 TGDNDManager.cxx:711
 TGDNDManager.cxx:712
 TGDNDManager.cxx:713
 TGDNDManager.cxx:714
 TGDNDManager.cxx:715
 TGDNDManager.cxx:716
 TGDNDManager.cxx:717
 TGDNDManager.cxx:718
 TGDNDManager.cxx:719
 TGDNDManager.cxx:720
 TGDNDManager.cxx:721
 TGDNDManager.cxx:722
 TGDNDManager.cxx:723
 TGDNDManager.cxx:724
 TGDNDManager.cxx:725
 TGDNDManager.cxx:726
 TGDNDManager.cxx:727
 TGDNDManager.cxx:728
 TGDNDManager.cxx:729
 TGDNDManager.cxx:730
 TGDNDManager.cxx:731
 TGDNDManager.cxx:732
 TGDNDManager.cxx:733
 TGDNDManager.cxx:734
 TGDNDManager.cxx:735
 TGDNDManager.cxx:736
 TGDNDManager.cxx:737
 TGDNDManager.cxx:738
 TGDNDManager.cxx:739
 TGDNDManager.cxx:740
 TGDNDManager.cxx:741
 TGDNDManager.cxx:742
 TGDNDManager.cxx:743
 TGDNDManager.cxx:744
 TGDNDManager.cxx:745
 TGDNDManager.cxx:746
 TGDNDManager.cxx:747
 TGDNDManager.cxx:748
 TGDNDManager.cxx:749
 TGDNDManager.cxx:750
 TGDNDManager.cxx:751
 TGDNDManager.cxx:752
 TGDNDManager.cxx:753
 TGDNDManager.cxx:754
 TGDNDManager.cxx:755
 TGDNDManager.cxx:756
 TGDNDManager.cxx:757
 TGDNDManager.cxx:758
 TGDNDManager.cxx:759
 TGDNDManager.cxx:760
 TGDNDManager.cxx:761
 TGDNDManager.cxx:762
 TGDNDManager.cxx:763
 TGDNDManager.cxx:764
 TGDNDManager.cxx:765
 TGDNDManager.cxx:766
 TGDNDManager.cxx:767
 TGDNDManager.cxx:768
 TGDNDManager.cxx:769
 TGDNDManager.cxx:770
 TGDNDManager.cxx:771
 TGDNDManager.cxx:772
 TGDNDManager.cxx:773
 TGDNDManager.cxx:774
 TGDNDManager.cxx:775
 TGDNDManager.cxx:776
 TGDNDManager.cxx:777
 TGDNDManager.cxx:778
 TGDNDManager.cxx:779
 TGDNDManager.cxx:780
 TGDNDManager.cxx:781
 TGDNDManager.cxx:782
 TGDNDManager.cxx:783
 TGDNDManager.cxx:784
 TGDNDManager.cxx:785
 TGDNDManager.cxx:786
 TGDNDManager.cxx:787
 TGDNDManager.cxx:788
 TGDNDManager.cxx:789
 TGDNDManager.cxx:790
 TGDNDManager.cxx:791
 TGDNDManager.cxx:792
 TGDNDManager.cxx:793
 TGDNDManager.cxx:794
 TGDNDManager.cxx:795
 TGDNDManager.cxx:796
 TGDNDManager.cxx:797
 TGDNDManager.cxx:798
 TGDNDManager.cxx:799
 TGDNDManager.cxx:800
 TGDNDManager.cxx:801
 TGDNDManager.cxx:802
 TGDNDManager.cxx:803
 TGDNDManager.cxx:804
 TGDNDManager.cxx:805
 TGDNDManager.cxx:806
 TGDNDManager.cxx:807
 TGDNDManager.cxx:808
 TGDNDManager.cxx:809
 TGDNDManager.cxx:810
 TGDNDManager.cxx:811
 TGDNDManager.cxx:812
 TGDNDManager.cxx:813
 TGDNDManager.cxx:814
 TGDNDManager.cxx:815
 TGDNDManager.cxx:816
 TGDNDManager.cxx:817
 TGDNDManager.cxx:818
 TGDNDManager.cxx:819
 TGDNDManager.cxx:820
 TGDNDManager.cxx:821
 TGDNDManager.cxx:822
 TGDNDManager.cxx:823
 TGDNDManager.cxx:824
 TGDNDManager.cxx:825
 TGDNDManager.cxx:826
 TGDNDManager.cxx:827
 TGDNDManager.cxx:828
 TGDNDManager.cxx:829
 TGDNDManager.cxx:830
 TGDNDManager.cxx:831
 TGDNDManager.cxx:832
 TGDNDManager.cxx:833
 TGDNDManager.cxx:834
 TGDNDManager.cxx:835
 TGDNDManager.cxx:836
 TGDNDManager.cxx:837
 TGDNDManager.cxx:838
 TGDNDManager.cxx:839
 TGDNDManager.cxx:840
 TGDNDManager.cxx:841
 TGDNDManager.cxx:842
 TGDNDManager.cxx:843
 TGDNDManager.cxx:844
 TGDNDManager.cxx:845
 TGDNDManager.cxx:846
 TGDNDManager.cxx:847
 TGDNDManager.cxx:848
 TGDNDManager.cxx:849
 TGDNDManager.cxx:850
 TGDNDManager.cxx:851
 TGDNDManager.cxx:852
 TGDNDManager.cxx:853
 TGDNDManager.cxx:854
 TGDNDManager.cxx:855
 TGDNDManager.cxx:856
 TGDNDManager.cxx:857
 TGDNDManager.cxx:858
 TGDNDManager.cxx:859
 TGDNDManager.cxx:860
 TGDNDManager.cxx:861
 TGDNDManager.cxx:862
 TGDNDManager.cxx:863
 TGDNDManager.cxx:864
 TGDNDManager.cxx:865
 TGDNDManager.cxx:866
 TGDNDManager.cxx:867
 TGDNDManager.cxx:868
 TGDNDManager.cxx:869
 TGDNDManager.cxx:870
 TGDNDManager.cxx:871
 TGDNDManager.cxx:872
 TGDNDManager.cxx:873
 TGDNDManager.cxx:874
 TGDNDManager.cxx:875
 TGDNDManager.cxx:876
 TGDNDManager.cxx:877
 TGDNDManager.cxx:878
 TGDNDManager.cxx:879
 TGDNDManager.cxx:880
 TGDNDManager.cxx:881
 TGDNDManager.cxx:882
 TGDNDManager.cxx:883
 TGDNDManager.cxx:884
 TGDNDManager.cxx:885
 TGDNDManager.cxx:886
 TGDNDManager.cxx:887
 TGDNDManager.cxx:888
 TGDNDManager.cxx:889
 TGDNDManager.cxx:890
 TGDNDManager.cxx:891
 TGDNDManager.cxx:892
 TGDNDManager.cxx:893
 TGDNDManager.cxx:894
 TGDNDManager.cxx:895
 TGDNDManager.cxx:896
 TGDNDManager.cxx:897
 TGDNDManager.cxx:898
 TGDNDManager.cxx:899
 TGDNDManager.cxx:900
 TGDNDManager.cxx:901
 TGDNDManager.cxx:902
 TGDNDManager.cxx:903
 TGDNDManager.cxx:904
 TGDNDManager.cxx:905
 TGDNDManager.cxx:906
 TGDNDManager.cxx:907
 TGDNDManager.cxx:908
 TGDNDManager.cxx:909
 TGDNDManager.cxx:910
 TGDNDManager.cxx:911
 TGDNDManager.cxx:912
 TGDNDManager.cxx:913
 TGDNDManager.cxx:914
 TGDNDManager.cxx:915
 TGDNDManager.cxx:916
 TGDNDManager.cxx:917
 TGDNDManager.cxx:918
 TGDNDManager.cxx:919
 TGDNDManager.cxx:920
 TGDNDManager.cxx:921
 TGDNDManager.cxx:922
 TGDNDManager.cxx:923
 TGDNDManager.cxx:924
 TGDNDManager.cxx:925
 TGDNDManager.cxx:926
 TGDNDManager.cxx:927
 TGDNDManager.cxx:928
 TGDNDManager.cxx:929
 TGDNDManager.cxx:930
 TGDNDManager.cxx:931
 TGDNDManager.cxx:932
 TGDNDManager.cxx:933
 TGDNDManager.cxx:934
 TGDNDManager.cxx:935
 TGDNDManager.cxx:936
 TGDNDManager.cxx:937
 TGDNDManager.cxx:938
 TGDNDManager.cxx:939
 TGDNDManager.cxx:940
 TGDNDManager.cxx:941
 TGDNDManager.cxx:942
 TGDNDManager.cxx:943
 TGDNDManager.cxx:944
 TGDNDManager.cxx:945
 TGDNDManager.cxx:946
 TGDNDManager.cxx:947
 TGDNDManager.cxx:948
 TGDNDManager.cxx:949
 TGDNDManager.cxx:950
 TGDNDManager.cxx:951
 TGDNDManager.cxx:952
 TGDNDManager.cxx:953
 TGDNDManager.cxx:954
 TGDNDManager.cxx:955
 TGDNDManager.cxx:956
 TGDNDManager.cxx:957
 TGDNDManager.cxx:958
 TGDNDManager.cxx:959
 TGDNDManager.cxx:960
 TGDNDManager.cxx:961
 TGDNDManager.cxx:962
 TGDNDManager.cxx:963
 TGDNDManager.cxx:964
 TGDNDManager.cxx:965
 TGDNDManager.cxx:966
 TGDNDManager.cxx:967
 TGDNDManager.cxx:968
 TGDNDManager.cxx:969
 TGDNDManager.cxx:970
 TGDNDManager.cxx:971
 TGDNDManager.cxx:972
 TGDNDManager.cxx:973
 TGDNDManager.cxx:974
 TGDNDManager.cxx:975
 TGDNDManager.cxx:976
 TGDNDManager.cxx:977
 TGDNDManager.cxx:978
 TGDNDManager.cxx:979
 TGDNDManager.cxx:980
 TGDNDManager.cxx:981
 TGDNDManager.cxx:982
 TGDNDManager.cxx:983
 TGDNDManager.cxx:984
 TGDNDManager.cxx:985
 TGDNDManager.cxx:986
 TGDNDManager.cxx:987
 TGDNDManager.cxx:988
 TGDNDManager.cxx:989
 TGDNDManager.cxx:990
 TGDNDManager.cxx:991
 TGDNDManager.cxx:992
 TGDNDManager.cxx:993
 TGDNDManager.cxx:994
 TGDNDManager.cxx:995
 TGDNDManager.cxx:996
 TGDNDManager.cxx:997
 TGDNDManager.cxx:998
 TGDNDManager.cxx:999
 TGDNDManager.cxx:1000
 TGDNDManager.cxx:1001
 TGDNDManager.cxx:1002
 TGDNDManager.cxx:1003
 TGDNDManager.cxx:1004
 TGDNDManager.cxx:1005
 TGDNDManager.cxx:1006
 TGDNDManager.cxx:1007
 TGDNDManager.cxx:1008
 TGDNDManager.cxx:1009
 TGDNDManager.cxx:1010
 TGDNDManager.cxx:1011
 TGDNDManager.cxx:1012
 TGDNDManager.cxx:1013
 TGDNDManager.cxx:1014
 TGDNDManager.cxx:1015
 TGDNDManager.cxx:1016
 TGDNDManager.cxx:1017
 TGDNDManager.cxx:1018
 TGDNDManager.cxx:1019
 TGDNDManager.cxx:1020
 TGDNDManager.cxx:1021
 TGDNDManager.cxx:1022
 TGDNDManager.cxx:1023
 TGDNDManager.cxx:1024
 TGDNDManager.cxx:1025
 TGDNDManager.cxx:1026
 TGDNDManager.cxx:1027
 TGDNDManager.cxx:1028
 TGDNDManager.cxx:1029
 TGDNDManager.cxx:1030
 TGDNDManager.cxx:1031
 TGDNDManager.cxx:1032
 TGDNDManager.cxx:1033
 TGDNDManager.cxx:1034
 TGDNDManager.cxx:1035
 TGDNDManager.cxx:1036
 TGDNDManager.cxx:1037
 TGDNDManager.cxx:1038
 TGDNDManager.cxx:1039
 TGDNDManager.cxx:1040
 TGDNDManager.cxx:1041
 TGDNDManager.cxx:1042
 TGDNDManager.cxx:1043
 TGDNDManager.cxx:1044
 TGDNDManager.cxx:1045
 TGDNDManager.cxx:1046
 TGDNDManager.cxx:1047
 TGDNDManager.cxx:1048
 TGDNDManager.cxx:1049
 TGDNDManager.cxx:1050
 TGDNDManager.cxx:1051
 TGDNDManager.cxx:1052
 TGDNDManager.cxx:1053
 TGDNDManager.cxx:1054
 TGDNDManager.cxx:1055
 TGDNDManager.cxx:1056
 TGDNDManager.cxx:1057
 TGDNDManager.cxx:1058
 TGDNDManager.cxx:1059
 TGDNDManager.cxx:1060
 TGDNDManager.cxx:1061
 TGDNDManager.cxx:1062
 TGDNDManager.cxx:1063
 TGDNDManager.cxx:1064
 TGDNDManager.cxx:1065
 TGDNDManager.cxx:1066
 TGDNDManager.cxx:1067
 TGDNDManager.cxx:1068
 TGDNDManager.cxx:1069
 TGDNDManager.cxx:1070
 TGDNDManager.cxx:1071
 TGDNDManager.cxx:1072
 TGDNDManager.cxx:1073
 TGDNDManager.cxx:1074