コード例 #1
0
ファイル: menus.c プロジェクト: ShadowKyogre/lunchbox
/**
@pre      display is valid, themes is valid, cursors is valid.
@pre      all widgets are zero'd.
@pre      themes is valid and has loaded at least a background for the popup_menu_parent. 
@post     Menu with borders and background but no items is created but not mapped.
@brief    This function is used to create a blank and generic menu.  Items must be added by caller.
@return   void
**/
void 
create_popup_menu(Display *display, struct Popup_menu *menu, struct Themes *themes, struct Cursors *cursors) {

  XSetWindowAttributes set_attributes;
  Window root = DefaultRootWindow(display);
  Screen* screen = DefaultScreenOfDisplay(display);
  int black = BlackPixelOfScreen(screen);
  
  const int width = menu->inner_width + themes->popup_menu[popup_l_edge].w + themes->popup_menu[popup_r_edge].w;
  const int height = menu->inner_height + themes->popup_menu[popup_t_edge].h + themes->popup_menu[popup_b_edge].h;
  
  menu->widgets[popup_menu_parent].widget = XCreateSimpleWindow(display, root
  , 0, 0
  , width, height, 0, black, black);

  XDefineCursor(display, menu->widgets[popup_menu_parent].widget, cursors->normal);
  XSetWindowBackgroundPixmap(display, menu->widgets[popup_menu_parent].widget
  , themes->popup_menu[popup_menu_parent].state_p[normal]);
   
  //Currently, this is the "base" of the popup menu.
  //A similar loop will be needed for the actual menu items but not in this function
  for(int i = popup_t_edge; i < popup_menu_parent; i++) { //popup_menu_parent already done

    int x = themes->popup_menu[i].x;
    int y = themes->popup_menu[i].y;
    int w = themes->popup_menu[i].w;
    int h = themes->popup_menu[i].h;
    
    if(x < 0)  x += width;
    if(y < 0)  y += height; 
    if(w <= 0) w += width;
    if(h <= 0) h += height;
  
    menu->widgets[i].widget = XCreateSimpleWindow(display
    , menu->widgets[popup_menu_parent].widget
    , x, y, w, h, 0, black, black);
    
    if(themes->popup_menu[i].w <= 0) w = XWidthOfScreen(screen);
    if(themes->popup_menu[i].h <= 0) h = XWidthOfScreen(screen);    
    for(int j = 0; j <= inactive; j++) {
      if(themes->popup_menu[i].state_p[j]) {
        menu->widgets[i].state[j] = XCreateSimpleWindow(display, menu->widgets[i].widget
        , 0, 0, w, h, 0, black, black);
        XSetWindowBackgroundPixmap(display, menu->widgets[i].state[j]
        , themes->popup_menu[i].state_p[j]);
        if(j == normal) XMapWindow(display, menu->widgets[i].state[j]);
      }
    }

    XMapWindow(display, menu->widgets[i].widget);
  } 

  set_attributes.override_redirect = True; 
  XChangeWindowAttributes(display, menu->widgets[popup_menu_parent].widget, CWOverrideRedirect, &set_attributes);

//  XMapWindow(display, menu->widgets[popup_menu_parent].widget);
  XFlush(display);


}
コード例 #2
0
ファイル: startupid.cpp プロジェクト: fluxer/kde-workspace
void StartupId::update_startupid()
    {
    int yoffset = 0;
    if( blinking )
        {
        XSetWindowBackgroundPixmap( QX11Info::display(), startup_window,
            pixmaps[ color_to_pixmap[ color_index ]].handle());
        XClearWindow( QX11Info::display(), startup_window );
        if( ++color_index >= ( sizeof( color_to_pixmap ) / sizeof( color_to_pixmap[ 0 ] )))
            color_index = 0;
        }
    else if( bouncing )
        {
        yoffset = frame_to_yoffset[ frame ];
        QPixmap pixmap = pixmaps[ frame_to_pixmap[ frame ] ];
        XSetWindowBackgroundPixmap( QX11Info::display(), startup_window, pixmap.handle());
        XClearWindow( QX11Info::display(), startup_window );
        if ( !pixmap.mask().isNull() ) // set mask
            XShapeCombineMask( QX11Info::display(), startup_window, ShapeBounding, 0, 0,
                pixmap.mask().handle(), ShapeSet );
        else // clear mask
            XShapeCombineMask( QX11Info::display(), startup_window, ShapeBounding, 0, 0, None, ShapeSet );
        if ( ++frame >= ( sizeof( frame_to_yoffset ) / sizeof( frame_to_yoffset[ 0 ] ) ) )
            frame = 0;
        }
    Window dummy1, dummy2;
    int x, y;
    int dummy3, dummy4;
    unsigned int dummy5;
    if( !XQueryPointer( QX11Info::display(), QX11Info::appRootWindow(), &dummy1, &dummy2, &x, &y, &dummy3, &dummy4, &dummy5 ))
        {
        XUnmapWindow( QX11Info::display(), startup_window );
        update_timer.start( 100 );
        return;
        }
    QPoint c_pos( x, y );
    int cursor_size = 0;
#ifdef HAVE_XCURSOR
    cursor_size = XcursorGetDefaultSize( QX11Info::display());
#endif
    int X_DIFF;
    if( cursor_size <= 16 )
        X_DIFF = 8 + 7;
    else if( cursor_size <= 32 )
        X_DIFF = 16 + 7;
    else if( cursor_size <= 48 )
        X_DIFF = 24 + 7;
    else
        X_DIFF = 32 + 7;
    int Y_DIFF = X_DIFF;
    XMoveWindow( QX11Info::display(), startup_window, c_pos.x() + X_DIFF, c_pos.y() + Y_DIFF + yoffset );
    XMapWindow( QX11Info::display(), startup_window );
    XRaiseWindow( QX11Info::display(), startup_window );
    update_timer.start( bouncing ? 30 : 100 );
    QApplication::flush();
    }
コード例 #3
0
ファイル: window.c プロジェクト: dochang/sxiv
void win_draw(win_t *win) {
	if (win == NULL || win->xwin == None)
		return;

	XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm);
	XClearWindow(win->env.dpy, win->xwin);
}
コード例 #4
0
static gboolean
cycle_window (GstXOverlay * ov)
{
  XGCValues values;
  Window old_win = win;
  GC old_gc = gc;

  win = XCreateSimpleWindow (disp, root, 0, 0, width, height, 0, 0, 0);

  XSetWindowBackgroundPixmap (disp, win, None);

  gc = XCreateGC (disp, win, 0, &values);

  XMapRaised (disp, win);

  XSync (disp, FALSE);

  gst_x_overlay_set_xwindow_id (ov, win);

  if (old_win) {
    XDestroyWindow (disp, old_win);
    XFreeGC (disp, old_gc);
    XSync (disp, FALSE);
  }

  return TRUE;
}
コード例 #5
0
ファイル: TrayWindow.c プロジェクト: t3swing/fcitx-clone
Bool CreateTrayWindow() {
    tray_init(dpy, &tray);
    XVisualInfo* vi = tray_get_visual(dpy, &tray);
    Window dock = tray_get_dock(dpy);
    if (vi && vi->visual) {
        Window p = DefaultRootWindow (dpy);
        Colormap colormap = XCreateColormap(dpy, p, vi->visual, AllocNone);
        XSetWindowAttributes wsa;
        wsa.background_pixmap = 0;
        wsa.colormap = colormap;
        wsa.background_pixel = 0;
        wsa.border_pixel = 0;
        tray.window = XCreateWindow(dpy, p, -1, -1, 1, 1,
                0, vi->depth, InputOutput, vi->visual,
                CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa);
    }
    else {
        tray.window = XCreateSimpleWindow (dpy, DefaultRootWindow(dpy), \
            0, 0, 1, 1, 0, \
            BlackPixel (dpy, DefaultScreen (dpy)), \
            WhitePixel (dpy, DefaultScreen (dpy)));
        XSetWindowBackgroundPixmap(dpy, tray.window, ParentRelative);
    }
    if (tray.window == (Window) NULL)
        return False;
    // GNOME, NET WM Specification
    tray_send_opcode(dpy, dock, CurrentTime, SYSTEM_TRAY_REQUEST_DOCK,
            0, 0);

    XSizeHints size_hints;
    size_hints.flags = PWinGravity | PBaseSize;
    size_hints.base_width = 22;
    size_hints.base_height = 22;
    XSetWMNormalHints(dpy, tray.window, &size_hints);

    if (!ProcessTrayIcon(inactive_xpm, &tray.icon[INACTIVE_ICON], &tray.icon_mask[INACTIVE_ICON],
				&tray.picon[INACTIVE_ICON])) {
        fprintf(stderr, "failed to get inactive icon image\n");
        return False;
    }

    if (!ProcessTrayIcon(active_xpm, &tray.icon[ACTIVE_ICON], &tray.icon_mask[ACTIVE_ICON],
				&tray.picon[ACTIVE_ICON])) {
        fprintf(stderr, "failed to get active icon image\n");
        return False;
    }

    /* GCs for copy and drawing on mask */
    XGCValues gv;
    gv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
    gv.background = BlackPixel(dpy, DefaultScreen(dpy));
    tray.gc = XCreateGC(dpy, tray.window, GCBackground|GCForeground, &gv);

	XSetClipMask(dpy, tray.gc, tray.icon_mask[0]);

    XSelectInput (dpy, tray.window, ExposureMask | KeyPressMask | \
            ButtonPressMask | ButtonReleaseMask | StructureNotifyMask \
            | EnterWindowMask | PointerMotionMask | LeaveWindowMask | VisibilityChangeMask);
    return True;
}
コード例 #6
0
ファイル: mywindow.c プロジェクト: CBke/xfwm4
void
xfwmWindowSetBG (xfwmWindow * win, xfwmPixmap * pix)
{
    gboolean done;

    if ((win->width < 1) || (win->height < 1) || (pix->width < 1) || (pix->height < 1))
    {
        return;
    }

    done = FALSE;
#ifdef HAVE_RENDER
    if ((win->visual != win->screen_info->visual) ||
        (win->depth  != win->screen_info->depth))
    {
        /* Try to use Render */
        done = xfwmWindowCopyComposite (win, pix);
    }
#endif

    if (!done)
    {
        /* Use the good old way */
        XSetWindowBackgroundPixmap (myScreenGetXDisplay (win->screen_info), win->window, pix->pixmap);
    }
}
コード例 #7
0
ファイル: xpmroot.c プロジェクト: Bluerise/bitrig-xenocara
void SetRootWindow(char *tline)
{
  XWindowAttributes root_attr;
  XpmAttributes xpm_attributes;
  Pixmap shapeMask;
  int val;

  XGetWindowAttributes(dpy,root,&root_attr);
  xpm_attributes.colormap = root_attr.colormap;
  xpm_attributes.valuemask = XpmSize | XpmReturnPixels|XpmColormap;
  if((val = XpmReadFileToPixmap(dpy,root, tline,
			 &rootXpm, &shapeMask, 
			 &xpm_attributes))!= XpmSuccess) 
    {
      if(val == XpmOpenFailed)
	fprintf(stderr, "Couldn't open pixmap file\n");
      else if(val == XpmColorFailed)
	fprintf(stderr, "Couldn't allocate required colors\n");
      else if(val == XpmFileInvalid)
	fprintf(stderr, "Invalid Format for an Xpm File\n");
      else if(val == XpmColorError)
	fprintf(stderr, "Invalid Color specified in Xpm FIle\n");
      else if(val == XpmNoMemory)
	fprintf(stderr, "Insufficient Memory\n");
      exit(1);
    }

  XSetWindowBackgroundPixmap(dpy, root, rootXpm);
  save_colors = 1;
  XClearWindow(dpy,root);

}
コード例 #8
0
static void
create_host_window (void)
{
  unsigned long valuemask;
  XSetWindowAttributes attributes;

  display = XOpenDisplay (NULL);
  if (display) {
    window =
        XCreateSimpleWindow (display, DefaultRootWindow (display), 0, 0,
        x_width, x_height, 0, 0, 0);
    if (window) {
      valuemask = CWOverrideRedirect;
      attributes.override_redirect = True;
      XChangeWindowAttributes (display, window, valuemask, &attributes);
      XSetWindowBackgroundPixmap (display, window, None);
      XMapRaised (display, window);
      XSync (display, FALSE);
    } else {
      GST_DEBUG ("could not create X window!");
    }
  } else {
    GST_DEBUG ("could not open display!");
  }
}
コード例 #9
0
ファイル: x11_window.c プロジェクト: UIKit0/picogui
g_error x11_create_window(hwrbitmap *hbmp) {
  struct x11bitmap *xb;
  g_error e;
  XSetWindowAttributes attr;

  e = g_malloc((void**)&xb, sizeof(struct x11bitmap));
  errorcheck;
  memset(xb,0,sizeof(struct x11bitmap));
  xb->is_window = 1;

  /* Create the window.
   * The size and everything else will be configured in x11_internal_window_resize()
   */
  xb->d = XCreateSimpleWindow(x11_display, RootWindow(x11_display, x11_screen),0,0,1,1,0,0,0);
  xb->sb.w = xb->sb.h = 0;

  /* This prevents X from redrawing the window background at all */
  XSetWindowBackgroundPixmap(x11_display, xb->d, None);

  /* Optionally double-buffer this window */
  if (get_param_int("video-x11","doublebuffer",1)) {
    e = x11_new_backbuffer(&xb, xb);
    errorcheck;
  }

  xb->next_window = x11_window_list;
  x11_window_list = xb;

  *hbmp = (hwrbitmap) xb;
  return success;
}
コード例 #10
0
    uint32_t createSurface(const IntSize& size)
    {
        XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, m_fbConfig);
        if (!visualInfo)
            return 0;

        Colormap cmap = XCreateColormap(m_display, m_offScreenWindow.getXWindow(), visualInfo->visual, AllocNone);

        XSetWindowAttributes a;
        a.background_pixel = WhitePixel(m_display, 0);
        a.border_pixel = BlackPixel(m_display, 0);
        a.colormap = cmap;
        m_surface = XCreateWindow(m_display, m_offScreenWindow.getXWindow(), 0, 0, size.width(), size.height(),
            0, visualInfo->depth, InputOutput, visualInfo->visual,
            CWBackPixel | CWBorderPixel | CWColormap, &a);
        XSetWindowBackgroundPixmap(m_display, m_surface, 0);
        XCompositeRedirectWindow(m_display, m_surface, CompositeRedirectManual);
        m_glxSurface = glXCreateWindow(m_display, m_fbConfig, m_surface, 0);
        XFree(visualInfo);

        // Make sure the XRender Extension is available.
        int eventBasep, errorBasep;
        if (!XRenderQueryExtension(m_display, &eventBasep, &errorBasep))
            return 0;

        XMapWindow(m_display, m_surface);
        return m_surface;
    }
コード例 #11
0
ファイル: clientwin.c プロジェクト: mozeq/skippy-xd
void
clientwin_move(ClientWin *cw, float f, int x, int y)
{
	/* int border = MAX(1, (double)DISTANCE(cw->mainwin) * f * 0.25); */
	int border = 0;
	XSetWindowBorderWidth(cw->mainwin->dpy, cw->mini.window, border);
	
	cw->factor = f;
	cw->mini.x = x + (int)cw->x * f;
	cw->mini.y = y + (int)cw->y * f;
	if(cw->mainwin->lazy_trans)
	{
		cw->mini.x += cw->mainwin->x;
		cw->mini.y += cw->mainwin->y;
	}
	cw->mini.width = MAX(1, (int)cw->client.width * f);
	cw->mini.height = MAX(1, (int)cw->client.height * f);
	XMoveResizeWindow(cw->mainwin->dpy, cw->mini.window, cw->mini.x - border, cw->mini.y - border, cw->mini.width, cw->mini.height);
	
	if(cw->pixmap)
		XFreePixmap(cw->mainwin->dpy, cw->pixmap);
	
	if(cw->destination)
		XRenderFreePicture(cw->mainwin->dpy, cw->destination);
	
	cw->pixmap = XCreatePixmap(cw->mainwin->dpy, cw->mini.window, cw->mini.width, cw->mini.height, cw->mainwin->depth);
	XSetWindowBackgroundPixmap(cw->mainwin->dpy, cw->mini.window, cw->pixmap);
	
	cw->destination = XRenderCreatePicture(cw->mainwin->dpy, cw->pixmap, cw->mini.format, 0, 0);
}
コード例 #12
0
ファイル: render.c プロジェクト: carriercomm/bmpanel
static void update_bg()
{
	if (currootpmap != *rootpmap && *rootpmap != 0) {
		currootpmap = *rootpmap;
		imlib_context_set_drawable(currootpmap);
		if (bg) {
			imlib_context_set_image(bg);
			imlib_free_image();
		}
		bg = imlib_create_image_from_drawable(0, bbx, bby, bbwidth, bbheight, 1);

		Pixmap tile, mask;
		imlib_context_set_display(bbdpy);
		imlib_context_set_visual(bbvis);
		imlib_context_set_drawable(bbwin);
		imlib_context_set_image(bg);
		
		Imlib_Image tmpbg = imlib_clone_image();
		tile_image_blend(tmpbg, theme->tile_img, 0, bbwidth);
		imlib_render_pixmaps_for_whole_image(&tile, &mask);
		XSetWindowBackgroundPixmap(bbdpy, bbwin, tile);
		imlib_free_pixmap_and_mask(tile);
		imlib_free_image();
	}
}
コード例 #13
0
ファイル: draw.c プロジェクト: lf94/Resurrection
void
Rterm_sync_screen(struct R_termscreen *screen, int row, int column, int len, int mode)
{
    if (screen == NULL) {

	return;
    }

    if (screen->buf) {
	if (mode == RTERM_SCREEN_SYNC) {
	    XSetWindowBackgroundPixmap(screen->window->app->display,
				       screen->window->id,
				       screen->buf);
	    XClearWindow(screen->window->app->display,
			 screen->window->id);
            XSync(screen->window->app->display, False);
	} else {
	    XCopyArea(screen->window->app->display,
		      screen->buf,
		      screen->window->id,
		      screen->bufgc,
		      Rterm_screen_column_x(screen, column),
		      Rterm_screen_row_y(screen, row),
		      screen->charw * len,
		      screen->charh,
		      Rterm_screen_column_x(screen, column),
		      Rterm_screen_row_y(screen, row));
	}
    }

    return;
}
コード例 #14
0
ファイル: app.cpp プロジェクト: BackupTheBerlios/slim-svn
void App::setBackground(const string& themedir) {
    string filename;
    filename = themedir + "/background.png";
    Image *image = new Image;
    bool loaded = image->Read(filename.c_str());
    if (!loaded){ // try jpeg if png failed
        filename = "";
        filename = themedir + "/background.jpg";
        loaded = image->Read(filename.c_str());
    }
    if (loaded) {
        string bgstyle = cfg.getOption("background_style");
        if (bgstyle == "stretch") {
            image->Resize(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
        } else if (bgstyle == "tile") {
            image->Tile(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
        } else if (bgstyle == "center") {
    	    string hexvalue = cfg.getOption("background_color");
            hexvalue = hexvalue.substr(1,6);
    	    image->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
        			    hexvalue.c_str());
        } else { // plain color or error
    	    string hexvalue = cfg.getOption("background_color");
            hexvalue = hexvalue.substr(1,6);
    	    image->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
        			    hexvalue.c_str());
        }
        Pixmap p = image->createPixmap(Dpy, Scr, Root);
        XSetWindowBackgroundPixmap(Dpy, Root, p);
    }
    XClearWindow(Dpy, Root);

    XFlush(Dpy);
}
コード例 #15
0
ファイル: window.c プロジェクト: rck/sxiv
void win_draw(win_t *win) {
	if (!win || !win->xwin)
		return;

	XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm);
	XClearWindow(win->env.dpy, win->xwin);
}
コード例 #16
0
void
mbdesktop_progress_dialog_set_percentage (MBDesktop   *mb, 
					  int          percentage)
{
  int barwidth = ((mb->desktop_width/2) * percentage) / 100 ;

  XSetForeground(mbdesktop_xdisplay(mb), mb->gc, 
		 WhitePixel(mbdesktop_xdisplay(mb), 
			    mbdesktop_xscreen(mb)));

  /* Clear Background */
  XFillRectangle(mbdesktop_xdisplay(mb), 
		 mb->win_dialog_backing, 
		 mb->gc, 
		 0, 0, 
		 mb->win_dialog_w, mb->win_dialog_h);

  XSetForeground(mbdesktop_xdisplay(mb), mb->gc, 
		 mb_col_xpixel(mb->hl_col));


  XFillRectangle(mbdesktop_xdisplay(mb), 
		 mb->win_dialog_backing, 
		 mb->gc, 
		 DIALOG_BORDER, DIALOG_BORDER, 
		 barwidth, (mb->desktop_height/4));

  XSetWindowBackgroundPixmap(mbdesktop_xdisplay(mb), mb->win_dialog, 
			     mb->win_dialog_backing);

  XClearWindow(mbdesktop_xdisplay(mb), mb->win_dialog);

  XFlush(mbdesktop_xdisplay(mb));
}
コード例 #17
0
ファイル: switcher.cpp プロジェクト: jordigh/fusilli
void
KWD::Switcher::redrawPixmap ()
{
	QPainter p (&mPixmap);
	QPainter bp (&mBackgroundPixmap);

	const int contentWidth  = mPixmap.width ();
	const int contentHeight = mPixmap.height ();

	mPixmap.fill (Qt::transparent);

	p.setCompositionMode (QPainter::CompositionMode_Source);
	p.setRenderHint (QPainter::SmoothPixmapTransform);

	mBackground->resizeFrame (QSizeF (contentWidth, contentHeight));
	mBackground->paintFrame (&p, QRect (0, 0, contentWidth, contentHeight));

	bp.setCompositionMode (QPainter::CompositionMode_Source);
	bp.drawPixmap (0, 0, mPixmap, mBorder.left, mBorder.top,
	               mGeometry.width (), mGeometry.height ());

	XSetWindowBackgroundPixmap (QX11Info::display (), mId,
	                            mX11BackgroundPixmap);

	XClearWindow (QX11Info::display (), mId);
}
コード例 #18
0
ファイル: gui.c プロジェクト: chinese-opendesktop/oxim
winlist_t *
gui_new_win(void)
{
    winlist_t *win;

    if (free_win)
    {
	win = free_win;
	free_win = free_win->next;
	bzero(win, sizeof(winlist_t));
    }
    else
    {
	win = oxim_malloc(sizeof(winlist_t), True);
    }
    win->window = XCreateSimpleWindow(gui->display, gui->root,
		0, 0, 1, 1, 1, 0, 0);
		XSetWindowBackgroundPixmap(gui->display, win->window, ParentRelative);
    win->win_draw_func = NULL;
    win->win_event_func = NULL;
    win->next = winlist;
    winlist = win;

    return win;
}
コード例 #19
0
EAPI void
ecore_x_window_pixmap_set(Ecore_X_Window win,
                          Ecore_X_Pixmap pmap)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   XSetWindowBackgroundPixmap(_ecore_x_disp, win, pmap);
}
コード例 #20
0
ファイル: clientwin.c プロジェクト: mozeq/skippy-xd
void
clientwin_unmap(ClientWin *cw)
{
	if(cw->damage)
	{
		XDamageDestroy(cw->mainwin->dpy, cw->damage);
		cw->damage = None;
	}
	
	if(cw->destination)
	{
		XRenderFreePicture(cw->mainwin->dpy, cw->destination);
		cw->destination = None;
	}
	
	if(cw->pixmap)
	{
		XFreePixmap(cw->mainwin->dpy, cw->pixmap);
		cw->pixmap = None;
	}
	
	XUnmapWindow(cw->mainwin->dpy, cw->mini.window);
	XSetWindowBackgroundPixmap(cw->mainwin->dpy, cw->mini.window, None);
	
	cw->focused = 0;
}
コード例 #21
0
int toolwin_win_create(ToolWin *tw) {
	tw->win = XCreateSimpleWindow(dpy, root, 20, 20, tw->w, tw->h, 0, 0, 0);
	tw->buf = XCreatePixmap(dpy, root, tw->w, tw->h, DefaultDepth(dpy,scr));
	cairo_surface_t *t = cairo_xlib_surface_create(dpy, tw->buf,
			DefaultVisual(dpy,scr), tw->w, tw->h);
	tw->ctx = cairo_create(t);
	cairo_surface_destroy(t);
	cairo_set_font_face(tw->ctx,conf.font);
	cairo_set_font_size(tw->ctx,conf.font_size);
	XSelectInput(dpy, tw->win, EVENT_MASK);
	XSetTransientForHint(dpy, tw->win, win);
	XSetWMProtocols(dpy, tw->win, &WM_DELETE_WINDOW, 1);
	XSizeHints *hints = XAllocSizeHints();
	hints->min_width = hints->max_width = tw->w;
	hints->min_height = hints->max_height = tw->h;
	hints->flags = PMinSize | PMaxSize;
	XSetWMNormalHints(dpy, tw->win, hints);
	XFree(hints);
	XStoreName(dpy, tw->win, tw->name);
	if (tw->backing) tw->backing(tw);
	else toolwin_backing(tw);
	XSetWindowBackgroundPixmap(dpy, tw->win, tw->buf);
	XFlush(dpy);
	return 0;
}
コード例 #22
0
ファイル: xlib_events.c プロジェクト: BehaviorEnterprises/Fex
void expose(XEvent *ev) {
	XExposeEvent *e = &ev->xexpose;
	if (e->window == info->win) info->draw(info);
	else {
		XSetWindowBackgroundPixmap(dpy, win, buf);
		XClearWindow(dpy,win);
	}
}
コード例 #23
0
ファイル: balloon.c プロジェクト: cneira/wmaker-crm
static void showText(WScreen *scr, int x, int y, int h, int w, const char *text)
{
	int width;
	int height;
	Pixmap pixmap;
	Pixmap mask;
	WMFont *font = scr->info_text_font;
	int side = 0;
	int ty;
	int bx, by;

	if (scr->balloon->contents)
		XFreePixmap(dpy, scr->balloon->contents);

	width = getMaxStringWidth(font, text) + 16;
	height = countLines(text) * WMFontHeight(font) + 4;

	if (height < 16)
		height = 16;
	if (width < height)
		width = height;

	if (x + width > scr->scr_width) {
		side = RIGHT;
		bx = x - width + w / 2;
		if (bx < 0)
			bx = 0;
	} else {
		side = LEFT;
		bx = x + w / 2;
	}
	if (bx + width > scr->scr_width)
		bx = scr->scr_width - width;

	if (y - (height + SPACE) < 0) {
		side |= TOP;
		by = y + h - 1;
		ty = SPACE;
	} else {
		side |= BOTTOM;
		by = y - (height + SPACE);
		ty = 0;
	}
	pixmap = makePixmap(scr, width, height, side, &mask);

	drawMultiLineString(scr->wmscreen, pixmap, scr->black, font, 8, ty + 2, text, strlen(text));

	XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
	scr->balloon->contents = pixmap;

	XResizeWindow(dpy, scr->balloon->window, width, height + SPACE);
	XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, mask, ShapeSet);
	XFreePixmap(dpy, mask);
	XMoveWindow(dpy, scr->balloon->window, bx, by);
	XMapRaised(dpy, scr->balloon->window);

	scr->balloon->mapped = 1;
}
コード例 #24
0
ファイル: dockapp.c プロジェクト: yogsothoth/wmmp
void
dockapp_set_background(Pixmap pixmap)
{
    if (dockapp_iswindowed) {
	Pixmap bg;
	bg = create_bg_pixmap();
	XCopyArea(display, pixmap, bg, gc, 0, 0, width, height,
		  offset_w, offset_w);
	XSetWindowBackgroundPixmap(display, icon_window, bg);
	XSetWindowBackgroundPixmap(display, window, bg);
	XFreePixmap(display, bg);
    } else {
	XSetWindowBackgroundPixmap(display, icon_window, pixmap);
	XSetWindowBackgroundPixmap(display, window, pixmap);
    }
    XClearWindow(display, icon_window);
    XFlush(display);
}
コード例 #25
0
ファイル: window.c プロジェクト: muennich/sxiv
void win_draw(win_t *win)
{
	if (win->bar.h > 0)
		win_draw_bar(win);

	XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->buf.pm);
	XClearWindow(win->env.dpy, win->xwin);
	XFlush(win->env.dpy);
}
コード例 #26
0
ファイル: xpaint.c プロジェクト: marioaugustorama/tropix-cmd
/*
 ****************************************************************
 *	Desenha o fundo da janela				*
 ****************************************************************
 */
int
draw_window (Display *dpy, Window win, XImage *ximage, IMAGE *ip)
{
	char		title[256];
	static int	old_width, old_height;

	/*
	 *	Pequena consistência.
	 */
	if (ximage->depth != DefaultDepth (dpy, screen))
	{
		msg
		(	"\"%s\": imagem tem profundidade incorreta (%d :: %d)",
			ip->i_name, ximage->depth, DefaultDepth (dpy, screen)
		);

		return (-1);
	}

	/*
	 *	Modifica o fundo, o tamanho e o título da janela.
	 */
	XSetWindowBackgroundPixmap (dpy, win, None);

	if (old_width == ximage->width && old_height == ximage->height)
		XResizeWindow (dpy, win, ximage->width - 1, ximage->height - 1);

	if (set_background (dpy, win, ximage, ip->i_name) < 0)
		return (-1);

	XResizeWindow (dpy, win, old_width = ximage->width, old_height = ximage->height);

	if (ip->i_comment == NOSTR)
	{
		snprintf
		(	title, sizeof (title),
			ip->i_ncolors > 0 ? "%s (%d x %d, %d cores)" : "%s (%d x %d)",
			basename (ip->i_name), ximage->width, ximage->height, ip->i_ncolors
		);
	}
	else
	{
		snprintf
		(	title, sizeof (title),
			ip->i_ncolors > 0 ? "%s (%d x %d, %d cores), %s" : "%s (%d x %d)",
			basename (ip->i_name), ximage->width, ximage->height, ip->i_ncolors,
			ip->i_comment
		);
	}

	XStoreName (dpy, win, title);

	XFlush (dpy);

	return (0);

}	/* end draw_window */
コード例 #27
0
ファイル: TrayWindow.c プロジェクト: niubenben/fcitx
void InitTrayWindow(TrayWindow *trayWindow)
{
    FcitxClassicUI *classicui = trayWindow->owner;
    Display *dpy = classicui->dpy;
    int iScreen = classicui->iScreen;
    char   strWindowName[] = "Fcitx Tray Window";
    if (!classicui->bUseTrayIcon || classicui->isSuspend)
        return;

    InitTray(dpy, trayWindow);

    XVisualInfo* vi = TrayGetVisual(dpy, trayWindow);
    if (vi && vi->visual) {
        Window p = DefaultRootWindow(dpy);
        Colormap colormap = XCreateColormap(dpy, p, vi->visual, AllocNone);
        XSetWindowAttributes wsa;
        wsa.background_pixmap = 0;
        wsa.colormap = colormap;
        wsa.background_pixel = 0;
        wsa.border_pixel = 0;
        trayWindow->window = XCreateWindow(dpy, p, -1, -1, 1, 1,
                                           0, vi->depth, InputOutput, vi->visual,
                                           CWBackPixmap | CWBackPixel | CWBorderPixel | CWColormap, &wsa);
    } else {
        trayWindow->window = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
                             -1, -1, 1, 1, 0,
                             BlackPixel(dpy, DefaultScreen(dpy)),
                             WhitePixel(dpy, DefaultScreen(dpy)));
        XSetWindowBackgroundPixmap(dpy, trayWindow->window, ParentRelative);
    }
    if (trayWindow->window == (Window) NULL)
        return;

    XSizeHints size_hints;
    size_hints.flags = PWinGravity | PBaseSize;
    size_hints.base_width = trayWindow->size;
    size_hints.base_height = trayWindow->size;
    XSetWMNormalHints(dpy, trayWindow->window, &size_hints);

    if (vi && vi->visual)
        trayWindow->cs_x = cairo_xlib_surface_create(dpy, trayWindow->window, trayWindow->visual.visual, 200, 200);
    else {
        Visual *target_visual = DefaultVisual(dpy, iScreen);
        trayWindow->cs_x = cairo_xlib_surface_create(dpy, trayWindow->window, target_visual, 200, 200);
    }
    trayWindow->cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 200, 200);

    XSelectInput(dpy, trayWindow->window, ExposureMask | KeyPressMask |
                 ButtonPressMask | ButtonReleaseMask | StructureNotifyMask
                 | EnterWindowMask | PointerMotionMask | LeaveWindowMask | VisibilityChangeMask);

    ClassicUISetWindowProperty(classicui, trayWindow->window, FCITX_WINDOW_DOCK, strWindowName);

    TrayFindDock(dpy, trayWindow);
}
コード例 #28
0
ファイル: razordeskman.cpp プロジェクト: B-Rich/razor-qt
RazorDeskManager::RazorDeskManager(const QString & configId, RazorSettings * config)
    : DesktopPlugin(configId, config)
{
    m_launchMode = DesktopPlugin::launchModeFromString(config->value("icon-launch-mode").toString());

    config->beginGroup(configId);
    bool makeIcons = config->value("icons", false).toBool();
    //now we got the desktop we need to determine if the user wants a defined picture there
    QString finalPixmap = config->value("wallpaper", "").toString();
    config->endGroup();

    if (finalPixmap.isEmpty() || !QFile::exists(finalPixmap))
    {
        //now we want to use the system default - we still need to find that one out though
        finalPixmap = razorTheme.desktopBackground();
        qDebug() << "trying to get system-defaults" << finalPixmap;
    }

    if (! finalPixmap.isEmpty())
    {
        qDebug() << "Creating wallpaper";
        int width,height;
        QDesktopWidget * dw = QApplication::desktop();
        if (dw->screenCount() == 1)
        {
            width=dw->width();
            height = dw->height();
        }
        else
        {
            width=dw->screenGeometry(-1).width();
            height=dw->screenGeometry(-1).height();
        }

        QPixmap pixmap(finalPixmap);
        pixmap = pixmap.scaled(width,height);
        Pixmap p = pixmap.handle();
        XGrabServer(QX11Info::display());
        XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(), XfitMan::atom("_XROOTPMAP_ID"), XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
        XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(), XfitMan::atom("ESETROOT_PMAP_ID"), XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
        XSetCloseDownMode(QX11Info::display(), RetainPermanent);
        XSetWindowBackgroundPixmap(QX11Info::display(), QX11Info::appRootWindow(), p);
        XClearWindow(QX11Info::display(), QX11Info::appRootWindow());
        XUngrabServer(QX11Info::display());
        XFlush(QX11Info::display());
    }
    
    if (makeIcons)
    {
        deskicons = new RazorSettings("deskicons", this);    
        m_fsw = new QFileSystemWatcher(QStringList() << QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), this);
        connect(m_fsw, SIGNAL(directoryChanged(const QString&)), this, SLOT(updateIconList()));
        updateIconList();
    }
}
コード例 #29
0
ファイル: xwnd.cpp プロジェクト: emuikernel/BaijieCppUILib
  void window::set_background ( color& c )
  {
    // hold a ref to the alloc'ed color
    back_color.set ( c );

    XSetWindowBackgroundPixmap( env, hwnd, None );
    /*XSetWindowBackground ( env,
         hwnd,
         c.pixel() ); */
    refresh();
  }
コード例 #30
-1
ファイル: menu.c プロジェクト: talisein/feh
void feh_menu_redraw(feh_menu * m)
{
	Imlib_Updates u, uu;

	if ((!m->needs_redraw) || (!m->visible) || (!m->updates))
		return;
	m->needs_redraw = 0;
	if (!m->pmap)
		m->pmap = XCreatePixmap(disp, m->win, m->w, m->h, depth);
	XSetWindowBackgroundPixmap(disp, m->win, m->pmap);

	u = imlib_updates_merge_for_rendering(m->updates, m->w, m->h);
	m->updates = NULL;
	if (u) {
		D(("I have updates to render\n"));
		for (uu = u; u; u = imlib_updates_get_next(u)) {
			int x, y, w, h;
			Imlib_Image im;

			imlib_updates_get_coordinates(u, &x, &y, &w, &h);
			D(("update coords %d,%d %d*%d\n", x, y, w, h));
			im = imlib_create_image(w, h);
			gib_imlib_image_fill_rectangle(im, 0, 0, w, h, 0, 0, 0, 0);
			if (im) {
				feh_menu_draw_to_buf(m, im, x, y);
				gib_imlib_render_image_on_drawable(m->pmap, im, x, y, 1, 0, 0);
				gib_imlib_free_image(im);
				XClearArea(disp, m->win, x, y, w, h, False);
			}
		}
		imlib_updates_free(uu);
	}
	return;
}