From 64d809ab736ca44aef2168f3f830717f34a36dbc Mon Sep 17 00:00:00 2001 From: routersys Date: Tue, 25 Aug 2026 00:05:31 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=9B=A2=E3=81=97=E3=81=9F=E7=AA=93?= =?UTF-8?q?=E3=81=AE=E9=85=8D=E7=BD=AE=E3=82=92=E8=A6=9A=E3=81=88=E3=82=8B?= =?UTF-8?q?=E4=BB=95=E7=B5=84=E3=81=BF=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DockLayout.vcxproj | 2 ++ DockLayout.vcxproj.filters | 6 ++++ src/FloatOrigin.cpp | 61 ++++++++++++++++++++++++++++++++++++++ src/FloatOrigin.h | 23 ++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 src/FloatOrigin.cpp create mode 100644 src/FloatOrigin.h diff --git a/DockLayout.vcxproj b/DockLayout.vcxproj index 90b6755..24bc243 100644 --- a/DockLayout.vcxproj +++ b/DockLayout.vcxproj @@ -96,6 +96,7 @@ + @@ -113,6 +114,7 @@ + diff --git a/DockLayout.vcxproj.filters b/DockLayout.vcxproj.filters index 2f130e5..90b1b1c 100644 --- a/DockLayout.vcxproj.filters +++ b/DockLayout.vcxproj.filters @@ -31,6 +31,9 @@ ソース ファイル + + ソース ファイル + ソース ファイル @@ -75,6 +78,9 @@ ヘッダー ファイル + + ヘッダー ファイル + ヘッダー ファイル diff --git a/src/FloatOrigin.cpp b/src/FloatOrigin.cpp new file mode 100644 index 0000000..6e701de --- /dev/null +++ b/src/FloatOrigin.cpp @@ -0,0 +1,61 @@ +#include "FloatOrigin.h" + +#include + +namespace dl { + +struct Entry { + HWND window; + FloatOrigin origin; +}; + +static std::vector g_entries; + +static bool g_pending = false; +static FloatOrigin g_pendingOrigin; + +void SetPendingFloat(const FloatOrigin& origin) { + g_pending = true; + g_pendingOrigin = origin; +} + +bool TakePendingFloat(FloatOrigin* out) { + if (!g_pending) return false; + g_pending = false; + if (out) *out = g_pendingOrigin; + return true; +} + +void RememberFloat(HWND window, const FloatOrigin& origin) { + if (!window) return; + for (Entry& entry : g_entries) { + if (entry.window != window) continue; + entry.origin = origin; + return; + } + g_entries.push_back(Entry{ window, origin }); +} + +void ForgetFloat(HWND window) { + for (size_t i = 0; i < g_entries.size(); i++) { + if (g_entries[i].window != window) continue; + g_entries.erase(g_entries.begin() + i); + return; + } +} + +bool FloatOriginOf(HWND window, FloatOrigin* out) { + for (const Entry& entry : g_entries) { + if (entry.window != window) continue; + if (out) *out = entry.origin; + return true; + } + return false; +} + +void ClearFloatOrigins() { + g_entries.clear(); + g_pending = false; +} + +} diff --git a/src/FloatOrigin.h b/src/FloatOrigin.h new file mode 100644 index 0000000..5813f95 --- /dev/null +++ b/src/FloatOrigin.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace dl { + +struct FloatOrigin { + double left = 0; + double top = 0; + double right = 0; + double bottom = 0; + int area = -1; +}; + +void SetPendingFloat(const FloatOrigin& origin); +bool TakePendingFloat(FloatOrigin* out); + +void RememberFloat(HWND window, const FloatOrigin& origin); +void ForgetFloat(HWND window); +bool FloatOriginOf(HWND window, FloatOrigin* out); +void ClearFloatOrigins(); + +}