MacOS desktop tinting

70 views
Skip to first unread message

Mo_Al_

unread,
Oct 2, 2021, 9:51:04 AM10/2/21
to fltk.general
Hello
This is more of a Cocoa question than an FLTK question, but since my experience with stackoverflow regarding anything Cocoa or Objc related hasn't been stellar, I thought I'd ask here.

Apps running on MacOS's dark mode benefit from desktop tinting. So even if I get dark mode's windowBackgroundColor using:

  void get_windowBackgroundColor(double *r, double *g, double *b, double *a) {                
    NSColor *c = [NSColor windowBackgroundCOlor];                                              
    NSColor *s = [i colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; 
    [s getRed:r green:g blue:b alpha:a];                                       
  }
I use the values to set the FL_BACKGROUND_COLOR or the window's color and they would be correct when disabling desktop tinting, but with desktop tinting enabled, the colors would be off. 
NSColor has a static method, currentControlTint, but it always returns a Blue tint enum value regardless of the desktop color. I have tried enabling transparency of the window using NSWindow's -setAlphaValue:, it helps but only if the window is directly on top of the desktop. 
Is there something I'm missing?
Is there a way to programmatically get the current desktop tint and somehow apply it to an FLTK window?

Thank you

Albrecht Schlosser

unread,
Oct 2, 2021, 10:04:43 AM10/2/21
to fltkg...@googlegroups.com
On 10/2/21 3:51 PM Mo_Al_ wrote:
> Hello
> This is more of a Cocoa question than an FLTK question, but since my
> experience with stackoverflow regarding anything Cocoa or Objc related
> hasn't been stellar, I thought I'd ask here.
>
> Apps running on MacOS's dark mode benefit from desktop tinting. So
> even if I get dark mode's windowBackgroundColor using:
> [...]
> Is there something I'm missing?
> Is there a way to programmatically get the current desktop tint and
> somehow apply it to an FLTK window?

I have no idea what "desktop tinting" means and what you really
want/need. That said, we have a new branch called "darkmode" (inactive,
not yet merged) where Mike Sweet added something to get the dark mode
system colors from macOS. Maybe this can help?

https://github.com/fltk/fltk/tree/darkmode

The latest three commits in that branch *might* give you some clues (or
maybe not, I don't know).
https://github.com/fltk/fltk/commits/darkmode

In this commit Mike commented "(gotta love how Apple's documentation is
broken...)", whatever that means. ;-)
https://github.com/fltk/fltk/commit/9459c8b345801d9da7ac661445843f89a757a915

Mo_Al_

unread,
Oct 2, 2021, 10:31:40 AM10/2/21
to fltk.general
Thank you. I'll check out that branch.

The Desktop tinting (or wallpaper tinting) can be enabled or disabled in the settings:
tinting.jpg

The difference can be even more pronounced with lighter (or more red) the wallpaper is. 

I have a small program which extracts all non-deprecated non-beta colors cocoa colors if that might be useful to the darkmode branch:
and the generated colors:
Reply all
Reply to author
Forward
0 new messages