Exemplo n.º 1
0
void XImlib2Image::repaint()
{
    XDesktopContainer * xContainer =
	dynamic_cast<XDesktopContainer *>(container);
    
    Imlib_Image cropImage = xContainer->bg->createCropImage(x, y, width, height, width, height);
    
    imlib_context_set_dither(1);

    imlib_context_set_blend(1);       //automatically blend image and background
    imlib_context_set_dither_mask(0);
    imlib_context_set_image(cropImage);
    imlib_blend_image_onto_image(image, 1, 0, 0, width, height, 0, 0, width, height);
    
    imlib_image_set_has_alpha(1);
    
    imlib_context_set_anti_alias(1);  //smoother scaling
    imlib_context_set_blend(0);    
    
    imlib_context_set_drawable(window);
    imlib_render_image_on_drawable_at_size(0, 0, width, height);
    
    imlib_free_image();
    imlib_context_set_drawable(xContainer->getRootWindow());
}
Exemplo n.º 2
0
void XImlib2Image::configure()
{
    x = iconParent->getX();
    y = iconParent->getY();

    DesktopIconConfig * dIconConfig =
        dynamic_cast<DesktopIconConfig *>(iconConfig);
	
    DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(config);

    transparency = dConfig->getTransparency();

    width = dIconConfig->getWidth();
    height = dIconConfig->getHeight();
    
    glowing = false;
    glowChange = true;

    colorMod = imlib_create_color_modifier();
    
    fillStyle = dIconConfig->getFillStyle();
    
    XDesktopContainer * xContainer =
		    dynamic_cast<XDesktopContainer *>(container);  
	
    rootWindow = xContainer->getRootWindow();
    widthOfScreen = xContainer->widthOfScreen();
    heightOfScreen = xContainer->heightOfScreen();
    display = xContainer->getDisplay();
    visual = imlib_context_get_visual();
    cmap = imlib_context_get_colormap();
    screen = DefaultScreen(display);
    depth =  DefaultDepth(display,screen);
}
Exemplo n.º 3
0
void XImlib2Caption::moveWindow(int xC, int yC)
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);
    setXY(xC, yC);
    XMoveWindow( xContainer->getDisplay(), window, xC, yC );
}
Exemplo n.º 4
0
void XImlib2Caption::unmapWindow()
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);

    XUnmapWindow( xContainer->getDisplay(), window );
}
Exemplo n.º 5
0
Timer::Timer(AbstractContainer * con):container(con)
{
	XDesktopContainer * xContainer = dynamic_cast<XDesktopContainer *>(container);
	c = ConnectionNumber(xContainer->getDisplay());
	if( fcntl( c, F_SETFD, 1 ) == -1) {
		cerr << "* Error: Couldn't mark display connection as close-on-exec\n";
		exit(0);
	}
}
Exemplo n.º 6
0
void XImlib2Shadow::moveWindow(int xCord, int yCord)
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(container);
    XIcon * xIcon = dynamic_cast<XIcon *>(iconParent);

    if (xCord >= 0 &&
        yCord >= 0 &&
        xCord < xContainer->widthOfScreen() &&
        yCord < xContainer->heightOfScreen() )
    {
        x = xCord;
        y = yCord;
        XMoveWindow( xContainer->getDisplay() , window, x, y );
    }
}
Exemplo n.º 7
0
XImlib2Caption::~XImlib2Caption()
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);

   XftColorFree( xContainer->getDisplay(), visual, cmap, &fontColor );

    if (shadowOn)
        XftColorFree( xContainer->getDisplay(), visual, cmap, &shadowFontColor);

    if(gc)
	XFreeGC(xContainer->getDisplay(), gc);
    
     XDestroyWindow(xContainer->getDisplay(), window);
     XftDrawDestroy(fontDrawHandle);
}
Exemplo n.º 8
0
void XImlib2Caption::draw()
{
        XDesktopContainer * xContainer =
			dynamic_cast<XDesktopContainer *>(AbstractImage::container);
	XIconWithShadow * sIcon = dynamic_cast<XIconWithShadow *>(AbstractImage::iconParent);

        Display * display = xContainer->getDisplay();
    
	int fX, fY;
    
	setXY(fX, fY);
	
	Imlib_Image cropImage = xContainer->bg->createCropImage(fX, fY, width, height, width, height);
	
	imlib_context_set_image(cropImage);
	
	imlib_context_set_drawable(window);
	imlib_render_image_on_drawable(0, 0);
	
	Pixmap shapeMask;
	imlib_render_pixmaps_for_whole_image (&pixmap, &shapeMask);
	XSetWindowBackgroundPixmap (display, window, pixmap);
	imlib_free_image();
	
	imlib_context_set_drawable(xContainer->getRootWindow());

       	imlib_context_set_image(xContainer->bg->spareRoot);
    
    // if the icon shadow is enabled and the shadow is visible underneath the
    // text window
	if (sIcon && //TODO Fix this
		   sIcon->getShadowX() > fX - sIcon->getWidth() &&
		   sIcon->getShadowY() > fY - sIcon->getHeight() &&
		   sIcon->getShadowX() < fX + sIcon->getWidth() &&
		   sIcon->getShadowY() < fY + sIcon->getHeight() )
		sIcon->renderShadowToImage(pixmap, fX, fY);

	updateText();

	XMoveWindow(display, window, fX, fY );
    
        //apply the buffer to the window
	XSetFillStyle(display, gc, FillTiled);
	XSetTile(display, gc, pixmap);
	XFillRectangle(display, window, gc, 0, 0, width, height);
	imlib_free_pixmap_and_mask(pixmap);
}
Exemplo n.º 9
0
void XImlib2Caption::createWindow()
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);

    DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(XImlib2Image::config);

    XSetWindowAttributes attr;
    attr.override_redirect = True;
    attr.cursor = XCreateFontCursor(xContainer->getDisplay(), dConfig->getCursorOver());
    
    attr.event_mask = SubstructureRedirectMask |
                      SubstructureNotifyMask   |
                      ButtonPressMask          |
                      ButtonReleaseMask        |
                      PointerMotionMask        |
                      PropertyChangeMask       |
                      ExposureMask;

    XftTextExtentsUtf8( xContainer->getDisplay(), font, (XftChar8*)text.c_str(), text.length(), &fontInfo );

    // fix window extents so shadow text is not cut
    // TODO: fix window extents if shadow is negative:
    // Would have to edit x and y of the window
    width = fontInfo.width + FONTSHIFT;
    height = font->height;

    if (shadowOn)
    {
        width += shadowX > 0 ? shadowX : 0;
        height += shadowY > 0 ? shadowY : 0;
    }
    window = XCreateWindow( xContainer->getDisplay(),
                            xContainer->getRootWindow(),
                            0,
                            0,
                            width,
                            height,
                            0,
                            CopyFromParent,
                            CopyFromParent,
                            CopyFromParent,
			    CWOverrideRedirect|CWEventMask|CWCursor,
                            &attr );
}
Exemplo n.º 10
0
void XImlib2Background::esetroot_pixmap_property(Window root_window, Pixmap p, GC gc , int w, int h)
{
	Pixmap esetroot_pixmap = None;
	
	XDesktopContainer * xContainer =
			dynamic_cast<XDesktopContainer *>(container);
	
	Display* display = xContainer->getDisplay();
	int screen = DefaultScreen(display);

	if (!p)
		set_root_pixmap(display,  root_window, None);
  
	if (root_window)
	{	
		esetroot_pixmap = make_root_pixmap(display, w, h);
		XCopyArea(display, p , esetroot_pixmap,  gc , 0, 0, w, h, 0, 0);
		set_root_pixmap(display, root_window, esetroot_pixmap);
	}
}
Exemplo n.º 11
0
void XImlib2Caption::createFont()
{
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);
    DesktopIconConfig * dIconConfig =
        dynamic_cast<DesktopIconConfig *>(AbstractImage::iconConfig);

    font = XftFontOpen( xContainer->getDisplay(),
                        DefaultScreen( xContainer->getDisplay()), 
                        XFT_FAMILY,
                        XftTypeString,
                        dIconConfig->getFont().c_str(),
                        XFT_SIZE,
                        XftTypeDouble,
                        (double)dIconConfig->getFontSize(), 
                        XFT_WEIGHT, XftTypeInteger, boldVal,
                        NULL );
    
    XColor  screen, exact;
    if (!XAllocNamedColor (xContainer->getDisplay(), cmap, (char*)dIconConfig->getFontColor().c_str(), &screen, &exact))
        cout << "BAD COLORS!!!\n";
    
    XftColorAllocName(xContainer->getDisplay(), visual, cmap,
                      (char*)dIconConfig->getFontColor().c_str(), &fontColor );

    if (shadowOn)
        XftColorAllocName(xContainer->getDisplay(), visual, cmap,
                          (char*)shadowColor.c_str(), &shadowFontColor );
}
Exemplo n.º 12
0
void XImlib2Caption::renderFont2Imlib()
{
   
    XDesktopContainer * xContainer =
        dynamic_cast<XDesktopContainer *>(AbstractImage::container);

    Display * display = xContainer->getDisplay();
    int screen =  DefaultScreen(display);

    pixmap = XCreatePixmap(display, window, width,
                            height,
                           DefaultDepth(display, screen));
    
    XSetWindowBackgroundPixmap (display, window, pixmap);
    
    gc = XCreateGC(display, window, 0, 0);
    
    if( pixmap == (Pixmap) NULL )
    {
	    printf("\nError creando Pixmap\n");
	    XCloseDisplay(display);
	    exit(1);
    }
    
    fontDrawHandle = XftDrawCreate(display, pixmap, visual, cmap);

    XSetFillStyle(display, gc, FillSolid);
    XSetForeground(display, gc, BlackPixel(display, 0));
    XSetBackground(display, gc, WhitePixel(display, 0));
    XFillRectangle(display, pixmap, gc, 0, 0, width, height);
    Pixmap shapeMask = XCreatePixmap(display, window, width, height,1);
    GC tempGc = XCreateGC(display, shapeMask, 0, 0);
    XCopyPlane(display, pixmap, shapeMask, tempGc, 0, 0, width, height, 0, 0, 1);
#ifdef SHAPE					
    XShapeCombineMask(display, window, 0, 0, 0, shapeMask, ShapeUnion);
#endif // SHAPE
    imlib_context_set_drawable(pixmap);
}
Exemplo n.º 13
0
void XImlib2Image::setupLayer() {
  
    XDesktopContainer * xContainer =
            dynamic_cast<XDesktopContainer *>(container);
	    
    Display *disp = xContainer->getDisplay();

    Atom type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", false);
    Atom state = XInternAtom(disp, "_NET_WM_STATE", false);
    
    Atom state_atoms[] = {
        XInternAtom(disp, "_NET_WM_STATE_BELOW", false),
        XInternAtom(disp, "_NET_WM_STATE_HIDDEN", false),
        XInternAtom(disp, "_NET_WM_STATE_SKIP_PAGER", false),
        XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", false),
        XInternAtom(disp, "_NET_WM_STATE_STICKY", false)
    };

    Atom type_atoms =  XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DESKTOP", false);

    XChangeProperty(disp, window, state, XA_ATOM,
                                 32, PropModeReplace,
                                 (unsigned char *)(state_atoms), 5);
    XChangeProperty(disp, window, type, XA_ATOM,
                                 32, PropModeReplace,
                                 (unsigned char *)(&type_atoms), 1);

    XChangeProperty(disp, window, state, XA_ATOM,
                                  32, PropModeReplace,
                                  (unsigned char *)(state_atoms), 5);
    
    XChangeProperty(disp, window, type, XA_ATOM,
                                  32, PropModeReplace,
                                  (unsigned char *)(&type_atoms), 1);

}
Exemplo n.º 14
0
void XImlib2Background::SetMultiImage(Imlib_Image image)
{
      Pixmap pmap = None, mask = None;
      GC gc;
      XGCValues gcv;
      XColor xcolor;
      int w, h, x, y, widthOfScreen, heightOfScreen, screen, depth;
      char *bgcolor = NULL;
      Colormap colormap;
      Display* display;
      Window rootWindow;
      string mode;
      
      DesktopConfig * dConfig =
		    dynamic_cast<DesktopConfig *>(config);
       
      XDesktopContainer * xContainer =
                    dynamic_cast<XDesktopContainer *>(container);
      
      display = xContainer->getDisplay();
      rootWindow = xContainer->getRootWindow();	
      screen = DefaultScreen(display);
      depth =  DefaultDepth(display, screen);
      colormap = DefaultColormap(display, screen);
      widthOfScreen = xContainer->widthOfScreen();
      heightOfScreen = xContainer->heightOfScreen();
      mode = dConfig->getModeBackground();
      
      pixmap = XCreatePixmap(display, rootWindow , widthOfScreen, heightOfScreen, depth);
      
      string color = dConfig->getColorBackground();
      
      if(color != "None"){
      	gcv.foreground = gcv.background = BlackPixel(display, screen);
      
      	bgcolor = (char*)dConfig->getColorBackground().c_str();
      
      	if (bgcolor && XParseColor(display, colormap , bgcolor, &xcolor) && XAllocColor(display,  colormap, &xcolor)) {
	      gcv.foreground = gcv.background = xcolor.pixel;
      	  }
        }
      
      gc = XCreateGC(display, pixmap, (GCForeground | GCBackground), &gcv);
      
        if(image){
		
		imlib_context_set_image(image);
		
		if (mode == "SCALE") {
			w = widthOfScreen;
			h = heightOfScreen;
		} else if (mode == "MIRROR") {
			w = imlib_image_get_width() * 2;
			h = imlib_image_get_height() * 2;
		} else if (mode == "FIT") {
			double x_ratio, y_ratio;
			x_ratio = ((double) widthOfScreen) / ((double)  imlib_image_get_width());
			y_ratio = ((double) heightOfScreen) / ((double) imlib_image_get_height());
			if (x_ratio > y_ratio) {
				x_ratio = y_ratio;
			}
			w = (int) (imlib_image_get_width() * x_ratio);
			h = (int) (imlib_image_get_height() * x_ratio);
		} else {
			w = imlib_image_get_width();
			h = imlib_image_get_height();
		}
      	
		if (mode == "SCALE") {
			XFillRectangle(display, pixmap, gc, 0, 0, w, h);
		}
		if (mode == "CENTER" || mode == "FIT") {
			XFillRectangle(display, pixmap, gc, 0, 0, widthOfScreen, heightOfScreen);
			x = (widthOfScreen - w) >> 1;
			y = (heightOfScreen - h) >> 1;
		} else {