示例#1
0
bool
image_effects::set_blur (const char *geom)
{
  bool changed = false;
  unsigned int hr, vr;
  int junk;
  int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr);

  if (!(geom_flags & WidthValue))
    hr = 1;
  if (!(geom_flags & HeightValue))
    vr = hr;

  min_it (hr, 128);
  min_it (vr, 128);

  if (h_blurRadius != hr)
    {
      changed = true;
      h_blurRadius = hr;
    }

  if (v_blurRadius != vr)
    {
      changed = true;
      v_blurRadius = vr;
    }

  return changed;
}
示例#2
0
void
rxvt_term::render_image (rxvt_image &image)
{
  int image_width = image.img->w;
  int image_height = image.img->h;
  int parent_width = szHint.width;
  int parent_height = szHint.height;
  int h_scale = min (image.h_scale, 32767 * 100 / parent_width);
  int v_scale = min (image.v_scale, 32767 * 100 / parent_height);

  int w;
  int h;
  int x;
  int y;

  w = h_scale * parent_width / 100;
  h = v_scale * parent_height / 100;

  if (image.flags & IM_KEEP_ASPECT)
    {
      float scale = (float)w / image_width;
      min_it (scale, (float)h / image_height);
      w = image_width * scale + 0.5;
      h = image_height * scale + 0.5;
    }

  if (!w) w = image_width;
  if (!h) h = image_height;

  if (image.flags & IM_ROOT_ALIGN)
    {
      x = -parent_x;
      y = -parent_y;
    }
  else
    {
      x = make_align_position (image.h_align, parent_width, w);
      y = make_align_position (image.v_align, parent_height, h);
    }

  if (!(image.flags & IM_ROOT_ALIGN)
      && (x >= parent_width
          || y >= parent_height
          || x + w <= 0
          || y + h <= 0))
    return;

  rxvt_img *img = image.img->scale (w, h);

  if (image.flags & IM_TILE)
    img->repeat_mode (RepeatNormal);
  else
    img->repeat_mode (RepeatNone);
  img->sub_rect (-x, -y, parent_width, parent_height)->replace (img);

  if (bg_img)
    img->draw (bg_img, PictOpOver, image.alpha * 1. / 0xffff);

  XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
  img->convert_format (format, pix_colors [Color_bg])->replace (img);

  delete bg_img;
  bg_img = img;
}
示例#3
0
文件: main.C 项目: nneonneo/rxvt-js
/*
 * window size/position calculations for XSizeHint and other storage.
 * if width/height are non-zero then override calculated width/height
 */
void
rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight)
{
  short recalc_x, recalc_y;
  int x, y, flags;
  unsigned int w, h;
  unsigned int max_width, max_height;

  szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
  szHint.win_gravity = NorthWestGravity;
  /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */

  recalc_x = recalc_y = 0;
  flags = 0;

  if (!parsed_geometry)
    {
      parsed_geometry = 1;

      if (rs[Rs_geometry])
        flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);

      if (flags & WidthValue)
        {
          if (!w)
            rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n");

          ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ());
          szHint.flags |= USSize;
        }

      if (flags & HeightValue)
        {
          if (!h)
            rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n");

          nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ());
          szHint.flags |= USSize;
        }

      if (flags & XValue)
        {
          szHint.x = x;
          szHint.flags |= USPosition;

          if (flags & XNegative)
            {
              recalc_x = 1;
              szHint.win_gravity = NorthEastGravity;
            }
        }

      if (flags & YValue)
        {
          szHint.y = y;
          szHint.flags |= USPosition;

          if (flags & YNegative)
            {
              recalc_y = 1;

              if (szHint.win_gravity == NorthEastGravity)
                szHint.win_gravity = SouthEastGravity;
              else
                szHint.win_gravity = SouthWestGravity;
            }
        }
    }

  /* TODO: BOUNDS */
  width = ncol * fwidth;
  height = nrow * fheight;
  max_width = MAX_COLS * fwidth;
  max_height = MAX_ROWS * fheight;

  szHint.base_width = szHint.base_height = 2 * int_bwidth;

  window_vt_x = window_vt_y = int_bwidth;

  if (scrollBar.state)
    {
      int sb_w = scrollBar.total_width ();
      szHint.base_width += sb_w;

      if (!option (Opt_scrollBar_right))
        window_vt_x += sb_w;
    }

  szHint.width_inc  = fwidth;
  szHint.height_inc = fheight;
  szHint.min_width  = szHint.base_width + szHint.width_inc;
  szHint.min_height = szHint.base_height + szHint.height_inc;

  if (newwidth && newwidth - szHint.base_width < max_width)
    {
      szHint.width = newwidth;
      width = newwidth - szHint.base_width;
    }
  else
    {
      min_it (width, max_width);
      szHint.width = szHint.base_width + width;
    }

  if (newheight && newheight - szHint.base_height < max_height)
    {
      szHint.height = newheight;
      height = newheight - szHint.base_height;
    }
  else
    {
      min_it (height, max_height);
      szHint.height = szHint.base_height + height;
    }

  if (recalc_x)
    szHint.x += DisplayWidth  (dpy, display->screen) - szHint.width  - 2 * ext_bwidth;

  if (recalc_y)
    szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth;

  ncol = width  / fwidth;
  nrow = height / fheight;
}