xc/programs/twm/Imakefile XORG-6_8_99_1 XORG-6_8_99_2 XORG-6_8_99_3 XORG-6_8_99_4
authorRoland Mainz <roland.mainz@nrubsig.org>
Fri, 11 Mar 2005 21:18:12 +0000 (21:18 +0000)
committerRoland Mainz <roland.mainz@nrubsig.org>
Fri, 11 Mar 2005 21:18:12 +0000 (21:18 +0000)
xc/programs/twm/twm.c
//bugs.freedesktop.org/show_bug.cgi?id=2705) attachment #2087
    (https://bugs.freedesktop.org/attachment.cgi?id=2087) Make twm ignore
    print screens to avoid that users accidentally warp on a non-video
    screen (which are not visible on any monitor) when the Xserver has both
    video and print screens. (This includes also a small cleanup of
    xdpyinfo where parts of the print screen test code comes from) Patch by
    Julien Lafon <julien.lafon@gmail.com> (MIT/X.org license).

xdpyinfo.c

index 598cd9c..70cce19 100644 (file)
@@ -5,6 +5,7 @@
  *
  * 
 Copyright 1988, 1998  The Open Group
+Copyright 2005 Hitachi, Ltd.
 
 Permission to use, copy, modify, distribute, and sell this software and its
 documentation for any purpose is hereby granted without fee, provided that
@@ -343,6 +344,8 @@ print_visual_info(XVisualInfo *vip)
            vip->bits_per_rgb);
 }
 
+/* xc/programs/twm/twm.c has a copy of |hasExtension()|, please
+ * keep both versions in sync... */
 static
 Bool hasExtension(Display *dpy, char *extname)
 {
@@ -356,6 +359,29 @@ Bool hasExtension(Display *dpy, char *extname)
   return i != num_extensions;
 }
 
+/* xc/programs/twm/twm.c has a copy of |IsPrintScreen()|, please
+ * keep both versions in sync... */
+static
+Bool IsPrintScreen(Screen *s)
+{
+    Display *dpy = XDisplayOfScreen(s);
+    int      i;
+
+    /* Check whether this is a screen of a print DDX */
+    if (hasExtension(dpy, XP_PRINTNAME)) {
+        Screen **pscreens;
+        int      pscrcount;
+
+        pscreens = XpQueryScreens(dpy, &pscrcount);
+        for( i = 0 ; (i < pscrcount) && pscreens ; i++ ) {
+            if (s == pscreens[i]) {
+                return True;
+            }
+        }
+        XFree(pscreens);                      
+    }
+    return False;
+}
 
 static void
 print_screen_info(Display *dpy, int scr)
@@ -370,7 +396,7 @@ print_screen_info(Display *dpy, int scr)
     double xres, yres;
     int ndepths = 0, *depths = NULL;
     unsigned int width, height;
-    Bool isPrintScreen = False;
+    Bool isPrintScreen = False; /* Initalise this if |INCLUDE_XPRINT_SUPPORT| is not set */
 
     /*
      * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
@@ -390,19 +416,7 @@ print_screen_info(Display *dpy, int scr)
 
 #ifdef INCLUDE_XPRINT_SUPPORT
     /* Check whether this is a screen of a print DDX */
-    if (hasExtension(dpy, XP_PRINTNAME)) {
-        Screen **pscreens;
-        int      pscrcount;
-
-        pscreens = XpQueryScreens(dpy, &pscrcount);
-        for( i = 0 ; (i < pscrcount) && pscreens ; i++ ) {
-            if (scr == (int)XScreenNumberOfScreen(pscreens[i])) {
-                isPrintScreen = True;
-                break;
-            }
-        }
-        XFree(pscreens);                     
-    }
+    isPrintScreen = IsPrintScreen(s);
     printf ("  print screen:    %s\n", isPrintScreen?"yes":"no");
 #endif /* INCLUDE_XPRINT_SUPPORT */