Black Light, Night Shift & Flux

Black Light and Night Shift are good friends.

Many users of Black Light also want to use Flux (or f.lux) to tint their screen in warmer colors at night. The problem is that you can’t use both apps at the same time: they each compete to take control of the screen’s gamma curve and the result is a unusable flashing screen alternating between the gamma settings of the two apps.

In yesterday’s 10.12.4 update, macOS Sierra added a Flux-like feature called Night Shift. The good new is that, unlike Flux, Night Shift works well with Black Light.

The mechanism used by Night Shift is different. It does not rely on the gamma curve, which is good as it’s not fighting with Black Light. This also makes it limited in the hardware it supports1. After applying the update, you can check if your computer has the Night Shift tab in Apple Menu > System Preferences > Displays.

There remains only one small caveat: Night Shift combined with the “Invert Screen” filter will tint the screen light blue instead of the expected yellow-orange. Other filters will combine well with Night Shift.

Also of note: Gamma Control works with Night Shift too.

  1. Night Shift is supported by all Macs introduced since 2012, excluding the tower-format Mac Pros. ↩︎

Using Black Light to Avoid Image Retention

My iMac slowly started showing signs of image retention (or image persistence) a few months ago. After leaving the screen on for a few hours, I’ll see the imprint of what was left unmoved for too long. It only happens near the edges, and it will fade after some time, but it can be a bit annoying.

My Black Light Preferences

This week I made a little discovery: if I use Black Light to dim the screen by the smallest amount it’ll let me, I get no image retention. Black Light dims the screen by making each pixel color a bit darker, not by dimming the backlight. I suspect changing all the white pixels to a very light gray prevents the liquid crystals from getting stuck.

This is anecdotal: I tested it on my own computer and only for a few days. I can’t be sure it’ll work with other screens that are experiencing image retention. But if your screen has that problem, I think you should give Black Light a try and see for yourself.

Counterparts Lite Update

There’s an update available today for Counterparts Lite. Here’s what’s new in version 1.3.2.

Squashed Bugs

The first has something to do with the currently-edited text not being saved if you close the document window before exiting the text editing mode. I’m pretty sure I saw someone complain about this a while ago in a review in the Mac App Store, but with the review lacking specifics and having no way to interact with the poster I failed to locate the problem.

The second could cause the app to misbehave after editing a key in a .strings file if the key is already present in the document. An alert would appear asking you what to do, and everything went wrong after that. That’s all fixed now.


For customers getting Counterparts Lite directly from the website (as opposed to getting it from the Mac App Store), you will notice that it now includes an auto-update feature.

30-day Free Trial

If you’re not a customer (yet), you can just download the app to start your free trial of 30 days. Visit the Counterparts Lite website to learn more.

Choosing a Window Level in Red Stripe and Sim Daltonism

In OS X, windows are grouped by level. Windows within a particular level can usually be reordered by clicking on one to bring it to the front, but that will only bring the window on top of all other windows of the level it belongs to. For instance, clicking on a document window won’t make it come on top of a floating palette, or the dock, because the floating palette and the dock belong to a higher level.

When writing code, you can choose the level a window belongs to by setting the windowLevel property on the window. The OS has many predefined window levels you can access using CGWindowLevelForKey with one of the keys defined in the CGWindowLevelKey enum. Calling that function returns an integer representing the level: windows with a higher level stay on top of those with a lower one.

Here is some code to check the predefined levels in a Swift 3 playground, with the result for OS X 10.11:

CGWindowLevelForKey(.baseWindow)                // -2147483648
CGWindowLevelForKey(.minimumWindow)             // -2147483643
CGWindowLevelForKey(.desktopWindow)             // -2147483623
CGWindowLevelForKey(.desktopIconWindow)         // -2147483603
CGWindowLevelForKey(.backstopMenu)              // -20
CGWindowLevelForKey(.normalWindow)              // 0
CGWindowLevelForKey(.floatingWindow)            // 3
CGWindowLevelForKey(.tornOffMenuWindow)         // 3
CGWindowLevelForKey(.modalPanelWindow)          // 8
CGWindowLevelForKey(.utilityWindow)             // 19
CGWindowLevelForKey(.dockWindow)                // 20
CGWindowLevelForKey(.mainMenuWindow)            // 24
CGWindowLevelForKey(.statusWindow)              // 25
CGWindowLevelForKey(.popUpMenuWindow)           // 101
CGWindowLevelForKey(.helpWindow)                // 200
CGWindowLevelForKey(.draggingWindow)            // 500
CGWindowLevelForKey(.screenSaverWindow)         // 1000
CGWindowLevelForKey(.assistiveTechHighWindow)   // 1500
CGWindowLevelForKey(.cursorWindow)              // 2147483630
CGWindowLevelForKey(.maximumWindow)             // 2147483631

When I wrote Red Stripe, I used the assistiveTechHighWindow level because the goal is to filter the screen to help differentiate colors, and to that end the window must sit on top of everything. Even the name is appropriate, since Red Stripe is an assistive technology.

Then I rewrote Sim Daltonism this January based on the code from Red Stripe. Sim Daltonism is basically the reverse of an assistive technology: it simulates color blindness. Unsurprisingly, there is no predefined window level for that. Like Red Stripe, it needs to sit on top of everything so it can filter the content behind the window, so at first I was using the same window level.

But at some point I tested the two apps together. It’s great that you can use Red Stripe to add a pattern to certain colors and then put Sim Daltonism on top to check as a not-color-blind person if you can make sense of the resulting image. Except that Red Stripe only works well when the Sim Daltonism window is above it, otherwise it gets an image which already lost its useful color information and adding stripes does not make sense.

So now Sim Daltonism uses the following non-standard window level to always stay on top of Red Stripe:

CGWindowLevelForKey(.assistiveTechHighWindow) + 1

This is basically a made-up window level, and it turns out the window server will happily accept that. Note that I’m keeping the level relative to the assistive tech window level, so if that level changes in a future version of OS X, the window will still be above it. If I hard-coded the value 1501 instead, it wouldn’t be as future proof.

  • © 2003–2018 Michel Fortin.