From 0b661e4af72cab10d2e7db3400087612e0e9f4af Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:46:12 +0900 Subject: [PATCH] Initialize Tizen 2.3 --- AUTHORS | 2 + COPYING | 64 ++ ChangeLog | 1152 +++++++++++++++++++++++++++++++++ INSTALL | 291 +++++++++ Makefile.am | 37 ++ README | 25 + autogen.sh | 12 + configure.ac | 63 ++ include/X11/extensions/Xrandr.h | 557 ++++++++++++++++ man/Makefile.am | 55 ++ man/XRRConfigCurrentConfiguration.man | 1 + man/XRRConfigCurrentRate.man | 1 + man/XRRConfigRates.man | 1 + man/XRRConfigRotations.man | 1 + man/XRRConfigSizes.man | 1 + man/XRRConfigTimes.man | 1 + man/XRRFreeScreenConfigInfo.man | 1 + man/XRRGetScreenInfo.man | 1 + man/XRRQueryExtension.man | 1 + man/XRRQueryVersion.man | 1 + man/XRRRootToScreen.man | 1 + man/XRRSelectInput.man | 1 + man/XRRSetScreenConfig.man | 1 + man/XRRSetScreenConfigAndRate.man | 1 + man/Xrandr.man | 348 ++++++++++ packaging/libXrandr.spec | 66 ++ src/Makefile.am | 27 + src/Xrandr.c | 513 +++++++++++++++ src/Xrandrint.h | 98 +++ src/XrrConfig.c | 434 +++++++++++++ src/XrrCrtc.c | 553 ++++++++++++++++ src/XrrMode.c | 149 +++++ src/XrrOutput.c | 190 ++++++ src/XrrProperty.c | 339 ++++++++++ src/XrrProvider.c | 217 +++++++ src/XrrProviderProperty.c | 339 ++++++++++ src/XrrScreen.c | 263 ++++++++ xrandr.pc.in | 12 + 38 files changed, 5820 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 README create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 include/X11/extensions/Xrandr.h create mode 100644 man/Makefile.am create mode 100644 man/XRRConfigCurrentConfiguration.man create mode 100644 man/XRRConfigCurrentRate.man create mode 100644 man/XRRConfigRates.man create mode 100644 man/XRRConfigRotations.man create mode 100644 man/XRRConfigSizes.man create mode 100644 man/XRRConfigTimes.man create mode 100644 man/XRRFreeScreenConfigInfo.man create mode 100644 man/XRRGetScreenInfo.man create mode 100644 man/XRRQueryExtension.man create mode 100644 man/XRRQueryVersion.man create mode 100644 man/XRRRootToScreen.man create mode 100644 man/XRRSelectInput.man create mode 100644 man/XRRSetScreenConfig.man create mode 100644 man/XRRSetScreenConfigAndRate.man create mode 100644 man/Xrandr.man create mode 100755 packaging/libXrandr.spec create mode 100644 src/Makefile.am create mode 100644 src/Xrandr.c create mode 100644 src/Xrandrint.h create mode 100644 src/XrrConfig.c create mode 100644 src/XrrCrtc.c create mode 100644 src/XrrMode.c create mode 100644 src/XrrOutput.c create mode 100644 src/XrrProperty.c create mode 100644 src/XrrProvider.c create mode 100644 src/XrrProviderProperty.c create mode 100644 src/XrrScreen.c create mode 100644 xrandr.pc.in diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e794390 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Jim Gettys, Compaq and Hewlett-Packard, and Keith Packard, + SuSE and Hewlett-Packard diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..29a2f5d --- /dev/null +++ b/COPYING @@ -0,0 +1,64 @@ +Copyright © 2000, Compaq Computer Corporation, +Copyright © 2002, Hewlett Packard, Inc. + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation, and that the name of Compaq or HP not be used in advertising +or publicity pertaining to distribution of the software without specific, +written prior permission. HP makes no representations about the +suitability of this software for any purpose. It is provided "as is" +without express or implied warranty. + +HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP +BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Copyright © 2000 Compaq Computer Corporation, Inc. +Copyright © 2002 Hewlett-Packard Company, Inc. +Copyright © 2006 Intel Corporation +Copyright © 2008 Red Hat, Inc. + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting documentation, and +that the name of the copyright holders not be used in advertising or +publicity pertaining to distribution of the software without specific, +written prior permission. The copyright holders make no representations +about the suitability of this software for any purpose. It is provided "as +is" without express or implied warranty. + +THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. + +Copyright © 2000 Compaq Computer Corporation, Inc. +Copyright © 2002 Hewlett Packard Company, Inc. +Copyright © 2006 Keith Packard + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting documentation, and +that the name of the copyright holders not be used in advertising or +publicity pertaining to distribution of the software without specific, +written prior permission. The copyright holders make no representations +about the suitability of this software for any purpose. It is provided "as +is" without express or implied warranty. + +THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..80284ca --- /dev/null +++ b/ChangeLog @@ -0,0 +1,1152 @@ +commit 754b492ddf490682c5fff2518a36d0afb5655a36 +Author: Alan Coopersmith +Date: Wed Jun 29 21:50:39 2011 -0700 + + libXrandr 1.3.2 + + Signed-off-by: Alan Coopersmith + +commit 2a8e4e3b6c28d095e315da6874a72e05ef113edb +Author: Cyril Brulebois +Date: Thu Mar 31 03:43:57 2011 +0200 + + Xrandr.man: Document how to request notifications. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit 7613d6e70c4af791bdb3e005a6231f1d4d14745c +Author: Cyril Brulebois +Date: Thu Mar 3 16:17:51 2011 +0100 + + Xrandr.man: Fix parenthesis escaping. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit d0b9b06d2d0b85da3eb89adf4abd973b092201df +Author: Cyril Brulebois +Date: Thu Mar 3 16:01:56 2011 +0100 + + Xrandr.man: Fix missing closing parenthesis. + + Also fix the closing tag (\fP instead of \fI). + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit cf351e133c71fdae77c961373e01258404a5ff7f +Author: Cyril Brulebois +Date: Thu Mar 3 15:54:58 2011 +0100 + + Xrandr.man: Build full sentences for easier reading. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit e92474f36a2157ce8939b143e077d9342638e74a +Author: Cyril Brulebois +Date: Thu Mar 3 15:52:58 2011 +0100 + + Xrandr.man: Fix typo. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit d77cd6cc30bd9ebaea7c3b1c97e6984844a607f9 +Author: Cyril Brulebois +Date: Thu Mar 3 15:50:08 2011 +0100 + + Xrandr.man: Try to make some sense. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Reviewed-by: Magnus Kessler + Signed-off-by: Cyril Brulebois + +commit 58b664ba4c8c8d34a2c6169dbaf55f0d21fc0139 +Author: Cyril Brulebois +Date: Thu Mar 3 15:49:57 2011 +0100 + + Xrandr.man: Build full sentences, possibly easier to read. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit dfb543b9061428e745b7a1b5910c46ffa46fadf5 +Author: Cyril Brulebois +Date: Thu Mar 3 15:34:41 2011 +0100 + + Xrandr.man: Fix grammar. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit f340f5b117b69cccabf9b3a0f2834a4b6aae057e +Author: Cyril Brulebois +Date: Thu Mar 3 15:32:03 2011 +0100 + + Xrandr.man: Remove trailing spaces. + + Reviewed-by: Peter Hutterer + Reviewed-by: Alan Coopersmith + Signed-off-by: Cyril Brulebois + +commit 2da3bb5e59db3ed5f689686774dd051766dd39a6 +Author: Gaetan Nadon +Date: Wed Feb 2 11:43:44 2011 -0500 + + config: comment, minor upgrade, quote and layout configure.ac + + Group statements per section as per Autoconf standard layout + Quote statements where appropriate. + Autoconf recommends not using dnl instead of # for comments + + Use AC_CONFIG_FILES to replace the deprecated AC_OUTPUT with parameters. + Add AC_CONFIG_SRCDIR([Makefile.am]) + + This helps automated maintenance and release activities. + Details can be found in http://wiki.x.org/wiki/NewModuleGuidelines + +commit 04d5ffa04c2255025580ce1740c3f0bb2146e716 +Author: Gaetan Nadon +Date: Fri Jan 28 19:41:37 2011 -0500 + + config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS + + Signed-off-by: Gaetan Nadon + +commit ae18cc9cd98f4db512a21e0b4e1cb18a69fcf532 +Author: Gaetan Nadon +Date: Fri Jan 28 16:34:14 2011 -0500 + + config: remove unrequired AC_CONFIG_AUX_DIR + + The default location for the generation of configuation files is the current + package root directory. These files are config.* and friends. + + Signed-off-by: Gaetan Nadon + +commit c1c5283f37387fbae7772e1dcd56528a515f0a23 +Author: Gaetan Nadon +Date: Thu Jan 27 18:50:15 2011 -0500 + + config: remove AC_PROG_CC as it overrides AC_PROG_C_C99 + + XORG_STRICT_OPTION from XORG_DEFAULT_OPTIONS calls + AC_PROG_C_C99. This sets gcc with -std=gnu99. + If AC_PROG_CC macro is called afterwards, it resets CC to gcc. + + Signed-off-by: Gaetan Nadon + +commit b7e31c69d345d3cba359d7648c304cff43ff7437 +Author: Alan Coopersmith +Date: Thu Oct 28 12:34:26 2010 -0700 + + libXrandr 1.3.1 + + Signed-off-by: Alan Coopersmith + +commit f490ed44a1c85c75183d87d034b94f9973b88abd +Author: Alan Coopersmith +Date: Thu Oct 28 12:30:27 2010 -0700 + + Fix configure.ac comment for RandR instead of Render + + Signed-off-by: Alan Coopersmith + +commit 95cf69bd452db86b6aefe3837e1f7010ebf21e80 +Author: Alan Coopersmith +Date: Thu Oct 28 12:27:30 2010 -0700 + + Sun's copyrights now belong to Oracle + + Signed-off-by: Alan Coopersmith + +commit 12f22e0ae0cbd748b416c7e2486f289f89c5c77c +Author: Jesse Adkins +Date: Tue Sep 28 13:30:03 2010 -0700 + + Purge cvs tags. + + Signed-off-by: Jesse Adkins + Signed-off-by: Alan Coopersmith + +commit 247ad2a3865ba503e6c77444f855c71e7a210f13 +Author: Gaetan Nadon +Date: Tue Aug 17 07:57:08 2010 -0400 + + man: store shadow man pages in git rather than generating them + + Simplify the build process and the makefile. + + Local fix in CVS for bug 5628 is not required + as the problem has been fixed in + util-macros d9062e4077ebfd0985baf8418f3d0f111b9ddbba + + Signed-off-by: Gaetan Nadon + +commit 8f23ad4703c7fcfdd7d53d52ddebb7590c3cb265 +Author: Alan Coopersmith +Date: Thu Jul 8 14:40:39 2010 -0700 + + Use make rules instead of shell for loops to generate shadow man pages + + Allows parallel make and simpler build logs/error reporting + + Signed-off-by: Alan Coopersmith + +commit 82bc24d6137cc4f03944af88e69c4d67b26d3cc9 +Author: Alan Coopersmith +Date: Thu Jul 8 14:34:18 2010 -0700 + + config: upgrade to util-macros 1.8 for additional man page support + + Use MAN_SUBST now supplied in XORG_MANPAGE_SECTIONS + The value of MAN_SUBST is the same for all X.Org packages. + + Use AC_PROG_SED now supplied by XORG_DEFAULT_OPTIONS + The existing statement can now be removed from the configuration file. + + Use automake provided $(AM_V_GEN) and XORG_DEFAULT_OPTIONS provided $(SED) + Enables silent rule and use platform appropriate version of sed. + + Signed-off-by: Alan Coopersmith + +commit 2e5c60f477fc68634f1fa31a2fc4a166642ab318 +Author: Fernando Carrijo +Date: Thu Jul 1 07:01:47 2010 -0300 + + Purge macros NEED_EVENTS and NEED_REPLIES + + Signed-off-by: Fernando Carrijo + Acked-by: Tiago Vignatti + Reviewed-by: Alan Coopersmith + +commit 18517a55d08cdcf9e29bed6761cf4311e1d4109f +Author: Leif Middelschulte +Date: Tue May 25 14:52:50 2010 -0300 + + Add parameter safety check + + As mentioned in bugzilla ticket 28150. + Calling '_XRRValidateCache' with 'improper' arguments results in a SEGV. + This patch adds a parameter validation to the mentioned function. + + Signed-off-by: Leif Middelschulte + Signed-off-by: Peter Hutterer + +commit 7a7bac907ac15033c0ddb979202c7f3ddc368726 +Author: Gaetan Nadon +Date: Mon Mar 29 16:50:34 2010 -0400 + + config: update AC_PREREQ statement to 2.60 + + Unrelated to the previous patches, the new value simply reflects + the reality that the minimum level for autoconf to configure + all x.org modules is 2.60 dated June 2006. + + ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz + + Signed-off-by: Gaetan Nadon + +commit 883acff30b23c2bdf446988ff7b780cd61e49a5e +Author: Gaetan Nadon +Date: Mon Mar 29 14:53:49 2010 -0400 + + config: remove the pkgconfig pc.in file from EXTRA_DIST + + Automake always includes it in the tarball. + + Signed-off-by: Gaetan Nadon + +commit 74bb9072015b8a785f6b6458ba0605287a1ffcaf +Author: Gaetan Nadon +Date: Tue Feb 16 10:37:21 2010 -0500 + + config: move CWARNFLAGS from configure.ac to Makefile.am + + Compiler warning flags should be explicitly set in the makefile + rather than being merged with other packages compiler flags. + + Signed-off-by: Gaetan Nadon + +commit 449d22180549d990ad3164c98b22968359b55df2 +Author: Gaetan Nadon +Date: Thu Jan 14 09:41:26 2010 -0500 + + COPYING: add missing copyright notices + + Refer to: Xrandr.h XrrConfig.c + Copyright © 2006 Intel Corporation + Copyright © 2008 Red Hat, Inc. + Copyright © 2006 Keith Packard + + Signed-off-by: Gaetan Nadon + +commit 51887f07a7722576933ddcc00c5380266d6fa37c +Author: Alan Coopersmith +Date: Thu Jan 14 21:02:20 2010 -0800 + + Update Sun license notices to current X.Org standard form + + Signed-off-by: Alan Coopersmith + +commit cd6fcaeaf0da7ca66ec0ab63ce282def37c21c3b +Author: Gaetan Nadon +Date: Fri Nov 27 20:56:04 2009 -0500 + + Makefile.am: add ChangeLog and INSTALL on MAINTAINERCLEANFILES + + Now that the INSTALL file is generated. + Allows running make maintainer-clean. + +commit 61c4a57286b601ff266a15565740aea31e68d1bb +Author: Gaetan Nadon +Date: Wed Oct 28 14:09:10 2009 -0400 + + INSTALL, NEWS, README or AUTHORS files are missing/incorrect #24206 + + Add missing INSTALL file. Use standard GNU file on building tarball + README may have been updated + Remove AUTHORS file as it is empty and no content available yet. + Remove NEWS file as it is empty and no content available yet. + +commit 170a3efb274d473165a8d6085c185792b1c43005 +Author: Gaetan Nadon +Date: Tue Oct 27 15:07:25 2009 -0400 + + Deploy the new XORG_DEFAULT_OPTIONS #24242 + + This macro aggregate a number of existing macros that sets commmon + X.Org components configuration options. It shields the configuration file from + future changes. + +commit 8567a45cb36857a8b5e2699a3d3ed7850b053281 +Author: Gaetan Nadon +Date: Mon Oct 26 22:08:43 2009 -0400 + + Makefile.am: ChangeLog not required: EXTRA_DIST or *CLEANFILES #24432 + + ChangeLog filename is known to Automake and requires no further + coding in the makefile. + +commit 015687dbec93d954fb18981bc6e15937a206a4b7 +Author: Gaetan Nadon +Date: Thu Oct 22 12:34:19 2009 -0400 + + .gitignore: use common defaults with custom section # 24239 + + Using common defaults will reduce errors and maintenance. + Only the very small or inexistent custom section need periodic maintenance + when the structure of the component changes. Do not edit defaults. + +commit 2e07e9d4f300e8153e4e93cd78bc51e0d91dba6f +Author: Adam Jackson +Date: Mon Nov 9 17:51:03 2009 -0500 + + GetCrtcGamma: Fix error handling. + + We didn't treat _XReply failure as fatal. Parsing an xError as a gamma + ramp reply doesn't work that often. + + Signed-off-by: Adam Jackson + Reviewed-by: Jamey Sharp + +commit 7b41b589213293793182b61f20006229a89d5ba7 +Author: Adam Jackson +Date: Mon Nov 9 17:50:42 2009 -0500 + + GetCrtcGammaSize: Return 0, not garbage, on failure + + Signed-off-by: Adam Jackson + Reviewed-by: Jamey Sharp + +commit 5e94f071f45ca504ccafe083e2e289351ba6eab4 +Author: Adam Jackson +Date: Mon Nov 9 17:49:40 2009 -0500 + + GetScreenSizeRange: Document funky return code in the header + + Signed-off-by: Adam Jackson + Reviewed-by: Jamey Sharp + +commit f98cbea8b33356a0de1f777c3a862ecbf163cfd3 +Author: Adam Jackson +Date: Mon Nov 9 17:49:10 2009 -0500 + + SetScreenConfigAndRate: Document error handling better + + Signed-off-by: Adam Jackson + Reviewed-by: Jamey Sharp + +commit a8af918c0db758a667345b7c3055075124197f6c +Author: Adam Jackson +Date: Mon Nov 9 17:48:22 2009 -0500 + + GetOutputProperty: Return the error code, not BadRequest + + Signed-off-by: Adam Jackson + Reviewed-by: Jamey Sharp + +commit 7f463b2a2221065c03b6122c0cffd2fa5cb13427 +Author: Jeremy Huddleston +Date: Wed Oct 21 12:47:26 2009 -0700 + + This is not a GNU project, so declare it foreign. + + On Wed, 2009-10-21 at 13:36 +1000, Peter Hutterer wrote: + > On Tue, Oct 20, 2009 at 08:23:55PM -0700, Jeremy Huddleston wrote: + > > I noticed an INSTALL file in xlsclients and libXvMC today, and it + > > was quite annoying to work around since 'autoreconf -fvi' replaces + > > it and git wants to commit it. Should these files even be in git? + > > Can I nuke them for the betterment of humanity and since they get + > > created by autoreconf anyways? + > + > See https://bugs.freedesktop.org/show_bug.cgi?id=24206 + + As an interim measure, replace AM_INIT_AUTOMAKE([dist-bzip2]) with + AM_INIT_AUTOMAKE([foreign dist-bzip2]). This will prevent the generation + of the INSTALL file. It is also part of the 24206 solution. + + Signed-off-by: Jeremy Huddleston + +commit e3036766916d55d0c8ae72d5752fd1699ae7390d +Author: Matthias Hopf +Date: Fri Mar 6 15:13:56 2009 +0100 + + Bump to 1.3.0 + +commit 6bf8648e7e408be7a869fd4c4527a4fd73fc687d +Author: Alan Coopersmith +Date: Mon Feb 2 20:34:36 2009 -0800 + + Add README with pointers to mailing list, bugzilla & git repos + + Signed-off-by: Alan Coopersmith + +commit 70d641c6d170cda44856579dfdcb42d3bb1f8221 +Author: Keith Packard +Date: Fri Jan 30 20:12:43 2009 -0800 + + Send X_RRGetOutputPrimary when making an X_RRGetOutputPrimary request + + Using X_RRGetOutputProperty does not yield success here. + + Signed-off-by: Keith Packard + +commit bf284b043d4c5688da2207647126b095f8c2b0cd +Author: Paulo Cesar Pereira de Andrade +Date: Fri Jan 30 16:38:03 2009 -0200 + + Janitor: make distcheck, compiler warnings, .gitignore + + Warning corrections are either unused symbols or using an + integer as a pointer (generated by sparse). + +commit a0c45b798d2fa810167d64a92093840178f993b1 +Author: Julien Cristau +Date: Sun Dec 21 16:32:17 2008 +0100 + + Fix thinkos + + * XRRExtensionInfo can be static + * XRRExtensionName is not called XrandrExtensionName + +commit 8574ffb20fa10b6f2e9a5f115f23506b93c64b12 +Author: Adam Jackson +Date: Wed Dec 17 11:33:37 2008 -0500 + + libXrandr 1.2.99.4 + +commit e2f075ea3927f83fb7ee8b359ef951222e8f894b +Author: Adam Jackson +Date: Wed Dec 17 11:29:05 2008 -0500 + + Define _XRRHasRates internally. + +commit 53bd07438d3671dca86df2bf3052f89ee8ce0891 +Author: Adam Jackson +Date: Wed Dec 17 11:27:19 2008 -0500 + + Be sure to return NULL when returning no properties. + +commit 7c1ccb19bd2545ccdf7099489e946e772a25649f +Author: Adam Jackson +Date: Wed Dec 17 11:25:20 2008 -0500 + + Use RRCheckExtension in function returning a value. + +commit 2db939e82c29fa3ab868bac9d2b54de18419004b +Author: Adam Jackson +Date: Wed Dec 17 11:24:33 2008 -0500 + + Fix type of GetReq() argument. + +commit c79e2aecab080d8f47b258ae3c4dd9394280ae2a +Author: Adam Jackson +Date: Wed Dec 17 11:23:51 2008 -0500 + + Use RRSimpleCheckExtension in functions returning void + +commit dda80ea67e33d18f7cc869c6f828c444c8966704 +Author: Matthias Hopf +Date: Fri Dec 12 13:04:57 2008 +0100 + + Bump to 1.2.99.3 + +commit 59c8812099f33d56b43044f999ffe5df16adf5ff +Author: Adam Jackson +Date: Mon Dec 8 15:37:53 2008 -0500 + + Add [GS]etOutputPrimary + +commit 0f11922bdc0d4e3929df4dc967379ea0b48338b8 +Author: Matthias Hopf +Date: Thu Dec 4 18:24:42 2008 +0100 + + Bump to 1.2.99.2. + + Note the .99 + +commit e788c1ed41e029e54470a2c79f1478c1be7bba92 +Author: Matthias Hopf +Date: Thu Dec 4 15:51:07 2008 +0100 + + Nuke config-timestamp for panning. + +commit 1de7212d9a945403f13f4dc15a66ec115c3be44c +Author: Matthias Hopf +Date: Fri Nov 28 17:26:43 2008 +0100 + + Panning support + +commit 0dd24bd6ad3c437f320c5d8e922c479fb61b115f +Author: Julien Cristau +Date: Mon Dec 1 21:19:35 2008 +0100 + + Bump to 1.2.91 + +commit 0fa7452220701ee44d8bafc57001e362afcedb0c +Author: Julien Cristau +Date: Mon Dec 1 21:09:44 2008 +0100 + + RRNotify subevents have 'window' at different offsets, the sequel + + f176b2bda103f6f38aabab8207f47a02cc797659 fixed XRRWireToEvent, but + XRREventToWire had the same bug. + + Signed-off-by: Julien Cristau + +commit 83e567f427f68dc4ae2de796a1184748bbe0238e +Merge: 908de8f 00f2e30 +Author: Julien Cristau +Date: Mon Dec 1 20:59:39 2008 +0100 + + Merge branch 'transform-proposal' of git.freedesktop.org:/git/xorg/lib/libXrandr + + Conflicts: + + src/Xrandr.c + +commit 00f2e30d0b8296668776d62a4c47f96bf95faa08 +Author: Julien Cristau +Date: Fri Nov 28 16:16:22 2008 +0100 + + Set attr->pendingNparams in XRRGetCrtcTransform() + +commit 908de8fc7228ecc7b02825ebede5fb937f3abf1b +Author: Adam Jackson +Date: Mon Nov 24 16:11:46 2008 -0500 + + Add GetScreenResourcesCurrent + +commit 377126fdaf1094354d54b1743f9d2bf1f2de1e0c +Author: Keith Packard +Date: Fri Sep 12 20:18:21 2008 -0700 + + Set NparamsFilter in XRRGetCrtcTransform return value. + + Leaving this uninitialized isn't very helpful, and can cause segfaults. + +commit f176b2bda103f6f38aabab8207f47a02cc797659 +Author: Tomas Carnecky +Date: Wed Aug 13 10:24:11 2008 -0400 + + RRNotify subevents have 'window' at different offsets. + +commit d631e453d62104b4a4afdcf0b34e6f3aefd62644 +Author: Adam Jackson +Date: Wed Aug 13 10:21:51 2008 -0400 + + Remove RCS tags. + +commit bf476779616b24c6456339bc77896460f1a2545a +Author: Adam Jackson +Date: Wed Jul 2 15:28:08 2008 -0400 + + libXrandr 1.2.3 + +commit 203fc002b6948c3942f0461a0346dd07b633222d +Author: thb +Date: Mon Jun 23 13:25:12 2008 -0400 + + Bug #16430: Ignore ConfigureNotify on non-root windows in UpdateConfiguration + +commit 332eee90c4d00be3b11049e0261323abe89a96dc +Author: Peter Hutterer +Date: Mon May 19 17:34:36 2008 +0930 + + Rename parameters to clarify QueryVersion/QueryExtension. + + These parameters are not treated as input. Rename them to make the inner + workings slightly more obvious. + + X.Org Bug 14511 + +commit 824f3d4a3a4669526a5c391c6668df0384b49cdb +Author: Julien Cristau +Date: Tue Feb 5 15:37:32 2008 +0100 + + Bug #14388: Remove XRRScreenConfig() and XRRConfig() from Xrandr.h. + + It seems that they were never actually implemented. + Also remove the corresponding manpage symlinks. + +commit 7a21e7bc994c5fa7d3ab15ba7201667e134f1512 +Author: Keith Packard +Date: Tue Mar 18 16:02:36 2008 -0700 + + Eliminate inverse matrix from randr transform protocol + + It is easier, and potentially more precise, to compute the inverse in the + server where everything can eventually be kept in floating point form. + +commit a6e5fa4ceb72795380496fcfe62c083866791dc1 +Author: Keith Packard +Date: Sat Mar 15 00:33:30 2008 -0700 + + Support CRTC Transform filters + + XRRGetCrtcTransform now returns a giant struct containing all of the + transform and filter data. + + XRRSetCrtcTransform now accepts filter parameters. + +commit 2a5fb0e58ed6ee1ff1f0ff00b5bf5b2623991132 +Author: Keith Packard +Date: Tue Mar 4 08:17:48 2008 -0800 + + Add support for new Transform requests. + +commit dc0ce2e363dbdac560fc2a8c1296c5468d75f644 +Author: Matthieu Herrb +Date: Sun Mar 9 08:37:17 2008 +0100 + + nuke RCS Ids + +commit 23a47035818390ca197179a9a69a54badb370990 +Author: Julien Cristau +Date: Tue Feb 5 15:35:30 2008 +0100 + + Hide some private symbols. + + XExtensionInfo, XRRExtensionName, XRRFindDisplay, _XRRHasRates and + _XRRVersionHandler are internal to libXrandr. Don't export them. + +commit 732ae92882383b33384791c2e9136a54e0fd06f3 +Author: James Cloos +Date: Thu Dec 6 16:38:42 2007 -0500 + + Replace static ChangeLog with dist-hook to generate from git log + +commit e56fa06624dc240dbe8d3e127cc3b65da580fe6e +Merge: 27b91d1 0294912 +Author: James Cloos +Date: Sun Nov 11 10:27:35 2007 -0500 + + Merge branch 'master' of git://git.freedesktop.org/git/xorg/lib/libXrandr + +commit 029491243b43c2e03a62c143ac21941449f335aa +Author: Eric Anholt +Date: Wed Sep 5 10:01:06 2007 -0700 + + Bump version to 1.2.2. + +commit 27b91d1d62acb70da7d131ee4b6da265d64cb835 +Author: James Cloos +Date: Mon Sep 3 05:53:48 2007 -0400 + + Add *~ to .gitignore to skip patch/emacs droppings + +commit 126143add5349fc34488b23d54d1bdcc7e8847b9 +Author: Keith Packard +Date: Tue Jul 3 09:58:09 2007 -0700 + + CrtcChange event format conversion was using 'height' for 'width'. + + CrtcChange events were getting the source 'height' value stored in the + 'width' target in both conversion directions. + +commit 3e753542bcf0fd49fe977e56b7ab7e540bbd4282 +Author: Keith Packard +Date: Sun Mar 4 20:03:59 2007 -0800 + + Set version to 1.2.1 for release. + +commit c279b64ccca18b14974e413b0b1d55ac81abceda +Author: Fredrik Höglund +Date: Tue Feb 20 22:30:00 2007 +0100 + + Fix the use of a C++ keyword as a parameter name in Xrandr.h + +commit 75d9944484651d4180e3079a739be4edb36545fe +Author: Keith Packard +Date: Sun Feb 18 20:57:31 2007 -0800 + + Reset version from 1.2.0.0 to 1.2.0 + +commit ac82ee50f3938b7b4d6dbcec850d38500258bfe0 +Author: Keith Packard +Date: Thu Feb 15 16:56:11 2007 -0800 + + Must pass size information in SetCrtcGamma request. + +commit 9c4fea702a0382689898fc14cbdab456fb18c403 +Merge: c85237a 382b7a3 +Author: Keith Packard +Date: Wed Jan 31 14:24:57 2007 -0800 + + Merge 64-bit fixes in + +commit c85237a1651ae8e1abe9ae442ffa04dcb20c1d3e +Author: Keith Packard +Date: Wed Jan 31 14:20:33 2007 -0800 + + Fix read sizes for 64-bit machines. + + Be consistent in variable usage: + nbytes = network byte length. + rbytes = memory byte length. + nbytesRead = actual network bytes read. + Malloc rbytes data to pass to _XRead*, but use nbytes as the + amount of data to read (yes, this is insane, welcome to Xlib). + Some of this patch is semi-gratuitous, but the goal is to be consistent + everywhere. + +commit 382b7a3cfabdd37a6231e18a2ac92bc8a3722b79 +Author: Eric Anholt +Date: Tue Jan 16 13:10:49 2007 -0800 + + Return a valid property info even if we lack valid value sets. + + Previously, XRRQueryOutputProperty90 would return an uninitialized pointer if + num_values was 0. + +commit 36a4a633a93a89bd854f49e670777925c9751de3 +Author: Keith Packard +Date: Sat Jan 6 12:42:47 2007 -0800 + + Avoid nested LockDisplay calls. + + XRRFindDisplay must make extension requests that use LockDisplay, so don't + call it with the display locked, instead pass the info around to the + internal functions that were calling it themselves, having acquired the info + before the outer LockDisplay is called. + +commit d70a3e7f111cb65c37edfa78ca66449338d3bb8f +Author: Keith Packard +Date: Sat Dec 30 13:11:10 2006 -0800 + + Failed to copy rotations from reply to XRRCrtcInfo. + + XRRGetCrtcInfo was not moving the rotations value from the wire reply + structure to the XRRCrtcInfo being returned, leaving the value uninitialized. + +commit bc75a92cac23dad4a661a13e6af121f6072cecc8 +Merge: 7fcdcbb 370fa28 +Author: Dave Airlie +Date: Sat Dec 2 11:27:36 2006 +1100 + + Merge branch 'randr-1.2' + +commit 370fa28a6afd70ec91411edf1413c0e448ae45b6 +Author: Keith Packard +Date: Thu Nov 30 21:56:59 2006 -0800 + + Add initial implementation of crtc gamma and mode adding requests. + + They build. More testing seems indicated. + +commit 7fcdcbb0f9c4736bd678be7f9bf76d472293233f +Merge: 875867f 0dba1be +Author: Eric Anholt +Date: Mon Nov 27 15:41:03 2006 -0800 + + Merge branch 'randr-1.2' + + Conflicts: + + configure.ac + +commit 0dba1be7969aa56f934d93889cbd589b3dafd3d4 +Author: Keith Packard +Date: Mon Nov 20 20:59:18 2006 -0800 + + Change properties to have a pending value and report valid values. + + Pending values are transferred to current values at mode set, allowing a + queue of values to accrue in preparation for the modeset operation while + still reporting valid 'current' values for applications. + + The set of valid values is also available so applications can present + a reasonable list to the user during configuration. + +commit 8edabfeba65562f026111b35ec14a9801b4b6a5c +Author: Keith Packard +Date: Thu Nov 16 13:35:46 2006 -0800 + + Remove RandR output options. + + Options are to be implemented as properties instead. + +commit 7ac8dba76fe33b13620e023699bf971fe8c99fb2 +Author: Eric Anholt +Date: Thu Nov 9 20:26:33 2006 -0800 + + Return the right actual property type for XRRGetOutputProperty. + +commit b49342b58d17267fae81205f1a89263ec4d3d114 +Author: Eric Anholt +Date: Thu Nov 9 17:07:55 2006 -0800 + + Add support for various output property requests. + + These should be reviewed by someone with proto clue, which I'm generally + lacking. + +commit 6676505b6012c97d2f711a84237fa14a62d1d33d +Author: Keith Packard +Date: Wed Nov 1 00:25:45 2006 -0800 + + Moving physical size from mode to output. + + Follows protocol change which places physical size + information in the output rather than (inappropriately) + in each mode line. + +commit 875867f275803682e58f0649f054a83293c6e02c +Author: Adam Jackson +Date: Fri Oct 13 17:09:57 2006 -0400 + + Bump to 1.1.2 + +commit 6eacf491a094add48363d530357dce0d25b8f244 +Author: Adam Jackson +Date: Fri Oct 13 16:25:00 2006 -0400 + + Bump to 1.1.1 + +commit d914d05d34991b4cfa3af411fd2a3e281ea0e73b +Author: Jamey Sharp +Date: Thu Oct 12 17:42:48 2006 -0700 + + Do not call UnlockDisplay without calling LockDisplay. + + Thanks to Magnus Kessler for reporting this + bug and a correct fix. + +commit ab4207db14d70384f017cc2a22379d7c358b60e0 +Author: Keith Packard +Date: Wed Oct 4 20:04:09 2006 -0700 + + Remove mode origins. Add preferred mode count. + +commit dd0fb435a0168d4041ecd81024d6493295651c61 +Author: Keith Packard +Date: Tue Oct 3 21:03:10 2006 -0700 + + Add mode origins and output options. + +commit cb1dbb7c2446ddf514ee709fba940cc4e75438a0 +Author: Keith Packard +Date: Wed Sep 20 20:00:57 2006 -0700 + + XRRGetScreenSizeRange returns Status. Lots more requests added. + + XRRGetCrtcInfo + XRRSetCrtcConfig + XRRGetScreenSizeRange + XRRSetScreenSize + + properties still to do. + +commit c712df73eeb0cb84aad6a0bec2be0f480418c217 +Author: Keith Packard +Date: Tue Sep 19 00:42:49 2006 -0700 + + Start update to 1.2, splitting code across multiple files. + +commit a8abbe92f0486f174fb89ca2c81eabede646bf32 +Author: Alan Coopersmith +Date: Thu Jul 13 14:59:05 2006 -0700 + + renamed: .cvsignore -> .gitignore + +commit 88f4e37d937f171352dc0089a0903c0a3d9487d8 +Author: Alan Coopersmith +Date: Sun Feb 12 18:19:22 2006 +0000 + + Bug #5628 Shadow pages + not created correctly when MANDIR & MANSUFFIX don't match. + +commit c6541af3ef1cfaba57a73369090b6ac1a38b9b1e +Author: Kevin E Martin +Date: Thu Dec 15 00:24:33 2005 +0000 + + Update package version number for final X11R7 release candidate. + +commit be2b102d0ce89f4ac2eb2c2aad5b2e3af947abba +Author: Kevin E Martin +Date: Tue Dec 6 22:48:44 2005 +0000 + + Change *man_SOURCES ==> *man_PRE to fix autotools warnings. + +commit 8f9937022d259917ea7f1a3fefab58607300756a +Author: Kevin E Martin +Date: Sat Dec 3 05:49:45 2005 +0000 + + Update package version number for X11R7 RC3 release. + +commit 127ec4993118efe56caef761febef86eae2b7300 +Author: Kevin E Martin +Date: Sat Dec 3 04:41:50 2005 +0000 + + Add check and cflags for malloc(0) returning NULL. + +commit 89f4aca8d76806edf51d4999223011cbff1c3f55 +Author: Alan Coopersmith +Date: Mon Nov 28 22:03:06 2005 +0000 + + Change *mandir targets to use new *_MAN_DIR variables set by xorg-macros.m4 + update to fix bug #5167 (Linux prefers *.1x man pages in man1 subdir) + +commit bf2fcad15b7bf2c505f5478648bf6ecbc0be701a +Author: Kevin E Martin +Date: Sat Nov 19 07:15:43 2005 +0000 + + Update pkgconfig files to separate library build-time dependencies from + application build-time dependencies, and update package deps to work + with separate build roots. + +commit a27c3d61d107fe4af33181a63f8ea951367ff418 +Author: Kevin E Martin +Date: Mon Nov 14 22:02:13 2005 +0000 + + Fix pkgconfig deps for separate build roots. + +commit 1d690983d20e3d874b7f0e7f430e3d0cf2710c53 +Author: Kevin E Martin +Date: Wed Nov 9 21:19:13 2005 +0000 + + Update package version number for X11R7 RC2 release. + +commit 090314b101b9d3626dc0dc970be68aec7e382d0f +Author: Kevin E Martin +Date: Tue Nov 1 15:11:51 2005 +0000 + + Update pkgcheck dependencies to work with separate build roots. + +commit 2deac5f213ee0a1cedccc721cd015691661b8002 +Author: Kevin E Martin +Date: Wed Oct 19 02:48:11 2005 +0000 + + Update package version number for RC1 release. + +commit 33d17445401ec09bb0c2305d477b00c3abc2182a +Author: Alan Coopersmith +Date: Tue Oct 18 00:00:09 2005 +0000 + + Use @LIB_MAN_SUFFIX@ instead of $(LIB_MAN_SUFFIX) in macro substitutions to + work better with BSD make + +commit a42c72fe8924e98f0794e37dec8e5ef49fd7423c +Author: Alan Coopersmith +Date: Mon Oct 17 21:13:22 2005 +0000 + + Rename .shadows.DONE to shadows.DONE to avoid some make's thinking it's a + suffix rule (reported by Matthieu Herrb) + +commit 13ec5d5d689bb03e01d8f269d2c7a72e4cf0b5f1 +Author: Alan Coopersmith +Date: Thu Oct 13 05:06:10 2005 +0000 + + [lib/Xrandr] + Use sed to fill in variables in man page Add shadow man pages for man pages + that document multiple functions. + +commit 544ec9ae021fecc6001df97a6000095f294b7422 +Author: Alan Coopersmith +Date: Thu Oct 13 02:56:42 2005 +0000 + + Fix troff macros from last commit to not generate cpp warnings + +commit f678f6cc9b73960c3ad61cc93fc61acefbe40ef5 +Author: Alan Coopersmith +Date: Wed Oct 12 23:45:05 2005 +0000 + + Use troff macros to prevent cpp eating C comments & #defines that are + supposed to appear in man page output. + +commit a42516d3a5aa532ed7c19fa128afd63d159676f8 +Author: Aaron Plattner +Date: Fri Sep 30 04:25:14 2005 +0000 + + Bug #2965 Patch #2994 + Swap the screen + dimensions when handling XRRScreenChangeNotify events for 90- and + 270-degree rotations. This fixes KDE's panel placement for rotated + screens. + +commit f9c9043f2a6787cdb6ab130f66fd39b29e7f2506 +Author: Kevin E Martin +Date: Fri Jul 29 21:22:52 2005 +0000 + + Various changes preparing packages for RC0: + - Verify and update package version numbers as needed + - Implement versioning scheme + - Change bug address to point to bugzilla bug entry form + - Disable loadable i18n in libX11 by default (use --enable-loadable-i18n to + reenable it) + - Fix makedepend to use pkgconfig and pass distcheck + - Update build script to build macros first + - Update modular Xorg version + +commit 6fd64a5c552ce5f0559838b2b4ae5a27b40e52f1 +Author: Kevin E Martin +Date: Sat Jul 23 05:27:00 2005 +0000 + + Fix distchecks + +commit bceba127b9b671e378030b348f36602eb44278af +Author: Daniel Stone +Date: Sat Jul 16 07:34:59 2005 +0000 + + Set soversion to 2.0.0 with -version-number. + +commit 63538e6c68e1697e027e55a5015791de3af7bc8c +Author: Keith Packard +Date: Sat Jul 9 06:48:05 2005 +0000 + + Add .cvsignore files Switch _la_CFLAGS for AM_CFLAGS to clean up directory + +commit 3f5e389cb5bd5305cc45aca522086d3b92506265 +Author: Kevin E Martin +Date: Sat Jul 2 06:35:03 2005 +0000 + + Add appropriate lib*_CFLAGS to Makefile.am's -- fixes build problems + +commit 48a3a08206e827a5af88d6a2d8ac62aa3bbbe122 +Author: Daniel Stone +Date: Fri Jun 10 14:10:29 2005 +0000 + + Bug #1976: Fix deadlock when attempting to initialise with threads. + +commit 1279a7f95e654bb33c9057e25a291e2a093f2dee +Author: Alexander Gottwald +Date: Thu Jun 9 12:52:44 2005 +0000 + + Require renderproto instead of render for pkgconfig + +commit 9c36643810a7e837f325970ddd5964bbff4971b6 +Author: Søren Sandmann Pedersen +Date: Wed Jun 8 20:22:47 2005 +0000 + + - Don't search for non-autoconf'ed X libs in Xrandr + - Rename man page Xrandr.3 + +commit 73b3dff9d12d417716c19a33a95eac5f73e5da13 +Author: Søren Sandmann Pedersen +Date: Wed Jun 8 19:19:31 2005 +0000 + + Add Xcursor + conditionally include config.h + +commit 32107cdd57b4796c3f41ac56c9ba683be3d894af +Author: Søren Sandmann Pedersen +Date: Wed Jun 8 17:48:03 2005 +0000 + + Check in build system for Xrandr + +commit 84264cf7a9ce88850f3bc18428e2c046ff0251ed +Author: Markus Kuhn +Date: Sat Dec 4 00:42:48 2004 +0000 + + Encoding of numerous files changed to UTF-8 + +commit a9b18ca5a13816d4ffbbd00d3fc80a048e84e94f +Author: Egbert Eich +Date: Mon May 24 19:06:58 2004 +0000 + + Fix build glitches when building modules independently using Imake. + +commit 76f134caf8da6a08f0fb3587868efaec401c7e74 +Author: Egbert Eich +Date: Fri Apr 23 18:43:47 2004 +0000 + + Merging XORG-CURRENT into trunk + +commit 634976e69c2d0cd014ac537acb1e52884c1d89b2 +Author: Egbert Eich +Date: Sun Mar 14 08:32:25 2004 +0000 + + Importing vendor version xf86-4_4_99_1 on Sun Mar 14 00:26:39 PST 2004 + +commit f07005c663731709ec6c5d7f36492ff3ac253845 +Author: Egbert Eich +Date: Wed Mar 3 12:11:30 2004 +0000 + + Importing vendor version xf86-4_4_0 on Wed Mar 3 04:09:24 PST 2004 + +commit e61377128a66342b8e39a4c5b7e2acd34f38799f +Author: Egbert Eich +Date: Thu Feb 26 13:35:33 2004 +0000 + + readding XFree86's cvs IDs + +commit 696a58bfcb75b56cad6e5994f8c974ac4bb884da +Author: Egbert Eich +Date: Thu Feb 26 09:22:44 2004 +0000 + + Importing vendor version xf86-4_3_99_903 on Wed Feb 26 01:21:00 PST 2004 + +commit 731775dea70f37fd41e4a384d484236e9d0ce4ef +Author: Kaleb Keithley +Date: Thu Dec 4 22:02:57 2003 +0000 + + XFree86 4.3.99.901 (RC 1) + +commit 35eca17cac066690575683bc1367b1fdaba1f4cc +Author: Kaleb Keithley +Date: Tue Nov 25 19:28:15 2003 +0000 + + XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folks + +commit 8a8b419755dd3c815cc70265ed0d44e5f31028cc +Author: Kaleb Keithley +Date: Fri Nov 14 16:48:49 2003 +0000 + + XFree86 4.3.0.1 + +commit 52d0891b9e3c51d43fd13d0b2680b7e24b2f2e2d +Author: Kaleb Keithley +Date: Fri Nov 14 16:48:49 2003 +0000 + + Initial revision diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..8b82ade --- /dev/null +++ b/INSTALL @@ -0,0 +1,291 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008 Free Software Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *Note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7d6700d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,37 @@ +# +# Copyright © 2003 Keith Packard, Noah Levitt +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Keith Packard not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Keith Packard makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +SUBDIRS = src man + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = xrandr.pc + +MAINTAINERCLEANFILES = ChangeLog INSTALL + +.PHONY: ChangeLog INSTALL + +INSTALL: + $(INSTALL_CMD) + +ChangeLog: + $(CHANGELOG_CMD) + +dist-hook: ChangeLog INSTALL diff --git a/README b/README new file mode 100644 index 0000000..b035b8b --- /dev/null +++ b/README @@ -0,0 +1,25 @@ +libXrandr - X Resize, Rotate and Reflection extension library + +All questions regarding this software should be directed at the +Xorg mailing list: + + http://lists.freedesktop.org/mailman/listinfo/xorg + +Please submit bug reports to the Xorg bugzilla: + + https://bugs.freedesktop.org/enter_bug.cgi?product=xorg + +The master development code repository can be found at: + + git://anongit.freedesktop.org/git/xorg/lib/libXrandr + + http://cgit.freedesktop.org/xorg/lib/libXrandr + +For patch submission instructions, see: + + http://www.x.org/wiki/Development/Documentation/SubmittingPatches + +For more information on the git code manager, see: + + http://wiki.x.org/wiki/GitPage + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..218197d --- /dev/null +++ b/autogen.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +#$srcdir/configure --enable-maintainer-mode "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..d89cc8b --- /dev/null +++ b/configure.ac @@ -0,0 +1,63 @@ +# +# Copyright © 2003 Keith Packard, Noah Levitt +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Keith Packard not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Keith Packard makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# + +# Initialize Autoconf +AC_PREREQ([2.60]) +# +# Version should match the current Randr version. XRRQueryVersion +# returns the version from randr.h, NOT the version we set here. But we +# try to keep these the same. Note that the library has an extra +# digit in the version number to track changes which don't affect the +# protocol, so Xrandr version l.n.m corresponds to protocol version l.n +# +AC_INIT([libXrandr], [1.4.0], + [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXrandr]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) + +# Initialize Automake +AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AM_MAINTAINER_MODE + +# Initialize libtool +AC_PROG_LIBTOOL + +# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.8) +XORG_DEFAULT_OPTIONS +XORG_CHECK_MALLOC_ZERO + +# Check randr configuration, strip extra digits from package version to +# find the required protocol version +RANDR_VERSION=[`echo $VERSION | sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`] +AC_SUBST(RANDR_VERSION) + +# Obtain compiler/linker options for depedencies +PKG_CHECK_MODULES(RANDR, x11 randrproto >= $RANDR_VERSION xext xextproto xrender renderproto) + +AC_CONFIG_FILES([Makefile + src/Makefile + man/Makefile + xrandr.pc]) +AC_OUTPUT diff --git a/include/X11/extensions/Xrandr.h b/include/X11/extensions/Xrandr.h new file mode 100644 index 0000000..b1baf8a --- /dev/null +++ b/include/X11/extensions/Xrandr.h @@ -0,0 +1,557 @@ +/* + * Copyright © 2000 Compaq Computer Corporation, Inc. + * Copyright © 2002 Hewlett-Packard Company, Inc. + * Copyright © 2006 Intel Corporation + * Copyright © 2008 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. + * Keith Packard, Intel Corporation + */ + +#ifndef _XRANDR_H_ +#define _XRANDR_H_ + +#include +#include + +#include + +_XFUNCPROTOBEGIN + +typedef XID RROutput; +typedef XID RRCrtc; +typedef XID RRMode; +typedef XID RRProvider; + +typedef struct { + int width, height; + int mwidth, mheight; +} XRRScreenSize; + +/* + * Events. + */ + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + Window root; /* Root window for changed screen */ + Time timestamp; /* when the screen change occurred */ + Time config_timestamp; /* when the last configuration change */ + SizeID size_index; + SubpixelOrder subpixel_order; + Rotation rotation; + int width; + int height; + int mwidth; + int mheight; +} XRRScreenChangeNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_ subtype */ +} XRRNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_OutputChange */ + RROutput output; /* affected output */ + RRCrtc crtc; /* current crtc (or None) */ + RRMode mode; /* current mode (or None) */ + Rotation rotation; /* current rotation of associated crtc */ + Connection connection; /* current connection status */ + SubpixelOrder subpixel_order; +} XRROutputChangeNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_CrtcChange */ + RRCrtc crtc; /* current crtc (or None) */ + RRMode mode; /* current mode (or None) */ + Rotation rotation; /* current rotation of associated crtc */ + int x, y; /* position */ + unsigned int width, height; /* size */ +} XRRCrtcChangeNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_OutputProperty */ + RROutput output; /* related output */ + Atom property; /* changed property */ + Time timestamp; /* time of change */ + int state; /* NewValue, Deleted */ +} XRROutputPropertyNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_ProviderChange */ + RRProvider provider; /* current provider (or None) */ + Time timestamp; /* time of change */ + unsigned int current_role; +} XRRProviderChangeNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_ProviderProperty */ + RRProvider provider; /* related provider */ + Atom property; /* changed property */ + Time timestamp; /* time of change */ + int state; /* NewValue, Deleted */ +} XRRProviderPropertyNotifyEvent; + +typedef struct { + int type; /* event base */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window which selected for this event */ + int subtype; /* RRNotify_ResourceChange */ + Time timestamp; /* time of change */ +} XRRResourceChangeNotifyEvent; + +/* internal representation is private to the library */ +typedef struct _XRRScreenConfiguration XRRScreenConfiguration; + +Bool XRRQueryExtension (Display *dpy, + int *event_base_return, + int *error_base_return); +Status XRRQueryVersion (Display *dpy, + int *major_version_return, + int *minor_version_return); + +XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy, + Window window); + +void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config); + +/* + * Note that screen configuration changes are only permitted if the client can + * prove it has up to date configuration information. We are trying to + * insist that it become possible for screens to change dynamically, so + * we want to ensure the client knows what it is talking about when requesting + * changes. + */ +Status XRRSetScreenConfig (Display *dpy, + XRRScreenConfiguration *config, + Drawable draw, + int size_index, + Rotation rotation, + Time timestamp); + +/* added in v1.1, sorry for the lame name */ +Status XRRSetScreenConfigAndRate (Display *dpy, + XRRScreenConfiguration *config, + Drawable draw, + int size_index, + Rotation rotation, + short rate, + Time timestamp); + + +Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation); + +Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp); + +XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes); + +short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates); + +SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config, + Rotation *rotation); + +short XRRConfigCurrentRate (XRRScreenConfiguration *config); + +int XRRRootToScreen(Display *dpy, Window root); + +/* + * returns the screen configuration for the specified screen; does a lazy + * evalution to delay getting the information, and caches the result. + * These routines should be used in preference to XRRGetScreenInfo + * to avoid unneeded round trips to the X server. These are new + * in protocol version 0.1. + */ + + +void XRRSelectInput(Display *dpy, Window window, int mask); + +/* + * the following are always safe to call, even if RandR is not implemented + * on a screen + */ + + +Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation); +XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes); +short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates); +Time XRRTimes (Display *dpy, int screen, Time *config_timestamp); + + +/* Version 1.2 additions */ + +/* despite returning a Status, this returns 1 for success */ +Status +XRRGetScreenSizeRange (Display *dpy, Window window, + int *minWidth, int *minHeight, + int *maxWidth, int *maxHeight); + +void +XRRSetScreenSize (Display *dpy, Window window, + int width, int height, + int mmWidth, int mmHeight); + +typedef unsigned long XRRModeFlags; + +typedef struct _XRRModeInfo { + RRMode id; + unsigned int width; + unsigned int height; + unsigned long dotClock; + unsigned int hSyncStart; + unsigned int hSyncEnd; + unsigned int hTotal; + unsigned int hSkew; + unsigned int vSyncStart; + unsigned int vSyncEnd; + unsigned int vTotal; + char *name; + unsigned int nameLength; + XRRModeFlags modeFlags; +} XRRModeInfo; + +typedef struct _XRRScreenResources { + Time timestamp; + Time configTimestamp; + int ncrtc; + RRCrtc *crtcs; + int noutput; + RROutput *outputs; + int nmode; + XRRModeInfo *modes; +} XRRScreenResources; + +XRRScreenResources * +XRRGetScreenResources (Display *dpy, Window window); + +void +XRRFreeScreenResources (XRRScreenResources *resources); + +typedef struct _XRROutputInfo { + Time timestamp; + RRCrtc crtc; + char *name; + int nameLen; + unsigned long mm_width; + unsigned long mm_height; + Connection connection; + SubpixelOrder subpixel_order; + int ncrtc; + RRCrtc *crtcs; + int nclone; + RROutput *clones; + int nmode; + int npreferred; + RRMode *modes; +} XRROutputInfo; + +XRROutputInfo * +XRRGetOutputInfo (Display *dpy, XRRScreenResources *resources, RROutput output); + +void +XRRFreeOutputInfo (XRROutputInfo *outputInfo); + +Atom * +XRRListOutputProperties (Display *dpy, RROutput output, int *nprop); + +typedef struct { + Bool pending; + Bool range; + Bool immutable; + int num_values; + long *values; +} XRRPropertyInfo; + +XRRPropertyInfo * +XRRQueryOutputProperty (Display *dpy, RROutput output, Atom property); + +void +XRRConfigureOutputProperty (Display *dpy, RROutput output, Atom property, + Bool pending, Bool range, int num_values, + long *values); + +void +XRRChangeOutputProperty (Display *dpy, RROutput output, + Atom property, Atom type, + int format, int mode, + _Xconst unsigned char *data, int nelements); + +void +XRRDeleteOutputProperty (Display *dpy, RROutput output, Atom property); + +int +XRRGetOutputProperty (Display *dpy, RROutput output, + Atom property, long offset, long length, + Bool _delete, Bool pending, Atom req_type, + Atom *actual_type, int *actual_format, + unsigned long *nitems, unsigned long *bytes_after, + unsigned char **prop); + +XRRModeInfo * +XRRAllocModeInfo (char *name, int nameLength); + +RRMode +XRRCreateMode (Display *dpy, Window window, XRRModeInfo *modeInfo); + +void +XRRDestroyMode (Display *dpy, RRMode mode); + +void +XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode); + +void +XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode); + +void +XRRFreeModeInfo (XRRModeInfo *modeInfo); + +typedef struct _XRRCrtcInfo { + Time timestamp; + int x, y; + unsigned int width, height; + RRMode mode; + Rotation rotation; + int noutput; + RROutput *outputs; + Rotation rotations; + int npossible; + RROutput *possible; +} XRRCrtcInfo; + +XRRCrtcInfo * +XRRGetCrtcInfo (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); + +void +XRRFreeCrtcInfo (XRRCrtcInfo *crtcInfo); + +Status +XRRSetCrtcConfig (Display *dpy, + XRRScreenResources *resources, + RRCrtc crtc, + Time timestamp, + int x, int y, + RRMode mode, + Rotation rotation, + RROutput *outputs, + int noutputs); + +int +XRRGetCrtcGammaSize (Display *dpy, RRCrtc crtc); + +typedef struct _XRRCrtcGamma { + int size; + unsigned short *red; + unsigned short *green; + unsigned short *blue; +} XRRCrtcGamma; + +XRRCrtcGamma * +XRRGetCrtcGamma (Display *dpy, RRCrtc crtc); + +XRRCrtcGamma * +XRRAllocGamma (int size); + +void +XRRSetCrtcGamma (Display *dpy, RRCrtc crtc, XRRCrtcGamma *gamma); + +void +XRRFreeGamma (XRRCrtcGamma *gamma); + +/* Version 1.3 additions */ + +XRRScreenResources * +XRRGetScreenResourcesCurrent (Display *dpy, Window window); + +void +XRRSetCrtcTransform (Display *dpy, + RRCrtc crtc, + XTransform *transform, + char *filter, + XFixed *params, + int nparams); + +typedef struct _XRRCrtcTransformAttributes { + XTransform pendingTransform; + char *pendingFilter; + int pendingNparams; + XFixed *pendingParams; + XTransform currentTransform; + char *currentFilter; + int currentNparams; + XFixed *currentParams; +} XRRCrtcTransformAttributes; + +/* + * Get current crtc transforms and filters. + * Pass *attributes to XFree to free + */ +Status +XRRGetCrtcTransform (Display *dpy, + RRCrtc crtc, + XRRCrtcTransformAttributes **attributes); + +/* + * intended to take RRScreenChangeNotify, or + * ConfigureNotify (on the root window) + * returns 1 if it is an event type it understands, 0 if not + */ +int XRRUpdateConfiguration(XEvent *event); + +typedef struct _XRRPanning { + Time timestamp; + unsigned int left; + unsigned int top; + unsigned int width; + unsigned int height; + unsigned int track_left; + unsigned int track_top; + unsigned int track_width; + unsigned int track_height; + int border_left; + int border_top; + int border_right; + int border_bottom; +} XRRPanning; + +XRRPanning * +XRRGetPanning (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); + +void +XRRFreePanning (XRRPanning *panning); + +Status +XRRSetPanning (Display *dpy, + XRRScreenResources *resources, + RRCrtc crtc, + XRRPanning *panning); + +void +XRRSetOutputPrimary(Display *dpy, + Window window, + RROutput output); + +RROutput +XRRGetOutputPrimary(Display *dpy, + Window window); + +typedef struct _XRRProviderResources { + Time timestamp; + int nproviders; + RRProvider *providers; +} XRRProviderResources; + +XRRProviderResources * +XRRGetProviderResources(Display *dpy, Window window); + +void +XRRFreeProviderResources(XRRProviderResources *resources); + +typedef struct _XRRProviderInfo { + unsigned int capabilities; + int ncrtcs; + RRCrtc *crtcs; + int noutputs; + RROutput *outputs; + char *name; + int nassociatedproviders; + RRProvider *associated_providers; + unsigned int *associated_capability; + int nameLen; +} XRRProviderInfo; + +XRRProviderInfo * +XRRGetProviderInfo(Display *dpy, XRRScreenResources *resources, RRProvider provider); + +void +XRRFreeProviderInfo(XRRProviderInfo *provider); + +int +XRRSetProviderOutputSource(Display *dpy, XID provider, XID source_provider); + +int +XRRSetProviderOffloadSink(Display *dpy, XID provider, XID sink_provider); + +Atom * +XRRListProviderProperties (Display *dpy, RRProvider provider, int *nprop); + +XRRPropertyInfo * +XRRQueryProviderProperty (Display *dpy, RRProvider provider, Atom property); + +void +XRRConfigureProviderProperty (Display *dpy, RRProvider provider, Atom property, + Bool pending, Bool range, int num_values, + long *values); + +void +XRRChangeProviderProperty (Display *dpy, RRProvider provider, + Atom property, Atom type, + int format, int mode, + _Xconst unsigned char *data, int nelements); + +void +XRRDeleteProviderProperty (Display *dpy, RRProvider provider, Atom property); + +int +XRRGetProviderProperty (Display *dpy, RRProvider provider, + Atom property, long offset, long length, + Bool _delete, Bool pending, Atom req_type, + Atom *actual_type, int *actual_format, + unsigned long *nitems, unsigned long *bytes_after, + unsigned char **prop); + +_XFUNCPROTOEND + +#endif /* _XRANDR_H_ */ diff --git a/man/Makefile.am b/man/Makefile.am new file mode 100644 index 0000000..f3bc1b8 --- /dev/null +++ b/man/Makefile.am @@ -0,0 +1,55 @@ +# +# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +libmandir = $(LIB_MAN_DIR) + +libman_PRE = \ + Xrandr.man \ + $(Xrandr_shadows:=.man) + +Xrandr_shadows = \ + XRRQueryExtension \ + XRRQueryVersion \ + XRRGetScreenInfo \ + XRRFreeScreenConfigInfo \ + XRRSetScreenConfig \ + XRRSetScreenConfigAndRate \ + XRRConfigRotations \ + XRRConfigTimes \ + XRRConfigSizes \ + XRRConfigRates \ + XRRConfigCurrentConfiguration \ + XRRConfigCurrentRate \ + XRRRootToScreen \ + XRRSelectInput + +libman_DATA = $(libman_PRE:man=@LIB_MAN_SUFFIX@) + +EXTRA_DIST = $(libman_PRE) +CLEANFILES = $(libman_DATA) + +SUFFIXES = .$(LIB_MAN_SUFFIX) .man + +# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure +.man.$(LIB_MAN_SUFFIX): + $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@ diff --git a/man/XRRConfigCurrentConfiguration.man b/man/XRRConfigCurrentConfiguration.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRConfigCurrentConfiguration.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRConfigCurrentRate.man b/man/XRRConfigCurrentRate.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRConfigCurrentRate.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRConfigRates.man b/man/XRRConfigRates.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRConfigRates.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRConfigRotations.man b/man/XRRConfigRotations.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRConfigRotations.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRConfigSizes.man b/man/XRRConfigSizes.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRConfigSizes.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRConfigTimes.man b/man/XRRConfigTimes.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRConfigTimes.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRFreeScreenConfigInfo.man b/man/XRRFreeScreenConfigInfo.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRFreeScreenConfigInfo.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRGetScreenInfo.man b/man/XRRGetScreenInfo.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRGetScreenInfo.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRQueryExtension.man b/man/XRRQueryExtension.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRQueryExtension.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRQueryVersion.man b/man/XRRQueryVersion.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRQueryVersion.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRRootToScreen.man b/man/XRRRootToScreen.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRRootToScreen.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRSelectInput.man b/man/XRRSelectInput.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRSelectInput.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRSetScreenConfig.man b/man/XRRSetScreenConfig.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRSetScreenConfig.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/XRRSetScreenConfigAndRate.man b/man/XRRSetScreenConfigAndRate.man new file mode 100644 index 0000000..e02ca38 --- /dev/null +++ b/man/XRRSetScreenConfigAndRate.man @@ -0,0 +1 @@ +.so man__libmansuffix__/Xrandr.__libmansuffix__ diff --git a/man/Xrandr.man b/man/Xrandr.man new file mode 100644 index 0000000..0f95bf1 --- /dev/null +++ b/man/Xrandr.man @@ -0,0 +1,348 @@ +.\" +.\" Copyright 2002 Hewlett-Packard Company.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation, and that the name of Hewlett-Packard Company not be used in +.\" advertising or publicity pertaining to distribution of the software without +.\" specific, written prior permission. Hewlett Packard Company makes no +.\" representations about the suitability of this software for any purpose. It +.\" is provided "as is" without express or implied warranty. +.\" +.\" Hewlett-Packard DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +.\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +.\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +.\" PERFORMANCE OF THIS SOFTWARE. +.\" +.de TQ +.br +.ns +.TP \\$1 +.. +.TH XRANDR __libmansuffix__ __vendorversion__ + +.SH NAME + Xrandr \- X Resize, Rotate and Reflection extension. +.SH SYNTAX +\&#include +.nf +.sp +Bool XRRQueryExtension \^(\^Display *\fIdpy\fP, + int *\fIevent_base_return\fP, int *\fIerror_base_return\fP\^); +.sp +Status XRRQueryVersion \^(\^Display *\fIdpy\fP, + int *\fImajor_version_return\fP, + int *\fIminor_version_return\fP\^); +.sp +XRRScreenConfiguration *XRRGetScreenInfo \^(\^Display *dpy, + Drawable \fIdraw\fP\^); +.sp +void XRRFreeScreenConfigInfo \^(\^ + \fIXRRScreenConfiguration *config\fP\^); +.sp +Status XRRSetScreenConfig \^(\^Display *\fIdpy\fP, + XRRScreenConfiguration *\fIconfig\fP, + Drawable \fIdraw\fP, + int \fIsize_index\fP, + Rotation \fIrotation\fP, + Time \fItimestamp\fP\^); +.sp +Status XRRSetScreenConfigAndRate \^(\^Display *\fIdpy\fP, + XRRScreenConfiguration *\fIconfig\fP, + Drawable \fIdraw\fP, + int \fIsize_index\fP, + Rotation \fIrotation\fP, + short \fIrate\fP, + Time \fItimestamp\fP\^); +.sp +Rotation XRRConfigRotations\^(\^ + XRRScreenConfiguration *\fIconfig\fP, + Rotation *\fIcurrent_rotation\fP\^); +.sp +Time XRRConfigTimes \^(\^ + XRRScreenConfiguration *\fIconfig\fP, + Time *\fIconfig_timestamp\fP\^); +.sp +XRRScreenSize *XRRConfigSizes\^(\^ + XRRScreenConfiguration *\fIconfig\fP, + int *\fInsizes\fP\^); +.sp +short *XRRConfigRates \^(\^ + XRRScreenConfiguration *\fIconfig\fP, + int \fIsize_index\fP, + int *\fInrates\fP\^); +.sp +SizeID XRRConfigCurrentConfiguration \^(\^ + XRRScreenConfiguration *\fIconfig\fP, + Rotation *\fIrotation\fP\^); +.sp +short XRRConfigCurrentRate \^(\^ + XRRScreenConfiguration *\fIconfig\fP\^); +.sp +int XRRRootToScreen\^(\^ + Display *\fIdpy\fP, + Window \fIroot\fP\^); +.sp +void XRRSelectInput\^(\^Display *\fIdpy\fP, Window \fIwindow\fP, int \fImask\fP\^); +.sp +/\(** + * intended to take RRScreenChangeNotify, or + * ConfigureNotify \^(\^\fIon the root window\fP\^) + * returns 1 if it is an event type it understands, 0 if not + */ +int XRRUpdateConfiguration\^(\^XEvent *\fIevent\fP\^); +.sp +/\(** + * the following are always safe to call, even if RandR is + * not implemented on a screen + */ +.br +Rotation XRRRotations\^(\^ + Display *\fIdpy\fP, int \fIscreen\fP, + Rotation *\fIcurrent_rotation\fP\^); +.sp +XRRScreenSize *XRRSizes\^(\^Display *\fIdpy\fP, + int \fIscreen\fP, int *\fInsizes\fP\^); +.sp +short *XRRRates \^(\^Display *\fIdpy\fP, int \fIscreen\fP, + int \fIsize_index\fP, int *\fInrates\fP\^); +.sp +Time XRRTimes \^(\^Display *\fIdpy\fP, int \fIscreen\fP, Time *\fIconfig_timestamp\fP\^); +.fi +.SH ARGUMENTS +.IP \fIdisplay\fP 1i +Specifies the connection to the X server. +.IP \fIscreen\fP 1i +Specifies which screen. +.IP \fIdraw\fP 1i +Specifies the screen. +.IP \fIrotation\fP 1i +Specifies the possible rotations or reflections of the screen. +.IP \fIcurrent_rotation\fP 1i +Specifies the current rotations and reflection of the screen. +.IP \fItimestamp\fP 1i +Specifies the server timestamp. +.IP \fIconfig_timestamp\fP 1i +Specifies the timestamp when the screen was last (re)configured. +.IP \fIconfig\fP 1i +Specifies the screen configuration being used. +.IP \fIsizes\fP 1i +Specifies the array of supported sizes. +.IP \fIrate\fP 1i +Specifies the refresh rate in Hz. + +.SH DATATYPES + +.PP +.B Rotations/Reflections +.PP +Can be any of: +.nf +\&#define RR_Rotate_0 1 +\&#define RR_Rotate_90 2 +\&#define RR_Rotate_180 4 +\&#define RR_Rotate_270 8 + +/\(** new in 1.0 protocol, to allow reflection of screen */ +/\(** reflection is applied after rotation */ + +\&#define RR_Reflect_X 16 +\&#define RR_Reflect_Y 32 + + +typedef struct { + int width, height; + int mwidth, mheight; +} XRRScreenSize; + +typedef struct { + int type; /\(** event base */ + unsigned long serial; /\(** # of last request processed by server */ + Bool send_event; /\(** true if this came from a SendEvent request */ + Display *display; /\(** Display the event was read from */ + Window window; /\(** window which selected for this event */ + Window root; /\(** Root window for changed screen */ + Time timestamp; /\(** when the screen change occurred */ + Time config_timestamp; /\(** when the last configuration change */ + SizeID size_index; + SubpixelOrder subpixel_order; + Rotation rotation; + int width; + int height; + int mwidth; + int mheight; +} XRRScreenChangeNotifyEvent; +.sp +.fi +The +.B XRRScreenSize +structure contains a possible root size in pixels and in millimeters. + +A +.B XRRScreenChangeNotifyEvent +is sent to a client that has requested notification whenever the screen +configuration is changed. A client can perform this request by calling +\fBXRRSelectInput\fP, passing the display, the root window, and the +\fBRRScreenChangeNotifyMask\fP mask. + +.B XRRScreenConfiguration +is an opaque data type containing the configuration information +for a screen. + +.B Timestamps +.PP +Time stamps are included and must be used to ensure the client is playing +with a full deck: the screen may change properties +on the fly and this ensures its knowledge of the configuration is up to date. +This is to help issues when screens may become hot-pluggable in the future. + +.SH DESCRIPTION +.B Xrandr +is a simple library designed to interface the X Resize and Rotate +Extension. This allows clients to change the size and rotation of the +root window of a screen, along with the ability to reflect the screen +about either axis (if supported by the implementation). Rotation and +reflection may be implemented by software and may result in slower +performance if rotation and reflection are implemented in this fashion +(as are all implementations as of October 2002). +.PP +The Xrandr library does some minimal caching to avoid roundtrips to +provide clients frequently used information. See "The X Resize and +Rotate Extension" for a detailed description; also note that depth +switching, as described in the document is not implemented, and may +(or may not) ever be implemented, as display memory is growing rapidly, +and toolkits are already beginning to support migration, mitigating the +need for depth switching. If it is implemented in the future, we +expect to do so via an upward compatible extension to the +current library/protocol; functionality described here should continue +to work. +.PP +Rotation and reflection and how they interact can be confusing. In +Randr, the coordinate system is rotated in a counter-clockwise +direction relative to the normal orientation. Reflection is along the +window system coordinate system, not the physical screen X and Y axis, +so that rotation and reflection do not interact. The other way to +consider reflection is to treat it as specified in the "normal" +orientation, before rotation. +.PP +The +.B XRRScreenChangeNotify +event is sent to clients that ask to be informed whenever the root window +configuration changes. Configuration changes may include resolution, +physical size, subpixel order (see XRender(3)), and rotation. Note +that changes to any or all of these could occur due to external events +(user control in the X server, a different monitor/flat panel display +being hot-plugged) and is not only the result of a protocol/library +request to the X server. +.PP +Additionally, to eliminate a potential race condition, +this event may be generated +immediately upon selecting for notification if the screen has changed +since the client of Xrandr connected to the X server, to enable +reliable screen resolution changing when a user may log in and +change the configuration while one or many clients are starting up. +.PP +.B Xlib notification +.PP +Clients must call back into Xlib using +.B XRRUpdateConfiguration +when screen configuration change notify events are generated +(or root window configuration changes occur, to update Xlib's +view of the resolution, size, rotation, reflection or subpixel order. +Generally, toolkits will perform this operation on behalf of applications; +we did not want to change display structure data behind the back of toolkits, +as in multithreaded clients, various race conditions might occur. +Toolkits should provide clients some mechanism for notification of +screen change, of course. + +.SH FUNCTIONS +There are two classes of interfaces: those which can be safely called +even if RandR is not implemented on a screen (to make common idioms not +dependent on the server having support), and those which will return +errors if the extension is not present. +.PP +.B XRRRotations +returns both the possible set of rotations/reflections supported +(as a bitmask) as the value of the function, along with the current +rotation/reflection of the screen. +.PP +.B XRRSizes +returns the size and a pointer to the current sizes supported by +the specified screen. The first size specified is the default size +of the server. If RandR is not supported, it returns 0 for +the number of sizes. +.PP +.B XRRRates +returns a pointer to the rates supported by the specified size. +If RandR is not supported, it returns 0 for the number of rates. +.PP +.B XRRTimes +returns the time last reported by the server along with the +timestamp the last configuration changed. +If the configuration has changed since the client last updated +its view of the server time, requests to change the configuration +will fail until the client has an up to date timestamp. +.PP +.B XRRRootToScreen +returns the screen number given a root window (for example, from +an \fBXRRScreenChangeNotifyEvent\fP). +.PP +The rest of the functions will fail if applied to screens not +implementing the RandR extension. +.B XRRSetScreenConfig +sets the screen size and rotation and reflection to the desired +values on the screen specified by \fIdraw\fP, or returns a +.B BadValue +error. +\fIsize_index\fP specifies which size configuration is to be used, +\fIrotation\fP specifies which rotation or reflection is to +be used (or a +.B BadValue +error is returned). +The \fItimestamp\fP is used by the server to make sure the client +has up to date configuration information. Status is returned +to indicate success or failure; a client must refresh its configuration +information if it fails and try the call again (by calling +\fBXRRGetScreenInfo\fP). +.PP +.B XRRSetScreenConfigAndRate +is like +.B XRRSetScreenConfig +but also sets the refresh rate. If specified rate is not supported a +.B BadValue +error is returned. +.PP +.B XRRConfigRotations, +.B XRRConfigSizes, +.B XRRConfigCurrentConfiguration, +.B XRRConfigTimes, +.B XRRConfigRates, +and +.B XRRConfigCurrentRate +are used to get specific configuration information out of a screen +configuration. +.PP +.B XRRGetScreenInfo +returns a screen configuration for later use; the information is +private to the library. +Call +.B XRRFreeScreenConfigInfo +to free this information when you are finished with it. +It forces a round trip to the server. + +Other functions include: +.B XRRQueryExtension +which returns the event and error base codes, +.B XRRQueryVersion +, which returns the current version of the extension (this information +is cached by the library). +.SH RESTRICTIONS +.B Xrandr +will remain upward compatible after the current 1.0 release. +.SH AUTHOR +Jim Gettys, and Keith Packard, HP. + diff --git a/packaging/libXrandr.spec b/packaging/libXrandr.spec new file mode 100755 index 0000000..eb82952 --- /dev/null +++ b/packaging/libXrandr.spec @@ -0,0 +1,66 @@ +Summary: X.Org X11 libXrandr runtime library +Name: libXrandr +Version: 1.4.0 +Release: 3 +License: MIT +Group: System Environment/Libraries +URL: http://www.x.org + +Source0: %{name}-%{version}.tar.gz + +BuildRequires: pkgconfig(xorg-macros) +BuildRequires: pkgconfig(xproto) +BuildRequires: pkgconfig(randrproto) >= 1.3.0 +BuildRequires: pkgconfig(xrender) +BuildRequires: pkgconfig(xext) + +%description +X.Org X11 libXrandr runtime library + +%package devel +Summary: X.Org X11 libXrandr development package +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Provides: libxrandr-devel + +%description devel +X.Org X11 libXrandr development package + +%prep +%setup -q + +%build +%reconfigure --disable-static \ + LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed" +make %{?jobs:-j%jobs} + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p %{buildroot}/usr/share/license +cp -af COPYING %{buildroot}/usr/share/license/%{name} +make install DESTDIR=$RPM_BUILD_ROOT + +rm -f $RPM_BUILD_ROOT%{_libdir}/*.la + +%remove_docs + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root,-) +/usr/share/license/%{name} +%doc AUTHORS COPYING ChangeLog +%{_libdir}/libXrandr.so.2 +%{_libdir}/libXrandr.so.2.2.0 + +%files devel +%defattr(-,root,root,-) +%{_includedir}/X11/extensions/Xrandr.h +%{_libdir}/libXrandr.so +%{_libdir}/pkgconfig/xrandr.pc +#%dir %{_mandir}/man3x +#%{_mandir}/man3/*.3* diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..7a47b9c --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,27 @@ +lib_LTLIBRARIES = libXrandr.la + +libXrandr_la_SOURCES = \ + Xrandr.c \ + Xrandrint.h \ + XrrConfig.c \ + XrrCrtc.c \ + XrrMode.c \ + XrrOutput.c \ + XrrProperty.c \ + XrrScreen.c \ + XrrProvider.c \ + XrrProviderProperty.c + +libXrandr_la_LIBADD = @RANDR_LIBS@ + +AM_CFLAGS = \ + $(RANDR_CFLAGS) \ + $(MALLOC_ZERO_CFLAGS) \ + $(CWARNFLAGS) + +INCLUDES = -I$(top_srcdir)/include/X11/extensions + +libXrandr_la_LDFLAGS = -version-number 2:2:0 -no-undefined + +libXrandrincludedir = $(includedir)/X11/extensions +libXrandrinclude_HEADERS = $(top_srcdir)/include/X11/extensions/Xrandr.h diff --git a/src/Xrandr.c b/src/Xrandr.c new file mode 100644 index 0000000..b1e97ec --- /dev/null +++ b/src/Xrandr.c @@ -0,0 +1,513 @@ +/* + * Copyright © 2000 Compaq Computer Corporation, Inc. + * Copyright © 2002 Hewlett Packard Company, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Compaq or HP not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. HP makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Jim Gettys, HP Labs, HP. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +static XExtensionInfo XRRExtensionInfo; +_X_HIDDEN char XRRExtensionName[] = RANDR_NAME; + +static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire); +static Status XRREventToWire(Display *dpy, XEvent *event, xEvent *wire); + +static int +XRRCloseDisplay (Display *dpy, XExtCodes *codes); + +static /* const */ XExtensionHooks rr_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + XRRCloseDisplay, /* close_display */ + XRRWireToEvent, /* wire_to_event */ + XRREventToWire, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + +static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + + RRCheckExtension(dpy, info, False); + + switch ((wire->u.u.type & 0x7F) - info->codes->first_event) + { + case RRScreenChangeNotify: { + XRRScreenChangeNotifyEvent *aevent= (XRRScreenChangeNotifyEvent *) event; + xRRScreenChangeNotifyEvent *awire = (xRRScreenChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->root = awire->root; + aevent->timestamp = awire->timestamp; + aevent->config_timestamp = awire->configTimestamp; + aevent->size_index = awire->sizeID; + aevent->subpixel_order = awire->subpixelOrder; + aevent->rotation = awire->rotation; + aevent->width = awire->widthInPixels; + aevent->height = awire->heightInPixels; + aevent->mwidth = awire->widthInMillimeters; + aevent->mheight = awire->heightInMillimeters; + return True; + } + case RRNotify: { + switch (wire->u.u.detail) { + case RRNotify_OutputChange: { + XRROutputChangeNotifyEvent *aevent = (XRROutputChangeNotifyEvent *) event; + xRROutputChangeNotifyEvent *awire = (xRROutputChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; + aevent->output = awire->output; + aevent->crtc = awire->crtc; + aevent->mode = awire->mode; + aevent->rotation = awire->rotation; + aevent->connection = awire->connection; + aevent->subpixel_order = awire->subpixelOrder; + return True; + } + case RRNotify_CrtcChange: { + XRRCrtcChangeNotifyEvent *aevent = (XRRCrtcChangeNotifyEvent *) event; + xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; + aevent->crtc = awire->crtc; + aevent->mode = awire->mode; + aevent->rotation = awire->rotation; + aevent->x = awire->x; + aevent->y = awire->y; + aevent->width = awire->width; + aevent->height = awire->height; + return True; + } + case RRNotify_OutputProperty: { + XRROutputPropertyNotifyEvent *aevent = (XRROutputPropertyNotifyEvent *) event; + xRROutputPropertyNotifyEvent *awire = (xRROutputPropertyNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; + aevent->output = awire->output; + aevent->property = awire->atom; + aevent->timestamp = awire->timestamp; + aevent->state = awire->state; + return True; + } + case RRNotify_ProviderChange: { + XRRProviderChangeNotifyEvent *aevent = (XRRProviderChangeNotifyEvent *) event; + xRRProviderChangeNotifyEvent *awire = (xRRProviderChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; + aevent->provider = awire->provider; + aevent->timestamp = awire->timestamp; + return True; + } + case RRNotify_ProviderProperty: { + XRRProviderPropertyNotifyEvent *aevent = (XRRProviderPropertyNotifyEvent *) event; + xRRProviderPropertyNotifyEvent *awire = (xRRProviderPropertyNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; + aevent->provider = awire->provider; + aevent->property = awire->atom; + aevent->timestamp = awire->timestamp; + aevent->state = awire->state; + return True; + } + case RRNotify_ResourceChange: { + XRRResourceChangeNotifyEvent *aevent = (XRRResourceChangeNotifyEvent *) event; + xRRResourceChangeNotifyEvent *awire = (xRRResourceChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; + aevent->timestamp = awire->timestamp; + return True; + } + break; + } + } + } + + return False; +} + +static Status XRREventToWire(Display *dpy, XEvent *event, xEvent *wire) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + + RRCheckExtension(dpy, info, False); + + switch ((event->type & 0x7F) - info->codes->first_event) + { + case RRScreenChangeNotify: { + xRRScreenChangeNotifyEvent *awire = (xRRScreenChangeNotifyEvent *) wire; + XRRScreenChangeNotifyEvent *aevent = (XRRScreenChangeNotifyEvent *) event; + awire->type = aevent->type | (aevent->send_event ? 0x80 : 0); + awire->rotation = (CARD8) aevent->rotation; + awire->sequenceNumber = aevent->serial & 0xFFFF; + awire->timestamp = aevent->timestamp; + awire->configTimestamp = aevent->config_timestamp; + awire->root = aevent->root; + awire->window = aevent->window; + awire->sizeID = aevent->size_index; + awire->subpixelOrder = aevent->subpixel_order; + awire->widthInPixels = aevent->width; + awire->heightInPixels = aevent->height; + awire->widthInMillimeters = aevent->mwidth; + awire->heightInMillimeters = aevent->mheight; + return True; + } + case RRNotify: { + xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; + XRRNotifyEvent *aevent = (XRRNotifyEvent *) event; + awire->type = aevent->type | (aevent->send_event ? 0x80 : 0); + awire->sequenceNumber = aevent->serial & 0xFFFF; + awire->subCode = aevent->subtype; + switch (aevent->subtype) { + case RRNotify_OutputChange: { + xRROutputChangeNotifyEvent *awire = (xRROutputChangeNotifyEvent *) wire; + XRROutputChangeNotifyEvent *aevent = (XRROutputChangeNotifyEvent *) event; + awire->window = aevent->window; + awire->output = aevent->output; + awire->crtc = aevent->crtc; + awire->mode = aevent->mode; + awire->rotation = aevent->rotation; + awire->connection = aevent->connection; + awire->subpixelOrder = aevent->subpixel_order; + return True; + } + case RRNotify_CrtcChange: { + xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; + XRRCrtcChangeNotifyEvent *aevent = (XRRCrtcChangeNotifyEvent *) event; + awire->window = aevent->window; + awire->crtc = aevent->crtc; + awire->mode = aevent->mode; + awire->rotation = aevent->rotation; + awire->x = aevent->x; + awire->y = aevent->y; + awire->width = aevent->width; + awire->height = aevent->height; + return True; + } + case RRNotify_OutputProperty: { + xRROutputPropertyNotifyEvent *awire = (xRROutputPropertyNotifyEvent *) wire; + XRROutputPropertyNotifyEvent *aevent = (XRROutputPropertyNotifyEvent *) event; + awire->window = aevent->window; + awire->output = aevent->output; + awire->atom = aevent->property; + awire->timestamp = aevent->timestamp; + awire->state = aevent->state; + return True; + } + case RRNotify_ProviderChange: { + xRRProviderChangeNotifyEvent *awire = (xRRProviderChangeNotifyEvent *) wire; + XRRProviderChangeNotifyEvent *aevent = (XRRProviderChangeNotifyEvent *) event; + awire->window = aevent->window; + awire->provider = aevent->provider; + return True; + } + case RRNotify_ProviderProperty: { + xRRProviderPropertyNotifyEvent *awire = (xRRProviderPropertyNotifyEvent *) wire; + XRRProviderPropertyNotifyEvent *aevent = (XRRProviderPropertyNotifyEvent *) event; + awire->window = aevent->window; + awire->provider = aevent->provider; + awire->atom = aevent->property; + awire->timestamp = aevent->timestamp; + awire->state = aevent->state; + return True; + } + case RRNotify_ResourceChange: { + xRRResourceChangeNotifyEvent *awire = (xRRResourceChangeNotifyEvent *) wire; + XRRResourceChangeNotifyEvent *aevent = (XRRResourceChangeNotifyEvent *) event; + awire->window = aevent->window; + awire->timestamp = aevent->timestamp; + return True; + } + } + } + } + return False; +} + +_X_HIDDEN XExtDisplayInfo * +XRRFindDisplay (Display *dpy) +{ + XExtDisplayInfo *dpyinfo; + XRandRInfo *xrri; + int i, numscreens; + + dpyinfo = XextFindDisplay (&XRRExtensionInfo, dpy); + if (!dpyinfo) { + dpyinfo = XextAddDisplay (&XRRExtensionInfo, dpy, + XRRExtensionName, + &rr_extension_hooks, + RRNumberEvents, NULL); + numscreens = ScreenCount(dpy); + xrri = Xmalloc (sizeof(XRandRInfo) + + sizeof(char *) * numscreens); + xrri->config = (XRRScreenConfiguration **)(xrri + 1); + for(i = 0; i < numscreens; i++) + xrri->config[i] = NULL; + xrri->major_version = -1; + dpyinfo->data = (char *) xrri; + } + return dpyinfo; +} + +static int +XRRCloseDisplay (Display *dpy, XExtCodes *codes) +{ + int i; + XRRScreenConfiguration **configs; + XExtDisplayInfo *info = XRRFindDisplay (dpy); + XRandRInfo *xrri; + + LockDisplay(dpy); + /* + * free cached data + */ + if (XextHasExtension(info)) { + xrri = (XRandRInfo *) info->data; + if (xrri) { + configs = xrri->config; + + for (i = 0; i < ScreenCount(dpy); i++) { + if (configs[i] != NULL) XFree (configs[i]); + } + XFree (xrri); + } + } + UnlockDisplay(dpy); + return XextRemoveDisplay (&XRRExtensionInfo, dpy); +} + +int XRRRootToScreen(Display *dpy, Window root) +{ + int snum; + for (snum = 0; snum < ScreenCount(dpy); snum++) { + if (RootWindow(dpy, snum) == root) return snum; + } + return -1; +} + + +Bool XRRQueryExtension (Display *dpy, + int *event_base_return, + int *error_base_return) +{ + XExtDisplayInfo *info = XRRFindDisplay (dpy); + + if (XextHasExtension(info)) { + *event_base_return = info->codes->first_event; + *error_base_return = info->codes->first_error; + return True; + } else { + return False; + } +} + +_X_HIDDEN Bool +_XRRHasRates (int major, int minor) +{ + return major > 1 || (major == 1 && minor >= 1); +} + +Status XRRQueryVersion (Display *dpy, + int *major_versionp, + int *minor_versionp) +{ + XExtDisplayInfo *info = XRRFindDisplay (dpy); + xRRQueryVersionReply rep; + xRRQueryVersionReq *req; + XRandRInfo *xrri; + + RRCheckExtension (dpy, info, 0); + + xrri = (XRandRInfo *) info->data; + + /* + * only get the version information from the server if we don't have it already + */ + if (xrri->major_version == -1) { + LockDisplay (dpy); + GetReq (RRQueryVersion, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRQueryVersion; + req->majorVersion = RANDR_MAJOR; + req->minorVersion = RANDR_MINOR; + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { + UnlockDisplay (dpy); + SyncHandle (); + return 0; + } + xrri->major_version = rep.majorVersion; + xrri->minor_version = rep.minorVersion; + xrri->has_rates = _XRRHasRates (xrri->major_version, xrri->minor_version); + UnlockDisplay (dpy); + SyncHandle (); + } + *major_versionp = xrri->major_version; + *minor_versionp = xrri->minor_version; + return 1; +} + +_X_HIDDEN Bool +_XRRVersionHandler (Display *dpy, + xReply *rep, + char *buf, + int len, + XPointer data) +{ + xRRQueryVersionReply replbuf; + xRRQueryVersionReply *repl; + _XRRVersionState *state = (_XRRVersionState *) data; + + if (dpy->last_request_read != state->version_seq) + return False; + if (rep->generic.type == X_Error) + { + state->error = True; + return False; + } + repl = (xRRQueryVersionReply *) + _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, + (SIZEOF(xRRQueryVersionReply) - SIZEOF(xReply)) >> 2, + True); + state->major_version = repl->majorVersion; + state->minor_version = repl->minorVersion; + return True; +} + +/* + * in protocol version 0.1, routine added to allow selecting for new events. + */ + +void XRRSelectInput (Display *dpy, Window window, int mask) +{ + XExtDisplayInfo *info = XRRFindDisplay (dpy); + xRRSelectInputReq *req; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay (dpy); + GetReq (RRSelectInput, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSelectInput; + req->window = window; + req->enable = 0; + if (mask) req->enable = mask; + UnlockDisplay (dpy); + SyncHandle (); + return; +} + +int XRRUpdateConfiguration(XEvent *event) +{ + XRRScreenChangeNotifyEvent *scevent; + XConfigureEvent *rcevent; + Display *dpy = event->xany.display; + XExtDisplayInfo *info; + XRandRInfo *xrri; + int snum; + + /* first, see if it is a vanilla configure notify event */ + if (event->type == ConfigureNotify) { + rcevent = (XConfigureEvent *) event; + snum = XRRRootToScreen(dpy, rcevent->window); + if (snum != -1) { + dpy->screens[snum].width = rcevent->width; + dpy->screens[snum].height = rcevent->height; + return 1; + } + } + + info = XRRFindDisplay(dpy); + RRCheckExtension (dpy, info, 0); + + switch (event->type - info->codes->first_event) { + case RRScreenChangeNotify: + scevent = (XRRScreenChangeNotifyEvent *) event; + snum = XRRRootToScreen(dpy, + ((XRRScreenChangeNotifyEvent *) event)->root); + if (scevent->rotation & (RR_Rotate_90 | RR_Rotate_270)) { + dpy->screens[snum].width = scevent->height; + dpy->screens[snum].height = scevent->width; + dpy->screens[snum].mwidth = scevent->mheight; + dpy->screens[snum].mheight = scevent->mwidth; + } else { + dpy->screens[snum].width = scevent->width; + dpy->screens[snum].height = scevent->height; + dpy->screens[snum].mwidth = scevent->mwidth; + dpy->screens[snum].mheight = scevent->mheight; + } + XRenderSetSubpixelOrder (dpy, snum, scevent->subpixel_order); + break; + default: + return 0; + } + xrri = (XRandRInfo *) info->data; + /* + * so the next time someone wants some data, it will be fetched; + * it might be better to force the round trip immediately, but + * I dislike pounding the server simultaneously when not necessary + */ + if (xrri->config[snum] != NULL) { + XFree (xrri->config[snum]); + xrri->config[snum] = NULL; + } + return 1; +} diff --git a/src/Xrandrint.h b/src/Xrandrint.h new file mode 100644 index 0000000..aed10e4 --- /dev/null +++ b/src/Xrandrint.h @@ -0,0 +1,98 @@ +/* + * Copyright © 2000, Compaq Computer Corporation, + * Copyright © 2002, Hewlett Packard, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Compaq or HP not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. HP makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. + */ + +#ifndef _XRANDRINT_H_ +#define _XRANDRINT_H_ + +#include +#include +#include +#include +#include "Xrandr.h" +#include +#include + +extern char XRRExtensionName[]; + +#define RRCheckExtension(dpy,i,val) \ + XextCheckExtension (dpy, i, XRRExtensionName, val) +#define RRSimpleCheckExtension(dpy,i) \ + XextSimpleCheckExtension (dpy, i, XRRExtensionName) + +XExtDisplayInfo *XRRFindDisplay (Display *dpy); + + +/* deliberately opaque internal data structure; can be extended, + but not reordered */ +struct _XRRScreenConfiguration { + Screen *screen; /* the root window in GetScreenInfo */ + XRRScreenSize *sizes; + Rotation rotations; + Rotation current_rotation; + int nsizes; + int current_size; + short current_rate; + Time timestamp; + Time config_timestamp; + int subpixel_order; /* introduced in randr v0.1 */ + short *rates; /* introduced in randr v1.1 */ + int nrates; +}; + +/* + * if a configure notify on the root is recieved, or + * an XRRScreenChangeNotify is recieved, + * XRRUpdateConfiguration should be called to update the X library's + * view of the screen configuration; it will also invalidate the cache + * provided by XRRScreenConfig and XRRConfig, and force a round trip + * when next used. Returns invalid status if not an event type + * the library routine understand. + */ + +/* we cache one screen configuration/screen */ + +typedef struct _XRandRInfo { + XRRScreenConfiguration **config; + int major_version, minor_version; /* major_version = -1 means we don't know */ + Bool has_rates; /* Server supports refresh rates */ +} XRandRInfo; + +typedef struct _randrVersionState { + unsigned long version_seq; + Bool error; + int major_version; + int minor_version; +} _XRRVersionState; + +Bool +_XRRVersionHandler (Display *dpy, + xReply *rep, + char *buf, + int len, + XPointer data); + +_X_HIDDEN Bool +_XRRHasRates (int major, int minor); + +#endif /* _XRANDRINT_H_ */ diff --git a/src/XrrConfig.c b/src/XrrConfig.c new file mode 100644 index 0000000..2f0282b --- /dev/null +++ b/src/XrrConfig.c @@ -0,0 +1,434 @@ +/* + * Copyright © 2000 Compaq Computer Corporation, Inc. + * Copyright © 2002 Hewlett Packard Company, Inc. + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + * Author: Jim Gettys, HP Labs, HP. + * Author: Keith Packard, Intel Corporation + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +static XRRScreenConfiguration *_XRRGetScreenInfo (Display *dpy, + XExtDisplayInfo *info, + Window window); + +Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation) +{ + *current_rotation = config->current_rotation; + return config->rotations; +} + +XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes) +{ + *nsizes = config->nsizes; + return config->sizes; +} + +short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates) +{ + short *r = config->rates; + int nents = config->nrates; + + /* Skip over the intervening rate lists */ + while (sizeID > 0 && nents > 0) + { + int i = (*r + 1); + r += i; + nents -= i; + sizeID--; + } + if (!nents) + { + *nrates = 0; + return NULL; + } + *nrates = (int) *r; + return r + 1; +} + +Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp) +{ + *config_timestamp = config->config_timestamp; + return config->timestamp; +} + + +SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config, + Rotation *rotation) +{ + *rotation = (Rotation) config->current_rotation; + return (SizeID) config->current_size; +} + +short XRRConfigCurrentRate (XRRScreenConfiguration *config) +{ + return config->current_rate; +} + +/* + * Go get the screen configuration data and salt it away for future use; + * returns NULL if extension not supported + */ +static XRRScreenConfiguration *_XRRValidateCache (Display *dpy, + XExtDisplayInfo *info, + int screen) +{ + XRRScreenConfiguration **configs; + XRandRInfo *xrri; + + if ((screen >= 0) && (screen < ScreenCount(dpy)) && XextHasExtension(info)) { + xrri = (XRandRInfo *) info->data; + configs = xrri->config; + + if (configs[screen] == NULL) + configs[screen] = _XRRGetScreenInfo (dpy, info, RootWindow(dpy, screen)); + return configs[screen]; + } else { + return NULL; + } +} + +/* given a screen, return the information from the (possibly) cached data */ +Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation) +{ + XRRScreenConfiguration *config; + XExtDisplayInfo *info = XRRFindDisplay(dpy); + Rotation cr; + LockDisplay(dpy); + if ((config = _XRRValidateCache(dpy, info, screen))) { + *current_rotation = config->current_rotation; + cr = config->rotations; + UnlockDisplay(dpy); + return cr; + } + else { + UnlockDisplay(dpy); + *current_rotation = RR_Rotate_0; + return 0; /* no rotations supported */ + } +} + +/* given a screen, return the information from the (possibly) cached data */ +XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes) +{ + XRRScreenConfiguration *config; + XExtDisplayInfo *info = XRRFindDisplay(dpy); + XRRScreenSize *sizes; + + LockDisplay(dpy); + if ((config = _XRRValidateCache(dpy, info, screen))) { + *nsizes = config->nsizes; + sizes = config->sizes; + UnlockDisplay(dpy); + return sizes; + } + else { + UnlockDisplay(dpy); + *nsizes = 0; + return NULL; + } +} + +short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates) +{ + XRRScreenConfiguration *config; + XExtDisplayInfo *info = XRRFindDisplay(dpy); + short *rates; + + LockDisplay(dpy); + if ((config = _XRRValidateCache(dpy, info, screen))) { + rates = XRRConfigRates (config, sizeID, nrates); + UnlockDisplay(dpy); + return rates; + } + else { + UnlockDisplay(dpy); + *nrates = 0; + return NULL; + } +} + +/* given a screen, return the information from the (possibly) cached data */ +Time XRRTimes (Display *dpy, int screen, Time *config_timestamp) +{ + XRRScreenConfiguration *config; + XExtDisplayInfo *info = XRRFindDisplay(dpy); + Time ts; + + LockDisplay(dpy); + if ((config = _XRRValidateCache(dpy, info, screen))) { + *config_timestamp = config->config_timestamp; + ts = config->timestamp; + UnlockDisplay(dpy); + return ts; + } else { + UnlockDisplay(dpy); + return CurrentTime; + } +} + +/* need a version that does not hold the display lock */ +static XRRScreenConfiguration *_XRRGetScreenInfo (Display *dpy, + XExtDisplayInfo *info, + Window window) +{ + xRRGetScreenInfoReply rep; + xRRGetScreenInfoReq *req; + _XAsyncHandler async; + _XRRVersionState async_state; + int nbytes, nbytesRead, rbytes; + int i; + xScreenSizes size; + struct _XRRScreenConfiguration *scp; + XRRScreenSize *ssp; + short *rates; + xRRQueryVersionReq *vreq; + XRandRInfo *xrri; + Bool getting_version = False; + + xrri = (XRandRInfo *) info->data; + if (!xrri) + return NULL; + + if (xrri->major_version == -1) + { + /* hide a version query in the request */ + GetReq (RRQueryVersion, vreq); + vreq->reqType = info->codes->major_opcode; + vreq->randrReqType = X_RRQueryVersion; + vreq->majorVersion = RANDR_MAJOR; + vreq->minorVersion = RANDR_MINOR; + + async_state.version_seq = dpy->request; + async_state.error = False; + async.next = dpy->async_handlers; + async.handler = _XRRVersionHandler; + async.data = (XPointer) &async_state; + dpy->async_handlers = &async; + + getting_version = True; + } + + GetReq (RRGetScreenInfo, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetScreenInfo; + req->window = window; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + if (getting_version) + DeqAsyncHandler (dpy, &async); + SyncHandle (); + return NULL; + } + if (getting_version) + { + DeqAsyncHandler (dpy, &async); + if (async_state.error) + { + UnlockDisplay (dpy); + SyncHandle(); + LockDisplay (dpy); + } + xrri->major_version = async_state.major_version; + xrri->minor_version = async_state.minor_version; + xrri->has_rates = _XRRHasRates (xrri->minor_version, xrri->major_version); + } + + /* + * Make the reply compatible with v1.1 + */ + if (!xrri->has_rates) + { + rep.rate = 0; + rep.nrateEnts = 0; + } + + nbytes = (long) rep.length << 2; + + nbytesRead = (long) (rep.nSizes * SIZEOF (xScreenSizes) + + ((rep.nrateEnts + 1)& ~1) * 2 /* SIZEOF (CARD16) */); + + /* + * first we must compute how much space to allocate for + * randr library's use; we'll allocate the structures in a single + * allocation, on cleanlyness grounds. + */ + + rbytes = sizeof (XRRScreenConfiguration) + + (rep.nSizes * sizeof (XRRScreenSize) + + rep.nrateEnts * sizeof (int)); + + scp = (struct _XRRScreenConfiguration *) Xmalloc(rbytes); + if (scp == NULL) { + _XEatData (dpy, (unsigned long) nbytes); + return NULL; + } + + + ssp = (XRRScreenSize *)(scp + 1); + rates = (short *) (ssp + rep.nSizes); + + /* set up the screen configuration structure */ + scp->screen = + ScreenOfDisplay (dpy, XRRRootToScreen(dpy, rep.root)); + + scp->sizes = ssp; + scp->rates = rates; + scp->rotations = rep.setOfRotations; + scp->current_size = rep.sizeID; + scp->current_rate = rep.rate; + scp->current_rotation = rep.rotation; + scp->timestamp = rep.timestamp; + scp->config_timestamp = rep.configTimestamp; + scp->nsizes = rep.nSizes; + scp->nrates = rep.nrateEnts; + + /* + * Time to unpack the data from the server. + */ + + /* + * First the size information + */ + for (i = 0; i < rep.nSizes; i++) { + _XReadPad (dpy, (char *) &size, SIZEOF (xScreenSizes)); + + ssp[i].width = size.widthInPixels; + ssp[i].height = size.heightInPixels; + ssp[i].mwidth = size.widthInMillimeters; + ssp[i].mheight = size.heightInMillimeters; + } + /* + * And the rates + */ + _XRead16Pad (dpy, rates, 2 /* SIZEOF (CARD16) */ * rep.nrateEnts); + + /* + * Skip any extra data + */ + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + + return (XRRScreenConfiguration *)(scp); +} + +XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy, Window window) +{ + XRRScreenConfiguration *config; + XExtDisplayInfo *info = XRRFindDisplay(dpy); + XRRFindDisplay(dpy); + LockDisplay (dpy); + config = _XRRGetScreenInfo(dpy, info, window); + UnlockDisplay (dpy); + SyncHandle (); + return config; +} + + +void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config) +{ + Xfree (config); +} + +Status XRRSetScreenConfigAndRate (Display *dpy, + XRRScreenConfiguration *config, + Drawable draw, + int size_index, + Rotation rotation, + short rate, + Time timestamp) +{ + XExtDisplayInfo *info = XRRFindDisplay (dpy); + xRRSetScreenConfigReply rep; + XRandRInfo *xrri; + int major, minor; + + RRCheckExtension (dpy, info, 0); + + /* Make sure has_rates is set */ + if (!XRRQueryVersion (dpy, &major, &minor)) + return 0; + + LockDisplay (dpy); + xrri = (XRandRInfo *) info->data; + if (xrri->has_rates) + { + xRRSetScreenConfigReq *req; + GetReq (RRSetScreenConfig, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetScreenConfig; + req->drawable = draw; + req->sizeID = size_index; + req->rotation = rotation; + req->timestamp = timestamp; + req->configTimestamp = config->config_timestamp; + req->rate = rate; + } + else + { + xRR1_0SetScreenConfigReq *req; + GetReq (RR1_0SetScreenConfig, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetScreenConfig; + req->drawable = draw; + req->sizeID = size_index; + req->rotation = rotation; + req->timestamp = timestamp; + req->configTimestamp = config->config_timestamp; + } + + (void) _XReply (dpy, (xReply *) &rep, 0, xTrue); + + /* actually .errorCode in struct xError */ + if (rep.status == RRSetConfigSuccess) { + /* if we succeed, set our view of reality to what we set it to */ + config->config_timestamp = rep.newConfigTimestamp; + config->timestamp = rep.newTimestamp; + config->screen = ScreenOfDisplay (dpy, XRRRootToScreen(dpy, rep.root)); + config->current_size = size_index; + config->current_rotation = rotation; + } + UnlockDisplay (dpy); + SyncHandle (); + return(rep.status); +} + +Status XRRSetScreenConfig (Display *dpy, + XRRScreenConfiguration *config, + Drawable draw, + int size_index, + Rotation rotation, Time timestamp) +{ + return XRRSetScreenConfigAndRate (dpy, config, draw, size_index, + rotation, 0, timestamp); +} diff --git a/src/XrrCrtc.c b/src/XrrCrtc.c new file mode 100644 index 0000000..0762373 --- /dev/null +++ b/src/XrrCrtc.c @@ -0,0 +1,553 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +XRRCrtcInfo * +XRRGetCrtcInfo (Display *dpy, XRRScreenResources *resources, RRCrtc crtc) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetCrtcInfoReply rep; + xRRGetCrtcInfoReq *req; + int nbytes, nbytesRead, rbytes; + XRRCrtcInfo *xci; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRGetCrtcInfo, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetCrtcInfo; + req->crtc = crtc; + req->configTimestamp = resources->configTimestamp; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + nbytes = (long) rep.length << 2; + + nbytesRead = (long) (rep.nOutput * 4 + + rep.nPossibleOutput * 4); + + /* + * first we must compute how much space to allocate for + * randr library's use; we'll allocate the structures in a single + * allocation, on cleanlyness grounds. + */ + + rbytes = (sizeof (XRRCrtcInfo) + + rep.nOutput * sizeof (RROutput) + + rep.nPossibleOutput * sizeof (RROutput)); + + xci = (XRRCrtcInfo *) Xmalloc(rbytes); + if (xci == NULL) { + _XEatData (dpy, (unsigned long) nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + xci->timestamp = rep.timestamp; + xci->x = rep.x; + xci->y = rep.y; + xci->width = rep.width; + xci->height = rep.height; + xci->mode = rep.mode; + xci->rotation = rep.rotation; + xci->noutput = rep.nOutput; + xci->outputs = (RROutput *) (xci + 1); + xci->rotations = rep.rotations; + xci->npossible = rep.nPossibleOutput; + xci->possible = (RROutput *) (xci->outputs + rep.nOutput); + + _XRead32 (dpy, xci->outputs, rep.nOutput << 2); + _XRead32 (dpy, xci->possible, rep.nPossibleOutput << 2); + + /* + * Skip any extra data + */ + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + + UnlockDisplay (dpy); + SyncHandle (); + return (XRRCrtcInfo *) xci; +} + +void +XRRFreeCrtcInfo (XRRCrtcInfo *crtcInfo) +{ + Xfree (crtcInfo); +} + +Status +XRRSetCrtcConfig (Display *dpy, + XRRScreenResources *resources, + RRCrtc crtc, + Time timestamp, + int x, int y, + RRMode mode, + Rotation rotation, + RROutput *outputs, + int noutputs) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetCrtcConfigReply rep; + xRRSetCrtcConfigReq *req; + + RRCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq (RRSetCrtcConfig, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetCrtcConfig; + req->length += noutputs; + req->crtc = crtc; + req->timestamp = timestamp; + req->configTimestamp = resources->configTimestamp; + req->x = x; + req->y = y; + req->mode = mode; + req->rotation = rotation; + Data32 (dpy, outputs, noutputs << 2); + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + rep.status = RRSetConfigFailed; + UnlockDisplay (dpy); + SyncHandle (); + return rep.status; +} + +int +XRRGetCrtcGammaSize (Display *dpy, RRCrtc crtc) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetCrtcGammaSizeReply rep; + xRRGetCrtcGammaSizeReq *req; + + RRCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq (RRGetCrtcGammaSize, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetCrtcGammaSize; + req->crtc = crtc; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + rep.size = 0; + UnlockDisplay (dpy); + SyncHandle (); + return rep.size; +} + +XRRCrtcGamma * +XRRGetCrtcGamma (Display *dpy, RRCrtc crtc) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetCrtcGammaReply rep; + xRRGetCrtcGammaReq *req; + XRRCrtcGamma *crtc_gamma = NULL; + long nbytes; + long nbytesRead; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay(dpy); + GetReq (RRGetCrtcGamma, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetCrtcGamma; + req->crtc = crtc; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + goto out; + + nbytes = (long) rep.length << 2; + + /* three channels of CARD16 data */ + nbytesRead = (rep.size * 2 * 3); + + crtc_gamma = XRRAllocGamma (rep.size); + + if (!crtc_gamma) + { + _XEatData (dpy, (unsigned long) nbytes); + goto out; + } + _XRead16 (dpy, crtc_gamma->red, rep.size * 2); + _XRead16 (dpy, crtc_gamma->green, rep.size * 2); + _XRead16 (dpy, crtc_gamma->blue, rep.size * 2); + + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + +out: + UnlockDisplay (dpy); + SyncHandle (); + return crtc_gamma; +} + +XRRCrtcGamma * +XRRAllocGamma (int size) +{ + XRRCrtcGamma *crtc_gamma; + + crtc_gamma = Xmalloc (sizeof (XRRCrtcGamma) + + sizeof (crtc_gamma->red[0]) * size * 3); + if (!crtc_gamma) + return NULL; + crtc_gamma->size = size; + crtc_gamma->red = (unsigned short *) (crtc_gamma + 1); + crtc_gamma->green = crtc_gamma->red + size; + crtc_gamma->blue = crtc_gamma->green + size; + return crtc_gamma; +} + +void +XRRSetCrtcGamma (Display *dpy, RRCrtc crtc, XRRCrtcGamma *crtc_gamma) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetCrtcGammaReq *req; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRSetCrtcGamma, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetCrtcGamma; + req->crtc = crtc; + req->size = crtc_gamma->size; + req->length += (crtc_gamma->size * 2 * 3 + 3) >> 2; + /* + * Note this assumes the structure was allocated with XRRAllocGamma, + * otherwise the channels might not be contiguous + */ + Data16 (dpy, crtc_gamma->red, crtc_gamma->size * 2 * 3); + + UnlockDisplay (dpy); + SyncHandle (); +} + +void +XRRFreeGamma (XRRCrtcGamma *crtc_gamma) +{ + Xfree (crtc_gamma); +} + +/* Version 1.3 additions */ + +static void +XTransform_from_xRenderTransform (XTransform *x, + xRenderTransform *render) +{ + x->matrix[0][0] = render->matrix11; + x->matrix[0][1] = render->matrix12; + x->matrix[0][2] = render->matrix13; + + x->matrix[1][0] = render->matrix21; + x->matrix[1][1] = render->matrix22; + x->matrix[1][2] = render->matrix23; + + x->matrix[2][0] = render->matrix31; + x->matrix[2][1] = render->matrix32; + x->matrix[2][2] = render->matrix33; +} + +static void +xRenderTransform_from_XTransform (xRenderTransform *render, + XTransform *x) +{ + render->matrix11 = x->matrix[0][0]; + render->matrix12 = x->matrix[0][1]; + render->matrix13 = x->matrix[0][2]; + + render->matrix21 = x->matrix[1][0]; + render->matrix22 = x->matrix[1][1]; + render->matrix23 = x->matrix[1][2]; + + render->matrix31 = x->matrix[2][0]; + render->matrix32 = x->matrix[2][1]; + render->matrix33 = x->matrix[2][2]; +} + +void +XRRSetCrtcTransform (Display *dpy, + RRCrtc crtc, + XTransform *transform, + char *filter, + XFixed *params, + int nparams) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetCrtcTransformReq *req; + int nbytes = strlen (filter); + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRSetCrtcTransform, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetCrtcTransform; + req->crtc = crtc; + + xRenderTransform_from_XTransform (&req->transform, transform); + + req->nbytesFilter = nbytes; + req->length += ((nbytes + 3) >> 2) + nparams; + Data (dpy, filter, nbytes); + Data32 (dpy, params, nparams << 2); + + UnlockDisplay (dpy); + SyncHandle (); +} + +#define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32) + +static const xRenderTransform identity = { + 0x10000, 0, 0, + 0, 0x10000, 0, + 0, 0, 0x10000, +}; + +static Bool +_XRRHasTransform (int major, int minor) +{ + return major > 1 || (major == 1 && minor >= 3); +} + +Status +XRRGetCrtcTransform (Display *dpy, + RRCrtc crtc, + XRRCrtcTransformAttributes **attributes) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetCrtcTransformReply rep; + xRRGetCrtcTransformReq *req; + int major_version, minor_version; + XRRCrtcTransformAttributes *attr; + char *extra = NULL, *e; + int p; + + *attributes = NULL; + + RRCheckExtension (dpy, info, False); + + if (!XRRQueryVersion (dpy, &major_version, &minor_version) || + !_XRRHasTransform (major_version, minor_version)) + { + /* For pre-1.3 servers, just report identity matrices everywhere */ + rep.pendingTransform = identity; + rep.pendingNbytesFilter = 0; + rep.pendingNparamsFilter = 0; + rep.currentTransform = identity; + rep.currentNbytesFilter = 0; + rep.currentNparamsFilter = 0; + } + else + { + LockDisplay (dpy); + GetReq (RRGetCrtcTransform, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetCrtcTransform; + req->crtc = crtc; + + if (!_XReply (dpy, (xReply *) &rep, CrtcTransformExtra >> 2, xFalse)) + { + rep.pendingTransform = identity; + rep.pendingNbytesFilter = 0; + rep.pendingNparamsFilter = 0; + rep.currentTransform = identity; + rep.currentNbytesFilter = 0; + rep.currentNparamsFilter = 0; + } + else + { + int extraBytes = rep.length * 4 - CrtcTransformExtra; + extra = Xmalloc (extraBytes); + if (!extra) { + _XEatData (dpy, extraBytes); + UnlockDisplay (dpy); + SyncHandle (); + return False; + } + _XRead (dpy, extra, extraBytes); + } + + UnlockDisplay (dpy); + SyncHandle (); + } + + attr = Xmalloc (sizeof (XRRCrtcTransformAttributes) + + rep.pendingNparamsFilter * sizeof (XFixed) + + rep.currentNparamsFilter * sizeof (XFixed) + + rep.pendingNbytesFilter + 1 + + rep.currentNbytesFilter + 1); + + if (!attr) { + XFree (extra); + return False; + } + XTransform_from_xRenderTransform (&attr->pendingTransform, &rep.pendingTransform); + XTransform_from_xRenderTransform (&attr->currentTransform, &rep.currentTransform); + + attr->pendingParams = (XFixed *) (attr + 1); + attr->currentParams = attr->pendingParams + rep.pendingNparamsFilter; + attr->pendingFilter = (char *) (attr->currentParams + rep.currentNparamsFilter); + attr->currentFilter = attr->pendingFilter + rep.pendingNbytesFilter + 1; + + e = extra; + + memcpy (attr->pendingFilter, e, rep.pendingNbytesFilter); + attr->pendingFilter[rep.pendingNbytesFilter] = '\0'; + e += (rep.pendingNbytesFilter + 3) & ~3; + for (p = 0; p < rep.pendingNparamsFilter; p++) { + INT32 f; + memcpy (&f, e, 4); + e += 4; + attr->pendingParams[p] = (XFixed) f; + } + attr->pendingNparams = rep.pendingNparamsFilter; + + memcpy (attr->currentFilter, e, rep.currentNbytesFilter); + attr->currentFilter[rep.currentNbytesFilter] = '\0'; + e += (rep.currentNbytesFilter + 3) & ~3; + for (p = 0; p < rep.currentNparamsFilter; p++) { + INT32 f; + memcpy (&f, e, 4); + e += 4; + attr->currentParams[p] = (XFixed) f; + } + attr->currentNparams = rep.currentNparamsFilter; + + if (extra) + XFree (extra); + *attributes = attr; + + return True; +} + +XRRPanning * +XRRGetPanning (Display *dpy, XRRScreenResources *resources, RRCrtc crtc) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetPanningReply rep; + xRRGetPanningReq *req; + XRRPanning *xp; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRGetPanning, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetPanning; + req->crtc = crtc; + + if (!_XReply (dpy, (xReply *) &rep, 1, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + if (! (xp = (XRRPanning *) Xmalloc(sizeof(XRRPanning))) ) { + _XEatData (dpy, sizeof(XRRPanning)); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + xp->timestamp = rep.timestamp; + xp->left = rep.left; + xp->top = rep.top; + xp->width = rep.width; + xp->height = rep.height; + xp->track_left = rep.track_left; + xp->track_top = rep.track_top; + xp->track_width = rep.track_width; + xp->track_height = rep.track_height; + xp->border_left = rep.border_left; + xp->border_top = rep.border_top; + xp->border_right = rep.border_right; + xp->border_bottom = rep.border_bottom; + + UnlockDisplay (dpy); + SyncHandle (); + return (XRRPanning *) xp; +} + +void +XRRFreePanning (XRRPanning *panning) +{ + Xfree (panning); +} + +Status +XRRSetPanning (Display *dpy, + XRRScreenResources *resources, + RRCrtc crtc, + XRRPanning *panning) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetPanningReply rep; + xRRSetPanningReq *req; + + RRCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq (RRSetPanning, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetPanning; + req->crtc = crtc; + req->timestamp = panning->timestamp; + req->left = panning->left; + req->top = panning->top; + req->width = panning->width; + req->height = panning->height; + req->track_left = panning->track_left; + req->track_top = panning->track_top; + req->track_width = panning->track_width; + req->track_height = panning->track_height; + req->border_left = panning->border_left; + req->border_top = panning->border_top; + req->border_right = panning->border_right; + req->border_bottom = panning->border_bottom; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + rep.status = RRSetConfigFailed; + UnlockDisplay (dpy); + SyncHandle (); + return rep.status; +} + diff --git a/src/XrrMode.c b/src/XrrMode.c new file mode 100644 index 0000000..0b74a73 --- /dev/null +++ b/src/XrrMode.c @@ -0,0 +1,149 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +XRRModeInfo * +XRRAllocModeInfo (char *name, int nameLength) +{ + XRRModeInfo *mode_info; + + mode_info = Xmalloc (sizeof (XRRModeInfo) + nameLength + 1); + if (!mode_info) + return NULL; + memset (mode_info, '\0', sizeof (XRRModeInfo)); + mode_info->nameLength = nameLength; + mode_info->name = (char *) (mode_info + 1); + memcpy (mode_info->name, name, nameLength); + mode_info->name[nameLength] = '\0'; + return mode_info; +} + +RRMode +XRRCreateMode (Display *dpy, Window window, XRRModeInfo *mode_info) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRCreateModeReq *req; + xRRCreateModeReply rep; + + RRCheckExtension (dpy, info, None); + + LockDisplay(dpy); + GetReq (RRCreateMode, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRCreateMode; + req->length += (mode_info->nameLength + 3) >> 2; + + req->window = window; + + req->modeInfo.id = 0; + req->modeInfo.width = mode_info->width; + req->modeInfo.height = mode_info->height; + req->modeInfo.dotClock = mode_info->dotClock; + req->modeInfo.hSyncStart = mode_info->hSyncStart; + req->modeInfo.hSyncEnd = mode_info->hSyncEnd; + req->modeInfo.hTotal = mode_info->hTotal; + req->modeInfo.hSkew = mode_info->hSkew; + req->modeInfo.vSyncStart = mode_info->vSyncStart; + req->modeInfo.vSyncEnd = mode_info->vSyncEnd; + req->modeInfo.vTotal = mode_info->vTotal; + req->modeInfo.nameLength = mode_info->nameLength; + req->modeInfo.modeFlags = mode_info->modeFlags; + + Data (dpy, mode_info->name, mode_info->nameLength); + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return None; + } + + UnlockDisplay (dpy); + SyncHandle (); + return rep.mode; +} + +void +XRRDestroyMode (Display *dpy, RRMode mode) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRDestroyModeReq *req; + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRDestroyMode, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRDestroyMode; + req->mode = mode; + UnlockDisplay (dpy); + SyncHandle (); +} + +void +XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRAddOutputModeReq *req; + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRAddOutputMode, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRAddOutputMode; + req->output = output; + req->mode = mode; + UnlockDisplay (dpy); + SyncHandle (); +} + +void +XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRDeleteOutputModeReq *req; + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRDeleteOutputMode, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRDeleteOutputMode; + req->output = output; + req->mode = mode; + UnlockDisplay (dpy); + SyncHandle (); +} + +void +XRRFreeModeInfo (XRRModeInfo *modeInfo) +{ + Xfree (modeInfo); +} diff --git a/src/XrrOutput.c b/src/XrrOutput.c new file mode 100644 index 0000000..f13a932 --- /dev/null +++ b/src/XrrOutput.c @@ -0,0 +1,190 @@ +/* + * Copyright © 2006 Keith Packard + * Copyright © 2008 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32) + +XRROutputInfo * +XRRGetOutputInfo (Display *dpy, XRRScreenResources *resources, RROutput output) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetOutputInfoReply rep; + xRRGetOutputInfoReq *req; + int nbytes, nbytesRead, rbytes; + XRROutputInfo *xoi; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRGetOutputInfo, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetOutputInfo; + req->output = output; + req->configTimestamp = resources->configTimestamp; + + if (!_XReply (dpy, (xReply *) &rep, OutputInfoExtra >> 2, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + nbytes = ((long) (rep.length) << 2) - OutputInfoExtra; + + nbytesRead = (long) (rep.nCrtcs * 4 + + rep.nModes * 4 + + rep.nClones * 4 + + ((rep.nameLength + 3) & ~3)); + + /* + * first we must compute how much space to allocate for + * randr library's use; we'll allocate the structures in a single + * allocation, on cleanlyness grounds. + */ + + rbytes = (sizeof (XRROutputInfo) + + rep.nCrtcs * sizeof (RRCrtc) + + rep.nModes * sizeof (RRMode) + + rep.nClones * sizeof (RROutput) + + rep.nameLength + 1); /* '\0' terminate name */ + + xoi = (XRROutputInfo *) Xmalloc(rbytes); + if (xoi == NULL) { + _XEatData (dpy, (unsigned long) nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + xoi->timestamp = rep.timestamp; + xoi->crtc = rep.crtc; + xoi->mm_width = rep.mmWidth; + xoi->mm_height = rep.mmHeight; + xoi->connection = rep.connection; + xoi->subpixel_order = rep.subpixelOrder; + xoi->ncrtc = rep.nCrtcs; + xoi->crtcs = (RRCrtc *) (xoi + 1); + xoi->nmode = rep.nModes; + xoi->npreferred = rep.nPreferred; + xoi->modes = (RRMode *) (xoi->crtcs + rep.nCrtcs); + xoi->nclone = rep.nClones; + xoi->clones = (RROutput *) (xoi->modes + rep.nModes); + xoi->name = (char *) (xoi->clones + rep.nClones); + + _XRead32 (dpy, xoi->crtcs, rep.nCrtcs << 2); + _XRead32 (dpy, xoi->modes, rep.nModes << 2); + _XRead32 (dpy, xoi->clones, rep.nClones << 2); + + /* + * Read name and '\0' terminate + */ + _XReadPad (dpy, xoi->name, rep.nameLength); + xoi->name[rep.nameLength] = '\0'; + xoi->nameLen = rep.nameLength; + + /* + * Skip any extra data + */ + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + + UnlockDisplay (dpy); + SyncHandle (); + return (XRROutputInfo *) xoi; +} + +void +XRRFreeOutputInfo (XRROutputInfo *outputInfo) +{ + Xfree (outputInfo); +} + +static Bool +_XRRHasOutputPrimary (int major, int minor) +{ + return major > 1 || (major == 1 && minor >= 3); +} + +void +XRRSetOutputPrimary(Display *dpy, Window window, RROutput output) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetOutputPrimaryReq *req; + int major_version, minor_version; + + RRSimpleCheckExtension (dpy, info); + + if (!XRRQueryVersion (dpy, &major_version, &minor_version) || + !_XRRHasOutputPrimary (major_version, minor_version)) + return; + + LockDisplay(dpy); + GetReq (RRSetOutputPrimary, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetOutputPrimary; + req->window = window; + req->output = output; + + UnlockDisplay (dpy); + SyncHandle (); +} + +RROutput +XRRGetOutputPrimary(Display *dpy, Window window) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetOutputPrimaryReq *req; + xRRGetOutputPrimaryReply rep; + int major_version, minor_version; + + RRCheckExtension (dpy, info, 0); + + if (!XRRQueryVersion (dpy, &major_version, &minor_version) || + !_XRRHasOutputPrimary (major_version, minor_version)) + return None; + + LockDisplay(dpy); + GetReq (RRGetOutputPrimary, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetOutputPrimary; + req->window = window; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + rep.output = None; + + UnlockDisplay(dpy); + SyncHandle(); + + return rep.output; +} diff --git a/src/XrrProperty.c b/src/XrrProperty.c new file mode 100644 index 0000000..4c3fdb0 --- /dev/null +++ b/src/XrrProperty.c @@ -0,0 +1,339 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +Atom * +XRRListOutputProperties (Display *dpy, RROutput output, int *nprop) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRListOutputPropertiesReply rep; + xRRListOutputPropertiesReq *req; + int nbytes, rbytes; + Atom *props = NULL; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRListOutputProperties, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRListOutputProperties; + req->output = output; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { + UnlockDisplay (dpy); + SyncHandle (); + *nprop = 0; + return NULL; + } + + if (rep.nAtoms) { + rbytes = rep.nAtoms * sizeof (Atom); + nbytes = rep.nAtoms << 2; + + props = (Atom *) Xmalloc (rbytes); + if (props == NULL) { + _XEatData (dpy, nbytes); + UnlockDisplay (dpy); + SyncHandle (); + *nprop = 0; + return NULL; + } + + _XRead32 (dpy, props, nbytes); + } + + *nprop = rep.nAtoms; + UnlockDisplay (dpy); + SyncHandle (); + return props; +} + +XRRPropertyInfo * +XRRQueryOutputProperty (Display *dpy, RROutput output, Atom property) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRQueryOutputPropertyReply rep; + xRRQueryOutputPropertyReq *req; + int rbytes, nbytes; + XRRPropertyInfo *prop_info; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRQueryOutputProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRQueryOutputProperty; + req->output = output; + req->property = property; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + rbytes = sizeof (XRRPropertyInfo) + rep.length * sizeof (long); + nbytes = rep.length << 2; + + prop_info = (XRRPropertyInfo *) Xmalloc (rbytes); + if (prop_info == NULL) { + _XEatData (dpy, nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + prop_info->pending = rep.pending; + prop_info->range = rep.range; + prop_info->immutable = rep.immutable; + prop_info->num_values = rep.length; + if (rep.length != 0) { + prop_info->values = (long *) (prop_info + 1); + _XRead32 (dpy, prop_info->values, nbytes); + } else { + prop_info->values = NULL; + } + + UnlockDisplay (dpy); + SyncHandle (); + return prop_info; +} + +void +XRRConfigureOutputProperty (Display *dpy, RROutput output, Atom property, + Bool pending, Bool range, int num_values, + long *values) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRConfigureOutputPropertyReq *req; + long len; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRConfigureOutputProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRConfigureOutputProperty; + req->output = output; + req->property = property; + req->pending = pending; + req->range = range; + + len = num_values; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + len = (long)num_values << 2; + Data32 (dpy, values, len); + } /* else force BadLength */ + + UnlockDisplay(dpy); + SyncHandle(); +} + +void +XRRChangeOutputProperty (Display *dpy, RROutput output, + Atom property, Atom type, + int format, int mode, + _Xconst unsigned char *data, int nelements) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRChangeOutputPropertyReq *req; + long len; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRChangeOutputProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRChangeOutputProperty; + req->output = output; + req->property = property; + req->type = type; + req->mode = mode; + if (nelements < 0) { + req->nUnits = 0; + req->format = 0; /* ask for garbage, get garbage */ + } else { + req->nUnits = nelements; + req->format = format; + } + + switch (req->format) { + case 8: + len = ((long)nelements + 3) >> 2; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + Data (dpy, (char *)data, nelements); + } /* else force BadLength */ + break; + + case 16: + len = ((long)nelements + 1) >> 1; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + len = (long)nelements << 1; + Data16 (dpy, (short *) data, len); + } /* else force BadLength */ + break; + + case 32: + len = nelements; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + len = (long)nelements << 2; + Data32 (dpy, (long *) data, len); + } /* else force BadLength */ + break; + + default: + /* BadValue will be generated */ ; + } + + UnlockDisplay(dpy); + SyncHandle(); +} + +void +XRRDeleteOutputProperty (Display *dpy, RROutput output, Atom property) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRDeleteOutputPropertyReq *req; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq(RRDeleteOutputProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRDeleteOutputProperty; + req->output = output; + req->property = property; + UnlockDisplay(dpy); + SyncHandle(); +} + +int +XRRGetOutputProperty (Display *dpy, RROutput output, + Atom property, long offset, long length, + Bool delete, Bool pending, Atom req_type, + Atom *actual_type, int *actual_format, + unsigned long *nitems, unsigned long *bytes_after, + unsigned char **prop) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetOutputPropertyReply rep; + xRRGetOutputPropertyReq *req; + long nbytes, rbytes; + + RRCheckExtension (dpy, info, 1); + + LockDisplay (dpy); + GetReq (RRGetOutputProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetOutputProperty; + req->output = output; + req->property = property; + req->type = req_type; + req->longOffset = offset; + req->longLength = length; + req->delete = delete; + req->pending = pending; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return ((xError *)&rep)->errorCode; + } + + *prop = (unsigned char *) NULL; + if (rep.propertyType != None) { + /* + * One extra byte is malloced than is needed to contain the property + * data, but this last byte is null terminated and convenient for + * returning string properties, so the client doesn't then have to + * recopy the string to make it null terminated. + */ + switch (rep.format) { + case 8: + nbytes = rep.nItems; + rbytes = rep.nItems + 1; + if (rbytes > 0 && + (*prop = (unsigned char *) Xmalloc ((unsigned)rbytes))) + _XReadPad (dpy, (char *) *prop, nbytes); + break; + + case 16: + nbytes = rep.nItems << 1; + rbytes = rep.nItems * sizeof (short) + 1; + if (rbytes > 0 && + (*prop = (unsigned char *) Xmalloc ((unsigned)rbytes))) + _XRead16Pad (dpy, (short *) *prop, nbytes); + break; + + case 32: + nbytes = rep.nItems << 2; + rbytes = rep.nItems * sizeof (long) + 1; + if (rbytes > 0 && + (*prop = (unsigned char *) Xmalloc ((unsigned)rbytes))) + _XRead32 (dpy, (long *) *prop, nbytes); + break; + + default: + /* + * This part of the code should never be reached. If it is, + * the server sent back a property with an invalid format. + */ + nbytes = rep.length << 2; + _XEatData(dpy, (unsigned long) nbytes); + UnlockDisplay(dpy); + SyncHandle(); + return(BadImplementation); + } + if (! *prop) { + _XEatData(dpy, (unsigned long) nbytes); + UnlockDisplay(dpy); + SyncHandle(); + return(BadAlloc); + } + (*prop)[rbytes - 1] = '\0'; + } + + *actual_type = rep.propertyType; + *actual_format = rep.format; + *nitems = rep.nItems; + *bytes_after = rep.bytesAfter; + UnlockDisplay (dpy); + SyncHandle (); + + return Success; +} diff --git a/src/XrrProvider.c b/src/XrrProvider.c new file mode 100644 index 0000000..fcd06ff --- /dev/null +++ b/src/XrrProvider.c @@ -0,0 +1,217 @@ +/* + * Copyright © 2011 Dave Airlie + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +XRRProviderResources * +XRRGetProviderResources(Display *dpy, Window window) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetProvidersReply rep; + xRRGetProvidersReq *req; + XRRProviderResources *xrpr; + long nbytes, nbytesRead; + int rbytes; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + + GetReq(RRGetProviders, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetProviders; + req->window = window; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + nbytes = (long) rep.length << 2; + + nbytesRead = (long) (rep.nProviders * 4); + + rbytes = (sizeof(XRRProviderResources) + rep.nProviders * sizeof(RRProvider)); + xrpr = (XRRProviderResources *) Xmalloc(rbytes); + + if (xrpr == NULL) { + _XEatData (dpy, (unsigned long) nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + xrpr->timestamp = rep.timestamp; + xrpr->nproviders = rep.nProviders; + xrpr->providers = (RRProvider *)(xrpr + 1); + + _XRead32(dpy, xrpr->providers, rep.nProviders << 2); + + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + + + UnlockDisplay (dpy); + SyncHandle(); + + return (XRRProviderResources *) xrpr; +} + +void +XRRFreeProviderResources(XRRProviderResources *provider_resources) +{ + free(provider_resources); +} + +#define ProviderInfoExtra (SIZEOF(xRRGetProviderInfoReply) - 32) +XRRProviderInfo * +XRRGetProviderInfo(Display *dpy, XRRScreenResources *resources, RRProvider provider) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetProviderInfoReply rep; + xRRGetProviderInfoReq *req; + int nbytes, nbytesRead, rbytes; + XRRProviderInfo *xpi; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRGetProviderInfo, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetProviderInfo; + req->provider = provider; + req->configTimestamp = resources->configTimestamp; + + if (!_XReply (dpy, (xReply *) &rep, ProviderInfoExtra >> 2, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + nbytes = ((long) rep.length << 2) - ProviderInfoExtra; + + nbytesRead = (long)(rep.nCrtcs * 4 + + rep.nOutputs * 4 + + rep.nAssociatedProviders * 8 + + ((rep.nameLength + 3) & ~3)); + + rbytes = (sizeof(XRRProviderInfo) + + rep.nCrtcs * sizeof(RRCrtc) + + rep.nOutputs * sizeof(RROutput) + + rep.nAssociatedProviders * (sizeof(RRProvider) + sizeof(unsigned int))+ + rep.nameLength + 1); + + xpi = (XRRProviderInfo *)Xmalloc(rbytes); + if (xpi == NULL) { + _XEatData (dpy, (unsigned long) nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + xpi->capabilities = rep.capabilities; + xpi->ncrtcs = rep.nCrtcs; + xpi->noutputs = rep.nOutputs; + xpi->nassociatedproviders = rep.nAssociatedProviders; + xpi->crtcs = (RRCrtc *)(xpi + 1); + xpi->outputs = (RROutput *)(xpi->crtcs + rep.nCrtcs); + xpi->associated_providers = (RRProvider *)(xpi->outputs + rep.nOutputs); + xpi->associated_capability = (unsigned int *)(xpi->associated_providers + rep.nAssociatedProviders); + xpi->name = (char *)(xpi->associated_capability + rep.nAssociatedProviders); + + _XRead32(dpy, xpi->crtcs, rep.nCrtcs << 2); + _XRead32(dpy, xpi->outputs, rep.nOutputs << 2); + + _XRead32(dpy, xpi->associated_providers, rep.nAssociatedProviders << 2); + _XRead32(dpy, xpi->associated_capability, rep.nAssociatedProviders << 2); + + _XReadPad(dpy, xpi->name, rep.nameLength); + xpi->name[rep.nameLength] = '\0'; + + /* + * Skip any extra data + */ + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + + UnlockDisplay (dpy); + SyncHandle (); + return (XRRProviderInfo *) xpi; +} + +void +XRRFreeProviderInfo(XRRProviderInfo *provider) +{ + free(provider); +} + +int +XRRSetProviderOutputSource(Display *dpy, XID provider, + XID source_provider) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetProviderOutputSourceReq *req; + + RRCheckExtension (dpy, info, 0); + LockDisplay (dpy); + GetReq (RRSetProviderOutputSource, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetProviderOutputSource; + req->provider = provider; + req->source_provider = source_provider; + UnlockDisplay (dpy); + SyncHandle (); + return 0; +} + +int +XRRSetProviderOffloadSink(Display *dpy, XID provider, + XID sink_provider) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetProviderOffloadSinkReq *req; + + RRCheckExtension (dpy, info, 0); + LockDisplay (dpy); + GetReq (RRSetProviderOffloadSink, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetProviderOffloadSink; + req->provider = provider; + req->sink_provider = sink_provider; + UnlockDisplay (dpy); + SyncHandle (); + return 0; +} diff --git a/src/XrrProviderProperty.c b/src/XrrProviderProperty.c new file mode 100644 index 0000000..c8c08e9 --- /dev/null +++ b/src/XrrProviderProperty.c @@ -0,0 +1,339 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +Atom * +XRRListProviderProperties (Display *dpy, RRProvider provider, int *nprop) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRListProviderPropertiesReply rep; + xRRListProviderPropertiesReq *req; + int nbytes, rbytes; + Atom *props = NULL; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRListProviderProperties, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRListProviderProperties; + req->provider = provider; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { + UnlockDisplay (dpy); + SyncHandle (); + *nprop = 0; + return NULL; + } + + if (rep.nAtoms) { + rbytes = rep.nAtoms * sizeof (Atom); + nbytes = rep.nAtoms << 2; + + props = (Atom *) Xmalloc (rbytes); + if (props == NULL) { + _XEatData (dpy, nbytes); + UnlockDisplay (dpy); + SyncHandle (); + *nprop = 0; + return NULL; + } + + _XRead32 (dpy, props, nbytes); + } + + *nprop = rep.nAtoms; + UnlockDisplay (dpy); + SyncHandle (); + return props; +} + +XRRPropertyInfo * +XRRQueryProviderProperty (Display *dpy, RRProvider provider, Atom property) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRQueryProviderPropertyReply rep; + xRRQueryProviderPropertyReq *req; + int rbytes, nbytes; + XRRPropertyInfo *prop_info; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + GetReq (RRQueryProviderProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRQueryProviderProperty; + req->provider = provider; + req->property = property; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + rbytes = sizeof (XRRPropertyInfo) + rep.length * sizeof (long); + nbytes = rep.length << 2; + + prop_info = (XRRPropertyInfo *) Xmalloc (rbytes); + if (prop_info == NULL) { + _XEatData (dpy, nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + prop_info->pending = rep.pending; + prop_info->range = rep.range; + prop_info->immutable = rep.immutable; + prop_info->num_values = rep.length; + if (rep.length != 0) { + prop_info->values = (long *) (prop_info + 1); + _XRead32 (dpy, prop_info->values, nbytes); + } else { + prop_info->values = NULL; + } + + UnlockDisplay (dpy); + SyncHandle (); + return prop_info; +} + +void +XRRConfigureProviderProperty (Display *dpy, RRProvider provider, Atom property, + Bool pending, Bool range, int num_values, + long *values) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRConfigureProviderPropertyReq *req; + long len; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRConfigureProviderProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRConfigureProviderProperty; + req->provider = provider; + req->property = property; + req->pending = pending; + req->range = range; + + len = num_values; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + len = (long)num_values << 2; + Data32 (dpy, values, len); + } /* else force BadLength */ + + UnlockDisplay(dpy); + SyncHandle(); +} + +void +XRRChangeProviderProperty (Display *dpy, RRProvider provider, + Atom property, Atom type, + int format, int mode, + _Xconst unsigned char *data, int nelements) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRChangeProviderPropertyReq *req; + long len; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRChangeProviderProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRChangeProviderProperty; + req->provider = provider; + req->property = property; + req->type = type; + req->mode = mode; + if (nelements < 0) { + req->nUnits = 0; + req->format = 0; /* ask for garbage, get garbage */ + } else { + req->nUnits = nelements; + req->format = format; + } + + switch (req->format) { + case 8: + len = ((long)nelements + 3) >> 2; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + Data (dpy, (char *)data, nelements); + } /* else force BadLength */ + break; + + case 16: + len = ((long)nelements + 1) >> 1; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + len = (long)nelements << 1; + Data16 (dpy, (short *) data, len); + } /* else force BadLength */ + break; + + case 32: + len = nelements; + if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { + SetReqLen(req, len, len); + len = (long)nelements << 2; + Data32 (dpy, (long *) data, len); + } /* else force BadLength */ + break; + + default: + /* BadValue will be generated */ ; + } + + UnlockDisplay(dpy); + SyncHandle(); +} + +void +XRRDeleteProviderProperty (Display *dpy, RRProvider provider, Atom property) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRDeleteProviderPropertyReq *req; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq(RRDeleteProviderProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRDeleteProviderProperty; + req->provider = provider; + req->property = property; + UnlockDisplay(dpy); + SyncHandle(); +} + +int +XRRGetProviderProperty (Display *dpy, RRProvider provider, + Atom property, long offset, long length, + Bool delete, Bool pending, Atom req_type, + Atom *actual_type, int *actual_format, + unsigned long *nitems, unsigned long *bytes_after, + unsigned char **prop) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetProviderPropertyReply rep; + xRRGetProviderPropertyReq *req; + long nbytes, rbytes; + + RRCheckExtension (dpy, info, 1); + + LockDisplay (dpy); + GetReq (RRGetProviderProperty, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetProviderProperty; + req->provider = provider; + req->property = property; + req->type = req_type; + req->longOffset = offset; + req->longLength = length; + req->delete = delete; + req->pending = pending; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return ((xError *)&rep)->errorCode; + } + + *prop = (unsigned char *) NULL; + if (rep.propertyType != None) { + /* + * One extra byte is malloced than is needed to contain the property + * data, but this last byte is null terminated and convenient for + * returning string properties, so the client doesn't then have to + * recopy the string to make it null terminated. + */ + switch (rep.format) { + case 8: + nbytes = rep.nItems; + rbytes = rep.nItems + 1; + if (rbytes > 0 && + (*prop = (unsigned char *) Xmalloc ((unsigned)rbytes))) + _XReadPad (dpy, (char *) *prop, nbytes); + break; + + case 16: + nbytes = rep.nItems << 1; + rbytes = rep.nItems * sizeof (short) + 1; + if (rbytes > 0 && + (*prop = (unsigned char *) Xmalloc ((unsigned)rbytes))) + _XRead16Pad (dpy, (short *) *prop, nbytes); + break; + + case 32: + nbytes = rep.nItems << 2; + rbytes = rep.nItems * sizeof (long) + 1; + if (rbytes > 0 && + (*prop = (unsigned char *) Xmalloc ((unsigned)rbytes))) + _XRead32 (dpy, (long *) *prop, nbytes); + break; + + default: + /* + * This part of the code should never be reached. If it is, + * the server sent back a property with an invalid format. + */ + nbytes = rep.length << 2; + _XEatData(dpy, (unsigned long) nbytes); + UnlockDisplay(dpy); + SyncHandle(); + return(BadImplementation); + } + if (! *prop) { + _XEatData(dpy, (unsigned long) nbytes); + UnlockDisplay(dpy); + SyncHandle(); + return(BadAlloc); + } + (*prop)[rbytes - 1] = '\0'; + } + + *actual_type = rep.propertyType; + *actual_format = rep.format; + *nitems = rep.nItems; + *bytes_after = rep.bytesAfter; + UnlockDisplay (dpy); + SyncHandle (); + + return Success; +} diff --git a/src/XrrScreen.c b/src/XrrScreen.c new file mode 100644 index 0000000..f830913 --- /dev/null +++ b/src/XrrScreen.c @@ -0,0 +1,263 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +/* we need to be able to manipulate the Display structure on events */ +#include +#include +#include +#include "Xrandrint.h" + +/* + * this is cheating on the knowledge that the two requests are identical + * but for the request number. + */ +static XRRScreenResources * +doGetScreenResources (Display *dpy, Window window, int poll) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetScreenResourcesReply rep; + xRRGetScreenResourcesReq *req; + _XAsyncHandler async; + _XRRVersionState async_state; + int nbytes, nbytesRead, rbytes; + int i; + xRRQueryVersionReq *vreq; + XRRScreenResources *xrsr; + char *names; + char *wire_names, *wire_name; + Bool getting_version = False; + XRandRInfo *xrri; + + RRCheckExtension (dpy, info, NULL); + + LockDisplay (dpy); + xrri = (XRandRInfo *) info->data; + + if (xrri->major_version == -1) + { + /* hide a version query in the request */ + GetReq (RRQueryVersion, vreq); + vreq->reqType = info->codes->major_opcode; + vreq->randrReqType = X_RRQueryVersion; + vreq->majorVersion = RANDR_MAJOR; + vreq->minorVersion = RANDR_MINOR; + + async_state.version_seq = dpy->request; + async_state.error = False; + async.next = dpy->async_handlers; + async.handler = _XRRVersionHandler; + async.data = (XPointer) &async_state; + dpy->async_handlers = &async; + + getting_version = True; + } + + GetReq (RRGetScreenResources, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = poll ? X_RRGetScreenResources + : X_RRGetScreenResourcesCurrent; + req->window = window; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + if (getting_version) + DeqAsyncHandler (dpy, &async); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + if (getting_version) + { + DeqAsyncHandler (dpy, &async); + if (async_state.error) + { + UnlockDisplay (dpy); + SyncHandle(); + LockDisplay (dpy); + } + xrri->major_version = async_state.major_version; + xrri->minor_version = async_state.minor_version; + xrri->has_rates = _XRRHasRates (xrri->minor_version, xrri->major_version); + } + + nbytes = (long) rep.length << 2; + + nbytesRead = (long) (rep.nCrtcs * 4 + + rep.nOutputs * 4 + + rep.nModes * SIZEOF (xRRModeInfo) + + ((rep.nbytesNames + 3) & ~3)); + + /* + * first we must compute how much space to allocate for + * randr library's use; we'll allocate the structures in a single + * allocation, on cleanlyness grounds. + */ + + rbytes = (sizeof (XRRScreenResources) + + rep.nCrtcs * sizeof (RRCrtc) + + rep.nOutputs * sizeof (RROutput) + + rep.nModes * sizeof (XRRModeInfo) + + rep.nbytesNames + rep.nModes); /* '\0' terminate names */ + + xrsr = (XRRScreenResources *) Xmalloc(rbytes); + wire_names = (char *) Xmalloc (rep.nbytesNames); + if (xrsr == NULL || wire_names == NULL) { + if (xrsr) Xfree (xrsr); + if (wire_names) Xfree (wire_names); + _XEatData (dpy, (unsigned long) nbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + + xrsr->timestamp = rep.timestamp; + xrsr->configTimestamp = rep.configTimestamp; + xrsr->ncrtc = rep.nCrtcs; + xrsr->crtcs = (RRCrtc *) (xrsr + 1); + xrsr->noutput = rep.nOutputs; + xrsr->outputs = (RROutput *) (xrsr->crtcs + rep.nCrtcs); + xrsr->nmode = rep.nModes; + xrsr->modes = (XRRModeInfo *) (xrsr->outputs + rep.nOutputs); + names = (char *) (xrsr->modes + rep.nModes); + + _XRead32 (dpy, xrsr->crtcs, rep.nCrtcs << 2); + _XRead32 (dpy, xrsr->outputs, rep.nOutputs << 2); + + for (i = 0; i < rep.nModes; i++) { + xRRModeInfo modeInfo; + + _XReadPad (dpy, (char *) &modeInfo, SIZEOF (xRRModeInfo)); + xrsr->modes[i].id = modeInfo.id; + xrsr->modes[i].width = modeInfo.width; + xrsr->modes[i].height = modeInfo.height; + xrsr->modes[i].dotClock = modeInfo.dotClock; + xrsr->modes[i].hSyncStart = modeInfo.hSyncStart; + xrsr->modes[i].hSyncEnd = modeInfo.hSyncEnd; + xrsr->modes[i].hTotal = modeInfo.hTotal; + xrsr->modes[i].hSkew = modeInfo.hSkew; + xrsr->modes[i].vSyncStart = modeInfo.vSyncStart; + xrsr->modes[i].vSyncEnd = modeInfo.vSyncEnd; + xrsr->modes[i].vTotal = modeInfo.vTotal; + xrsr->modes[i].nameLength = modeInfo.nameLength; + xrsr->modes[i].modeFlags = modeInfo.modeFlags; + } + + /* + * Read names and '\0' pad each one + */ + _XReadPad (dpy, wire_names, rep.nbytesNames); + wire_name = wire_names; + for (i = 0; i < rep.nModes; i++) { + xrsr->modes[i].name = names; + memcpy (names, wire_name, xrsr->modes[i].nameLength); + names[xrsr->modes[i].nameLength] = '\0'; + names += xrsr->modes[i].nameLength + 1; + wire_name += xrsr->modes[i].nameLength; + } + Xfree (wire_names); + + /* + * Skip any extra data + */ + if (nbytes > nbytesRead) + _XEatData (dpy, (unsigned long) (nbytes - nbytesRead)); + + UnlockDisplay (dpy); + SyncHandle(); + return (XRRScreenResources *) xrsr; +} + +XRRScreenResources * +XRRGetScreenResources(Display *dpy, Window window) +{ + return doGetScreenResources(dpy, window, 1); +} + +XRRScreenResources * +XRRGetScreenResourcesCurrent(Display *dpy, Window window) +{ + return doGetScreenResources(dpy, window, 0); +} + +void +XRRFreeScreenResources (XRRScreenResources *resources) +{ + Xfree (resources); +} + +Status +XRRGetScreenSizeRange (Display *dpy, Window window, + int *minWidth, int *minHeight, + int *maxWidth, int *maxHeight) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetScreenSizeRangeReq *req; + xRRGetScreenSizeRangeReply rep; + + RRCheckExtension (dpy, info, 0); + LockDisplay (dpy); + GetReq (RRGetScreenSizeRange, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetScreenSizeRange; + req->window = window; + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + { + UnlockDisplay (dpy); + SyncHandle (); + return False; + } + UnlockDisplay (dpy); + SyncHandle (); + *minWidth = rep.minWidth; + *minHeight = rep.minHeight; + *maxWidth = rep.maxWidth; + *maxHeight = rep.maxHeight; + return True; +} + +void +XRRSetScreenSize (Display *dpy, Window window, + int width, int height, + int mmWidth, int mmHeight) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetScreenSizeReq *req; + + RRSimpleCheckExtension (dpy, info); + LockDisplay (dpy); + GetReq (RRSetScreenSize, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetScreenSize; + req->window = window; + req->width = width; + req->height = height; + req->widthInMillimeters = mmWidth; + req->heightInMillimeters = mmHeight; + UnlockDisplay (dpy); + SyncHandle (); +} diff --git a/xrandr.pc.in b/xrandr.pc.in new file mode 100644 index 0000000..c691d17 --- /dev/null +++ b/xrandr.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Xrandr +Description: X RandR Library +Version: @VERSION@ +Requires: xproto randrproto >= @RANDR_VERSION@ +Requires.private: x11 xext xrender +Cflags: -I${includedir} +Libs: -L${libdir} -lXrandr -- 2.7.4