2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2001-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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors:
|
|
|
|
* Kevin E. Martin <kem@redhat.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* This file provides support for window-related functions. */
|
|
|
|
|
|
|
|
#ifdef HAVE_DMX_CONFIG_H
|
|
|
|
#include <dmx-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dmx.h"
|
|
|
|
#include "dmxsync.h"
|
|
|
|
#include "dmxwindow.h"
|
|
|
|
#include "dmxpixmap.h"
|
|
|
|
#include "dmxcmap.h"
|
|
|
|
#include "dmxvisual.h"
|
|
|
|
#include "dmxinput.h"
|
|
|
|
#include "dmxextension.h"
|
|
|
|
#include "dmxpict.h"
|
|
|
|
|
|
|
|
#include "windowstr.h"
|
|
|
|
|
|
|
|
static void dmxDoRestackWindow(WindowPtr pWindow);
|
|
|
|
static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
|
2012-06-10 07:21:05 -06:00
|
|
|
unsigned long *mask,
|
|
|
|
XSetWindowAttributes * attribs);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void dmxDoSetShape(WindowPtr pWindow);
|
|
|
|
|
|
|
|
/** Initialize the private area for the window functions. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxInitWindow(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dixRegisterPrivateKey
|
|
|
|
(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
Window
|
|
|
|
dmxCreateRootWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
Window parent;
|
|
|
|
Visual *visual;
|
|
|
|
unsigned long mask;
|
|
|
|
XSetWindowAttributes attribs;
|
|
|
|
ColormapPtr pCmap;
|
|
|
|
dmxColormapPrivPtr pCmapPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Create root window */
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
parent = dmxScreen->scrnWin; /* This is our "Screen" window */
|
2006-11-26 11:13:41 -07:00
|
|
|
visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pCmap, wColormap(pWindow),
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_COLORMAP, NullClient, DixUnknownAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
|
|
|
|
|
|
|
|
mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
attribs.event_mask = ExposureMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
attribs.backing_store = NotUseful;
|
2012-06-10 07:21:05 -06:00
|
|
|
attribs.colormap = pCmapPriv->cmap;
|
|
|
|
attribs.border_pixel = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Incorporate new attributes, if needed */
|
|
|
|
if (pWinPriv->attribMask) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
|
|
|
|
mask |= pWinPriv->attribMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return XCreateWindow(dmxScreen->beDisplay,
|
2012-06-10 07:21:05 -06:00
|
|
|
parent,
|
|
|
|
pWindow->origin.x - wBorderWidth(pWindow),
|
|
|
|
pWindow->origin.y - wBorderWidth(pWindow),
|
|
|
|
pWindow->drawable.width,
|
|
|
|
pWindow->drawable.height,
|
|
|
|
pWindow->borderWidth,
|
|
|
|
pWindow->drawable.depth,
|
|
|
|
pWindow->drawable.class, visual, mask, &attribs);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Change the location and size of the "screen" window. Called from
|
2011-11-05 07:32:40 -06:00
|
|
|
* dmxextension.c dmxConfigureScreenWindow(). */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxResizeScreenWindow(ScreenPtr pScreen, int x, int y, int w, int h)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!dmxScreen->beDisplay)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Handle resizing on back-end server */
|
|
|
|
m = CWX | CWY | CWWidth | CWHeight;
|
|
|
|
c.x = x;
|
|
|
|
c.y = y;
|
|
|
|
c.width = w;
|
|
|
|
c.height = h;
|
|
|
|
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
|
|
|
|
dmxSync(dmxScreen, False);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Change the location and size of the "root" window. Called from
|
2011-11-05 07:32:40 -06:00
|
|
|
* #dmxCreateWindow. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxResizeRootWindow(WindowPtr pRoot, int x, int y, int w, int h)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Handle resizing on back-end server */
|
|
|
|
if (dmxScreen->beDisplay) {
|
2012-06-10 07:21:05 -06:00
|
|
|
m = CWX | CWY | CWWidth | CWHeight;
|
|
|
|
c.x = x;
|
|
|
|
c.y = y;
|
|
|
|
c.width = (w > 0) ? w : 1;
|
|
|
|
c.height = (h > 0) ? h : 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (w == 0 || h == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWinPriv->mapped) {
|
|
|
|
if (dmxScreen->beDisplay)
|
|
|
|
XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
|
|
|
|
pWinPriv->mapped = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!pWinPriv->mapped) {
|
|
|
|
if (dmxScreen->beDisplay)
|
|
|
|
XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
|
|
|
|
pWinPriv->mapped = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dmxScreen->beDisplay)
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxGetDefaultWindowAttributes(WindowPtr pWindow,
|
|
|
|
Colormap * cmap, Visual ** visual)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWindow->drawable.class != InputOnly &&
|
2012-06-10 07:21:05 -06:00
|
|
|
pWindow->optional &&
|
|
|
|
pWindow->optional->visual != wVisual(pWindow->parent)) {
|
|
|
|
|
|
|
|
/* Find the matching visual */
|
|
|
|
*visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
|
|
|
|
|
|
|
|
/* Handle optional colormaps */
|
|
|
|
if (pWindow->optional->colormap) {
|
|
|
|
ColormapPtr pCmap;
|
|
|
|
dmxColormapPrivPtr pCmapPriv;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pCmap, wColormap(pWindow),
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_COLORMAP, NullClient, DixUnknownAccess);
|
|
|
|
pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
|
|
|
|
*cmap = pCmapPriv->cmap;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*visual = CopyFromParent;
|
|
|
|
*cmap = (Colormap) 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Window
|
|
|
|
dmxCreateNonRootWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
Window parent;
|
|
|
|
unsigned long mask = 0L;
|
|
|
|
XSetWindowAttributes attribs;
|
|
|
|
dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Create window on back-end server */
|
|
|
|
|
|
|
|
parent = pParentPriv->window;
|
|
|
|
|
|
|
|
/* The parent won't exist if this call to CreateNonRootWindow came
|
|
|
|
from ReparentWindow and the grandparent window has not yet been
|
|
|
|
created */
|
|
|
|
if (!parent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
|
|
|
|
parent = pParentPriv->window;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Incorporate new attributes, if needed */
|
|
|
|
if (pWinPriv->attribMask) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
|
|
|
|
mask |= pWinPriv->attribMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add in default attributes */
|
|
|
|
if (pWindow->drawable.class != InputOnly) {
|
2012-06-10 07:21:05 -06:00
|
|
|
mask |= CWBackingStore;
|
|
|
|
attribs.backing_store = NotUseful;
|
|
|
|
|
|
|
|
if (!(mask & CWColormap) && pWinPriv->cmap) {
|
|
|
|
mask |= CWColormap;
|
|
|
|
attribs.colormap = pWinPriv->cmap;
|
|
|
|
if (!(mask & CWBorderPixel)) {
|
|
|
|
mask |= CWBorderPixel;
|
|
|
|
attribs.border_pixel = 0;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle case where subwindows are being mapped, but created out of
|
|
|
|
order -- if current window has a previous sibling, then it cannot
|
|
|
|
be created on top of the stack, so we must restack the windows */
|
|
|
|
pWinPriv->restacked = (pWindow->prevSib != NullWindow);
|
|
|
|
|
|
|
|
return XCreateWindow(dmxScreen->beDisplay,
|
2012-06-10 07:21:05 -06:00
|
|
|
parent,
|
|
|
|
pWindow->origin.x - wBorderWidth(pWindow),
|
|
|
|
pWindow->origin.y - wBorderWidth(pWindow),
|
|
|
|
pWindow->drawable.width,
|
|
|
|
pWindow->drawable.height,
|
|
|
|
pWindow->borderWidth,
|
|
|
|
pWindow->drawable.depth,
|
|
|
|
pWindow->drawable.class,
|
|
|
|
pWinPriv->visual, mask, &attribs);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** This function handles lazy window creation and realization. Window
|
|
|
|
* creation is handled by #dmxCreateNonRootWindow(). It also handles
|
|
|
|
* any stacking changes that have occured since the window was
|
|
|
|
* originally created by calling #dmxDoRestackWindow(). If the window
|
|
|
|
* is shaped, the shape is set on the back-end server by calling
|
|
|
|
* #dmxDoSetShape(), and if the window has pictures (from RENDER)
|
|
|
|
* associated with it, those pictures are created on the back-end
|
|
|
|
* server by calling #dmxCreatePictureList(). If \a doSync is TRUE,
|
|
|
|
* then #dmxSync() is called. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxScreen->beDisplay)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pWinPriv->window = dmxCreateNonRootWindow(pWindow);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWinPriv->restacked)
|
|
|
|
dmxDoRestackWindow(pWindow);
|
|
|
|
if (pWinPriv->isShaped)
|
|
|
|
dmxDoSetShape(pWindow);
|
|
|
|
if (pWinPriv->hasPict)
|
|
|
|
dmxCreatePictureList(pWindow);
|
|
|
|
if (pWinPriv->mapped)
|
|
|
|
XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
|
|
|
|
if (doSync)
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Create \a pWindow on the back-end server. If the lazy window
|
|
|
|
* creation optimization is enabled, then the actual creation and
|
|
|
|
* realization of the window is handled by
|
|
|
|
* #dmxCreateAndRealizeWindow(). */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxCreateWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
Bool ret = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->CreateWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = pScreen->CreateWindow(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Set up the defaults */
|
2012-06-10 07:21:05 -06:00
|
|
|
pWinPriv->window = (Window) 0;
|
|
|
|
pWinPriv->offscreen = TRUE;
|
|
|
|
pWinPriv->mapped = FALSE;
|
|
|
|
pWinPriv->restacked = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
pWinPriv->attribMask = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
pWinPriv->isShaped = FALSE;
|
|
|
|
pWinPriv->hasPict = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef GLXEXT
|
2012-06-10 07:21:05 -06:00
|
|
|
pWinPriv->swapGroup = NULL;
|
|
|
|
pWinPriv->barrier = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (dmxScreen->beDisplay) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Only create the root window at this stage -- non-root windows are
|
|
|
|
created when they are mapped and are on-screen */
|
|
|
|
if (!pWindow->parent) {
|
|
|
|
dmxScreen->rootWin = pWinPriv->window
|
|
|
|
= dmxCreateRootWindow(pWindow);
|
|
|
|
if (dmxScreen->scrnX != dmxScreen->rootX
|
|
|
|
|| dmxScreen->scrnY != dmxScreen->rootY
|
|
|
|
|| dmxScreen->scrnWidth != dmxScreen->rootWidth
|
|
|
|
|| dmxScreen->scrnHeight != dmxScreen->rootHeight) {
|
|
|
|
dmxResizeRootWindow(pWindow,
|
|
|
|
dmxScreen->rootX,
|
|
|
|
dmxScreen->rootY,
|
|
|
|
dmxScreen->rootWidth,
|
|
|
|
dmxScreen->rootHeight);
|
|
|
|
dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
|
|
|
|
dmxScreen->rootX,
|
|
|
|
dmxScreen->rootY,
|
|
|
|
dmxScreen->rootWidth,
|
|
|
|
dmxScreen->rootHeight);
|
|
|
|
pWindow->origin.x = dmxScreen->rootX;
|
|
|
|
pWindow->origin.y = dmxScreen->rootY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dmxGetDefaultWindowAttributes(pWindow,
|
|
|
|
&pWinPriv->cmap, &pWinPriv->visual);
|
|
|
|
|
|
|
|
if (dmxLazyWindowCreation) {
|
|
|
|
/* Save parent's visual for use later */
|
|
|
|
if (pWinPriv->visual == CopyFromParent)
|
|
|
|
pWinPriv->visual =
|
|
|
|
dmxLookupVisualFromID(pScreen,
|
|
|
|
wVisual(pWindow->parent));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pWinPriv->window = dmxCreateNonRootWindow(pWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destroy \a pWindow on the back-end server. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxBEDestroyWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
|
|
|
|
pWinPriv->window = (Window) 0;
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destroy \a pWindow on the back-end server. If any RENDER pictures
|
|
|
|
were created, destroy them as well. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxDestroyWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool ret = TRUE;
|
|
|
|
Bool needSync = FALSE;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef GLXEXT
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
/* Destroy any picture list associated with this window */
|
|
|
|
needSync |= dmxDestroyPictureList(pWindow);
|
|
|
|
|
|
|
|
/* Destroy window on back-end server */
|
|
|
|
needSync |= dmxBEDestroyWindow(pWindow);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (needSync)
|
|
|
|
dmxSync(dmxScreen, FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef GLXEXT
|
|
|
|
if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWinPriv->windowDestroyed(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pScreen->DestroyWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = pScreen->DestroyWindow(pWindow);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Change the position of \a pWindow to be \a x, \a y. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxPositionWindow(WindowPtr pWindow, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
Bool ret = TRUE;
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->PositionWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = pScreen->PositionWindow(pWindow, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Determine if the window is completely off the visible portion of
|
|
|
|
the screen */
|
|
|
|
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
|
|
|
|
|
|
|
|
/* If the window is now on-screen and it is mapped and it has not
|
|
|
|
been created yet, create it and map it */
|
|
|
|
if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxCreateAndRealizeWindow(pWindow, TRUE);
|
|
|
|
}
|
|
|
|
else if (pWinPriv->window) {
|
|
|
|
/* Position window on back-end server */
|
|
|
|
m = CWX | CWY | CWWidth | CWHeight;
|
|
|
|
c.x = pWindow->origin.x - wBorderWidth(pWindow);
|
|
|
|
c.y = pWindow->origin.y - wBorderWidth(pWindow);
|
|
|
|
c.width = pWindow->drawable.width;
|
|
|
|
c.height = pWindow->drawable.height;
|
|
|
|
if (pWindow->drawable.class != InputOnly) {
|
|
|
|
m |= CWBorderWidth;
|
|
|
|
c.border_width = pWindow->borderWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxDoChangeWindowAttributes(WindowPtr pWindow,
|
|
|
|
unsigned long *mask, XSetWindowAttributes * attribs)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxPixPrivPtr pPixPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWBackPixmap) {
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (pWindow->backgroundState) {
|
|
|
|
case None:
|
|
|
|
attribs->background_pixmap = None;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ParentRelative:
|
|
|
|
attribs->background_pixmap = ParentRelative;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BackgroundPixmap:
|
|
|
|
pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
|
|
|
|
attribs->background_pixmap = pPixPriv->pixmap;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BackgroundPixel:
|
|
|
|
*mask &= ~CWBackPixmap;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*mask & CWBackPixel) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWindow->backgroundState == BackgroundPixel)
|
|
|
|
attribs->background_pixel = pWindow->background.pixel;
|
|
|
|
else
|
|
|
|
*mask &= ~CWBackPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*mask & CWBorderPixmap) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWindow->borderIsPixel)
|
|
|
|
*mask &= ~CWBorderPixmap;
|
|
|
|
else {
|
|
|
|
pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
|
|
|
|
attribs->border_pixmap = pPixPriv->pixmap;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*mask & CWBorderPixel) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWindow->borderIsPixel)
|
|
|
|
attribs->border_pixel = pWindow->border.pixel;
|
|
|
|
else
|
|
|
|
*mask &= ~CWBorderPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*mask & CWBitGravity)
|
2012-06-10 07:21:05 -06:00
|
|
|
attribs->bit_gravity = pWindow->bitGravity;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWWinGravity)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWWinGravity; /* Handled by dix */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWBackingStore)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWBackingStore; /* Backing store not supported */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWBackingPlanes)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWBackingPlanes; /* Backing store not supported */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWBackingPixel)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWBackingPixel; /* Backing store not supported */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWOverrideRedirect)
|
2012-06-10 07:21:05 -06:00
|
|
|
attribs->override_redirect = pWindow->overrideRedirect;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWSaveUnder)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWSaveUnder; /* Save unders not supported */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWEventMask)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWEventMask; /* Events are handled by dix */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWDontPropagate)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWDontPropagate; /* Events are handled by dix */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (*mask & CWColormap) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ColormapPtr pCmap;
|
|
|
|
dmxColormapPrivPtr pCmapPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pCmap, wColormap(pWindow),
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_COLORMAP, NullClient, DixUnknownAccess);
|
|
|
|
pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
|
|
|
|
attribs->colormap = pCmapPriv->cmap;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*mask & CWCursor)
|
2012-06-10 07:21:05 -06:00
|
|
|
*mask &= ~CWCursor; /* Handled by the cursor code */
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Change the window attributes of \a pWindow. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
Bool ret = TRUE;
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
XSetWindowAttributes attribs;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->ChangeWindowAttributes)
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = pScreen->ChangeWindowAttributes(pWindow, mask);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Change window attribs on back-end server */
|
|
|
|
dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
|
|
|
|
|
|
|
|
/* Save mask for lazy window creation optimization */
|
|
|
|
pWinPriv->attribMask |= mask;
|
|
|
|
|
|
|
|
if (mask && pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
|
|
|
|
mask, &attribs);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Realize \a pWindow on the back-end server. If the lazy window
|
|
|
|
* creation optimization is enabled, the window is only realized when
|
|
|
|
* it at least partially overlaps the screen. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxRealizeWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool ret = TRUE;
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->RealizeWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = pScreen->RealizeWindow(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Determine if the window is completely off the visible portion of
|
|
|
|
the screen */
|
|
|
|
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
|
|
|
|
|
|
|
|
/* If the window hasn't been created and it's not offscreen, then
|
|
|
|
create it */
|
|
|
|
if (!pWinPriv->window && !pWinPriv->offscreen) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxCreateAndRealizeWindow(pWindow, FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Realize window on back-end server */
|
|
|
|
XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Let the other functions know that the window is now mapped */
|
|
|
|
pWinPriv->mapped = TRUE;
|
|
|
|
|
|
|
|
DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Unrealize \a pWindow on the back-end server. */
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
dmxUnrealizeWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool ret = TRUE;
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->UnrealizeWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
ret = pScreen->UnrealizeWindow(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Unrealize window on back-end server */
|
|
|
|
XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* When unrealized (i.e., unmapped), the window is always considered
|
|
|
|
off of the visible portion of the screen */
|
|
|
|
pWinPriv->offscreen = TRUE;
|
|
|
|
pWinPriv->mapped = FALSE;
|
|
|
|
|
|
|
|
#ifdef GLXEXT
|
|
|
|
if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
pWinPriv->windowUnmapped(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxDoRestackWindow(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
WindowPtr pNextSib = pWindow->nextSib;
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pNextSib == NullWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Window is at the bottom of the stack */
|
|
|
|
m = CWStackMode;
|
|
|
|
c.sibling = (Window) 0;
|
|
|
|
c.stack_mode = Below;
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Window is not at the bottom of the stack */
|
|
|
|
dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
|
|
|
|
|
|
|
|
/* Handle case where siblings have not yet been created due to
|
2006-11-26 11:13:41 -07:00
|
|
|
lazy window creation optimization by first finding the next
|
|
|
|
sibling in the sibling list that has been created (if any)
|
|
|
|
and then putting the current window just above that sibling,
|
|
|
|
and if no next siblings have been created yet, then put it at
|
|
|
|
the bottom of the stack (since it might have a previous
|
|
|
|
sibling that should be above it). */
|
2012-06-10 07:21:05 -06:00
|
|
|
while (!pNextSibPriv->window) {
|
|
|
|
pNextSib = pNextSib->nextSib;
|
|
|
|
if (pNextSib == NullWindow) {
|
|
|
|
/* Window is at the bottom of the stack */
|
|
|
|
m = CWStackMode;
|
|
|
|
c.sibling = (Window) 0;
|
|
|
|
c.stack_mode = Below;
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
|
|
|
|
}
|
|
|
|
|
|
|
|
m = CWStackMode | CWSibling;
|
|
|
|
c.sibling = pNextSibPriv->window;
|
|
|
|
c.stack_mode = Above;
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Handle window restacking. The actual restacking occurs in
|
|
|
|
* #dmxDoRestackWindow(). */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->RestackWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->RestackWindow(pWindow, pOldNextSib);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pOldNextSib != pWindow->nextSib) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Track restacking for lazy window creation optimization */
|
|
|
|
pWinPriv->restacked = TRUE;
|
|
|
|
|
|
|
|
/* Restack window on back-end server */
|
|
|
|
if (pWinPriv->window) {
|
|
|
|
dmxDoRestackWindow(pWindow);
|
|
|
|
dmxSync(dmxScreen, False);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
|
|
|
|
dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool
|
|
|
|
dmxWindowExposurePredicate(Display * dpy, XEvent * ev, XPointer ptr)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return (ev->type == Expose && ev->xexpose.window == *(Window *) ptr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Handle exposures on \a pWindow. Since window exposures are handled
|
|
|
|
* in DMX, the events that are generated by the back-end server are
|
|
|
|
* redundant, so we eat them here. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
2015-09-16 13:10:19 -06:00
|
|
|
dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
XEvent ev;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
|
|
|
|
|
|
|
|
dmxSync(dmxScreen, False);
|
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
|
|
|
|
dmxWindowExposurePredicate,
|
2013-06-07 11:28:45 -06:00
|
|
|
(XPointer) &pWinPriv->window)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Handle expose events -- this should not be necessary
|
|
|
|
since the base window in which the root window was
|
|
|
|
created is guaranteed to be on top (override_redirect),
|
|
|
|
so we should just swallow these events. If for some
|
|
|
|
reason the window is not on top, then we'd need to
|
|
|
|
collect these events and send them to the client later
|
|
|
|
(e.g., during the block handler as Xnest does). */
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
if (pScreen->WindowExposures)
|
2015-09-16 13:10:19 -06:00
|
|
|
pScreen->WindowExposures(pWindow, prgn);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Move \a pWindow on the back-end server. Determine whether or not it
|
|
|
|
* is on or offscreen, and realize it if it is newly on screen and the
|
|
|
|
* lazy window creation optimization is enabled. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->CopyWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Determine if the window is completely off the visible portion of
|
|
|
|
the screen */
|
|
|
|
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
|
|
|
|
|
|
|
|
/* If the window is now on-screen and it is mapped and it has not
|
|
|
|
been created yet, create it and map it */
|
|
|
|
if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxCreateAndRealizeWindow(pWindow, TRUE);
|
|
|
|
}
|
|
|
|
else if (pWinPriv->window) {
|
|
|
|
/* Move window on back-end server */
|
|
|
|
m = CWX | CWY | CWWidth | CWHeight;
|
|
|
|
c.x = pWindow->origin.x - wBorderWidth(pWindow);
|
|
|
|
c.y = pWindow->origin.y - wBorderWidth(pWindow);
|
|
|
|
c.width = pWindow->drawable.width;
|
|
|
|
c.height = pWindow->drawable.height;
|
|
|
|
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
|
|
|
|
dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Resize \a pWindow on the back-end server. Determine whether or not
|
|
|
|
* it is on or offscreen, and realize it if it is newly on screen and
|
|
|
|
* the lazy window creation optimization is enabled. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxResizeWindow(WindowPtr pWindow, int x, int y,
|
|
|
|
unsigned int w, unsigned int h, WindowPtr pSib)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
|
|
|
|
#if 1
|
|
|
|
if (pScreen->ResizeWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Determine if the window is completely off the visible portion of
|
|
|
|
the screen */
|
|
|
|
pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
|
|
|
|
|
|
|
|
/* If the window is now on-screen and it is mapped and it has not
|
|
|
|
been created yet, create it and map it */
|
|
|
|
if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxCreateAndRealizeWindow(pWindow, TRUE);
|
|
|
|
}
|
|
|
|
else if (pWinPriv->window) {
|
|
|
|
/* Handle resizing on back-end server */
|
|
|
|
m = CWX | CWY | CWWidth | CWHeight;
|
|
|
|
c.x = pWindow->origin.x - wBorderWidth(pWindow);
|
|
|
|
c.y = pWindow->origin.y - wBorderWidth(pWindow);
|
|
|
|
c.width = pWindow->drawable.width;
|
|
|
|
c.height = pWindow->drawable.height;
|
|
|
|
|
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
|
|
|
|
dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Reparent \a pWindow on the back-end server. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
|
|
|
|
#if 0
|
|
|
|
if (pScreen->ReparentWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->ReparentWindow(pWindow, pPriorParent);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pParentPriv->window) {
|
|
|
|
dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle reparenting on back-end server */
|
|
|
|
XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
|
|
|
|
pParentPriv->window,
|
|
|
|
pWindow->origin.x - wBorderWidth(pWindow),
|
|
|
|
pWindow->origin.x - wBorderWidth(pWindow));
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
|
|
|
|
dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Change border width for \a pWindow to \a width pixels. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
unsigned int m;
|
|
|
|
XWindowChanges c;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
|
|
|
|
#if 1
|
|
|
|
if (pScreen->ChangeBorderWidth)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->ChangeBorderWidth(pWindow, width);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* NOTE: Do we need to check for on/off screen here? */
|
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Handle border width change on back-end server */
|
|
|
|
m = CWBorderWidth;
|
|
|
|
c.border_width = width;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
|
|
|
|
dmxSync(dmxScreen, False);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxDoSetShape(WindowPtr pWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
|
|
|
int nBox;
|
|
|
|
BoxPtr pBox;
|
|
|
|
int nRect;
|
|
|
|
XRectangle *pRect;
|
|
|
|
XRectangle *pRectFirst;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* First, set the bounding shape */
|
|
|
|
if (wBoundingShape(pWindow)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pBox = RegionRects(wBoundingShape(pWindow));
|
|
|
|
nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
|
2016-05-29 06:02:34 -06:00
|
|
|
pRectFirst = pRect = xallocarray(nRect, sizeof(*pRect));
|
2012-06-10 07:21:05 -06:00
|
|
|
while (nBox--) {
|
|
|
|
pRect->x = pBox->x1;
|
|
|
|
pRect->y = pBox->y1;
|
|
|
|
pRect->width = pBox->x2 - pBox->x1;
|
|
|
|
pRect->height = pBox->y2 - pBox->y1;
|
|
|
|
pBox++;
|
|
|
|
pRect++;
|
|
|
|
}
|
|
|
|
XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
|
|
|
|
ShapeBounding, 0, 0,
|
|
|
|
pRectFirst, nRect, ShapeSet, YXBanded);
|
|
|
|
free(pRectFirst);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
|
|
|
|
ShapeBounding, 0, 0, None, ShapeSet);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Next, set the clip shape */
|
|
|
|
if (wClipShape(pWindow)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pBox = RegionRects(wClipShape(pWindow));
|
|
|
|
nRect = nBox = RegionNumRects(wClipShape(pWindow));
|
2016-05-29 06:02:34 -06:00
|
|
|
pRectFirst = pRect = xallocarray(nRect, sizeof(*pRect));
|
2012-06-10 07:21:05 -06:00
|
|
|
while (nBox--) {
|
|
|
|
pRect->x = pBox->x1;
|
|
|
|
pRect->y = pBox->y1;
|
|
|
|
pRect->width = pBox->x2 - pBox->x1;
|
|
|
|
pRect->height = pBox->y2 - pBox->y1;
|
|
|
|
pBox++;
|
|
|
|
pRect++;
|
|
|
|
}
|
|
|
|
XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
|
|
|
|
ShapeClip, 0, 0,
|
|
|
|
pRectFirst, nRect, ShapeSet, YXBanded);
|
|
|
|
free(pRectFirst);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
|
|
|
|
ShapeClip, 0, 0, None, ShapeSet);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("Input selected for window %x on Screen %d\n",
|
|
|
|
(unsigned int) pWinPriv->window, pScreen->myNum);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set shape of \a pWindow on the back-end server. */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
dmxSetShape(WindowPtr pWindow, int kind)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
|
|
|
dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DMX_UNWRAP(SetShape, dmxScreen, pScreen);
|
|
|
|
#if 1
|
|
|
|
if (pScreen->SetShape)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->SetShape(pWindow, kind);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pWinPriv->window) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Handle setting the current shape on the back-end server */
|
|
|
|
dmxDoSetShape(pWindow);
|
|
|
|
dmxSync(dmxScreen, False);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pWinPriv->isShaped = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
|
|
|
|
}
|