ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.119 by sf-exg, Thu Nov 18 17:28:12 2010 UTC vs.
Revision 1.120 by sf-exg, Thu Nov 18 17:29:25 2010 UTC

246 int geom_flags = 0; 246 int geom_flags = 0;
247 int x = 0, y = 0; 247 int x = 0, y = 0;
248 unsigned int w = 0, h = 0; 248 unsigned int w = 0, h = 0;
249 unsigned int n; 249 unsigned int n;
250 unsigned long new_flags = (flags & (~geometryFlags)); 250 unsigned long new_flags = (flags & (~geometryFlags));
251 const char *p; 251 const char *ops;
252# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ 252# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */
253 253
254 if (geom == NULL) 254 if (geom == NULL)
255 return false; 255 return false;
256 256
257 char str[MAXLEN_GEOM]; 257 char str[MAXLEN_GEOM];
258 258
259 while (isspace(*geom)) ++geom;
260 if ((p = strchr (geom, ';')) == NULL)
261 p = strchr (geom, '\0'); 259 ops = strchr (geom, ':');
262 260 if (ops == NULL)
261 n = strlen (geom);
262 else
263 n = (p - geom); 263 n = ops - geom;
264
264 if (n < MAXLEN_GEOM) 265 if (n < MAXLEN_GEOM)
265 { 266 {
266 char *ops;
267
268 memcpy (str, geom, n); 267 memcpy (str, geom, n);
269 str[n] = '\0'; 268 str[n] = '\0';
269 rxvt_strtrim (str);
270
270 if (str[0] == ':') 271 if (str[0])
271 ops = &str[0];
272 else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0]))
273 ops = &str[0];
274 else
275 {
276 char *tmp;
277 ops = strchr (str, ':');
278 if (ops != NULL)
279 {
280 for (tmp = ops-1; tmp >= str && isspace(*tmp); --tmp);
281 *(++tmp) = '\0';
282 if (ops == tmp) ++ops;
283 }
284 }
285
286 if (ops > str || ops == NULL)
287 { 272 {
288 /* we have geometry string - let's handle it prior to applying ops */ 273 /* we have geometry string - let's handle it prior to applying ops */
289 geom_flags = XParseGeometry (str, &x, &y, &w, &h); 274 geom_flags = XParseGeometry (str, &x, &y, &w, &h);
290
291 if (!update) /* setting up geometry from scratch */
292 {
293 if (!(geom_flags & XValue))
294 {
295 /* use default geometry - centered */
296 x = y = defaultAlign;
297 }
298 else if (!(geom_flags & YValue))
299 y = x;
300
301 if ((geom_flags & (WidthValue|HeightValue)) == 0)
302 {
303 /* use default geometry - scaled */
304 w = h = defaultScale;
305 }
306 else if (geom_flags & WidthValue)
307 {
308 if (!(geom_flags & HeightValue))
309 h = w;
310 }
311 else
312 w = h;
313 }
314 } /* done parsing geometry string */ 275 } /* done parsing geometry string */
315 else if (!update)
316 {
317 /* default geometry - scaled and centered */
318 x = y = defaultAlign;
319 w = h = defaultScale;
320 }
321 276
322 if (!update) 277 if (!update)
278 {
279 if (!(geom_flags & XValue))
280 x = y = defaultAlign;
281 else if (!(geom_flags & YValue))
282 y = x;
283
284 if (!(geom_flags & (WidthValue|HeightValue)))
285 w = h = defaultScale;
286 else if (!(geom_flags & HeightValue))
287 h = w;
288 else if (!(geom_flags & WidthValue))
289 w = h;
290
323 geom_flags |= WidthValue|HeightValue|XValue|YValue; 291 geom_flags |= WidthValue|HeightValue|XValue|YValue;
292 }
324 293
325 if (ops) 294 if (ops)
326 { 295 {
327 while (*ops) 296 while (*ops)
328 { 297 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines