netsurf: branch master updated. 40a754a362723d332512c59beaad089c740e5ce6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/40a754a362723d332512c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/40a754a362723d332512c59...
...tree http://git.netsurf-browser.org/netsurf.git/tree/40a754a362723d332512c59be...
The branch, master has been updated
via 40a754a362723d332512c59beaad089c740e5ce6 (commit)
from ffa3e6bf3565143c3bda79a0198fe47af5c00276 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/40a754a362723d33251...
commit 40a754a362723d332512c59beaad089c740e5ce6
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Convert move pointer during build and use it for page drag-scroll.
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index af5891b..3992aff 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -101,6 +101,7 @@ FB_IMAGE_hand_image := framebuffer/res/pointers/point.png
FB_IMAGE_caret_image := framebuffer/res/pointers/caret.png
FB_IMAGE_menu_image := framebuffer/res/pointers/menu.png
FB_IMAGE_progress_image := framebuffer/res/pointers/progress.png
+FB_IMAGE_move_image := framebuffer/res/pointers/move.png
FB_IMAGE_throbber0 := framebuffer/res/throbber/throbber0.png
FB_IMAGE_throbber1 := framebuffer/res/throbber/throbber1.png
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index f7b6533..b098702 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -653,6 +653,7 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (gui_drag.state == GUI_DRAG_DRAG) {
/* End of a drag, rather than click */
gui_drag.state = GUI_DRAG_NONE;
+ framebuffer_set_cursor(&pointer_image);
break;
}
/* This is a click;
@@ -1529,6 +1530,10 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
framebuffer_set_cursor(&progress_image);
break;
+ case GUI_POINTER_MOVE:
+ framebuffer_set_cursor(&move_image);
+ break;
+
default:
framebuffer_set_cursor(&pointer_image);
break;
diff --git a/framebuffer/image_data.h b/framebuffer/image_data.h
index 5ebac91..a6d8b6a 100644
--- a/framebuffer/image_data.h
+++ b/framebuffer/image_data.h
@@ -42,6 +42,7 @@ extern struct fbtk_bitmap pointer_image;
extern struct fbtk_bitmap hand_image;
extern struct fbtk_bitmap caret_image;
extern struct fbtk_bitmap menu_image;
+extern struct fbtk_bitmap move_image;
extern struct fbtk_bitmap progress_image;
extern struct fbtk_bitmap throbber0;
-----------------------------------------------------------------------
Summary of changes:
framebuffer/Makefile.target | 1 +
framebuffer/gui.c | 5 +++++
framebuffer/image_data.h | 1 +
3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index af5891b..3992aff 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -101,6 +101,7 @@ FB_IMAGE_hand_image := framebuffer/res/pointers/point.png
FB_IMAGE_caret_image := framebuffer/res/pointers/caret.png
FB_IMAGE_menu_image := framebuffer/res/pointers/menu.png
FB_IMAGE_progress_image := framebuffer/res/pointers/progress.png
+FB_IMAGE_move_image := framebuffer/res/pointers/move.png
FB_IMAGE_throbber0 := framebuffer/res/throbber/throbber0.png
FB_IMAGE_throbber1 := framebuffer/res/throbber/throbber1.png
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index f7b6533..b098702 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -653,6 +653,7 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (gui_drag.state == GUI_DRAG_DRAG) {
/* End of a drag, rather than click */
gui_drag.state = GUI_DRAG_NONE;
+ framebuffer_set_cursor(&pointer_image);
break;
}
/* This is a click;
@@ -1529,6 +1530,10 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
framebuffer_set_cursor(&progress_image);
break;
+ case GUI_POINTER_MOVE:
+ framebuffer_set_cursor(&move_image);
+ break;
+
default:
framebuffer_set_cursor(&pointer_image);
break;
diff --git a/framebuffer/image_data.h b/framebuffer/image_data.h
index 5ebac91..a6d8b6a 100644
--- a/framebuffer/image_data.h
+++ b/framebuffer/image_data.h
@@ -42,6 +42,7 @@ extern struct fbtk_bitmap pointer_image;
extern struct fbtk_bitmap hand_image;
extern struct fbtk_bitmap caret_image;
extern struct fbtk_bitmap menu_image;
+extern struct fbtk_bitmap move_image;
extern struct fbtk_bitmap progress_image;
extern struct fbtk_bitmap throbber0;
--
NetSurf Browser
10 years, 8 months
netsurf: branch master updated. ffa3e6bf3565143c3bda79a0198fe47af5c00276
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ffa3e6bf3565143c3bda7...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ffa3e6bf3565143c3bda79a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ffa3e6bf3565143c3bda79a01...
The branch, master has been updated
via ffa3e6bf3565143c3bda79a0198fe47af5c00276 (commit)
via 30bc438ab00483ce3be7fc994a2739dfbf486c5a (commit)
from 6bbae1f2284a7d52daf96ad30e1519600ae5493b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ffa3e6bf3565143c3bd...
commit ffa3e6bf3565143c3bda79a0198fe47af5c00276
Merge: 30bc438 6bbae1f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/30bc438ab00483ce3be...
commit 30bc438ab00483ce3be7fc994a2739dfbf486c5a
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Pass drags to core. Enables page drag-scrolling, text selection, frames scrollbars, etc.
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index c451bc8..f7b6533 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -82,6 +82,17 @@ struct browser_widget_s {
int panx, pany; /**< Panning required. */
};
+static struct gui_drag {
+ enum state {
+ GUI_DRAG_NONE,
+ GUI_DRAG_PRESSED,
+ GUI_DRAG_DRAG
+ } state;
+ int button;
+ int x;
+ int y;
+} gui_drag;
+
/* queue a redraw operation, co-ordinates are relative to the window */
static void
@@ -585,7 +596,9 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
- float scale;
+ float scale = gw->bw->scale;
+ int x = (cbi->x + bwidget->scrollx) / scale;
+ int y = (cbi->y + bwidget->scrolly) / scale;
if (cbi->event->type != NSFB_EVENT_KEY_DOWN &&
cbi->event->type != NSFB_EVENT_KEY_UP)
@@ -597,37 +610,33 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_DOWN:
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
- scale = gw->bw->scale;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_PRESS_1,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_PRESS_1, x, y);
+ gui_drag.state = GUI_DRAG_PRESSED;
+ gui_drag.button = 1;
+ gui_drag.x = x;
+ gui_drag.y = y;
break;
case NSFB_KEY_MOUSE_3:
- scale = gw->bw->scale;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_PRESS_2,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_PRESS_2, x, y);
+ gui_drag.state = GUI_DRAG_PRESSED;
+ gui_drag.button = 2;
+ gui_drag.x = x;
+ gui_drag.y = y;
break;
case NSFB_KEY_MOUSE_4:
/* scroll up */
- scale = gw->bw->scale;
- if (browser_window_scroll_at_point(gw->bw,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale,
+ if (browser_window_scroll_at_point(gw->bw, x, y,
0, -100) == false)
widget_scroll_y(gw, -100, false);
break;
case NSFB_KEY_MOUSE_5:
/* scroll down */
- scale = gw->bw->scale;
- if (browser_window_scroll_at_point(gw->bw,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale,
+ if (browser_window_scroll_at_point(gw->bw, x, y,
0, 100) == false)
widget_scroll_y(gw, 100, false);
break;
@@ -641,19 +650,29 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_UP:
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
- scale = gw->bw->scale;
+ if (gui_drag.state == GUI_DRAG_DRAG) {
+ /* End of a drag, rather than click */
+ gui_drag.state = GUI_DRAG_NONE;
+ break;
+ }
+ /* This is a click;
+ * clear PRESSED state and pass to core */
+ gui_drag.state = GUI_DRAG_NONE;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_CLICK_1,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_CLICK_1, x, y);
break;
case NSFB_KEY_MOUSE_3:
- scale = gw->bw->scale;
+ if (gui_drag.state == GUI_DRAG_DRAG) {
+ /* End of a drag, rather than click */
+ gui_drag.state = GUI_DRAG_NONE;
+ break;
+ }
+ /* This is a click;
+ * clear PRESSED state and pass to core */
+ gui_drag.state = GUI_DRAG_NONE;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_CLICK_2,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_CLICK_2, x, y);
break;
default:
@@ -673,12 +692,39 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
static int
fb_browser_window_move(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
+ browser_mouse_state mouse = 0;
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
+ int x = (cbi->x + bwidget->scrollx) / gw->bw->scale;
+ int y = (cbi->y + bwidget->scrolly) / gw->bw->scale;
+
+ if (gui_drag.state == GUI_DRAG_PRESSED &&
+ (abs(x - gui_drag.x) < 5 ||
+ abs(y - gui_drag.y) < 5)) {
+ /* Drag started */
+ if (gui_drag.button == 1) {
+ browser_window_mouse_click(gw->bw,
+ BROWSER_MOUSE_DRAG_1,
+ gui_drag.x, gui_drag.y);
+ } else {
+ browser_window_mouse_click(gw->bw,
+ BROWSER_MOUSE_DRAG_2,
+ gui_drag.x, gui_drag.y);
+ }
+ gui_drag.state = GUI_DRAG_DRAG;
+ }
+
+ if (gui_drag.state == GUI_DRAG_DRAG) {
+ /* set up mouse state */
+ mouse |= BROWSER_MOUSE_DRAG_ON;
+
+ if (gui_drag.button == 1)
+ mouse |= BROWSER_MOUSE_HOLDING_1;
+ else
+ mouse |= BROWSER_MOUSE_HOLDING_2;
+ }
- browser_window_mouse_track(gw->bw, 0,
- (cbi->x + bwidget->scrollx) / gw->bw->scale,
- (cbi->y + bwidget->scrolly) / gw->bw->scale);
+ browser_window_mouse_track(gw->bw, mouse, x, y);
return 0;
}
-----------------------------------------------------------------------
Summary of changes:
framebuffer/gui.c | 102 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 74 insertions(+), 28 deletions(-)
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index c451bc8..f7b6533 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -82,6 +82,17 @@ struct browser_widget_s {
int panx, pany; /**< Panning required. */
};
+static struct gui_drag {
+ enum state {
+ GUI_DRAG_NONE,
+ GUI_DRAG_PRESSED,
+ GUI_DRAG_DRAG
+ } state;
+ int button;
+ int x;
+ int y;
+} gui_drag;
+
/* queue a redraw operation, co-ordinates are relative to the window */
static void
@@ -585,7 +596,9 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
- float scale;
+ float scale = gw->bw->scale;
+ int x = (cbi->x + bwidget->scrollx) / scale;
+ int y = (cbi->y + bwidget->scrolly) / scale;
if (cbi->event->type != NSFB_EVENT_KEY_DOWN &&
cbi->event->type != NSFB_EVENT_KEY_UP)
@@ -597,37 +610,33 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_DOWN:
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
- scale = gw->bw->scale;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_PRESS_1,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_PRESS_1, x, y);
+ gui_drag.state = GUI_DRAG_PRESSED;
+ gui_drag.button = 1;
+ gui_drag.x = x;
+ gui_drag.y = y;
break;
case NSFB_KEY_MOUSE_3:
- scale = gw->bw->scale;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_PRESS_2,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_PRESS_2, x, y);
+ gui_drag.state = GUI_DRAG_PRESSED;
+ gui_drag.button = 2;
+ gui_drag.x = x;
+ gui_drag.y = y;
break;
case NSFB_KEY_MOUSE_4:
/* scroll up */
- scale = gw->bw->scale;
- if (browser_window_scroll_at_point(gw->bw,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale,
+ if (browser_window_scroll_at_point(gw->bw, x, y,
0, -100) == false)
widget_scroll_y(gw, -100, false);
break;
case NSFB_KEY_MOUSE_5:
/* scroll down */
- scale = gw->bw->scale;
- if (browser_window_scroll_at_point(gw->bw,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale,
+ if (browser_window_scroll_at_point(gw->bw, x, y,
0, 100) == false)
widget_scroll_y(gw, 100, false);
break;
@@ -641,19 +650,29 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_UP:
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
- scale = gw->bw->scale;
+ if (gui_drag.state == GUI_DRAG_DRAG) {
+ /* End of a drag, rather than click */
+ gui_drag.state = GUI_DRAG_NONE;
+ break;
+ }
+ /* This is a click;
+ * clear PRESSED state and pass to core */
+ gui_drag.state = GUI_DRAG_NONE;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_CLICK_1,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_CLICK_1, x, y);
break;
case NSFB_KEY_MOUSE_3:
- scale = gw->bw->scale;
+ if (gui_drag.state == GUI_DRAG_DRAG) {
+ /* End of a drag, rather than click */
+ gui_drag.state = GUI_DRAG_NONE;
+ break;
+ }
+ /* This is a click;
+ * clear PRESSED state and pass to core */
+ gui_drag.state = GUI_DRAG_NONE;
browser_window_mouse_click(gw->bw,
- BROWSER_MOUSE_CLICK_2,
- (cbi->x + bwidget->scrollx) / scale,
- (cbi->y + bwidget->scrolly) / scale);
+ BROWSER_MOUSE_CLICK_2, x, y);
break;
default:
@@ -673,12 +692,39 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
static int
fb_browser_window_move(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
+ browser_mouse_state mouse = 0;
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
+ int x = (cbi->x + bwidget->scrollx) / gw->bw->scale;
+ int y = (cbi->y + bwidget->scrolly) / gw->bw->scale;
+
+ if (gui_drag.state == GUI_DRAG_PRESSED &&
+ (abs(x - gui_drag.x) < 5 ||
+ abs(y - gui_drag.y) < 5)) {
+ /* Drag started */
+ if (gui_drag.button == 1) {
+ browser_window_mouse_click(gw->bw,
+ BROWSER_MOUSE_DRAG_1,
+ gui_drag.x, gui_drag.y);
+ } else {
+ browser_window_mouse_click(gw->bw,
+ BROWSER_MOUSE_DRAG_2,
+ gui_drag.x, gui_drag.y);
+ }
+ gui_drag.state = GUI_DRAG_DRAG;
+ }
+
+ if (gui_drag.state == GUI_DRAG_DRAG) {
+ /* set up mouse state */
+ mouse |= BROWSER_MOUSE_DRAG_ON;
+
+ if (gui_drag.button == 1)
+ mouse |= BROWSER_MOUSE_HOLDING_1;
+ else
+ mouse |= BROWSER_MOUSE_HOLDING_2;
+ }
- browser_window_mouse_track(gw->bw, 0,
- (cbi->x + bwidget->scrollx) / gw->bw->scale,
- (cbi->y + bwidget->scrolly) / gw->bw->scale);
+ browser_window_mouse_track(gw->bw, mouse, x, y);
return 0;
}
--
NetSurf Browser
10 years, 8 months
netsurf: branch master updated. 6bbae1f2284a7d52daf96ad30e1519600ae5493b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6bbae1f2284a7d52daf96...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6bbae1f2284a7d52daf96ad...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6bbae1f2284a7d52daf96ad30...
The branch, master has been updated
via 6bbae1f2284a7d52daf96ad30e1519600ae5493b (commit)
from b238791002697efbda1ece31985ca15331511fa8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/6bbae1f2284a7d52daf...
commit 6bbae1f2284a7d52daf96ad30e1519600ae5493b
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add document IDL and test for geteleemntbyid
diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
index bb5019c..c54d2f6 100644
--- a/javascript/jsapi/document.c
+++ b/javascript/jsapi/document.c
@@ -24,6 +24,80 @@
#include "render/html_internal.h"
#include "utils/log.h"
+/* IDL from http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html
+
+
+interface Document : Node {
+ // Modified in DOM Level 3:
+ readonly attribute DocumentType doctype;
+ readonly attribute DOMImplementation implementation;
+ readonly attribute Element documentElement;
+ Element createElement(in DOMString tagName)
+ raises(DOMException);
+ DocumentFragment createDocumentFragment();
+ Text createTextNode(in DOMString data);
+ Comment createComment(in DOMString data);
+ CDATASection createCDATASection(in DOMString data)
+ raises(DOMException);
+ ProcessingInstruction createProcessingInstruction(in DOMString target,
+ in DOMString data)
+ raises(DOMException);
+ Attr createAttribute(in DOMString name)
+ raises(DOMException);
+ EntityReference createEntityReference(in DOMString name)
+ raises(DOMException);
+ NodeList getElementsByTagName(in DOMString tagname);
+ // Introduced in DOM Level 2:
+ Node importNode(in Node importedNode,
+ in boolean deep)
+ raises(DOMException);
+ // Introduced in DOM Level 2:
+ Element createElementNS(in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+ // Introduced in DOM Level 2:
+ Attr createAttributeNS(in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+ // Introduced in DOM Level 2:
+ NodeList getElementsByTagNameNS(in DOMString namespaceURI,
+ in DOMString localName);
+ // Introduced in DOM Level 2:
+ Element getElementById(in DOMString elementId);
+ // Introduced in DOM Level 3:
+ readonly attribute DOMString inputEncoding;
+ // Introduced in DOM Level 3:
+ readonly attribute DOMString xmlEncoding;
+ // Introduced in DOM Level 3:
+ attribute boolean xmlStandalone;
+ // raises(DOMException) on setting
+
+ // Introduced in DOM Level 3:
+ attribute DOMString xmlVersion;
+ // raises(DOMException) on setting
+
+ // Introduced in DOM Level 3:
+ attribute boolean strictErrorChecking;
+ // Introduced in DOM Level 3:
+ attribute DOMString documentURI;
+ // Introduced in DOM Level 3:
+ Node adoptNode(in Node source)
+ raises(DOMException);
+ // Introduced in DOM Level 3:
+ readonly attribute DOMConfiguration domConfig;
+ // Introduced in DOM Level 3:
+ void normalizeDocument();
+ // Introduced in DOM Level 3:
+ Node renameNode(in Node n,
+ in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+};
+
+
+ */
+
+
static JSClass jsclass_document =
{
"document",
@@ -39,6 +113,12 @@ static JSClass jsclass_document =
JSCLASS_NO_OPTIONAL_MEMBERS
};
+static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
+{
+ JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
+
+ return JS_TRUE;
+}
static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
{
@@ -67,6 +147,7 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
static JSFunctionSpec jsfunctions_document[] = {
JSAPI_FS(write, 1, 0),
+ JSAPI_FS(getElementById, 1, 0),
JSAPI_FS_END
};
diff --git a/test/js/index.html b/test/js/index.html
index f7ce2f3..6bb010c 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -10,7 +10,9 @@
<li><a href="inline-doc-write-simple.html">Simple docuemnt write</a></li>
<li><a href="inline-doc-write.html">Script within inline script</a></li>
<li><a href="sync-script.html">External syncronous script</a></li>
+<li><a href="sync-script-err.html">External syncronous script with missing js file</a></li>
<li><a href="sync-script-css.html">External syncronous script (with css)</a></li>
+<li><a href="inline-innerhtml.html">Inline script innerHtml test</a></li>
</ul>
diff --git a/test/js/inline-innerhtml.html b/test/js/inline-innerhtml.html
new file mode 100644
index 0000000..6bfd660
--- /dev/null
+++ b/test/js/inline-innerhtml.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>Inline Script innerHTML Test</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Inline Script innerHTML Test</h1>
+<p>Before</p>
+<p id="demo">some text you should never see</p>
+<script type="text/javascript">
+document.getElementById("demo").innerHTML="text inserted by script";
+</script>
+<p>Afterwards</p>
+</body>
+</html>
diff --git a/test/js/sync-script-css.html b/test/js/sync-script-css.html
index 55840f2..ecba5be 100644
--- a/test/js/sync-script-css.html
+++ b/test/js/sync-script-css.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Sync script Test (css0</h1>
+<h1>Sync script Test (css)</h1>
<p>Before</p>
<script src="tst.js"></script>
<p>Afterwards</p>
diff --git a/test/js/sync-script-err.html b/test/js/sync-script-err.html
new file mode 100644
index 0000000..68e77ba
--- /dev/null
+++ b/test/js/sync-script-err.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>Sync script Test with bad src</title>
+</head>
+<body>
+<h1>Sync script Test with bad src</h1>
+<p>Before</p>
+<script src="notthere.js"></script>
+<script src="tst.js"></script>
+<p>Afterwards</p>
+</body>
+</html>
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/document.c | 81 +++++++++++++++++++++++++++++++++++++++++
test/js/index.html | 2 +
test/js/inline-innerhtml.html | 15 ++++++++
test/js/sync-script-css.html | 2 +-
test/js/sync-script-err.html | 12 ++++++
5 files changed, 111 insertions(+), 1 deletions(-)
create mode 100644 test/js/inline-innerhtml.html
create mode 100644 test/js/sync-script-err.html
diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
index bb5019c..c54d2f6 100644
--- a/javascript/jsapi/document.c
+++ b/javascript/jsapi/document.c
@@ -24,6 +24,80 @@
#include "render/html_internal.h"
#include "utils/log.h"
+/* IDL from http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html
+
+
+interface Document : Node {
+ // Modified in DOM Level 3:
+ readonly attribute DocumentType doctype;
+ readonly attribute DOMImplementation implementation;
+ readonly attribute Element documentElement;
+ Element createElement(in DOMString tagName)
+ raises(DOMException);
+ DocumentFragment createDocumentFragment();
+ Text createTextNode(in DOMString data);
+ Comment createComment(in DOMString data);
+ CDATASection createCDATASection(in DOMString data)
+ raises(DOMException);
+ ProcessingInstruction createProcessingInstruction(in DOMString target,
+ in DOMString data)
+ raises(DOMException);
+ Attr createAttribute(in DOMString name)
+ raises(DOMException);
+ EntityReference createEntityReference(in DOMString name)
+ raises(DOMException);
+ NodeList getElementsByTagName(in DOMString tagname);
+ // Introduced in DOM Level 2:
+ Node importNode(in Node importedNode,
+ in boolean deep)
+ raises(DOMException);
+ // Introduced in DOM Level 2:
+ Element createElementNS(in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+ // Introduced in DOM Level 2:
+ Attr createAttributeNS(in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+ // Introduced in DOM Level 2:
+ NodeList getElementsByTagNameNS(in DOMString namespaceURI,
+ in DOMString localName);
+ // Introduced in DOM Level 2:
+ Element getElementById(in DOMString elementId);
+ // Introduced in DOM Level 3:
+ readonly attribute DOMString inputEncoding;
+ // Introduced in DOM Level 3:
+ readonly attribute DOMString xmlEncoding;
+ // Introduced in DOM Level 3:
+ attribute boolean xmlStandalone;
+ // raises(DOMException) on setting
+
+ // Introduced in DOM Level 3:
+ attribute DOMString xmlVersion;
+ // raises(DOMException) on setting
+
+ // Introduced in DOM Level 3:
+ attribute boolean strictErrorChecking;
+ // Introduced in DOM Level 3:
+ attribute DOMString documentURI;
+ // Introduced in DOM Level 3:
+ Node adoptNode(in Node source)
+ raises(DOMException);
+ // Introduced in DOM Level 3:
+ readonly attribute DOMConfiguration domConfig;
+ // Introduced in DOM Level 3:
+ void normalizeDocument();
+ // Introduced in DOM Level 3:
+ Node renameNode(in Node n,
+ in DOMString namespaceURI,
+ in DOMString qualifiedName)
+ raises(DOMException);
+};
+
+
+ */
+
+
static JSClass jsclass_document =
{
"document",
@@ -39,6 +113,12 @@ static JSClass jsclass_document =
JSCLASS_NO_OPTIONAL_MEMBERS
};
+static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
+{
+ JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
+
+ return JS_TRUE;
+}
static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
{
@@ -67,6 +147,7 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
static JSFunctionSpec jsfunctions_document[] = {
JSAPI_FS(write, 1, 0),
+ JSAPI_FS(getElementById, 1, 0),
JSAPI_FS_END
};
diff --git a/test/js/index.html b/test/js/index.html
index f7ce2f3..6bb010c 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -10,7 +10,9 @@
<li><a href="inline-doc-write-simple.html">Simple docuemnt write</a></li>
<li><a href="inline-doc-write.html">Script within inline script</a></li>
<li><a href="sync-script.html">External syncronous script</a></li>
+<li><a href="sync-script-err.html">External syncronous script with missing js file</a></li>
<li><a href="sync-script-css.html">External syncronous script (with css)</a></li>
+<li><a href="inline-innerhtml.html">Inline script innerHtml test</a></li>
</ul>
diff --git a/test/js/inline-innerhtml.html b/test/js/inline-innerhtml.html
new file mode 100644
index 0000000..6bfd660
--- /dev/null
+++ b/test/js/inline-innerhtml.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>Inline Script innerHTML Test</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Inline Script innerHTML Test</h1>
+<p>Before</p>
+<p id="demo">some text you should never see</p>
+<script type="text/javascript">
+document.getElementById("demo").innerHTML="text inserted by script";
+</script>
+<p>Afterwards</p>
+</body>
+</html>
diff --git a/test/js/sync-script-css.html b/test/js/sync-script-css.html
index 55840f2..ecba5be 100644
--- a/test/js/sync-script-css.html
+++ b/test/js/sync-script-css.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Sync script Test (css0</h1>
+<h1>Sync script Test (css)</h1>
<p>Before</p>
<script src="tst.js"></script>
<p>Afterwards</p>
diff --git a/test/js/sync-script-err.html b/test/js/sync-script-err.html
new file mode 100644
index 0000000..68e77ba
--- /dev/null
+++ b/test/js/sync-script-err.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>Sync script Test with bad src</title>
+</head>
+<body>
+<h1>Sync script Test with bad src</h1>
+<p>Before</p>
+<script src="notthere.js"></script>
+<script src="tst.js"></script>
+<p>Afterwards</p>
+</body>
+</html>
--
NetSurf Browser
10 years, 8 months
netsurf: branch master updated. b238791002697efbda1ece31985ca15331511fa8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b238791002697efbda1ec...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b238791002697efbda1ece3...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b238791002697efbda1ece319...
The branch, master has been updated
via b238791002697efbda1ece31985ca15331511fa8 (commit)
from 46527795dbf69f08d55692fa1ca85b54a6bcc4dc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/b238791002697efbda1...
commit b238791002697efbda1ece31985ca15331511fa8
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Use enum instead of magic numbers for tracking key modifier states. Pass special keys to core (e.g. WORD_LEFT, SELECT_ALL, etc).
diff --git a/framebuffer/fbtk.h b/framebuffer/fbtk.h
index f2b09e5..220700f 100644
--- a/framebuffer/fbtk.h
+++ b/framebuffer/fbtk.h
@@ -74,6 +74,15 @@ struct fbtk_bitmap {
int hot_y;
};
+/* Key modifier status */
+typedef enum fbtk_modifier_type {
+ FBTK_MOD_CLEAR = 0,
+ FBTK_MOD_LSHIFT = (1 << 0),
+ FBTK_MOD_RSHIFT = (1 << 1),
+ FBTK_MOD_LCTRL = (1 << 2),
+ FBTK_MOD_RCTRL = (1 << 3)
+} fbtk_modifier_type;
+
typedef int (*fbtk_callback)(fbtk_widget_t *widget, fbtk_callback_info *cbi);
/* enter pressed on writable icon */
@@ -198,7 +207,7 @@ bool fbtk_tgrab_pointer(fbtk_widget_t *widget);
*
* Character mapping between keycode with modifier state and ucs-4.
*/
-int fbtk_keycode_to_ucs4(int code, uint8_t mods);
+int fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods);
/******************* Widget Information **********************/
diff --git a/framebuffer/fbtk/event.c b/framebuffer/fbtk/event.c
index 570c829..67f9306 100644
--- a/framebuffer/fbtk/event.c
+++ b/framebuffer/fbtk/event.c
@@ -34,6 +34,7 @@
#include "css/css.h"
#include "desktop/browser.h"
#include "desktop/plotters.h"
+#include "desktop/textinput.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
@@ -292,16 +293,46 @@ static int sh_keymap[] = {
/* exported function documented in fbtk.h */
int
-fbtk_keycode_to_ucs4(int code, uint8_t mods)
+fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods)
{
int ucs4 = -1;
- if (mods) {
+ if (mods & FBTK_MOD_LSHIFT || mods & FBTK_MOD_RSHIFT) {
if ((code >= 0) && (code < (int) NOF_ELEMENTS(sh_keymap)))
ucs4 = sh_keymap[code];
- } else {
+
+ } 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 = KEY_SELECT_ALL;
+ break;
+
+ case NSFB_KEY_c:
+ ucs4 = KEY_COPY_SELECTION;
+ break;
+
+ case NSFB_KEY_u:
+ ucs4 = KEY_CUT_LINE;
+ break;
+
+ case NSFB_KEY_v:
+ ucs4 = KEY_PASTE;
+ break;
+
+ case NSFB_KEY_x:
+ ucs4 = KEY_CUT_SELECTION;
+ break;
+
+ case NSFB_KEY_z:
+ ucs4 = KEY_CLEAR_SELECTION;
+ break;
+ default:
+ break;
+ }
}
return ucs4;
}
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index 60a14e5..936f3d2 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -262,7 +262,7 @@ static int
text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
int value;
- static uint8_t modifier = 0;
+ static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
char *temp;
plot_font_style_t font_style;
int fh;
@@ -284,19 +284,19 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_DOWN) {
switch (value) {
case NSFB_KEY_RSHIFT:
- modifier &= ~1;
+ modifier &= ~FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier &= ~(1<<1);
+ modifier &= ~FBTK_MOD_LSHIFT;
break;
case NSFB_KEY_RCTRL:
- modifier &= ~(1<<2);
+ modifier &= ~FBTK_MOD_RCTRL;
break;
case NSFB_KEY_LCTRL:
- modifier &= ~(1<<3);
+ modifier &= ~FBTK_MOD_LCTRL;
break;
default:
@@ -328,7 +328,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_KEY_RIGHT:
if (widget->u.text.idx < widget->u.text.len) {
- if (modifier == 0)
+ if (modifier == FBTK_MOD_CLEAR)
widget->u.text.idx++;
else
widget->u.text.idx = widget->u.text.len;
@@ -339,7 +339,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_KEY_LEFT:
if (widget->u.text.idx > 0) {
- if (modifier == 0)
+ if (modifier == FBTK_MOD_CLEAR)
widget->u.text.idx--;
else
widget->u.text.idx = 0;
@@ -357,23 +357,23 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
break;
case NSFB_KEY_RSHIFT:
- modifier |= 1;
+ modifier |= FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier |= 1<<1;
+ modifier |= FBTK_MOD_LSHIFT;
break;
case NSFB_KEY_RCTRL:
- modifier |= 1<<2;
+ modifier |= FBTK_MOD_RCTRL;
break;
case NSFB_KEY_LCTRL:
- modifier |= 1<<3;
+ modifier |= FBTK_MOD_LCTRL;
break;
default:
- if (modifier & 1<<2 || modifier & 1<<3) {
+ if (modifier & FBTK_MOD_LCTRL || modifier & FBTK_MOD_RCTRL) {
/* CTRL pressed, don't enter any text */
if (value == NSFB_KEY_u) {
/* CTRL+U: clear writable */
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 286f263..c451bc8 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -688,7 +688,7 @@ static int
fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
struct gui_window *gw = cbi->context;
- static uint8_t modifier = 0;
+ static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
int ucs4 = -1;
LOG(("got value %d", cbi->event->value.keycode));
@@ -698,41 +698,93 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
switch (cbi->event->value.keycode) {
case NSFB_KEY_PAGEUP:
- if (browser_window_key_press(gw->bw, KEY_PAGE_UP) == false)
- widget_scroll_y(gw, -fbtk_get_height(gw->browser), false);
+ if (browser_window_key_press(gw->bw,
+ KEY_PAGE_UP) == false)
+ widget_scroll_y(gw, -fbtk_get_height(
+ gw->browser), false);
break;
case NSFB_KEY_PAGEDOWN:
- if (browser_window_key_press(gw->bw, KEY_PAGE_DOWN) == false)
- widget_scroll_y(gw, fbtk_get_height(gw->browser), false);
+ if (browser_window_key_press(gw->bw,
+ KEY_PAGE_DOWN) == false)
+ widget_scroll_y(gw, fbtk_get_height(
+ gw->browser), false);
break;
case NSFB_KEY_RIGHT:
- if (browser_window_key_press(gw->bw, KEY_RIGHT) == false)
- widget_scroll_x(gw, 100, false);
+ if (modifier & FBTK_MOD_RCTRL ||
+ modifier & FBTK_MOD_LCTRL) {
+ /* CTRL held */
+ if (browser_window_key_press(gw->bw,
+ 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,
+ KEY_WORD_RIGHT) == false)
+ widget_scroll_x(gw, fbtk_get_width(
+ gw->browser), false);
+
+ } else {
+ /* no modifier */
+ if (browser_window_key_press(gw->bw,
+ KEY_RIGHT) == false)
+ widget_scroll_x(gw, 100, false);
+ }
break;
case NSFB_KEY_LEFT:
- if (browser_window_key_press(gw->bw, KEY_LEFT) == false)
- widget_scroll_x(gw, -100, false);
+ if (modifier & FBTK_MOD_RCTRL ||
+ modifier & FBTK_MOD_LCTRL) {
+ /* CTRL held */
+ if (browser_window_key_press(gw->bw,
+ 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,
+ KEY_WORD_LEFT) == false)
+ widget_scroll_x(gw, -fbtk_get_width(
+ gw->browser), false);
+
+ } else {
+ /* no modifier */
+ if (browser_window_key_press(gw->bw,
+ KEY_LEFT) == false)
+ widget_scroll_x(gw, -100, false);
+ }
break;
case NSFB_KEY_UP:
- if (browser_window_key_press(gw->bw, KEY_UP) == false)
+ if (browser_window_key_press(gw->bw,
+ KEY_UP) == false)
widget_scroll_y(gw, -100, false);
break;
case NSFB_KEY_DOWN:
- if (browser_window_key_press(gw->bw, KEY_DOWN) == false)
+ if (browser_window_key_press(gw->bw,
+ KEY_DOWN) == false)
widget_scroll_y(gw, 100, false);
break;
case NSFB_KEY_RSHIFT:
- modifier |= 1;
+ modifier |= FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier |= 1<<1;
+ modifier |= FBTK_MOD_LSHIFT;
+ break;
+
+ case NSFB_KEY_RCTRL:
+ modifier |= FBTK_MOD_RCTRL;
+ break;
+
+ case NSFB_KEY_LCTRL:
+ modifier |= FBTK_MOD_LCTRL;
break;
default:
@@ -747,11 +799,19 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_UP:
switch (cbi->event->value.keycode) {
case NSFB_KEY_RSHIFT:
- modifier &= ~1;
+ modifier &= ~FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier &= ~(1<<1);
+ modifier &= ~FBTK_MOD_LSHIFT;
+ break;
+
+ case NSFB_KEY_RCTRL:
+ modifier &= ~FBTK_MOD_RCTRL;
+ break;
+
+ case NSFB_KEY_LCTRL:
+ modifier &= ~FBTK_MOD_LCTRL;
break;
default:
-----------------------------------------------------------------------
Summary of changes:
framebuffer/fbtk.h | 11 +++++-
framebuffer/fbtk/event.c | 37 +++++++++++++++++--
framebuffer/fbtk/text.c | 24 ++++++------
framebuffer/gui.c | 90 ++++++++++++++++++++++++++++++++++++++--------
4 files changed, 131 insertions(+), 31 deletions(-)
diff --git a/framebuffer/fbtk.h b/framebuffer/fbtk.h
index f2b09e5..220700f 100644
--- a/framebuffer/fbtk.h
+++ b/framebuffer/fbtk.h
@@ -74,6 +74,15 @@ struct fbtk_bitmap {
int hot_y;
};
+/* Key modifier status */
+typedef enum fbtk_modifier_type {
+ FBTK_MOD_CLEAR = 0,
+ FBTK_MOD_LSHIFT = (1 << 0),
+ FBTK_MOD_RSHIFT = (1 << 1),
+ FBTK_MOD_LCTRL = (1 << 2),
+ FBTK_MOD_RCTRL = (1 << 3)
+} fbtk_modifier_type;
+
typedef int (*fbtk_callback)(fbtk_widget_t *widget, fbtk_callback_info *cbi);
/* enter pressed on writable icon */
@@ -198,7 +207,7 @@ bool fbtk_tgrab_pointer(fbtk_widget_t *widget);
*
* Character mapping between keycode with modifier state and ucs-4.
*/
-int fbtk_keycode_to_ucs4(int code, uint8_t mods);
+int fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods);
/******************* Widget Information **********************/
diff --git a/framebuffer/fbtk/event.c b/framebuffer/fbtk/event.c
index 570c829..67f9306 100644
--- a/framebuffer/fbtk/event.c
+++ b/framebuffer/fbtk/event.c
@@ -34,6 +34,7 @@
#include "css/css.h"
#include "desktop/browser.h"
#include "desktop/plotters.h"
+#include "desktop/textinput.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
@@ -292,16 +293,46 @@ static int sh_keymap[] = {
/* exported function documented in fbtk.h */
int
-fbtk_keycode_to_ucs4(int code, uint8_t mods)
+fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods)
{
int ucs4 = -1;
- if (mods) {
+ if (mods & FBTK_MOD_LSHIFT || mods & FBTK_MOD_RSHIFT) {
if ((code >= 0) && (code < (int) NOF_ELEMENTS(sh_keymap)))
ucs4 = sh_keymap[code];
- } else {
+
+ } 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 = KEY_SELECT_ALL;
+ break;
+
+ case NSFB_KEY_c:
+ ucs4 = KEY_COPY_SELECTION;
+ break;
+
+ case NSFB_KEY_u:
+ ucs4 = KEY_CUT_LINE;
+ break;
+
+ case NSFB_KEY_v:
+ ucs4 = KEY_PASTE;
+ break;
+
+ case NSFB_KEY_x:
+ ucs4 = KEY_CUT_SELECTION;
+ break;
+
+ case NSFB_KEY_z:
+ ucs4 = KEY_CLEAR_SELECTION;
+ break;
+ default:
+ break;
+ }
}
return ucs4;
}
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index 60a14e5..936f3d2 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -262,7 +262,7 @@ static int
text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
int value;
- static uint8_t modifier = 0;
+ static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
char *temp;
plot_font_style_t font_style;
int fh;
@@ -284,19 +284,19 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_DOWN) {
switch (value) {
case NSFB_KEY_RSHIFT:
- modifier &= ~1;
+ modifier &= ~FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier &= ~(1<<1);
+ modifier &= ~FBTK_MOD_LSHIFT;
break;
case NSFB_KEY_RCTRL:
- modifier &= ~(1<<2);
+ modifier &= ~FBTK_MOD_RCTRL;
break;
case NSFB_KEY_LCTRL:
- modifier &= ~(1<<3);
+ modifier &= ~FBTK_MOD_LCTRL;
break;
default:
@@ -328,7 +328,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_KEY_RIGHT:
if (widget->u.text.idx < widget->u.text.len) {
- if (modifier == 0)
+ if (modifier == FBTK_MOD_CLEAR)
widget->u.text.idx++;
else
widget->u.text.idx = widget->u.text.len;
@@ -339,7 +339,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_KEY_LEFT:
if (widget->u.text.idx > 0) {
- if (modifier == 0)
+ if (modifier == FBTK_MOD_CLEAR)
widget->u.text.idx--;
else
widget->u.text.idx = 0;
@@ -357,23 +357,23 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
break;
case NSFB_KEY_RSHIFT:
- modifier |= 1;
+ modifier |= FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier |= 1<<1;
+ modifier |= FBTK_MOD_LSHIFT;
break;
case NSFB_KEY_RCTRL:
- modifier |= 1<<2;
+ modifier |= FBTK_MOD_RCTRL;
break;
case NSFB_KEY_LCTRL:
- modifier |= 1<<3;
+ modifier |= FBTK_MOD_LCTRL;
break;
default:
- if (modifier & 1<<2 || modifier & 1<<3) {
+ if (modifier & FBTK_MOD_LCTRL || modifier & FBTK_MOD_RCTRL) {
/* CTRL pressed, don't enter any text */
if (value == NSFB_KEY_u) {
/* CTRL+U: clear writable */
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 286f263..c451bc8 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -688,7 +688,7 @@ static int
fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
{
struct gui_window *gw = cbi->context;
- static uint8_t modifier = 0;
+ static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
int ucs4 = -1;
LOG(("got value %d", cbi->event->value.keycode));
@@ -698,41 +698,93 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
switch (cbi->event->value.keycode) {
case NSFB_KEY_PAGEUP:
- if (browser_window_key_press(gw->bw, KEY_PAGE_UP) == false)
- widget_scroll_y(gw, -fbtk_get_height(gw->browser), false);
+ if (browser_window_key_press(gw->bw,
+ KEY_PAGE_UP) == false)
+ widget_scroll_y(gw, -fbtk_get_height(
+ gw->browser), false);
break;
case NSFB_KEY_PAGEDOWN:
- if (browser_window_key_press(gw->bw, KEY_PAGE_DOWN) == false)
- widget_scroll_y(gw, fbtk_get_height(gw->browser), false);
+ if (browser_window_key_press(gw->bw,
+ KEY_PAGE_DOWN) == false)
+ widget_scroll_y(gw, fbtk_get_height(
+ gw->browser), false);
break;
case NSFB_KEY_RIGHT:
- if (browser_window_key_press(gw->bw, KEY_RIGHT) == false)
- widget_scroll_x(gw, 100, false);
+ if (modifier & FBTK_MOD_RCTRL ||
+ modifier & FBTK_MOD_LCTRL) {
+ /* CTRL held */
+ if (browser_window_key_press(gw->bw,
+ 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,
+ KEY_WORD_RIGHT) == false)
+ widget_scroll_x(gw, fbtk_get_width(
+ gw->browser), false);
+
+ } else {
+ /* no modifier */
+ if (browser_window_key_press(gw->bw,
+ KEY_RIGHT) == false)
+ widget_scroll_x(gw, 100, false);
+ }
break;
case NSFB_KEY_LEFT:
- if (browser_window_key_press(gw->bw, KEY_LEFT) == false)
- widget_scroll_x(gw, -100, false);
+ if (modifier & FBTK_MOD_RCTRL ||
+ modifier & FBTK_MOD_LCTRL) {
+ /* CTRL held */
+ if (browser_window_key_press(gw->bw,
+ 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,
+ KEY_WORD_LEFT) == false)
+ widget_scroll_x(gw, -fbtk_get_width(
+ gw->browser), false);
+
+ } else {
+ /* no modifier */
+ if (browser_window_key_press(gw->bw,
+ KEY_LEFT) == false)
+ widget_scroll_x(gw, -100, false);
+ }
break;
case NSFB_KEY_UP:
- if (browser_window_key_press(gw->bw, KEY_UP) == false)
+ if (browser_window_key_press(gw->bw,
+ KEY_UP) == false)
widget_scroll_y(gw, -100, false);
break;
case NSFB_KEY_DOWN:
- if (browser_window_key_press(gw->bw, KEY_DOWN) == false)
+ if (browser_window_key_press(gw->bw,
+ KEY_DOWN) == false)
widget_scroll_y(gw, 100, false);
break;
case NSFB_KEY_RSHIFT:
- modifier |= 1;
+ modifier |= FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier |= 1<<1;
+ modifier |= FBTK_MOD_LSHIFT;
+ break;
+
+ case NSFB_KEY_RCTRL:
+ modifier |= FBTK_MOD_RCTRL;
+ break;
+
+ case NSFB_KEY_LCTRL:
+ modifier |= FBTK_MOD_LCTRL;
break;
default:
@@ -747,11 +799,19 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_UP:
switch (cbi->event->value.keycode) {
case NSFB_KEY_RSHIFT:
- modifier &= ~1;
+ modifier &= ~FBTK_MOD_RSHIFT;
break;
case NSFB_KEY_LSHIFT:
- modifier &= ~(1<<1);
+ modifier &= ~FBTK_MOD_LSHIFT;
+ break;
+
+ case NSFB_KEY_RCTRL:
+ modifier &= ~FBTK_MOD_RCTRL;
+ break;
+
+ case NSFB_KEY_LCTRL:
+ modifier &= ~FBTK_MOD_LCTRL;
break;
default:
--
NetSurf Browser
10 years, 8 months
netsurf: branch master updated. 46527795dbf69f08d55692fa1ca85b54a6bcc4dc
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/46527795dbf69f08d5569...
...commit http://git.netsurf-browser.org/netsurf.git/commit/46527795dbf69f08d55692f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/46527795dbf69f08d55692fa1...
The branch, master has been updated
via 46527795dbf69f08d55692fa1ca85b54a6bcc4dc (commit)
from d84ad62a04938ed80455e604135325777d7ea562 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/46527795dbf69f08d55...
commit 46527795dbf69f08d55692fa1ca85b54a6bcc4dc
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Pass pointer hotspots to libnsfb.
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c
index b29fe9f..4356bb2 100644
--- a/framebuffer/fbtk/fbtk.c
+++ b/framebuffer/fbtk/fbtk.c
@@ -373,7 +373,9 @@ fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi)
(nsfb_colour_t *)bm->pixdata,
bm->width,
bm->height,
- bm->width);
+ bm->width,
+ bm->hot_x,
+ bm->hot_y);
return 0;
}
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index fda8aae..da80a13 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -427,7 +427,7 @@ framebuffer_finalise(void)
bool
framebuffer_set_cursor(struct fbtk_bitmap *bm)
{
- return nsfb_cursor_set(nsfb, (nsfb_colour_t *)bm->pixdata, bm->width, bm->height, bm->width);
+ return nsfb_cursor_set(nsfb, (nsfb_colour_t *)bm->pixdata, bm->width, bm->height, bm->width, bm->hot_x, bm->hot_y);
}
nsfb_t *framebuffer_set_surface(nsfb_t *new_nsfb)
-----------------------------------------------------------------------
Summary of changes:
framebuffer/fbtk/fbtk.c | 4 +++-
framebuffer/framebuffer.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c
index b29fe9f..4356bb2 100644
--- a/framebuffer/fbtk/fbtk.c
+++ b/framebuffer/fbtk/fbtk.c
@@ -373,7 +373,9 @@ fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi)
(nsfb_colour_t *)bm->pixdata,
bm->width,
bm->height,
- bm->width);
+ bm->width,
+ bm->hot_x,
+ bm->hot_y);
return 0;
}
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index fda8aae..da80a13 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -427,7 +427,7 @@ framebuffer_finalise(void)
bool
framebuffer_set_cursor(struct fbtk_bitmap *bm)
{
- return nsfb_cursor_set(nsfb, (nsfb_colour_t *)bm->pixdata, bm->width, bm->height, bm->width);
+ return nsfb_cursor_set(nsfb, (nsfb_colour_t *)bm->pixdata, bm->width, bm->height, bm->width, bm->hot_x, bm->hot_y);
}
nsfb_t *framebuffer_set_surface(nsfb_t *new_nsfb)
--
NetSurf Browser
10 years, 8 months
libnsfb: branch master updated. bde04d10347414251b40af574d1bc94962d23a5a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnsfb.git/shortlog/bde04d10347414251b40a...
...commit http://git.netsurf-browser.org/libnsfb.git/commit/bde04d10347414251b40af5...
...tree http://git.netsurf-browser.org/libnsfb.git/tree/bde04d10347414251b40af574...
The branch, master has been updated
via bde04d10347414251b40af574d1bc94962d23a5a (commit)
from 56dd658e6265fb1902c92d6d88420c3accb79225 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libnsfb.git/commitdiff/bde04d10347414251b4...
commit bde04d10347414251b40af574d1bc94962d23a5a
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add support for offset mouse pointer hotspots.
diff --git a/include/cursor.h b/include/cursor.h
index e3a8a04..076e6c9 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -20,6 +20,8 @@ struct nsfb_cursor_s {
int bmp_width;
int bmp_height;
int bmp_stride;
+ int hotspot_x;
+ int hotspot_y;
/* current saved image */
nsfb_bbox_t savloc;
diff --git a/include/libnsfb_cursor.h b/include/libnsfb_cursor.h
index 4f36793..525bd83 100644
--- a/include/libnsfb_cursor.h
+++ b/include/libnsfb_cursor.h
@@ -17,15 +17,22 @@ bool nsfb_cursor_init(nsfb_t *nsfb);
/** Set cursor parameters.
*
- * Set a cursor, the cursor will be shown at the specified location and
- * size. The pixel data may be referenced untill the cursor is altered or
- * cleared
+ * Set a cursor bitmap, the cursor will be shown at the location set by
+ * nsfb_cursor_loc_set. The pixel data may be referenced untill the cursor
+ * is altered or cleared
*
- * @param nsfb The frambuffer context.
- * @param loc The location of the cursor
- * @param pixel The pixel data for the cursor
+ * @param nsfb The frambuffer context
+ * @param pixel The cursor bitmap data
+ * @param bmp_width The width of the cursor bitmap
+ * @param bmp_height The height of the cursor bitmap
+ * @param bmp_stride The cursor bitmap's row stride
+ * @param hotspot_x Coordinate within cursor image to place over cursor loc
+ * @param hotspot_y Coordinate within cursor image to place over cursor loc
+ *
+ * (hot_spot_x, hot_spot_y) is from top left. (0, 0) means top left pixel of
+ * cursor bitmap is to be rendered over the cursor location.
*/
-bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride);
+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 location.
*
diff --git a/src/cursor.c b/src/cursor.c
index bd9f04b..5e3f41e 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -36,7 +36,9 @@ bool nsfb_cursor_init(nsfb_t *nsfb)
return true;
}
-bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride)
+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)
{
if (nsfb->cursor == NULL)
return false;
@@ -47,6 +49,9 @@ bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, in
nsfb->cursor->bmp_stride = bmp_stride;
nsfb->cursor->loc.x1 = nsfb->cursor->loc.x0 + nsfb->cursor->bmp_width;
nsfb->cursor->loc.y1 = nsfb->cursor->loc.y0 + nsfb->cursor->bmp_height;
+
+ nsfb->cursor->hotspot_x = hotspot_x;
+ nsfb->cursor->hotspot_y = hotspot_y;
return nsfb->surface_rtns->cursor(nsfb, nsfb->cursor);
}
@@ -81,6 +86,12 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
nsfb->plotter_fns->get_clip(nsfb, &sclip);
nsfb->plotter_fns->set_clip(nsfb, NULL);
+ /* offset cursor rect for hotspot */
+ cursor->loc.x0 -= cursor->hotspot_x;
+ cursor->loc.y0 -= cursor->hotspot_y;
+ cursor->loc.x1 -= cursor->hotspot_x;
+ cursor->loc.y1 -= cursor->hotspot_y;
+
cursor->savloc = cursor->loc;
cursor->sav_width = cursor->savloc.x1 - cursor->savloc.x0;
@@ -91,11 +102,12 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
cursor->sav = realloc(cursor->sav, sav_size);
cursor->sav_size = sav_size;
}
-
- nsfb->plotter_fns->readrect(nsfb, &cursor->savloc, cursor->sav );
+
+ nsfb->plotter_fns->readrect(nsfb, &cursor->savloc, cursor->sav);
cursor->sav_width = cursor->savloc.x1 - cursor->savloc.x0;
cursor->sav_height = cursor->savloc.y1 - cursor->savloc.y0;
-
+
+ nsfb->plotter_fns->set_clip(nsfb, NULL);
nsfb->plotter_fns->bitmap(nsfb,
&cursor->loc,
cursor->pixel,
@@ -104,6 +116,12 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
cursor->bmp_stride,
true);
+ /* undo hotspot offset */
+ cursor->loc.x0 += cursor->hotspot_x;
+ cursor->loc.y0 += cursor->hotspot_y;
+ cursor->loc.x1 += cursor->hotspot_x;
+ cursor->loc.y1 += cursor->hotspot_y;
+
nsfb->plotter_fns->set_clip(nsfb, &sclip);
cursor->plotted = true;
diff --git a/src/surface/sdl.c b/src/surface/sdl.c
index 2a905f5..8908a21 100644
--- a/src/surface/sdl.c
+++ b/src/surface/sdl.c
@@ -636,8 +636,13 @@ sdl_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
nsfb_bbox_t fbarea;
if ((cursor != NULL) && (cursor->plotted == true)) {
+ nsfb_bbox_t loc_shift = cursor->loc;
+ loc_shift.x0 -= cursor->hotspot_x;
+ loc_shift.y0 -= cursor->hotspot_y;
+ loc_shift.x1 -= cursor->hotspot_x;
+ loc_shift.y1 -= cursor->hotspot_y;
- nsfb_plot_add_rect(&cursor->savloc, &cursor->loc, &redraw);
+ nsfb_plot_add_rect(&cursor->savloc, &loc_shift, &redraw);
/* screen area */
fbarea.x0 = 0;
-----------------------------------------------------------------------
Summary of changes:
include/cursor.h | 2 ++
include/libnsfb_cursor.h | 21 ++++++++++++++-------
src/cursor.c | 26 ++++++++++++++++++++++----
src/surface/sdl.c | 7 ++++++-
4 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/include/cursor.h b/include/cursor.h
index e3a8a04..076e6c9 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -20,6 +20,8 @@ struct nsfb_cursor_s {
int bmp_width;
int bmp_height;
int bmp_stride;
+ int hotspot_x;
+ int hotspot_y;
/* current saved image */
nsfb_bbox_t savloc;
diff --git a/include/libnsfb_cursor.h b/include/libnsfb_cursor.h
index 4f36793..525bd83 100644
--- a/include/libnsfb_cursor.h
+++ b/include/libnsfb_cursor.h
@@ -17,15 +17,22 @@ bool nsfb_cursor_init(nsfb_t *nsfb);
/** Set cursor parameters.
*
- * Set a cursor, the cursor will be shown at the specified location and
- * size. The pixel data may be referenced untill the cursor is altered or
- * cleared
+ * Set a cursor bitmap, the cursor will be shown at the location set by
+ * nsfb_cursor_loc_set. The pixel data may be referenced untill the cursor
+ * is altered or cleared
*
- * @param nsfb The frambuffer context.
- * @param loc The location of the cursor
- * @param pixel The pixel data for the cursor
+ * @param nsfb The frambuffer context
+ * @param pixel The cursor bitmap data
+ * @param bmp_width The width of the cursor bitmap
+ * @param bmp_height The height of the cursor bitmap
+ * @param bmp_stride The cursor bitmap's row stride
+ * @param hotspot_x Coordinate within cursor image to place over cursor loc
+ * @param hotspot_y Coordinate within cursor image to place over cursor loc
+ *
+ * (hot_spot_x, hot_spot_y) is from top left. (0, 0) means top left pixel of
+ * cursor bitmap is to be rendered over the cursor location.
*/
-bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride);
+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 location.
*
diff --git a/src/cursor.c b/src/cursor.c
index bd9f04b..5e3f41e 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -36,7 +36,9 @@ bool nsfb_cursor_init(nsfb_t *nsfb)
return true;
}
-bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride)
+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)
{
if (nsfb->cursor == NULL)
return false;
@@ -47,6 +49,9 @@ bool nsfb_cursor_set(nsfb_t *nsfb, const nsfb_colour_t *pixel, int bmp_width, in
nsfb->cursor->bmp_stride = bmp_stride;
nsfb->cursor->loc.x1 = nsfb->cursor->loc.x0 + nsfb->cursor->bmp_width;
nsfb->cursor->loc.y1 = nsfb->cursor->loc.y0 + nsfb->cursor->bmp_height;
+
+ nsfb->cursor->hotspot_x = hotspot_x;
+ nsfb->cursor->hotspot_y = hotspot_y;
return nsfb->surface_rtns->cursor(nsfb, nsfb->cursor);
}
@@ -81,6 +86,12 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
nsfb->plotter_fns->get_clip(nsfb, &sclip);
nsfb->plotter_fns->set_clip(nsfb, NULL);
+ /* offset cursor rect for hotspot */
+ cursor->loc.x0 -= cursor->hotspot_x;
+ cursor->loc.y0 -= cursor->hotspot_y;
+ cursor->loc.x1 -= cursor->hotspot_x;
+ cursor->loc.y1 -= cursor->hotspot_y;
+
cursor->savloc = cursor->loc;
cursor->sav_width = cursor->savloc.x1 - cursor->savloc.x0;
@@ -91,11 +102,12 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
cursor->sav = realloc(cursor->sav, sav_size);
cursor->sav_size = sav_size;
}
-
- nsfb->plotter_fns->readrect(nsfb, &cursor->savloc, cursor->sav );
+
+ nsfb->plotter_fns->readrect(nsfb, &cursor->savloc, cursor->sav);
cursor->sav_width = cursor->savloc.x1 - cursor->savloc.x0;
cursor->sav_height = cursor->savloc.y1 - cursor->savloc.y0;
-
+
+ nsfb->plotter_fns->set_clip(nsfb, NULL);
nsfb->plotter_fns->bitmap(nsfb,
&cursor->loc,
cursor->pixel,
@@ -104,6 +116,12 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
cursor->bmp_stride,
true);
+ /* undo hotspot offset */
+ cursor->loc.x0 += cursor->hotspot_x;
+ cursor->loc.y0 += cursor->hotspot_y;
+ cursor->loc.x1 += cursor->hotspot_x;
+ cursor->loc.y1 += cursor->hotspot_y;
+
nsfb->plotter_fns->set_clip(nsfb, &sclip);
cursor->plotted = true;
diff --git a/src/surface/sdl.c b/src/surface/sdl.c
index 2a905f5..8908a21 100644
--- a/src/surface/sdl.c
+++ b/src/surface/sdl.c
@@ -636,8 +636,13 @@ sdl_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor)
nsfb_bbox_t fbarea;
if ((cursor != NULL) && (cursor->plotted == true)) {
+ nsfb_bbox_t loc_shift = cursor->loc;
+ loc_shift.x0 -= cursor->hotspot_x;
+ loc_shift.y0 -= cursor->hotspot_y;
+ loc_shift.x1 -= cursor->hotspot_x;
+ loc_shift.y1 -= cursor->hotspot_y;
- nsfb_plot_add_rect(&cursor->savloc, &cursor->loc, &redraw);
+ nsfb_plot_add_rect(&cursor->savloc, &loc_shift, &redraw);
/* screen area */
fbarea.x0 = 0;
--
NetSurf Framebuffer library
10 years, 8 months
netsurf: branch master updated. d84ad62a04938ed80455e604135325777d7ea562
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d84ad62a04938ed80455e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d84ad62a04938ed80455e60...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d84ad62a04938ed80455e6041...
The branch, master has been updated
via d84ad62a04938ed80455e604135325777d7ea562 (commit)
via 465ebb2c7bcfc214616571a6cb3a29c87a206653 (commit)
from 37779f77d256000ec4f3a53bf9a1e198ab5e5ed0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/d84ad62a04938ed8045...
commit d84ad62a04938ed80455e604135325777d7ea562
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Scroll text in writable text widget so caret is always in view.
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index 3fd2a50..60a14e5 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -96,9 +96,15 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
int caret_x, caret_y, caret_h;
int fh;
int padding;
+ int scroll = 0;
+ bool caret = false;
fb_text_font_style(widget, &fh, &padding, &font_style);
+ if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
+ caret = true;
+ }
+
root = fbtk_get_root_widget(widget);
fbtk_get_bbox(widget, &bbox);
@@ -122,27 +128,28 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
}
if (widget->u.text.text != NULL) {
- FBTK_LOG(("plotting %p at %d,%d %d,%d w/h %d,%d "
- "font h %d padding %d",
- widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1,
- widget->width, widget->height, fh, padding));
+ int x = bbox.x0 + padding;
+ int y = bbox.y0 + ((fh * 3) / 4) + padding;
+
+ if (caret && widget->width - padding - padding < caret_x) {
+ scroll = (widget->width - padding - padding) - caret_x;
+ x += scroll;
+ }
+
/* Call the fb text plotting, baseline is 3/4 down the font */
- fb_plotters.text(bbox.x0 + padding,
- bbox.y0 + ((fh * 3) / 4) + padding,
- widget->u.text.text,
- widget->u.text.len,
- &font_style);
+ fb_plotters.text(x, y, widget->u.text.text,
+ widget->u.text.len, &font_style);
}
- if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
+ if (caret) {
/* This widget has caret, so render it */
nsfb_t *nsfb = fbtk_get_nsfb(widget);
nsfb_bbox_t line;
nsfb_plot_pen_t pen;
- line.x0 = bbox.x0 + caret_x;
+ line.x0 = bbox.x0 + caret_x + scroll;
line.y0 = bbox.y0 + caret_y;
- line.x1 = bbox.x0 + caret_x;
+ line.x1 = bbox.x0 + caret_x + scroll;
line.y1 = bbox.y0 + caret_y + caret_h;
pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
@@ -173,7 +180,6 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
nsfb_bbox_t line;
nsfb_plot_pen_t pen;
plot_font_style_t font_style;
- int caret_x, caret_y, caret_h;
int fh;
int border;
fbtk_widget_t *root = fbtk_get_root_widget(widget);
@@ -223,9 +229,6 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
}
if (widget->u.text.text != NULL) {
- LOG(("plotting %p at %d,%d %d,%d w/h %d,%d font h %d border %d",
- widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1,
- widget->width, widget->height, fh, border));
/* Call the fb text plotting, baseline is 3/4 down the font */
fb_plotters.text(bbox.x0 + border,
bbox.y0 + ((fh * 3) / 4) + border,
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/465ebb2c7bcfc214616...
commit 465ebb2c7bcfc214616571a6cb3a29c87a206653
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Only writable text widget needs caret rendering.
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index 15c3f7a..3fd2a50 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -234,24 +234,6 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
&font_style);
}
- if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
- /* This widget has caret, so render it */
- nsfb_t *nsfb = fbtk_get_nsfb(widget);
- nsfb_bbox_t line;
- nsfb_plot_pen_t pen;
-
- line.x0 = bbox.x0 + caret_x;
- line.y0 = bbox.y0 + caret_y;
- line.x1 = bbox.x0 + caret_x;
- line.y1 = bbox.y0 + caret_y + caret_h;
-
- pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
- pen.stroke_width = 1;
- pen.stroke_colour = 0xFF0000FF;
-
- nsfb_plot_line(nsfb, &line, &pen);
- }
-
nsfb_update(root->u.root.fb, &bbox);
return 0;
-----------------------------------------------------------------------
Summary of changes:
framebuffer/fbtk/text.c | 53 ++++++++++++++++------------------------------
1 files changed, 19 insertions(+), 34 deletions(-)
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index 15c3f7a..60a14e5 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -96,9 +96,15 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
int caret_x, caret_y, caret_h;
int fh;
int padding;
+ int scroll = 0;
+ bool caret = false;
fb_text_font_style(widget, &fh, &padding, &font_style);
+ if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
+ caret = true;
+ }
+
root = fbtk_get_root_widget(widget);
fbtk_get_bbox(widget, &bbox);
@@ -122,27 +128,28 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
}
if (widget->u.text.text != NULL) {
- FBTK_LOG(("plotting %p at %d,%d %d,%d w/h %d,%d "
- "font h %d padding %d",
- widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1,
- widget->width, widget->height, fh, padding));
+ int x = bbox.x0 + padding;
+ int y = bbox.y0 + ((fh * 3) / 4) + padding;
+
+ if (caret && widget->width - padding - padding < caret_x) {
+ scroll = (widget->width - padding - padding) - caret_x;
+ x += scroll;
+ }
+
/* Call the fb text plotting, baseline is 3/4 down the font */
- fb_plotters.text(bbox.x0 + padding,
- bbox.y0 + ((fh * 3) / 4) + padding,
- widget->u.text.text,
- widget->u.text.len,
- &font_style);
+ fb_plotters.text(x, y, widget->u.text.text,
+ widget->u.text.len, &font_style);
}
- if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
+ if (caret) {
/* This widget has caret, so render it */
nsfb_t *nsfb = fbtk_get_nsfb(widget);
nsfb_bbox_t line;
nsfb_plot_pen_t pen;
- line.x0 = bbox.x0 + caret_x;
+ line.x0 = bbox.x0 + caret_x + scroll;
line.y0 = bbox.y0 + caret_y;
- line.x1 = bbox.x0 + caret_x;
+ line.x1 = bbox.x0 + caret_x + scroll;
line.y1 = bbox.y0 + caret_y + caret_h;
pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
@@ -173,7 +180,6 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
nsfb_bbox_t line;
nsfb_plot_pen_t pen;
plot_font_style_t font_style;
- int caret_x, caret_y, caret_h;
int fh;
int border;
fbtk_widget_t *root = fbtk_get_root_widget(widget);
@@ -223,9 +229,6 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
}
if (widget->u.text.text != NULL) {
- LOG(("plotting %p at %d,%d %d,%d w/h %d,%d font h %d border %d",
- widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1,
- widget->width, widget->height, fh, border));
/* Call the fb text plotting, baseline is 3/4 down the font */
fb_plotters.text(bbox.x0 + border,
bbox.y0 + ((fh * 3) / 4) + border,
@@ -234,24 +237,6 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
&font_style);
}
- if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
- /* This widget has caret, so render it */
- nsfb_t *nsfb = fbtk_get_nsfb(widget);
- nsfb_bbox_t line;
- nsfb_plot_pen_t pen;
-
- line.x0 = bbox.x0 + caret_x;
- line.y0 = bbox.y0 + caret_y;
- line.x1 = bbox.x0 + caret_x;
- line.y1 = bbox.y0 + caret_y + caret_h;
-
- pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
- pen.stroke_width = 1;
- pen.stroke_colour = 0xFF0000FF;
-
- nsfb_plot_line(nsfb, &line, &pen);
- }
-
nsfb_update(root->u.root.fb, &bbox);
return 0;
--
NetSurf Browser
10 years, 8 months
netsurf: branch master updated. 37779f77d256000ec4f3a53bf9a1e198ab5e5ed0
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/37779f77d256000ec4f3a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/37779f77d256000ec4f3a53...
...tree http://git.netsurf-browser.org/netsurf.git/tree/37779f77d256000ec4f3a53bf...
The branch, master has been updated
via 37779f77d256000ec4f3a53bf9a1e198ab5e5ed0 (commit)
from 845dca45def00350df5866d27ff22eb492f355d9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/37779f77d256000ec4f...
commit 37779f77d256000ec4f3a53bf9a1e198ab5e5ed0
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
Fix build: we need libdom now.
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index a12e4be..a60c1d7 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -3,7 +3,7 @@
# ----------------------------------------------------------------------------
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libdom libcss)
LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
@@ -32,7 +32,7 @@
-DMONKEY_RESPATH=\"$(NETSURF_MONKEY_RESOURCES)\" \
$(WARNFLAGS) -I. -g \
$(shell $(PKG_CONFIG) --cflags glib-2.0) \
- $(shell $(PKG_CONFIG) --cflags libhubbub libcurl) \
+ $(shell $(PKG_CONFIG) --cflags libdom libcurl) \
$(shell $(PKG_CONFIG) --cflags openssl) \
$(shell xml2-config --cflags)
-----------------------------------------------------------------------
Summary of changes:
monkey/Makefile.target | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index a12e4be..a60c1d7 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -3,7 +3,7 @@
# ----------------------------------------------------------------------------
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libhubbub libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libdom libcss)
LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
@@ -32,7 +32,7 @@
-DMONKEY_RESPATH=\"$(NETSURF_MONKEY_RESOURCES)\" \
$(WARNFLAGS) -I. -g \
$(shell $(PKG_CONFIG) --cflags glib-2.0) \
- $(shell $(PKG_CONFIG) --cflags libhubbub libcurl) \
+ $(shell $(PKG_CONFIG) --cflags libdom libcurl) \
$(shell $(PKG_CONFIG) --cflags openssl) \
$(shell xml2-config --cflags)
--
NetSurf Browser
10 years, 8 months