diff --git a/DockLayout.vcxproj b/DockLayout.vcxproj
index 061c5d2..360c9fa 100644
--- a/DockLayout.vcxproj
+++ b/DockLayout.vcxproj
@@ -95,6 +95,7 @@
+
@@ -110,6 +111,7 @@
+
diff --git a/DockLayout.vcxproj.filters b/DockLayout.vcxproj.filters
index f1e3a09..29fa386 100644
--- a/DockLayout.vcxproj.filters
+++ b/DockLayout.vcxproj.filters
@@ -28,6 +28,9 @@
ソース ファイル
+
+ ソース ファイル
+
ソース ファイル
@@ -66,6 +69,9 @@
ヘッダー ファイル
+
+ ヘッダー ファイル
+
ヘッダー ファイル
diff --git a/src/FloatWindowHook.cpp b/src/FloatWindowHook.cpp
new file mode 100644
index 0000000..dfe6347
--- /dev/null
+++ b/src/FloatWindowHook.cpp
@@ -0,0 +1,116 @@
+#include "FloatWindowHook.h"
+
+#include
+#include
+
+#include "DragSession.h"
+#include "HostContext.h"
+
+namespace dl {
+
+static const wchar_t* const kHostClassName = L"aviutl2Manager";
+static const wchar_t* const kWatchClassName = L"DockLayoutFloatWatch";
+static const UINT_PTR kWatchTimerId = 1;
+static const UINT kWatchIntervalMs = 500;
+
+static HWND g_watch = nullptr;
+static std::vector g_hooked;
+
+static void Unhook(HWND window) {
+ WNDPROC original = OriginalProc(window);
+ if (original) SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)original);
+ ClearWindowProc(window);
+ for (size_t i = 0; i < g_hooked.size(); i++) {
+ if (g_hooked[i] != window) continue;
+ g_hooked.erase(g_hooked.begin() + i);
+ return;
+ }
+}
+
+static LRESULT CALLBACK FloatProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
+ switch (msg) {
+ case WM_MOVING: {
+ if (!Drag().Dragging()) Drag().BeginFloat(hwnd);
+ if (Drag().Window() == hwnd) {
+ POINT cursor = {};
+ GetCursorPos(&cursor);
+ Drag().Track(cursor);
+ }
+ break;
+ }
+
+ case WM_EXITSIZEMOVE: {
+ const LRESULT result = CallOriginalProc(hwnd, msg, wp, lp);
+ if (Drag().Dragging() && Drag().Window() == hwnd) {
+ POINT cursor = {};
+ GetCursorPos(&cursor);
+ Drag().Commit(cursor);
+ }
+ return result;
+ }
+
+ case WM_NCDESTROY: {
+ if (Drag().Window() == hwnd) Drag().Cancel();
+ const LRESULT result = CallOriginalProc(hwnd, msg, wp, lp);
+ Unhook(hwnd);
+ return result;
+ }
+ }
+ return CallOriginalProc(hwnd, msg, wp, lp);
+}
+
+static bool Hooked(HWND window) {
+ for (HWND hooked : g_hooked)
+ if (hooked == window) return true;
+ return false;
+}
+
+static BOOL CALLBACK Collect(HWND window, LPARAM) {
+ if (window == HostWindow() || Hooked(window)) return TRUE;
+
+ DWORD process = 0;
+ GetWindowThreadProcessId(window, &process);
+ if (process != GetCurrentProcessId()) return TRUE;
+
+ wchar_t name[64] = {};
+ GetClassNameW(window, name, 63);
+ if (wcscmp(name, kHostClassName) != 0) return TRUE;
+
+ SetWindowProc(window, (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)FloatProc));
+ g_hooked.push_back(window);
+ return TRUE;
+}
+
+static LRESULT CALLBACK WatchProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
+ if (msg == WM_TIMER && wp == kWatchTimerId) {
+ EnumWindows(Collect, 0);
+ return 0;
+ }
+ return DefWindowProcW(hwnd, msg, wp, lp);
+}
+
+void InstallFloatWindowHook() {
+ if (g_watch) return;
+
+ WNDCLASSEXW wc = { sizeof(wc) };
+ wc.lpfnWndProc = WatchProc;
+ wc.hInstance = GetModuleHandleW(nullptr);
+ wc.lpszClassName = kWatchClassName;
+ RegisterClassExW(&wc);
+
+ g_watch = CreateWindowExW(0, kWatchClassName, L"", 0, 0, 0, 0, 0,
+ HWND_MESSAGE, nullptr, wc.hInstance, nullptr);
+ if (g_watch) SetTimer(g_watch, kWatchTimerId, kWatchIntervalMs, nullptr);
+ EnumWindows(Collect, 0);
+}
+
+void UninstallFloatWindowHook() {
+ if (g_watch) {
+ KillTimer(g_watch, kWatchTimerId);
+ DestroyWindow(g_watch);
+ g_watch = nullptr;
+ }
+ while (!g_hooked.empty()) Unhook(g_hooked.back());
+}
+
+}
diff --git a/src/FloatWindowHook.h b/src/FloatWindowHook.h
new file mode 100644
index 0000000..2d134bd
--- /dev/null
+++ b/src/FloatWindowHook.h
@@ -0,0 +1,8 @@
+#pragma once
+
+namespace dl {
+
+void InstallFloatWindowHook();
+void UninstallFloatWindowHook();
+
+}
diff --git a/src/Plugin.cpp b/src/Plugin.cpp
index fa5b290..dd7e35f 100644
--- a/src/Plugin.cpp
+++ b/src/Plugin.cpp
@@ -1,7 +1,12 @@
#include
+#include "DragSession.h"
+#include "FloatWindowHook.h"
+#include "GuideWindow.h"
#include "HostContext.h"
+#include "HostWindowHook.h"
#include "Log.h"
+#include "WindowMenu.h"
#include "plugin2.h"
@@ -23,10 +28,19 @@ EXTERN_C __declspec(dllexport) bool InitializePlugin(DWORD) { return true; }
EXTERN_C __declspec(dllexport) void RegisterPlugin(HOST_APP_TABLE* host) {
SetHostWindow(host->create_edit_handle()->get_host_app_window());
- LogF(L"DockLayout registered (host=%p)", (void*)HostWindow());
+ InstallWindowMenuHook();
+ InstallHostWindowHook();
+ InstallFloatWindowHook();
+
+ LogF(L"ドッキング配置: 有効になりました");
}
EXTERN_C __declspec(dllexport) void UninitializePlugin() {
+ Drag().Cancel();
+ Overlay().Destroy();
+ UninstallFloatWindowHook();
+ UninstallHostWindowHook();
+ UninstallWindowMenuHook();
}
BOOL APIENTRY DllMain(HMODULE, DWORD, LPVOID) { return TRUE; }