コード例 #1
0
static cairo_t *
gdk_cairo_create (GdkDrawable *drawable)
{
    int width, height;
    cairo_t *cr = NULL;
    cairo_surface_t *surface = NULL;
    GdkVisual *visual = gdk_drawable_get_visual (drawable);

    gdk_drawable_get_size (drawable, &width, &height);
    if (visual)
	surface = cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable),
					     GDK_DRAWABLE_XID (drawable),
					     GDK_VISUAL_XVISUAL (visual),
					     width, height);
    else if (gdk_drawable_get_depth (drawable) == 1)
	surface = cairo_xlib_surface_create_for_bitmap
	    (GDK_PIXMAP_XDISPLAY (drawable),
	     GDK_PIXMAP_XID (drawable),
	     GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (drawable)),
	     width, height);
    else {
	g_warning ("Using Cairo rendering requires the drawable argument to\n"
		   "have a specified colormap. All windows have a colormap,\n"
		   "however, pixmaps only have colormap by default if they\n"
		   "were created with a non-NULL window argument. Otherwise\n"
		   "a colormap must be set on them with "
		   "gdk_drawable_set_colormap");
	return NULL;
    }
    if (surface) {
	cr = cairo_create (surface);
	cairo_surface_destroy (surface);
    }
    return cr;
}
コード例 #2
0
ファイル: display-common.c プロジェクト: phjbernard/viewglob
void raise_wrapped(GtkWidget* display_win_gtk, gchar* term_win_str) {

	Display* Xdisplay;
	Window display_win, term_win;

	Xdisplay = GDK_DRAWABLE_XDISPLAY(display_win_gtk->window);
	display_win = GDK_WINDOW_XID(display_win_gtk->window);
	term_win = str_to_win(term_win_str);

	if (display_win == 0 || term_win == 0)
		return;

	gint term_desktop = get_desktop(Xdisplay, term_win);
	gint disp_desktop = get_desktop(Xdisplay, display_win);

	if (term_desktop != -1 && disp_desktop != -1
			&& term_desktop != disp_desktop) {
		window_to_desktop(Xdisplay, display_win, term_desktop);
	}

	static int i = 0; i++;
	g_warning("raise %d", i);
	/*raise_window(Xdisplay, display_win, term_win, TRUE);*/
	//XMapRaised(Xdisplay, display_win);
	XRaiseWindow(Xdisplay, display_win);
}
コード例 #3
0
ファイル: display-common.c プロジェクト: phjbernard/viewglob
void refocus_wrapped(GtkWidget* display_win_gtk, gchar* term_win_str) {
	g_return_if_fail(display_win_gtk != NULL);
	g_return_if_fail(term_win_str != NULL);
	g_return_if_fail(display_win_gtk->window != NULL);

	Display* Xdisplay;
	Window display_win, term_win;

	Xdisplay = GDK_DRAWABLE_XDISPLAY(display_win_gtk->window);
	display_win = GDK_WINDOW_XID(display_win_gtk->window);
	term_win = str_to_win(term_win_str);

	if (display_win == 0 || term_win == 0)
		return;

	refocus(Xdisplay, display_win, term_win);
	static int i = 0; i++;
	g_warning("refocus %d", i);
}
コード例 #4
0
/*
 * This is identical to nsCanvasRenderingContext2D::Render, we just don't
 * have a good place to put it; though maybe I want a CanvasContextImpl that
 * all this stuff can derive from?
 */
NS_METHOD 
compzillaRenderingContext::Render (nsIRenderingContext *rc)
{
    DEBUG ("Render\n");

    nsresult rv = NS_OK;

#ifdef MOZ_CAIRO_GFX

    DEBUG ("thebes\n");

    gfxContext* ctx = (gfxContext*) rc->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
    nsRefPtr<gfxPattern> pat = new gfxPattern(mThebesSurface);

    // XXX I don't want to use PixelSnapped here, but layout doesn't guarantee
    // pixel alignment for this stuff!
    ctx->NewPath();
    ctx->PixelSnappedRectangleAndSetPattern(gfxRect(0, 0, mWidth, mHeight), pat);
    ctx->Fill();
#else
    DEBUG ("non-thebes\n");

    // non-Thebes; this becomes exciting
    cairo_surface_t *dest = nsnull;
    cairo_t *dest_cr = nsnull;

    GdkDrawable *gdkdraw = nsnull;
#ifdef MOZILLA_1_8_BRANCH
    rv = rc->RetrieveCurrentNativeGraphicData((void**) &gdkdraw);
    if (NS_FAILED(rv) || !gdkdraw)
        return NS_ERROR_FAILURE;
#else
    gdkdraw = (GdkDrawable*) rc->GetNativeGraphicData(nsIRenderingContext::NATIVE_GDK_DRAWABLE);
    if (!gdkdraw)
        return NS_ERROR_FAILURE;
#endif

    gint w, h;
    gdk_drawable_get_size (gdkdraw, &w, &h);
    dest = cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY(gdkdraw),
                                      GDK_DRAWABLE_XID(gdkdraw),
                                      GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(gdkdraw)),
                                      w, h);
    dest_cr = cairo_create (dest);

    nsTransform2D *tx = nsnull;
    rc->GetCurrentTransform(tx);

    nsCOMPtr<nsIDeviceContext> dctx;
    rc->GetDeviceContext(*getter_AddRefs(dctx));

    float x0 = 0.0, y0 = 0.0;
    float sx = 1.0, sy = 1.0;
    if (tx->GetType() & MG_2DTRANSLATION) {
        tx->Transform(&x0, &y0);
    }

    if (tx->GetType() & MG_2DSCALE) {
        sx = sy = dctx->DevUnitsToTwips();
        tx->TransformNoXLate(&sx, &sy);
    }

    cairo_translate (dest_cr, NSToIntRound(x0), NSToIntRound(y0));
    if (sx != 1.0 || sy != 1.0)
        cairo_scale (dest_cr, sx, sy);

    cairo_rectangle (dest_cr, 0, 0, mWidth, mHeight);
    cairo_clip (dest_cr);

    cairo_set_source_surface (dest_cr, mSurface, 0, 0);
    cairo_paint (dest_cr);

    if (dest_cr)
        cairo_destroy (dest_cr);
    if (dest)
        cairo_surface_destroy (dest);
#endif

    return rv;
}