Last Comment Bug 816803 - Need a way to detect existence of Aero Glass via CSS
: Need a way to detect existence of Aero Glass via CSS
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: Widget: Win32 (show other bugs)
: Trunk
: All Windows 8
: -- normal (vote)
: mozilla21
Assigned To: Matthew N. [:MattN] (PTO Jun. 29-30)
:
Mentors:
Depends on:
Blocks: 834888 813812 832666
  Show dependency treegraph
 
Reported: 2012-11-29 17:33 PST by Matthew N. [:MattN] (PTO Jun. 29-30)
Modified: 2013-08-23 01:30 PDT (History)
14 users (show)
MattN+bmo: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
v.1 GetWindowsVersion when updating cache (2.22 KB, patch)
2013-01-08 15:22 PST, Matthew N. [:MattN] (PTO Jun. 29-30)
no flags Details | Diff | Review
v.2 add -moz-windows-glass for Windows < 8 (11.73 KB, patch)
2013-01-18 16:52 PST, Matthew N. [:MattN] (PTO Jun. 29-30)
jmathies: review+
roc: superreview+
Details | Diff | Review

Description Matthew N. [:MattN] (PTO Jun. 29-30) 2012-11-29 17:33:32 PST
On Windows 8, there isn't glass but I don't see a way to detect this via CSS.  For Australis tabs we show a fog on top of glass but we don't want to show this on Windows 8.  -moz-windows-compositor was used for Windows 7 but that also matches on Windows 8.

It would be nice if there was a system metric/media query to detect glass e.g. -moz-windows-glass.
Comment 1 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-13 15:55:59 PST
Robert, is there someone on your team could take a look at this to see if there is a Windows API to detect glass?  If not, I guess we would have to check the Windows version along with DWM.
Comment 2 Brian R. Bondy [:bbondy] 2012-12-13 16:02:55 PST
Maybe this?

DwmIsCompositionEnabled
http://msdn.microsoft.com/en-us/library/aa969518%28v=vs.85%29.aspx

About DWM composition:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa969540%28v=vs.85%29.aspx
Comment 3 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-13 16:14:02 PST
(In reply to Brian R. Bondy [:bbondy] from comment #2)
> Maybe this?
> 
> DwmIsCompositionEnabled

That's what we're already using to detect glass at the moment but that always returns true on Windows 8 even when there isn't glass. My understanding is the DWM is always in use on Windows 8.
Comment 4 Robert Strong [:rstrong] (use needinfo to contact me) 2012-12-13 16:52:14 PST
Wouldn't changing -moz-windows-glass to exclude Windows 8 be sufficient?
Comment 5 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-13 17:01:19 PST
(In reply to Robert Strong [:rstrong] (do not email) from comment #4)
> Wouldn't changing -moz-windows-glass to exclude Windows 8 be sufficient?

We don't have a -moz-windows-glass media query keyword[1].  We currently use -moz-windows-compositor for that.  I'd be fine if we create -moz-windows-glass and have it check for DWM and Windows 7 or earlier if there is no other way (see comment 1).
Comment 6 Brian R. Bondy [:bbondy] 2012-12-13 17:06:37 PST
Ah I see, ya that makes sense.  There are ways to enable glass on Windows 8 by the way. 

I'd probably try enabling it with procmon open and see if it modifies a registry key or something. Then you can check the value of that regkey in addition to DwmIsCompositionEnabled.
Comment 7 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-13 17:15:11 PST
(In reply to Brian R. Bondy [:bbondy] from comment #6)
> Ah I see, ya that makes sense.  There are ways to enable glass on Windows 8
> by the way. 

Yeah, I saw that while googling for this.

> I'd probably try enabling it with procmon open and see if it modifies a
> registry key or something. Then you can check the value of that regkey in
> addition to DwmIsCompositionEnabled.

Good idea. I don't have Windows 8 RTM (and therefore still always have glass) so I probably wouldn't get accurate results at the moment. I'd appreciate if someone with RTM could try this.

I also just found IsThemeBackgroundPartiallyTransparent[1] which isn't specifically about glass but may be just as useful for us as long as it's true with glass and false otherwise (e.g. Aero Basic & XP). I haven't tested if this is the case.
[1] http://msdn.microsoft.com/en-us/library/windows/desktop/bb759815%28v=vs.85%29.aspx
Comment 8 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-13 20:56:13 PST
(In reply to Matthew N. [:MattN] from comment #7)
> (In reply to Brian R. Bondy [:bbondy] from comment #6)
> > Ah I see, ya that makes sense.  There are ways to enable glass on Windows 8
> > by the way. 
> 
> Yeah, I saw that while googling for this.
> 
> > I'd probably try enabling it with procmon open and see if it modifies a
> > registry key or something. Then you can check the value of that regkey in
> > addition to DwmIsCompositionEnabled.
> 
> Good idea. I don't have Windows 8 RTM (and therefore still always have
> glass) so I probably wouldn't get accurate results at the moment. I'd
> appreciate if someone with RTM could try this.

I got access to Windows 8 RTM and then actually read the tutorials to get Glass on Windows 8 and I see now that they are only achieving transparency but not the fog so it's not actually Glass.  I also tried Aero8Tuner and it does the same thing.  Both of these approaches use high contrast mode to get the transparency and set the following registry key:
HKCU\Software\Microsoft\Windows\DWM\ColorizationGlassAttribute (0 = default, 2 = transparency)

So far I'm not sure this helps us because I don't see a supported way of having transparency on a Firefox window in Windows 8.
Comment 9 Richard Marti (:Paenglab) 2012-12-13 23:37:10 PST
Is this only to detect if Glass is enabled or can it be used to detect Win8? If it's only for Glass, bug 810399 is still valid?
Comment 10 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-20 13:43:03 PST
I'll take this and make a new -moz-windows-glass media feature which is the same as -moz-windows-compositor except that it doesn't match on Windows 8.

(In reply to Richard Marti [:Paenglab] from comment #9)
> Is this only to detect if Glass is enabled or can it be used to detect Win8?
> If it's only for Glass, bug 810399 is still valid?

We tend to prefer having pseudo-selectors and media features detecting features rather than version numbers as they lead to more future proof styles.
Comment 11 Jim Mathies [:jimm] 2012-12-21 03:41:10 PST
(In reply to Matthew N. [:MattN] from comment #10)
> I'll take this and make a new -moz-windows-glass media feature which is the
> same as -moz-windows-compositor except that it doesn't match on Windows 8.
> 
> (In reply to Richard Marti [:Paenglab] from comment #9)
> > Is this only to detect if Glass is enabled or can it be used to detect Win8?
> > If it's only for Glass, bug 810399 is still valid?
> 
> We tend to prefer having pseudo-selectors and media features detecting
> features rather than version numbers as they lead to more future proof
> styles.

Why dupe moz-windows-compositor? We've always used that to identify the existence of glass. In retrospect we chose the wrong string id but we are stuck with it now.

We have a windows theme selector (which needs updating) that can be used to identify all of the stock win8 themes - 

http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsLookAndFeel.cpp#387
http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsUXThemeData.cpp#260

Lets update that instead, and update the dev docs for moz-windows-compositor.
Comment 12 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-21 13:31:09 PST
(In reply to Jim Mathies [:jimm] from comment #11)
> Why dupe moz-windows-compositor? We've always used that to identify the
> existence of glass. In retrospect we chose the wrong string id but we are
> stuck with it now.

I thought knowing whether DWM is on may be useful for other cases and I didn't want the name to be a lie on Windows 8. I also thought -moz-windows-glass is easier to understand.

> We have a windows theme selector (which needs updating) that can be used to
> identify all of the stock win8 themes - 
> 
> http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsLookAndFeel.
> cpp#387
> http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsUXThemeData.
> cpp#260

Yes, I noticed these need to be updated but it doesn't really help with this bug AFAICT so that can be done separately.

> Lets update that instead, and update the dev docs for moz-windows-compositor.

Do you mean you want -moz-windows-compositor to not apply to Windows 8 and update the docs to say that? Or, did you mean to only use the theme selector for this purpose?
Comment 13 Jim Mathies [:jimm] 2012-12-31 06:22:32 PST
(In reply to Matthew N. [:MattN] from comment #12)
> (In reply to Jim Mathies [:jimm] from comment #11)
> > Why dupe moz-windows-compositor? We've always used that to identify the
> > existence of glass. In retrospect we chose the wrong string id but we are
> > stuck with it now.
> 
> I thought knowing whether DWM is on may be useful for other cases and I
> didn't want the name to be a lie on Windows 8. I also thought
> -moz-windows-glass is easier to understand.


Dao can confirm this but AFAIK, compositor checks are all about detecting glass. If moz-windows-compositor doesn't detect the presence of glass accurately, I think a lot of our glass specific theming is going to be on when it shouldn't. For example - 

http://mxr.mozilla.org/mozilla-central/search?string=moz-windows-compositor

browser-aero.css is the glass desktop theme.

> > Lets update that instead, and update the dev docs for moz-windows-compositor.
> 
> Do you mean you want -moz-windows-compositor to not apply to Windows 8 and
> update the docs to say that? Or, did you mean to only use the theme selector
> for this purpose?

I was thinking of updating moz-windows-compositor such that it is true when glass is present (including on win8) and false when it is not.
Comment 14 Matthew N. [:MattN] (PTO Jun. 29-30) 2012-12-31 07:03:25 PST
(In reply to Jim Mathies [:jimm] from comment #13)
> > > Lets update that instead, and update the dev docs for moz-windows-compositor.
> > 
> > Do you mean you want -moz-windows-compositor to not apply to Windows 8 and
> > update the docs to say that? Or, did you mean to only use the theme selector
> > for this purpose?
> 
> I was thinking of updating moz-windows-compositor such that it is true when
> glass is present (including on win8) and false when it is not.

I couldn't find a way to get Glass on Win8, only transparency.
Comment 15 Matthew N. [:MattN] (PTO Jun. 29-30) 2013-01-08 15:22:01 PST
Created attachment 699469 [details] [diff] [review]
v.1 GetWindowsVersion when updating cache
Comment 16 Matthew N. [:MattN] (PTO Jun. 29-30) 2013-01-08 17:42:49 PST
Comment on attachment 699469 [details] [diff] [review]
v.1 GetWindowsVersion when updating cache

Oops, code other than CSS styling relies on CheckForCompositor.
Comment 17 Jim Mathies [:jimm] 2013-01-09 05:18:41 PST
(In reply to Matthew N. [:MattN] from comment #16)
> Comment on attachment 699469 [details] [diff] [review]
> v.1 GetWindowsVersion when updating cache
> 
> Oops, code other than CSS styling relies on CheckForCompositor.

Maybe add a new routine CheckForGlass and tie that to css? Also add a good comment in there explaining what's going on. 

roc should probably sr the decision to update the meaning of moz-windows-compositor as well.
Comment 18 Justin Dolske [:Dolske] 2013-01-10 14:09:46 PST
I'd sure like to see us have a selector/query/whatever that's more selfdescriptive (even ignoring the Windows 8 issue). "moz-windows-compositor" isn't really self documenting (and, really, is an implementation detail), and has led to some of the confusion Matt's noted here.
Comment 19 Dão Gottwald [:dao] 2013-01-11 03:46:12 PST
I don't think coming up with a new name is worth it, given that Aero Glass is going away. We'd need to keep -moz-windows-compositor as an alias anyway, since third-party themes would still use it to detect Aero Glass.
Comment 20 Justin Dolske [:Dolske] 2013-01-13 21:45:36 PST
I'm not sure what you're actually objecting to. Do you have a specific proposal for the problem Matt's describing? I don't mind keeping -moz-windows-compositor around for backwards compat (although neither do I think it would be an undue burden to just change it). Having more natural ways to express in CSS what we want to do seems like an obvious win to me.
Comment 21 Dão Gottwald [:dao] 2013-01-14 01:07:26 PST
(In reply to Justin Dolske [:Dolske] from comment #20)
> I'm not sure what you're actually objecting to. Do you have a specific
> proposal for the problem Matt's describing?

What problem?
Comment 22 Matthew N. [:MattN] (PTO Jun. 29-30) 2013-01-18 16:52:44 PST
Created attachment 704144 [details] [diff] [review]
v.2 add -moz-windows-glass for Windows < 8

I've think adding -moz-windows-glass is the right solution because I determined that -moz-windows-compositor is used to detect UI conventions other than Aero Glass and changing -moz-windows-compositor to not apply on Windows 8 would regress positioning of UI elements to pre-Vista style and break things such as the caption buttons (making them solid black). It also greatly improves readability of the CSS because people don't know what -moz-windows-compositor means.

(In reply to Dão Gottwald [:dao] from comment #19)
> I don't think coming up with a new name is worth it, given that Aero Glass
> is going away. 

It's not going to go away anytime soon in our codebase because Windows 7 will be supported by Microsoft until 1/13/2015 (extended support to 1/14/2020) and lack of support won't stop people from using it. Windows 7 is turning into the new Windows XP IME.

> We'd need to keep -moz-windows-compositor as an alias anyway,
> since third-party themes would still use it to detect Aero Glass.

It won't be an alias because -moz-windows-compositor isn't only used to detect Aero Glass, even in our own code.  We also use it to determine whether there is a separate titlebar to determine the draggable region[1] and for positioning UI elements[2] to align with other native applications in Vista and higher. If -moz-windows-compositor was only used for changing colours due to transparency from Aero Glass then changing it to not match on Windows 8 would work, but unfortunately we're not in that situation AFAICT and while we can fix this in browser-aero.css, it's non-trivial and we can't fix similar situations in add-ons.

[1] https://mxr.mozilla.org/mozilla-central/source/browser/themes/winstripe/browser-aero.css?rev=04557efa1fd9&mark=276#270
[2] https://mxr.mozilla.org/mozilla-central/source/browser/themes/winstripe/browser-aero.css?rev=04557efa1fd9&mark=128,141,155,159,244#121
Comment 23 Jim Mathies [:jimm] 2013-01-19 08:15:59 PST
Comment on attachment 704144 [details] [diff] [review]
v.2 add -moz-windows-glass for Windows < 8

Review of attachment 704144 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/LookAndFeel.h
@@ +250,5 @@
>       */
>      eIntID_WindowsClassic,
>  
>      /*
> +     * A Boolean value to determine whether Windows is using Aero Glass.

Nit, I would explain this a bit more clearly - "to determine whether the current Windows desktop theme supports AeroGlass." or similar.
Comment 24 Jim Mathies [:jimm] 2013-01-19 08:18:24 PST
We should file a bug to investigate what is currently happening under the hood with our browser-aero theme and glass. Our front end theme assumes glass is present even though it's not. There's might be overhead here we might be able to avoid.
Comment 25 Matthew N. [:MattN] (PTO Jun. 29-30) 2013-01-25 13:43:16 PST
Thanks!
https://hg.mozilla.org/integration/fx-team/rev/b188c776e9b4

Try push: https://tbpl.mozilla.org/?tree=Try&rev=97d9f432152b

(In reply to Jim Mathies [:jimm] from comment #24)
> We should file a bug to investigate what is currently happening under the
> hood with our browser-aero theme and glass. Our front end theme assumes
> glass is present even though it's not. There's might be overhead here we
> might be able to avoid.

Agreed, I'm filing it now.
Comment 26 Ryan VanderMeulen [:RyanVM] 2013-01-26 18:25:20 PST
https://hg.mozilla.org/mozilla-central/rev/b188c776e9b4

Note You need to log in before you can comment on or make changes to this bug.