glfw icon indicating copy to clipboard operation
glfw copied to clipboard

Implement focus callback

Open meyerzinn opened this issue 6 years ago • 2 comments

Resolves #12.

This uses the browser's focus and blur events to implement the focus callback, which is informed when the browser window is in focus (active window) or not.

Depending on whether or not we want to consider multiple tabs as "all focused" or if each is focused individually, we may need to change the listener to attach to the document instead of the window. I have not explored browser functionality related to that.

meyerzinn avatar Apr 16 '18 15:04 meyerzinn

Just did some tests with:

window.addEventListener('focus', () => console.log('window focus'))
window.addEventListener('blur', () => console.log('window blur'))
document.addEventListener('focus', () => console.log('document focus'))
document.addEventListener('blur', () => console.log('document blur'))

The second two event handlers did not execute at all, which indicates to me that the former two are the correct mechanism for this to be implemented, as I have done in this PR.

meyerzinn avatar Apr 16 '18 15:04 meyerzinn

Thanks for the new PR. I'll able to test and review it about a week from now, sorry about the delay (busy time for me). Feel free to ping in case I forget.

dmitshur avatar Apr 16 '18 15:04 dmitshur

Thanks @meyerzinn. Merged as commit a8743c0d1829b17a0e654d08c6be66f46adf5144.

dmitshur avatar Jul 04 '23 04:07 dmitshur