… | |
… | |
46 | * W and H are percentages of the terminal window size. |
46 | * W and H are percentages of the terminal window size. |
47 | * X and Y are also percentages; e.g., +50+50 centers |
47 | * X and Y are also percentages; e.g., +50+50 centers |
48 | * the image in the window. |
48 | * the image in the window. |
49 | * |
49 | * |
50 | * Pixmap Operations : (should be prepended by a colon) |
50 | * Pixmap Operations : (should be prepended by a colon) |
51 | * tile Tile image. Scaling/position modifiers above will affect |
|
|
52 | * the tile size and origin. |
|
|
53 | * propscale When scaling, scale proportionally. That is, maintain the |
|
|
54 | * proper aspect ratio for the image. Any portion of the |
|
|
55 | * background not covered by the image is filled with the |
|
|
56 | * current background color. |
|
|
57 | * scale Scale both up and down |
|
|
58 | */ |
51 | */ |
59 | |
52 | |
60 | #ifdef HAVE_BG_PIXMAP |
53 | #ifdef HAVE_BG_PIXMAP |
61 | void |
54 | void |
62 | rxvt_term::bg_destroy () |
55 | rxvt_term::bg_destroy () |
… | |
… | |
204 | { |
197 | { |
205 | bool changed = false; |
198 | bool changed = false; |
206 | int geom_flags = 0; |
199 | int geom_flags = 0; |
207 | int x = 0, y = 0; |
200 | int x = 0, y = 0; |
208 | unsigned int w = 0, h = 0; |
201 | unsigned int w = 0, h = 0; |
209 | unsigned int n; |
|
|
210 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
202 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
211 | const char *ops; |
|
|
212 | |
203 | |
213 | if (geom == NULL) |
204 | if (geom == NULL) |
214 | return false; |
205 | return false; |
215 | |
206 | |
216 | char str[256]; |
207 | if (geom[0]) |
217 | |
|
|
218 | ops = strchr (geom, ':'); |
|
|
219 | if (ops == NULL) |
|
|
220 | n = strlen (geom); |
|
|
221 | else |
|
|
222 | n = ops - geom; |
|
|
223 | |
|
|
224 | if (n >= sizeof (str)) |
|
|
225 | return false; |
|
|
226 | |
|
|
227 | memcpy (str, geom, n); |
|
|
228 | str[n] = '\0'; |
|
|
229 | rxvt_strtrim (str); |
|
|
230 | |
|
|
231 | if (str[0]) |
|
|
232 | { |
208 | { |
233 | /* we have geometry string - let's handle it prior to applying ops */ |
209 | char **arr = rxvt_strsplit (':', geom); |
|
|
210 | |
|
|
211 | for (int i = 0; arr[i]; i++) |
|
|
212 | { |
|
|
213 | if (!strcasecmp (arr[i], "style=tiled")) |
|
|
214 | { |
|
|
215 | new_flags = BG_TILE; |
|
|
216 | w = h = noScale; |
|
|
217 | x = y = 0; |
|
|
218 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
219 | } |
|
|
220 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
|
|
221 | { |
|
|
222 | new_flags = BG_PROP_SCALE; |
|
|
223 | x = y = centerAlign; |
|
|
224 | geom_flags = XValue|YValue; |
|
|
225 | } |
|
|
226 | else if (!strcasecmp (arr[i], "style=stretched")) |
|
|
227 | { |
|
|
228 | new_flags = 0; |
|
|
229 | w = h = windowScale; |
|
|
230 | geom_flags = WidthValue|HeightValue; |
|
|
231 | } |
|
|
232 | else if (!strcasecmp (arr[i], "style=centered")) |
|
|
233 | { |
|
|
234 | new_flags = 0; |
|
|
235 | w = h = noScale; |
|
|
236 | x = y = centerAlign; |
|
|
237 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
238 | } |
|
|
239 | else if (!strcasecmp (arr[i], "style=root-tiled")) |
|
|
240 | { |
|
|
241 | new_flags = BG_TILE|BG_ROOT_ALIGN; |
|
|
242 | w = h = noScale; |
|
|
243 | geom_flags = WidthValue|HeightValue; |
|
|
244 | } |
|
|
245 | else if (!strcasecmp (arr[i], "op=tile")) |
|
|
246 | new_flags |= BG_TILE; |
|
|
247 | else if (!strcasecmp (arr[i], "op=pscale")) |
|
|
248 | new_flags |= BG_PROP_SCALE; |
|
|
249 | else if (!strcasecmp (arr[i], "op=root")) |
|
|
250 | new_flags |= BG_ROOT_ALIGN; |
|
|
251 | |
|
|
252 | // deprecated |
|
|
253 | else if (!strcasecmp (arr[i], "tile")) |
|
|
254 | { |
|
|
255 | new_flags |= BG_TILE; |
|
|
256 | w = h = noScale; |
|
|
257 | geom_flags |= WidthValue|HeightValue; |
|
|
258 | } |
|
|
259 | else if (!strcasecmp (arr[i], "propscale")) |
|
|
260 | { |
|
|
261 | new_flags |= BG_PROP_SCALE; |
|
|
262 | } |
|
|
263 | else if (!strcasecmp (arr[i], "hscale")) |
|
|
264 | { |
|
|
265 | new_flags |= BG_TILE; |
|
|
266 | w = windowScale; |
|
|
267 | h = noScale; |
|
|
268 | geom_flags |= WidthValue|HeightValue; |
|
|
269 | } |
|
|
270 | else if (!strcasecmp (arr[i], "vscale")) |
|
|
271 | { |
|
|
272 | new_flags |= BG_TILE; |
|
|
273 | h = windowScale; |
|
|
274 | w = noScale; |
|
|
275 | geom_flags |= WidthValue|HeightValue; |
|
|
276 | } |
|
|
277 | else if (!strcasecmp (arr[i], "scale")) |
|
|
278 | { |
|
|
279 | w = h = windowScale; |
|
|
280 | geom_flags |= WidthValue|HeightValue; |
|
|
281 | } |
|
|
282 | else if (!strcasecmp (arr[i], "auto")) |
|
|
283 | { |
|
|
284 | w = h = windowScale; |
|
|
285 | x = y = centerAlign; |
|
|
286 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
287 | } |
|
|
288 | else if (!strcasecmp (arr[i], "root")) |
|
|
289 | { |
|
|
290 | new_flags |= BG_TILE|BG_ROOT_ALIGN; |
|
|
291 | w = h = noScale; |
|
|
292 | geom_flags |= WidthValue|HeightValue; |
|
|
293 | } |
|
|
294 | |
|
|
295 | else |
234 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
296 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
235 | } /* done parsing geometry string */ |
297 | } /* done parsing ops */ |
|
|
298 | |
|
|
299 | rxvt_free_strsplit (arr); |
|
|
300 | } |
236 | |
301 | |
237 | if (!update) |
302 | if (!update) |
238 | { |
303 | { |
239 | if (!(geom_flags & XValue)) |
304 | if (!(geom_flags & XValue)) |
240 | x = y = defaultAlign; |
305 | x = y = defaultAlign; |
… | |
… | |
247 | h = w; |
312 | h = w; |
248 | else if (!(geom_flags & WidthValue)) |
313 | else if (!(geom_flags & WidthValue)) |
249 | w = h; |
314 | w = h; |
250 | |
315 | |
251 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
316 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
252 | } |
|
|
253 | |
|
|
254 | if (ops) |
|
|
255 | { |
|
|
256 | char **arr = rxvt_strsplit (':', ops + 1); |
|
|
257 | |
|
|
258 | for (int i = 0; arr[i]; i++) |
|
|
259 | { |
|
|
260 | if (!strcasecmp (arr[i], "tile")) |
|
|
261 | { |
|
|
262 | new_flags |= BG_TILE; |
|
|
263 | w = h = noScale; |
|
|
264 | geom_flags |= WidthValue|HeightValue; |
|
|
265 | } |
|
|
266 | else if (!strcasecmp (arr[i], "propscale")) |
|
|
267 | { |
|
|
268 | new_flags |= BG_PROP_SCALE; |
|
|
269 | } |
|
|
270 | else if (!strcasecmp (arr[i], "scale")) |
|
|
271 | { |
|
|
272 | if (h == 0) h = windowScale; |
|
|
273 | if (w == 0) w = windowScale; |
|
|
274 | |
|
|
275 | geom_flags |= WidthValue|HeightValue; |
|
|
276 | } |
|
|
277 | else if (!strcasecmp (arr[i], "root")) |
|
|
278 | { |
|
|
279 | new_flags |= BG_TILE|BG_ROOT_ALIGN; |
|
|
280 | w = h = noScale; |
|
|
281 | geom_flags |= WidthValue|HeightValue; |
|
|
282 | } |
|
|
283 | } /* done parsing ops */ |
|
|
284 | |
|
|
285 | rxvt_free_strsplit (arr); |
|
|
286 | } |
317 | } |
287 | |
318 | |
288 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
319 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
289 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
320 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
290 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
321 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |