summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-06-03 11:33:15 -0700
committerMichael Forney <mforney@mforney.org>2017-06-03 14:10:48 -0700
commitb5aa658cacdd1a49a6639a1fb9ebb6a099b8db4e (patch)
treee05b2de3b521640ec3087332f12be0da7e96f05c
parentf8aeeb79ec8cf0c4c3eda17cffeac416790337a7 (diff)
netsurf: Use new tiny frontend and remove libnsfb
The tiny backend was written from scratch and offers several improvements over the framebuffer backend: - Supports copy-paste. - Re-uses browser widgets for UI. - Simpler, and easier to work with.
-rw-r--r--.gitmodules7
-rw-r--r--pkg/netsurf/config.h26
-rw-r--r--pkg/netsurf/gen.rc58
-rw-r--r--pkg/netsurf/libnsfb/gen.rc26
-rw-r--r--pkg/netsurf/libnsfb/patch/0001-Add-XKB-key-events.patch55
-rw-r--r--pkg/netsurf/libnsfb/patch/0002-Add-cursor_shape-surface-method.patch106
-rw-r--r--pkg/netsurf/libnsfb/rev1
m---------pkg/netsurf/libnsfb/src0
-rw-r--r--pkg/netsurf/libnsfb/wl.c911
-rw-r--r--pkg/netsurf/patch/0001-Remove-non-reproducible-info-from-about-page.patch40
-rw-r--r--pkg/netsurf/patch/0002-framebuffer-Set-default-backend-to-wayland.patch25
-rw-r--r--pkg/netsurf/patch/0003-framebuffer-Fix-cookie-defaults.patch100
-rw-r--r--pkg/netsurf/patch/0004-framebuffer-Fix-font-layout-function-return-values.patch112
-rw-r--r--pkg/netsurf/patch/0005-framebuffer-Use-XKB-key-events.patch558
-rw-r--r--pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch225
-rw-r--r--pkg/netsurf/rev2
m---------pkg/netsurf/src0
17 files changed, 28 insertions, 2224 deletions
diff --git a/.gitmodules b/.gitmodules
index 01a2730f..4f680903 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -130,8 +130,7 @@
url = https://github.com/rydberg/mtdev
[submodule "pkg/netsurf/src"]
path = pkg/netsurf/src
- url = git://git.netsurf-browser.org/netsurf.git
- ignore = all
+ url = https://github.com/michaelforney/netsurf
[submodule "pkg/netsurf/libcss/src"]
path = pkg/netsurf/libcss/src
url = git://git.netsurf-browser.org/libcss.git
@@ -144,10 +143,6 @@
[submodule "pkg/netsurf/libnsbmp/src"]
path = pkg/netsurf/libnsbmp/src
url = git://git.netsurf-browser.org/libnsbmp.git
-[submodule "pkg/netsurf/libnsfb/src"]
- path = pkg/netsurf/libnsfb/src
- url = git://git.netsurf-browser.org/libnsfb.git
- ignore = all
[submodule "pkg/netsurf/libnsgif/src"]
path = pkg/netsurf/libnsgif/src
url = git://git.netsurf-browser.org/libnsgif.git
diff --git a/pkg/netsurf/config.h b/pkg/netsurf/config.h
index 8f6a93ee..37ea2297 100644
--- a/pkg/netsurf/config.h
+++ b/pkg/netsurf/config.h
@@ -1,19 +1,17 @@
-#define nsframebuffer
+#define nstiny
#define NETSURF_HOMEPAGE "https://google.com"
-#define NETSURF_FB_RESPATH "${HOME}/.netsurf:${NETSURFRES}:/share/netsurf"
-#define NETSURF_FB_FONTPATH "/share/fonts"
+#define TINY_RESPATH "/share/netsurf:/share/fonts"
-#define FB_USE_FREETYPE
-#define NETSURF_FB_FONT_SANS_SERIF "source-sans-pro/SourceSansPro-Regular.otf"
-#define NETSURF_FB_FONT_SANS_SERIF_BOLD "source-sans-pro/SourceSansPro-Bold.otf"
-#define NETSURF_FB_FONT_SANS_SERIF_ITALIC "source-sans-pro/SourceSansPro-It.otf"
-#define NETSURF_FB_FONT_SANS_SERIF_ITALIC_BOLD "source-sans-pro/SourceSansPro-BoldIt.otf"
-#define NETSURF_FB_FONT_SERIF "source-serif-pro/SourceSerifPro-Regular.otf"
-#define NETSURF_FB_FONT_SERIF_BOLD "source-serif-pro/SourceSerifPro-Bold.otf"
-#define NETSURF_FB_FONT_MONOSPACE "source-code-pro/SourceCodePro-Regular.otf"
-#define NETSURF_FB_FONT_MONOSPACE_BOLD "source-code-pro/SourceCodePro-Bold.otf"
-#define NETSURF_FB_FONT_CURSIVE ""
-#define NETSURF_FB_FONT_FANTASY ""
+#define TINY_FONT_SANS_SERIF "source-sans-pro/SourceSansPro-Regular.otf"
+#define TINY_FONT_SANS_SERIF_BOLD "source-sans-pro/SourceSansPro-Bold.otf"
+#define TINY_FONT_SANS_SERIF_ITALIC "source-sans-pro/SourceSansPro-It.otf"
+#define TINY_FONT_SANS_SERIF_ITALIC_BOLD "source-sans-pro/SourceSansPro-BoldIt.otf"
+#define TINY_FONT_SERIF "source-serif-pro/SourceSerifPro-Regular.otf"
+#define TINY_FONT_SERIF_BOLD "source-serif-pro/SourceSerifPro-Bold.otf"
+#define TINY_FONT_MONOSPACE "source-code-pro/SourceCodePro-Regular.otf"
+#define TINY_FONT_MONOSPACE_BOLD "source-code-pro/SourceCodePro-Bold.otf"
+#define TINY_FONT_CURSIVE TINY_FONT_SANS_SERIF
+#define TINY_FONT_FANTASY TINY_FONT_SANS_SERIF
#define DUK_OPT_HAVE_CUSTOM_H 1
diff --git a/pkg/netsurf/gen.rc b/pkg/netsurf/gen.rc
index 1d548024..db43bcf2 100644
--- a/pkg/netsurf/gen.rc
+++ b/pkg/netsurf/gen.rc
@@ -4,7 +4,6 @@ subgen libcss
subgen libdom
subgen libhubbub
subgen libnsbmp
-subgen libnsfb
subgen libnsgif
subgen libnsutils
subgen libparserutils
@@ -25,12 +24,14 @@ cflags\
-isystem '$builddir'/pkg/libjpeg-turbo/include\
-isystem '$builddir'/pkg/libpng/include\
-isystem '$builddir'/pkg/libressl/include\
+ -isystem '$builddir'/pkg/pixman/include\
+ -isystem '$builddir'/pkg/wayland/include\
+ -isystem '$builddir'/pkg/wayland-protocols/include\
-isystem '$builddir'/pkg/zlib/include\
-isystem '$dir'/libcss/src/include\
-isystem '$dir'/libdom/src/include\
-isystem '$dir'/libhubbub/src/include\
-isystem '$dir'/libnsbmp/src/include\
- -isystem '$dir'/libnsfb/src/include\
-isystem '$dir'/libnsgif/src/include\
-isystem '$dir'/libnsutils/src/include\
-isystem '$dir'/libparserutils/src/include\
@@ -38,6 +39,7 @@ cflags\
-isystem '$dir'/libwapcaplet/src/include\
-isystem pkg/freetype/src/include\
-isystem pkg/libxkbcommon/src\
+ -isystem pkg/openbsd/include\
-I '$dir' \
-I '$srcdir' \
-I '$srcdir'/include\
@@ -53,35 +55,10 @@ rule nsgenbind '$outdir/nsgenbind/nsgenbind -v -I $srcdir/content/handlers/javas
nsgenbind_srcs='$outdir'/duktape/`{cat nsgenbind.txt}
build $"nsgenbind_srcs nsgenbind '$srcdir'/content/handlers/javascript/duktape/netsurf.bnd '|' '$outdir'/nsgenbind/nsgenbind
-rule convert_image '$outdir/convert_image $in $out $var'
-fn convert_image {
- build '$outdir'/$1.c convert_image '$srcdir'/frontends/$2 '|' '$outdir'/convert_image ; with\
- var $1
-}
-
-convert_image left_arrow framebuffer/res/icons/back.png
-convert_image right_arrow framebuffer/res/icons/forward.png
-convert_image reload framebuffer/res/icons/reload.png
-convert_image stop_image framebuffer/res/icons/stop.png
-convert_image history_image framebuffer/res/icons/history.png
-
-convert_image left_arrow_g framebuffer/res/icons/back_g.png
-convert_image right_arrow_g framebuffer/res/icons/forward_g.png
-convert_image reload_g framebuffer/res/icons/reload_g.png
-convert_image stop_image_g framebuffer/res/icons/stop_g.png
-convert_image history_image_g framebuffer/res/icons/history_g.png
-
-convert_image osk_image framebuffer/res/icons/osk.png
-
-for(d in l r u d)
- convert_image scroll$d framebuffer/res/icons/scroll$d.png
-for(n in 0 1 2 3 4 5 6 7 8)
- convert_image throbber$n gtk/res/throbber/throbber$n.png
-
phony deps '$outdir'/duktape/binding.c\
'$outdir'/^(\
- libcss libdom libhubbub libnsbmp libnsfb libnsgif\
- libparserutils libutf8proc libwapcaplet libnsutils\
+ libcss libdom libhubbub libnsbmp libnsgif libparserutils\
+ libutf8proc libwapcaplet libnsutils\
)^/fetch.stamp\
'$builddir'/pkg/^(freetype libxkbcommon)^/fetch.stamp\
('$dir'/libdom pkg/^(curl libjpeg-turbo libpng libressl zlib))^/headers
@@ -97,15 +74,7 @@ exe netsurf -d '$dir'/deps\
save_complete.c save_text.c selection.c textinput.c gui_factory.c\
save_pdf.c font_haru.c\
)\
- frontends/framebuffer/^(\
- gui.c framebuffer.c schedule.c bitmap.c fetch.c\
- findfile.c localhistory.c clipboard.c\
- font_freetype.c\
- fbtk/^(\
- fbtk.c event.c fill.c bitmap.c user.c window.c\
- text.c scroll.c osk.c\
- )\
- )\
+ frontends/tiny/^(fetch.c icons.c gui.c render.c schedule.c ui.c wl.c)\
content/^(\
content.c content_factory.c dirlist.c fetch.c hlcache.c\
llcache.c mimesniff.c urldb.c no_backing_store.c\
@@ -150,16 +119,10 @@ exe netsurf -d '$dir'/deps\
)\
'$outdir'/^(\
duktape/`{grep '\.c$' nsgenbind.txt}\
- left_arrow.c right_arrow.c reload.c stop_image.c history_image.c\
- left_arrow_g.c right_arrow_g.c reload_g.c stop_image_g.c history_image_g.c\
- scroll^(l r u d)^.c\
- osk_image.c\
- throbber^(0 1 2 3 4 5 6 7 8)^.c\
\
libcss/libcss.a.d\
libdom/libdom.a.d\
libnsbmp/libnsbmp.a\
- libnsfb/^(libnsfb.a.d src/surface/ram.c.o wl.c.o)\
libnsgif/libnsgif.a\
libnsutils/libnsutils.a\
libutf8proc/libutf8proc.a\
@@ -169,7 +132,12 @@ exe netsurf -d '$dir'/deps\
freetype/libfreetype.a.d\
libjpeg-turbo/libjpeg-turbo.a\
libpng/libpng.a\
+ libxkbcommon/libxkbcommon.a\
+ pixman/libpixman.a\
+ wayland/^(libwayland-client.a.d libwayland-cursor.a)\
zlib/libz.a\
+ \
+ wayland-protocols/xdg-shell-unstable-v5-protocol.c.o\
)
file bin/netsurf '$outdir'/netsurf 755
@@ -191,5 +159,7 @@ sym share/netsurf/maps.html welcome.html
file share/netsurf/netsurf.png '$srcdir'/!NetSurf/Resources/netsurf.png,b60 644
file share/netsurf/quirks.css '$srcdir'/!NetSurf/Resources/Quirks,f79 644
file share/netsurf/welcome.html '$srcdir'/!NetSurf/Resources/en/welcome.html,faf 644
+for(icon in back forward add remove home reload stop close)
+ file share/netsurf/icons/$icon.ff '$srcdir'/frontends/tiny/res/icons/$icon.ff 644
fetch git
diff --git a/pkg/netsurf/libnsfb/gen.rc b/pkg/netsurf/libnsfb/gen.rc
deleted file mode 100644
index b760b4ce..00000000
--- a/pkg/netsurf/libnsfb/gen.rc
+++ /dev/null
@@ -1,26 +0,0 @@
-cflags\
- -isystem '$builddir'/pkg/wayland/include\
- -isystem '$builddir'/pkg/wayland-protocols/include\
- -isystem pkg/libxkbcommon/src\
- -I '$srcdir'/include\
- -I '$srcdir'/src
-
-deps=(\
- pkg/^(wayland wayland-protocols)^/headers\
- '$builddir'/pkg/libxkbcommon/fetch.stamp\
- '$outdir'/fetch.stamp\
-)
-build '$outdir'/wl.c.o cc '$dir'/wl.c '||' $deps
-cc src/surface/ram.c
-
-lib libnsfb.a src/^(\
- libnsfb.c dump.c cursor.c palette.c\
- plot/^(api.c util.c generic.c 32bpp-xrgb8888.c 32bpp-xbgr8888.c 16bpp.c 8bpp.c)\
- surface/surface.c\
-) '$builddir'/pkg/^(\
- wayland/^(libwayland-client.a.d libwayland-cursor.a)\
- wayland-protocols/xdg-shell-unstable-v5-protocol.c.o\
- libxkbcommon/libxkbcommon.a\
-)
-
-fetch git
diff --git a/pkg/netsurf/libnsfb/patch/0001-Add-XKB-key-events.patch b/pkg/netsurf/libnsfb/patch/0001-Add-XKB-key-events.patch
deleted file mode 100644
index f51a891a..00000000
--- a/pkg/netsurf/libnsfb/patch/0001-Add-XKB-key-events.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 4fd4359563e38ee0b4cd70fcaba6d935f4d2afdf Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Sun, 25 Dec 2016 14:50:47 -0800
-Subject: [PATCH] Add XKB key events
-
----
- include/libnsfb_event.h | 13 +++++++++++++
- 1 file changed, 13 insertions(+)
-
-diff --git a/include/libnsfb_event.h b/include/libnsfb_event.h
-index f98b5ba..006b51c 100644
---- a/include/libnsfb_event.h
-+++ b/include/libnsfb_event.h
-@@ -11,11 +11,15 @@
- #ifndef _LIBNSFB_EVENT_H
- #define _LIBNSFB_EVENT_H 1
-
-+#include <xkbcommon/xkbcommon.h>
-+
- enum nsfb_event_type_e {
- NSFB_EVENT_NONE,
- NSFB_EVENT_CONTROL,
- NSFB_EVENT_KEY_DOWN,
- NSFB_EVENT_KEY_UP,
-+ NSFB_EVENT_XKB_KEY_DOWN,
-+ NSFB_EVENT_XKB_KEY_UP,
- NSFB_EVENT_MOVE_RELATIVE,
- NSFB_EVENT_MOVE_ABSOLUTE,
- NSFB_EVENT_RESIZE
-@@ -179,6 +183,11 @@ enum nsfb_key_code_e {
-
- };
-
-+enum nsfb_mod_e {
-+ NSFB_MOD_CTRL = 1 << 0,
-+ NSFB_MOD_SHIFT = 1 << 1,
-+};
-+
- enum nsfb_control_e {
- NSFB_CONTROL_NONE,
- NSFB_CONTROL_TIMEOUT, /* timeout event */
-@@ -199,6 +208,10 @@ struct nsfb_event_s {
- int w; /**< Width in pixels */
- int h; /**< Height in pixels */
- } resize; /**< Window resize event: NSFB_EVENT_RESIZE */
-+ struct {
-+ xkb_keysym_t sym;
-+ enum nsfb_mod_e mod;
-+ } xkb;
- } value;
- };
-
---
-2.11.0
-
diff --git a/pkg/netsurf/libnsfb/patch/0002-Add-cursor_shape-surface-method.patch b/pkg/netsurf/libnsfb/patch/0002-Add-cursor_shape-surface-method.patch
deleted file mode 100644
index 5dc8d5e1..00000000
--- a/pkg/netsurf/libnsfb/patch/0002-Add-cursor_shape-surface-method.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From 82405df494578e57152a70c0736bd27d6b8eee34 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Fri, 30 Dec 2016 01:54:41 -0800
-Subject: [PATCH] Add cursor_shape surface method
-
----
- include/libnsfb_cursor.h | 25 +++++++++++++++++++++++++
- src/cursor.c | 8 ++++++++
- src/surface.h | 5 +++++
- 3 files changed, 38 insertions(+)
-
-diff --git a/include/libnsfb_cursor.h b/include/libnsfb_cursor.h
-index 525bd83..a71f056 100644
---- a/include/libnsfb_cursor.h
-+++ b/include/libnsfb_cursor.h
-@@ -11,6 +11,28 @@
- #ifndef _LIBNSFB_CURSOR_H
- #define _LIBNSFB_CURSOR_H 1
-
-+enum nsfb_cursor_shape_e {
-+ NSFB_CURSOR_DEFAULT,
-+ NSFB_CURSOR_POINT,
-+ NSFB_CURSOR_CARET,
-+ NSFB_CURSOR_MENU,
-+ NSFB_CURSOR_UP,
-+ NSFB_CURSOR_DOWN,
-+ NSFB_CURSOR_LEFT,
-+ NSFB_CURSOR_RIGHT,
-+ NSFB_CURSOR_RU,
-+ NSFB_CURSOR_LD,
-+ NSFB_CURSOR_LU,
-+ NSFB_CURSOR_RD,
-+ NSFB_CURSOR_CROSS,
-+ NSFB_CURSOR_MOVE,
-+ NSFB_CURSOR_WAIT,
-+ NSFB_CURSOR_HELP,
-+ NSFB_CURSOR_NO_DROP,
-+ NSFB_CURSOR_NOT_ALLOWED,
-+ NSFB_CURSOR_PROGRESS,
-+};
-+
- /** Initialise the cursor.
- */
- bool nsfb_cursor_init(nsfb_t *nsfb);
-@@ -34,6 +56,9 @@ bool nsfb_cursor_init(nsfb_t *nsfb);
- */
- bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, int hotspot_x, int hotspot_y);
-
-+/** Set cursor shape. */
-+bool nsfb_cursor_shape_set(nsfb_t *nsfb, enum nsfb_cursor_shape_e shape);
-+
- /** Set cursor location.
- *
- * @param nsfb The frambuffer context.
-diff --git a/src/cursor.c b/src/cursor.c
-index 87633dc..96cc45b 100644
---- a/src/cursor.c
-+++ b/src/cursor.c
-@@ -56,6 +56,14 @@ bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel,
- return nsfb->surface_rtns->cursor(nsfb, nsfb->cursor);
- }
-
-+bool nsfb_cursor_shape_set(nsfb_t *nsfb, enum nsfb_cursor_shape_e shape)
-+{
-+ if (nsfb->cursor == NULL)
-+ return false;
-+
-+ return nsfb->surface_rtns->cursor_shape(nsfb, shape);
-+}
-+
- bool nsfb_cursor_loc_set(nsfb_t *nsfb, const nsfb_bbox_t *loc)
- {
- if (nsfb->cursor == NULL)
-diff --git a/src/surface.h b/src/surface.h
-index efb84fb..ac72cd9 100644
---- a/src/surface.h
-+++ b/src/surface.h
-@@ -2,6 +2,7 @@
-
- #include "libnsfb.h"
- #include "libnsfb_plot.h"
-+#include "libnsfb_cursor.h"
- #include "nsfb.h"
-
- /* surface default options */
-@@ -31,6 +32,9 @@ typedef int (nsfb_surfacefn_update_t)(nsfb_t *nsfb, nsfb_bbox_t *box);
- /* surface cursor display */
- typedef int (nsfb_surfacefn_cursor_t)(nsfb_t *nsfb, struct nsfb_cursor_s *cursor);
-
-+/* surface cursor shape */
-+typedef int (nsfb_surfacefn_cursor_shape_t)(nsfb_t *nsfb, enum nsfb_cursor_shape_e shape);
-+
- typedef struct nsfb_surface_rtns_s {
- nsfb_surfacefn_defaults_t *defaults;
- nsfb_surfacefn_init_t *initialise;
-@@ -41,6 +45,7 @@ typedef struct nsfb_surface_rtns_s {
- nsfb_surfacefn_claim_t *claim;
- nsfb_surfacefn_update_t *update;
- nsfb_surfacefn_cursor_t *cursor;
-+ nsfb_surfacefn_cursor_shape_t *cursor_shape;
- } nsfb_surface_rtns_t;
-
- void _nsfb_register_surface(const enum nsfb_type_e type, const nsfb_surface_rtns_t *rtns, const char *name);
---
-2.11.0
-
diff --git a/pkg/netsurf/libnsfb/rev b/pkg/netsurf/libnsfb/rev
deleted file mode 100644
index 0cfbf088..00000000
--- a/pkg/netsurf/libnsfb/rev
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/pkg/netsurf/libnsfb/src b/pkg/netsurf/libnsfb/src
deleted file mode 160000
-Subproject 167205c109291aa1957ba64667efa12ce53bba5
diff --git a/pkg/netsurf/libnsfb/wl.c b/pkg/netsurf/libnsfb/wl.c
deleted file mode 100644
index 35de2080..00000000
--- a/pkg/netsurf/libnsfb/wl.c
+++ /dev/null
@@ -1,911 +0,0 @@
-#include <fcntl.h>
-#include <linux/input.h>
-#include <linux/memfd.h>
-#include <poll.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/param.h>
-#include <sys/syscall.h>
-#include <time.h>
-#include <unistd.h>
-#include <wayland-client.h>
-#include <wayland-cursor.h>
-#include <xdg-shell-unstable-v5-client-protocol.h>
-#include <xkbcommon/xkbcommon.h>
-
-#include "libnsfb.h"
-#include "libnsfb_plot.h"
-#include "libnsfb_cursor.h"
-#include "libnsfb_event.h"
-
-#include "nsfb.h"
-#include "surface.h"
-#include "plot.h"
-
-struct wlevent {
- struct wlevent *next;
- nsfb_event_t event;
-};
-
-struct format {
- uint32_t wl;
- enum nsfb_format_e ns;
-};
-
-struct wlimage {
- void *data;
- int width, height, stride, size;
- enum nsfb_format_e format;
- struct wl_shm_pool *pool;
- struct wl_buffer *buffer;
-};
-
-struct wlstate {
- struct wl_display *display;
- struct wl_registry *registry;
- struct wl_compositor *compositor;
- struct wl_seat *seat;
- struct wl_shm *shm;
- struct wl_keyboard *keyboard;
- struct wl_pointer *pointer;
-
- struct wl_surface *surface;
- struct wlimage *image;
-
- struct xdg_shell *shell;
- struct xdg_surface *xdg_surface;
-
- struct wlevent *events, **events_end;
-
- struct format *formats;
- int num_formats;
-
- int nextwidth, nextheight;
-
- struct {
- struct xkb_context *ctx;
- struct xkb_state *state;
- struct xkb_keymap *map;
- xkb_mod_index_t ctrl, shift;
- } xkb;
- enum nsfb_mod_e mods;
- int buttons;
-
- struct {
- int delay, interval, last;
- bool started;
- xkb_keysym_t sym;
- } repeat;
-
- struct {
- enum nsfb_cursor_shape_e shape;
- struct wl_surface *surface;
- struct wl_cursor_theme *theme;
- struct wl_cursor_image *image;
- } cursor;
-};
-
-static nsfb_event_t *
-queue_event(struct wlstate *wl)
-{
- struct wlevent *event;
-
- event = calloc(1, sizeof(*event));
- if (!event)
- return NULL;
- *wl->events_end = event;
- wl->events_end = &event->next;
- return &event->event;
-}
-
-static int
-clocknow(void)
-{
- struct timespec ts;
-
- if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
- return -1;
- return ts.tv_sec * 1000 + ts.tv_nsec / 1e6;
-}
-
-static void
-registry_global(void *data, struct wl_registry *reg, uint32_t name, const char *interface, uint32_t version)
-{
- struct wlstate *wl = data;
-
- if (strcmp(interface, "wl_compositor") == 0) {
- wl->compositor = wl_registry_bind(reg, name, &wl_compositor_interface, MIN(version, 4));
- } else if (strcmp(interface, "wl_seat") == 0) {
- wl->seat = wl_registry_bind(reg, name, &wl_seat_interface, MIN(version, 4));
- } else if (strcmp(interface, "wl_shm") == 0) {
- wl->shm = wl_registry_bind(reg, name, &wl_shm_interface, MIN(version, 1));
- } else if (strcmp(interface, "xdg_shell") == 0) {
- wl->shell = wl_registry_bind(reg, name, &xdg_shell_interface, MIN(version, 1));
- }
-}
-
-static void
-registry_global_remove(void *data, struct wl_registry *reg, uint32_t name)
-{
-}
-
-static struct wl_registry_listener registry_listener = {
- .global = registry_global,
- .global_remove = registry_global_remove,
-};
-
-static void
-shm_format(void *data, struct wl_shm *shm, uint32_t wlformat)
-{
- struct wlstate *wl = data;
- enum nsfb_format_e nsformat;
- struct format *formats;
-
- switch (wlformat) {
- case WL_SHM_FORMAT_XBGR8888:
- nsformat = NSFB_FMT_XBGR8888;
- break;
- case WL_SHM_FORMAT_XRGB8888:
- nsformat = NSFB_FMT_XRGB8888;
- break;
- case WL_SHM_FORMAT_ABGR8888:
- nsformat = NSFB_FMT_ABGR8888;
- break;
- case WL_SHM_FORMAT_ARGB8888:
- nsformat = NSFB_FMT_ARGB8888;
- break;
- case WL_SHM_FORMAT_RGB888:
- nsformat = NSFB_FMT_RGB888;
- break;
- case WL_SHM_FORMAT_ARGB1555:
- nsformat = NSFB_FMT_ARGB1555;
- break;
- case WL_SHM_FORMAT_RGB565:
- nsformat = NSFB_FMT_RGB565;
- break;
- case WL_SHM_FORMAT_C8:
- nsformat = NSFB_FMT_I8;
- break;
- default:
- return;
- }
-
- formats = realloc(wl->formats, (wl->num_formats + 1) * sizeof(*wl->formats));
- if (formats == NULL)
- return;
- wl->formats = formats;
- wl->formats[wl->num_formats++] = (struct format){wlformat, nsformat};
-}
-
-static struct wl_shm_listener shm_listener = {
- .format = shm_format,
-};
-
-static void
-keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size)
-{
- struct wlstate *wl = data;
- char *str;
-
- str = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
- if (str == MAP_FAILED)
- return;
-
- xkb_keymap_unref(wl->xkb.map);
- wl->xkb.map = xkb_keymap_new_from_buffer(wl->xkb.ctx, str, size, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
- if (wl->xkb.map == NULL)
- return;
-
- xkb_state_unref(wl->xkb.state);
- wl->xkb.state = xkb_state_new(wl->xkb.map);
- wl->xkb.ctrl = xkb_keymap_mod_get_index(wl->xkb.map, XKB_MOD_NAME_CTRL);
- wl->xkb.shift = xkb_keymap_mod_get_index(wl->xkb.map, XKB_MOD_NAME_SHIFT);
-}
-
-static void
-keyboard_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial , struct wl_surface *surface, struct wl_array *keys)
-{
-}
-
-static void
-keyboard_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface)
-{
- struct wlstate *wl = data;
-
- wl->repeat.sym = XKB_KEY_NoSymbol;
-}
-
-static void
-keyboard_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
-{
- struct wlstate *wl = data;
- xkb_keysym_t sym;
- nsfb_event_t *event;
- int now;
-
- if (!wl->xkb.state)
- return;
-
- sym = xkb_state_key_get_one_sym(wl->xkb.state, key + 8);
-
- event = queue_event(wl);
- if (!event)
- return;
-
- event->value.xkb.sym = sym;
- event->value.xkb.mod = wl->mods;
- if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
- event->type = NSFB_EVENT_XKB_KEY_DOWN;
- if (xkb_keymap_key_repeats(wl->xkb.map, key) && (now = clocknow()) >= 0) {
- wl->repeat.sym = sym;
- wl->repeat.started = false;
- wl->repeat.last = now;
- }
- } else {
- event->type = NSFB_EVENT_XKB_KEY_UP;
- if (sym == wl->repeat.sym)
- wl->repeat.sym = XKB_KEY_NoSymbol;
- }
-}
-
-static void
-keyboard_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group)
-{
- struct wlstate *wl = data;
-
- xkb_state_update_mask(wl->xkb.state, depressed, latched, locked, group, 0, 0);
-
- wl->mods = 0;
- if (wl->xkb.ctrl != XKB_MOD_INVALID && xkb_state_mod_index_is_active(wl->xkb.state, wl->xkb.ctrl, XKB_STATE_MODS_EFFECTIVE))
- wl->mods |= NSFB_MOD_CTRL;
- if (wl->xkb.shift != XKB_MOD_INVALID && xkb_state_mod_index_is_active(wl->xkb.state, wl->xkb.shift, XKB_STATE_MODS_EFFECTIVE))
- wl->mods |= NSFB_MOD_SHIFT;
-}
-
-static void
-keyboard_repeat_info(void *data, struct wl_keyboard *keyboard, int32_t rate, int32_t delay)
-{
- struct wlstate *wl = data;
-
- wl->repeat.delay = delay;
- wl->repeat.interval = 1000 / rate;
-}
-
-static struct wl_keyboard_listener keyboard_listener = {
- .keymap = keyboard_keymap,
- .enter = keyboard_enter,
- .leave = keyboard_leave,
- .key = keyboard_key,
- .modifiers = keyboard_modifiers,
- .repeat_info = keyboard_repeat_info,
-};
-
-static void
-updatecursor(struct wlstate *wl)
-{
- struct wl_cursor_image *image = wl->cursor.image;
- struct wl_buffer *buffer;
-
- if (!image)
- return;
- wl_pointer_set_cursor(wl->pointer, 0, wl->cursor.surface, image->hotspot_x, image->hotspot_y);
- buffer = wl_cursor_image_get_buffer(wl->cursor.image);
- wl_surface_damage(wl->cursor.surface, 0, 0, image->width, image->height);
- wl_surface_attach(wl->cursor.surface, buffer, 0, 0);
- wl_surface_commit(wl->cursor.surface);
-}
-
-static void
-pointer_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y)
-{
- struct wlstate *wl = data;
- nsfb_event_t *event;
-
- updatecursor(wl);
-
- event = queue_event(wl);
- if (!event)
- return;
-
- event->type = NSFB_EVENT_MOVE_ABSOLUTE;
- event->value.vector.x = wl_fixed_to_int(x);
- event->value.vector.y = wl_fixed_to_int(y);
-}
-
-static void
-pointer_leave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface)
-{
- struct wlstate *wl = data;
- int i;
- nsfb_event_t *event;
-
- for (i = 0; i < 3; ++i) {
- if (!(wl->buttons & (1 << i)))
- continue;
- event = queue_event(wl);
- if (!event)
- break;
- event->type = NSFB_EVENT_KEY_UP;
- switch (i) {
- case 0:
- event->value.keycode = NSFB_KEY_MOUSE_1;
- break;
- case 1:
- event->value.keycode = NSFB_KEY_MOUSE_2;
- break;
- case 2:
- event->value.keycode = NSFB_KEY_MOUSE_3;
- break;
- }
- }
- wl->buttons = 0;
-}
-
-static void
-pointer_motion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y)
-{
- struct wlstate *wl = data;
- nsfb_event_t *event;
-
- event = queue_event(wl);
- if (!event)
- return;
-
- event->type = NSFB_EVENT_MOVE_ABSOLUTE;
- event->value.vector.x = wl_fixed_to_int(x);
- event->value.vector.y = wl_fixed_to_int(y);
-}
-
-static void
-pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
-{
- struct wlstate *wl = data;
- enum nsfb_key_code_e code;
- nsfb_event_t *event;
- int num;
-
- switch (button) {
- case BTN_LEFT:
- code = NSFB_KEY_MOUSE_1;
- num = 0;
- break;
- case BTN_MIDDLE:
- code = NSFB_KEY_MOUSE_2;
- num = 1;
- break;
- case BTN_RIGHT:
- code = NSFB_KEY_MOUSE_3;
- num = 2;
- break;
- default:
- return;
- }
- if (state == WL_POINTER_BUTTON_STATE_PRESSED)
- wl->buttons |= 1 << num;
- else
- wl->buttons &= ~(1 << num);
-
- event = queue_event(wl);
- if (!event)
- return;
- if (state == WL_POINTER_BUTTON_STATE_PRESSED)
- event->type = NSFB_EVENT_KEY_DOWN;
- else
- event->type = NSFB_EVENT_KEY_UP;
- event->value.keycode = code;
-}
-
-static void
-pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
-{
- struct wlstate *wl = data;
- nsfb_event_t *event;
- enum nsfb_key_code_e code;
- int n = wl_fixed_to_int(value) / 10;
-
- if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL)
- return;
-
- if (n > 0) {
- code = NSFB_KEY_MOUSE_5;
- } else {
- code = NSFB_KEY_MOUSE_4;
- n = -n;
- }
-
- for (; n; --n) {
- event = queue_event(wl);
- if (!event)
- return;
- event->type = NSFB_EVENT_KEY_DOWN;
- event->value.keycode = code;
- }
-}
-
-static struct wl_pointer_listener pointer_listener = {
- .enter = pointer_enter,
- .leave = pointer_leave,
- .motion = pointer_motion,
- .button = pointer_button,
- .axis = pointer_axis,
-};
-
-static void
-seat_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities)
-{
- struct wlstate *wl = data;
-
- if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD && !wl->keyboard) {
- wl->keyboard = wl_seat_get_keyboard(wl->seat);
- if (wl->keyboard != NULL)
- wl_keyboard_add_listener(wl->keyboard, &keyboard_listener, wl);
- }
- if (capabilities & WL_SEAT_CAPABILITY_POINTER && !wl->pointer) {
- wl->pointer = wl_seat_get_pointer(wl->seat);
- if (wl->pointer != NULL)
- wl_pointer_add_listener(wl->pointer, &pointer_listener, wl);
- }
-}
-
-static void
-seat_name(void *data, struct wl_seat *seat, const char *name)
-{
-}
-
-static struct wl_seat_listener seat_listener = {
- .capabilities = seat_capabilities,
- .name = seat_name,
-};
-
-static void
-shell_ping(void *data, struct xdg_shell *shell, uint32_t serial)
-{
- xdg_shell_pong(shell, serial);
-}
-
-static struct xdg_shell_listener shell_listener = {
- .ping = shell_ping,
-};
-
-static void
-xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, int32_t width, int32_t height, struct wl_array *states, uint32_t serial)
-{
- struct wlstate *wl = data;
-
- if (width)
- wl->nextwidth = width;
- if (height)
- wl->nextheight = height;
- xdg_surface_ack_configure(xdg_surface, serial);
-}
-
-static void
-xdg_surface_close(void *data, struct xdg_surface *xdg_surface)
-{
- struct wlstate *wl = data;
- nsfb_event_t *event;
-
- event = queue_event(wl);
- if (!event)
- return;
- event->type = NSFB_EVENT_CONTROL;
- event->value.controlcode = NSFB_CONTROL_QUIT;
-}
-
-static struct xdg_surface_listener xdg_surface_listener = {
- .configure = xdg_surface_configure,
- .close = xdg_surface_close,
-};
-
-static int
-format_index(struct wlstate *wl, enum nsfb_format_e format)
-{
- int i;
-
- for (i = 0; i < wl->num_formats; ++i) {
- if (wl->formats[i].ns == format)
- return i;
- }
- return -1;
-}
-
-static struct wlimage *
-create_image(struct wlstate *wl, int w, int h, uint32_t format, int bpp)
-{
- struct wlimage *i;
- int fd;
-
- i = calloc(1, sizeof(*i));
- if (i == NULL)
- goto err0;
- i->width = w;
- i->height = h;
- i->stride = w * bpp;
- i->size = h * i->stride;
- fd = syscall(SYS_memfd_create, "nsfb", 0);
- if (fd < 0)
- goto err1;
- if (posix_fallocate(fd, 0, i->size) < 0)
- goto err2;
- i->data = mmap(NULL, i->size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if (i->data == MAP_FAILED)
- goto err2;
- i->pool = wl_shm_create_pool(wl->shm, fd, i->size);
- if (i->pool == NULL)
- goto err3;
- i->buffer = wl_shm_pool_create_buffer(i->pool, 0, w, h, i->stride, format);
- if (i->buffer == NULL)
- goto err4;
-
- close(fd);
- return i;
-
-err4:
- wl_shm_pool_destroy(i->pool);
-err3:
- munmap(i->data, i->size);
-err2:
- close(fd);
-err1:
- free(i);
-err0:
- return NULL;
-}
-
-static void
-destroy_image(struct wlimage *i)
-{
- wl_buffer_destroy(i->buffer);
- wl_shm_pool_destroy(i->pool);
- munmap(i->data, i->size);
- free(i);
-}
-
-static int
-wayland_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e nsformat)
-{
- struct wlstate *wl = nsfb->surface_priv;
- uint32_t wlformat;
- int i;
-
- if (!wl)
- return 0;
-
- if (width)
- nsfb->width = width;
- if (height)
- nsfb->height = height;
- if (nsformat != NSFB_FMT_ANY)
- nsfb->format = nsformat;
-
- select_plotters(nsfb);
-
- for (i = 0; i < wl->num_formats; ++i) {
- if (wl->formats[i].ns == nsfb->format) {
- wlformat = wl->formats[i].wl;
- break;
- }
- }
- if (i == wl->num_formats)
- return -1;
-
- if (wl->image)
- destroy_image(wl->image);
- wl->image = create_image(wl, width, height, wlformat, nsfb->bpp);
- if (wl->image == NULL)
- return -1;
- nsfb->ptr = wl->image->data;
- nsfb->linelen = wl->image->stride;
- wl_surface_attach(wl->surface, wl->image->buffer, 0, 0);
-
- return 0;
-}
-
-static int
-wayland_initialise(nsfb_t *nsfb)
-{
- struct wlstate *wl = nsfb->surface_priv;
-
- if (wl != NULL)
- return -1;
-
- wl = calloc(1, sizeof(*wl));
- if (wl == NULL)
- return -1;
- wl->xkb.ctx = xkb_context_new(0);
- if (!wl->xkb.ctx)
- return -1;
-
- wl->events_end = &wl->events;
- wl->nextwidth = nsfb->width;
- wl->nextheight = nsfb->height;
- wl->repeat.delay = 500;
- wl->repeat.interval = 25;
-
- wl->display = wl_display_connect(NULL);
- if (!wl->display) {
- free(wl);
- return -1;
- }
-
- wl->registry = wl_display_get_registry(wl->display);
- if (!wl->registry) {
- wl_display_disconnect(wl->display);
- free(wl);
- return -1;
- }
- wl_registry_add_listener(wl->registry, &registry_listener, wl);
-
- wl_display_roundtrip(wl->display);
-
- if (!wl->compositor || !wl->seat || !wl->shm || !wl->shell) {
- fprintf(stderr, "display is missing required globals\n");
- wl_display_disconnect(wl->display);
- free(wl);
- return -1;
- }
-
- wl_seat_add_listener(wl->seat, &seat_listener, wl);
- wl_shm_add_listener(wl->shm, &shm_listener, wl);
- xdg_shell_use_unstable_version(wl->shell, XDG_SHELL_VERSION_CURRENT);
- xdg_shell_add_listener(wl->shell, &shell_listener, NULL);
-
- wl->cursor.theme = wl_cursor_theme_load(NULL, 32, wl->shm);
- if (!wl->cursor.theme)
- return -1;
- wl->cursor.surface = wl_compositor_create_surface(wl->compositor);
- if (!wl->cursor.surface)
- return -1;
- wl->surface = wl_compositor_create_surface(wl->compositor);
- if (!wl->surface)
- return -1;
- wl->xdg_surface = xdg_shell_get_xdg_surface(wl->shell, wl->surface);
- if (!wl->xdg_surface)
- return -1;
- xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl);
-
-
- wl_display_roundtrip(wl->display);
-
- nsfb->surface_priv = wl;
- if (wayland_geometry(nsfb, wl->nextwidth, wl->nextheight, nsfb->format) < 0)
- return -1;
-
- return 0;
-}
-
-static int
-wayland_finalise(nsfb_t *nsfb)
-{
- struct wlstate *wl = nsfb->surface_priv;
- struct wlevent *event;
-
- if (wl == NULL)
- return 0;
-
- xdg_surface_destroy(wl->xdg_surface);
- xdg_shell_destroy(wl->shell);
- wl_surface_destroy(wl->surface);
- if (wl->keyboard) {
- if (wl_keyboard_get_version(wl->keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION)
- wl_keyboard_release(wl->keyboard);
- else
- wl_keyboard_destroy(wl->keyboard);
- }
- if (wl->pointer) {
- if (wl_pointer_get_version(wl->pointer) >= WL_POINTER_RELEASE_SINCE_VERSION)
- wl_pointer_release(wl->pointer);
- else
- wl_pointer_destroy(wl->pointer);
- }
- wl_surface_destroy(wl->cursor.surface);
- wl_cursor_theme_destroy(wl->cursor.theme);
- wl_seat_destroy(wl->seat);
- wl_shm_destroy(wl->shm);
- wl_compositor_destroy(wl->compositor);
- wl_registry_destroy(wl->registry);
-
- xkb_state_unref(wl->xkb.state);
- xkb_keymap_unref(wl->xkb.map);
- xkb_context_unref(wl->xkb.ctx);
-
- while (wl->events) {
- event = wl->events;
- wl->events = event->next;
- free(event);
- }
- free(wl->formats);
- free(wl);
-
- return 0;
-}
-
-static bool
-wayland_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout)
-{
- nsfb_event_t *resize;
- struct wlstate *wl = nsfb->surface_priv;
- struct pollfd fd;
- int ret, now, delay, left;
- bool dorepeat = false;
-
- if (wl == NULL)
- return false;
-
- wl_display_dispatch_pending(wl->display);
- wl_display_flush(wl->display);
-
- if (wl->events != NULL)
- goto nextevent;
-
- if (wl->repeat.sym != XKB_KEY_NoSymbol) {
- now = clocknow();
- if (now >= 0) {
- delay = wl->repeat.started ? wl->repeat.interval : wl->repeat.delay;
- left = delay - (now - wl->repeat.last);
- if (left <= 0)
- goto keyrepeat;
- if (left <= timeout) {
- timeout = left;
- dorepeat = true;
- }
- }
- }
-
- if (timeout >= 0) {
- fd.fd = wl_display_get_fd(wl->display);
- fd.events = POLLIN;
- ret = poll(&fd, 1, timeout);
- if (ret == 0) {
- if (dorepeat) {
-keyrepeat:
- wl->repeat.last = now;
- wl->repeat.started = true;
- event->type = NSFB_EVENT_XKB_KEY_DOWN;
- event->value.xkb.sym = wl->repeat.sym;
- } else {
- event->type = NSFB_EVENT_CONTROL;
- event->value.controlcode = NSFB_CONTROL_TIMEOUT;
- }
- return true;
- }
- }
-
- if (wl_display_dispatch(wl->display) == -1) {
- event->type = NSFB_EVENT_CONTROL;
- event->value.controlcode = NSFB_CONTROL_QUIT;
- return true;
- }
-
- if (wl->nextwidth != nsfb->width || wl->nextheight != nsfb->height) {
- resize = queue_event(wl);
- if (resize) {
- resize->type = NSFB_EVENT_RESIZE;
- resize->value.resize.w = wl->nextwidth;
- resize->value.resize.h = wl->nextheight;
- }
- }
-
- if (wl->events == NULL)
- return false;
-
-nextevent:
- *event = wl->events->event;
- if (wl->events_end == &wl->events->next)
- wl->events_end = &wl->events;
- wl->events = wl->events->next;
-
- return true;
-}
-
-static int
-wayland_update(nsfb_t *nsfb, nsfb_bbox_t *box)
-{
- struct wlstate *wl = nsfb->surface_priv;
-
- if (!wl)
- return 0;
-
- wl_surface_damage(wl->surface, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0);
- wl_surface_commit(wl->surface);
- return 0;
-}
-
-static int
-wayland_cursor_shape(nsfb_t *nsfb, enum nsfb_cursor_shape_e shape)
-{
- struct wlstate *wl = nsfb->surface_priv;
- const char *str = NULL;
- struct wl_cursor *cursor;
- struct wl_cursor_image *image;
- struct wl_buffer *buffer;
-
- if (!wl || wl->cursor.shape == shape)
- return 0;
- wl->cursor.shape = shape;
-
- switch (shape) {
- case NSFB_CURSOR_DEFAULT:
- str = "left_ptr";
- break;
- case NSFB_CURSOR_POINT:
- str = "hand2";
- break;
- case NSFB_CURSOR_CARET:
- str = "xterm";
- break;
- case NSFB_CURSOR_MENU:
- break;
- case NSFB_CURSOR_UP:
- str = "top_side";
- break;
- case NSFB_CURSOR_DOWN:
- str = "bottom_side";
- break;
- case NSFB_CURSOR_LEFT:
- str = "left_side";
- break;
- case NSFB_CURSOR_RIGHT:
- str = "right_side";
- break;
- case NSFB_CURSOR_LD:
- str = "bottom_left_corner";
- break;
- case NSFB_CURSOR_RD:
- str = "bottom_right_corner";
- break;
- case NSFB_CURSOR_LU:
- str = "top_left_corner";
- break;
- case NSFB_CURSOR_RU:
- str = "top_right_corner";
- break;
- case NSFB_CURSOR_CROSS:
- str = "cross";
- break;
- case NSFB_CURSOR_MOVE:
- str = "grabbing";
- break;
- case NSFB_CURSOR_WAIT:
- str = "watch";
- break;
- case NSFB_CURSOR_HELP:
- str = "question_arrow";
- break;
- case NSFB_CURSOR_NO_DROP:
- break;
- case NSFB_CURSOR_NOT_ALLOWED:
- break;
- case NSFB_CURSOR_PROGRESS:
- str = "watch";
- break;
- }
-
- if (!str)
- str = "left_ptr";
-
- cursor = wl_cursor_theme_get_cursor(wl->cursor.theme, str);
- if (!cursor) {
- printf("no cursor image: %s (%d)\n", str, shape);
- return -1;
- }
-
- image = cursor->images[0];
- wl->cursor.image = image;
- updatecursor(wl);
- return 0;
-}
-
-const nsfb_surface_rtns_t wayland_rtns = {
- .initialise = wayland_initialise,
- .finalise = wayland_finalise,
- .input = wayland_input,
- .update = wayland_update,
- .geometry = wayland_geometry,
- .cursor_shape = wayland_cursor_shape,
-};
-
-NSFB_SURFACE_DEF(wayland, NSFB_SURFACE_WL, &wayland_rtns)
diff --git a/pkg/netsurf/patch/0001-Remove-non-reproducible-info-from-about-page.patch b/pkg/netsurf/patch/0001-Remove-non-reproducible-info-from-about-page.patch
deleted file mode 100644
index 98663d3a..00000000
--- a/pkg/netsurf/patch/0001-Remove-non-reproducible-info-from-about-page.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From ba5389200ff60bb5494efe503f1f1fc165383a85 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Fri, 23 Dec 2016 14:41:52 -0800
-Subject: [PATCH] Remove non-reproducible info from about page
-
----
- content/fetchers/about.c | 17 -----------------
- 1 file changed, 17 deletions(-)
-
-diff --git a/content/fetchers/about.c b/content/fetchers/about.c
-index 4d14020b0..aff21c81a 100644
---- a/content/fetchers/about.c
-+++ b/content/fetchers/about.c
-@@ -477,23 +477,6 @@ static bool fetch_about_testament_handler(struct fetch_about_context *ctx)
- if (fetch_about_send_callback(&msg, ctx))
- goto fetch_about_testament_handler_aborted;
-
--
-- slen = snprintf(buffer, sizeof buffer,
-- "Built by %s (%s) from %s at revision %s on %s\n\n",
-- GECOS, USERNAME, WT_BRANCHPATH, WT_REVID, WT_COMPILEDATE);
--
-- msg.data.header_or_data.len = slen;
-- if (fetch_about_send_callback(&msg, ctx))
-- goto fetch_about_testament_handler_aborted;
--
-- slen = snprintf(buffer, sizeof buffer,
-- "Built on %s in %s\n\n",
-- WT_HOSTNAME, WT_ROOT);
--
-- msg.data.header_or_data.len = slen;
-- if (fetch_about_send_callback(&msg, ctx))
-- goto fetch_about_testament_handler_aborted;
--
- if (WT_MODIFIED > 0) {
- slen = snprintf(buffer, sizeof buffer,
- "Working tree has %d modification%s\n\n",
---
-2.11.0
-
diff --git a/pkg/netsurf/patch/0002-framebuffer-Set-default-backend-to-wayland.patch b/pkg/netsurf/patch/0002-framebuffer-Set-default-backend-to-wayland.patch
deleted file mode 100644
index 4b63ac8e..00000000
--- a/pkg/netsurf/patch/0002-framebuffer-Set-default-backend-to-wayland.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From ecd460198f101721260d770a6dcc52922f643a62 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Fri, 23 Dec 2016 15:13:31 -0800
-Subject: [PATCH] framebuffer: Set default backend to wayland
-
----
- frontends/framebuffer/gui.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
-index 4d4c7334f..2e819e6fa 100644
---- a/frontends/framebuffer/gui.c
-+++ b/frontends/framebuffer/gui.c
-@@ -466,7 +466,7 @@ process_cmdline(int argc, char** argv)
-
- LOG("argc %d, argv %p", argc, argv);
-
-- fename = "sdl";
-+ fename = "wayland";
- febpp = 32;
-
- fewidth = nsoption_int(window_width);
---
-2.11.0
-
diff --git a/pkg/netsurf/patch/0003-framebuffer-Fix-cookie-defaults.patch b/pkg/netsurf/patch/0003-framebuffer-Fix-cookie-defaults.patch
deleted file mode 100644
index 17bc12f5..00000000
--- a/pkg/netsurf/patch/0003-framebuffer-Fix-cookie-defaults.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 8a15a5505db85870f340c61fea1db3da16fde039 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Sat, 24 Dec 2016 16:57:34 -0800
-Subject: [PATCH] framebuffer: Fix cookie defaults
-
----
- frontends/framebuffer/gui.c | 48 +++++++++++++++++++++++++++++++++++++++++++--
- 1 file changed, 46 insertions(+), 2 deletions(-)
-
-diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
-index 2e819e6fa..e176ac9e4 100644
---- a/frontends/framebuffer/gui.c
-+++ b/frontends/framebuffer/gui.c
-@@ -31,6 +31,7 @@
-
- #include "utils/utils.h"
- #include "utils/nsoption.h"
-+#include "utils/file.h"
- #include "utils/filepath.h"
- #include "utils/log.h"
- #include "utils/messages.h"
-@@ -61,6 +62,7 @@
- fbtk_widget_t *fbtk;
-
- static bool fb_complete = false;
-+static char *fb_data_home;
-
- struct gui_window *input_window = NULL;
- struct gui_window *search_current_window;
-@@ -527,9 +529,18 @@ process_cmdline(int argc, char** argv)
- */
- static nserror set_defaults(struct nsoption_s *defaults)
- {
-+ char *fname;
-+
- /* Set defaults for absent option strings */
-- nsoption_setnull_charp(cookie_file, strdup("~/.netsurf/Cookies"));
-- nsoption_setnull_charp(cookie_jar, strdup("~/.netsurf/Cookies"));
-+ fname = NULL;
-+ netsurf_mkpath(&fname, NULL, 2, fb_data_home, "Cookies");
-+ if (fname != NULL)
-+ nsoption_setnull_charp(cookie_file, fname);
-+
-+ fname = NULL;
-+ netsurf_mkpath(&fname, NULL, 2, fb_data_home, "Cookies");
-+ if (fname != NULL)
-+ nsoption_setnull_charp(cookie_jar, fname);
-
- if (nsoption_charp(cookie_file) == NULL ||
- nsoption_charp(cookie_jar) == NULL) {
-@@ -2076,6 +2087,34 @@ static struct gui_misc_table framebuffer_misc_table = {
- .quit = gui_quit,
- };
-
-+static nserror get_data_home(char **data_home_out)
-+{
-+ nserror ret;
-+ char *xdg_data_home, *data_home, *home;
-+
-+ xdg_data_home = getenv("XDG_DATA_HOME");
-+ if ((xdg_data_home == NULL) || (*xdg_data_home == '\0')) {
-+ home = getenv("HOME");
-+ if (home == NULL)
-+ return NSERROR_NOT_DIRECTORY;
-+ ret = netsurf_mkpath(&data_home, NULL, 5, home, ".local", "share", "netsurf", "/");
-+ } else {
-+ ret = netsurf_mkpath(&data_home, NULL, 3, xdg_data_home, "netsurf", "/");
-+ }
-+ if (ret != NSERROR_OK)
-+ return ret;
-+
-+ ret = netsurf_mkdir_all(data_home);
-+ if (ret != NSERROR_OK) {
-+ free(data_home);
-+ return ret;
-+ }
-+ data_home[strlen(data_home) - 1] = 0;
-+ *data_home_out = data_home;
-+
-+ return NSERROR_OK;
-+}
-+
- /** Entry point from OS.
- *
- * /param argc The number of arguments in the string vector.
-@@ -2106,6 +2145,11 @@ main(int argc, char** argv)
- die("NetSurf operation table failed registration");
- }
-
-+ ret = get_data_home(&fb_data_home);
-+ if (ret != NSERROR_OK) {
-+ die("Failed to get home data directory");
-+ }
-+
- respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH);
-
- /* initialise logging. Not fatal if it fails but not much we
---
-2.11.0
-
diff --git a/pkg/netsurf/patch/0004-framebuffer-Fix-font-layout-function-return-values.patch b/pkg/netsurf/patch/0004-framebuffer-Fix-font-layout-function-return-values.patch
deleted file mode 100644
index accd9cc0..00000000
--- a/pkg/netsurf/patch/0004-framebuffer-Fix-font-layout-function-return-values.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 507e82825f659742b76df9179e59975b3bd55b30 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Sun, 25 Dec 2016 00:23:34 -0800
-Subject: [PATCH] framebuffer: Fix font layout function return values
-
-The return type is nserror, so they should return NSERROR_OK, not true.
----
- frontends/framebuffer/font_freetype.c | 10 +++++-----
- frontends/framebuffer/font_internal.c | 10 +++++-----
- 2 files changed, 10 insertions(+), 10 deletions(-)
-
-diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c
-index 9235ad476..42be6d443 100644
---- a/frontends/framebuffer/font_freetype.c
-+++ b/frontends/framebuffer/font_freetype.c
-@@ -445,7 +445,7 @@ fb_font_width(const plot_font_style_t *fstyle,
- *width += glyph->advance.x >> 16;
- }
-
-- return true;
-+ return NSERROR_OK;
- }
-
-
-@@ -481,7 +481,7 @@ fb_font_position(const plot_font_style_t *fstyle,
- *actual_x = prev_x;
-
- *char_offset = nxtchr;
-- return true;
-+ return NSERROR_OK;
- }
-
-
-@@ -494,7 +494,7 @@ fb_font_position(const plot_font_style_t *fstyle,
- * \param x width available
- * \param char_offset updated to offset in string of actual_x, [1..length]
- * \param actual_x updated to x coordinate of character closest to x
-- * \return true on success, false on error and error reported
-+ * \return NSERROR_OK on success or error code on failure
- *
- * On exit, char_offset indicates first character after split point.
- *
-@@ -537,7 +537,7 @@ fb_font_split(const plot_font_style_t *fstyle,
- * found a space; return previous space */
- *actual_x = last_space_x;
- *char_offset = last_space_idx;
-- return true;
-+ return NSERROR_OK;
- }
-
- nxtchr = utf8_next(string, length, nxtchr);
-@@ -545,7 +545,7 @@ fb_font_split(const plot_font_style_t *fstyle,
-
- *char_offset = nxtchr;
-
-- return true;
-+ return NSERROR_OK;
- }
-
- static struct gui_layout_table layout_table = {
-diff --git a/frontends/framebuffer/font_internal.c b/frontends/framebuffer/font_internal.c
-index 9164a29db..a9054098f 100644
---- a/frontends/framebuffer/font_internal.c
-+++ b/frontends/framebuffer/font_internal.c
-@@ -364,7 +364,7 @@ fb_font_width(const plot_font_style_t *fstyle,
- }
-
- *width *= fb_get_font_size(fstyle);
-- return true;
-+ return NSERROR_OK;
- }
-
-
-@@ -397,7 +397,7 @@ fb_font_position(const plot_font_style_t *fstyle,
- *actual_x = x_pos;
-
- *char_offset = nxtchr;
-- return true;
-+ return NSERROR_OK;
- }
-
-
-@@ -410,7 +410,7 @@ fb_font_position(const plot_font_style_t *fstyle,
- * \param x width available
- * \param char_offset updated to offset in string of actual_x, [1..length]
- * \param actual_x updated to x coordinate of character closest to x
-- * \return true on success, false on error and error reported
-+ * \return NSERROR_OK on success or error code on failure
- *
- * On exit, char_offset indicates first character after split point.
- *
-@@ -455,7 +455,7 @@ fb_font_split(const plot_font_style_t *fstyle,
- * found a space; return previous space */
- *actual_x = last_space_x;
- *char_offset = last_space_idx;
-- return true;
-+ return NSERROR_OK;
- }
-
- nxtchr = utf8_next(string, length, nxtchr);
-@@ -463,7 +463,7 @@ fb_font_split(const plot_font_style_t *fstyle,
-
- *char_offset = nxtchr;
-
-- return true;
-+ return NSERROR_OK;
- }
-
-
---
-2.11.0
-
diff --git a/pkg/netsurf/patch/0005-framebuffer-Use-XKB-key-events.patch b/pkg/netsurf/patch/0005-framebuffer-Use-XKB-key-events.patch
deleted file mode 100644
index e79e4f4c..00000000
--- a/pkg/netsurf/patch/0005-framebuffer-Use-XKB-key-events.patch
+++ /dev/null
@@ -1,558 +0,0 @@
-From e8a794e1ee7422613be28dbe6263b5877d9bf840 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Sun, 25 Dec 2016 14:46:31 -0800
-Subject: [PATCH] framebuffer: Use XKB key events
-
----
- frontends/framebuffer/fbtk/event.c | 86 +------------
- frontends/framebuffer/fbtk/text.c | 83 ++++---------
- frontends/framebuffer/gui.c | 240 +++++++++++++++----------------------
- 3 files changed, 128 insertions(+), 281 deletions(-)
-
-diff --git a/frontends/framebuffer/fbtk/event.c b/frontends/framebuffer/fbtk/event.c
-index a48e63809..29eed3286 100644
---- a/frontends/framebuffer/fbtk/event.c
-+++ b/frontends/framebuffer/fbtk/event.c
-@@ -224,6 +224,11 @@ fbtk_event(fbtk_widget_t *root, nsfb_event_t *event, int timeout)
- }
- break;
-
-+ case NSFB_EVENT_XKB_KEY_DOWN:
-+ case NSFB_EVENT_XKB_KEY_UP:
-+ fbtk_input(root, event);
-+ break;
-+
- case NSFB_EVENT_CONTROL:
- unused = true;
- break;
-@@ -261,87 +266,6 @@ fbtk_event(fbtk_widget_t *root, nsfb_event_t *event, int timeout)
- return unused;
- }
-
--static int keymap[] = {
-- /* 0 1 2 3 4 5 6 7 8 9 */
-- -1, -1, -1, -1, -1, -1, -1, -1, 8, 9, /* 0 - 9 */
-- -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, /* 10 - 19 */
-- -1, -1, -1, -1, -1, -1, -1, 27, -1, -1, /* 20 - 29 */
-- -1, -1, ' ', '!', '"', '#', '$', -1, '&','\'', /* 30 - 39 */
-- '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', /* 40 - 49 */
-- '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', /* 50 - 59 */
-- '<', '=', '>', '?', '@', -1, -1, -1, -1, -1, /* 60 - 69 */
-- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 70 - 79 */
-- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80 - 89 */
-- -1, '[','\\', ']', '~', '_', '`', 'a', 'b', 'c', /* 90 - 99 */
-- 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', /* 100 - 109 */
-- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', /* 110 - 119 */
-- 'x', 'y', 'z', -1, -1, -1, -1, -1, -1, -1, /* 120 - 129 */
--};
--
--static int sh_keymap[] = {
-- /* 0 1 2 3 4 5 6 7 8 9 */
-- -1, -1, -1, -1, -1, -1, -1, -1, 8, 9, /* 0 - 9 */
-- -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, /* 10 - 19 */
-- -1, -1, -1, -1, -1, -1, -1, 27, -1, -1, /* 20 - 29 */
-- -1, -1, ' ', '!', '"', '~', '$', -1, '&', '@', /* 30 - 39 */
-- '(', ')', '*', '+', '<', '_', '>', '?', ')', '!', /* 40 - 49 */
-- '"', 243, '$', '%', '^', '&', '*', '(', ';', ':', /* 50 - 59 */
-- '<', '+', '>', '?', '@', -1, -1, -1, -1, -1, /* 60 - 69 */
-- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 70 - 79 */
-- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80 - 89 */
-- -1, '{', '|', '}', '~', '_', 254, 'A', 'B', 'C', /* 90 - 99 */
-- 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', /* 100 - 109 */
-- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', /* 110 - 119 */
-- 'X', 'Y', 'Z', -1, -1, -1, -1, -1, -1, -1, /* 120 - 129 */
--};
--
--
--/* exported function documented in fbtk.h */
--int
--fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods)
--{
-- int ucs4 = -1;
--
-- if (mods & FBTK_MOD_LSHIFT || mods & FBTK_MOD_RSHIFT) {
-- if ((code >= 0) && (code < (int) NOF_ELEMENTS(sh_keymap)))
-- ucs4 = sh_keymap[code];
--
-- } else if (mods == FBTK_MOD_CLEAR) {
-- if ((code >= 0) && (code < (int) NOF_ELEMENTS(keymap)))
-- ucs4 = keymap[code];
--
-- } else if (mods & FBTK_MOD_LCTRL || mods & FBTK_MOD_RCTRL) {
-- switch (code) {
-- case NSFB_KEY_a:
-- ucs4 = NS_KEY_SELECT_ALL;
-- break;
--
-- case NSFB_KEY_c:
-- ucs4 = NS_KEY_COPY_SELECTION;
-- break;
--
-- case NSFB_KEY_u:
-- ucs4 = NS_KEY_DELETE_LINE;
-- break;
--
-- case NSFB_KEY_v:
-- ucs4 = NS_KEY_PASTE;
-- break;
--
-- case NSFB_KEY_x:
-- ucs4 = NS_KEY_CUT_SELECTION;
-- break;
--
-- case NSFB_KEY_z:
-- ucs4 = NS_KEY_CLEAR_SELECTION;
-- break;
-- default:
-- break;
-- }
-- }
-- return ucs4;
--}
--
- /*
- * Local Variables:
- * c-basic-offset:8
-diff --git a/frontends/framebuffer/fbtk/text.c b/frontends/framebuffer/fbtk/text.c
-index 00dcba491..95333a52f 100644
---- a/frontends/framebuffer/fbtk/text.c
-+++ b/frontends/framebuffer/fbtk/text.c
-@@ -26,6 +26,7 @@
- #include <libnsfb_plot.h>
- #include <libnsfb_plot_util.h>
- #include <libnsfb_event.h>
-+#include <xkbcommon/xkbcommon.h>
-
- #include "utils/log.h"
- #include "netsurf/browser_window.h"
-@@ -287,13 +288,14 @@ fb_text_input_remove_caret_cb(fbtk_widget_t *widget)
- static int
- text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- {
-- int value;
-- static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
-+ xkb_keysym_t sym;
-+ enum nsfb_mod_e mods;
- char *temp;
- plot_font_style_t font_style;
- int fh;
- int border;
- bool caret_moved = false;
-+ uint32_t key;
-
- fb_text_font_style(widget, &fh, &border, &font_style);
-
-@@ -305,34 +307,14 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- return 0;
- }
-
-- value = cbi->event->value.keycode;
--
-- if (cbi->event->type != NSFB_EVENT_KEY_DOWN) {
-- switch (value) {
-- case NSFB_KEY_RSHIFT:
-- modifier &= ~FBTK_MOD_RSHIFT;
-- break;
--
-- case NSFB_KEY_LSHIFT:
-- modifier &= ~FBTK_MOD_LSHIFT;
-- break;
--
-- case NSFB_KEY_RCTRL:
-- modifier &= ~FBTK_MOD_RCTRL;
-- break;
--
-- case NSFB_KEY_LCTRL:
-- modifier &= ~FBTK_MOD_LCTRL;
-- break;
--
-- default:
-- break;
-- }
-+ if (cbi->event->type != NSFB_EVENT_XKB_KEY_DOWN)
- return 0;
-- }
-
-- switch (value) {
-- case NSFB_KEY_BACKSPACE:
-+ sym = cbi->event->value.xkb.sym;
-+ mods = cbi->event->value.xkb.mod;
-+
-+ switch (sym) {
-+ case XKB_KEY_BackSpace:
- if (widget->u.text.idx <= 0)
- break;
- memmove(widget->u.text.text + widget->u.text.idx - 1,
-@@ -348,13 +330,13 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- caret_moved = true;
- break;
-
-- case NSFB_KEY_RETURN:
-+ case XKB_KEY_Return:
- widget->u.text.enter(widget->u.text.pw, widget->u.text.text);
- break;
-
-- case NSFB_KEY_RIGHT:
-+ case XKB_KEY_Right:
- if (widget->u.text.idx < widget->u.text.len) {
-- if (modifier == FBTK_MOD_CLEAR)
-+ if (mods == 0)
- widget->u.text.idx++;
- else
- widget->u.text.idx = widget->u.text.len;
-@@ -363,9 +345,9 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- }
- break;
-
-- case NSFB_KEY_LEFT:
-+ case XKB_KEY_Left:
- if (widget->u.text.idx > 0) {
-- if (modifier == FBTK_MOD_CLEAR)
-+ if (mods == 0)
- widget->u.text.idx--;
- else
- widget->u.text.idx = 0;
-@@ -374,34 +356,18 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- }
- break;
-
-- case NSFB_KEY_PAGEUP:
-- case NSFB_KEY_PAGEDOWN:
-- case NSFB_KEY_UP:
-- case NSFB_KEY_DOWN:
-+ case XKB_KEY_Page_Up:
-+ case XKB_KEY_Page_Down:
-+ case XKB_KEY_Up:
-+ case XKB_KEY_Down:
- /* Not handling any of these correctly yet, but avoid putting
- * charcters in the text widget when they're pressed. */
- break;
-
-- case NSFB_KEY_RSHIFT:
-- modifier |= FBTK_MOD_RSHIFT;
-- break;
--
-- case NSFB_KEY_LSHIFT:
-- modifier |= FBTK_MOD_LSHIFT;
-- break;
--
-- case NSFB_KEY_RCTRL:
-- modifier |= FBTK_MOD_RCTRL;
-- break;
--
-- case NSFB_KEY_LCTRL:
-- modifier |= FBTK_MOD_LCTRL;
-- break;
--
- default:
-- if (modifier & FBTK_MOD_LCTRL || modifier & FBTK_MOD_RCTRL) {
-+ if (mods & NSFB_MOD_CTRL) {
- /* CTRL pressed, don't enter any text */
-- if (value == NSFB_KEY_u) {
-+ if (sym == XKB_KEY_u) {
- /* CTRL+U: clear writable */
- widget->u.text.idx = 0;
- widget->u.text.len = 0;
-@@ -412,6 +378,10 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- break;
- }
-
-+ key = xkb_keysym_to_utf32(sym);
-+ if (key == 0)
-+ break;
-+
- /* allow for new character and null */
- temp = realloc(widget->u.text.text, widget->u.text.len + 2);
- if (temp == NULL) {
-@@ -422,8 +392,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- memmove(widget->u.text.text + widget->u.text.idx + 1,
- widget->u.text.text + widget->u.text.idx,
- widget->u.text.len - widget->u.text.idx);
-- widget->u.text.text[widget->u.text.idx] =
-- fbtk_keycode_to_ucs4(value, modifier);
-+ widget->u.text.text[widget->u.text.idx] = key;
- widget->u.text.idx++;
- widget->u.text.len++;
- widget->u.text.text[widget->u.text.len] = '\0';
-diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
-index e176ac9e4..6bf5152c0 100644
---- a/frontends/framebuffer/gui.c
-+++ b/frontends/framebuffer/gui.c
-@@ -28,6 +28,7 @@
- #include <libnsfb.h>
- #include <libnsfb_plot.h>
- #include <libnsfb_event.h>
-+#include <xkbcommon/xkbcommon.h>
-
- #include "utils/utils.h"
- #include "utils/nsoption.h"
-@@ -831,170 +832,123 @@ static int
- fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- {
- struct gui_window *gw = cbi->context;
-- static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
-- int ucs4 = -1;
-+ xkb_keysym_t sym = cbi->event->value.xkb.sym;
-+ enum nsfb_mod_e mods = cbi->event->value.xkb.mod;
-+ uint32_t key;
-
-- LOG("got value %d", cbi->event->value.keycode);
--
-- switch (cbi->event->type) {
-- case NSFB_EVENT_KEY_DOWN:
-- switch (cbi->event->value.keycode) {
--
-- case NSFB_KEY_DELETE:
-- browser_window_key_press(gw->bw, NS_KEY_DELETE_RIGHT);
-- break;
-+ if (cbi->event->type != NSFB_EVENT_XKB_KEY_DOWN)
-+ return 0;
-
-- case NSFB_KEY_PAGEUP:
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_PAGE_UP) == false)
-- widget_scroll_y(gw, -fbtk_get_height(
-- gw->browser), false);
-- break;
-+ LOG("got value %d", cbi->event->value.xkb.sym);
-
-- case NSFB_KEY_PAGEDOWN:
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_PAGE_DOWN) == false)
-- widget_scroll_y(gw, fbtk_get_height(
-- gw->browser), false);
-- break;
-+ switch (sym) {
-+ case XKB_KEY_Delete:
-+ browser_window_key_press(gw->bw, NS_KEY_DELETE_RIGHT);
-+ break;
-
-- case NSFB_KEY_RIGHT:
-- if (modifier & FBTK_MOD_RCTRL ||
-- modifier & FBTK_MOD_LCTRL) {
-- /* CTRL held */
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_LINE_END) == false)
-- widget_scroll_x(gw, INT_MAX, true);
--
-- } else if (modifier & FBTK_MOD_RSHIFT ||
-- modifier & FBTK_MOD_LSHIFT) {
-- /* SHIFT held */
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_WORD_RIGHT) == false)
-- widget_scroll_x(gw, fbtk_get_width(
-- gw->browser), false);
-+ case XKB_KEY_Page_Up:
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_PAGE_UP) == false)
-+ widget_scroll_y(gw, -fbtk_get_height(
-+ gw->browser), false);
-+ break;
-
-- } else {
-- /* no modifier */
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_RIGHT) == false)
-- widget_scroll_x(gw, 100, false);
-- }
-- break;
-+ case XKB_KEY_Page_Down:
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_PAGE_DOWN) == false)
-+ widget_scroll_y(gw, fbtk_get_height(
-+ gw->browser), false);
-+ break;
-
-- case NSFB_KEY_LEFT:
-- if (modifier & FBTK_MOD_RCTRL ||
-- modifier & FBTK_MOD_LCTRL) {
-- /* CTRL held */
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_LINE_START) == false)
-- widget_scroll_x(gw, 0, true);
--
-- } else if (modifier & FBTK_MOD_RSHIFT ||
-- modifier & FBTK_MOD_LSHIFT) {
-- /* SHIFT held */
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_WORD_LEFT) == false)
-- widget_scroll_x(gw, -fbtk_get_width(
-- gw->browser), false);
-+ case XKB_KEY_Right:
-+ if (mods & NSFB_MOD_CTRL) {
-+ /* CTRL held */
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_LINE_END) == false)
-+ widget_scroll_x(gw, INT_MAX, true);
-
-- } else {
-- /* no modifier */
-- if (browser_window_key_press(gw->bw,
-- NS_KEY_LEFT) == false)
-- widget_scroll_x(gw, -100, false);
-- }
-- break;
-+ } else if (mods & NSFB_MOD_SHIFT) {
-+ /* SHIFT held */
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_WORD_RIGHT) == false)
-+ widget_scroll_x(gw, fbtk_get_width(
-+ gw->browser), false);
-
-- case NSFB_KEY_UP:
-+ } else {
-+ /* no modifier */
- if (browser_window_key_press(gw->bw,
-- NS_KEY_UP) == false)
-- widget_scroll_y(gw, -100, false);
-- break;
-+ NS_KEY_RIGHT) == false)
-+ widget_scroll_x(gw, 100, false);
-+ }
-+ break;
-
-- case NSFB_KEY_DOWN:
-+ case XKB_KEY_Left:
-+ if (mods & NSFB_MOD_CTRL) {
-+ /* CTRL held */
- if (browser_window_key_press(gw->bw,
-- NS_KEY_DOWN) == false)
-- widget_scroll_y(gw, 100, false);
-- break;
-+ NS_KEY_LINE_START) == false)
-+ widget_scroll_x(gw, 0, true);
-
-- case NSFB_KEY_RSHIFT:
-- modifier |= FBTK_MOD_RSHIFT;
-- break;
-+ } else if (mods & NSFB_MOD_SHIFT) {
-+ /* SHIFT held */
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_WORD_LEFT) == false)
-+ widget_scroll_x(gw, -fbtk_get_width(
-+ gw->browser), false);
-
-- case NSFB_KEY_LSHIFT:
-- modifier |= FBTK_MOD_LSHIFT;
-- break;
-+ } else {
-+ /* no modifier */
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_LEFT) == false)
-+ widget_scroll_x(gw, -100, false);
-+ }
-+ break;
-
-- case NSFB_KEY_RCTRL:
-- modifier |= FBTK_MOD_RCTRL;
-- break;
-+ case XKB_KEY_Up:
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_UP) == false)
-+ widget_scroll_y(gw, -100, false);
-+ break;
-
-- case NSFB_KEY_LCTRL:
-- modifier |= FBTK_MOD_LCTRL;
-- break;
-+ case XKB_KEY_Down:
-+ if (browser_window_key_press(gw->bw,
-+ NS_KEY_DOWN) == false)
-+ widget_scroll_y(gw, 100, false);
-+ break;
-
-- case NSFB_KEY_y:
-- case NSFB_KEY_z:
-- if (cbi->event->value.keycode == NSFB_KEY_z &&
-- (modifier & FBTK_MOD_RCTRL ||
-- modifier & FBTK_MOD_LCTRL) &&
-- (modifier & FBTK_MOD_RSHIFT ||
-- modifier & FBTK_MOD_LSHIFT)) {
-- /* Z pressed with CTRL and SHIFT held */
-- browser_window_key_press(gw->bw, NS_KEY_REDO);
-+ default:
-+ if (mods & NSFB_MOD_CTRL) {
-+ switch (sym) {
-+ case XKB_KEY_a:
-+ key = NS_KEY_SELECT_ALL;
- break;
--
-- } else if (cbi->event->value.keycode == NSFB_KEY_z &&
-- (modifier & FBTK_MOD_RCTRL ||
-- modifier & FBTK_MOD_LCTRL)) {
-- /* Z pressed with CTRL held */
-- browser_window_key_press(gw->bw, NS_KEY_UNDO);
-+ case XKB_KEY_c:
-+ key = NS_KEY_COPY_SELECTION;
- break;
--
-- } else if (cbi->event->value.keycode == NSFB_KEY_y &&
-- (modifier & FBTK_MOD_RCTRL ||
-- modifier & FBTK_MOD_LCTRL)) {
-- /* Y pressed with CTRL held */
-- browser_window_key_press(gw->bw, NS_KEY_REDO);
-+ case XKB_KEY_u:
-+ key = NS_KEY_DELETE_LINE;
-+ break;
-+ case XKB_KEY_v:
-+ key = NS_KEY_PASTE;
-+ break;
-+ case XKB_KEY_x:
-+ key = NS_KEY_CUT_SELECTION;
-+ break;
-+ case XKB_KEY_y:
-+ key = NS_KEY_REDO;
-+ break;
-+ case XKB_KEY_z:
-+ key = mods & NSFB_MOD_SHIFT ? NS_KEY_REDO : NS_KEY_UNDO;
-+ break;
-+ default:
-+ key = 0;
- break;
- }
-- /* Z or Y pressed but not undo or redo;
-- * Fall through to default handling */
--
-- default:
-- ucs4 = fbtk_keycode_to_ucs4(cbi->event->value.keycode,
-- modifier);
-- if (ucs4 != -1)
-- browser_window_key_press(gw->bw, ucs4);
-- break;
-- }
-- break;
--
-- case NSFB_EVENT_KEY_UP:
-- switch (cbi->event->value.keycode) {
-- case NSFB_KEY_RSHIFT:
-- modifier &= ~FBTK_MOD_RSHIFT;
-- break;
--
-- case NSFB_KEY_LSHIFT:
-- modifier &= ~FBTK_MOD_LSHIFT;
-- break;
--
-- case NSFB_KEY_RCTRL:
-- modifier &= ~FBTK_MOD_RCTRL;
-- break;
--
-- case NSFB_KEY_LCTRL:
-- modifier &= ~FBTK_MOD_LCTRL;
-- break;
--
-- default:
-- break;
- }
-- break;
--
-- default:
-+ if (key == 0)
-+ key = xkb_keysym_to_utf32(cbi->event->value.xkb.sym);
-+ if (key != 0)
-+ browser_window_key_press(gw->bw, key);
- break;
- }
-
---
-2.11.0
-
diff --git a/pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch b/pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch
deleted file mode 100644
index 8b2e069e..00000000
--- a/pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch
+++ /dev/null
@@ -1,225 +0,0 @@
-From f035892771ed294255b5516547419704827c8f19 Mon Sep 17 00:00:00 2001
-From: Michael Forney <mforney@mforney.org>
-Date: Fri, 30 Dec 2016 01:50:18 -0800
-Subject: [PATCH] framebuffer: Use cursor shapes
-
----
- frontends/framebuffer/bitmap.c | 1 +
- frontends/framebuffer/fbtk/bitmap.c | 4 +++-
- frontends/framebuffer/fbtk/fbtk.c | 12 +++---------
- frontends/framebuffer/fbtk/text.c | 4 +++-
- frontends/framebuffer/framebuffer.c | 6 ++++++
- frontends/framebuffer/framebuffer.h | 1 +
- frontends/framebuffer/gui.c | 19 ++++++++++---------
- frontends/framebuffer/localhistory.c | 1 +
- 8 files changed, 28 insertions(+), 20 deletions(-)
-
-diff --git a/frontends/framebuffer/bitmap.c b/frontends/framebuffer/bitmap.c
-index 027e0122b..f3f6a6406 100644
---- a/frontends/framebuffer/bitmap.c
-+++ b/frontends/framebuffer/bitmap.c
-@@ -27,6 +27,7 @@
- #include <assert.h>
- #include <libnsfb.h>
- #include <libnsfb_plot.h>
-+#include <libnsfb_cursor.h>
-
- #include "utils/log.h"
- #include "utils/utils.h"
-diff --git a/frontends/framebuffer/fbtk/bitmap.c b/frontends/framebuffer/fbtk/bitmap.c
-index 759b626d9..40b2e6255 100644
---- a/frontends/framebuffer/fbtk/bitmap.c
-+++ b/frontends/framebuffer/fbtk/bitmap.c
-@@ -23,6 +23,7 @@
-
- #include <libnsfb.h>
- #include <libnsfb_plot.h>
-+#include <libnsfb_cursor.h>
-
- #include "netsurf/browser_window.h"
-
-@@ -114,6 +115,7 @@ fbtk_create_button(fbtk_widget_t *parent,
- fbtk_callback click,
- void *pw)
- {
-+ static enum nsfb_cursor_shape_e shape = NSFB_CURSOR_POINT;
- fbtk_widget_t *neww;
-
- neww = fbtk_widget_new(parent, FB_WIDGET_TYPE_BITMAP, x, y, width, height);
-@@ -124,7 +126,7 @@ fbtk_create_button(fbtk_widget_t *parent,
-
- fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_bitmap, NULL);
- fbtk_set_handler(neww, FBTK_CBT_CLICK, click, pw);
-- fbtk_set_handler(neww, FBTK_CBT_POINTERENTER, fbtk_set_ptr, &hand_image);
-+ fbtk_set_handler(neww, FBTK_CBT_POINTERENTER, fbtk_set_ptr, &shape);
-
- return neww;
- }
-diff --git a/frontends/framebuffer/fbtk/fbtk.c b/frontends/framebuffer/fbtk/fbtk.c
-index c63a6d8c9..65bf4c532 100644
---- a/frontends/framebuffer/fbtk/fbtk.c
-+++ b/frontends/framebuffer/fbtk/fbtk.c
-@@ -387,15 +387,9 @@ int
- fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- {
- fbtk_widget_t *root = fbtk_get_root_widget(widget);
-- struct fbtk_bitmap *bm = cbi->context;
--
-- nsfb_cursor_set(root->u.root.fb,
-- (nsfb_colour_t *)bm->pixdata,
-- bm->width,
-- bm->height,
-- bm->width,
-- bm->hot_x,
-- bm->hot_y);
-+ enum nsfb_cursor_shape_e *shape = cbi->context;
-+
-+ nsfb_cursor_shape_set(root->u.root.fb, *shape);
-
- return 0;
- }
-diff --git a/frontends/framebuffer/fbtk/text.c b/frontends/framebuffer/fbtk/text.c
-index 95333a52f..ec1d285c1 100644
---- a/frontends/framebuffer/fbtk/text.c
-+++ b/frontends/framebuffer/fbtk/text.c
-@@ -25,6 +25,7 @@
- #include <libnsfb.h>
- #include <libnsfb_plot.h>
- #include <libnsfb_plot_util.h>
-+#include <libnsfb_cursor.h>
- #include <libnsfb_event.h>
- #include <xkbcommon/xkbcommon.h>
-
-@@ -585,6 +586,7 @@ fbtk_create_text_button(fbtk_widget_t *parent,
- fbtk_callback click,
- void *pw)
- {
-+ static enum nsfb_cursor_shape_e shape = NSFB_CURSOR_POINT;
- fbtk_widget_t *neww;
-
- neww = fbtk_widget_new(parent, FB_WIDGET_TYPE_TEXT, x, y, width, height);
-@@ -597,7 +599,7 @@ fbtk_create_text_button(fbtk_widget_t *parent,
- fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_text_button, NULL);
- fbtk_set_handler(neww, FBTK_CBT_DESTROY, fb_destroy_text, NULL);
- fbtk_set_handler(neww, FBTK_CBT_CLICK, click, pw);
-- fbtk_set_handler(neww, FBTK_CBT_POINTERENTER, fbtk_set_ptr, &hand_image);
-+ fbtk_set_handler(neww, FBTK_CBT_POINTERENTER, fbtk_set_ptr, &shape);
-
- return neww;
- }
-diff --git a/frontends/framebuffer/framebuffer.c b/frontends/framebuffer/framebuffer.c
-index 74c72fe71..9344b8277 100644
---- a/frontends/framebuffer/framebuffer.c
-+++ b/frontends/framebuffer/framebuffer.c
-@@ -456,6 +456,12 @@ bool
- framebuffer_set_cursor(struct fbtk_bitmap *bm)
- {
- return nsfb_cursor_set(nsfb, (nsfb_colour_t *)bm->pixdata, bm->width, bm->height, bm->width, bm->hot_x, bm->hot_y);
-+}
-+
-+bool
-+framebuffer_set_cursor_shape(enum nsfb_cursor_shape_e shape)
-+{
-+ return nsfb_cursor_shape_set(nsfb, shape);
- }
-
- nsfb_t *framebuffer_set_surface(nsfb_t *new_nsfb)
-diff --git a/frontends/framebuffer/framebuffer.h b/frontends/framebuffer/framebuffer.h
-index d99049f52..e4050f51d 100644
---- a/frontends/framebuffer/framebuffer.h
-+++ b/frontends/framebuffer/framebuffer.h
-@@ -30,6 +30,7 @@ nsfb_t *framebuffer_initialise(const char *fename, int width, int height, int bp
- bool framebuffer_resize(nsfb_t *nsfb, int width, int height, int bpp);
- void framebuffer_finalise(void);
- bool framebuffer_set_cursor(struct fbtk_bitmap *bm);
-+bool framebuffer_set_cursor_shape(enum nsfb_cursor_shape_e shape);
-
- /** Set framebuffer surface to render into
- *
-diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
-index 6bf5152c0..2704f3dbf 100644
---- a/frontends/framebuffer/gui.c
-+++ b/frontends/framebuffer/gui.c
-@@ -27,6 +27,7 @@
-
- #include <libnsfb.h>
- #include <libnsfb_plot.h>
-+#include <libnsfb_cursor.h>
- #include <libnsfb_event.h>
- #include <xkbcommon/xkbcommon.h>
-
-@@ -1096,14 +1097,14 @@ fb_url_enter(void *pw, char *text)
- static int
- fb_url_move(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- {
-- framebuffer_set_cursor(&caret_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_CARET);
- return 0;
- }
-
- static int
- set_ptr_default_move(fbtk_widget_t *widget, fbtk_callback_info *cbi)
- {
-- framebuffer_set_cursor(&pointer_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_DEFAULT);
- return 0;
- }
-
-@@ -1851,27 +1852,27 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
- {
- switch (shape) {
- case GUI_POINTER_POINT:
-- framebuffer_set_cursor(&hand_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_POINT);
- break;
-
- case GUI_POINTER_CARET:
-- framebuffer_set_cursor(&caret_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_CARET);
- break;
-
- case GUI_POINTER_MENU:
-- framebuffer_set_cursor(&menu_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_MENU);
- break;
-
- case GUI_POINTER_PROGRESS:
-- framebuffer_set_cursor(&progress_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_PROGRESS);
- break;
-
- case GUI_POINTER_MOVE:
-- framebuffer_set_cursor(&move_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_MOVE);
- break;
-
- default:
-- framebuffer_set_cursor(&pointer_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_DEFAULT);
- break;
- }
- }
-@@ -2145,7 +2146,7 @@ main(int argc, char** argv)
- if (nsfb == NULL)
- die("Unable to initialise framebuffer");
-
-- framebuffer_set_cursor(&pointer_image);
-+ framebuffer_set_cursor_shape(NSFB_CURSOR_DEFAULT);
-
- if (fb_font_init() == false)
- die("Unable to initialise the font system");
-diff --git a/frontends/framebuffer/localhistory.c b/frontends/framebuffer/localhistory.c
-index 3192f0747..97d0f2036 100644
---- a/frontends/framebuffer/localhistory.c
-+++ b/frontends/framebuffer/localhistory.c
-@@ -22,6 +22,7 @@
-
- #include <libnsfb.h>
- #include <libnsfb_plot.h>
-+#include <libnsfb_cursor.h>
- #include <libnsfb_event.h>
-
- #include "desktop/browser_history.h"
---
-2.11.0
-
diff --git a/pkg/netsurf/rev b/pkg/netsurf/rev
index 00750edc..b8626c4c 100644
--- a/pkg/netsurf/rev
+++ b/pkg/netsurf/rev
@@ -1 +1 @@
-3
+4
diff --git a/pkg/netsurf/src b/pkg/netsurf/src
-Subproject c56ecfd924b16d15bf74385c4d556a6b7002e8a
+Subproject f6b7a2a0125038f7418184b7fc7e672b4f95128