diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt index 58cca8e821..ac9897c251 100644 --- a/Source/Core/DolphinQt2/CMakeLists.txt +++ b/Source/Core/DolphinQt2/CMakeLists.txt @@ -50,7 +50,7 @@ set(SRCS GameList/ListProxyModel.cpp QtUtils/DoubleClickEventFilter.cpp QtUtils/ElidedButton.cpp - QtUtils/FocusEventFilter.cpp + QtUtils/WindowActivationEventFilter.cpp Settings/GeneralPane.cpp Settings/InterfacePane.cpp Settings/PathPane.cpp diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj b/Source/Core/DolphinQt2/DolphinQt2.vcxproj index c89ea4a076..96a1310352 100644 --- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj +++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj @@ -78,7 +78,7 @@ - + @@ -89,7 +89,7 @@ - + @@ -151,7 +151,7 @@ - + diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 71e72f6fea..5c95c28daf 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -31,7 +31,7 @@ #include "DolphinQt2/Host.h" #include "DolphinQt2/HotkeyScheduler.h" #include "DolphinQt2/MainWindow.h" -#include "DolphinQt2/QtUtils/FocusEventFilter.h" +#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h" #include "DolphinQt2/Resources.h" #include "DolphinQt2/Settings.h" @@ -88,13 +88,15 @@ void MainWindow::ShutdownControllers() m_hotkey_scheduler->deleteLater(); } -static void InstallHotkeyFilter(QDialog* dialog) +static void InstallHotkeyFilter(QWidget* dialog) { - auto* filter = new FocusEventFilter(); + auto* filter = new WindowActivationEventFilter(); dialog->installEventFilter(filter); - filter->connect(filter, &FocusEventFilter::focusOutEvent, [] { HotkeyManagerEmu::Enable(true); }); - filter->connect(filter, &FocusEventFilter::focusInEvent, [] { HotkeyManagerEmu::Enable(false); }); + filter->connect(filter, &WindowActivationEventFilter::windowDeactivated, + [] { HotkeyManagerEmu::Enable(true); }); + filter->connect(filter, &WindowActivationEventFilter::windowActivated, + [] { HotkeyManagerEmu::Enable(false); }); } void MainWindow::CreateComponents() diff --git a/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.cpp b/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.cpp deleted file mode 100644 index c6023f4ff7..0000000000 --- a/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include -#include - -#include "DolphinQt2/QtUtils/FocusEventFilter.h" - -bool FocusEventFilter::eventFilter(QObject* object, QEvent* event) -{ - if (event->type() == QEvent::FocusOut) - emit focusOutEvent(); - - if (event->type() == QEvent::FocusIn) - emit focusInEvent(); - - return false; -} diff --git a/Source/Core/DolphinQt2/QtUtils/WindowActivationEventFilter.cpp b/Source/Core/DolphinQt2/QtUtils/WindowActivationEventFilter.cpp new file mode 100644 index 0000000000..97263c3747 --- /dev/null +++ b/Source/Core/DolphinQt2/QtUtils/WindowActivationEventFilter.cpp @@ -0,0 +1,19 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include +#include + +#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h" + +bool WindowActivationEventFilter::eventFilter(QObject* object, QEvent* event) +{ + if (event->type() == QEvent::WindowDeactivate) + emit windowDeactivated(); + + if (event->type() == QEvent::WindowActivate) + emit windowActivated(); + + return false; +} diff --git a/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.h b/Source/Core/DolphinQt2/QtUtils/WindowActivationEventFilter.h similarity index 69% rename from Source/Core/DolphinQt2/QtUtils/FocusEventFilter.h rename to Source/Core/DolphinQt2/QtUtils/WindowActivationEventFilter.h index 0783622b0f..c48e239540 100644 --- a/Source/Core/DolphinQt2/QtUtils/FocusEventFilter.h +++ b/Source/Core/DolphinQt2/QtUtils/WindowActivationEventFilter.h @@ -6,12 +6,12 @@ #include -class FocusEventFilter : public QObject +class WindowActivationEventFilter : public QObject { Q_OBJECT signals: - void focusInEvent(); - void focusOutEvent(); + void windowActivated(); + void windowDeactivated(); private: bool eventFilter(QObject* object, QEvent* event) override;