summaryrefslogtreecommitdiff
path: root/xdpyinfo.c
diff options
context:
space:
mode:
authorRoland Mainz <roland.mainz@nrubsig.org>2005-03-11 21:18:12 +0000
committerRoland Mainz <roland.mainz@nrubsig.org>2005-03-11 21:18:12 +0000
commit5adf5a253e5434c2b0c2276ce3733cbb05282980 (patch)
treed7ef94fc4040d2f5856beaef90bce535331666c7 /xdpyinfo.c
parent4d275dcc29658972a3d7c2e72b812140819a10c3 (diff)
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).
Diffstat (limited to 'xdpyinfo.c')
-rw-r--r--xdpyinfo.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/xdpyinfo.c b/xdpyinfo.c
index 598cd9c..70cce19 100644
--- a/xdpyinfo.c
+++ b/xdpyinfo.c
@@ -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 */