Fixed blank screen issue on windows and also made changes to use NWjs manifest for remembering window size. Fixes #6419

This commit is contained in:
Aditya Toshniwal
2021-08-26 11:19:15 +05:30
committed by Akshay Joshi
parent b30a42ab9e
commit 092f830c3c
5 changed files with 23 additions and 66 deletions

View File

@@ -365,34 +365,9 @@ let ConfigureStore = {
jsonData: {},
init: function() {
// Initialize the Screen.
let screen_obj = nw.Screen.Init();
// Minimum resolution support
let screen_height = 480;
let screen_width = 640;
// if screen_obj is not null and have at least one element then get the
// height and width of the work area.
if (screen_obj !== null && screen_obj !== undefined &&
screen_obj.screens.length > 0) {
screen_height = screen_obj.screens[0]['work_area']['height'] - 100;
screen_width = screen_obj.screens[0]['work_area']['width'] - 100;
}
if (!this.readConfig()){
this.jsonData = DEFAULT_CONFIG_DATA;
this.jsonData['windowHeight'] = screen_height;
this.jsonData['windowWidth'] = screen_width;
this.saveConfig();
} else {
// Check if stored window height and width is greater then the
// actual screen height and width, set the screen height and width.
if (ConfigureStore.get('windowHeight') > screen_height ||
ConfigureStore.get('windowWidth') > screen_width) {
this.set('windowHeight', screen_height);
this.set('windowWidth', screen_width);
this.saveConfig();
}
}
},

View File

@@ -201,18 +201,14 @@ function startDesktopMode() {
function launchPgAdminWindow() {
// Create and launch new window and open pgAdmin url
misc.writeServerLog('Application Server URL: ' + startPageUrl);
let winWidth = misc.ConfigureStore.get('windowWidth');
let winHeight = misc.ConfigureStore.get('windowHeight');
nw.Window.open(startPageUrl, {
'id': 'pgadmin-main',
'icon': '../../assets/pgAdmin4.png',
'frame': true,
'width': winWidth,
'height': winHeight,
'position': 'center',
'resizable': true,
'min_width': 400,
'min_height': 200,
'min_width': 640,
'min_height': 480,
'focus': true,
'show': false,
}, (pgadminWindow)=> {
@@ -232,19 +228,21 @@ function launchPgAdminWindow() {
// set up handler for new-win-policy event.
// Set the width and height for the new window.
pgadminWindow.on('new-win-policy', function(frame, url, policy) {
policy.setNewWindowManifest({
'icon': '../../assets/pgAdmin4.png',
'frame': true,
'width': winWidth,
'height': winHeight,
'position': 'center',
});
if(!frame) {
policy.setNewWindowManifest({
'id': 'pgadmin-tools',
'icon': '../../assets/pgAdmin4.png',
'frame': true,
'position': 'center',
'min_width': 640,
'min_height': 480,
'width': pgadminWindow.width,
'height': pgadminWindow.height,
});
}
});
pgadminWindow.on('loaded', function() {
// Hide the splash screen
splashWindow.hide();
/* Make the new window opener to null as it is
* nothing but a splash screen. We will have to make it null,
* so that open in new browser tab will work.
@@ -254,26 +252,9 @@ function launchPgAdminWindow() {
// Show new window
pgadminWindow.show();
pgadminWindow.focus();
});
pgadminWindow.on('resize', function(width, height) {
// Set the width and height for the new window on resize.
pgadminWindow.on('new-win-policy', function(frame, url, policy) {
policy.setNewWindowManifest({
'icon': '../../assets/pgAdmin4.png',
'frame': true,
'width': width,
'height': height,
'position': 'center',
});
});
// No need to write setting in case of full screen
if (!pgadminWindow.isFullscreen) {
misc.ConfigureStore.set('windowWidth', width);
misc.ConfigureStore.set('windowHeight', height);
misc.ConfigureStore.saveConfig();
}
// Hide the splash screen
splashWindow.hide();
});
pgadminWindow.on('blur', function() {