VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropSource.cpp@ 51469

Last change on this file since 51469 was 51469, checked in by vboxsync, 11 years ago

VBoxTray: Logging; ripped out all custom logging.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: VBoxDnDDropSource.cpp 51469 2014-05-30 11:49:42Z vboxsync $ */
2/** @file
3 * VBoxDnDSource.cpp - IDropSource implementation.
4 */
5
6/*
7 * Copyright (C) 2013-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#include <windows.h>
18#include <new> /* For bad_alloc. */
19
20#ifdef LOG_GROUP
21# undef LOG_GROUP
22#endif
23#define LOG_GROUP LOG_GROUP_GUEST_DND
24#include <VBox/log.h>
25
26#include "VBoxTray.h"
27#include "VBoxHelpers.h"
28#include "VBoxDnD.h"
29
30#include "VBox/HostServices/DragAndDropSvc.h"
31
32
33
34VBoxDnDDropSource::VBoxDnDDropSource(VBoxDnDWnd *pParent)
35 : mRefCount(1),
36 mpWndParent(pParent),
37 mClientID(UINT32_MAX),
38 mdwCurEffect(0),
39 muCurAction(DND_IGNORE_ACTION)
40{
41 int rc = VbglR3DnDConnect(&mClientID);
42
43 LogFlowFunc(("rc=%Rrc\n", rc));
44}
45
46VBoxDnDDropSource::~VBoxDnDDropSource(void)
47{
48 int rc = VbglR3DnDDisconnect(mClientID);
49
50 LogFlowFunc(("rc=%Rrc, mRefCount=%RI32\n", rc, mRefCount));
51}
52
53/*
54 * IUnknown methods.
55 */
56
57STDMETHODIMP_(ULONG) VBoxDnDDropSource::AddRef(void)
58{
59 return InterlockedIncrement(&mRefCount);
60}
61
62STDMETHODIMP_(ULONG) VBoxDnDDropSource::Release(void)
63{
64 LONG lCount = InterlockedDecrement(&mRefCount);
65 if (lCount == 0)
66 {
67 delete this;
68 return 0;
69 }
70
71 return lCount;
72}
73
74STDMETHODIMP VBoxDnDDropSource::QueryInterface(REFIID iid, void **ppvObject)
75{
76 AssertPtrReturn(ppvObject, E_INVALIDARG);
77
78 if ( iid == IID_IDropSource
79 || iid == IID_IUnknown)
80 {
81 AddRef();
82 *ppvObject = this;
83 return S_OK;
84 }
85
86 *ppvObject = 0;
87 return E_NOINTERFACE;
88}
89
90/*
91 * IDropSource methods.
92 */
93
94/**
95 * The system informs us about whether we should continue the drag'n drop
96 * operation or not, depending on the sent key states.
97 *
98 * @return HRESULT
99 */
100STDMETHODIMP VBoxDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState)
101{
102#ifndef DEBUG_andy
103 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, muCurAction=%RU32\n",
104 fEscapePressed, dwKeyState, mdwCurEffect, muCurAction));
105#endif
106
107 /* ESC pressed? Bail out. */
108 if (fEscapePressed)
109 {
110 mdwCurEffect = 0;
111 muCurAction = DND_IGNORE_ACTION;
112
113 return DRAGDROP_S_CANCEL;
114 }
115
116 /* Left mouse button released? Start "drop" action. */
117 if ((dwKeyState & MK_LBUTTON) == 0)
118 return DRAGDROP_S_DROP;
119
120 /* No change, just continue. */
121 return S_OK;
122}
123
124/**
125 * The drop target gives our source feedback about whether
126 * it can handle our data or not.
127 *
128 * @return HRESULT
129 */
130STDMETHODIMP VBoxDnDDropSource::GiveFeedback(DWORD dwEffect)
131{
132 uint32_t uAction = DND_IGNORE_ACTION;
133
134#ifndef DEBUG_andy
135 LogFlowFunc(("dwEffect=0x%x\n", dwEffect));
136#endif
137 if (dwEffect)
138 {
139 if (dwEffect & DROPEFFECT_COPY)
140 uAction |= DND_COPY_ACTION;
141 if (dwEffect & DROPEFFECT_MOVE)
142 uAction |= DND_MOVE_ACTION;
143 if (dwEffect & DROPEFFECT_LINK)
144 uAction |= DND_LINK_ACTION;
145 }
146
147 mdwCurEffect = dwEffect;
148 muCurAction = uAction;
149
150 return DRAGDROP_S_USEDEFAULTCURSORS;
151}
152
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette