summaryrefslogtreecommitdiff
path: root/pkg/netsurf
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2016-12-30 02:15:11 -0800
committerMichael Forney <mforney@mforney.org>2016-12-30 02:15:11 -0800
commitace6bd2fc1e1e2075da654b8a8b5cd342425ae33 (patch)
tree606daf0ff847d10a43897003b7118117678c8ad0 /pkg/netsurf
parent8fd1326a9ae8bbdd23de9ec772fd18831d134bd7 (diff)
netsurf: Implement cursor changing
Diffstat (limited to 'pkg/netsurf')
-rw-r--r--pkg/netsurf/libnsfb/gen.rc2
-rw-r--r--pkg/netsurf/libnsfb/patch/0002-Add-cursor_shape-surface-method.patch106
-rw-r--r--pkg/netsurf/libnsfb/rev2
-rw-r--r--pkg/netsurf/libnsfb/wl.c124
-rw-r--r--pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch154
-rw-r--r--pkg/netsurf/rev2
6 files changed, 386 insertions, 4 deletions
diff --git a/pkg/netsurf/libnsfb/gen.rc b/pkg/netsurf/libnsfb/gen.rc
index 3d63e893..b760b4ce 100644
--- a/pkg/netsurf/libnsfb/gen.rc
+++ b/pkg/netsurf/libnsfb/gen.rc
@@ -18,7 +18,7 @@ lib libnsfb.a src/^(\
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\
+ wayland/^(libwayland-client.a.d libwayland-cursor.a)\
wayland-protocols/xdg-shell-unstable-v5-protocol.c.o\
libxkbcommon/libxkbcommon.a\
)
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
new file mode 100644
index 00000000..5dc8d5e1
--- /dev/null
+++ b/pkg/netsurf/libnsfb/patch/0002-Add-cursor_shape-surface-method.patch
@@ -0,0 +1,106 @@
+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
index d00491fd..0cfbf088 100644
--- a/pkg/netsurf/libnsfb/rev
+++ b/pkg/netsurf/libnsfb/rev
@@ -1 +1 @@
-1
+2
diff --git a/pkg/netsurf/libnsfb/wl.c b/pkg/netsurf/libnsfb/wl.c
index f443e829..35de2080 100644
--- a/pkg/netsurf/libnsfb/wl.c
+++ b/pkg/netsurf/libnsfb/wl.c
@@ -12,10 +12,13 @@
#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"
@@ -76,6 +79,13 @@ struct wlstate {
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 *
@@ -274,11 +284,28 @@ static struct wl_keyboard_listener keyboard_listener = {
};
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;
@@ -626,14 +653,21 @@ wayland_initialise(nsfb_t *nsfb)
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;
@@ -667,6 +701,8 @@ wayland_finalise(nsfb_t *nsfb)
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);
@@ -778,12 +814,98 @@ wayland_update(nsfb_t *nsfb, nsfb_bbox_t *box)
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/0006-framebuffer-Use-cursor-shapes.patch b/pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch
new file mode 100644
index 00000000..3148ac7b
--- /dev/null
+++ b/pkg/netsurf/patch/0006-framebuffer-Use-cursor-shapes.patch
@@ -0,0 +1,154 @@
+From 735dc3f45505fffbc7c621dfef4adc7c997efcd4 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/text.c | 1 +
+ frontends/framebuffer/framebuffer.c | 6 ++++++
+ frontends/framebuffer/framebuffer.h | 1 +
+ frontends/framebuffer/gui.c | 19 ++++++++++---------
+ frontends/framebuffer/localhistory.c | 1 +
+ 6 files changed, 20 insertions(+), 9 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/text.c b/frontends/framebuffer/fbtk/text.c
+index 95333a52f..90e0ed9ab 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>
+
+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 d00491fd..0cfbf088 100644
--- a/pkg/netsurf/rev
+++ b/pkg/netsurf/rev
@@ -1 +1 @@
-1
+2