Line |
Branch |
Exec |
Source |
1 |
|
|
/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */ |
2 |
|
|
/* Tool to set the property _GNOME_SESSION_ACCELERATED on the root window */ |
3 |
|
|
/* |
4 |
|
|
* Copyright (C) 2019 Red Hat, Inc. |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
* |
20 |
|
|
* Author: |
21 |
|
|
* Bastien Nocera <hadess@hadess.net> |
22 |
|
|
* Matthias Clasen <mclasen@redhat.com> |
23 |
|
|
*/ |
24 |
|
|
|
25 |
|
|
#include <gtk/gtk.h> |
26 |
|
|
#include <epoxy/gl.h> |
27 |
|
|
|
28 |
|
|
static char * |
29 |
|
✗ |
get_gtk_gles_renderer (void) |
30 |
|
|
{ |
31 |
|
|
GdkSurface *surface; |
32 |
|
|
GtkNative *native; |
33 |
|
|
GtkWidget *win; |
34 |
|
|
GdkGLContext *context; |
35 |
|
✗ |
char *renderer = NULL; |
36 |
|
|
|
37 |
|
✗ |
win = gtk_window_new (); |
38 |
|
✗ |
gtk_widget_realize (win); |
39 |
|
✗ |
native = gtk_widget_get_native (win); |
40 |
|
✗ |
surface = gtk_native_get_surface (native); |
41 |
|
✗ |
context = gdk_surface_create_gl_context (surface, NULL); |
42 |
|
✗ |
if (!context) |
43 |
|
✗ |
return NULL; |
44 |
|
✗ |
gdk_gl_context_make_current (context); |
45 |
|
✗ |
renderer = g_strdup ((char *) glGetString (GL_RENDERER)); |
46 |
|
✗ |
gdk_gl_context_clear_current (); |
47 |
|
✗ |
g_object_unref (context); |
48 |
|
|
|
49 |
|
✗ |
return renderer; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
int |
53 |
|
✗ |
main (int argc, char **argv) |
54 |
|
|
{ |
55 |
|
✗ |
g_autofree char *renderer_string = NULL; |
56 |
|
|
|
57 |
|
✗ |
g_log_writer_default_set_use_stderr (TRUE); |
58 |
|
|
|
59 |
|
✗ |
gtk_init (); |
60 |
|
|
|
61 |
|
✗ |
renderer_string = get_gtk_gles_renderer (); |
62 |
|
✗ |
if (renderer_string) { |
63 |
|
✗ |
g_print ("%s", renderer_string); |
64 |
|
✗ |
return 0; |
65 |
|
|
} |
66 |
|
✗ |
return 1; |
67 |
|
|
} |
68 |
|
|
|