Lines 764-769
meta_frames_unflicker_bg (MetaFrames *frames,
Link Here
|
764 |
set_background_none (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow); |
764 |
set_background_none (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow); |
765 |
} |
765 |
} |
766 |
|
766 |
|
|
|
767 |
#ifdef HAVE_SHAPE |
768 |
static void |
769 |
apply_cairo_region_to_window (Display *display, |
770 |
Window xwindow, |
771 |
cairo_region_t *region, |
772 |
int op) |
773 |
{ |
774 |
int n_rects, i; |
775 |
XRectangle *rects; |
776 |
|
777 |
n_rects = cairo_region_num_rectangles (region); |
778 |
rects = g_new (XRectangle, n_rects); |
779 |
|
780 |
for (i = 0; i < n_rects; i++) |
781 |
{ |
782 |
cairo_rectangle_int_t rect; |
783 |
|
784 |
cairo_region_get_rectangle (region, i, &rect); |
785 |
|
786 |
rects[i].x = rect.x; |
787 |
rects[i].y = rect.y; |
788 |
rects[i].width = rect.width; |
789 |
rects[i].height = rect.height; |
790 |
} |
791 |
|
792 |
XShapeCombineRectangles (display, xwindow, |
793 |
ShapeBounding, 0, 0, rects, n_rects, |
794 |
ShapeSet, YXBanded); |
795 |
|
796 |
g_free (rects); |
797 |
} |
798 |
#endif |
799 |
|
767 |
void |
800 |
void |
768 |
meta_frames_apply_shapes (MetaFrames *frames, |
801 |
meta_frames_apply_shapes (MetaFrames *frames, |
769 |
Window xwindow, |
802 |
Window xwindow, |
Lines 775-783
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
775 |
/* Apply shapes as if window had new_window_width, new_window_height */ |
808 |
/* Apply shapes as if window had new_window_width, new_window_height */ |
776 |
MetaUIFrame *frame; |
809 |
MetaUIFrame *frame; |
777 |
MetaFrameGeometry fgeom; |
810 |
MetaFrameGeometry fgeom; |
778 |
XRectangle xrect; |
811 |
cairo_rectangle_int_t rect; |
779 |
Region corners_xregion; |
812 |
cairo_region_t *corners_region; |
780 |
Region window_xregion; |
813 |
cairo_region_t *window_region; |
781 |
Display *display; |
814 |
Display *display; |
782 |
|
815 |
|
783 |
frame = meta_frames_lookup_window (frames, xwindow); |
816 |
frame = meta_frames_lookup_window (frames, xwindow); |
Lines 813-819
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
813 |
return; /* nothing to do */ |
846 |
return; /* nothing to do */ |
814 |
} |
847 |
} |
815 |
|
848 |
|
816 |
corners_xregion = XCreateRegion (); |
849 |
corners_region = cairo_region_create (); |
817 |
|
850 |
|
818 |
if (fgeom.top_left_corner_rounded_radius != 0) |
851 |
if (fgeom.top_left_corner_rounded_radius != 0) |
819 |
{ |
852 |
{ |
Lines 824-835
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
824 |
for (i=0; i<corner; i++) |
857 |
for (i=0; i<corner; i++) |
825 |
{ |
858 |
{ |
826 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
859 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
827 |
xrect.x = 0; |
860 |
rect.x = 0; |
828 |
xrect.y = i; |
861 |
rect.y = i; |
829 |
xrect.width = width; |
862 |
rect.width = width; |
830 |
xrect.height = 1; |
863 |
rect.height = 1; |
831 |
|
864 |
|
832 |
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); |
865 |
cairo_region_union_rectangle (corners_region, &rect); |
833 |
} |
866 |
} |
834 |
} |
867 |
} |
835 |
|
868 |
|
Lines 842-853
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
842 |
for (i=0; i<corner; i++) |
875 |
for (i=0; i<corner; i++) |
843 |
{ |
876 |
{ |
844 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
877 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
845 |
xrect.x = new_window_width - width; |
878 |
rect.x = new_window_width - width; |
846 |
xrect.y = i; |
879 |
rect.y = i; |
847 |
xrect.width = width; |
880 |
rect.width = width; |
848 |
xrect.height = 1; |
881 |
rect.height = 1; |
849 |
|
882 |
|
850 |
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); |
883 |
cairo_region_union_rectangle (corners_region, &rect); |
851 |
} |
884 |
} |
852 |
} |
885 |
} |
853 |
|
886 |
|
Lines 860-871
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
860 |
for (i=0; i<corner; i++) |
893 |
for (i=0; i<corner; i++) |
861 |
{ |
894 |
{ |
862 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
895 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
863 |
xrect.x = 0; |
896 |
rect.x = 0; |
864 |
xrect.y = new_window_height - i - 1; |
897 |
rect.y = new_window_height - i - 1; |
865 |
xrect.width = width; |
898 |
rect.width = width; |
866 |
xrect.height = 1; |
899 |
rect.height = 1; |
867 |
|
900 |
|
868 |
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); |
901 |
cairo_region_union_rectangle (corners_region, &rect); |
869 |
} |
902 |
} |
870 |
} |
903 |
} |
871 |
|
904 |
|
Lines 878-904
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
878 |
for (i=0; i<corner; i++) |
911 |
for (i=0; i<corner; i++) |
879 |
{ |
912 |
{ |
880 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
913 |
const int width = floor(0.5 + radius - sqrt(radius*radius - (radius-(i+0.5))*(radius-(i+0.5)))); |
881 |
xrect.x = new_window_width - width; |
914 |
rect.x = new_window_width - width; |
882 |
xrect.y = new_window_height - i - 1; |
915 |
rect.y = new_window_height - i - 1; |
883 |
xrect.width = width; |
916 |
rect.width = width; |
884 |
xrect.height = 1; |
917 |
rect.height = 1; |
885 |
|
918 |
|
886 |
XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); |
919 |
cairo_region_union_rectangle (corners_region, &rect); |
887 |
} |
920 |
} |
888 |
} |
921 |
} |
889 |
|
922 |
|
890 |
window_xregion = XCreateRegion (); |
923 |
window_region = cairo_region_create (); |
891 |
|
924 |
|
892 |
xrect.x = 0; |
925 |
rect.x = 0; |
893 |
xrect.y = 0; |
926 |
rect.y = 0; |
894 |
xrect.width = new_window_width; |
927 |
rect.width = new_window_width; |
895 |
xrect.height = new_window_height; |
928 |
rect.height = new_window_height; |
896 |
|
929 |
|
897 |
XUnionRectWithRegion (&xrect, window_xregion, window_xregion); |
930 |
cairo_region_union_rectangle (window_region, &rect); |
898 |
|
931 |
|
899 |
XSubtractRegion (window_xregion, corners_xregion, window_xregion); |
932 |
cairo_region_subtract (window_region, corners_region); |
900 |
|
933 |
|
901 |
XDestroyRegion (corners_xregion); |
934 |
cairo_region_destroy (corners_region); |
902 |
|
935 |
|
903 |
if (window_has_shape) |
936 |
if (window_has_shape) |
904 |
{ |
937 |
{ |
Lines 911-917
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
911 |
XSetWindowAttributes attrs; |
944 |
XSetWindowAttributes attrs; |
912 |
Window shape_window; |
945 |
Window shape_window; |
913 |
Window client_window; |
946 |
Window client_window; |
914 |
Region client_xregion; |
947 |
cairo_region_t *client_region; |
915 |
GdkScreen *screen; |
948 |
GdkScreen *screen; |
916 |
int screen_number; |
949 |
int screen_number; |
917 |
|
950 |
|
Lines 951-971
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
951 |
/* Punch the client area out of the normal frame shape, |
984 |
/* Punch the client area out of the normal frame shape, |
952 |
* then union it with the shape_window's existing shape |
985 |
* then union it with the shape_window's existing shape |
953 |
*/ |
986 |
*/ |
954 |
client_xregion = XCreateRegion (); |
987 |
client_region = cairo_region_create (); |
955 |
|
988 |
|
956 |
xrect.x = fgeom.left_width; |
989 |
rect.x = fgeom.left_width; |
957 |
xrect.y = fgeom.top_height; |
990 |
rect.y = fgeom.top_height; |
958 |
xrect.width = new_window_width - fgeom.right_width - xrect.x; |
991 |
rect.width = new_window_width - fgeom.right_width - rect.x; |
959 |
xrect.height = new_window_height - fgeom.bottom_height - xrect.y; |
992 |
rect.height = new_window_height - fgeom.bottom_height - rect.y; |
960 |
|
993 |
|
961 |
XUnionRectWithRegion (&xrect, client_xregion, client_xregion); |
994 |
cairo_region_union_rectangle (client_region, &rect); |
962 |
|
995 |
|
963 |
XSubtractRegion (window_xregion, client_xregion, window_xregion); |
996 |
cairo_region_subtract (window_region, client_region); |
964 |
|
997 |
|
965 |
XDestroyRegion (client_xregion); |
998 |
cairo_region_destroy (client_region); |
966 |
|
999 |
|
967 |
XShapeCombineRegion (display, shape_window, |
1000 |
apply_cairo_region_to_window (display, shape_window, |
968 |
ShapeBounding, 0, 0, window_xregion, ShapeUnion); |
1001 |
window_region, ShapeUnion); |
969 |
|
1002 |
|
970 |
/* Now copy shape_window shape to the real frame */ |
1003 |
/* Now copy shape_window shape to the real frame */ |
971 |
XShapeCombineShape (display, frame->xwindow, ShapeBounding, |
1004 |
XShapeCombineShape (display, frame->xwindow, ShapeBounding, |
Lines 984-996
meta_frames_apply_shapes (MetaFrames *frames,
Link Here
|
984 |
"Frame 0x%lx has shaped corners\n", |
1017 |
"Frame 0x%lx has shaped corners\n", |
985 |
frame->xwindow); |
1018 |
frame->xwindow); |
986 |
|
1019 |
|
987 |
XShapeCombineRegion (display, frame->xwindow, |
1020 |
apply_cairo_region_to_window (display, frame->xwindow, |
988 |
ShapeBounding, 0, 0, window_xregion, ShapeSet); |
1021 |
window_region, ShapeSet); |
989 |
} |
1022 |
} |
990 |
|
1023 |
|
991 |
frame->shape_applied = TRUE; |
1024 |
frame->shape_applied = TRUE; |
992 |
|
1025 |
|
993 |
XDestroyRegion (window_xregion); |
1026 |
cairo_region_destroy (window_region); |
994 |
#endif /* HAVE_SHAPE */ |
1027 |
#endif /* HAVE_SHAPE */ |
995 |
} |
1028 |
} |
996 |
|
1029 |
|
997 |
- |
|
|