electron: Windows: WorkArea property not updated
- Electron version: 1.x and above
- Operating system: Windows 10
I was previously using version 0.37.3 for my application and tried to upgrade to 1.0 but this caused the WorkArea property of screen to not get updated to desktop WorkArea changes while the application is running.
For example. My resolution is 2560 * 1440 so if the taskbar is located at the bottom of the desktop the WorkArea property will look like { x: 0, y: 40, width: 2560, height: 1400 }
(indicating the taskbar is 40pixels heigh and located at the bottom). If I locate the taskbar area to left instead the property will be { x: 82, y: 0, width: 2478, height: 1440 }
indicating the taskbar is located to the left. In version 0.37.3 I could use this logic to perfectly place the application over the tray icon depending on the taskbar location.
With newer Electron version the WorkArea property never changes. It’s always returns the values according to what the WorkArea are when the application started. So if I start my application with the taskbar located at the bottom the WorkArea property will always be { x: 0, y: 40, width: 2560, height: 1400 }
even if the taskbar is changed to be located to the left. If I restart the application the property gets updated to show that the taskbar is now to the left ({ x: 82, y: 0, width: 2478, height: 1440 }
).
The display-metrics-changed
event of screen doesn’t respond to taskbar changes either.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 20 (4 by maintainers)
The PR was merged into Chromium last night: https://codereview.chromium.org/2829693003/ note this is a Windows-only fix.
It looks like Chromium does not track changes to screen work areas properly, and returns the stale values still to Electron. I opened a Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=712871
and have submitted a PR for a fix that solves the problem for me: https://codereview.chromium.org/2829693003
@z-ax I looked around but was unable to find a related Chromium issue either. I’m surprised this has been an issue for 5 months without something ticketed on their side… Is there someone with more knowledge of Electron’s interface with Chromium that could file an issue related to this and get more visibility on this?
Checked with v1.3.0 - still an issue.
@llhupp Agree, haven’t found any Chromium issue and sadly don’t know the details of Electron APIs good enough to write a proper issue.
@zcbenz Can you write a Chromium issue or link to existing one for this?
@Ciantic Thanks! This is what I was thinking of doing as well. Given up hope that this will be solved any time soon and can’t upgrade Electron until this has been fixed. The only missing part is to know when to get the new params (like display changes). I think there was an issue with WorkArea changes not being notified about as well. But for me this should be enough so thanks.
Here is the code to get it using Node-FFI, using WinAPI crap, it’s ugly as hell.
Note3 I think the X, Y, are now correct, however I think there is some flakiness with below method:
Is there an issue in Chromium for this regression? Didn’t find.