mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-06 23:36:58 +02:00
WIP
This commit is contained in:
@@ -164,10 +164,10 @@ SysTrayX.Messaging = {
|
||||
newFilters.push(SysTrayX.Messaging.filters[i]);
|
||||
} else {
|
||||
if (SysTrayX.Info.browserInfo.majorVersion < 115) {
|
||||
if (SysTrayX.Messaging.new[id] != undefined) {
|
||||
if (SysTrayX.Messaging.new[id] !== undefined) {
|
||||
delete SysTrayX.Messaging.new[id];
|
||||
}
|
||||
if (SysTrayX.Messaging.unread[id] != undefined) {
|
||||
if (SysTrayX.Messaging.unread[id] !== undefined) {
|
||||
delete SysTrayX.Messaging.unread[id];
|
||||
}
|
||||
}
|
||||
@@ -362,7 +362,7 @@ SysTrayX.Messaging = {
|
||||
|
||||
const window = await browser.windows.getCurrent();
|
||||
|
||||
console.debug("onCloseButton2 Window: " + JSON.stringify( window ) );
|
||||
console.debug("onCloseButton Window: " + JSON.stringify( window ) );
|
||||
|
||||
if( window.id === SysTrayX.mainWindowId ) {
|
||||
SysTrayX.Link.postSysTrayXMessage({ window: "minimized_all" });
|
||||
@@ -1081,15 +1081,18 @@ async function start() {
|
||||
|
||||
|
||||
// Get the window id
|
||||
const id = browser.windowHandler.getWindowId(SysTrayX.mainWindowId);
|
||||
const id = await browser.windowHandler.getWindowId( Number( SysTrayX.mainWindowId ) );
|
||||
|
||||
console.debug("Main window real ID: " + id);
|
||||
|
||||
|
||||
|
||||
// Get the close type
|
||||
// Set the close type
|
||||
browser.windowEvent2.setCloseType( Number( SysTrayX.Messaging.closeType ) );
|
||||
|
||||
// Set the main window id
|
||||
browser.windowEvent2.setMainWindowId( Number( SysTrayX.mainWindowId ) );
|
||||
|
||||
// Intercept close button?
|
||||
if (SysTrayX.Messaging.closeType !== "0") {
|
||||
// Intercept new window
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
this.closeType = this.MESSAGE_CLOSE_TYPE_DEFAULT;
|
||||
this.oldClose = undefined;
|
||||
this.mainWindowId = 0;
|
||||
}
|
||||
|
||||
get listenerIdNewWindow() {
|
||||
@@ -66,6 +67,10 @@
|
||||
this.closeType = this.MESSAGE_CLOSE_TYPE_MIN_ALL;
|
||||
} else console.log("Unknown close type: " + closeType);
|
||||
}
|
||||
|
||||
setMainWindowId(id) {
|
||||
this.mainWindowId = id;
|
||||
}
|
||||
|
||||
addOnNewWindow( callback ) {
|
||||
// Registering the callback for "new-window".
|
||||
@@ -110,6 +115,18 @@
|
||||
onCloseButton( event ) {
|
||||
if ( event ) event.preventDefault();
|
||||
windowListener.emit( "close-clicked" );
|
||||
|
||||
console.log("Close clicked");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
onCloseMenu( event ) {
|
||||
if ( event ) event.preventDefault();
|
||||
windowListener.emit( "close-clicked" );
|
||||
|
||||
console.log("Close menu");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,43 +142,25 @@
|
||||
"chrome://messenger/content/messenger.xul",
|
||||
],
|
||||
onLoadWindow: function ( window ) {
|
||||
if( this.closeType !== )
|
||||
|
||||
|
||||
window.addEventListener(
|
||||
"close",
|
||||
windowListener.onCloseButton,
|
||||
true
|
||||
);
|
||||
|
||||
windowListener.oldClose = window.close;
|
||||
window.close = () => windowListener.onCloseButton( null );
|
||||
|
||||
// console.debug("Window: " + JSON.stringify(window));
|
||||
|
||||
/*
|
||||
console.debug( "Window id1: " + window.id );
|
||||
console.debug( "Window id1: " + window.windowId );
|
||||
|
||||
let windowId2 = getInnerWindowID(window);
|
||||
console.debug( "Window id2: " + windowId2 );
|
||||
|
||||
// Get a real window from a window ID:
|
||||
let windowObject = context.extension.windowManager.get(windowId2);
|
||||
// let windowObject = context.extension.windowManager.get(windowId);
|
||||
let realWindow = windowObject.window;
|
||||
|
||||
console.debug( "WinObj: " + JSON.stringify( windowObject ) );
|
||||
// windowListener.oldClose = window.close;
|
||||
// window.close = () => windowListener.onCloseMenu();
|
||||
|
||||
// Get a window ID from a real window:
|
||||
const id = context.extension.windowManager.getWrapper(realWindow).id;
|
||||
let id = context.extension.windowManager.getWrapper(window).id;
|
||||
|
||||
console.debug( "WinObj Real: " + id );
|
||||
|
||||
// Get all windows: (note this returns a Generator, not an array like the API)
|
||||
// context.extension.windowManager.getAll();
|
||||
console.log( "Close listener mid:" + windowListener.mainWindowId);
|
||||
console.log( "Close listener id:" + id);
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
console.log( "Close listener added" );
|
||||
},
|
||||
});
|
||||
@@ -185,7 +184,9 @@ console.debug( "Window id1: " + window.windowId );
|
||||
true
|
||||
);
|
||||
|
||||
window.close = windowListener.oldClose;
|
||||
if ( windowListener.oldClose != undefined ) {
|
||||
window.close = windowListener.oldClose;
|
||||
}
|
||||
|
||||
console.log( "Close listener removed" );
|
||||
}
|
||||
@@ -218,6 +219,10 @@ console.debug( "Window id1: " + window.windowId );
|
||||
windowListener.setCloseType(type);
|
||||
},
|
||||
|
||||
setMainWindowId: async function (id) {
|
||||
windowListener.setMainWindowId(id);
|
||||
},
|
||||
|
||||
// An event. Most of this is boilerplate you don't need to worry about, just copy it.
|
||||
onNewWindow: new ExtensionCommon.EventManager({
|
||||
context,
|
||||
|
||||
@@ -67,6 +67,14 @@
|
||||
let windowObject = context.extension.windowManager.get(windowId);
|
||||
let realWindow = windowObject.window;
|
||||
|
||||
// Get all windows: (note this returns a Generator, not an array like the API)
|
||||
let allWindowObjects = await context.extension.windowManager.getAll();
|
||||
|
||||
for( wo in allWindowObjects ) {
|
||||
console.debug("Window: " + JSON.stringify( context.extension.windowManager.getWrapper(wo.window).id) );
|
||||
}
|
||||
|
||||
|
||||
// Get a window ID from a real window:
|
||||
let id = context.extension.windowManager.getWrapper(realWindow).id;
|
||||
|
||||
|
||||
@@ -15,6 +15,18 @@
|
||||
"maximum": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "setMainWindowId",
|
||||
"type": "function",
|
||||
"description": "Set the main window id.",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "type"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
|
||||
@@ -7,7 +7,12 @@
|
||||
"type": "function",
|
||||
"description": "Get the window Id",
|
||||
"async": true,
|
||||
"parameters": []
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "type"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user