   return unless browser = gBrowser.getBrowserForTab(tab)
   vimBucket.forget(browser.contentWindow)
 
+updateButton = (vim) ->
+  return unless rootWindow = utils.getRootWindow(vim.window)
+  updateToolbarButton(rootWindow, {blacklisted: vim.blacklisted, insertMode: vim.mode == 'insert'})
+
 # The following listeners are installed on every top level Chrome window
 windowsListeners =
   keydown:     keyListener

  TabSelect: (event) ->
    return unless window = event.originalTarget?.linkedBrowser?.contentDocument?.defaultView
    return unless vim = vimBucket.get(window)
    return unless rootWindow = utils.getRootWindow(window)
    updateToolbarButton(rootWindow, {blacklisted: vim.blacklisted})

# This listener works on individual tabs within Chrome Window
tabsListener =

    if vim.mode == 'hints'
      vim.enterNormalMode()

    vim.blacklisted = utils.isBlacklisted(location.spec)
    updateButton(vim)

addEventListeners = (window) ->
  for name, listener of windowsListeners
