Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: BrowserWindow: isFocused() returns true even after calling blur() on macOS #33732

Closed
3 tasks done
RaisinTen opened this issue Apr 12, 2022 · 2 comments · Fixed by #33734
Closed
3 tasks done

[Bug]: BrowserWindow: isFocused() returns true even after calling blur() on macOS #33732

RaisinTen opened this issue Apr 12, 2022 · 2 comments · Fixed by #33734

Comments

@RaisinTen
Copy link
Member

RaisinTen commented Apr 12, 2022

Preflight Checklist

Electron Version

18.0.3

What operating system are you using?

macOS

Operating System Version

macOS Monterey 12.2.1

What arch are you using?

x64

Last Known Working Electron version

Unknown, reproduces back to v14.

Expected Behavior

isFocused() should return false after blur() has been called on it.

Actual Behavior

It returns true instead, hence the assertion error:

$ npm test

> electron@1.0.0 test
> electron test.js

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

true !== false

    at /Users/raisinten/Desktop/temp/project/electron/test.js:10:3 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: true,
  expected: false,
  operator: 'strictEqual'
}
$ echo $?
1

Testcase Gist URL

https://gist.github.com/RaisinTen/245976064623786f2276dd89d2df0185

Additional Information

No response

@RaisinTen RaisinTen changed the title [Bug]: isFocused() returns true even after calling blur() on macOS [Bug]: BrowserWindow: isFocused() returns true even after calling blur() on macOS Apr 12, 2022
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 12, 2022
The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
@RaisinTen
Copy link
Member Author

PR: #33734

RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 12, 2022
The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 12, 2022
The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 12, 2022
The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
@RaisinTen
Copy link
Member Author

FYI, this was also reported in #20464 (comment).

RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 13, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 14, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 14, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately doesn't work well with
focus() and blur() because these weren't calling any macOS APIs that
would change the key status of the window. Hence, this changes the
implementation of blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 14, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 14, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 14, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 26, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue Apr 26, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue May 2, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen added a commit to RaisinTen/electron that referenced this issue May 3, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
zcbenz pushed a commit that referenced this issue May 3, 2022
…d on macOS (#33734)

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
trop bot pushed a commit that referenced this issue May 3, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
trop bot pushed a commit that referenced this issue May 3, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
trop bot pushed a commit that referenced this issue May 3, 2022
…d on macOS

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
MarshallOfSound pushed a commit that referenced this issue May 4, 2022
…d on macOS (#34031)

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>

Co-authored-by: Darshan Sen <raisinten@gmail.com>
MarshallOfSound pushed a commit that referenced this issue May 4, 2022
…d on macOS (#34030)

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>

Co-authored-by: Darshan Sen <raisinten@gmail.com>
MarshallOfSound pushed a commit that referenced this issue May 4, 2022
…d on macOS (#34029)

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: #33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>

Co-authored-by: Darshan Sen <raisinten@gmail.com>
khalwa pushed a commit to solarwindscloud/electron that referenced this issue Feb 22, 2023
…d on macOS (electron#33734)

The isFocused() method on macOS works by checking if the selected
BrowserWindow is a key window. Unfortunately, this didn't work well
with blur() because it wasn't calling any macOS APIs that would change
the key status of the window. Hence, this changes the implementation of
blur() to call orderOut first, which removes the key
status of the window. Then when the orderBack function is called, it
moves the window to the back of its level in the screen list, without
changing the key window.

Fixes: electron#33732
Signed-off-by: Darshan Sen <raisinten@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants