다음을 통해 공유


Under the Hood of the Desktop Window Manager

I've made a grand total of one post in about the last 21 months.  What have I been doing during this time?  Why, working on the new Desktop Window Manager for Windows Vista, of course!  The Desktop Window Manager (DWM) is one of the more visible features and changes to Windows coming out with the upcoming Windows Vista release.

Does this mean that I've abandoned Windows Presentation Foundation (Avalon) to work on the DWM?  By no means.  The DWM is built upon the core graphics layer of Avalon, and is being developed by the same team responsible for Avalon. 

We've been heads down on design, development, and testing for quite some time, but now that there's an end in sight, I figured I'd come up for air and describe a bit about what we've done and the technical underpinnings of this visible feature.  There's lots and lots that can potentially be discussed, so I'm going to keep this first post fairly broad and high level, and will be interested in feedback if there are other specific areas of interest that readers would like to delve further into.  So please do comment with your thoughts!

The public face of the Desktop Window Manager

The DWM is of course just part of Windows Vista and not considered distinct from it.  Its features are exclusively available in the Windows Vista Aero experience.  I'm pulling out some of the more recognizable features here.

This is "Aero Glass", the semi-transparent look that Aero provides, with the blurry content behind the window frames, designed to allow the user to focus on the window itself, and not on what lies behind.

 

Here are the live thumbnail views provided on the Windows Vista taskbar.

 

And here are Windows Flip and Windows Flip3D -- the updated Windows Vista experiences invoked by Alt-Tab and Windows-Tab, respectively, for navigating between and selecting windows.

 

Desktop Composition

By far the largest change to Windows Vista in the way that windows are presented is the introduction of "desktop composition".  This underlies everything that is done by the DWM.  The primary takeaway for desktop composition:  the way an application gets pixels on the screen has fundamentally changed

In all versions of Windows, up until Windows XP, applications were asked by Windows to paint their visible region, and they would paint directly to the buffer that was to be displayed by the video card.  With Windows Vista, applications are asked by Windows to paint their entire surface to an offscreen surface (alternatively known as a bitmap, buffer, or texture), and it's up to the DWM to take all of these offscreen surfaces, and "compose" them together to the onscreen buffer.

Read the previous paragraph again.  From a windowing system display perspective, this has profound implications in terms of the features that can be implemented, and the quality that can be achieved.  Some examples:

  • Access to windows - now that applications are rendered offscreen, those offscreen representations can be used in other places.  This is precisely how the Flip, Flip3D, and thumbnail features work, and other features can be built that take advantage of this as well.
     

  • Don't involve background applications in window operations - when a window moves across the screen in XP and before, the portions of background windows that are newly visible only get painted when the background application wakes up and starts painting (in response to WM_PAINT messages it receives when the top window is moving).  For non-responsive background applications, or even responsive ones that happen to be paged out, this can yield a very poor user experience. 

    Consider moving an 'Paint' program window over an IE window.  On XP and before, the following symptoms are unfortunately all too common:

       

    In both of these cases, the underlying Internet Explorer application was unable to repaint itself quick enough to avoid the "trails" that the moving Paint window left behind. 

    Under Windows Vista, this simply isn't the case -- underlying windows do not receive WM_PAINTs and are not asked to re-render, since their content is already available to the DWM and is used to composite the screen.
     

  • Tear free experience - given that the DWM orchestrates all rendering to the screen, the latest technologies provided by DirectX that are typically used for games can be used for the overall desktop experience.  In particular, graphics cards' ability to "flip" the front buffer results in an absolutely tear free experience as windows are moved around the screen, increasing the smoothness and quality of the user experience.
     

  • High resolution support - the majority of applications out there are agnostic of the monitor resolution (DPI) that they're running at.  On the increasingly popular higher resolution monitors (120 DPI, 144 DPI, and beyond), this can produce a bad experience where applications appear very small in physical space.  Because the DWM has access to offscreen representation of the application window, the DWM is in a unique position to scale such DPI-unaware applications for their final presentation to the user, making for a much improved experience on the higher resolution monitor.

Possible Future Topics

Desktop composition is the most fundamental aspect of what the DWM provides, but we've really only scratched the surface of that topic, and there are still a lot of related topics to explore for a full understanding of what we're doing in Windows Vista.  Here's a rough cut of likely topics, roughly in the order I'd expect to tackle them.

  • DWMs use of DirectX, GPUs, and hardware acceleration
  • The importance and impact of the Windows Vista Display Driver Model to the DWM
  • Redirecting GDI and DirectX applications
  • How underlying WPF concepts and technology are being used
  • How the DWM paints the window frame and other non-client area
  • Remoting, Magnification, and Accessibility under the DWM
  • High DPI support
  • Publicly exposed DWM APIs
  • Rendering and visibility optimizations
  • Memory usage in the DWM

Again, please do comment with your interests and where you'd like this conversation to go.  No promises of course that we'll even get to any of them... but I do expect to.

While this is probably the most technically comprehensive discussion thus far of the DWM out on the web (though I'm certainly happy to be proven wrong), there are definitely other places with great sources of information and news: 

  • My ever-esteemed colleague Kam VedBrat maintains a blog that often gives a great inside perspective about the DWM, specific DWM features, and Windows Vista Aero. 
  • The microsoft.public.windows.developer.winfx.aero newsgroup carries discussion of all things Aero

Comments

  • Anonymous
    March 05, 2006
    I'd like to know why DWM can't just use the alpha channel of the buffer that Avalon draws to, to be able to do completely hardware accelerated irregular shaped and alpha blended windows, but instead has to drop Avalon HW acceleration and go to software rendering...

  • Anonymous
    March 06, 2006
    Great to see you again Greg. That's very-very-very cool stuff, I'm just waiting to see more low-level details (particularly regarding the use of DWM in custom apps).

    Welcome back!

  • Anonymous
    March 06, 2006

    "Tear free experience"

    How is this possible? Doesn't this depend on how much is getting drawn?

    Two decades ago, on machines like Atari ST and Amiga, it was all about the vertical blank. People used to write applications (demo) that would draw based on the vertical blank frequency, avoid the drawing spot, resulting in smooth scrollers and so on. Whatever happened to this?

    In other words, I don't think the tear experience scales well if you drawing too much on the screen at the same time, say you are running a couple videos concurrently.

    And I still fail to see how tear-free experience will make mom and dad feel excited about Windows Vista. Sorry, it had to be said.

  • Anonymous
    March 06, 2006
    The comment has been removed

  • Anonymous
    March 06, 2006
    Greg shows of what he's been working on for the last 21 months. 
    It's worth a read, as he points...

  • Anonymous
    March 06, 2006
    Found this via Jessica Fosler's blog. I'm subscribed. Hope to see more great posts like this. DWM is very exciting and I'm glad to see Windows painting working the way it always should have.

  • Anonymous
    March 06, 2006
    Greg Schechter rejoins us after a lengthy blogging pause to fill us in on profound changes in how Windows...

  • Anonymous
    March 06, 2006
    The comment has been removed

  • Anonymous
    March 06, 2006
    Thanks for shedding light on this topic.  Regarding your future topics, please bring 'em on and the quicker, the better.  :-)

  • Anonymous
    March 06, 2006
    Can't wait you to blog about all listed topics!

  • Anonymous
    March 06, 2006
    I think I'm understanding that each window's content is stored in memory so that they do not receive WM_PAINT messages when a window moves over them and then reveals part of the background window.

    My question is how do you handle the memory requirements for that as it could potential eat a lot of memory?



  • Anonymous
    March 06, 2006
    As I'm reading a few dozen questions come to mind.  You hit on some of them in your "upcoming topics" hit list but here are the things that sparked:

    1. How signifigant will hardware acceleration be to Glass?  It used to be there was the 2D benchmarks for work apps then the 3D benchmark for the fun things.  An amazing game card would often be horrible at having a lot of small Excel/Word/Visual Studio windows open.

    2. One of the first things new developers learn is to do their own screen buffering, to a bitmap, metafile, etc.  Does the DWM change that since it's already buffering?

    3. What kind of impact will this have on apps like Photoshop?  Are there things raster image editing programs can do to improve speed if they are running on Vista?

    4. If you are running old hardward does everything still go through the DWM?  Like inside a Virtual PC?

    5. How much control will we have over DWM?  For example could someone create Flip/Flip3D as a stand-alone app?  The nerdling fun side of my brain imagines interfaces a la Minority Report (minus the gloves and Tom Cruise).

    6. Hmm, speaking of the Minority Report UI, how well will video drag?

    7. How heavy a load does DWM put on the system?  I remember when shell replacements were big (LiteStep, geoShell, Cloud9, etc) and the goal was always reducing load while giving UI goodness.  Sounds like DWM could be that as long as it isn't seen as a boat anchor.

    Looking forward to more blog posts on this subject.  Try to come up for air just a wee bit more often :)

  • Anonymous
    March 06, 2006
    Will and how will the DWM affect windows redrawing while resizing? I've noticed some apps in the Feb CTP (Event Viewer comes to mind) that redraw rather chaotically when resizing. I guess I was expecting a more Mac OS X like experience, where the window contents are redrawn cleanly and completely even if this causes the size of the window to lag somewhat behind the mouse movements. Both methods have their downsides but the later gives a more solid feel to the applications IMHO.

    Any insights?

  • Anonymous
    March 06, 2006
    Great news, sounds very promising.

    What impact does it have on existing applications? My existing Win32 application uses a custom double-buffer to create a flicker-free experience.

    Does it mean I should get rid of my (now unnecessary) custom back buffer when I port my app to Vista? Does it also mean that all flickering applications will automatically become flicker-free?

  • Anonymous
    March 06, 2006
    Hi Greg, the first screenshot, with the bigger caption buttons, is this a real screenshot or something done with photoshop? If this is a real screenshot it shows how great vista will scale to higher dpi monitors!

  • Anonymous
    March 06, 2006
    Another thing related to what I stated first, but on the polar opposite:

    The same way one can have the system render itself proportionally bigger, the opposite seems technically feasable, to make everything smaller resulting in virtually more desktop space, at least to some extent, before text becomes unreadable.

    What do you think Greg?

  • Anonymous
    March 06, 2006
    Greg Schechter is one of the Architects on the Avalon team who's focus for the last year or so has been...

  • Anonymous
    March 06, 2006
    Дельное объяснение без понтов и лишней зауми.

  • Anonymous
    March 06, 2006
    That sounds fantastic! Does the automatic window buffering mean we could get rid of the traditional WM_PAINT event processing altogether, and just draw new elements immediately as required?

    Also, what happens when a window is scaled to a higher resolution? Will OpenType text be recognized as such, and appropriately re-rendered at a greater point size?

  • Anonymous
    March 06, 2006
    Is it possible to enable anti-aliasing on DWM to prevent the jagged edges on skin and in Flip3D?

  • Anonymous
    March 06, 2006
    Look forward to hearing about it. =)

    I have a couple of questions. How do the glass blurring effects work? Pixel shaders? And, does the DWM use the 3D hardware to accelerate non-WPF, old GDI drawing commands?

  • Anonymous
    March 06, 2006
    PingBack from http://blog.jensthebrain.de/archives/2006/02/27/windows-vista-aero-screenshots/

  • Anonymous
    March 06, 2006
    I would love to hear more details about how you are doing your text rendering now that you are going through the DWM all the time.

  • Anonymous
    March 06, 2006
    The comment has been removed

  • Anonymous
    March 06, 2006
    Is DWM written in managed language?

  • Anonymous
    March 06, 2006
    Can you do anything about the fact that launching any Java app or applet with Sun's JRE 1.5.0_06 causes the DWM to switch off?

    I'm guessing that Sun are using DirectDraw with a locked primary surface to do their rendering. A communication from David Blythe indicated that this would disable the DWM.

  • Anonymous
    March 06, 2006
    I'm interested in the memory usage of the DWM. If every window is rendered offscreen, isn't it the case that in some extreme situations some of these offscreen surfaces may be either paged down to disk or re-rendered continuously affecting the whole system performance?

    Also, does the desktop composition process try to fix potential aliasing issues? I have noticed a quite annoying border aliasing on some of the Flick3D screenshots.

  • Anonymous
    March 06, 2006
    The comment has been removed

  • Anonymous
    March 07, 2006
    The comment has been removed

  • Anonymous
    March 07, 2006
    Malheureusement en anglais, mais très intéressant, cet article vous expliquera le fonctionnement du Windows...

  • Anonymous
    March 07, 2006
    Look like a familiar problem?  Want to know what we’re doing about in Windows Vista? 

    Greg...

  • Anonymous
    March 07, 2006
    The comment has been removed

  • Anonymous
    March 08, 2006
    second the request for info on anti-aliasing. The 3d flip is cool, but I can't take jaggies any more...

    Also second the request for info on memory usage- should I buy a 512meg (1gig?) graphics card in the future, etc?

  • Anonymous
    March 08, 2006
    First forgive me since I haven't installed a beta copy of Vista yet (I have 5308 but haven't decided to install or wait for consumer beta release) and some of this post may be answered if I had.

    This is really interesting to me and the off-screen approach makes total sense.  That said, what types of effects from DX10 will also make their way into the DWM?  A simple example from MAC is the way windows minimize and maximize.  Will the DWM take any advantage of particle affects or other fun UI?  Will this be left up to the community to build and not really be done by Gold Master time frame by MS?  Kinda the way things went with windowblinds etc...

    I worked for AOL over the last few years and we had a presentation 2 years ago on a concept of what a Vista AOL client may look and act like done by MS.  This showed seamless movements between browsing a picture on the web and dragging it into another app across the screen.  It also showed how the desktop can be utilized as a personal clip board with images from the web dragged seamlessly as well as text and special affects to make everything "alive" (move, pulse, etc...).  Do these things exist or will they in the coming consumer beta?

  • Anonymous
    March 08, 2006
    why is there just flip3d and nothing equally functional like expose in mac os x where you can drag and drop from one to another window while seeing all windows at once? flip3d is, in my opinion, more like a toy than a useful thing, because tabbing or scrolling through the whole open windows is much more time consuming than having all windows in a small preview at once on the whole screen.

  • Anonymous
    March 09, 2006
    Shawn wrote:
    "4. If you are running old hardward does everything still go through the DWM?  Like inside a Virtual PC?"

    I got the impression from the post that DWM will only be used with the new Aero Glass interface. Therefore, if you're running on older hardware, you can switch back to the XP look, and use the traditional window manager.

  • Anonymous
    March 09, 2006
    I'm curious to hear the relationship between DWM and WPF.  I've read on the Avalon newsgroup that Explorer (and thus DWM) is not using WPF, and that WPF isn't even installed by default with Vista.  That leads me to think that there's a great deal of duplicate code in both technologies, and I worry about a divergence of functionality along the lines of Office's UI widgets and commctrl32.dll.  If this really is the case, do the two technologies eventually converge, with everything built to WPF?

  • Anonymous
    March 09, 2006
    Hey Greg,

    thanks for the post but what about the important topic: "How underlying WPF concepts and technology are being used"? I always read that DWM uses wpf tech? Please post about that issue it is important to know!!!

    chris

  • Anonymous
    March 09, 2006
    I read and participate in newsgroups (and blogs) regularly.  This entry is derived from a recent long post of mine in response to some very passionate newsgroup posts by some folks using the latest Windows Vista CTP

    The are a number of very positive

  • Anonymous
    March 10, 2006
    Lots of great comments coming in.  Rather than responding to them with more comments, I added a new post to do that.

  • Anonymous
    March 12, 2006
    That is one very, very neatly constructed aero objects.  It is awesome!

  • Anonymous
    March 12, 2006
    Very interesting and informative conversation. Thanks Greg...

  • Anonymous
    March 19, 2006
    For the last few years, both desktop and laptop PCs have been outfitted with increasingly powerful graphics...

  • Anonymous
    March 26, 2006
    The comment has been removed

  • Anonymous
    April 09, 2006
    Charlie Owen on the Windows Media Center team has been posting quite a bit lately on Windows Vista. He's...

  • Anonymous
    April 20, 2006
    Here's a list of topics that I have posted on (with active links) or expect to post on (without links)...

  • Anonymous
    April 21, 2006
    I came across Sean's blog while figuring out how to register with Technocrati... He recently got around...

  • Anonymous
    June 07, 2006
    When talking about WPF during the Windows Vista ISV Touchdown training a lot of people were interested...

  • Anonymous
    June 20, 2006
    PingBack from http://www.nicolas-lefebvre.eu/blog/?p=3

  • Anonymous
    August 06, 2006
    A good amount of ink has been spilled on this blog talking about all the
    cost, nuance, impact, and...

  • Anonymous
    September 28, 2006
    Today I'd like to share the fearful tale about a Vista upgrade gone horribly wrong.  Base on a true...

  • Anonymous
    November 23, 2006
    PingBack from http://www.jogiles.co.nz/blog/?p=56

  • Anonymous
    November 23, 2006
    PingBack from http://www.jogiles.co.nz/blog/?p=57

  • Anonymous
    December 05, 2006
    PingBack from http://blog.stevex.net/index.php/2006/12/05/vista-dwm/

  • Anonymous
    February 02, 2007
    PingBack from http://vistaonamacbookpro.info/?p=72

  • Anonymous
    April 07, 2007
    PingBack from http://budigelli.wordpress.com/2007/04/08/desktop-window-manager-in-vista/

  • Anonymous
    April 30, 2007
    PingBack from http://tech.cybernetnews.com/2007/04/30/what-is-the-desktop-window-manager-dwm-in-vista/

  • Anonymous
    May 01, 2007
    PingBack from http://www.errorforum.com/microsoft-windows-vista-error/19206-what-desktop-window-manager-dwm-vista.html#post24211

  • Anonymous
    May 01, 2007
    PingBack from http://vistamalaya.wordpress.com/2007/05/02/why-the-news-analyst-tellvista-was-vulnerable/

  • Anonymous
    May 31, 2007
    When talking about WPF during the Windows Vista ISV Touchdown training a lot of people were interested

  • Anonymous
    June 17, 2007
    PingBack from http://blog.budigelli.com/index.php/2007/04/08/desktop-window-manager-in-vista/

  • Anonymous
    August 28, 2007
    The comment has been removed

  • Anonymous
    January 25, 2008
    PingBack from http://softwareinformation.247blogging.info/greg-schechters-blog-under-the-hood-of-the-desktop-window-manager/

  • Anonymous
    February 28, 2008
    PingBack from http://www.itwriting.com/blog/?p=530

  • Anonymous
    January 20, 2009
    PingBack from http://www.hilpers-esp.com/338428-aero

  • Anonymous
    January 21, 2009
    PingBack from http://www.keyongtech.com/2964995-desktop-composition

  • Anonymous
    May 26, 2009
    PingBack from http://backyardshed.info/story.php?title=greg-schechter-s-blog-under-the-hood-of-the-desktop-window-manager

  • Anonymous
    May 31, 2009
    PingBack from http://woodtvstand.info/story.php?id=1833

  • Anonymous
    June 08, 2009
    PingBack from http://insomniacuresite.info/story.php?id=6820

  • Anonymous
    June 16, 2009
    PingBack from http://workfromhomecareer.info/story.php?id=2558