… | |
… | |
123 | } |
123 | } |
124 | } |
124 | } |
125 | return false; |
125 | return false; |
126 | } |
126 | } |
127 | |
127 | |
|
|
128 | static inline int |
|
|
129 | make_align_position (int align, int window_size, int image_size) |
|
|
130 | { |
|
|
131 | int diff = window_size - image_size; |
|
|
132 | int smaller = MIN (image_size,window_size); |
|
|
133 | |
|
|
134 | if (align >= 0 && align <= 50) |
|
|
135 | return diff * align / 100; |
|
|
136 | else if (align > 50 && align <= 100) |
|
|
137 | return window_size - image_size + diff * align / 100; |
|
|
138 | else if (align > 100 && align <= 200 ) |
|
|
139 | return ((align - 100) * smaller / 100) + window_size - smaller; |
|
|
140 | else if (align > -100 && align < 0) |
|
|
141 | return ((align + 100) * smaller / 100) - image_size; |
|
|
142 | return 0; |
|
|
143 | } |
|
|
144 | |
|
|
145 | static inline void |
|
|
146 | make_clip_rectangle (int pos, int size, int target_size, short &clip_pos, unsigned short &clip_size) |
|
|
147 | { |
|
|
148 | if (pos < 0) |
|
|
149 | { |
|
|
150 | clip_pos = 0; |
|
|
151 | clip_size = MIN (target_size, size + pos); |
|
|
152 | } |
|
|
153 | else |
|
|
154 | { |
|
|
155 | clip_pos = pos; |
|
|
156 | clip_size = size; |
|
|
157 | if (pos < target_size && (int)clip_size > target_size - pos) |
|
|
158 | clip_pos = target_size - pos; |
|
|
159 | } |
|
|
160 | } |
|
|
161 | |
128 | bool |
162 | bool |
129 | bgPixmap_t::handle_geometry (const char *geom) |
163 | bgPixmap_t::handle_geometry (const char *geom) |
130 | { |
164 | { |
131 | int geom_flags = 0, changed = 0; |
165 | int geom_flags = 0, changed = 0; |
132 | int x = 0, y = 0; |
166 | int x = 0, y = 0; |
… | |
… | |
315 | } |
349 | } |
316 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
350 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
317 | // flags, h_scale, v_scale, h_align, v_align); |
351 | // flags, h_scale, v_scale, h_align, v_align); |
318 | return (changed > 0); |
352 | return (changed > 0); |
319 | } |
353 | } |
|
|
354 | |
|
|
355 | #ifdef HAVE_AFTERIMAGE |
|
|
356 | ASImage * |
|
|
357 | bgPixmap_t::resize_asim (rxvt_term *target, ASImage *background, XRectangle &dst_rect) |
|
|
358 | { |
|
|
359 | if (original_asim == NULL || target == NULL) |
|
|
360 | return NULL; |
|
|
361 | |
|
|
362 | int target_width = (int)target->szHint.width; |
|
|
363 | int target_height = (int)target->szHint.height; |
|
|
364 | int w = h_scale * target_width / 100; |
|
|
365 | int h = v_scale * target_height / 100; |
|
|
366 | int x = make_align_position (h_align, target_width, w); |
|
|
367 | int y = make_align_position (v_align, target_height, h); |
|
|
368 | |
|
|
369 | make_clip_rectangle (x, w, target_width, dst_rect.x, dst_rect.width); |
|
|
370 | make_clip_rectangle (y, h, target_height, dst_rect.y, dst_rect.height); |
|
|
371 | |
|
|
372 | /* TODO : actuall scaling code :) */ |
|
|
373 | |
|
|
374 | } |
|
|
375 | #endif |
320 | |
376 | |
321 | void |
377 | void |
322 | rxvt_term::resize_pixmap () |
378 | rxvt_term::resize_pixmap () |
323 | { |
379 | { |
324 | XGCValues gcvalue; |
380 | XGCValues gcvalue; |