From f035892771ed294255b5516547419704827c8f19 Mon Sep 17 00:00:00 2001 From: Michael Forney 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 #include #include +#include #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 #include +#include #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 #include #include +#include #include #include @@ -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 #include +#include #include #include @@ -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 #include +#include #include #include "desktop/browser_history.h" -- 2.11.0