Merge pull request #18077 from hrydgard/fix-input-events

Avoid double-processing of input events caused by the overlay screen.
This commit is contained in:
Henrik Rydgård 2023-09-05 17:43:09 +02:00 committed by GitHub
commit 828328b50d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View File

@ -49,15 +49,13 @@ void ScreenManager::update() {
}
if (overlayScreen_) {
// NOTE: This is not a full UIScreen update, to avoid double global event processing.
overlayScreen_->update();
}
if (stack_.size()) {
stack_.back().screen->update();
}
// NOTE: We should not update the OverlayScreen. In fact, we must never update more than one
// UIScreen in here, because we might end up double-processing the stuff in Root.cpp.
g_iconCache.FrameUpdate();
}

View File

@ -73,12 +73,13 @@ protected:
bool ignoreInsets_ = false;
bool ignoreInput_ = false;
private:
protected:
void DoRecreateViews();
bool recreateViews_ = true;
bool lastVertical_;
private:
std::mutex eventQueueLock_;
std::deque<QueuedEvent> eventQueue_;
};

View File

@ -11,6 +11,7 @@
#include "Common/UI/IconCache.h"
#include "UI/RetroAchievementScreens.h"
#include "UI/DebugOverlay.h"
#include "UI/Root.h"
#include "Common/UI/Context.h"
#include "Common/System/OSD.h"
@ -526,6 +527,17 @@ void OSDOverlayScreen::render() {
}
}
void OSDOverlayScreen::update() {
// Partial version of UIScreen::update() but doesn't do event processing to avoid duplicate event processing.
bool vertical = UseVerticalLayout();
if (vertical != lastVertical_) {
RecreateViews();
lastVertical_ = vertical;
}
DoRecreateViews();
}
void NoticeView::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const {
Bounds bounds(0, 0, layoutParams_->width, layoutParams_->height);
if (bounds.w < 0) {

View File

@ -42,6 +42,7 @@ public:
void CreateViews() override;
void render() override;
void update() override;
private:
OnScreenMessagesView *osmView_ = nullptr;