1 /*
2  *  Copyright (C) 2013 Felix Geyer <debfx@fobos.de>
3  *  Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "OSEventFilter.h"
20 
21 #include <QByteArray>
22 
23 #include "autotype/AutoType.h"
24 #include "gui/MainWindow.h"
25 #ifdef Q_OS_WIN
26 #include <windows.h>
27 #endif
28 
OSEventFilter()29 OSEventFilter::OSEventFilter()
30 {
31 }
32 
nativeEventFilter(const QByteArray & eventType,void * message,long * result)33 bool OSEventFilter::nativeEventFilter(const QByteArray& eventType, void* message, long* result)
34 {
35     Q_UNUSED(result)
36 
37 #if defined(Q_OS_UNIX)
38     if (eventType == QByteArrayLiteral("xcb_generic_event_t")) {
39 #elif defined(Q_OS_WIN)
40     if (eventType == QByteArrayLiteral("windows_generic_MSG")
41         || eventType == QByteArrayLiteral("windows_dispatcher_MSG")) {
42 #endif
43         return autoType()->callEventFilter(message) == 1;
44     }
45 
46     return false;
47 }
48