VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 2 years ago

scm --update-copyright-year

  • 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 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * VBoxDnDSource.cpp - IDropSource implementation.
4 */
5
6/*
7 * Copyright (C) 2013-2022 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
18#include <iprt/win/windows.h>
19#include <new> /* For bad_alloc. */
20
21#ifdef LOG_GROUP
22# undef LOG_GROUP
23#endif
24#define LOG_GROUP LOG_GROUP_GUEST_DND
25#include <VBox/log.h>
26
27#include "VBoxTray.h"
28#include "VBoxHelpers.h"
29#include "VBoxDnD.h"
30
31#include "VBox/HostServices/DragAndDropSvc.h"
32
33
34
35VBoxDnDDropSource::VBoxDnDDropSource(VBoxDnDWnd *pParent)
36 : m_cRefs(1),
37 m_pWndParent(pParent),
38 m_dwCurEffect(0),
39 m_enmActionCurrent(VBOX_DND_ACTION_IGNORE)
40{
41 LogFlowFuncEnter();
42}
43
44VBoxDnDDropSource::~VBoxDnDDropSource(void)
45{
46 LogFlowFunc(("mRefCount=%RI32\n", m_cRefs));
47}
48
49/*
50 * IUnknown methods.
51 */
52
53STDMETHODIMP_(ULONG) VBoxDnDDropSource::AddRef(void)
54{
55 return InterlockedIncrement(&m_cRefs);
56}
57
58STDMETHODIMP_(ULONG) VBoxDnDDropSource::Release(void)
59{
60 LONG lCount = InterlockedDecrement(&m_cRefs);
61 if (lCount == 0)
62 {
63 delete this;
64 return 0;
65 }
66
67 return lCount;
68}
69
70STDMETHODIMP VBoxDnDDropSource::QueryInterface(REFIID iid, void **ppvObject)
71{
72 AssertPtrReturn(ppvObject, E_INVALIDARG);
73
74 if ( iid == IID_IDropSource
75 || iid == IID_IUnknown)
76 {
77 AddRef();
78 *ppvObject = this;
79 return S_OK;
80 }
81
82 *ppvObject = 0;
83 return E_NOINTERFACE;
84}
85
86/*
87 * IDropSource methods.
88 */
89
90/**
91 * The system informs us about whether we should continue the drag'n drop
92 * operation or not, depending on the sent key states.
93 *
94 * @return HRESULT
95 */
96STDMETHODIMP VBoxDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState)
97{
98#if 1
99 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, mDnDActionCurrent=%RU32\n",
100 fEscapePressed, dwKeyState, m_dwCurEffect, m_enmActionCurrent));
101#endif
102
103 /* ESC pressed? Bail out. */
104 if (fEscapePressed)
105 {
106 m_dwCurEffect = 0;
107 m_enmActionCurrent = VBOX_DND_ACTION_IGNORE;
108
109 LogFlowFunc(("Canceled\n"));
110 return DRAGDROP_S_CANCEL;
111 }
112
113 /* Left mouse button released? Start "drop" action. */
114 if ((dwKeyState & MK_LBUTTON) == 0)
115 {
116 LogFlowFunc(("Dropping ...\n"));
117 return DRAGDROP_S_DROP;
118 }
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 = VBOX_DND_ACTION_IGNORE;
133
134#if 1
135 LogFlowFunc(("dwEffect=0x%x\n", dwEffect));
136#endif
137 if (dwEffect)
138 {
139 if (dwEffect & DROPEFFECT_COPY)
140 uAction |= VBOX_DND_ACTION_COPY;
141 if (dwEffect & DROPEFFECT_MOVE)
142 uAction |= VBOX_DND_ACTION_MOVE;
143 if (dwEffect & DROPEFFECT_LINK)
144 uAction |= VBOX_DND_ACTION_LINK;
145 }
146
147 m_dwCurEffect = dwEffect;
148 m_enmActionCurrent = uAction;
149
150 return DRAGDROP_S_USEDEFAULTCURSORS;
151}
152
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use