Closed Bug 816803 Opened 12 years ago Closed 11 years ago

Need a way to detect existence of Aero Glass via CSS

Categories

(Core :: Widget: Win32, defect)

All
Windows 8
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: MattN, Assigned: MattN)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file, 1 obsolete file)

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.
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.
Flags: needinfo?(robert.bugzilla)
(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.
Wouldn't changing -moz-windows-glass to exclude Windows 8 be sufficient?
Flags: needinfo?(robert.bugzilla)
(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).
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.
(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
(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.
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?
See Also: → 810399
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.
Assignee: nobody → mnoorenberghe+bmo
Status: NEW → ASSIGNED
(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.
(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?
(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.
(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.
Attachment #699469 - Flags: review?(jmathies)
Comment on attachment 699469 [details] [diff] [review]
v.1 GetWindowsVersion when updating cache

Oops, code other than CSS styling relies on CheckForCompositor.
Attachment #699469 - Attachment is obsolete: true
Attachment #699469 - Flags: review?(jmathies)
(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.
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.
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.
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.
(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?
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
Attachment #704144 - Flags: superreview?(roc)
Attachment #704144 - Flags: review?(jmathies)
Attachment #704144 - Flags: superreview?(roc) → superreview+
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.
Attachment #704144 - Flags: review?(jmathies) → review+
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.
Blocks: 832666
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.
Flags: in-testsuite+
Blocks: 834888
Keywords: dev-doc-needed
https://hg.mozilla.org/mozilla-central/rev/b188c776e9b4
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in before you can comment on or make changes to this bug.