Initialize color listener after app is ready

This commit is contained in:
Kevin Sawicki 2017-02-02 09:34:20 -08:00
parent 62a400b7d6
commit 5973aa36ad
3 changed files with 24 additions and 6 deletions

View file

@ -117,6 +117,14 @@ std::string SystemPreferences::GetColor(const std::string& color,
void SystemPreferences::InitializeWindow() {
invertered_color_scheme_ = IsInvertedColorScheme();
// Wait until app is ready before creating sys color listener
// Creating this listener before the app is ready causes global shortcuts
// to not fire
if (Browser::Get()->is_ready())
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
else
Browser::Get()->AddObserver(this);
WNDCLASSEX window_class;
base::win::InitializeWindowClass(
kSystemPreferencesWindowClass,
@ -172,6 +180,11 @@ void SystemPreferences::OnSysColorChange() {
Emit("color-changed");
}
void SystemPreferences::OnFinishLaunching(
const base::DictionaryValue& launch_info) {
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
}
} // namespace api
} // namespace atom