From 487c5fc1aedc68929823b10d2cf32c7be6e51f11 Mon Sep 17 00:00:00 2001 From: Andrew Zambazos <62979495+Bobbybear007@users.noreply.github.com> Date: Sun, 12 Jul 2026 19:42:06 +1200 Subject: [PATCH] Add Windows app icon resource & load it Add Windows resource files and load the app icon in the window class. Introduce resources/nebula.rc and resources/resource.h (defines IDI_APPICON referencing assets/images/branding/Nebula-Favicon.ico). Include resource.h in nebula_window_win.cpp and set window_class.hIcon/hIconSm via LoadImageW. Update CMakeLists.txt to compile the .rc and add the resources include directory for Windows. --- CMakeLists.txt | 4 ++++ resources/nebula.rc | 3 +++ resources/resource.h | 3 +++ src/platform/win/nebula_window_win.cpp | 15 +++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 resources/nebula.rc create mode 100644 resources/resource.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e899011..ed8c343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ if(OS_WINDOWS) src/platform/win/startup_win.cpp src/platform/win/browser_host_win.cpp src/platform/win/nebula_window_win.cpp + resources/nebula.rc ) elseif(OS_MACOSX) set(NEBULA_PLATFORM_SOURCES @@ -156,6 +157,9 @@ function(add_nebula_app_target nebula_target entry_source) if(OS_WINDOWS) target_link_libraries(${nebula_target} PRIVATE dwmapi) + target_include_directories(${nebula_target} PRIVATE + "${CMAKE_SOURCE_DIR}/resources" + ) target_compile_definitions(${nebula_target} PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN diff --git a/resources/nebula.rc b/resources/nebula.rc new file mode 100644 index 0000000..d54b912 --- /dev/null +++ b/resources/nebula.rc @@ -0,0 +1,3 @@ +#include "resource.h" + +IDI_APPICON ICON "..\\assets\\images\\branding\\Nebula-Favicon.ico" diff --git a/resources/resource.h b/resources/resource.h new file mode 100644 index 0000000..7737cfe --- /dev/null +++ b/resources/resource.h @@ -0,0 +1,3 @@ +#pragma once + +#define IDI_APPICON 1 diff --git a/src/platform/win/nebula_window_win.cpp b/src/platform/win/nebula_window_win.cpp index dbe4d09..29190aa 100644 --- a/src/platform/win/nebula_window_win.cpp +++ b/src/platform/win/nebula_window_win.cpp @@ -7,6 +7,7 @@ #include #include +#include "resource.h" #include "ui/paths.h" namespace nebula::window { @@ -426,6 +427,20 @@ void nebula::window::NebulaWindowImpl::RegisterClass(HINSTANCE instance_handle) window_class.lpfnWndProc = StaticWndProc; window_class.hInstance = instance_handle; window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.hIcon = static_cast(LoadImageW( + instance_handle, + MAKEINTRESOURCEW(IDI_APPICON), + IMAGE_ICON, + GetSystemMetrics(SM_CXICON), + GetSystemMetrics(SM_CYICON), + LR_DEFAULTCOLOR)); + window_class.hIconSm = static_cast(LoadImageW( + instance_handle, + MAKEINTRESOURCEW(IDI_APPICON), + IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), + GetSystemMetrics(SM_CYSMICON), + LR_DEFAULTCOLOR)); window_class.lpszClassName = WindowClassName(); RegisterClassExW(&window_class);