Use logo as an icon in Linux windows
This commit is contained in:
@@ -50,10 +50,12 @@ bool SDLPlatform::Init()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PLATFORM_LINUX
|
#if PLATFORM_LINUX
|
||||||
// TODO: This should be read from the platform configuration (needed for desktop icon handling)
|
// The name follows the .desktop entry specification, this is used to get a fallback icon on Wayland:
|
||||||
|
// https://specifications.freedesktop.org/desktop-entry-spec/latest/file-naming.html
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
SDL_SetHint(SDL_HINT_APP_ID, StringAnsi("com.FlaxEngine.FlaxEditor").Get());
|
SDL_SetHint(SDL_HINT_APP_ID, StringAnsi("com.FlaxEngine.FlaxEditor").Get());
|
||||||
#else
|
#else
|
||||||
|
// TODO: This should be read from the platform configuration (needed for desktop icon handling)
|
||||||
SDL_SetHint(SDL_HINT_APP_ID, StringAnsi("com.FlaxEngine.FlaxGame").Get());
|
SDL_SetHint(SDL_HINT_APP_ID, StringAnsi("com.FlaxEngine.FlaxGame").Get());
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -5,16 +5,23 @@
|
|||||||
#include "SDLWindow.h"
|
#include "SDLWindow.h"
|
||||||
#include "SDLInput.h"
|
#include "SDLInput.h"
|
||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
|
#include "Engine/Core/Math/Color32.h"
|
||||||
#include "Engine/Core/Math/Math.h"
|
#include "Engine/Core/Math/Math.h"
|
||||||
#include "Engine/Core/Math/Rectangle.h"
|
#include "Engine/Core/Math/Rectangle.h"
|
||||||
#include "Engine/Engine/Engine.h"
|
#include "Engine/Engine/Globals.h"
|
||||||
#include "Engine/Graphics/GPUDevice.h"
|
#include "Engine/Graphics/GPUDevice.h"
|
||||||
#include "Engine/Graphics/GPUSwapChain.h"
|
#include "Engine/Graphics/GPUSwapChain.h"
|
||||||
#include "Engine/Graphics/RenderTask.h"
|
#include "Engine/Graphics/RenderTask.h"
|
||||||
|
#include "Engine/Graphics/Textures/TextureData.h"
|
||||||
#include "Engine/Input/Input.h"
|
#include "Engine/Input/Input.h"
|
||||||
#include "Engine/Input/Keyboard.h"
|
#include "Engine/Input/Keyboard.h"
|
||||||
#include "Engine/Input/Mouse.h"
|
#include "Engine/Input/Mouse.h"
|
||||||
|
#include "Engine/Platform/FileSystem.h"
|
||||||
#include "Engine/Platform/WindowsManager.h"
|
#include "Engine/Platform/WindowsManager.h"
|
||||||
|
#if PLATFORM_LINUX
|
||||||
|
#define COMPILE_WITH_TEXTURE_TOOL 1 // FIXME
|
||||||
|
#include "Engine/Tools/TextureTool/TextureTool.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NOGDI
|
#define NOGDI
|
||||||
#include <SDL3/SDL_events.h>
|
#include <SDL3/SDL_events.h>
|
||||||
@@ -212,6 +219,27 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
|||||||
if (SDLPlatform::UsesX11() && _settings.AllowInput)
|
if (SDLPlatform::UsesX11() && _settings.AllowInput)
|
||||||
SDL_StartTextInput(_window);
|
SDL_StartTextInput(_window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PLATFORM_LINUX && COMPILE_WITH_TEXTURE_TOOL
|
||||||
|
// Ensure windows other than the main window have some kind of icon
|
||||||
|
static SDL_Surface* surface = nullptr;
|
||||||
|
static Array<Color32> colorData;
|
||||||
|
if (surface == nullptr)
|
||||||
|
{
|
||||||
|
const String iconPath = Globals::BinariesFolder / TEXT("Logo.png");
|
||||||
|
if (FileSystem::FileExists(iconPath))
|
||||||
|
{
|
||||||
|
TextureData icon;
|
||||||
|
if (!TextureTool::ImportTexture(iconPath, icon))
|
||||||
|
{
|
||||||
|
icon.GetPixels(colorData);
|
||||||
|
surface = SDL_CreateSurfaceFrom(icon.Width, icon.Height, SDL_PIXELFORMAT_ABGR8888, colorData.Get(), sizeof(Color32) * icon.Width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (surface != nullptr)
|
||||||
|
SDL_SetWindowIcon(_window, surface);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Window* SDLWindow::GetSDLWindow() const
|
SDL_Window* SDLWindow::GetSDLWindow() const
|
||||||
@@ -966,5 +994,15 @@ void SDLWindow::UpdateCursor()
|
|||||||
SDL_SetCursor(Cursors[index]);
|
SDL_SetCursor(Cursors[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLWindow::SetIcon(TextureData& icon)
|
||||||
|
{
|
||||||
|
Array<Color32> colorData;
|
||||||
|
icon.GetPixels(colorData);
|
||||||
|
SDL_Surface* surface = SDL_CreateSurfaceFrom(icon.Width, icon.Height, SDL_PIXELFORMAT_ABGR8888, colorData.Get(), sizeof(Color32) * icon.Width);
|
||||||
|
|
||||||
|
SDL_SetWindowIcon(_window, surface);
|
||||||
|
SDL_free(surface);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ public:
|
|||||||
void EndClippingCursor() override;
|
void EndClippingCursor() override;
|
||||||
void SetMousePosition(const Float2& position) const override;
|
void SetMousePosition(const Float2& position) const override;
|
||||||
void SetCursor(CursorType type) override;
|
void SetCursor(CursorType type) override;
|
||||||
|
void SetIcon(TextureData& icon) override;
|
||||||
|
|
||||||
#if USE_EDITOR && PLATFORM_WINDOWS
|
#if USE_EDITOR && PLATFORM_WINDOWS
|
||||||
// [IUnknown]
|
// [IUnknown]
|
||||||
|
|||||||
Reference in New Issue
Block a user