649N/A * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. 649N/A * Copyright © 2002 Hewlett Packard Company, Inc. 649N/A * Copyright © 2006 Intel Corporation 649N/A * Permission to use, copy, modify, distribute, and sell this software and its 649N/A * documentation for any purpose is hereby granted without fee, provided that 649N/A * the above copyright notice appear in all copies and that both that copyright 649N/A * notice and this permission notice appear in supporting documentation, and 649N/A * that the name of the copyright holders not be used in advertising or 649N/A * publicity pertaining to distribution of the software without specific, 649N/A * written prior permission. The copyright holders make no representations 649N/A * about the suitability of this software for any purpose. It is provided "as 649N/A * is" without express or implied warranty. 649N/A * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 649N/A * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 649N/A * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 649N/A * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 649N/A * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 649N/A * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 1459N/A * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. 919N/A * Permission is hereby granted, free of charge, to any person obtaining a 919N/A * copy of this software and associated documentation files (the "Software"), 919N/A * to deal in the Software without restriction, including without limitation 919N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 919N/A * and/or sell copies of the Software, and to permit persons to whom the 919N/A * Software is furnished to do so, subject to the following conditions: 919N/A * The above copyright notice and this permission notice (including the next 919N/A * paragraph) shall be included in all copies or substantial portions of the 919N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 919N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 919N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 919N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 919N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 919N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 919N/A * DEALINGS IN THE SOFTWARE. 649N/A/* v refresh frequency in Hz */ 649N/A /* sanity check output info */ 649N/A fatal (
"Output %s is not disconnected but has no modes\n",
649N/A /* set output name and info */ 649N/A /* comment it out because DisplayWidth() does not reflect the 649N/A change of fb_width and fb_height previously set by 649N/A if (fb_width == DisplayWidth (dpy, screen) && 649N/A fb_height == DisplayHeight (dpy, screen) && 649N/A fb_width_mm == DisplayWidthMM (dpy, screen) && 649N/A fb_height_mm == DisplayHeightMM (dpy, screen)) 649N/A /* first disable all crtcs */ 649N/A /* next reset screen size */ 649N/A /* now restore all crtcs */ 649N/A * uh-oh, something bad happened in the middle of changing 649N/A * the configuration. Revert to the previous configuration 649N/A * Turn off any crtcs which are to be disabled or which are 649N/A * larger than the target size 649N/A * if this crtc is already disabled, skip it 649N/A * Note server sets crtc_info->mode (before change) 649N/A * If this crtc is to be left enabled, make 649N/A * sure the old size fits then new screen 649N/A * When crtc->mode_info is null, the crtc is to be 649N/A * disabled. Note set_crtcs () sets crtc->mode_info for 649N/A * new mode (to be changed to). 649N/A /* old position and size information */ 649N/A /* if it fits, skip it */ 649N/A * Hold the server grabbed while messing with 649N/A * the screen so that apps which notice the resize 649N/A * event and ask for xinerama information from the server 649N/A * receive up-to-date information 649N/A * Release the server grab and let all clients 649N/A * respond to the updated state 649N/A * Use current output state to complete the output list 649N/A * Test whether 'crtc' can be used for 'output' 649N/A /* see if the output connected to the crtc can clone to this output */ 649N/A /* not on the list, can't clone */ 649N/A /* Check if the output is to be turned on */ 649N/A /* make sure the state matches */ 649N/A * Make sure the dependent object has been set in place 649N/A fatal (
"loop in relative position specifications\n");
649N/A * Now normalize positions so the upper left corner of all outputs is at 0,0 649N/A * find the best mapping from output to crtc available 649N/A * Score with this output disabled 649N/A * Now score with this output any valid crtc 649N/A /* reset crtc allocation for following outputs */ 649N/A /* slight preference for existing connections */ 649N/A * Reset other outputs based on this one using the best crtc 649N/A * Pick crtcs for any changing outputs that don't have one 649N/A * First try to match up newly enabled outputs with spare crtcs 649N/A * When the simple way fails, see if there is a way 649N/A * to swap crtcs around and make things work 649N/A /* first try to find mode with common same size */ 649N/A /* then try to find mode with common id for possible cloning */ 649N/A /* use common id if it is not smaller */ 649N/A /* Initialize con_outputs array */ 649N/A /* set initial mode_info */ 649N/A if ((i ==
1) || (i ==
2) || (i ==
4)) {
649N/A /* remember position and mode info in single state */ 649N/A /* reset crtcs before allocation */ 1323N/A /* Now, take the deferred output off */ 765N/A * Send another instance of dispswitch (a daemon) an event to 649N/A while (*p ==
' ') *p-- = 0;
649N/A while ((p > s) && (*(p-
1) ==
' ')) p--;
765N/A * Create an atom, a trivial window, and make it selection owner. 765N/A * Ready to accept a client event request for switch 649N/A /* set default key and modifier if not given in command */ 649N/A /* Too long since last switch, need to check output changes */ 1323N/A * Workaround for intel based graphics: in switching from 1323N/A * LVDS to VGA, off on LVDS needs to be deferred.