michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; michael@0: michael@0: this.EXPORTED_SYMBOLS = ["Windows8WindowFrameColor"]; michael@0: michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: let Registry = Cu.import("resource://gre/modules/WindowsRegistry.jsm").WindowsRegistry; michael@0: michael@0: const Windows8WindowFrameColor = { michael@0: _windowFrameColor: null, michael@0: michael@0: get: function() { michael@0: if (this._windowFrameColor) michael@0: return this._windowFrameColor; michael@0: michael@0: const HKCU = Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER; michael@0: const dwmKey = "Software\\Microsoft\\Windows\\DWM"; michael@0: let customizationColor = Registry.readRegKey(HKCU, dwmKey, michael@0: "ColorizationColor"); michael@0: // The color returned from the Registry is in decimal form. michael@0: let customizationColorHex = customizationColor.toString(16); michael@0: // Zero-pad the number just to make sure that it is 8 digits. michael@0: customizationColorHex = ("00000000" + customizationColorHex).substr(-8); michael@0: let customizationColorArray = customizationColorHex.match(/../g); michael@0: let [unused, fgR, fgG, fgB] = customizationColorArray.map(function(val) parseInt(val, 16)); michael@0: let colorizationColorBalance = Registry.readRegKey(HKCU, dwmKey, michael@0: "ColorizationColorBalance"); michael@0: // Window frame base color when Color Intensity is at 0, see bug 1004576. michael@0: let frameBaseColor = 217; michael@0: let alpha = colorizationColorBalance / 100; michael@0: michael@0: // Alpha-blend the foreground color with the frame base color. michael@0: let r = Math.round(fgR * alpha + frameBaseColor * (1 - alpha)); michael@0: let g = Math.round(fgG * alpha + frameBaseColor * (1 - alpha)); michael@0: let b = Math.round(fgB * alpha + frameBaseColor * (1 - alpha)); michael@0: return this._windowFrameColor = [r, g, b]; michael@0: }, michael@0: };