[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-desktop/amourphious/keyboard] kcms/keyboard: ported XEventNotifier::getNewDeviceEventType(xc
From: shivam makkar <amourphious1992 () gmail ! com>
Date: 2014-05-31 19:18:24
Message-ID: E1WqonQ-0007f5-PR () scm ! kde ! org
[Download RAW message or body]
Git commit aac3a7489f8ee1e606c3fe5a21f58f607067b5c0 by shivam makkar.
Committed on 01/06/2014 at 00:48.
Pushed by makkar into branch 'amourphious/keyboard'.
ported XEventNotifier::getNewDeviceEventType(xcb_generic_event_t *event)
M +0 -4 kcms/keyboard/flags.cpp
M +32 -34 kcms/keyboard/xinput_helper.cpp
http://commits.kde.org/plasma-desktop/aac3a7489f8ee1e606c3fe5a21f58f607067b5c0
diff --git a/kcms/keyboard/flags.cpp b/kcms/keyboard/flags.cpp
index 3fb98e5..5206d1d 100644
--- a/kcms/keyboard/flags.cpp
+++ b/kcms/keyboard/flags.cpp
@@ -18,10 +18,6 @@
#include "flags.h"
-<<<<<<< HEAD
-=======
-//#include <kdebug.h>
->>>>>>> b756db51d8293b4a96ab851f9174e48f8ef36429
#include <kstandarddirs.h>
#include <kiconloader.h>
#include <kglobalsettings.h>
diff --git a/kcms/keyboard/xinput_helper.cpp b/kcms/keyboard/xinput_helper.cpp
index 980338e..1c9604b 100644
--- a/kcms/keyboard/xinput_helper.cpp
+++ b/kcms/keyboard/xinput_helper.cpp
@@ -37,12 +37,16 @@
static int DEVICE_NONE = 0;
static int DEVICE_KEYBOARD = 1;
static int DEVICE_POINTER = 2;
+static int connectedDevices;
+static int addedDevices = 0;
XInputEventNotifier::XInputEventNotifier(QWidget* parent):
XEventNotifier(parent), //TODO: destruct properly?
xinputEventType(-1)
{
+ XListInputDevices(QX11Info::display(), &connectedDevices);
+ qDebug()<<"initializing connectedDevices to: "<<connectedDevices;
}
void XInputEventNotifier::start()
@@ -72,8 +76,9 @@ bool XInputEventNotifier::processOtherEvents(xcb_generic_event_t* \
event) else if( newDeviceType == DEVICE_POINTER ) {
emit(newPointerDevice());
emit(newKeyboardDevice()); // arghhh, looks like X resets xkb map even when only \
pointer device is connected
- }
- return true;
+ }
+ XListInputDevices(QX11Info::display(), &connectedDevices);
+ return true;
}
@@ -93,40 +98,33 @@ static bool isRealKeyboard(const char* deviceName)
&& strstr(deviceName, "WMI hotkeys") == NULL;
}
-int XInputEventNotifier::getNewDeviceEventType(xcb_generic_event_t* /*event*/)
+int XInputEventNotifier::getNewDeviceEventType(xcb_generic_event_t* event)
{
int newDeviceType = DEVICE_NONE;
-
-#if 0
- if( xinputEventType != -1 && event->type == xinputEventType ) {
- XDevicePresenceNotifyEvent *xdpne = (XDevicePresenceNotifyEvent*) event;
- if( xdpne->devchange == DeviceEnabled ) {
- int ndevices;
- XDeviceInfo *devices = XListInputDevices(xdpne->display, &ndevices);
- if( devices != NULL ) {
-// kDebug() << "New device id:" << xdpne->deviceid;
- for(int i=0; i<ndevices; i++) {
-// kDebug() << "id:" << devices[i].id << "name:" << devices[i].name << "used \
as:" << devices[i].use;
- if( devices[i].id == xdpne->deviceid ) {
- if( devices[i].use == IsXKeyboard || devices[i].use == IsXExtensionKeyboard ) \
{
- if( isRealKeyboard(devices[i].name) ) {
- newDeviceType = DEVICE_KEYBOARD;
- qDebug() << "new keyboard device, id:" << devices[i].id << "name:" << \
devices[i].name << "used as:" << devices[i].use;
- break;
- }
- }
- if( devices[i].use == IsXPointer || devices[i].use == IsXExtensionPointer ) {
- newDeviceType = DEVICE_POINTER;
- qDebug() << "new pointer device, id:" << devices[i].id << "name:" << \
devices[i].name << "used as:" << devices[i].use;
- break;
- }
- }
- }
- XFreeDeviceList(devices);
- }
- }
- }
-#endif
+ int ndevices;
+ XDeviceInfo *devices = XListInputDevices(QX11Info::display(), &ndevices);
+ if((ndevices > connectedDevices && addedDevices < 20)){
+ addedDevices++;
+ qDebug() << "id:" << devices[ndevices - 1].id << "name:" << devices[ndevices \
- 1].name << "used as:" << devices[ndevices-1].use; + if( devices[ndevices - \
1].use == IsXKeyboard || devices[ndevices - 1].use == IsXExtensionKeyboard ) { + \
if( isRealKeyboard(devices[ndevices - 1].name) ) { + newDeviceType = \
DEVICE_KEYBOARD; + qDebug() << "new keyboard device, id:" << \
devices[ndevices - 1].id << "name:" << devices[ndevices - 1].name << "used as:" << \
devices[ndevices - 1].use; + }
+ }
+ if( devices[ndevices - 1].use == IsXPointer || devices[ndevices - 1].use == \
IsXExtensionPointer ) { + newDeviceType = DEVICE_POINTER;
+ qDebug() << "new pointer device, id:" << devices[ndevices - 1].id << \
"name:" << devices[ndevices - 1].name << "used as:" << devices[ndevices - 1].use; + \
} + }
+ else{
+ connectedDevices = ndevices;
+ addedDevices = 0;
+ }
+ if(addedDevices == 20){
+ connectedDevices = ndevices;
+ addedDevices = 0;
+ }
return newDeviceType;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic