Changeset 50177 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
- Timestamp:
- Jan 23, 2014 11:51:09 AM (11 years ago)
- File:
-
- 1 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 {
Note:
See TracChangeset
for help on using the changeset viewer.