Skip to content

Commit 97937d5

Browse files
committed
v3.1.8
Refactored drag logic in LaunchyWidget to track both local and global drag start positions, improving accuracy when moving the widget between screens. Added debug logging for mouse events and screen geometry, and updated logic to reload the skin only when the widget is moved to a different screen. Also incremented the patch version to 3.1.8.
1 parent 0b8e4c8 commit 97937d5

File tree

3 files changed

+48
-27
lines changed

3 files changed

+48
-27
lines changed

src/Launchy/LaunchyVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2121

2222
#define LAUNCHY_VERSION_MAJOR 3
2323
#define LAUNCHY_VERSION_MINOR 1
24-
#define LAUNCHY_VERSION_PATCH 7
24+
#define LAUNCHY_VERSION_PATCH 8
2525

2626
// auto generate version number and string below
2727
constexpr unsigned LAUNCHY_VERSION

src/Launchy/LaunchyWidget.cpp

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,65 +1308,82 @@ void LaunchyWidget::applySkin(const QString& name) {
13081308
InputDataList::setSeparator(m_inputBox->separatorText());
13091309
}
13101310

1311-
void LaunchyWidget::mousePressEvent(QMouseEvent *event) {
1312-
if (event->buttons() == Qt::LeftButton) {
1313-
if (!g_settings->value(OPTION_DRAGMODE, OPTION_DRAGMODE_DEFAULT).toBool()
1314-
|| (event->modifiers() & Qt::ShiftModifier)) {
1315-
m_dragging = true;
1316-
m_dragStartPoint = event->pos();
1317-
}
1311+
void LaunchyWidget::mousePressEvent(QMouseEvent* event) {
1312+
1313+
if (event->buttons() == Qt::LeftButton
1314+
&& (!g_settings->value(OPTION_DRAGMODE, OPTION_DRAGMODE_DEFAULT).toBool()
1315+
|| (event->modifiers() & Qt::ShiftModifier))) {
1316+
1317+
m_dragging = true;
1318+
m_dragStartPos = event->pos();
1319+
m_dragStartGlobalPos = event->globalPos();
1320+
1321+
qDebug() << "LaunchyWidget::mousePressEvent, drag begin, global pos:"
1322+
<< m_dragStartGlobalPos << "pos:" << m_dragStartPos;
13181323
}
1324+
13191325
hideAlternativeList();
13201326
activateWindow();
13211327
m_inputBox->setFocus();
13221328
}
13231329

13241330
void LaunchyWidget::mouseMoveEvent(QMouseEvent* event) {
1325-
if (event->buttons() == Qt::LeftButton
1326-
&& m_dragging) {
1331+
if (m_dragging && event->buttons() == Qt::LeftButton) {
13271332

13281333
hideAlternativeList();
13291334

13301335
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1331-
QPoint pt = event->globalPos() - m_dragStartPoint;
1336+
QPoint pt = event->globalPos() - m_dragStartPos;
13321337
#else
1333-
QPoint pt = event->globalPosition().toPoint() - m_dragStartPoint;
1338+
QPoint pt = event->globalPosition().toPoint() - m_dragStartPos;
13341339
#endif
13351340

13361341
move(pt);
13371342

1338-
// qDebug() << "LaunchyWidget::mouseMoveEvent, pos:" << pt;
1339-
13401343
m_inputBox->setFocus();
13411344
}
13421345
}
13431346

13441347
void LaunchyWidget::mouseReleaseEvent(QMouseEvent* event) {
1348+
if (m_dragging == false) {
1349+
return;
1350+
}
13451351

13461352
m_dragging = false;
13471353

1348-
hideAlternativeList();
1349-
m_inputBox->setFocus();
1350-
1351-
int screenIndex = g_settings->value(OPTION_SCREEN_INDEX, OPTION_SCREEN_INDEX_DEFAULT).toInt();
1352-
13531354
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
13541355
QPoint pt = event->globalPos();
13551356
#else
13561357
QPoint pt = event->globalPosition().toPoint();
13571358
#endif
13581359

1360+
qDebug() << "LaunchyWidget::mouseReleaseEvent, drag end, global pos:" << pt;
1361+
1362+
hideAlternativeList();
1363+
m_inputBox->setFocus();
1364+
1365+
int prevScreenIndex = -1;
1366+
int currScreenIndex = -1;
1367+
13591368
QList<QScreen*> listScreens = qApp->screens();
13601369
for (int i = 0; i < listScreens.size(); ++i) {
1361-
QScreen* pScreen = listScreens.at(i);
1370+
QScreen* screen = listScreens.at(i);
13621371

1363-
if (pScreen->geometry().contains(pt)) {
1364-
// skip when cursor screen is enabled
1365-
if (screenIndex != -1) {
1366-
g_settings->setValue(OPTION_SCREEN_INDEX, i);
1367-
}
1372+
qDebug() << "LaunchyWidget::mouseReleaseEvent, screen:" << i
1373+
<< " geometry:" << screen->geometry();
1374+
1375+
if (prevScreenIndex == -1 && screen->geometry().contains(m_dragStartGlobalPos)) {
1376+
prevScreenIndex = i;
1377+
}
13681378

1369-
if (screenIndex != i) {
1379+
if (currScreenIndex == -1 && screen->geometry().contains(pt)) {
1380+
currScreenIndex = i;
1381+
}
1382+
1383+
if (prevScreenIndex >= 0 && currScreenIndex >= 0) {
1384+
qDebug() << "LaunchyWidget::mouseReleaseEvent, prev screen:" << prevScreenIndex
1385+
<< "curr screen:" << currScreenIndex;
1386+
if (prevScreenIndex != currScreenIndex) {
13701387
reloadSkin();
13711388
}
13721389
break;
@@ -1375,6 +1392,9 @@ void LaunchyWidget::mouseReleaseEvent(QMouseEvent* event) {
13751392
}
13761393

13771394
void LaunchyWidget::contextMenuEvent(QContextMenuEvent* event) {
1395+
qDebug() << "LaunchyWidget::contextMenuEvent, global pos:"
1396+
<< event->globalPos() << "pos:" << event->pos();
1397+
13781398
QMenu menu(this);
13791399
menu.addAction(m_actRebuild);
13801400
menu.addAction(m_actReloadSkin);

src/Launchy/LaunchyWidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ protected slots:
182182
bool m_alwaysShowLaunchy;
183183

184184
bool m_dragging;
185-
QPoint m_dragStartPoint;
185+
QPoint m_dragStartPos;
186+
QPoint m_dragStartGlobalPos;
186187
bool m_menuOpen;
187188

188189
OptionDialog* m_optionDialog;

0 commit comments

Comments
 (0)