예제 #1
0
static void InitWindows(xccore_t *xccore)
{
    gui_status_init();
    gui_root_init();
    gui_preedit_init();
    gui_select_init();
    gui_tray_init();
    gui_menu_init();
    gui_symbol_init();
    gui_keyboard_init();
    gui_xcin_init();
    gui_msgbox_init();
    gui_selectmenu_init();

    int isok = gui_restore_window_pos();

    winlist_t *win = winlist;

    while (win)
    {
	win->data = (void *)xccore;
	if (win->draw)
	{
	    XftDrawDestroy(win->draw);
	}

	win->draw = XftDrawCreate(gui->display, win->window, gui->visual, gui->colormap);

	XSelectInput(gui->display, win->window, (ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask|StructureNotifyMask|KeyPressMask));
 	MakeDefaultFont(win); /* 建立預設字型 */
	XMoveResizeWindow(gui->display, win->window,
			win->pos_x, win->pos_y, win->width, win->height);
	win = win->next;
    }
}
void main (void)
{
    Display *dsp = XOpenDisplay (0);
    if (dsp)
    {
        int scr = DefaultScreen (dsp);

        Window p = XCreateSimpleWindow (dsp, RootWindow (dsp, scr), 100, 100, 300, 100, 1,
                                             BlackPixel (dsp, scr), WhitePixel (dsp, scr));
        XSelectInput (dsp, p, ExposureMask);
        XMapWindow (dsp, p);

        XftColor xft_color;
        XftColorAllocName (dsp, DefaultVisual (dsp, scr), DefaultColormap (dsp, scr), "tan", &xft_color);

        XftFont *font = XftFontOpenName (dsp, scr, "sans:bold:pixelsize=18");
        XftDraw *draw = XftDrawCreate (dsp, p, DefaultVisual (dsp, scr), DefaultColormap (dsp, scr));

        for (;;)
        {
            char *txt = "Lorem ipsum";
            XEvent e;
            XNextEvent (dsp, &e);
            if (e.type == Expose)
                XftDrawString8 (draw, &xft_color, font, 20, 30, (XftChar8*)(txt), strlen(txt));
        }
    }
}
예제 #3
0
void
xwindow_draw_string_xft(XWindow *xw, char *text, int x, int y) {
  int n;
  XftDraw *draw;
  XftColor color;
  XRenderColor rc;
  XftFont *font;
  XGlyphInfo extents;
  float shift[] = { 0.0, 0.0, -0.5, -1.0 };
  
  n = strlen(text);

  font = xw->font->font_xft;
  if(!font) {
    return;
  }
  draw = XftDrawCreate(DISPLAY(xw),
                       xw->buffer,
                       VISUAL(xw),
                       DefaultColormap(DISPLAY(xw), SCREEN(xw)));

  /* Set Text from current Color */
  rc.red   = xw->color->red;
  rc.green = xw->color->green;
  rc.blue  = xw->color->blue;
  rc.alpha = 0xFFFF; /* 65535 */
  XftColorAllocValue(DISPLAY(xw),
                     VISUAL(xw),
                     DefaultColormap(DISPLAY(xw), SCREEN(xw)),
                     &rc,
                     &color);
  
  XftTextExtents8(DISPLAY(xw), font, (FcChar8*)text, n, &extents);

  if(cmgdm.tangle != 0.0) {
    XftMatrix m;
    m.xx =  0.0;
    m.xy = -1.0;
    m.yx =  1.0;
    m.yy =  0.0;

    y = y - shift[cmgdm.ihjust] * extents.xOff;
    x = x - shift[cmgdm.ivjust] * (font->ascent + font->descent);
    
    font = XftFontOpen(DISPLAY(xw),
                       SCREEN(xw),
                       XFT_FAMILY,    XftTypeString,  xw->font->family,
                       XFT_SIZE,      XftTypeDouble,  xw->font->size,
                       XFT_STYLE,     XftTypeString,  xfont_style(xw->font),
                       XFT_ANTIALIAS, XftTypeBool,    xw->font->antialias,
                       XFT_MATRIX, XftTypeMatrix, &m,
                       NULL);

    
  } else {
    x = x + shift[cmgdm.ihjust] * extents.xOff;
    y = y - shift[cmgdm.ivjust] * (font->ascent + font->descent);
  }
  XftDrawString8(draw, &color, font, x, y, (FcChar8 *)text, n);
}
예제 #4
0
static void
draw_text (struct widget_xft_data *data, char *lbl, int inverse)
{
    Screen *sc = XtScreen (data->widget);
    int screen = XScreenNumberOfScreen (sc);
    int y = data->xft_font->ascent;
    int x = inverse ? 0 : 2;
    char *bp = lbl;

    data->xft_draw = XftDrawCreate (XtDisplay (data->widget),
                                    data->p,
                                    DefaultVisual (XtDisplay (data->widget),
                                            screen),
                                    DefaultColormapOfScreen (sc));
    XftDrawRect (data->xft_draw,
                 inverse ? &data->xft_fg : &data->xft_bg,
                 0, 0, data->p_width, data->p_height);

    if (!inverse) y += 2;
    while (bp && *bp != '\0')
    {
        char *cp = strchr (bp, '\n');
        XftDrawStringUtf8 (data->xft_draw,
                           inverse ? &data->xft_bg : &data->xft_fg,
                           data->xft_font, x, y,
                           (FcChar8 *) bp,
                           cp ? cp - bp : strlen (bp));
        bp = cp ? cp + 1 : NULL;
        /* 1.2 gives reasonable line spacing.  */
        y += data->xft_font->height * 1.2;
    }

}
예제 #5
0
//=========================================
// XColorSetup
//-----------------------------------------
XTColor XColorSetup (XInit xi,XTFont xt,Window win,Color col) {
	// ...
	// Create two pixmaps initially containing the background
	// of the window win and use them for drawing with double
	// buffering to avoid flickering while the string fade out
	// Create a XFT drawable needed to print text using xft
	// ---
	XGCValues values;
	XTColor xc;

	xc.FTcolor = (XftColor*)malloc(sizeof(XftColor));
	xc.PBack = XCreatePixmap (xi.dpy,win,xt.XTwidth,xt.XTheight,xi.DDepth);
	xc.PAint = XCreatePixmap (xi.dpy,win,xt.XTwidth,xt.XTheight,xi.DDepth);
	XCopyArea(
		xi.dpy,win,xc.PAint,xi.DGc,0,0,xt.XTwidth,xt.XTheight,0,0
	);
	XCopyArea(
		xi.dpy,win,xc.PBack,xi.DGc,0,0,xt.XTwidth,xt.XTheight,0,0
	);
	xc.color.red   = ((col.red   << 8) | col.red );
	xc.color.green = ((col.green << 8) | col.green);
	xc.color.blue  = ((col.blue  << 8) | col.blue );
	XAllocColor(xi.dpy,xi.DMap,&xc.color);
	XSetForeground(xi.dpy,xi.DGc,xc.color.pixel);

	XGetGCValues (xi.dpy, xi.DGc, GCForeground|GCBackground, &values);
	xc.FTdraw = XftDrawCreate (
		xi.dpy, xc.PAint, xi.DVisual, xi.DMap
	);
	xc.FTcolor->color.red   = xc.color.red;
	xc.FTcolor->color.green = xc.color.green;
	xc.FTcolor->color.blue  = xc.color.blue;
	return(xc);
}
예제 #6
0
파일: gui.c 프로젝트: mortehu/bra
static void
configure_window (struct gui_instance *gi)
{
  if (gi->back_buffer)
    XRenderFreePicture (GUI_display, gi->back_buffer);

  if (gi->fontdraw)
    XftDrawDestroy (gi->fontdraw);

  if (gi->pmap)
    XFreePixmap (GUI_display, gi->pmap);

  if (gi->gc)
    XFreeGC (GUI_display, gi->gc);

  gi->gc = XCreateGC (GUI_display, gi->window, 0, 0);

  gi->pmap = XCreatePixmap (GUI_display, gi->window, gi->width, gi->height, GUI_visual_info->depth);

  gi->fontdraw = XftDrawCreate (GUI_display, gi->pmap, GUI_visual, DefaultColormap (GUI_display, GUI_screenidx));

  gi->back_buffer
    = XRenderCreatePicture (GUI_display, gi->pmap, xrenderpictformat, 0, 0);

  if (!gi->back_buffer)
    errx (EXIT_FAILURE, "Failed to create back buffer for X window (XRenderCreatePicture)");
}
예제 #7
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);
}
예제 #8
0
void
render_init(void)
{
	font = XftFontOpen(display, screen,
	    XFT_FAMILY, XftTypeString, FONT_NAME,
	    XFT_SIZE, XftTypeInteger, FONT_SIZE,
	    NULL);
	if (!XftColorAllocName(display, XDefaultVisual(display, screen),
		DefaultColormap(display, screen), TouchCross, &cross)) {
		fprintf(stderr, "Cannot get color");
		exit(2);
	}
	if (!XftColorAllocName(display, XDefaultVisual(display, screen),
		DefaultColormap(display, screen), PromptText, &promptColor)) {
		fprintf(stderr, "Cannot get color");
		exit(2);
	}
	if (!XftColorAllocName(display, XDefaultVisual(display, screen),
		DefaultColormap(display, screen), Background, &bg)) {
		fprintf(stderr, "Cannot get bg color");
		exit(2);
	}
	if (!XftColorAllocName(display, XDefaultVisual(display, screen),
		DefaultColormap(display, screen), Error, &errorColor)) {
		fprintf(stderr, "Cannot get color");
		exit(2);
	}
	draw = XftDrawCreate(display, win, DefaultVisual(display, screen),
	    DefaultColormap(display, screen));
}
예제 #9
0
파일: pango_x.cpp 프로젝트: 3v1n0/wxWidgets
void
x11_draw_glyphs( Drawable            drawable,
                 GC                  gc,
                 PangoFont          *font,
                 int                 x,
                 int                 y,
                 PangoGlyphString   *glyphs,
                 wxColour           &colour )
{
    if (PANGO_XFT_IS_FONT (font))
    {
        Display* xdisplay = wxGlobalDisplay();
        int xscreen = DefaultScreen( xdisplay );
        Visual* xvisual = DefaultVisual( xdisplay, xscreen );

        Colormap xcolormap = DefaultColormapOfScreen( XScreenOfDisplay( xdisplay, xscreen ) );

        XftDraw *draw = XftDrawCreate( xdisplay, drawable, xvisual, xcolormap );
        XftColor color;
        color.pixel = 0;
        color.color.red = colour.Red() << 8;
        color.color.green = colour.Green() << 8;
        color.color.blue = colour.Blue() << 8;
        color.color.alpha = 65000;
        pango_xft_render( draw, &color, font, glyphs, x, y );

        XftDrawDestroy( draw );
    }
}
예제 #10
0
파일: drw.c 프로젝트: Cornu/dwm
void
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text) {
	char buf[256];
	int i, tx, ty, th, len, olen;
	Extnts tex;
	XftDraw *d;

	if(!drw || !drw->scheme)
		return;
	XSetForeground(drw->dpy, drw->gc, drw->scheme->bg->rgb);
	XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
	if(!text || !drw->font)
		return;
	olen = strlen(text);
	drw_font_getexts(drw, text, olen, &tex);
	/* shorten text if necessary */
	for(len = MIN(olen, sizeof buf); len && (tex.w > w - tex.h || w < tex.h); len--)
		drw_font_getexts(drw, text, len, &tex);
	if(!len)
		return;
	memcpy(buf, text, len);
	if(len < olen)
		for(i = len; i && i > len - 3; buf[--i] = '.');

	th = drw->font->ascent + drw->font->descent;
	ty = y + (h / 2) - (th / 2) + drw->font->ascent;
	tx = x + (w / 2) - (tex.w / 2);
	d = XftDrawCreate(drw->dpy, drw->drawable, DefaultVisual(drw->dpy, drw->screen), DefaultColormap(drw->dpy, drw->screen));
	XftDrawStringUtf8(d, &drw->scheme->fg->xftc, drw->font->xfont, tx, ty, (XftChar8 *) buf, len);
	XftDrawDestroy(d);
}
예제 #11
0
//=========================================
// setText
//-----------------------------------------
XImage* setText (Display* dpy,int screen,char* text, int* x, int* y) {
	Window root = RootWindow    ( dpy,screen );
	int DWidth  = DisplayWidth  ( dpy,screen );
	int DHeight = DisplayHeight ( dpy,screen );

	XftPattern *pattern = NULL;
	XftFont*  FTfont    = NULL;
	XftDraw*  FTdraw    = NULL;
	XftColor* FTcolor   = NULL;
	XImage*   Image     = NULL;

	XGlyphInfo FTinfo;
	XColor color;
	XGCValues values;
	int XTwidth;
	int XTheight;
	int x1,y1;

	pattern = XftNameParse (XFTFONT);
	pattern = XftFontMatch (dpy,screen,pattern,NULL);
	FTfont  = XftFontOpenPattern (dpy, pattern);
	XftTextExtentsUtf8 (
		dpy,FTfont,text,strlen(text),&FTinfo
	);
	XTwidth = FTinfo.xOff;
	XTheight= FTfont->height + 20;
	FTdraw  = XftDrawCreate (
		dpy, root, DefaultVisual(dpy,screen),DefaultColormap(dpy,screen)
	);
	FTcolor = (XftColor*)malloc(sizeof(XftColor));
	color.red   = 255 << 8;
	color.green = 255 << 8;
	color.blue  = 255 << 8;
	XAllocColor (dpy,DefaultColormap(dpy,screen),&color);
	XSetForeground(dpy,DefaultGC (dpy,screen),color.pixel);
	XGetGCValues (
		dpy, DefaultGC (dpy,screen),
		GCForeground | GCBackground, &values
	);
	FTcolor->color.red   = color.red;
	FTcolor->color.green = color.green;
	FTcolor->color.blue  = color.blue;
	FTcolor->color.alpha = 0xffff;

	x1 = (int)((DWidth  / 2) - (XTwidth  / 2));
	y1 = (int)((DHeight / 2) - (XTheight / 2));

	XftDrawStringUtf8 (
		FTdraw, FTcolor,FTfont,x1,y1,text,strlen(text)
	);
	XFlush (dpy);
	y1 = (int)((DHeight / 2) - XTheight);
	Image = XGetImage(
		dpy,root,x1,y1,XTwidth,XTheight,AllPlanes,XYPixmap
	);
	*x = x1;
	*y = y1;
	return (Image);
}
예제 #12
0
파일: draw.c 프로젝트: fsckoff/minimusWM
/** Draw a string in a Drawable
 * \param d Drawable
 * \param x X position
 * \param y Y position
 * \param fg Foreground text color
 * \param pad Text padding
 * \param str String that will be draw
*/
void
draw_image_ofset_text(Drawable d, int x, int y, char* fg, char *str, int x_image_ofset, int y_image_ofset)
{
     XftColor xftcolor;
     XftDraw *xftd;
#ifdef HAVE_IMLIB
     char *ostr = NULL;
     int i, ni, sw = 0;
     ImageAttr im[128];
     size_t textlen;
#else
     (void)x_image_ofset;
     (void)y_image_ofset;
#endif /* HAVE_IMLIB */

     if(!str)
          return;

     /* To draw image everywhere we can draw text */
#ifdef HAVE_IMLIB

     ostr = xstrdup(str);
     textlen = strlen(ostr);

     if(strstr(str, "i["))
     {
          ni = parse_image_block(im, str);

          if(infobar[conf.systray.screen].bar && d == infobar[conf.systray.screen].bar->dr)
               sw = systray_get_width();

          for(i = 0; i < ni; ++i)
               draw_image(d, x_image_ofset + im[i].x - sw, y_image_ofset + im[i].y, im[i].w, im[i].h, im[i].name);
     }
#endif /* HAVE_IMLIB */

     /* Transform X Drawable -> Xft Drawable */
     xftd = XftDrawCreate(dpy, d, DefaultVisual(dpy, SCREEN), DefaultColormap(dpy, SCREEN));

     /* Alloc text color */
     XftColorAllocName(dpy, DefaultVisual(dpy, SCREEN),
                       DefaultColormap(dpy, SCREEN), fg, &xftcolor);

     XftDrawStringUtf8(xftd, &xftcolor, font, x, y, (FcChar8 *)str, strlen(str));

     /* Free the text color and XftDraw */
     XftColorFree(dpy, DefaultVisual(dpy, SCREEN), DefaultColormap(dpy, SCREEN), &xftcolor);

     XftDrawDestroy(xftd);

#ifdef HAVE_IMLIB
     if(strstr(ostr, "i["))
          strncpy(str, ostr, textlen);

     free(ostr);
#endif /* HAVE_IMLIB */

     return;
}
예제 #13
0
void ImageDraw::Init()
{
	GuiLock __;
	dw = XCreatePixmap(Xdisplay, Xroot, max(size.cx, 1), max(size.cy, 1), Xdepth);
	gc = XCreateGC(Xdisplay, dw, 0, 0);
	xftdraw = XftDrawCreate(Xdisplay, (Drawable) dw, DefaultVisual(Xdisplay, Xscreenno), Xcolormap);

	alpha.dw = XCreatePixmap(Xdisplay, Xroot, max(size.cx, 1), max(size.cy, 1), Xdepth);
	alpha.gc = XCreateGC(Xdisplay, alpha.dw, 0, 0);
	alpha.xftdraw = XftDrawCreate(Xdisplay, (Drawable) alpha.dw, DefaultVisual(Xdisplay, Xscreenno), Xcolormap);

	Vector<Rect> clip;
	clip.Add(RectC(0, 0, size.cx, size.cy));
	SystemDraw::Init(clip, Point(0, 0));
	alpha.Init(clip, Point(0, 0));

	has_alpha = false;
}
예제 #14
0
파일: x11.c 프로젝트: NattyNarwhal/edit
static int
init()
{
	XWindowAttributes wa;
	XSetWindowAttributes swa;
	XGCValues gcv;
	Window root;
	XConfigureEvent ce;

	d = XOpenDisplay(0);
	if (!d)
		die("cannot open display");
	root = DefaultRootWindow(d);
	XGetWindowAttributes(d, root, &wa);
	visual = wa.visual;
	cmap = wa.colormap;
	screen = DefaultScreen(d);
	depth = DefaultDepth(d, screen);

	/* create the main window */
	win = XCreateSimpleWindow(d, root, 0, 0, Width, Height, 0, 0,
	                          WhitePixel(d, screen));
	swa.backing_store = WhenMapped;
	swa.bit_gravity = NorthWestGravity;
	XChangeWindowAttributes(d, win, CWBackingStore|CWBitGravity, &swa);
	XStoreName(d, win, "ED");
	XSelectInput(d, win, StructureNotifyMask|ButtonPressMask|ButtonReleaseMask|Button1MotionMask|KeyPressMask|ExposureMask);

	/* simulate an initial resize and map the window */
	ce.type = ConfigureNotify;
	ce.width = Width;
	ce.height = Height;
	XSendEvent(d, win, False, StructureNotifyMask, (XEvent *)&ce);
	XMapWindow(d, win);

	/* allocate font */
	font = XftFontOpenName(d, screen, FONTNAME);
	if (!font)
		die("cannot open default font");

	/* initialize gc */
	gcv.foreground = WhitePixel(d, screen);
	gcv.graphics_exposures = False;
	gc = XCreateGC(d, win, GCForeground|GCGraphicsExposures, &gcv);

	/* initialize back buffer and Xft drawing context */
	pbuf = XCreatePixmap(d, win, Width, Height, depth);
	xft = XftDrawCreate(d, pbuf, visual, cmap);

	/* set the action rectangle */
	gui_x11.actionr.w = HMargin - 3;
	gui_x11.actionr.h = VMargin + font->height;

	return XConnectionNumber(d);
}
예제 #15
0
파일: Logo.c 프로젝트: aosm/X11
static void
RenderPrepare (LogoWidget w)
{
    if (!w->logo.draw)
    {
	w->logo.draw = XftDrawCreate (XtDisplay (w), XtWindow (w),
				       DefaultVisual (XtDisplay (w),
						      DefaultScreen(XtDisplay (w))),
				       w->core.colormap);
    }
}
예제 #16
0
int
createWin(XDataStr *data)
{
    u_long attributeMask;
    XSetWindowAttributes attribute;
    Window w;
    Display *display = data->display;
    int screen = DefaultScreen(display);
    XGCValues gc_val;
    Screen *s;

    attribute.background_pixel = WhitePixel(display, screen);
    attribute.border_pixel = WhitePixel(display, screen);
    attribute.bit_gravity = NorthWestGravity;
    attribute.event_mask = ButtonPressMask|ButtonReleaseMask|KeyPressMask|
        ExposureMask;

    attributeMask =
        CWBorderPixel |
        CWBackPixel |
        CWEventMask |
        CWBitGravity;
    s = ScreenOfDisplay(data->display, screen);

    w = XCreateWindow(display, RootWindow(display, screen), 0, 0,
            DisplayWidth(display, screen)/2, 150,
            0, DefaultDepth(display, screen), InputOutput,
            DefaultVisual(display, screen), attributeMask, &attribute);

    data->font = XftFontOpen(display, screen,
            XFT_FAMILY, XftTypeString, "mono",
            XFT_SIZE, XftTypeInteger, 16,
            NULL);
    if (!XftColorAllocName(display, XDefaultVisual(display, screen),
                DefaultColormap(display, screen), "red4", &data->color)) {
        fprintf(stderr, "cannot get color");
        return -1;
    }
    if (!XftColorAllocName(display, XDefaultVisual(display, screen),
                DefaultColormap(display, screen), "linen", &data->bg)) {
        fprintf(stderr, "cannot get bg color");
        return -1;
    }
    data->draw = XftDrawCreate(display, w, DefaultVisual(display, screen),
            DefaultColormap(display, screen));
    gc_val.foreground = BlackPixel(display, screen);
    gc_val.background = WhitePixel(display, screen);
    data->gc = XCreateGC (display, w, GCForeground|GCBackground,
            &gc_val);

    data->win = w;
    return 0;
}
예제 #17
0
파일: text_xft.c 프로젝트: burzumishi/e16
int
_xft_FdcInit(TextState * ts, Win win, EX_Drawable draw)
{
   FontCtxXft         *fdc = (FontCtxXft *) ts->fdc;

   fdc->win = win;
   fdc->draw = draw;

   fdc->xftd = XftDrawCreate(disp, draw, WinGetVisual(win), WinGetCmap(win));
   if (!fdc->xftd)
      return -1;
   return 0;
}
예제 #18
0
파일: xview.c 프로젝트: sonald/semacs
void se_text_xviewer_draw_create( se_text_xviewer* viewer )
{
    assert ( viewer->env->xftFont );

    if ( viewer->xftDraw ) {
        XftDrawDestroy( viewer->xftDraw );
        viewer->xftDraw = NULL;
    }
    
    viewer->xftDraw = XftDrawCreate(
        viewer->env->display, viewer->view, viewer->env->visual,
        viewer->env->colormap );
}
예제 #19
0
파일: font.c 프로젝트: dct/xvnkb
/*----------------------------------------------------------------------------*/
void VKDrawFontDialog()
{
    static char *titles[2] = {"Select interface font", "Chọn font giao dien"};
    static char *mesages[] = {"Press a key group:", "Nhấn một nhóm phím:"};
    char *S = mesages[vk_interface];
    char *T = titles[vk_interface];
    int i, fa = vk_text_ascent;

#ifdef USE_XFT
    XftDraw *draw;
    draw = XftDrawCreate(display, fnt.window, visual, colormap);
#else
#define	draw
#endif

    XClearWindow(display, fnt.window);
    VKSetColor(display, fnt.gc, clBackground);
    XFillRectangle(display, fnt.window, fnt.gc, 0, 0, fnt.width, fnt.height);
    VKSetColor(display, fnt.gc, clBorder);
    XDrawRectangle(display, fnt.window, fnt.gc, 1, 1, fnt.width-3, fnt.height-3);
    XFillRectangle(display, fnt.window, fnt.gc, 1, 1, fnt.width-3, vk_text_height+6);
    XDrawLine(display, fnt.window, fnt.gc, 1, fnt.ly, fnt.width-3, fnt.ly);
    for( i=0; i<3; i++ ) {
        VKDrawLabel((VKLabel *)fc[i]);
    }
#ifdef USE_XFT
    XftDrawStringUtf8(draw, &clBlack, vk_font,
                      11, fa+5+1, (XftChar8*)T, strlen(T));
    XftDrawStringUtf8(draw, &clWhite, vk_font,
                      10, fa+5, (XftChar8*)T, strlen(T));
    XftDrawStringUtf8(draw, &clGray, vk_font,
                      fnt.tx+1, fnt.ty+1, (XftChar8*)S, strlen(S));
    XftDrawStringUtf8(draw, &clBlack, vk_font,
                      fnt.tx, fnt.ty, (XftChar8*)S, strlen(S));
    XftDrawDestroy(draw);
#else
#undef draw
    VKSetColor(display, fnt.gc, clBlack);
    XmbDrawString(display, fnt.window, vk_fontset, fnt.gc,
                  11, fa+5+1, T, strlen(T));
    VKSetColor(display, fnt.gc, clWhite);
    XmbDrawString(display, fnt.window, vk_fontset, fnt.gc,
                  10, fa+5, T, strlen(T));
    VKSetColor(display, fnt.gc, clGray);
    XmbDrawString(display, fnt.window, vk_fontset, fnt.gc,
                  fnt.tx+1, fnt.ty+1, S, strlen(S));
    VKSetColor(display, fnt.gc, clBlack);
    XmbDrawString(display, fnt.window, vk_fontset, fnt.gc,
                  fnt.tx, fnt.ty, S, strlen(S));
#endif
}
예제 #20
0
파일: draw.c 프로젝트: wm4/dunst
void
resizedc(DC *dc, unsigned int w, unsigned int h) {
    if(dc->canvas)
        XFreePixmap(dc->dpy, dc->canvas);

    dc->w = w;
    dc->h = h;
    dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
                               DefaultDepth(dc->dpy, DefaultScreen(dc->dpy)));

    dc->xftdrawable = XftDrawCreate(dc->dpy, dc->canvas, DefaultVisual(dc->dpy,screen), DefaultColormap(dc->dpy,screen));
    if(!dc->xftdrawable)
        eprintf("cannot create drawable\n");
}
예제 #21
0
파일: nenu.c 프로젝트: mytchel/nenu
void setup() {
	XSetWindowAttributes attributes;
	XWindowAttributes window_attributes;
	Visual *vis;
	Colormap cmap;
	int ignore;
	
	display = XOpenDisplay(NULL);
	screen = DefaultScreen(display);
	vis = XDefaultVisual(display, screen);
	cmap = DefaultColormap(display, screen);

	if (XGetGeometry(display, RootWindow(display, screen), &root,
	        &ignore, &ignore,
	        &max_width, &max_height, &ignore, &ignore) == False)
	        die("Failed to get root Geometry!");

	if (!XftColorAllocName(display, vis, cmap, fg_name, &fg))
		die("Failed to allocate foreground color");
	if (!XftColorAllocName(display, vis, cmap, bg_name, &bg))
		die("Failed to allocate background color");

	/* Setup and map window */
	attributes.border_pixel = fg.pixel;
	attributes.background_pixel = bg.pixel;
	attributes.override_redirect = True;
	attributes.event_mask = 
	     ExposureMask|KeyPressMask|ButtonPressMask|ButtonReleaseMask;

	win = XCreateWindow(display, root,
	     0, 0, 1, 1, BORDER_WIDTH,
	     DefaultDepth(display, 0),
	     CopyFromParent, CopyFromParent,
	     CWBackPixel|CWOverrideRedirect|CWEventMask|CWBorderPixel,
	     &attributes);

	xim = XOpenIM(display, NULL, NULL, NULL);
	xic = XCreateIC(xim, XNInputStyle, 
	    XIMPreeditNothing | XIMStatusNothing,
	    XNClientWindow, win, XNFocusWindow, win, NULL);

	gc = XCreateGC(display, win, 0, 0);

	buf = XCreatePixmap(display, win, 1, 1, 
	                    DefaultDepth(display, screen));
	    
	draw = XftDrawCreate(display, buf, vis, cmap);

	load_font(font_str);
}
예제 #22
0
파일: config.c 프로젝트: segin/matwm2
void cfg_reinitialize(void) {
	int i;
	#ifdef USE_XFT
	int xft = xftfont ? 1 : 0;
	#endif
	/* free things from old configuration */
	XFreeGC(dpy, gc);
	XFreeGC(dpy, igc);
	XFreeGC(dpy, bgc);
	XFreeGC(dpy, ibgc);
	keys_free();
	/* read config again */
	cfg_read(0);
	/* update some things */
	p_attr.background_pixel = fg.pixel;
	p_attr.border_pixel = ibfg.pixel;
	select_root_events();
	/* update clients */
	for(i = 0; i < cn; i++) {
		#ifdef USE_XFT
		if(xftfont && !xft)
			clients[i]->wlist_draw = XftDrawCreate(dpy, clients[i]->wlist_item, visual, colormap);
		if(!xftfont && xft) {
			XftDrawDestroy(clients[i]->title_draw);
			XftDrawDestroy(clients[i]->wlist_draw);
		}
		#endif
		XDestroyWindow(dpy, clients[i]->button_parent_left);
		XDestroyWindow(dpy, clients[i]->button_parent_right);
		free((void *) clients[i]->buttons);
		clients[i]->flags ^= clients[i]->flags & HAS_BUTTONS;
		buttons_create(clients[i]); /* buttons are now on top of the client window */
		XRaiseWindow(dpy, clients[i]->window); /* hence this line */
		client_update(clients[i]);
		client_update_name(clients[i]);
		(clients[i] == current) ? client_set_bg(clients[i], bg, fg) : client_set_bg(clients[i], ibg, ifg);
		if(clients[i]->flags & IS_TASKBAR)
			client_set_layer(clients[i], taskbar_ontop ? TOP : NORMAL);
		XUngrabButton(dpy, AnyButton, AnyModifier, clients[i]->parent);
		client_grab_buttons(clients[i]);
		if(clients[i]->flags & FULLSCREEN && clients[i]->layer <= NORMAL && fullscreen_stacking != FS_NORMAL)
			client_update_layer(clients[i], (fullscreen_stacking == FS_ALWAYS_ONTOP) ? NORMAL : TOP);
		if(clients[i]->flags & HAS_BORDER)
			XSetWindowBorderWidth(dpy, clients[i]->parent, border_width);
		ewmh_update_extents(clients[i]);
	}
	ewmh_update_number_of_desktops();
	ewmh_update_geometry();
	ewmh_update_strut();
}
예제 #23
0
파일: taskbar.c 프로젝트: no0p/windowlab
void make_taskbar(void)
{
	XSetWindowAttributes pattr;

	pattr.override_redirect = True;
	pattr.background_pixel = empty_col.pixel;
	pattr.border_pixel = border_col.pixel;
	pattr.event_mask = ChildMask|ButtonPressMask|ExposureMask|EnterWindowMask;
	taskbar = XCreateWindow(dsply, root, 0 - DEF_BORDERWIDTH, 0 - DEF_BORDERWIDTH, DisplayWidth(dsply, screen), BARHEIGHT() - DEF_BORDERWIDTH, DEF_BORDERWIDTH, DefaultDepth(dsply, screen), CopyFromParent, DefaultVisual(dsply, screen), CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr);

	XMapWindow(dsply, taskbar);

#ifdef XFT
	tbxftdraw = XftDrawCreate(dsply, (Drawable) taskbar, DefaultVisual(dsply, DefaultScreen(dsply)), DefaultColormap(dsply, DefaultScreen(dsply)));
#endif
}
예제 #24
0
파일: draw.c 프로젝트: nileshp87/tint3
void resizedc(DC * dc, unsigned int w, unsigned int h, XVisualInfo * vinfo, XSetWindowAttributes * wa) {
    if(dc->canvas)
        XFreePixmap(dc->dpy, dc->canvas);
    dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
                               vinfo -> depth);
    dc->empty = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
                               vinfo -> depth);
    dc->x = dc->y = 0;
    dc->w = w;
    dc->h = h;
    if(dc->font.xft_font && !(dc->xftdraw)) {
        dc->xftdraw = XftDrawCreate(dc->dpy, dc->canvas, vinfo->visual, wa -> colormap);
        if(!(dc->xftdraw))
            printf("error, cannot create xft drawable\n");
    }
}
예제 #25
0
파일: draw.c 프로젝트: francescarpi/midwm
void
resizedc(DC *dc, unsigned int w, unsigned int h) {
	int screen = DefaultScreen(dc->dpy);
	if(dc->canvas)
		XFreePixmap(dc->dpy, dc->canvas);

	dc->w = w;
	dc->h = h;
	dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
	                           DefaultDepth(dc->dpy, screen));
	if(dc->font.xft_font && !(dc->xftdraw)) {
		dc->xftdraw = XftDrawCreate(dc->dpy, dc->canvas, DefaultVisual(dc->dpy,screen), DefaultColormap(dc->dpy,screen));
		if(!(dc->xftdraw))
			eprintf("error, cannot create xft drawable\n");
	}
}
예제 #26
0
void BC_Pixmap::resize(int w, int h)
{
	Pixmap new_pixmap = XCreatePixmap(top_level->display, 
			top_level->win, 
			w, 
			h, 
			top_level->default_depth);
#ifdef HAVE_XFT
	XftDraw *new_xft_draw;
	if(BC_WindowBase::get_resources()->use_xft)
	{
		new_xft_draw = XftDrawCreate(top_level->display,
		       new_pixmap,
		       top_level->vis,
		       top_level->cmap);
	}
#endif




	XCopyArea(top_level->display,
		opaque_pixmap,
		new_pixmap,
		top_level->gc,
		0,
		0,
		get_w(),
		get_h(),
		0,
		0);
	this->w = w;
	this->h = h;
#ifdef HAVE_XFT
	if(BC_WindowBase::get_resources()->use_xft)
		XftDrawDestroy((XftDraw*)opaque_xft_draw);
#endif
	XFreePixmap(top_level->display, opaque_pixmap);

	opaque_pixmap = new_pixmap;
#ifdef HAVE_XFT
	if(BC_WindowBase::get_resources()->use_xft)
		opaque_xft_draw = new_xft_draw;
#endif
}
예제 #27
0
void InitXlibMenu(XlibMenu* menu)
{
    FcitxLightUI* lightui = menu->owner;
    char        strWindowName[]="Fcitx Menu Window";
    XSetWindowAttributes attrib;
    unsigned long   attribmask;
    int depth;
    Colormap cmap;
    Visual * vs;
    XGCValues xgv;
    GC gc;
    Display* dpy = lightui->dpy;
    int iScreen = lightui->iScreen;

    vs= NULL;
    LightUIInitWindowAttribute(lightui, &vs, &cmap, &attrib, &attribmask, &depth);

    //开始只创建一个简单的窗口不做任何动作
    menu->menuWindow =XCreateWindow (dpy,
                                     RootWindow (dpy, iScreen),
                                     0, 0,
                                     MENU_WINDOW_WIDTH,MENU_WINDOW_HEIGHT,
                                     0, depth, InputOutput,
                                     vs, attribmask, &attrib);

    if (menu->menuWindow == (Window) NULL)
        return;

    XSetTransientForHint (dpy, menu->menuWindow, DefaultRootWindow (dpy));

    menu->pixmap = XCreatePixmap(dpy,
                                 menu->menuWindow,
                                 MENU_WINDOW_WIDTH,
                                 MENU_WINDOW_HEIGHT,
                                 depth);

    menu->xftDraw = XftDrawCreate(dpy, menu->pixmap, DefaultVisual (dpy, DefaultScreen (dpy)), DefaultColormap (dpy, DefaultScreen (dpy)));

    XSelectInput (dpy, menu->menuWindow, KeyPressMask | ExposureMask | ButtonPressMask | ButtonReleaseMask  | PointerMotionMask | LeaveWindowMask | StructureNotifyMask );

    LightUISetWindowProperty(lightui, menu->menuWindow, FCITX_WINDOW_MENU, strWindowName);

    menu->iPosX=100;
    menu->iPosY=100;
}
예제 #28
0
static XftDraw *
xftfont_get_xft_draw (struct frame *f)
{
  XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);

  if (! xft_draw)
    {
      block_input ();
      xft_draw= XftDrawCreate (FRAME_X_DISPLAY (f),
			       FRAME_X_WINDOW (f),
			       FRAME_X_VISUAL (f),
			       FRAME_X_COLORMAP (f));
      unblock_input ();
      eassert (xft_draw != NULL);
      font_put_frame_data (f, &xftfont_driver, xft_draw);
    }
  return xft_draw;
}
예제 #29
0
파일: xftfont.c 프로젝트: Sunmonds/emacs
static XftDraw *
xftfont_get_xft_draw (FRAME_PTR f)
{
  XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);

  if (! xft_draw)
    {
      BLOCK_INPUT;
      xft_draw= XftDrawCreate (FRAME_X_DISPLAY (f),
			       FRAME_X_WINDOW (f),
			       FRAME_X_VISUAL (f),
			       FRAME_X_COLORMAP (f));
      UNBLOCK_INPUT;
      if (! xft_draw)
	abort ();
      font_put_frame_data (f, &xftfont_driver, xft_draw);
    }
  return xft_draw;
}
예제 #30
0
파일: window.c 프로젝트: muennich/sxiv
void win_draw_bar(win_t *win)
{
	int len, x, y, w, tw;
	win_env_t *e;
	win_bar_t *l, *r;
	XftDraw *d;
	const XftColor *bg, *fg;

	if ((l = &win->bar.l)->buf == NULL || (r = &win->bar.r)->buf == NULL)
		return;

	e = &win->env;
	y = win->h + font->ascent + V_TEXT_PAD;
	w = win->w - 2*H_TEXT_PAD;
	d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr),
	                  DefaultColormap(e->dpy, e->scr));

	if (win->fullscreen && !win->light)
		bg = &win->bg, fg = &win->fg;
	else
		bg = &win->fg, fg = &win->bg;

	XSetForeground(e->dpy, gc, bg->pixel);
	XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);

	XSetForeground(e->dpy, gc, fg->pixel);
	XSetBackground(e->dpy, gc, bg->pixel);

	if ((len = strlen(r->buf)) > 0) {
		if ((tw = TEXTWIDTH(win, r->buf, len)) > w)
			return;
		x = win->w - tw - H_TEXT_PAD;
		w -= tw;
		win_draw_text(win, d, fg, x, y, r->buf, len, tw);
	}
	if ((len = strlen(l->buf)) > 0) {
		x = H_TEXT_PAD;
		w -= 2 * H_TEXT_PAD; /* gap between left and right parts */
		win_draw_text(win, d, fg, x, y, l->buf, len, w);
	}
	XftDrawDestroy(d);
}