• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    sidebar windowId

    Opera add-ons
    2
    11
    2715
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kroppy
      kroppy last edited by

      Hey there 🙂 Sorry for late response, I will be here just for a moment since I have something to do, but I will be back in few hours 😛

      chrome.windows.getCurrent
      Yes I'm using this when sidebar opens, each sidebar gets this same windowId because this windowId is not the id where the sidebar is, it's from Chrome's API and unfortunately it's not related to sidebar's window. You can check it with my extension if you want.
      Open few windows with my extension, exit opera (using ctrl+Shift+x), or from menu->exit opera.
      Start Opera; In result you will get tabs from active window in all windows with sidebars, "cloned".

      Problem is here:
      "still, there is enough time for your code in every individually sidebar records it's parent window id."

      Where do I get that parent window id? There is no way to guess in which window sidebar is. It does not matter if window is active or not.
      onFocusChanged does not help me, correct tabs will be only in first focused window, since all sidebars do exactly the same code and all will think they are in focused window which is not true.
      I'm not sure if you get what I mean. There is no connection between chrome's API and sidebar's API...
      Only from here:
      opr.sidebarAction.onFocus.addListener
      or here
      opr.sidebarAction.onBlur.addListener
      Both are not good on Opera's start since there is no action from user.

      Reply Quote 0
        1 Reply Last reply
      • A Former User
        A Former User last edited by

        @kroppy
        well, let's try this way :wizard:

        I don't know how you did logic in your extension, this is example from my code

        this is for individual opening

        ...and this is when users starts with multiple windows

        every sidebar is aware of it's parent window :smurf:

        Reply Quote 0
          1 Reply Last reply
        • kroppy
          kroppy last edited by

          You made me scratch my head for hours here. But I found the problem.
          And it's not in my code.
          When I use:
          chrome.windows.getCurrent(function(window){alert(window.id);});

          All I get, are alerts with the same id.
          So I watched your video ten times, and noticed no difference between what I do.
          But after a while I realized that you use Opera dev!

          So I checked Dev 33 and baaaam!

          Problem f*cking solved!

          In opera dev 33, chrome.windows.getCurrent gives me frigging different ids !!!!!
          Now I know that problem is that in CURRENT STABLE version there is NO WAY to get current windowId, where the sidebar is! Check it out for yourself!
          The bug was just here, chrome.windows.getCurrent, returns ACTIVE windowId on startup.

          Cheers and thanks for your time
          :happy:

          Reply Quote 0
            1 Reply Last reply
          • A Former User
            A Former User last edited by

            I think your problem is in alert, try using console.log (it behaves differently, not good to test these things with alert)
            In my first video, I'm using stable.... didn't want to break work, so for second video i used developer
            on my side it works fine in stable just like in dev

            Reply Quote 0
              1 Reply Last reply
            • kroppy
              kroppy last edited by

              I did a little test with stable and all sidebars get this same windowId as active window. I have no doubt here.

              This seems to be fixed in dev 33 version, it looks like they finally linked current windowId with sidebar, so I'm not sure if it's worth a further investigation here, but I double checked it with opr.sidebarAction.onFocus.addListener with log inside.

              If you have a moment you can compare dev and stable and see the results for yourself.
              Paste that at the top of your sidebar's script:

              opr.sidebarAction.onFocus.addListener(function(window) {
              chrome.windows.getCurrent({populate:false}, function(current_win){
              console.log("You focused sidebar in window with id: "+window.id+" sidebar window id: "+current_win.id);
              });
              });

              In opera stable you will see that both ids are equal when focus is changed, in dev you will get correct id, where sidebar is and the one from focused window.

              I discovered that thanks to you, so I'm glad I checked dev, since it's been a while since I used it.
              :cheers:

              Reply Quote 0
                1 Reply Last reply
              • A Former User
                A Former User last edited by

                you don't need to use sidebarAction.onFocus
                it's new and probably buggy still (not ready for mac yet, from docu)
                when you have onFocusChanged already for windows

                Reply Quote 0
                  1 Reply Last reply
                • kroppy
                  kroppy last edited by

                  "onFocusChanged" don't worry I'm not using it anyway, yes it gives this same, but on click and it's not buggy, it works perfectly (at least on pc). I only pointed out that chrome.windows.getCurrent will give you different windowId in dev and stable Opera. Which I'm after. I consider it as "solved" but only in dev version, hopefully it will work when Opera 33 hits stable. 🆙 :happy:

                  Reply Quote 0
                    1 Reply Last reply
                  • kroppy
                    kroppy last edited by

                    Opsss i copied and pasted "onFocusChanged" instead of "sidebarAction.onFocus" in my previous post. Can't edit since I went to eat, and now it's too late 😛

                    Reply Quote 0
                      1 Reply Last reply
                    • A Former User
                      A Former User last edited by

                      uhmmm...btw, current window is window in which code is currently executing...so not necessarily focused one...
                      why there is different behavior between dev and stable, I'm not sure...
                      maybe Stable is doing some more actions when switching between windows... so getCurrent is fired while some process are still hooked on stable

                      Reply Quote 0
                        1 Reply Last reply
                      • kroppy
                        kroppy last edited by

                        I'm asking myself why that happens... In chrome there was no way to tell since all extensions where just in a popup (or a separate popup window), so active window was usually the current one, so maybe it's a recent fix in chromium 46, but I can't tell if that is the case. Or maybe just a bug in Opera. 😕

                        Reply Quote 0
                          1 Reply Last reply
                        • First post
                          Last post

                        Computer browsers

                        • Opera for Windows
                        • Opera for Mac
                        • Opera for Linux
                        • Opera beta version
                        • Opera USB

                        Mobile browsers

                        • Opera for Android
                        • Opera Mini
                        • Opera Touch
                        • Opera for basic phones

                        • Add-ons
                        • Opera account
                        • Wallpapers
                        • Opera Ads

                        • Help & support
                        • Opera blogs
                        • Opera forums
                        • Dev.Opera

                        • Security
                        • Privacy
                        • Cookies Policy
                        • EULA
                        • Terms of Service

                        • About Opera
                        • Press info
                        • Jobs
                        • Investors
                        • Become a partner
                        • Contact us

                        Follow Opera

                        • Opera - Facebook
                        • Opera - Twitter
                        • Opera - YouTube
                        • Opera - LinkedIn
                        • Opera - Instagram

                        © Opera Software 1995-