共用方式為


Why do some applications disable Windows Aero?

If you're using a recent build of Windows Vista, you may have noticed that some applications cause a dialog box to pop up which disables desktop composition when they start up.

Here’s why this happens: one of the key aspects of desktop composition is that applications never render to the front-buffer directly, instead they render to redirection surfaces in software (for GDI applications) or shared surfaces (for DX applications), which are then in turn composed to the desktop by the DWM. But if an application needs to lock the front buffer (for read-back, or some other purpose), it can do so, but that will result in disabling desktop composition. In most cases, this is OK, because the application is drawing to the entire area of the display (as is the case with full-screen games, or watching a video in full-screen mode). Unfortunately, sometimes this also happens with applications that run in windows (vs. full screen) and in those situations the DWM shuts down.

Real-world examples of when you might see this are Apple's QuickTime Player & iTunes software. When they start up, they use DirectDraw to get access to the front buffer, even though they aren’t full-screen applications. Luckily – you can work around this! Here’s how:

  1. Open Quicktime preferences by selecting “Preferences” and then “QuickTime Preferences…” from the “Edit” menu in the QuickTime player application. A dialog box will pop up, with the title: “Quicktime Settings”.
  2. Select the “Advanced” tab in this dialog, and in the third section from the top, called “Video” select “Safe Mode (GDI Only)”
  3. Close the QuickTime player, and exit the QuickTime system tray application as well

The next time you start iTunes or QuickTime, it will use GDI to present its content instead of DirectDraw, which will work in a way that is more compatible with desktop composition. Most other applications that use DirectDraw have a fallback path to use GDI that you can find if you look in the options for the application itself.

So if you have a an application that uses DirectDraw and you don't want Aero to disable when your application is in use, the best way to do this is to adjust your code so that you're sticking to using DirectDraw's Blt methods (Blt, BltFast, etc.) to get your data into your sufraces, and make sure that you're not calling Lock or GetDC on those surfaces at any time, as these are the methods that will cause Windows to shut down composition.

Another thing to consider is using the methods in dwmapi.h to detect if composition is enabled, and automatically fall back to your GDI codepaths when starting up if you are not in a position to refactor your DirectDraw code.

Comments