XORG_NV/sun-src/xc/programs/Xserver/tsol/tsolprotocol.c
changeset 73 8877ee2f6c6d
parent 64 c03273ff2fb9
equal deleted inserted replaced
72:030174ae2e68 73:8877ee2f6c6d
    24  * shall not be used in advertising or otherwise to promote the sale, use
    24  * shall not be used in advertising or otherwise to promote the sale, use
    25  * or other dealings in this Software without prior written authorization
    25  * or other dealings in this Software without prior written authorization
    26  * of the copyright holder.
    26  * of the copyright holder.
    27  */ 
    27  */ 
    28 
    28 
    29 #pragma ident	"@(#)tsolprotocol.c 1.14	06/09/19 SMI"
    29 #pragma ident	"@(#)tsolprotocol.c 1.15	06/10/06 SMI"
    30 
    30 
    31 #include <sys/param.h>
    31 #include <sys/param.h>
    32 #include <fcntl.h>
    32 #include <fcntl.h>
    33 #include <sys/types.h>
    33 #include <sys/types.h>
    34 #include <sys/stat.h>
    34 #include <sys/stat.h>
   176 
   176 
   177 Atom MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit);
   177 Atom MakeTSOLAtom(ClientPtr client, char *string, unsigned int len, Bool makeit);
   178 
   178 
   179 #define INITIAL_TSOL_NODELENGTH 1500
   179 #define INITIAL_TSOL_NODELENGTH 1500
   180 
   180 
       
   181 extern WindowPtr XYToWindow(int x, int y);
       
   182 extern WindowPtr AnyWindowOverlapsJustMe(WindowPtr pWin, 
       
   183 	WindowPtr pHead, BoxPtr box);
       
   184 
   181 extern Atom tsol_lastAtom;
   185 extern Atom tsol_lastAtom;
   182 extern int tsol_nodelength;
   186 extern int tsol_nodelength;
   183 extern TsolNodePtr tsol_node;
   187 extern TsolNodePtr tsol_node;
   184 extern int NumCurrentSelections;
   188 extern int NumCurrentSelections;
   185 extern Selection *CurrentSelections;
   189 extern Selection *CurrentSelections;
   186 extern WindowPtr tpwin;
   190 extern WindowPtr tpwin;
       
   191 extern int tsolMultiLevel;
   187 
   192 
   188 static int tsol_sel_agnt = -1; /* index this to CurrentSelection to get seln */
   193 static int tsol_sel_agnt = -1; /* index this to CurrentSelection to get seln */
   189 
   194 
   190 /*
   195 /*
   191  * Get number of atoms defined in the system
   196  * Get number of atoms defined in the system
  2815     {
  2820     {
  2816 	client->errorValue = format;
  2821 	client->errorValue = format;
  2817         return(BadValue);
  2822         return(BadValue);
  2818     }
  2823     }
  2819     SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess);
  2824     SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess);
  2820     if(pDraw->type == DRAWABLE_WINDOW)
  2825 
  2821     {
       
  2822 #ifdef TSOL
  2826 #ifdef TSOL
       
  2827     if (!xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, 
       
  2828 	    pDraw, client, TSOL_ALL, (void *)MAJOROP) &&
       
  2829 	(DrawableIsRoot(pDraw) || !tsolMultiLevel))
       
  2830     {
       
  2831 	return DoGetImage(client, format, drawable, x, y, 
       
  2832 		width, height, planemask, im_return);
       
  2833     }
       
  2834 
       
  2835     if (pDraw->type == DRAWABLE_WINDOW)
       
  2836     {
  2823         if (DrawableIsRoot(pDraw))
  2837         if (DrawableIsRoot(pDraw))
  2824         {
  2838         {
  2825             /* Get the actual window on which get image is done */
  2839             pWin = XYToWindow(x, y);
  2826 
       
  2827             pWin = XYToWindow( x, y);
       
  2828             if (!WindowIsRoot(pWin))
  2840             if (!WindowIsRoot(pWin))
  2829             {
  2841             {
  2830                 not_root_window = TRUE;
       
  2831                 pDrawtmp = &(pWin->parent->drawable);
  2842                 pDrawtmp = &(pWin->parent->drawable);
  2832                 if (((WindowPtr) pDrawtmp)->realized)
  2843                 if (((WindowPtr) pDrawtmp)->realized)
  2833                 {
  2844                 {
  2834                     pDraw = pDrawtmp;
  2845 		    int tmpx, tmpy;
  2835                     /*
  2846 
  2836                      * Adjust the coordinates only w.r.t the new drawable.
  2847                     tmpx = x - pDrawtmp->x;
  2837 		     * Adjusting width and height will cause incorrect
  2848                     tmpy = y - pDrawtmp->y;
  2838 		     * amount of data being returned to client.
  2849 
  2839                      */
  2850 		    /* requested area must be a subset of the window area */
  2840                     x -= pDraw->x;
  2851 		    if (tmpx >= 0 && tmpy >= 0 &&
  2841                     if (x < 0)
  2852 			width <= pDrawtmp->width &&
  2842                         x = 0;
  2853 			height <= pDrawtmp->height)
  2843                     y -= pDraw->y;
  2854 		    {
  2844                     if (y < 0)
  2855                         pDraw = pDrawtmp;
  2845                         y = 0;
  2856 			x = tmpx;
       
  2857 			y = tmpy;
       
  2858                 	not_root_window = TRUE;
       
  2859 		    }
  2846                 }
  2860                 }
  2847             }
  2861             }
  2848         }
  2862         }
  2849         else
  2863         else
  2850         {
  2864         {
  2854         if (not_root_window)
  2868         if (not_root_window)
  2855         {
  2869         {
  2856             Window   root;
  2870             Window   root;
  2857             WindowPtr tmpwin;
  2871             WindowPtr tmpwin;
  2858 
  2872 
       
  2873             not_root_window = TRUE;
  2859             tmpwin = (WindowPtr)LookupWindow(pDraw->id, client);
  2874             tmpwin = (WindowPtr)LookupWindow(pDraw->id, client);
  2860             while (tmpwin)
  2875             while (tmpwin)
  2861             {
  2876             {
  2862                 if (tmpwin->parent && WindowIsRoot(tmpwin->parent))
  2877                 if (tmpwin->parent && WindowIsRoot(tmpwin->parent))
  2863                 {
  2878                 {
  2878             pHead = pRoot->firstChild;
  2893             pHead = pRoot->firstChild;
  2879         }
  2894         }
  2880 
  2895 
  2881         if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, pDraw,
  2896         if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, pDraw,
  2882                          client, TSOL_ALL, (void *)MAJOROP))
  2897                          client, TSOL_ALL, (void *)MAJOROP))
  2883         {
       
  2884             /* Don't return error code. Return  contents  all zero */
       
  2885             getimage_ok = FALSE;
  2898             getimage_ok = FALSE;
  2886         }
  2899 	else
       
  2900             getimage_ok = TRUE;
       
  2901     }
  2887 #endif /* TSOL */
  2902 #endif /* TSOL */
       
  2903 
       
  2904     if(pDraw->type == DRAWABLE_WINDOW)
       
  2905     {
  2888 
  2906 
  2889       if( /* check for being viewable */
  2907       if( /* check for being viewable */
  2890 	 !((WindowPtr) pDraw)->realized ||
  2908 	 !((WindowPtr) pDraw)->realized ||
  2891 	  /* check for being on screen */
  2909 	  /* check for being on screen */
  2892          pDraw->x + x < 0 ||
  2910          pDraw->x + x < 0 ||
  2902 	    return(BadMatch);
  2920 	    return(BadMatch);
  2903 	xgi.visual = wVisual (((WindowPtr) pDraw));
  2921 	xgi.visual = wVisual (((WindowPtr) pDraw));
  2904     }
  2922     }
  2905     else
  2923     else
  2906     {
  2924     {
  2907 #ifdef TSOL
       
  2908         if (xtsol_policy(TSOL_RES_PIXEL, TSOL_READ, pDraw,
       
  2909                          client, TSOL_ALL, (void *)MAJOROP))
       
  2910         {
       
  2911             /* Don't return error code. Return  contents  all zero */
       
  2912             getimage_ok = FALSE;
       
  2913         }
       
  2914 #endif  /* TSOL */
       
  2915 
       
  2916       if(x < 0 ||
  2925       if(x < 0 ||
  2917          x+width > (int)pDraw->width ||
  2926          x+width > (int)pDraw->width ||
  2918          y < 0 ||
  2927          y < 0 ||
  2919          y+height > (int)pDraw->height
  2928          y+height > (int)pDraw->height
  2920         )
  2929         )