On 2012-06-19 11:41, pancake wrote:
> i've been thinking about that, but after some tries i realized it would
> require more changes than expected, because of the GDK thing.
> 
> I'm with creating a fork (surf3?) and start working on that, but first
> someone should get a working branch.
> 
> I dont have much time to work on this. But i'm curious about the results.

It just so happens that I broke gtk 2 on my laptop a few months back and
didn't have a working browser, so I got surf running with gtk 3. I
ignored all the gdk stuff by commenting it out, but I think the rest is
reasonable. I've attached the patch for it, it should build with either
gtk2 or gtk3 just by changing the config.mk so I don't think it really
needs a fork.

Maybe I'll look into drawing with gtk3, I think it uses cairo or
something?
diff -r f0cea0f2bfc6 config.def.h
--- a/config.def.h      Mon Jun 11 17:16:28 2012 +0200
+++ b/config.def.h      Wed Jun 20 02:46:43 2012 +0000
@@ -24,26 +24,26 @@
 #define MODKEY GDK_CONTROL_MASK
 static Key keys[] = {
     /* modifier                    keyval      function    arg             
Focus */
-    { MODKEY|GDK_SHIFT_MASK,GDK_r,      reload,     { .b = TRUE } },
-    { MODKEY,               GDK_r,      reload,     { .b = FALSE } },
-    { MODKEY|GDK_SHIFT_MASK,GDK_p,      print,      { 0 } },
-    { MODKEY,               GDK_p,      clipboard,  { .b = TRUE } },
-    { MODKEY,               GDK_y,      clipboard,  { .b = FALSE } },
-    { MODKEY|GDK_SHIFT_MASK,GDK_j,      zoom,       { .i = -1 } },
-    { MODKEY|GDK_SHIFT_MASK,GDK_k,      zoom,       { .i = +1 } },
-    { MODKEY|GDK_SHIFT_MASK,GDK_i,      zoom,       { .i = 0  } },
-    { MODKEY,               GDK_l,      navigate,   { .i = +1 } },
-    { MODKEY,               GDK_h,      navigate,   { .i = -1 } },
-    { MODKEY,               GDK_j,           scroll_v,   { .i = +1 } },
-    { MODKEY,               GDK_k,           scroll_v,   { .i = -1 } },
-    { MODKEY,               GDK_b,           scroll_v,   { .i = -10000 } },
-    { MODKEY,               GDK_space,       scroll_v,   { .i = +10000 } },
-    { MODKEY,               GDK_i,           scroll_h,   { .i = +1 } },
-    { MODKEY,               GDK_u,           scroll_h,   { .i = -1 } },
-    { 0,                    GDK_Escape, stop,       { 0 } },
-    { MODKEY,               GDK_o,      source,     { 0 } },
-    { MODKEY,               GDK_g,      spawn,      SETPROP("_SURF_URI", 
"_SURF_GO") },
-    { MODKEY,               GDK_f,      spawn,      SETPROP("_SURF_FIND", 
"_SURF_FIND") },
-    { MODKEY,               GDK_n,      find,       { .b = TRUE } },
-    { MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_r,      reload,     { .b = TRUE } },
+    { MODKEY,               GDK_KEY_r,      reload,     { .b = FALSE } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_p,      print,      { 0 } },
+    { MODKEY,               GDK_KEY_p,      clipboard,  { .b = TRUE } },
+    { MODKEY,               GDK_KEY_y,      clipboard,  { .b = FALSE } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_j,      zoom,       { .i = -1 } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_k,      zoom,       { .i = +1 } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_i,      zoom,       { .i = 0  } },
+    { MODKEY,               GDK_KEY_l,      navigate,   { .i = +1 } },
+    { MODKEY,               GDK_KEY_h,      navigate,   { .i = -1 } },
+    { MODKEY,               GDK_KEY_j,           scroll_v,   { .i = +1 } },
+    { MODKEY,               GDK_KEY_k,           scroll_v,   { .i = -1 } },
+    { MODKEY,               GDK_KEY_b,           scroll_v,   { .i = -10000 } },
+    { MODKEY,               GDK_KEY_space,       scroll_v,   { .i = +10000 } },
+    { MODKEY,               GDK_KEY_i,           scroll_h,   { .i = +1 } },
+    { MODKEY,               GDK_KEY_u,           scroll_h,   { .i = -1 } },
+    { 0,                    GDK_KEY_Escape, stop,       { 0 } },
+    { MODKEY,               GDK_KEY_o,      source,     { 0 } },
+    { MODKEY,               GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", 
"_SURF_GO") },
+    { MODKEY,               GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", 
"_SURF_FIND") },
+    { MODKEY,               GDK_KEY_n,      find,       { .b = TRUE } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_n,      find,       { .b = FALSE } },
 };
diff -r f0cea0f2bfc6 config.mk
--- a/config.mk Mon Jun 11 17:16:28 2012 +0200
+++ b/config.mk Wed Jun 20 02:46:43 2012 +0000
@@ -10,8 +10,8 @@
 X11INC = /usr/X11R6/include
 X11LIB = /usr/X11R6/lib
 
-GTKINC = `pkg-config --cflags gtk+-2.0 webkit-1.0`
-GTKLIB = `pkg-config --libs gtk+-2.0 webkit-1.0`
+GTKINC = `pkg-config --cflags gtk+-3.0 webkitgtk-3.0`
+GTKLIB = `pkg-config --libs gtk+-3.0 webkitgtk-3.0`
 
 # includes and libs
 INCS = -I. -I/usr/include -I${X11INC} ${GTKINC}
diff -r f0cea0f2bfc6 surf.c
--- a/surf.c    Mon Jun 11 17:16:28 2012 +0200
+++ b/surf.c    Wed Jun 20 02:46:43 2012 +0000
@@ -20,6 +20,10 @@
 #include <JavaScriptCore/JavaScript.h>
 #include <sys/file.h>
 
+#if GTK_MAJOR_VERSION == 3
+#include <gtk/gtkx.h>
+#endif
+
 #define LENGTH(x)               (sizeof x / sizeof x[0])
 
 enum { AtomFind, AtomGo, AtomUri, AtomLast };
@@ -58,7 +62,7 @@
 static Display *dpy;
 static Atom atoms[AtomLast];
 static Client *clients = NULL;
-static GdkNativeWindow embed = 0;
+static Window embed = 0;
 static gboolean showxid = FALSE;
 static char winid[64];
 static char *progname;
@@ -95,6 +99,7 @@
 static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer 
d);
 static void progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
 static void reload(Client *c, const Arg *arg);
+static void resize(GtkWidget *w, GtkAllocation *a, Client *c);
 static void scroll_h(Client *c, const Arg *arg);
 static void scroll_v(Client *c, const Arg *arg);
 static void scroll(GtkAdjustment *a, const Arg *arg);
@@ -255,6 +260,7 @@
 
 void
 drawindicator(Client *c) {
+#if GTK_MAJOR_VERSION == 2
        gint width;
        const char *uri;
        GtkWidget *w;
@@ -277,6 +283,7 @@
        gdk_draw_rectangle(w->window, gc, TRUE, 0, 0, width,
                        w->allocation.height);
        g_object_unref(gc);
+#endif
 }
 
 gboolean
@@ -311,7 +318,7 @@
        unsigned long ldummy;
        unsigned char *p = NULL;
 
-       XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
+       XGetWindowProperty(dpy, 
GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))),
                        atoms[a], 0L, BUFSIZ, False, XA_STRING,
                        &adummy, &idummy, &ldummy, &ldummy, &p);
        if(p)
@@ -516,8 +523,8 @@
        gtk_widget_show(GTK_WIDGET(c->view));
        gtk_widget_show(c->win);
        gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, 
GDK_HINT_MIN_SIZE);
-       gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
-       gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
+       gdk_window_set_events(gtk_widget_get_window(GTK_WIDGET(c->win)), 
GDK_ALL_EVENTS_MASK);
+       gdk_window_add_filter(gtk_widget_get_window(GTK_WIDGET(c->win)), 
processx, c);
        webkit_web_view_set_full_content_zoom(c->view, TRUE);
        frame = webkit_web_view_get_main_frame(c->view);
        runscript(frame);
@@ -544,7 +551,7 @@
        clients = c;
        if(showxid) {
                gdk_display_sync(gtk_widget_get_display(c->win));
-               printf("%u\n", 
(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
+               printf("%u\n", 
(guint)GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))));
                fflush(NULL);
                 if (fclose(stdout) != 0) {
                        die("Error closing stdout");
@@ -697,7 +704,7 @@
 void
 setatom(Client *c, int a, const char *v) {
        XSync(dpy, False);
-       XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), 
atoms[a],
+       XChangeProperty(dpy, 
GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))), atoms[a],
                        XA_STRING, 8, PropModeReplace, (unsigned char *)v,
                        strlen(v) + 1);
 }
@@ -715,7 +722,7 @@
        if (!g_thread_supported())
                g_thread_init(NULL);
 
-       dpy = GDK_DISPLAY();
+       dpy = GDK_SCREEN_XDISPLAY(gdk_screen_get_default());
        s = webkit_get_default_session();
 
        /* atoms */
@@ -814,7 +821,7 @@
 void
 updatewinid(Client *c) {
        snprintf(winid, LENGTH(winid), "%u",
-                       (int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
+                       
(int)GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))));
 }
 
 void

Reply via email to