Changeset 49891 in vbox for trunk/src/VBox/Additions/x11/VBoxClient
- Timestamp:
- Dec 12, 2013 8:09:20 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91269
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/VBox-4.1 merged: 85944-85947,85949-85950,85953,86701,86728,87009 /branches/andy/draganddrop (added) merged: 90781-91268
- Property svn:mergeinfo changed
-
trunk/src/VBox
- Property svn:mergeinfo changed
/branches/andy/draganddrop/src/VBox (added) merged: 90781-91268
- Property svn:mergeinfo changed
-
trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
r49455 r49891 4 4 5 5 /* 6 * Copyright (C) 2011-201 2Oracle Corporation6 * Copyright (C) 2011-2013 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 55 55 * G->H: 56 56 * This is a lot more trickery than H->G. When a pending event from HGCM 57 * arrives, we ask s if there is currentlyan owner of the XdndSelection57 * arrives, we ask if there currently is an owner of the XdndSelection 58 58 * property. If so, our proxy window is shown (1x1, but without backing store) 59 59 * and some mouse event is triggered. This should be followed by an XdndEnter … … 65 65 * Todo: 66 66 * - this isn't finished, yet. Currently the mouse isn't correctly released 67 * in the guest (both, when the drop was successfully or canceled).67 * in the guest (both, when the drop was successfully or canceled). 68 68 * - cancel (e.g. with the ESC key) doesn't work 69 69 * … … 74 74 * - really check for the Xdnd version and the supported features 75 75 */ 76 77 #define VERBOSE 178 79 #if defined(VERBOSE) && defined(DEBUG_poetzsch)80 # include <iprt/stream.h>81 # define DO(s) RTPrintf s82 #else83 # define DO(s) do {} while (0)84 //# define DO(s) Log s85 #endif86 76 87 77 #define VBOX_XDND_VERSION (4) … … 154 144 public: 155 145 156 static xHelpers * instance(Display *pDisplay = 0)146 static xHelpers *getInstance(Display *pDisplay = 0) 157 147 { 158 148 if (!m_pInstance) 159 149 { 160 AssertPtrReturn(pDisplay, 0);150 AssertPtrReturn(pDisplay, NULL); 161 151 m_pInstance = new xHelpers(pDisplay); 162 152 } 153 163 154 return m_pInstance; 164 155 } … … 211 202 212 203 /* Some xHelpers convenience defines. */ 213 #define gX11 xHelpers:: instance()204 #define gX11 xHelpers::getInstance() 214 205 #define xAtom(xa) gX11->xAtom((xa)) 215 206 #define xAtomToString(xa) gX11->xAtomToString((xa)) … … 285 276 286 277 /* Todo: make this iterative */ 287 Window xHelpers::applicationWindowBelowCursor(Window parentWin) const278 Window xHelpers::applicationWindowBelowCursor(Window wndParent) const 288 279 { 289 280 /* No parent, nothing to do. */ 290 if( parentWin== 0)281 if(wndParent == 0) 291 282 return 0; 292 283 293 Window appWin= 0;284 Window wndApp = 0; 294 285 int cProps = -1; 295 286 /* Fetch all x11 window properties of the parent window. */ 296 Atom *pProps = XListProperties(m_pDisplay, parentWin, &cProps);287 Atom *pProps = XListProperties(m_pDisplay, wndParent, &cProps); 297 288 if (cProps > 0) 298 289 { 299 290 /* We check the window for the WM_STATE property. */ 300 for (int i = 0; i < cProps; ++i)301 if (pProps[i] == xAtom(XA_WM_STATE))291 for (int i = 0; i < cProps; ++i) 292 if (pProps[i] == xAtom(XA_WM_STATE)) 302 293 { 303 294 /* Found it. */ 304 appWin = parentWin;295 wndApp = wndParent; 305 296 break; 306 297 } … … 309 300 } 310 301 311 if (! appWin)312 { 313 Window childWin, wtmp;302 if (!wndApp) 303 { 304 Window wndChild, wndTemp; 314 305 int tmp; 315 306 unsigned int utmp; 316 307 /* Query the next child window of the parent window at the current 317 308 * mouse position. */ 318 XQueryPointer(m_pDisplay, parentWin, &wtmp, &childWin, &tmp, &tmp, &tmp, &tmp, &utmp);309 XQueryPointer(m_pDisplay, wndParent, &wndTemp, &wndChild, &tmp, &tmp, &tmp, &tmp, &utmp); 319 310 /* Recursive call our self to dive into the child tree. */ 320 appWin = applicationWindowBelowCursor(childWin);321 } 322 323 return appWin;311 wndApp = applicationWindowBelowCursor(wndChild); 312 } 313 314 return wndApp; 324 315 } 325 316 … … 390 381 391 382 /* Member vars */ 383 uint32_t m_uClientID; 392 384 DragAndDropService *m_pParent; 393 385 Display *m_pDisplay; 394 386 int m_screenId; 395 387 Screen *m_pScreen; 396 Window m_ rootWin;397 Window m_ proxyWin;398 Window m_ curWin;388 Window m_wndRoot; 389 Window m_wndProxy; 390 Window m_wndCur; 399 391 long m_curVer; 400 392 RTCList<Atom> m_formats; … … 418 410 { 419 411 public: 420 DragAndDropService( )412 DragAndDropService(void) 421 413 : m_pDisplay(0) 422 414 , m_hHGCMThread(NIL_RTTHREAD) … … 433 425 virtual int run(bool fDaemonised = false); 434 426 435 virtual void cleanup( )427 virtual void cleanup(void) 436 428 { 437 429 /* Cleanup */ 438 430 x11DragAndDropTerm(); 439 VbglR3DnDTerm();440 431 }; 441 432 442 433 private: 443 int x11DragAndDropInit( );444 int x11DragAndDropTerm( );434 int x11DragAndDropInit(void); 435 int x11DragAndDropTerm(void); 445 436 static int hgcmEventThread(RTTHREAD hThread, void *pvUser); 446 437 static int x11EventThread(RTTHREAD hThread, void *pvUser); … … 451 442 * Unfortunately this doesn't work exactly with the events we need. So we 452 443 * use this predicate method below and XCheckIfEvent. */ 453 static Bool isDnDRespondEvent(Display * /* pDisplay */, XEvent *pEvent, char *pUser)444 static bool isDnDRespondEvent(Display * /* pDisplay */, XEvent *pEvent, char *pUser) 454 445 { 455 446 if (!pEvent) 456 return False;447 return false; 457 448 if ( pEvent->type == SelectionClear 458 449 || pEvent->type == ClientMessage … … 463 454 // || ( pEvent->type == SelectionRequest 464 455 // && reinterpret_cast<XSelectionRequestEvent*>(pEvent)->requestor == reinterpret_cast<Window>(pUser))) 465 return True;466 return False;456 return true; 457 return false; 467 458 } 468 459 … … 487 478 488 479 DragInstance::DragInstance(Display *pDisplay, DragAndDropService *pParent) 489 : m_pParent(pParent) 480 : m_uClientID(0) 481 , m_pParent(pParent) 490 482 , m_pDisplay(pDisplay) 491 483 , m_pScreen(0) 492 , m_ rootWin(0)493 , m_ proxyWin(0)494 , m_ curWin(0)484 , m_wndRoot(0) 485 , m_wndProxy(0) 486 , m_wndCur(0) 495 487 , m_curVer(-1) 496 488 , m_mode(Unknown) … … 500 492 } 501 493 502 void DragInstance::uninit( )494 void DragInstance::uninit(void) 503 495 { 504 496 reset(); 505 if (m_proxyWin != 0) 506 XDestroyWindow(m_pDisplay, m_proxyWin); 497 if (m_wndProxy != 0) 498 XDestroyWindow(m_pDisplay, m_wndProxy); 499 500 if (m_uClientID) 501 { 502 VbglR3DnDDisconnect(m_uClientID); 503 m_uClientID = 0; 504 } 505 507 506 m_state = Uninitialized; 508 507 m_screenId = -1; 509 508 m_pScreen = 0; 510 m_ rootWin= 0;511 m_ proxyWin= 0;512 } 513 514 void DragInstance::reset( )509 m_wndRoot = 0; 510 m_wndProxy = 0; 511 } 512 513 void DragInstance::reset(void) 515 514 { 516 515 /* Hide the proxy win. */ … … 518 517 /* If we are currently the Xdnd selection owner, clear that. */ 519 518 Window w = XGetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection)); 520 if (w == m_ proxyWin)519 if (w == m_wndProxy) 521 520 XSetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection), None, CurrentTime); 522 521 /* Clear any other DnD specific data on the proxy win. */ 523 clearFormatsWindowProperty(m_ proxyWin);524 clearActionsWindowProperty(m_ proxyWin);522 clearFormatsWindowProperty(m_wndProxy); 523 clearActionsWindowProperty(m_wndProxy); 525 524 /* Reset the internal state. */ 526 525 m_formats.clear(); 527 m_ curWin= 0;526 m_wndCur = 0; 528 527 m_curVer = -1; 529 528 m_state = Initialized; … … 546 545 int DragInstance::init(uint32_t u32ScreenId) 547 546 { 548 int rc = VINF_SUCCESS; 547 int rc; 548 549 549 do 550 550 { 551 551 uninit(); 552 /* Enough screens configured in the x11 server? */ 552 553 rc = VbglR3DnDConnect(&m_uClientID); 554 if (RT_FAILURE(rc)) 555 break; 556 557 /* 558 * Enough screens configured in the x11 server? 559 */ 553 560 if ((int)u32ScreenId > ScreenCount(m_pDisplay)) 554 561 { 555 rc = VERR_ GENERAL_FAILURE;562 rc = VERR_INVALID_PARAMETER; 556 563 break; 557 564 } … … 565 572 m_screenId = u32ScreenId; 566 573 /* Now query the corresponding root window of this screen. */ 567 m_ rootWin= RootWindow(m_pDisplay, m_screenId);568 if (!m_ rootWin)574 m_wndRoot = RootWindow(m_pDisplay, m_screenId); 575 if (!m_wndRoot) 569 576 { 570 577 rc = VERR_GENERAL_FAILURE; 571 578 break; 572 579 } 573 /* Create an invisible window which will act as proxy for the DnD 580 581 /* 582 * Create an invisible window which will act as proxy for the DnD 574 583 * operation. This window will be used for both the GH and HG 575 * direction. */ 584 * direction. 585 */ 576 586 XSetWindowAttributes attr; 577 587 RT_ZERO(attr); 578 588 attr.do_not_propagate_mask = 0; 579 589 attr.override_redirect = True; 580 // attr.background_pixel = WhitePixel(m_pDisplay, m_screenId); 581 m_proxyWin = XCreateWindow(m_pDisplay, m_rootWin, 0, 0, 1, 1, 0, 590 #if 0 591 attr.background_pixel = WhitePixel(m_pDisplay, m_screenId); 592 #endif 593 m_wndProxy = XCreateWindow(m_pDisplay, m_wndRoot, 0, 0, 1, 1, 0, 582 594 CopyFromParent, InputOnly, CopyFromParent, 583 595 CWOverrideRedirect | CWDontPropagate, 584 596 &attr); 585 586 // m_proxyWin = XCreateSimpleWindow(m_pDisplay, m_rootWin, 0, 0, 50, 50, 0, WhitePixel(m_pDisplay, m_screenId), WhitePixel(m_pDisplay, m_screenId)); 587 588 if (!m_proxyWin) 597 #ifdef DEBUG_andy 598 m_wndProxy = XCreateSimpleWindow(m_pDisplay, m_wndRoot, 0, 0, 50, 50, 0, 599 WhitePixel(m_pDisplay, m_screenId), 600 WhitePixel(m_pDisplay, m_screenId)); 601 #endif 602 if (!m_wndProxy) 589 603 { 590 604 rc = VERR_GENERAL_FAILURE; 591 605 break; 592 606 } 607 593 608 /* Make the new window Xdnd aware. */ 594 609 Atom ver = VBOX_XDND_VERSION; 595 XChangeProperty(m_pDisplay, m_ proxyWin, xAtom(XA_XdndAware), XA_ATOM, 32, PropModeReplace,610 XChangeProperty(m_pDisplay, m_wndProxy, xAtom(XA_XdndAware), XA_ATOM, 32, PropModeReplace, 596 611 reinterpret_cast<unsigned char*>(&ver), 1); 597 612 } while (0); 598 613 599 m_state = Initialized; 600 614 if (RT_SUCCESS(rc)) 615 m_state = Initialized; 616 617 LogFlowFuncLeaveRC(rc); 601 618 return rc; 602 619 } … … 606 623 */ 607 624 608 int DragInstance::hgEnter(const RTCList<RTCString> &formats, uint32_t actions) 609 { 610 int rc = VINF_SUCCESS; 611 625 int DragInstance::hgEnter(const RTCList<RTCString> &formats, uint32_t uActions) 626 { 612 627 reset(); 613 DO(("DnD_ENTR: formats=%u: ", formats.size())); 614 #if defined(VERBOSE) && defined(DEBUG_poetzsch) 628 629 #ifdef DEBUG 630 LogFlowThisFunc(("uActions=0x%x, lstFormats=%zu: ", uActions, formats.size())); 615 631 for (size_t i = 0; i < formats.size(); ++i) 616 DO(("'%s' ", formats.at(i).c_str()));617 #endif /* DEBUG */ 618 DO(("\n")); 632 LogFlow(("'%s' ", formats.at(i).c_str())); 633 LogFlow(("\n")); 634 #endif 619 635 620 636 m_formats = toAtomList(formats); … … 622 638 /* If we have more than 3 formats we have to use the type list extension. */ 623 639 if (m_formats.size() > 3) 624 setFormatsWindowProperty(m_ proxyWin, xAtom(XA_XdndTypeList));640 setFormatsWindowProperty(m_wndProxy, xAtom(XA_XdndTypeList)); 625 641 626 642 /* Announce the possible actions */ 627 setActionsWindowProperty(m_ proxyWin, toX11Actions(actions));643 setActionsWindowProperty(m_wndProxy, toX11Actions(uActions)); 628 644 629 645 /* Set the DnD selection owner to our window. */ 630 XSetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection), m_ proxyWin, CurrentTime);646 XSetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection), m_wndProxy, CurrentTime); 631 647 632 648 m_mode = HG; 633 649 m_state = Dragging; 634 650 635 return rc; 636 } 637 638 int DragInstance::hgMove(uint32_t u32xPos, uint32_t u32yPos, uint32_t action) 639 { 640 DO(("DnD_MOVE: ")); 651 return VINF_SUCCESS; 652 } 653 654 int DragInstance::hgMove(uint32_t u32xPos, uint32_t u32yPos, uint32_t uAction) 655 { 656 LogFlowThisFunc(("u32xPos=%RU32, u32yPos=%RU32, uAction=%RU32\n", 657 u32xPos, u32yPos, uAction)); 641 658 642 659 if ( m_mode != HG … … 650 667 moveCursor(u32xPos, u32yPos); 651 668 652 Window newWin = None; /* Default to _no_ window below the cursor. */ 653 long newVer = -1; /* This means the current window is _not_ XdndAware. */ 669 long newVer = -1; /* This means the current window is _not_ XdndAware. */ 654 670 655 671 /* Search for the application window below the cursor. */ 656 newWin = gX11->applicationWindowBelowCursor(m_rootWin);657 if ( newWin!= None)672 Window wndCursor = gX11->applicationWindowBelowCursor(m_wndRoot); 673 if (wndCursor != None) 658 674 { 659 675 /* Temp stuff for the XGetWindowProperty call. */ … … 662 678 unsigned long cItems, cbRemaining; 663 679 unsigned char *pcData = NULL; 680 664 681 /* Query the XdndAware property from the window. We are interested in 665 682 * the version and if it is XdndAware at all. */ 666 xrc = XGetWindowProperty(m_pDisplay, newWin, xAtom(XA_XdndAware), 0, 2, False, AnyPropertyType, &atmp, &fmt, &cItems, &cbRemaining, &pcData); 683 xrc = XGetWindowProperty(m_pDisplay, wndCursor, xAtom(XA_XdndAware), 684 0, 2, False, AnyPropertyType, 685 &atmp, &fmt, &cItems, &cbRemaining, &pcData); 667 686 if (RT_UNLIKELY(xrc != Success)) 668 DO(("DnD_MOVE: error in getting the window property (%s)\n", gX11->xErrorToString(xrc).c_str()));687 LogFlowThisFunc(("Error in getting the window property: %s\n", gX11->xErrorToString(xrc).c_str())); 669 688 else 670 689 { 671 690 if (RT_UNLIKELY(pcData == NULL || fmt != 32 || cItems != 1)) 672 DO(("Prop=error[data=%#x,fmt=%u,items=%u]", pcData, fmt, cItems));691 LogFlowThisFunc(("Wrong properties pcData=%#x, iFmt=%u, cItems=%u\n", pcData, fmt, cItems)); 673 692 else 674 693 { 675 694 newVer = reinterpret_cast<long*>(pcData)[0]; 676 DO(("XdndAware=%u", newVer));695 LogFlowThisFunc(("wndCursor=%#x, XdndAware=%u\n", newVer)); 677 696 } 678 697 XFree(pcData); … … 680 699 } 681 700 682 if (newWin != m_curWin && m_curVer != -1) 683 { 684 DO(("leave=%#x ", m_curWin)); 701 /* 702 * Is the window under the cursor another one than our current one? 703 */ 704 if (wndCursor != m_wndCur && m_curVer != -1) 705 { 706 LogFlowThisFunc(("Leaving window=%#x\n", m_wndCur)); 685 707 686 708 /* We left the current XdndAware window. Announce this to the window. */ 687 688 709 XClientMessageEvent m; 689 710 RT_ZERO(m); 690 711 m.type = ClientMessage; 691 712 m.display = m_pDisplay; 692 m.window = m_ curWin;713 m.window = m_wndCur; 693 714 m.message_type = xAtom(XA_XdndLeave); 694 715 m.format = 32; 695 m.data.l[0] = m_ proxyWin;696 697 xrc = XSendEvent(m_pDisplay, m_ curWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));716 m.data.l[0] = m_wndProxy; 717 718 xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 698 719 if (RT_UNLIKELY(xrc == 0)) 699 DO(("DnD_MOVE: error sending xevent\n")); 700 } 701 702 if (newWin != m_curWin && newVer != -1) 703 { 704 DO(("enter=%#x ", newWin)); 705 706 /* We enter a new window. Announce the XdndEnter event to the new 720 LogFlowThisFunc(("Error sending XA_XdndLeave to old window=%#x\n", m_wndCur)); 721 } 722 723 /* 724 * Do we have a new window which now is under the cursor? 725 */ 726 if (wndCursor != m_wndCur && newVer != -1) 727 { 728 LogFlowThisFunc(("Entering window=%#x\n", wndCursor)); 729 730 /* 731 * We enter a new window. Announce the XdndEnter event to the new 707 732 * window. The first three mime types are attached to the event (the 708 733 * others could be requested by the XdndTypeList property from the 709 * window itself). */710 734 * window itself). 735 */ 711 736 XClientMessageEvent m; 712 737 RT_ZERO(m); 713 738 m.type = ClientMessage; 714 739 m.display = m_pDisplay; 715 m.window = newWin;740 m.window = wndCursor; 716 741 m.message_type = xAtom(XA_XdndEnter); 717 742 m.format = 32; 718 m.data.l[0] = m_ proxyWin;743 m.data.l[0] = m_wndProxy; 719 744 m.data.l[1] = RT_MAKE_U32_FROM_U8(m_formats.size() > 3 ? 1 : 0, 0, 0, RT_MIN(VBOX_XDND_VERSION, newVer)); 720 745 m.data.l[2] = m_formats.value(0, None); … … 722 747 m.data.l[4] = m_formats.value(2, None); 723 748 724 xrc = XSendEvent(m_pDisplay, newWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));749 xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 725 750 if (RT_UNLIKELY(xrc == 0)) 726 DO(("DnD_MOVE: error sending xevent\n"));751 LogFlowThisFunc(("Error sending XA_XdndEnter to new window=%#x\n", wndCursor)); 727 752 } 728 753 729 754 if (newVer != -1) 730 755 { 731 DO(("move=%#x pos=%ux%u ", newWin, u32xPos, u32yPos)); 732 733 /* Send a XdndPosition event with the proposed action to the guest. */ 734 735 Atom pa = toX11Action(action); 736 DO(("action='%s' ", xAtomToString(pa).c_str())); 756 LogFlowThisFunc(("Moving window=%#x, xPos=%RU32, yPos=%RU32\n", 757 wndCursor, u32xPos, u32yPos)); 758 759 /* 760 * Send a XdndPosition event with the proposed action to the guest. 761 */ 762 Atom pa = toX11Action(uAction); 763 LogFlowThisFunc(("strAction='%s' ", xAtomToString(pa).c_str())); 737 764 738 765 XClientMessageEvent m; … … 740 767 m.type = ClientMessage; 741 768 m.display = m_pDisplay; 742 m.window = newWin;769 m.window = wndCursor; 743 770 m.message_type = xAtom(XA_XdndPosition); 744 771 m.format = 32; 745 m.data.l[0] = m_ proxyWin;772 m.data.l[0] = m_wndProxy; 746 773 m.data.l[2] = RT_MAKE_U32(u32yPos, u32xPos); 747 774 m.data.l[3] = CurrentTime; 748 775 m.data.l[4] = pa; 749 776 750 xrc = XSendEvent(m_pDisplay, newWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));777 xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 751 778 if (RT_UNLIKELY(xrc == 0)) 752 DO(("DnD_MOVE: error sending xevent\n")); 753 } 754 if (newWin == None && newVer == -1) 779 LogFlowThisFunc(("Error sending XA_XdndPosition to window=%#x\n", wndCursor)); 780 } 781 782 if (wndCursor == None && newVer == -1) 783 { 755 784 /* No window to process, so send a ignore ack event to the host. */ 756 rc = VbglR3DnDHGAcknowledgeOperation(DND_IGNORE_ACTION); 757 758 m_curWin = newWin; 785 rc = VbglR3DnDHGAcknowledgeOperation(m_uClientID, DND_IGNORE_ACTION); 786 } 787 788 m_wndCur = wndCursor; 759 789 m_curVer = RT_MIN(VBOX_XDND_VERSION, newVer); 760 790 761 DO(("\n")); 762 791 LogFlowFuncLeaveRC(rc); 763 792 return rc; 764 793 } … … 774 803 int rc = VINF_SUCCESS; 775 804 if ( e.xclient.message_type == xAtom(XA_XdndStatus) 776 && m_ curWin== static_cast<Window>(e.xclient.data.l[0]))805 && m_wndCur == static_cast<Window>(e.xclient.data.l[0])) 777 806 { 778 807 /* The XdndStatus message tell us if the window will accept the DnD 779 808 * event and with which action. We immediately send this info down to 780 809 * the host as a response of a previous DnD message. */ 781 DO(("DnD_STAT: win=%#x,accept=%RTbool,action='%s'\n", 782 e.xclient.data.l[0], 783 ASMBitTest(&e.xclient.data.l[1], 0), 784 xAtomToString(e.xclient.data.l[4]).c_str())); 810 LogFlowThisFunc(("XA_XdndStatus wnd=%#x, accept=%RTbool, action='%s'\n", 811 e.xclient.data.l[0], 812 ASMBitTest(&e.xclient.data.l[1], 0), 813 xAtomToString(e.xclient.data.l[4]).c_str())); 814 785 815 uint32_t uAction = DND_IGNORE_ACTION; 786 /* Todo: compare this with the allowed actions. */816 /** @todo Compare this with the allowed actions. */ 787 817 if (ASMBitTest(&e.xclient.data.l[1], 0)) 788 818 uAction = toHGCMAction(static_cast<Atom>(e.xclient.data.l[4])); 789 rc = VbglR3DnDHGAcknowledgeOperation(uAction); 819 820 rc = VbglR3DnDHGAcknowledgeOperation(m_uClientID, uAction); 790 821 } 791 822 else if (e.xclient.message_type == xAtom(XA_XdndFinished)) 792 823 { 793 824 /* This message is send on a un/successful DnD drop request. */ 794 DO(("DnD_FINI: win=%#x,success=%RTbool,action='%s'\n",825 LogFlowThisFunc(("XA_XdndFinished: wnd=%#x, success=%RTbool, action='%s'\n", 795 826 e.xclient.data.l[0], 796 827 ASMBitTest(&e.xclient.data.l[1], 0), 797 828 xAtomToString(e.xclient.data.l[2]).c_str())); 829 798 830 reset(); 799 831 } 800 832 else 801 DO(("DnD_CLI: win=%#x,msg='%s'\n", e.xclient.data.l[0], xAtomToString(e.xclient.message_type).c_str())); 833 LogFlowThisFunc(("Unhandled: wnd=%#x, msg='%s'\n", 834 e.xclient.data.l[0], xAtomToString(e.xclient.message_type).c_str())); 835 836 LogFlowFuncLeaveRC(rc); 802 837 return rc; 803 838 } 804 839 805 int DragInstance::hgDrop() 806 { 807 DO(("DnD_DROP: win=%#x\n", m_curWin)); 840 int DragInstance::hgDrop(void) 841 { 842 LogFlowThisFunc(("wndCur=%#x, mMode=%RU32, mState=%RU32\n", 843 m_wndCur, m_mode, m_state)); 808 844 809 845 if ( m_mode != HG … … 818 854 m.type = ClientMessage; 819 855 m.display = m_pDisplay; 820 m.window = m_ curWin;856 m.window = m_wndCur; 821 857 m.message_type = xAtom(XA_XdndDrop); 822 858 m.format = 32; 823 m.data.l[0] = m_ proxyWin;859 m.data.l[0] = m_wndProxy; 824 860 m.data.l[2] = CurrentTime; 825 861 826 int xrc = XSendEvent(m_pDisplay, m_ curWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));862 int xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 827 863 if (RT_UNLIKELY(xrc == 0)) 828 DO(("DnD_DROP: error sending xevent\n"));829 830 m_ curWin= None;864 LogFlowThisFunc(("Error sending XA_XdndDrop to window=%#x\n", m_wndCur)); 865 866 m_wndCur = None; 831 867 m_curVer = -1; 832 868 833 869 m_state = Dropped; 834 870 871 LogFlowFuncLeaveRC(rc); 835 872 return rc; 836 873 } … … 844 881 return VERR_INVALID_STATE; 845 882 846 DO(("DnD_SELR: owner=%#x,requestor=%#x,sel_atom='%s',tar_atom='%s',prop_atom='%s',time=%u\n",847 e.xselectionrequest.owner,848 e.xselectionrequest.requestor,849 xAtomToString(e.xselectionrequest.selection).c_str(),850 xAtomToString(e.xselectionrequest.target).c_str(),851 xAtomToString(e.xselectionrequest.property).c_str(),852 e.xselectionrequest.time));883 LogFlowThisFunc(("owner=%#x, requestor=%#x, sel_atom='%s', tar_atom='%s', prop_atom='%s', time=%u\n", 884 e.xselectionrequest.owner, 885 e.xselectionrequest.requestor, 886 xAtomToString(e.xselectionrequest.selection).c_str(), 887 xAtomToString(e.xselectionrequest.target).c_str(), 888 xAtomToString(e.xselectionrequest.property).c_str(), 889 e.xselectionrequest.time)); 853 890 854 891 int rc = VINF_SUCCESS; 855 892 856 /* A window is asking for some data. Normally here the data would be copied 893 /* 894 * A window is asking for some data. Normally here the data would be copied 857 895 * into the selection buffer and send to the requestor. Obviously we can't 858 896 * do that, cause we first need to ask the host for the data of the 859 897 * requested mime type. This is done and later answered with the correct 860 * data (s. dataReceived). */ 898 * data (s. dataReceived). 899 */ 861 900 862 901 /* Is the requestor asking for the possible mime types? */ 863 902 if(e.xselectionrequest.target == xAtom(XA_TARGETS)) 864 903 { 865 DO(("DnD_SELR: ask for target list\n")); 904 LogFlowThisFunc(("wnd=%#x asking for target list\n", e.xselectionrequest.requestor)); 905 866 906 /* If so, set the window property with the formats on the requestor 867 907 * window. */ 868 908 setFormatsWindowProperty(e.xselectionrequest.requestor, e.xselectionrequest.property); 909 869 910 XEvent s; 870 911 RT_ZERO(s); … … 876 917 s.xselection.target = e.xselectionrequest.target; 877 918 s.xselection.property = e.xselectionrequest.property; 919 878 920 int xrc = XSendEvent(e.xselection.display, e.xselectionrequest.requestor, False, 0, &s); 879 921 if (RT_UNLIKELY(xrc == 0)) 880 DO(("DnD_SELR: error sending xevent\n"));922 LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", e.xselectionrequest.requestor)); 881 923 } 882 924 /* Is the requestor asking for a specific mime type (we support)? */ 883 925 else if(m_formats.contains(e.xselectionrequest.target)) 884 926 { 885 DO(("DnD_SELR: ask for data (format='%s')\n", xAtomToString(e.xselectionrequest.target).c_str())); 927 LogFlowThisFunc(("wnd=%#x asking for data (format='%s')\n", 928 e.xselectionrequest.requestor, xAtomToString(e.xselectionrequest.target).c_str())); 929 886 930 /* If so, we need to inform the host about this request. Save the 887 931 * selection request event for later use. */ … … 889 933 // || m_curWin != e.xselectionrequest.requestor) 890 934 { 891 DO(("DnD_SELR: refuse\n")); 935 LogFlowThisFunc(("Refusing ...\n")); 936 892 937 XEvent s; 893 938 RT_ZERO(s); … … 899 944 s.xselection.target = None; 900 945 s.xselection.property = e.xselectionrequest.property; 946 901 947 int xrc = XSendEvent(e.xselection.display, e.xselectionrequest.requestor, False, 0, &s); 902 948 if (RT_UNLIKELY(xrc == 0)) 903 DO(("DnD_SELR: error sending xevent\n"));949 LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", e.xselectionrequest.requestor)); 904 950 } 905 951 else 906 952 { 953 LogFlowThisFunc(("Copying data from host ...\n")); 954 907 955 memcpy(&m_selEvent, &e, sizeof(XEvent)); 908 rc = VbglR3DnDHGRequestData( xAtomToString(e.xselectionrequest.target).c_str());956 rc = VbglR3DnDHGRequestData(m_uClientID, xAtomToString(e.xselectionrequest.target).c_str()); 909 957 } 910 958 } … … 912 960 else 913 961 { 914 DO(("DnD_SELR: refuse\n")); 962 LogFlowThisFunc(("Refusing unknown command\n")); 963 915 964 /* We don't understand this request message and therefore answer with an 916 965 * refusal messages. */ … … 926 975 int xrc = XSendEvent(e.xselection.display, e.xselectionrequest.requestor, False, 0, &s); 927 976 if (RT_UNLIKELY(xrc == 0)) 928 DO(("DnD_SELR: error sending xevent\n")); 929 } 930 977 LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", e.xselectionrequest.requestor)); 978 } 979 980 LogFlowFuncLeaveRC(rc); 931 981 return rc; 932 982 } … … 951 1001 memcpy(pvNewData, pvData, cData); 952 1002 953 /* The host send us the DnD data in the requested mime type. This allows us 1003 /* 1004 * The host send us the DnD data in the requested mime type. This allows us 954 1005 * to fill the XdndSelection property of the requestor window with the data 955 * and afterwards inform him about the new status. */ 1006 * and afterwards inform him about the new status. 1007 */ 956 1008 XEvent s; 957 1009 RT_ZERO(s); … … 965 1017 s.xselection.property = m_selEvent.xselectionrequest.property; 966 1018 967 DO(("DnD_SEND:owner=%#x,requestor=%#x,sel_atom='%s',tar_atom='%s',prop_atom='%s',time=%u\n",968 m_selEvent.xselectionrequest.owner,969 s.xselection.requestor,970 xAtomToString(s.xselection.selection).c_str(),971 xAtomToString(s.xselection.target).c_str(),972 xAtomToString(s.xselection.property).c_str(),973 s.xselection.time));1019 LogFlowThisFunc(("owner=%#x,requestor=%#x,sel_atom='%s',tar_atom='%s',prop_atom='%s',time=%u\n", 1020 m_selEvent.xselectionrequest.owner, 1021 s.xselection.requestor, 1022 xAtomToString(s.xselection.selection).c_str(), 1023 xAtomToString(s.xselection.target).c_str(), 1024 xAtomToString(s.xselection.property).c_str(), 1025 s.xselection.time)); 974 1026 975 1027 /* Fill up the property with the data. */ … … 978 1030 int xrc = XSendEvent(s.xselection.display, s.xselection.requestor, True, 0, &s); 979 1031 if (RT_UNLIKELY(xrc == 0)) 980 DO(("DnD_SEND: error sending xevent\n"));1032 LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", s.xselection.requestor)); 981 1033 982 1034 return VINF_SUCCESS; … … 989 1041 */ 990 1042 991 int DragInstance::ghIsDnDPending( )1043 int DragInstance::ghIsDnDPending(void) 992 1044 { 993 1045 int rc = VINF_SUCCESS; 994 Window w = XGetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection)); 995 DO(("Checking pending %X %X\n", w, m_proxyWin)); 1046 Window wndOwner = XGetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection)); 1047 LogFlowThisFunc(("Checking pending wndOwner=%#x wndProxy=%#x\n", wndOwner, m_wndProxy)); 1048 996 1049 /* Is there someone own the Xdnd selection which aren't we. */ 997 if ( w 998 && w != m_proxyWin)1050 if ( wndOwner 1051 && wndOwner != m_wndProxy) 999 1052 { 1000 1053 /* Map the window on the current cursor position, which should provoke … … 1007 1060 int xrc = Success; 1008 1061 XClientMessageEvent *clme = reinterpret_cast<XClientMessageEvent*>(&e); 1009 DO(("next X event %s\n", gX11->xAtomToString(clme->message_type).c_str()));1062 LogFlowThisFunc(("Next X event %s\n", gX11->xAtomToString(clme->message_type).c_str())); 1010 1063 if (clme->message_type == xAtom(XA_XdndEnter)) 1011 1064 { … … 1018 1071 m_formats.clear(); 1019 1072 m_actions.clear(); 1020 m_ curWin = w;1021 DO(("XA_XdndEnter\n"));1073 m_wndCur = wndOwner; 1074 LogFlowThisFunc(("XA_XdndEnter\n")); 1022 1075 /* Check if the mime types are in the msg itself or if we need 1023 1076 * to fetch the XdndTypeList property from the window. */ … … 1026 1079 for (int i = 2; i < 5; ++i) 1027 1080 { 1028 DO(("receive list msg: %s\n", gX11->xAtomToString(clme->data.l[i]).c_str()));1081 LogFlowThisFunc(("Receive list msg: %s\n", gX11->xAtomToString(clme->data.l[i]).c_str())); 1029 1082 m_formats.append(clme->data.l[i]); 1030 1083 } … … 1032 1085 else 1033 1086 { 1034 xrc = XGetWindowProperty(m_pDisplay, w , xAtom(XA_XdndTypeList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);1087 xrc = XGetWindowProperty(m_pDisplay, wndOwner, xAtom(XA_XdndTypeList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret); 1035 1088 if ( xrc == Success 1036 1089 && n > 0 … … 1040 1093 for (int i = 0; i < RT_MIN(VBOX_MAX_XPROPERTIES, n); ++i) 1041 1094 { 1042 DO(("receive list: %s\n", gX11->xAtomToString(data[i]).c_str()));1095 LogFlowThisFunc(("Receive list: %s\n", gX11->xAtomToString(data[i]).c_str())); 1043 1096 m_formats.append(data[i]); 1044 1097 } … … 1047 1100 } 1048 1101 /* Fetch the possible list of actions, if this property is set. */ 1049 xrc = XGetWindowProperty(m_pDisplay, w , xAtom(XA_XdndActionList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);1102 xrc = XGetWindowProperty(m_pDisplay, wndOwner, xAtom(XA_XdndActionList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret); 1050 1103 if ( xrc == Success 1051 1104 && n > 0 … … 1055 1108 for (int i = 0; i < RT_MIN(VBOX_MAX_XPROPERTIES, n); ++i) 1056 1109 { 1057 DO(("receive actions: %s\n", gX11->xAtomToString(data[i]).c_str()));1110 LogFlowThisFunc(("Receive actions: %s\n", gX11->xAtomToString(data[i]).c_str())); 1058 1111 m_actions.append(data[i]); 1059 1112 } … … 1072 1125 m.message_type = xAtom(XA_XdndStatus); 1073 1126 m.format = 32; 1074 m.data.l[0] = m_ proxyWin;1127 m.data.l[0] = m_wndProxy; 1075 1128 m.data.l[1] = 1; 1076 1129 m.data.l[4] = xAtom(XA_XdndActionCopy); 1077 1130 xrc = XSendEvent(m_pDisplay, clme->data.l[0], False, 0, reinterpret_cast<XEvent*>(&m)); 1078 1131 if (RT_UNLIKELY(xrc == 0)) 1079 DO(("DnD_PNDG: error sending xevent\n"));1132 LogFlowThisFunc(("Error sending xevent\n")); 1080 1133 } 1081 1134 else if (clme->message_type == xAtom(XA_XdndPosition)) 1082 1135 { 1083 DO(("XA_XdndPosition\n"));1136 LogFlowThisFunc(("XA_XdndPosition\n")); 1084 1137 XClientMessageEvent m; 1085 1138 RT_ZERO(m); … … 1089 1142 m.message_type = xAtom(XA_XdndStatus); 1090 1143 m.format = 32; 1091 m.data.l[0] = m_ proxyWin;1144 m.data.l[0] = m_wndProxy; 1092 1145 m.data.l[1] = 1; 1093 1146 m.data.l[4] = clme->data.l[4]; 1094 1147 xrc = XSendEvent(m_pDisplay, clme->data.l[0], False, 0, reinterpret_cast<XEvent*>(&m)); 1095 1148 if (RT_UNLIKELY(xrc == 0)) 1096 DO(("DnD_PNDG: error sending xevent\n"));1149 LogFlowThisFunc(("Error sending xevent\n")); 1097 1150 } 1098 1151 else if (clme->message_type == xAtom(XA_XdndLeave)) … … 1102 1155 hideProxyWin(); 1103 1156 1104 rc = VbglR3DnDGHAcknowledgePending(DND_COPY_ACTION, toHGCMActions(m_actions), gX11->xAtomListToString(m_formats).c_str()); 1105 } 1157 rc = VbglR3DnDGHAcknowledgePending(DND_COPY_ACTION, toHGCMActions(m_actions), 1158 gX11->xAtomListToString(m_formats).c_str()); 1159 } 1160 1161 LogFlowFuncLeaveRC(rc); 1106 1162 return rc; 1107 1163 } … … 1109 1165 int DragInstance::ghDropped(const RTCString &strFormat, uint32_t action) 1110 1166 { 1111 DO(("DND_DRO:format='%s' action=%d\n", strFormat.c_str(), action));1167 LogFlowThisFunc(("format='%s' action=%d\n", strFormat.c_str(), action)); 1112 1168 int rc = VINF_SUCCESS; 1113 1169 … … 1118 1174 /* We send a fake release event to the current window, cause 1119 1175 * this should have the grab. */ 1120 sendButtonEvent(m_ curWin, rx, ry, 1, false);1176 sendButtonEvent(m_wndCur, rx, ry, 1, false); 1121 1177 /* The fake button release event, should lead to an XdndDrop event from the 1122 1178 * source. Because of the showing of the proxy window, sometimes other Xdnd … … 1145 1201 /* Request to convert the selection in the specific format and 1146 1202 * place it to our proxy window as property. */ 1147 Window srcWin = m_ curWin;//clme->data.l[0];1203 Window srcWin = m_wndCur;//clme->data.l[0]; 1148 1204 Atom aFormat = gX11->stringToxAtom(strFormat.c_str()); 1149 XConvertSelection(m_pDisplay, xAtom(XA_XdndSelection), aFormat, xAtom(XA_XdndSelection), m_ proxyWin, clme->data.l[2]);1205 XConvertSelection(m_pDisplay, xAtom(XA_XdndSelection), aFormat, xAtom(XA_XdndSelection), m_wndProxy, clme->data.l[2]); 1150 1206 /* Wait for the selection notify event. */ 1151 1207 RT_ZERO(e); … … 1156 1212 && e.xselection.display == m_pDisplay 1157 1213 && e.xselection.selection == xAtom(XA_XdndSelection) 1158 && e.xselection.requestor == m_ proxyWin1214 && e.xselection.requestor == m_wndProxy 1159 1215 && e.xselection.target == aFormat) 1160 1216 { 1161 DO(("DND_DRO: selection notfiy (from: %x)\n", m_curWin));1217 LogFlowThisFunc(("Selection notfiy (from: %x)\n", m_wndCur)); 1162 1218 Atom type; 1163 1219 int format; 1164 1220 unsigned long cItems, cbRemaining; 1165 1221 unsigned char *ucData = 0; 1166 XGetWindowProperty(m_pDisplay, m_ proxyWin, xAtom(XA_XdndSelection),1222 XGetWindowProperty(m_pDisplay, m_wndProxy, xAtom(XA_XdndSelection), 1167 1223 0, VBOX_MAX_XPROPERTIES, True, AnyPropertyType, 1168 1224 &type, &format, &cItems, &cbRemaining, &ucData); 1169 DO(("DND_DRO:%s %d %d %s\n", gX11->xAtomToString(type).c_str(), cItems, format, ucData));1225 LogFlowThisFunc(("%s %d %d %s\n", gX11->xAtomToString(type).c_str(), cItems, format, ucData)); 1170 1226 if ( type != None 1171 1227 && ucData != NULL … … 1181 1237 && ucData[cbData - 1] != '\0') 1182 1238 { 1183 DO(("rebuild %u\n", cbData));1239 LogFlowThisFunc(("Rebuild %u\n", cbData)); 1184 1240 unsigned char *ucData1 = static_cast<unsigned char*>(RTMemAlloc(cbData + 1)); 1185 1241 if (ucData1) … … 1198 1254 rc = VbglR3DnDGHSendData(ucData, cbData); 1199 1255 1200 DO(("send responce\n"));1256 LogFlowThisFunc(("send responce\n")); 1201 1257 /* Confirm the result of the transfer to the source window. */ 1202 1258 XClientMessageEvent m; … … 1207 1263 m.message_type = xAtom(XA_XdndFinished); 1208 1264 m.format = 32; 1209 m.data.l[0] = m_ proxyWin;1265 m.data.l[0] = m_wndProxy; 1210 1266 m.data.l[1] = RT_SUCCESS(rc) ? 1 : 0; /* Confirm or deny success */ 1211 1267 m.data.l[2] = RT_SUCCESS(rc) ? toX11Action(action) : None; /* Action used on success */ … … 1213 1269 int xrc = XSendEvent(m_pDisplay, srcWin, True, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1214 1270 if (RT_UNLIKELY(xrc == 0)) 1215 DO(("DnD_DRO: error sending xevent\n"));1271 LogFlowThisFunc(("Error sending xevent\n")); 1216 1272 } 1217 1273 else … … 1236 1292 m.message_type = xAtom(XA_XdndFinished); 1237 1293 m.format = 32; 1238 m.data.l[0] = m_ proxyWin;1294 m.data.l[0] = m_wndProxy; 1239 1295 m.data.l[1] = 0; 1240 1296 m.data.l[2] = None; 1241 1297 int xrc = XSendEvent(m_pDisplay, srcWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1242 1298 if (RT_UNLIKELY(xrc == 0)) 1243 DO(("DnD_DRO: error sending xevent\n"));1244 m_ curWin= 0;1299 LogFlowThisFunc(("Error sending xevent\n")); 1300 m_wndCur = 0; 1245 1301 } 1246 1302 /* Cleanup */ … … 1268 1324 reset(); 1269 1325 1326 LogFlowFuncLeaveRC(rc); 1270 1327 return rc; 1271 1328 } … … 1281 1338 /* Move the guest pointer to the DnD position, so we can find the window 1282 1339 * below that position. */ 1283 XWarpPointer(m_pDisplay, None, m_ rootWin, 0, 0, 0, 0, u32xPos, u32yPos);1340 XWarpPointer(m_pDisplay, None, m_wndRoot, 0, 0, 0, 0, u32xPos, u32yPos); 1284 1341 return VINF_SUCCESS; 1285 1342 } … … 1295 1352 RT_ZERO(be); 1296 1353 be.display = m_pDisplay; 1297 be.root = m_ rootWin;1354 be.root = m_wndRoot; 1298 1355 be.window = w; 1299 1356 be.subwindow = None; … … 1312 1369 int xrc = XSendEvent(m_pDisplay, be.window, True, ButtonPressMask, reinterpret_cast<XEvent*>(&be)); 1313 1370 if (RT_UNLIKELY(xrc == 0)) 1314 DO(("DnD_BTN: error sending xevent\n")); 1315 } 1316 1371 LogFlowThisFunc(("Error sending xevent\n")); 1372 } 1317 1373 } 1318 1374 … … 1323 1379 Window r, c; 1324 1380 // XTestGrabControl(m_pDisplay, False); 1325 XQueryPointer(m_pDisplay, m_ rootWin, &r, &c, &rx, &ry, &cx, &cy, &m);1381 XQueryPointer(m_pDisplay, m_wndRoot, &r, &c, &rx, &ry, &cx, &cy, &m); 1326 1382 XSynchronize(m_pDisplay, True); 1327 XMapWindow(m_pDisplay, m_ proxyWin);1328 XRaiseWindow(m_pDisplay, m_ proxyWin);1329 XMoveResizeWindow(m_pDisplay, m_ proxyWin, rx, ry, 1, 1);1330 XWarpPointer(m_pDisplay, None, m_ rootWin, 0, 0, 0, 0, rx , ry);1383 XMapWindow(m_pDisplay, m_wndProxy); 1384 XRaiseWindow(m_pDisplay, m_wndProxy); 1385 XMoveResizeWindow(m_pDisplay, m_wndProxy, rx, ry, 1, 1); 1386 XWarpPointer(m_pDisplay, None, m_wndRoot, 0, 0, 0, 0, rx , ry); 1331 1387 XSynchronize(m_pDisplay, False); 1332 1388 // XTestGrabControl(m_pDisplay, True); 1333 1389 } 1334 1390 1335 void DragInstance::hideProxyWin( ) const1336 { 1337 XUnmapWindow(m_pDisplay, m_ proxyWin);1391 void DragInstance::hideProxyWin(void) const 1392 { 1393 XUnmapWindow(m_pDisplay, m_wndProxy); 1338 1394 } 1339 1395 1340 1396 /* Currently, not used */ 1341 void DragInstance::registerForEvents(Window w ) const1397 void DragInstance::registerForEvents(Window wndThis) const 1342 1398 { 1343 1399 // if (w == m_proxyWin) 1344 1400 // return; 1345 1401 1346 DO(("%x\n", w));1402 LogFlowThisFunc(("%x\n", wndThis)); 1347 1403 // XSelectInput(m_pDisplay, w, Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask);//| SubstructureNotifyMask); 1348 1404 // XSelectInput(m_pDisplay, w, ButtonMotionMask); //PointerMotionMask); 1349 XSelectInput(m_pDisplay, w , PointerMotionMask); //PointerMotionMask);1405 XSelectInput(m_pDisplay, wndThis, PointerMotionMask); //PointerMotionMask); 1350 1406 Window hRealRoot, hParent; 1351 1407 Window *phChildrenRaw = NULL; 1352 1408 unsigned cChildren; 1353 if (XQueryTree(m_pDisplay, w , &hRealRoot, &hParent, &phChildrenRaw, &cChildren))1409 if (XQueryTree(m_pDisplay, wndThis, &hRealRoot, &hParent, &phChildrenRaw, &cChildren)) 1354 1410 { 1355 1411 for (unsigned i = 0; i < cChildren; ++i) … … 1359 1415 } 1360 1416 1361 void DragInstance::setActionsWindowProperty(Window w in, const RTCList<Atom> &actionList) const1417 void DragInstance::setActionsWindowProperty(Window wndThis, const RTCList<Atom> &actionList) const 1362 1418 { 1363 1419 if (actionList.isEmpty()) 1364 1420 return; 1365 1421 1366 XChangeProperty(m_pDisplay, w in, xAtom(XA_XdndActionList), XA_ATOM, 32, PropModeReplace,1422 XChangeProperty(m_pDisplay, wndThis, xAtom(XA_XdndActionList), XA_ATOM, 32, PropModeReplace, 1367 1423 reinterpret_cast<const unsigned char*>(actionList.raw()), actionList.size()); 1368 1424 } 1369 1425 1370 void DragInstance::clearActionsWindowProperty(Window w in) const1371 { 1372 XDeleteProperty(m_pDisplay, w in, xAtom(XA_XdndActionList));1373 } 1374 1375 void DragInstance::setFormatsWindowProperty(Window w in, Atom property) const1426 void DragInstance::clearActionsWindowProperty(Window wndThis) const 1427 { 1428 XDeleteProperty(m_pDisplay, wndThis, xAtom(XA_XdndActionList)); 1429 } 1430 1431 void DragInstance::setFormatsWindowProperty(Window wndThis, Atom property) const 1376 1432 { 1377 1433 if (m_formats.isEmpty()) … … 1384 1440 1385 1441 /* Add the property with the property data to the window. */ 1386 XChangeProperty(m_pDisplay, w in, property, XA_ATOM, 32, PropModeReplace,1442 XChangeProperty(m_pDisplay, wndThis, property, XA_ATOM, 32, PropModeReplace, 1387 1443 reinterpret_cast<const unsigned char*>(targets.raw()), targets.size()); 1388 1444 } 1389 1445 1390 void DragInstance::clearFormatsWindowProperty(Window w in) const1391 { 1392 XDeleteProperty(m_pDisplay, w in, xAtom(XA_XdndTypeList));1446 void DragInstance::clearFormatsWindowProperty(Window wndThis) const 1447 { 1448 XDeleteProperty(m_pDisplay, wndThis, xAtom(XA_XdndTypeList)); 1393 1449 } 1394 1450 … … 1417 1473 * even if the data isn't zero terminated. */ 1418 1474 char *pszTmp = RTStrDupN(pszStr, cSize); 1419 DO(("f: %s\n", pszTmp));1475 LogFlowThisFunc(("f: %s\n", pszTmp)); 1420 1476 atomList.append(XInternAtom(m_pDisplay, pszTmp, False)); 1421 1477 RTStrFree(pszTmp); … … 1512 1568 if (!m_eventQueue.isEmpty()) 1513 1569 { 1514 DO(("new msg size %d\n", m_eventQueue.size()));1570 LogFlowThisFunc(("new msg size %d\n", m_eventQueue.size())); 1515 1571 /* Check if there is a client message in the queue. */ 1516 1572 for (size_t i = 0; i < m_eventQueue.size(); ++i) … … 1518 1574 DnDEvent e = m_eventQueue.at(i); 1519 1575 if( e.type == DnDEvent::X11_Type) 1520 DO(("new msg\n"));1576 LogFlowThisFunc(("new msg\n")); 1521 1577 if( e.type == DnDEvent::X11_Type 1522 1578 && e.x11.type == type) … … 1551 1607 do 1552 1608 { 1553 /* Initialize our service */1554 rc = VbglR3DnDInit();1555 if (RT_FAILURE(rc))1556 break;1557 1558 1609 /* Initialize X11 DND */ 1559 1610 rc = x11DragAndDropInit(); … … 1562 1613 1563 1614 m_pCurDnD = new DragInstance(m_pDisplay, this); 1615 if (!m_pCurDnD) 1616 { 1617 rc = VERR_NO_MEMORY; 1618 break; 1619 } 1564 1620 /* Note: For multiple screen support in VBox it is not necessary to use 1565 1621 * another screen number than zero. Maybe in the future it will become 1566 1622 * necessary if VBox supports multiple X11 screens. */ 1567 m_pCurDnD->init(0); 1623 rc = m_pCurDnD->init(0); 1624 if (RT_FAILURE(rc)) 1625 break; 1626 1568 1627 /* Loop over new events */ 1569 1628 do … … 1577 1636 e = m_eventQueue.first(); 1578 1637 m_eventQueue.removeFirst(); 1579 DO(("new msg %d\n", e.type));1638 LogFlowThisFunc(("new msg %d\n", e.type)); 1580 1639 if (e.type == DnDEvent::HGCM_Type) 1581 1640 { … … 1624 1683 } 1625 1684 #endif 1685 default: 1686 LogFlowThisFunc(("Unknown message: %RU32\n", e.hgcm.uType)); 1687 break; 1626 1688 } 1689 1627 1690 /* Some messages require cleanup. */ 1628 1691 switch (e.hgcm.uType) … … 1647 1710 break; 1648 1711 } 1712 default: 1713 break; 1649 1714 } 1650 1651 1715 } 1652 1716 else if(e.type == DnDEvent::X11_Type) 1653 1717 { 1654 DO(("X11 type: %u\n", e.x11.type));1718 LogFlowThisFunc(("X11 type: %u\n", e.x11.type)); 1655 1719 /* Now the X11 event stuff */ 1656 1720 switch (e.x11.type) … … 1658 1722 case SelectionRequest: m_pCurDnD->hgX11SelectionRequest(e.x11); break; 1659 1723 case ClientMessage: m_pCurDnD->hgX11ClientMessage(e.x11); break; 1660 case SelectionClear: DO(("DnD_CLER\n")); break;1724 case SelectionClear: LogFlowThisFunc(("DnD_CLER\n")); break; 1661 1725 // case MotionNotify: m_pCurDnD->hide(); break; 1662 1726 } … … 1666 1730 } while (0); 1667 1731 1668 Log RelFlowFunc(("returning %Rrc\n", rc));1732 LogFlowFuncLeaveRC(rc); 1669 1733 return rc; 1670 1734 } 1671 1735 1672 int DragAndDropService::x11DragAndDropInit( )1736 int DragAndDropService::x11DragAndDropInit(void) 1673 1737 { 1674 1738 /* Connect to the x11 server. */ … … 1678 1742 return VERR_NOT_FOUND; 1679 1743 1680 xHelpers::instance(m_pDisplay); 1744 xHelpers *pHelpers = xHelpers::getInstance(m_pDisplay); 1745 if (!pHelpers) 1746 return VERR_NO_MEMORY; 1681 1747 1682 1748 int rc = VINF_SUCCESS; … … 1706 1772 } 1707 1773 1708 int DragAndDropService::x11DragAndDropTerm( )1774 int DragAndDropService::x11DragAndDropTerm(void) 1709 1775 { 1710 1776 /* Mark that we are stopping. */ … … 1724 1790 int xrc = XSendEvent(m_pDisplay, None, True, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1725 1791 if (RT_UNLIKELY(xrc == 0)) 1726 DO(("DnD_TERM: error sending xevent\n"));1792 LogFlowThisFunc(("Error sending xevent\n")); 1727 1793 } 1728 1794 … … 1755 1821 DragAndDropService *pThis = static_cast<DragAndDropService*>(pvUser); 1756 1822 DnDEvent e; 1823 1824 uint32_t uClientID; 1825 int rc = VbglR3DnDConnect(&uClientID); 1826 if (RT_FAILURE(rc)) { 1827 LogFlowFunc(("Unable to connect to HGCM service, rc=%Rrc\n", rc)); 1828 return rc; 1829 } 1830 1757 1831 do 1758 1832 { … … 1760 1834 e.type = DnDEvent::HGCM_Type; 1761 1835 /* Wait for new events */ 1762 int rc = VbglR3DnDProcessNextMessage(&e.hgcm);1836 rc = VbglR3DnDProcessNextMessage(uClientID, &e.hgcm); 1763 1837 if (RT_SUCCESS(rc)) 1764 1838 { … … 1769 1843 } 1770 1844 } while (!ASMAtomicReadBool(&pThis->m_fSrvStopping)); 1845 1846 VbglR3DnDDisconnect(uClientID); 1771 1847 1772 1848 return VINF_SUCCESS; … … 1815 1891 1816 1892 /* Static factory */ 1817 VBoxClient::Service *VBoxClient::GetDragAndDropService() 1818 { 1819 return new(DragAndDropService); 1820 } 1893 VBoxClient::Service *VBoxClient::GetDragAndDropService(void) 1894 { 1895 DragAndDropService *pService = new DragAndDropService(); 1896 return pService; 1897 } 1898
Note:
See TracChangeset
for help on using the changeset viewer.