From 88d2b360eb102d2675bec5be096d5557c4e49e48 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Sep 2024 13:25:27 +0200 Subject: [PATCH] screen: remove GetMainPosition() Apply Y offsets manually in OnMouse(). This fixes a problem when hiding the title bar. --- src/screen.cxx | 11 ++++++++++- src/screen.hxx | 4 ---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/screen.cxx b/src/screen.cxx index 209d6932..039a6932 100644 --- a/src/screen.cxx +++ b/src/screen.cxx @@ -309,7 +309,16 @@ void ScreenManager::OnMouse(struct mpdclient &c, DelayedSeek &seek, Point p, mmask_t bstate) { - if (GetCurrentPage().OnMouse(c, p - GetMainPosition(), bstate)) + if (options.show_title_bar) { + const int title_height = title_bar.GetHeight(); + if (p.y < title_height) { + return; + } + + p.y -= title_height; + } + + if (GetCurrentPage().OnMouse(c, p, bstate)) return; /* if button 2 was pressed switch screen */ diff --git a/src/screen.hxx b/src/screen.hxx index e2be8b1a..d654552f 100644 --- a/src/screen.hxx +++ b/src/screen.hxx @@ -92,10 +92,6 @@ public: void Init(struct mpdclient *c) noexcept; void Exit() noexcept; - Point GetMainPosition() const noexcept { - return {0, (int)title_bar.GetHeight()}; - } - const PageMeta &GetCurrentPageMeta() const noexcept { return *current_page->first; }