150 extern uint32_t list_length(); |
150 extern uint32_t list_length(); |
151 */ |
151 */ |
152 |
152 |
153 /* Prototype Declarations for Static Functions */ |
153 /* Prototype Declarations for Static Functions */ |
154 static void TransferImage( |
154 static void TransferImage( |
155 #if NeedFunctionPrototypes |
|
156 Display *, XImage *,int32_t, int32_t , image_region_type*, |
155 Display *, XImage *,int32_t, int32_t , image_region_type*, |
157 XImage *,int32_t ,int32_t |
156 XImage *,int32_t ,int32_t |
158 #endif |
|
159 ); |
157 ); |
160 static XImage * ReadRegionsInList( |
158 static XImage * ReadRegionsInList( |
161 #if NeedFunctionPrototypes |
|
162 Display *, Visual *, int32_t ,int32_t ,int32_t , |
159 Display *, Visual *, int32_t ,int32_t ,int32_t , |
163 int32_t , XRectangle, list_ptr |
160 int32_t , XRectangle, list_ptr |
164 #endif |
|
165 ); |
161 ); |
166 |
162 |
167 static list_ptr make_region_list( |
163 static list_ptr make_region_list( |
168 #if NeedFunctionPrototypes |
|
169 Display*, Window, XRectangle*, |
164 Display*, Window, XRectangle*, |
170 int32_t*, int32_t, XVisualInfo**, int32_t * |
165 int32_t*, int32_t, XVisualInfo**, int32_t * |
171 #endif |
|
172 ); |
166 ); |
173 |
167 |
174 static void destroy_region_list( |
168 static void destroy_region_list( |
175 #if NeedFunctionPrototypes |
|
176 list_ptr |
169 list_ptr |
177 #endif |
|
178 ) ; |
170 ) ; |
179 static void subtr_rect_from_image_region( |
171 static void subtr_rect_from_image_region( |
180 #if NeedFunctionPrototypes |
|
181 image_region_type *, int32_t , int32_t , int32_t , int32_t |
172 image_region_type *, int32_t , int32_t , int32_t , int32_t |
182 #endif |
|
183 ); |
173 ); |
184 static void add_rect_to_image_region( |
174 static void add_rect_to_image_region( |
185 #if NeedFunctionPrototypes |
|
186 image_region_type *, |
175 image_region_type *, |
187 int32_t , int32_t , int32_t , int32_t |
176 int32_t , int32_t , int32_t , int32_t |
188 #endif |
|
189 ); |
177 ); |
190 static int32_t src_in_region_list( |
178 static int32_t src_in_region_list( |
191 #if NeedFunctionPrototypes |
|
192 image_win_type *, list_ptr |
179 image_win_type *, list_ptr |
193 #endif |
|
194 ); |
180 ); |
195 static void add_window_to_list( |
181 static void add_window_to_list( |
196 #if NeedFunctionPrototypes |
|
197 list_ptr, Window, int32_t, int32_t , |
182 list_ptr, Window, int32_t, int32_t , |
198 int32_t , int32_t , int32_t , int32_t, int32_t, |
183 int32_t , int32_t , int32_t , int32_t, int32_t, |
199 Visual*, Colormap, Window |
184 Visual*, Colormap, Window |
200 #endif |
|
201 ); |
185 ); |
202 static int32_t src_in_image( |
186 static int32_t src_in_image( |
203 #if NeedFunctionPrototypes |
|
204 image_win_type *, int32_t , XVisualInfo** |
187 image_win_type *, int32_t , XVisualInfo** |
205 #endif |
|
206 ); |
188 ); |
207 static int32_t src_in_overlay( |
189 static int32_t src_in_overlay( |
208 #if NeedFunctionPrototypes |
|
209 image_region_type *, int32_t, OverlayInfo *, int32_t*, int32_t* |
190 image_region_type *, int32_t, OverlayInfo *, int32_t*, int32_t* |
210 #endif |
|
211 ); |
191 ); |
212 |
192 |
213 /* End of Prototype Declarations */ |
193 /* End of Prototype Declarations */ |
214 |
194 |
215 void initFakeVisual(Vis) |
195 void initFakeVisual(Visual *Vis) |
216 Visual *Vis ; |
|
217 { |
196 { |
218 Vis->ext_data=NULL; |
197 Vis->ext_data=NULL; |
219 Vis->class = DirectColor ; |
198 Vis->class = DirectColor ; |
220 Vis->red_mask = 0x00FF0000; |
199 Vis->red_mask = 0x00FF0000; |
221 Vis->green_mask = 0x0000FF00 ; |
200 Vis->green_mask = 0x0000FF00 ; |
226 |
205 |
227 /* QueryColorMap has been moved into robot_common.c so it can be used by |
206 /* QueryColorMap has been moved into robot_common.c so it can be used by |
228 * awt_DataTransferer.c as well. |
207 * awt_DataTransferer.c as well. |
229 */ |
208 */ |
230 |
209 |
|
210 |
|
211 /* |
|
212 * srcRootWinid: root win on which grab was done |
|
213 * x, y: root rel UL corner of bounding box of grab |
|
214 * width, height: size of bounding box of grab |
|
215 * vis_regions: list of regions to read from |
|
216 */ |
231 int32_t |
217 int32_t |
232 GetMultiVisualRegions(disp,srcRootWinid, x, y, width, height, |
218 GetMultiVisualRegions( |
233 transparentOverlays,numVisuals, pVisuals,numOverlayVisuals, pOverlayVisuals, |
219 Display *disp, |
234 numImageVisuals, pImageVisuals,vis_regions,vis_image_regions,allImage) |
220 Window srcRootWinid, |
235 Display *disp; |
221 int32_t x, |
236 Window srcRootWinid; /* root win on which grab was done */ |
222 int32_t y, |
237 int32_t x; /* root rel UL corner of bounding box of grab */ |
223 uint32_t width, |
238 int32_t y; |
224 uint32_t height, |
239 uint32_t width; /* size of bounding box of grab */ |
225 int32_t *transparentOverlays, |
240 uint32_t height; |
226 int32_t *numVisuals, |
241 int32_t *transparentOverlays ; |
227 XVisualInfo **pVisuals, |
242 int32_t *numVisuals; |
228 int32_t *numOverlayVisuals, |
243 XVisualInfo **pVisuals; |
229 OverlayInfo **pOverlayVisuals, |
244 int32_t *numOverlayVisuals; |
230 int32_t *numImageVisuals, |
245 OverlayInfo **pOverlayVisuals; |
231 XVisualInfo ***pImageVisuals, |
246 int32_t *numImageVisuals; |
232 list_ptr *vis_regions, |
247 XVisualInfo ***pImageVisuals; |
233 list_ptr *vis_image_regions, |
248 list_ptr *vis_regions; /* list of regions to read from */ |
234 int32_t *allImage |
249 list_ptr *vis_image_regions ; |
235 ) |
250 int32_t *allImage ; |
|
251 { |
236 { |
252 int32_t hasNonDefault; |
237 int32_t hasNonDefault; |
253 XRectangle bbox; /* bounding box of grabbed area */ |
238 XRectangle bbox; /* bounding box of grabbed area */ |
254 |
239 |
255 |
240 |
288 (*vis_image_regions)->next->next ) ) return 1 ; |
273 (*vis_image_regions)->next->next ) ) return 1 ; |
289 else return 0 ; |
274 else return 0 ; |
290 |
275 |
291 } |
276 } |
292 |
277 |
293 static void TransferImage(disp,reg_image,srcw,srch,reg, |
278 static void TransferImage( |
294 target_image,dst_x,dst_y) |
279 Display *disp, XImage *reg_image, |
295 Display *disp; |
280 int32_t srcw, int32_t srch, |
296 XImage *reg_image,*target_image ; |
281 image_region_type *reg, XImage *target_image, |
297 image_region_type *reg; |
282 int32_t dst_x, int32_t dst_y) |
298 int32_t srcw,srch,dst_x , dst_y ; |
|
299 { |
283 { |
300 int32_t ncolors; |
284 int32_t ncolors; |
301 int32_t i,j,old_pixel,new_pixel,red_ind,green_ind,blue_ind ; |
285 int32_t i,j,old_pixel,new_pixel,red_ind,green_ind,blue_ind ; |
302 XColor *colors; |
286 XColor *colors; |
303 int32_t rShift,gShift,bShift; |
287 int32_t rShift,gShift,bShift; |
444 |
434 |
445 |
435 |
446 /** ------------------------------------------------------------------------ |
436 /** ------------------------------------------------------------------------ |
447 ------------------------------------------------------------------------ **/ |
437 ------------------------------------------------------------------------ **/ |
448 |
438 |
449 XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, |
439 /* |
450 numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,numImageVisuals, |
440 * srcRootWinid: root win on which grab was done |
451 pImageVisuals,vis_regions,vis_image_regions,format,allImage) |
441 * x, y: root rel UL corner of bounding box of grab |
452 Display *disp; |
442 * width, height: size of bounding box of grab |
453 Window srcRootWinid; /* root win on which grab was done */ |
443 * vis_regions: list of regions to read from |
454 int32_t x; /* root rel UL corner of bounding box of grab */ |
444 * vis_image_regions: list of regions to read from |
455 int32_t y; |
445 */ |
456 uint32_t width; /* size of bounding box of grab */ |
446 XImage *ReadAreaToImage( |
457 uint32_t height; |
447 Display *disp, |
458 /** int32_t transparentOverlays; ***/ |
448 Window srcRootWinid, |
459 int32_t numVisuals; |
449 int32_t x, |
460 XVisualInfo *pVisuals; |
450 int32_t y, |
461 int32_t numOverlayVisuals; |
451 uint32_t width, |
462 OverlayInfo *pOverlayVisuals; |
452 uint32_t height, |
463 int32_t numImageVisuals; |
453 int32_t numVisuals, |
464 XVisualInfo **pImageVisuals; |
454 XVisualInfo *pVisuals, |
465 list_ptr vis_regions; /* list of regions to read from */ |
455 int32_t numOverlayVisuals, |
466 list_ptr vis_image_regions ;/* list of regions to read from */ |
456 OverlayInfo *pOverlayVisuals, |
467 int32_t format; |
457 int32_t numImageVisuals, |
468 int32_t allImage ; |
458 XVisualInfo **pImageVisuals, |
|
459 list_ptr vis_regions, |
|
460 list_ptr vis_image_regions , |
|
461 int32_t format, |
|
462 int32_t allImage |
|
463 ) |
469 { |
464 { |
470 image_region_type *reg; |
465 image_region_type *reg; |
471 XRectangle bbox; /* bounding box of grabbed area */ |
466 XRectangle bbox; /* bounding box of grabbed area */ |
472 int32_t depth ; |
467 int32_t depth ; |
473 XImage *ximage, *ximage_ipm ; |
468 XImage *ximage, *ximage_ipm ; |
637 different visual than their parents. The function is recursive. |
632 different visual than their parents. The function is recursive. |
638 This list is used in make_region_list(), which coalesces the |
633 This list is used in make_region_list(), which coalesces the |
639 windows with the same visual into a region. |
634 windows with the same visual into a region. |
640 image_wins must point to an existing list struct that's already |
635 image_wins must point to an existing list struct that's already |
641 been zeroed (zero_list()). |
636 been zeroed (zero_list()). |
642 ------------------------------------------------------------------------ **/ |
637 |
643 static void make_src_list( disp, image_wins, bbox, curr, x_rootrel, y_rootrel, |
638 bbox: bnding box of area we want |
644 curr_attrs, pclip) |
639 x_rootrel, y_rootrel: pos of curr WRT root |
645 Display *disp; |
640 pclip: visible part of curr, not obscurred by ancestors |
646 list_ptr image_wins; |
641 ------------------------------------------------------------------------ **/ |
647 XRectangle *bbox; /* bnding box of area we want */ |
642 static void make_src_list( |
648 Window curr; |
643 Display *disp, |
649 int32_t x_rootrel; /* pos of curr WRT root */ |
644 list_ptr image_wins, |
650 int32_t y_rootrel; |
645 XRectangle *bbox, |
651 XWindowAttributes *curr_attrs; |
646 Window curr, |
652 XRectangle *pclip; /* visible part of curr, not */ |
647 int32_t x_rootrel, |
653 /* obscurred by ancestors */ |
648 int32_t y_rootrel, |
|
649 XWindowAttributes *curr_attrs, |
|
650 XRectangle *pclip |
|
651 ) |
654 { |
652 { |
655 XWindowAttributes child_attrs; |
653 XWindowAttributes child_attrs; |
656 Window root, parent, *child; /* variables for XQueryTree() */ |
654 Window root, parent, *child; /* variables for XQueryTree() */ |
657 Window *save_child_list; /* variables for XQueryTree() */ |
655 Window *save_child_list; /* variables for XQueryTree() */ |
658 uint32_t nchild; /* variables for XQueryTree() */ |
656 uint32_t nchild; /* variables for XQueryTree() */ |
735 which are drawn with the same visual. For example, if the |
733 which are drawn with the same visual. For example, if the |
736 window consists of subwindows of two different visual types, |
734 window consists of subwindows of two different visual types, |
737 there will be two regions in the list. |
735 there will be two regions in the list. |
738 Returns a pointer to the list. |
736 Returns a pointer to the list. |
739 ------------------------------------------------------------------------ **/ |
737 ------------------------------------------------------------------------ **/ |
740 static list_ptr make_region_list( disp, win, bbox, hasNonDefault, |
738 static list_ptr make_region_list( |
741 numImageVisuals, pImageVisuals, allImage) |
739 Display *disp, |
742 Display *disp; |
740 Window win, |
743 Window win; |
741 XRectangle *bbox, |
744 XRectangle *bbox; |
742 int32_t *hasNonDefault, |
745 int32_t *hasNonDefault; |
743 int32_t numImageVisuals, |
746 int32_t numImageVisuals; |
744 XVisualInfo **pImageVisuals, |
747 XVisualInfo **pImageVisuals; |
745 int32_t *allImage |
748 int32_t *allImage; |
746 ) |
749 { |
747 { |
750 XWindowAttributes win_attrs; |
748 XWindowAttributes win_attrs; |
751 list image_wins; |
749 list image_wins; |
752 list_ptr image_regions; |
750 list_ptr image_regions; |
753 list_ptr srcs_left; |
751 list_ptr srcs_left; |
838 return image_regions; |
836 return image_regions; |
839 } |
837 } |
840 /** ------------------------------------------------------------------------ |
838 /** ------------------------------------------------------------------------ |
841 Destructor called from destroy_region_list(). |
839 Destructor called from destroy_region_list(). |
842 ------------------------------------------------------------------------ **/ |
840 ------------------------------------------------------------------------ **/ |
843 void destroy_image_region( image_region) |
841 void destroy_image_region(image_region_type *image_region) |
844 image_region_type *image_region; |
|
845 { |
842 { |
846 XDestroyRegion( image_region->visible_region); |
843 XDestroyRegion( image_region->visible_region); |
847 free( (void *) image_region); |
844 free( (void *) image_region); |
848 } |
845 } |
849 |
846 |
850 /** ------------------------------------------------------------------------ |
847 /** ------------------------------------------------------------------------ |
851 Destroys the region list, destroying all the regions contained in it. |
848 Destroys the region list, destroying all the regions contained in it. |
852 ------------------------------------------------------------------------ **/ |
849 ------------------------------------------------------------------------ **/ |
853 static void destroy_region_list( rlist) |
850 static void destroy_region_list(list_ptr rlist) |
854 list_ptr rlist; |
|
855 { |
851 { |
856 delete_list_destroying( rlist, (DESTRUCT_FUNC_PTR)destroy_image_region); |
852 delete_list_destroying( rlist, (DESTRUCT_FUNC_PTR)destroy_image_region); |
857 } |
853 } |
858 |
854 |
859 |
855 |
988 |
985 |
989 /** ------------------------------------------------------------------------ |
986 /** ------------------------------------------------------------------------ |
990 Returns TRUE if the given src's visual is in the overlay planes |
987 Returns TRUE if the given src's visual is in the overlay planes |
991 and transparency is possible, FALSE otherwise. |
988 and transparency is possible, FALSE otherwise. |
992 ------------------------------------------------------------------------ **/ |
989 ------------------------------------------------------------------------ **/ |
993 static int32_t src_in_overlay( src, numOverlayVisuals, pOverlayVisuals, |
990 static int32_t src_in_overlay( |
994 transparentColor, transparentType) |
991 image_region_type *src, |
995 image_region_type *src; |
992 int32_t numOverlayVisuals, |
996 int32_t numOverlayVisuals; |
993 OverlayInfo *pOverlayVisuals, |
997 OverlayInfo *pOverlayVisuals; |
994 int32_t *transparentColor, |
998 int32_t *transparentColor; |
995 int32_t *transparentType |
999 int32_t *transparentType; |
996 ) |
1000 { |
997 { |
1001 int32_t i; |
998 int32_t i; |
1002 |
999 |
1003 for (i = 0 ; i < numOverlayVisuals ; i++) |
1000 for (i = 0 ; i < numOverlayVisuals ; i++) |
1004 { |
1001 { |
1060 * overlay or image visual. |
1057 * overlay or image visual. |
1061 * |
1058 * |
1062 * If the routine sucessfully obtained the visual information, it returns zero. |
1059 * If the routine sucessfully obtained the visual information, it returns zero. |
1063 * If the routine didn't obtain the visual information, it returns non-zero. |
1060 * If the routine didn't obtain the visual information, it returns non-zero. |
1064 * |
1061 * |
|
1062 * display: Which X server (aka "display"). |
|
1063 * screen: Which screen of the "display". |
|
1064 * transparentOverlays: Non-zero if there's at least one overlay visual and if |
|
1065 * at least one of those supports a transparent pixel. |
|
1066 * numVisuals: Number of XVisualInfo struct's pointed to by pVisuals. |
|
1067 * pVisuals: All of the device's visuals. |
|
1068 * numOverlayVisuals: Number of OverlayInfo's pointed to by pOverlayVisuals. |
|
1069 * If this number is zero, the device does not have overlay planes. |
|
1070 * pOverlayVisuals: The device's overlay plane visual information. |
|
1071 * numImageVisuals: Number of XVisualInfo's pointed to by pImageVisuals. |
|
1072 * pImageVisuals: The device's image visuals. |
|
1073 * |
1065 ******************************************************************************/ |
1074 ******************************************************************************/ |
1066 |
1075 |
1067 int32_t GetXVisualInfo(display, screen, transparentOverlays, |
1076 int32_t GetXVisualInfo( |
1068 numVisuals, pVisuals, |
1077 Display *display, |
1069 numOverlayVisuals, pOverlayVisuals, |
1078 int32_t screen, |
1070 numImageVisuals, pImageVisuals) |
1079 int32_t *transparentOverlays, |
1071 |
1080 int32_t *numVisuals, |
1072 Display *display; /* Which X server (aka "display"). */ |
1081 XVisualInfo **pVisuals, |
1073 int32_t screen; /* Which screen of the "display". */ |
1082 int32_t *numOverlayVisuals, |
1074 int32_t *transparentOverlays; /* Non-zero if there's at least one |
1083 OverlayInfo **pOverlayVisuals, |
1075 * overlay visual and if at least one |
1084 int32_t *numImageVisuals, |
1076 * of those supports a transparent |
1085 XVisualInfo ***pImageVisuals |
1077 * pixel. */ |
1086 ) |
1078 int32_t *numVisuals; /* Number of XVisualInfo struct's |
|
1079 * pointed to by pVisuals. */ |
|
1080 XVisualInfo **pVisuals; /* All of the device's visuals. */ |
|
1081 int32_t *numOverlayVisuals; /* Number of OverlayInfo's pointed |
|
1082 * to by pOverlayVisuals. If this |
|
1083 * number is zero, the device does |
|
1084 * not have overlay planes. */ |
|
1085 OverlayInfo **pOverlayVisuals; /* The device's overlay plane visual |
|
1086 * information. */ |
|
1087 int32_t *numImageVisuals; /* Number of XVisualInfo's pointed |
|
1088 * to by pImageVisuals. */ |
|
1089 XVisualInfo ***pImageVisuals; /* The device's image visuals. */ |
|
1090 { |
1087 { |
1091 XVisualInfo getVisInfo; /* Parameters of XGetVisualInfo */ |
1088 XVisualInfo getVisInfo; /* Parameters of XGetVisualInfo */ |
1092 int32_t mask; |
1089 int32_t mask; |
1093 XVisualInfo *pVis, **pIVis; /* Faster, local copies */ |
1090 XVisualInfo *pVis, **pIVis; /* Faster, local copies */ |
1094 OverlayInfo *pOVis; |
1091 OverlayInfo *pOVis; |