示例#1
0
void set_shape(client_t *c)
{
    int n, order;
    XRectangle temp, *rects;

    rects = XShapeGetRectangles(dpy, c->win, ShapeBounding, &n, &order);

    if (n > 1) {
        XShapeCombineShape(dpy, c->frame, ShapeBounding,
            0, frame_height(c), c->win, ShapeBounding, ShapeSet);
        temp.x = -BW(c);
        temp.y = -BW(c);
        temp.width = c->geom.w + 2*BW(c);
        temp.height = frame_height(c) + BW(c);
        XShapeCombineRectangles(dpy, c->frame, ShapeBounding,
            0, 0, &temp, 1, ShapeUnion, YXBanded);
        temp.x = 0;
        temp.y = 0;
        temp.width = c->geom.w;
        temp.height = frame_height(c) - BW(c);
        XShapeCombineRectangles(dpy, c->frame, ShapeClip,
            0, frame_height(c), &temp, 1, ShapeUnion, YXBanded);
        c->shaped = 1;
    } else if (c->shaped) {
        /* I can't find a ``remove all shaping'' function... */
        temp.x = -BW(c);
        temp.y = -BW(c);
        temp.width = c->geom.w + 2*BW(c);
        temp.height = c->geom.h + frame_height(c) + 2*BW(c);
        XShapeCombineRectangles(dpy, c->frame, ShapeBounding,
            0, 0, &temp, 1, ShapeSet, YXBanded);
    }

    XFree(rects);
}
示例#2
0
static void reparent(client_t *c, strut_t *s)
{
    XSetWindowAttributes pattr;
    geom_t f;

    f = frame_geom(c);
    pattr.override_redirect = True;
    pattr.background_pixel = bg.pixel;
    pattr.border_pixel = bd.pixel;
    pattr.event_mask = SubMask|ButtonPressMask|ExposureMask|EnterWindowMask;
    c->frame = XCreateWindow(dpy, root, f.x, f.y, f.w, f.h, BW(c),
        DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
        CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr);

#ifdef SHAPE
    if (shape) {
        XShapeSelectInput(dpy, c->win, ShapeNotifyMask);
        set_shape(c);
    }
#endif

#ifdef XFT
    c->xftdraw = XftDrawCreate(dpy, (Drawable)c->frame,
        DefaultVisual(dpy, DefaultScreen(dpy)),
        DefaultColormap(dpy, DefaultScreen(dpy)));
#endif

    XAddToSaveSet(dpy, c->win);
    XSelectInput(dpy, c->win, ColormapChangeMask|PropertyChangeMask);
    XSetWindowBorderWidth(dpy, c->win, 0);
    XResizeWindow(dpy, c->win, c->geom.w, c->geom.h);
    XReparentWindow(dpy, c->win, c->frame, 0, frame_height(c));

    send_config(c);
}
示例#3
0
void ongr_dot( frame *f, onpoint *p )
{
  onpoint abs;
  double bw = real_min(frame_width(f),frame_height(f))/150.0;
  bw = real_max(DOT_RADIUS * 0.75,real_min(1.5 * DOT_RADIUS,bw));
  r2a(f,p,&abs);
  ag_disc(abs.x,abs.y,bw);
}
示例#4
0
void print_and_shrink( frame *fr, char *mess )
{
  onpoint p;
  p.x = CW/2.0;
  p.y = frame_height(fr) - CH * 0.8;
  ongr_print(fr,&p,mess);
  fr -> top_right.y -= CH;
}
示例#5
0
void compute_axes_details(ongr *on, frame *fr)
/*
    Alters horizontal and vertical axis position and labelling
    according to frame details.
*/
{
  double w = frame_width(fr);
  double h = frame_height(fr);
  compute_hor_axis_markings(&on->x_axis,w);
  compute_vert_axis_markings(&on->y_axis,h);
}
示例#6
0
geom_t frame_geom(client_t *c)
{
    geom_t f = c->geom;

    /* everything else is the same as c->geom was */
    f.h = frame_height(c) + (c->shaded ? -BW(c) : c->geom.h);

    /* X, in its perpetual helpfulness, always does native borders NorthWest
     * style. This, as usual, ruins everything. So we compensate. */
    switch (GRAV(c)) {
        case NorthWestGravity:
            break;
        case NorthGravity:
            f.x -= BW(c);
            break;
        case NorthEastGravity:
            f.x -= 2 * BW(c);
            break;
        case EastGravity:
            f.x -= 2 * BW(c);
            f.y -= frame_height(c) / 2 + BW(c);
            break;
        case SouthEastGravity:
            f.x -= 2 * BW(c);
            f.y -= frame_height(c) + 2 * BW(c);
            break;
        case SouthGravity:
            f.x -= BW(c);
            f.y -= frame_height(c) + 2 * BW(c);
            break;
        case SouthWestGravity:
            f.y -= frame_height(c) + 2 * BW(c);
            break;
        case WestGravity:
            f.y -= frame_height(c) / 2 + BW(c);
            break;
        case StaticGravity:
            f.y -= frame_height(c) + BW(c);
            f.x -= BW(c);
            break;
        case CenterGravity:
            f.x -= BW(c);
            f.y -= frame_height(c) / 2 + BW(c);
            break;
    }

    return f;
}
示例#7
0
void redraw_frame(client_t *c)
{
    int x, y;

    if (c && c->decor) {
        XClearWindow(dpy, c->frame);
        if (!c->shaded) XDrawLine(dpy, c->frame, border_gc,
            0, frame_height(c) - BW(c) + BW(c)/2,
            c->geom.w, frame_height(c) - BW(c) + BW(c)/2);
        XDrawLine(dpy, c->frame, border_gc,
            c->geom.w - frame_height(c) + BW(c)/2, 0,
            c->geom.w - frame_height(c) + BW(c)/2, frame_height(c));

        if (!c->trans && c->name) {
            x = opt_pad + DESCENT/2;
            y = opt_pad + ASCENT;
#ifdef XFT
#ifdef X_HAVE_UTF8_STRING
            XftDrawStringUtf8(c->xftdraw, &xft_fg, xftfont, x, y,
                (unsigned char *)c->name, strlen(c->name));
#else
            XftDrawString8(c->xftdraw, &xft_fg, xftfont, x, y,
                (unsigned char *)c->name, strlen(c->name));
#endif
#else
#ifdef X_HAVE_UTF8_STRING
            Xutf8DrawString(dpy, c->frame, font_set, string_gc, x, y,
                c->name, strlen(c->name));
#else
            XDrawString(dpy, c->frame, string_gc, x, y,
                c->name, strlen(c->name));
#endif
#endif
        }
    }
}
示例#8
0
void sub_frame(
    frame *super_frame,
    int i,
    int j,
    int rows,
    int cols,
    frame *fr
  )
{
  double w = frame_width(super_frame) / cols;
  double h = frame_height(super_frame) / rows;
  fr->bottom_left.x = super_frame->bottom_left.x + w * i;
  fr->bottom_left.y = super_frame->bottom_left.y + h * j;
  fr->top_right.x = fr->bottom_left.x + w;
  fr->top_right.y = fr->bottom_left.y + h;
}
示例#9
0
void draw_one_axis( frame *fr, axis *ax )
{
  int i;
  onpoint p;
  int color = ag_pen_color();
  ag_set_pen_color(AG_RED);
  ongr_line(fr,&ax->start,&ax->end);

  for ( i = 0 ; i <= ax->marks ; i++ )
  {
    char mark[100];
    double tick;
    p.x = ax->start.x + ((ax->end.x - ax->start.x) * i) / ax->marks;
    p.y = ax->start.y + ((ax->end.y - ax->start.y) * i) / ax->marks;
    ag_set_pen_color(AG_RED);
    ongr_cross(fr,&p);
    p.x += ax->rel_mark_number.x;
    p.y += ax->rel_mark_number.y;
    tick = ax->lo + ax->delta * i;
    sprintf(mark,"%g", fabs(tick) < 1.0e-15 ? 0.0 : tick); /*fix bad rounding*/
    ag_set_pen_color(color);
    ongr_print(fr,&p,mark);
  }
  ag_set_pen_color(color);

/* Finally, we do the label for the axis */

  if ( ax -> vertical )
  {
    p.x = CW/2.0;
    p.y = frame_height(fr) - CH;
  }
  else
  {
    p.x = real_max(0.0,real_min(ax->start.x,frame_width(fr)-CW*strlen(ax->label)));
    p.y = CH/2.0;
  }

  ongr_print(fr,&p,ax->label);
}