Skip to content

Commit b28fd1a

Browse files
committed
fix: use initialClass and initialTitle when storing sizes on close
1 parent 614f2ad commit b28fd1a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/config/ConfigManager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,13 +3051,18 @@ void CConfigManager::ensurePersistentWorkspacesPresent() {
30513051
}
30523052

30533053
void CConfigManager::storeFloatingSize(PHLWINDOW window, const Vector2D& size) {
3054-
Debug::log(LOG, "storing floating size {}x{} for window {}::{}", size.x, size.y, window->m_class, window->m_title);
3055-
SFloatCache id{window};
3054+
Debug::log(LOG, "storing floating size {}x{} for window {}::{}", size.x, size.y, window->m_initialClass, window->m_initialTitle);
3055+
// true -> use m_initialClass and m_initialTitle
3056+
SFloatCache id{window, true};
30563057
m_mStoredFloatingSizes[id] = size;
30573058
}
30583059

30593060
std::optional<Vector2D> CConfigManager::getStoredFloatingSize(PHLWINDOW window) {
3060-
SFloatCache id{window};
3061+
// At startup, m_initialClass and m_initialTitle are undefined
3062+
// and m_class and m_title are just "initial" ones.
3063+
// false -> use m_class and m_title
3064+
SFloatCache id{window, false};
3065+
Debug::log(LOG, "Hash for window {}::{} = {}", window->m_class, window->m_title, id.hash);
30613066
if (m_mStoredFloatingSizes.contains(id)) {
30623067
Debug::log(LOG, "got stored size {}x{} for window {}::{}", m_mStoredFloatingSizes[id].x, m_mStoredFloatingSizes[id].y, window->m_class, window->m_title);
30633068
return m_mStoredFloatingSizes[id];

src/config/ConfigManager.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ struct SFirstExecRequest {
141141
struct SFloatCache {
142142
size_t hash;
143143

144-
SFloatCache(PHLWINDOW window) {
145-
hash = std::hash<std::string>{}(window->m_class) ^ (std::hash<std::string>{}(window->m_title) << 1);
144+
SFloatCache(PHLWINDOW window, bool initial) {
145+
if (initial)
146+
hash = std::hash<std::string>{}(window->m_initialClass) ^ (std::hash<std::string>{}(window->m_initialTitle) << 1);
147+
else
148+
hash = std::hash<std::string>{}(window->m_class) ^ (std::hash<std::string>{}(window->m_title) << 1);
146149
}
147150

148151
bool operator==(const SFloatCache& other) const {

0 commit comments

Comments
 (0)