- Timestamp:
- Jan 20, 2010, 12:56:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qdnd_pm.cpp
r450 r451 292 292 } 293 293 294 // Equivalent of QApplication::mouseButtons() (mouse events aren't delivered 295 // to the window during DnD in PM so this metnod returns an incorrect value). 296 static Qt::MouseButtons mouseButtons() 297 { 298 Qt::MouseButtons buttons = Qt::NoButton; 299 300 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) 301 buttons |= Qt::LeftButton; 302 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000) 303 buttons |= Qt::RightButton; 304 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000) 305 buttons |= Qt::MidButton; 306 307 return buttons; 308 } 309 310 // Equivalent of QApplication::keyboardModifiers() (keyboard events aren't delivered 311 // to the window during DnD in PM so this metnod returns an incorrect value). 312 static Qt::KeyboardModifiers keyboardModifiers() 313 { 314 Qt::KeyboardModifiers mods = Qt::NoModifier; 315 316 if (WinGetKeyState(HWND_DESKTOP, VK_SHIFT ) & 0x8000) 317 mods |= Qt::ShiftModifier; 318 if ((WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000) || 319 (WinGetKeyState(HWND_DESKTOP, VK_ALTGRAF) & 0x8000)) 320 mods |= Qt::AltModifier; 321 if (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) 322 mods |= Qt::ControlModifier; 323 324 // Note: we cannot properly detect LWIN/RWIN (Meta) key state here as it 325 // doesn't have a corresponding VK_ value. The best we can do is to check 326 // the physical keyboard state using the hardware scancode but it has the 327 // following problems: 328 // 329 // 1. The physical keyboard state may be out of sync with the current 330 // input message we are processing. 331 // 2. The scancode may be hardware dependent 332 // 333 // 0x7E is what I get as a scancode value for LWIN from PM here. 334 // Unfortunately, I have no keyboard with RWIN around so I can't get its 335 // scan code. 336 337 if (WinGetPhysKeyState(HWND_DESKTOP, 0x7E) & 0x8000) 338 mods |= Qt::MetaModifier; 339 340 return mods; 341 } 342 294 343 void QDragManager::init_sys() 295 344 { … … 448 497 QDragEnterEvent dee(pnt, 449 498 toQDragDropActions(dragData->supportedOps), 450 data, QApplication::mouseButtons(), 451 QApplication::keyboardModifiers()); 499 data, mouseButtons(), keyboardModifiers()); 452 500 dee.setDropAction(dragData->lastAction); 453 501 sendDropEvent(dragOverWidget, &dee); … … 469 517 QDragMoveEvent dme(pnt, 470 518 toQDragDropActions(dragData->supportedOps), 471 data, QApplication::mouseButtons(), 472 QApplication::keyboardModifiers()); 519 data, mouseButtons(), keyboardModifiers()); 473 520 // accept by default, since enter event was accepted. 474 521 dme.setDropAction(dragData->lastAction); … … 549 596 dragData->setDropped(true); 550 597 551 QDropEvent de(pnt, dragData->lastAction, data, QApplication::mouseButtons(),552 QApplication::keyboardModifiers());598 QDropEvent de(pnt, dragData->lastAction, data, mouseButtons(), 599 keyboardModifiers()); 553 600 if (dragData->lastDropReply == DOR_DROP) 554 601 de.setDropAction(dragData->lastAction); … … 651 698 // QPMObjectWindow interface 652 699 MRESULT message(ULONG msg, MPARAM mp1, MPARAM mp2); 653 700 654 701 private: 655 702 QList<DragWorker*> workers; … … 667 714 bool gotExcl = false; // got isExclusive() worker? 668 715 bool skipExcl = false; // skip isExclusive() or itemCount() > 1 workers? 669 ULONG coopLevel = 0; // itemCount() level for !isExclusive() workers 716 ULONG coopLevel = 0; // itemCount() level for !isExclusive() workers 670 717 671 718 bool gotExclForMime = false; … … 734 781 // target's side (where the first encountered drop worker 735 782 // for the given RMF would be used for actual data transfer 736 // anyway). See also QClipboard::setData(). 783 // anyway). See also QClipboard::setData(). 737 784 break; 738 785 } … … 755 802 756 803 // remove either all exclusive workers or all their fall-back workers 757 // (depending on skipExcl) and remove duplicates 804 // (depending on skipExcl) and remove duplicates 758 805 for (QList<DragWorker*>::iterator it = workers.begin(); 759 806 it < workers.end();) { … … 767 814 } 768 815 769 #if defined(QDND_DEBUG) 816 #if defined(QDND_DEBUG) 770 817 foreach (DragWorker *wrk, workers) { 771 818 DEBUG(() << "QPMCoopDragWorker: Will use worker" << wrk 772 819 << "( isExclusive" << wrk->isExclusive() 773 << "itemCount" << wrk->itemCount() << ")"); 820 << "itemCount" << wrk->itemCount() << ")"); 774 821 } 775 822 #endif … … 785 832 if (!firstWorker) 786 833 return 0; 787 834 788 835 if (firstWorker->isExclusive() && firstWorker->itemCount() == 0) { 789 836 // this is a super exclusive worker that will do everything on its own 790 837 return firstWorker->hwnd(); 791 838 } 792 839 793 840 return QPMObjectWindow::hwnd(); 794 841 } … … 806 853 { 807 854 bool moveDisallowed = false; 808 855 809 856 foreach(DragWorker *wrk, workers) { 810 857 // disallow the Move operation if at least one worker asked so … … 837 884 return firstWorker->createDragInfo(targetName, supportedOps); 838 885 } 839 886 840 887 // note that all workers at this place require the same amount of items 841 888 // (guaranteed by collectWorkers()) 842 889 843 890 DEBUG(() << "QPMCoopDragWorker: itemCnt" << itemCnt); 844 891 … … 847 894 if (!info) 848 895 return 0; 849 896 850 897 // collect all mechanism/format pairs 851 898 QByteArray allFormats; … … 866 913 867 914 static ULONG itemID = 0; 868 915 869 916 const char *type = 0; 870 917 const char *ext = 0; … … 885 932 else 886 933 name = QString(QLatin1String("%1 %2")).arg(targetName).arg(i + 1); 887 934 888 935 if (ext) { 889 936 name += QLatin1Char('.'); … … 896 943 // Note 1: DRAGITEM::hstrType is actually ignored by WPS, 897 944 // only the target extension matters. 898 945 899 946 // Note 2: We're not required to fill in the hwndItem field because we 900 947 // use the DC_PREPARE flag (to indicate it will be filled later, after 901 948 // DM_RENDERPREPARE); however, Mozilla refuses to render if hwndItem 902 949 // is initially 0. Set it to our HWND instead (we'll issue a warning if 903 // DM_RENDER or DM_ENDCONVERSATION is erroneously sent to us) 950 // DM_RENDER or DM_ENDCONVERSATION is erroneously sent to us) 904 951 905 952 item->hwndItem = hwnd(); … … 915 962 item->fsSupportedOps = supportedOps; 916 963 } 917 964 918 965 if (!ok) { 919 966 DrgFreeDraginfo(info); 920 967 info = 0; 921 968 } 922 969 923 970 return info; 924 971 } … … 930 977 DEBUG(() << "Drop target sent DM_RENDERPREPARE after the DnD " 931 978 "session is over!"); 932 // free the given DRAGTRANSFER structure to avoud memory leak 979 // free the given DRAGTRANSFER structure to avoud memory leak 933 980 DRAGTRANSFER *xfer = (DRAGTRANSFER *)mp1; 934 981 if (xfer) … … 936 983 return (MRESULT)FALSE; 937 984 } 938 985 939 986 DRAGTRANSFER *xfer = (DRAGTRANSFER *)mp1; 940 987 Q_ASSERT(xfer && xfer->pditem); 941 988 if (!xfer || !xfer->pditem) 942 989 return (MRESULT)FALSE; 943 990 944 991 // find the item's index (ordinal number) 945 992 ULONG itemCnt = DrgQueryDragitemCount(info); … … 948 995 if (DrgQueryDragitemPtr(info, index) == xfer->pditem) 949 996 break; 950 997 951 998 Q_ASSERT(index < itemCnt); 952 999 if (index >= itemCnt) … … 956 1003 << QPMMime::queryHSTR(xfer->hstrSelectedRMF) << "for item" 957 1004 << index << "( id" << xfer->pditem->ulItemID << ")"); 958 1005 959 1006 QByteArray drm, drf; 960 1007 if (!QPMMime::parseRMF(xfer->hstrSelectedRMF, drm, drf)) { … … 976 1023 return (MRESULT)(xfer->pditem->hwndItem ? TRUE : FALSE); 977 1024 } 978 1025 979 1026 if (msg == DM_RENDER || msg == DM_ENDCONVERSATION) { 980 1027 DEBUG(() << "Drop target sent DM_RENDER or DM_ENDCONVERSATION to the " 981 1028 "drag source window instead of the drag item window!"); 982 1029 if (msg == DM_RENDER) { 983 // free the given DRAGTRANSFER structure to avoud memory leak 1030 // free the given DRAGTRANSFER structure to avoud memory leak 984 1031 DRAGTRANSFER *xfer = (DRAGTRANSFER *)mp1; 985 1032 if (xfer) … … 987 1034 } 988 1035 } 989 1036 990 1037 return (MRESULT)FALSE; 991 1038 } … … 1014 1061 ULONG msg = WinQuerySysValue(HWND_DESKTOP, SV_BEGINDRAG) & 0xFFFF; 1015 1062 switch(msg) { 1016 case WM_BUTTON1MOTIONSTART: vkTerminate = VK_BUTTON1; break; 1017 case WM_BUTTON2MOTIONSTART: vkTerminate = VK_BUTTON2; break; 1018 case WM_BUTTON3MOTIONSTART: vkTerminate = VK_BUTTON3; break; 1063 case WM_BUTTON1MOTIONSTART: vkTerminate = VK_BUTTON1; break; 1064 case WM_BUTTON2MOTIONSTART: vkTerminate = VK_BUTTON2; break; 1065 case WM_BUTTON3MOTIONSTART: vkTerminate = VK_BUTTON3; break; 1019 1066 } 1020 1067 … … 1042 1089 1043 1090 static QPMCoopDragWorker dragWorker; 1044 1091 1045 1092 bool ok = dragWorker.collectWorkers(o); 1046 1093 Q_ASSERT(ok); … … 1098 1145 bool moveDisallowed = dragWorker.cleanup(beingCancelled || target == 0); 1099 1146 dragWorker.src = 0; 1100 1147 1101 1148 moveDisallowed |= beingCancelled || target == 0 || 1102 1149 info->usOperation != DO_MOVE; … … 1139 1186 if (!object || beingCancelled) 1140 1187 return; 1141 1188 1142 1189 beingCancelled = true; 1143 1190
Note:
See TracChangeset
for help on using the changeset viewer.