summaryrefslogtreecommitdiffstats
path: root/panels/info-overview/gnome-control-center-print-renderer.c
blob: e84a11a81fdb6a36ff55fe0ded28f10720c70934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */
/* Tool to set the property _GNOME_SESSION_ACCELERATED on the root window */
/*
 * Copyright (C) 2019 Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author:
 *   Bastien Nocera <hadess@hadess.net>
 *   Matthias Clasen <mclasen@redhat.com>
 */

#include <gtk/gtk.h>
#include <epoxy/gl.h>

static char *
get_gtk_gles_renderer (void)
{
        GdkSurface *surface;
        GtkNative *native;
        GtkWidget *win;
        GdkGLContext *context;
        char *renderer = NULL;

        win = gtk_window_new ();
        gtk_widget_realize (win);
        native = gtk_widget_get_native (win);
        surface = gtk_native_get_surface (native);
        context = gdk_surface_create_gl_context (surface, NULL);
        if (!context)
                return NULL;
        gdk_gl_context_make_current (context);
        renderer = g_strdup ((char *) glGetString (GL_RENDERER));
        gdk_gl_context_clear_current ();
        g_object_unref (context);

        return renderer;
}

int
main (int argc, char **argv)
{
        g_autofree char *renderer_string = NULL;

        gtk_init ();

        renderer_string = get_gtk_gles_renderer ();
        if (renderer_string) {
                g_print ("%s", renderer_string);
                return 0;
        }
        return 1;
}