[gtk+] gdk-win32: Really Implement GdkScreen->is_composited()



commit b85f0ccc672455d4b7c895cb00d3804b44310659
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Apr 15 17:44:55 2015 +0800

    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

 build/win32/vs10/gdk.vcxprojin |    8 ++++----
 build/win32/vs9/gdk.vcprojin   |    8 ++++----
 configure.ac                   |    2 +-
 gdk/win32/gdkglobals-win32.c   |    2 ++
 gdk/win32/gdkmain-win32.c      |    1 +
 gdk/win32/gdkprivate-win32.h   |    2 ++
 gdk/win32/gdkscreen-win32.c    |   13 ++++++++++++-
 7 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/build/win32/vs10/gdk.vcxprojin b/build/win32/vs10/gdk.vcxprojin
index 35e14a2..fff2f6d 100644
--- a/build/win32/vs10/gdk.vcxprojin
+++ b/build/win32/vs10/gdk.vcxprojin
@@ -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>
diff --git a/build/win32/vs9/gdk.vcprojin b/build/win32/vs9/gdk.vcprojin
index ad33f6e..59d1736 100644
--- a/build/win32/vs9/gdk.vcprojin
+++ b/build/win32/vs9/gdk.vcprojin
@@ -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"
diff --git a/configure.ac b/configure.ac
index 7dc9c26..ba8954c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c
index 5248a00..3d1c17f 100644
--- a/gdk/win32/gdkglobals-win32.c
+++ b/gdk/win32/gdkglobals-win32.c
@@ -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;
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 905c729..f12c166 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -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 ();
 }
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index acc3fca..dbb9a79 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -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__ */
diff --git a/gdk/win32/gdkscreen-win32.c b/gdk/win32/gdkscreen-win32.c
index 8c6fb03..4e9cc99 100644
--- a/gdk/win32/gdkscreen-win32.c
+++ b/gdk/win32/gdkscreen-win32.c
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]