#include <X11/extensions/xf86vmode.h> Bool XF86VidModeQueryExtension( Display *display, int *event_base_return, int *error_base_return); Bool XF86VidModeQueryVersion( Display *display, int *major_version_return, int *minor_version_return); Bool XF86VidModeSetClientVersion( Display *display); Bool XF86VidModeGetModeLine( Display *display, int screen, int *dotclock_return, XF86VidModeModeLine *modeline); Bool XF86VidModeGetAllModeLines( Display *display, int screen, int *modecount_return, XF86VidModeModeInfo ***modesinfo); Bool XF86VidModeDeleteModeLine( Display *display, int screen, XF86VidModeModeInfo *modeline); Bool XF86VidModeModModeLine( Display *display, int screen, XF86VidModeModeLine *modeline); Status XF86VidModeValidateModeLine( Display *display, int screen, XF86VidModeModeLine *modeline); Bool XF86VidModeSwitchMode( Display *display, int screen, int zoom); Bool XF86VidModeSwitchToMode( Display *display, int screen, XF86VidModeModeInfo *modeline); Bool XF86VidModeLockModeSwitch( Display *display, int screen, int lock); Bool XF86VidModeGetMonitor( Display *display, int screen, XF86VidModeMonitor *monitor); Bool XF86VidModeGetViewPort( Display *display, int screen, int *x_return, int *y_return); Bool XF86VidModeSetViewPort( Display *display, int screen, int x, int y); XF86VidModeGetDotClocks( Display *display, int screen, int *flags return, int *number of clocks return, int *max dot clock return, int **clocks return); XF86VidModeGetGamma( Display *display, int screen, XF86VidModeGamma *Gamma); XF86VidModeSetGamma( Display *display, int screen, XF86VidModeGamma *Gamma); XF86VidModeGetGammaRamp( Display *display, int screen, int size, unsigned short *red array, unsigned short *green array, unsigned short *blue array); XF86VidModeSetGammaRamp( Display *display, int screen, int size, unsigned short *red array, unsigned short *green array, unsigned short *blue array); XF86VidModeGetGammaRampSize( Display *display, int screen, int *size);
Video Mode Settings: typedef struct { unsigned short hdisplay; /* Number of display pixels horizontally */ unsigned short hsyncstart; /* Horizontal sync start */ unsigned short hsyncend; /* Horizontal sync end */ unsigned short htotal; /* Total horizontal pixels */ unsigned short vdisplay; /* Number of display pixels vertically */ unsigned short vsyncstart; /* Vertical sync start */ unsigned short vsyncend; /* Vertical sync start */ unsigned short vtotal; /* Total vertical pixels */ unsigned int flags; /* Mode flags */ int privsize; /* Size of private */ INT32 *private; /* Server privates */ } XF86VidModeModeLine; typedef struct { unsigned int dotclock; /* Pixel clock */ unsigned short hdisplay; /* Number of display pixels horizontally */ unsigned short hsyncstart; /* Horizontal sync start */ unsigned short hsyncend; /* Horizontal sync end */ unsigned short htotal; /* Total horizontal pixels */ unsigned short vdisplay; /* Number of display pixels vertically */ unsigned short vsyncstart; /* Vertical sync start */ unsigned short vsyncend; /* Vertical sync start */ unsigned short vtotal; /* Total vertical pixels */ unsigned int flags; /* Mode flags */ int privsize; /* Size of private */ INT32 *private; /* Server privates */ } XF86VidModeModeInfo; Monitor information: typedef struct { char* vendor; /* Name of manufacturer */ char* model; /* Model name */ float EMPTY; /* unused, for backward compatibility */ unsigned char nhsync; /* Number of horiz sync ranges */ XF86VidModeSyncRange* hsync;/* Horizontal sync ranges */ unsigned char nvsync; /* Number of vert sync ranges */ XF86VidModeSyncRange* vsync;/* Vertical sync ranges */ } XF86VidModeMonitor; typedef struct { float hi; /* Top of range */ float lo; /* Bottom of range */ } XF86VidModeSyncRange; typedef struct { int type; /* of event */ unsigned long serial; /* # of last request processed by server */ Bool send_event; /* true if this came from a SendEvent req */ Display *display; /* Display the event was read from */ Window root; /* root window of event screen */ int state; /* What happened */ int kind; /* What happened */ Bool forced; /* extents of new region */ Time time; /* event timestamp */ } XF86VidModeNotifyEvent; typedef struct { float red; /* Red Gamma value */ float green; /* Green Gamma value */ float blue; /* Blue Gamma value */ } XF86VidModeGamma;
If there are any server private values (currently only applicable to the S3 server) the function will allocate storage for them. Therefore, if the privsize field is non-zero, the calling program should call Xfree(private) to free the storage.
XF86VidModeGetAllModeLines returns the settings for all video modes. The calling program supplies the address of a pointer which will be set by the function to point to an array of XF86VidModeModeInfo structures. The memory occupied by the array is dynamically allocated by the XF86VidModeGetAllModeLines function and should be freed by the caller. The first element of the array corresponds to the current video mode.
The XF86VidModeModModeLine function can be used to change the settings of the current video mode provided the requested settings are valid (e.g. they don't exceed the capabilities of the monitor).
Modes can be deleted with the XF86VidModeDeleteModeLine function. The specified mode must match an existing mode. To be considered a match, all of the fields of the given XF86VidModeModeInfo structure must match, except the privsize and private fields. If the mode to be deleted is the current mode, a mode switch to the next mode will occur first. The last remaining mode can not be deleted.
The validity of a mode can be checked with the XF86VidModeValidateModeLine function. If the specified mode can be used by the server (i.e. meets all the constraints placed upon a mode by the combination of the server, card, and monitor) the function returns MODE_OK, otherwise it returns a value indicating the reason why the mode is invalid (as defined in xf86.h)
Note: Because of the asynchronous nature of the X protocol, a call to XFlush is needed if the application wants to see the mode change immediately. To be informed of the execution status of the request, a custom error handler should be installed using XSetErrorHandler before calling the mode switching function.
The vendor, model, hsync, and vsync fields point to dynamically allocated storage that should be freed by the caller.
The function XF86VidModeQueryExtension returns the lowest numbered error and event values assigned to the extension.