tmandry / Swindler

macOS window management library for Swift
https://tmandry.github.io/Swindler/docs/main/
MIT License
690 stars 66 forks source link

Mark writes that did not match the desired value as external events #49

Closed tmandry closed 5 years ago

tmandry commented 5 years ago

When a property is written, we read back the new value to observe what changed, and fire an event with external = false to denote that the change was triggered by our program.

This can cause problems when something is happening simultaneously (i.e. the user is dragging/resizing the window). If the value we read back is not what we wrote, we should mark the event as external and let the program deal with it.

Sometimes, what we read is not what we wrote because what we wrote is out-of-bounds (i.e. moving the window off the screen). In that case, we should still mark the event as external so the program can see that something external (in this case, the application or operating system) affected the value.

Would we lose anything here? Is it ever important to know that an event occurred during a write? Maybe (I can't think of a reason off the top of my head), but we can always add that flag to events later.