1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
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
|