summaryrefslogtreecommitdiffstats
path: root/kxkb
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-11-13 00:07:36 +0200
committerMavridis Philippe <mavridisf@gmail.com>2024-11-13 00:07:36 +0200
commit7478f48dc40bdc142a5962b3ded09903bec8495a (patch)
treef6b6dc3f74c7d34f25c764ee775baee2aed2d3e0 /kxkb
parent753873e6d73ffcf00199d31e084e6a96b9eb84e0 (diff)
downloadtdebase-7478f48dc40bdc142a5962b3ded09903bec8495a.tar.gz
tdebase-7478f48dc40bdc142a5962b3ded09903bec8495a.zip
Kxkb: reapply Xkb settings when a keyboard device changes state
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kxkb')
-rw-r--r--kxkb/CMakeLists.txt2
-rw-r--r--kxkb/kxkb.cpp45
-rw-r--r--kxkb/kxkb.h7
3 files changed, 49 insertions, 5 deletions
diff --git a/kxkb/CMakeLists.txt b/kxkb/CMakeLists.txt
index cb0d4b9db..83ca72be7 100644
--- a/kxkb/CMakeLists.txt
+++ b/kxkb/CMakeLists.txt
@@ -67,5 +67,5 @@ tde_add_tdeinit_executable( kxkb AUTOMOC
extension.cpp x11helper.cpp rules.cpp kxkbconfig.cpp
pixmap.cpp layoutmap.cpp kxkb.cpp kxkbtraywindow.cpp
kxkb.skel
- LINK tdeui-shared ${XKBFILE_LIBRARIES}
+ LINK tdeui-shared ${XKBFILE_LIBRARIES} ${TDEHW_LIBRARIES}
)
diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp
index 3d04824ad..92b12472b 100644
--- a/kxkb/kxkb.cpp
+++ b/kxkb/kxkb.cpp
@@ -34,6 +34,7 @@ DESCRIPTION
#include <tdeaboutdata.h>
#include <tdecmdlineargs.h>
+#include <tdehardwaredevices.h>
#include <tdeglobal.h>
#include <kglobalaccel.h>
#include <tdelocale.h>
@@ -84,6 +85,11 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled)
connect( this, TQ_SIGNAL(settingsChanged(int)), TQ_SLOT(slotSettingsChanged(int)) );
addKipcEventMask( KIPC::SettingsChanged );
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ connect(hwdevices, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(hardwareAdded(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(hardwareRemoved(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(hardwareUpdated(TDEGenericDevice*)));
}
KXKBApp::~KXKBApp()
@@ -107,10 +113,7 @@ int KXKBApp::newInstance()
bool KXKBApp::settingsRead()
{
kxkbConfig.load(KxkbConfig::LOAD_ALL);
- XkbOptions options = kxkbConfig.getKXkbOptions();
- if (!m_extension->setXkbOptions(options)) {
- kdWarning() << "Setting XKB options failed!" << endl;
- }
+ applySettings();
if ( kxkbConfig.m_useKxkb == false ) {
kapp->quit();
@@ -165,6 +168,14 @@ bool KXKBApp::settingsRead()
return true;
}
+void KXKBApp::applySettings()
+{
+ XkbOptions options = kxkbConfig.getKXkbOptions();
+ if (!m_extension->setXkbOptions(options)) {
+ kdWarning() << "Setting XKB options failed!" << endl;
+ }
+}
+
void KXKBApp::initTray()
{
if (!m_tray)
@@ -179,6 +190,32 @@ void KXKBApp::initTray()
m_tray->show();
}
+void KXKBApp::hardwareAdded(TDEGenericDevice *dev)
+{
+ if (dev->type() == TDEGenericDeviceType::Keyboard)
+ {
+ kdDebug() << "keyboard attached: " << dev->friendlyName() << endl;
+ applySettings();
+ }
+}
+void KXKBApp::hardwareRemoved(TDEGenericDevice *dev)
+{
+ if (dev->type() == TDEGenericDeviceType::Keyboard)
+ {
+ kdDebug() << "keyboard removed: " << dev->friendlyName() << endl;
+ applySettings();
+ }
+}
+
+void KXKBApp::hardwareUpdated(TDEGenericDevice *dev)
+{
+ if (dev->type() == TDEGenericDeviceType::Keyboard)
+ {
+ kdDebug() << "keyboard updated: " << dev->friendlyName() << endl;
+ applySettings();
+ }
+}
+
// kdcop
bool KXKBApp::setLayout(const TQString& layoutPair)
{
diff --git a/kxkb/kxkb.h b/kxkb/kxkb.h
index 143b68301..5708efd48 100644
--- a/kxkb/kxkb.h
+++ b/kxkb/kxkb.h
@@ -32,6 +32,7 @@ DESCRIPTION
#include <tqptrqueue.h>
#include <kuniqueapplication.h>
+#include <tdegenericdevice.h>
#include "kxkbtraywindow.h"
#include "kxkbconfig.h"
@@ -78,6 +79,12 @@ protected slots:
void showLayoutNotification();
void showErrorNotification(TQString layout);
+ void hardwareAdded(TDEGenericDevice *dev);
+ void hardwareRemoved(TDEGenericDevice *dev);
+ void hardwareUpdated(TDEGenericDevice *dev);
+
+ void applySettings();
+
protected:
// Read settings, and apply them.
bool settingsRead();