Skip to content

Commit

Permalink
cleanup zoomlevel configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Dec 1, 2015
1 parent fe88d38 commit 158be75
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/vs/workbench/electron-browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@
};
}

// disable pinch zoom
// disable pinch zoom & apply zoom level early to avoid glitches
var windowConfiguration = globalSettings.settings && globalSettings.settings.window;
webFrame.setZoomLevelLimits(1, 1);
if (windowConfiguration && typeof windowConfiguration.zoomLevel === 'number' && windowConfiguration.zoomLevel !== 0) {
webFrame.setZoomLevel(windowConfiguration.zoomLevel);
}

// apply zoom level very early to avoid glitches
webFrame.setZoomLevel(globalSettings.settings.window.zoomLevel);

// Load the loader and start loading the workbench
var rootUrl = uriFromPath(configuration.appRoot) + '/out';
createScript(rootUrl + '/vs/loader.js', function() {
require.config({
Expand Down
13 changes: 11 additions & 2 deletions src/vs/workbench/electron-browser/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
import {IWorkspaceContextService}from 'vs/workbench/services/workspace/common/contextService';
import {IWindowService}from 'vs/workbench/services/window/electron-browser/windowService';
import {IWindowConfiguration} from 'vs/workbench/electron-browser/window';
import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceEventTypes} from 'vs/platform/configuration/common/configuration';

import win = require('vs/workbench/electron-browser/window');
Expand Down Expand Up @@ -103,8 +104,16 @@ export class ElectronIntegration {

// Configuration changes
this.configurationService.addListener(ConfigurationServiceEventTypes.UPDATED, (e: IConfigurationServiceEvent) => {
let zoomLevel = e.config && e.config.window && e.config.window.zoomLevel;
webFrame.setZoomLevel(zoomLevel);
let windowConfig: IWindowConfiguration = e.config;

let newZoomLevel = 0;
if (windowConfig.window && typeof windowConfig.window.zoomLevel === 'number') {
newZoomLevel = windowConfig.window.zoomLevel;
}

if (webFrame.getZoomLevel() !== newZoomLevel) {
webFrame.setZoomLevel(newZoomLevel);
}
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/electron-browser/main.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ configurationRegistry.registerConfiguration({
},
'window.zoomLevel': {
'type': 'number',
'default': '0',
'description': nls.localize('zoomLevel', "Zoom level todo")
'default': 0,
'description': nls.localize('zoomLevel', "Adjust the zoom level of the window. The original size is 0 and each increment above or below represents zooming 20% larger or smaller.")
}
}
});
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/electron-browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ import ipc = require('ipc');
const Shell = remote.require('shell');
const Dialog = remote.require('dialog');

export interface IWindowConfiguration {
window: {
openFilesInNewWindow: boolean;
reopenFolders: string;
zoomLevel: number;
}
}

export class ElectronWindow {
private win: remote.BrowserWindow;

Expand Down

0 comments on commit 158be75

Please sign in to comment.