summaryrefslogtreecommitdiffstats
path: root/kdecore/kglobalaccel_x11.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-04-19 02:37:55 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-04-19 02:37:55 +0000
commit9f2307382d4acc636b621570ed7770dcab0d652a (patch)
tree0fa904481c8f137230fef32a6eb27320e0a0bfae /kdecore/kglobalaccel_x11.cpp
parent13da15f83844afa55de41ab2940541f5ae586187 (diff)
downloadtdelibs-9f2307382d4acc636b621570ed7770dcab0d652a.tar.gz
tdelibs-9f2307382d4acc636b621570ed7770dcab0d652a.zip
Part II of the previous kdebase commit, adding the global hotkeys<-->DBUS connection.
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1116280 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/kglobalaccel_x11.cpp')
-rw-r--r--kdecore/kglobalaccel_x11.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/kdecore/kglobalaccel_x11.cpp b/kdecore/kglobalaccel_x11.cpp
index 542e04361..249c06460 100644
--- a/kdecore/kglobalaccel_x11.cpp
+++ b/kdecore/kglobalaccel_x11.cpp
@@ -89,6 +89,7 @@ KGlobalAccelPrivate::KGlobalAccelPrivate()
all_accels->append( this );
m_sConfigGroup = "Global Shortcuts";
kapp->installX11EventFilter( this );
+ connect(kapp, SIGNAL(coreFakeKeyPress(unsigned int)), this, SLOT(fakeKeyPressed(unsigned int)));
}
KGlobalAccelPrivate::~KGlobalAccelPrivate()
@@ -269,6 +270,49 @@ void KGlobalAccelPrivate::x11MappingNotify()
updateConnections();
}
+void KGlobalAccelPrivate::fakeKeyPressed(unsigned int keyCode) {
+ CodeMod codemod;
+ codemod.code = keyCode;
+ codemod.mod = 0;
+
+ KKey key = (keyCode, 0);
+
+ kdDebug(125) << "fakeKeyPressed: seek " << key.toStringInternal()
+ << QString( " keyCodeX: %1 keyCode: %2 keyModX: %3" )
+ .arg( codemod.code, 0, 16 ).arg( keyCode, 0, 16 ).arg( codemod.mod, 0, 16 ) << endl;
+
+ // Search for which accelerator activated this event:
+ if( !m_rgCodeModToAction.contains( codemod ) ) {
+#ifndef NDEBUG
+ for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) {
+ KAccelAction* pAction = *it;
+ kdDebug(125) << "\tcode: " << QString::number(it.key().code, 16) << " mod: " << QString::number(it.key().mod, 16)
+ << (pAction ? QString(" name: \"%1\" shortcut: %2").arg(pAction->name()).arg(pAction->shortcut().toStringInternal()) : QString::null)
+ << endl;
+ }
+#endif
+ return;
+ }
+
+ KAccelAction* pAction = m_rgCodeModToAction[codemod];
+
+ if( !pAction ) {
+ static bool recursion_block = false;
+ if( !recursion_block ) {
+ recursion_block = true;
+ QPopupMenu* pMenu = createPopupMenu( 0, KKeySequence(key) );
+ connect( pMenu, SIGNAL(activated(int)), this, SLOT(slotActivated(int)) );
+ pMenu->exec( QPoint( 0, 0 ) );
+ disconnect( pMenu, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
+ delete pMenu;
+ recursion_block = false;
+ }
+ } else if( !pAction->objSlotPtr() || !pAction->isEnabled() )
+ return;
+ else
+ activate( pAction, KKeySequence(key) );
+}
+
bool KGlobalAccelPrivate::x11KeyPress( const XEvent *pEvent )
{
// do not change this line unless you really really know what you are doing (Matthias)