Merge pull request #2630 from wwylele/qt-focus-loss-2
Qt: Release all pressed buttons when window focus is lost [rebased]
This commit is contained in:
commit
a48e5c64b6
@ -235,7 +235,10 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
|
|||||||
motion_emu->EndTilt();
|
motion_emu->EndTilt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::ReloadSetKeymaps() {}
|
void GRenderWindow::focusOutEvent(QFocusEvent* event) {
|
||||||
|
QWidget::focusOutEvent(event);
|
||||||
|
InputCommon::GetKeyboard()->ReleaseAllKeys();
|
||||||
|
}
|
||||||
|
|
||||||
void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) {
|
void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) {
|
||||||
NotifyClientAreaSizeChanged(std::make_pair(width, height));
|
NotifyClientAreaSizeChanged(std::make_pair(width, height));
|
||||||
|
@ -128,7 +128,7 @@ public:
|
|||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
void ReloadSetKeymaps();
|
void focusOutEvent(QFocusEvent* event) override;
|
||||||
|
|
||||||
void OnClientAreaResized(unsigned width, unsigned height);
|
void OnClientAreaResized(unsigned width, unsigned height);
|
||||||
|
|
||||||
|
@ -612,7 +612,6 @@ void GMainWindow::OnConfigure() {
|
|||||||
auto result = configureDialog.exec();
|
auto result = configureDialog.exec();
|
||||||
if (result == QDialog::Accepted) {
|
if (result == QDialog::Accepted) {
|
||||||
configureDialog.applyConfiguration();
|
configureDialog.applyConfiguration();
|
||||||
render_window->ReloadSetKeymaps();
|
|
||||||
config->Save();
|
config->Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChangeAllKeyStatus(bool pressed) {
|
||||||
|
std::lock_guard<std::mutex> guard(mutex);
|
||||||
|
for (const KeyButtonPair& pair : list) {
|
||||||
|
pair.key_button->status.store(pressed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
std::list<KeyButtonPair> list;
|
std::list<KeyButtonPair> list;
|
||||||
@ -79,4 +86,8 @@ void Keyboard::ReleaseKey(int key_code) {
|
|||||||
key_button_list->ChangeKeyStatus(key_code, false);
|
key_button_list->ChangeKeyStatus(key_code, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Keyboard::ReleaseAllKeys() {
|
||||||
|
key_button_list->ChangeAllKeyStatus(false);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace InputCommon
|
} // namespace InputCommon
|
||||||
|
@ -38,6 +38,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void ReleaseKey(int key_code);
|
void ReleaseKey(int key_code);
|
||||||
|
|
||||||
|
void ReleaseAllKeys();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<KeyButtonList> key_button_list;
|
std::shared_ptr<KeyButtonList> key_button_list;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user