sagebind / atom-gtk-dark-theme

Toggles the dark theme variant for Atom windows on GTK+3
https://atom.io/packages/gtk-dark-theme
MIT License
18 stars 3 forks source link

Wrong window's title bar darkened #2

Open meghprkh opened 8 years ago

meghprkh commented 8 years ago

This happens when you launch an application just after launching atom.

For example, I open atom using atom . and while that is loading and window is still not shown I open pinta (or any other application with a titlebar, you wont be able to see the difference in a header bar window)

screenshot from 2016-07-25 16-18-17

moimael commented 7 years ago

I have the same issue, because I launch my work applications automatically on startup and atom is launched, then slack and slack get the dark titlebar and atom does not. I have to restart atom to get it to work.

sagebind commented 7 years ago

This is caused by a race condition that I can't easily fix. The way the titlebar is darkened follows these steps asynchronously:

  1. Get all windows open on the desktop.
  2. Get all process IDs that belong to Atom.
  3. For each window, check if it is owned by any of Atom's process IDs. If so, set the titlebar to dark.

The problem is, Atom could spawn or terminate processes at any point while this is happening, and a PID formerly assigned to Atom could be claimed by a different application.

I'm not sure if this is fixable. This is already an improved version of the strategy used by Sublime Text's GTKDarkThemeVariantSetter, which was subject to even more race condition bugs.

I would say #1 is related, and could solve this problem once and for all.