2004-06-30 20:06:56 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
|
|
|
|
|
*
|
|
|
|
|
* 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 on 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
|
|
|
|
|
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Author:
|
|
|
|
|
* Rickard E. (Rik) Faith <faith@redhat.com>
|
|
|
|
|
* Kevin E. Martin <kem@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* This file provides the only interface to the X server extension support
|
|
|
|
|
* in programs/Xserver/Xext. Those programs should only include dmxext.h
|
|
|
|
|
*/
|
|
|
|
|
|
2005-07-12 00:52:48 +00:00
|
|
|
#ifdef HAVE_DMX_CONFIG_H
|
|
|
|
|
#include <dmx-config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
#include "dmx.h"
|
|
|
|
|
#include "dmxinit.h"
|
|
|
|
|
#include "dmxextension.h"
|
|
|
|
|
#include "dmxwindow.h"
|
|
|
|
|
#include "dmxcb.h"
|
|
|
|
|
#include "dmxcursor.h"
|
|
|
|
|
#include "dmxpixmap.h"
|
|
|
|
|
#include "dmxgc.h"
|
|
|
|
|
#include "dmxfont.h"
|
|
|
|
|
#include "dmxcmap.h"
|
2008-08-05 04:04:09 -04:00
|
|
|
#include "dmxshm.h"
|
2004-06-30 20:06:56 +00:00
|
|
|
#ifdef RENDER
|
|
|
|
|
#include "dmxpict.h"
|
|
|
|
|
#endif
|
2008-06-03 18:18:04 -04:00
|
|
|
#ifdef RANDR
|
2008-07-25 23:00:14 -04:00
|
|
|
#include "dmxrandr.h"
|
2008-06-03 18:18:04 -04:00
|
|
|
#endif
|
2004-06-30 20:06:56 +00:00
|
|
|
#include "dmxinput.h"
|
2008-09-15 16:16:36 +02:00
|
|
|
#include "dmxlog.h"
|
2008-07-30 15:54:17 -04:00
|
|
|
#include "dmxgrab.h"
|
2004-06-30 20:06:56 +00:00
|
|
|
#include "dmxsync.h"
|
|
|
|
|
#include "dmxscrinit.h"
|
2008-07-25 14:23:38 -04:00
|
|
|
#ifdef XV
|
|
|
|
|
#include "dmxxv.h"
|
|
|
|
|
#endif
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
#include "windowstr.h"
|
2005-07-12 00:52:48 +00:00
|
|
|
#include "inputstr.h" /* For DeviceIntRec */
|
|
|
|
|
#include <X11/extensions/dmxproto.h> /* For DMX_BAD_* */
|
2004-06-30 20:06:56 +00:00
|
|
|
#include "cursorstr.h"
|
2008-07-10 14:26:31 -04:00
|
|
|
#include "propertyst.h"
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-07-30 15:54:17 -04:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-06-30 15:51:12 -04:00
|
|
|
#define dmxErrorSet(set, error, name, fmt, ...) \
|
|
|
|
|
if (set) (*set) (error, name, fmt, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
#define dmxLogErrorSet(type, set, error, name, fmt, ...) \
|
|
|
|
|
dmxLog (type, fmt "\n", ##__VA_ARGS__); \
|
|
|
|
|
dmxErrorSet (set, error, name, fmt, ##__VA_ARGS__)
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* The default font is declared in dix/globals.c, but is not included in
|
|
|
|
|
* _any_ header files. */
|
|
|
|
|
extern FontPtr defaultFont;
|
|
|
|
|
|
|
|
|
|
/** This routine provides information to the DMX protocol extension
|
|
|
|
|
* about a particular screen. */
|
|
|
|
|
Bool dmxGetScreenAttributes(int physical, DMXScreenAttributesPtr attr)
|
|
|
|
|
{
|
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
|
|
|
|
|
|
if (physical < 0 || physical >= dmxNumScreens) return FALSE;
|
|
|
|
|
|
|
|
|
|
dmxScreen = &dmxScreens[physical];
|
2008-06-30 19:08:42 -04:00
|
|
|
attr->name = dmxScreen->name;
|
|
|
|
|
attr->displayName = dmxScreen->display;
|
2004-06-30 20:06:56 +00:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
attr->logicalScreen = noPanoramiXExtension ? dmxScreen->index : 0;
|
|
|
|
|
#else
|
|
|
|
|
attr->logicalScreen = dmxScreen->index;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
attr->screenWindowWidth = dmxScreen->scrnWidth;
|
|
|
|
|
attr->screenWindowHeight = dmxScreen->scrnHeight;
|
2008-08-10 10:26:08 -04:00
|
|
|
attr->screenWindowXoffset = 0;
|
|
|
|
|
attr->screenWindowYoffset = 0;
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-08-10 10:26:08 -04:00
|
|
|
attr->rootWindowWidth = WindowTable[physical]->drawable.width;
|
|
|
|
|
attr->rootWindowHeight = WindowTable[physical]->drawable.height;
|
2008-08-11 16:02:49 -04:00
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
if (!noPanoramiXExtension)
|
|
|
|
|
{
|
|
|
|
|
attr->rootWindowWidth = PanoramiXPixWidth;
|
|
|
|
|
attr->rootWindowHeight = PanoramiXPixHeight;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
attr->rootWindowXoffset = dmxScreen->rootX;
|
|
|
|
|
attr->rootWindowYoffset = dmxScreen->rootY;
|
|
|
|
|
|
2008-08-10 10:26:08 -04:00
|
|
|
attr->rootWindowXorigin = 0;
|
|
|
|
|
attr->rootWindowYorigin = 0;
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** This routine provides information to the DMX protocol extension
|
|
|
|
|
* about a particular window. */
|
|
|
|
|
Bool dmxGetWindowAttributes(WindowPtr pWindow, DMXWindowAttributesPtr attr)
|
|
|
|
|
{
|
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
|
|
|
|
|
|
attr->screen = pWindow->drawable.pScreen->myNum;
|
|
|
|
|
attr->window = pWinPriv->window;
|
|
|
|
|
|
|
|
|
|
attr->pos.x = pWindow->drawable.x;
|
|
|
|
|
attr->pos.y = pWindow->drawable.y;
|
|
|
|
|
attr->pos.width = pWindow->drawable.width;
|
|
|
|
|
attr->pos.height = pWindow->drawable.height;
|
|
|
|
|
|
|
|
|
|
if (!pWinPriv->window || pWinPriv->offscreen) {
|
|
|
|
|
attr->vis.x = 0;
|
|
|
|
|
attr->vis.y = 0;
|
|
|
|
|
attr->vis.height = 0;
|
|
|
|
|
attr->vis.width = 0;
|
|
|
|
|
return pWinPriv->window ? TRUE : FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute display-relative coordinates */
|
|
|
|
|
attr->vis.x = pWindow->drawable.x;
|
|
|
|
|
attr->vis.y = pWindow->drawable.y;
|
|
|
|
|
attr->vis.width = pWindow->drawable.width;
|
|
|
|
|
attr->vis.height = pWindow->drawable.height;
|
|
|
|
|
|
|
|
|
|
if (attr->pos.x < 0) {
|
|
|
|
|
attr->vis.x -= attr->pos.x;
|
|
|
|
|
attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x;
|
|
|
|
|
}
|
|
|
|
|
if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) {
|
|
|
|
|
if (attr->pos.x < 0)
|
|
|
|
|
attr->vis.width = pWindow->drawable.pScreen->width;
|
|
|
|
|
else
|
|
|
|
|
attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x;
|
|
|
|
|
}
|
|
|
|
|
if (attr->pos.y < 0) {
|
|
|
|
|
attr->vis.y -= attr->pos.y;
|
|
|
|
|
attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y;
|
|
|
|
|
}
|
|
|
|
|
if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) {
|
|
|
|
|
if (attr->pos.y < 0)
|
|
|
|
|
attr->vis.height = pWindow->drawable.pScreen->height;
|
|
|
|
|
else
|
|
|
|
|
attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert to window-relative coordinates */
|
|
|
|
|
attr->vis.x -= attr->pos.x;
|
|
|
|
|
attr->vis.y -= attr->pos.y;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
/** This routine provides information to the DMX protocol extension
|
|
|
|
|
* about a particular window. */
|
|
|
|
|
Bool dmxGetDrawableAttributes(DrawablePtr pDraw, DMXWindowAttributesPtr attr)
|
|
|
|
|
{
|
|
|
|
|
if ((pDraw->type == UNDRAWABLE_WINDOW) || (pDraw->type == DRAWABLE_WINDOW))
|
|
|
|
|
{
|
|
|
|
|
WindowPtr pWindow = (WindowPtr) pDraw;
|
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV (pWindow);
|
|
|
|
|
|
|
|
|
|
attr->screen = pWindow->drawable.pScreen->myNum;
|
|
|
|
|
attr->window = pWinPriv->window;
|
|
|
|
|
|
|
|
|
|
attr->pos.x = pWindow->drawable.x;
|
|
|
|
|
attr->pos.y = pWindow->drawable.y;
|
|
|
|
|
attr->pos.width = pWindow->drawable.width;
|
|
|
|
|
attr->pos.height = pWindow->drawable.height;
|
|
|
|
|
|
|
|
|
|
if (!pWinPriv->window || pWinPriv->offscreen) {
|
|
|
|
|
attr->vis.x = 0;
|
|
|
|
|
attr->vis.y = 0;
|
|
|
|
|
attr->vis.height = 0;
|
|
|
|
|
attr->vis.width = 0;
|
|
|
|
|
return pWinPriv->window ? TRUE : FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute display-relative coordinates */
|
|
|
|
|
attr->vis.x = pWindow->drawable.x;
|
|
|
|
|
attr->vis.y = pWindow->drawable.y;
|
|
|
|
|
attr->vis.width = pWindow->drawable.width;
|
|
|
|
|
attr->vis.height = pWindow->drawable.height;
|
|
|
|
|
|
|
|
|
|
if (attr->pos.x < 0) {
|
|
|
|
|
attr->vis.x -= attr->pos.x;
|
|
|
|
|
attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x;
|
|
|
|
|
}
|
|
|
|
|
if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) {
|
|
|
|
|
if (attr->pos.x < 0)
|
|
|
|
|
attr->vis.width = pWindow->drawable.pScreen->width;
|
|
|
|
|
else
|
|
|
|
|
attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x;
|
|
|
|
|
}
|
|
|
|
|
if (attr->pos.y < 0) {
|
|
|
|
|
attr->vis.y -= attr->pos.y;
|
|
|
|
|
attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y;
|
|
|
|
|
}
|
|
|
|
|
if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) {
|
|
|
|
|
if (attr->pos.y < 0)
|
|
|
|
|
attr->vis.height = pWindow->drawable.pScreen->height;
|
|
|
|
|
else
|
|
|
|
|
attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert to window-relative coordinates */
|
|
|
|
|
attr->vis.x -= attr->pos.x;
|
|
|
|
|
attr->vis.y -= attr->pos.y;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pPixmap = (PixmapPtr) pDraw;
|
|
|
|
|
dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV (pPixmap);
|
|
|
|
|
xRectangle empty = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
|
|
attr->screen = pDraw->pScreen->myNum;
|
|
|
|
|
attr->window = pPixPriv->pixmap;
|
|
|
|
|
attr->pos = attr->vis = empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr)
|
|
|
|
|
{
|
|
|
|
|
attr->width = dmxGlobalWidth;
|
|
|
|
|
attr->height = dmxGlobalHeight;
|
|
|
|
|
attr->shiftX = 0; /* NOTE: The upper left hand corner of */
|
|
|
|
|
attr->shiftY = 0; /* the desktop is always <0,0>. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Return the total number of devices, not just #dmxNumInputs. The
|
|
|
|
|
* number returned should be the same as that returned by
|
|
|
|
|
* XListInputDevices. */
|
|
|
|
|
int dmxGetInputCount(void)
|
|
|
|
|
{
|
|
|
|
|
int i, total;
|
|
|
|
|
|
2008-09-15 16:16:36 +02:00
|
|
|
for (total = i = 0; i < dmxNumScreens; i++)
|
|
|
|
|
total += dmxScreens[i].input.numDevs;
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
return total;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Return information about the device with id = \a deviceId. This
|
|
|
|
|
* information is primarily for the #ProcDMXGetInputAttributes()
|
|
|
|
|
* function, which does not have access to the appropriate data
|
|
|
|
|
* structure. */
|
|
|
|
|
int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr)
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
DMXInputInfo *dmxInput;
|
|
|
|
|
|
|
|
|
|
if (deviceId < 0) return -1;
|
2008-09-15 16:16:36 +02:00
|
|
|
for (i = 0; i < dmxNumScreens; i++) {
|
|
|
|
|
dmxInput = &dmxScreens[i].input;
|
2004-06-30 20:06:56 +00:00
|
|
|
for (j = 0; j < dmxInput->numDevs; j++) {
|
2008-09-15 16:16:36 +02:00
|
|
|
if (deviceId != dmxInput->devs[i]->id) continue;
|
|
|
|
|
attr->isCore = FALSE;
|
|
|
|
|
attr->sendsCore = TRUE;
|
|
|
|
|
attr->detached = FALSE;
|
|
|
|
|
attr->inputType = 2;
|
|
|
|
|
attr->physicalScreen = i;
|
|
|
|
|
attr->name = dmxInput->devs[i]->name;
|
|
|
|
|
attr->physicalId = deviceId;
|
|
|
|
|
return 0; /* Success */
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1; /* Failure */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Add an input with the specified attributes. If the input is added,
|
|
|
|
|
* the physical id is returned in \a deviceId. */
|
|
|
|
|
int dmxAddInput(DMXInputAttributesPtr attr, int *id)
|
|
|
|
|
{
|
2008-09-15 16:16:36 +02:00
|
|
|
if (attr->physicalScreen < 0 || attr->physicalScreen >= dmxNumScreens)
|
|
|
|
|
return BadValue;
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-09-15 16:16:36 +02:00
|
|
|
if (attr->inputType == 2)
|
|
|
|
|
{
|
2008-09-26 13:46:25 -04:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[attr->physicalScreen];
|
|
|
|
|
int ret;
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
if (dmxScreen->beDisplay)
|
2008-07-30 15:54:17 -04:00
|
|
|
{
|
2008-09-26 13:46:25 -04:00
|
|
|
ret = dmxInputAttach (&dmxScreen->input);
|
|
|
|
|
if (ret != Success)
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
dmxInputEnable (&dmxScreen->input);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dmxScreen->beDisplay = dmxScreen->beAttachedDisplay;
|
|
|
|
|
ret = dmxInputAttach (&dmxScreen->input);
|
|
|
|
|
dmxScreen->beDisplay = NULL;
|
|
|
|
|
|
|
|
|
|
if (ret != Success)
|
|
|
|
|
return ret;
|
2008-07-30 15:54:17 -04:00
|
|
|
}
|
2008-09-15 16:16:36 +02:00
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
*id = attr->physicalScreen;
|
|
|
|
|
|
2008-09-15 16:16:36 +02:00
|
|
|
return ret;
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
2008-09-15 16:16:36 +02:00
|
|
|
return BadValue;
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Remove the input with physical id \a id. */
|
|
|
|
|
int dmxRemoveInput(int id)
|
|
|
|
|
{
|
2008-09-26 13:46:25 -04:00
|
|
|
int ret;
|
|
|
|
|
|
2008-09-15 16:16:36 +02:00
|
|
|
if (id < 0 || id >= dmxNumScreens)
|
|
|
|
|
return BadValue;
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
if (dmxScreens[id].beDisplay)
|
|
|
|
|
{
|
|
|
|
|
dmxInputDisable (&dmxScreens[id].input);
|
|
|
|
|
ret = dmxInputDetach (&dmxScreens[id].input);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dmxScreens[id].beDisplay = dmxScreens[id].beAttachedDisplay;
|
|
|
|
|
ret = dmxInputDetach (&dmxScreens[id].input);
|
|
|
|
|
dmxScreens[id].beDisplay = NULL;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Return the value of #dmxNumScreens -- the total number of backend
|
|
|
|
|
* screens in use (these are logical screens and may be larger than the
|
|
|
|
|
* number of backend displays). */
|
|
|
|
|
unsigned long dmxGetNumScreens(void)
|
|
|
|
|
{
|
|
|
|
|
return dmxNumScreens;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Make sure that #dmxCreateAndRealizeWindow has been called for \a
|
|
|
|
|
* pWindow. */
|
|
|
|
|
void dmxForceWindowCreation(WindowPtr pWindow)
|
|
|
|
|
{
|
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
|
if (!pWinPriv->window) dmxCreateAndRealizeWindow(pWindow, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Flush pending syncs for all screens. */
|
|
|
|
|
void dmxFlushPendingSyncs(void)
|
|
|
|
|
{
|
|
|
|
|
dmxSync(NULL, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Update DMX's screen resources to match those of the newly moved
|
|
|
|
|
* and/or resized "root" window. */
|
|
|
|
|
void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
|
|
|
|
|
{
|
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
|
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
|
|
|
|
WindowPtr pChild;
|
|
|
|
|
Bool anyMarked = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Handle special case where width and/or height are zero */
|
|
|
|
|
if (w == 0 || h == 0) {
|
|
|
|
|
w = 1;
|
|
|
|
|
h = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Change screen size */
|
|
|
|
|
pScreen->width = w;
|
|
|
|
|
pScreen->height = h;
|
|
|
|
|
|
|
|
|
|
/* Reset the root window's drawable's size */
|
|
|
|
|
pRoot->drawable.width = w;
|
|
|
|
|
pRoot->drawable.height = h;
|
|
|
|
|
|
|
|
|
|
/* Set the root window's new winSize and borderSize */
|
|
|
|
|
pRoot->winSize.extents.x1 = 0;
|
|
|
|
|
pRoot->winSize.extents.y1 = 0;
|
|
|
|
|
pRoot->winSize.extents.x2 = w;
|
|
|
|
|
pRoot->winSize.extents.y2 = h;
|
|
|
|
|
|
|
|
|
|
pRoot->borderSize.extents.x1 = 0;
|
|
|
|
|
pRoot->borderSize.extents.y1 = 0;
|
|
|
|
|
pRoot->borderSize.extents.x2 = w;
|
|
|
|
|
pRoot->borderSize.extents.y2 = h;
|
|
|
|
|
|
|
|
|
|
/* Recompute this screen's mmWidth & mmHeight */
|
|
|
|
|
pScreen->mmWidth =
|
|
|
|
|
(w * 254 + dmxScreen->beXDPI * 5) / (dmxScreen->beXDPI * 10);
|
|
|
|
|
pScreen->mmHeight =
|
|
|
|
|
(h * 254 + dmxScreen->beYDPI * 5) / (dmxScreen->beYDPI * 10);
|
|
|
|
|
|
|
|
|
|
/* Recompute this screen's window's clip rects as follows: */
|
|
|
|
|
/* 1. Mark all of root's children's windows */
|
|
|
|
|
for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
|
|
|
|
|
anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
|
|
|
|
|
(WindowPtr *)NULL);
|
|
|
|
|
|
|
|
|
|
/* 2. Set the root window's borderClip */
|
|
|
|
|
pRoot->borderClip.extents.x1 = 0;
|
|
|
|
|
pRoot->borderClip.extents.y1 = 0;
|
|
|
|
|
pRoot->borderClip.extents.x2 = w;
|
|
|
|
|
pRoot->borderClip.extents.y2 = h;
|
|
|
|
|
|
|
|
|
|
/* 3. Set the root window's clipList */
|
|
|
|
|
if (anyMarked) {
|
|
|
|
|
/* If any windows have been marked, set the root window's
|
|
|
|
|
* clipList to be broken since it will be recalculated in
|
|
|
|
|
* ValidateTree()
|
|
|
|
|
*/
|
|
|
|
|
REGION_BREAK(pScreen, &pRoot->clipList);
|
|
|
|
|
} else {
|
|
|
|
|
/* Otherwise, we just set it directly since there are no
|
|
|
|
|
* windows visible on this screen
|
|
|
|
|
*/
|
|
|
|
|
pRoot->clipList.extents.x1 = 0;
|
|
|
|
|
pRoot->clipList.extents.y1 = 0;
|
|
|
|
|
pRoot->clipList.extents.x2 = w;
|
|
|
|
|
pRoot->clipList.extents.y2 = h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 4. Revalidate all clip rects and generate expose events */
|
|
|
|
|
if (anyMarked) {
|
|
|
|
|
pScreen->ValidateTree(pRoot, NULL, VTBroken);
|
|
|
|
|
pScreen->HandleExposures(pRoot);
|
|
|
|
|
if (pScreen->PostValidateTree)
|
|
|
|
|
pScreen->PostValidateTree(pRoot, NULL, VTBroken);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Create the scratch GCs per depth. */
|
|
|
|
|
static void dmxBECreateScratchGCs(int scrnNum)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[scrnNum];
|
|
|
|
|
GCPtr *ppGC = pScreen->GCperDepth;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i <= pScreen->numDepths; i++)
|
|
|
|
|
dmxBECreateGC(pScreen, ppGC[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
static Bool FoundPixImage;
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
extern unsigned long XRT_PICTURE;
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
|
|
|
|
|
* to have its image restored. When it is found, see if there is
|
|
|
|
|
* another screen with the same image. If so, copy the pixmap image
|
|
|
|
|
* from the existing screen to the newly created pixmap. */
|
|
|
|
|
static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
|
|
|
|
|
pointer p)
|
|
|
|
|
{
|
2008-06-03 18:18:04 -04:00
|
|
|
PixmapPtr pSrc = NULL;
|
|
|
|
|
PixmapPtr pDst = (PixmapPtr) p;
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
int i;
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
PanoramiXRes *pXinPix = (PanoramiXRes *)value;
|
|
|
|
|
PixmapPtr pPix;
|
|
|
|
|
|
|
|
|
|
pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
|
|
|
|
|
if (pPix != pDst) return; /* Not a match.... Next! */
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
for (i = 0; i < PanoramiXNumScreens; i++)
|
|
|
|
|
{
|
2004-06-30 20:06:56 +00:00
|
|
|
if (i == idx) continue; /* Self replication is bad */
|
|
|
|
|
|
|
|
|
|
pSrc =
|
|
|
|
|
(PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
|
2008-06-03 18:18:04 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef RENDER
|
|
|
|
|
else if ((type & TypeMask) == (XRT_PICTURE & TypeMask))
|
|
|
|
|
{
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
PanoramiXRes *pXinPic = (PanoramiXRes *) value;
|
|
|
|
|
PicturePtr pPic;
|
|
|
|
|
|
|
|
|
|
pPic = (PicturePtr) LookupIDByType (pXinPic->info[idx].id,
|
|
|
|
|
PictureType);
|
|
|
|
|
|
|
|
|
|
/* Not a match.... Next! */
|
|
|
|
|
if (!pPic || !pPic->pDrawable) return;
|
|
|
|
|
if (pPic->pDrawable->type != DRAWABLE_PIXMAP) return;
|
|
|
|
|
if (pPic->pDrawable != (DrawablePtr) pDst) return;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PanoramiXNumScreens; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i == idx) continue; /* Self replication is bad */
|
|
|
|
|
|
|
|
|
|
pPic = (PicturePtr) LookupIDByType (pXinPic->info[i].id,
|
|
|
|
|
PictureType);
|
|
|
|
|
pSrc = (PixmapPtr) pPic->pDrawable;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
else if ((type & TypeMask) == (XRT_WINDOW & TypeMask))
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pDst = (PixmapPtr)p;
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
PanoramiXRes *pXinWin = (PanoramiXRes *) value;
|
|
|
|
|
Bool border;
|
|
|
|
|
WindowPtr pWin;
|
|
|
|
|
|
|
|
|
|
pWin = (WindowPtr) LookupIDByType (pXinWin->info[idx].id, RT_WINDOW);
|
|
|
|
|
|
|
|
|
|
if (!pWin) return;
|
|
|
|
|
if (!pWin->borderIsPixel && pWin->border.pixmap == pDst)
|
|
|
|
|
{
|
|
|
|
|
border = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else if (pWin->backgroundState == BackgroundPixmap &&
|
|
|
|
|
pWin->background.pixmap == pDst)
|
|
|
|
|
{
|
|
|
|
|
border = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PanoramiXNumScreens; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i == idx) continue; /* Self replication is bad */
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
pWin = (WindowPtr) LookupIDByType (pXinWin->info[i].id, RT_WINDOW);
|
|
|
|
|
|
|
|
|
|
if (border)
|
|
|
|
|
pSrc = pWin->border.pixmap;
|
|
|
|
|
else
|
|
|
|
|
pSrc = pWin->background.pixmap;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pSrc)
|
|
|
|
|
{
|
|
|
|
|
dmxPixPrivPtr pSrcPriv = DMX_GET_PIXMAP_PRIV (pSrc);
|
|
|
|
|
|
|
|
|
|
if (pSrcPriv->pixmap)
|
|
|
|
|
{
|
|
|
|
|
DMXScreenInfo *dmxSrcScreen = &dmxScreens[i];
|
|
|
|
|
DMXScreenInfo *dmxDstScreen = &dmxScreens[idx];
|
|
|
|
|
dmxPixPrivPtr pDstPriv = DMX_GET_PIXMAP_PRIV(pDst);
|
|
|
|
|
XImage *img = NULL;
|
|
|
|
|
int j;
|
|
|
|
|
XlibGC gc = NULL;
|
|
|
|
|
|
|
|
|
|
/* This should never happen, but just in case.... */
|
|
|
|
|
if (pSrc->drawable.width != pDst->drawable.width ||
|
|
|
|
|
pSrc->drawable.height != pDst->drawable.height)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
XLIB_PROLOGUE (dmxSrcScreen);
|
|
|
|
|
|
|
|
|
|
/* Copy from src pixmap to dst pixmap */
|
|
|
|
|
img = XGetImage(dmxSrcScreen->beDisplay,
|
|
|
|
|
pSrcPriv->pixmap,
|
|
|
|
|
0, 0,
|
|
|
|
|
pSrc->drawable.width, pSrc->drawable.height,
|
|
|
|
|
-1,
|
|
|
|
|
ZPixmap);
|
|
|
|
|
|
|
|
|
|
XLIB_EPILOGUE (dmxSrcScreen);
|
|
|
|
|
|
|
|
|
|
if (img)
|
|
|
|
|
{
|
2004-06-30 20:06:56 +00:00
|
|
|
for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) {
|
|
|
|
|
if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) {
|
|
|
|
|
unsigned long m;
|
|
|
|
|
XGCValues v;
|
|
|
|
|
|
|
|
|
|
m = GCFunction | GCPlaneMask | GCClipMask;
|
|
|
|
|
v.function = GXcopy;
|
|
|
|
|
v.plane_mask = AllPlanes;
|
|
|
|
|
v.clip_mask = None;
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_PROLOGUE (dmxDstScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
gc = XCreateGC(dmxDstScreen->beDisplay,
|
|
|
|
|
dmxDstScreen->scrnDefDrawables[j],
|
|
|
|
|
m, &v);
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_EPILOGUE (dmxDstScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gc) {
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_PROLOGUE (dmxDstScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
XPutImage(dmxDstScreen->beDisplay,
|
|
|
|
|
pDstPriv->pixmap,
|
|
|
|
|
gc, img, 0, 0, 0, 0,
|
|
|
|
|
pDst->drawable.width, pDst->drawable.height);
|
|
|
|
|
XFreeGC(dmxDstScreen->beDisplay, gc);
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_EPILOGUE (dmxDstScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
FoundPixImage = True;
|
|
|
|
|
} else {
|
|
|
|
|
dmxLog(dmxWarning, "Could not create GC\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XDestroyImage(img);
|
2008-06-03 18:18:04 -04:00
|
|
|
} else {
|
|
|
|
|
dmxLog(dmxWarning, "Could not create image\n");
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/** Restore the pixmap image either from another screen or from an image
|
|
|
|
|
* that was saved when the screen was previously detached. */
|
|
|
|
|
static void dmxBERestorePixmap(PixmapPtr pPixmap)
|
|
|
|
|
{
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* If Xinerama is not active, there's nothing we can do (see comment
|
|
|
|
|
* in #else below for more info). */
|
|
|
|
|
if (noPanoramiXExtension) {
|
|
|
|
|
dmxLog(dmxWarning, "Cannot restore pixmap image\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FoundPixImage = False;
|
|
|
|
|
for (i = currentMaxClients; --i >= 0; )
|
|
|
|
|
if (clients[i])
|
|
|
|
|
FindAllClientResources(clients[i], dmxBERestorePixmapImage,
|
|
|
|
|
(pointer)pPixmap);
|
|
|
|
|
|
|
|
|
|
/* No corresponding pixmap image was found on other screens, so we
|
|
|
|
|
* need to copy it from the saved image when the screen was detached
|
|
|
|
|
* (if available). */
|
|
|
|
|
if (!FoundPixImage) {
|
|
|
|
|
dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
|
|
|
|
|
|
|
|
|
|
if (pPixPriv->detachedImage) {
|
|
|
|
|
ScreenPtr pScreen = pPixmap->drawable.pScreen;
|
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
|
XlibGC gc = NULL;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
|
|
|
|
|
if (dmxScreen->bePixmapFormats[i].depth ==
|
|
|
|
|
pPixPriv->detachedImage->depth) {
|
|
|
|
|
unsigned long m;
|
|
|
|
|
XGCValues v;
|
|
|
|
|
|
|
|
|
|
m = GCFunction | GCPlaneMask | GCClipMask;
|
|
|
|
|
v.function = GXcopy;
|
|
|
|
|
v.plane_mask = AllPlanes;
|
|
|
|
|
v.clip_mask = None;
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
gc = XCreateGC(dmxScreen->beDisplay,
|
|
|
|
|
dmxScreen->scrnDefDrawables[i],
|
|
|
|
|
m, &v);
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gc) {
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
XPutImage(dmxScreen->beDisplay,
|
|
|
|
|
pPixPriv->pixmap,
|
|
|
|
|
gc,
|
|
|
|
|
pPixPriv->detachedImage,
|
|
|
|
|
0, 0, 0, 0,
|
|
|
|
|
pPixmap->drawable.width, pPixmap->drawable.height);
|
|
|
|
|
XFreeGC(dmxScreen->beDisplay, gc);
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
} else {
|
|
|
|
|
dmxLog(dmxWarning, "Cannot restore pixmap image\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XDestroyImage(pPixPriv->detachedImage);
|
|
|
|
|
pPixPriv->detachedImage = NULL;
|
|
|
|
|
} else {
|
2008-06-03 18:18:04 -04:00
|
|
|
dmxLog(dmxWarning, "Cannot restore pixmap image: %dx%d - %d\n",
|
|
|
|
|
pPixmap->drawable.width,
|
|
|
|
|
pPixmap->drawable.height,
|
|
|
|
|
pPixmap->drawable.depth);
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
/* If Xinerama is not enabled, then there is no other copy of the
|
|
|
|
|
* pixmap image that we can restore. Saving all pixmap data is not
|
|
|
|
|
* a feasible option since there is no mechanism for updating pixmap
|
|
|
|
|
* data when a screen is detached, which means that the data that
|
|
|
|
|
* was previously saved would most likely be out of date. */
|
|
|
|
|
dmxLog(dmxWarning, "Cannot restore pixmap image\n");
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Create resources on the back-end server. This function is called
|
|
|
|
|
* from #dmxAttachScreen() via the dix layer's FindAllResources
|
|
|
|
|
* function. It walks all resources, compares them to the screen
|
|
|
|
|
* number passed in as \a n and calls the appropriate DMX function to
|
|
|
|
|
* create the associated resource on the back-end server. */
|
|
|
|
|
static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
|
|
|
|
|
pointer n)
|
|
|
|
|
{
|
|
|
|
|
int scrnNum = (int)n;
|
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[scrnNum];
|
|
|
|
|
|
|
|
|
|
if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
|
|
|
|
|
/* Window resources are created below in dmxBECreateWindowTree */
|
|
|
|
|
} else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
|
|
|
|
|
PixmapPtr pPix = value;
|
|
|
|
|
if (pPix->drawable.pScreen->myNum == scrnNum) {
|
|
|
|
|
dmxBECreatePixmap(pPix);
|
|
|
|
|
dmxBERestorePixmap(pPix);
|
|
|
|
|
}
|
|
|
|
|
} else if ((type & TypeMask) == (RT_GC & TypeMask)) {
|
|
|
|
|
GCPtr pGC = value;
|
|
|
|
|
if (pGC->pScreen->myNum == scrnNum) {
|
|
|
|
|
/* Create the GC on the back-end server */
|
|
|
|
|
dmxBECreateGC(pScreen, pGC);
|
|
|
|
|
/* Create any pixmaps associated with this GC */
|
|
|
|
|
if (!pGC->tileIsPixel) {
|
|
|
|
|
dmxBECreatePixmap(pGC->tile.pixmap);
|
|
|
|
|
dmxBERestorePixmap(pGC->tile.pixmap);
|
|
|
|
|
}
|
|
|
|
|
if (pGC->stipple != pScreen->PixmapPerDepth[0]) {
|
|
|
|
|
dmxBECreatePixmap(pGC->stipple);
|
|
|
|
|
dmxBERestorePixmap(pGC->stipple);
|
|
|
|
|
}
|
|
|
|
|
if (pGC->font != defaultFont) {
|
|
|
|
|
(void)dmxBELoadFont(pScreen, pGC->font);
|
|
|
|
|
}
|
|
|
|
|
/* Update the GC on the back-end server */
|
|
|
|
|
dmxChangeGC(pGC, -1L);
|
|
|
|
|
}
|
|
|
|
|
} else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
|
|
|
|
|
(void)dmxBELoadFont(pScreen, (FontPtr)value);
|
|
|
|
|
} else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
|
2008-06-24 12:28:20 -04:00
|
|
|
dmxBECreateCursor (pScreen, (CursorPtr) value);
|
|
|
|
|
} else if ((type & TypeMask) == (RT_PASSIVEGRAB & TypeMask)) {
|
|
|
|
|
GrabPtr grab = value;
|
|
|
|
|
if (grab->cursor)
|
|
|
|
|
dmxBECreateCursor (pScreen, grab->cursor);
|
2004-06-30 20:06:56 +00:00
|
|
|
} else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
|
|
|
|
|
ColormapPtr pCmap = value;
|
|
|
|
|
if (pCmap->pScreen->myNum == scrnNum)
|
|
|
|
|
(void)dmxBECreateColormap((ColormapPtr)value);
|
2008-08-05 04:04:09 -04:00
|
|
|
} else if ((type & TypeMask) == (DMX_SHMSEG & TypeMask)) {
|
|
|
|
|
dmxBEAttachShmSeg (&dmxScreens[scrnNum], (dmxShmSegInfoPtr) value);
|
2004-06-30 20:06:56 +00:00
|
|
|
#if 0
|
|
|
|
|
#ifdef RENDER
|
|
|
|
|
/* TODO: Recreate Picture and GlyphSet resources */
|
|
|
|
|
} else if ((type & TypeMask) == (PictureType & TypeMask)) {
|
|
|
|
|
/* Picture resources are created when windows are created */
|
|
|
|
|
} else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
|
|
|
|
|
dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
/* Other resource types??? */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Create window hierachy on back-end server. The window tree is
|
|
|
|
|
* created in a special order (bottom most subwindow first) so that the
|
|
|
|
|
* #dmxCreateNonRootWindow() function does not need to recursively call
|
|
|
|
|
* itself to create each window's parents. This is required so that we
|
|
|
|
|
* have the opportunity to create each window's border and background
|
|
|
|
|
* pixmaps (where appropriate) before the window is created. */
|
|
|
|
|
static void dmxBECreateWindowTree(int idx)
|
|
|
|
|
{
|
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[idx];
|
|
|
|
|
WindowPtr pRoot = WindowTable[idx];
|
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
|
|
|
|
|
WindowPtr pWin;
|
|
|
|
|
|
|
|
|
|
/* Create the pixmaps associated with the root window */
|
|
|
|
|
if (!pRoot->borderIsPixel) {
|
|
|
|
|
dmxBECreatePixmap(pRoot->border.pixmap);
|
|
|
|
|
dmxBERestorePixmap(pRoot->border.pixmap);
|
|
|
|
|
}
|
|
|
|
|
if (pRoot->backgroundState == BackgroundPixmap) {
|
|
|
|
|
dmxBECreatePixmap(pRoot->background.pixmap);
|
|
|
|
|
dmxBERestorePixmap(pRoot->background.pixmap);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
dmxBECreateCursor (screenInfo.screens[idx], pRoot->optional->cursor);
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Create root window first */
|
|
|
|
|
dmxScreen->rootWin = pWinPriv->window = dmxCreateRootWindow(pRoot);
|
2008-06-03 18:18:04 -04:00
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
#ifdef RENDER
|
|
|
|
|
if (pWinPriv->hasPict) dmxCreatePictureList (pRoot);
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
pWin = pRoot->lastChild;
|
|
|
|
|
while (pWin) {
|
|
|
|
|
pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
|
|
|
|
|
|
|
|
|
|
/* Create the pixmaps regardless of whether or not the
|
|
|
|
|
* window is created or not due to lazy window creation.
|
|
|
|
|
*/
|
|
|
|
|
if (!pWin->borderIsPixel) {
|
|
|
|
|
dmxBECreatePixmap(pWin->border.pixmap);
|
|
|
|
|
dmxBERestorePixmap(pWin->border.pixmap);
|
|
|
|
|
}
|
|
|
|
|
if (pWin->backgroundState == BackgroundPixmap) {
|
|
|
|
|
dmxBECreatePixmap(pWin->background.pixmap);
|
|
|
|
|
dmxBERestorePixmap(pWin->background.pixmap);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
if (wUseDefault(pWin, cursor, 0))
|
|
|
|
|
dmxBECreateCursor (screenInfo.screens[idx],
|
|
|
|
|
pWin->optional->cursor);
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Reset the window attributes */
|
|
|
|
|
dmxGetDefaultWindowAttributes(pWin,
|
|
|
|
|
&pWinPriv->cmap,
|
|
|
|
|
&pWinPriv->visual);
|
|
|
|
|
|
|
|
|
|
/* Create the window */
|
2008-06-03 18:18:04 -04:00
|
|
|
dmxCreateAndRealizeWindow(pWin, TRUE);
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-07-10 17:12:10 -04:00
|
|
|
/* Next, create the bottom-most child */
|
|
|
|
|
if (pWin->lastChild) {
|
|
|
|
|
pWin = pWin->lastChild;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the window has no children, move on to the next higher window */
|
|
|
|
|
while (!pWin->prevSib && (pWin != pRoot))
|
|
|
|
|
pWin = pWin->parent;
|
|
|
|
|
|
|
|
|
|
if (pWin->prevSib) {
|
|
|
|
|
pWin = pWin->prevSib;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* When we reach the root window, we are finished */
|
|
|
|
|
if (pWin == pRoot)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-09-02 14:25:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dmxBEMapRootWindow(int idx)
|
|
|
|
|
{
|
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[idx];
|
2008-09-02 14:19:01 +02:00
|
|
|
|
|
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
|
|
|
|
XMapWindow(dmxScreen->beDisplay, dmxScreen->rootWin);
|
|
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
2008-07-10 17:12:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dmxBECreateWindowProperties (int idx)
|
|
|
|
|
{
|
|
|
|
|
WindowPtr pRoot = WindowTable[idx];
|
2008-09-03 14:52:46 +02:00
|
|
|
WindowPtr pRoot0 = pRoot;
|
2008-07-10 17:12:10 -04:00
|
|
|
WindowPtr pWin;
|
|
|
|
|
WindowPtr pWin0;
|
2008-09-03 13:42:42 +02:00
|
|
|
PropertyPtr pProp, pLast;
|
2008-07-10 17:12:10 -04:00
|
|
|
|
2008-09-03 14:52:46 +02:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
if (!noPanoramiXExtension)
|
|
|
|
|
pRoot0 = WindowTable[0];
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-09-03 13:42:42 +02:00
|
|
|
pWin = pRoot;
|
|
|
|
|
pWin0 = pRoot0;
|
2008-07-10 17:12:10 -04:00
|
|
|
while (pWin)
|
|
|
|
|
{
|
2008-09-03 13:42:42 +02:00
|
|
|
pLast = NULL;
|
2008-09-03 14:52:46 +02:00
|
|
|
do
|
2008-09-03 13:42:42 +02:00
|
|
|
{
|
|
|
|
|
for (pProp = wUserProps (pWin0); pProp; pProp = pProp->next)
|
2008-09-03 14:52:46 +02:00
|
|
|
if (pProp->next == pLast)
|
2008-09-03 13:42:42 +02:00
|
|
|
break;
|
|
|
|
|
|
2008-09-03 14:52:46 +02:00
|
|
|
if (pProp)
|
|
|
|
|
dmxBESetWindowProperty (pWin, (pLast = pProp));
|
|
|
|
|
} while (pLast != wUserProps (pWin0));
|
2008-07-10 14:26:31 -04:00
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Next, create the bottom-most child */
|
|
|
|
|
if (pWin->lastChild) {
|
|
|
|
|
pWin = pWin->lastChild;
|
2008-07-10 14:26:31 -04:00
|
|
|
pWin0 = pWin0->lastChild;
|
2004-06-30 20:06:56 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the window has no children, move on to the next higher window */
|
|
|
|
|
while (!pWin->prevSib && (pWin != pRoot))
|
2008-07-10 14:26:31 -04:00
|
|
|
{
|
2004-06-30 20:06:56 +00:00
|
|
|
pWin = pWin->parent;
|
2008-07-10 14:26:31 -04:00
|
|
|
pWin0 = pWin0->parent;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
if (pWin->prevSib) {
|
|
|
|
|
pWin = pWin->prevSib;
|
2008-07-10 14:26:31 -04:00
|
|
|
pWin0 = pWin0->prevSib;
|
2004-06-30 20:06:56 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* When we reach the root window, we are finished */
|
|
|
|
|
if (pWin == pRoot)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Compare the new and old screens to see if they are compatible. */
|
2008-06-30 15:51:12 -04:00
|
|
|
static Bool dmxCompareScreens(DMXScreenInfo *new,
|
|
|
|
|
DMXScreenInfo *old,
|
|
|
|
|
dmxErrorSetProcPtr errorSet,
|
|
|
|
|
void *error,
|
|
|
|
|
const char *errorName)
|
2004-06-30 20:06:56 +00:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2008-06-04 23:40:22 -04:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
if (!noPanoramiXExtension)
|
|
|
|
|
{
|
2008-07-14 10:45:43 -04:00
|
|
|
ScreenPtr pScreen = screenInfo.screens[0];
|
|
|
|
|
int j;
|
2008-06-04 23:40:22 -04:00
|
|
|
|
2008-07-03 16:27:36 -04:00
|
|
|
old = dmxScreens; /* each new screen must match the first screen */
|
2008-06-04 23:40:22 -04:00
|
|
|
|
|
|
|
|
if (new->beDepth != old->beDepth)
|
|
|
|
|
{
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen depth is not %d",
|
|
|
|
|
old->beDepth);
|
2008-06-04 23:40:22 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new->beBPP != old->beBPP)
|
|
|
|
|
{
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen BPP is not %d",
|
|
|
|
|
old->beBPP);
|
2008-06-04 23:40:22 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < old->beNumDepths; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j = 0; j < new->beNumDepths; j++)
|
|
|
|
|
if (new->beDepths[j] == old->beDepths[i])
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (j == new->beNumDepths)
|
|
|
|
|
{
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen doesn't support depth %d",
|
|
|
|
|
old->beDepths[i]);
|
2008-06-04 23:40:22 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < old->beNumPixmapFormats; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j = 0; j < new->beNumPixmapFormats; j++)
|
|
|
|
|
if (new->bePixmapFormats[j].depth ==
|
|
|
|
|
old->bePixmapFormats[i].depth &&
|
|
|
|
|
new->bePixmapFormats[j].bits_per_pixel ==
|
|
|
|
|
old->bePixmapFormats[i].bits_per_pixel &&
|
|
|
|
|
new->bePixmapFormats[j].scanline_pad ==
|
|
|
|
|
old->bePixmapFormats[i].scanline_pad)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (j == new->beNumPixmapFormats)
|
|
|
|
|
{
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen doesn't support pixmap format "
|
|
|
|
|
"depth=%d,bits_per_pixel=%d,scanline_pad=%d\n",
|
|
|
|
|
old->bePixmapFormats[i].depth,
|
|
|
|
|
old->bePixmapFormats[i].bits_per_pixel,
|
|
|
|
|
old->bePixmapFormats[i].scanline_pad);
|
2008-06-04 23:40:22 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-14 10:45:43 -04:00
|
|
|
for (i = 0; i < pScreen->numVisuals; i++)
|
2008-06-04 23:40:22 -04:00
|
|
|
{
|
2008-07-14 10:45:43 -04:00
|
|
|
int k;
|
|
|
|
|
|
|
|
|
|
for (k = 0; k < old->beNumVisuals; k++)
|
|
|
|
|
if (pScreen->visuals[i].class ==
|
|
|
|
|
old->beVisuals[k].class &&
|
|
|
|
|
pScreen->visuals[i].bitsPerRGBValue ==
|
|
|
|
|
old->beVisuals[k].bits_per_rgb &&
|
|
|
|
|
pScreen->visuals[i].ColormapEntries ==
|
|
|
|
|
old->beVisuals[k].colormap_size &&
|
|
|
|
|
pScreen->visuals[i].nplanes ==
|
|
|
|
|
old->beVisuals[k].depth &&
|
|
|
|
|
pScreen->visuals[i].redMask ==
|
|
|
|
|
old->beVisuals[k].red_mask &&
|
|
|
|
|
pScreen->visuals[i].greenMask ==
|
|
|
|
|
old->beVisuals[k].green_mask &&
|
|
|
|
|
pScreen->visuals[i].blueMask ==
|
|
|
|
|
old->beVisuals[k].blue_mask)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
assert (k < old->beNumVisuals);
|
|
|
|
|
|
2008-06-04 23:40:22 -04:00
|
|
|
for (j = 0; j < new->beNumVisuals; j++)
|
|
|
|
|
if (new->beVisuals[j].depth ==
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].depth &&
|
2008-06-04 23:40:22 -04:00
|
|
|
new->beVisuals[j].class ==
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class &&
|
2008-06-04 23:40:22 -04:00
|
|
|
new->beVisuals[j].red_mask ==
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].red_mask &&
|
2008-06-04 23:40:22 -04:00
|
|
|
new->beVisuals[j].green_mask ==
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].green_mask &&
|
2008-06-04 23:40:22 -04:00
|
|
|
new->beVisuals[j].blue_mask ==
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].blue_mask &&
|
2008-07-03 16:56:56 -04:00
|
|
|
new->beVisuals[j].bits_per_rgb >=
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].bits_per_rgb &&
|
|
|
|
|
new->beVisuals[j].colormap_size >=
|
|
|
|
|
old->beVisuals[k].colormap_size)
|
2008-06-04 23:40:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (j == new->beNumVisuals)
|
|
|
|
|
{
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen doesn't support visual: "
|
|
|
|
|
"class: %s, "
|
|
|
|
|
"depth: %d planes, "
|
|
|
|
|
"available colormap entries: %d%s, "
|
|
|
|
|
"red/green/blue masks: 0x%lx/0x%lx/0x%lx, "
|
|
|
|
|
"significant bits in color specification: "
|
|
|
|
|
"%d bits",
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class == StaticGray ?
|
2008-06-30 15:51:12 -04:00
|
|
|
"StaticGray" :
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class == GrayScale ?
|
2008-06-30 15:51:12 -04:00
|
|
|
"GrayScale" :
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class == StaticColor ?
|
2008-06-30 15:51:12 -04:00
|
|
|
"StaticColor" :
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class == PseudoColor ?
|
2008-06-30 15:51:12 -04:00
|
|
|
"PseudoColor" :
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class == TrueColor ?
|
2008-06-30 15:51:12 -04:00
|
|
|
"TrueColor" :
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].class == DirectColor ?
|
2008-06-30 15:51:12 -04:00
|
|
|
"DirectColor" :
|
|
|
|
|
"Unknown Class",
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].depth,
|
|
|
|
|
old->beVisuals[k].colormap_size,
|
|
|
|
|
(old->beVisuals[k].class == TrueColor ||
|
|
|
|
|
old->beVisuals[k].class == DirectColor) ?
|
2008-06-30 15:51:12 -04:00
|
|
|
" per subfield" : "",
|
2008-07-14 10:45:43 -04:00
|
|
|
old->beVisuals[k].red_mask,
|
|
|
|
|
old->beVisuals[k].green_mask,
|
|
|
|
|
old->beVisuals[k].blue_mask,
|
|
|
|
|
old->beVisuals[k].bits_per_rgb);
|
2008-06-04 23:40:22 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2008-06-03 18:18:04 -04:00
|
|
|
|
2008-06-30 15:51:12 -04:00
|
|
|
if (new->beWidth != old->beWidth || new->beHeight != old->beHeight)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen dimensions are not %dx%d",
|
|
|
|
|
old->beWidth, old->beHeight);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (new->beDepth != old->beDepth)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen depth is not %d",
|
|
|
|
|
old->beDepth);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (new->beBPP != old->beBPP)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen BPP is not %dx%d",
|
|
|
|
|
old->beBPP);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (new->beNumDepths != old->beNumDepths)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen number of depths is not %d",
|
|
|
|
|
old->beNumDepths);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < old->beNumDepths; i++)
|
2008-06-30 15:51:12 -04:00
|
|
|
if (new->beDepths[i] != old->beDepths[i])
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen depth index %d is not %d",
|
|
|
|
|
i, old->beDepths[i]);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-06-30 15:51:12 -04:00
|
|
|
if (new->beNumPixmapFormats != old->beNumPixmapFormats)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen number of pixmap formats is not %d",
|
|
|
|
|
old->beNumPixmapFormats);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
for (i = 0; i < old->beNumPixmapFormats; i++) {
|
|
|
|
|
if (new->bePixmapFormats[i].depth !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->bePixmapFormats[i].depth)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"depth of screen pixmap format index %d is not %d",
|
|
|
|
|
i, old->bePixmapFormats[i].depth);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->bePixmapFormats[i].bits_per_pixel !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->bePixmapFormats[i].bits_per_pixel)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"bits_per_pixel of screen pixmap format "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->bePixmapFormats[i].bits_per_pixel);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->bePixmapFormats[i].scanline_pad !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->bePixmapFormats[i].scanline_pad)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"scanline_pad of screen pixmap format "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->bePixmapFormats[i].scanline_pad);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-30 15:51:12 -04:00
|
|
|
if (new->beNumVisuals != old->beNumVisuals)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen number of visuals is not %d",
|
|
|
|
|
old->beNumVisuals);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
for (i = 0; i < old->beNumVisuals; i++) {
|
|
|
|
|
if (new->beVisuals[i].visualid !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].visualid)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"visualid of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].visualid);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].screen !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].screen)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"screen of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].screen);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].depth !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].depth)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"depth of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].depth);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].class !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].class)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"class of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].class);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].red_mask !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].red_mask)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"red_mask of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].red_mask);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].green_mask !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].green_mask)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"green_mask of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].green_mask);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].blue_mask !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].blue_mask)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"blue_mask of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].blue_mask);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].colormap_size !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].colormap_size)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"colormap_size of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].colormap_size);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
if (new->beVisuals[i].bits_per_rgb !=
|
2008-06-30 15:51:12 -04:00
|
|
|
old->beVisuals[i].bits_per_rgb)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"bits_per_rgb of screen visual "
|
|
|
|
|
"index %d is not %d",
|
|
|
|
|
i, old->beVisuals[i].bits_per_rgb);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-30 15:51:12 -04:00
|
|
|
if (new->beDefVisualIndex != old->beDefVisualIndex)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Screen default visual index is not %d",
|
|
|
|
|
old->beDefVisualIndex);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-16 12:02:38 -05:00
|
|
|
#ifdef RENDER
|
|
|
|
|
/** Restore Render's picture */
|
|
|
|
|
static void dmxBERestoreRenderPict(pointer value, XID id, pointer n)
|
|
|
|
|
{
|
|
|
|
|
PicturePtr pPicture = value; /* The picture */
|
|
|
|
|
DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */
|
|
|
|
|
int scrnNum = (int)n;
|
|
|
|
|
|
2008-07-17 07:29:40 -04:00
|
|
|
if (pDraw)
|
|
|
|
|
{
|
|
|
|
|
if (pDraw->pScreen->myNum != scrnNum) {
|
|
|
|
|
/* Picture not on the screen we are restoring*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-12-16 12:02:38 -05:00
|
|
|
|
2008-07-17 07:29:40 -04:00
|
|
|
if (pDraw->type == DRAWABLE_PIXMAP) {
|
|
|
|
|
PixmapPtr pPixmap = (PixmapPtr)pDraw;
|
2006-12-16 12:02:38 -05:00
|
|
|
|
2008-07-17 07:29:40 -04:00
|
|
|
/* Create and restore the pixmap drawable */
|
|
|
|
|
dmxBECreatePixmap(pPixmap);
|
|
|
|
|
dmxBERestorePixmap(pPixmap);
|
|
|
|
|
}
|
2006-12-16 12:02:38 -05:00
|
|
|
}
|
|
|
|
|
|
2008-07-17 07:29:40 -04:00
|
|
|
dmxBECreatePicture(scrnNum, pPicture);
|
2006-12-16 12:02:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Restore Render's glyphs */
|
|
|
|
|
static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
|
|
|
|
|
{
|
|
|
|
|
GlyphSetPtr glyphSet = value;
|
|
|
|
|
int scrnNum = (int)n;
|
|
|
|
|
dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
|
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum];
|
|
|
|
|
GlyphRefPtr table;
|
|
|
|
|
char *images;
|
|
|
|
|
Glyph *gids;
|
|
|
|
|
XGlyphInfo *glyphs;
|
|
|
|
|
char *pos;
|
|
|
|
|
int beret;
|
|
|
|
|
int len_images = 0;
|
2008-07-16 19:40:58 -04:00
|
|
|
int i, size;
|
2006-12-16 12:02:38 -05:00
|
|
|
int ctr;
|
|
|
|
|
|
|
|
|
|
if (glyphPriv->glyphSets[scrnNum]) {
|
|
|
|
|
/* Only restore glyphs on the screen we are attaching */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* First we must create the glyph set on the backend. */
|
|
|
|
|
if ((beret = dmxBECreateGlyphSet(scrnNum, glyphSet)) != Success) {
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"\tdmxBERestoreRenderGlyph failed to create glyphset!\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now for the complex part, restore the glyph data */
|
|
|
|
|
table = glyphSet->hash.table;
|
|
|
|
|
|
|
|
|
|
/* We need to know how much memory to allocate for this part */
|
|
|
|
|
for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
|
|
|
|
|
GlyphRefPtr gr = &table[i];
|
|
|
|
|
GlyphPtr gl = gr->glyph;
|
|
|
|
|
|
|
|
|
|
if (!gl || gl == DeletedGlyph) continue;
|
2008-06-24 12:28:20 -04:00
|
|
|
|
|
|
|
|
size = gl->info.height * PixmapBytePad (gl->info.width,
|
|
|
|
|
glyphSet->format->depth);
|
|
|
|
|
if (size & 3)
|
|
|
|
|
size += 4 - (size & 3);
|
|
|
|
|
|
|
|
|
|
len_images += size;
|
2006-12-16 12:02:38 -05:00
|
|
|
}
|
|
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
if (!len_images)
|
|
|
|
|
return;
|
|
|
|
|
|
2006-12-16 12:02:38 -05:00
|
|
|
/* Now allocate the memory we need */
|
2008-10-20 16:54:34 -04:00
|
|
|
images = calloc(len_images, sizeof(char));
|
2007-11-05 14:10:21 +00:00
|
|
|
gids = xalloc(glyphSet->hash.tableEntries*sizeof(Glyph));
|
|
|
|
|
glyphs = xalloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
|
2006-12-16 12:02:38 -05:00
|
|
|
|
|
|
|
|
pos = images;
|
|
|
|
|
ctr = 0;
|
|
|
|
|
|
|
|
|
|
/* Fill the allocated memory with the proper data */
|
|
|
|
|
for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
|
|
|
|
|
GlyphRefPtr gr = &table[i];
|
|
|
|
|
GlyphPtr gl = gr->glyph;
|
2008-07-16 19:40:58 -04:00
|
|
|
char *data;
|
2006-12-16 12:02:38 -05:00
|
|
|
|
|
|
|
|
if (!gl || gl == DeletedGlyph) continue;
|
|
|
|
|
|
|
|
|
|
/* First lets put the data into gids */
|
|
|
|
|
gids[ctr] = gr->signature;
|
|
|
|
|
|
|
|
|
|
/* Next do the glyphs data structures */
|
|
|
|
|
glyphs[ctr].width = gl->info.width;
|
|
|
|
|
glyphs[ctr].height = gl->info.height;
|
|
|
|
|
glyphs[ctr].x = gl->info.x;
|
|
|
|
|
glyphs[ctr].y = gl->info.y;
|
|
|
|
|
glyphs[ctr].xOff = gl->info.xOff;
|
|
|
|
|
glyphs[ctr].yOff = gl->info.yOff;
|
|
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
size = gl->info.height * PixmapBytePad (gl->info.width,
|
|
|
|
|
glyphSet->format->depth);
|
|
|
|
|
if (size & 3)
|
|
|
|
|
size += 4 - (size & 3);
|
|
|
|
|
|
2008-07-16 19:40:58 -04:00
|
|
|
data = dixLookupPrivate (&(gl)->devPrivates, dmxGlyphPrivateKey);
|
|
|
|
|
if (data)
|
2008-06-24 12:28:20 -04:00
|
|
|
{
|
2008-07-16 19:40:58 -04:00
|
|
|
memcpy (pos, data, size);
|
2008-06-24 12:28:20 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dmxLog (dmxWarning,
|
|
|
|
|
"Cannot restore glyph image: %dx%d %d\n",
|
|
|
|
|
gl->info.width,
|
|
|
|
|
gl->info.height,
|
|
|
|
|
glyphSet->format->depth);
|
|
|
|
|
|
|
|
|
|
memset (pos, 0xff, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos += size;
|
2006-12-16 12:02:38 -05:00
|
|
|
ctr++;
|
|
|
|
|
}
|
2008-06-24 12:28:20 -04:00
|
|
|
|
2006-12-16 12:02:38 -05:00
|
|
|
/* Now restore the glyph data */
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
2006-12-16 12:02:38 -05:00
|
|
|
XRenderAddGlyphs(dmxScreen->beDisplay, glyphPriv->glyphSets[scrnNum],
|
2008-06-24 12:28:20 -04:00
|
|
|
gids, glyphs, ctr, images, len_images);
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
2006-12-16 12:02:38 -05:00
|
|
|
|
|
|
|
|
/* Clean up */
|
2008-06-24 12:28:20 -04:00
|
|
|
xfree(images);
|
2007-11-05 14:10:21 +00:00
|
|
|
xfree(gids);
|
|
|
|
|
xfree(glyphs);
|
2006-12-16 12:02:38 -05:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/** Reattach previously detached back-end screen. */
|
2008-06-27 15:19:14 -04:00
|
|
|
int
|
|
|
|
|
dmxAttachScreen (int idx,
|
|
|
|
|
DMXScreenAttributesPtr attr,
|
2008-08-08 12:22:03 -04:00
|
|
|
unsigned int window,
|
2008-06-27 15:19:14 -04:00
|
|
|
const char *authType,
|
2008-08-08 12:22:03 -04:00
|
|
|
int authTypeLen,
|
2008-06-27 15:19:14 -04:00
|
|
|
const char *authData,
|
2008-06-30 15:51:12 -04:00
|
|
|
int authDataLen,
|
|
|
|
|
dmxErrorSetProcPtr errorSet,
|
|
|
|
|
void *error,
|
|
|
|
|
const char *errorName)
|
2004-06-30 20:06:56 +00:00
|
|
|
{
|
2008-09-26 13:46:25 -04:00
|
|
|
ScreenPtr pScreen;
|
2006-04-07 01:18:01 +00:00
|
|
|
DMXScreenInfo *dmxScreen;
|
2008-09-26 13:46:25 -04:00
|
|
|
DMXScreenInfo oldDMXScreen;
|
2008-11-19 17:33:38 -05:00
|
|
|
Bool beShape = FALSE;
|
|
|
|
|
int errorBase;
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
/* Return failure if dynamic addition/removal of screens is disabled */
|
|
|
|
|
if (!dmxAddRemoveScreens) {
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"Attempting to add a screen, but the AddRemoveScreen\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"extension has not been enabled. To enable this extension\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"add the \"-addremovescreens\" option either to the command\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"line or in the configuration file.\n");
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxErrorSet (errorSet, error, errorName,
|
|
|
|
|
"Screen attach extension has not been enabled");
|
2004-06-30 20:06:56 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Cannot add a screen that does not exist */
|
2008-06-30 15:51:12 -04:00
|
|
|
if (idx < 0 || idx >= dmxNumScreens)
|
|
|
|
|
{
|
|
|
|
|
dmxErrorSet (errorSet, error, errorName,
|
|
|
|
|
"Screen %d does not exist", idx);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-07 01:18:01 +00:00
|
|
|
pScreen = screenInfo.screens[idx];
|
|
|
|
|
dmxScreen = &dmxScreens[idx];
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
/* Cannot attach to a screen that is already opened */
|
2008-09-26 13:46:25 -04:00
|
|
|
if (dmxScreen->name && *dmxScreen->name) {
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
2008-08-08 12:22:03 -04:00
|
|
|
"Attempting to attach back-end server to screen #%d "
|
|
|
|
|
"but back-end server is already attached to this "
|
|
|
|
|
"screen", idx);
|
2004-06-30 20:06:56 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dmxLogOutput(dmxScreen, "Attaching screen #%d\n", idx);
|
|
|
|
|
|
|
|
|
|
/* Save old info */
|
|
|
|
|
oldDMXScreen = *dmxScreen;
|
|
|
|
|
|
2008-08-10 10:26:08 -04:00
|
|
|
dmxScreen->scrnWin = window;
|
2008-07-18 00:23:10 -04:00
|
|
|
dmxScreen->virtualFb = FALSE;
|
2008-07-09 18:06:28 -04:00
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Open display and get all of the screen info */
|
2008-09-26 13:46:25 -04:00
|
|
|
if (!dmxOpenDisplay(dmxScreen,
|
|
|
|
|
attr->displayName,
|
|
|
|
|
authType,
|
|
|
|
|
authTypeLen,
|
|
|
|
|
authData,
|
|
|
|
|
authDataLen)) {
|
2008-06-30 15:51:12 -04:00
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Can't open display: %s",
|
2008-09-26 13:46:25 -04:00
|
|
|
attr->displayName);
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
/* Restore the old screen */
|
|
|
|
|
*dmxScreen = oldDMXScreen;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-19 17:40:58 -05:00
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
2008-11-19 17:33:38 -05:00
|
|
|
beShape = XShapeQueryExtension (dmxScreen->beDisplay,
|
|
|
|
|
&dmxScreen->beShapeEventBase,
|
|
|
|
|
&errorBase);
|
|
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
|
|
|
|
|
|
|
|
|
if (!beShape)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
2009-01-22 11:40:31 -05:00
|
|
|
"SHAPE extension missing on back-end server");
|
2008-11-19 17:33:38 -05:00
|
|
|
dmxCloseDisplay (dmxScreen);
|
|
|
|
|
|
|
|
|
|
/* Restore the old screen */
|
|
|
|
|
*dmxScreen = oldDMXScreen;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-22 11:40:31 -05:00
|
|
|
#ifdef COMPOSITE
|
|
|
|
|
if (!noCompositeExtension)
|
|
|
|
|
{
|
|
|
|
|
Bool beComposite = FALSE;
|
|
|
|
|
int eventBase;
|
|
|
|
|
|
|
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
|
|
|
|
beComposite = XCompositeQueryExtension (dmxScreen->beDisplay,
|
|
|
|
|
&eventBase,
|
|
|
|
|
&errorBase);
|
|
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
|
|
|
|
|
|
|
|
|
if (!beComposite)
|
|
|
|
|
{
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"Composite extension missing on back-end server");
|
|
|
|
|
dmxCloseDisplay (dmxScreen);
|
|
|
|
|
|
|
|
|
|
/* Restore the old screen */
|
|
|
|
|
*dmxScreen = oldDMXScreen;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-08-10 10:26:08 -04:00
|
|
|
if (!dmxScreen->scrnWin)
|
|
|
|
|
dmxScreen->scrnWin = DefaultRootWindow (dmxScreen->beDisplay);
|
|
|
|
|
|
2008-11-19 17:40:58 -05:00
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
2008-10-04 22:07:22 -04:00
|
|
|
XSelectInput (dmxScreen->beDisplay,
|
|
|
|
|
dmxScreen->scrnWin,
|
|
|
|
|
StructureNotifyMask);
|
2008-11-19 17:40:58 -05:00
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
2008-10-04 22:07:22 -04:00
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
dmxSetErrorHandler(dmxScreen);
|
|
|
|
|
dmxGetScreenAttribs(dmxScreen);
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
if (!dmxGetVisualInfo(dmxScreen)) {
|
|
|
|
|
dmxLogErrorSet (dmxWarning, errorSet, error, errorName,
|
|
|
|
|
"No matching visuals found");
|
|
|
|
|
XFree(dmxScreen->beVisuals);
|
|
|
|
|
dmxCloseDisplay (dmxScreen);
|
|
|
|
|
|
|
|
|
|
/* Restore the old screen */
|
|
|
|
|
*dmxScreen = oldDMXScreen;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dmxGetColormaps(dmxScreen);
|
|
|
|
|
dmxGetPixmapFormats(dmxScreen);
|
|
|
|
|
|
|
|
|
|
/* Verify that the screen to be added has the same info as the
|
|
|
|
|
* previously added screen. */
|
|
|
|
|
if (!dmxCompareScreens(dmxScreen,
|
|
|
|
|
&oldDMXScreen,
|
|
|
|
|
errorSet,
|
|
|
|
|
error,
|
|
|
|
|
errorName))
|
|
|
|
|
{
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"New screen data (%s) does not match previously\n",
|
|
|
|
|
dmxScreen->name);
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"attached screen data\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"All data must match in order to attach to screen #%d\n",
|
|
|
|
|
idx);
|
|
|
|
|
XFree(dmxScreen->beVisuals);
|
|
|
|
|
XFree(dmxScreen->beDepths);
|
|
|
|
|
XFree(dmxScreen->bePixmapFormats);
|
|
|
|
|
dmxCloseDisplay (dmxScreen);
|
|
|
|
|
|
|
|
|
|
/* Restore the old screen */
|
|
|
|
|
*dmxScreen = oldDMXScreen;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create the default font */
|
|
|
|
|
if (!dmxBELoadFont(pScreen, defaultFont))
|
|
|
|
|
{
|
|
|
|
|
dmxErrorSet (errorSet, error, errorName,
|
|
|
|
|
"Failed to load default font");
|
|
|
|
|
XFree(dmxScreen->beVisuals);
|
|
|
|
|
XFree(dmxScreen->beDepths);
|
|
|
|
|
XFree(dmxScreen->bePixmapFormats);
|
|
|
|
|
dmxCloseDisplay (dmxScreen);
|
|
|
|
|
|
|
|
|
|
/* Restore the old screen */
|
|
|
|
|
*dmxScreen = oldDMXScreen;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We used these to compare the old and new screens. They are no
|
|
|
|
|
* longer needed since we have a newly attached screen, so we can
|
|
|
|
|
* now free the old screen's resources. */
|
|
|
|
|
if (oldDMXScreen.beVisuals)
|
|
|
|
|
XFree(oldDMXScreen.beVisuals);
|
|
|
|
|
if (oldDMXScreen.beDepths)
|
|
|
|
|
XFree(oldDMXScreen.beDepths);
|
|
|
|
|
if (oldDMXScreen.bePixmapFormats)
|
|
|
|
|
XFree(oldDMXScreen.bePixmapFormats);
|
|
|
|
|
|
|
|
|
|
if (attr->name)
|
|
|
|
|
dmxScreen->name = strdup(attr->name);
|
|
|
|
|
else
|
|
|
|
|
dmxScreen->name = strdup(attr->displayName);
|
2008-10-04 22:07:22 -04:00
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
dmxScreen->beAttachedDisplay = dmxScreen->beDisplay;
|
|
|
|
|
dmxScreen->beDisplay = NULL;
|
|
|
|
|
|
2009-01-26 18:41:32 -05:00
|
|
|
dmxScreen->rootX = attr->rootWindowXoffset;
|
|
|
|
|
dmxScreen->rootY = attr->rootWindowYoffset;
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
return 0; /* Success */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
dmxEnableScreen (int idx)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[idx];
|
|
|
|
|
dmxScreen = &dmxScreens[idx];
|
|
|
|
|
|
|
|
|
|
dmxLogOutput(dmxScreen, "Enable screen #%d\n", idx);
|
|
|
|
|
|
|
|
|
|
dmxScreen->beDisplay = dmxScreen->beAttachedDisplay;
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Initialize the BE screen resources */
|
2008-10-06 19:13:52 -04:00
|
|
|
dmxBEScreenInit(screenInfo.screens[idx]);
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
/* TODO: Handle GLX visual initialization. GLXProxy needs to be
|
|
|
|
|
* updated to handle dynamic addition/removal of screens. */
|
|
|
|
|
|
|
|
|
|
/* Create default stipple */
|
|
|
|
|
dmxBECreatePixmap(pScreen->PixmapPerDepth[0]);
|
|
|
|
|
dmxBERestorePixmap(pScreen->PixmapPerDepth[0]);
|
|
|
|
|
|
|
|
|
|
/* Create the scratch GCs */
|
|
|
|
|
dmxBECreateScratchGCs(idx);
|
|
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
/* Create the scratch pixmap */
|
|
|
|
|
if (pScreen->pScratchPixmap)
|
|
|
|
|
dmxBECreatePixmap(pScreen->pScratchPixmap);
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Create all resources that don't depend on windows */
|
|
|
|
|
for (i = currentMaxClients; --i >= 0; )
|
|
|
|
|
if (clients[i])
|
|
|
|
|
FindAllClientResources(clients[i], dmxBECreateResources,
|
|
|
|
|
(pointer)idx);
|
|
|
|
|
|
|
|
|
|
/* Create window hierarchy (top down) */
|
|
|
|
|
dmxBECreateWindowTree(idx);
|
2008-07-15 15:36:39 -04:00
|
|
|
dmxBECreateWindowProperties(idx);
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2006-12-16 12:02:38 -05:00
|
|
|
#ifdef RENDER
|
|
|
|
|
/* Restore the picture state for RENDER */
|
|
|
|
|
for (i = currentMaxClients; --i >= 0; )
|
|
|
|
|
if (clients[i])
|
|
|
|
|
FindClientResourcesByType(clients[i],PictureType,
|
|
|
|
|
dmxBERestoreRenderPict,(pointer)idx);
|
|
|
|
|
|
|
|
|
|
/* Restore the glyph state for RENDER */
|
|
|
|
|
for (i = currentMaxClients; --i >= 0; )
|
|
|
|
|
if (clients[i])
|
|
|
|
|
FindClientResourcesByType(clients[i],GlyphSetType,
|
|
|
|
|
dmxBERestoreRenderGlyph,(pointer)idx);
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-09-02 14:26:52 +02:00
|
|
|
dmxBEMapRootWindow(idx);
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
#ifdef RANDR
|
2008-06-24 12:28:20 -04:00
|
|
|
RRGetInfo (screenInfo.screens[0]);
|
2004-06-30 20:06:56 +00:00
|
|
|
#endif
|
2008-06-03 18:18:04 -04:00
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
dmxInputEnable (&dmxScreen->input);
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Resources that may have state on the BE server and need to be freed:
|
|
|
|
|
*
|
|
|
|
|
* RT_NONE
|
|
|
|
|
* RT_WINDOW
|
|
|
|
|
* RT_PIXMAP
|
|
|
|
|
* RT_GC
|
|
|
|
|
* RT_FONT
|
|
|
|
|
* RT_CURSOR
|
|
|
|
|
* RT_COLORMAP
|
|
|
|
|
* RT_CMAPENTRY
|
|
|
|
|
* RT_OTHERCLIENT
|
|
|
|
|
* RT_PASSIVEGRAB
|
|
|
|
|
* XRT_WINDOW
|
|
|
|
|
* XRT_PIXMAP
|
|
|
|
|
* XRT_GC
|
|
|
|
|
* XRT_COLORMAP
|
|
|
|
|
* XRT_PICTURE
|
|
|
|
|
* PictureType
|
|
|
|
|
* PictFormatType
|
|
|
|
|
* GlyphSetType
|
|
|
|
|
* ClientType
|
|
|
|
|
* EventType
|
|
|
|
|
* RT_INPUTCLIENT
|
|
|
|
|
* XETrapType
|
|
|
|
|
* RTCounter
|
|
|
|
|
* RTAwait
|
|
|
|
|
* RTAlarmClient
|
|
|
|
|
* RT_XKBCLIENT
|
|
|
|
|
* RTContext
|
|
|
|
|
* TagResType
|
|
|
|
|
* StalledResType
|
|
|
|
|
* SecurityAuthorizationResType
|
|
|
|
|
* RTEventClient
|
|
|
|
|
* __glXContextRes
|
|
|
|
|
* __glXClientRes
|
|
|
|
|
* __glXPixmapRes
|
|
|
|
|
* __glXWindowRes
|
|
|
|
|
* __glXPbufferRes
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
|
|
|
|
|
* to have its image saved. */
|
|
|
|
|
static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
|
|
|
|
|
pointer p)
|
|
|
|
|
{
|
|
|
|
|
if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
|
|
|
|
|
PixmapPtr pDst = (PixmapPtr)p;
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
PanoramiXRes *pXinPix = (PanoramiXRes *)value;
|
|
|
|
|
PixmapPtr pPix;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
|
2008-06-03 18:18:04 -04:00
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
if (pPix != pDst) return; /* Not a match.... Next! */
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PanoramiXNumScreens; i++) {
|
|
|
|
|
PixmapPtr pSrc;
|
|
|
|
|
dmxPixPrivPtr pSrcPriv = NULL;
|
|
|
|
|
|
|
|
|
|
if (i == idx) continue; /* Self replication is bad */
|
|
|
|
|
|
|
|
|
|
pSrc =
|
|
|
|
|
(PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
|
2008-06-03 18:18:04 -04:00
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
|
|
|
|
|
if (pSrcPriv->pixmap) {
|
|
|
|
|
FoundPixImage = True;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-06-03 18:18:04 -04:00
|
|
|
|
|
|
|
|
#ifdef RENDER
|
|
|
|
|
else if ((type & TypeMask) == (XRT_PICTURE & TypeMask))
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pDst = (PixmapPtr) p;
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
PanoramiXRes *pXinPic = (PanoramiXRes *) value;
|
|
|
|
|
PicturePtr pPic;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
pPic = (PicturePtr) LookupIDByType (pXinPic->info[idx].id,
|
|
|
|
|
PictureType);
|
|
|
|
|
|
|
|
|
|
/* Not a match.... Next! */
|
|
|
|
|
if (!pPic || !pPic->pDrawable) return;
|
|
|
|
|
if (pPic->pDrawable->type != DRAWABLE_PIXMAP) return;
|
|
|
|
|
if (pPic->pDrawable != (DrawablePtr) pDst) return;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PanoramiXNumScreens; i++) {
|
|
|
|
|
dmxPixPrivPtr pSrcPriv = NULL;
|
|
|
|
|
|
|
|
|
|
if (i == idx) continue; /* Self replication is bad */
|
|
|
|
|
|
|
|
|
|
pPic = (PicturePtr) LookupIDByType (pXinPic->info[i].id,
|
|
|
|
|
PictureType);
|
|
|
|
|
|
|
|
|
|
pSrcPriv = DMX_GET_PIXMAP_PRIV ((PixmapPtr) pPic->pDrawable);
|
|
|
|
|
if (pSrcPriv->pixmap)
|
|
|
|
|
{
|
|
|
|
|
FoundPixImage = True;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
else if ((type & TypeMask) == (XRT_WINDOW & TypeMask))
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pDst = (PixmapPtr)p;
|
|
|
|
|
int idx = pDst->drawable.pScreen->myNum;
|
|
|
|
|
PanoramiXRes *pXinWin = (PanoramiXRes *) value;
|
|
|
|
|
Bool border;
|
|
|
|
|
WindowPtr pWin;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
pWin = (WindowPtr) LookupIDByType (pXinWin->info[idx].id, RT_WINDOW);
|
|
|
|
|
|
|
|
|
|
if (!pWin) return;
|
|
|
|
|
if (!pWin->borderIsPixel && pWin->border.pixmap == pDst)
|
|
|
|
|
{
|
|
|
|
|
border = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else if (pWin->backgroundState == BackgroundPixmap &&
|
|
|
|
|
pWin->background.pixmap == pDst)
|
|
|
|
|
{
|
|
|
|
|
border = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PanoramiXNumScreens; i++) {
|
|
|
|
|
dmxPixPrivPtr pSrcPriv = NULL;
|
|
|
|
|
|
|
|
|
|
if (i == idx) continue; /* Self replication is bad */
|
|
|
|
|
|
|
|
|
|
pWin = (WindowPtr) LookupIDByType (pXinWin->info[i].id, RT_WINDOW);
|
|
|
|
|
|
|
|
|
|
if (border)
|
|
|
|
|
pSrcPriv = DMX_GET_PIXMAP_PRIV (pWin->border.pixmap);
|
|
|
|
|
else
|
|
|
|
|
pSrcPriv = DMX_GET_PIXMAP_PRIV (pWin->background.pixmap);
|
|
|
|
|
|
|
|
|
|
if (pSrcPriv->pixmap)
|
|
|
|
|
{
|
|
|
|
|
FoundPixImage = True;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/** Save the pixmap image only when there is not another screen with
|
|
|
|
|
* that pixmap from which the image can be read when the screen is
|
|
|
|
|
* reattached. To do this, we first try to find a pixmap on another
|
|
|
|
|
* screen corresponding to the one we are trying to save. If we find
|
|
|
|
|
* one, then we do not need to save the image data since during
|
|
|
|
|
* reattachment, the image data can be read from that other pixmap.
|
|
|
|
|
* However, if we do not find one, then we need to save the image data.
|
|
|
|
|
* The common case for these are for the default stipple and root
|
|
|
|
|
* tile. */
|
|
|
|
|
static void dmxBESavePixmap(PixmapPtr pPixmap)
|
|
|
|
|
{
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* If Xinerama is not active, there's nothing we can do (see comment
|
|
|
|
|
* in #else below for more info). */
|
|
|
|
|
if (noPanoramiXExtension) return;
|
|
|
|
|
|
|
|
|
|
FoundPixImage = False;
|
|
|
|
|
for (i = currentMaxClients; --i >= 0; )
|
|
|
|
|
if (clients[i])
|
|
|
|
|
FindAllClientResources(clients[i], dmxBEFindPixmapImage,
|
|
|
|
|
(pointer)pPixmap);
|
|
|
|
|
|
|
|
|
|
/* Save the image only if there is no other screens that have a
|
|
|
|
|
* pixmap that corresponds to the one we are trying to save. */
|
|
|
|
|
if (!FoundPixImage) {
|
|
|
|
|
dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
|
|
|
|
|
|
|
|
|
|
if (!pPixPriv->detachedImage) {
|
|
|
|
|
ScreenPtr pScreen = pPixmap->drawable.pScreen;
|
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_PROLOGUE (dmxScreen);
|
2004-06-30 20:06:56 +00:00
|
|
|
pPixPriv->detachedImage = XGetImage(dmxScreen->beDisplay,
|
|
|
|
|
pPixPriv->pixmap,
|
|
|
|
|
0, 0,
|
|
|
|
|
pPixmap->drawable.width,
|
|
|
|
|
pPixmap->drawable.height,
|
|
|
|
|
-1,
|
|
|
|
|
ZPixmap);
|
2008-06-03 18:18:04 -04:00
|
|
|
XLIB_EPILOGUE (dmxScreen);
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
if (!pPixPriv->detachedImage)
|
2008-06-03 18:18:04 -04:00
|
|
|
{
|
|
|
|
|
dmxLog(dmxWarning, "Cannot save pixmap image: %p - %dx%d %d\n",
|
|
|
|
|
pPixmap, pPixmap->drawable.width,
|
|
|
|
|
pPixmap->drawable.height,
|
|
|
|
|
pPixmap->drawable.depth);
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
/* NOTE: The only time there is a pixmap on another screen that
|
|
|
|
|
* corresponds to the one we are trying to save is when Xinerama is
|
|
|
|
|
* active. Otherwise, the pixmap image data is only stored on a
|
|
|
|
|
* single screen, which means that once it is detached, that data is
|
|
|
|
|
* lost. We could save the data here, but then that would require
|
|
|
|
|
* us to implement the ability for Xdmx to keep the pixmap up to
|
|
|
|
|
* date while the screen is detached, which is beyond the scope of
|
|
|
|
|
* the current project. */
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Destroy resources on the back-end server. This function is called
|
|
|
|
|
* from #dmxDetachScreen() via the dix layer's FindAllResources
|
|
|
|
|
* function. It walks all resources, compares them to the screen
|
|
|
|
|
* number passed in as \a n and calls the appropriate DMX function to
|
|
|
|
|
* free the associated resource on the back-end server. */
|
|
|
|
|
static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
|
|
|
|
|
pointer n)
|
|
|
|
|
{
|
|
|
|
|
int scrnNum = (int)n;
|
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[scrnNum];
|
|
|
|
|
|
|
|
|
|
if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
|
|
|
|
|
/* Window resources are destroyed below in dmxBEDestroyWindowTree */
|
|
|
|
|
} else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
|
|
|
|
|
PixmapPtr pPix = value;
|
|
|
|
|
if (pPix->drawable.pScreen->myNum == scrnNum) {
|
|
|
|
|
dmxBESavePixmap(pPix);
|
|
|
|
|
dmxBEFreePixmap(pPix);
|
|
|
|
|
}
|
|
|
|
|
} else if ((type & TypeMask) == (RT_GC & TypeMask)) {
|
|
|
|
|
GCPtr pGC = value;
|
|
|
|
|
if (pGC->pScreen->myNum == scrnNum)
|
|
|
|
|
dmxBEFreeGC(pGC);
|
|
|
|
|
} else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
|
|
|
|
|
dmxBEFreeFont(pScreen, (FontPtr)value);
|
|
|
|
|
} else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
|
2008-06-24 12:28:20 -04:00
|
|
|
dmxBEFreeCursor (pScreen, (CursorPtr) value);
|
2004-06-30 20:06:56 +00:00
|
|
|
} else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
|
|
|
|
|
ColormapPtr pCmap = value;
|
|
|
|
|
if (pCmap->pScreen->myNum == scrnNum)
|
|
|
|
|
dmxBEFreeColormap((ColormapPtr)value);
|
2008-08-05 04:04:09 -04:00
|
|
|
} else if ((type & TypeMask) == (DMX_SHMSEG & TypeMask)) {
|
|
|
|
|
dmxBEDetachShmSeg (&dmxScreens[scrnNum], (dmxShmSegInfoPtr) value);
|
2004-06-30 20:06:56 +00:00
|
|
|
#ifdef RENDER
|
|
|
|
|
} else if ((type & TypeMask) == (PictureType & TypeMask)) {
|
|
|
|
|
PicturePtr pPict = value;
|
2008-07-17 07:29:40 -04:00
|
|
|
if (pPict->pDrawable) {
|
|
|
|
|
if (pPict->pDrawable->pScreen->myNum == scrnNum) {
|
|
|
|
|
/* Free the pixmaps on the backend if needed */
|
|
|
|
|
if (pPict->pDrawable->type == DRAWABLE_PIXMAP) {
|
|
|
|
|
PixmapPtr pPixmap = (PixmapPtr)(pPict->pDrawable);
|
|
|
|
|
dmxBESavePixmap(pPixmap);
|
|
|
|
|
dmxBEFreePixmap(pPixmap);
|
|
|
|
|
}
|
2008-07-21 16:15:58 -04:00
|
|
|
|
|
|
|
|
dmxBEFreePicture(pScreen, (PicturePtr)value);
|
2006-12-16 12:02:38 -05:00
|
|
|
}
|
|
|
|
|
}
|
2008-07-21 16:15:58 -04:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dmxBEFreePicture(pScreen, (PicturePtr)value);
|
|
|
|
|
}
|
2004-06-30 20:06:56 +00:00
|
|
|
} else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
|
|
|
|
|
dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
/* Other resource types??? */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Destroy the scratch GCs that are created per depth. */
|
|
|
|
|
static void dmxBEDestroyScratchGCs(int scrnNum)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[scrnNum];
|
|
|
|
|
GCPtr *ppGC = pScreen->GCperDepth;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i <= pScreen->numDepths; i++)
|
|
|
|
|
dmxBEFreeGC(ppGC[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Destroy window hierachy on back-end server. To ensure that all
|
|
|
|
|
* XDestroyWindow() calls succeed, they must be performed in a bottom
|
|
|
|
|
* up order so that windows are not destroyed before their children.
|
|
|
|
|
* XDestroyWindow(), which is called from #dmxBEDestrowWindow(), will
|
|
|
|
|
* destroy a window as well as all of it's children. */
|
|
|
|
|
static void dmxBEDestroyWindowTree(int idx)
|
|
|
|
|
{
|
|
|
|
|
WindowPtr pWin = WindowTable[idx];
|
|
|
|
|
WindowPtr pChild = pWin;
|
|
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
if (pChild->firstChild) {
|
|
|
|
|
pChild = pChild->firstChild;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Destroy the window */
|
|
|
|
|
dmxBEDestroyWindow(pChild);
|
|
|
|
|
|
2008-06-24 12:28:20 -04:00
|
|
|
if (wUseDefault(pChild, cursor, 0))
|
|
|
|
|
dmxBEFreeCursor (screenInfo.screens[idx],
|
|
|
|
|
pChild->optional->cursor);
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Make sure we destroy the window's border and background
|
|
|
|
|
* pixmaps if they exist */
|
|
|
|
|
if (!pChild->borderIsPixel) {
|
|
|
|
|
dmxBESavePixmap(pChild->border.pixmap);
|
|
|
|
|
dmxBEFreePixmap(pChild->border.pixmap);
|
|
|
|
|
}
|
|
|
|
|
if (pChild->backgroundState == BackgroundPixmap) {
|
|
|
|
|
dmxBESavePixmap(pChild->background.pixmap);
|
|
|
|
|
dmxBEFreePixmap(pChild->background.pixmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (!pChild->nextSib && (pChild != pWin)) {
|
|
|
|
|
pChild = pChild->parent;
|
|
|
|
|
dmxBEDestroyWindow(pChild);
|
2008-06-24 12:28:20 -04:00
|
|
|
if (wUseDefault(pChild, cursor, 0))
|
|
|
|
|
dmxBEFreeCursor (screenInfo.screens[idx],
|
|
|
|
|
pChild->optional->cursor);
|
2004-06-30 20:06:56 +00:00
|
|
|
if (!pChild->borderIsPixel) {
|
|
|
|
|
dmxBESavePixmap(pChild->border.pixmap);
|
|
|
|
|
dmxBEFreePixmap(pChild->border.pixmap);
|
|
|
|
|
}
|
|
|
|
|
if (pChild->backgroundState == BackgroundPixmap) {
|
|
|
|
|
dmxBESavePixmap(pChild->background.pixmap);
|
|
|
|
|
dmxBEFreePixmap(pChild->background.pixmap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pChild == pWin)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
pChild = pChild->nextSib;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
void
|
|
|
|
|
dmxDisableScreen (int idx)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[idx];
|
|
|
|
|
dmxScreen = &dmxScreens[idx];
|
|
|
|
|
|
|
|
|
|
dmxLogOutput(dmxScreen, "Disable screen #%d\n", idx);
|
|
|
|
|
|
|
|
|
|
dmxInputDisable (&dmxScreen->input);
|
|
|
|
|
|
|
|
|
|
#ifdef XV
|
|
|
|
|
dmxBEXvScreenFini (pScreen);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef RANDR
|
|
|
|
|
dmxBERRScreenFini (pScreen);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Save all relevant state (TODO) */
|
|
|
|
|
|
|
|
|
|
/* Free all non-window resources related to this screen */
|
|
|
|
|
for (i = currentMaxClients; --i >= 0; )
|
|
|
|
|
if (clients[i])
|
|
|
|
|
FindAllClientResources(clients[i], dmxBEDestroyResources,
|
|
|
|
|
(pointer)idx);
|
|
|
|
|
|
|
|
|
|
/* Free scratch GCs */
|
|
|
|
|
dmxBEDestroyScratchGCs(idx);
|
|
|
|
|
|
|
|
|
|
/* Free window resources related to this screen */
|
|
|
|
|
dmxBEDestroyWindowTree(idx);
|
|
|
|
|
|
|
|
|
|
/* Free default stipple */
|
|
|
|
|
dmxBESavePixmap(pScreen->PixmapPerDepth[0]);
|
|
|
|
|
dmxBEFreePixmap(pScreen->PixmapPerDepth[0]);
|
|
|
|
|
|
|
|
|
|
if (pScreen->pScratchPixmap)
|
|
|
|
|
dmxBEFreePixmap(pScreen->pScratchPixmap);
|
|
|
|
|
|
|
|
|
|
/* Free the remaining screen resources and close the screen */
|
|
|
|
|
dmxBECloseScreen(pScreen);
|
|
|
|
|
|
|
|
|
|
/* Screen is now disabled */
|
|
|
|
|
dmxScreen->beDisplay = NULL;
|
|
|
|
|
|
2008-09-26 16:32:33 -04:00
|
|
|
/* Make sure we don't have any pending sync replies */
|
2008-10-08 14:41:20 -04:00
|
|
|
dmxScreenSyncReply (pScreen, 0, NULL, NULL, 0);
|
2008-09-26 16:32:33 -04:00
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
#ifdef RANDR
|
|
|
|
|
RRGetInfo (screenInfo.screens[0]);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/** Detach back-end screen. */
|
|
|
|
|
int dmxDetachScreen(int idx)
|
|
|
|
|
{
|
2008-09-26 13:46:25 -04:00
|
|
|
DMXScreenInfo *dmxScreen;
|
2004-06-30 20:06:56 +00:00
|
|
|
|
|
|
|
|
/* Return failure if dynamic addition/removal of screens is disabled */
|
|
|
|
|
if (!dmxAddRemoveScreens) {
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"Attempting to remove a screen, but the AddRemoveScreen\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"extension has not been enabled. To enable this extension\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"add the \"-addremovescreens\" option either to the command\n");
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"line or in the configuration file.\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Cannot remove a screen that does not exist */
|
|
|
|
|
if (idx < 0 || idx >= dmxNumScreens) return 1;
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
dmxScreen = &dmxScreens[idx];
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
if (idx == 0) {
|
|
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"Attempting to remove screen #%d\n",
|
|
|
|
|
idx);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Cannot detach from a screen that is not opened */
|
2008-09-26 13:46:25 -04:00
|
|
|
if (!dmxScreen->beAttachedDisplay && !dmxScreen->beDisplay) {
|
2004-06-30 20:06:56 +00:00
|
|
|
dmxLog(dmxWarning,
|
|
|
|
|
"Attempting to remove screen #%d but it has not been opened\n",
|
|
|
|
|
idx);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dmxLogOutput(dmxScreen, "Detaching screen #%d\n", idx);
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
if (dmxScreen->beDisplay)
|
|
|
|
|
dmxDisableScreen (idx);
|
2008-07-25 14:23:38 -04:00
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
/* Detach input */
|
2008-09-15 16:16:36 +02:00
|
|
|
dmxInputDetach (&dmxScreen->input);
|
2004-06-30 20:06:56 +00:00
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
dmxScreen->beDisplay = dmxScreen->beAttachedDisplay;
|
|
|
|
|
dmxCloseDisplay (dmxScreen);
|
|
|
|
|
|
|
|
|
|
dmxScreen->beAttachedDisplay = NULL;
|
|
|
|
|
dmxScreen->beDisplay = NULL;
|
|
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
dmxScreen->scrnWidth = 1;
|
|
|
|
|
dmxScreen->scrnHeight = 1;
|
|
|
|
|
dmxScreen->rootX = 0;
|
|
|
|
|
dmxScreen->rootY = 0;
|
|
|
|
|
dmxScreen->beWidth = 1;
|
|
|
|
|
dmxScreen->beHeight = 1;
|
|
|
|
|
dmxScreen->beXDPI = 75;
|
|
|
|
|
dmxScreen->beYDPI = 75;
|
|
|
|
|
dmxScreen->beDepth = 24;
|
|
|
|
|
dmxScreen->beBPP = 32;
|
|
|
|
|
|
2008-06-27 15:19:14 -04:00
|
|
|
if (dmxScreen->name)
|
|
|
|
|
{
|
|
|
|
|
free (dmxScreen->name);
|
|
|
|
|
dmxScreen->name = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-30 19:08:42 -04:00
|
|
|
if (dmxScreen->display)
|
|
|
|
|
{
|
|
|
|
|
free (dmxScreen->display);
|
|
|
|
|
dmxScreen->display = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 15:19:14 -04:00
|
|
|
if (dmxScreen->authType)
|
|
|
|
|
{
|
|
|
|
|
free (dmxScreen->authType);
|
|
|
|
|
dmxScreen->authType = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-26 13:46:25 -04:00
|
|
|
dmxScreen->authTypeLen = 0;
|
|
|
|
|
|
2008-06-27 15:19:14 -04:00
|
|
|
if (dmxScreen->authData)
|
|
|
|
|
{
|
|
|
|
|
free (dmxScreen->authData);
|
|
|
|
|
dmxScreen->authData = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dmxScreen->authDataLen = 0;
|
2008-05-29 20:59:57 -04:00
|
|
|
|
2008-06-03 18:18:04 -04:00
|
|
|
#ifdef RANDR
|
2008-06-24 12:28:20 -04:00
|
|
|
RRGetInfo (screenInfo.screens[0]);
|
2008-06-03 18:18:04 -04:00
|
|
|
#endif
|
|
|
|
|
|
2004-06-30 20:06:56 +00:00
|
|
|
return 0; /* Success */
|
|
|
|
|
}
|