Skip to content

Support detecting inverted color scheme on Windows - #7518

Merged
zcbenz merged 6 commits into
masterfrom
inverted-color-scheme
Oct 11, 2016
Merged

zcbenz merged 6 commits into
masterfrom
inverted-color-scheme

Conversation

@kevinsawicki

@kevinsawicki kevinsawicki commented Oct 6, 2016 •

Copy link
Copy Markdown
Contributor

This API allows app's to determine if a high contrast theme is active on Windows in case they want to adjust their styles at startup or when the value is changed.

Chrome currently uses this API to show a popover about installing a dark theme and high contrast extension.

  • Add isInvertedColorScheme helper
  • Add inverted-color-scheme-changed event for when the theme/colors switched into and out of an inverted color scheme.

Closes #7469

@MarshallOfSound

Copy link
Copy Markdown
Member

Should we also listen for WM_COLORCHANGE messages and fire appropriate events?

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

Should we also listen for WM_COLORCHANGE messages and fire appropriate events?

Yeah, events for this would be great too, I think Chrome already has a custom listener wrapper for these, will explore.

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

Here is the Chrome helper for these: https://cs.chromium.org/chromium/src/ui/gfx/sys_color_change_listener.h

Will update this pull request to use it as well and see how it goes.

@kevinsawicki kevinsawicki changed the title Add systemPreferences.isInvertedColorScheme API [WIP] Add systemPreferences.isInvertedColorScheme API Oct 6, 2016
@MarshallOfSound

Copy link
Copy Markdown
Member

@MarshallOfSound

Copy link
Copy Markdown
Member

Ahhaha, you beat me by like 45 seconds... 😆

@kevinsawicki
kevinsawicki force-pushed the inverted-color-scheme branch from eaabd23 to 979728d Compare October 7, 2016 16:51
@kevinsawicki kevinsawicki changed the title [WIP] Add systemPreferences.isInvertedColorScheme API Support detecting inverted color scheme on Windows Oct 7, 2016
@kevinsawicki
kevinsawicki force-pushed the inverted-color-scheme branch 2 times, most recently from fe2ed99 to e55d64f Compare October 7, 2016 17:03
@kevinsawicki

Copy link
Copy Markdown
Contributor Author

Should we also listen for WM_COLORCHANGE messages and fire appropriate events?

Updated this pull request to emit an inverted-color-scheme-changed event for when the theme/colors are updated and impact that value.

@kevinsawicki
kevinsawicki force-pushed the inverted-color-scheme branch from e55d64f to 214038e Compare October 7, 2016 21:07
@anaisbetts

anaisbetts commented Oct 7, 2016 •

Copy link
Copy Markdown
Contributor

I give this PR full marks, if you want extra credit, give a way to get the High Contrast colors by asking for COLOR_WINDOWTEXT and COLOR_WINDOW colors, https://msdn.microsoft.com/en-us/library/dd318443(vs.85).aspx has some more info

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

give a way to get the High Contrast colors by asking for WINDOW_BACKGROUND and WINDOW_TEXT colors

Would these be the COLOR_WINDOWTEXT and COLOR_WINDOW color values?

Looks like that is what Chrome uses to detect high contrast colors: https://cs.chromium.org/chromium/src/ui/gfx/sys_color_change_listener.cc?l=25

@anaisbetts

Copy link
Copy Markdown
Contributor

@kevinsawicki Yeah, fixed my typo

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

Yeah, fixed my typo

Awesome, yeah, that sounds good 👍


namespace api {

class SystemPreferencesColorChangeListener

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SystemPreferences can inherit gfx::SysColorChangeListener directly.


bool invertered_color_scheme_ = false;

std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since color_change_listener_ is initialized in constructor, there is no need to put gfx::ScopedSysColorChangeListener in a unique_ptr.


std::string current_color_;

bool invertered_color_scheme_ = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invertered_color_scheme_ should be initialized with IsInvertedColorScheme().

@kevinsawicki
kevinsawicki force-pushed the inverted-color-scheme branch from b1c08a6 to c7b9e51 Compare October 10, 2016 17:34
@kevinsawicki

Copy link
Copy Markdown
Contributor Author

give a way to get the High Contrast colors by asking for COLOR_WINDOWTEXT and COLOR_WINDOW colors

After thinking about this a bit more, I'd like to do this in a separate PR that adds something like systemPreferences.getColor(id) and exposes access to all the colors listed on https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx

@kevinsawicki
kevinsawicki force-pushed the inverted-color-scheme branch from c7b9e51 to 38281f3 Compare October 10, 2016 17:42
@zcbenz

zcbenz commented Oct 11, 2016

Copy link
Copy Markdown
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants