krdc: fixed handling of keyboard grab/release. This resolves issue #27.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/28/head
Michele Calgaro 4 years ago
parent 87f4e9ab47
commit 63ead30414
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -48,7 +48,7 @@ const int XKeyRelease = KeyRelease;
KeyCaptureDialog::KeyCaptureDialog(TQWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n( "Enter Key Combination" ),
Cancel, Cancel, true), m_grabbed(false) {
Cancel, Cancel, true) {
TQFrame *main = makeMainWidget();
TQVBoxLayout *layout = new TQVBoxLayout( main, 0, KDialog::spacingHint() );
m_captureWidget = new KeyCaptureWidget( main, "m_captureWidget" );
@ -57,15 +57,13 @@ KeyCaptureDialog::KeyCaptureDialog(TQWidget *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 TQWidget::x11Event( pEvent );
return KDialogBase::x11Event( pEvent );
}
void KeyCaptureDialog::x11EventKeyPress( XEvent *pEvent )

@ -30,8 +30,6 @@ class KeyCaptureWidget;
class KeyCaptureDialog : public KDialogBase {
Q_OBJECT
bool m_grabbed;
public:
KeyCaptureDialog(TQWidget * parent= 0, const char *name = 0);
~KeyCaptureDialog();

Loading…
Cancel
Save