1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
   7  *
   8  * Copyright © 2000 Compaq Computer Corporation, Inc.
   9  * Copyright © 2002 Hewlett-Packard Company, Inc.
  10  *
  11  * Permission to use, copy, modify, distribute, and sell this software and its
  12  * documentation for any purpose is hereby granted without fee, provided that
  13  * the above copyright notice appear in all copies and that both that
  14  * copyright notice and this permission notice appear in supporting
  15  * documentation, and that the name of Compaq not be used in advertising or
  16  * publicity pertaining to distribution of the software without specific,
  17  * written prior permission.  HP makes no representations about the
  18  * suitability of this software for any purpose.  It is provided "as is"
  19  * without express or implied warranty.
  20  *
  21  * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
  23  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  24  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  25  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  26  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27  *
  28  * Author:  Jim Gettys, HP Labs, HP.
  29  */
  30 
  31 #ifndef _XRANDR_H_
  32 #define _XRANDR_H_
  33 
  34 /*#include <X11/extensions/randr.h>*/
  35 #include "randr.h"
  36 
  37 #include <X11/Xfuncproto.h>
  38 
  39 _XFUNCPROTOBEGIN
  40 
  41 
  42 typedef struct {
  43     int width, height;
  44     int mwidth, mheight;
  45 } XRRScreenSize;
  46 
  47 /*
  48  *  Events.
  49  */
  50 
  51 typedef struct {
  52     int type;                   /* event base */
  53     unsigned long serial;       /* # of last request processed by server */
  54     Bool send_event;            /* true if this came from a SendEvent request */
  55     Display *display;           /* Display the event was read from */
  56     Window window;              /* window which selected for this event */
  57     Window root;                /* Root window for changed screen */
  58     Time timestamp;             /* when the screen change occurred */
  59     Time config_timestamp;      /* when the last configuration change */
  60     SizeID size_index;
  61     SubpixelOrder subpixel_order;
  62     Rotation rotation;
  63     int width;
  64     int height;
  65     int mwidth;
  66     int mheight;
  67 } XRRScreenChangeNotifyEvent;
  68 
  69 typedef XID RROutput;
  70 typedef XID RRCrtc;
  71 typedef XID RRMode;
  72 
  73 typedef unsigned long XRRModeFlags;
  74 
  75 typedef struct {
  76     RRMode              id;
  77     unsigned int        width;
  78     unsigned int        height;
  79     unsigned long       dotClock;
  80     unsigned int        hSyncStart;
  81     unsigned int        hSyncEnd;
  82     unsigned int        hTotal;
  83     unsigned int        hSkew;
  84     unsigned int        vSyncStart;
  85     unsigned int        vSyncEnd;
  86     unsigned int        vTotal;
  87     char                *name;
  88     unsigned int        nameLength;
  89     XRRModeFlags        modeFlags;
  90 } XRRModeInfo;
  91 
  92 typedef struct {
  93     Time        timestamp;
  94     Time        configTimestamp;
  95     int         ncrtc;
  96     RRCrtc      *crtcs;
  97     int         noutput;
  98     RROutput    *outputs;
  99     int         nmode;
 100     XRRModeInfo *modes;
 101 } XRRScreenResources;
 102 
 103 typedef struct {
 104     Time            timestamp;
 105     RRCrtc          crtc;
 106     char            *name;
 107     int             nameLen;
 108     unsigned long   mm_width;
 109     unsigned long   mm_height;
 110     Connection      connection;
 111     SubpixelOrder   subpixel_order;
 112     int             ncrtc;
 113     RRCrtc          *crtcs;
 114     int             nclone;
 115     RROutput        *clones;
 116     int             nmode;
 117     int             npreferred;
 118     RRMode          *modes;
 119 } XRROutputInfo;
 120 
 121 typedef struct {
 122     Time            timestamp;
 123     int             x, y;
 124     unsigned int    width, height;
 125     RRMode          mode;
 126     Rotation        rotation;
 127     int             noutput;
 128     RROutput        *outputs;
 129     Rotation        rotations;
 130     int             npossible;
 131     RROutput        *possible;
 132 } XRRCrtcInfo;
 133 
 134 XRRScreenResources *XRRGetScreenResources (Display *dpy, Window window);
 135 
 136 void XRRFreeScreenResources (XRRScreenResources *resources);
 137 
 138 XRROutputInfo * XRRGetOutputInfo (Display *dpy, XRRScreenResources *resources,
 139                                                                RROutput output);
 140 void XRRFreeOutputInfo (XRROutputInfo *outputInfo);
 141 
 142 XRRCrtcInfo *XRRGetCrtcInfo (Display *dpy, XRRScreenResources *resources,
 143                                                                    RRCrtc crtc);
 144 void XRRFreeCrtcInfo (XRRCrtcInfo *crtcInfo);
 145 
 146 
 147 /* internal representation is private to the library */
 148 typedef struct _XRRScreenConfiguration XRRScreenConfiguration;
 149 
 150 Bool XRRQueryExtension (Display *dpy, int *event_basep, int *error_basep);
 151 Status XRRQueryVersion (Display *dpy,
 152                             int     *major_versionp,
 153                             int     *minor_versionp);
 154 
 155 XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy,
 156                                           Drawable draw);
 157 
 158 void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config);
 159 
 160 /*
 161  * Note that screen configuration changes are only permitted if the client can
 162  * prove it has up to date configuration information.  We are trying to
 163  * insist that it become possible for screens to change dynamically, so
 164  * we want to ensure the client knows what it is talking about when requesting
 165  * changes.
 166  */
 167 Status XRRSetScreenConfig (Display *dpy,
 168                            XRRScreenConfiguration *config,
 169                            Drawable draw,
 170                            int size_index,
 171                            Rotation rotation,
 172                            Time timestamp);
 173 
 174 /* added in v1.1, sorry for the lame name */
 175 Status XRRSetScreenConfigAndRate (Display *dpy,
 176                                   XRRScreenConfiguration *config,
 177                                   Drawable draw,
 178                                   int size_index,
 179                                   Rotation rotation,
 180                                   short rate,
 181                                   Time timestamp);
 182 
 183 
 184 Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation);
 185 
 186 Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp);
 187 
 188 XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes);
 189 
 190 short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates);
 191 
 192 SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config,
 193                               Rotation *rotation);
 194 
 195 short XRRConfigCurrentRate (XRRScreenConfiguration *config);
 196 
 197 int XRRRootToScreen(Display *dpy, Window root);
 198 
 199 /*
 200  * returns the screen configuration for the specified screen; does a lazy
 201  * evalution to delay getting the information, and caches the result.
 202  * These routines should be used in preference to XRRGetScreenInfo
 203  * to avoid unneeded round trips to the X server.  These are new
 204  * in protocol version 0.1.
 205  */
 206 
 207 
 208 XRRScreenConfiguration *XRRScreenConfig(Display *dpy, int screen);
 209 XRRScreenConfiguration *XRRConfig(Screen *screen);
 210 void XRRSelectInput(Display *dpy, Window window, int mask);
 211 
 212 /*
 213  * the following are always safe to call, even if RandR is not implemented
 214  * on a screen
 215  */
 216 
 217 
 218 Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation);
 219 XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes);
 220 short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates);
 221 Time XRRTimes (Display *dpy, int screen, Time *config_timestamp);
 222 
 223 
 224 /*
 225  * intended to take RRScreenChangeNotify,  or
 226  * ConfigureNotify (on the root window)
 227  * returns 1 if it is an event type it understands, 0 if not
 228  */
 229 int XRRUpdateConfiguration(XEvent *event);
 230 
 231 _XFUNCPROTOEND
 232 
 233 #endif /* _XRANDR_H_ */