From 3a2d309b99b14bc3fcbdc54c1b4c82134ec8b3b0 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 20 Oct 2021 03:06:58 -0400 Subject: [PATCH] network/surf: Updated for version 2.1. Signed-off-by: B. Watson Signed-off-by: Willy Sudiarto Raharjo --- network/surf/getkbdevice.diff | 61 ---------------------- network/surf/options.txt | 11 ++-- network/surf/patches.txt | 1 - network/surf/patches/homepage.diff | 8 +-- network/surf/patches/searchengines.diff | 68 ++++++++++++------------- network/surf/surf.SlackBuild | 31 +++++------ network/surf/surf.info | 6 +-- 7 files changed, 59 insertions(+), 127 deletions(-) delete mode 100644 network/surf/getkbdevice.diff diff --git a/network/surf/getkbdevice.diff b/network/surf/getkbdevice.diff deleted file mode 100644 index 14bef9460d..0000000000 --- a/network/surf/getkbdevice.diff +++ /dev/null @@ -1,61 +0,0 @@ -diff -Naur surf-2.0/surf.c surf-2.0.patched/surf.c ---- surf-2.0/surf.c 2017-03-28 12:17:45.000000000 -0400 -+++ surf-2.0.patched/surf.c 2017-06-25 01:23:41.445168316 -0400 -@@ -174,6 +174,7 @@ - static void cleanup(void); - - /* GTK/WebKit */ -+static GdkDevice *getkbdevice(void); - static WebKitWebView *newview(Client *c, WebKitWebView *rv); - static void initwebextensions(WebKitWebContext *wc, Client *c); - static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a, -@@ -263,7 +264,6 @@ - void - setup(void) - { -- GdkDisplay *gdpy; - int i, j; - - /* clean up any zombies immediately */ -@@ -281,8 +281,6 @@ - - gtk_init(NULL, NULL); - -- gdpy = gdk_display_get_default(); -- - curconfig = defconfig; - - /* dirs and files */ -@@ -290,7 +288,7 @@ - scriptfile = buildfile(scriptfile); - cachedir = buildpath(cachedir); - -- gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy)); -+ gdkkb = getkbdevice(); - - if (!stylefile) { - styledir = buildpath(styledir); -@@ -329,6 +327,23 @@ - } - } - -+static GdkDevice * -+getkbdevice(void) -+{ -+ GList *l, *gdl = gdk_device_manager_list_devices( -+ gdk_display_get_device_manager(gdk_display_get_default()), -+ GDK_DEVICE_TYPE_MASTER); -+ GdkDevice *gd = NULL; -+ -+ for (l = gdl; l != NULL; l = l->next) -+ if (gdk_device_get_source(l->data) == GDK_SOURCE_KEYBOARD) -+ gd = l->data; -+ -+ g_list_free(gdl); -+ return gd; -+} -+ -+ - void - sigchld(int unused) - { diff --git a/network/surf/options.txt b/network/surf/options.txt index 6069a9ebac..308ab3bc86 100644 --- a/network/surf/options.txt +++ b/network/surf/options.txt @@ -21,13 +21,14 @@ HOMEPAGE WIDTH HEIGHT The default window size for surf to use, when it starts. Default values - are WIDTH=800 HEIGHT=600. + are WIDTH=1280 HEIGHT=1024. SLACKVER - The version of Slackware you're building for. If not set, the version - from /etc/slackware-version will be used. You only need to set this - if building on Slackware-current (use SLACKVER=current). This is only - used for the searchengines patch, so it does nothing if PATCH=no. + The version of Slackware you're building for. If not set, the + version from /etc/slackware-version will be used. You only need to + set this if building on Slackware-current (use the latest stable + version). This is only used for the searchengines patch, so it does + nothing if PATCH=no. STRICTSSL If STRICTSSL=yes, refuse untrusted connections (e.g. invalid/unknown diff --git a/network/surf/patches.txt b/network/surf/patches.txt index 957465989a..2295c4983e 100644 --- a/network/surf/patches.txt +++ b/network/surf/patches.txt @@ -9,7 +9,6 @@ google for foo and bar. Supported engines: g - google.com dict - search for a word on thefreedictionary.com sb - search for packages on slackbuilds.org - sw - search for official slackware packages on search.slackware.eu homepage - The browser will start at your home page if called with no arguments (normally it starts with a blank window). diff --git a/network/surf/patches/homepage.diff b/network/surf/patches/homepage.diff index 4e130a6e88..0e8e680891 100644 --- a/network/surf/patches/homepage.diff +++ b/network/surf/patches/homepage.diff @@ -1,7 +1,7 @@ -diff -Naur surf-2.0/surf.c surf-2.0.patched/surf.c ---- surf-2.0/surf.c 2017-03-28 12:17:45.000000000 -0400 -+++ surf-2.0.patched/surf.c 2017-06-25 01:33:34.501169322 -0400 -@@ -1751,7 +1751,7 @@ +diff -Naur surf-2.1/surf.c surf-2.1.patched/surf.c +--- surf-2.1/surf.c 2021-05-09 18:34:33.000000000 -0400 ++++ surf-2.1.patched/surf.c 2021-10-20 02:55:17.426198883 -0400 +@@ -2117,7 +2117,7 @@ if (argc > 0) arg.v = argv[0]; else diff --git a/network/surf/patches/searchengines.diff b/network/surf/patches/searchengines.diff index e4577632e0..7666efbad3 100644 --- a/network/surf/patches/searchengines.diff +++ b/network/surf/patches/searchengines.diff @@ -1,70 +1,70 @@ -diff -Naur surf-2.0/config.def.h surf-2.0.patched/config.def.h ---- surf-2.0/config.def.h 2017-03-28 12:17:45.000000000 -0400 -+++ surf-2.0.patched/config.def.h 2017-06-25 02:20:53.529174137 -0400 -@@ -153,6 +153,13 @@ +diff -Naur surf-2.1/config.def.h surf-2.1.patched/config.def.h +--- surf-2.1/config.def.h 2021-05-09 18:34:33.000000000 -0400 ++++ surf-2.1.patched/config.def.h 2021-10-20 02:51:08.497221512 -0400 +@@ -179,6 +179,13 @@ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, }; +static SearchEngine searchengines[] = { + { "d", "https://duckduckgo.com/html/?q=%s" }, + { "g", "https://www.google.com/search?q=%s" }, -+ { "dict", "http://www.thefreedictionary.com/%s" }, -+ { "sb", "http://slackbuilds.org/result/?search=%s&sv=@SLACKVER@" }, ++ { "dict", "https://www.thefreedictionary.com/%s" }, ++ { "sb", "https://slackbuilds.org/result/?search=%s&sv=@SLACKVER@" }, +}; + /* button definitions */ /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ static Button buttons[] = { -diff -Naur surf-2.0/surf.c surf-2.0.patched/surf.c ---- surf-2.0/surf.c 2017-03-28 12:17:45.000000000 -0400 -+++ surf-2.0.patched/surf.c 2017-06-25 02:04:32.517172473 -0400 -@@ -129,6 +129,11 @@ +diff -Naur surf-2.1/surf.c surf-2.1.patched/surf.c +--- surf-2.1/surf.c 2021-05-09 18:34:33.000000000 -0400 ++++ surf-2.1.patched/surf.c 2021-10-20 02:53:48.600206958 -0400 +@@ -130,6 +130,11 @@ } Button; typedef struct { -+ char *token; -+ char *uri; ++ char *token; ++ char *uri; +} SearchEngine; + +typedef struct { const char *uri; Parameter config[ParameterLast]; regex_t re; -@@ -202,6 +207,7 @@ - static void download(Client *c, WebKitURIResponse *r); +@@ -216,6 +221,7 @@ + Client *c); static void closeview(WebKitWebView *v, Client *c); static void destroywin(GtkWidget* w, Client *c); +static gchar *parseuri(const gchar *uri); /* Hotkeys */ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); -@@ -477,7 +483,7 @@ - url = g_strdup_printf("file://%s", path); - free(path); - } else { -- url = g_strdup_printf("http://%s", uri); -+ url = parseuri(uri); - } - - setatom(c, AtomUri, url); -@@ -1461,6 +1467,22 @@ +@@ -576,7 +582,7 @@ + url = g_strdup_printf("file://%s", path); + free(path); + } else { +- url = g_strdup_printf("http://%s", uri); ++ url = parseuri(uri); + } + if (apath != uri) + free(apath); +@@ -1776,6 +1782,22 @@ gtk_main_quit(); } +gchar * +parseuri(const gchar *uri) { -+ guint i; ++ guint i; + -+ for (i = 0; i < LENGTH(searchengines); i++) { -+ if (searchengines[i].token == NULL || searchengines[i].uri == NULL || -+ *(uri + strlen(searchengines[i].token)) != ' ') -+ continue; -+ if (g_str_has_prefix(uri, searchengines[i].token)) -+ return g_strdup_printf(searchengines[i].uri, -+ uri + strlen(searchengines[i].token) + 1); -+ } ++ for (i = 0; i < LENGTH(searchengines); i++) { ++ if (searchengines[i].token == NULL || searchengines[i].uri == NULL || ++ *(uri + strlen(searchengines[i].token)) != ' ') ++ continue; ++ if (g_str_has_prefix(uri, searchengines[i].token)) ++ return g_strdup_printf(searchengines[i].uri, ++ uri + strlen(searchengines[i].token) + 1); ++ } + -+ return g_strdup_printf("http://%s", uri); ++ return g_strdup_printf("http://%s", uri); +} + void diff --git a/network/surf/surf.SlackBuild b/network/surf/surf.SlackBuild index 872d1474aa..3b19b5dfe5 100644 --- a/network/surf/surf.SlackBuild +++ b/network/surf/surf.SlackBuild @@ -6,6 +6,11 @@ # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. +# 20211020 bkw: +# - updated for v2.1. +# - rework patches again, can't build old versions no more. +# - embiggen the default window size to 1280x1024. + # 20170625 bkw: # - updated for v2.0 (webkit2gtk now required). # - re-work searchengines.diff and homepage.diff for v2.0. @@ -23,7 +28,7 @@ cd $(dirname $0) ; CWD=$(pwd) PRGNAM=surf -VERSION=${VERSION:-2.0} +VERSION=${VERSION:-2.1} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} @@ -36,9 +41,6 @@ if [ -z "$ARCH" ]; then esac fi -# If the variable PRINT_PACKAGE_NAME is set, then this script will report what -# the name of the created package would be, and then exit. This information -# could be useful to other scripts. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" exit 0 @@ -71,17 +73,8 @@ rm -rf $PRGNAM-$VERSION tar xvf $CWD/$PRGNAM-$VERSION.tar.gz cd $PRGNAM-$VERSION chown -R root:root . -find -L . \ - \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \ - -exec chmod 755 {} \; -o \ - \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ - -exec chmod 644 {} \; - -# Revert upstream commit f9714ab8, which requires gtk+3-3.20.0 or greater. -# We only have 3.18.9 in Slack 14.2. NB: submission reviewer, please don't -# move this patch into patches/ (it must always be applied, whether or not -# PATCH=yes is set). -patch -p1 < $CWD/getkbdevice.diff +find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \ + \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+ # Add a couple of nice patches from upstream, unless disabled. Note that # upstream expects users to add patches and edit the source to customize it. @@ -101,8 +94,8 @@ fi TERMINAL=${TERMINAL:-rxvt} # Default geometry -WIDTH=${WIDTH:-800} -HEIGHT=${HEIGHT:-600} +WIDTH=${WIDTH:-1280} +HEIGHT=${HEIGHT:-1024} # Homepage (if browser called with no arguments). No effect if PATCH=no HOMEPAGE="${HOMEPAGE:-https://duckduckgo.com/html/}" @@ -118,11 +111,11 @@ fi sed -i \ -e "s,@HOMEPAGE@,$HOMEPAGE,g" \ - -e "s,\<800\>,$WIDTH," \ - -e "s,\<600\>,$HEIGHT," \ $PRGNAM.c sed -i \ + -e "s,\<800\>,$WIDTH," \ + -e "s,\<600\>,$HEIGHT," \ -e "s,\,$TERMINAL," \ -e "s,@SLACKVER@,$SLACKVER," \ config.def.h diff --git a/network/surf/surf.info b/network/surf/surf.info index ae13a4ab0c..4bef3e7877 100644 --- a/network/surf/surf.info +++ b/network/surf/surf.info @@ -1,8 +1,8 @@ PRGNAM="surf" -VERSION="2.0" +VERSION="2.1" HOMEPAGE="https://surf.suckless.org/" -DOWNLOAD="https://dl.suckless.org/surf/surf-2.0.tar.gz" -MD5SUM="11713901fa83c536f3ddfacfc28c3acc" +DOWNLOAD="https://dl.suckless.org/surf/surf-2.1.tar.gz" +MD5SUM="b814baf863826cb939a7121eafbb0344" DOWNLOAD_x86_64="" MD5SUM_x86_64="" REQUIRES="webkit2gtk dmenu"