CtrlCore: Cocoa always use bundled icon (#339)

* CtrlCore: Cocoa always use bundled icon.

* Reworked

* .cosmetics

* .simplified
This commit is contained in:
Zbigniew Rębacz 2026-01-12 08:33:07 +01:00 committed by GitHub
parent 1596195267
commit d4bae3cd09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 9 deletions

View file

@ -2,8 +2,10 @@ private:
friend struct MMCtrl;
friend struct MMImp;
static bool local_dnd_copy;
static Ptr<Ctrl> lastActive;
static bool local_dnd_copy;
static Ptr<Ctrl> lastActive;
static bool always_use_bundled_icon;
friend void CocoInit(int argc, const char **argv, const char **envptr);
@ -15,11 +17,14 @@ protected:
static void SyncAppIcon();
static void ResetCocoaMouse();
static void DoCancelPreedit();
static int GetCaretBlinkTime() { return 500; }
static int GetCaretBlinkTime() { return 500; }
public:
static void EndSession() {}
static bool IsEndSession() { return false; }
static void EndSession() {}
static bool IsEndSession() { return false; }
static void SetAlwaysUseBundledIcon(bool enable = true) { always_use_bundled_icon = enable; }
static bool IsAlwaysUseBundledIcon() { return always_use_bundled_icon; }
void *GetNSWindow() const;
void *GetNSView() const;

View file

@ -21,3 +21,5 @@ public:
Event<Bar&> WhenDockMenu;
void SetMainMenu(Event<Bar&> menu);
void SetBadgeLabel(const String& label = String());

View file

@ -2,7 +2,9 @@
#ifdef GUI_COCOA
NAMESPACE_UPP
#include <CtrlCore/CocoMM.h>
namespace Upp {
#define LLOG(x) // LOG(x)
@ -25,7 +27,13 @@ bool TopWindow::IsTopMost() const
void TopWindow::GuiPlatformConstruct()
{
}
END_UPP_NAMESPACE
void TopWindow::SetBadgeLabel(const String& label)
{
NSString* nlabel = [NSString stringWithUTF8String:~label];
[[NSApp dockTile] setBadgeLabel:nlabel];
}
}
#endif

View file

@ -35,6 +35,8 @@ namespace Upp {
static Vector<Ptr<Ctrl>> mmtopctrl; // should work without Ptr, but let us be defensive....
bool Ctrl::always_use_bundled_icon = false;
Ctrl *Ctrl::GetOwner()
{
GuiLock __;
@ -276,6 +278,9 @@ void TopWindow::SyncTitle()
void Ctrl::SyncAppIcon()
{
if(always_use_bundled_icon)
return;
Ctrl *q = GetFocusCtrl();
if(!q)
q = lastActive;

View file

@ -124,7 +124,7 @@ file
CocoClip.mm,
CocoCtrl.cpp,
CocoWnd.cpp,
CocoTop.cpp,
CocoTop.mm,
CocoChSysInit.cpp,
"RTF support" readonly separator,
ParseRTF.cpp,

View file

@ -570,6 +570,12 @@ void Ide::SetIdeState(int newstate)
}
void Ide::MakeIcon() {
#ifdef PLATFORM_COCOA
String badge = IsOpen() ? main : "";
SetBadgeLabel(badge);
return;
#endif
Image li = IdeImg::Icon256();
#ifndef PLATFORM_POSIX // Kubuntu is using this icon for window while ignoring it in taskbar...
WString mp = main.ToWString();

View file

@ -217,6 +217,9 @@ void AppMain___()
Ctrl::SetDarkThemeEnabled();
Ctrl::SkinChangeSensitive();
Ctrl::SetAppName("TheIDE");
#ifdef PLATFORM_COCOA
Ctrl::SetAlwaysUseBundledIcon();
#endif
SetLanguage(LNG_ENGLISH);
SetDefaultCharset(CHARSET_UTF8);