delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kdedglobalaccel / kglobalaccel_win.cpp
blob84120cd5ff6125cd82b0090d2cabb4d29bfd7405
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>
25 #ifdef Q_WS_WIN
27 #include "kglobalaccel.h"
28 #include "globalshortcutsregistry.h"
30 #include <kapplication.h>
31 #include <kdebug.h>
33 #include <windows.h>
35 KGlobalAccelImpl::KGlobalAccelImpl(GlobalShortcutsRegistry* owner)
36 : m_owner(owner), m_enabled(false)
40 bool KGlobalAccelImpl::grabKey( int keyQt, bool grab )
42 if( !keyQt ) {
43 kWarning(125) << "Tried to grab key with null code.";
44 return false;
47 uint keyCodeW;
48 uint keyModW;
49 KKeyServer::keyQtToCodeWin(keyQt, &keyCodeW);
50 KKeyServer::keyQtToModWin(keyQt, &keyModW);
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);
60 return b;
63 void KGlobalAccelImpl::setEnabled( bool enable )
65 m_enabled = 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);
80 return false;
83 #include "kglobalaccel_win.moc"
85 #endif // Q_WS_WIN