1 /* This file is part of the KDE libraries
2 Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "kglobalaccel_win.h"
22 #include "kkeyserver_win.h"
24 #include <QtGui/QWidgetList>
27 #include "kglobalaccel.h"
28 #include "globalshortcutsregistry.h"
30 #include <kapplication.h>
35 KGlobalAccelImpl::KGlobalAccelImpl(GlobalShortcutsRegistry
* owner
)
36 : m_owner(owner
), m_enabled(false)
40 bool KGlobalAccelImpl::grabKey( int keyQt
, bool grab
)
43 kWarning(125) << "Tried to grab key with null code.";
49 KKeyServer::keyQtToCodeWin(keyQt
, &keyCodeW
);
50 KKeyServer::keyQtToModWin(keyQt
, &keyModW
);
52 ATOM id
= GlobalAddAtom(MAKEINTATOM(keyQt
));
55 b
= RegisterHotKey(winId(), id
, keyModW
, keyCodeW
);
57 b
= UnregisterHotKey(winId(), id
);
63 void KGlobalAccelImpl::setEnabled( bool enable
)
68 bool KGlobalAccelImpl::winEvent( MSG
* message
, long * result
)
70 if (message
->message
== WM_HOTKEY
) {
71 uint keyCodeW
= HIWORD(message
->lParam
);
72 uint keyModW
= LOWORD(message
->lParam
);
74 int keyCodeQt
, keyModQt
;
75 KKeyServer::codeWinToKeyQt(keyCodeW
, &keyCodeQt
);
76 KKeyServer::modWinToKeyQt(keyModW
, &keyModQt
);
78 return m_owner
->keyPressed(keyCodeQt
| keyModQt
);
83 #include "kglobalaccel_win.moc"