Changeset 50177 in vbox
- Timestamp:
- Jan 23, 2014 11:51:09 AM (11 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
r50101 r50177 146 146 { 147 147 DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_NOACTIVATE; 148 DWORD dwStyle = WS_POPUP WINDOW;148 DWORD dwStyle = WS_POPUP; 149 149 #ifdef VBOX_DND_DEBUG_WND 150 dwExStyle &= ~WS_EX_TRANSPARENT; 151 dwStyle |= WS_VISIBLE | WS_OVERLAPPEDWINDOW;150 dwExStyle &= ~WS_EX_TRANSPARENT; /* Remove transparency bit. */ 151 dwStyle |= WS_VISIBLE; /* Make the window visible. */ 152 152 #endif 153 153 pThis->hWnd = … … 176 176 #else 177 177 LogFlowFunc(("Debug proxy window created, hWnd=0x%x\n", pThis->hWnd)); 178 179 /* 180 * Install some mouse tracking. 181 */ 182 TRACKMOUSEEVENT me; 183 RT_ZERO(me); 184 me.cbSize = sizeof(TRACKMOUSEEVENT); 185 me.dwFlags = TME_HOVER | TME_LEAVE | TME_NONCLIENT; 186 me.hwndTrack = pThis->hWnd; 187 BOOL fRc = TrackMouseEvent(&me); 188 Assert(fRc); 178 189 #endif 179 190 } … … 183 194 { 184 195 OleInitialize(NULL); 196 197 pThis->RegisterAsDropTarget(); 185 198 186 199 bool fShutdown = false; … … 269 282 LogFlowThisFunc(("WM_LBUTTONUP\n")); 270 283 mfMouseButtonDown = false; 284 return 0; 285 286 case WM_MOUSELEAVE: 287 LogFlowThisFunc(("WM_MOUSELEAVE\n")); 271 288 return 0; 272 289 … … 341 358 else if (mMode == GH) /* Guest to host. */ 342 359 { 343 hide(); 360 //hide(); 361 362 /* Starting here VBoxDnDDropTarget should 363 * take over; was instantiated when registering 364 * this proxy window as a (valid) drop target. */ 344 365 } 345 366 else … … 350 371 return 0; 351 372 } 373 374 case WM_NCMOUSEHOVER: 375 LogFlowThisFunc(("WM_NCMOUSEHOVER\n")); 376 return 0; 377 378 case WM_NCMOUSELEAVE: 379 LogFlowThisFunc(("WM_NCMOUSELEAVE\n")); 380 return 0; 352 381 353 382 case WM_VBOXTRAY_DND_MESSAGE: … … 532 561 return VINF_SUCCESS; 533 562 534 int rc = VBoxDnDDropTarget::CreateDropTarget(this /* pParent */,535 &pDropTarget);536 if (RT_SUCCESS(rc))537 {563 int rc; 564 try 565 { 566 pDropTarget = new VBoxDnDDropTarget(this /* pParent */); 538 567 AssertPtr(pDropTarget); 539 568 HRESULT hr = CoLockObjectExternal(pDropTarget, TRUE /* fLock */, … … 544 573 if (FAILED(hr)) 545 574 { 546 LogRel(("DnD: Creating drop target failed with hr= 0x%x\n", hr));575 LogRel(("DnD: Creating drop target failed with hr=%Rhrc\n", hr)); 547 576 rc = VERR_GENERAL_FAILURE; /** @todo Find a better rc. */ 548 577 } 578 else 579 rc = VINF_SUCCESS; 580 } 581 catch (std::bad_alloc) 582 { 583 rc = VERR_NO_MEMORY; 549 584 } 550 585 … … 707 742 rc = VbglR3DnDHGAcknowledgeOperation(mClientID, uActionNotify); 708 743 if (RT_FAILURE(rc)) 709 LogFlowThisFunc(("Acknowled ing operation failed with rc=%Rrc\n", rc));744 LogFlowThisFunc(("Acknowledging operation failed with rc=%Rrc\n", rc)); 710 745 } 711 746 … … 828 863 if (mState == Initialized) 829 864 { 830 //rc = makeFullscreen(); 831 rc = VINF_SUCCESS; 865 rc = makeFullscreen(); 866 /*if (RT_SUCCESS(rc)) 867 rc = RegisterAsDropTarget();*/ 868 832 869 if (RT_SUCCESS(rc)) 833 rc = RegisterAsDropTarget(); 834 835 if (RT_SUCCESS(rc)) 870 { 871 /* 872 * We have to release the left mouse button to 873 * get into our (invisible) proxy window. 874 */ 875 dragRelease(); 876 877 /* 878 * Even if we just released the left mouse button 879 * we're still in the dragging state to handle our 880 * own drop target (for the host). 881 */ 836 882 mState = Dragging; 883 } 837 884 } 838 885 else 839 886 rc = VINF_SUCCESS; 887 888 /** 889 * Some notes regarding guest cursor movement: 890 * - The host only sends an HOST_DND_GH_REQ_PENDING message to the guest 891 * if the mouse cursor is outside the VM's window. 892 * - The guest does not know anything about the host's cursor 893 * position / state due to security reasons. 894 * - The guest *only* knows that the host currently is asking whether a 895 * guest DnD operation is in progress. 896 */ 840 897 841 898 if ( RT_SUCCESS(rc) … … 845 902 POINT p; 846 903 GetCursorPos(&p); 847 904 ClientToScreen(hWnd, &p); 848 905 #ifdef DEBUG_andy 849 LogFlowThisFunc(("Setting cursor to curX=%d, curY=%d\n", p.x, p.y)); 850 #endif 906 LogFlowThisFunc(("Client to screen curX=%ld, curY=%ld\n", p.x, p.y)); 907 #endif 908 909 #if 1 851 910 /** @todo Multi-monitor setups? */ 852 911 int iScreenX = GetSystemMetrics(SM_CXSCREEN) - 1; 853 912 int iScreenY = GetSystemMetrics(SM_CYSCREEN) - 1; 854 913 855 static int pos = 100; 856 pos++; 914 static LONG px = p.x; 915 if (px <= 0) 916 px = 1; 917 static LONG py = p.y; 918 if (py <= 0) 919 py = 1; 920 //px++; py++; 921 LogFlowThisFunc(("px=%ld, py=%ld\n", px, py)); 857 922 858 923 INPUT Input[1] = { 0 }; 859 924 Input[0].type = INPUT_MOUSE; 860 Input[0].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE; 861 Input[0].mi.dx = pos * (65535 / iScreenX); //p.x * (65535 / iScreenX); 862 Input[0].mi.dy = 100 * (65535 / iScreenY); //p.y * (65535 / iScreenY); 863 SendInput(1, Input, sizeof(INPUT)); 925 Input[0].mi.dwFlags = MOUSEEVENTF_MOVE | /*MOUSEEVENTF_LEFTDOWN |*/ MOUSEEVENTF_ABSOLUTE; 926 Input[0].mi.dx = px * (65535 / iScreenX); 927 Input[0].mi.dy = py * (65535 / iScreenY); 928 UINT uiProcessed = SendInput(1, Input, sizeof(INPUT)); 929 if (uiProcessed) 930 { 931 #ifdef DEBUG_andy 932 LogFlowFunc(("Sent %RU16 mouse input(s), x=%ld, y=%ld, flags=0x%x\n", 933 uiProcessed, Input[0].mi.dx, Input[0].mi.dy, Input[0].mi.dwFlags)); 934 #endif 935 } 936 else 937 LogFlowFunc(("Unable to send input, error=0x%x\n", GetLastError())); 938 #else 939 SetCursorPos(p.x, p.y); 940 #endif 864 941 865 942 #ifdef DEBUG_andy … … 875 952 } 876 953 877 int rc2= VbglR3DnDGHAcknowledgePending(mClientID, 878 DND_COPY_ACTION, DND_COPY_ACTION, "text/plain;charset=utf-8"); 879 LogFlowThisFunc(("sent=%Rrc\n", rc2)); 954 if (RT_SUCCESS(rc)) 955 { 956 uint32_t uDefAction = DND_IGNORE_ACTION; 957 RTCString strFormat = "unknown"; 958 if ( pDropTarget 959 && pDropTarget->HasData()) 960 { 961 uDefAction = DND_COPY_ACTION; 962 uAllActions = uDefAction; 963 strFormat = "text/plain;charset=utf-8"; 964 } 965 966 LogFlowFunc(("Acknowledging pDropTarget=0x%p, uDefAction=0x%x, uAllActions=0x%x, strFormat=%s\n", 967 pDropTarget, uDefAction, uAllActions, strFormat.c_str())); 968 rc = VbglR3DnDGHAcknowledgePending(mClientID, 969 uDefAction, uAllActions, strFormat.c_str()); 970 } 880 971 881 972 LogFlowFuncLeaveRC(rc); … … 888 979 LogFlowThisFunc(("mMode=%ld, mState=%ld, cbFormats=%RU32, uDefAction=0x%x\n", 889 980 mMode, mState, cbFormats, uDefAction)); 890 891 981 int rc; 892 982 if (mState == Dragging) 893 983 { 984 AssertPtr(pDropTarget); 894 985 } 895 986 else … … 913 1004 int VBoxDnDWnd::dragRelease(void) 914 1005 { 1006 #ifdef DEBUG_andy 1007 LogFlowFunc(("\n")); 1008 #endif 915 1009 /* Release mouse button in the guest to start the "drop" 916 1010 * action at the current mouse cursor position. */ … … 925 1019 int VBoxDnDWnd::hide(void) 926 1020 { 1021 #ifdef DEBUG_andy 1022 LogFlowFunc(("\n")); 1023 #endif 927 1024 ShowWindow(hWnd, SW_HIDE); 928 1025 … … 967 1064 if (RT_SUCCESS(rc)) 968 1065 { 1066 LONG lStyle = GetWindowLong(hWnd, GWL_STYLE); 1067 SetWindowLong(hWnd, GWL_STYLE, 1068 lStyle & ~(WS_CAPTION | WS_THICKFRAME)); 1069 LONG lExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); 1070 SetWindowLong(hWnd, GWL_EXSTYLE, 1071 lExStyle & ~( WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE 1072 | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); 1073 969 1074 fRc = SetWindowPos(hWnd, HWND_TOPMOST, 970 1075 r.left, … … 973 1078 r.bottom - r.top, 974 1079 #ifdef VBOX_DND_DEBUG_WND 975 SWP_SHOWWINDOW );1080 SWP_SHOWWINDOW | SWP_FRAMECHANGED); 976 1081 #else 977 1082 SWP_SHOWWINDOW | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); 978 1083 #endif 979 1084 if (fRc) 1085 { 980 1086 LogFlowFunc(("Virtual screen is %ld,%ld,%ld,%ld (%ld x %ld)\n", 981 1087 r.left, r.top, r.right, r.bottom, 982 1088 r.right - r.left, r.bottom - r.top)); 1089 } 983 1090 else 984 1091 { -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.h
r50102 r50177 106 106 public: 107 107 108 static int CreateDropSource(VBoxDnDWnd *pParent, IDropSource **ppDropSource);109 110 public:111 112 108 uint32_t GetCurrentAction(void) { return muCurAction; } 113 109 … … 139 135 virtual ~VBoxDnDDropTarget(void); 140 136 141 public:142 143 static int CreateDropTarget(VBoxDnDWnd *pParent, IDropTarget **ppDropTarget);144 145 137 public: /* IUnknown methods. */ 146 138 … … 159 151 160 152 static DWORD GetDropEffect(DWORD grfKeyState, DWORD dwAllowedEffects); 153 154 public: 155 156 const IDataObject *GetDataObject(void) { return mpDataObject; } 157 bool HasData(void) { return mfHasDropData; } 161 158 162 159 protected: … … 374 371 bool mfMouseButtonDown; 375 372 # ifdef VBOX_WITH_DRAG_AND_DROP_GH 376 IDropTarget*pDropTarget;373 VBoxDnDDropTarget *pDropTarget; 377 374 # endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 378 375 #else -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropSource.cpp
r49947 r50177 5 5 6 6 /* 7 * Copyright (C) 2013 Oracle Corporation7 * Copyright (C) 2013-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 43 43 44 44 LogFlowFunc(("rc=%Rrc, mRefCount=%RI32\n", rc, mRefCount)); 45 }46 47 /* static */48 int VBoxDnDDropSource::CreateDropSource(VBoxDnDWnd *pParent, IDropSource **ppDropSource)49 {50 AssertPtrReturn(pParent, VERR_INVALID_POINTER);51 AssertPtrReturn(ppDropSource, VERR_INVALID_POINTER);52 53 int rc;54 try55 {56 *ppDropSource = new VBoxDnDDropSource(pParent);57 rc = VINF_SUCCESS;58 }59 catch(std::bad_alloc &)60 {61 rc = VERR_NO_MEMORY;62 }63 64 return rc;65 45 } 66 46 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropTarget.cpp
r50116 r50177 47 47 } 48 48 49 /* static */50 int VBoxDnDDropTarget::CreateDropTarget(VBoxDnDWnd *pParent, IDropTarget **ppDropTarget)51 {52 AssertPtrReturn(pParent, VERR_INVALID_POINTER);53 AssertPtrReturn(ppDropTarget, VERR_INVALID_POINTER);54 55 int rc;56 try57 {58 *ppDropTarget = new VBoxDnDDropTarget(pParent);59 rc = VINF_SUCCESS;60 }61 catch(std::bad_alloc &)62 {63 rc = VERR_NO_MEMORY;64 }65 66 return rc;67 }68 69 49 /* 70 50 * IUnknown methods. … … 117 97 mfHasDropData, pDataObject, grfKeyState, pt.x, pt.y, *pdwEffect)); 118 98 119 FORMATETC fmtetc = { CF_ HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };99 FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 120 100 121 101 /* We only handle CF_HDROP in an HGLOBAL medium at the moment. */ … … 162 142 163 143 #ifdef DEBUG_andy 164 LogFlowFunc(("Returning pdwEffect=%ld\n",pdwEffect));144 LogFlowFunc(("Returning *pdwEffect=%ld\n", *pdwEffect)); 165 145 #endif 166 146 return S_OK; … … 184 164 AssertPtrReturn(pdwEffect, E_INVALIDARG); 185 165 186 #ifdef DEBUG _andy166 #ifdef DEBUG 187 167 LogFlowFunc(("mfHasDropData=%RTbool, pDataObject=0x%p, grfKeyState=0x%x, x=%ld, y=%ld\n", 188 168 mfHasDropData, pDataObject, grfKeyState, pt.x, pt.y)); 189 169 #endif 190 191 //PositionCursor(m_hWnd, pt);192 193 170 bool fCanDrop = false; 194 171 if (mfHasDropData) 195 172 { 196 // construct a FORMATETC object 197 FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 198 STGMEDIUM stgmed; 173 FORMATETC fmtEtc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 174 STGMEDIUM stgMed; 199 175 200 176 AssertPtr(pDataObject); 201 if ( (pDataObject->QueryGetData(&fmt etc)== S_OK)202 && (pDataObject->GetData(&fmt etc, &stgmed) == S_OK))177 if ( (pDataObject->QueryGetData(&fmtEtc) == S_OK) 178 && (pDataObject->GetData(&fmtEtc, &stgMed) == S_OK)) 203 179 { 204 // we asked for the data as a HGLOBAL, so access it appropriately205 PVOID data = GlobalLock(stgmed.hGlobal); 206 207 //SetWindowText(hwnd, (char *)data);208 209 GlobalUnlock(stg med.hGlobal);210 211 / / release the data using the COM API212 ReleaseStgMedium(&stg med);180 PVOID pvData = GlobalLock(stgMed.hGlobal); 181 #ifdef DEBUG 182 if (fmtEtc.cfFormat == CF_TEXT) 183 LogFlowFunc(("pvData=%s\n", (char*)pvData)); 184 #endif 185 GlobalUnlock(stgMed.hGlobal); 186 187 /* Release storage medium again. */ 188 ReleaseStgMedium(&stgMed); 213 189 214 190 fCanDrop = true; … … 225 201 *pdwEffect = DROPEFFECT_NONE; 226 202 203 LogFlowFunc(("Returning with mfHasDropData=%RTbool, fCanDrop=%RTbool, *pdwEffect=%RI32\n", 204 mfHasDropData, fCanDrop, *pdwEffect)); 227 205 return S_OK; 228 206 } … … 251 229 252 230 #ifdef DEBUG_andy 253 LogFlowFunc(("dwEffect=%ld\n", dwEffect)); 231 LogFlowFunc(("grfKeyState=0x%x, dwAllowedEffects=0x%x, dwEffect=0x%x\n", 232 grfKeyState, dwAllowedEffects, dwEffect)); 254 233 #endif 255 234 return dwEffect;
Note:
See TracChangeset
for help on using the changeset viewer.