[wiki] [sites] Add smooth scrolling/gtk3 patch for surf || Charles Lehner

From: <git_AT_suckless.org>
Date: Sun, 29 Dec 2013 16:13:19 +0100

commit 05accfc7cfb316a75908a838ce634eaa8933f7ff
Author: Charles Lehner <celehner1_AT_gmail.com>
Date: Sun Dec 29 10:09:47 2013 -0500

    Add smooth scrolling/gtk3 patch for surf

diff --git a/surf.suckless.org/patches/smoothscrolling.md b/surf.suckless.org/patches/smoothscrolling.md
new file mode 100644
index 0000000..80f4817
--- /dev/null
+++ b/surf.suckless.org/patches/smoothscrolling.md
_AT_@ -0,0 +1,18 @@
+smoothscrolling
+==========
+
+Description
+-----------
+
+Enable smooth scrolling by compiling surf with GTK3 instead of GTK2.
+
+Download
+--------
+
+* [surf-0.6-smoothscrolling.diff](surf-0.6-smoothscrolling.diff) (9.4K) (20131229)
+
+Author
+------
+
+* Charles Lehner <[http://celehner.com](http://celehner.com)>
+
diff --git a/surf.suckless.org/patches/surf-0.6-smoothscrolling.diff b/surf.suckless.org/patches/surf-0.6-smoothscrolling.diff
new file mode 100644
index 0000000..b39e8ba
--- /dev/null
+++ b/surf.suckless.org/patches/surf-0.6-smoothscrolling.diff
_AT_@ -0,0 +1,219 @@
+diff --git a/config.def.h b/config.def.h
+index b81e6b0..8e192aa 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -53,47 +53,47 @@ static Bool allowgeolocation = TRUE;
+ */
+ 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_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_p, clipboard, { .b = TRUE } },
+- { MODKEY, GDK_y, clipboard, { .b = FALSE } },
++ { MODKEY, GDK_KEY_p, clipboard, { .b = TRUE } },
++ { MODKEY, GDK_KEY_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_q, zoom, { .i = 0 } },
+- { MODKEY, GDK_minus, zoom, { .i = -1 } },
+- { MODKEY, GDK_plus, zoom, { .i = +1 } },
++ { 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_q, zoom, { .i = 0 } },
++ { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
++ { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
+
+- { MODKEY, GDK_l, navigate, { .i = +1 } },
+- { MODKEY, GDK_h, navigate, { .i = -1 } },
++ { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
++ { MODKEY, GDK_KEY_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 } },
++ { 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_F11, fullscreen, { 0 } },
+- { 0, GDK_Escape, stop, { 0 } },
+- { MODKEY, GDK_o, source, { 0 } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_o, inspector, { 0 } },
++ { 0, GDK_KEY_F11, fullscreen, { 0 } },
++ { 0, GDK_KEY_Escape, stop, { 0 } },
++ { MODKEY, GDK_KEY_o, source, { 0 } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_o, inspector, { 0 } },
+
+- { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") },
+- { MODKEY, GDK_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
+- { MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
++ { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") },
++ { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
++ { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
+
+- { MODKEY, GDK_n, find, { .b = TRUE } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_n, find, { .b = FALSE } },
++ { MODKEY, GDK_KEY_n, find, { .b = TRUE } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_n, find, { .b = FALSE } },
+
+- { MODKEY|GDK_SHIFT_MASK,GDK_c, toggle, { .v = "enable-caret-browsing" } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_i, toggle, { .v = "auto-load-images" } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_s, toggle, { .v = "enable-scripts" } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle,{ 0 } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars,{ 0 } },
+- { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_c, toggle, { .v = "enable-caret-browsing" } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_i, toggle, { .v = "auto-load-images" } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_s, toggle, { .v = "enable-scripts" } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_v, toggle, { .v = "enable-plugins" } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_m, togglestyle,{ 0 } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_b, togglescrollbars,{ 0 } },
++ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_g, togglegeolocation, { 0 } },
+ };
+
+diff --git a/config.mk b/config.mk
+index b7a902f..82ebe38 100644
+--- a/config.mk
++++ b/config.mk
+_AT_@ -10,8 +10,8 @@ MANPREFIX = ${PREFIX}/share/man
+ 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 --git a/surf.c b/surf.c
+index d970f7f..3a083d3 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -7,6 +7,7 @@
+ #include <X11/X.h>
+ #include <X11/Xatom.h>
+ #include <gtk/gtk.h>
++#include <gtk/gtkx.h>
+ #include <gdk/gdkx.h>
+ #include <gdk/gdk.h>
+ #include <gdk/gdkkeysyms.h>
+_AT_@ -74,7 +75,7 @@ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+ 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 gboolean usingproxy = 0;
+_AT_@ -472,7 +473,7 @@ getatom(Client *c, int a) {
+ 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) {
+_AT_@ -660,6 +661,7 @@ newclient(void) {
+ WebKitWebFrame *frame;
+ GdkGeometry hints = { 1, 1 };
+ GdkScreen *screen;
++ GdkWindow *window;
+ gdouble dpi;
+ char *uri, *ua;
+
+_AT_@ -686,6 +688,10 @@ newclient(void) {
+ */
+ gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
+ }
++
++ gtk_widget_realize(GTK_WIDGET(c->win));
++ window = gtk_widget_get_window(GTK_WIDGET(c->win));
++
+ gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
+ g_signal_connect(G_OBJECT(c->win),
+ "destroy",
+_AT_@ -695,10 +701,10 @@ newclient(void) {
+ addaccelgroup(c);
+
+ /* Pane */
+- c->pane = gtk_vpaned_new();
++ c->pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
+
+ /* VBox */
+- c->vbox = gtk_vbox_new(FALSE, 0);
++ c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_paned_pack1(GTK_PANED(c->pane), c->vbox, TRUE, TRUE);
+
+ /* Webview */
+_AT_@ -778,8 +784,8 @@ newclient(void) {
+ 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(window, GDK_ALL_EVENTS_MASK);
++ gdk_window_add_filter(window, processx, c);
+ webkit_web_view_set_full_content_zoom(c->view, TRUE);
+
+ runscript(frame);
+_AT_@ -811,7 +817,7 @@ newclient(void) {
+ * It is equivalent to firefox's "layout.css.devPixelsPerPx" setting.
+ */
+ if(zoomto96dpi) {
+- screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window);
++ screen = gdk_window_get_screen(window);
+ dpi = gdk_screen_get_resolution(screen);
+ if(dpi != -1) {
+ g_object_set(G_OBJECT(settings), "enforce-96-dpi", true,
+_AT_@ -856,7 +862,7 @@ newclient(void) {
+ if(showxid) {
+ gdk_display_sync(gtk_widget_get_display(c->win));
+ printf("%u
",
+- (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
++ (guint)GDK_WINDOW_XID(window));
+ fflush(NULL);
+ if (fclose(stdout) != 0) {
+ die("Error closing stdout");
+_AT_@ -1031,7 +1037,7 @@ scroll(GtkAdjustment *a, const Arg *arg) {
+ static void
+ setatom(Client *c, int a, const char *v) {
+ XSync(dpy, False);
+- XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
++ 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);
+ }
+_AT_@ -1047,7 +1053,7 @@ setup(void) {
+ sigchld(0);
+ gtk_init(NULL, NULL);
+
+- dpy = GDK_DISPLAY();
++ dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
+
+ /* atoms */
+ atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
+_AT_@ -1276,7 +1282,7 @@ updatetitle(Client *c) {
+ static 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))));
+ }
+
+ static void
Received on Sun Dec 29 2013 - 16:13:19 CET

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:38:01 CEST