File kdenetwork-trinity-keyboard-grab.patch of Package kdenetwork3
From 63ead30414e858a324809fa81ac79a4ebe18f754 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Fri, 9 Oct 2020 19:44:46 +0800
Subject: krdc: fixed handling of keyboard grab/release. This resolves issue
#27.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
krdc/keycapturedialog.cpp | 30 ++++++++++++++++++------------
krdc/keycapturedialog.h | 2 --
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/krdc/keycapturedialog.cpp b/krdc/keycapturedialog.cpp
index 03322b56..5bceaa2e 100644
--- a/krdc/keycapturedialog.cpp
+++ b/krdc/keycapturedialog.cpp
@@ -48,7 +48,7 @@ const int XKeyRelease = KeyRelease;
KeyCaptureDialog::KeyCaptureDialog(QWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n( "Enter Key Combination" ),
- Cancel, Cancel, true), m_grabbed(false) {
+ Cancel, Cancel, true) {
QFrame *main = makeMainWidget();
QVBoxLayout *layout = new QVBoxLayout( main, 0, KDialog::spacingHint() );
m_captureWidget = new KeyCaptureWidget( main, "m_captureWidget" );
@@ -57,15 +57,13 @@ KeyCaptureDialog::KeyCaptureDialog(QWidget *parent, const char *name)
}
KeyCaptureDialog::~KeyCaptureDialog() {
- if (m_grabbed)
- releaseKeyboard();
+ releaseKeyboard();
}
void KeyCaptureDialog::execute() {
m_captureWidget->keyLabel->setText("");
exec();
- if (m_grabbed)
- releaseKeyboard();
+ releaseKeyboard();
}
bool KeyCaptureDialog::x11Event(XEvent *pEvent)
@@ -76,17 +74,25 @@ bool KeyCaptureDialog::x11Event(XEvent *pEvent)
x11EventKeyPress( pEvent );
return true;
case XFocusIn:
- if (!m_grabbed)
- grabKeyboard();
- return true;
+ {
+ XFocusInEvent *fie = (XFocusInEvent*)pEvent;
+ if (fie->mode != NotifyGrab && fie->mode != NotifyUngrab) {
+ grabKeyboard();
+ }
+ }
+ break;
case XFocusOut:
- if (m_grabbed)
- releaseKeyboard();
- return true;
+ {
+ XFocusOutEvent *foe = (XFocusOutEvent*)pEvent;
+ if (foe->mode != NotifyGrab && foe->mode != NotifyUngrab) {
+ releaseKeyboard();
+ }
+ }
+ break;
default:
break;
}
- return QWidget::x11Event( pEvent );
+ return KDialogBase::x11Event( pEvent );
}
void KeyCaptureDialog::x11EventKeyPress( XEvent *pEvent )
diff --git a/krdc/keycapturedialog.h b/krdc/keycapturedialog.h
index 94e81699..e1860966 100644
--- a/krdc/keycapturedialog.h
+++ b/krdc/keycapturedialog.h
@@ -30,7 +30,6 @@ class KeyCaptureWidget;
class KeyCaptureDialog : public KDialogBase {
Q_OBJECT
- bool m_grabbed;
public:
KeyCaptureDialog(QWidget * parent= 0, const char *name = 0);
~KeyCaptureDialog();
--
cgit v1.2.1