[gtk/wip/otte/win32-cleanup: 6/12] win32: Remove global _gdk_display_hdc




commit df3090c1e02606bb31d65743a890a22ef50fccec
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jul 21 02:05:28 2021 +0200

    win32: Remove global _gdk_display_hdc
    
    Bunch of unused code in there.

 gdk/win32/gdkglobals-win32.c  |  1 -
 gdk/win32/gdkmain-win32.c     | 22 ----------------------
 gdk/win32/gdkprivate-win32.h  |  2 --
 gdk/win32/gdkproperty-win32.c |  8 ++++++--
 4 files changed, 6 insertions(+), 27 deletions(-)
---
diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c
index 1904876a12..b1eb8210a3 100644
--- a/gdk/win32/gdkglobals-win32.c
+++ b/gdk/win32/gdkglobals-win32.c
@@ -32,7 +32,6 @@ GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
 
 int              _gdk_offset_x, _gdk_offset_y;
 
-HDC              _gdk_display_hdc;
 HINSTANCE        _gdk_dll_hinstance;
 HINSTANCE        _gdk_app_hmodule;
 
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 5d43f4d3a4..706a86e5d2 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -63,7 +63,6 @@ _gdk_win32_surfaceing_init (void)
     GdiSetBatchLimit (1);
 
   _gdk_app_hmodule = GetModuleHandle (NULL);
-  _gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
   _gdk_input_locale = GetKeyboardLayout (0);
   _gdk_win32_keymap_set_active_layout (GDK_WIN32_KEYMAP (_gdk_win32_display_get_keymap (_gdk_display)), 
_gdk_input_locale);
   GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
@@ -149,27 +148,6 @@ _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
                 (g_sprintf (buf, " %d", pep[i].peFlags), buf))))));
 }
 
-void
-_gdk_win32_print_system_palette (void)
-{
-  PALETTEENTRY *pe;
-  int k;
-
-  k = GetSystemPaletteEntries (_gdk_display_hdc, 0, 0, NULL);
-  pe = g_new (PALETTEENTRY, k);
-  k = GetSystemPaletteEntries (_gdk_display_hdc, 0, k, pe);
-
-  if (!k)
-    g_print ("GetSystemPaletteEntries failed: %s\n",
-            g_win32_error_message (GetLastError ()));
-  else
-    {
-      g_print ("System palette: %d entries\n", k);
-      _gdk_win32_print_paletteentries (pe, k);
-    }
-  g_free (pe);
-}
-
 static int
 palette_size (HPALETTE hpal)
 {
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index d37866bcf3..5485bf5eff 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -208,7 +208,6 @@ gboolean   _gdk_modal_blocked       (GdkSurface *window);
 #ifdef G_ENABLE_DEBUG
 void   _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
                                         const int           nentries);
-void   _gdk_win32_print_system_palette (void);
 void   _gdk_win32_print_hpalette       (HPALETTE     hpal);
 void   _gdk_win32_print_dc             (HDC          hdc);
 
@@ -272,7 +271,6 @@ extern GdkDeviceManagerWin32 *_gdk_device_manager;
  */
 extern int               _gdk_offset_x, _gdk_offset_y;
 
-extern HDC               _gdk_display_hdc;
 extern HINSTANCE         _gdk_dll_hinstance;
 extern HINSTANCE         _gdk_app_hmodule;
 
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index 15ed2714df..031f48fa61 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -34,8 +34,9 @@
 #include "gdkwin32.h"
 
 static char *
-_get_system_font_name (HDC hdc)
+_get_system_font_name (void)
 {
+  HDC hdc;
   NONCLIENTMETRICSW ncm;
   PangoFontDescription *font_desc;
   char *result, *font_desc_string;
@@ -46,7 +47,10 @@ _get_system_font_name (HDC hdc)
   if (!SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0))
     return NULL;
 
+  hdc = GetDC (NULL);
   logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY);
+  ReleaseDC (NULL, hdc);
+
   font_desc = pango_win32_font_description_from_logfontw (&ncm.lfMessageFont);
   font_desc_string = pango_font_description_to_string (font_desc);
   pango_font_description_free (font_desc);
@@ -188,7 +192,7 @@ _gdk_win32_get_setting (const char *name,
     }
   else if (strcmp ("gtk-font-name", name) == 0)
     {
-      char *font_name = _get_system_font_name (_gdk_display_hdc);
+      char *font_name = _get_system_font_name ();
 
       if (font_name)
         {


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