sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

surf-0.6-smoothscrolling.diff (9547B)


      1 diff --git a/config.def.h b/config.def.h
      2 index b81e6b0..8e192aa 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -53,47 +53,47 @@ static Bool allowgeolocation = TRUE;
      6   */
      7  static Key keys[] = {
      8      /* modifier	            keyval      function    arg             Focus */
      9 -    { MODKEY|GDK_SHIFT_MASK,GDK_r,      reload,     { .b = TRUE } },
     10 -    { MODKEY,               GDK_r,      reload,     { .b = FALSE } },
     11 -    { MODKEY|GDK_SHIFT_MASK,GDK_p,      print,      { 0 } },
     12 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_r,  reload,     { .b = TRUE } },
     13 +    { MODKEY,               GDK_KEY_r,  reload,     { .b = FALSE } },
     14 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_p,  print,      { 0 } },
     15  
     16 -    { MODKEY,               GDK_p,      clipboard,  { .b = TRUE } },
     17 -    { MODKEY,               GDK_y,      clipboard,  { .b = FALSE } },
     18 +    { MODKEY,               GDK_KEY_p,  clipboard,  { .b = TRUE } },
     19 +    { MODKEY,               GDK_KEY_y,  clipboard,  { .b = FALSE } },
     20  
     21 -    { MODKEY|GDK_SHIFT_MASK,GDK_j,      zoom,       { .i = -1 } },
     22 -    { MODKEY|GDK_SHIFT_MASK,GDK_k,      zoom,       { .i = +1 } },
     23 -    { MODKEY|GDK_SHIFT_MASK,GDK_q,      zoom,       { .i = 0  } },
     24 -    { MODKEY,               GDK_minus,  zoom,       { .i = -1 } },
     25 -    { MODKEY,               GDK_plus,   zoom,       { .i = +1 } },
     26 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_j,      zoom,       { .i = -1 } },
     27 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_k,      zoom,       { .i = +1 } },
     28 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_q,      zoom,       { .i = 0  } },
     29 +    { MODKEY,               GDK_KEY_minus,  zoom,       { .i = -1 } },
     30 +    { MODKEY,               GDK_KEY_plus,   zoom,       { .i = +1 } },
     31  
     32 -    { MODKEY,               GDK_l,      navigate,   { .i = +1 } },
     33 -    { MODKEY,               GDK_h,      navigate,   { .i = -1 } },
     34 +    { MODKEY,               GDK_KEY_l,      navigate,   { .i = +1 } },
     35 +    { MODKEY,               GDK_KEY_h,      navigate,   { .i = -1 } },
     36  
     37 -    { MODKEY,               GDK_j,           scroll_v,   { .i = +1 } },
     38 -    { MODKEY,               GDK_k,           scroll_v,   { .i = -1 } },
     39 -    { MODKEY,               GDK_b,           scroll_v,   { .i = -10000 } },
     40 -    { MODKEY,               GDK_space,       scroll_v,   { .i = +10000 } },
     41 -    { MODKEY,               GDK_i,           scroll_h,   { .i = +1 } },
     42 -    { MODKEY,               GDK_u,           scroll_h,   { .i = -1 } },
     43 +    { MODKEY,               GDK_KEY_j,      scroll_v,   { .i = +1 } },
     44 +    { MODKEY,               GDK_KEY_k,      scroll_v,   { .i = -1 } },
     45 +    { MODKEY,               GDK_KEY_b,      scroll_v,   { .i = -10000 } },
     46 +    { MODKEY,               GDK_KEY_space,  scroll_v,   { .i = +10000 } },
     47 +    { MODKEY,               GDK_KEY_i,      scroll_h,   { .i = +1 } },
     48 +    { MODKEY,               GDK_KEY_u,      scroll_h,   { .i = -1 } },
     49  
     50 -    { 0,                    GDK_F11,    fullscreen, { 0 } },
     51 -    { 0,                    GDK_Escape, stop,       { 0 } },
     52 -    { MODKEY,               GDK_o,      source,     { 0 } },
     53 -    { MODKEY|GDK_SHIFT_MASK,GDK_o,      inspector,  { 0 } },
     54 +    { 0,                    GDK_KEY_F11,    fullscreen, { 0 } },
     55 +    { 0,                    GDK_KEY_Escape, stop,       { 0 } },
     56 +    { MODKEY,               GDK_KEY_o,      source,     { 0 } },
     57 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_o,      inspector,  { 0 } },
     58  
     59 -    { MODKEY,               GDK_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
     60 -    { MODKEY,               GDK_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     61 -    { MODKEY,               GDK_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     62 +    { MODKEY,               GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
     63 +    { MODKEY,               GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     64 +    { MODKEY,               GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     65  
     66 -    { MODKEY,               GDK_n,      find,       { .b = TRUE } },
     67 -    { MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
     68 +    { MODKEY,               GDK_KEY_n,  find,       { .b = TRUE } },
     69 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_n,  find,       { .b = FALSE } },
     70  
     71 -    { MODKEY|GDK_SHIFT_MASK,GDK_c,      toggle,     { .v = "enable-caret-browsing" } },
     72 -    { MODKEY|GDK_SHIFT_MASK,GDK_i,      toggle,     { .v = "auto-load-images" } },
     73 -    { MODKEY|GDK_SHIFT_MASK,GDK_s,      toggle,     { .v = "enable-scripts" } },
     74 -    { MODKEY|GDK_SHIFT_MASK,GDK_v,      toggle,     { .v = "enable-plugins" } },
     75 -    { MODKEY|GDK_SHIFT_MASK,GDK_m,      togglestyle,{ 0 } },
     76 -    { MODKEY|GDK_SHIFT_MASK,GDK_b,      togglescrollbars,{ 0 } },
     77 -    { MODKEY|GDK_SHIFT_MASK,GDK_g,      togglegeolocation, { 0 } },
     78 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_c,  toggle,     { .v = "enable-caret-browsing" } },
     79 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_i,  toggle,     { .v = "auto-load-images" } },
     80 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_s,  toggle,     { .v = "enable-scripts" } },
     81 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_v,  toggle,     { .v = "enable-plugins" } },
     82 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_m,  togglestyle,{ 0 } },
     83 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_b,  togglescrollbars,{ 0 } },
     84 +    { MODKEY|GDK_SHIFT_MASK,GDK_KEY_g,  togglegeolocation, { 0 } },
     85  };
     86  
     87 diff --git a/config.mk b/config.mk
     88 index b7a902f..82ebe38 100644
     89 --- a/config.mk
     90 +++ b/config.mk
     91 @@ -10,8 +10,8 @@ MANPREFIX = ${PREFIX}/share/man
     92  X11INC = /usr/X11R6/include
     93  X11LIB = /usr/X11R6/lib
     94  
     95 -GTKINC = `pkg-config --cflags gtk+-2.0 webkit-1.0`
     96 -GTKLIB = `pkg-config --libs gtk+-2.0 webkit-1.0`
     97 +GTKINC = `pkg-config --cflags gtk+-3.0 webkitgtk-3.0`
     98 +GTKLIB = `pkg-config --libs gtk+-3.0 webkitgtk-3.0`
     99  
    100  # includes and libs
    101  INCS = -I. -I/usr/include -I${X11INC} ${GTKINC}
    102 diff --git a/surf.c b/surf.c
    103 index d970f7f..3a083d3 100644
    104 --- a/surf.c
    105 +++ b/surf.c
    106 @@ -7,6 +7,7 @@
    107  #include <X11/X.h>
    108  #include <X11/Xatom.h>
    109  #include <gtk/gtk.h>
    110 +#include <gtk/gtkx.h>
    111  #include <gdk/gdkx.h>
    112  #include <gdk/gdk.h>
    113  #include <gdk/gdkkeysyms.h>
    114 @@ -74,7 +75,7 @@ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
    115  static Display *dpy;
    116  static Atom atoms[AtomLast];
    117  static Client *clients = NULL;
    118 -static GdkNativeWindow embed = 0;
    119 +static Window embed = 0;
    120  static gboolean showxid = FALSE;
    121  static char winid[64];
    122  static gboolean usingproxy = 0;
    123 @@ -472,7 +473,7 @@ getatom(Client *c, int a) {
    124  	unsigned long ldummy;
    125  	unsigned char *p = NULL;
    126  
    127 -	XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
    128 +	XGetWindowProperty(dpy, GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))),
    129  			atoms[a], 0L, BUFSIZ, False, XA_STRING,
    130  			&adummy, &idummy, &ldummy, &ldummy, &p);
    131  	if(p) {
    132 @@ -660,6 +661,7 @@ newclient(void) {
    133  	WebKitWebFrame *frame;
    134  	GdkGeometry hints = { 1, 1 };
    135  	GdkScreen *screen;
    136 +	GdkWindow *window;
    137  	gdouble dpi;
    138  	char *uri, *ua;
    139  
    140 @@ -686,6 +688,10 @@ newclient(void) {
    141  		 */
    142  		gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
    143  	}
    144 +
    145 +	gtk_widget_realize(GTK_WIDGET(c->win));
    146 +	window = gtk_widget_get_window(GTK_WIDGET(c->win));
    147 +
    148  	gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
    149  	g_signal_connect(G_OBJECT(c->win),
    150  			"destroy",
    151 @@ -695,10 +701,10 @@ newclient(void) {
    152  		addaccelgroup(c);
    153  
    154  	/* Pane */
    155 -	c->pane = gtk_vpaned_new();
    156 +	c->pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
    157  
    158  	/* VBox */
    159 -	c->vbox = gtk_vbox_new(FALSE, 0);
    160 +	c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    161  	gtk_paned_pack1(GTK_PANED(c->pane), c->vbox, TRUE, TRUE);
    162  
    163  	/* Webview */
    164 @@ -778,8 +784,8 @@ newclient(void) {
    165  	gtk_widget_show(c->win);
    166  	gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
    167  			GDK_HINT_MIN_SIZE);
    168 -	gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
    169 -	gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
    170 +	gdk_window_set_events(window, GDK_ALL_EVENTS_MASK);
    171 +	gdk_window_add_filter(window, processx, c);
    172  	webkit_web_view_set_full_content_zoom(c->view, TRUE);
    173  
    174  	runscript(frame);
    175 @@ -811,7 +817,7 @@ newclient(void) {
    176  	 * It is equivalent to firefox's "layout.css.devPixelsPerPx" setting.
    177  	 */
    178  	if(zoomto96dpi) {
    179 -		screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window);
    180 +		screen = gdk_window_get_screen(window);
    181  		dpi = gdk_screen_get_resolution(screen);
    182  		if(dpi != -1) {
    183  			g_object_set(G_OBJECT(settings), "enforce-96-dpi", true,
    184 @@ -856,7 +862,7 @@ newclient(void) {
    185  	if(showxid) {
    186  		gdk_display_sync(gtk_widget_get_display(c->win));
    187  		printf("%u\n",
    188 -			(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
    189 +			(guint)GDK_WINDOW_XID(window));
    190  		fflush(NULL);
    191                  if (fclose(stdout) != 0) {
    192  			die("Error closing stdout");
    193 @@ -1031,7 +1037,7 @@ scroll(GtkAdjustment *a, const Arg *arg) {
    194  static void
    195  setatom(Client *c, int a, const char *v) {
    196  	XSync(dpy, False);
    197 -	XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
    198 +	XChangeProperty(dpy, GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))),
    199  			atoms[a], XA_STRING, 8, PropModeReplace,
    200  			(unsigned char *)v, strlen(v) + 1);
    201  }
    202 @@ -1047,7 +1053,7 @@ setup(void) {
    203  	sigchld(0);
    204  	gtk_init(NULL, NULL);
    205  
    206 -	dpy = GDK_DISPLAY();
    207 +	dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
    208  
    209  	/* atoms */
    210  	atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
    211 @@ -1276,7 +1282,7 @@ updatetitle(Client *c) {
    212  static void
    213  updatewinid(Client *c) {
    214  	snprintf(winid, LENGTH(winid), "%u",
    215 -			(int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
    216 +			(int)GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))));
    217  }
    218  
    219  static void