From 2d3f5855c62588c6bd5145aa3b53c3902dbe499f Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 10 May 2022 11:12:04 +0300 Subject: [PATCH] [Windows] Save and re-apply window icon when changing window style. (cherry picked from commit b268c4b4bc8a1c246984249b2ce88277df47fe78) --- platform/windows/os_windows.cpp | 13 ++++++++++--- platform/windows/os_windows.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 64cc9cc4848..e6ab0fb07f5 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2312,6 +2312,10 @@ void OS_Windows::_update_window_style(bool p_repaint, bool p_maximized) { } } + if (icon.is_valid()) { + set_icon(icon); + } + SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); if (p_repaint) { @@ -3040,9 +3044,12 @@ void OS_Windows::set_native_icon(const String &p_filename) { void OS_Windows::set_icon(const Ref &p_icon) { ERR_FAIL_COND(!p_icon.is_valid()); - Ref icon = p_icon->duplicate(); - if (icon->get_format() != Image::FORMAT_RGBA8) - icon->convert(Image::FORMAT_RGBA8); + if (icon != p_icon) { + icon = p_icon->duplicate(); + if (icon->get_format() != Image::FORMAT_RGBA8) { + icon->convert(Image::FORMAT_RGBA8); + } + } int w = icon->get_width(); int h = icon->get_height(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 7472e47b52c..549b9f0e1f9 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -318,6 +318,8 @@ class OS_Windows : public OS { uint32_t move_timer_id; + Ref icon; + HCURSOR hCursor; Size2 min_size;