1 /****************************************************************************
\r
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
\r
5 ** This file is part of the QxtGui module of the Qt eXTension library
\r
7 ** This library is free software; you can redistribute it and/or modify it
\r
8 ** under the terms of th Common Public License, version 1.0, as published by
\r
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
\r
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
\r
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
\r
14 ** FITNESS FOR A PARTICULAR PURPOSE.
\r
16 ** You should have received a copy of the CPL along with this file.
\r
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
\r
18 ** distribution for more information. If you did not receive a copy of the
\r
19 ** license, contact the Qxt Foundation.
\r
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
\r
23 ****************************************************************************/
\r
24 #include "qxtapplication.h"
\r
25 #include "qxtapplication_p.h"
\r
26 #include <qt_windows.h>
\r
29 bool QxtApplication::winEventFilter(MSG* msg, long* result)
\r
31 foreach (QxtNativeEventFilter* filter, qxt_d().nativeFilters)
\r
33 if (filter && filter->winEventFilter(msg, result))
\r
37 if (msg->message == WM_HOTKEY)
\r
39 uint modifiers = LOWORD(msg->lParam);
\r
40 uint keycode = HIWORD(msg->lParam);
\r
41 qxt_d().activateHotKey(modifiers, keycode);
\r
43 return QApplication::winEventFilter(msg, result);
\r
46 uint QxtApplicationPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) const
\r
48 // MOD_ALT, MOD_CONTROL, (MOD_KEYUP), MOD_SHIFT, MOD_WIN
\r
50 if (modifiers & Qt::ShiftModifier)
\r
51 native |= MOD_SHIFT;
\r
52 if (modifiers & Qt::ControlModifier)
\r
53 native |= MOD_CONTROL;
\r
54 if (modifiers & Qt::AltModifier)
\r
56 if (modifiers & Qt::MetaModifier)
\r
58 // TODO: resolve these?
\r
59 //if (modifiers & Qt::KeypadModifier)
\r
60 //if (modifiers & Qt::GroupSwitchModifier)
\r
64 uint QxtApplicationPrivate::nativeKeycode(Qt::Key key) const
\r
68 case Qt::Key_Escape:
\r
71 case Qt::Key_Backtab:
\r
73 case Qt::Key_Backspace:
\r
75 case Qt::Key_Return:
\r
78 case Qt::Key_Insert:
\r
80 case Qt::Key_Delete:
\r
100 case Qt::Key_PageUp:
\r
102 case Qt::Key_PageDown:
\r
152 case Qt::Key_Space:
\r
154 case Qt::Key_Asterisk:
\r
155 return VK_MULTIPLY;
\r
158 case Qt::Key_Comma:
\r
159 return VK_SEPARATOR;
\r
160 case Qt::Key_Minus:
\r
161 return VK_SUBTRACT;
\r
162 case Qt::Key_Slash:
\r
212 bool QxtApplicationPrivate::registerHotKey(uint modifiers, uint keycode, QWidget* receiver)
\r
214 Q_ASSERT(receiver);
\r
215 return RegisterHotKey(receiver->winId(), modifiers ^ keycode, modifiers, keycode);
\r
218 bool QxtApplicationPrivate::unregisterHotKey(uint modifiers, uint keycode, QWidget* receiver)
\r
220 Q_ASSERT(receiver);
\r
221 return UnregisterHotKey(receiver->winId(), modifiers ^ keycode);
\r