apandhi / Autumn

A macOS window manager for JavaScript hackers
GNU General Public License v3.0
340 stars 10 forks source link

Focus is not bringing the window to the front #6

Open felipethome opened 4 years ago

felipethome commented 4 years ago

When trying to focus a specific window with a Hotkey the window is not being brought to the front. It stays behind other windows. Is this the expected behavior?

And isFocused is being interpreted in the IDE as a property instead of a method.

apandhi commented 4 years ago

Can you share a quick snippet that demonstrations the issue?

felipethome commented 4 years ago

Sure! Maybe it is my lack of understanding of the API, sorry if that is the case:

Hotkey.activate(['command', 'option', 'control'], '1', () => {
  const mainScreen = Screen.allScreens().find((s) => s.id === 69733248);

  const mainChromeWindow = mainScreen.allWindows()
    .find((w) => w.app.name === 'Google Chrome');

  console.log('focus main chrome');

  if (mainChromeWindow) {
    mainChromeWindow.focus();
  }
});

I can see the console.log is executed, but the window is not brought to the front.

felipethome commented 4 years ago

MacOS 10.14.4

in mov

tobiastom commented 4 years ago

I have the same issue with this snippet:

for (const direction of ['left', 'right', 'up', 'down']) {
  Hotkey.activate(['command', 'control'], direction, () => {
    const focusedWindow = Window.focusedWindow();
    if (focusedWindow) {
      const windowsInDirection = focusedWindow.windowsInDirection(direction);
      if (windowsInDirection[0]) {
        console.log(direction, windowsInDirection[0].title());
        windowsInDirection[0].focus()
      }
    }
  });  
}

The name and the direction is displayed inside the console correctly, but the windows do not get the focus.