2

I am trying to fetch all events (maximized, maximize etc). I have a suitable code for this from this link How to Detect Window On Minimize/Maximize Event in Chrome Extension?.

The problem is when I open the context menu (right click) and then left click on the window it is firing with windowId = -1, but it is focused on the window. It shouldn't fire with windowId = -1. So I couldn't find the exact minimize/maximize event after opening context-menu.

My code is :

chrome.windows.onFocusChanged.addListener(function(windowId) {
    if (windowId === -1) {
         // Assume minimized
         console.log("minimized",windowId);
    } else {
        chrome.windows.get(windowId, function(chromeWindow) {
            if (chromeWindow.state === "minimized") {
                console.log("minimized");
            } else {
                console.log("maximized");
            }
        });
    }
});

Please help me in this,thank you.

Community
  • 1
  • 1
Sourav Mondal
  • 405
  • 2
  • 12

0 Answers0