/*
* Predefines
@@ -216,6 +218,11 @@ class WindowCtrlUnix : public QObject
*/
QList< quint64 > getWinIds();
+ /**
+ * @brief updatePositions. Update the window positions.
+ */
+ void updatePositions();
+
/**
* @brief minimizeWindow. Minimize window.
*
@@ -246,6 +253,13 @@ class WindowCtrlUnix : public QObject
*/
void deleteWindow( quint64 window );
+ /**
+ * @brief setPositions. Set the startup positions.
+ *
+ * @param window_positions The window positions list.
+ */
+ void setPositions( QList< QPoint > window_positions );
+
private:
/**
@@ -329,6 +343,16 @@ class WindowCtrlUnix : public QObject
*/
QStringList atomWindowType( Display* display, quint64 window );
+ /**
+ * @brief atomFrameExtents. Get the frame extents of the window.
+ *
+ * @param display The display
+ * @param window The window
+ *
+ * @return Type of the window.
+ */
+ QMargins atomFrameExtents( Display *display, quint64 window );
+
signals:
/**
@@ -338,6 +362,13 @@ class WindowCtrlUnix : public QObject
*/
void signalConsole( QString message );
+ /**
+ * @brief signalPosition. Signal the new window position.
+ *
+ * @param position
+ */
+ void signalPositions( QList< QPoint > positions );
+
private:
/**
@@ -360,6 +391,11 @@ class WindowCtrlUnix : public QObject
*/
QList< quint64 > m_tb_windows;
+ /**
+ * @brief m_tb_windows_pos. The Thunderbird window positions.
+ */
+ QList< QPoint > m_tb_windows_pos;
+
/**
* @brief m_tb_window_states. The Thunderbird window states.
*/
diff --git a/app/SysTray-X/windowctrl.cpp b/app/SysTray-X/windowctrl.cpp
index 24e9cfb..fc9e999 100644
--- a/app/SysTray-X/windowctrl.cpp
+++ b/app/SysTray-X/windowctrl.cpp
@@ -164,10 +164,15 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
/*
* Minimize all?
*/
- if( state == Preferences::STATE_MINIMIZED_ALL )
+ if( state == Preferences::STATE_MINIMIZED_ALL || state == Preferences::STATE_MINIMIZED_ALL_STARTUP )
{
// emit signalConsole( QString( "Minimize all" ) );
+ if( state == Preferences::STATE_MINIMIZED_ALL )
+ {
+ updatePositions();
+ }
+
/*
* Close pressed on one of the windows, minimize them all
*/
@@ -207,7 +212,7 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
/*
* Minimize all?
*/
- if( state == Preferences::STATE_MINIMIZED_ALL )
+ if( state == Preferences::STATE_MINIMIZED_ALL || state == Preferences::STATE_MINIMIZED_ALL_STARTUP )
{
// emit signalConsole( QString( "Minimize all" ) );
@@ -247,6 +252,8 @@ void WindowCtrl::slotShowHide()
for( int i = 0 ; i < win_ids.length() ; ++i )
{
+ updatePositions();
+
if( win_states.at( i ) == Preferences::STATE_MINIMIZED )
{
// emit signalConsole( QString( "Show %1" ).arg( win_ids.at( i ) ) );
@@ -289,3 +296,16 @@ void WindowCtrl::slotClose()
deleteWindow( win_ids.at( i ) );
}
}
+
+
+/*
+ * Handle the startup window posiions.
+ */
+void WindowCtrl::slotPositions( QList< QPoint > window_positions )
+{
+#ifdef Q_OS_UNIX
+
+ setPositions( window_positions );
+
+#endif
+}
diff --git a/app/SysTray-X/windowctrl.h b/app/SysTray-X/windowctrl.h
index 67b50f7..9c81eb4 100644
--- a/app/SysTray-X/windowctrl.h
+++ b/app/SysTray-X/windowctrl.h
@@ -98,6 +98,11 @@ class WindowCtrl : public QObject
*/
void slotClose();
+ /**
+ * @brief slotPositions. Slot for handling of the startup window posiions.
+ */
+ void slotPositions( QList< QPoint > window_positions );
+
private:
/**
diff --git a/webext/_locales/de/messages.json b/webext/_locales/de/messages.json
index b226d9d..bbef320 100644
--- a/webext/_locales/de/messages.json
+++ b/webext/_locales/de/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Fensterpositionen wiederherstellen beim Start",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Symbole",
"description": "Title for Icons options"
diff --git a/webext/_locales/el/messages.json b/webext/_locales/el/messages.json
index b462be5..ae76469 100644
--- a/webext/_locales/el/messages.json
+++ b/webext/_locales/el/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Επαναφορά θέσεων παραθύρου κατά την εκκίνηση",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Εικονίδια",
"description": "Title for Icons options"
diff --git a/webext/_locales/en-US/messages.json b/webext/_locales/en-US/messages.json
index e43ac7d..1bf8803 100644
--- a/webext/_locales/en-US/messages.json
+++ b/webext/_locales/en-US/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Restore window positions on startup",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Icons",
"description": "Title for Icons options"
@@ -233,22 +238,22 @@
"message": "SysTray-X Companion App by Ximi1970",
"description": "Line 1"
},
-
+
"about_version": {
"message": "Version:",
"description": "Version"
},
-
+
"about_build": {
"message": "Build:",
"description": "Build"
},
-
+
"about_hash": {
"message": "Hash:",
"description": "Hash"
},
-
+
"about_branch": {
"message": "Branch:",
"description": "Branch"
@@ -303,12 +308,12 @@
"message": "Close",
"description": "Close button"
},
-
+
"mail_notification_icon": {
"message": "Mail notification icon",
"description": "Mail icon selection title"
},
-
+
"number_properties": {
"message": "Number properties",
"description": "Number properties title"
@@ -318,17 +323,17 @@
"message": "Open image",
"description": "File image dialog"
},
-
+
"image_files": {
"message": "Image Files (*.png *.jpg *.bmp)",
"description": "File image selection"
},
-
+
"image_save": {
"message": "Save",
"description": "File image save"
},
-
+
"image_cancel": {
"message": "Cancel",
"description": "File image cancel"
diff --git a/webext/_locales/it/messages.json b/webext/_locales/it/messages.json
index 625fb76..2924336 100644
--- a/webext/_locales/it/messages.json
+++ b/webext/_locales/it/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Ripristina le posizioni della finestra all'avvio",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Icona",
"description": "Title for Icons options"
diff --git a/webext/_locales/nl/messages.json b/webext/_locales/nl/messages.json
index 81a54b7..5c02b33 100644
--- a/webext/_locales/nl/messages.json
+++ b/webext/_locales/nl/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Herstel vensterposities bij opstarten",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Pictogrammen",
"description": "Title for Icons options"
diff --git a/webext/_locales/pt-BR/messages.json b/webext/_locales/pt-BR/messages.json
index 2a77190..9fcb25f 100644
--- a/webext/_locales/pt-BR/messages.json
+++ b/webext/_locales/pt-BR/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Restaurar posições da janela na inicialização",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Ícones",
"description": "Title for Icons options"
diff --git a/webext/_locales/ru/messages.json b/webext/_locales/ru/messages.json
index 0922822..6523aa9 100644
--- a/webext/_locales/ru/messages.json
+++ b/webext/_locales/ru/messages.json
@@ -99,6 +99,11 @@
"description": "Start minimized"
},
+ "restore_positions_on_startup": {
+ "message": "Восстановить положение окон при запуске",
+ "description": "Restore the window positions on startup"
+ },
+
"icons": {
"message": "Иконка",
"description": "Title for Icons options"
diff --git a/webext/background.js b/webext/background.js
index 9dca769..b3b8588 100644
--- a/webext/background.js
+++ b/webext/background.js
@@ -3,6 +3,9 @@ var SysTrayX = {
startupState: undefined,
+ restorePositions: false,
+ startupWindowPositions: [],
+
hideDefaultIcon: false,
platformInfo: undefined,
@@ -22,7 +25,14 @@ SysTrayX.Messaging = {
init: function () {
// Minimuze on startup handled by Companion app as backup
if (SysTrayX.startupState == "minimized") {
- SysTrayX.Link.postSysTrayXMessage({ window: "minimized_all" });
+ SysTrayX.Link.postSysTrayXMessage({ window: "minimized_all_startup" });
+ }
+
+ // Send the startup positions?
+ if (SysTrayX.restorePositions) {
+ SysTrayX.Link.postSysTrayXMessage({
+ positions: SysTrayX.startupWindowPositions,
+ });
}
// Lookout for storage changes
@@ -393,6 +403,15 @@ SysTrayX.Link = {
});
}
+ const positions = response["positions"];
+ if (positions) {
+ console.debug("Positions" + JSON.stringify(positions));
+
+ browser.storage.sync.set({
+ windowPositions: positions,
+ });
+ }
+
if (response["preferences"]) {
// Store the preferences from the app
const defaultIconMime = response["preferences"].defaultIconMime;
@@ -523,6 +542,16 @@ async function start() {
SysTrayX.startupState = state;
+ // Restore window positions
+ const restorePositions = await getRestorePositionsState();
+
+ if (restorePositions == "true") {
+ SysTrayX.restorePositions = true;
+
+ // Get the start window positions
+ SysTrayX.startupWindowPositions = await getStartupWindowPositions();
+ }
+
// Get the close type
SysTrayX.Messaging.closeType = await getCloseType();
browser.windowEvent.setCloseType(Number(SysTrayX.Messaging.closeType));
diff --git a/webext/js/defaults.js b/webext/js/defaults.js
index 01bad9e..d94b998 100644
--- a/webext/js/defaults.js
+++ b/webext/js/defaults.js
@@ -113,7 +113,7 @@ async function getIcon() {
// Get window startup state
//
async function getStartupState() {
- function getStartupState(result) {
+ function getStartupStateCb(result) {
const startMinimized = result.startMinimized || "false";
return startMinimized === "true" ? "minimized" : "normal";
}
@@ -123,7 +123,47 @@ async function getStartupState() {
}
const getState = browser.storage.sync.get("startMinimized");
- return await getState.then(getStartupState, onStartupStateError);
+ return await getState.then(getStartupStateCb, onStartupStateError);
+}
+
+//
+// Get window restore position state
+//
+async function getRestorePositionsState() {
+ function getRestorePositionsStateCb(result) {
+ const restorePositions = result.restorePositions || "false";
+ return restorePositions;
+ }
+
+ function onRestorePositionsStateError() {
+ return "false";
+ }
+
+ const getState = browser.storage.sync.get("restorePositions");
+ return await getState.then(
+ getRestorePositionsStateCb,
+ onRestorePositionsStateError
+ );
+}
+
+//
+// Get window startup window positions
+//
+async function getStartupWindowPositions() {
+ function getStartupWindowPositionsCb(result) {
+ const windowPositions = result.windowPositions || [];
+ return windowPositions;
+ }
+
+ function onStartupWindowPositionsError() {
+ return [];
+ }
+
+ const getWindowPositions = browser.storage.sync.get("windowPositions");
+ return await getWindowPositions.then(
+ getStartupWindowPositionsCb,
+ onStartupWindowPositionsError
+ );
}
//
diff --git a/webext/options.html b/webext/options.html
index d465123..b5a5665 100644
--- a/webext/options.html
+++ b/webext/options.html
@@ -101,6 +101,17 @@
>__MSG_windows_start_min__
+
+
+
+
diff --git a/webext/options.js b/webext/options.js
index 28f2143..61e4b1d 100644
--- a/webext/options.js
+++ b/webext/options.js
@@ -86,6 +86,16 @@ SysTrayX.SaveOptions = {
startMinimized: `${startMinimized}`,
});
+ //
+ // Save restore window positions state
+ //
+ const restorePositions = document.querySelector(
+ 'input[name="restorePositions"]'
+ ).checked;
+ browser.storage.sync.set({
+ restorePositions: `${restorePositions}`,
+ });
+
//
// Save default icon preferences
//
@@ -197,10 +207,7 @@ SysTrayX.RestoreOptions = {
//
// Restore minimize type
//
- const getMinimizeType = browser.storage.sync.get([
- "platformInfo",
- "minimizeType",
- ]);
+ const getMinimizeType = browser.storage.sync.get("minimizeType");
getMinimizeType.then(
SysTrayX.RestoreOptions.setMinimizeType,
SysTrayX.RestoreOptions.onMinimizeTypeError
@@ -224,6 +231,18 @@ SysTrayX.RestoreOptions = {
SysTrayX.RestoreOptions.onStartMinimizedError
);
+ //
+ // Restore restore position state
+ //
+ const getRestorePositions = browser.storage.sync.get([
+ "platformInfo",
+ "restorePositions",
+ ]);
+ getRestorePositions.then(
+ SysTrayX.RestoreOptions.setRestorePositions,
+ SysTrayX.RestoreOptions.onRestorePositionsError
+ );
+
//
// Restore default icon type
//
@@ -339,7 +358,7 @@ SysTrayX.RestoreOptions = {
// Restore minimize type callbacks
//
setMinimizeType: function (result) {
- const platformInfo = result.platformInfo || { os: "linux" };
+ // const platformInfo = result.platformInfo || { os: "linux" };
const minimizeType = result.minimizeType || "1";
// Tweak option for platform
@@ -382,7 +401,7 @@ SysTrayX.RestoreOptions = {
},
//
- // Restore hide on minimize callbacks
+ // Restore start minimized callbacks
//
setStartMinimized: function (result) {
const startMinimized = result.startMinimized || "false";
@@ -395,6 +414,31 @@ SysTrayX.RestoreOptions = {
console.log(`startMinimized Error: ${error}`);
},
+ //
+ // Restore restore position state callbacks
+ //
+ setRestorePositions: function (result) {
+ const platformInfo = result.platformInfo || { os: "linux" };
+ const restorePositions = result.restorePositions || "false";
+
+ // Tweak option for platform
+ if (platformInfo.os === "win") {
+ document
+ .getElementById("restorePos")
+ .setAttribute("style", "display:none;");
+ document
+ .getElementById("restorePositionsLabel")
+ .setAttribute("style", "display:none;");
+ }
+
+ const checkbox = document.querySelector(`input[name="restorePositions"]`);
+ checkbox.checked = restorePositions === "true";
+ },
+
+ onRestorePositionsError: function (error) {
+ console.log(`RestorePositions Error: ${error}`);
+ },
+
//
// Restore icon type callbacks
//
@@ -767,6 +811,11 @@ SysTrayX.StorageChanged = {
debug: changes[item].newValue,
});
}
+ if (item === "restorePositions") {
+ SysTrayX.RestoreOptions.setRestorePositions({
+ restorePositions: changes[item].newValue,
+ });
+ }
}
if (changed_icon) {