fix(bridge): real-input dance dat window tai cursor thay vi goc work-area - het GUI floating ngoai cua so DAW khi click vao embed (iZotope/JUCE reject PostMessage)

This commit is contained in:
2026-08-19 08:25:12 +07:00
parent 0334c2a5a3
commit 346ada6e47
+15 -7
View File
@@ -254,14 +254,22 @@ uint64_t frameHash(HWND hwnd) {
return h;
}
void danceStart(HWND hwnd) {
void danceStart(HWND hwnd, HWND target, int x, int y) {
if (g_dance) return;
RECT wa = {0}, wr = {0};
SystemParametersInfoA(SPI_GETWORKAREA, 0, &wa, 0);
// Dat window ngay tai vi tri cursor (dang nam tren panel embed trong DAW)
// chu khong nhay ra goc man hinh: shift window sao cho client point (x,y)
// cua editor trung voi screen point dang click -> GUI xuat hien dung cho
// panel, khong con floating ngoai cua so DAW.
POINT pt = { x, y };
ClientToScreen(target, &pt); // screen cua diem click (window con offscreen)
POINT cur;
GetCursorPos(&cur);
RECT wr = {0};
GetWindowRect(hwnd, &wr);
const int w = wr.right - wr.left, h = wr.bottom - wr.top;
const int nx = wr.left + (cur.x - pt.x);
const int ny = wr.top + (cur.y - pt.y);
GetCursorPos(&g_savedCursor);
SetWindowPos(hwnd, HWND_TOPMOST, wa.right - w, wa.bottom - h, 0, 0,
SetWindowPos(hwnd, HWND_TOPMOST, nx, ny, 0, 0,
SWP_NOSIZE | SWP_SHOWWINDOW);
Sleep(60); // let the compositor repaint so the editor sees itself active
g_dance = true;
@@ -334,7 +342,7 @@ void relayInput(HWND hwnd, const json_object_s* o) {
if (g_realInput && (isDown || isUp || type == "mousemove" || type == "wheel")) {
if (isDown) {
danceStart(hwnd);
danceStart(hwnd, target, x, y);
POINT pt = { x, y };
if (!outside) ClientToScreen(target, &pt);
realClick(pt.x, pt.y, true, button);
@@ -355,7 +363,7 @@ void relayInput(HWND hwnd, const json_object_s* o) {
danceEnd(hwnd);
}
} else if (type == "wheel") {
danceStart(hwnd);
danceStart(hwnd, target, x, y);
POINT pt = { x, y };
if (!outside) ClientToScreen(target, &pt);
SetCursorPos(pt.x, pt.y);