Only check for mouse button being pressed on separator move for Qt
That's a workaround for a bug. Other platforms might not have the same bug and might not have a way to query mouse buttons the same way Qt does.
This commit is contained in:
@@ -82,6 +82,12 @@ bool Platform::isQtQuick() const
|
||||
return strcmp(name(), "qtquick") == 0;
|
||||
}
|
||||
|
||||
bool Platform::isQt() const
|
||||
{
|
||||
static const bool is = isQtWidgets() || isQtQuick();
|
||||
return is;
|
||||
}
|
||||
|
||||
int Platform::startDragDistance() const
|
||||
{
|
||||
const int userRequestedDistance = Config::self().startDragDistance();
|
||||
|
||||
@@ -92,6 +92,9 @@ public:
|
||||
/// @brief Returns whether this platform is QtQuick
|
||||
bool isQtQuick() const;
|
||||
|
||||
/// @brief Returns whether this platform is Qt based
|
||||
bool isQt() const;
|
||||
|
||||
/// @brief Returns how many pixels the mouse must move for a drag to start
|
||||
/// This is usually 4 by default (QApplication::startDragDistance() for QtWidgets)
|
||||
/// You can override by calling Config::setStartDragDistance(), so you don't need to create
|
||||
|
||||
@@ -229,28 +229,31 @@ void Separator::onMouseDoubleClick()
|
||||
|
||||
void Separator::onMouseMove(QPoint pos)
|
||||
{
|
||||
Q_UNUSED(pos);
|
||||
if (!isBeingDragged())
|
||||
return;
|
||||
|
||||
if (!Platform::instance()->isLeftMouseButtonPressed()) {
|
||||
qCDebug(separators) << Q_FUNC_INFO
|
||||
<< "Ignoring spurious mouse event. Someone ate our ReleaseEvent";
|
||||
onMouseReleased();
|
||||
return;
|
||||
}
|
||||
if (Platform::instance()->isQt()) {
|
||||
// Workaround a bug in Qt where we're getting mouse moves without without the button being
|
||||
// pressed
|
||||
if (!Platform::instance()->isLeftMouseButtonPressed()) {
|
||||
qCDebug(separators) << Q_FUNC_INFO
|
||||
<< "Ignoring spurious mouse event. Someone ate our ReleaseEvent";
|
||||
onMouseReleased();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Try harder, Qt can be wrong, if mixed with MFC
|
||||
const bool mouseButtonIsReallyDown =
|
||||
(GetKeyState(VK_LBUTTON) & 0x8000) || (GetKeyState(VK_RBUTTON) & 0x8000);
|
||||
if (!mouseButtonIsReallyDown) {
|
||||
qCDebug(separators) << Q_FUNC_INFO
|
||||
<< "Ignoring spurious mouse event. Someone ate our ReleaseEvent";
|
||||
onMouseReleased();
|
||||
return;
|
||||
}
|
||||
// Try harder, Qt can be wrong, if mixed with MFC
|
||||
const bool mouseButtonIsReallyDown =
|
||||
(GetKeyState(VK_LBUTTON) & 0x8000) || (GetKeyState(VK_RBUTTON) & 0x8000);
|
||||
if (!mouseButtonIsReallyDown) {
|
||||
qCDebug(separators) << Q_FUNC_INFO
|
||||
<< "Ignoring spurious mouse event. Someone ate our ReleaseEvent";
|
||||
onMouseReleased();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const int positionToGoTo = Layouting::pos(pos, d->orientation);
|
||||
const int minPos = d->parentContainer->minPosForSeparator_global(this);
|
||||
|
||||
Reference in New Issue
Block a user