/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* $XConsortium: multiVis.c /main/4 1996/10/14 15:04:08 swick $ */
/** ------------------------------------------------------------------------
This file contains functions to create a list of regions which
tile a specified window. Each region contains all visible
portions of the window which are drawn with the same visual.
If the window consists of subwindows of two different visual types,
there will be two regions in the list. The list can be traversed
to correctly pull an image of the window using XGetImage or the
Image Library.
This file is available under and governed by the GNU General Public
License version 2 only, as published by the Free Software Foundation.
However, the following notice accompanied the original version of this
file:
Copyright (c) 1994 Hewlett-Packard Co.
Copyright (c) 1996 X Consortium
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 the rights to use, copy, modify, merge, publish,
distribute, sublicense, and 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 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 NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM 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.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
------------------------------------------------------------------------ **/
#include <stdlib.h>
#include <stdio.h>
#include "list.h"
#include "wsutils.h"
#include "multiVis.h"
#include "robot_common.h"
"PseudoColor","TrueColor","DirectColor" } ;
* they're invisible from the outside.*/
typedef struct {
} myREGION;
/* Items in long list of windows that have some part in the grabbed area */
typedef struct {
/* Items in short list of regions that tile the grabbed area. May have
multiple windows in the region.
*/
typedef struct {
/** ------------------------------------------------------------------------
Returns TRUE if the two structs pointed to have the same "vis" &
"cmap" fields and s2 lies completely within s1. s1 and s2 can
point to structs of image_win_type or image_region_type.
------------------------------------------------------------------------ **/
#ifndef MIN
#define MIN( a, b) ((a) < (b) ? a : b)
#define MAX( a, b) ((a) > (b) ? a : b)
#endif
#define BLUE_SHIFT 0
/*
extern list_ptr new_list();
extern list_ptr dup_list_head();
extern void * first_in_list();
extern void * next_in_list();
extern int32_t add_to_list();
extern void zero_list();
extern void delete_list();
extern void delete_list_destroying();
extern uint32_t list_length();
*/
/* Prototype Declarations for Static Functions */
static void TransferImage(
#endif
);
static XImage * ReadRegionsInList(
#endif
);
static list_ptr make_region_list(
#endif
);
static void destroy_region_list(
#endif
) ;
static void subtr_rect_from_image_region(
#endif
);
static void add_rect_to_image_region(
#endif
);
static int32_t src_in_region_list(
#endif
);
static void add_window_to_list(
#endif
);
static int32_t src_in_image(
#endif
);
static int32_t src_in_overlay(
#endif
);
/* End of Prototype Declarations */
{
}
/* QueryColorMap has been moved into robot_common.c so it can be used by
* awt_DataTransferer.c as well.
*/
int32_t x; /* root rel UL corner of bounding box of grab */
int32_t y;
{
/* Java uses 32-bit ints for coordinates, but XRectangles use 16-bit shorts.
* Hope nobody passes in too big a coordinate */
bbox.x = (short) x; /* init X rect for bounding box */
bbox.y = (short) y;
return 0 ;
if (*transparentOverlays)
{
this flags that it to be an image only list */
}
/* if there is a second region in any of the two lists return 1 **/
else return 0 ;
}
{
case TrueColor :
for(i=0 ; i < srch ; i++)
{
for(j=0 ; j < srcw ; j++)
{
/* commented out since not using server RGB masks in all true color modes
* causes the R and B values to be swapped around on some X servers
* - robi.khan@eng 9/7/1999
* if( reg->vis->map_entries == 16) {
*/
new_pixel = (
);
/* }
* else
* new_pixel = old_pixel;
*/
}
}
break;
case DirectColor :
for(i=0 ; i < srch ; i++)
{
for(j=0 ; j < srcw ; j++)
{
new_pixel = (
);
}
}
break;
default :
for(i=0 ; i < srch ; i++)
{
for(j=0 ; j < srcw ; j++)
{
new_pixel = (
);
}
}
break;
}
/* Fix memory leak by freeing colors
* - robi.khan@eng 9/22/1999
*/
}
static XImage *
{
bitmap_unit = sizeof (long);
else
/* Find out how many more bytes are required for padding so that
** bytes per scan line will be multiples of bitmap_unit bits */
if (rem)
}
else
{
for (rect = 0;
rect++)
{
/** ------------------------------------------------------------------------
Intersect bbox with visible part of region giving src rect & output
location. Width is the min right side minus the max left side.
Similar for height. Offset src rect so x,y are relative to
origin of win, not the root-relative visible rect of win.
------------------------------------------------------------------------ **/
}
}
return ximage ;
}
/** ------------------------------------------------------------------------
------------------------------------------------------------------------ **/
int32_t x; /* root rel UL corner of bounding box of grab */
int32_t y;
/** int32_t transparentOverlays; ***/
{
bbox.x = (short) x; /* init X rect for bounding box */
bbox.y = (short) y;
ximage_ipm = NULL;
depth = 24 ;
/* if transparency possible do it again, but this time for image planes only */
{
}
/* Now tranverse the overlay visual windows and test for transparency index. */
/* If you find one, subsitute the value from the matching image plane pixmap. */
{
{
/* let's test some pixels for transparency */
0xffffffff, ZPixmap);
/* let's assume byte per pixel for overlay image for now */
{
unsigned char *pixel_ptr;
{
if (*pixel_ptr++ == transparentColor)
{
/*
*pmData++ = *ipmData++;
*pmData++ = *ipmData++;
*pmData++ = *ipmData++;
*/
if(!test){
test = 1 ;
}
}
/*
else {
pmData +=3;
ipmData +=3;
}
*/
}
}
} else {
if (transparentType == TransparentPixel) {
{
if (pixel_value == transparentColor)
{
/*
*pmData++ = *ipmData++;
*pmData++ = *ipmData++;
*pmData++ = *ipmData++;
*/
if(!test){
test = 1 ;
}
}
/*
else {
pmData +=3;
ipmData +=3;
}
*/
}
}
} else {
{
if (pixel_value & transparentColor)
{
/*
*pmData++ = *ipmData++;
*pmData++ = *ipmData++;
*pmData++ = *ipmData++;
*/
if(!test){
test = 1 ;
}
}
/*
else {
pmData +=3;
ipmData +=3;
}
*/
}
}
}
}
} /* end of src_in_overlay */
} /** end transparency **/
if (ximage_ipm != NULL) {
}
return ximage;
}
/** ------------------------------------------------------------------------
Creates a list of the subwindows of a given window which have a
different visual than their parents. The function is recursive.
This list is used in make_region_list(), which coalesces the
windows with the same visual into a region.
image_wins must point to an existing list struct that's already
been zeroed (zero_list()).
------------------------------------------------------------------------ **/
/* obscurred by ancestors */
{
/* check that win is mapped & not outside bounding box */
/** ------------------------------------------------------------------------
set RR coords of right (Rt), left (X), bottom (Bt) and top (Y)
of rect we clip all children by. This is our own clip rect (pclip)
inflicted on us by our parent plus our own borders. Within the
child loop, we figure the clip rect for each child by adding in
it's rectangle (not taking into account the child's borders).
------------------------------------------------------------------------ **/
while (nchild--) {
/* intersect parent & child clip rects */
if (new_width >= 0) {
if (new_height >= 0) {
&child_attrs, &child_clip);
}
}
child++;
}
}
}
/** ------------------------------------------------------------------------
This function creates a list of regions which tile a specified
window. Each region contains all visible portions of the window
which are drawn with the same visual. For example, if the
window consists of subwindows of two different visual types,
there will be two regions in the list.
Returns a pointer to the list.
------------------------------------------------------------------------ **/
{
*hasNonDefault = False;
zero_list( &image_wins);
clip.x = 0;
clip.y = 0;
image_regions = new_list();
{
/* test for image visual */
{
/* find a window whose visual hasn't been put in list yet */
{
if (! (new_reg = (image_region_type *)
malloc( sizeof( image_region_type)))) {
}
count++;
}
else {
{
}
}
}
*hasNonDefault = True;
}
}
else {
}
}
} else *allImage = 0;
}
return image_regions;
}
/** ------------------------------------------------------------------------
Destructor called from destroy_region_list().
------------------------------------------------------------------------ **/
{
free( (void *) image_region);
}
/** ------------------------------------------------------------------------
Destroys the region list, destroying all the regions contained in it.
------------------------------------------------------------------------ **/
{
}
/** ------------------------------------------------------------------------
Subtracts the specified rectangle from the region in image_region.
First converts the rectangle to a region of its own, since X
only provides a way to subtract one region from another, not a
rectangle from a region.
------------------------------------------------------------------------ **/
int32_t x;
int32_t y;
{
rect_region = XCreateRegion();
rect.x = (short)x;
rect.y = (short)y;
}
/** ------------------------------------------------------------------------
Adds the specified rectangle to the region in image_region.
------------------------------------------------------------------------ **/
int32_t x;
int32_t y;
{
rect.x = (short) x;
rect.y = (short) y;
}
/** ------------------------------------------------------------------------
Returns TRUE if the given src's visual is already represented in
the image_regions list, FALSE otherwise.
------------------------------------------------------------------------ **/
{
return 1;
}
}
return 0;
}
/** ------------------------------------------------------------------------
Makes a new entry in image_wins with the given fields filled in.
------------------------------------------------------------------------ **/
Window w;
{
return;
}
/** ------------------------------------------------------------------------
Returns TRUE if the given src's visual is in the image planes,
FALSE otherwise.
------------------------------------------------------------------------ **/
{
int32_t i;
for (i = 0 ; i < numImageVisuals ; i++)
{
return 1;
}
return 0;
}
/** ------------------------------------------------------------------------
Returns TRUE if the given src's visual is in the overlay planes
and transparency is possible, FALSE otherwise.
------------------------------------------------------------------------ **/
{
int32_t i;
for (i = 0 ; i < numOverlayVisuals ; i++)
{
{
return 1;
}
else {
}
}
return 0;
}
/********************** from wsutils.c ******************************/
/******************************************************************************
*
* This file contains a set of example utility procedures; procedures that can
* help a "window-smart" Starbase or PHIGS program determine information about
* a device, and create image and overlay plane windows. To use these
* utilities, #include "wsutils.h" and compile this file and link the results
* with your program.
*
******************************************************************************/
/******************************************************************************
*
* GetXVisualInfo()
*
* This routine takes an X11 Display, screen number, and returns whether the
* screen supports transparent overlays and three arrays:
*
* 1) All of the XVisualInfo struct's for the screen.
* 2) All of the OverlayInfo struct's for the screen.
* 3) An array of pointers to the screen's image plane XVisualInfo
* structs.
*
* The code below obtains the array of all the screen's visuals, and obtains
* the array of all the screen's overlay visual information. It then processes
* the array of the screen's visuals, determining whether the visual is an
* overlay or image visual.
*
* If the routine sucessfully obtained the visual information, it returns zero.
* If the routine didn't obtain the visual information, it returns non-zero.
*
******************************************************************************/
* overlay visual and if at least one
* of those supports a transparent
* pixel. */
* pointed to to by pVisuals. */
* to by pOverlayVisuals. If this
* number is zero, the device does
* not have overlay planes. */
* information. */
* to by pImageVisuals. */
{
/* First, get the list of visuals for this screen. */
if ((nVisuals = *numVisuals) <= 0)
{
/* Return that the information wasn't sucessfully obtained: */
return(1);
}
/* Now, get the overlay visual information for this screen. To obtain
* this information, get the SERVER_OVERLAY_VISUALS property.
*/
if (overlayVisualsAtom != None)
{
/* Since the Atom exists, we can request the property's contents. The
* do-while loop makes sure we get the entire list from the X server.
*/
bytesAfter = 0;
do
{
} while (bytesAfter > 0);
/* Calculate the number of overlay visuals in the list. */
/* *numOverlayVisuals = numLongs / (sizeof(OverlayVisualPropertyRec) / 4); */
}
else
{
/* This screen doesn't have overlay planes. */
*numOverlayVisuals = 0;
*pOverlayVisuals = NULL;
*transparentOverlays = 0;
}
/* Process the pVisuals array. */
*numImageVisuals = 0;
nImageVisualsAlloced = 1;
while (--nVisuals >= 0)
{
pOVis = *pOverlayVisuals;
imageVisual = True;
while (--nOVisuals >= 0)
{
{
imageVisual = False;
*transparentOverlays = 1;
}
pOVis++;
}
if (imageVisual)
{
{
*pImageVisuals = (XVisualInfo **)
}
}
pVis++;
}
/* Return that the information was sucessfully obtained: */
return(0);
} /* GetXVisualInfo() */
/******************************************************************************
*
* FreeXVisualInfo()
*
* This routine frees the data that was allocated by GetXVisualInfo().
*
******************************************************************************/
{
else
} /* FreeXVisualInfo() */