|
| 1 | +/****************************************************************************** |
| 2 | + Copyright (C) 2025 by Taylor Giampaolo <[email protected]> |
1 | 3 |
|
| 4 | + This program is free software: you can redistribute it and/or modify |
| 5 | + it under the terms of the GNU General Public License as published by |
| 6 | + the Free Software Foundation, either version 2 of the License, or |
| 7 | + (at your option) any later version. |
2 | 8 |
|
3 | | -#include <utility/NativeEventFilter.hpp> |
| 9 | + This program 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 |
| 12 | + GNU General Public License for more details. |
4 | 13 |
|
5 | | -#include <widgets/OBSBasic.hpp> |
| 14 | + You should have received a copy of the GNU General Public License |
| 15 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +******************************************************************************/ |
6 | 17 |
|
7 | | -#ifdef _WIN32 |
8 | | -#include <sstream> |
9 | | -#define WIN32_LEAN_AND_MEAN |
10 | | -#include <windows.h> |
11 | | -#else |
12 | | -#include <unistd.h> |
13 | | -#include <sys/socket.h> |
14 | | -#endif |
| 18 | +#include "NativeEventFilter.hpp" |
15 | 19 |
|
16 | 20 | namespace OBS { |
17 | 21 |
|
18 | 22 | bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) |
19 | 23 | { |
20 | | - if (eventType == "windows_generic_MSG") { |
21 | | -#ifdef _WIN32 |
22 | | - MSG *msg = static_cast<MSG *>(message); |
23 | | - |
24 | | - OBSBasic *main = OBSBasic::Get(); |
25 | | - if (!main) { |
26 | | - return false; |
27 | | - } |
28 | | - |
29 | | - switch (msg->message) { |
30 | | - case WM_QUERYENDSESSION: |
31 | | - main->saveAll(); |
32 | | - if (msg->lParam == ENDSESSION_CRITICAL) { |
33 | | - break; |
34 | | - } |
35 | | - |
36 | | - if (main->shouldPromptForClose()) { |
37 | | - *result = FALSE; |
38 | | - return true; |
39 | | - } |
40 | | - |
41 | | - return false; |
42 | | - case WM_ENDSESSION: |
43 | | - if (msg->wParam == TRUE) { |
44 | | - // Session is ending, start closing the main window now with no checks or prompts. |
45 | | - main->closeWindow(); |
46 | | - } else { |
47 | | - /* Session is no longer ending. If OBS is still open, odds are it is what held |
48 | | - * up the session end due to it's higher than default priority. We call the |
49 | | - * close method to trigger the confirmation window flow. We do this after the fact |
50 | | - * to avoid blocking the main window event loop prior to this message. |
51 | | - * Otherwise OBS is already gone and invoking this does nothing */ |
52 | | - main->close(); |
53 | | - } |
54 | | - |
55 | | - return true; |
56 | | - } |
57 | | -#else |
58 | | - UNUSED_PARAMETER(message); |
59 | | - UNUSED_PARAMETER(result); |
60 | | -#endif |
61 | | - } |
62 | | - |
| 24 | + // Stub file for operating systems that do not need nativeEventFilter |
63 | 25 | return false; |
64 | 26 | } |
65 | 27 | } // namespace OBS |
0 commit comments