sites

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

surf-0.7-smoothscrolling.diff (9765B)


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