分離ウィンドウのサブクラス化を追加
このコミットが含まれているのは:
5ファイル変更
+147
-1
検索条件に一致するファイルはありません
@@ -95,6 +95,7 @@
|
||||
<ClCompile Include="src\DockGuides.cpp" />
|
||||
<ClCompile Include="src\DockModel.cpp" />
|
||||
<ClCompile Include="src\DragSession.cpp" />
|
||||
<ClCompile Include="src\FloatWindowHook.cpp" />
|
||||
<ClCompile Include="src\GuideWindow.cpp" />
|
||||
<ClCompile Include="src\HostContext.cpp" />
|
||||
<ClCompile Include="src\HostSurface.cpp" />
|
||||
@@ -110,6 +111,7 @@
|
||||
<ClInclude Include="src\DockGuides.h" />
|
||||
<ClInclude Include="src\DockModel.h" />
|
||||
<ClInclude Include="src\DragSession.h" />
|
||||
<ClInclude Include="src\FloatWindowHook.h" />
|
||||
<ClInclude Include="src\GuideWindow.h" />
|
||||
<ClInclude Include="src\HostContext.h" />
|
||||
<ClInclude Include="src\HostSurface.h" />
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
<ClCompile Include="src\DragSession.cpp">
|
||||
<Filter>ソース ファイル</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FloatWindowHook.cpp">
|
||||
<Filter>ソース ファイル</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GuideWindow.cpp">
|
||||
<Filter>ソース ファイル</Filter>
|
||||
</ClCompile>
|
||||
@@ -66,6 +69,9 @@
|
||||
<ClInclude Include="src\DragSession.h">
|
||||
<Filter>ヘッダー ファイル</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FloatWindowHook.h">
|
||||
<Filter>ヘッダー ファイル</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\GuideWindow.h">
|
||||
<Filter>ヘッダー ファイル</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "FloatWindowHook.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
|
||||
#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<HWND> 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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace dl {
|
||||
|
||||
void InstallFloatWindowHook();
|
||||
void UninstallFloatWindowHook();
|
||||
|
||||
}
|
||||
+15
-1
@@ -1,7 +1,12 @@
|
||||
#include <windows.h>
|
||||
|
||||
#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; }
|
||||
新しいイシューから参照
ユーザーをブロックする