… | |
… | |
259 | void |
259 | void |
260 | rxvt_term::get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y) |
260 | rxvt_term::get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y) |
261 | { |
261 | { |
262 | int image_width = image.img->w; |
262 | int image_width = image.img->w; |
263 | int image_height = image.img->h; |
263 | int image_height = image.img->h; |
264 | int target_width = szHint.width; |
264 | int parent_width = szHint.width; |
265 | int target_height = szHint.height; |
265 | int parent_height = szHint.height; |
266 | int h_scale = min (image.h_scale, 32767 * 100 / target_width); |
266 | int h_scale = min (image.h_scale, 32767 * 100 / parent_width); |
267 | int v_scale = min (image.v_scale, 32767 * 100 / target_height); |
267 | int v_scale = min (image.v_scale, 32767 * 100 / parent_height); |
268 | |
268 | |
269 | w = h_scale * target_width / 100; |
269 | w = h_scale * parent_width / 100; |
270 | h = v_scale * target_height / 100; |
270 | h = v_scale * parent_height / 100; |
271 | |
271 | |
272 | if (image.flags & IM_KEEP_ASPECT) |
272 | if (image.flags & IM_KEEP_ASPECT) |
273 | { |
273 | { |
274 | float scale = (float)w / image_width; |
274 | float scale = (float)w / image_width; |
275 | min_it (scale, (float)h / image_height); |
275 | min_it (scale, (float)h / image_height); |
… | |
… | |
285 | x = -parent_x; |
285 | x = -parent_x; |
286 | y = -parent_y; |
286 | y = -parent_y; |
287 | } |
287 | } |
288 | else |
288 | else |
289 | { |
289 | { |
290 | x = make_align_position (image.h_align, target_width, w); |
290 | x = make_align_position (image.h_align, parent_width, w); |
291 | y = make_align_position (image.v_align, target_height, h); |
291 | y = make_align_position (image.v_align, parent_height, h); |
292 | } |
292 | } |
293 | } |
293 | } |
294 | |
294 | |
295 | bool |
295 | bool |
296 | rxvt_term::render_image (rxvt_image &image) |
296 | rxvt_term::render_image (rxvt_image &image) |
297 | { |
297 | { |
298 | int target_width = szHint.width; |
298 | int parent_width = szHint.width; |
299 | int target_height = szHint.height; |
299 | int parent_height = szHint.height; |
300 | |
300 | |
301 | int x = 0; |
301 | int x = 0; |
302 | int y = 0; |
302 | int y = 0; |
303 | int w = 0; |
303 | int w = 0; |
304 | int h = 0; |
304 | int h = 0; |
305 | |
305 | |
306 | get_image_geometry (image, w, h, x, y); |
306 | get_image_geometry (image, w, h, x, y); |
307 | |
307 | |
308 | if (!(image.flags & IM_ROOT_ALIGN) |
308 | if (!(image.flags & IM_ROOT_ALIGN) |
309 | && (x >= target_width |
309 | && (x >= parent_width |
310 | || y >= target_height |
310 | || y >= parent_height |
311 | || x + w <= 0 |
311 | || x + w <= 0 |
312 | || y + h <= 0)) |
312 | || y + h <= 0)) |
313 | return false; |
313 | return false; |
314 | |
314 | |
315 | rxvt_img *img = image.img->scale (w, h); |
315 | rxvt_img *img = image.img->scale (w, h); |
316 | |
316 | |
317 | if (image.flags & IM_TILE) |
317 | if (image.flags & IM_TILE) |
318 | img->repeat_mode (RepeatNormal); |
318 | img->repeat_mode (RepeatNormal); |
319 | else |
319 | else |
320 | img->repeat_mode (RepeatNone); |
320 | img->repeat_mode (RepeatNone); |
321 | img->sub_rect (-x, -y, target_width, target_height)->replace (img); |
321 | img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); |
322 | |
322 | |
323 | if (bg_flags & BG_IS_VALID) |
323 | if (bg_flags & BG_IS_VALID) |
324 | { |
324 | { |
325 | double factor = image.alpha * 1. / 0xffff; |
325 | double factor = image.alpha * 1. / 0xffff; |
326 | bg_img->blend (img, factor)->replace (img); |
326 | bg_img->blend (img, factor)->replace (img); |
… | |
… | |
457 | * be always up-to-date, so let's use it : |
457 | * be always up-to-date, so let's use it : |
458 | */ |
458 | */ |
459 | int screen = display->screen; |
459 | int screen = display->screen; |
460 | int root_width = DisplayWidth (dpy, screen); |
460 | int root_width = DisplayWidth (dpy, screen); |
461 | int root_height = DisplayHeight (dpy, screen); |
461 | int root_height = DisplayHeight (dpy, screen); |
462 | int window_width = szHint.width; |
462 | int parent_width = szHint.width; |
463 | int window_height = szHint.height; |
463 | int parent_height = szHint.height; |
464 | int sx, sy; |
464 | int sx, sy; |
465 | |
465 | |
466 | sx = parent_x; |
466 | sx = parent_x; |
467 | sy = parent_y; |
467 | sy = parent_y; |
468 | |
468 | |
469 | if (!root_img) |
469 | if (!root_img) |
470 | return false; |
470 | return false; |
471 | |
471 | |
472 | /* check if we are outside of the visible part of the virtual screen : */ |
472 | /* check if we are outside of the visible part of the virtual screen : */ |
473 | if (sx + window_width <= 0 || sy + window_height <= 0 |
473 | if (sx + parent_width <= 0 || sy + parent_height <= 0 |
474 | || sx >= root_width || sy >= root_height) |
474 | || sx >= root_width || sy >= root_height) |
475 | return 0; |
475 | return 0; |
476 | |
476 | |
477 | while (sx < 0) sx += root_img->w; |
477 | while (sx < 0) sx += root_img->w; |
478 | while (sy < 0) sy += root_img->h; |
478 | while (sy < 0) sy += root_img->h; |
479 | |
479 | |
480 | rxvt_img *img = root_img->sub_rect (sx, sy, window_width, window_height); |
480 | rxvt_img *img = root_img->sub_rect (sx, sy, parent_width, parent_height); |
481 | |
481 | |
482 | if (root_effects.need_blur ()) |
482 | if (root_effects.need_blur ()) |
483 | img->blur (root_effects.h_blurRadius, root_effects.v_blurRadius)->replace (img); |
483 | img->blur (root_effects.h_blurRadius, root_effects.v_blurRadius)->replace (img); |
484 | |
484 | |
485 | if (root_effects.need_tint ()) |
485 | if (root_effects.need_tint ()) |