Ejemplo n.º 1
0
Archivo: imlib2.c Proyecto: rdebath/sgt
void image_to_pixmap(image *img, GdkPixmap *pm, int w, int h)
{
    int realw, realh;
    int need_free;

    imlib_context_set_image(img->image);
    realw = imlib_image_get_width();
    realh = imlib_image_get_height();
    if (w != realw || h != realh) {
	Imlib_Image newimg;

	newimg = imlib_create_cropped_scaled_image(0, 0, realw, realh, w, h);
	imlib_context_set_image(newimg);
	need_free = TRUE;
    } else
	need_free = FALSE;

    imlib_context_set_display(GDK_WINDOW_XDISPLAY(pm));
    imlib_context_set_visual(GDK_VISUAL_XVISUAL(gdk_visual_get_system()));
    imlib_context_set_colormap
	(GDK_COLORMAP_XCOLORMAP(gdk_colormap_get_system()));
    imlib_context_set_drawable(GDK_WINDOW_XWINDOW(pm));
    imlib_context_set_blend(1);
    imlib_render_image_on_drawable(0, 0);

    if (need_free)
	imlib_free_image();
}
Ejemplo n.º 2
0
/** Draw an image in a drawable
  * \param dr Drawable
  * \param x X position
  * \param y Y position
  * \param name Path of the image
*/
static void draw_image(Drawable dr, int x, int y, int w, int h, char *name)
{
     Imlib_Image image;

     if(!name)
          return;

     imlib_set_cache_size(2048 * 1024);
     imlib_context_set_display(dpy);
     imlib_context_set_visual(DefaultVisual(dpy, DefaultScreen(dpy)));
     imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));
     imlib_context_set_drawable(dr);

     image = imlib_load_image(patht(name));
     imlib_context_set_image(image);

     if(w <= 0)
          w = imlib_image_get_width();

     if(h <= 0)
          h = imlib_image_get_height();

     if(image)
     {
          imlib_render_image_on_drawable_at_size(x, y, w, h);
          imlib_free_image();
     }
     else
          warnx("Can't draw image: '%s'", name);

     return;
}
Ejemplo n.º 3
0
Archivo: image.c Proyecto: Xender/sxiv
void img_init(img_t *img, win_t *win)
{
	zoom_min = zoom_levels[0] / 100.0;
	zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;

	if (img == NULL || win == NULL)
		return;

	imlib_context_set_display(win->env.dpy);
	imlib_context_set_visual(win->env.vis);
	imlib_context_set_colormap(win->env.cmap);

	img->im = NULL;
	img->win = win;
	img->zoom = options->zoom;
	img->zoom = MAX(img->zoom, zoom_min);
	img->zoom = MIN(img->zoom, zoom_max);
	img->checkpan = false;
	img->dirty = false;
	img->aa = RENDER_ANTI_ALIAS;
	img->alpha = !RENDER_WHITE_ALPHA;
	img->multi.cap = img->multi.cnt = 0;
	img->multi.animate = false;

	img->cmod = imlib_create_color_modifier();
	img->gamma = MIN(MAX(options->gamma, -GAMMA_RANGE), GAMMA_RANGE);
}
Ejemplo n.º 4
0
void img_init(img_t *img, win_t *win) {
	zoom_min = zoom_levels[0] / 100.0;
	zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;

	if (img == NULL || win == NULL)
		return;

	imlib_context_set_display(win->env.dpy);
	imlib_context_set_visual(win->env.vis);
	imlib_context_set_colormap(win->env.cmap);

	img->im = NULL;
	img->win = win;
	img->zoom = options->zoom;
	img->zoom = MAX(img->zoom, zoom_min);
	img->zoom = MIN(img->zoom, zoom_max);
	img->checkpan = false;
	img->dirty = false;
	img->aa = options->aa;
	img->alpha = true;
	img->slideshow = false;
	img->ss_delay = SLIDESHOW_DELAY * 1000;
	img->multi.cap = img->multi.cnt = 0;
	img->multi.animate = false;
}
Ejemplo n.º 5
0
void init_x_and_imlib(void)
{
	disp = XOpenDisplay(NULL);
	if (!disp)
		eprintf("Can't open X display. It *is* running, yeah?");
	vis = DefaultVisual(disp, DefaultScreen(disp));
	depth = DefaultDepth(disp, DefaultScreen(disp));
	cm = DefaultColormap(disp, DefaultScreen(disp));
	root = RootWindow(disp, DefaultScreen(disp));
	scr = ScreenOfDisplay(disp, DefaultScreen(disp));
	xid_context = XUniqueContext();

#ifdef HAVE_LIBXINERAMA
	init_xinerama();
#endif				/* HAVE_LIBXINERAMA */

	imlib_context_set_display(disp);
	imlib_context_set_visual(vis);
	imlib_context_set_colormap(cm);
	imlib_context_set_color_modifier(NULL);
	imlib_context_set_progress_function(NULL);
	imlib_context_set_operation(IMLIB_OP_COPY);
	wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False);

	/* Initialise random numbers */
	srand(getpid() * time(NULL) % ((unsigned int) -1));

	return;
}
Ejemplo n.º 6
0
/* initialisation function.   */
static tvalue im2_init(Display *disp)
{
  Visual    *vis;
  Colormap  cm;
  int       depth;

  imlib_set_cache_size(sequ_config_imlib_cache_size*1048576);
  imlib_set_color_usage(sequ_config_imlib_color_usage);
  imlib_context_set_dither(sequ_config_imlib_dither);
  imlib_context_set_anti_alias(sequ_config_imlib_anti_alias);  
  
  if(im2_initialized == TRUE)
    return TRUE;
 
  if(!disp)
    return FALSE;

  vis   = DefaultVisual(disp, DefaultScreen(disp));
  depth = DefaultDepth(disp, DefaultScreen(disp));
  cm    = DefaultColormap(disp, DefaultScreen(disp));

  imlib_context_set_display(disp);
  imlib_context_set_visual(vis);
  imlib_context_set_colormap(cm);
  
  im2_initialized=TRUE;

  return TRUE;
}
Ejemplo n.º 7
0
int xtwitter_xaw_init(){
    int argc = 0;
    XInitThreads();
    XtSetLanguageProc(NULL, NULL, NULL);
    widget_shell = XtAppInitialize(&context, PACKAGE, NULL, 0, &argc, NULL,
                                   default_resources, NULL, 0);

    widget_tl_viewport = XtVaCreateManagedWidget(
        "wdget_tl_viewport",
        viewportWidgetClass,
        widget_shell,
        XtNallowVert, True,
        XtNuseRight, True,
        XtNforceBars, True,
        NULL);

    widget_tl_form = XtVaCreateManagedWidget(
        "widget_tl_form",
        formWidgetClass,
        widget_tl_viewport,
        XtNdefaultDistance, 10,
        NULL);

    XtRealizeWidget(widget_shell);
    XFlush(XtDisplay(widget_shell));

    imlib_context_set_display(XtDisplay(widget_shell));
    imlib_context_set_visual(DefaultVisual(XtDisplay(widget_shell), 0));
    imlib_context_set_colormap(DefaultColormap(XtDisplay(widget_shell), 0));

    return 0;
}
Ejemplo n.º 8
0
Archivo: image.c Proyecto: kkb7401/sxiv
void img_init(img_t *img, win_t *win)
{
	zoom_min = zoom_levels[0] / 100.0;
	zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;

	if (img == NULL || win == NULL)
		return;

	imlib_context_set_display(win->env.dpy);
	imlib_context_set_visual(win->env.vis);
	imlib_context_set_colormap(win->env.cmap);

	img->im = NULL;
	img->win = win;
	img->scalemode = options->scalemode;
	img->zoom = options->zoom;
	img->zoom = MAX(img->zoom, zoom_min);
	img->zoom = MIN(img->zoom, zoom_max);
	img->checkpan = false;
	img->dirty = false;
	img->aa = ANTI_ALIAS;
	img->alpha = ALPHA_LAYER;
	img->multi.cap = img->multi.cnt = 0;
	img->multi.animate = false;
	img->multi.length = img->multi.repeat = 0;

	img->cmod = imlib_create_color_modifier();
	img->gamma = MIN(MAX(options->gamma, -GAMMA_RANGE), GAMMA_RANGE);
	
	img->ss.on = options->slideshow > 0;
	img->ss.delay = options->slideshow > 0 ? options->slideshow : SLIDESHOW_DELAY;
}
Ejemplo n.º 9
0
void XDesktopContainer::initImlib()
{
    //Imlib2 stuff
    imlib_context_set_display(display);
    imlib_context_set_visual(DefaultVisual(display,DefaultScreen(display)) );
    imlib_context_set_colormap(DefaultColormap(display, 
                DefaultScreen(display)) );
}
Ejemplo n.º 10
0
Archivo: image.c Proyecto: pts/pts-qiv
static void setup_imlib_for_drawable(GdkDrawable * d)
{
  imlib_context_set_dither(1); /* dither for depths < 24bpp */
  imlib_context_set_display(
    gdk_x11_drawable_get_xdisplay(d));
  imlib_context_set_visual(
    gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(d)));
  imlib_context_set_colormap(
    gdk_x11_colormap_get_xcolormap(gdk_drawable_get_colormap(d)));
  imlib_context_set_drawable(
    gdk_x11_drawable_get_xid(d));
}
Ejemplo n.º 11
0
void init_X11() {
    server.dsp = XOpenDisplay(NULL);
    if (!server.dsp) DIE("tint: could not open display.");

    server_init_atoms();
    server.screen = DefaultScreen(server.dsp);
    server.root_win = RootWindow(server.dsp, server.screen);
    server.desktop = server_get_current_desktop();
    server_init_visual();
    XSetErrorHandler((XErrorHandler)server_catch_error);

#ifdef HAVE_SN
    // Initialize startup-notification
    server.sn_dsp = sn_display_new(server.dsp, error_trap_push, error_trap_pop);
    server.pids = g_tree_new(cmp_ptr);
    // Setup a handler for child termination
    struct sigaction act;
    memset(&act, 0, sizeof(struct sigaction));
    act.sa_handler = sigchld_handler;
    if (sigaction(SIGCHLD, &act, 0)) {
        perror("sigaction");
    }
#endif  // HAVE_SN

    imlib_context_set_display(server.dsp);
    imlib_context_set_visual(server.visual);
    imlib_context_set_colormap(server.colormap);

    /* Catch events */
    XSelectInput(server.dsp, server.root_win,
                 PropertyChangeMask | StructureNotifyMask);

    setlocale(LC_ALL, "");
    // config file use '.' as decimal separator
    setlocale(LC_NUMERIC, "POSIX");

    // load default icon
    gchar* path;
    const gchar* const* data_dirs;
    data_dirs = g_get_system_data_dirs();
    int i;
    for (i = 0; data_dirs[i] != NULL; i++) {
        path = g_build_filename(data_dirs[i], "tinto", "default_icon.png", NULL);
        if (g_file_test(path, G_FILE_TEST_EXISTS))
            default_icon = imlib_load_image(path);
        g_free(path);
    }

    // get monitor and desktop config
    get_monitors();
    get_desktops();
}
Ejemplo n.º 12
0
int command_line(int argc, const char **argv) {
	if ( !(dpy=XOpenDisplay(0x0)) ) exit(1);
	scr = DefaultScreen(dpy); root = DefaultRootWindow(dpy);
	sw = DisplayWidth(dpy,scr); sh = DisplayHeight(dpy,scr);
	int i; const char *c;
	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') break;
		if ( *(c=argv[i]+1) == '-' ) c++;
		if (*c == '\0') continue;
		if (*c == 'b') win = root;
	}
	if ( !(img=imlib_load_image(argv[i])) ) exit(2);;
	imlib_context_set_image(img);
	imlib_context_set_display(dpy);
	imlib_context_set_visual(DefaultVisual(dpy,scr));
	imlib_context_set_colormap(DefaultColormap(dpy,scr));
	iw = imlib_image_get_width();
	ih = imlib_image_get_height();
	imlib_context_set_anti_alias(0);
	imlib_context_set_dither(0);
	imlib_context_set_blend(0);
	XSetWindowAttributes wa;
	if (win == root) {
		Pixmap buf = XCreatePixmap(dpy,root,sw,sh,DefaultDepth(dpy,scr));
		imlib_context_set_drawable(buf);
		imlib_render_image_on_drawable_at_size(0, 0, sw, sh);
		wa.background_pixmap = buf;
		XSetWindowBackgroundPixmap(dpy,root,buf);
		XFlush(dpy);
		XFreePixmap(dpy,buf);
		XCloseDisplay(dpy);
		exit(0);
	}
	if (iw > mw) scale = mw / (float) iw;
	if (ih * scale > mh) scale = mh / (float) ih;
	ww = iw * scale + 0.5; wh = ih * scale + 0.5;
	wa.background_pixel = BlackPixel(dpy,scr);
	wa.event_mask = KeyPressMask | ExposureMask | StructureNotifyMask;
	win = XCreateWindow(dpy,root,0,0,ww,wh,0,DefaultDepth(dpy,scr),
			InputOutput, DefaultVisual(dpy,scr),CWEventMask|CWBackPixel,&wa);
	const char *name;
	if ( (name=strrchr(argv[i],'/')) ) name++;
	else name = argv[i];
	XStoreName(dpy,win,name);
	class.res_name = (char *) argv[0];
	class.res_class = "float";
	XSetClassHint(dpy,win,&class);
	XMapWindow(dpy,win); XFlush(dpy);
	imlib_context_set_drawable(win);
	return 0;
}
Ejemplo n.º 13
0
void
R_init_imlib2(struct R_app *app)
{
    imlib_context_set_display(app->display);
    imlib_context_set_visual(app->visual);
    imlib_context_set_colormap(app->colormap);
    imlib_context_set_blend(0);
    imlib_context_set_mask(0);
    imlib_set_cache_size(IMLIB2_CACHE_SIZE);
    imlib_set_font_cache_size(IMLIB2_FONT_CACHE_SIZE);
    imlib_add_path_to_font_path(RESURRECTION_FONT_SEARCH_PATH "ttf");

    return;
}
Ejemplo n.º 14
0
void
init_imlib(void)
{
  bg_image = imlib_load_image("/home/matt/gradient.jpg");

  /* imlib settings */
  imlib_set_cache_size(2048 * 1024);
  imlib_set_color_usage(128);
  imlib_context_set_dither(1);
  imlib_context_set_blend(1);
  imlib_context_set_display(disp);
  imlib_context_set_visual(vis);
  imlib_context_set_colormap(cm);
}
Ejemplo n.º 15
0
void init_render(struct xinfo *X, struct panel *P)
{
	bbwidth = P->width;
	bbheight = P->theme->height;
	bb = imlib_create_image(bbwidth, bbheight);
	bbcolor = imlib_create_image(bbwidth, bbheight);
	imlib_context_set_image(bb);
	imlib_image_set_has_alpha(1);
	bbdpy = X->display;
	bbvis = X->visual;
	bbwin = P->win;
	bbcm = X->colmap;
	bbx = P->x;
	bby = P->y;
	rootpmap = &X->rootpmap;
	theme = P->theme;

	imlib_context_set_display(bbdpy);
	imlib_context_set_visual(bbvis);
	imlib_context_set_colormap(bbcm);

#ifdef WITH_COMPOSITE
	if (P->theme->use_composite) {
		XRenderPictFormat *fmt = XRenderFindStandardFormat(bbdpy, PictStandardARGB32);
		bbalpha = imlib_create_image(bbwidth, bbheight);

		pixcolor = XCreatePixmap(bbdpy, bbwin, bbwidth, bbheight, 32);
		pixalpha = XCreatePixmap(bbdpy, bbwin, bbwidth, bbheight, 32);

		piccolor = XRenderCreatePicture(bbdpy, pixcolor, fmt, 0, 0);
		picalpha = XRenderCreatePicture(bbdpy, pixalpha, fmt, 0, 0);
	
		XRenderPictureAttributes pwin;
		pwin.subwindow_mode = IncludeInferiors;
		rootpic = XRenderCreatePicture(bbdpy, bbwin, XRenderFindVisualFormat(bbdpy, bbvis), 
				CPSubwindowMode, &pwin);
	} else 
#endif
	if (*rootpmap) {
		update_bg();
	} else {
		set_bg();
	}

	imlib_context_set_blend(0);
	imlib_context_set_operation(IMLIB_OP_COPY);
}
Ejemplo n.º 16
0
int init_x11() {
	if ((display = XOpenDisplay(NULL)) == NULL)
		dief("cannot open display");
	window = XCreateSimpleWindow(display, DefaultRootWindow(display),
			x, y, width, height, 0, 0, 0);
	XSelectInput(display, window, ExposureMask);
	XMapWindow(display, window);

	imlib_context_set_dither(1);
	imlib_context_set_anti_alias(1);
	imlib_context_set_display(display);
	imlib_context_set_visual(DefaultVisual(display, DefaultScreen(display)));
	imlib_context_set_colormap(DefaultColormap(display, DefaultScreen(display)));
	imlib_context_set_drawable(window);

	updates = imlib_updates_init();

	return ConnectionNumber(display);
}
Ejemplo n.º 17
0
void
tinto_init_x11 (void) {
  server.dsp = XOpenDisplay (getenv ("DISPLAY"));
  if (!server.dsp)
    DIE ("%s Failed to open display.", PROJECT_NAME);

  server_init_atoms ();
  server.screen = DefaultScreen (server.dsp);
  server.root_win = RootWindow (server.dsp, server.screen);
  server.desktop = server_get_current_desktop ();

  // config file use '.' as decimal separator
  setlocale (LC_ALL, "");
  setlocale (LC_NUMERIC, "POSIX");

  // get monitor and desktop config
  get_monitors ();
  get_desktops ();

  server.disable_transparency = 0;

  server_init_visual ();

  imlib_context_set_display (server.dsp);
  imlib_context_set_visual (server.visual);
  imlib_context_set_colormap (server.colormap);

  /* Catch events */
  XSelectInput (server.dsp, server.root_win,
		PropertyChangeMask | StructureNotifyMask);

  gchar *path;
  const gchar * const *data_dirs = g_get_system_data_dirs ();
  for (size_t i = 0; data_dirs[i] != NULL; ++i)	{
    path = g_build_filename (data_dirs[i], "tint2", "icon.png", NULL);
    if (g_file_test (path, G_FILE_TEST_EXISTS))
      default_icon = imlib_load_image (path);

    g_free (path);
  }
}
Ejemplo n.º 18
0
Archivo: bgs.c Proyecto: Gottox/bgs
/* set up imlib and X */
void
setup(char *paths[], int c, const char *col) {
	Visual *vis;
	Colormap cm;
	XColor color;
	int i, screen;

	/* Loading images */
	for(nimage = i = 0; i < c && i < LENGTH(images); i++) {
		if((images[nimage] = imlib_load_image_without_cache(paths[i])))
			nimage++;
		else {
			fprintf(stderr, "Warning: Cannot load file `%s`. "
					"Ignoring.\n", paths[nimage]);
			continue;
		}
	}
	if(nimage == 0)
		die("Error: No image to draw.\n");

	/* set up X */
	screen = DefaultScreen(dpy);
	vis = DefaultVisual(dpy, screen);
	cm = DefaultColormap(dpy, screen);
	root = RootWindow(dpy, screen);
	XSelectInput(dpy, root, StructureNotifyMask);
	sx = sy = 0;
	sw = DisplayWidth(dpy, screen);
	sh = DisplayHeight(dpy, screen);

	if(!XAllocNamedColor(dpy, cm, col, &color, &color))
		die("Error: Cannot allocate color.\n");

	/* set up Imlib */
	imlib_context_set_display(dpy);
	imlib_context_set_visual(vis);
	imlib_context_set_colormap(cm);
	imlib_context_set_color(color.red, color.green, color.blue, 255);
}
Ejemplo n.º 19
0
int
app_init_imlib2(struct R_app *app)
{
    if (app == NULL) {

	return -1;
    }

    imlib_context_set_display(app->display);
    imlib_context_set_visual(app->visual);
    imlib_context_set_colormap(app->colormap);
    imlib_context_set_drawable(app->window->win);
    imlib_context_set_blend(0);
    imlib_context_set_mask(0);
    imlib_set_font_cache_size(1024 * 1024);
#if 0
    imlib_add_path_to_font_path(RESURRECTION_FONT_SEARCH_PATH "ttf/");
#endif
    imlib_set_cache_size(4096 * 1024);

    return 0;
}
Ejemplo n.º 20
0
static void
draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data)
{
#if 0
	void *image;
	int w,h;
	printf("draw_image_warp data=%s\n", data);
	image = imlib_load_image(data);
	imlib_context_set_display(gdk_x11_drawable_get_xdisplay(gr->widget->window));
	imlib_context_set_colormap(gdk_x11_colormap_get_xcolormap(gtk_widget_get_colormap(gr->widget)));
	imlib_context_set_visual(gdk_x11_visual_get_xvisual(gtk_widget_get_visual(gr->widget)));
	imlib_context_set_drawable(gdk_x11_drawable_get_xid(gr->drawable));
	imlib_context_set_image(image);
	w = imlib_image_get_width();
	h = imlib_image_get_height();
	if (count == 3) {
		imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, p[1].y-p[0].y, p[2].x-p[0].x, p[2].y-p[0].y);
	}
	if (count == 2) {
		imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, 0, 0, p[1].y-p[0].y);
	}
#endif
}
Ejemplo n.º 21
0
void LFSTK_imageClass::LFSTK_clearWindow(void)
{
	if(this->wc->useTile==true) 
		{
			XSetTSOrigin(this->display,this->gc,0-this->gadgetGeom.x,0-this->gadgetGeom.y);
			XSetFillStyle(this->display,this->gc,FillTiled);
			XSetTile(this->display,this->gc,this->wc->tile[0]);
			XFillRectangle(this->display,this->window,this->gc,0,0,this->gadgetGeom.w,this->gadgetGeom.h);
			XSetFillStyle(this->display,this->gc,FillSolid);
		}
	else
		{
			XSetFillStyle(this->display,this->gc,FillSolid);
			XSetForeground(this->display,this->gc,this->wc->windowColourNames[NORMALCOLOUR].pixel);
			XFillRectangle(this->display,this->window,this->gc,0,0,this->gadgetGeom.w,this->gadgetGeom.h);
		}

	if(this->gotIcon==true)
		{
			XSetClipMask(this->display,this->gc,this->icon[1]);
			XSetClipOrigin(this->display,this->gc,0,0);
			XCopyArea(this->display,this->icon[0],this->window,this->gc,0,0,this->iconSize,this->iconSize,0,0);
			XSetClipMask(this->display,this->gc,None);
		}
	else if(this->useImage==true)
		{
			imlib_context_set_display(this->display);
			imlib_context_set_visual(this->visual);
			imlib_context_set_colormap(this->cm);

			imlib_context_set_drawable(this->window);
			imlib_context_set_image(this->image);
			imlib_context_set_blend(1);
			imlib_render_image_on_drawable_at_size(4,(this->gadgetGeom.h/2)-(this->imageHeight/2),this->imageWidth,this->imageHeight); 
		}
}
Ejemplo n.º 22
0
int xtwitter_x_init()
{
    Window root;
    int screen;
    int root_x, root_y;
    unsigned int root_width, root_height, root_border, root_depth;
    int missing_count;
    char** missing_list;
    char* def_string;

    XInitThreads();

    if(!setlocale(LC_CTYPE, "")){
        fprintf(stderr, "error: setlocale()\n");
        return -1;
    }
    if (!XSupportsLocale()){
        fprintf(stderr, "error: XSupportsLocale()\n");
        return -1;
    }
    display = XOpenDisplay(NULL);
    if(!display){
        fprintf(stderr, "Can't open display\n");
        return -1;
    }
    root = DefaultRootWindow(display);
    screen = DefaultScreen(display);
    color_white= WhitePixel(display, screen);
    color_black= BlackPixel(display, screen);

    XGetGeometry(display, RootWindow(display, 0), &root,
                 &root_x, &root_y, &root_width, &root_height,
                 &root_border, &root_depth);

    text_fonts = XCreateFontSet(display, "-*-*-medium-r-normal--12-*-*-*", 
                                &missing_list, &missing_count, &def_string);

    if(!text_fonts){
        printf( "error: XCreateFontSet\n" );
        return 1;
    }
    if(!missing_list){
        XFreeStringList(missing_list);
    }

    user_fonts = XCreateFontSet(display, "-*-*-medium-r-normal--12-*-*-*", 
                                &missing_list, &missing_count, &def_string);
    if(!user_fonts){
        printf( "error: XCreateFontSet\n" );
        return 1;
    }
    if(!missing_list){
        XFreeStringList(missing_list);
    }

    window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0,
                                 XTWITTER_WINDOW_WIDTH, XTWITTER_WINDOW_HEIGHT,
                                 1, color_black, color_white);

    atom_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
    XSetWMProtocols(display, window, &atom_delete_window, 1);

    gc = XCreateGC(display, window, 0, NULL);
    XSetBackground(display, gc, color_white);
    XSetForeground(display, gc, color_black);

	imlib_context_set_display(display);
	imlib_context_set_visual(DefaultVisual(display, 0));
	imlib_context_set_colormap(DefaultColormap(display, 0));

    pixmap = XCreatePixmap(display, window,
                           XTWITTER_WINDOW_WIDTH, XTWITTER_WINDOW_HEIGHT,
                           DefaultDepth(display, screen));

    // control under window manager
    XSetWindowAttributes attr;
    attr.override_redirect = False;
    XChangeWindowAttributes(display, window, CWOverrideRedirect, &attr);

    // set title bar
    XTextProperty  prop;
    prop.value    = (unsigned char *)PACKAGE;
    prop.encoding = XA_STRING;
    prop.format = 8;
    prop.nitems = strlen(PACKAGE);
    XSetWMName(display, window, &prop);

    // fill pixmap by white
    XSetForeground(display, gc, color_white);
    XSetBackground(display, gc, color_black);
    XFillRectangle(display, pixmap, gc,
                   0, 0, XTWITTER_WINDOW_WIDTH, XTWITTER_WINDOW_HEIGHT);

    XMapWindow(display, window);
    XFlush(display);
    return 0;
}
Ejemplo n.º 23
0
static int
x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)
{
    struct x11_info *xi;
#if defined(USE_IMLIB)
    ImlibImage *im;
#elif defined(USE_IMLIB2)
    Imlib_Image im;
#elif defined(USE_GDKPIXBUF)
    GdkPixbufAnimation *animation;
    GList *frames;
    int i, j, iw, ih, n, frame_num, delay, max_anim;
    double ratio_w, ratio_h;
    struct x11_image *ximg;
    Pixmap tmp_pixmap;
#endif

    if (self == NULL)
	return 0;
    xi = (struct x11_info *)self->priv;
    if (xi == NULL)
	return 0;

#if defined(USE_IMLIB)
    im = Imlib_load_image(xi->id, fname);
    if (!im)
	return 0;
    if (w <= 0)
	w = im->rgb_width;
    if (h <= 0)
	h = im->rgb_height;
    img->pixmap = (void *)XCreatePixmap(xi->display, xi->parent, w, h,
					DefaultDepth(xi->display, 0));
    if (!img->pixmap)
	return 0;
    XSetForeground(xi->display, xi->imageGC, xi->background_pixel);
    XFillRectangle(xi->display, (Pixmap) img->pixmap, xi->imageGC, 0, 0, w, h);
    Imlib_paste_image(xi->id, im, (Pixmap) img->pixmap, 0, 0, w, h);
    Imlib_kill_image(xi->id, im);
#elif defined(USE_IMLIB2)
    im = imlib_load_image(fname);
    if (!im)
	return 0;
    imlib_context_set_image(im);
    if (w <= 0)
	w = imlib_image_get_width();
    if (h <= 0)
	h = imlib_image_get_height();
    img->pixmap = (void *)XCreatePixmap(xi->display, xi->parent, w, h,
					DefaultDepth(xi->display, 0));
    if (!img->pixmap)
	return 0;
    XSetForeground(xi->display, xi->imageGC, xi->background_pixel);
    XFillRectangle(xi->display, (Pixmap) img->pixmap, xi->imageGC, 0, 0, w, h);
    imlib_context_set_display(xi->display);
    imlib_context_set_visual(DefaultVisual(xi->display, 0));
    imlib_context_set_colormap(DefaultColormap(xi->display, 0));
    imlib_context_set_drawable((Drawable) img->pixmap);
    imlib_render_image_on_drawable_at_size(0, 0, w, h);
    imlib_free_image();
#elif defined(USE_GDKPIXBUF)
    max_anim = self->max_anim;
    animation = gdk_pixbuf_animation_new_from_file(fname);
    if (!animation)
	return 0;
    frames = gdk_pixbuf_animation_get_frames(animation);
    frame_num = n = gdk_pixbuf_animation_get_num_frames(animation);

    get_animation_size(animation, &iw, &ih, &delay);
    if (delay <= 0)
	max_anim = -1;

    if (max_anim < 0) {
	frame_num = (-max_anim > n) ? n : -max_anim;
    }
    else if (max_anim > 0) {
	frame_num = n = (max_anim > n) ? n : max_anim;
    }

    if (w < 1 || h < 1) {
	w = iw;
	h = ih;
	ratio_w = ratio_h = 1;
    }
    else {
	ratio_w = 1.0 * w / iw;
	ratio_h = 1.0 * h / ih;
    }
    tmp_pixmap = XCreatePixmap(xi->display, xi->parent, w, h,
			       DefaultDepth(xi->display, 0));
    XFillRectangle(xi->display, (Pixmap) tmp_pixmap, xi->imageGC, 0, 0, w, h);
    if (!tmp_pixmap) {
	gdk_pixbuf_animation_unref(animation);
	return 0;
    }
    ximg = x11_img_new(xi, w, h, frame_num);
    if (!ximg) {
	XFreePixmap(xi->display, tmp_pixmap);
	gdk_pixbuf_animation_unref(animation);
	return 0;
    }
    for (j = 0; j < n; j++) {
	GdkPixbufFrame *frame;
	GdkPixbuf *org_pixbuf, *pixbuf;
	int width, height, ofstx, ofsty;

	if (max_anim < 0) {
	    i = (j - n + frame_num > 0) ? (j - n + frame_num) : 0;
	}
	else {
	    i = j;
	}
	frame = (GdkPixbufFrame *) g_list_nth_data(frames, j);
	org_pixbuf = gdk_pixbuf_frame_get_pixbuf(frame);
	ofstx = gdk_pixbuf_frame_get_x_offset(frame);
	ofsty = gdk_pixbuf_frame_get_y_offset(frame);
	delay = gdk_pixbuf_frame_get_delay_time(frame);
	width = gdk_pixbuf_get_width(org_pixbuf);
	height = gdk_pixbuf_get_height(org_pixbuf);

	if (ofstx == 0 && ofsty == 0 && width == w && height == h) {
	    pixbuf = resize_image(org_pixbuf, w, h);
	}
	else {
	    pixbuf =
		resize_image(org_pixbuf, width * ratio_w, height * ratio_h);
	    ofstx *= ratio_w;
	    ofsty *= ratio_h;
	}
	width = gdk_pixbuf_get_width(pixbuf);
	height = gdk_pixbuf_get_height(pixbuf);

	if (delay > ximg->delay)
	    ximg->delay = delay;

	XCopyArea(xi->display, tmp_pixmap, ximg->pixmap[i],
		  xi->imageGC, 0, 0, w, h, 0, 0);
	gdk_pixbuf_xlib_render_to_drawable_alpha(pixbuf,
						 (Drawable) ximg->pixmap[i], 0,
						 0, ofstx, ofsty, width,
						 height,
						 GDK_PIXBUF_ALPHA_BILEVEL, 1,
						 XLIB_RGB_DITHER_NORMAL, 0, 0);

	switch (gdk_pixbuf_frame_get_action(frame)) {
	case GDK_PIXBUF_FRAME_RETAIN:
	    XCopyArea(xi->display, ximg->pixmap[i], tmp_pixmap,
		      xi->imageGC, 0, 0, w, h, 0, 0);
	    break;
	case GDK_PIXBUF_FRAME_DISPOSE:
	    break;
	case GDK_PIXBUF_FRAME_REVERT:
	    XCopyArea(xi->display, ximg->pixmap[0], tmp_pixmap,
		      xi->imageGC, 0, 0, w, h, 0, 0);
	    break;
	default:
	    XCopyArea(xi->display, ximg->pixmap[0], tmp_pixmap,
		      xi->imageGC, 0, 0, w, h, 0, 0);
	    break;
	}


	if (org_pixbuf != pixbuf)
	    gdk_pixbuf_finalize(pixbuf);

    }
    XFreePixmap(xi->display, tmp_pixmap);
    gdk_pixbuf_animation_unref(animation);
    img->pixmap = ximg;
#endif

    img->width = w;
    img->height = h;
    return 1;
}
Ejemplo n.º 24
0
int
main(void)
{
	dlist *clients = 0, *config = 0;
	Display *dpy = XOpenDisplay(NULL);
	MainWin *mw;
	Imlib_Context context;
	KeyCode keycode;
	KeySym keysym;
	const char *tmp, *homedir;
	char cfgpath[8192];
	Bool invertShift = False;
	
	if(! dpy) {
		fprintf(stderr, "FATAL: Couldn't connect to display.\n");
		return -1;
	}
	
	wm_get_atoms(dpy);
	
	if(! wm_check(dpy)) {
		fprintf(stderr, "FATAL: WM not NETWM or GNOME WM Spec compliant.\n");
		return -1;
	}
	
	homedir = getenv("HOME");
	if(homedir) {
		snprintf(cfgpath, 8191, "%s/%s", homedir, ".skippyrc");
		config = config_load(cfgpath);
	}
	else
		fprintf(stderr, "WARNING: $HOME not set, not loading config.\n");
	
	wm_use_netwm_fullscreen(strcasecmp("true", config_get(config, "general", "useNETWMFullscreen", "true")) == 0);
	wm_ignore_skip_taskbar(strcasecmp("true", config_get(config, "general", "ignoreSkipTaskbar", "false")) == 0);
	
	mw = mainwin_create(dpy, config);
	if(! mw)
	{
		fprintf(stderr, "FATAL: Couldn't create main window.\n");
		config_free(config);
		XCloseDisplay(mw->dpy);
		return -1;
	}
	
	invertShift = strcasecmp("true", config_get(config, "xinerama", "showAll", "false")) == 0;
	
	context = imlib_context_new();
	imlib_context_push(context);
	imlib_context_set_display(dpy);
	imlib_context_set_visual(mw->visual);
	imlib_context_set_colormap(mw->colormap);
	
	tmp = config_get(config, "general", "keysym", "F11");
	keysym = XStringToKeysym(tmp);
	if(keysym == NoSymbol)
	{
		fprintf(stderr, "FATAL: Couldn't look up keysym for '%s', bailing out.\n", tmp);
		config_free(config);
		XCloseDisplay(mw->dpy);
		return -1;
	}
	
	mainwin_update_background(mw);
	XSelectInput(mw->dpy, mw->root, PropertyChangeMask);
	
	keycode = XKeysymToKeycode(mw->dpy, keysym);
	XGrabKey(mw->dpy, keycode, AnyModifier, mw->root, False, GrabModeAsync, GrabModeAsync);
	while(! DIE_NOW)
	{
		XEvent ev;
		XNextEvent(mw->dpy, &ev);
		if(ev.type == PropertyNotify && (ev.xproperty.atom == ESETROOT_PMAP_ID || ev.xproperty.atom == _XROOTPMAP_ID))
			mainwin_update_background(mw);
		else if(ev.type == KeyRelease && ev.xkey.keycode == keycode)
		{
			Window leader = None, focused = wm_get_focused(mw->dpy);
			Bool shifted = (ev.xkey.state & ShiftMask) ? ! invertShift : invertShift;
			
			if(ev.xkey.state & Mod1Mask)
			{
				if(focused != None)
					leader = wm_get_group_leader(mw->dpy, focused);
				if(! leader)
					continue;
			}
			clients = skippy_run(mw, clients, (ev.xkey.state & ControlMask), focused, leader, shifted);
		}
	}
	
	dlist_free_with_func(clients, (dlist_free_func)clientwin_destroy);
	
	XFlush(mw->dpy);
	
	mainwin_destroy(mw);
	
	imlib_context_pop();
	imlib_context_free(context);
	
	XSync(dpy, True);
	XCloseDisplay(dpy);
	config_free(config);
	
	return 0;
}
Ejemplo n.º 25
0
int
main(int argc, char **argv)
{
   int                 w, h, tw, th;
   Imlib_Image         im_bg = NULL;
   XEvent              ev;
   KeySym              keysym;
   static char         kbuf[20];
   Imlib_Font          font;
   Imlib_Color_Range   range;
   const char         *display_name = getenv("DISPLAY");

   /**
    * First tests to determine which rendering task to perform
    */
   if (display_name == NULL)
       display_name = ":0";
   disp = XOpenDisplay(display_name);
   if (disp == NULL)
     {
       fprintf(stderr, "Can't open display %s\n", display_name);
       return 1;
     }
   vis = DefaultVisual(disp, DefaultScreen(disp));
   depth = DefaultDepth(disp, DefaultScreen(disp));
   cm = DefaultColormap(disp, DefaultScreen(disp));
   win =
       XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
                           0);
   XSelectInput(disp, win,
                ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
                PointerMotionMask | ExposureMask | KeyPressMask);
   XMapWindow(disp, win);

   /**
    * Start rendering
    */
   imlib_set_font_cache_size(512 * 1024);
   imlib_add_path_to_font_path(PACKAGE_DATA_DIR"/data/fonts");
   imlib_context_set_display(disp);
   imlib_context_set_visual(vis);
   imlib_context_set_colormap(cm);
   imlib_context_set_drawable(win);
   imlib_context_set_blend(0);
   imlib_context_set_color_modifier(NULL);
   imlib_context_set_blend(0);

   im_bg = imlib_create_image(600, 400);
   imlib_context_set_image(im_bg);
   w = imlib_image_get_width();
   h = imlib_image_get_height();
   imlib_context_set_color(128, 128, 255, 255);
   imlib_image_fill_rectangle(0, 0, w, h);
   XResizeWindow(disp, win, w, h);
   XSync(disp, False);

   while (1)
     {
        do
          {
             XNextEvent(disp, &ev);
             switch (ev.type)
               {
                 case ButtonRelease:
                    exit(0);
                    break;
                 case KeyPress:
                    XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
                                  NULL);
                    switch (*kbuf)
                      {
                        case 'q':
                           exit(0);
                        default:
                           break;
                      }
                    break;
                 default:
                    break;

               }
          }
        while (XPending(disp));

        imlib_context_set_image(im_bg);
        imlib_context_set_color(128, 128, 255, 255);
        imlib_image_fill_rectangle(0, 0, w, h);
        imlib_context_set_color(0, 0, 0, 255);
        imlib_image_draw_rectangle(20, 20, 560, 140);
        imlib_image_draw_rectangle(20, 220, 560, 140);
        font = imlib_load_font("notepad/15");
        if (font)
          {
             char                text[4096];

             imlib_context_set_font(font);
             imlib_context_set_color(0, 0, 0, 255);
             sprintf(text, "RGBA range, 2 points, from red to magenta");
             imlib_get_text_size(text, &tw, &th);
             imlib_text_draw(300 - tw / 2, 180 - th / 2, text);
             sprintf(text, "HSVA range, 2 points, from red to magenta");
             imlib_get_text_size(text, &tw, &th);
             imlib_text_draw(300 - tw / 2, 380 - th / 2, text);
             imlib_free_font();
          }

        /* Draw rectangle w/ RGBA gradient */
        range = imlib_create_color_range();
        imlib_context_set_color_range(range);
        imlib_context_set_color(255, 0, 0, 255);
        imlib_add_color_to_color_range(0);
        imlib_context_set_color(255, 0, 255, 255);
        imlib_add_color_to_color_range(20);
        imlib_image_fill_color_range_rectangle(21, 21, 558, 138, -90.0);
        imlib_free_color_range();

        /* Draw rectangle w/ HSVA gradient */
        range = imlib_create_color_range();
        imlib_context_set_color_range(range);
        imlib_context_set_color_hsva(0, 1, 1, 255);
        imlib_add_color_to_color_range(0);
        imlib_context_set_color_hsva(300, 1, 1, 255);
        imlib_add_color_to_color_range(20);
        imlib_image_fill_hsva_color_range_rectangle(21, 221, 558, 138, -90.0);
        imlib_free_color_range();

        imlib_render_image_on_drawable(0, 0);
     }
   return 0;
}
Ejemplo n.º 26
0
int main (int argc, char **argv)
{
	Visual *vis;
	Colormap cm;
	Display *_display;
	Imlib_Context context;
	Imlib_Image image;
	Pixmap pixmap;
	Imlib_Color_Modifier modifier = NULL;
	_display = XOpenDisplay (NULL);
	int width, height, depth, i, alpha;

	
	char str1[40];
	char str2[40];
	char str3[40];
	char str4[40];
	char str5[40];
		
	int ck0;
	int w, h;
	w = 0;
	h = 0;
			
			
	char strA1[30] = "hwe";
	char strA2[30] = "hwer";
	const char jpg[15] = "jpg"; //1
	const char png[15] = "png"; //2
	
	char *A1; 
	char *A2; 
	
	strcpy(strA1, argv[argc-1]);
	strcpy(strA2, strA1);
	A1 = strstr(strA1, jpg);
	A2 = strstr(strA2, png);
	
		//check to be sure image format is written right or abort
	 	checkForNull(A1, A2);
		
		
			
		
	for (screen = 0; screen < ScreenCount (_display); screen++)
	{
		display = XOpenDisplay (NULL);

		context = imlib_context_new ();
		imlib_context_push (context);

		imlib_context_set_display (display);
		vis = DefaultVisual (display, screen);
		cm = DefaultColormap (display, screen);

		width = DisplayWidth (display, screen);
		height = DisplayHeight (display, screen);

		depth = DefaultDepth (display, screen);

		pixmap =
			XCreatePixmap (display, RootWindow (display, screen),
							width, height, depth);

		imlib_context_set_visual (vis);
		imlib_context_set_colormap (cm);
		imlib_context_set_drawable (pixmap);
		imlib_context_set_color_range (imlib_create_color_range ());
		
		image = imlib_create_image (width, height);
		imlib_context_set_image (image);
				printf("1\n");
		imlib_context_set_color (0, 0, 0, 255);
		imlib_image_fill_rectangle (0, 0, width, height);

		imlib_context_set_dither (1);
		imlib_context_set_blend (1);
		printf("2\n");
		alpha = 255;


	for (i = 1; i < argc; i++)
	{
		if (modifier != NULL)
		{
			imlib_apply_color_modifier ();
			imlib_free_color_modifier ();
		}

	modifier = imlib_create_color_modifier ();
	imlib_context_set_color_modifier (modifier);

		if (strcmp (argv[i], "-alpha") == 0)
		{
			if ((++i) >= argc)
			{
				fprintf (stderr, "Missing alpha\n");
				continue;
			}
				if (sscanf (argv[i], "%i", &alpha) == 0)
				{
					fprintf (stderr, "Bad alpha (%s)\n", argv[i]);
					continue;
				}
		}
	else if (strcmp (argv[i], "-solid") == 0)
	{
		Color c;
		
		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing color\n");
			continue;
		}
			if (parse_color (argv[i], &c, alpha) == 1)
			{
				fprintf (stderr, "Bad color (%s)\n", argv[i]);
				continue;
			}

		imlib_context_set_color (c.r, c.g, c.b, c.a);
		imlib_image_fill_rectangle (0, 0, width, height);
	}
		else if (strcmp (argv[i], "-clear") == 0)
		{
			imlib_free_color_range ();
			imlib_context_set_color_range (imlib_create_color_range ());
		}
	else if (strcmp (argv[i], "-add") == 0)
	{
		Color c;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing color\n");
			continue;
		}
			if (parse_color (argv[i], &c, alpha) == 1)
			{
				fprintf (stderr, "Bad color (%s)\n", argv[i - 1]);
				continue;
			}

		imlib_context_set_color (c.r, c.g, c.b, c.a);
		imlib_add_color_to_color_range (1);
	}
	else if (strcmp (argv[i], "-addd") == 0)
	{
		Color c;
		int distance;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing color\n");
			continue;
		}
			if ((++i) >= argc)
			{
				fprintf (stderr, "Missing distance\n");
				continue;
			}
				if (parse_color (argv[i - 1], &c, alpha) == 1)
				{
					fprintf (stderr, "Bad color (%s)\n", argv[i - 1]);
					continue;
				}
					if (sscanf (argv[i], "%i", &distance) == 1)
					{
						fprintf (stderr, "Bad distance (%s)\n", argv[i]);
						continue;
					}

				imlib_context_set_color (c.r, c.g, c.b, c.a);
				imlib_add_color_to_color_range (distance);
	}
	else if (strcmp (argv[i], "-gradient") == 0)
	{
		int angle;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing angle\n");
			continue;
		}
			if (sscanf (argv[i], "%i", &angle) == 1)
			{
				fprintf (stderr, "Bad angle (%s)\n", argv[i]);
				continue;
			}

		imlib_image_fill_color_range_rectangle (0, 0, width, height,
												angle);
	}

	 else if (strcmp (argv[i], "-fill") == 0)
	 {
		if ((++i) >= argc)
		{
		  fprintf (stderr, "Missing image\n");
		  continue;
		}
		if ( load_Mod_image(Fill, argv[i], width, height, alpha, image, ck0) == 1)
		{
		  fprintf (stderr, "Bad image (%s)\n", argv[i]);
		  continue;
		}
	 }
	else if (strcmp (argv[i], "-dia") == 0)
	{
		if((++i) >= argc)
		{
			fprintf(stderr, "missing Dia, and Image\n");
			continue;
		}
			strcpy (str1, argv[i]);
			strcpy (str2, str1);
				
			if ( findX(str1, &w, &h) == 1 )
			{
				fprintf(stderr, " Bad Format\n");
				continue;
			}
			else if (findX(str2, &w, &h) == 0 && ((++i) >= argc))
			{
				fprintf(stderr, "Missing Image\n");
				continue;
			}
			else
			{
				//if format is correct then assign a number for
				//load_Mod_Image to check
				ck0 = -2;
				w = w;
				h = h;
			}
			if( load_Mod_image(Dia, argv[i], w, h, alpha, image, ck0) == 1 )
			{
			fprintf(stderr, "Bad Image or Bad Image Dimensions \n");
			}
	} 
	else if (strcmp (argv[i], "-tile") == 0)
	{
		if ((++i) >= argc)

			{
			fprintf(stderr, "format 0 missing \n");
			continue;
			}
				strcpy (str1, argv[i]);
				strcpy (str2, str1);
				strcpy (str3, str2);
				strcpy (str4, str3);
				strcpy (str5, str4);


			if ( findX(str1, &w, &h) == 3 &&  ((++i) >= argc))
			{ 
				fprintf(stderr, "missing Image\n");
				continue;
			} //check to see if format is -tile 0 
			else if (findX(str2, &w, &h) == 3)
			{
				ck0 = 3;
				if( load_Mod_image(Tile, argv[i], width, height, alpha, image, ck0) == 1 )
				{
					fprintf(stderr, "Bad Image or Bad Image Dimensions \n");
					continue;
				}
			}

			if (findX(str3, &w, &h) == 1)
			{
				fprintf(stderr, "bad format\n");
				continue;
			}
			 if (findX(str4, &w, &h) == 0 && ((++i) >= argc))
			{
				fprintf(stderr, "missing something again\n");
				continue;
			}
			if (findX (str5, &w, &h) == 0 )
			{
				ck0 = 2;
				w = w;
				h = h;
				
			}
			if( load_Mod_image(Tile, argv[i], w, h, alpha, image, ck0) == 1 )
			{
			fprintf(stderr, "Bad Image or Bad Image Dimension\n");
			}

	}

	else if (strcmp (argv[i], "-center") == 0)
	{
		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing image\n");
			continue;
		}
			if (load_Mod_image (Center, argv[i], width, height, alpha, image, ck0) == 1)
			{
				fprintf (stderr, "Bad image (%s)\n", argv[i]);
				continue;
			}
	}
	else if (strcmp (argv[i], "-tint") == 0)
	{
		Color c;
		DATA8 r[256], g[256], b[256], a[256];
		int j;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing color\n");
			continue;
		}
			if (parse_color (argv[i], &c, 255) == 1)
			{
				fprintf (stderr, "Bad color\n");
				continue;
			}

		imlib_get_color_modifier_tables (r, g, b, a);

			for (j = 0; j < 256; j++)
			{
				r[j] = (DATA8) (((double) r[j] / 255.0) * (double) c.r);
				g[j] = (DATA8) (((double) g[j] / 255.0) * (double) c.g);
				b[j] = (DATA8) (((double) b[j] / 255.0) * (double) c.b);
			}

		imlib_set_color_modifier_tables (r, g, b, a);
	}
	else if (strcmp (argv[i], "-blur") == 0)
	{
		int intval;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing value\n");
			continue;
		}
			if (sscanf (argv[i], "%i", &intval) == 1)
			{
				fprintf (stderr, "Bad value (%s)\n", argv[i]);
				continue;
			}
		imlib_image_blur (intval);
	}
	else if (strcmp (argv[i], "-sharpen") == 0)
	{
		int intval;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing value\n");
			continue;
		}
			if (sscanf (argv[i], "%i", &intval) == 1)
			{
				fprintf (stderr, "Bad value (%s)\n", argv[i]);
				continue;
			}
		imlib_image_sharpen (intval);
	}
	else if (strcmp (argv[i], "-contrast") == 0)
	{
		double dblval;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing value\n");
			continue;
		}
			if (sscanf (argv[i], "%lf", &dblval) == 1)
			{
				fprintf (stderr, "Bad value (%s)\n", argv[i]);
				continue;
			}
		imlib_modify_color_modifier_contrast (dblval);
	}
	else if (strcmp (argv[i], "-brightness") == 0)
	{
		double dblval;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing value\n");
			continue;
		}
			if (sscanf (argv[i], "%lf", &dblval) == 1)
			{
				fprintf (stderr, "Bad value (%s)\n", argv[i]);
				continue;
			}
		imlib_modify_color_modifier_brightness (dblval);
	}
	else if (strcmp (argv[i], "-gamma") == 0)
	{
		double dblval;

		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing value\n");
			continue;
		}
			if (sscanf (argv[i], "%lf", &dblval) == 1)
			{
				fprintf (stderr, "Bad value (%s)\n", argv[i]);
				continue;
			}
		imlib_modify_color_modifier_gamma (dblval);
	}
	else if (strcmp (argv[i], "-flipv") == 0)
	{
		imlib_image_flip_vertical ();
	}
	else if (strcmp (argv[i], "-fliph") == 0)
	{
		imlib_image_flip_horizontal ();
	}
	else if (strcmp (argv[i], "-flipd") == 0)
	{
		imlib_image_flip_diagonal ();
	}
	else if (strcmp (argv[i], "-write") == 0)
	{
		if ((++i) >= argc)
		{
			fprintf (stderr, "Missing filename\n");
			continue;
		}
      imlib_save_image (argv[i]);
	}
	else
	{
		usage (argv[0]);
		imlib_free_image ();
		imlib_free_color_range ();

			if (modifier != NULL)
			{
				imlib_context_set_color_modifier (modifier);
				imlib_free_color_modifier ();
				modifier = NULL;
			}
				XFreePixmap (display, pixmap);
				exit (1);
	} // end else
} // end loop off of argc

	if (modifier != NULL)
	{
		imlib_context_set_color_modifier (modifier);
        imlib_apply_color_modifier ();
        imlib_free_color_modifier ();
        modifier = NULL;
	}

		imlib_render_image_on_drawable (0, 0);
		imlib_free_image ();
		imlib_free_color_range ();

		if (setRootAtoms (pixmap) == 0)
			fprintf (stderr, "Couldn't create atoms...\n");

		XKillClient (display, AllTemporary);
		XSetCloseDownMode (display, RetainTemporary);

		XSetWindowBackgroundPixmap (display, RootWindow (display, screen),
									pixmap);

		XClearWindow (display, RootWindow (display, screen));

		XFlush (display);
		XSync (display, False);

		imlib_context_pop ();
		imlib_context_free (context);

	} // end for loop off screen
                   //   } //  frist if statment at start of main
  return 0;
}
Ejemplo n.º 27
0
int
main(int argc, char **argv)
{
   int                 w, h;
   Imlib_Image         im_bg = NULL;
   XEvent              ev;
   KeySym              keysym;
   static char         kbuf[20];
   ImlibPolygon        poly, poly1, poly2;
   const char         *display_name = getenv("DISPLAY");

   /**
    * First tests to determine which rendering task to perform
    */
   if (display_name == NULL)
       display_name = ":0";
   disp = XOpenDisplay(display_name);
   if (disp == NULL)
     {
       fprintf(stderr, "Can't open display %s\n", display_name);
       return 1;
     }
   vis = DefaultVisual(disp, DefaultScreen(disp));
   depth = DefaultDepth(disp, DefaultScreen(disp));
   cm = DefaultColormap(disp, DefaultScreen(disp));
   win =
       XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
                           0);
   XSelectInput(disp, win,
                ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
                PointerMotionMask | ExposureMask | KeyPressMask);
   XMapWindow(disp, win);

   /**
    * Start rendering
    */
   imlib_context_set_display(disp);
   imlib_context_set_visual(vis);
   imlib_context_set_colormap(cm);
   imlib_context_set_drawable(win);
   imlib_context_set_blend(0);
   imlib_context_set_color_modifier(NULL);
   imlib_context_set_blend(0);

   im_bg = imlib_create_image(400, 400);
   imlib_context_set_image(im_bg);
   w = imlib_image_get_width();
   h = imlib_image_get_height();
   imlib_context_set_color(0, 0, 0, 255);
   imlib_image_fill_rectangle(0, 0, w, h);
   XResizeWindow(disp, win, w, h);
   XSync(disp, False);

   poly = imlib_polygon_new();
   imlib_polygon_add_point(poly, 20, 20);
   imlib_polygon_add_point(poly, 70, 20);
   imlib_polygon_add_point(poly, 70, 70);
   imlib_polygon_add_point(poly, 20, 70);

   poly1 = imlib_polygon_new();
   imlib_polygon_add_point(poly1, 100, 20);
   imlib_polygon_add_point(poly1, 190, 100);
   imlib_polygon_add_point(poly1, 120, 70);

   poly2 = imlib_polygon_new();
   imlib_polygon_add_point(poly2, 290, 20);
   imlib_polygon_add_point(poly2, 200, 100);
   imlib_polygon_add_point(poly2, 270, 70);

   while (1)
     {
        do
          {
             XNextEvent(disp, &ev);
             switch (ev.type)
               {
                 case ButtonRelease:
                    exit(0);
                    break;
                 case KeyPress:
                    XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
                                  NULL);
                    switch (*kbuf)
                      {
                        case ' ':
                           imlib_context_set_anti_alias
                               (!imlib_context_get_anti_alias());
                           printf("AA is %s\n",
                                  imlib_context_get_anti_alias()? "on" : "off");
                           break;
                        case 'q':
                           exit(0);
                        default:
                           break;
                      }
                    break;
                 default:
                    break;

               }
          }
        while (XPending(disp));

        imlib_context_set_image(im_bg);
        imlib_context_set_color(0, 0, 0, 255);
        imlib_image_fill_rectangle(0, 0, w, h);
        imlib_context_set_color(255, 255, 255, 255);
        imlib_image_fill_polygon(poly);
        imlib_image_fill_polygon(poly1);
        imlib_image_fill_polygon(poly2);
        imlib_render_image_on_drawable(0, 0);
     }
   return 0;
}
Ejemplo n.º 28
0
int
main(int argc, char **argv)
{
   int                 w, h, x, y;
   Imlib_Image         im = NULL, im_bg = NULL;
   XEvent              ev;
   const char         *display_name = getenv("DISPLAY");

   /**
    * Initialization according to options
    */
   printf("Initialising\n");

   /**
    * First tests to determine which rendering task to perform
    */
   if (display_name == NULL)
       display_name = ":0";
   disp = XOpenDisplay(display_name);
   if (disp == NULL)
     {
       fprintf(stderr, "Can't open display %s\n", display_name);
       return 1;
     }
   vis = DefaultVisual(disp, DefaultScreen(disp));
   depth = DefaultDepth(disp, DefaultScreen(disp));
   cm = DefaultColormap(disp, DefaultScreen(disp));
   win =
       XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
                           0);
   XSelectInput(disp, win,
                ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
                PointerMotionMask | ExposureMask);
   XMapWindow(disp, win);

   /**
    * Start rendering
    */
   printf("Rendering\n");
   imlib_context_set_display(disp);
   imlib_context_set_visual(vis);
   imlib_context_set_colormap(cm);
   imlib_context_set_drawable(win);
   imlib_context_set_dither(1);
   imlib_context_set_blend(0);
   imlib_context_set_color_modifier(NULL);

   im_bg = imlib_load_image(PACKAGE_DATA_DIR"/data/images/imlib2.png");
   im = imlib_load_image(PACKAGE_DATA_DIR"/data/images/imlib2.png");

   imlib_context_set_image(im_bg);
   w = imlib_image_get_width();
   h = imlib_image_get_height();
   printf("Resizing Window to %d by %d\n", w, h);
   XResizeWindow(disp, win, w, h);
   XSync(disp, False);
   x = -9999;
   y = -9999;
   while (1)
     {
        Imlib_Image        *temp, *temp2;

        do
          {
             XNextEvent(disp, &ev);
             switch (ev.type)
               {
                 case Expose:
                    break;
                 case ButtonRelease:
                    exit(0);
                    break;
                 case MotionNotify:
                    x = ev.xmotion.x;
                    y = ev.xmotion.y;
                 default:
                    break;

               }
          }
        while (XPending(disp));

        imlib_context_set_blend(0);
        imlib_context_set_image(im_bg);
        temp = imlib_clone_image();
        imlib_context_set_image(temp);

        /*    imlib_blend_image_onto_image(im_bg, 0,
         * 0, 0, w, h,
         * 0, 0, w, h);
         * first = 0; */

        imlib_apply_filter
            ("bump_map_point(x=[],y=[],map="PACKAGE_DATA_DIR"/data/images/imlib2.png);", &x, &y);

        temp2 = im_bg;
        im_bg = temp;
        imlib_context_set_image(im_bg);
        imlib_render_image_on_drawable(0, 0);
        im_bg = temp2;
        imlib_context_set_image(temp);
        imlib_free_image();
     }

   return 0;
}
Ejemplo n.º 29
0
int
main(int argc, char **argv)
{
   Imlib_Image        *im = NULL;
   char               *file = NULL;
   int                 no = 1;
   const char         *display_name = getenv("DISPLAY");

   if (argc < 2)
      return 1;

   file = argv[no];
   if (display_name == NULL)
      display_name = ":0";
   disp = XOpenDisplay(display_name);
   if (disp == NULL)
     {
        fprintf(stderr, "Can't open display %s\n", display_name);
        return 1;
     }
   vis = DefaultVisual(disp, DefaultScreen(disp));
   depth = DefaultDepth(disp, DefaultScreen(disp));
   cm = DefaultColormap(disp, DefaultScreen(disp));
   win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 10, 10,
                             0, 0, 0);
   XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask |
                ButtonMotionMask | PointerMotionMask);
   imlib_context_set_display(disp);
   imlib_context_set_visual(vis);
   imlib_context_set_colormap(cm);
   imlib_context_set_progress_function(progress);
   imlib_context_set_progress_granularity(10);
   imlib_context_set_drawable(win);
   im = imlib_load_image(file);
   while (!im)
     {
        no++;
        if (no == argc)
          {
             fprintf(stderr, "Image format not available\n");
             exit(0);
          }
        file = argv[no];
        image_width = 0;
        im = imlib_load_image(file);
        imlib_context_set_image(im);
     }
   if (!im)
     {
        fprintf(stderr, "Image format not available\n");
        exit(0);
     }
   for (;;)
     {
        int                 x, y, b, count, fdsize, xfd, timeout = 0;
        XEvent              ev;
        static int          zoom_mode = 0, zx, zy;
        static double       zoom = 1.0;
        struct timeval      tval;
        fd_set              fdset;
        double              t1;

        XFlush(disp);
        XNextEvent(disp, &ev);
        switch (ev.type)
          {
          case ButtonPress:
             b = ev.xbutton.button;
             x = ev.xbutton.x;
             y = ev.xbutton.y;
             if (b == 3)
               {
                  zoom_mode = 1;
                  zx = x;
                  zy = y;
                  imlib_context_set_drawable(pm);
                  imlib_context_set_image(bg_im);
                  imlib_context_set_anti_alias(0);
                  imlib_context_set_dither(0);
                  imlib_context_set_blend(0);
                  imlib_render_image_part_on_drawable_at_size
                     (0, 0, image_width, image_height,
                      0, 0, image_width, image_height);
                  XSetWindowBackgroundPixmap(disp, win, pm);
                  XClearWindow(disp, win);
               }
             break;
          case ButtonRelease:
             b = ev.xbutton.button;
             x = ev.xbutton.x;
             y = ev.xbutton.y;
             if (b == 3)
                zoom_mode = 0;
             if (b == 1)
               {
                  no++;
                  if (no == argc)
                     no = argc - 1;
                  file = argv[no];
                  image_width = 0;
                  zoom = 1.0;
                  zoom_mode = 0;
                  imlib_context_set_image(im);
                  imlib_free_image_and_decache();
                  im = imlib_load_image(file);
                  while (!im)
                    {
                       no++;
                       if (no == argc)
                          exit(0);
                       file = argv[no];
                       image_width = 0;
                       im = imlib_load_image(file);
                    }
                  imlib_context_set_image(im);
               }
             if (b == 2)
               {
                  no--;
                  if (no == 0)
                     no = 1;
                  file = argv[no];
                  image_width = 0;
                  zoom = 1.0;
                  zoom_mode = 0;
                  imlib_context_set_image(im);
                  imlib_free_image_and_decache();
                  im = imlib_load_image(file);
                  while (!im)
                    {
                       no--;
                       if (no == 0)
                          no = 1;
                       file = argv[no];
                       image_width = 0;
                       im = imlib_load_image(file);
                    }
                  imlib_context_set_image(im);
               }
             break;
          case MotionNotify:
             while (XCheckTypedWindowEvent(disp, win, MotionNotify, &ev));
             x = ev.xmotion.x;
             y = ev.xmotion.y;
             if (zoom_mode)
               {
                  int                 sx, sy, sw, sh, dx, dy, dw, dh;

                  zoom = ((double)x - (double)zx) / 32.0;
                  if (zoom < 0)
                     zoom = 1.0 + ((zoom * 32.0) / ((double)(zx + 1)));
                  else
                     zoom += 1.0;
                  if (zoom <= 0.0001)
                     zoom = 0.0001;
                  if (zoom > 1.0)
                    {
                       dx = 0;
                       dy = 0;
                       dw = image_width;
                       dh = image_height;

                       sx = zx - (zx / zoom);
                       sy = zy - (zy / zoom);
                       sw = image_width / zoom;
                       sh = image_height / zoom;
                    }
                  else
                    {
                       dx = zx - (zx * zoom);
                       dy = zy - (zy * zoom);
                       dw = image_width * zoom;
                       dh = image_height * zoom;

                       sx = 0;
                       sy = 0;
                       sw = image_width;
                       sh = image_height;
                    }
                  imlib_context_set_anti_alias(0);
                  imlib_context_set_dither(0);
                  imlib_context_set_blend(0);
                  imlib_context_set_image(bg_im);
                  imlib_render_image_part_on_drawable_at_size
                     (sx, sy, sw, sh, dx, dy, dw, dh);
                  XSetWindowBackgroundPixmap(disp, win, pm);
                  XClearWindow(disp, win);
                  XFlush(disp);
                  timeout = 1;
               }
          default:
             break;
          }
        t1 = 0.2;
        tval.tv_sec = (long)t1;
        tval.tv_usec = (long)((t1 - ((double)tval.tv_sec)) * 1000000);
        xfd = ConnectionNumber(disp);
        fdsize = xfd + 1;
        FD_ZERO(&fdset);
        FD_SET(xfd, &fdset);
        if (timeout)
           count = select(fdsize, &fdset, NULL, NULL, &tval);
        else
           count = select(fdsize, &fdset, NULL, NULL, NULL);
        if (count < 0)
          {
             if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))
                exit(1);
          }
        else
          {
             if ((count == 0) && (timeout))
               {
                  int                 sx, sy, sw, sh, dx, dy, dw, dh;

                  if (zoom > 1.0)
                    {
                       dx = 0;
                       dy = 0;
                       dw = image_width;
                       dh = image_height;

                       sx = zx - (zx / zoom);
                       sy = zy - (zy / zoom);
                       sw = image_width / zoom;
                       sh = image_height / zoom;
                    }
                  else
                    {
                       dx = zx - (zx * zoom);
                       dy = zy - (zy * zoom);
                       dw = image_width * zoom;
                       dh = image_height * zoom;

                       sx = 0;
                       sy = 0;
                       sw = image_width;
                       sh = image_height;
                    }
                  imlib_context_set_anti_alias(1);
                  imlib_context_set_dither(1);
                  imlib_context_set_blend(0);
                  imlib_context_set_image(bg_im);
                  imlib_render_image_part_on_drawable_at_size
                     (sx, sy, sw, sh, dx, dy, dw, dh);
                  XSetWindowBackgroundPixmap(disp, win, pm);
                  XClearWindow(disp, win);
                  XFlush(disp);
                  timeout = 0;
               }
          }
     }
   return 0;
}
Ejemplo n.º 30
0
void systray_render_icon_composited(void *t)
{
	// we end up in this function only in real transparency mode or if systray_task_asb != 100 0 0
	// we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here
	TrayWindow *traywin = t;

	if (systray_profile)
		fprintf(stderr,
		        "[%f] %s:%d win = %lu (%s)\n",
		        profiling_get_time(),
		        __FUNCTION__,
		        __LINE__,
		        traywin->win,
		        traywin->name);

	// wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms
	struct timespec now;
	clock_gettime(CLOCK_MONOTONIC, &now);
	struct timespec earliest_render = add_msec_to_timespec(traywin->time_last_render, min_refresh_period);
	if (compare_timespecs(&earliest_render, &now) > 0) {
		traywin->num_fast_renders++;
		if (traywin->num_fast_renders > max_fast_refreshes) {
			traywin->render_timeout =
			    add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout);
			if (systray_profile)
				fprintf(stderr,
				        YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n",
				        profiling_get_time(),
				        __FUNCTION__,
				        __LINE__,
				        traywin->win,
				        traywin->name);
			return;
		}
	} else {
		traywin->time_last_render.tv_sec = now.tv_sec;
		traywin->time_last_render.tv_nsec = now.tv_nsec;
		traywin->num_fast_renders = 0;
	}

	if (traywin->width == 0 || traywin->height == 0) {
		// reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu)
		traywin->render_timeout =
		    add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout);
		if (systray_profile)
			fprintf(stderr,
			        YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n",
			        profiling_get_time(),
			        __FUNCTION__,
			        __LINE__,
			        traywin->win,
			        traywin->name);
		return;
	}

	if (traywin->render_timeout) {
		stop_timeout(traywin->render_timeout);
		traywin->render_timeout = NULL;
	}

	// good systray icons support 32 bit depth, but some icons are still 24 bit.
	// We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and
	// mask out all pixel with the same rgb value

	// Very ugly hack, but somehow imlib2 is not able to get the image from the traywindow itself,
	// so we first render the tray window onto a pixmap, and then we tell imlib2 to use this pixmap as
	// drawable. If someone knows why it does not work with the traywindow itself, please tell me ;)
	Pixmap tmp_pmap = XCreatePixmap(server.display, traywin->win, traywin->width, traywin->height, 32);
	if (!tmp_pmap) {
		goto on_systray_error;
	}
	XRenderPictFormat *f;
	if (traywin->depth == 24) {
		f = XRenderFindStandardFormat(server.display, PictStandardRGB24);
	} else if (traywin->depth == 32) {
		f = XRenderFindStandardFormat(server.display, PictStandardARGB32);
	} else {
		fprintf(stderr, RED "Strange tray icon found with depth: %d" RESET "\n", traywin->depth);
		XFreePixmap(server.display, tmp_pmap);
		return;
	}
	XRenderPictFormat *f32 = XRenderFindVisualFormat(server.display, server.visual32);
	if (!f || !f32) {
		XFreePixmap(server.display, tmp_pmap);
		goto on_systray_error;
	}

	XSync(server.display, False);
	error = FALSE;
	XErrorHandler old = XSetErrorHandler(window_error_handler);

	// if (server.real_transparency)
	// Picture pict_image = XRenderCreatePicture(server.display, traywin->parent, f, 0, 0);
	// reverted Rev 407 because here it's breaking alls icon with systray + xcompmgr
	Picture pict_image = XRenderCreatePicture(server.display, traywin->win, f, 0, 0);
	if (!pict_image) {
		XFreePixmap(server.display, tmp_pmap);
		XSetErrorHandler(old);
		goto on_error;
	}
	Picture pict_drawable =
		XRenderCreatePicture(server.display, tmp_pmap, XRenderFindVisualFormat(server.display, server.visual32), 0, 0);
	if (!pict_drawable) {
		XRenderFreePicture(server.display, pict_image);
		XFreePixmap(server.display, tmp_pmap);
		XSetErrorHandler(old);
		goto on_error;
	}
	XRenderComposite(server.display,
	                 PictOpSrc,
	                 pict_image,
	                 None,
	                 pict_drawable,
	                 0,
	                 0,
	                 0,
	                 0,
	                 0,
	                 0,
	                 traywin->width,
	                 traywin->height);
	XRenderFreePicture(server.display, pict_image);
	XRenderFreePicture(server.display, pict_drawable);
	// end of the ugly hack and we can continue as before

	imlib_context_set_visual(server.visual32);
	imlib_context_set_colormap(server.colormap32);
	imlib_context_set_drawable(tmp_pmap);
	Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, traywin->width, traywin->height, 1);
	imlib_context_set_visual(server.visual);
	imlib_context_set_colormap(server.colormap);
	XFreePixmap(server.display, tmp_pmap);
	if (!image) {
		imlib_context_set_visual(server.visual);
		imlib_context_set_colormap(server.colormap);
		XSetErrorHandler(old);
		goto on_error;
	} else {
		if (traywin->image) {
			imlib_context_set_image(traywin->image);
			imlib_free_image_and_decache();
		}
		traywin->image = image;
	}

	imlib_context_set_image(traywin->image);
	// if (traywin->depth == 24)
	// imlib_save_image("/home/thil77/test.jpg");
	imlib_image_set_has_alpha(1);
	DATA32 *data = imlib_image_get_data();
	if (traywin->depth == 24) {
		create_heuristic_mask(data, traywin->width, traywin->height);
	}

	if (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)
		adjust_asb(data,
		           traywin->width,
		           traywin->height,
		           systray.alpha,
		           (float)systray.saturation / 100,
		           (float)systray.brightness / 100);
	imlib_image_put_back_data(data);

	systray_render_icon_from_image(traywin);

	if (traywin->damage)
		XDamageSubtract(server.display, traywin->damage, None, None);
	XSync(server.display, False);
	XSetErrorHandler(old);

	if (error)
		goto on_error;

	panel_refresh = TRUE;

	if (systray_profile)
		fprintf(stderr,
		        "[%f] %s:%d win = %lu (%s)\n",
		        profiling_get_time(),
		        __FUNCTION__,
		        __LINE__,
		        traywin->win,
		        traywin->name);

	return;

on_error:
	fprintf(stderr,
	        RED "systray %d: rendering error for icon %lu (%s) pid %d" RESET "\n",
	        __LINE__,
	        traywin->win,
	        traywin->name,
	        traywin->pid);
	return;

on_systray_error:
	fprintf(stderr,
	        RED "systray %d: rendering error for icon %lu (%s) pid %d. "
	            "Disabling compositing and restarting systray..." RESET "\n",
	        __LINE__,
	        traywin->win,
	        traywin->name,
	        traywin->pid);
	systray_composited = 0;
	stop_net();
	start_net();
	return;
}