… | |
… | |
197 | { |
197 | { |
198 | bool changed = false; |
198 | bool changed = false; |
199 | int geom_flags = 0; |
199 | int geom_flags = 0; |
200 | int x = 0, y = 0; |
200 | int x = 0, y = 0; |
201 | unsigned int w = 0, h = 0; |
201 | unsigned int w = 0, h = 0; |
202 | unsigned int n; |
|
|
203 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
202 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
204 | const char *ops; |
|
|
205 | |
203 | |
206 | if (geom == NULL) |
204 | if (geom == NULL) |
207 | return false; |
205 | return false; |
208 | |
206 | |
209 | char str[256]; |
207 | if (geom[0]) |
210 | |
|
|
211 | ops = strchr (geom, ':'); |
|
|
212 | if (ops == NULL) |
|
|
213 | n = strlen (geom); |
|
|
214 | else |
|
|
215 | n = ops - geom; |
|
|
216 | |
|
|
217 | if (n >= sizeof (str)) |
|
|
218 | return false; |
|
|
219 | |
|
|
220 | memcpy (str, geom, n); |
|
|
221 | str[n] = '\0'; |
|
|
222 | rxvt_strtrim (str); |
|
|
223 | |
|
|
224 | if (str[0]) |
|
|
225 | { |
208 | { |
226 | /* 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 |
227 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
296 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
228 | } /* done parsing geometry string */ |
297 | } /* done parsing ops */ |
|
|
298 | |
|
|
299 | rxvt_free_strsplit (arr); |
|
|
300 | } |
229 | |
301 | |
230 | if (!update) |
302 | if (!update) |
231 | { |
303 | { |
232 | if (!(geom_flags & XValue)) |
304 | if (!(geom_flags & XValue)) |
233 | x = y = defaultAlign; |
305 | x = y = defaultAlign; |
… | |
… | |
240 | h = w; |
312 | h = w; |
241 | else if (!(geom_flags & WidthValue)) |
313 | else if (!(geom_flags & WidthValue)) |
242 | w = h; |
314 | w = h; |
243 | |
315 | |
244 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
316 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
245 | } |
|
|
246 | |
|
|
247 | if (ops) |
|
|
248 | { |
|
|
249 | char **arr = rxvt_strsplit (':', ops + 1); |
|
|
250 | |
|
|
251 | for (int i = 0; arr[i]; i++) |
|
|
252 | { |
|
|
253 | if (!strcasecmp (arr[i], "style=tiled")) |
|
|
254 | { |
|
|
255 | new_flags = BG_TILE; |
|
|
256 | w = h = noScale; |
|
|
257 | x = y = 0; |
|
|
258 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
259 | } |
|
|
260 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
|
|
261 | { |
|
|
262 | new_flags = BG_PROP_SCALE; |
|
|
263 | x = y = centerAlign; |
|
|
264 | geom_flags = XValue|YValue; |
|
|
265 | } |
|
|
266 | else if (!strcasecmp (arr[i], "style=stretched")) |
|
|
267 | { |
|
|
268 | new_flags = 0; |
|
|
269 | w = h = windowScale; |
|
|
270 | geom_flags = WidthValue|HeightValue; |
|
|
271 | } |
|
|
272 | else if (!strcasecmp (arr[i], "style=centered")) |
|
|
273 | { |
|
|
274 | new_flags = 0; |
|
|
275 | w = h = noScale; |
|
|
276 | x = y = centerAlign; |
|
|
277 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
278 | } |
|
|
279 | else if (!strcasecmp (arr[i], "style=root-tiled")) |
|
|
280 | { |
|
|
281 | new_flags = BG_TILE|BG_ROOT_ALIGN; |
|
|
282 | w = h = noScale; |
|
|
283 | geom_flags = WidthValue|HeightValue; |
|
|
284 | } |
|
|
285 | else if (!strcasecmp (arr[i], "op=tile")) |
|
|
286 | new_flags |= BG_TILE; |
|
|
287 | else if (!strcasecmp (arr[i], "op=pscale")) |
|
|
288 | new_flags |= BG_PROP_SCALE; |
|
|
289 | else if (!strcasecmp (arr[i], "op=root")) |
|
|
290 | new_flags |= BG_ROOT_ALIGN; |
|
|
291 | |
|
|
292 | // deprecated |
|
|
293 | else if (!strcasecmp (arr[i], "tile")) |
|
|
294 | { |
|
|
295 | new_flags |= BG_TILE; |
|
|
296 | w = h = noScale; |
|
|
297 | geom_flags |= WidthValue|HeightValue; |
|
|
298 | } |
|
|
299 | else if (!strcasecmp (arr[i], "propscale")) |
|
|
300 | { |
|
|
301 | new_flags |= BG_PROP_SCALE; |
|
|
302 | } |
|
|
303 | else if (!strcasecmp (arr[i], "hscale")) |
|
|
304 | { |
|
|
305 | new_flags |= BG_TILE; |
|
|
306 | w = windowScale; |
|
|
307 | h = noScale; |
|
|
308 | geom_flags |= WidthValue|HeightValue; |
|
|
309 | } |
|
|
310 | else if (!strcasecmp (arr[i], "vscale")) |
|
|
311 | { |
|
|
312 | new_flags |= BG_TILE; |
|
|
313 | h = windowScale; |
|
|
314 | w = noScale; |
|
|
315 | geom_flags |= WidthValue|HeightValue; |
|
|
316 | } |
|
|
317 | else if (!strcasecmp (arr[i], "scale")) |
|
|
318 | { |
|
|
319 | w = h = windowScale; |
|
|
320 | geom_flags |= WidthValue|HeightValue; |
|
|
321 | } |
|
|
322 | else if (!strcasecmp (arr[i], "auto")) |
|
|
323 | { |
|
|
324 | w = h = windowScale; |
|
|
325 | x = y = centerAlign; |
|
|
326 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
327 | } |
|
|
328 | else if (!strcasecmp (arr[i], "root")) |
|
|
329 | { |
|
|
330 | new_flags |= BG_TILE|BG_ROOT_ALIGN; |
|
|
331 | w = h = noScale; |
|
|
332 | geom_flags |= WidthValue|HeightValue; |
|
|
333 | } |
|
|
334 | } /* done parsing ops */ |
|
|
335 | |
|
|
336 | rxvt_free_strsplit (arr); |
|
|
337 | } |
317 | } |
338 | |
318 | |
339 | 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; |
340 | 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; |
341 | 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; |