sites

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

surf-modal-20190209-d068a38.diff (6157B)


      1 From 74a98d9600c50d50b9323cf8e459c88eb15da557 Mon Sep 17 00:00:00 2001
      2 From: efe <efe@efe.kim>
      3 Date: Sat, 9 Feb 2019 13:16:51 -0500
      4 Subject: [PATCH] Modal behaviour, 'i' to insert 'Esc' to get to the normal
      5  mode
      6 
      7 ---
      8  config.def.h | 53 +++++++++++++++++++++++++++-------------------------
      9  surf.c       | 14 +++++++++++++-
     10  2 files changed, 41 insertions(+), 26 deletions(-)
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index 34265f6..8b7d5a2 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -130,41 +130,44 @@ static SiteSpecific certs[] = {
     17   */
     18  static Key keys[] = {
     19  	/* modifier              keyval          function    arg */
     20 -	{ MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
     21 -	{ MODKEY,                GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
     22 -	{ MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
     23 +	{ 0,                     GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
     24 +	{ 0,                     GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
     25 +	{ 0,                     GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
     26  
     27 -	{ 0,                     GDK_KEY_Escape, stop,       { 0 } },
     28 -	{ MODKEY,                GDK_KEY_c,      stop,       { 0 } },
     29 +	{ 0,                     GDK_KEY_i,      insert,     { .i = 1 } },
     30 +	{ 0,                     GDK_KEY_Escape, insert,     { .i = 0 } },
     31  
     32 -	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_r,      reload,     { .i = 1 } },
     33 -	{ MODKEY,                GDK_KEY_r,      reload,     { .i = 0 } },
     34 +	{ 0,                     GDK_KEY_c,      stop,       { 0 } },
     35  
     36 -	{ MODKEY,                GDK_KEY_l,      navigate,   { .i = +1 } },
     37 -	{ MODKEY,                GDK_KEY_h,      navigate,   { .i = -1 } },
     38 +	{ MODKEY,                GDK_KEY_r,      reload,     { .i = 1 } },
     39 +	{ 0,                     GDK_KEY_r,      reload,     { .i = 0 } },
     40 +
     41 +	{ 0,                     GDK_KEY_l,      navigate,   { .i = +1 } },
     42 +	{ 0,                     GDK_KEY_h,      navigate,   { .i = -1 } },
     43  
     44  	/* vertical and horizontal scrolling, in viewport percentage */
     45 -	{ MODKEY,                GDK_KEY_j,      scrollv,    { .i = +10 } },
     46 -	{ MODKEY,                GDK_KEY_k,      scrollv,    { .i = -10 } },
     47 -	{ MODKEY,                GDK_KEY_space,  scrollv,    { .i = +50 } },
     48 -	{ MODKEY,                GDK_KEY_b,      scrollv,    { .i = -50 } },
     49 -	{ MODKEY,                GDK_KEY_i,      scrollh,    { .i = +10 } },
     50 -	{ MODKEY,                GDK_KEY_u,      scrollh,    { .i = -10 } },
     51 +	{ 0,                     GDK_KEY_j,      scrollv,    { .i = +10 } },
     52 +	{ 0,                     GDK_KEY_k,      scrollv,    { .i = -10 } },
     53 +	{ 0,                     GDK_KEY_space,  scrollv,    { .i = +50 } },
     54 +	{ 0,                     GDK_KEY_b,      scrollv,    { .i = -50 } },
     55 +	{ 0,                     GDK_KEY_i,      scrollh,    { .i = +10 } },
     56 +	{ 0,                     GDK_KEY_u,      scrollh,    { .i = -10 } },
     57  
     58  
     59 -	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j,      zoom,       { .i = -1 } },
     60 -	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k,      zoom,       { .i = +1 } },
     61 -	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q,      zoom,       { .i = 0  } },
     62 -	{ MODKEY,                GDK_KEY_minus,  zoom,       { .i = -1 } },
     63 -	{ MODKEY,                GDK_KEY_plus,   zoom,       { .i = +1 } },
     64 +	{ 0|GDK_SHIFT_MASK,      GDK_KEY_j,      zoom,       { .i = -1 } },
     65 +	{ 0|GDK_SHIFT_MASK,      GDK_KEY_k,      zoom,       { .i = +1 } },
     66 +	{ 0|GDK_SHIFT_MASK,      GDK_KEY_q,      zoom,       { .i = 0  } },
     67 +	{ 0,                     GDK_KEY_minus,  zoom,       { .i = -1 } },
     68 +	{ 0|GDK_SHIFT_MASK,      GDK_KEY_plus,   zoom,       { .i = +1 } },
     69 +	{ 0,                     GDK_KEY_equal,  zoom,       { .i = 0  } },
     70  
     71 -	{ MODKEY,                GDK_KEY_p,      clipboard,  { .i = 1 } },
     72 -	{ MODKEY,                GDK_KEY_y,      clipboard,  { .i = 0 } },
     73 +	{ 0,                     GDK_KEY_p,      clipboard,  { .i = 1 } },
     74 +	{ 0,                     GDK_KEY_y,      clipboard,  { .i = 0 } },
     75  
     76 -	{ MODKEY,                GDK_KEY_n,      find,       { .i = +1 } },
     77 -	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n,      find,       { .i = -1 } },
     78 +	{ 0,                     GDK_KEY_n,      find,       { .i = +1 } },
     79 +	{ 0|GDK_SHIFT_MASK,      GDK_KEY_n,      find,       { .i = -1 } },
     80  
     81 -	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      print,      { 0 } },
     82 +	{ MODKEY,                GDK_KEY_p,      print,      { 0 } },
     83  	{ MODKEY,                GDK_KEY_t,      showcert,   { 0 } },
     84  
     85  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a,      togglecookiepolicy, { 0 } },
     86 diff --git a/surf.c b/surf.c
     87 index 2b54e3c..f4cbe68 100644
     88 --- a/surf.c
     89 +++ b/surf.c
     90 @@ -175,6 +175,7 @@ static void spawn(Client *c, const Arg *a);
     91  static void msgext(Client *c, char type, const Arg *a);
     92  static void destroyclient(Client *c);
     93  static void cleanup(void);
     94 +static int insertmode = 0;
     95  
     96  /* GTK/WebKit */
     97  static WebKitWebView *newview(Client *c, WebKitWebView *rv);
     98 @@ -231,6 +232,7 @@ static void togglefullscreen(Client *c, const Arg *a);
     99  static void togglecookiepolicy(Client *c, const Arg *a);
    100  static void toggleinspector(Client *c, const Arg *a);
    101  static void find(Client *c, const Arg *a);
    102 +static void insert(Client *c, const Arg *a);
    103  
    104  /* Buttons */
    105  static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
    106 @@ -1333,7 +1335,11 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c)
    107  		updatetitle(c);
    108  		break;
    109  	case GDK_KEY_PRESS:
    110 -		if (!curconfig[KioskMode].val.i) {
    111 +		if (!curconfig[KioskMode].val.i &&
    112 +		    !insertmode ||
    113 +		    CLEANMASK(e->key.state) == (MODKEY|GDK_SHIFT_MASK) ||
    114 +		    CLEANMASK(e->key.state) == (MODKEY) ||
    115 +		    gdk_keyval_to_lower(e->key.keyval) == (GDK_KEY_Escape)) {
    116  			for (i = 0; i < LENGTH(keys); ++i) {
    117  				if (gdk_keyval_to_lower(e->key.keyval) ==
    118  				    keys[i].keyval &&
    119 @@ -1947,6 +1953,12 @@ find(Client *c, const Arg *a)
    120  	}
    121  }
    122  
    123 +void
    124 +insert(Client *c, const Arg *a)
    125 +{
    126 +		insertmode = (a->i);
    127 +}
    128 +
    129  void
    130  clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h)
    131  {
    132 -- 
    133 2.20.1
    134