Skip to content

Added MacOS support for 3.0#29

Merged
SnosMe merged 3 commits intoSnosMe:masterfrom
hsource:macos
Dec 8, 2022
Merged

Added MacOS support for 3.0#29
SnosMe merged 3 commits intoSnosMe:masterfrom
hsource:macos

Conversation

@hsource
Copy link
Contributor

@hsource hsource commented Dec 8, 2022

Motivation

I wanted to get awakened_poe_trade working on Mac, and this was the biggest barrier, since no binaries existed for this on Mac.

PS: thanks a lot for the great demo app! I don't think developing this would've been possible without that

Fix

Created Mac interface for overlay_window.h - for the most part, this is structured similarly to the Windows/Linux code, with a few exceptions:

  1. Mac doesn't allow windows to be attached/reparented to those of other applications, so the overlay window has to stay within the separate app. To make this not look weird, we hide the window whenever the target window isn't on top
  2. Mac doesn't give a global way to listen to windows becoming the foreground window. We instead do 2 things:
    • Attach to the foreground window and detect when it gets deactivated or destroyed. When it does that, attach to the next foreground window
    • When attaching observers, we poll for 5 seconds since the observers seem to take a while to take effect

Side changes

  • Documented the general structure of the code a bit in DEVELOPING.md
  • Changed the example to work with TextEdit on Mac too and changed the keyboard shortcuts to not conflict with system shortcuts (Cmd + H on Mac is hide, Cmd + Q is quit app)

Testing

Tested by:

  1. Run yarn demo:electron
  2. Open an empty, untitled TextEdit window. If you need to change the sample window, edit attachByTitle in the electron-demo file to attach to a window with a different title

Tested

  • Getting permission
  • Blurring/focusing
  • Closing the app
  • Only opening the window after startup
  • Keyboard shortcuts

Resizing, focusing

Testing

Fullscreen

Screen.Recording.2021-05-28.at.3.13.07.AM.mp4

@hsource
Copy link
Contributor Author

hsource commented Dec 8, 2022

@SnosMe - would it be possible to just merge this in? That would save me the tedious work of having to rebase once in a while. You don't have to address the Mac bugs and can just @ me for them and I can take a look.

@hsource
Copy link
Contributor Author

hsource commented Dec 8, 2022

Here's a new recording of the latest test - note that it actually works on fullscreen too, but my screen recorder (liceCAP) is broken with it.

Retesting MacOS

@SnosMe SnosMe merged commit b220eb3 into SnosMe:master Dec 8, 2022
hsource added a commit to hsource/electron-overlay-window that referenced this pull request Dec 9, 2022
Per a comment in SnosMe#29 , this added line doesn't seem necessary, as the `this.events.on('focus'` handler should get called immediately after, which does the same thing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants