Skip to content

Commit 2f061df

Browse files
committed
Fix embedding not working intermittently
1 parent bdf625b commit 2f061df

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

platform/linuxbsd/x11/display_server_x11.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5718,7 +5718,7 @@ Error DisplayServerX11::embed_process(WindowID p_window, OS::ProcessID p_pid, co
57185718
}
57195719
}
57205720

5721-
if (desired_rect.size.x < 100 || desired_rect.size.y < 100) {
5721+
if (desired_rect.size.x <= 100 || desired_rect.size.y <= 100) {
57225722
p_visible = false;
57235723
}
57245724

platform/windows/display_server_windows.cpp

+3-21
Original file line numberDiff line numberDiff line change
@@ -2876,10 +2876,7 @@ static BOOL CALLBACK _enum_proc_find_window_from_process_id_callback(HWND hWnd,
28762876
GetWindowThreadProcessId(hWnd, &process_id);
28772877
if (ed.process_id == process_id) {
28782878
if (GetParent(hWnd) != ed.parent_hWnd) {
2879-
const DWORD style = GetWindowLongPtr(hWnd, GWL_STYLE);
2880-
if ((style & WS_VISIBLE) != WS_VISIBLE) {
2881-
return TRUE;
2882-
}
2879+
return TRUE;
28832880
}
28842881

28852882
// Found it.
@@ -2935,24 +2932,9 @@ Error DisplayServerWindows::embed_process(WindowID p_window, OS::ProcessID p_pid
29352932
ep->is_visible = (style & WS_VISIBLE) == WS_VISIBLE;
29362933

29372934
embedded_processes.insert(p_pid, ep);
2938-
2939-
HWND old_parent = GetParent(ep->window_handle);
2940-
if (old_parent != wd.hWnd) {
2941-
// It's important that the window does not have the WS_CHILD flag
2942-
// to prevent the current process from interfering with the embedded process.
2943-
// I observed lags and issues with mouse capture when WS_CHILD is set.
2944-
// Additionally, WS_POPUP must be set to ensure that the coordinates of the embedded
2945-
// window remain screen coordinates and not local coordinates of the parent window.
2946-
if ((style & WS_CHILD) == WS_CHILD || (style & WS_POPUP) != WS_POPUP) {
2947-
const DWORD new_style = (style & ~WS_CHILD) | WS_POPUP;
2948-
SetWindowLong(ep->window_handle, GWL_STYLE, new_style);
2949-
}
2950-
// Set the parent to current window.
2951-
SetParent(ep->window_handle, wd.hWnd);
2952-
}
29532935
}
29542936

2955-
if (p_rect.size.x < 100 || p_rect.size.y < 100) {
2937+
if (p_rect.size.x <= 100 || p_rect.size.y <= 100) {
29562938
p_visible = false;
29572939
}
29582940

@@ -2961,7 +2943,7 @@ Error DisplayServerWindows::embed_process(WindowID p_window, OS::ProcessID p_pid
29612943
// (e.g., a screen to the left of the main screen).
29622944
const Rect2i adjusted_rect = Rect2i(p_rect.position + _get_screens_origin(), p_rect.size);
29632945

2964-
SetWindowPos(ep->window_handle, HWND_BOTTOM, adjusted_rect.position.x, adjusted_rect.position.y, adjusted_rect.size.x, adjusted_rect.size.y, SWP_NOZORDER | SWP_NOACTIVATE);
2946+
SetWindowPos(ep->window_handle, nullptr, adjusted_rect.position.x, adjusted_rect.position.y, adjusted_rect.size.x, adjusted_rect.size.y, SWP_NOZORDER | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS);
29652947

29662948
if (ep->is_visible != p_visible) {
29672949
if (p_visible) {

0 commit comments

Comments
 (0)