]> Pileus Git - grits/blobdiff - src/gtkgl.c
Add support for GTK 3
[grits] / src / gtkgl.c
index 8808ed585b1066d8be602faa6680fef7cd3b8db5..19f3219043273e18f82be3b976acf83d911b80ae 100644 (file)
@@ -108,11 +108,16 @@ void gtk_gl_enable(GtkWidget *widget)
 
        g_object_set_data(G_OBJECT(widget), "glcontext", context);
 
 
        g_object_set_data(G_OBJECT(widget), "glcontext", context);
 
-       /* Fix up colormap */
+       /* Fix up visual/colormap */
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkVisual *visual = gdk_x11_screen_lookup_visual(screen, xvinfo->visualid);
+       gtk_widget_set_visual(widget, visual);
+#else
        GdkVisual   *visual = gdk_x11_screen_lookup_visual(screen, xvinfo->visualid);
        GdkColormap *cmap   = gdk_colormap_new(visual, FALSE);
        gtk_widget_set_colormap(widget, cmap);
        g_object_unref(cmap);
        GdkVisual   *visual = gdk_x11_screen_lookup_visual(screen, xvinfo->visualid);
        GdkColormap *cmap   = gdk_colormap_new(visual, FALSE);
        gtk_widget_set_colormap(widget, cmap);
        g_object_unref(cmap);
+#endif
        XFree(xvinfo);
 
        /* Disable GTK double buffering */
        XFree(xvinfo);
 
        /* Disable GTK double buffering */
@@ -288,6 +293,8 @@ void gtk_gl_begin(GtkWidget *widget)
        GtkAllocation alloc;
        gdk_window_ensure_native(gtk_widget_get_window(widget));
        gtk_widget_get_allocation(widget, &alloc);
        GtkAllocation alloc;
        gdk_window_ensure_native(gtk_widget_get_window(widget));
        gtk_widget_get_allocation(widget, &alloc);
+       gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget),
+               0, 0, &alloc.x, &alloc.y);
 
        NSOpenGLContext *ctx  = g_object_get_data(G_OBJECT(widget), "glcontext");
        GdkWindow       *win  = gtk_widget_get_window(widget);
 
        NSOpenGLContext *ctx  = g_object_get_data(G_OBJECT(widget), "glcontext");
        GdkWindow       *win  = gtk_widget_get_window(widget);
@@ -298,6 +305,7 @@ void gtk_gl_begin(GtkWidget *widget)
        [ctx  makeCurrentContext];
        [ctx  update];
        [view setFrame:rect];
        [ctx  makeCurrentContext];
        [ctx  update];
        [view setFrame:rect];
+       [view setWantsBestResolutionOpenGLSurface:YES];
 }
 
 void gtk_gl_end(GtkWidget *widget)
 }
 
 void gtk_gl_end(GtkWidget *widget)