Navigation Menu

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

Windows: display-removed event not working #3075

Closed
delvedor opened this issue Oct 13, 2015 · 16 comments
Closed

Windows: display-removed event not working #3075

delvedor opened this issue Oct 13, 2015 · 16 comments

Comments

@delvedor
Copy link

Hi all, I'm trying to use the display-removed event in my electron app, but while under OSX 10.10 all works correctly, under Windows 7 the event is not detected/emitted.

This is my code:

let electronScreen = require('screen');
electronScreen.on('display-removed', () => {
  console.log('display removed');
});

The event display-added works correctly.

I'm using Electron 0.33.7.

@ervwalter
Copy link

I can confirm a similar problem that is probably related. In my case, not only is the event not working, but the array returned by getAllDisplays() still contains the old entry after a display is removed. Seems likely that the two symptoms are related.

@imzc
Copy link

imzc commented Oct 30, 2015

I have same issue as @delvedor and @ervwalter on windows, 0.29.2 and 0.34.1

@ervwalter
Copy link

Also, the reason this is important to me is that when you remote desktop into a windows machine that normally has multiple monitors, the displays change to a new virtual display (and then they switch back to the physical displays when you log in at the physical machine later). During that remote desktop session, the display information returned by the screen module is wrong.

So it's not just an issue when you actually physically remove displays (which I would assume is a fairly rare occurrence). It's much more common in enterprise environments for people to be remoting into their desktop machine.

@raleksandar
Copy link

I can also confirm that only display-added event is fired on Windows (Windows 10 Pro Insider Preview build 10576 at least).

Both display-removed and display-metrics-changed are never emitted (I've tested by plugging in/out monitors and changing resolution).

Tested with 0.34.2 Electron build

@lbonnet
Copy link

lbonnet commented Nov 16, 2015

Confirmed on windows 7, electron 0.29.2

@michaeljonsampson
Copy link

Confirming this issue for windows 8.1 and windows 10. Tested on 0.36.3 and 0.34.2.

@mradionov
Copy link

The same on Ubuntu 14.04 , electron 0.36.9.

@atietje
Copy link

atietje commented Apr 15, 2016

Will this issue be adressed in the near future?

No offense, but it was reported six month ago, and I currently fight screen rotation issues on a Windows 10 Tablet using Electron v0.37.4 …

@miniak
Copy link
Contributor

miniak commented Apr 28, 2016

Looks like the problem is that the ID is not persistent, the monitor is not found in the vector.

void Screen::OnDisplayRemoved(const gfx::Display& old_display) {
  auto iter = FindById(&displays_, old_display.id());
  if (iter == displays_.end())
    return;

  displays_.erase(iter);
  Emit("display-removed", old_display);
}

@miniak
Copy link
Contributor

miniak commented Apr 28, 2016

I think that also display-metrics-changed is not working properly due to this.

@delvedor
Copy link
Author

This issue/bug is very strange.
In addition to events, if you do this:

setInterval(() => {
  console.log(screen.getAllDisplays())
}, 1000)

And you try to change the monitor's resolution, you will see that the AllDisplays array will not change.
As temporary workaround I've made this module, but it gives only the AllDisplays array.

@miniak
Copy link
Contributor

miniak commented Apr 28, 2016

My PR should fix that too

@zcbenz zcbenz closed this as completed in 340b722 Apr 28, 2016
zcbenz added a commit that referenced this issue Apr 28, 2016
Fix #3075 by not caching the displays (id is not persistent on Windows)
davemackintosh pushed a commit to Floato/electron that referenced this issue May 31, 2016
@doot0
Copy link

doot0 commented Dec 7, 2016

These events still aren't fired on OSX Sierra, current electron version. Request to reopen.

@VladimirMerk
Copy link

The problem still exists in the electron 2.0.3 on ubuntu 16

@DanielMcAssey
Copy link

This problem still exists on 16.1.0

@oopses
Copy link

oopses commented Dec 15, 2023

This problem still exists on 24.5.1,Monitor hot plug does not trigger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests