emacs-devel
[Top][All Lists]
Advanced

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

Re: x-display-pixel-width/height inconsistency


From: YAMAMOTO Mitsuharu
Subject: Re: x-display-pixel-width/height inconsistency
Date: Thu, 21 Mar 2013 10:44:29 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Thu, 21 Mar 2013 02:09:53 +0100, grischka <address@hidden> said:

>> It is the size of whole "(virtual) screen" that we want to know here,
>> rather than the size of a particular monitor.  

> Then use
>          w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
>          h = GetSystemMetrics(SM_CYVIRTUALSCREEN);

Thanks.  I tried making a patch using them.  Do you happen to know an
appropriate way to exclude Windows 95 and NT 4 where
SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN are not available?

                             YAMAMOTO Mitsuharu
                        address@hidden

=== modified file 'src/w32fns.c'
--- src/w32fns.c        2013-03-20 11:29:37 +0000
+++ src/w32fns.c        2013-03-21 01:39:22 +0000
@@ -4731,15 +4731,13 @@
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
   HDC hdc;
-  int cap;
+  float ratio;
 
-  hdc = GetDC (dpyinfo->root_window);
+  hdc = GetDC (NULL);
+  ratio = (float) GetDeviceCaps (hdc, VERTSIZE) / GetDeviceCaps (dc, VERTRES);
+  ReleaseDC (NULL, hdc);
 
-  cap = GetDeviceCaps (hdc, VERTSIZE);
-
-  ReleaseDC (dpyinfo->root_window, hdc);
-
-  return make_number (cap);
+  return make_number ((int) (ratio * x_display_pixel_height (dpyinfo) + 0.5));
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -4750,17 +4748,14 @@
   (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
-
   HDC hdc;
-  int cap;
-
-  hdc = GetDC (dpyinfo->root_window);
-
-  cap = GetDeviceCaps (hdc, HORZSIZE);
+  float ratio;
 
-  ReleaseDC (dpyinfo->root_window, hdc);
+  hdc = GetDC (NULL);
+  ratio = (float) GetDeviceCaps (hdc, HORZSIZE) / GetDeviceCaps (dc, HORZRES);
+  ReleaseDC (NULL, hdc);
 
-  return make_number (cap);
+  return make_number ((int) (ratio * x_display_pixel_width (dpyinfo) + 0.5));
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,

=== modified file 'src/w32term.c'
--- src/w32term.c       2013-03-15 10:07:29 +0000
+++ src/w32term.c       2013-03-21 01:32:55 +0000
@@ -142,6 +142,15 @@
 #define WS_EX_LAYERED 0x80000
 #endif
 
+/* SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN are not defined on 95 and
+   NT4.  */
+#ifndef SM_CXVIRTUALSCREEN
+#define SM_CXVIRTUALSCREEN 78
+#endif
+#ifndef SM_CYVIRTUALSCREEN
+#define SM_CXVIRTUALSCREEN 79
+#endif
+
 /* This is a frame waiting to be autoraised, within w32_read_socket.  */
 struct frame *pending_autoraise_frame;
 
@@ -515,19 +524,29 @@
 int
 x_display_pixel_height (struct w32_display_info *dpyinfo)
 {
-  HDC dc = GetDC (NULL);
-  int pixels = GetDeviceCaps (dc, VERTRES);
-  ReleaseDC (NULL, dc);
-  return pixels;
+  if (1 /* XXX: exclude 95 and NT4 */)
+    return GetSystemMetrics (SM_CYVIRTUALSCREEN);
+  else
+    {
+      HDC dc = GetDC (NULL);
+      int pixels = GetDeviceCaps (dc, VERTRES);
+      ReleaseDC (NULL, dc);
+      return pixels;
+    }
 }
 
 int
 x_display_pixel_width (struct w32_display_info *dpyinfo)
 {
-  HDC dc = GetDC (NULL);
-  int pixels = GetDeviceCaps (dc, HORZRES);
-  ReleaseDC (NULL, dc);
-  return pixels;
+  if (1 /* XXX: exclude 95 and NT4 */)
+    return GetSystemMetrics (SM_CXVIRTUALSCREEN);
+  else
+    {
+      HDC dc = GetDC (NULL);
+      int pixels = GetDeviceCaps (dc, HORZRES);
+      ReleaseDC (NULL, dc);
+      return pixels;
+    }
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]