From 1c673852bc9b18c144dbe90e4e2e366d65a120d3 Mon Sep 17 00:00:00 2001 From: Ian Farrell Date: Wed, 6 Sep 2023 20:36:05 -0400 Subject: [PATCH 1/2] Keyboard State Indicator: do not toggle on left click This suppresses toggling states when accessing the context menu --- plugin-kbindicator/src/content.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin-kbindicator/src/content.cpp b/plugin-kbindicator/src/content.cpp index ed034108d..6d4040756 100644 --- a/plugin-kbindicator/src/content.cpp +++ b/plugin-kbindicator/src/content.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -129,7 +130,8 @@ QWidget* Content::widget(Controls cnt) const bool Content::eventFilter(QObject *object, QEvent *event) { - if (event->type() == QEvent::QEvent::MouseButtonRelease) + if (event->type() == QEvent::QEvent::MouseButtonRelease + && static_cast(event)->button() == Qt::LeftButton) { if (object == m_capsLock) emit controlClicked(Controls::Caps); From 36e75c81a0ca7ab90ae0b03ce5568f91709dd8c5 Mon Sep 17 00:00:00 2001 From: Ian Farrell Date: Mon, 11 Sep 2023 11:15:16 -0400 Subject: [PATCH 2/2] Toggle on middle click Keep middle click behavior the same --- plugin-kbindicator/src/content.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin-kbindicator/src/content.cpp b/plugin-kbindicator/src/content.cpp index 6d4040756..f688f2886 100644 --- a/plugin-kbindicator/src/content.cpp +++ b/plugin-kbindicator/src/content.cpp @@ -130,15 +130,18 @@ QWidget* Content::widget(Controls cnt) const bool Content::eventFilter(QObject *object, QEvent *event) { - if (event->type() == QEvent::QEvent::MouseButtonRelease - && static_cast(event)->button() == Qt::LeftButton) + if (event->type() == QEvent::QEvent::MouseButtonRelease) { - if (object == m_capsLock) - emit controlClicked(Controls::Caps); - else if (object == m_numLock) - emit controlClicked(Controls::Num); - else if (object == m_scrollLock) - emit controlClicked(Controls::Scroll); + Qt::MouseButton btn = static_cast(event)->button(); + if (btn == Qt::LeftButton || btn == Qt::MiddleButton) + { + if (object == m_capsLock) + emit controlClicked(Controls::Caps); + else if (object == m_numLock) + emit controlClicked(Controls::Num); + else if (object == m_scrollLock) + emit controlClicked(Controls::Scroll); + } } return QWidget::eventFilter(object, event);