diff --git a/config.h b/config.h index 79b30c4..bc5c721 100644 --- a/config.h +++ b/config.h @@ -79,6 +79,12 @@ static unsigned int pagingkeep = 40; /* pixels kept when paging */ #define ENABLE_MATCH_HIGHLITING static const int searchoptions = CaseInsensitive | Wrapping; +/* resize */ +#define RESIZE_PERC 0.05 + +/* move */ +#define MOVE_PERC 0.05 + /* search engines */ static Searchengine searchengines[] = { { "i", "http://ixquick.com/do/metasearch.pl?query=%s" }, @@ -119,6 +125,17 @@ static Key keys[] = { { GDK_CONTROL_MASK, 0, GDK_e, scroll, {ScrollMove | DirectionBottom | UnitLine} }, { GDK_CONTROL_MASK, 0, GDK_y, scroll, {ScrollMove | DirectionTop | UnitLine} }, + { 0, 0, GDK_comma, resize, {Decrement | DirectionBottom } }, + { 0, 0, GDK_period, resize, {Increment | DirectionBottom } }, + { GDK_SHIFT_MASK, 0, GDK_less, resize, {Decrement | DirectionRight } }, + { GDK_SHIFT_MASK, 0, GDK_greater, resize, {Increment | DirectionRight } }, + + { GDK_CONTROL_MASK, 0, GDK_h, move, {DirectionLeft } }, + { GDK_CONTROL_MASK, 0, GDK_j, move, {DirectionTop } }, + { GDK_CONTROL_MASK, 0, GDK_k, move, {DirectionBottom } }, + { GDK_CONTROL_MASK, 0, GDK_l, move, {DirectionRight } }, + + { GDK_CONTROL_MASK, 0, GDK_i, navigate, {NavigationBack} }, { GDK_CONTROL_MASK, 0, GDK_o, navigate, {NavigationForward} }, { GDK_SHIFT_MASK, 0, GDK_H, navigate, {NavigationBack} }, diff --git a/main.c b/main.c index abb0000..81f7ef9 100644 --- a/main.c +++ b/main.c @@ -66,6 +66,9 @@ static gboolean view_source(const Arg * arg); static gboolean zoom(const Arg *arg); static gboolean quickmark(const Arg *arg); +static gboolean move(const Arg *arg); +static gboolean resize(const Arg *arg); + static void update_url(const char *uri); static void update_state(void); static void setup_modkeys(void); @@ -887,6 +890,40 @@ input(const Arg *arg) { } gboolean +move(const Arg *arg) { + gint x, y, screenw, screenh; + GdkScreen *screen; + screen = gtk_window_get_screen(GTK_WINDOW(window)); + screenw = gdk_screen_get_width(screen); + screenh = gdk_screen_get_height(screen); + gtk_window_get_position(GTK_WINDOW(window), &x, &y); + switch (arg->i) { + case DirectionLeft: + x = x - (screenw * MOVE_PERC); + if (x <= 0) + x = 0; + break; + case DirectionTop: + y = y + (screenh * MOVE_PERC); + if (y >= screenh) + y = screenh; + break; + case DirectionBottom: + y = y - (screenh * MOVE_PERC); + if (y <= 0) + y = 0; + break; + case DirectionRight: + x = x + (screenw * MOVE_PERC); + if (x >= screenw) + x = screenw; + break; + } + gtk_window_move(GTK_WINDOW(window), x, y); + return TRUE; +} + +gboolean navigate(const Arg *arg) { if (arg->i & NavigationForwardBack) webkit_web_view_go_back_or_forward(webview, (arg->i == NavigationBack ? -1 : 1) * (count ? count : 1)); @@ -1067,6 +1104,40 @@ revive(const Arg *arg) { return FALSE; } +gboolean +resize(const Arg *arg) { + gint w, h, screenw, screenh; + GdkScreen *screen; + screen = gtk_window_get_screen(GTK_WINDOW(window)); + screenw = gdk_screen_get_width(screen); + screenh = gdk_screen_get_height(screen); + gtk_window_get_size(GTK_WINDOW(window), &w, &h); + switch (arg->i) { + case Decrement | DirectionBottom: + h = h - (screenh * RESIZE_PERC); + if (h <= 0) + h = 1; + break; + case Increment | DirectionBottom: + h = h + (screenh * RESIZE_PERC); + if (h >= screenh) + h = screenh; + break; + case Decrement | DirectionRight: + w = w - (screenw * RESIZE_PERC); + if (w <= 0) + w = 1; + break; + case Increment | DirectionRight: + w = w + (screenw * RESIZE_PERC); + if (w >= screenw) + w = screenw; + break; + } + gtk_window_resize(GTK_WINDOW(window), w, h); + return TRUE; +} + gboolean search(const Arg *arg) { count = count ? count : 1;