Bug 1355771 - Automatically enable Firefox touch mode in Windows Tablet mode. r=dao

MozReview-Commit-ID: 1KLFdsNlib1
This commit is contained in:
Johann Hofmann
2017-06-07 12:54:39 +02:00
parent bbfd7e2e11
commit df0adde97c
2 changed files with 24 additions and 3 deletions

View File

@@ -240,6 +240,13 @@ pref("general.autoScroll", true);
// UI density of the browser chrome. This mostly affects toolbarbutton // UI density of the browser chrome. This mostly affects toolbarbutton
// and urlbar spacing. The possible values are 0=normal, 1=compact, 2=touch. // and urlbar spacing. The possible values are 0=normal, 1=compact, 2=touch.
pref("browser.uidensity", 0); pref("browser.uidensity", 0);
// Whether Firefox will automatically override the uidensity to "touch"
// while the user is in a touch environment (such as Windows tablet mode).
#ifdef MOZ_PHOTON_THEME
pref("browser.touchmode.auto", true);
#else
pref("browser.touchmode.auto", false);
#endif
// At startup, check if we're the default browser and prompt user if not. // At startup, check if we're the default browser and prompt user if not.
pref("browser.shell.checkDefaultBrowser", true); pref("browser.shell.checkDefaultBrowser", true);

View File

@@ -5407,6 +5407,7 @@ var TabletModeUpdater = {
document.documentElement.removeAttribute("tabletmode"); document.documentElement.removeAttribute("tabletmode");
} }
if (wasInTabletMode != isInTabletMode) { if (wasInTabletMode != isInTabletMode) {
gUIDensity.update();
TabsInTitlebar.updateAppearance(true); TabsInTitlebar.updateAppearance(true);
} }
}, },
@@ -5446,7 +5447,10 @@ function displaySecurityInfo() {
// Updates the UI density (for touch and compact mode) based on the uidensity pref. // Updates the UI density (for touch and compact mode) based on the uidensity pref.
var gUIDensity = { var gUIDensity = {
MODE_COMPACT: 1,
MODE_TOUCH: 2,
prefDomain: "browser.uidensity", prefDomain: "browser.uidensity",
observe(aSubject, aTopic, aPrefName) { observe(aSubject, aTopic, aPrefName) {
if (aTopic != "nsPref:changed" || aPrefName != this.prefDomain) if (aTopic != "nsPref:changed" || aPrefName != this.prefDomain)
return; return;
@@ -5455,12 +5459,22 @@ var gUIDensity = {
}, },
update() { update() {
let mode;
// Automatically override the uidensity to touch in Windows tablet mode.
if (AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
WindowsUIUtils.inTabletMode &&
gPrefService.getBoolPref("browser.touchmode.auto")) {
mode = this.MODE_TOUCH;
} else {
mode = gPrefService.getIntPref(this.prefDomain);
}
let doc = document.documentElement; let doc = document.documentElement;
switch (gPrefService.getIntPref(this.prefDomain)) { switch (mode) {
case 1: case this.MODE_COMPACT:
doc.setAttribute("uidensity", "compact"); doc.setAttribute("uidensity", "compact");
break; break;
case 2: case this.MODE_TOUCH:
doc.setAttribute("uidensity", "touch"); doc.setAttribute("uidensity", "touch");
break; break;
default: default: