home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / PEXlib / pl_wks.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  26.9 KB  |  1,293 lines

  1. /* $XConsortium: pl_wks.c,v 1.8 92/08/26 13:06:25 mor Exp $ */
  2.  
  3. /******************************************************************************
  4. Copyright 1987,1991 by Digital Equipment Corporation, Maynard, Massachusetts
  5. Copyright 1992 by ShoGraphics, Inc., Mountain View, California
  6. Copyright 1992 by the Massachusetts Institute of Technology
  7.  
  8.                         All Rights Reserved
  9.  
  10. Permission to use, copy, modify, distribute, and sell this software and its
  11. documentation for any purpose is hereby granted without fee, provided that
  12. the above copyright notice appear in all copies and that both that copyright
  13. notice and this permission notice appear in supporting documentation, and that
  14. the name of Digital, ShowGraphics, or M.I.T. not be used in advertising or
  15. publicity pertaining to distribution of the software without specific, written
  16. prior permission.  Digital, ShowGraphics, and M.I.T. make no representations
  17. about the suitability of this software for any purpose.  It is provided "as is"
  18. without express or implied warranty.
  19.  
  20. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  21. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  22. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  23. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  25. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  26. SOFTWARE.
  27.  
  28. SHOGRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. SHOGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. *************************************************************************/
  36.  
  37. #include "PEXlib.h"
  38. #include "PEXlibint.h"
  39.  
  40.  
  41. PEXWorkstation
  42. PEXCreateWorkstation (display, drawable, lineBundle, markerBundle, textBundle,
  43.     interiorBundle, edgeBundle, colorTable, patternTable, textFontTable,
  44.     depthCueTable, lightTable, colorApproxTable, highlightIncl,
  45.     highlightExcl, invisibilityIncl, invisibilityExcl, bufferMode)
  46.  
  47. INPUT Display        *display;
  48. INPUT Drawable        drawable;
  49. INPUT PEXLookupTable    lineBundle;
  50. INPUT PEXLookupTable    markerBundle;
  51. INPUT PEXLookupTable    textBundle;
  52. INPUT PEXLookupTable    interiorBundle;
  53. INPUT PEXLookupTable    edgeBundle;
  54. INPUT PEXLookupTable    colorTable;
  55. INPUT PEXLookupTable    patternTable;
  56. INPUT PEXLookupTable    textFontTable;
  57. INPUT PEXLookupTable    depthCueTable;
  58. INPUT PEXLookupTable    lightTable;
  59. INPUT PEXLookupTable    colorApproxTable;
  60. INPUT PEXNameSet    highlightIncl;
  61. INPUT PEXNameSet    highlightExcl;
  62. INPUT PEXNameSet    invisibilityIncl;
  63. INPUT PEXNameSet    invisibilityExcl;
  64. INPUT int        bufferMode;
  65.  
  66. {
  67.     pexCreateWorkstationReq    *req;
  68.     PEXWorkstation        wks;
  69.  
  70.  
  71.     /*
  72.      * Get a Phigs Workstation resource id from X.
  73.      */
  74.  
  75.     wks = XAllocID (display);
  76.  
  77.  
  78.     /*
  79.      * Lock around the critical section, for multithreading.
  80.      */
  81.  
  82.     LockDisplay (display);
  83.  
  84.  
  85.     /*
  86.      * Put the request in the X request buffer.
  87.      */
  88.  
  89.     PEXGetReq (CreateWorkstation, req);
  90.     req->drawable = drawable;
  91.     req->wks = wks;
  92.     req->lineBundle = lineBundle;
  93.     req->markerBundle = markerBundle;
  94.     req->textBundle = textBundle;
  95.     req->interiorBundle = interiorBundle;
  96.     req->edgeBundle = edgeBundle;
  97.     req->colorTable = colorTable;
  98.     req->patternTable = patternTable;
  99.     req->textFontTable = textFontTable;
  100.     req->depthCueTable = depthCueTable;
  101.     req->lightTable = lightTable;
  102.     req->colorApproxTable = colorApproxTable;
  103.     req->highlightIncl = highlightIncl;
  104.     req->highlightExcl = highlightExcl;
  105.     req->invisIncl = invisibilityIncl;
  106.     req->invisExcl = invisibilityExcl;
  107.     req->bufferMode = bufferMode;
  108.  
  109.  
  110.     /*
  111.      * Done, so unlock and check for synchronous-ness.
  112.      */
  113.  
  114.     UnlockDisplay (display);
  115.     PEXSyncHandle (display);
  116.  
  117.     return (wks);
  118. }
  119.  
  120.  
  121. void
  122. PEXFreeWorkstation (display, wks)
  123.  
  124. INPUT Display        *display;
  125. INPUT PEXWorkstation    wks;
  126.  
  127. {
  128.     pexFreeWorkstationReq    *req;
  129.  
  130.  
  131.     /*
  132.      * Lock around the critical section, for multithreading.
  133.      */
  134.  
  135.     LockDisplay (display);
  136.  
  137.  
  138.     /*
  139.      * Put the request in the X request buffer.
  140.      */
  141.  
  142.     PEXGetReq (FreeWorkstation, req);
  143.     req->id = wks;
  144.  
  145.  
  146.     /*
  147.      * Done, so unlock and check for synchronous-ness.
  148.      */
  149.  
  150.     UnlockDisplay (display);
  151.     PEXSyncHandle (display);
  152. }
  153.  
  154.  
  155. PEXWorkstationAttributes *
  156. PEXGetWorkstationAttributes (display, wks, valueMask)
  157.  
  158. INPUT Display        *display;
  159. INPUT PEXWorkstation    wks;
  160. INPUT unsigned long    *valueMask;
  161.  
  162. {
  163.     pexGetWorkstationAttributesReq    *req;
  164.     pexGetWorkstationAttributesReply    rep;
  165.     PEXWorkstationAttributes        *ppwi;
  166.     unsigned long            *pv;
  167.     Bool                bitSet;
  168.     int                    i, size;
  169.     int                    convertFP;
  170.  
  171.  
  172.     /*
  173.      * Lock around the critical section, for multithreading.
  174.      */
  175.  
  176.     LockDisplay (display);
  177.  
  178.  
  179.     /*
  180.      * Put the request in the X request buffer and get a reply.
  181.      */
  182.  
  183.     PEXGetFPReq (GetWorkstationAttributes, req, convertFP);
  184.     req->wks = wks;
  185.     req->itemMask0 = valueMask[0];
  186.     req->itemMask1 = valueMask[1];
  187.  
  188.     if (_XReply (display, &rep, 0, xFalse) == 0)
  189.     {
  190.         UnlockDisplay (display);
  191.         PEXSyncHandle (display);
  192.         return (NULL);            /* return an error */
  193.     }
  194.  
  195.  
  196.     /*
  197.      * Allocate a scratch buffer and copy the reply data to the buffer.
  198.      */
  199.  
  200.     pv = (unsigned long *) _XAllocScratch (display,
  201.         (unsigned long) (rep.length << 2));
  202.  
  203.     _XRead (display, (char *) pv, (long) (rep.length << 2));
  204.  
  205.  
  206.     /*
  207.      * Allocate a buffer for the replies to pass back to the client.
  208.      */
  209.  
  210.     ppwi = (PEXWorkstationAttributes *)
  211.         PEXAllocBuf ((unsigned) (sizeof (PEXWorkstationAttributes)));
  212.  
  213.     ppwi->defined_views.count = 0;
  214.     ppwi->defined_views.views = NULL;
  215.     ppwi->posted_structures.count = 0;
  216.     ppwi->posted_structures.structures = NULL;
  217.  
  218.     for (i = 0; i < (PEXPWMaxShift + 1); i++)
  219.     {
  220.     bitSet = valueMask[i >> 5] & (1L << (i & 0x1f));
  221.     if (bitSet != 0)
  222.     {
  223.         switch (i)
  224.         {
  225.         case PEXPWDisplayUpdate:
  226.         ppwi->drawable_update = *pv;
  227.         pv++;
  228.         break;
  229.         case PEXPWVisualState:
  230.         ppwi->visual_state = *pv;
  231.         pv++;
  232.         break;
  233.         case PEXPWDisplaySurface:
  234.         ppwi->drawable_surface = *pv;
  235.         pv++;
  236.         break;
  237.         case PEXPWViewUpdate:
  238.         ppwi->view_update = *pv;
  239.         pv++;
  240.         break;
  241.         case PEXPWDefinedViews:
  242.         size = *((int *) pv);
  243.         pv++;
  244.         ppwi->defined_views.count = size;
  245.         size *= sizeof (pexTableIndex);
  246.         ppwi->defined_views.views = 
  247.             (PEXTableIndex *) PEXAllocBuf ((unsigned) size);
  248.         COPY_AREA ((char *) pv,
  249.             (char *) (ppwi->defined_views.views), size);
  250.         pv += NUMWORDS (size);
  251.         break;
  252.         case PEXPWWorkstationUpdate:
  253.         ppwi->wks_update = *pv;
  254.         pv++;
  255.         break;
  256.         case PEXPWReqNPCSubVolume:
  257.         ppwi->req_npc_subvolume = *((PEXNPCSubVolume *) pv);
  258.         pv += LENOF (pexNpcSubvolume);
  259.         break;
  260.         case PEXPWCurNPCSubVolume:
  261.         ppwi->cur_npc_subvolume = *((PEXNPCSubVolume *) pv);
  262.         pv += LENOF (pexNpcSubvolume);
  263.         break;
  264.         case PEXPWReqViewport:
  265.         ppwi->req_workstation_viewport = *((PEXViewport *) pv);
  266.         pv += LENOF (pexViewport);
  267.         break;
  268.         case PEXPWCurViewport:
  269.         ppwi->cur_workstation_viewport = *((PEXViewport *) pv);
  270.         pv += LENOF (pexViewport);
  271.         break;
  272.         case PEXPWHLHSRUpdate:
  273.         ppwi->hlhsr_update = *pv;
  274.         pv++;
  275.         break;
  276.         case PEXPWReqHLHSRMode:
  277.         ppwi->req_hlhsr_mode = *pv;
  278.         pv++;
  279.         break;
  280.         case PEXPWCurHLHSRMode:
  281.         ppwi->cur_hlhsr_mode = *pv;
  282.         pv++;
  283.         break;
  284.         case PEXPWDrawable:
  285.         ppwi->drawable = *((Drawable *) pv);
  286.         pv += LENOF (Drawable);
  287.         break;
  288.         case PEXPWMarkerBundle:
  289.         ppwi->marker_bundle = *((PEXLookupTable *) pv);
  290.         pv += LENOF (pexLookupTable);
  291.         break;
  292.         case PEXPWTextBundle:
  293.         ppwi->text_bundle = *((PEXLookupTable *) pv);
  294.         pv += LENOF (pexLookupTable);
  295.         break;
  296.         case PEXPWLineBundle:
  297.         ppwi->line_bundle = *((PEXLookupTable *) pv);
  298.         pv += LENOF (pexLookupTable);
  299.         break;
  300.         case PEXPWInteriorBundle:
  301.         ppwi->interior_bundle = *((PEXLookupTable *) pv);
  302.         pv += LENOF (pexLookupTable);
  303.         break;
  304.         case PEXPWEdgeBundle:
  305.         ppwi->edge_bundle = *((PEXLookupTable *) pv);
  306.         pv += LENOF (pexLookupTable);
  307.         break;
  308.         case PEXPWColorTable:
  309.         ppwi->color_table = *((PEXLookupTable *) pv);
  310.         pv += LENOF (pexLookupTable);
  311.         break;
  312.         case PEXPWDepthCueTable:
  313.         ppwi->depth_cue_table = *((PEXLookupTable *) pv);
  314.         pv += LENOF (pexLookupTable);
  315.         break;
  316.         case PEXPWLightTable:
  317.         ppwi->light_table = *((PEXLookupTable *) pv);
  318.         pv += LENOF (pexLookupTable);
  319.         break;
  320.         case PEXPWColorApproxTable:
  321.         ppwi->color_approx_table = *((PEXLookupTable *) pv);
  322.         pv += LENOF (pexLookupTable);
  323.         break;
  324.         case PEXPWPatternTable:
  325.         ppwi->pattern_table = *((PEXLookupTable *) pv);
  326.         pv += LENOF (pexLookupTable);
  327.         break;
  328.         case PEXPWTextFontTable:
  329.         ppwi->text_font_table = *((PEXLookupTable *) pv);
  330.         pv += LENOF (pexLookupTable);
  331.         break;
  332.         case PEXPWHighlightIncl:
  333.         ppwi->highlight_incl = *((PEXNameSet *) pv);
  334.         pv += LENOF (pexNameSet);
  335.         break;
  336.         case PEXPWHighlightExcl:
  337.         ppwi->highlight_excl = *((PEXNameSet *) pv);
  338.         pv += LENOF (pexNameSet);
  339.         break;
  340.         case PEXPWInvisibilityIncl:
  341.         ppwi->invisibility_incl = *((PEXNameSet *) pv);
  342.         pv += LENOF (pexNameSet);
  343.         break;
  344.         case PEXPWInvisibilityExcl:
  345.         ppwi->invisibility_excl = *((PEXNameSet *) pv);
  346.         pv += LENOF (pexNameSet);
  347.         break;
  348.         case PEXPWPostedStructures:
  349.         size = *((int *) pv);
  350.         pv++;
  351.         ppwi->posted_structures.count = size;
  352.         size *= sizeof (pexStructureInfo);
  353.         ppwi->posted_structures.structures = 
  354.             (PEXPostedStructure *) PEXAllocBuf ((unsigned) size);
  355.         COPY_AREA ((char *) pv,
  356.             (char *) (ppwi->posted_structures.structures), size);
  357.         pv += NUMWORDS (size);
  358.         break;
  359.         case PEXPWNumPriorities:
  360.         ppwi->count_priorities = *pv;
  361.         pv++;
  362.         break;
  363.         case PEXPWBufferUpdate:
  364.         ppwi->buffer_update = *pv;
  365.         pv++;
  366.         break;
  367.         case PEXPWReqBufferMode:
  368.         ppwi->req_buffer_mode = *pv;
  369.         pv++;
  370.         break;
  371.         case PEXPWCurBufferMode:
  372.         ppwi->cur_buffer_mode = *pv;
  373.         pv++;
  374.         break;
  375.         }
  376.     }
  377.     }
  378.  
  379.  
  380.     /*
  381.      * Done, so unlock and check for synchronous-ness.
  382.      */
  383.  
  384.     UnlockDisplay (display);
  385.     PEXSyncHandle (display);
  386.  
  387.     return (ppwi);
  388. }
  389.  
  390.  
  391. Status
  392. PEXGetWorkstationDynamics (display, d, dynamics)
  393.  
  394. INPUT Display            *display;
  395. INPUT Drawable            d;
  396. INPUT PEXWorkstationDynamics    *dynamics;
  397.  
  398. {
  399.     pexGetWorkstationDynamicsReq    *req;
  400.     pexGetWorkstationDynamicsReply    rep;
  401.  
  402.  
  403.     /*
  404.      * Lock around the critical section, for multithreading.
  405.      */
  406.  
  407.     LockDisplay (display);
  408.  
  409.  
  410.     /*
  411.      * Put the request in the X request buffer and get a reply.
  412.      */
  413.  
  414.     PEXGetReq (GetWorkstationDynamics, req);
  415.     req->drawable = d;
  416.  
  417.     if (_XReply (display, &rep, 0, xFalse) == 0)
  418.     {
  419.         UnlockDisplay (display);
  420.         PEXSyncHandle (display);
  421.         return (0);            /* return an error */
  422.     }
  423.  
  424.  
  425.     /*
  426.      * Fill in the dynamics.
  427.      */
  428.  
  429.     dynamics->view_rep = rep.viewRep;
  430.     dynamics->marker_bundle = rep.markerBundle;
  431.     dynamics->text_bundle = rep.textBundle;
  432.     dynamics->line_bundle = rep.lineBundle;
  433.     dynamics->interior_bundle = rep.interiorBundle;
  434.     dynamics->edge_bundle = rep.edgeBundle;
  435.     dynamics->color_table = rep.colorTable;
  436.     dynamics->pattern_table = rep.patternTable;
  437.     dynamics->wks_transform = rep.wksTransform;
  438.     dynamics->highlight_filter = rep.highlightFilter;
  439.     dynamics->invisibility_filter = rep.invisibilityFilter;
  440.     dynamics->hlhsr_mode = rep.HlhsrMode;
  441.     dynamics->structure_modify = rep.structureModify;
  442.     dynamics->post_structure = rep.postStructure;
  443.     dynamics->unpost_structure = rep.unpostStructure;
  444.     dynamics->delete_structure = rep.deleteStructure;
  445.     dynamics->reference_modify = rep.referenceModify;
  446.     dynamics->buffer_modify = rep.bufferModify;
  447.     dynamics->light_table = rep.lightTable;
  448.     dynamics->depth_cue_table = rep.depthCueTable;
  449.     dynamics->color_approx_table = rep.colorApproxTable;
  450.  
  451.  
  452.     /*
  453.      * Done, so unlock and check for synchronous-ness.
  454.      */
  455.  
  456.     UnlockDisplay (display);
  457.     PEXSyncHandle (display);
  458.  
  459.     return (1);
  460. }
  461.  
  462.  
  463. Status
  464. PEXGetWorkstationViewRep (display, wks, index,
  465.     viewUpdateReturn, reqViewReturn, curViewReturn)
  466.  
  467. INPUT Display        *display;
  468. INPUT PEXWorkstation    wks;
  469. INPUT unsigned int    index;
  470. OUTPUT int        *viewUpdateReturn;
  471. OUTPUT PEXViewRep    *reqViewReturn;
  472. OUTPUT PEXViewRep    *curViewReturn;
  473.  
  474. {
  475.     pexGetWorkstationViewRepReq        *req;
  476.     pexGetWorkstationViewRepReply    rep;
  477.     unsigned long            *pv;
  478.     int                    convertFP;
  479.  
  480.  
  481.     /*
  482.      * Lock around the critical section, for multithreading.
  483.      */
  484.  
  485.     LockDisplay (display);
  486.  
  487.  
  488.     /*
  489.      * Put the request in the X request buffer and get a reply.
  490.      */
  491.  
  492.     PEXGetFPReq (GetWorkstationViewRep, req, convertFP);
  493.     req->wks = wks;
  494.     req->index = index;
  495.  
  496.  
  497.     if (_XReply (display, &rep, 0, xFalse) == 0)
  498.     {
  499.         UnlockDisplay (display);
  500.         PEXSyncHandle (display);
  501.         return (0);            /* return an error */
  502.     }
  503.  
  504.     *viewUpdateReturn = rep.viewUpdate;
  505.  
  506.  
  507.     /*
  508.      * Allocate a scratch buffer and copy the reply data to the buffer.
  509.      */
  510.  
  511.     pv = (unsigned long *) _XAllocScratch (display,
  512.         (unsigned long) (rep.length << 2));
  513.  
  514.     _XRead (display, (char *) pv, (long) (rep.length << 2));
  515.  
  516.  
  517.     /*
  518.      * Fill in the current and requested view reps.
  519.      */
  520.  
  521.     reqViewReturn->index = *pv;
  522.     pv ++;
  523.     reqViewReturn->view.clip_flags = *pv;
  524.     pv++;
  525.  
  526. #ifdef WORD64
  527. #else
  528.     reqViewReturn->view.clip_limits = *((PEXNPCSubVolume *) pv);
  529. #endif
  530.     pv += LENOF (pexNpcSubvolume);
  531.  
  532.     COPY_AREA ((char *) pv,
  533.         (char *) (reqViewReturn->view.orientation), sizeof (pexMatrix));
  534.     pv += LENOF (pexMatrix);
  535.     COPY_AREA ((char *) pv, (char *) (reqViewReturn->view.mapping),
  536.      sizeof (pexMatrix));
  537.     pv += LENOF (pexMatrix);
  538.  
  539.     curViewReturn->index = *pv;
  540.     pv++;
  541.     curViewReturn->view.clip_flags = *pv;
  542.     pv++;
  543.  
  544. #ifdef WORD64
  545. #else
  546.     curViewReturn->view.clip_limits = *((PEXNPCSubVolume *) pv);
  547. #endif
  548.     pv += LENOF (pexNpcSubvolume);
  549.  
  550.     COPY_AREA ((char *) pv,
  551.         (char *)(curViewReturn->view.orientation), sizeof (pexMatrix));
  552.     pv += LENOF (pexMatrix);
  553.     COPY_AREA ((char *) pv, (char *) (curViewReturn->view.mapping),
  554.         sizeof (pexMatrix));
  555.     pv += LENOF (pexMatrix);
  556.  
  557.  
  558.     /*
  559.      * Done, so unlock and check for synchronous-ness.
  560.      */
  561.  
  562.     UnlockDisplay (display);
  563.     PEXSyncHandle (display);
  564.  
  565.     return (1);
  566. }
  567.  
  568.  
  569. Status
  570. PEXGetWorkstationPostings (display, structure, numWksReturn, wksReturn)
  571.  
  572. INPUT Display        *display;
  573. INPUT PEXStructure    structure;
  574. OUTPUT unsigned long    *numWksReturn;
  575. OUTPUT PEXWorkstation    **wksReturn;
  576.  
  577. {
  578.     pexGetWorkstationPostingsReq    *req;
  579.     pexGetWorkstationPostingsReply    rep;
  580.  
  581.  
  582.     /*
  583.      * Lock around the critical section, for multithreading.
  584.      */
  585.  
  586.     LockDisplay (display);
  587.  
  588.  
  589.     /*
  590.      * Put the request in the X request buffer and get a reply.
  591.      */
  592.  
  593.     PEXGetReq (GetWorkstationPostings, req);
  594.     req->id = structure;
  595.  
  596.     if (_XReply (display, &rep, 0, xFalse) == 0)
  597.     {
  598.         UnlockDisplay (display);
  599.         PEXSyncHandle (display);
  600.     *wksReturn = NULL;
  601.         return (0);            /* return an error */
  602.     }
  603.  
  604.     *numWksReturn = rep.length;
  605.  
  606.  
  607.     /*
  608.      * Allocate a buffer for the replies to pass back to the client.
  609.      */
  610.  
  611.     *wksReturn = (PEXWorkstation *) PEXAllocBuf (
  612.     (unsigned) (rep.length << 2));
  613.  
  614.     _XRead (display, (char *) *wksReturn, (long) (rep.length << 2));
  615.  
  616.  
  617.     /*
  618.      * Done, so unlock and check for synchronous-ness.
  619.      */
  620.  
  621.     UnlockDisplay (display);
  622.     PEXSyncHandle (display);
  623.  
  624.     return (1);
  625. }
  626.  
  627.  
  628. void
  629. PEXSetWorkstationViewPriority (display, wks, index1, index2, priority)
  630.  
  631. INPUT Display        *display;
  632. INPUT PEXWorkstation    wks;
  633. INPUT unsigned int    index1;
  634. INPUT unsigned int    index2;
  635. INPUT int        priority;
  636.  
  637. {
  638.     pexSetWorkstationViewPriorityReq    *req;
  639.  
  640.  
  641.     /*
  642.      * Lock around the critical section, for multithreading.
  643.      */
  644.  
  645.     LockDisplay (display);
  646.  
  647.  
  648.     /*
  649.      * Put the request in the X request buffer.
  650.      */
  651.  
  652.     PEXGetReq (SetWorkstationViewPriority, req);
  653.     req->wks = wks;
  654.     req->index1 = index1;
  655.     req->index2 = index2;
  656.     req->priority = priority;
  657.  
  658.  
  659.     /*
  660.      * Done, so unlock and check for synchronous-ness.
  661.      */
  662.  
  663.     UnlockDisplay (display);
  664.     PEXSyncHandle (display);
  665. }
  666.  
  667.  
  668. void
  669. PEXSetWorkstationDisplayUpdateMode (display, wks, displayUpdate)
  670.  
  671. INPUT Display        *display;
  672. INPUT PEXWorkstation    wks;
  673. INPUT int        displayUpdate;
  674.  
  675. {
  676.     pexSetWorkstationDisplayUpdateModeReq    *req;
  677.  
  678.  
  679.     /*
  680.      * Lock around the critical section, for multithreading.
  681.      */
  682.  
  683.     LockDisplay (display);
  684.  
  685.  
  686.     /*
  687.      * Put the request in the X request buffer.
  688.      */
  689.  
  690.     PEXGetReq (SetWorkstationDisplayUpdateMode, req);
  691.     req->wks = wks;
  692.     req->displayUpdate = displayUpdate;
  693.  
  694.  
  695.     /*
  696.      * Done, so unlock and check for synchronous-ness.
  697.      */
  698.  
  699.     UnlockDisplay (display);
  700.     PEXSyncHandle (display);
  701. }
  702.  
  703.  
  704. void
  705. PEXSetWorkstationBufferMode (display, wks, bufferMode)
  706.  
  707. INPUT Display        *display;
  708. INPUT PEXWorkstation    wks;
  709. INPUT int        bufferMode;
  710.  
  711. {
  712.     pexSetWorkstationBufferModeReq    *req;
  713.  
  714.  
  715.     /*
  716.      * Lock around the critical section, for multithreading.
  717.      */
  718.  
  719.     LockDisplay (display);
  720.  
  721.  
  722.     /*
  723.      * Put the request in the X request buffer.
  724.      */
  725.  
  726.     PEXGetReq (SetWorkstationBufferMode, req);
  727.     req->wks = wks;
  728.     req->bufferMode = bufferMode;
  729.  
  730.  
  731.     /*
  732.      * Done, so unlock and check for synchronous-ness.
  733.      */
  734.  
  735.     UnlockDisplay (display);
  736.     PEXSyncHandle (display);
  737. }
  738.  
  739.  
  740. void
  741. PEXSetWorkstationViewRep (display, wks, viewIndex, values)
  742.  
  743. INPUT Display        *display;
  744. INPUT PEXWorkstation    wks;
  745. INPUT unsigned int    viewIndex;
  746. INPUT PEXViewEntry    *values;
  747.  
  748. {
  749.     pexSetWorkstationViewRepReq        *req;
  750.     int                    convertFP;
  751.  
  752.  
  753.     /*
  754.      * Lock around the critical section, for multithreading.
  755.      */
  756.  
  757.     LockDisplay (display);
  758.  
  759.  
  760.     /*
  761.      * Put the request in the X request buffer.
  762.      */
  763.  
  764.     PEXGetFPReq (SetWorkstationViewRep, req, convertFP);
  765.     req->wks = wks;
  766.     req->viewRep.index = viewIndex;
  767. #ifdef WORD64
  768. #else
  769.     req->viewRep.view = *(pexViewEntry *) values;
  770. #endif
  771.  
  772.  
  773.     /*
  774.      * Done, so unlock and check for synchronous-ness.
  775.      */
  776.  
  777.     UnlockDisplay (display);
  778.     PEXSyncHandle (display);
  779. }
  780.  
  781.  
  782. void
  783. PEXSetWorkstationWindow (display, wks, npcSubvolume)
  784.  
  785. INPUT Display        *display;
  786. INPUT PEXWorkstation    wks;
  787. INPUT PEXNPCSubVolume    *npcSubvolume;
  788.  
  789. {
  790.     pexSetWorkstationWindowReq    *req;
  791.     int                convertFP;
  792.  
  793.  
  794.     /*
  795.      * Lock around the critical section, for multithreading.
  796.      */
  797.  
  798.     LockDisplay (display);
  799.  
  800.  
  801.     /*
  802.      * Put the request in the X request buffer.
  803.      */
  804.  
  805.     PEXGetFPReq (SetWorkstationWindow, req, convertFP);
  806.     req->wks = wks;
  807. #ifdef WORD64
  808. #else
  809.     req->npcSubvolume = *(pexNpcSubvolume *) npcSubvolume;
  810. #endif
  811.  
  812.  
  813.     /*
  814.      * Done, so unlock and check for synchronous-ness.
  815.      */
  816.  
  817.     UnlockDisplay (display);
  818.     PEXSyncHandle (display);
  819. }
  820.  
  821.  
  822. void
  823. PEXSetWorkstationViewport (display, wks, viewport)
  824.  
  825. INPUT Display        *display;
  826. INPUT PEXWorkstation    wks;
  827. INPUT PEXViewport    *viewport;
  828.  
  829. {
  830.     pexSetWorkstationViewportReq    *req;
  831.     int                    convertFP;
  832.  
  833.  
  834.     /*
  835.      * Lock around the critical section, for multithreading.
  836.      */
  837.  
  838.     LockDisplay (display);
  839.  
  840.  
  841.     /*
  842.      * Put the request in the X request buffer.
  843.      */
  844.  
  845.     PEXGetFPReq (SetWorkstationViewport, req, convertFP);
  846.     req->wks = wks;
  847. #ifdef WORD64
  848. #else
  849.     req->viewport = *(pexViewport *) viewport;
  850. #endif
  851.  
  852.  
  853.     /*
  854.      * Done, so unlock and check for synchronous-ness.
  855.      */
  856.  
  857.     UnlockDisplay (display);
  858.     PEXSyncHandle (display);
  859. }
  860.  
  861.  
  862. void
  863. PEXSetWorkstationHLHSRMode (display, wks, hlhsrMode)
  864.  
  865. INPUT Display        *display;
  866. INPUT PEXWorkstation    wks;
  867. INPUT int        hlhsrMode;
  868.  
  869. {
  870.     pexSetWorkstationHLHSRModeReq    *req;
  871.  
  872.  
  873.     /*
  874.      * Lock around the critical section, for multithreading.
  875.      */
  876.  
  877.     LockDisplay (display);
  878.  
  879.  
  880.     /*
  881.      * Put the request in the X request buffer.
  882.      */
  883.  
  884.     PEXGetReq (SetWorkstationHLHSRMode, req);
  885.     req->wks = wks;
  886.     req->mode = (pexEnumTypeIndex)hlhsrMode;
  887.  
  888.  
  889.     /*
  890.      * Done, so unlock and check for synchronous-ness.
  891.      */
  892.  
  893.     UnlockDisplay (display);
  894.     PEXSyncHandle (display);
  895. }
  896.  
  897.  
  898. void
  899. PEXRedrawAllStructures (display, wks)
  900.  
  901. INPUT Display        *display;
  902. INPUT PEXWorkstation    wks;
  903.  
  904. {
  905.     pexRedrawAllStructuresReq    *req;
  906.  
  907.  
  908.     /*
  909.      * Lock around the critical section, for multithreading.
  910.      */
  911.  
  912.     LockDisplay (display);
  913.  
  914.  
  915.     /*
  916.      * Put the request in the X request buffer.
  917.      */
  918.  
  919.     PEXGetReq (RedrawAllStructures, req);
  920.     req->id = wks;
  921.  
  922.  
  923.     /*
  924.      * Done, so unlock and check for synchronous-ness.
  925.      */
  926.  
  927.     UnlockDisplay (display);
  928.     PEXSyncHandle (display);
  929. }
  930.  
  931.  
  932. void
  933. PEXUpdateWorkstation (display, wks)
  934.  
  935. INPUT Display        *display;
  936. INPUT PEXWorkstation    wks;
  937.  
  938. {
  939.     pexUpdateWorkstationReq    *req;
  940.  
  941.  
  942.     /*
  943.      * Lock around the critical section, for multithreading.
  944.      */
  945.  
  946.     LockDisplay (display);
  947.  
  948.  
  949.     /*
  950.      * Put the request in the X request buffer.
  951.      */
  952.  
  953.     PEXGetReq (UpdateWorkstation, req);
  954.     req->id = wks;
  955.  
  956.  
  957.     /*
  958.      * Done, so unlock and check for synchronous-ness.
  959.      */
  960.  
  961.     UnlockDisplay (display);
  962.     PEXSyncHandle (display);
  963. }
  964.  
  965.  
  966. void
  967. PEXExecuteDeferredActions (display, wks)
  968.  
  969. INPUT Display        *display;
  970. INPUT PEXWorkstation    wks;
  971.  
  972. {
  973.     pexExecuteDeferredActionsReq    *req;
  974.  
  975.  
  976.     /*
  977.      * Lock around the critical section, for multithreading.
  978.      */
  979.  
  980.     LockDisplay (display);
  981.  
  982.  
  983.     /*
  984.      * Put the request in the X request buffer.
  985.      */
  986.  
  987.     PEXGetReq (ExecuteDeferredActions, req);
  988.     req->id = wks;
  989.  
  990.  
  991.     /*
  992.      * Done, so unlock and check for synchronous-ness.
  993.      */
  994.  
  995.     UnlockDisplay (display);
  996.     PEXSyncHandle (display);
  997. }
  998.  
  999.  
  1000. Status
  1001. PEXMapDCToWC (display, wks, dc_count, dc_points,
  1002.     view_index_return, wc_count_return, wc_points_return)
  1003.  
  1004. INPUT Display            *display;
  1005. INPUT PEXWorkstation        wks;
  1006. INPUT unsigned long        dc_count;
  1007. INPUT PEXDeviceCoord        *dc_points;
  1008. OUTPUT unsigned int        *view_index_return;
  1009. OUTPUT unsigned long        *wc_count_return;
  1010. OUTPUT PEXCoord            **wc_points_return;
  1011.  
  1012. {
  1013.     pexMapDCtoWCReq    *req;
  1014.     pexMapDCtoWCReply    rep;
  1015.     int            size;
  1016.     int            convertFP;
  1017.  
  1018.  
  1019.     /*
  1020.      * Lock around the critical section, for multithreading.
  1021.      */
  1022.  
  1023.     LockDisplay (display);
  1024.  
  1025.  
  1026.     /*
  1027.      * Put the request in the X request buffer and get a reply.
  1028.      */
  1029.  
  1030.     size = dc_count * sizeof (PEXDeviceCoord);
  1031.  
  1032.     PEXGetFPReqExtra (MapDCtoWC, size, req, convertFP);
  1033.     req->wks = wks;
  1034.     req->numCoords = dc_count;
  1035.  
  1036.     COPY_AREA ((char *) dc_points, ((char *) &req[1]), size);
  1037.  
  1038.     if (_XReply (display, &rep, 0, xFalse) == 0)
  1039.     {
  1040.         UnlockDisplay (display);
  1041.         PEXSyncHandle (display);
  1042.     *wc_count_return = 0;
  1043.     *wc_points_return = NULL;
  1044.         return (0);            /* return an error */
  1045.     }
  1046.  
  1047.     *view_index_return = rep.viewIndex;
  1048.     *wc_count_return = rep.numCoords;
  1049.  
  1050.  
  1051.     /*
  1052.      * Allocate a buffer for the replies to pass back to the client.
  1053.      */
  1054.  
  1055.     *wc_points_return = (PEXCoord *) PEXAllocBuf (
  1056.     (unsigned) (rep.length << 2));
  1057.  
  1058.     _XRead (display, (char *) *wc_points_return, (long) (rep.length << 2));
  1059.  
  1060.  
  1061.     /*
  1062.      * Done, so unlock and check for synchronous-ness.
  1063.      */
  1064.  
  1065.     UnlockDisplay (display);
  1066.     PEXSyncHandle (display);
  1067.  
  1068.     return (1);
  1069. }
  1070.  
  1071.  
  1072. Status
  1073. PEXMapWCToDC (display, wks, wc_count, wc_points,
  1074.     view_index, dc_count_return, dc_points_return)
  1075.  
  1076. INPUT Display            *display;
  1077. INPUT PEXWorkstation        wks;
  1078. INPUT unsigned long        wc_count;
  1079. INPUT PEXCoord            *wc_points;
  1080. INPUT unsigned int        view_index;
  1081. OUTPUT unsigned long        *dc_count_return;
  1082. OUTPUT PEXDeviceCoord        **dc_points_return;
  1083.  
  1084. {
  1085.     pexMapWCtoDCReq    *req;
  1086.     pexMapWCtoDCReply    rep;
  1087.     int            size;
  1088.     int            convertFP;
  1089.  
  1090.  
  1091.     /*
  1092.      * Lock around the critical section, for multithreading.
  1093.      */
  1094.  
  1095.     LockDisplay (display);
  1096.  
  1097.  
  1098.     /*
  1099.      * Put the request in the X request buffer and get a reply.
  1100.      */
  1101.  
  1102.     size = wc_count * sizeof (PEXCoord);
  1103.  
  1104.     PEXGetFPReqExtra (MapWCtoDC, size, req, convertFP);
  1105.     req->wks = wks;
  1106.     req->index = view_index;
  1107.     req->numCoords = wc_count;
  1108.  
  1109.     COPY_AREA ((char *) wc_points, ((char *) &req[1]), size);
  1110.  
  1111.     if (_XReply (display, &rep, 0, xFalse) == 0)
  1112.     {
  1113.         UnlockDisplay (display);
  1114.         PEXSyncHandle (display);
  1115.     *dc_count_return = 0;
  1116.     *dc_points_return = NULL;
  1117.         return (0);            /* return an error */
  1118.     }
  1119.  
  1120.     *dc_count_return = rep.numCoords;
  1121.  
  1122.  
  1123.     /*
  1124.      * Allocate a buffer for the replies to pass back to the client.
  1125.      */
  1126.  
  1127.     *dc_points_return = (PEXDeviceCoord *) PEXAllocBuf (
  1128.     (unsigned) (rep.length << 2));
  1129.  
  1130.     _XRead (display, (char *) *dc_points_return, (long) (rep.length << 2));
  1131.  
  1132.  
  1133.     /*
  1134.      * Done, so unlock and check for synchronous-ness.
  1135.      */
  1136.  
  1137.     UnlockDisplay (display);
  1138.     PEXSyncHandle (display);
  1139.  
  1140.     return (1);
  1141. }
  1142.  
  1143.  
  1144. void
  1145. PEXPostStructure (display, wks, structure, priority)
  1146.  
  1147. INPUT Display        *display;
  1148. INPUT PEXWorkstation    wks;
  1149. INPUT PEXStructure    structure;
  1150. INPUT double        priority;
  1151.  
  1152. {
  1153.     pexPostStructureReq    *req;
  1154.     int            convertFP;
  1155.  
  1156.  
  1157.     /*
  1158.      * Lock around the critical section, for multithreading.
  1159.      */
  1160.  
  1161.     LockDisplay (display);
  1162.  
  1163.  
  1164.     /*
  1165.      * Put the request in the X request buffer.
  1166.      */
  1167.  
  1168.     PEXGetFPReq (PostStructure, req, convertFP);
  1169.     req->wks = wks;
  1170.     req->sid = structure;
  1171.     req->priority = priority;
  1172.  
  1173.  
  1174.     /*
  1175.      * Done, so unlock and check for synchronous-ness.
  1176.      */
  1177.  
  1178.     UnlockDisplay (display);
  1179.     PEXSyncHandle (display);
  1180. }
  1181.  
  1182.  
  1183. void
  1184. PEXUnpostStructure (display, wks, structure)
  1185.  
  1186. INPUT Display        *display;
  1187. INPUT PEXWorkstation    wks;
  1188. INPUT PEXStructure    structure;
  1189.  
  1190. {
  1191.     pexUnpostStructureReq    *req;
  1192.  
  1193.  
  1194.     /*
  1195.      * Lock around the critical section, for multithreading.
  1196.      */
  1197.  
  1198.     LockDisplay (display);
  1199.  
  1200.  
  1201.     /*
  1202.      * Put the request in the X request buffer.
  1203.      */
  1204.  
  1205.     PEXGetReq (UnpostStructure, req);
  1206.     req->wks = wks;
  1207.     req->sid = structure;
  1208.  
  1209.  
  1210.     /*
  1211.      * Done, so unlock and check for synchronous-ness.
  1212.      */
  1213.  
  1214.     UnlockDisplay (display);
  1215.     PEXSyncHandle (display);
  1216. }
  1217.  
  1218.  
  1219. void
  1220. PEXUnpostAllStructures (display, wks)
  1221.  
  1222. INPUT Display        *display;
  1223. INPUT PEXWorkstation    wks;
  1224.  
  1225. {
  1226.     pexUnpostAllStructuresReq    *req;
  1227.  
  1228.  
  1229.     /*
  1230.      * Lock around the critical section, for multithreading.
  1231.      */
  1232.  
  1233.     LockDisplay (display);
  1234.  
  1235.  
  1236.     /*
  1237.      * Put the request in the X request buffer.
  1238.      */
  1239.  
  1240.     PEXGetReq (UnpostAllStructures, req);
  1241.     req->id = wks;
  1242.  
  1243.  
  1244.     /*
  1245.      * Done, so unlock and check for synchronous-ness.
  1246.      */
  1247.  
  1248.     UnlockDisplay (display);
  1249.     PEXSyncHandle (display);
  1250. }
  1251.  
  1252.  
  1253. void
  1254. PEXRedrawClipRegion (display, wks, numRectangles, deviceRectangles)
  1255.  
  1256. INPUT Display        *display;
  1257. INPUT PEXWorkstation    wks;
  1258. INPUT unsigned long    numRectangles;
  1259. INPUT PEXDeviceRect    *deviceRectangles;
  1260.  
  1261. {
  1262.     pexRedrawClipRegionReq    *req;
  1263.     int                size;
  1264.  
  1265.  
  1266.     /*
  1267.      * Lock around the critical section, for multithreading.
  1268.      */
  1269.  
  1270.     LockDisplay (display);
  1271.  
  1272.  
  1273.     /*
  1274.      * Put the request in the X request buffer.
  1275.      */
  1276.  
  1277.     size = numRectangles * sizeof (PEXDeviceRect);
  1278.  
  1279.     PEXGetReqExtra (RedrawClipRegion, size, req);
  1280.     req->wks = wks;
  1281.     req->numRects = numRectangles;
  1282.  
  1283.     COPY_AREA ((char *) deviceRectangles, ((char *) &req[1]), size);
  1284.  
  1285.  
  1286.     /*
  1287.      * Done, so unlock and check for synchronous-ness.
  1288.      */
  1289.  
  1290.     UnlockDisplay (display);
  1291.     PEXSyncHandle (display);
  1292. }
  1293.