Commit ac4c2abe authored by's avatar Committed by Keith Packard

xserver: add monitor Option "ZoomModes" [v2]

Section "Monitor"
  Identifier "a21inch"
  Option "PreferredMode" "1600x1200"
  Option "ZoomModes" "1600x1200 1280x1024 1280x1024 640x480"

The option's effect is to search for and mark once each named mode in
the output modes list.  So the specification order is free and the zoom
modes sequence follows the order of the output modes list.  All marked
modes are available via the Ctrl+Alt+Keypad-{Plus,Minus} key

See also

This option has its use for combined monitor and television setups.
It allows for easy switching between 60 Hz and 50 Hz modes even when a
monitor refuses to display the input signal.

(Includes a few minor changes suggested by Aaron for v2)
Signed-off-by: default avatarServaas Vandenberghe <>
Reviewed-by: Aaron Plattner's avatarAaron Plattner <>
Signed-off-by: Keith Packard's avatarKeith Packard <>
parent 2967391c
......@@ -1676,6 +1676,17 @@ This optional entry specifies a mode to be marked as the preferred initial mode
of the monitor.
(RandR 1.2-supporting drivers only)
.TP 7
.BI "Option \*qZoomModes\*q \*q" name " " name " " ... \*q
This optional entry specifies modes to be marked as zoom modes.
It is possible to switch to the next and previous mode via
.BR Ctrl+Alt+Keypad\-Plus " and " Ctrl+Alt+Keypad\-Minus .
All these keypad available modes are selected from the screen mode list.
This list is a copy of the compatibility output monitor mode list.
Since this output is the output connected to the lowest
dot-area monitor, as determined from its largest size mode, that
monitor defines the available zoom modes.
(RandR 1.2-supporting drivers only)
.TP 7
.BI "Option \*qPosition\*q \*q" x " " y \*q
This optional entry specifies the position of the monitor within the X
......@@ -428,6 +428,7 @@ extern XF86ConfigPtr xf86configptr;
typedef enum {
......@@ -446,6 +447,7 @@ typedef enum {
static OptionInfoRec xf86OutputOptions[] = {
......@@ -1418,6 +1420,90 @@ preferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output)
return preferred_mode;
/** identify a token
* args
* *src a string with zero or more tokens, e.g. "tok0 tok1",
* **token stores a pointer to the first token character,
* *len stores the token length.
* return
* a pointer into src[] at the token terminating character, or
* NULL if no token is found.
static const char *
gettoken(const char *src, const char **token, int *len)
const char *delim = " \t";
int skip;
if (!src)
return NULL;
skip = strspn(src, delim);
*token = &src[skip];
*len = strcspn(*token, delim);
/* Support for backslash escaped delimiters could be implemented
* here.
/* (*token)[0] != '\0' <==> *len > 0 */
if (*len > 0)
return &(*token)[*len];
return NULL;
/** Check for a user configured zoom mode list, Option "ZoomModes":
* Section "Monitor"
* Identifier "a21inch"
* Option "ZoomModes" "1600x1200 1280x1024 1280x1024 640x480"
* EndSection
* Each user mode name is searched for independently so the list
* specification order is free. An output mode is matched at most
* once, a mode with an already set M_T_USERDEF type bit is skipped.
* Thus a repeat mode name specification matches the next output mode
* with the same name.
* Ctrl+Alt+Keypad-{Plus,Minus} zooms {in,out} by selecting the
* {next,previous} M_T_USERDEF mode in the screen modes list, itself
* sorted toward lower dot area or lower dot clock frequency, see
* modes/xf86Crtc.c: xf86SortModes() xf86SetScrnInfoModes(), and
* common/xf86Cursor.c: xf86ZoomViewport().
static int
processZoomModes(xf86OutputPtr output)
const char *zoom_modes;
int count = 0;
zoom_modes = xf86GetOptValString(output->options, OPTION_ZOOM_MODES);
if (zoom_modes) {
const char *token, *next;
int len;
next = gettoken(zoom_modes, &token, &len);
while (next) {
DisplayModePtr mode;
for (mode = output->probed_modes; mode; mode = mode->next)
if (!strncmp(token, mode->name, len) /* prefix match */
&& mode->name[len] == '\0' /* equal length */
&& !(mode->type & M_T_USERDEF)) { /* no rematch */
mode->type |= M_T_USERDEF;
next = gettoken(next, &token, &len);
return count;
static void
GuessRangeFromModes(MonPtr mon, DisplayModePtr mode)
......@@ -1713,6 +1799,9 @@ xf86ProbeOutputModes(ScrnInfoPtr scrn, int maxX, int maxY)
/* Ctrl+Alt+Keypad-{Plus,Minus} zoom mode: M_T_USERDEF mode type */
output->initial_rotation = xf86OutputInitialRotation(output);
if (debug_modes) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment