disabled drag and drop feature if there is no --enable-drag-drop cmd arg

This commit is contained in:
jerry 2013-09-25 12:37:27 +00:00
parent e24afa5670
commit fd0f5e1db2
8 changed files with 36 additions and 7 deletions

View File

@ -361,7 +361,7 @@ CMSWindowsScreen::leave()
m_isOnScreen = false; m_isOnScreen = false;
forceShowCursor(); forceShowCursor();
if (m_draggingStarted) { if (getDraggingStarted()) {
CString& draggingDir = getDraggingFileDir(); CString& draggingDir = getDraggingFileDir();
LOG((CLOG_DEBUG "get dragging file dir: %s", draggingDir.c_str())); LOG((CLOG_DEBUG "get dragging file dir: %s", draggingDir.c_str()));
size_t size = draggingDir.size(); size_t size = draggingDir.size();
@ -1322,14 +1322,14 @@ CMSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam)
if (button >= kButtonLeft && button <= kButtonExtra0 + 1) { if (button >= kButtonLeft && button <= kButtonExtra0 + 1) {
if (pressed) { if (pressed) {
m_buttons[button] = true; m_buttons[button] = true;
if (CApp::instance().argsBase().m_enableDragDrop && button == kButtonLeft) { if (button == kButtonLeft) {
m_draggingFileDir.clear(); m_draggingFileDir.clear();
LOG((CLOG_DEBUG2 "dragging file directory is cleared")); LOG((CLOG_DEBUG2 "dragging file directory is cleared"));
} }
} }
else { else {
m_buttons[button] = false; m_buttons[button] = false;
if (CApp::instance().argsBase().m_enableDragDrop && m_draggingStarted && button == kButtonLeft) { if (m_draggingStarted && button == kButtonLeft) {
m_draggingStarted = false; m_draggingStarted = false;
} }
} }

View File

@ -317,6 +317,7 @@ COSXScreen::isAnyMouseButtonDown(UInt32& buttonID) const
{ {
if (m_buttonState.test(0)) { if (m_buttonState.test(0)) {
buttonID = kButtonLeft; buttonID = kButtonLeft;
return true;
} }
return (GetCurrentButtonState() != 0); return (GetCurrentButtonState() != 0);
@ -900,7 +901,7 @@ COSXScreen::leave()
{ {
hideCursor(); hideCursor();
if (m_draggingStarted) { if (getDraggingStarted()) {
CFStringRef dragInfo = getDraggedFileURL(); CFStringRef dragInfo = getDraggedFileURL();
char* dragInfoCStr = CFStringRefToUTF8String(dragInfo); char* dragInfoCStr = CFStringRefToUTF8String(dragInfo);
LOG((CLOG_DEBUG "drag info: %s", dragInfoCStr)); LOG((CLOG_DEBUG "drag info: %s", dragInfoCStr));

View File

@ -302,6 +302,7 @@ CScreen*
CClientApp::openClientScreen() CClientApp::openClientScreen()
{ {
CScreen* screen = createScreen(); CScreen* screen = createScreen();
screen->setEnableDragDrop(argsBase().m_enableDragDrop);
m_events->adoptHandler(m_events->forIScreen().error(), m_events->adoptHandler(m_events->forIScreen().error(),
screen->getEventTarget(), screen->getEventTarget(),
new TMethodEventJob<CClientApp>( new TMethodEventJob<CClientApp>(

View File

@ -17,6 +17,8 @@
*/ */
#include "CPlatformScreen.h" #include "CPlatformScreen.h"
#include "CApp.h"
#include "CArgsBase.h"
CPlatformScreen::CPlatformScreen(IEventQueue* events) : CPlatformScreen::CPlatformScreen(IEventQueue* events) :
IPlatformScreen(events), IPlatformScreen(events),
@ -110,3 +112,12 @@ CPlatformScreen::pollPressedKeys(KeyButtonSet& pressedKeys) const
{ {
getKeyState()->pollPressedKeys(pressedKeys); getKeyState()->pollPressedKeys(pressedKeys);
} }
bool
CPlatformScreen::getDraggingStarted()
{
if (CApp::instance().argsBase().m_enableDragDrop) {
return m_draggingStarted;
}
return false;
}

View File

@ -78,7 +78,7 @@ public:
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const; virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const;
virtual void setDraggingStarted(bool started) { m_draggingStarted = started; } virtual void setDraggingStarted(bool started) { m_draggingStarted = started; }
virtual bool getDraggingStarted() { return m_draggingStarted; } virtual bool getDraggingStarted();
virtual bool getFakeDraggingStarted() { return m_fakeDraggingStarted; } virtual bool getFakeDraggingStarted() { return m_fakeDraggingStarted; }
virtual CString& getDraggingFileDir() { return m_draggingFileDir; } virtual CString& getDraggingFileDir() { return m_draggingFileDir; }

View File

@ -36,7 +36,8 @@ CScreen::CScreen(IPlatformScreen* platformScreen, IEventQueue* events) :
m_entered(m_isPrimary), m_entered(m_isPrimary),
m_screenSaverSync(true), m_screenSaverSync(true),
m_fakeInput(false), m_fakeInput(false),
m_mock(false) m_mock(false),
m_enableDragDrop(false)
{ {
assert(m_screen != NULL); assert(m_screen != NULL);
@ -368,12 +369,18 @@ CScreen::isLockedToScreen() const
// check for pressed mouse buttons // check for pressed mouse buttons
// HACK: commented out as it breaks new drag drop feature // HACK: commented out as it breaks new drag drop feature
UInt32 buttonID = 0; UInt32 buttonID = 0;
if (m_screen->isAnyMouseButtonDown(buttonID)) { if (m_screen->isAnyMouseButtonDown(buttonID)) {
if (buttonID != kButtonLeft) { if (buttonID != kButtonLeft) {
LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID)); LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID));
} }
return (buttonID == kButtonLeft) ? false : true; if (m_enableDragDrop) {
return (buttonID == kButtonLeft) ? false : true;
}
else {
return true;
}
} }
// not locked // not locked
@ -433,6 +440,12 @@ CScreen::startDraggingFiles(CString str)
m_screen->fakeDraggingFiles(str); m_screen->fakeDraggingFiles(str);
} }
void
CScreen::setEnableDragDrop(bool enabled)
{
m_enableDragDrop = enabled;
}
CString& CString&
CScreen::getDraggingFileDir() const CScreen::getDraggingFileDir() const
{ {

View File

@ -225,6 +225,7 @@ public:
//! Fake a files dragging operation //! Fake a files dragging operation
void startDraggingFiles(CString str); void startDraggingFiles(CString str);
void setEnableDragDrop(bool enabled);
//@} //@}
//! @name accessors //! @name accessors
//@{ //@{
@ -335,6 +336,7 @@ private:
IEventQueue* m_events; IEventQueue* m_events;
bool m_mock; bool m_mock;
bool m_enableDragDrop;
}; };
#endif #endif

View File

@ -547,6 +547,7 @@ bool CServerApp::initServer()
CScreen* CServerApp::openServerScreen() CScreen* CServerApp::openServerScreen()
{ {
CScreen* screen = createScreen(); CScreen* screen = createScreen();
screen->setEnableDragDrop(argsBase().m_enableDragDrop);
m_events->adoptHandler(m_events->forIScreen().error(), m_events->adoptHandler(m_events->forIScreen().error(),
screen->getEventTarget(), screen->getEventTarget(),
new TMethodEventJob<CServerApp>( new TMethodEventJob<CServerApp>(