gdk-win32: Really Implement GdkScreen->is_composited()

The current GdkScreen->is_composited() is a stub as we were having Windows
XP being supported, which does not support Desktop Window Manager (DWM),
which is used by Windows for composition.

Windows Vista and later support DWM, and it is always enabled on Windows 8/
Server 2012 and later.

Please note that as we are dropping XP support in this cycle, this is the
commit that would say goodbye to Windows XP support for GTK+-3.x, by
linking directly to dwmapi.dll.  This means, we only check whether we are
on Windows 8 or Server 2012 (or later) to see whether we unconditionally
have composition enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=741849
This commit is contained in:
Chun-wei Fan 2015-04-15 17:44:55 +08:00
parent 24d3f3fcb2
commit b85f0ccc67
7 changed files with 26 additions and 10 deletions

View File

@ -167,7 +167,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
@ -209,7 +209,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
@ -257,7 +257,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
@ -299,7 +299,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>

View File

@ -74,7 +74,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
LinkIncremental="1"
GenerateDebugInformation="true"
@ -136,7 +136,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
LinkIncremental="1"
GenerateDebugInformation="true"
@ -202,7 +202,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
LinkIncremental="1"
GenerateDebugInformation="true"
@ -264,7 +264,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
LinkIncremental="1"
GenerateDebugInformation="true"

View File

@ -375,7 +375,7 @@ if test "$enable_win32_backend" = "yes"; then
backend_immodules="$backend_immodules,ime"
GDK_WINDOWING="$GDK_WINDOWING
#define GDK_WINDOWING_WIN32"
GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm"
GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi"
AM_CONDITIONAL(USE_WIN32, true)
PANGO_PACKAGES="pangowin32 pangocairo"
else

View File

@ -82,3 +82,5 @@ gboolean _ignore_destroy_clipboard = FALSE;
HGLOBAL _delayed_rendering_data = NULL;
GHashTable *_format_atom_table = NULL;
gboolean _is_win8_or_later = FALSE;

View File

@ -130,6 +130,7 @@ _gdk_win32_windowing_init (void)
_cf_url = RegisterClipboardFormat ("UniformResourceLocatorW");
_cf_html_format = RegisterClipboardFormat ("HTML Format");
_cf_text_html = RegisterClipboardFormat ("text/html");
_is_win8_or_later = g_win32_check_windows_version (6, 2, 0, G_WIN32_OS_ANY);
_gdk_win32_selection_init ();
}

View File

@ -508,4 +508,6 @@ void _gdk_events_init (void);
void _gdk_input_init (GdkDisplay *display);
void _gdk_input_wintab_init_check (GdkDeviceManager *device_manager);
extern gboolean _is_win8_or_later;
#endif /* __GDK_PRIVATE_WIN32_H__ */

View File

@ -21,6 +21,8 @@
#include "gdkscreenprivate.h"
#include "gdkwin32screen.h"
#include <dwmapi.h>
struct _GdkWin32Screen
{
GdkScreen parent_instance;
@ -195,9 +197,18 @@ gdk_win32_screen_get_window_stack (GdkScreen *screen)
static gboolean
gdk_win32_screen_is_composited (GdkScreen *screen)
{
gboolean is_composited;
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
return FALSE;
/* On Windows 8 and later, DWM (composition) is always enabled */
if (_is_win8_or_later)
return TRUE;
else
{
if (DwmIsCompositionEnabled (&is_composited) != S_OK)
return FALSE;
return is_composited;
}
}
static void