… | |
… | |
157 | # endif |
157 | # endif |
158 | |
158 | |
159 | # ifdef BG_IMAGE_FROM_FILE |
159 | # ifdef BG_IMAGE_FROM_FILE |
160 | if (have_image) |
160 | if (have_image) |
161 | { |
161 | { |
162 | if (h_align == rootAlign || v_align == rootAlign) |
162 | if (flags & rootAlign) |
163 | return true; |
163 | return true; |
164 | } |
164 | } |
165 | # endif |
165 | # endif |
166 | |
166 | |
167 | return false; |
167 | return false; |
… | |
… | |
207 | static inline bool |
207 | static inline bool |
208 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
208 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
209 | { |
209 | { |
210 | if (geom_flags & flag) |
210 | if (geom_flags & flag) |
211 | { |
211 | { |
212 | if (new_value != bgPixmap_t::rootAlign) |
|
|
213 | { |
|
|
214 | if (new_value < -100) |
212 | if (new_value < -100) |
215 | new_value = -100; |
213 | new_value = -100; |
216 | else if (new_value > 200) |
214 | else if (new_value > 200) |
217 | new_value = 200; |
215 | new_value = 200; |
218 | } |
|
|
219 | if (new_value != align) |
216 | if (new_value != align) |
220 | { |
217 | { |
221 | align = new_value; |
218 | align = new_value; |
222 | return true; |
219 | return true; |
223 | } |
220 | } |
… | |
… | |
235 | return diff * align / 100; |
232 | return diff * align / 100; |
236 | else if (align > 50 && align <= 100) |
233 | else if (align > 50 && align <= 100) |
237 | return window_size - image_size - diff * (100 - align) / 100; |
234 | return window_size - image_size - diff * (100 - align) / 100; |
238 | else if (align > 100 && align <= 200 ) |
235 | else if (align > 100 && align <= 200 ) |
239 | return ((align - 100) * smaller / 100) + window_size - smaller; |
236 | return ((align - 100) * smaller / 100) + window_size - smaller; |
240 | else if (align > -100 && align < 0) |
237 | else if (align >= -100 && align < 0) |
241 | return ((align + 100) * smaller / 100) - image_size; |
238 | return ((align + 100) * smaller / 100) - image_size; |
242 | return 0; |
239 | return 0; |
243 | } |
240 | } |
244 | |
241 | |
245 | static inline int |
242 | static inline int |
… | |
… | |
418 | x = y = centerAlign; |
415 | x = y = centerAlign; |
419 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
416 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
420 | } |
417 | } |
421 | else if (CHECK_GEOM_OPS ("root")) |
418 | else if (CHECK_GEOM_OPS ("root")) |
422 | { |
419 | { |
|
|
420 | new_flags |= rootAlign; |
423 | w = h = noScale; |
421 | w = h = noScale; |
424 | x = y = rootAlign; |
|
|
425 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
422 | geom_flags |= WidthValue|HeightValue; |
426 | } |
423 | } |
427 | # undef CHECK_GEOM_OPS |
424 | # undef CHECK_GEOM_OPS |
428 | |
425 | |
429 | while (*ops != ':' && *ops != '\0') ++ops; |
426 | while (*ops != ':' && *ops != '\0') ++ops; |
430 | } /* done parsing ops */ |
427 | } /* done parsing ops */ |
… | |
… | |
464 | { |
461 | { |
465 | w = h_scale * target_width / 100; |
462 | w = h_scale * target_width / 100; |
466 | h = v_scale * target_height / 100; |
463 | h = v_scale * target_height / 100; |
467 | } |
464 | } |
468 | |
465 | |
469 | if (h_align == rootAlign || v_align == rootAlign) |
466 | if (flags & rootAlign) |
470 | { |
467 | { |
471 | target->get_window_origin (x, y); |
468 | target->get_window_origin (x, y); |
472 | x = -x; |
469 | x = -x; |
473 | y = -y; |
470 | y = -y; |
474 | } |
471 | } |
475 | |
472 | else |
476 | if (h_align != rootAlign) |
473 | { |
477 | x = make_align_position (h_align, target_width, w > 0 ? w : image_width); |
474 | x = make_align_position (h_align, target_width, w > 0 ? w : image_width); |
478 | |
|
|
479 | if (v_align != rootAlign) |
|
|
480 | y = make_align_position (v_align, target_height, h > 0 ? h : image_height); |
475 | y = make_align_position (v_align, target_height, h > 0 ? h : image_height); |
|
|
476 | } |
481 | |
477 | |
482 | flags &= ~sizeSensitive; |
478 | flags &= ~sizeSensitive; |
483 | if (h_scale != 0 || v_scale != 0 |
479 | if (h_scale != 0 || v_scale != 0 |
484 | || h_align != 0 || v_align != 0 |
480 | || h_align != 0 || v_align != 0 |
485 | || image_width > target_width || image_height > target_height) |
481 | || image_width > target_width || image_height > target_height) |
… | |
… | |
1049 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1045 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1050 | return true; |
1046 | return true; |
1051 | } |
1047 | } |
1052 | |
1048 | |
1053 | return false; |
1049 | return false; |
|
|
1050 | } |
|
|
1051 | |
|
|
1052 | bool |
|
|
1053 | bgPixmap_t::tint_pixmap (Pixmap pixmap) |
|
|
1054 | { |
|
|
1055 | Window root = target->display->root; |
|
|
1056 | Display *dpy = target->dpy; |
|
|
1057 | int window_width = target->szHint.width; |
|
|
1058 | int window_height = target->szHint.height; |
|
|
1059 | bool ret = false; |
|
|
1060 | |
|
|
1061 | if (flags & tintWholesome) |
|
|
1062 | { |
|
|
1063 | XGCValues gcv; |
|
|
1064 | GC gc; |
|
|
1065 | |
|
|
1066 | /* In this case we can tint image server-side getting significant |
|
|
1067 | * performance improvements, as we eliminate XImage transfer |
|
|
1068 | */ |
|
|
1069 | gcv.foreground = Pixel (tint); |
|
|
1070 | gcv.function = GXand; |
|
|
1071 | gcv.fill_style = FillSolid; |
|
|
1072 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1073 | if (gc) |
|
|
1074 | { |
|
|
1075 | XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height); |
|
|
1076 | ret = true; |
|
|
1077 | XFreeGC (dpy, gc); |
|
|
1078 | } |
|
|
1079 | } |
|
|
1080 | else |
|
|
1081 | { |
|
|
1082 | # if XFT |
|
|
1083 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1084 | |
|
|
1085 | if (flags & tintSet) |
|
|
1086 | tint.get (c); |
|
|
1087 | |
|
|
1088 | if (shade > 0 && shade < 100) |
|
|
1089 | { |
|
|
1090 | c.r = (c.r * shade) / 100; |
|
|
1091 | c.g = (c.g * shade) / 100; |
|
|
1092 | c.b = (c.b * shade) / 100; |
|
|
1093 | } |
|
|
1094 | else if (shade > 100 && shade < 200) |
|
|
1095 | { |
|
|
1096 | c.r = (c.r * (200 - shade)) / 100; |
|
|
1097 | c.g = (c.g * (200 - shade)) / 100; |
|
|
1098 | c.b = (c.b * (200 - shade)) / 100; |
|
|
1099 | } |
|
|
1100 | |
|
|
1101 | XRenderPictFormat pf; |
|
|
1102 | pf.type = PictTypeDirect; |
|
|
1103 | pf.depth = 32; |
|
|
1104 | pf.direct.redMask = 0xff; |
|
|
1105 | pf.direct.greenMask = 0xff; |
|
|
1106 | pf.direct.blueMask = 0xff; |
|
|
1107 | pf.direct.alphaMask = 0xff; |
|
|
1108 | |
|
|
1109 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
1110 | (PictFormatType| |
|
|
1111 | PictFormatDepth| |
|
|
1112 | PictFormatRedMask| |
|
|
1113 | PictFormatGreenMask| |
|
|
1114 | PictFormatBlueMask| |
|
|
1115 | PictFormatAlphaMask), |
|
|
1116 | &pf, |
|
|
1117 | 0); |
|
|
1118 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
1119 | XRenderPictureAttributes pa; |
|
|
1120 | |
|
|
1121 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, root_format, 0, &pa); |
|
|
1122 | |
|
|
1123 | pa.repeat = True; |
|
|
1124 | |
|
|
1125 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1126 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1127 | XFreePixmap (dpy, overlay_pmap); |
|
|
1128 | |
|
|
1129 | pa.component_alpha = True; |
|
|
1130 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1131 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
1132 | XFreePixmap (dpy, mask_pmap); |
|
|
1133 | |
|
|
1134 | if (mask_pic && overlay_pic && back_pic) |
|
|
1135 | { |
|
|
1136 | XRenderColor mask_c; |
|
|
1137 | |
|
|
1138 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
1139 | mask_c.alpha = 0xffff; |
|
|
1140 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1141 | |
|
|
1142 | mask_c.alpha = 0; |
|
|
1143 | mask_c.red = 0xffff - c.r; |
|
|
1144 | mask_c.green = 0xffff - c.g; |
|
|
1145 | mask_c.blue = 0xffff - c.b; |
|
|
1146 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1147 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
1148 | ret = true; |
|
|
1149 | } |
|
|
1150 | |
|
|
1151 | XRenderFreePicture (dpy, mask_pic); |
|
|
1152 | XRenderFreePicture (dpy, overlay_pic); |
|
|
1153 | XRenderFreePicture (dpy, back_pic); |
|
|
1154 | # if DO_TIMING_TEST |
|
|
1155 | XSync (dpy, False); |
|
|
1156 | # endif |
|
|
1157 | # endif |
|
|
1158 | } |
|
|
1159 | |
|
|
1160 | return ret; |
1054 | } |
1161 | } |
1055 | |
1162 | |
1056 | /* make_transparency_pixmap() |
1163 | /* make_transparency_pixmap() |
1057 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1164 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1058 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
1165 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
… | |
… | |
1188 | { |
1295 | { |
1189 | if (!need_client_side_rendering ()) |
1296 | if (!need_client_side_rendering ()) |
1190 | { |
1297 | { |
1191 | if ((flags & tintNeeded)) |
1298 | if ((flags & tintNeeded)) |
1192 | { |
1299 | { |
1193 | if (flags & tintWholesome) |
1300 | if (tint_pixmap (tiled_root_pmap)) |
1194 | { |
|
|
1195 | /* In this case we can tint image server-side getting significant |
|
|
1196 | * performance improvements, as we eliminate XImage transfer |
|
|
1197 | */ |
|
|
1198 | gcv.foreground = Pixel (tint); |
|
|
1199 | gcv.function = GXand; |
|
|
1200 | gcv.fill_style = FillSolid; |
|
|
1201 | if (gc) |
|
|
1202 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1203 | else |
|
|
1204 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1205 | if (gc) |
|
|
1206 | { |
|
|
1207 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
1208 | result |= transpPmapTinted; |
1301 | result |= transpPmapTinted; |
1209 | } |
|
|
1210 | } |
|
|
1211 | else |
|
|
1212 | { |
|
|
1213 | # if XFT |
|
|
1214 | Picture back_pic = 0; |
|
|
1215 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1216 | |
|
|
1217 | if (flags & tintSet) |
|
|
1218 | tint.get (c); |
|
|
1219 | |
|
|
1220 | if (shade > 0 && shade < 100) |
|
|
1221 | { |
|
|
1222 | c.r = (c.r * shade) / 100; |
|
|
1223 | c.g = (c.g * shade) / 100; |
|
|
1224 | c.b = (c.b * shade) / 100; |
|
|
1225 | } |
|
|
1226 | else if (shade > 100 && shade < 200) |
|
|
1227 | { |
|
|
1228 | c.r = (c.r * (200 - shade)) / 100; |
|
|
1229 | c.g = (c.g * (200 - shade)) / 100; |
|
|
1230 | c.b = (c.b * (200 - shade)) / 100; |
|
|
1231 | } |
|
|
1232 | |
|
|
1233 | XRenderPictFormat pf; |
|
|
1234 | pf.type = PictTypeDirect; |
|
|
1235 | pf.depth = 32; |
|
|
1236 | pf.direct.redMask = 0xff; |
|
|
1237 | pf.direct.greenMask = 0xff; |
|
|
1238 | pf.direct.blueMask = 0xff; |
|
|
1239 | pf.direct.alphaMask = 0xff; |
|
|
1240 | |
|
|
1241 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
1242 | (PictFormatType| |
|
|
1243 | PictFormatDepth| |
|
|
1244 | PictFormatRedMask| |
|
|
1245 | PictFormatGreenMask| |
|
|
1246 | PictFormatBlueMask| |
|
|
1247 | PictFormatAlphaMask), |
|
|
1248 | &pf, |
|
|
1249 | 0); |
|
|
1250 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
1251 | XRenderPictureAttributes pa ; |
|
|
1252 | |
|
|
1253 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
|
|
1254 | |
|
|
1255 | pa.repeat = True; |
|
|
1256 | |
|
|
1257 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1258 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1259 | XFreePixmap (dpy, overlay_pmap); |
|
|
1260 | |
|
|
1261 | pa.component_alpha = True; |
|
|
1262 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1263 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
1264 | XFreePixmap (dpy, mask_pmap); |
|
|
1265 | |
|
|
1266 | if (mask_pic && overlay_pic && back_pic) |
|
|
1267 | { |
|
|
1268 | XRenderColor mask_c; |
|
|
1269 | |
|
|
1270 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
1271 | mask_c.alpha = 0xffff; |
|
|
1272 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1273 | |
|
|
1274 | mask_c.alpha = 0; |
|
|
1275 | mask_c.red = 0xffff - c.r; |
|
|
1276 | mask_c.green = 0xffff - c.g; |
|
|
1277 | mask_c.blue = 0xffff - c.b; |
|
|
1278 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1279 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
1280 | result |= transpPmapTinted; |
|
|
1281 | } |
|
|
1282 | |
|
|
1283 | XRenderFreePicture (dpy, mask_pic); |
|
|
1284 | XRenderFreePicture (dpy, overlay_pic); |
|
|
1285 | XRenderFreePicture (dpy, back_pic); |
|
|
1286 | # if DO_TIMING_TEST |
|
|
1287 | XSync (dpy, False); |
|
|
1288 | # endif |
|
|
1289 | # endif |
|
|
1290 | } |
|
|
1291 | } |
1302 | } |
1292 | } /* server side rendering completed */ |
1303 | } /* server side rendering completed */ |
1293 | |
1304 | |
1294 | if (pixmap) |
1305 | if (pixmap) |
1295 | XFreePixmap (dpy, pixmap); |
1306 | XFreePixmap (dpy, pixmap); |