changeset 101977:9a5d93661ee4

(x_display_pixel_height, x_display_pixel_width): Release DC when finished. Use NULL window to refer to desktop. (w32_term_init): Use NULL window to refer to desktop. (Bug#460)
author Jason Rumney <jasonr@gnu.org>
date Thu, 12 Feb 2009 14:36:33 +0000
parents 3162f3263757
children 9a4825a9e483
files src/w32term.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32term.c	Thu Feb 12 14:06:24 2009 +0000
+++ b/src/w32term.c	Thu Feb 12 14:36:33 2009 +0000
@@ -464,14 +464,20 @@
 x_display_pixel_height (dpyinfo)
      struct w32_display_info *dpyinfo;
 {
-  return GetDeviceCaps (GetDC (GetDesktopWindow ()), VERTRES);
+  HDC dc = GetDC (NULL);
+  int pixels = GetDeviceCaps (dc, VERTRES);
+  ReleaseDC (NULL, dc);
+  return pixels;
 }
 
 int
 x_display_pixel_width (dpyinfo)
      struct w32_display_info *dpyinfo;
 {
-  return GetDeviceCaps (GetDC (GetDesktopWindow ()), HORZRES);
+  HDC dc = GetDC (NULL);
+  int pixels = GetDeviceCaps (dc, HORZRES);
+  ReleaseDC (NULL, dc);
+  return pixels;
 }
 
 
@@ -6216,7 +6222,7 @@
   dpyinfo->next = x_display_list;
   x_display_list = dpyinfo;
 
-  hdc = GetDC (GetDesktopWindow ());
+  hdc = GetDC (NULL);
 
   dpyinfo->root_window = GetDesktopWindow ();
   dpyinfo->n_planes = GetDeviceCaps (hdc, PLANES);
@@ -6224,7 +6230,7 @@
   dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX);
   dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY);
   dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE;
-  ReleaseDC (GetDesktopWindow (), hdc);
+  ReleaseDC (NULL, hdc);
 
   /* initialise palette with white and black */
   {