|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; |
|
7 |
|
8 this.EXPORTED_SYMBOLS = ["Windows8WindowFrameColor"]; |
|
9 |
|
10 Cu.import("resource://gre/modules/Services.jsm"); |
|
11 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
12 let Registry = Cu.import("resource://gre/modules/WindowsRegistry.jsm").WindowsRegistry; |
|
13 |
|
14 const Windows8WindowFrameColor = { |
|
15 _windowFrameColor: null, |
|
16 |
|
17 get: function() { |
|
18 if (this._windowFrameColor) |
|
19 return this._windowFrameColor; |
|
20 |
|
21 const HKCU = Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER; |
|
22 const dwmKey = "Software\\Microsoft\\Windows\\DWM"; |
|
23 let customizationColor = Registry.readRegKey(HKCU, dwmKey, |
|
24 "ColorizationColor"); |
|
25 // The color returned from the Registry is in decimal form. |
|
26 let customizationColorHex = customizationColor.toString(16); |
|
27 // Zero-pad the number just to make sure that it is 8 digits. |
|
28 customizationColorHex = ("00000000" + customizationColorHex).substr(-8); |
|
29 let customizationColorArray = customizationColorHex.match(/../g); |
|
30 let [unused, fgR, fgG, fgB] = customizationColorArray.map(function(val) parseInt(val, 16)); |
|
31 let colorizationColorBalance = Registry.readRegKey(HKCU, dwmKey, |
|
32 "ColorizationColorBalance"); |
|
33 // Window frame base color when Color Intensity is at 0, see bug 1004576. |
|
34 let frameBaseColor = 217; |
|
35 let alpha = colorizationColorBalance / 100; |
|
36 |
|
37 // Alpha-blend the foreground color with the frame base color. |
|
38 let r = Math.round(fgR * alpha + frameBaseColor * (1 - alpha)); |
|
39 let g = Math.round(fgG * alpha + frameBaseColor * (1 - alpha)); |
|
40 let b = Math.round(fgB * alpha + frameBaseColor * (1 - alpha)); |
|
41 return this._windowFrameColor = [r, g, b]; |
|
42 }, |
|
43 }; |