Fixing infamous Windows multi-display behaviour (using custom WDDM driver?)

The problem:
Whenever user disconnects an external display from his laptop running Windows 10 it?s Extended Desktop collapses. And all it?s contents (application windows, desktop icons) are moved to laptop small display. This behavior is usually inconvenient. So our aim is to prevent any changes on laptop display whenever the external display is disconnected.
This topic has been a concern for a long time now (f.e. from Microsoft):
https://goo.gl/xPkgQ9
https://goo.gl/CAoXY4
and there is a solution: http://monitordetectkiller.com/. Though we think that it?s not acceptable and we?re looking for a programmatic approach.

Our thoughts on the problem:
Create a “virtual clone” (fake display) of external display, which will be a part of Extended Desktop. The real external display just mirrors that fake display, and whenever it gets disconnected, the mirroring just stops but the fake display remains, Extended Desktop stays unaffected, the coordinate grid of Virtual Screen is unchanged. Whenever necessary Virtual Display can be connected to any other real display and if it’s parameters are different, the picture would automatically adjust to that display resolution.
We?d like to avoid messing with PnP, because it may negatively affect the work of other devices.

The question of how effectively add a Fake Display to the system remains open, as we think this would be a most universal solution for this and similar tasks.
We can create a custom WDDM driver for this, but it sole purpose would be creating virtual clone of extended display. It will not be used to display image.

Questions:

  • Do we need a custom WDDM driver to create the Fake Display or are there any other more adequate methods to achieve this?
  • Is there a way to manually control the Virtual Screen coordinate grid?

Any competent advice will be highly appreciated.

xxxxx@outlook.com wrote:

The problem:
Whenever user disconnects an external display from his laptop running Windows 10 it?s Extended Desktop collapses. And all it?s contents (application windows, desktop icons) are moved to laptop small display. This behavior is usually inconvenient.

Why is it inconvenient?  You are making a number of HUGE assumptions
here that your standard operating procedure is the same as everyone’s. 
If I’m leaving the office and need to continue my work on the train, for
example, I need to have everything move to the laptop display.  And your
assumption that the laptop display is smaller than the monitor – at
least in terms of number of pixels – is certainly not universally
valid.  Most professional laptops have full HD displays.

That’s the key problem with the kind of hackery you are attempting. 
Windows has to satisfy every user in every circumstance.  You want
things to work YOUR way for YOUR circumstances, but you are not “every
user”.

I don’t see that there is any workable alternative other than the
current behavior.  When I lose a monitor, I need to be able to find ALL
of my applications and icons.  They only way to do that is to move them
to the monitors that remain.

So our aim is to prevent any changes on laptop display whenever the external display is disconnected.

And that would be a huge inconvenience in the case I mentioned, where I
need to continue working without an external monitor.

… Whenever necessary Virtual Display can be connected to any other real display and if it’s parameters are different, the picture would automatically adjust to that display resolution.

How would you do that?

Questions:

  • Do we need a custom WDDM driver to create the Fake Display or are there any other more adequate methods to achieve this?
  • Is there a way to manually control the Virtual Screen coordinate grid?

Well, you certainly have full control over the monitor layout. 
Everything that the Display control panel does can be adjusted
programmatically with APIs like EnumDisplaySettingsEx and
ChangeDisplaySettingsEx.  Assuming you had a fake monitor, you could set
it to echo the external monitors, but you’ll still end up in situations
where windows and icons are lost.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you for your opinion.

You work with large applications on a large display and you need to go to a cafe and take your laptop with you to answer e-mail.
The number of windows and icons on the laptop after turning off big display will be superfluous. And to close unnecessary windows to open them in half an hour and organize them again - not OK.

I do not want to break the standard process. I want to make it manageable, and not just by the will of PnP.
The fake (software) display can be easily turned off by software.
Or set the mirror mode with the physical (laptop, 1|2). Switch it off when unnecessary.
And turn it on again, providing the laptop with a comfortable mobile mode.
This problem is easily removed programmatically.

When changing the display resolution, WINDOWS can independently organize icons/windows, which is not always convenient, but it works.
The location of the desktop elements can also be saved and restored when needed.
We will make the necessary settings.

You can safely continue to work with the laptop display and as a plus you will have 2 modes (mobile / desktop).
Ideally, it should display any virtual display image on any real. I already think more.

The only question is how do I make virtual displays without conflict and interference with the system.

> The only question is how do I make virtual displays without conflict and
interference with the system.

What if you combine that monitordetectkiller device with virtual desktops of Win10?

  1. Suppose you disconnected the external monitor and go to a cafe. Due to the device, the system did not noticed disconnection of the monitor, but now you cannot see any apps on it.

  2. So you open Task View, find the app window and move it into a new virtual desktop. Or click “show this on all desktops”.
    Switch to the new desktop and enjoy.

  3. Back to the desk, reconnect the monitor and switch to the main desktop.

Of course if you can make the monitordetectkiller thing in software, it would be nicer :wink:

– pa

Pavel,

Virtual Desktop absolutely quite different technology and concept rather Virtual Display (Fake Display). At virtual desktops you can only transfer running applications (windows).
Real Desktop infrastructure (icons, files, etc.) just cloned.
If you delete some icons/files on any of the virual desktop, they deleted from all Desktops (real/virtual).

And they have nothing to do with physical displays. This infrastructure of virtual desktops is again cloned from real desktop. With MonitorDetectKiller, they are also unrelated.

Monitordetectkiller basically cheats Windows PnP, which is not good at all. We’ll have to use another technology. Probably fake/virtual display to get the desired result and not depend on hardware.

Hi Igor,

Yes, your idea is more general - but won’t it be overkill for a simple task?
When user adds a new virtual desktop, icons on the missing external screen will be not accessible, yes. But user can open their desktop folder in explorer. Or add the Desktop toolbar to the taskbar.
It is just a matter of a (short) break; user won’t have time for a lot of apps and files.

By the way, thanks for the monitordetectkiller link. Just got a related project and this is an useful hint.

– pa

Hi Pavel,

Yes. If we solve the issue with Fake Display - in Virtual Desktops everything will be transferred automatically by the system.

If you are working with 2 physical displays - Windows will combine them into an Extended Desktop and create a common Virtual Screen grid coordinates.
https://goo.gl/pVEcfP
When the external diplay is disconnected, the grid is compressed to the remaining real display. All Desktop elements and running applications from the disconnected are transferred to the remaining ones. Creating a mess.

Our task in essence is to keep Extended Desktop/Virtual screen by software and not only by the will of hardware/PnP.

I have not yet found a variant other than Fake (virtual, software) Display.
The question is generally open.

I think you are in for a lot of work. You likely need to implement a
virtual “display only driver” for wddm to provide the phantom device to the
video present network stuff that underlies the user level display
management. It is still going to mostly suck though as your phantom device
has to be off when the real device is on and vice versa, so there is going
to be a whole lot of shuffling going on regardless. And it is win8+ only,
not win7. For win7 you have to provide both halves of the driver.

The only good news is that there is a more or less functional single
monitor source code sample from msft on github.

The hardware dongle that lies about presence seems like a better approach.

Mark Roddy

On Fri, Dec 15, 2017 at 5:05 AM, xxxxx@outlook.com
wrote:

> Hi Pavel,
>
> Yes. If we solve the issue with Fake Display - in Virtual Desktops
> everything will be transferred automatically by the system.
>
> If you are working with 2 physical displays - Windows will combine them
> into an Extended Desktop and create a common Virtual Screen grid
> coordinates.
> https://goo.gl/pVEcfP
> When the external diplay is disconnected, the grid is compressed to the
> remaining real display. All Desktop elements and running applications from
> the disconnected are transferred to the remaining ones. Creating a mess.
>
> Our task in essence is to keep Extended Desktop/Virtual screen by software
> and not only by the will of hardware/PnP.
>
> I have not yet found a variant other than Fake (virtual, software) Display.
> The question is generally open.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

Hi Mark,

I agree with you about a lot of work.

But if to take a pure technical essence of result all reduces to variation 2 bit information.
When you disconnect the external display, all information about it remains, only 2 bits of information change, Active: Yes/no ; Disconnected: yes/No .
In fact, this is exactly what the hardware dongle (MonitorDetectKiller) solution does.
The WDDM Driver here looks like to go from Los Angeles to San Francisco through Paris.

In a pure and universal form (not interfere with the Windows regular PnP) the solution looks like this:
Make a SOFTWARE CLONE of an existing external display (fake display), revive it and independently change its status (connected: Yes; active: Yes).

We can software disable the actual display (Active: No). And turn it on.
Consequently, there should be a possibility to software enable Fake Display.

It is necessary to determine the correct way of such solution. And to bypass without conflicts regular PnP.
Before to load itself and then user’s PC extra WDDM-driver.

p.s.
Only Windows 10, other versions do not think now.

This appears to be a an attempt to mimic the Mac OS 10 behavior of (mostly) remembering where windows are/were when external displays come and go.

That’s one of the most glaring omissions in the Windows 10 (and previous versions) Window Manager. I think there might be some alternate Window Managers for Windows that do this, but I haven’t researched it. I think that’s where the OP should look, rather than trying to fool the PnP subsystem.

@OP, Think (and search) Window Manager, not Displays.

Phil

Not speaking for LogRhythm

Philip D Barila
Senior Software Engineer
720.881.5364 (W) ?
LogRhythm.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-643378-
xxxxx@lists.osr.com] On Behalf Of xxxxx@outlook.com
Sent: Friday, December 15, 2017 1:32 PM
To: Windows System Software Devs Interest List
> Subject: RE:[ntdev] Fixing infamous Windows multi-display behaviour (using
> custom WDDM driver?)
>
> Hi Mark,
>
> I agree with you about a lot of work.
>
> But if to take a pure technical essence of result all reduces to variation
> 2 bit information.
> When you disconnect the external display, all information about it
> remains, only 2 bits of information change, Active: Yes/no ; Disconnected:
> yes/No .
> In fact, this is exactly what the hardware dongle (MonitorDetectKiller)
> solution does.
> The WDDM Driver here looks like to go from Los Angeles to San Francisco
> through Paris.
>
> In a pure and universal form (not interfere with the Windows regular PnP)
> the solution looks like this:
> Make a SOFTWARE CLONE of an existing external display (fake display),
> revive it and independently change its status (connected: Yes; active:
> Yes).
>
> We can software disable the actual display (Active: No). And turn it on.
> Consequently, there should be a possibility to software enable Fake
> Display.
>
> It is necessary to determine the correct way of such solution. And to
> bypass without conflicts regular PnP.
> Before to load itself and then user’s PC extra WDDM-driver.
>
> p.s.
> Only Windows 10, other versions do not think now.

Hi Phil,

Why cheat a working and generally useful system (PnP)?
Easier not to break a get around.

Window Manager is (mostly) independent of PnP. It’s a consumer of PnP notifications, but it doesn’t participate in any way. It’s just a UM process that launches processes, positions windows and sends messages to them.

Explorer.exe is the default, I’m not sure if it still calls it’s root window progman, but it’s not the only one.

Another generic name for the function is Windows Shell.

Phil

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-643390-
xxxxx@lists.osr.com] On Behalf Of xxxxx@outlook.com
Sent: Friday, December 15, 2017 4:04 PM
To: Windows System Software Devs Interest List
> Subject: RE:[ntdev] Fixing infamous Windows multi-display behaviour (using
> custom WDDM driver?)
>
> Hi Phil,
>
> Why cheat a working and generally useful system (PnP)?
> Easier not to break a get around.

xxxxx@outlook.com wrote:

But if to take a pure technical essence of result all reduces to variation 2 bit information.
When you disconnect the external display, all information about it remains, only 2 bits of information change, Active: Yes/no ; Disconnected: yes/No .

In a pure and universal form (not interfere with the Windows regular PnP) the solution looks like this:
Make a SOFTWARE CLONE of an existing external display (fake display), revive it and independently change its status (connected: Yes; active: Yes).

But that’s not the right model.  A mirror driver is all about getting an
extra copy of the raw pixels, with no knowledge of windows or icons. 
That’s not what you need.  You don’t really want to clone an existing
display, and you don’t care one bit about having an extra copy of the
pixels on that display.  All you care about is the state of the windows
and icons that live on that display.  You just want to put those windows
and icons into deep freeze somewhere, to be restored if and when the
monitor is restored.  That’s not a driver job.

Conceptually, what you want is very, very similar to third party virtual
desktop solution.   For the last 12 years, I have used a very slick
virtual desktop package called goScreen.  I have 9 virtual monitors,
with hotkeys to switch between them.  I can put apps and icons on any of
those 9 virtual monitors, but I only see the windows and taskbar icons
for the windows I launched on the current monitor.  It does that by
moving the windows to window coordinates way beyond the desktop edges,
and then somehow hiding the taskbar icons.

That’s really what you want.  When a physical monitor detaches, you want
the windows and taskbar icons to continue to live, but in hiding, in a
location where they can be restored later.  That can all be done with a
user-mode application, with no kernel programming required.  I suggest
you look at some virtual desktop solutions.  I believe there are several
in open source.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

I have not found such open source solution yet. Which allow you not to change anything on the laptop screen when you disconnect the external display (in Extended Desktop mode).
The closest thing to the task is the hardware solution:
http://monitordetectkiller.com/ That doesn’t look convenient for use.

Virtual desktops are an additional entity that not everyone needs. And designed to work with running applications and do not solve the problem with displays. Use that is currently defined in Windows. Also use system folder %userprofile%\Desktop for display of elements (icons, files, folders, etc).
There are exceptions, but they more likely amateur cheat. https://goo.gl/bj11z1

The term Freeze you picked very precisely to the task.
But it will have to be done within the standard interface and functionality.

We do not think of doing Mirror driver.
We think it is possible to make fake displays on the basis of actual external displays
\HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY* changing some parameters as MonitorID/DeviceID/EDID info/…
Not only in Registry, other ways are also searched.

Hi Phil,

Windows Shell theme is complicated. All attempts to make alternatives have not yielded results. The deepest approach to the theme was SharpEnviro ( https://goo.gl/UdMph9 ) but it is abandoned since 2011-2014.
We will not approach such questions. Stay within Explorer.exe (progman).

Still a simple question and it is close to subject matter.

You have 2 displays (Windows 10, extended desktop)
How to SWAP their images?

The question is simple but I have not found exact answers.

Because of simplicity will demand specification:
There are 2 displays DISPLAY1, DISPLAY2. Identical it (for example). Extended desktop.
The image from DISPLAY1 is moved to DISPLAY2 and vice versa.
Windows Display settings (main display, layout) are not used.

> You have 2 displays (Windows 10, extended desktop)
How to SWAP their images?

Go to Display settings -> Multiple displays. There you will see images of the displays (as blue rectangles).
Drag one rectangle to the right or left of another.

– pa

I assume he meant problematically, but perhaps not. In either case the
answer is effectively the same.

Mark Roddy

On Sat, Dec 16, 2017 at 6:36 PM, xxxxx@fastmail.fm
wrote:

> > You have 2 displays (Windows 10, extended desktop)
> How to SWAP their images?
>
> Go to Display settings -> Multiple displays. There you will see images of
> the displays (as blue rectangles).
> Drag one rectangle to the right or left of another.
>
> – pa
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

Hi Pavel,

It is this issue that does not solve. Only the behavior of the mouse cursor will change.
Do not touch the Settings. They will not help here.

You have 2 displays. Identical. 1-st to your Right. 2-nd Left.
How to make the IMAGE of the Left display appear on the right and the IMAGE of the Right display on the left?
Do not move the displays physically and without touching the cables (which also does not give anything since the picture is attached to the display by Windows)?

SetDisplayConfig for win8 or later.

Mark Roddy

On Sun, Dec 17, 2017 at 3:54 AM, xxxxx@outlook.com
wrote:

> Hi Pavel,
>
> It is this issue that does not solve. Only the behavior of the mouse
> cursor will change.
> Do not touch the Settings. They will not help here.
>
> You have 2 displays. Identical. 1-st to your Right. 2-nd Left.
> How to make the IMAGE of the Left display appear on the right and the
> IMAGE of the Right display on the left?
> Do not move the displays physically and without touching the cables (which
> also does not give anything since the picture is attached to the display by
> Windows)?
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>