Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* This file is part of the KDE libraries |
---|---|
2 | Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> |
3 | |
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. |
8 | |
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. |
13 | |
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. |
18 | */ |
19 | |
20 | #include "kglobalaccel_win.h" |
21 | |
22 | #include "kkeyserver_win.h" |
23 | |
24 | #include <QWidgetList> |
25 | #ifdef Q_WS_WIN |
26 | |
27 | #include "kglobalaccel.h" |
28 | #include "globalshortcutsregistry.h" |
29 | |
30 | #include <kapplication.h> |
31 | #include <kdebug.h> |
32 | |
33 | #include <windows.h> |
34 | |
35 | KGlobalAccelImpl::KGlobalAccelImpl(GlobalShortcutsRegistry* owner) |
36 | : m_owner(owner), m_enabled(false) |
37 | { |
38 | } |
39 | |
40 | bool KGlobalAccelImpl::grabKey( int keyQt, bool grab ) |
41 | { |
42 | if( !keyQt ) { |
43 | kWarning(125) << "Tried to grab key with null code."; |
44 | return false; |
45 | } |
46 | |
47 | uint keyCodeW; |
48 | uint keyModW; |
49 | KKeyServer::keyQtToCodeWin(keyQt, &keyCodeW); |
50 | KKeyServer::keyQtToModWin(keyQt, &keyModW); |
51 | |
52 | ATOM id = GlobalAddAtom(MAKEINTATOM(keyQt)); |
53 | bool b; |
54 | if (grab) { |
55 | b = RegisterHotKey(winId(), id, keyModW, keyCodeW); |
56 | } else { |
57 | b = UnregisterHotKey(winId(), id); |
58 | } |
59 | |
60 | return b; |
61 | } |
62 | |
63 | void KGlobalAccelImpl::setEnabled( bool enable ) |
64 | { |
65 | m_enabled = enable; |
66 | } |
67 | |
68 | bool KGlobalAccelImpl::winEvent( MSG * message, long * result ) |
69 | { |
70 | if (message->message == WM_HOTKEY) { |
71 | uint keyCodeW = HIWORD(message->lParam); |
72 | uint keyModW = LOWORD(message->lParam); |
73 | |
74 | int keyCodeQt, keyModQt; |
75 | KKeyServer::codeWinToKeyQt(keyCodeW, &keyCodeQt); |
76 | KKeyServer::modWinToKeyQt(keyModW, &keyModQt); |
77 | |
78 | return m_owner->keyPressed(keyCodeQt | keyModQt); |
79 | } |
80 | return false; |
81 | } |
82 | |
83 | #include "kglobalaccel_win.moc" |
84 | |
85 | #endif // Q_WS_WIN |
86 |
Warning: That file was not part of the compilation database. It may have many parsing errors.