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
v3.5.13-sru
tpearson 15 years ago
parent 13da15f838
commit 9f2307382d

@ -64,3 +64,7 @@ void KAppDCOPInterface::reparseConfiguration()
KGlobal::config()->reparseConfiguration();
}
void KAppDCOPInterface::sendFakeKey( unsigned int keyCode) {
m_KApplication->broadcastKeyCode(keyCode);
}

@ -64,6 +64,12 @@ k_dcop:
void reparseConfiguration();
void updateUserTimestamp( ulong time );
/**
Send a fake keypress to all KApplication instances
For internal use in connecting insecure function keys to
KDE applications while the X keyboard is locked.
**/
void sendFakeKey( unsigned int keyCode);
private:
KApplication *m_KApplication;

@ -2603,6 +2603,11 @@ void KApplication::selectAll()
invokeEditSlot( SLOT( selectAll() ) );
}
void KApplication::broadcastKeyCode(unsigned int keyCode)
{
emit coreFakeKeyPress(keyCode);
}
QCString
KApplication::launcher()
{

@ -603,6 +603,14 @@ public slots:
*/
void selectAll();
/**
* Broadcast a received keycode to all listening KDE applications
* The primary use for this feature is to connect hotkeys such as
* XF86Display to their respective KGlobalAccel functions while
* the screen is locked by kdesktop_lock.
*/
void broadcastKeyCode(unsigned int keyCode);
public:
/**
* Returns the DCOP name of the service launcher. This will be something like
@ -1382,6 +1390,12 @@ signals:
*/
void updateIconLoaders();
/**
* @internal
* Used to send KGlobalAccel objects a new keypress from physical hotkeys.
*/
void coreFakeKeyPress(unsigned int keyCode);
private:
void propagateSettings(SettingsCategory category);
void kdisplaySetPalette();

@ -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)

@ -100,6 +100,7 @@ class KGlobalAccelPrivate : public QWidget, public KAccelBase
protected slots:
void slotActivated( int iAction );
void fakeKeyPressed(unsigned int keyCode);
private:
bool m_blocked;
bool m_blockingDisabled;

Loading…
Cancel
Save