*
* 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,
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/*
*
*
* @@@@ @@@@@ @ @ @@@@ @@@@ @@@ @@@@
* @ @ @ @@ @ @ @ @ @ @ @ @
* @@@@ @ @ @ @ @ @@@ @@@@ @@@@@ @@@@
* @ @ @ @ @@ @ @ @ @ @ @ @ @
* @ @ @ @ @ @@@@@ @@@@ @ @ @ @ @@@@
*
* DGA shared retained window access routines
*
* int
* dga_rtn_active(clientp)
* Dga_window clientp;
*
* u_char
* dga_rtn_cached(clientp)
* Dga_window clientp;
*
* void *
* dga_rtn_devinfo(clientp)
* Dga_window clientp;
*
* void
* dga_rtn_devtype(clientp, type, name)
* Dga_window clientp;
* u_char *type;
* char **name;
*
* void
* dga_rtn_dimensions(clientp, width, height, linebytes)
* Dga_window clientp;
* short *width;
* short *height;
* u_int *linebytes;
*
* int
* dga_rtn_grab(clientp)
* Dga_window clientp;
*
* void *
* dga_rtn_pixels(clientp)
* Dga_window clientp;
*
* int
* dga_rtn_ungrab(clientp)
* Dga_window clientp;
*
* int
* _dga_rtn_map(clientp)
* Dga_window clientp;
*
* int
* _dga_rtn_unmap(clientp)
* Dga_window clientp;
*
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#ifdef SERVER_DGA
#include "windowstr.h"
#include "dga_externaldefs.h"
#include "dga/dgawinstr.h"
#else
#include <fcntl.h>
#ifdef SVR4
#include <netdb.h>
#else
#endif
#endif /* SERVER_DGA */
#include "dga_incls.h"
#include "rtn_grab.h"
int dgai_rtn_ungrab_common();
/*
*
* dga_rtn_active()
*
* DGA Retained Windows Active. This function is called to determine
* if DGA to the retained portion of the specified dga_window is currently
* active. Since the server can drop support for this functionality at
* any time, the client should always call this function when a change has
* been has been recorded in the retained window information. This function
* should be called prior to accessing any other retained window information.
* The function returns a non-zero result if DGA to the retained portion
* of the window is active. A zero result is returned if support has
* been dropped.
*
* Inputs: Dga_window - Pointer to the client structure.
*
* Outputs: 0 - DGA Retained window support has been dropped.
* -1 - DGA Retained window support continues.
*
* Globals: None.
*
* Externals: None.
*
*/
int
{
return (RTN_PASSED);
else
return (RTN_FAILED);
}
/*
*
* dga_rtn_cached()
*
* DGA Retained HW Cache status. This function returns a non-zero
* value if the retained raster is cached in hardware. If set to
* DGA_RTN_NEW_DEV then the server has re-cached the retained
* raster from one device to another. If set to DGA_RTN_SAME_DEV
* the raster remains cached in the same device as previously
* recorded. If the retained raster is not cached in hw then the
* function returns DGA_RTN_NOT_CACHED (0).
*
* Inputs: Dga_window - Pointer to the client structure.
*
* Outputs: DGA_RTN_NOT_CACHED - not cached in hw
* DGA_RTN_SAME_DEV - cached in the same hw device
* DGA_RTN_NEW_DEV - cached in the new hw device
*
* Globals: None.
*
* Externals: RTN_INFOP() Internal MACRO
*
*
*/
int
{
return (DGA_RTN_NEW_DEV);
}
else
return (DGA_RTN_SAME_DEV);
else
return (DGA_RTN_NOT_CACHED);
}
/*
*
* dga_rtn_devinfop() <---external interface just to be consistent
* dga_rtn_devinfo()
*
* DGA Retained Device Info. This function returns a pointer to
* the shared device specific retained raster information when
* the retained raster is cached in hw. The pointer is invalid
* if the retained raster isn't cached in hw.
*
* Inputs: Dga_window - Pointer to the client structure.
*
* Outputs: void * - Pointer to the device specific information
*
* Globals: None.
*
* Externals: RTN_INFOP() Internal MACRO
*
*/
void *
{
/* This is the internal interface */
}
void *
{
}
/*
*
* dga_rtn_devtype()
*
* DGA Retained Device Type. This function is used to obtain
* the retained raster hardware cache device type and name.
*
* Inputs: Dga_window - Pointer to the client structure.
* Unsign8 * - Pointer to location to store device type.
* char ** - Pointer to location to store name string pointer.
*
* Outputs: None.
*
* Globals: None.
*
* Externals: RTN_INFOP() Internal MACRO
*
*/
void
char **name;
{
}
/*
*
* dga_rtn_dimensions()
*
* DGA Retained Raster Dimensions. This function is used to obtain
* the retained raster's dimensions.
*
* Inputs: Dga_window - Pointer to the client structure.
* short * - Pointer to location to store the width.
* short * - Pointer to location to store the height.
* u_int * - Pointer to the location to store the linebytes.
*
* Outputs: None.
*
* Globals: None.
*
* Externals: RTN_INFOP() Internal MACRO
*
*/
void
short *width;
short *height;
{
}
int
{
}
/*
*
* dga_rtn_grab()
*
* DGA Retained Window Grab. This function creates the shared memory
* interface to allow the calling process Direct Graphics Access (DGA)
* to the retained raster associated with the specified DGA window.
* A request to allow DGA access to the retained raster is sent to the
* mappings within the calling process's address space are then created.
* Should any of these steps fail, 0 is returned and the calling process
* is not allowed DGA to the retained raster. A non-zero result is
* returned upon success.
*
* Inputs: Dga_window - Pointer to the Dga_window for which DGA
* to the retained raster is desired.
*
* Outputs: 0 - failed
* -1 - passed
*
* Globals: None.
*
* Externals: XDgaGrabRetainedWindow()
* XDgaUnGrabRetainedWindow()
* _dga_is_X_window()
* _dga_rtn_map()
* fprintf() DEBUG ONLY
*
*/
int
{
#ifdef SERVER_DGA
#endif /* SERVER_DGA */
/*
* Check for an invalid Dga_window
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
#ifdef SERVER_DGA
/* Determine the window associated with this clientp */
/* Check to see if backing store has been turned on for thw window */
return (RTN_FAILED);
return (RTN_FAILED);
}
/* Map the shared memory into the calling process's address space.*/
if (!_dga_rtn_map(clientp)) {
/* Ungrab the retained raster */
return (RTN_FAILED);
}
#else
/*
* If the retained raster has already been grabbed. Don't
* do anything.
*/
return (RTN_PASSED);
/*
* Find out if this is an X window. If so get the Display and window
* id. These are used to determine the name of the shared retained
* info file. NOTE: DGA to retained rasters are currently supported
* only for X windows.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/* Check to see if backing store is turned on for this window; if not
* report failure
*/
{
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
}
/*
* Request the server to allow DGA to the retained raster associated
* with this Dga_window.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* Now map the shared memory into the calling process's address
* space.
*/
if (!_dga_rtn_map(clientp)) {
#ifdef DEBUG
#endif
/*
* Ungrab the retained raster
*/
return (RTN_FAILED);
}
#endif /* SERVER_DGA */
return (RTN_PASSED);
}
/*
*
* dga_rtn_pixels()
*
* DGA Retained Pixel Memory . This function returns a pointer
* to the shared retained pixel memory.
*
* Inputs: Dga_window - Pointer to the client structure.
*
* Outputs: u_char * - Pointer to retained pixel memory.
*
* Globals: None.
*
* Externals: None.
*
*
*/
void *
{
return ((void *)clientp->rtn_pixels);
}
/*
*
* dga_rtn_ungrab()
*
* DGA Retained Window Ungrab. This function frees the resources
* associated with a DGA retained retained raster. The shared
* memory mappings in the calling process's address space are
* unmapped, the shared info file is closed, and the server is
* notified through a protocol extension to free all its resources
* associated with the DGA retained raster. Should any of these
* steps fail, 0 is returned. A non-zero result is returned upon
* success.
*
* Inputs: Dga_window - Pointer to the Dga_window for which DGA
* to the retained raster is desired.
*
* Outputs: 0 - failed
* -1 - passed
*
* Globals: None.
*
* Externals: DisplayString() X11 MACRO
* XDgaUnGrabRetainedWindow()
* _dga_is_X_window()
* _dga_rtn_unmap()
* fprintf() DEBUG ONLY
*
*/
int
{
return (dgai_rtn_ungrab_common(clientp, 0));
}
int
int drawableGrabber;
{
#ifdef SERVER_DGA
#else
#endif /* SERVER_DGA */
/*
* Check for an invalid Dga_window
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* If the retained window has not been grabbed then don't
* do anything.
*/
return (RTN_FAILED);
/*
* Unmap the calling process's resources if present.
*/
/*
* Set the dga_window retained window server sequence counter pointer
* to reflect that the retained raster has NOT been grabbed.
*/
#ifdef SERVER_DGA
/* Determine the window associated with this clientp */
#else
/*
* Find out if this is an X window. If so get the Display and window
* id. These are used to determine the name of the shared retained
* info file. NOTE: DGA to retained rasters is currently supported
* only for X windows.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* Tell the server to deallocate its retained window
* resources.if there are no other clients grabbing this window
*/
#endif /* SERVER_DGA */
if (status)
return (RTN_PASSED);
else
return (RTN_FAILED);
}
/*
*
* _dga_rtn_map()
*
* DGA Retained Window Map. This function maps the retained window
* shared memory into the clients address space after determining
* the path to the retained window information file. The shared
* retained info structure is mapped followed by the actual pixel
* array used when the pixels are not cached in hardware. The
* address of the shared retained info structure is then place in
* the dga_window structure along with the client dependent information.
* Should any operation fail, a NULL pointer is placed in the dga_window
* structure and 0 is returned.
*
* Inputs: Dga_window - Pointer to the dga_window structure
*
* Outputs: 0 - failed
* -1 - passed
*
* Globals: None.
*
* Externals: DisplayString() X11 MACRO
* XDgaGetRetainedPath()
* _dga_is_X_window()
* close()
* fprintf() DEBUG ONLY
* fstat()
* getpagesize() SUNOS ONLY
* mmap()
* munmap()
* open()
* sprintf()
* sscanf()
* strcat()
* strcpy()
* strlen()
* sysconf() SVR4 ONLY
* unlink()
*
*/
int
{
#ifdef SERVER_DGA
#else
int filefd;
char *dpystr;
#endif /* SERVER_DGA */
/*
* Check for a non-zero pointer.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* If the shared retained information has already been mapped don't
* do anything.
*/
return (RTN_PASSED);
#ifdef SERVER_DGA
/* Determine the window associated with this clientp */
/* Initialise clientp's retained info structure - refer dga.h */
clientp->c_rtncachseq = 0;
return (RTN_PASSED);
#else /* SERVER_DGA */
/*
* Find out if this is an X window. If so get the Display and window
* id. These are used to determine the name of the shared retained
* info file. NOTE: DGA to retained rasters are currently supported
* only for X windows.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* Now locate the shared retained info file within the file system.
* This file is located in /tmp by default, but through a server
* command line option, can be located anywhere on the system in
* question. Get the path from the server using the protocol
* extension. Then create the filename using the display string
* and the port number.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* If the path is equal to "", then use the default directory
* path.
*/
if (!(*path))
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* Now get the port number for this display
*/
if (dpystr[0] == ':')
else
/*
* Combine the port number and the window id with the path
* string.
*/
#ifdef DEBUG
path);
#endif
return (RTN_FAILED);
}
/*
* Now unlink the file to guarantee that it will disappear
* should the client or server crash.
*/
#ifdef SVR4
#else
pagesize = getpagesize();
#endif
/*
* Check the state of the file. If the size of the file
* is insufficient to contain the first page of the shared
* retained info structure (ie < pagesize) report a failure.
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* Map the SHARED_RETAINED_INFO structure
*/
(off_t)0);
#ifdef DEBUG
path);
#endif
return (RTN_FAILED);
}
/*
* If the file is not actually a shared retained information file
* or its the wrong version, unmap the shared memory, close the
* file and return the error status.
*/
#ifdef DEBUG
path);
#endif
return (RTN_FAILED);
}
/*
* Map the pixel page
*/
#ifdef DEBUG
#endif
return (RTN_FAILED);
}
/*
* Set the fields of the client information.
*/
clientp->c_rtncachseq = 0;
#ifdef DEBUG
#endif
return (RTN_PASSED);
#endif /* SERVER_DGA */
}
/*
*
* _dga_rtn_unmap()
*
* DGA Retained Window Unmap. This function unmaps the retained window
* shared memory from the clients address space given the pointer to the
* dga_window structure. The pixel array associated with the retained info
* structure is unmapped first followed by the shared retained info
* structure. The pointer to the shared memory info structure within the
* dga_window structure is set to NULL and the shared memory file is then
* closed. Should any operation fail zero is returned.
*
* Inputs: Dga_window - Pointer to the dga_window structure for which
* the the shared retained info structure is to
* be removed.
*
* Outputs: 0 - failed
* -1 - passed
*
* Globals: None.
*
* Externals: close()
* fprintf() DEBUG ONLY
* getpagesize() SUNOS ONLY
* munmap()
* sysconf() SVR4 ONLY
* unlink()
*
*/
int
{
int status = 0;
return (RTN_FAILED);
#ifndef SERVER_DGA
#ifdef SVR4
#else
pagesize = getpagesize();
#endif
#ifdef DEBUG
#endif
status++;
}
#ifdef DEBUG
#endif
status++;
}
#endif /*SERVER_DGA */
clientp->c_rtncachseq = 0;
if (status)
return (RTN_FAILED);
else
return (RTN_PASSED);
}
#ifdef DEBUG
/*
*
* _dga_rtn_dump()
*
* DGA Retained Info Structure Dump. This function prints out the contents
* of the shared retained info structure found at the specified address.
*
* Inputs: SHARED_RETAINED_INFO * - Pointer to the structure to dump.
*
* Outputs: None.
*
* Globals: None.
*
* Externals: printf()
*
*/
void
{
(void) printf("NULL info pointer passed to _dga_rtn_dump\n");
else {
}
}
#endif
void *
{
return 0;
return (void *) &(infop->w_window_boundary);
}