示例#1
0
static VALUE
gdkwin_get_internal_paint_info(VALUE self)
{
    GdkDrawable* real_drawable;
    gint x_offset, y_offset;

    gdk_window_get_internal_paint_info(_SELF(self), &real_drawable,
                                       &x_offset, &y_offset);
    return rb_ary_new3(3, GOBJ2RVAL(real_drawable),
                       INT2NUM(x_offset), INT2NUM(y_offset));
}
void cp_gtk_grab_current_drawable(GtkWidget *widget, GdkDrawable **draw,
				  GdkWindow **win)
{
  g_assert (widget != NULL);
  g_assert (draw != NULL);
  g_assert (win != NULL);

  *win = widget->window;

  *draw = *win;
  gdk_window_get_internal_paint_info (*win, draw, 0, 0); 
}
示例#3
0
文件: vtepangox.c 项目: Cordia/vte
static void
_vte_pango_x_start(struct _vte_draw *draw)
{
	struct _vte_pango_x_data *data;
	Display *display;
	GdkDrawable *drawable;
	int x_offs, y_offs;

	data = (struct _vte_pango_x_data*) draw->impl_data;

	display = gdk_x11_drawable_get_xdisplay(draw->widget->window);
	if (data->ctx != NULL) {
		g_object_unref(data->ctx);
	}
	data->ctx = pango_x_get_context(display);

	if (data->layout != NULL) {
		g_object_unref(data->layout);
	}
	data->layout = pango_layout_new(data->ctx);

	if (data->font != NULL) {
		pango_layout_set_font_description(data->layout, data->font);
	}

	if (data->gc != NULL) {
		g_object_unref(data->gc);
	}
	data->gc = gdk_gc_new(draw->widget->window);

	gdk_rgb_find_color(gdk_drawable_get_colormap(draw->widget->window),
			   &data->color);

	gdk_window_get_internal_paint_info(draw->widget->window, &drawable,
					&x_offs, &y_offs);
	data->drawable = gdk_x11_drawable_get_xid(drawable);
	data->x_offs = x_offs;
	data->y_offs = y_offs;
}
示例#4
0
文件: gamine.c 项目: btong/gamine
static cairo_t *
get_cairo_context (gamine_t *cb)
{
    Display *dpy;
    Drawable xid;
    Visual *visual;
    GdkDrawable *drawable;
    gint x_offset, y_offset;
    gint width, height;
    cairo_surface_t *surface;
    cairo_t *context;
    if (cb->is_cairo)
        return cb->cr;
    //if (GDK_IS_WINDOW (window)) {
    gdk_window_get_internal_paint_info ((cb->da)->window, &drawable,&x_offset,
            &y_offset);
    //} else {
    //    drawable = window;
    //};
    dpy = gdk_x11_drawable_get_xdisplay (drawable);
    xid = gdk_x11_drawable_get_xid (drawable);
    gdk_drawable_get_size (drawable, &width, &height);
    visual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual (drawable));
    //create an xlib surface 
    surface = cairo_xlib_surface_create (dpy, xid, visual,
        width, height);
    //create context
    context = cairo_create (surface);
    //cairo_surface_destroy (surface);
    
    //if (GDK_IS_WINDOW (window))
    cairo_translate (context, -x_offset, -y_offset);
    cb->is_cairo = TRUE;
    cb->cr = context;
    cb->surface = surface;
    return context;
}
示例#5
0
static cairo_t *_mt_cairo_begin(MT_TOOLKIT *mt, MT_WINDOW *win, MT_RECTANGLE *area, int x, int y, int width, int height)
{
   GdkWindow *window = (GdkWindow *)win;
   GdkDrawable *drawable;
   cairo_t *cr;
   gint xoff, yoff;
   gint w, h;

   /* revert to rendering to GdkPixbuf (needed for Gecko based applications): */
   if (!window || !GDK_IS_WINDOW(window)) {
      return _mt_cairo_begin_pixbuf(mt, win, area, x, y, width, height);
   }

   gdk_window_get_internal_paint_info(window, &drawable, &xoff, &yoff);

   if (!drawable) {
      return _mt_cairo_begin_pixbuf(mt, win, area, x, y, width, height);
   }

   gdk_drawable_get_size(drawable, &w, &h);
   _cairo_surface = cairo_xlib_surface_create(gdk_x11_drawable_get_xdisplay(drawable),
                                              gdk_x11_drawable_get_xid(drawable),
                                              gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(drawable)),
                                              w, h);
   cr = cairo_create(_cairo_surface);
   
   cairo_translate(cr, -xoff + x, -yoff + y);

   if (area) {
      cairo_rectangle(cr, area->x - x, area->y - y, area->width, area->height);
      cairo_clip(cr);
      cairo_rectangle(cr, 0, 0, width, height);
      cairo_clip(cr);
   }

   return cr;
}
static void 
grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win)
{  
  g_assert (widget != NULL);
  g_assert (draw != NULL);
  g_assert (win != NULL);

  if (GTK_IS_WINDOW (widget))
    {
      *win = find_gtk_layout (widget)->bin_window;
    }
  else if (GTK_IS_LAYOUT (widget))
    {
      *win = GTK_LAYOUT (widget)->bin_window;
    }
  else
    {
      *win = widget->window;
    }

  *draw = *win;
  gdk_window_get_internal_paint_info (*win, draw, 0, 0);
  g_object_ref (*draw);
}
gboolean expose_parent(GtkWidget * widget, GdkEventExpose * event) {

    OMWeather *plugin = OMWEATHER(widget);
    GdkDrawable *drawable;
    gint x_offset, y_offset;
    XRenderColor color;
    Picture picture;
    XserverRegion region;
    cairo_t *cr;
    gint radius = 0;
    gint width, height, x, y;

    if (GTK_WIDGET_DRAWABLE(widget) == FALSE) {
        return FALSE;
    }

    gtk_widget_set_size_request(GTK_WIDGET(widget), -1, -1);
    gdk_window_get_internal_paint_info(widget->window, &drawable,
                                       &x_offset, &y_offset);


    picture = hildon_desktop_picture_from_drawable(drawable);

    if (picture == None) {
        return FALSE;
    }

    plugin->clip.x = event->area.x - x_offset;
    plugin->clip.y = event->area.y - y_offset;
    plugin->clip.width = event->area.width + x_offset;
    plugin->clip.height = event->area.height + y_offset;

    region = XFixesCreateRegion(GDK_DISPLAY(), &plugin->clip, 1);

    XFixesSetPictureClipRegion(GDK_DISPLAY(), picture, 0, 0, region);


    color.red = color.blue = color.green = 0;
    color.alpha = 0;

    XRenderFillRectangle(GDK_DISPLAY(), PictOpSrc, picture, &color,
                             0, 0,
                             widget->allocation.width,
                             widget->allocation.height);

    if (app->config->icons_layout < PRESET_NOW){
        radius = app->config->corner_radius;
        cr = gdk_cairo_create(drawable);
        cairo_set_source_rgba(cr,
                              (double)app->config->background_color.red /
                              (MAXSHORT * 2 + 1),
                              (double)app->config->background_color.green /
                              (MAXSHORT * 2 + 1),
                              (double)app->config->background_color.blue /
                              (MAXSHORT * 2 + 1),
                              (double)app->config->alpha_comp / 100);

        width = plugin->clip.width;
        height = plugin->clip.height;
        x = plugin->clip.x;
        y = plugin->clip.y;

        if ((radius > height / 2) || (radius > width / 2)) {
            if (width < height) {
                radius = width / 2 - 1;
            } else {
                radius = height / 2 - 2;
            }
        }

        cairo_move_to(cr, x + radius, y);
        cairo_line_to(cr, x + width - radius, y);
        cairo_curve_to(cr, x + width - radius, y, x + width, y, x + width,
                       y + radius);
        cairo_line_to(cr, x + width, y + height - radius);
        cairo_curve_to(cr, x + width, y + height - radius, x + width,
                       y + height, x + width - radius, y + height);
        cairo_line_to(cr, x + radius, y + height);
        cairo_curve_to(cr, x + radius, y + height, x, y + height, x,
                       y + height - radius);
        cairo_line_to(cr, x, y + radius);
        cairo_curve_to(cr, x, y + radius, x, y, x + radius, y);

        cairo_fill(cr);
        cairo_destroy(cr);
    }
    
    XFixesDestroyRegion(GDK_DISPLAY(), region);
    XRenderFreePicture(GDK_DISPLAY(), picture);

    if (plugin->queueRefresh) {
        redraw_home_window(TRUE);
        plugin->queueRefresh = FALSE;
    }

     
        
    return
        GTK_WIDGET_CLASS(g_type_class_peek_parent
                         (GTK_FRAME_GET_CLASS(widget)))->expose_event
        (widget, event);
}