netsurf: branch master updated. release/3.0-544-g1725518
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/172551870b2c11f80cc9d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/172551870b2c11f80cc9d70...
...tree http://git.netsurf-browser.org/netsurf.git/tree/172551870b2c11f80cc9d7078...
The branch, master has been updated
via 172551870b2c11f80cc9d707831914bd0acf9d23 (commit)
from 7f31b2c776b5af3051a5761ead7472df6ee861da (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/commit/?id=172551870b2c11f80cc...
commit 172551870b2c11f80cc9d707831914bd0acf9d23
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Squash warning from older GCC.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 0acd1fe..3f445bc 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -2855,7 +2855,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
int node_y, int mouse_x, int mouse_y, struct rect *rect)
{
struct treeview_text *field_data = NULL;
- struct treeview_field *ef, *field_desc;
+ struct treeview_field *ef, *field_desc = NULL;
int pos = node_y + tree_g.line_height;
int field_y = node_y;
int field_x;
@@ -2895,7 +2895,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
}
}
- if (field_data == NULL) {
+ if (field_data == NULL || field_desc == NULL) {
/* No editable field */
return false;
}
-----------------------------------------------------------------------
Summary of changes:
desktop/treeview.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 0acd1fe..3f445bc 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -2855,7 +2855,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
int node_y, int mouse_x, int mouse_y, struct rect *rect)
{
struct treeview_text *field_data = NULL;
- struct treeview_field *ef, *field_desc;
+ struct treeview_field *ef, *field_desc = NULL;
int pos = node_y + tree_g.line_height;
int field_y = node_y;
int field_x;
@@ -2895,7 +2895,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
}
}
- if (field_data == NULL) {
+ if (field_data == NULL || field_desc == NULL) {
/* No editable field */
return false;
}
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-543-g7f31b2c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7f31b2c776b5af3051a57...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7f31b2c776b5af3051a5761...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7f31b2c776b5af3051a5761ea...
The branch, master has been updated
via 7f31b2c776b5af3051a5761ead7472df6ee861da (commit)
via f13a11e31fa6a4c3fd5966a61dbc82cf94a486b3 (commit)
from 683ff4d1b51eb46cea9889c04a89edf4ad564c5e (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/commit/?id=7f31b2c776b5af3051a...
commit 7f31b2c776b5af3051a5761ead7472df6ee861da
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix use after unref.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 9af1d97..fde4c33 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -542,7 +542,6 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
if (title1 != NULL) {
title = dom_string_data(title1);
- dom_string_unref(title1);
} else {
title = "<No title>";
}
@@ -556,6 +555,9 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
warn_user(messages_get_errorcode(err), NULL);
+ if (title1 != NULL)
+ dom_string_unref(title1);
+
return err;
}
@@ -563,6 +565,8 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
err = hotlist_add_entry_internal(url, title, NULL, ctx->rel,
ctx->relshp, &ctx->rel);
nsurl_unref(url);
+ if (title1 != NULL)
+ dom_string_unref(title1);
ctx->relshp = TREE_REL_NEXT_SIBLING;
if (err != NSERROR_OK) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f13a11e31fa6a4c3fd5...
commit f13a11e31fa6a4c3fd5966a61dbc82cf94a486b3
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Destroy treeviews.
diff --git a/riscos/cookies.c b/riscos/cookies.c
index 7f37de8..0a15297 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -153,6 +153,18 @@ void ro_gui_cookies_postinitialise(void)
}
/**
+ * Destroy the cookies window.
+ */
+
+void ro_gui_cookies_destroy(void)
+{
+ if (cookies_window.tv == NULL)
+ return;
+
+ ro_treeview_destroy(cookies_window.tv);
+}
+
+/**
* Open the cookies window.
*
*/
diff --git a/riscos/cookies.h b/riscos/cookies.h
index e55ca02..b731339 100644
--- a/riscos/cookies.h
+++ b/riscos/cookies.h
@@ -28,6 +28,7 @@
void ro_gui_cookies_preinitialise(void);
void ro_gui_cookies_postinitialise(void);
+void ro_gui_cookies_destroy(void);
bool ro_gui_cookies_check_window(wimp_w window);
bool ro_gui_cookies_check_menu(wimp_menu *menu);
diff --git a/riscos/global_history.c b/riscos/global_history.c
index dfabbe9..840271f 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -160,6 +160,18 @@ void ro_gui_global_history_postinitialise(void)
}
/**
+ * Destroy the global history window.
+ */
+
+void ro_gui_global_history_destroy(void)
+{
+ if (global_history_window.tv == NULL)
+ return;
+
+ ro_treeview_destroy(global_history_window.tv);
+}
+
+/**
* Open the global history window.
*/
diff --git a/riscos/global_history.h b/riscos/global_history.h
index 99ea8c6..6f5ba11 100644
--- a/riscos/global_history.h
+++ b/riscos/global_history.h
@@ -28,6 +28,7 @@
void ro_gui_global_history_preinitialise(void);
void ro_gui_global_history_postinitialise(void);
+void ro_gui_global_history_destroy(void);
void ro_gui_global_history_open(void);
void ro_gui_global_history_save(void);
bool ro_gui_global_history_check_window(wimp_w window);
diff --git a/riscos/gui.c b/riscos/gui.c
index 69ec7e8..4ce5c81 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -919,6 +919,9 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_save));
ro_gui_window_quit();
+ ro_gui_global_history_destroy();
+ ro_gui_hotlist_destroy();
+ ro_gui_cookies_destroy();
ro_gui_saveas_quit();
rufl_quit();
free(gui_sprites);
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index d00e724..9e86542 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -182,6 +182,19 @@ void ro_gui_hotlist_postinitialise(void)
ro_gui_hotlist_menu_warning);
}
+/**
+ * Destroy the hotlist window.
+ */
+
+void ro_gui_hotlist_destroy(void)
+{
+ if (hotlist_window.tv == NULL)
+ return;
+
+ tree_hotlist_path = nsoption_charp(hotlist_save);
+ ro_treeview_destroy(hotlist_window.tv);
+}
+
/**
* Open the hotlist window.
diff --git a/riscos/hotlist.h b/riscos/hotlist.h
index 55f8d64..05ff088 100644
--- a/riscos/hotlist.h
+++ b/riscos/hotlist.h
@@ -38,6 +38,7 @@
void ro_gui_hotlist_preinitialise(void);
void ro_gui_hotlist_postinitialise(void);
+void ro_gui_hotlist_destroy(void);
void ro_gui_hotlist_open(void);
void ro_gui_hotlist_save(void);
bool ro_gui_hotlist_check_window(wimp_w window);
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 6 +++++-
riscos/cookies.c | 12 ++++++++++++
riscos/cookies.h | 1 +
riscos/global_history.c | 12 ++++++++++++
riscos/global_history.h | 1 +
riscos/gui.c | 3 +++
riscos/hotlist.c | 13 +++++++++++++
riscos/hotlist.h | 1 +
8 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 9af1d97..fde4c33 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -542,7 +542,6 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
if (title1 != NULL) {
title = dom_string_data(title1);
- dom_string_unref(title1);
} else {
title = "<No title>";
}
@@ -556,6 +555,9 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
warn_user(messages_get_errorcode(err), NULL);
+ if (title1 != NULL)
+ dom_string_unref(title1);
+
return err;
}
@@ -563,6 +565,8 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
err = hotlist_add_entry_internal(url, title, NULL, ctx->rel,
ctx->relshp, &ctx->rel);
nsurl_unref(url);
+ if (title1 != NULL)
+ dom_string_unref(title1);
ctx->relshp = TREE_REL_NEXT_SIBLING;
if (err != NSERROR_OK) {
diff --git a/riscos/cookies.c b/riscos/cookies.c
index 7f37de8..0a15297 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -153,6 +153,18 @@ void ro_gui_cookies_postinitialise(void)
}
/**
+ * Destroy the cookies window.
+ */
+
+void ro_gui_cookies_destroy(void)
+{
+ if (cookies_window.tv == NULL)
+ return;
+
+ ro_treeview_destroy(cookies_window.tv);
+}
+
+/**
* Open the cookies window.
*
*/
diff --git a/riscos/cookies.h b/riscos/cookies.h
index e55ca02..b731339 100644
--- a/riscos/cookies.h
+++ b/riscos/cookies.h
@@ -28,6 +28,7 @@
void ro_gui_cookies_preinitialise(void);
void ro_gui_cookies_postinitialise(void);
+void ro_gui_cookies_destroy(void);
bool ro_gui_cookies_check_window(wimp_w window);
bool ro_gui_cookies_check_menu(wimp_menu *menu);
diff --git a/riscos/global_history.c b/riscos/global_history.c
index dfabbe9..840271f 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -160,6 +160,18 @@ void ro_gui_global_history_postinitialise(void)
}
/**
+ * Destroy the global history window.
+ */
+
+void ro_gui_global_history_destroy(void)
+{
+ if (global_history_window.tv == NULL)
+ return;
+
+ ro_treeview_destroy(global_history_window.tv);
+}
+
+/**
* Open the global history window.
*/
diff --git a/riscos/global_history.h b/riscos/global_history.h
index 99ea8c6..6f5ba11 100644
--- a/riscos/global_history.h
+++ b/riscos/global_history.h
@@ -28,6 +28,7 @@
void ro_gui_global_history_preinitialise(void);
void ro_gui_global_history_postinitialise(void);
+void ro_gui_global_history_destroy(void);
void ro_gui_global_history_open(void);
void ro_gui_global_history_save(void);
bool ro_gui_global_history_check_window(wimp_w window);
diff --git a/riscos/gui.c b/riscos/gui.c
index 69ec7e8..4ce5c81 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -919,6 +919,9 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_save));
ro_gui_window_quit();
+ ro_gui_global_history_destroy();
+ ro_gui_hotlist_destroy();
+ ro_gui_cookies_destroy();
ro_gui_saveas_quit();
rufl_quit();
free(gui_sprites);
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index d00e724..9e86542 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -182,6 +182,19 @@ void ro_gui_hotlist_postinitialise(void)
ro_gui_hotlist_menu_warning);
}
+/**
+ * Destroy the hotlist window.
+ */
+
+void ro_gui_hotlist_destroy(void)
+{
+ if (hotlist_window.tv == NULL)
+ return;
+
+ tree_hotlist_path = nsoption_charp(hotlist_save);
+ ro_treeview_destroy(hotlist_window.tv);
+}
+
/**
* Open the hotlist window.
diff --git a/riscos/hotlist.h b/riscos/hotlist.h
index 55f8d64..05ff088 100644
--- a/riscos/hotlist.h
+++ b/riscos/hotlist.h
@@ -38,6 +38,7 @@
void ro_gui_hotlist_preinitialise(void);
void ro_gui_hotlist_postinitialise(void);
+void ro_gui_hotlist_destroy(void);
void ro_gui_hotlist_open(void);
void ro_gui_hotlist_save(void);
bool ro_gui_hotlist_check_window(wimp_w window);
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-541-g683ff4d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/683ff4d1b51eb46cea988...
...commit http://git.netsurf-browser.org/netsurf.git/commit/683ff4d1b51eb46cea9889c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/683ff4d1b51eb46cea9889c04...
The branch, master has been updated
via 683ff4d1b51eb46cea9889c04a89edf4ad564c5e (commit)
via bf3bea587499d9d69a4d19f8a0e1cf5948c52b39 (commit)
via f3f2c5b481c519d0ef4e501aa07c70baaaf7d86f (commit)
via ee8fb6f39f3014cf4e4c17a28904850a58f2f4f3 (commit)
via a00e0f91c7ccb27108cc396ca8afa3207935de4c (commit)
via e87596ad1f7755c50f7a00edc85e66908ad1ba10 (commit)
from 9871ca4a2d6ffc8f41634a05c177d5145c339959 (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/commit/?id=683ff4d1b51eb46cea9...
commit 683ff4d1b51eb46cea9889c04a89edf4ad564c5e
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Remove dotted box from treeview move drags, as core draws location arrow for us.
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 43fcdce..4cf3d42 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -1021,7 +1021,7 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
break;
case TREE_MOVE_DRAG:
- drag.type = wimp_DRAG_USER_FIXED;
+ drag.type = wimp_DRAG_USER_POINT;
drag.initial.x0 = pointer->pos.x - 4;
drag.initial.y0 = pointer->pos.y - 48;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bf3bea587499d9d69a4...
commit bf3bea587499d9d69a4d19f8a0e1cf5948c52b39
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Correct constraining rectangle for treeview drags so that pointer can't leave window.
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 4fb2e1e..43fcdce 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -1008,8 +1008,7 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
drag.bbox.x0 = state->visible.x0;
drag.bbox.y0 = state->visible.y0;
drag.bbox.x1 = state->visible.x1;
- drag.bbox.y1 = state->visible.y1 -
- ro_toolbar_height(tv->tb);
+ drag.bbox.y1 = state->visible.y1 - ro_toolbar_height(tv->tb) - 2;
switch (tv->drag) {
case TREE_SELECT_DRAG:
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f3f2c5b481c519d0ef4...
commit f3f2c5b481c519d0ef4e501aa07c70baaaf7d86f
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
gui_current_drag_type now only used for data transfer protocol routing; fix button bar drag handler.
Remove all references to gui_current_drag_type outside of gui.c which are not related to routing DataSaveAck messages.
Update button bar drag code so that it uses ro_mouse.
diff --git a/riscos/download.c b/riscos/download.c
index 3e70767..ebd981d 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -831,7 +831,6 @@ bool ro_gui_download_click(wimp_pointer *pointer)
y = (istate.icon.extent.y1 + istate.icon.extent.y0)/2 +
wstate.visible.y1 - wstate.yscroll;
}
- gui_current_drag_type = GUI_DRAG_DOWNLOAD_SAVE;
ro_mouse_drag_start(ro_gui_download_drag_end, NULL, NULL, NULL);
download_window_current = dw;
ro_gui_drag_icon(x, y, sprite);
@@ -954,6 +953,8 @@ static void ro_gui_download_drag_end(wimp_dragged *drag, void *data)
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+
+ gui_current_drag_type = GUI_DRAG_DOWNLOAD_SAVE;
}
diff --git a/riscos/gui.c b/riscos/gui.c
index 3ce44fd..69ec7e8 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -1784,6 +1784,8 @@ void ro_msg_datasave_ack(wimp_message *message)
default:
break;
}
+
+ gui_current_drag_type = GUI_DRAG_NONE;
}
diff --git a/riscos/gui.h b/riscos/gui.h
index 387fc95..5089315 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -65,10 +65,8 @@ extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
extern bool print_active, print_text_black;
extern bool no_font_blending;
-typedef enum { GUI_DRAG_NONE, GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
- GUI_DRAG_SAVE, GUI_DRAG_SCROLL, GUI_DRAG_STATUS_RESIZE,
- GUI_DRAG_TREEVIEW, GUI_DRAG_BUTTONBAR,
- GUI_DRAG_FRAME } ro_gui_drag_type;
+typedef enum { GUI_DRAG_NONE, GUI_DRAG_DOWNLOAD_SAVE, GUI_DRAG_SAVE }
+ ro_gui_drag_type;
extern ro_gui_drag_type gui_current_drag_type;
diff --git a/riscos/gui/button_bar.c b/riscos/gui/button_bar.c
index 00e3574..7ca67f1 100644
--- a/riscos/gui/button_bar.c
+++ b/riscos/gui/button_bar.c
@@ -33,6 +33,7 @@
#include "oslib/wimpspriteop.h"
#include "riscos/gui/button_bar.h"
#include "riscos/gui.h"
+#include "riscos/mouse.h"
#include "riscos/theme.h"
#include "riscos/wimp.h"
#include "utils/log.h"
@@ -110,6 +111,7 @@ static bool drag_separator = false;
static bool ro_gui_button_bar_place_buttons(struct button_bar *button_bar);
static bool ro_gui_button_bar_icon_update(struct button_bar *button_bar);
static bool ro_gui_button_bar_icon_resize(struct button_bar *button_bar);
+static void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data);
static void ro_gui_button_bar_sync_editors(struct button_bar *target,
struct button_bar *source);
static struct button_bar_button *ro_gui_button_bar_find_icon(
@@ -749,7 +751,6 @@ bool ro_gui_button_bar_click(struct button_bar *button_bar,
if (button != NULL && (!button->shaded || drag_separator ||
button_bar->edit_source != NULL)) {
- gui_current_drag_type = GUI_DRAG_BUTTONBAR;
drag_start = button_bar;
drag_opt = button->opt_key;
@@ -779,6 +780,10 @@ bool ro_gui_button_bar_click(struct button_bar *button_bar,
LOG(("xdragasprite_start: 0x%x: %s",
error->errnum, error->errmess));
+ ro_mouse_drag_start(ro_gui_button_bar_drag_end,
+ NULL, NULL, NULL);
+
+
return true;
}
@@ -847,9 +852,14 @@ bool ro_gui_button_bar_help_suffix(struct button_bar *button_bar, wimp_i i,
}
-/* This is an exported interface documented in button_bar.h */
+/**
+ * Terminate a drag event that was initiated by a button bar.
+ *
+ * \param *drag The drag event data.
+ * \param *data NULL data to satisfy callback syntax.
+ */
-void ro_gui_button_bar_drag_end(wimp_dragged *drag)
+void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data)
{
struct button_bar *drag_end = NULL;
struct button_bar *source = NULL, *target = NULL;
@@ -861,7 +871,6 @@ void ro_gui_button_bar_drag_end(wimp_dragged *drag)
os_error *error;
xdragasprite_stop();
- gui_current_drag_type = GUI_DRAG_NONE;
if (drag_start == NULL)
return;
diff --git a/riscos/gui/button_bar.h b/riscos/gui/button_bar.h
index d924288..9abae31 100644
--- a/riscos/gui/button_bar.h
+++ b/riscos/gui/button_bar.h
@@ -291,15 +291,6 @@ bool ro_gui_button_bar_help_suffix(struct button_bar *button_bar, wimp_i i,
/**
- * Terminate a drag event that was initiated by a button bar.
- *
- * \param *drag The drag event data.
- */
-
-void ro_gui_button_bar_drag_end(wimp_dragged *drag);
-
-
-/**
* Return a config string reflecting the configured order of buttons
* and spacers. The string is allocated with malloc(), and should be
* free()d after use.
diff --git a/riscos/gui/status_bar.c b/riscos/gui/status_bar.c
index e01ae3c..899fe99 100644
--- a/riscos/gui/status_bar.c
+++ b/riscos/gui/status_bar.c
@@ -526,7 +526,6 @@ bool ro_gui_status_bar_click(wimp_pointer *pointer)
switch (pointer->i) {
case ICON_WIDGET:
- gui_current_drag_type = GUI_DRAG_STATUS_RESIZE;
drag.w = pointer->w;
drag.type = wimp_DRAG_SYSTEM_SIZE;
drag.initial.x0 = pointer->pos.x;
diff --git a/riscos/save.c b/riscos/save.c
index ffda9c6..511af91 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -306,7 +306,6 @@ void ro_gui_save_start_drag(wimp_pointer *pointer)
y = (istate.icon.extent.y1 + istate.icon.extent.y0)/2 +
wstate.visible.y1 - wstate.yscroll;
}
- gui_current_drag_type = GUI_DRAG_SAVE;
ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
gui_save_sourcew = pointer->w;
saving_from_dialog = true;
@@ -384,7 +383,6 @@ void gui_drag_save_object(gui_save_type save_type, hlcache_handle *c,
save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
- gui_current_drag_type = GUI_DRAG_SAVE;
ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
@@ -433,7 +431,6 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
- gui_current_drag_type = GUI_DRAG_SAVE;
ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
@@ -478,7 +475,6 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
ro_gui_save_set_state(NULL, save_type, url, save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
- gui_current_drag_type = GUI_DRAG_SAVE;
ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
@@ -646,11 +642,8 @@ static void ro_gui_save_drag_end(wimp_dragged *drag, void *data)
dest_ok = browser_window_drop_file_at_point(g->bw,
pos.x, pos.y, NULL);
}
- if (!dest_ok) {
- /* cancel the drag operation */
- gui_current_drag_type = GUI_DRAG_NONE;
+ if (!dest_ok)
return;
- }
}
if (!saving_from_dialog) {
@@ -700,6 +693,8 @@ static void ro_gui_save_drag_end(wimp_dragged *drag, void *data)
ro_message_send_message_to_window(wimp_USER_MESSAGE_RECORDED, &message,
pointer.w, pointer.i, ro_gui_save_bounced, NULL);
+ gui_current_drag_type = GUI_DRAG_SAVE;
+
free(local_name);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ee8fb6f39f3014cf4e4...
commit ee8fb6f39f3014cf4e4c17a28904850a58f2f4f3
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Allow ro_mouse to enable null polls; remove unused global variables.
Implement ro_mouse_poll_interval() to allow ro_mouse to influence null polling.
Remove unused calls to drag type globals.
diff --git a/riscos/gui.c b/riscos/gui.c
index 890c5dd..3ce44fd 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -161,11 +161,6 @@ const char * NETSURF_DIR;
static const char *task_name = "NetSurf";
#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
-/** The pointer is over a window which is tracking mouse movement. */
-static bool gui_track = false;
-/** Browser window which the pointer is over, or 0 if none. */
-struct gui_window *gui_track_gui_window;
-
ro_gui_drag_type gui_current_drag_type;
wimp_t task_handle; /**< RISC OS wimp task handle. */
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
@@ -1026,26 +1021,19 @@ void gui_poll(bool active)
wimp_block block;
const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN |
wimp_SAVE_FP;
+ os_t track_poll_offset;
/* Poll wimp. */
xhourglass_off();
+ track_poll_offset = ro_mouse_poll_interval();
if (active) {
event = wimp_poll(mask, &block, 0);
- } else if (sched_active || gui_track || TRUE || browser_reformat_pending ||
+ } else if (sched_active || (track_poll_offset > 0) || browser_reformat_pending ||
bitmap_maintenance) {
os_t t = os_read_monotonic_time();
- if (gui_track)
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- t += 4; /* for smoother update */
- break;
-
- default:
- t += 10;
- break;
- }
+ if (track_poll_offset > 0)
+ t += track_poll_offset;
else
t += 10;
diff --git a/riscos/gui.h b/riscos/gui.h
index ea003cc..387fc95 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -54,7 +54,6 @@ extern wimp_w dialog_info, dialog_saveas, dialog_zoom, dialog_pageinfo,
dialog_objinfo, dialog_tooltip, dialog_warning, dialog_openurl,
dialog_debug, dialog_folder, dialog_entry, dialog_url_complete,
dialog_search, dialog_print, dialog_theme_install;
-extern struct gui_window *gui_track_gui_window;
extern wimp_w current_menu_window;
extern bool current_menu_open;
extern wimp_menu *recent_search_menu; /* search.c */
diff --git a/riscos/mouse.c b/riscos/mouse.c
index 73535ca..5ba1260 100644
--- a/riscos/mouse.c
+++ b/riscos/mouse.c
@@ -201,3 +201,44 @@ void ro_mouse_pointer_leaving_window(wimp_leaving *leaving)
ro_mouse_poll_data = NULL;
}
+
+/**
+ * Kill any tracking events if the data pointers match the supplied pointer.
+ *
+ * \param *data The data of the client to be killed.
+ */
+
+void ro_mouse_kill(void *data)
+{
+ if (data == ro_mouse_drag_data) {
+ ro_mouse_drag_end_callback = NULL;
+ ro_mouse_drag_track_callback = NULL;
+ ro_mouse_drag_cancel_callback = NULL;
+ ro_mouse_drag_data = NULL;
+ }
+
+ if (data == ro_mouse_poll_data) {
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+ }
+}
+
+
+/**
+ * Return the desired polling interval to allow the mouse tracking to be
+ * carried out.
+ *
+ * \return Desired poll interval (0 for none required).
+ */
+
+os_t ro_mouse_poll_interval(void)
+{
+ if (ro_mouse_drag_track_callback == NULL &&
+ ro_mouse_poll_track_callback == NULL)
+ return 0;
+
+ return 10; // \TODO Return 4 for DRAG_SELECTION && DRAG_SCROLL
+
+}
+
diff --git a/riscos/mouse.h b/riscos/mouse.h
index 26fb72e..e78a37e 100644
--- a/riscos/mouse.h
+++ b/riscos/mouse.h
@@ -90,5 +90,24 @@ void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
void ro_mouse_pointer_leaving_window(wimp_leaving *leaving);
+
+/**
+ * Kill any tracking events if the data pointers match the supplied pointer.
+ *
+ * \param *data The data of the client to be killed.
+ */
+
+void ro_mouse_kill(void *data);
+
+
+/**
+ * Return the desired polling interval to allow the mouse tracking to be
+ * carried out.
+ *
+ * \return Desired poll interval (0 for none required).
+ */
+
+os_t ro_mouse_poll_interval(void);
+
#endif
diff --git a/riscos/textselection.c b/riscos/textselection.c
index 501ac97..ab8ea5c 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -126,8 +126,6 @@ void gui_start_selection(struct gui_window *g)
LOG(("xwimp_auto_scroll: 0x%x: %s",
error->errnum, error->errmess));
- gui_current_drag_type = GUI_DRAG_SELECTION;
- gui_track_gui_window = g; // \TODO -- Remove?
ro_mouse_drag_start(ro_gui_selection_drag_end, ro_gui_window_mouse_at,
NULL, g);
@@ -163,10 +161,6 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
os_coord pos;
struct gui_window *g = (struct gui_window *) data;
- LOG(("ending text selection drag"));
-
- gui_current_drag_type = GUI_DRAG_NONE;
-
scroll.w = g->window;
error = xwimp_auto_scroll(0, &scroll, 0);
if (error)
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 4756d8c..4fb2e1e 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -1092,8 +1092,6 @@ static void ro_treeview_drag_end(wimp_dragged *drag, void *data)
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
-
- gui_current_drag_type = GUI_DRAG_NONE;
}
diff --git a/riscos/window.c b/riscos/window.c
index f3a6f05..65ac536 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -605,10 +605,7 @@ void gui_window_destroy(struct gui_window *g)
assert(g);
/* stop any tracking */
- if (gui_track_gui_window == g) {
- gui_track_gui_window = NULL;
- gui_current_drag_type = GUI_DRAG_NONE;
- }
+ ro_mouse_kill(g);
/* remove from list */
if (g->prev)
@@ -1245,8 +1242,6 @@ bool gui_window_scroll_start(struct gui_window *g)
return false;
}
- gui_track_gui_window = g; // \TODO -- Remove?
- gui_current_drag_type = GUI_DRAG_SCROLL;
ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
NULL, g);
return true;
@@ -1302,7 +1297,6 @@ bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
switch (type) {
case GDRAGGING_SCROLLBAR:
/* Dragging a core scrollbar */
- gui_current_drag_type = GUI_DRAG_SCROLL;
ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
NULL, g);
break;
@@ -3553,7 +3547,6 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
os_coord pos;
struct gui_window *g = (struct gui_window *) data;
- gui_current_drag_type = GUI_DRAG_NONE;
if (!g)
return;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a00e0f91c7ccb27108c...
commit a00e0f91c7ccb27108cc396ca8afa3207935de4c
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Move all mouse tracking into ro_mouse module.
Add Pointer Entering Window events to wimp_event module and add handlers to all modules requiring mouse tracking.
Updated: Treeview, URL Complete, History and GUI Window.
Delete all handling for Pointer Entering/Leaving from ro_gui.
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 0726cb3..7a333e6 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -158,6 +158,8 @@ void ro_gui_dialog_init(void)
dialog_url_complete = ro_gui_dialog_create("url_suggest");
ro_gui_wimp_event_register_mouse_click(dialog_url_complete,
ro_gui_url_complete_click);
+ ro_gui_wimp_event_register_pointer_entering_window(dialog_url_complete,
+ ro_gui_url_complete_entering);
ro_gui_wimp_event_register_redraw_window(dialog_url_complete,
ro_gui_url_complete_redraw);
ro_gui_wimp_event_set_help_prefix(dialog_url_complete, "HelpAutoURL");
diff --git a/riscos/gui.c b/riscos/gui.c
index 11ed3f4..890c5dd 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -163,8 +163,6 @@ static const char *task_name = "NetSurf";
/** The pointer is over a window which is tracking mouse movement. */
static bool gui_track = false;
-/** Handle of window which the pointer is over. */
-static wimp_w gui_track_wimp_w;
/** Browser window which the pointer is over, or 0 if none. */
struct gui_window *gui_track_gui_window;
@@ -239,10 +237,7 @@ static void ro_gui_choose_language(void);
static void ro_gui_signal(int sig);
static void ro_gui_cleanup(void);
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
-static void ro_gui_null_reason_code(void);
static void ro_gui_close_window_request(wimp_close *close);
-static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
-static void ro_gui_pointer_entering_window(wimp_entering *entering);
static void ro_gui_check_resolvers(void);
static void ro_gui_keypress(wimp_key *key);
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
@@ -1036,7 +1031,7 @@ void gui_poll(bool active)
xhourglass_off();
if (active) {
event = wimp_poll(mask, &block, 0);
- } else if (sched_active || gui_track || browser_reformat_pending ||
+ } else if (sched_active || gui_track || TRUE || browser_reformat_pending ||
bitmap_maintenance) {
os_t t = os_read_monotonic_time();
@@ -1095,7 +1090,8 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
{
switch (event) {
case wimp_NULL_REASON_CODE:
- ro_gui_null_reason_code();
+ ro_gui_throb();
+ ro_mouse_poll();
break;
case wimp_REDRAW_WINDOW_REQUEST:
@@ -1111,11 +1107,11 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_POINTER_LEAVING_WINDOW:
- ro_gui_pointer_leaving_window(&block->leaving);
+ ro_mouse_pointer_leaving_window(&block->leaving);
break;
case wimp_POINTER_ENTERING_WINDOW:
- ro_gui_pointer_entering_window(&block->entering);
+ ro_gui_wimp_event_pointer_entering_window(&block->entering);
break;
case wimp_MOUSE_CLICK:
@@ -1153,63 +1149,6 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
/**
- * Handle Null_Reason_Code events.
- */
-
-void ro_gui_null_reason_code(void)
-{
- wimp_pointer pointer;
- os_error *error;
-
- ro_gui_throb();
-
- ro_mouse_poll();
-
- if (!gui_track)
- return;
-
- error = xwimp_get_pointer_info(&pointer);
- if (error) {
- LOG(("xwimp_get_pointer_info: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- switch (gui_current_drag_type) {
-
- /* pointer is allowed to wander outside the initiating window
- for certain drag types */
-
- //case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- //case GUI_DRAG_FRAME:
- assert(gui_track_gui_window);
- ro_gui_window_mouse_at(&pointer, gui_track_gui_window);
- break;
-
-// case GUI_DRAG_SAVE:
-// ro_gui_selection_send_dragging(&pointer);
-// break;
-
- default:
- if (ro_gui_global_history_check_window(gui_track_wimp_w) ||
- ro_gui_hotlist_check_window(gui_track_wimp_w) ||
- ro_gui_cookies_check_window(gui_track_wimp_w))
- ro_treeview_mouse_at(&pointer, NULL);
- if (gui_track_wimp_w == history_window)
- ro_gui_history_mouse_at(&pointer);
- if (gui_track_wimp_w == dialog_url_complete)
- ro_gui_url_complete_mouse_at(&pointer);
- else if (gui_track_gui_window)
- ro_gui_window_mouse_at(&pointer,
- gui_track_gui_window);
- break;
- }
-}
-
-
-/**
* Handle Open_Window_Request events.
*/
@@ -1247,68 +1186,6 @@ void ro_gui_close_window_request(wimp_close *close)
/**
- * Handle Pointer_Leaving_Window events.
- */
-
-void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
-{
- if (gui_track_wimp_w == history_window)
- ro_gui_dialog_close(dialog_tooltip);
-
- LOG(("Leaving window 0x%x", leaving->w));
-
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- case GUI_DRAG_SAVE:
- case GUI_DRAG_FRAME:
- //case GUI_DRAG_TREEVIEW:
- /* ignore Pointer_Leaving_Window event that the Wimp mysteriously
- issues when a Wimp_DragBox drag operation is started */
- break;
-
- default:
- if (gui_track_gui_window)
- gui_window_set_pointer(gui_track_gui_window, GUI_POINTER_DEFAULT);
- gui_track_wimp_w = 0;
- gui_track_gui_window = NULL;
- gui_track = false;
- break;
- }
-}
-
-
-/**
- * Handle Pointer_Entering_Window events.
- */
-
-void ro_gui_pointer_entering_window(wimp_entering *entering)
-{
- LOG(("Entering window 0x%x", entering->w));
-
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- case GUI_DRAG_SAVE:
- case GUI_DRAG_FRAME:
- //case GUI_DRAG_TREEVIEW:
- /* ignore entering new windows/frames */
- break;
- default:
- gui_track_wimp_w = entering->w;
- gui_track_gui_window = ro_gui_window_lookup(entering->w);
- gui_track = gui_track_gui_window ||
- gui_track_wimp_w == history_window ||
- gui_track_wimp_w == dialog_url_complete ||
- ro_gui_hotlist_check_window(gui_track_wimp_w) ||
- ro_gui_global_history_check_window(gui_track_wimp_w) ||
- ro_gui_cookies_check_window(gui_track_wimp_w);
- break;
- }
-}
-
-
-/**
* Handle Key_Pressed events.
*/
diff --git a/riscos/gui.h b/riscos/gui.h
index 8f165c0..ea003cc 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -162,7 +162,6 @@ bool ro_gui_alt_pressed(void);
void ro_gui_history_init(void);
void ro_gui_history_open(struct browser_window *bw, struct history *history,
bool pointer);
-void ro_gui_history_mouse_at(wimp_pointer *pointer);
/* in filetype.c */
int ro_content_filetype(struct hlcache_handle *c);
diff --git a/riscos/history.c b/riscos/history.c
index be81e1a..a4aedc6 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -33,6 +33,7 @@
#include "desktop/browser_private.h"
#include "utils/nsoption.h"
#include "riscos/gui.h"
+#include "riscos/mouse.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/wimputils.h"
@@ -51,7 +52,9 @@ wimp_w history_window;
static void ro_gui_history_redraw(wimp_draw *redraw);
static bool ro_gui_history_click(wimp_pointer *pointer);
-
+static void ro_gui_history_pointer_entering(wimp_entering *entering);
+static void ro_gui_history_track_end(wimp_leaving *leaving, void *data);
+static void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data);
/**
@@ -65,6 +68,8 @@ void ro_gui_history_init(void)
ro_gui_history_redraw);
ro_gui_wimp_event_register_mouse_click(history_window,
ro_gui_history_click);
+ ro_gui_wimp_event_register_pointer_entering_window(history_window,
+ ro_gui_history_pointer_entering);
ro_gui_wimp_event_set_help_prefix(history_window, "HelpHistory");
}
@@ -169,10 +174,37 @@ void ro_gui_history_redraw(wimp_draw *redraw)
/**
+ * Handle Pointer Entering Window events the history window.
+ *
+ * \param *entering The Wimp_PointerEnteringWindow block.
+ */
+
+void ro_gui_history_pointer_entering(wimp_entering *entering)
+{
+ ro_mouse_track_start(ro_gui_history_track_end,
+ ro_gui_history_mouse_at, NULL);
+}
+
+
+/**
+ * Handle Pointer Leaving Window events the history window. These arrive as the
+ * termination callback handler from ro_mouse's mouse tracking.
+ *
+ * \param *leaving The Wimp_PointerLeavingWindow block.
+ * \param *data NULL data pointer.
+ */
+
+void ro_gui_history_track_end(wimp_leaving *leaving, void *data)
+{
+ ro_gui_dialog_close(dialog_tooltip);
+}
+
+
+/**
* Handle mouse movements over the history window.
*/
-void ro_gui_history_mouse_at(wimp_pointer *pointer)
+void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data)
{
int x, y;
int width;
@@ -181,6 +213,8 @@ void ro_gui_history_mouse_at(wimp_pointer *pointer)
wimp_icon_state ic;
os_box box = {0, 0, 0, 0};
os_error *error;
+
+ LOG(("Mouse at..."));
/* If the mouse hasn't moved, or if we don't want tooltips, exit */
if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) ||
diff --git a/riscos/mouse.c b/riscos/mouse.c
index 12b4e3e..73535ca 100644
--- a/riscos/mouse.c
+++ b/riscos/mouse.c
@@ -27,6 +27,12 @@
* - on Null Polls while the drag is active,
* - when the drag terminates with Event_DragEnd, and
* - when the drag terminates with Escape being pressed.
+ *
+ * 2. Mouse tracking support, allowing clients to track the mouse while it
+ * remains in the current window and specify callbacks to be used
+ *
+ * - on Null Polls while the pointer is in the window, and
+ * - when the pointer leaves the window.
*/
#include "oslib/wimp.h"
@@ -44,6 +50,15 @@ static void (*ro_mouse_drag_track_callback)(wimp_pointer *pointer, void *data)
static void (*ro_mouse_drag_cancel_callback)(void *data) = NULL;
static void *ro_mouse_drag_data = NULL;
+/* Data for the wimp poll handler. */
+
+static void (*ro_mouse_poll_end_callback)(wimp_leaving *leaving, void *data)
+ = NULL;
+static void (*ro_mouse_poll_track_callback)(wimp_pointer *pointer, void *data)
+ = NULL;
+static void *ro_mouse_poll_data = NULL;
+
+
/**
* Process Null polls for any drags and mouse trackers that are currently
* active.
@@ -56,7 +71,8 @@ void ro_mouse_poll(void)
/* If no trackers are active, just exit. */
- if (ro_mouse_drag_track_callback == NULL /* && no trackers */)
+ if (ro_mouse_drag_track_callback == NULL &&
+ ro_mouse_poll_track_callback == NULL)
return;
error = xwimp_get_pointer_info(&pointer);
@@ -71,6 +87,11 @@ void ro_mouse_poll(void)
if (ro_mouse_drag_track_callback != NULL)
ro_mouse_drag_track_callback(&pointer, ro_mouse_drag_data);
+
+ /* Process the window tracker, if one is active. */
+
+ if (ro_mouse_poll_track_callback != NULL)
+ ro_mouse_poll_track_callback(&pointer, ro_mouse_poll_data);
}
@@ -106,8 +127,8 @@ void ro_mouse_drag_start(void (*drag_end)(wimp_dragged *dragged, void *data),
/**
- * Process Wimp_DragEnd events by passing the details on to any registered
- * event handler.
+ * Process Wimp_DragEnd events by terminating an active drag track and passing
+ * the details on to any registered event handler.
*
* \param *dragged The Wimp_DragEnd data block.
*/
@@ -129,3 +150,54 @@ void ro_mouse_drag_end(wimp_dragged *dragged)
ro_mouse_drag_data = NULL;
}
+
+/**
+ * Start tracking the mouse in a window, providing a function to be called on
+ * null polls and optionally one to be called when it leaves the window.
+ *
+ * \param *drag_end Callback for when the pointer leaves the window, or
+ * NULL for none.
+ * \param *drag_track Callback for mouse tracking while the pointer remains
+ * in the window, or NULL for none.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
+ void (*poll_track)(wimp_pointer *pointer, void *data),
+ void *data)
+{
+ /* It should never be possible for the mouse to be in two windows
+ * at the same time!
+ */
+
+ assert(ro_mouse_poll_end_callback == NULL &&
+ ro_mouse_poll_track_callback == NULL &&
+ ro_mouse_poll_data == NULL);
+
+ ro_mouse_poll_end_callback = poll_end;
+ ro_mouse_poll_track_callback = poll_track;
+ ro_mouse_poll_data = data;
+}
+
+
+/**
+ * Process Wimp_PointerLeaving events by terminating an active mouse track and
+ * passing the details on to any registered event handler.
+ *
+ * \param *leaving The Wimp_PointerLeaving data block.
+ */
+
+void ro_mouse_pointer_leaving_window(wimp_leaving *leaving)
+{
+ if (ro_mouse_poll_end_callback != NULL)
+ ro_mouse_poll_end_callback(leaving, ro_mouse_poll_data);
+
+ /* Poll tracking is a one-shot event, so clear the data ready for
+ * another claimant.
+ */
+
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+}
+
diff --git a/riscos/mouse.h b/riscos/mouse.h
index 623c6df..26fb72e 100644
--- a/riscos/mouse.h
+++ b/riscos/mouse.h
@@ -65,5 +65,30 @@ void ro_mouse_drag_start(void (*drag_end)(wimp_dragged *dragged, void *data),
void ro_mouse_drag_end(wimp_dragged *dragged);
+
+/**
+ * Start tracking the mouse in a window, providing a function to be called on
+ * null polls and optionally one to be called when it leaves the window.
+ *
+ * \param *drag_end Callback for when the pointer leaves the window, or
+ * NULL for none.
+ * \param *drag_track Callback for mouse tracking while the pointer remains
+ * in the window, or NULL for none.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
+ void (*poll_track)(wimp_pointer *pointer, void *data),
+ void *data);
+
+/**
+ * Process Wimp_PointerLeaving events by terminating an active mouse track and
+ * passing the details on to any registered event handler.
+ *
+ * \param *leaving The Wimp_PointerLeaving data block.
+ */
+
+void ro_mouse_pointer_leaving_window(wimp_leaving *leaving);
+
#endif
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 4641a6d..4756d8c 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -100,6 +100,7 @@ static void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv,
osbool more);
static void ro_treeview_open(wimp_open *open);
static bool ro_treeview_mouse_click(wimp_pointer *pointer);
+static void ro_treeview_pointer_entering(wimp_entering *entering);
static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
wimp_window_state *state);
static void ro_treeview_drag_end(wimp_dragged *drag, void *data);
@@ -191,6 +192,8 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
ro_gui_wimp_event_register_redraw_window(tv->w, ro_treeview_redraw);
ro_gui_wimp_event_register_scroll_window(tv->w, ro_treeview_scroll);
+ ro_gui_wimp_event_register_pointer_entering_window(tv->w,
+ ro_treeview_pointer_entering);
ro_gui_wimp_event_register_open_window(tv->w, ro_treeview_open);
ro_gui_wimp_event_register_mouse_click(tv->w, ro_treeview_mouse_click);
ro_gui_wimp_event_register_keypress(tv->w, ro_treeview_keypress);
@@ -413,6 +416,7 @@ void ro_treeview_scroll(wimp_scroll *scroll)
}
}
+
/**
* Redraw a treeview window, once the initial readraw block has been collected.
*
@@ -899,6 +903,23 @@ static bool ro_treeview_mouse_click(wimp_pointer *pointer)
/**
+ * Handle Pointer Entering Window events for treeview windows.
+ *
+ * \param *entering The Wimp_PointerEnteringWindow block.
+ */
+
+void ro_treeview_pointer_entering(wimp_entering *entering)
+{
+ ro_treeview *tv;
+
+ tv = (ro_treeview *) ro_gui_wimp_event_get_user_data(entering->w);
+ if (tv == NULL)
+ return;
+
+ ro_mouse_track_start(NULL, ro_treeview_mouse_at, NULL);
+}
+
+/**
* Track the mouse under Null Polls from the wimp, to support dragging.
*
* \param *pointer Pointer to a Wimp Pointer block.
diff --git a/riscos/url_complete.c b/riscos/url_complete.c
index e26cb65..01774f6 100644
--- a/riscos/url_complete.c
+++ b/riscos/url_complete.c
@@ -30,6 +30,7 @@
#include "utils/log.h"
#include "riscos/global_history.h"
#include "riscos/gui.h"
+#include "riscos/mouse.h"
#include "utils/nsoption.h"
#include "riscos/toolbar.h"
#include "riscos/url_complete.h"
@@ -61,6 +62,7 @@ static int mouse_y;
static bool url_complete_callback(nsurl *url,
const struct url_data *data);
+static void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, void *data);
/* This is an exported interface documented in url_complete.h */
@@ -624,7 +626,20 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw)
/* This is an exported interface documented in url_complete.h */
-void ro_gui_url_complete_mouse_at(wimp_pointer *pointer)
+void ro_gui_url_complete_entering(wimp_entering *entering)
+{
+ ro_mouse_track_start(NULL, ro_gui_url_complete_mouse_at, NULL);
+}
+
+
+/**
+ * Handle mouse movement over the URL completion window.
+ *
+ * \param *pointer The pointer state
+ * \param *data NULL data pointer expected by mouse tracker
+ */
+
+void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, void *data)
{
wimp_mouse_state current;
diff --git a/riscos/url_complete.h b/riscos/url_complete.h
index 12f6400..6a4660e 100644
--- a/riscos/url_complete.h
+++ b/riscos/url_complete.h
@@ -79,12 +79,12 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw);
/**
- * Handle mouse movement over the URL completion window.
+ * Handle the pointer entering the URL completion window.
*
- * \param pointer the pointer state
- */
+ * \param *entering The pointer entering data block.
+ */
-void ro_gui_url_complete_mouse_at(wimp_pointer *pointer);
+void ro_gui_url_complete_entering(wimp_entering *entering);
/**
diff --git a/riscos/wimp_event.c b/riscos/wimp_event.c
index 7dea8ed..e879620 100644
--- a/riscos/wimp_event.c
+++ b/riscos/wimp_event.c
@@ -96,6 +96,7 @@ struct event_window {
void (*close_window)(wimp_w w);
void (*redraw_window)(wimp_draw *redraw);
void (*scroll_window)(wimp_scroll *scroll);
+ void (*entering_window)(wimp_entering *entering);
bool (*menu_prepare)(wimp_w w, wimp_i i, wimp_menu *m,
wimp_pointer *p);
bool (*menu_selection)(wimp_w w, wimp_i i, wimp_menu *m,
@@ -1134,6 +1135,24 @@ bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll)
/**
+ * Handle any pointer entering window requests
+ *
+ * \param entering the pointer entering window request
+ */
+bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering)
+{
+ struct event_window *window;
+
+ window = ro_gui_wimp_event_find_window(entering->w);
+ if ((window) && (window->entering_window)) {
+ window->entering_window(entering);
+ return true;
+ }
+ return false;
+}
+
+
+/**
* Process a Menu click in a window, by checking for a registered window
* menu and opening it if one is found.
*
@@ -1491,6 +1510,22 @@ bool ro_gui_wimp_event_register_scroll_window(wimp_w w,
}
/**
+ * Register a function to be called for all pointer entering window requests.
+ */
+
+bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w,
+ void (*callback)(wimp_entering *entering))
+{
+ struct event_window *window;
+
+ window = ro_gui_wimp_event_get_window(w);
+ if (!window)
+ return false;
+ window->entering_window = callback;
+ return true;
+}
+
+/**
* Register a function to be called before a menu is (re-)opened.
*
* \param *w The window for which events should be returned.
@@ -1788,3 +1823,4 @@ void ro_gui_wimp_event_register_submenu(wimp_w w)
ro_gui_wimp_event_close_window(ro_gui_wimp_event_submenu);
ro_gui_wimp_event_submenu = w;
}
+
diff --git a/riscos/wimp_event.h b/riscos/wimp_event.h
index 650f35c..0a54ab0 100644
--- a/riscos/wimp_event.h
+++ b/riscos/wimp_event.h
@@ -61,6 +61,7 @@ bool ro_gui_wimp_event_open_window(wimp_open *open);
bool ro_gui_wimp_event_close_window(wimp_w w);
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw);
bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll);
+bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering);
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer);
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu);
@@ -93,6 +94,8 @@ bool ro_gui_wimp_event_register_redraw_window(wimp_w w,
void (*callback)(wimp_draw *redraw));
bool ro_gui_wimp_event_register_scroll_window(wimp_w w,
void (*callback)(wimp_scroll *scroll));
+bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w,
+ void (*callback)(wimp_entering *entering));
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w,
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
wimp_pointer *p));
diff --git a/riscos/window.c b/riscos/window.c
index dbe505e..f3a6f05 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -94,6 +94,8 @@ static void gui_window_set_extent(struct gui_window *g, int width, int height);
static void ro_gui_window_redraw(wimp_draw *redraw);
static void ro_gui_window_scroll(wimp_scroll *scroll);
+static void ro_gui_window_pointer_entering(wimp_entering *entering);
+static void ro_gui_window_track_end(wimp_leaving *leaving, void *data);
static void ro_gui_window_open(wimp_open *open);
static void ro_gui_window_close(wimp_w w);
static bool ro_gui_window_click(wimp_pointer *mouse);
@@ -546,6 +548,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
ro_gui_wimp_event_register_close_window(g->window, ro_gui_window_close);
ro_gui_wimp_event_register_redraw_window(g->window, ro_gui_window_redraw);
ro_gui_wimp_event_register_scroll_window(g->window, ro_gui_window_scroll);
+ ro_gui_wimp_event_register_pointer_entering_window(g->window, ro_gui_window_pointer_entering);
ro_gui_wimp_event_register_keypress(g->window, ro_gui_window_keypress);
ro_gui_wimp_event_register_mouse_click(g->window, ro_gui_window_click);
ro_gui_wimp_event_register_menu(g->window, ro_gui_browser_window_menu,
@@ -3134,6 +3137,37 @@ void ro_gui_window_scroll(wimp_scroll *scroll)
}
}
+/**
+ * Process Pointer Entering Window events in a browser window.
+ *
+ * \param *entering The wimp pointer entering event data block.
+ */
+
+static void ro_gui_window_pointer_entering(wimp_entering *entering)
+{
+ struct gui_window *g = ro_gui_window_lookup(entering->w);
+
+ if (g != NULL)
+ ro_mouse_track_start(ro_gui_window_track_end,
+ ro_gui_window_mouse_at, g);
+}
+
+/**
+ * Process Pointer Leaving Window events in a browser window. These arrive via
+ * the termination callback handler from ro_mouse's mouse tracking.
+ *
+ * \param *leaving The wimp pointer leaving event data block.
+ * \param *data The GUI window that the pointer is leaving.
+ */
+
+static void ro_gui_window_track_end(wimp_leaving *leaving, void *data)
+{
+ struct gui_window *g = (struct gui_window *) data;
+
+ if (g != NULL)
+ gui_window_set_pointer(g, GUI_POINTER_DEFAULT);
+}
+
/**
* Scroll a browser window, either via the core or directly using the
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e87596ad1f7755c50f7...
commit e87596ad1f7755c50f7a00edc85e66908ad1ba10
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Restructure handling of DragEnd events.
Add ro_mouse module to process mouse events during drags and on null polls.
Implement support in ro_mouse for tracking the mouse during drags and passing on DragEnd events.
Remove ro_gui_drag_end() and update all of its clients so that they use ro_mouse.
Remove the unused ro_gui_window_frame_resize_end().
Termination of save drags with Escape is unimplemented, but appears broken anyway.
The use of gui_drag_type is still required to handle Message_DatasaveAck processing.
Mouse tracking is still handled via gui.c.
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index e73a5a3..b32590b 100644
--- a/riscos/Makefile.target
+++ b/riscos/Makefile.target
@@ -71,9 +71,9 @@ endif
S_RISCOS := 401login.c assert.c bitmap.c buffer.c cookies.c configure.c \
dialog.c download.c filetype.c font.c \
global_history.c gui.c help.c history.c hotlist.c iconbar.c \
- image.c menus.c message.c palettes.c plotters.c \
+ image.c menus.c message.c mouse.c palettes.c plotters.c \
print.c query.c save.c save_draw.c save_pdf.c schedule.c \
- search.c searchweb.c sslcert.c textarea.c \
+ search.c searchweb.c sslcert.c textarea.c \
textselection.c theme.c theme_install.c thumbnail.c toolbar.c \
treeview.c ucstables.c uri.c url_complete.c url_protocol.c \
url_suggest.c wimp.c wimp_event.c window.c \
diff --git a/riscos/download.c b/riscos/download.c
index 089714c..3e70767 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -45,6 +45,7 @@
#include "desktop/netsurf.h"
#include "riscos/dialog.h"
#include "utils/nsoption.h"
+#include "riscos/mouse.h"
#include "riscos/save.h"
#include "riscos/query.h"
#include "riscos/wimp.h"
@@ -133,7 +134,7 @@ static int download_progress_y1;
static char *download_dir = NULL;
static size_t download_dir_len;
-
+static void ro_gui_download_drag_end(wimp_dragged *drag, void *data);
static const char *ro_gui_download_temp_name(struct gui_download_window *dw);
static void ro_gui_download_update_status(struct gui_download_window *dw);
static void ro_gui_download_update_status_wrapper(void *p);
@@ -814,8 +815,9 @@ bool ro_gui_download_click(wimp_pointer *pointer)
os_error *error;
dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(pointer->w);
- if (pointer->i == ICON_DOWNLOAD_ICON && !dw->error &&
- !dw->saved) {
+ if ((pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) &&
+ pointer->i == ICON_DOWNLOAD_ICON &&
+ !dw->error && !dw->saved) {
const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i);
int x = pointer->pos.x, y = pointer->pos.y;
wimp_window_state wstate;
@@ -830,6 +832,7 @@ bool ro_gui_download_click(wimp_pointer *pointer)
wstate.visible.y1 - wstate.yscroll;
}
gui_current_drag_type = GUI_DRAG_DOWNLOAD_SAVE;
+ ro_mouse_drag_start(ro_gui_download_drag_end, NULL, NULL, NULL);
download_window_current = dw;
ro_gui_drag_icon(x, y, sprite);
@@ -899,10 +902,11 @@ bool ro_gui_download_keypress(wimp_key *key)
/**
* Handle User_Drag_Box event for a drag from a download window.
*
- * \param drag block returned by Wimp_Poll
+ * \param *drag block returned by Wimp_Poll
+ * \param *data NULL data to allow use as callback from ro_mouse.
*/
-void ro_gui_download_drag_end(wimp_dragged *drag)
+static void ro_gui_download_drag_end(wimp_dragged *drag, void *data)
{
wimp_pointer pointer;
wimp_message message;
diff --git a/riscos/gui.c b/riscos/gui.c
index 5811454..11ed3f4 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -74,6 +74,7 @@
#include "riscos/iconbar.h"
#include "riscos/menus.h"
#include "riscos/message.h"
+#include "riscos/mouse.h"
#include "riscos/print.h"
#include "riscos/query.h"
#include "riscos/save.h"
@@ -243,7 +244,6 @@ static void ro_gui_close_window_request(wimp_close *close);
static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
static void ro_gui_pointer_entering_window(wimp_entering *entering);
static void ro_gui_check_resolvers(void);
-static void ro_gui_drag_end(wimp_dragged *drag);
static void ro_gui_keypress(wimp_key *key);
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
static void ro_msg_dataload(wimp_message *block);
@@ -1123,7 +1123,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_USER_DRAG_BOX:
- ro_gui_drag_end(&(block->dragged));
+ ro_mouse_drag_end(&block->dragged);
break;
case wimp_KEY_PRESSED:
@@ -1162,6 +1162,8 @@ void ro_gui_null_reason_code(void)
os_error *error;
ro_gui_throb();
+
+ ro_mouse_poll();
if (!gui_track)
return;
@@ -1179,11 +1181,11 @@ void ro_gui_null_reason_code(void)
/* pointer is allowed to wander outside the initiating window
for certain drag types */
- case GUI_DRAG_SELECTION:
+ //case GUI_DRAG_SELECTION:
case GUI_DRAG_SCROLL:
- case GUI_DRAG_FRAME:
+ //case GUI_DRAG_FRAME:
assert(gui_track_gui_window);
- ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
+ ro_gui_window_mouse_at(&pointer, gui_track_gui_window);
break;
// case GUI_DRAG_SAVE:
@@ -1194,14 +1196,14 @@ void ro_gui_null_reason_code(void)
if (ro_gui_global_history_check_window(gui_track_wimp_w) ||
ro_gui_hotlist_check_window(gui_track_wimp_w) ||
ro_gui_cookies_check_window(gui_track_wimp_w))
- ro_treeview_mouse_at(&pointer);
+ ro_treeview_mouse_at(&pointer, NULL);
if (gui_track_wimp_w == history_window)
ro_gui_history_mouse_at(&pointer);
if (gui_track_wimp_w == dialog_url_complete)
ro_gui_url_complete_mouse_at(&pointer);
else if (gui_track_gui_window)
- ro_gui_window_mouse_at(gui_track_gui_window,
- &pointer);
+ ro_gui_window_mouse_at(&pointer,
+ gui_track_gui_window);
break;
}
}
@@ -1252,13 +1254,15 @@ void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
{
if (gui_track_wimp_w == history_window)
ro_gui_dialog_close(dialog_tooltip);
+
+ LOG(("Leaving window 0x%x", leaving->w));
switch (gui_current_drag_type) {
case GUI_DRAG_SELECTION:
case GUI_DRAG_SCROLL:
case GUI_DRAG_SAVE:
case GUI_DRAG_FRAME:
- case GUI_DRAG_TREEVIEW:
+ //case GUI_DRAG_TREEVIEW:
/* ignore Pointer_Leaving_Window event that the Wimp mysteriously
issues when a Wimp_DragBox drag operation is started */
break;
@@ -1280,12 +1284,14 @@ void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
void ro_gui_pointer_entering_window(wimp_entering *entering)
{
+ LOG(("Entering window 0x%x", entering->w));
+
switch (gui_current_drag_type) {
case GUI_DRAG_SELECTION:
case GUI_DRAG_SCROLL:
case GUI_DRAG_SAVE:
case GUI_DRAG_FRAME:
- case GUI_DRAG_TREEVIEW:
+ //case GUI_DRAG_TREEVIEW:
/* ignore entering new windows/frames */
break;
default:
@@ -1303,54 +1309,6 @@ void ro_gui_pointer_entering_window(wimp_entering *entering)
/**
- * Handle User_Drag_Box events.
- */
-
-void ro_gui_drag_end(wimp_dragged *drag)
-{
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- assert(gui_track_gui_window);
- ro_gui_selection_drag_end(gui_track_gui_window, drag);
- break;
-
- case GUI_DRAG_SCROLL:
- assert(gui_track_gui_window);
- ro_gui_window_scroll_end(gui_track_gui_window, drag);
- break;
-
- case GUI_DRAG_DOWNLOAD_SAVE:
- ro_gui_download_drag_end(drag);
- break;
-
- case GUI_DRAG_SAVE:
- ro_gui_save_drag_end(drag);
- break;
-
- case GUI_DRAG_STATUS_RESIZE:
- break;
-
- case GUI_DRAG_TREEVIEW:
- ro_treeview_drag_end(drag);
- break;
-
- case GUI_DRAG_BUTTONBAR:
- ro_gui_button_bar_drag_end(drag);
- break;
-
- case GUI_DRAG_FRAME:
- assert(gui_track_gui_window);
- ro_gui_window_frame_resize_end(gui_track_gui_window, drag);
- break;
-
- default:
- assert(gui_current_drag_type == GUI_DRAG_NONE);
- break;
- }
-}
-
-
-/**
* Handle Key_Pressed events.
*/
diff --git a/riscos/gui.h b/riscos/gui.h
index b9e0647..8f165c0 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -124,7 +124,6 @@ const char *ro_gui_default_language(void);
/* in download.c */
void ro_gui_download_init(void);
-void ro_gui_download_drag_end(wimp_dragged *drag);
void ro_gui_download_datasave_ack(wimp_message *message);
bool ro_gui_download_prequit(void);
@@ -133,11 +132,9 @@ void ro_gui_401login_init(void);
/* in window.c */
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
-void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
+void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data);
void ro_gui_window_iconise(struct gui_window *g,
wimp_full_message_window_info *wi);
-void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
-void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag);
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
void ro_gui_window_redraw_all(void);
void ro_gui_window_update_boxes(void);
diff --git a/riscos/mouse.c b/riscos/mouse.c
new file mode 100644
index 0000000..12b4e3e
--- /dev/null
+++ b/riscos/mouse.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2013 Stephen Fryatt <stevef(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file mouse.c
+ * Mouse dragging and tracking support (implementation).
+ *
+ * Two different functions are provided:-
+ *
+ * 1. Wimp_DragBox support, allowing clients to start a drag and specify
+ * callbacks to be used
+ *
+ * - on Null Polls while the drag is active,
+ * - when the drag terminates with Event_DragEnd, and
+ * - when the drag terminates with Escape being pressed.
+ */
+
+#include "oslib/wimp.h"
+
+#include "riscos/mouse.h"
+#include "utils/log.h"
+#include "utils/utils.h"
+
+/* Data for the wimp drag handler. */
+
+static void (*ro_mouse_drag_end_callback)(wimp_dragged *dragged, void *data)
+ = NULL;
+static void (*ro_mouse_drag_track_callback)(wimp_pointer *pointer, void *data)
+ = NULL;
+static void (*ro_mouse_drag_cancel_callback)(void *data) = NULL;
+static void *ro_mouse_drag_data = NULL;
+
+/**
+ * Process Null polls for any drags and mouse trackers that are currently
+ * active.
+ */
+
+void ro_mouse_poll(void)
+{
+ wimp_pointer pointer;
+ os_error *error;
+
+ /* If no trackers are active, just exit. */
+
+ if (ro_mouse_drag_track_callback == NULL /* && no trackers */)
+ return;
+
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ LOG(("xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ /* Process the drag tracker, if one is active. */
+
+ if (ro_mouse_drag_track_callback != NULL)
+ ro_mouse_drag_track_callback(&pointer, ro_mouse_drag_data);
+}
+
+
+/**
+ * Start a drag, providing a function to be called when the Wimp_DragEnd event
+ * is received and optionally a tracking function to be called on null polls
+ * in between times.
+ *
+ * \param *drag_end Callback for when the drag terminates, or NULL for none.
+ * \param *drag_track Callback for mouse tracking during the drag, or NULL for
+ * none.
+ * \param *drag_cancel Callback for cancelling the drag, or NULL if the drag
+ * can't be cancelled.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_drag_start(void (*drag_end)(wimp_dragged *dragged, void *data),
+ void (*drag_track)(wimp_pointer *pointer, void *data),
+ void (*drag_cancel)(void *data), void *data)
+{
+ /* A drag should never be started when one is already in progress. */
+
+ assert(ro_mouse_drag_end_callback == NULL &&
+ ro_mouse_drag_track_callback == NULL &&
+ ro_mouse_drag_cancel_callback == NULL &&
+ ro_mouse_drag_data == NULL);
+
+ ro_mouse_drag_end_callback = drag_end;
+ ro_mouse_drag_track_callback = drag_track;
+ ro_mouse_drag_cancel_callback = drag_cancel;
+ ro_mouse_drag_data = data;
+}
+
+
+/**
+ * Process Wimp_DragEnd events by passing the details on to any registered
+ * event handler.
+ *
+ * \param *dragged The Wimp_DragEnd data block.
+ */
+
+void ro_mouse_drag_end(wimp_dragged *dragged)
+{
+ if (ro_mouse_drag_end_callback != NULL)
+ ro_mouse_drag_end_callback(dragged, ro_mouse_drag_data);
+ else
+ warn_user("WimpError", "No callback");
+
+ /* Wimp_DragEnd is a one-shot event, so clear the data ready for
+ * another claimant.
+ */
+
+ ro_mouse_drag_end_callback = NULL;
+ ro_mouse_drag_track_callback = NULL;
+ ro_mouse_drag_cancel_callback = NULL;
+ ro_mouse_drag_data = NULL;
+}
+
diff --git a/riscos/mouse.h b/riscos/mouse.h
new file mode 100644
index 0000000..623c6df
--- /dev/null
+++ b/riscos/mouse.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2013 Stephen Fryatt <stevef(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/** \file mouse.h
+ * Mouse dragging and tracking support (interface).
+ */
+
+#ifndef _NETSURF_RISCOS_MOUSE_H_
+#define _NETSURF_RISCOS_MOUSE_H_
+
+enum ro_mouse_track_response {
+ RO_MOUSE_RESPONSE_LOW,
+ RO_MOUSE_RESPONSE_HIGH
+};
+
+
+/**
+ * Process Null polls for any drags and mouse trackers that are currently
+ * active.
+ */
+
+void ro_mouse_poll(void);
+
+
+/**
+ * Start a drag, providing a function to be called when the Wimp_DragEnd event
+ * is received and optionally a tracking function to be called on null polls
+ * in between times.
+ *
+ * \param *drag_end Callback for when the drag terminates, or NULL for none.
+ * \param *drag_track Callback for mouse tracking during the drag, or NULL for
+ * none.
+ * \param *drag_cancel Callback for cancelling the drag, or NULL if the drag
+ * can't be cancelled.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_drag_start(void (*drag_end)(wimp_dragged *dragged, void *data),
+ void (*drag_track)(wimp_pointer *pointer, void *data),
+ void (*drag_cancel)(void *data), void *data);
+
+
+/**
+ * Process Wimp_DragEnd events by passing the details on to any registered
+ * event handler.
+ *
+ * \param *dragged The Wimp_DragEnd data block.
+ */
+
+void ro_mouse_drag_end(wimp_dragged *dragged);
+
+#endif
+
diff --git a/riscos/save.c b/riscos/save.c
index ad2d4c4..ffda9c6 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -49,6 +49,7 @@
#include "riscos/gui.h"
#include "riscos/menus.h"
#include "riscos/message.h"
+#include "riscos/mouse.h"
#include "utils/nsoption.h"
#include "riscos/query.h"
#include "riscos/save.h"
@@ -110,6 +111,7 @@ static bool ro_gui_save_link(const char *url, const char *title, link_format for
static void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
const char *url, char *leaf_buf, size_t leaf_len,
char *icon_buf, size_t icon_len);
+static void ro_gui_save_drag_end(wimp_dragged *drag, void *data);
static bool ro_gui_save_create_thumbnail(hlcache_handle *h, const char *name);
static void ro_gui_save_overwrite_confirmed(query_id, enum query_response res, void *p);
static void ro_gui_save_overwrite_cancelled(query_id, enum query_response res, void *p);
@@ -305,6 +307,7 @@ void ro_gui_save_start_drag(wimp_pointer *pointer)
wstate.visible.y1 - wstate.yscroll;
}
gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
gui_save_sourcew = pointer->w;
saving_from_dialog = true;
gui_save_close_after = !(pointer->buttons & wimp_DRAG_ADJUST);
@@ -382,6 +385,7 @@ void gui_drag_save_object(gui_save_type save_type, hlcache_handle *c,
icon_buf, sizeof(icon_buf));
gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
@@ -430,6 +434,7 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
icon_buf, sizeof(icon_buf));
gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
@@ -474,6 +479,7 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
icon_buf, sizeof(icon_buf));
gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
@@ -598,9 +604,12 @@ void ro_gui_drag_box_cancel(void)
/**
* Handle User_Drag_Box event for a drag from the save dialog or browser window.
+ *
+ * \param *drag The Wimp_DragEnd data block.
+ * \param *data NULL, as function is used as a callback from ro_mouse.
*/
-void ro_gui_save_drag_end(wimp_dragged *drag)
+static void ro_gui_save_drag_end(wimp_dragged *drag, void *data)
{
const char *name;
wimp_pointer pointer;
@@ -714,6 +723,7 @@ void ro_gui_send_datasave(gui_save_type save_type,
gui_save_current_type = save_type;
gui_save_sourcew = (wimp_w)-1;
saving_from_dialog = false;
+
gui_current_drag_type = GUI_DRAG_SAVE;
}
}
diff --git a/riscos/save.h b/riscos/save.h
index b219de4..34a4a6b 100644
--- a/riscos/save.h
+++ b/riscos/save.h
@@ -37,7 +37,6 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
const char *title, struct gui_window *g);
void ro_gui_drag_icon(int x, int y, const char *sprite);
void ro_gui_drag_box_cancel(void);
-void ro_gui_save_drag_end(wimp_dragged *drag);
void ro_gui_send_datasave(gui_save_type save_type, wimp_full_message_data_xfer *message, wimp_t to);
void ro_gui_save_datasave_ack(wimp_message *message);
bool ro_gui_save_ok(wimp_w w);
diff --git a/riscos/textselection.c b/riscos/textselection.c
index 094924b..501ac97 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -31,6 +31,7 @@
#include "riscos/gui.h"
#include "riscos/menus.h"
#include "riscos/message.h"
+#include "riscos/mouse.h"
#include "riscos/save.h"
#include "riscos/textselection.h"
#include "utils/log.h"
@@ -66,6 +67,7 @@ static ro_gui_selection_prepare_paste_cb paste_cb = NULL;
static void *paste_cb_pw = NULL;
static int paste_prev_message = 0;
+static void ro_gui_selection_drag_end(wimp_dragged *drag, void *g);
static void ro_gui_discard_clipboard_contents(void);
static void ro_gui_dragging_bounced(wimp_message *message);
@@ -125,7 +127,9 @@ void gui_start_selection(struct gui_window *g)
error->errnum, error->errmess));
gui_current_drag_type = GUI_DRAG_SELECTION;
- gui_track_gui_window = g;
+ gui_track_gui_window = g; // \TODO -- Remove?
+ ro_mouse_drag_start(ro_gui_selection_drag_end, ro_gui_window_mouse_at,
+ NULL, g);
drag.type = wimp_DRAG_USER_POINT;
/* Don't constrain mouse pointer during drags */
@@ -147,16 +151,17 @@ void gui_start_selection(struct gui_window *g)
/**
* End of text selection drag operation
*
- * \param g gui window
- * \param dragged position of pointer at conclusion of drag
+ * \param *drag position of pointer at conclusion of drag
+ * \param *data gui window pointer.
*/
-void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag)
+static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
{
wimp_auto_scroll_info scroll;
wimp_pointer pointer;
os_error *error;
os_coord pos;
+ struct gui_window *g = (struct gui_window *) data;
LOG(("ending text selection drag"));
diff --git a/riscos/textselection.h b/riscos/textselection.h
index a3763b4..c6f96f0 100644
--- a/riscos/textselection.h
+++ b/riscos/textselection.h
@@ -35,7 +35,6 @@ bool ro_gui_selection_prepare_paste_datasave(
bool ro_gui_selection_prepare_paste_dataload(
wimp_full_message_data_xfer *dataxfer);
-void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag);
void ro_gui_selection_claim_entity(wimp_full_message_claim_entity *claim);
void ro_gui_selection_data_request(wimp_full_message_data_request *req);
bool ro_gui_save_clipboard(const char *path);
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 51b6809..4641a6d 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -45,6 +45,7 @@
#include "riscos/gui.h"
#include "riscos/image.h"
#include "riscos/menus.h"
+#include "riscos/mouse.h"
#include "riscos/toolbar.h"
#include "riscos/tinct.h"
#include "riscos/textarea.h"
@@ -101,6 +102,7 @@ static void ro_treeview_open(wimp_open *open);
static bool ro_treeview_mouse_click(wimp_pointer *pointer);
static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
wimp_window_state *state);
+static void ro_treeview_drag_end(wimp_dragged *drag, void *data);
static bool ro_treeview_keypress(wimp_key *key);
static void ro_treeview_set_window_extent(ro_treeview *tv,
@@ -899,10 +901,11 @@ static bool ro_treeview_mouse_click(wimp_pointer *pointer)
/**
* Track the mouse under Null Polls from the wimp, to support dragging.
*
- * \param *pointer Pointer to a Wimp Pointer block.
+ * \param *pointer Pointer to a Wimp Pointer block.
+ * \param *data NULL to allow use as a ro_mouse callback.
*/
-void ro_treeview_mouse_at(wimp_pointer *pointer)
+void ro_treeview_mouse_at(wimp_pointer *pointer, void *data)
{
os_error *error;
ro_treeview *tv;
@@ -1011,6 +1014,8 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
break;
}
+ LOG(("Drag start..."));
+
error = xwimp_drag_box_with_flags(&drag,
wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP);
if (error) {
@@ -1034,8 +1039,9 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
-
- gui_current_drag_type = GUI_DRAG_TREEVIEW;
+
+ ro_mouse_drag_start(ro_treeview_drag_end, ro_treeview_mouse_at,
+ NULL, NULL);
}
}
@@ -1045,9 +1051,10 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
* started by ro_treeview_drag_start().
*
* \param *drag Pointer to the User Drag Box Event block.
+ * \param *data NULL to allow use as a ro_mouse callback.
*/
-void ro_treeview_drag_end(wimp_dragged *drag)
+static void ro_treeview_drag_end(wimp_dragged *drag, void *data)
{
os_error *error;
diff --git a/riscos/treeview.h b/riscos/treeview.h
index 77505ac..80ff766 100644
--- a/riscos/treeview.h
+++ b/riscos/treeview.h
@@ -48,8 +48,7 @@ struct tree *ro_treeview_get_tree(ro_treeview *tv);
wimp_w ro_treeview_get_window(ro_treeview *tv);
void ro_treeview_set_origin(ro_treeview *tv, int x, int y);
-void ro_treeview_mouse_at(wimp_pointer *pointer);
-void ro_treeview_drag_end(wimp_dragged *drag);
+void ro_treeview_mouse_at(wimp_pointer *pointer, void *data);
int ro_treeview_get_help(help_full_message_request *message_data);
#endif
diff --git a/riscos/window.c b/riscos/window.c
index d3375be..dbe505e 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -68,6 +68,7 @@
#include "riscos/help.h"
#include "riscos/hotlist.h"
#include "riscos/menus.h"
+#include "riscos/mouse.h"
#include "utils/nsoption.h"
#include "riscos/oslib_pre7.h"
#include "riscos/save.h"
@@ -108,6 +109,8 @@ static bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
wimp_selection *selection, menu_action action);
static void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu);
+static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data);
+
static void ro_gui_window_scroll_action(struct gui_window *g,
int scroll_x, int scroll_y);
@@ -1239,8 +1242,10 @@ bool gui_window_scroll_start(struct gui_window *g)
return false;
}
- gui_track_gui_window = g;
+ gui_track_gui_window = g; // \TODO -- Remove?
gui_current_drag_type = GUI_DRAG_SCROLL;
+ ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
+ NULL, g);
return true;
}
@@ -1295,6 +1300,8 @@ bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
case GDRAGGING_SCROLLBAR:
/* Dragging a core scrollbar */
gui_current_drag_type = GUI_DRAG_SCROLL;
+ ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
+ NULL, g);
break;
default:
@@ -3350,13 +3357,14 @@ bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
/**
* Handle pointer movements in a browser window.
*
- * \param g browser window that the pointer is in
- * \param pointer new mouse position
+ * \param *pointer new mouse position
+ * \param *data browser window that the pointer is in
*/
-void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
+void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
{
os_coord pos;
+ struct gui_window *g = (struct gui_window *) data;
if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
browser_window_mouse_track(g->bw,
@@ -3500,14 +3508,16 @@ void ro_gui_window_iconise(struct gui_window *g,
/**
* Completes scrolling of a browser window
*
- * \param g gui window
+ * \param *drag The DragEnd event data block.
+ * \param *data gui window block pointer.
*/
-void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
+static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
{
wimp_pointer pointer;
os_error *error;
os_coord pos;
+ struct gui_window *g = (struct gui_window *) data;
gui_current_drag_type = GUI_DRAG_NONE;
if (!g)
@@ -3541,19 +3551,6 @@ void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
/**
- * Completes resizing of a browser frame
- *
- * \param g gui window
- */
-
-void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag)
-{
- /* our clean-up is the same as for page scrolling */
- ro_gui_window_scroll_end(g, drag);
-}
-
-
-/**
* Process Mouse_Click events in a toolbar's button bar. This does not handle
* other clicks in a toolbar: these are handled by the toolbar module itself.
*
-----------------------------------------------------------------------
Summary of changes:
riscos/Makefile.target | 4 +-
riscos/dialog.c | 2 +
riscos/download.c | 17 ++-
riscos/gui.c | 201 +++------------------------------------
riscos/gui.h | 13 +--
riscos/gui/button_bar.c | 17 +++-
riscos/gui/button_bar.h | 9 --
riscos/gui/status_bar.c | 1 -
riscos/history.c | 38 +++++++-
riscos/mouse.c | 244 +++++++++++++++++++++++++++++++++++++++++++++++
riscos/mouse.h | 113 ++++++++++++++++++++++
riscos/save.c | 23 +++--
riscos/save.h | 1 -
riscos/textselection.c | 17 ++--
riscos/textselection.h | 1 -
riscos/treeview.c | 45 +++++++--
riscos/treeview.h | 3 +-
riscos/url_complete.c | 17 +++-
riscos/url_complete.h | 8 +-
riscos/wimp_event.c | 36 +++++++
riscos/wimp_event.h | 3 +
riscos/window.c | 76 ++++++++++-----
22 files changed, 604 insertions(+), 285 deletions(-)
create mode 100644 riscos/mouse.c
create mode 100644 riscos/mouse.h
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index e73a5a3..b32590b 100644
--- a/riscos/Makefile.target
+++ b/riscos/Makefile.target
@@ -71,9 +71,9 @@ endif
S_RISCOS := 401login.c assert.c bitmap.c buffer.c cookies.c configure.c \
dialog.c download.c filetype.c font.c \
global_history.c gui.c help.c history.c hotlist.c iconbar.c \
- image.c menus.c message.c palettes.c plotters.c \
+ image.c menus.c message.c mouse.c palettes.c plotters.c \
print.c query.c save.c save_draw.c save_pdf.c schedule.c \
- search.c searchweb.c sslcert.c textarea.c \
+ search.c searchweb.c sslcert.c textarea.c \
textselection.c theme.c theme_install.c thumbnail.c toolbar.c \
treeview.c ucstables.c uri.c url_complete.c url_protocol.c \
url_suggest.c wimp.c wimp_event.c window.c \
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 0726cb3..7a333e6 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -158,6 +158,8 @@ void ro_gui_dialog_init(void)
dialog_url_complete = ro_gui_dialog_create("url_suggest");
ro_gui_wimp_event_register_mouse_click(dialog_url_complete,
ro_gui_url_complete_click);
+ ro_gui_wimp_event_register_pointer_entering_window(dialog_url_complete,
+ ro_gui_url_complete_entering);
ro_gui_wimp_event_register_redraw_window(dialog_url_complete,
ro_gui_url_complete_redraw);
ro_gui_wimp_event_set_help_prefix(dialog_url_complete, "HelpAutoURL");
diff --git a/riscos/download.c b/riscos/download.c
index 089714c..ebd981d 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -45,6 +45,7 @@
#include "desktop/netsurf.h"
#include "riscos/dialog.h"
#include "utils/nsoption.h"
+#include "riscos/mouse.h"
#include "riscos/save.h"
#include "riscos/query.h"
#include "riscos/wimp.h"
@@ -133,7 +134,7 @@ static int download_progress_y1;
static char *download_dir = NULL;
static size_t download_dir_len;
-
+static void ro_gui_download_drag_end(wimp_dragged *drag, void *data);
static const char *ro_gui_download_temp_name(struct gui_download_window *dw);
static void ro_gui_download_update_status(struct gui_download_window *dw);
static void ro_gui_download_update_status_wrapper(void *p);
@@ -814,8 +815,9 @@ bool ro_gui_download_click(wimp_pointer *pointer)
os_error *error;
dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(pointer->w);
- if (pointer->i == ICON_DOWNLOAD_ICON && !dw->error &&
- !dw->saved) {
+ if ((pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) &&
+ pointer->i == ICON_DOWNLOAD_ICON &&
+ !dw->error && !dw->saved) {
const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i);
int x = pointer->pos.x, y = pointer->pos.y;
wimp_window_state wstate;
@@ -829,7 +831,7 @@ bool ro_gui_download_click(wimp_pointer *pointer)
y = (istate.icon.extent.y1 + istate.icon.extent.y0)/2 +
wstate.visible.y1 - wstate.yscroll;
}
- gui_current_drag_type = GUI_DRAG_DOWNLOAD_SAVE;
+ ro_mouse_drag_start(ro_gui_download_drag_end, NULL, NULL, NULL);
download_window_current = dw;
ro_gui_drag_icon(x, y, sprite);
@@ -899,10 +901,11 @@ bool ro_gui_download_keypress(wimp_key *key)
/**
* Handle User_Drag_Box event for a drag from a download window.
*
- * \param drag block returned by Wimp_Poll
+ * \param *drag block returned by Wimp_Poll
+ * \param *data NULL data to allow use as callback from ro_mouse.
*/
-void ro_gui_download_drag_end(wimp_dragged *drag)
+static void ro_gui_download_drag_end(wimp_dragged *drag, void *data)
{
wimp_pointer pointer;
wimp_message message;
@@ -950,6 +953,8 @@ void ro_gui_download_drag_end(wimp_dragged *drag)
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+
+ gui_current_drag_type = GUI_DRAG_DOWNLOAD_SAVE;
}
diff --git a/riscos/gui.c b/riscos/gui.c
index 5811454..69ec7e8 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -74,6 +74,7 @@
#include "riscos/iconbar.h"
#include "riscos/menus.h"
#include "riscos/message.h"
+#include "riscos/mouse.h"
#include "riscos/print.h"
#include "riscos/query.h"
#include "riscos/save.h"
@@ -160,13 +161,6 @@ const char * NETSURF_DIR;
static const char *task_name = "NetSurf";
#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
-/** The pointer is over a window which is tracking mouse movement. */
-static bool gui_track = false;
-/** Handle of window which the pointer is over. */
-static wimp_w gui_track_wimp_w;
-/** Browser window which the pointer is over, or 0 if none. */
-struct gui_window *gui_track_gui_window;
-
ro_gui_drag_type gui_current_drag_type;
wimp_t task_handle; /**< RISC OS wimp task handle. */
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
@@ -238,12 +232,8 @@ static void ro_gui_choose_language(void);
static void ro_gui_signal(int sig);
static void ro_gui_cleanup(void);
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
-static void ro_gui_null_reason_code(void);
static void ro_gui_close_window_request(wimp_close *close);
-static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
-static void ro_gui_pointer_entering_window(wimp_entering *entering);
static void ro_gui_check_resolvers(void);
-static void ro_gui_drag_end(wimp_dragged *drag);
static void ro_gui_keypress(wimp_key *key);
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
static void ro_msg_dataload(wimp_message *block);
@@ -1031,26 +1021,19 @@ void gui_poll(bool active)
wimp_block block;
const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN |
wimp_SAVE_FP;
+ os_t track_poll_offset;
/* Poll wimp. */
xhourglass_off();
+ track_poll_offset = ro_mouse_poll_interval();
if (active) {
event = wimp_poll(mask, &block, 0);
- } else if (sched_active || gui_track || browser_reformat_pending ||
+ } else if (sched_active || (track_poll_offset > 0) || browser_reformat_pending ||
bitmap_maintenance) {
os_t t = os_read_monotonic_time();
- if (gui_track)
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- t += 4; /* for smoother update */
- break;
-
- default:
- t += 10;
- break;
- }
+ if (track_poll_offset > 0)
+ t += track_poll_offset;
else
t += 10;
@@ -1095,7 +1078,8 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
{
switch (event) {
case wimp_NULL_REASON_CODE:
- ro_gui_null_reason_code();
+ ro_gui_throb();
+ ro_mouse_poll();
break;
case wimp_REDRAW_WINDOW_REQUEST:
@@ -1111,11 +1095,11 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_POINTER_LEAVING_WINDOW:
- ro_gui_pointer_leaving_window(&block->leaving);
+ ro_mouse_pointer_leaving_window(&block->leaving);
break;
case wimp_POINTER_ENTERING_WINDOW:
- ro_gui_pointer_entering_window(&block->entering);
+ ro_gui_wimp_event_pointer_entering_window(&block->entering);
break;
case wimp_MOUSE_CLICK:
@@ -1123,7 +1107,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_USER_DRAG_BOX:
- ro_gui_drag_end(&(block->dragged));
+ ro_mouse_drag_end(&block->dragged);
break;
case wimp_KEY_PRESSED:
@@ -1153,61 +1137,6 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
/**
- * Handle Null_Reason_Code events.
- */
-
-void ro_gui_null_reason_code(void)
-{
- wimp_pointer pointer;
- os_error *error;
-
- ro_gui_throb();
-
- if (!gui_track)
- return;
-
- error = xwimp_get_pointer_info(&pointer);
- if (error) {
- LOG(("xwimp_get_pointer_info: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return;
- }
-
- switch (gui_current_drag_type) {
-
- /* pointer is allowed to wander outside the initiating window
- for certain drag types */
-
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- case GUI_DRAG_FRAME:
- assert(gui_track_gui_window);
- ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
- break;
-
-// case GUI_DRAG_SAVE:
-// ro_gui_selection_send_dragging(&pointer);
-// break;
-
- default:
- if (ro_gui_global_history_check_window(gui_track_wimp_w) ||
- ro_gui_hotlist_check_window(gui_track_wimp_w) ||
- ro_gui_cookies_check_window(gui_track_wimp_w))
- ro_treeview_mouse_at(&pointer);
- if (gui_track_wimp_w == history_window)
- ro_gui_history_mouse_at(&pointer);
- if (gui_track_wimp_w == dialog_url_complete)
- ro_gui_url_complete_mouse_at(&pointer);
- else if (gui_track_gui_window)
- ro_gui_window_mouse_at(gui_track_gui_window,
- &pointer);
- break;
- }
-}
-
-
-/**
* Handle Open_Window_Request events.
*/
@@ -1245,112 +1174,6 @@ void ro_gui_close_window_request(wimp_close *close)
/**
- * Handle Pointer_Leaving_Window events.
- */
-
-void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
-{
- if (gui_track_wimp_w == history_window)
- ro_gui_dialog_close(dialog_tooltip);
-
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- case GUI_DRAG_SAVE:
- case GUI_DRAG_FRAME:
- case GUI_DRAG_TREEVIEW:
- /* ignore Pointer_Leaving_Window event that the Wimp mysteriously
- issues when a Wimp_DragBox drag operation is started */
- break;
-
- default:
- if (gui_track_gui_window)
- gui_window_set_pointer(gui_track_gui_window, GUI_POINTER_DEFAULT);
- gui_track_wimp_w = 0;
- gui_track_gui_window = NULL;
- gui_track = false;
- break;
- }
-}
-
-
-/**
- * Handle Pointer_Entering_Window events.
- */
-
-void ro_gui_pointer_entering_window(wimp_entering *entering)
-{
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- case GUI_DRAG_SCROLL:
- case GUI_DRAG_SAVE:
- case GUI_DRAG_FRAME:
- case GUI_DRAG_TREEVIEW:
- /* ignore entering new windows/frames */
- break;
- default:
- gui_track_wimp_w = entering->w;
- gui_track_gui_window = ro_gui_window_lookup(entering->w);
- gui_track = gui_track_gui_window ||
- gui_track_wimp_w == history_window ||
- gui_track_wimp_w == dialog_url_complete ||
- ro_gui_hotlist_check_window(gui_track_wimp_w) ||
- ro_gui_global_history_check_window(gui_track_wimp_w) ||
- ro_gui_cookies_check_window(gui_track_wimp_w);
- break;
- }
-}
-
-
-/**
- * Handle User_Drag_Box events.
- */
-
-void ro_gui_drag_end(wimp_dragged *drag)
-{
- switch (gui_current_drag_type) {
- case GUI_DRAG_SELECTION:
- assert(gui_track_gui_window);
- ro_gui_selection_drag_end(gui_track_gui_window, drag);
- break;
-
- case GUI_DRAG_SCROLL:
- assert(gui_track_gui_window);
- ro_gui_window_scroll_end(gui_track_gui_window, drag);
- break;
-
- case GUI_DRAG_DOWNLOAD_SAVE:
- ro_gui_download_drag_end(drag);
- break;
-
- case GUI_DRAG_SAVE:
- ro_gui_save_drag_end(drag);
- break;
-
- case GUI_DRAG_STATUS_RESIZE:
- break;
-
- case GUI_DRAG_TREEVIEW:
- ro_treeview_drag_end(drag);
- break;
-
- case GUI_DRAG_BUTTONBAR:
- ro_gui_button_bar_drag_end(drag);
- break;
-
- case GUI_DRAG_FRAME:
- assert(gui_track_gui_window);
- ro_gui_window_frame_resize_end(gui_track_gui_window, drag);
- break;
-
- default:
- assert(gui_current_drag_type == GUI_DRAG_NONE);
- break;
- }
-}
-
-
-/**
* Handle Key_Pressed events.
*/
@@ -1961,6 +1784,8 @@ void ro_msg_datasave_ack(wimp_message *message)
default:
break;
}
+
+ gui_current_drag_type = GUI_DRAG_NONE;
}
diff --git a/riscos/gui.h b/riscos/gui.h
index b9e0647..5089315 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -54,7 +54,6 @@ extern wimp_w dialog_info, dialog_saveas, dialog_zoom, dialog_pageinfo,
dialog_objinfo, dialog_tooltip, dialog_warning, dialog_openurl,
dialog_debug, dialog_folder, dialog_entry, dialog_url_complete,
dialog_search, dialog_print, dialog_theme_install;
-extern struct gui_window *gui_track_gui_window;
extern wimp_w current_menu_window;
extern bool current_menu_open;
extern wimp_menu *recent_search_menu; /* search.c */
@@ -66,10 +65,8 @@ extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
extern bool print_active, print_text_black;
extern bool no_font_blending;
-typedef enum { GUI_DRAG_NONE, GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
- GUI_DRAG_SAVE, GUI_DRAG_SCROLL, GUI_DRAG_STATUS_RESIZE,
- GUI_DRAG_TREEVIEW, GUI_DRAG_BUTTONBAR,
- GUI_DRAG_FRAME } ro_gui_drag_type;
+typedef enum { GUI_DRAG_NONE, GUI_DRAG_DOWNLOAD_SAVE, GUI_DRAG_SAVE }
+ ro_gui_drag_type;
extern ro_gui_drag_type gui_current_drag_type;
@@ -124,7 +121,6 @@ const char *ro_gui_default_language(void);
/* in download.c */
void ro_gui_download_init(void);
-void ro_gui_download_drag_end(wimp_dragged *drag);
void ro_gui_download_datasave_ack(wimp_message *message);
bool ro_gui_download_prequit(void);
@@ -133,11 +129,9 @@ void ro_gui_401login_init(void);
/* in window.c */
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
-void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
+void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data);
void ro_gui_window_iconise(struct gui_window *g,
wimp_full_message_window_info *wi);
-void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
-void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag);
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
void ro_gui_window_redraw_all(void);
void ro_gui_window_update_boxes(void);
@@ -165,7 +159,6 @@ bool ro_gui_alt_pressed(void);
void ro_gui_history_init(void);
void ro_gui_history_open(struct browser_window *bw, struct history *history,
bool pointer);
-void ro_gui_history_mouse_at(wimp_pointer *pointer);
/* in filetype.c */
int ro_content_filetype(struct hlcache_handle *c);
diff --git a/riscos/gui/button_bar.c b/riscos/gui/button_bar.c
index 00e3574..7ca67f1 100644
--- a/riscos/gui/button_bar.c
+++ b/riscos/gui/button_bar.c
@@ -33,6 +33,7 @@
#include "oslib/wimpspriteop.h"
#include "riscos/gui/button_bar.h"
#include "riscos/gui.h"
+#include "riscos/mouse.h"
#include "riscos/theme.h"
#include "riscos/wimp.h"
#include "utils/log.h"
@@ -110,6 +111,7 @@ static bool drag_separator = false;
static bool ro_gui_button_bar_place_buttons(struct button_bar *button_bar);
static bool ro_gui_button_bar_icon_update(struct button_bar *button_bar);
static bool ro_gui_button_bar_icon_resize(struct button_bar *button_bar);
+static void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data);
static void ro_gui_button_bar_sync_editors(struct button_bar *target,
struct button_bar *source);
static struct button_bar_button *ro_gui_button_bar_find_icon(
@@ -749,7 +751,6 @@ bool ro_gui_button_bar_click(struct button_bar *button_bar,
if (button != NULL && (!button->shaded || drag_separator ||
button_bar->edit_source != NULL)) {
- gui_current_drag_type = GUI_DRAG_BUTTONBAR;
drag_start = button_bar;
drag_opt = button->opt_key;
@@ -779,6 +780,10 @@ bool ro_gui_button_bar_click(struct button_bar *button_bar,
LOG(("xdragasprite_start: 0x%x: %s",
error->errnum, error->errmess));
+ ro_mouse_drag_start(ro_gui_button_bar_drag_end,
+ NULL, NULL, NULL);
+
+
return true;
}
@@ -847,9 +852,14 @@ bool ro_gui_button_bar_help_suffix(struct button_bar *button_bar, wimp_i i,
}
-/* This is an exported interface documented in button_bar.h */
+/**
+ * Terminate a drag event that was initiated by a button bar.
+ *
+ * \param *drag The drag event data.
+ * \param *data NULL data to satisfy callback syntax.
+ */
-void ro_gui_button_bar_drag_end(wimp_dragged *drag)
+void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data)
{
struct button_bar *drag_end = NULL;
struct button_bar *source = NULL, *target = NULL;
@@ -861,7 +871,6 @@ void ro_gui_button_bar_drag_end(wimp_dragged *drag)
os_error *error;
xdragasprite_stop();
- gui_current_drag_type = GUI_DRAG_NONE;
if (drag_start == NULL)
return;
diff --git a/riscos/gui/button_bar.h b/riscos/gui/button_bar.h
index d924288..9abae31 100644
--- a/riscos/gui/button_bar.h
+++ b/riscos/gui/button_bar.h
@@ -291,15 +291,6 @@ bool ro_gui_button_bar_help_suffix(struct button_bar *button_bar, wimp_i i,
/**
- * Terminate a drag event that was initiated by a button bar.
- *
- * \param *drag The drag event data.
- */
-
-void ro_gui_button_bar_drag_end(wimp_dragged *drag);
-
-
-/**
* Return a config string reflecting the configured order of buttons
* and spacers. The string is allocated with malloc(), and should be
* free()d after use.
diff --git a/riscos/gui/status_bar.c b/riscos/gui/status_bar.c
index e01ae3c..899fe99 100644
--- a/riscos/gui/status_bar.c
+++ b/riscos/gui/status_bar.c
@@ -526,7 +526,6 @@ bool ro_gui_status_bar_click(wimp_pointer *pointer)
switch (pointer->i) {
case ICON_WIDGET:
- gui_current_drag_type = GUI_DRAG_STATUS_RESIZE;
drag.w = pointer->w;
drag.type = wimp_DRAG_SYSTEM_SIZE;
drag.initial.x0 = pointer->pos.x;
diff --git a/riscos/history.c b/riscos/history.c
index be81e1a..a4aedc6 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -33,6 +33,7 @@
#include "desktop/browser_private.h"
#include "utils/nsoption.h"
#include "riscos/gui.h"
+#include "riscos/mouse.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/wimputils.h"
@@ -51,7 +52,9 @@ wimp_w history_window;
static void ro_gui_history_redraw(wimp_draw *redraw);
static bool ro_gui_history_click(wimp_pointer *pointer);
-
+static void ro_gui_history_pointer_entering(wimp_entering *entering);
+static void ro_gui_history_track_end(wimp_leaving *leaving, void *data);
+static void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data);
/**
@@ -65,6 +68,8 @@ void ro_gui_history_init(void)
ro_gui_history_redraw);
ro_gui_wimp_event_register_mouse_click(history_window,
ro_gui_history_click);
+ ro_gui_wimp_event_register_pointer_entering_window(history_window,
+ ro_gui_history_pointer_entering);
ro_gui_wimp_event_set_help_prefix(history_window, "HelpHistory");
}
@@ -169,10 +174,37 @@ void ro_gui_history_redraw(wimp_draw *redraw)
/**
+ * Handle Pointer Entering Window events the history window.
+ *
+ * \param *entering The Wimp_PointerEnteringWindow block.
+ */
+
+void ro_gui_history_pointer_entering(wimp_entering *entering)
+{
+ ro_mouse_track_start(ro_gui_history_track_end,
+ ro_gui_history_mouse_at, NULL);
+}
+
+
+/**
+ * Handle Pointer Leaving Window events the history window. These arrive as the
+ * termination callback handler from ro_mouse's mouse tracking.
+ *
+ * \param *leaving The Wimp_PointerLeavingWindow block.
+ * \param *data NULL data pointer.
+ */
+
+void ro_gui_history_track_end(wimp_leaving *leaving, void *data)
+{
+ ro_gui_dialog_close(dialog_tooltip);
+}
+
+
+/**
* Handle mouse movements over the history window.
*/
-void ro_gui_history_mouse_at(wimp_pointer *pointer)
+void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data)
{
int x, y;
int width;
@@ -181,6 +213,8 @@ void ro_gui_history_mouse_at(wimp_pointer *pointer)
wimp_icon_state ic;
os_box box = {0, 0, 0, 0};
os_error *error;
+
+ LOG(("Mouse at..."));
/* If the mouse hasn't moved, or if we don't want tooltips, exit */
if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) ||
diff --git a/riscos/mouse.c b/riscos/mouse.c
new file mode 100644
index 0000000..5ba1260
--- /dev/null
+++ b/riscos/mouse.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2013 Stephen Fryatt <stevef(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file mouse.c
+ * Mouse dragging and tracking support (implementation).
+ *
+ * Two different functions are provided:-
+ *
+ * 1. Wimp_DragBox support, allowing clients to start a drag and specify
+ * callbacks to be used
+ *
+ * - on Null Polls while the drag is active,
+ * - when the drag terminates with Event_DragEnd, and
+ * - when the drag terminates with Escape being pressed.
+ *
+ * 2. Mouse tracking support, allowing clients to track the mouse while it
+ * remains in the current window and specify callbacks to be used
+ *
+ * - on Null Polls while the pointer is in the window, and
+ * - when the pointer leaves the window.
+ */
+
+#include "oslib/wimp.h"
+
+#include "riscos/mouse.h"
+#include "utils/log.h"
+#include "utils/utils.h"
+
+/* Data for the wimp drag handler. */
+
+static void (*ro_mouse_drag_end_callback)(wimp_dragged *dragged, void *data)
+ = NULL;
+static void (*ro_mouse_drag_track_callback)(wimp_pointer *pointer, void *data)
+ = NULL;
+static void (*ro_mouse_drag_cancel_callback)(void *data) = NULL;
+static void *ro_mouse_drag_data = NULL;
+
+/* Data for the wimp poll handler. */
+
+static void (*ro_mouse_poll_end_callback)(wimp_leaving *leaving, void *data)
+ = NULL;
+static void (*ro_mouse_poll_track_callback)(wimp_pointer *pointer, void *data)
+ = NULL;
+static void *ro_mouse_poll_data = NULL;
+
+
+/**
+ * Process Null polls for any drags and mouse trackers that are currently
+ * active.
+ */
+
+void ro_mouse_poll(void)
+{
+ wimp_pointer pointer;
+ os_error *error;
+
+ /* If no trackers are active, just exit. */
+
+ if (ro_mouse_drag_track_callback == NULL &&
+ ro_mouse_poll_track_callback == NULL)
+ return;
+
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ LOG(("xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ /* Process the drag tracker, if one is active. */
+
+ if (ro_mouse_drag_track_callback != NULL)
+ ro_mouse_drag_track_callback(&pointer, ro_mouse_drag_data);
+
+ /* Process the window tracker, if one is active. */
+
+ if (ro_mouse_poll_track_callback != NULL)
+ ro_mouse_poll_track_callback(&pointer, ro_mouse_poll_data);
+}
+
+
+/**
+ * Start a drag, providing a function to be called when the Wimp_DragEnd event
+ * is received and optionally a tracking function to be called on null polls
+ * in between times.
+ *
+ * \param *drag_end Callback for when the drag terminates, or NULL for none.
+ * \param *drag_track Callback for mouse tracking during the drag, or NULL for
+ * none.
+ * \param *drag_cancel Callback for cancelling the drag, or NULL if the drag
+ * can't be cancelled.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_drag_start(void (*drag_end)(wimp_dragged *dragged, void *data),
+ void (*drag_track)(wimp_pointer *pointer, void *data),
+ void (*drag_cancel)(void *data), void *data)
+{
+ /* A drag should never be started when one is already in progress. */
+
+ assert(ro_mouse_drag_end_callback == NULL &&
+ ro_mouse_drag_track_callback == NULL &&
+ ro_mouse_drag_cancel_callback == NULL &&
+ ro_mouse_drag_data == NULL);
+
+ ro_mouse_drag_end_callback = drag_end;
+ ro_mouse_drag_track_callback = drag_track;
+ ro_mouse_drag_cancel_callback = drag_cancel;
+ ro_mouse_drag_data = data;
+}
+
+
+/**
+ * Process Wimp_DragEnd events by terminating an active drag track and passing
+ * the details on to any registered event handler.
+ *
+ * \param *dragged The Wimp_DragEnd data block.
+ */
+
+void ro_mouse_drag_end(wimp_dragged *dragged)
+{
+ if (ro_mouse_drag_end_callback != NULL)
+ ro_mouse_drag_end_callback(dragged, ro_mouse_drag_data);
+ else
+ warn_user("WimpError", "No callback");
+
+ /* Wimp_DragEnd is a one-shot event, so clear the data ready for
+ * another claimant.
+ */
+
+ ro_mouse_drag_end_callback = NULL;
+ ro_mouse_drag_track_callback = NULL;
+ ro_mouse_drag_cancel_callback = NULL;
+ ro_mouse_drag_data = NULL;
+}
+
+
+/**
+ * Start tracking the mouse in a window, providing a function to be called on
+ * null polls and optionally one to be called when it leaves the window.
+ *
+ * \param *drag_end Callback for when the pointer leaves the window, or
+ * NULL for none.
+ * \param *drag_track Callback for mouse tracking while the pointer remains
+ * in the window, or NULL for none.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
+ void (*poll_track)(wimp_pointer *pointer, void *data),
+ void *data)
+{
+ /* It should never be possible for the mouse to be in two windows
+ * at the same time!
+ */
+
+ assert(ro_mouse_poll_end_callback == NULL &&
+ ro_mouse_poll_track_callback == NULL &&
+ ro_mouse_poll_data == NULL);
+
+ ro_mouse_poll_end_callback = poll_end;
+ ro_mouse_poll_track_callback = poll_track;
+ ro_mouse_poll_data = data;
+}
+
+
+/**
+ * Process Wimp_PointerLeaving events by terminating an active mouse track and
+ * passing the details on to any registered event handler.
+ *
+ * \param *leaving The Wimp_PointerLeaving data block.
+ */
+
+void ro_mouse_pointer_leaving_window(wimp_leaving *leaving)
+{
+ if (ro_mouse_poll_end_callback != NULL)
+ ro_mouse_poll_end_callback(leaving, ro_mouse_poll_data);
+
+ /* Poll tracking is a one-shot event, so clear the data ready for
+ * another claimant.
+ */
+
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+}
+
+
+/**
+ * Kill any tracking events if the data pointers match the supplied pointer.
+ *
+ * \param *data The data of the client to be killed.
+ */
+
+void ro_mouse_kill(void *data)
+{
+ if (data == ro_mouse_drag_data) {
+ ro_mouse_drag_end_callback = NULL;
+ ro_mouse_drag_track_callback = NULL;
+ ro_mouse_drag_cancel_callback = NULL;
+ ro_mouse_drag_data = NULL;
+ }
+
+ if (data == ro_mouse_poll_data) {
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+ }
+}
+
+
+/**
+ * Return the desired polling interval to allow the mouse tracking to be
+ * carried out.
+ *
+ * \return Desired poll interval (0 for none required).
+ */
+
+os_t ro_mouse_poll_interval(void)
+{
+ if (ro_mouse_drag_track_callback == NULL &&
+ ro_mouse_poll_track_callback == NULL)
+ return 0;
+
+ return 10; // \TODO Return 4 for DRAG_SELECTION && DRAG_SCROLL
+
+}
+
diff --git a/riscos/mouse.h b/riscos/mouse.h
new file mode 100644
index 0000000..e78a37e
--- /dev/null
+++ b/riscos/mouse.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2013 Stephen Fryatt <stevef(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/** \file mouse.h
+ * Mouse dragging and tracking support (interface).
+ */
+
+#ifndef _NETSURF_RISCOS_MOUSE_H_
+#define _NETSURF_RISCOS_MOUSE_H_
+
+enum ro_mouse_track_response {
+ RO_MOUSE_RESPONSE_LOW,
+ RO_MOUSE_RESPONSE_HIGH
+};
+
+
+/**
+ * Process Null polls for any drags and mouse trackers that are currently
+ * active.
+ */
+
+void ro_mouse_poll(void);
+
+
+/**
+ * Start a drag, providing a function to be called when the Wimp_DragEnd event
+ * is received and optionally a tracking function to be called on null polls
+ * in between times.
+ *
+ * \param *drag_end Callback for when the drag terminates, or NULL for none.
+ * \param *drag_track Callback for mouse tracking during the drag, or NULL for
+ * none.
+ * \param *drag_cancel Callback for cancelling the drag, or NULL if the drag
+ * can't be cancelled.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_drag_start(void (*drag_end)(wimp_dragged *dragged, void *data),
+ void (*drag_track)(wimp_pointer *pointer, void *data),
+ void (*drag_cancel)(void *data), void *data);
+
+
+/**
+ * Process Wimp_DragEnd events by passing the details on to any registered
+ * event handler.
+ *
+ * \param *dragged The Wimp_DragEnd data block.
+ */
+
+void ro_mouse_drag_end(wimp_dragged *dragged);
+
+
+/**
+ * Start tracking the mouse in a window, providing a function to be called on
+ * null polls and optionally one to be called when it leaves the window.
+ *
+ * \param *drag_end Callback for when the pointer leaves the window, or
+ * NULL for none.
+ * \param *drag_track Callback for mouse tracking while the pointer remains
+ * in the window, or NULL for none.
+ * \param *data Data to be passed to the callback functions, or NULL.
+ */
+
+void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
+ void (*poll_track)(wimp_pointer *pointer, void *data),
+ void *data);
+
+/**
+ * Process Wimp_PointerLeaving events by terminating an active mouse track and
+ * passing the details on to any registered event handler.
+ *
+ * \param *leaving The Wimp_PointerLeaving data block.
+ */
+
+void ro_mouse_pointer_leaving_window(wimp_leaving *leaving);
+
+
+/**
+ * Kill any tracking events if the data pointers match the supplied pointer.
+ *
+ * \param *data The data of the client to be killed.
+ */
+
+void ro_mouse_kill(void *data);
+
+
+/**
+ * Return the desired polling interval to allow the mouse tracking to be
+ * carried out.
+ *
+ * \return Desired poll interval (0 for none required).
+ */
+
+os_t ro_mouse_poll_interval(void);
+
+#endif
+
diff --git a/riscos/save.c b/riscos/save.c
index ad2d4c4..511af91 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -49,6 +49,7 @@
#include "riscos/gui.h"
#include "riscos/menus.h"
#include "riscos/message.h"
+#include "riscos/mouse.h"
#include "utils/nsoption.h"
#include "riscos/query.h"
#include "riscos/save.h"
@@ -110,6 +111,7 @@ static bool ro_gui_save_link(const char *url, const char *title, link_format for
static void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
const char *url, char *leaf_buf, size_t leaf_len,
char *icon_buf, size_t icon_len);
+static void ro_gui_save_drag_end(wimp_dragged *drag, void *data);
static bool ro_gui_save_create_thumbnail(hlcache_handle *h, const char *name);
static void ro_gui_save_overwrite_confirmed(query_id, enum query_response res, void *p);
static void ro_gui_save_overwrite_cancelled(query_id, enum query_response res, void *p);
@@ -304,7 +306,7 @@ void ro_gui_save_start_drag(wimp_pointer *pointer)
y = (istate.icon.extent.y1 + istate.icon.extent.y0)/2 +
wstate.visible.y1 - wstate.yscroll;
}
- gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
gui_save_sourcew = pointer->w;
saving_from_dialog = true;
gui_save_close_after = !(pointer->buttons & wimp_DRAG_ADJUST);
@@ -381,7 +383,7 @@ void gui_drag_save_object(gui_save_type save_type, hlcache_handle *c,
save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
- gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
@@ -429,7 +431,7 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
- gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
@@ -473,7 +475,7 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
ro_gui_save_set_state(NULL, save_type, url, save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
- gui_current_drag_type = GUI_DRAG_SAVE;
+ ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
ro_gui_drag_icon(pointer.pos.x, pointer.pos.y, icon_buf);
}
@@ -598,9 +600,12 @@ void ro_gui_drag_box_cancel(void)
/**
* Handle User_Drag_Box event for a drag from the save dialog or browser window.
+ *
+ * \param *drag The Wimp_DragEnd data block.
+ * \param *data NULL, as function is used as a callback from ro_mouse.
*/
-void ro_gui_save_drag_end(wimp_dragged *drag)
+static void ro_gui_save_drag_end(wimp_dragged *drag, void *data)
{
const char *name;
wimp_pointer pointer;
@@ -637,11 +642,8 @@ void ro_gui_save_drag_end(wimp_dragged *drag)
dest_ok = browser_window_drop_file_at_point(g->bw,
pos.x, pos.y, NULL);
}
- if (!dest_ok) {
- /* cancel the drag operation */
- gui_current_drag_type = GUI_DRAG_NONE;
+ if (!dest_ok)
return;
- }
}
if (!saving_from_dialog) {
@@ -691,6 +693,8 @@ void ro_gui_save_drag_end(wimp_dragged *drag)
ro_message_send_message_to_window(wimp_USER_MESSAGE_RECORDED, &message,
pointer.w, pointer.i, ro_gui_save_bounced, NULL);
+ gui_current_drag_type = GUI_DRAG_SAVE;
+
free(local_name);
}
@@ -714,6 +718,7 @@ void ro_gui_send_datasave(gui_save_type save_type,
gui_save_current_type = save_type;
gui_save_sourcew = (wimp_w)-1;
saving_from_dialog = false;
+
gui_current_drag_type = GUI_DRAG_SAVE;
}
}
diff --git a/riscos/save.h b/riscos/save.h
index b219de4..34a4a6b 100644
--- a/riscos/save.h
+++ b/riscos/save.h
@@ -37,7 +37,6 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
const char *title, struct gui_window *g);
void ro_gui_drag_icon(int x, int y, const char *sprite);
void ro_gui_drag_box_cancel(void);
-void ro_gui_save_drag_end(wimp_dragged *drag);
void ro_gui_send_datasave(gui_save_type save_type, wimp_full_message_data_xfer *message, wimp_t to);
void ro_gui_save_datasave_ack(wimp_message *message);
bool ro_gui_save_ok(wimp_w w);
diff --git a/riscos/textselection.c b/riscos/textselection.c
index 094924b..ab8ea5c 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -31,6 +31,7 @@
#include "riscos/gui.h"
#include "riscos/menus.h"
#include "riscos/message.h"
+#include "riscos/mouse.h"
#include "riscos/save.h"
#include "riscos/textselection.h"
#include "utils/log.h"
@@ -66,6 +67,7 @@ static ro_gui_selection_prepare_paste_cb paste_cb = NULL;
static void *paste_cb_pw = NULL;
static int paste_prev_message = 0;
+static void ro_gui_selection_drag_end(wimp_dragged *drag, void *g);
static void ro_gui_discard_clipboard_contents(void);
static void ro_gui_dragging_bounced(wimp_message *message);
@@ -124,8 +126,8 @@ void gui_start_selection(struct gui_window *g)
LOG(("xwimp_auto_scroll: 0x%x: %s",
error->errnum, error->errmess));
- gui_current_drag_type = GUI_DRAG_SELECTION;
- gui_track_gui_window = g;
+ ro_mouse_drag_start(ro_gui_selection_drag_end, ro_gui_window_mouse_at,
+ NULL, g);
drag.type = wimp_DRAG_USER_POINT;
/* Don't constrain mouse pointer during drags */
@@ -147,20 +149,17 @@ void gui_start_selection(struct gui_window *g)
/**
* End of text selection drag operation
*
- * \param g gui window
- * \param dragged position of pointer at conclusion of drag
+ * \param *drag position of pointer at conclusion of drag
+ * \param *data gui window pointer.
*/
-void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag)
+static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
{
wimp_auto_scroll_info scroll;
wimp_pointer pointer;
os_error *error;
os_coord pos;
-
- LOG(("ending text selection drag"));
-
- gui_current_drag_type = GUI_DRAG_NONE;
+ struct gui_window *g = (struct gui_window *) data;
scroll.w = g->window;
error = xwimp_auto_scroll(0, &scroll, 0);
diff --git a/riscos/textselection.h b/riscos/textselection.h
index a3763b4..c6f96f0 100644
--- a/riscos/textselection.h
+++ b/riscos/textselection.h
@@ -35,7 +35,6 @@ bool ro_gui_selection_prepare_paste_datasave(
bool ro_gui_selection_prepare_paste_dataload(
wimp_full_message_data_xfer *dataxfer);
-void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag);
void ro_gui_selection_claim_entity(wimp_full_message_claim_entity *claim);
void ro_gui_selection_data_request(wimp_full_message_data_request *req);
bool ro_gui_save_clipboard(const char *path);
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 51b6809..4cf3d42 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -45,6 +45,7 @@
#include "riscos/gui.h"
#include "riscos/image.h"
#include "riscos/menus.h"
+#include "riscos/mouse.h"
#include "riscos/toolbar.h"
#include "riscos/tinct.h"
#include "riscos/textarea.h"
@@ -99,8 +100,10 @@ static void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv,
osbool more);
static void ro_treeview_open(wimp_open *open);
static bool ro_treeview_mouse_click(wimp_pointer *pointer);
+static void ro_treeview_pointer_entering(wimp_entering *entering);
static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
wimp_window_state *state);
+static void ro_treeview_drag_end(wimp_dragged *drag, void *data);
static bool ro_treeview_keypress(wimp_key *key);
static void ro_treeview_set_window_extent(ro_treeview *tv,
@@ -189,6 +192,8 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
ro_gui_wimp_event_register_redraw_window(tv->w, ro_treeview_redraw);
ro_gui_wimp_event_register_scroll_window(tv->w, ro_treeview_scroll);
+ ro_gui_wimp_event_register_pointer_entering_window(tv->w,
+ ro_treeview_pointer_entering);
ro_gui_wimp_event_register_open_window(tv->w, ro_treeview_open);
ro_gui_wimp_event_register_mouse_click(tv->w, ro_treeview_mouse_click);
ro_gui_wimp_event_register_keypress(tv->w, ro_treeview_keypress);
@@ -411,6 +416,7 @@ void ro_treeview_scroll(wimp_scroll *scroll)
}
}
+
/**
* Redraw a treeview window, once the initial readraw block has been collected.
*
@@ -897,12 +903,30 @@ static bool ro_treeview_mouse_click(wimp_pointer *pointer)
/**
+ * Handle Pointer Entering Window events for treeview windows.
+ *
+ * \param *entering The Wimp_PointerEnteringWindow block.
+ */
+
+void ro_treeview_pointer_entering(wimp_entering *entering)
+{
+ ro_treeview *tv;
+
+ tv = (ro_treeview *) ro_gui_wimp_event_get_user_data(entering->w);
+ if (tv == NULL)
+ return;
+
+ ro_mouse_track_start(NULL, ro_treeview_mouse_at, NULL);
+}
+
+/**
* Track the mouse under Null Polls from the wimp, to support dragging.
*
- * \param *pointer Pointer to a Wimp Pointer block.
+ * \param *pointer Pointer to a Wimp Pointer block.
+ * \param *data NULL to allow use as a ro_mouse callback.
*/
-void ro_treeview_mouse_at(wimp_pointer *pointer)
+void ro_treeview_mouse_at(wimp_pointer *pointer, void *data)
{
os_error *error;
ro_treeview *tv;
@@ -984,8 +1008,7 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
drag.bbox.x0 = state->visible.x0;
drag.bbox.y0 = state->visible.y0;
drag.bbox.x1 = state->visible.x1;
- drag.bbox.y1 = state->visible.y1 -
- ro_toolbar_height(tv->tb);
+ drag.bbox.y1 = state->visible.y1 - ro_toolbar_height(tv->tb) - 2;
switch (tv->drag) {
case TREE_SELECT_DRAG:
@@ -998,7 +1021,7 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
break;
case TREE_MOVE_DRAG:
- drag.type = wimp_DRAG_USER_FIXED;
+ drag.type = wimp_DRAG_USER_POINT;
drag.initial.x0 = pointer->pos.x - 4;
drag.initial.y0 = pointer->pos.y - 48;
@@ -1011,6 +1034,8 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
break;
}
+ LOG(("Drag start..."));
+
error = xwimp_drag_box_with_flags(&drag,
wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP);
if (error) {
@@ -1034,8 +1059,9 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
-
- gui_current_drag_type = GUI_DRAG_TREEVIEW;
+
+ ro_mouse_drag_start(ro_treeview_drag_end, ro_treeview_mouse_at,
+ NULL, NULL);
}
}
@@ -1045,9 +1071,10 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
* started by ro_treeview_drag_start().
*
* \param *drag Pointer to the User Drag Box Event block.
+ * \param *data NULL to allow use as a ro_mouse callback.
*/
-void ro_treeview_drag_end(wimp_dragged *drag)
+static void ro_treeview_drag_end(wimp_dragged *drag, void *data)
{
os_error *error;
@@ -1064,8 +1091,6 @@ void ro_treeview_drag_end(wimp_dragged *drag)
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
-
- gui_current_drag_type = GUI_DRAG_NONE;
}
diff --git a/riscos/treeview.h b/riscos/treeview.h
index 77505ac..80ff766 100644
--- a/riscos/treeview.h
+++ b/riscos/treeview.h
@@ -48,8 +48,7 @@ struct tree *ro_treeview_get_tree(ro_treeview *tv);
wimp_w ro_treeview_get_window(ro_treeview *tv);
void ro_treeview_set_origin(ro_treeview *tv, int x, int y);
-void ro_treeview_mouse_at(wimp_pointer *pointer);
-void ro_treeview_drag_end(wimp_dragged *drag);
+void ro_treeview_mouse_at(wimp_pointer *pointer, void *data);
int ro_treeview_get_help(help_full_message_request *message_data);
#endif
diff --git a/riscos/url_complete.c b/riscos/url_complete.c
index e26cb65..01774f6 100644
--- a/riscos/url_complete.c
+++ b/riscos/url_complete.c
@@ -30,6 +30,7 @@
#include "utils/log.h"
#include "riscos/global_history.h"
#include "riscos/gui.h"
+#include "riscos/mouse.h"
#include "utils/nsoption.h"
#include "riscos/toolbar.h"
#include "riscos/url_complete.h"
@@ -61,6 +62,7 @@ static int mouse_y;
static bool url_complete_callback(nsurl *url,
const struct url_data *data);
+static void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, void *data);
/* This is an exported interface documented in url_complete.h */
@@ -624,7 +626,20 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw)
/* This is an exported interface documented in url_complete.h */
-void ro_gui_url_complete_mouse_at(wimp_pointer *pointer)
+void ro_gui_url_complete_entering(wimp_entering *entering)
+{
+ ro_mouse_track_start(NULL, ro_gui_url_complete_mouse_at, NULL);
+}
+
+
+/**
+ * Handle mouse movement over the URL completion window.
+ *
+ * \param *pointer The pointer state
+ * \param *data NULL data pointer expected by mouse tracker
+ */
+
+void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, void *data)
{
wimp_mouse_state current;
diff --git a/riscos/url_complete.h b/riscos/url_complete.h
index 12f6400..6a4660e 100644
--- a/riscos/url_complete.h
+++ b/riscos/url_complete.h
@@ -79,12 +79,12 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw);
/**
- * Handle mouse movement over the URL completion window.
+ * Handle the pointer entering the URL completion window.
*
- * \param pointer the pointer state
- */
+ * \param *entering The pointer entering data block.
+ */
-void ro_gui_url_complete_mouse_at(wimp_pointer *pointer);
+void ro_gui_url_complete_entering(wimp_entering *entering);
/**
diff --git a/riscos/wimp_event.c b/riscos/wimp_event.c
index 7dea8ed..e879620 100644
--- a/riscos/wimp_event.c
+++ b/riscos/wimp_event.c
@@ -96,6 +96,7 @@ struct event_window {
void (*close_window)(wimp_w w);
void (*redraw_window)(wimp_draw *redraw);
void (*scroll_window)(wimp_scroll *scroll);
+ void (*entering_window)(wimp_entering *entering);
bool (*menu_prepare)(wimp_w w, wimp_i i, wimp_menu *m,
wimp_pointer *p);
bool (*menu_selection)(wimp_w w, wimp_i i, wimp_menu *m,
@@ -1134,6 +1135,24 @@ bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll)
/**
+ * Handle any pointer entering window requests
+ *
+ * \param entering the pointer entering window request
+ */
+bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering)
+{
+ struct event_window *window;
+
+ window = ro_gui_wimp_event_find_window(entering->w);
+ if ((window) && (window->entering_window)) {
+ window->entering_window(entering);
+ return true;
+ }
+ return false;
+}
+
+
+/**
* Process a Menu click in a window, by checking for a registered window
* menu and opening it if one is found.
*
@@ -1491,6 +1510,22 @@ bool ro_gui_wimp_event_register_scroll_window(wimp_w w,
}
/**
+ * Register a function to be called for all pointer entering window requests.
+ */
+
+bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w,
+ void (*callback)(wimp_entering *entering))
+{
+ struct event_window *window;
+
+ window = ro_gui_wimp_event_get_window(w);
+ if (!window)
+ return false;
+ window->entering_window = callback;
+ return true;
+}
+
+/**
* Register a function to be called before a menu is (re-)opened.
*
* \param *w The window for which events should be returned.
@@ -1788,3 +1823,4 @@ void ro_gui_wimp_event_register_submenu(wimp_w w)
ro_gui_wimp_event_close_window(ro_gui_wimp_event_submenu);
ro_gui_wimp_event_submenu = w;
}
+
diff --git a/riscos/wimp_event.h b/riscos/wimp_event.h
index 650f35c..0a54ab0 100644
--- a/riscos/wimp_event.h
+++ b/riscos/wimp_event.h
@@ -61,6 +61,7 @@ bool ro_gui_wimp_event_open_window(wimp_open *open);
bool ro_gui_wimp_event_close_window(wimp_w w);
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw);
bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll);
+bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering);
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer);
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu);
@@ -93,6 +94,8 @@ bool ro_gui_wimp_event_register_redraw_window(wimp_w w,
void (*callback)(wimp_draw *redraw));
bool ro_gui_wimp_event_register_scroll_window(wimp_w w,
void (*callback)(wimp_scroll *scroll));
+bool ro_gui_wimp_event_register_pointer_entering_window(wimp_w w,
+ void (*callback)(wimp_entering *entering));
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w,
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
wimp_pointer *p));
diff --git a/riscos/window.c b/riscos/window.c
index d3375be..65ac536 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -68,6 +68,7 @@
#include "riscos/help.h"
#include "riscos/hotlist.h"
#include "riscos/menus.h"
+#include "riscos/mouse.h"
#include "utils/nsoption.h"
#include "riscos/oslib_pre7.h"
#include "riscos/save.h"
@@ -93,6 +94,8 @@ static void gui_window_set_extent(struct gui_window *g, int width, int height);
static void ro_gui_window_redraw(wimp_draw *redraw);
static void ro_gui_window_scroll(wimp_scroll *scroll);
+static void ro_gui_window_pointer_entering(wimp_entering *entering);
+static void ro_gui_window_track_end(wimp_leaving *leaving, void *data);
static void ro_gui_window_open(wimp_open *open);
static void ro_gui_window_close(wimp_w w);
static bool ro_gui_window_click(wimp_pointer *mouse);
@@ -108,6 +111,8 @@ static bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
wimp_selection *selection, menu_action action);
static void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu);
+static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data);
+
static void ro_gui_window_scroll_action(struct gui_window *g,
int scroll_x, int scroll_y);
@@ -543,6 +548,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
ro_gui_wimp_event_register_close_window(g->window, ro_gui_window_close);
ro_gui_wimp_event_register_redraw_window(g->window, ro_gui_window_redraw);
ro_gui_wimp_event_register_scroll_window(g->window, ro_gui_window_scroll);
+ ro_gui_wimp_event_register_pointer_entering_window(g->window, ro_gui_window_pointer_entering);
ro_gui_wimp_event_register_keypress(g->window, ro_gui_window_keypress);
ro_gui_wimp_event_register_mouse_click(g->window, ro_gui_window_click);
ro_gui_wimp_event_register_menu(g->window, ro_gui_browser_window_menu,
@@ -599,10 +605,7 @@ void gui_window_destroy(struct gui_window *g)
assert(g);
/* stop any tracking */
- if (gui_track_gui_window == g) {
- gui_track_gui_window = NULL;
- gui_current_drag_type = GUI_DRAG_NONE;
- }
+ ro_mouse_kill(g);
/* remove from list */
if (g->prev)
@@ -1239,8 +1242,8 @@ bool gui_window_scroll_start(struct gui_window *g)
return false;
}
- gui_track_gui_window = g;
- gui_current_drag_type = GUI_DRAG_SCROLL;
+ ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
+ NULL, g);
return true;
}
@@ -1294,7 +1297,8 @@ bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
switch (type) {
case GDRAGGING_SCROLLBAR:
/* Dragging a core scrollbar */
- gui_current_drag_type = GUI_DRAG_SCROLL;
+ ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
+ NULL, g);
break;
default:
@@ -3127,6 +3131,37 @@ void ro_gui_window_scroll(wimp_scroll *scroll)
}
}
+/**
+ * Process Pointer Entering Window events in a browser window.
+ *
+ * \param *entering The wimp pointer entering event data block.
+ */
+
+static void ro_gui_window_pointer_entering(wimp_entering *entering)
+{
+ struct gui_window *g = ro_gui_window_lookup(entering->w);
+
+ if (g != NULL)
+ ro_mouse_track_start(ro_gui_window_track_end,
+ ro_gui_window_mouse_at, g);
+}
+
+/**
+ * Process Pointer Leaving Window events in a browser window. These arrive via
+ * the termination callback handler from ro_mouse's mouse tracking.
+ *
+ * \param *leaving The wimp pointer leaving event data block.
+ * \param *data The GUI window that the pointer is leaving.
+ */
+
+static void ro_gui_window_track_end(wimp_leaving *leaving, void *data)
+{
+ struct gui_window *g = (struct gui_window *) data;
+
+ if (g != NULL)
+ gui_window_set_pointer(g, GUI_POINTER_DEFAULT);
+}
+
/**
* Scroll a browser window, either via the core or directly using the
@@ -3350,13 +3385,14 @@ bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
/**
* Handle pointer movements in a browser window.
*
- * \param g browser window that the pointer is in
- * \param pointer new mouse position
+ * \param *pointer new mouse position
+ * \param *data browser window that the pointer is in
*/
-void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
+void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
{
os_coord pos;
+ struct gui_window *g = (struct gui_window *) data;
if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
browser_window_mouse_track(g->bw,
@@ -3500,16 +3536,17 @@ void ro_gui_window_iconise(struct gui_window *g,
/**
* Completes scrolling of a browser window
*
- * \param g gui window
+ * \param *drag The DragEnd event data block.
+ * \param *data gui window block pointer.
*/
-void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
+static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
{
wimp_pointer pointer;
os_error *error;
os_coord pos;
+ struct gui_window *g = (struct gui_window *) data;
- gui_current_drag_type = GUI_DRAG_NONE;
if (!g)
return;
@@ -3541,19 +3578,6 @@ void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
/**
- * Completes resizing of a browser frame
- *
- * \param g gui window
- */
-
-void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag)
-{
- /* our clean-up is the same as for page scrolling */
- ro_gui_window_scroll_end(g, drag);
-}
-
-
-/**
* Process Mouse_Click events in a toolbar's button bar. This does not handle
* other clicks in a toolbar: these are handled by the toolbar module itself.
*
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-535-g9871ca4
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9871ca4a2d6ffc8f41634...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9871ca4a2d6ffc8f41634a0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9871ca4a2d6ffc8f41634a05c...
The branch, master has been updated
via 9871ca4a2d6ffc8f41634a05c177d5145c339959 (commit)
via 9c49eb3ccc1e4b534ae4b978a38f32cc8d5e7dd1 (commit)
via 454fc8dbaa6971944d1459d0a2efff9635b1ef37 (commit)
via f59a93f5ee9f1d906463e97d68a05b6075414214 (commit)
from fe67bd95d7612f9bbd8e54dcf803df0bb6cdca20 (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/commit/?id=9871ca4a2d6ffc8f416...
commit 9871ca4a2d6ffc8f41634a05c177d5145c339959
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
make the scroll bar disappear if size is -1 (untested)
diff --git a/amiga/tree.c b/amiga/tree.c
index d5ae885..5aee277 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -162,15 +162,27 @@ void ami_tree_resized(struct tree *tree, int width, int height, void *data)
{
GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER],(ULONG *)&bbox);
- RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
- SCROLLER_Total, height,
- SCROLLER_Visible, bbox->Height,
- TAG_DONE);
+ if(height == -1) {
+ SetAttrs((APTR)twin->objects[OID_MAIN],
+ WINDOW_VertProp, -1,
+ TAG_DONE);
+ } else {
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
+ SCROLLER_Total, height,
+ SCROLLER_Visible, bbox->Height,
+ TAG_DONE);
+ }
- RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
- SCROLLER_Total, width,
- SCROLLER_Visible, bbox->Width,
- TAG_DONE);
+ if(width == -1) {
+ SetAttrs((APTR)twin->objects[OID_MAIN],
+ WINDOW_HorizProp, -1,
+ TAG_DONE);
+ } else {
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
+ SCROLLER_Total, width,
+ SCROLLER_Visible, bbox->Width,
+ TAG_DONE);
+ }
}
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9c49eb3ccc1e4b534ae...
commit 9c49eb3ccc1e4b534ae4b978a38f32cc8d5e7dd1
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Remove unused. NB: new routine untested
diff --git a/amiga/menu.c b/amiga/menu.c
index 296ebb3..d8e49fc 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -89,10 +89,6 @@ int menu_glyph_width[NSA_GLYPH_MAX];
bool menu_glyphs_loaded = false;
static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
-#if 0
-void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
- int *item, struct gui_window_2 *gwin);
-#endif
void ami_menu_arexx_scan(struct gui_window_2 *gwin);
/* Functions for menu selections */
@@ -634,76 +630,7 @@ static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
ami_menu_hotlist_folder_enter_cb,
ami_menu_hotlist_address_cb,
ami_menu_hotlist_folder_leave_cb);
-
-#if 0
- struct node *root = tree_node_get_child(tree_get_root(tree));
- struct node *node;
- struct node_element *element;
- WORD gen = 0;
- int item;
-
- item = AMI_MENU_HOTLIST;
-
- for (node = root; node; node = tree_node_get_next(node))
- {
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(!element) element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(element && (strcmp(tree_node_element_get_text(element), messages_get("HotlistMenu")) == 0))
- {
- // found menu
- ami_menu_scan_2(tree, tree_node_get_child(node), &gen, &item, gwin);
- }
- }
-
- return(item - AMI_MENU_HOTLIST);
-#else
- return 0;
-#endif
-}
-
-#if 0
-void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
- int *item, struct gui_window_2 *gwin)
-{
- struct node *tempnode;
- struct node_element *element=NULL;
- struct node *node;
- UBYTE menu_type;
- char *icon;
- char key;
-
- *gen = *gen + 1;
-
- for (node = root; node; node = tree_node_get_next(node))
- {
- if((*gen > 0) && (*gen < 3))
- {
- if(*item >= AMI_MENU_HOTLIST_MAX) return;
-
- if(*gen == 1) menu_type = NM_ITEM;
- if(*gen == 2) menu_type = NM_SUB;
-
- if(tree_node_is_folder(node) == true) {
- icon = "icons/directory.png";
- } else {
- icon = "icons/content.png";
- }
-
- ami_menu_alloc_item(gwin, *item, menu_type, tree_url_node_get_title(node),
- 0, icon, ami_menu_item_hotlist_entries, (void *)tree_url_node_get_url(node));
- if(tree_node_is_folder(node) && (!tree_node_get_child(node)))
- gwin->menu[*item].nm_Flags = NM_ITEMDISABLED;
-
- *item = *item + 1;
- }
-
- if (tree_node_get_child(node))
- ami_menu_scan_2(tree, tree_node_get_child(node), gen, item, gwin);
- }
-
- *gen = *gen - 1;
}
-#endif
void ami_menu_update_checked(struct gui_window_2 *gwin)
{
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=454fc8dbaa6971944d1...
commit 454fc8dbaa6971944d1459d0a2efff9635b1ef37
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Use the nsurl directly
diff --git a/amiga/menu.c b/amiga/menu.c
index dadb717..296ebb3 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -547,7 +547,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
gwin->menu[item].nm_Label = NULL;
}
-static nserror ami_menu_hotlist_add(void *ctx, const char *title, struct nsurl *url, bool is_folder)
+static nserror ami_menu_hotlist_add(void *ctx, const char *title, nsurl *url, bool is_folder)
{
struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
UBYTE type;
@@ -1143,19 +1143,14 @@ static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct In
static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
- nsurl *url;
+ nsurl *url = hook->h_Data;
nserror error;
- char *urltxt = hook->h_Data;
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- if(urltxt == NULL) return;
+ if(url == NULL) return;
- error = nsurl_create(urltxt, &url);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- browser_window_navigate(gwin->bw,
+ browser_window_navigate(gwin->bw,
url,
NULL,
BROWSER_WINDOW_HISTORY |
@@ -1163,8 +1158,6 @@ static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct
NULL,
NULL,
NULL);
- nsurl_unref(url);
- }
}
static void ami_menu_item_settings_edit(struct Hook *hook, APTR window, struct IntuiMessage *msg)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f59a93f5ee9f1d90646...
commit f59a93f5ee9f1d906463e97d68a05b6075414214
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Attempt re-write of Hotlist menu creation
diff --git a/amiga/menu.c b/amiga/menu.c
index 7c42e77..dadb717 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -73,6 +73,14 @@ enum {
NSA_GLYPH_MAX
};
+struct ami_hotlist_ctx {
+ struct gui_window_2 *gw;
+ int level;
+ int item;
+ bool in_menu;
+};
+
+
BOOL menualreadyinit;
const char * const netsurf_version;
const char * const verdate;
@@ -80,7 +88,7 @@ Object *menu_glyph[NSA_GLYPH_MAX];
int menu_glyph_width[NSA_GLYPH_MAX];
bool menu_glyphs_loaded = false;
-ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
+static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
#if 0
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin);
@@ -539,8 +547,94 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
gwin->menu[item].nm_Label = NULL;
}
-ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+static nserror ami_menu_hotlist_add(void *ctx, const char *title, struct nsurl *url, bool is_folder)
+{
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
+ UBYTE type;
+ char *icon;
+
+ if(menu_ctx->item >= AMI_MENU_HOTLIST_MAX) return NSERROR_OK;
+
+ switch(menu_ctx->level) {
+ case 1:
+ type = NM_ITEM;
+ break;
+ case 2:
+ type = NM_SUB;
+ break;
+ default:
+ /* entries not at level 1 or 2 are not able to be added */
+ return NSERROR_OK;
+ break;
+ }
+
+ if(is_folder == true) {
+ icon = "icons/directory.png";
+ } else {
+ icon = "icons/content.png";
+ }
+
+ ami_menu_alloc_item(menu_ctx->gw, menu_ctx->item, type, title,
+ 0, icon, ami_menu_item_hotlist_entries, (void *)url);
+ if((is_folder == true) && (type == NM_SUB))
+ menu_ctx->gw->menu[menu_ctx->item].nm_Flags = NM_ITEMDISABLED;
+
+ menu_ctx->item++;
+
+ return NSERROR_OK;
+}
+
+static nserror ami_menu_hotlist_folder_enter_cb(void *ctx, const char *title)
+{
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
+
+ if(menu_ctx->in_menu == true) {
+ ami_menu_hotlist_add(menu_ctx, title, NULL, true);
+ } else {
+ if((menu_ctx->level == 0) && (strcmp(title, messages_get("HotlistMenu")) == 0))
+ menu_ctx->in_menu = true;
+ }
+
+ menu_ctx->level++;
+ return NSERROR_OK;
+}
+
+static nserror ami_menu_hotlist_address_cb(void *ctx, nsurl *url, const char *title)
+{
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
+
+ if(menu_ctx->in_menu == true)
+ ami_menu_hotlist_add(menu_ctx, title, url, false);
+
+ return NSERROR_OK;
+}
+
+static nserror ami_menu_hotlist_folder_leave_cb(void *ctx)
{
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
+
+ menu_ctx->level--;
+
+ if((menu_ctx->in_menu == true) && (menu_ctx->level == 0))
+ menu_ctx->in_menu = false;
+
+ return NSERROR_OK;
+}
+
+static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+{
+ struct ami_hotlist_ctx ctx;
+
+ ctx.level = 0;
+ ctx.item = 0;
+ ctx.in_menu = false;
+ ctx.gw = gwin;
+
+ return hotlist_iterate(&ctx,
+ ami_menu_hotlist_folder_enter_cb,
+ ami_menu_hotlist_address_cb,
+ ami_menu_hotlist_folder_leave_cb);
+
#if 0
struct node *root = tree_node_get_child(tree_get_root(tree));
struct node *node;
-----------------------------------------------------------------------
Summary of changes:
amiga/menu.c | 156 +++++++++++++++++++++++++++++++--------------------------
amiga/tree.c | 28 +++++++---
2 files changed, 105 insertions(+), 79 deletions(-)
diff --git a/amiga/menu.c b/amiga/menu.c
index 7c42e77..d8e49fc 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -73,6 +73,14 @@ enum {
NSA_GLYPH_MAX
};
+struct ami_hotlist_ctx {
+ struct gui_window_2 *gw;
+ int level;
+ int item;
+ bool in_menu;
+};
+
+
BOOL menualreadyinit;
const char * const netsurf_version;
const char * const verdate;
@@ -80,11 +88,7 @@ Object *menu_glyph[NSA_GLYPH_MAX];
int menu_glyph_width[NSA_GLYPH_MAX];
bool menu_glyphs_loaded = false;
-ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
-#if 0
-void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
- int *item, struct gui_window_2 *gwin);
-#endif
+static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
void ami_menu_arexx_scan(struct gui_window_2 *gwin);
/* Functions for menu selections */
@@ -539,77 +543,94 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
gwin->menu[item].nm_Label = NULL;
}
-ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+static nserror ami_menu_hotlist_add(void *ctx, const char *title, nsurl *url, bool is_folder)
{
-#if 0
- struct node *root = tree_node_get_child(tree_get_root(tree));
- struct node *node;
- struct node_element *element;
- WORD gen = 0;
- int item;
-
- item = AMI_MENU_HOTLIST;
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
+ UBYTE type;
+ char *icon;
+
+ if(menu_ctx->item >= AMI_MENU_HOTLIST_MAX) return NSERROR_OK;
+
+ switch(menu_ctx->level) {
+ case 1:
+ type = NM_ITEM;
+ break;
+ case 2:
+ type = NM_SUB;
+ break;
+ default:
+ /* entries not at level 1 or 2 are not able to be added */
+ return NSERROR_OK;
+ break;
+ }
- for (node = root; node; node = tree_node_get_next(node))
- {
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(!element) element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(element && (strcmp(tree_node_element_get_text(element), messages_get("HotlistMenu")) == 0))
- {
- // found menu
- ami_menu_scan_2(tree, tree_node_get_child(node), &gen, &item, gwin);
- }
+ if(is_folder == true) {
+ icon = "icons/directory.png";
+ } else {
+ icon = "icons/content.png";
}
- return(item - AMI_MENU_HOTLIST);
-#else
- return 0;
-#endif
+ ami_menu_alloc_item(menu_ctx->gw, menu_ctx->item, type, title,
+ 0, icon, ami_menu_item_hotlist_entries, (void *)url);
+ if((is_folder == true) && (type == NM_SUB))
+ menu_ctx->gw->menu[menu_ctx->item].nm_Flags = NM_ITEMDISABLED;
+
+ menu_ctx->item++;
+
+ return NSERROR_OK;
}
-#if 0
-void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
- int *item, struct gui_window_2 *gwin)
+static nserror ami_menu_hotlist_folder_enter_cb(void *ctx, const char *title)
{
- struct node *tempnode;
- struct node_element *element=NULL;
- struct node *node;
- UBYTE menu_type;
- char *icon;
- char key;
-
- *gen = *gen + 1;
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
- for (node = root; node; node = tree_node_get_next(node))
- {
- if((*gen > 0) && (*gen < 3))
- {
- if(*item >= AMI_MENU_HOTLIST_MAX) return;
+ if(menu_ctx->in_menu == true) {
+ ami_menu_hotlist_add(menu_ctx, title, NULL, true);
+ } else {
+ if((menu_ctx->level == 0) && (strcmp(title, messages_get("HotlistMenu")) == 0))
+ menu_ctx->in_menu = true;
+ }
+
+ menu_ctx->level++;
+ return NSERROR_OK;
+}
- if(*gen == 1) menu_type = NM_ITEM;
- if(*gen == 2) menu_type = NM_SUB;
+static nserror ami_menu_hotlist_address_cb(void *ctx, nsurl *url, const char *title)
+{
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
+
+ if(menu_ctx->in_menu == true)
+ ami_menu_hotlist_add(menu_ctx, title, url, false);
+
+ return NSERROR_OK;
+}
- if(tree_node_is_folder(node) == true) {
- icon = "icons/directory.png";
- } else {
- icon = "icons/content.png";
- }
+static nserror ami_menu_hotlist_folder_leave_cb(void *ctx)
+{
+ struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
- ami_menu_alloc_item(gwin, *item, menu_type, tree_url_node_get_title(node),
- 0, icon, ami_menu_item_hotlist_entries, (void *)tree_url_node_get_url(node));
- if(tree_node_is_folder(node) && (!tree_node_get_child(node)))
- gwin->menu[*item].nm_Flags = NM_ITEMDISABLED;
+ menu_ctx->level--;
- *item = *item + 1;
- }
+ if((menu_ctx->in_menu == true) && (menu_ctx->level == 0))
+ menu_ctx->in_menu = false;
- if (tree_node_get_child(node))
- ami_menu_scan_2(tree, tree_node_get_child(node), gen, item, gwin);
- }
+ return NSERROR_OK;
+}
- *gen = *gen - 1;
+static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
+{
+ struct ami_hotlist_ctx ctx;
+
+ ctx.level = 0;
+ ctx.item = 0;
+ ctx.in_menu = false;
+ ctx.gw = gwin;
+
+ return hotlist_iterate(&ctx,
+ ami_menu_hotlist_folder_enter_cb,
+ ami_menu_hotlist_address_cb,
+ ami_menu_hotlist_folder_leave_cb);
}
-#endif
void ami_menu_update_checked(struct gui_window_2 *gwin)
{
@@ -1049,19 +1070,14 @@ static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct In
static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
- nsurl *url;
+ nsurl *url = hook->h_Data;
nserror error;
- char *urltxt = hook->h_Data;
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- if(urltxt == NULL) return;
+ if(url == NULL) return;
- error = nsurl_create(urltxt, &url);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- browser_window_navigate(gwin->bw,
+ browser_window_navigate(gwin->bw,
url,
NULL,
BROWSER_WINDOW_HISTORY |
@@ -1069,8 +1085,6 @@ static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct
NULL,
NULL,
NULL);
- nsurl_unref(url);
- }
}
static void ami_menu_item_settings_edit(struct Hook *hook, APTR window, struct IntuiMessage *msg)
diff --git a/amiga/tree.c b/amiga/tree.c
index d5ae885..5aee277 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -162,15 +162,27 @@ void ami_tree_resized(struct tree *tree, int width, int height, void *data)
{
GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER],(ULONG *)&bbox);
- RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
- SCROLLER_Total, height,
- SCROLLER_Visible, bbox->Height,
- TAG_DONE);
+ if(height == -1) {
+ SetAttrs((APTR)twin->objects[OID_MAIN],
+ WINDOW_VertProp, -1,
+ TAG_DONE);
+ } else {
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_VSCROLL], twin->win, NULL,
+ SCROLLER_Total, height,
+ SCROLLER_Visible, bbox->Height,
+ TAG_DONE);
+ }
- RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
- SCROLLER_Total, width,
- SCROLLER_Visible, bbox->Width,
- TAG_DONE);
+ if(width == -1) {
+ SetAttrs((APTR)twin->objects[OID_MAIN],
+ WINDOW_HorizProp, -1,
+ TAG_DONE);
+ } else {
+ RefreshSetGadgetAttrs((APTR)twin->objects[OID_HSCROLL], twin->win, NULL,
+ SCROLLER_Total, width,
+ SCROLLER_Visible, bbox->Width,
+ TAG_DONE);
+ }
}
}
--
NetSurf Browser
9 years, 9 months
netsurf: branch master updated. release/3.0-531-gfe67bd9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/fe67bd95d7612f9bbd8e5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/fe67bd95d7612f9bbd8e54d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/fe67bd95d7612f9bbd8e54dcf...
The branch, master has been updated
via fe67bd95d7612f9bbd8e54dcf803df0bb6cdca20 (commit)
from 2468d006757ed81b782cfc8291029b2bb9f7411b (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/commit/?id=fe67bd95d7612f9bbd8...
commit fe67bd95d7612f9bbd8e54dcf803df0bb6cdca20
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
There must be a next widget for swap_siblings.
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c
index 1ee3b4d..9847484 100644
--- a/framebuffer/fbtk/fbtk.c
+++ b/framebuffer/fbtk/fbtk.c
@@ -144,11 +144,12 @@ fbtk_set_mapping(fbtk_widget_t *widget, bool map)
static void
swap_siblings(fbtk_widget_t *lw)
{
- fbtk_widget_t *rw; /* the widget to swap lw with */
+ fbtk_widget_t *rw = lw->next; /* the widget to swap lw with */
fbtk_widget_t *before;
fbtk_widget_t *after;
- rw = lw->next;
+ assert(rw != NULL);
+
LOG(("Swapping %p with %p", lw, rw));
before = lw->prev;
after = rw->next;
-----------------------------------------------------------------------
Summary of changes:
framebuffer/fbtk/fbtk.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c
index 1ee3b4d..9847484 100644
--- a/framebuffer/fbtk/fbtk.c
+++ b/framebuffer/fbtk/fbtk.c
@@ -144,11 +144,12 @@ fbtk_set_mapping(fbtk_widget_t *widget, bool map)
static void
swap_siblings(fbtk_widget_t *lw)
{
- fbtk_widget_t *rw; /* the widget to swap lw with */
+ fbtk_widget_t *rw = lw->next; /* the widget to swap lw with */
fbtk_widget_t *before;
fbtk_widget_t *after;
- rw = lw->next;
+ assert(rw != NULL);
+
LOG(("Swapping %p with %p", lw, rw));
before = lw->prev;
after = rw->next;
--
NetSurf Browser
9 years, 9 months
netsurf: branch master updated. release/3.0-530-g2468d00
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2468d006757ed81b782cf...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2468d006757ed81b782cfc8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2468d006757ed81b782cfc829...
The branch, master has been updated
via 2468d006757ed81b782cfc8291029b2bb9f7411b (commit)
from 411e367add02101011b61c7cb66c9955d48d21e2 (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/commit/?id=2468d006757ed81b782...
commit 2468d006757ed81b782cfc8291029b2bb9f7411b
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Check for error as soon as we have return value.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 54ff6f8..9af1d97 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -653,6 +653,10 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
/* Add folder node */
err = hotlist_add_folder_internal(title, current_ctx->rel,
current_ctx->relshp, &f);
+ if (err != NSERROR_OK) {
+ dom_string_unref(name);
+ return NSERROR_NOMEM;
+ }
/* Check if folder should be default folder */
error = dom_element_get_attribute(node, corestring_dom_id, &id);
@@ -671,11 +675,6 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
current_ctx->rel = rel;
current_ctx->relshp = TREE_REL_NEXT_SIBLING;
- if (err != NSERROR_OK) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
new_ctx.tree = current_ctx->tree;
new_ctx.rel = rel;
new_ctx.relshp = TREE_REL_FIRST_CHILD;
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 54ff6f8..9af1d97 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -653,6 +653,10 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
/* Add folder node */
err = hotlist_add_folder_internal(title, current_ctx->rel,
current_ctx->relshp, &f);
+ if (err != NSERROR_OK) {
+ dom_string_unref(name);
+ return NSERROR_NOMEM;
+ }
/* Check if folder should be default folder */
error = dom_element_get_attribute(node, corestring_dom_id, &id);
@@ -671,11 +675,6 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
current_ctx->rel = rel;
current_ctx->relshp = TREE_REL_NEXT_SIBLING;
- if (err != NSERROR_OK) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
new_ctx.tree = current_ctx->tree;
new_ctx.rel = rel;
new_ctx.relshp = TREE_REL_FIRST_CHILD;
--
NetSurf Browser
9 years, 9 months
netsurf: branch master updated. release/3.0-529-g411e367
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/411e367add02101011b61...
...commit http://git.netsurf-browser.org/netsurf.git/commit/411e367add02101011b61c7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/411e367add02101011b61c7cb...
The branch, master has been updated
via 411e367add02101011b61c7cb66c9955d48d21e2 (commit)
via 9c855df6914bab1f5727a865eae6f2d7cd9b6325 (commit)
via 2fce8cccbcaf866aefa755da4b8c1eeb7631834c (commit)
via 5d3362be810f0e37a04c5092ffe42a879e895e51 (commit)
via 84b90853b50f02a4b182bd49c4a6a5a360fb7b10 (commit)
via 33c383357d2b2b29eb1837c22ea718c7c7295fb6 (commit)
via 8007027f847977cd37a22ba0bff39f672dac8c27 (commit)
via e94528518d35f2a0d066b4eb27783d49e38d10ff (commit)
via decb4d40f3eea84df4bb8bef5f78b2453e2a8117 (commit)
from 8641d5cbda03acf1cf8333c3a94492182dc7bedd (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/commit/?id=411e367add02101011b...
commit 411e367add02101011b61c7cb66c9955d48d21e2
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Various tidyups to make ownership more clear.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index cc5680e..54ff6f8 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -70,37 +70,23 @@ struct hotlist_entry {
* Set a hotlist entry's data from the url_data.
*
* \param e hotlist entry to set up
- * \param title Title for entry, or NULL if using title from data
* \param url_data Data associated with entry's URL
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror hotlist_create_treeview_field_data(
- struct hotlist_entry *e, const char *title,
- const struct url_data *data)
+static nserror hotlist_create_treeview_field_visits_data(
+ struct hotlist_entry *e, const struct url_data *data)
{
char buffer[16];
const char *last_visited;
char *last_visited2;
int len;
- if (title == NULL) {
- title = (data->title != NULL) ?
- strdup(data->title) :
- strdup("<No title>");
- }
-
- e->data[HL_TITLE].field = hl_ctx.fields[HL_TITLE].field;
- e->data[HL_TITLE].value = title;
- e->data[HL_TITLE].value_len = (e->data[HL_TITLE].value != NULL) ?
- strlen(title) : 0;
-
- e->data[HL_URL].field = hl_ctx.fields[HL_URL].field;
- e->data[HL_URL].value = nsurl_access(e->url);
- e->data[HL_URL].value_len = nsurl_length(e->url);
-
+ /* Last visited */
last_visited = ctime(&data->last_visit);
last_visited2 = strdup(last_visited);
- if (last_visited2 != NULL) {
+ if (last_visited2 == NULL) {
+ return NSERROR_NOMEM;
+ } else {
assert(last_visited2[24] == '\n');
last_visited2[24] = '\0';
}
@@ -109,6 +95,7 @@ static nserror hotlist_create_treeview_field_data(
e->data[HL_LAST_VISIT].value = last_visited2;
e->data[HL_LAST_VISIT].value_len = (last_visited2 != NULL) ? 24 : 0;
+ /* Visits */
len = snprintf(buffer, 16, "%u", data->visits);
if (len == 16) {
len--;
@@ -117,11 +104,61 @@ static nserror hotlist_create_treeview_field_data(
e->data[HL_VISITS].field = hl_ctx.fields[HL_VISITS].field;
e->data[HL_VISITS].value = strdup(buffer);
+ if (e->data[HL_VISITS].value == NULL) {
+ free((void*)e->data[HL_LAST_VISIT].value);
+ return NSERROR_NOMEM;
+ }
e->data[HL_VISITS].value_len = len;
return NSERROR_OK;
}
+
+/**
+ * Set a hotlist entry's data from the url_data.
+ *
+ * \param e hotlist entry to set up
+ * \param title Title for entry, or NULL if using title from data
+ * \param url_data Data associated with entry's URL
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror hotlist_create_treeview_field_data(
+ struct hotlist_entry *e, const char *title,
+ const struct url_data *data)
+{
+ nserror err;
+
+ /* "URL" field */
+ e->data[HL_URL].field = hl_ctx.fields[HL_URL].field;
+ e->data[HL_URL].value = nsurl_access(e->url);
+ e->data[HL_URL].value_len = nsurl_length(e->url);
+
+ /* "Title" field */
+ if (title == NULL) {
+ /* Title not provided; use one from URL data */
+ title = (data->title != NULL) ?
+ data->title : nsurl_access(e->url);
+ }
+
+ e->data[HL_TITLE].field = hl_ctx.fields[HL_TITLE].field;
+ e->data[HL_TITLE].value = strdup(title);
+ if (e->data[HL_TITLE].value == NULL) {
+ return NSERROR_NOMEM;
+ }
+ e->data[HL_TITLE].value_len = (e->data[HL_TITLE].value != NULL) ?
+ strlen(title) : 0;
+
+ /* "Last visited" and "Visits" fields */
+ err = hotlist_create_treeview_field_visits_data(e, data);
+ if (err != NSERROR_OK) {
+ free((void*)e->data[HL_TITLE].value);
+ return NSERROR_OK;
+ }
+
+ return NSERROR_OK;
+}
+
+
/**
* Add a hotlist entry to the treeview
*
@@ -177,9 +214,6 @@ static void hotlist_delete_entry_internal(struct hotlist_entry *e)
/**
* Create hotlist entry data for URL.
*
- * If set, 'title' must be allocated on the heap, ownership is yeilded to
- * this function.
- *
* \param url URL for entry to add to hotlist.
* \param title Title for entry, or NULL if using title from data
* \param data URL data for the entry, or NULL
@@ -235,9 +269,6 @@ static nserror hotlist_create_entry(nsurl *url, const char *title,
/**
* Add an entry to the hotlist (creates the entry).
*
- * If set, 'title' must be allocated on the heap, ownership is yeilded to
- * this function.
- *
* \param url URL for entry to add to hotlist.
* \param title Title for entry, or NULL if using title from data
* \param data URL data for the entry, or NULL
@@ -276,9 +307,6 @@ static nserror hotlist_add_entry_internal(nsurl *url, const char *title,
/**
* Add folder to the hotlist (creates the folder).
*
- * If set, 'title' must be allocated on the heap, ownership is yeilded to
- * this function.
- *
* \param title Title for folder, or NULL if using title from data
* \param relation Existing node to insert as relation of, or NULL
* \param rel Folder's relationship to relation
@@ -295,20 +323,20 @@ static nserror hotlist_add_folder_internal(
if (title == NULL) {
/* TODO: use messages */
- title = strdup("New folder");
- if (title == NULL) {
- return NSERROR_NOMEM;
- }
+ title = "New folder";
}
/* Create the title field */
f = malloc(sizeof(struct hotlist_folder));
if (f == NULL) {
- free((void *)title); /* Eww */
return NSERROR_NOMEM;
}
f->data.field = hl_ctx.fields[HL_FOLDER].field;
- f->data.value = title;
+ f->data.value = strdup(title);
+ if (f->data.value == NULL) {
+ free(f);
+ return NSERROR_NOMEM;
+ }
f->data.value_len = strlen(title);
err = treeview_create_node_folder(hl_ctx.tree,
@@ -316,7 +344,7 @@ static nserror hotlist_add_folder_internal(
TREE_OPTION_NONE : TREE_OPTION_SUPPRESS_RESIZE |
TREE_OPTION_SUPPRESS_REDRAW);
if (err != NSERROR_OK) {
- free((void *)title); /* Eww */
+ free((void*)f->data.value); /* Eww */
free(f);
return err;
}
@@ -484,7 +512,7 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
{
dom_node *a;
dom_string *title1, *url1;
- char *title;
+ const char *title;
nsurl *url;
dom_exception derror;
nserror err;
@@ -513,16 +541,10 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
dom_node_unref(a);
if (title1 != NULL) {
- title = strndup(dom_string_data(title1),
- dom_string_byte_length(title1));
+ title = dom_string_data(title1);
dom_string_unref(title1);
} else {
- title = strdup("<No title>");
- }
- if (title == NULL) {
- warn_user("NoMemory", NULL);
- dom_string_unref(url1);
- return NSERROR_NOMEM;
+ title = "<No title>";
}
/* Need to get URL as a nsurl object */
@@ -534,8 +556,6 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
warn_user(messages_get_errorcode(err), NULL);
- free(title);
-
return err;
}
@@ -546,8 +566,6 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
ctx->relshp = TREE_REL_NEXT_SIBLING;
if (err != NSERROR_OK) {
- free(title);
-
return err;
}
@@ -624,18 +642,13 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
dom_string_caseless_lwc_isequal(name,
corestring_lwc_ul)) {
/* Directory handling, part 2: Make node, and handle children */
- char *title;
+ const char *title;
dom_string *id;
struct hotlist_folder *f;
hotlist_load_ctx new_ctx;
treeview_node *rel;
- title = strndup(dom_string_data(current_ctx->title),
- dom_string_byte_length(current_ctx->title));
- if (title == NULL) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
+ title = dom_string_data(current_ctx->title);
/* Add folder node */
err = hotlist_add_folder_internal(title, current_ctx->rel,
@@ -788,7 +801,7 @@ static nserror hotlist_generate(void)
int i;
struct hotlist_folder *f;
treeview_node *e;
- char *title;
+ const char *title;
nserror err;
nsurl *url;
static const struct {
@@ -808,7 +821,7 @@ static nserror hotlist_generate(void)
sizeof(default_entries[0]);
/* First make "NetSurf" folder for defualt entries */
- title = strdup("NetSurf");
+ title = "NetSurf";
err = hotlist_add_folder_internal(title, NULL,
TREE_REL_FIRST_CHILD, &f);
if (err != NSERROR_OK) {
@@ -823,7 +836,7 @@ static nserror hotlist_generate(void)
return NSERROR_NOMEM;
}
- title = strdup(messages_get(default_entries[i].msg_key));
+ title = messages_get(default_entries[i].msg_key);
/* Build the node */
err = hotlist_add_entry_internal(url, title,
@@ -831,7 +844,6 @@ static nserror hotlist_generate(void)
nsurl_unref(url);
if (err != NSERROR_OK) {
- free(title);
return NSERROR_NOMEM;
}
}
@@ -1200,8 +1212,8 @@ nserror hotlist_add_url(nsurl *url)
if (hl_ctx.default_folder == NULL) {
const char *temp = messages_get("HotlistDefaultFolderName");
struct hotlist_folder *f;
- err = hotlist_add_folder_internal(strdup(temp),
- NULL, TREE_REL_FIRST_CHILD, &f);
+ err = hotlist_add_folder_internal(temp, NULL,
+ TREE_REL_FIRST_CHILD, &f);
if (err != NSERROR_OK)
return err;
@@ -1346,8 +1358,7 @@ static nserror hotlist_update_url_walk_cb(void *ctx, void *node_data,
}
}
- err = hotlist_create_treeview_field_data(e,
- e->data[HL_TITLE].value, tw->data);
+ err = hotlist_create_treeview_field_visits_data(e, tw->data);
if (err != NSERROR_OK)
return err;
@@ -1398,14 +1409,6 @@ nserror hotlist_add_entry(nsurl *url, const char *title, bool at_y, int y)
nsurl_ref(url);
}
- if (title != NULL) {
- title = strdup(title);
- if (title == NULL) {
- nsurl_unref(url);
- return NSERROR_NOMEM;
- }
- }
-
err = treeview_get_relation(hl_ctx.tree, &relation, &rel, at_y, y);
if (err != NSERROR_OK) {
nsurl_unref(url);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9c855df6914bab1f572...
commit 9c855df6914bab1f5727a865eae6f2d7cd9b6325
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove dead assignment.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 49fd090..7c967b6 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1809,7 +1809,7 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
const struct plotter_table *plot = ctx->plot;
int line0, line1, line, left, right, line_y;
int text_y_offset, text_y_offset_baseline;
- unsigned int b_pos, b_len, b_len_part, b_start, b_end;
+ unsigned int b_pos, b_len, b_len_part, b_end;
unsigned int sel_start, sel_end;
char *line_text;
struct rect r, s;
@@ -2003,8 +2003,7 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
line_text = &(ta->show->data[ta->lines[line].b_start]);
- /* find b_start and b_end for this part of the line */
- b_start = b_end;
+ /* find b_end for this part of the line */
b_end += b_len_part;
/* find clip left/right for this part of line */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2fce8cccbcaf866aefa...
commit 2fce8cccbcaf866aefa755da4b8c1eeb7631834c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove dead assignement.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 9b2e52b..49fd090 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1809,7 +1809,7 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
const struct plotter_table *plot = ctx->plot;
int line0, line1, line, left, right, line_y;
int text_y_offset, text_y_offset_baseline;
- unsigned int b_pos, b_len, b_len_part, b_start, b_end, line_len;
+ unsigned int b_pos, b_len, b_len_part, b_start, b_end;
unsigned int sel_start, sel_end;
char *line_text;
struct rect r, s;
@@ -2002,7 +2002,6 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
fstyle.size = fsize;
line_text = &(ta->show->data[ta->lines[line].b_start]);
- line_len = ta->lines[line].b_length;
/* find b_start and b_end for this part of the line */
b_start = b_end;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5d3362be810f0e37a04...
commit 5d3362be810f0e37a04c5092ffe42a879e895e51
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix dead assignments.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 424de93..cc5680e 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1215,9 +1215,13 @@ nserror hotlist_add_url(nsurl *url)
err = hotlist_add_entry_internal(url, NULL, NULL,
hl_ctx.default_folder->folder,
TREE_REL_FIRST_CHILD, &entry);
+ if (err != NSERROR_OK)
+ return err;
/* Ensure default folder is expanded */
err = treeview_node_expand(hl_ctx.tree, hl_ctx.default_folder->folder);
+ if (err != NSERROR_OK)
+ return err;
return NSERROR_OK;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=84b90853b50f02a4b18...
commit 84b90853b50f02a4b182bd49c4a6a5a360fb7b10
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix dead assignement.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index a25d3f0..424de93 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1095,11 +1095,8 @@ static nserror hotlist_populate(const char *path)
/* Load hotlist file */
err = hotlist_load(path, &loaded);
- /* Ignoring errors, since if there was an error, we want to generate
- * the default hotlist anyway. */
-
- if (loaded)
- return NSERROR_OK;
+ if (loaded && err == NSERROR_OK)
+ return err;
/* Couldn't load hotlist, generate a default one */
err = hotlist_generate();
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=33c383357d2b2b29eb1...
commit 33c383357d2b2b29eb1837c22ea718c7c7295fb6
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Express logic to avoid confusing static analyser.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index d4bcc8f..0acd1fe 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -222,7 +222,7 @@ static inline treeview_node * treeview_node_next(treeview_node *node, bool full)
* go to next sibling if present, or nearest ancestor
* with a next sibling. */
- while (node != NULL && node->type != TREE_NODE_ROOT &&
+ while (node != NULL && node->parent != NULL &&
node->next_sib == NULL) {
node = node->parent;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8007027f847977cd37a...
commit 8007027f847977cd37a22ba0bff39f672dac8c27
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Express logic so that the static analyser can understand and not report NULL deref.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 50fa3d2..d4bcc8f 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1090,7 +1090,6 @@ static nserror treeview_delete_node_internal(treeview *tree, treeview_node *n,
static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
{
treeview_node *node, *child, *parent, *next_sibling, *p;
- treeview_node *root = tree->root;
bool abort = false;
nserror err;
struct treeview_node_delete nd = {
@@ -1099,7 +1098,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
.user_interaction = interaction
};
- node = root;
+ node = tree->root;
parent = node->parent;
next_sibling = node->next_sib;
child = (node->flags & TREE_NODE_EXPANDED) ? node->children : NULL;
@@ -1114,7 +1113,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
* go to next sibling if present, or nearest ancestor
* with a next sibling. */
- while (node != root &&
+ while (node->parent != NULL &&
next_sibling == NULL) {
if (node->type == TREE_NODE_FOLDER &&
node->children == NULL) {
@@ -1140,7 +1139,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
next_sibling = node->next_sib;
}
- if (node == root)
+ if (node->parent == NULL)
break;
if (node->type == TREE_NODE_FOLDER &&
@@ -1165,7 +1164,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
}
assert(node != NULL);
- assert(node != root);
+ assert(node->parent != NULL);
parent = node->parent;
next_sibling = node->next_sib;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e94528518d35f2a0d06...
commit e94528518d35f2a0d066b4eb27783d49e38d10ff
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove a couple of dead stores.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 302d6fd..50fa3d2 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -2599,7 +2599,6 @@ bool treeview_keypress(treeview *tree, uint32_t key)
{
struct rect r; /**< Redraw rectangle */
bool redraw = false;
- nserror err;
assert(tree != NULL);
@@ -2633,7 +2632,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
int h = tree->root->height;
/* Delete any empty nodes */
- err = treeview_delete_empty_nodes(tree, false);
+ treeview_delete_empty_nodes(tree, false);
/* Inform front end of change in dimensions */
if (tree->root->height != h) {
@@ -2645,7 +2644,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
break;
case KEY_CR:
case KEY_NL:
- err = treeview_launch_selection(tree);
+ treeview_launch_selection(tree);
break;
case KEY_ESCAPE:
case KEY_CLEAR_SELECTION:
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=decb4d40f3eea84df4b...
commit decb4d40f3eea84df4bb8bef5f78b2453e2a8117
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Ensure correct field is edited when more than one hidden field is editable.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index f9b984c..302d6fd 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -2941,7 +2941,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
}
tree->edit.node = n;
- tree->edit.field = ef->field;
+ tree->edit.field = field_desc->field;
/* Position the caret */
mouse_x -= field_x;
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 158 ++++++++++++++++++++++++++-------------------------
desktop/textarea.c | 6 +-
desktop/treeview.c | 18 +++---
3 files changed, 91 insertions(+), 91 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index a25d3f0..54ff6f8 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -70,37 +70,23 @@ struct hotlist_entry {
* Set a hotlist entry's data from the url_data.
*
* \param e hotlist entry to set up
- * \param title Title for entry, or NULL if using title from data
* \param url_data Data associated with entry's URL
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror hotlist_create_treeview_field_data(
- struct hotlist_entry *e, const char *title,
- const struct url_data *data)
+static nserror hotlist_create_treeview_field_visits_data(
+ struct hotlist_entry *e, const struct url_data *data)
{
char buffer[16];
const char *last_visited;
char *last_visited2;
int len;
- if (title == NULL) {
- title = (data->title != NULL) ?
- strdup(data->title) :
- strdup("<No title>");
- }
-
- e->data[HL_TITLE].field = hl_ctx.fields[HL_TITLE].field;
- e->data[HL_TITLE].value = title;
- e->data[HL_TITLE].value_len = (e->data[HL_TITLE].value != NULL) ?
- strlen(title) : 0;
-
- e->data[HL_URL].field = hl_ctx.fields[HL_URL].field;
- e->data[HL_URL].value = nsurl_access(e->url);
- e->data[HL_URL].value_len = nsurl_length(e->url);
-
+ /* Last visited */
last_visited = ctime(&data->last_visit);
last_visited2 = strdup(last_visited);
- if (last_visited2 != NULL) {
+ if (last_visited2 == NULL) {
+ return NSERROR_NOMEM;
+ } else {
assert(last_visited2[24] == '\n');
last_visited2[24] = '\0';
}
@@ -109,6 +95,7 @@ static nserror hotlist_create_treeview_field_data(
e->data[HL_LAST_VISIT].value = last_visited2;
e->data[HL_LAST_VISIT].value_len = (last_visited2 != NULL) ? 24 : 0;
+ /* Visits */
len = snprintf(buffer, 16, "%u", data->visits);
if (len == 16) {
len--;
@@ -117,11 +104,61 @@ static nserror hotlist_create_treeview_field_data(
e->data[HL_VISITS].field = hl_ctx.fields[HL_VISITS].field;
e->data[HL_VISITS].value = strdup(buffer);
+ if (e->data[HL_VISITS].value == NULL) {
+ free((void*)e->data[HL_LAST_VISIT].value);
+ return NSERROR_NOMEM;
+ }
e->data[HL_VISITS].value_len = len;
return NSERROR_OK;
}
+
+/**
+ * Set a hotlist entry's data from the url_data.
+ *
+ * \param e hotlist entry to set up
+ * \param title Title for entry, or NULL if using title from data
+ * \param url_data Data associated with entry's URL
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror hotlist_create_treeview_field_data(
+ struct hotlist_entry *e, const char *title,
+ const struct url_data *data)
+{
+ nserror err;
+
+ /* "URL" field */
+ e->data[HL_URL].field = hl_ctx.fields[HL_URL].field;
+ e->data[HL_URL].value = nsurl_access(e->url);
+ e->data[HL_URL].value_len = nsurl_length(e->url);
+
+ /* "Title" field */
+ if (title == NULL) {
+ /* Title not provided; use one from URL data */
+ title = (data->title != NULL) ?
+ data->title : nsurl_access(e->url);
+ }
+
+ e->data[HL_TITLE].field = hl_ctx.fields[HL_TITLE].field;
+ e->data[HL_TITLE].value = strdup(title);
+ if (e->data[HL_TITLE].value == NULL) {
+ return NSERROR_NOMEM;
+ }
+ e->data[HL_TITLE].value_len = (e->data[HL_TITLE].value != NULL) ?
+ strlen(title) : 0;
+
+ /* "Last visited" and "Visits" fields */
+ err = hotlist_create_treeview_field_visits_data(e, data);
+ if (err != NSERROR_OK) {
+ free((void*)e->data[HL_TITLE].value);
+ return NSERROR_OK;
+ }
+
+ return NSERROR_OK;
+}
+
+
/**
* Add a hotlist entry to the treeview
*
@@ -177,9 +214,6 @@ static void hotlist_delete_entry_internal(struct hotlist_entry *e)
/**
* Create hotlist entry data for URL.
*
- * If set, 'title' must be allocated on the heap, ownership is yeilded to
- * this function.
- *
* \param url URL for entry to add to hotlist.
* \param title Title for entry, or NULL if using title from data
* \param data URL data for the entry, or NULL
@@ -235,9 +269,6 @@ static nserror hotlist_create_entry(nsurl *url, const char *title,
/**
* Add an entry to the hotlist (creates the entry).
*
- * If set, 'title' must be allocated on the heap, ownership is yeilded to
- * this function.
- *
* \param url URL for entry to add to hotlist.
* \param title Title for entry, or NULL if using title from data
* \param data URL data for the entry, or NULL
@@ -276,9 +307,6 @@ static nserror hotlist_add_entry_internal(nsurl *url, const char *title,
/**
* Add folder to the hotlist (creates the folder).
*
- * If set, 'title' must be allocated on the heap, ownership is yeilded to
- * this function.
- *
* \param title Title for folder, or NULL if using title from data
* \param relation Existing node to insert as relation of, or NULL
* \param rel Folder's relationship to relation
@@ -295,20 +323,20 @@ static nserror hotlist_add_folder_internal(
if (title == NULL) {
/* TODO: use messages */
- title = strdup("New folder");
- if (title == NULL) {
- return NSERROR_NOMEM;
- }
+ title = "New folder";
}
/* Create the title field */
f = malloc(sizeof(struct hotlist_folder));
if (f == NULL) {
- free((void *)title); /* Eww */
return NSERROR_NOMEM;
}
f->data.field = hl_ctx.fields[HL_FOLDER].field;
- f->data.value = title;
+ f->data.value = strdup(title);
+ if (f->data.value == NULL) {
+ free(f);
+ return NSERROR_NOMEM;
+ }
f->data.value_len = strlen(title);
err = treeview_create_node_folder(hl_ctx.tree,
@@ -316,7 +344,7 @@ static nserror hotlist_add_folder_internal(
TREE_OPTION_NONE : TREE_OPTION_SUPPRESS_RESIZE |
TREE_OPTION_SUPPRESS_REDRAW);
if (err != NSERROR_OK) {
- free((void *)title); /* Eww */
+ free((void*)f->data.value); /* Eww */
free(f);
return err;
}
@@ -484,7 +512,7 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
{
dom_node *a;
dom_string *title1, *url1;
- char *title;
+ const char *title;
nsurl *url;
dom_exception derror;
nserror err;
@@ -513,16 +541,10 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
dom_node_unref(a);
if (title1 != NULL) {
- title = strndup(dom_string_data(title1),
- dom_string_byte_length(title1));
+ title = dom_string_data(title1);
dom_string_unref(title1);
} else {
- title = strdup("<No title>");
- }
- if (title == NULL) {
- warn_user("NoMemory", NULL);
- dom_string_unref(url1);
- return NSERROR_NOMEM;
+ title = "<No title>";
}
/* Need to get URL as a nsurl object */
@@ -534,8 +556,6 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
warn_user(messages_get_errorcode(err), NULL);
- free(title);
-
return err;
}
@@ -546,8 +566,6 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
ctx->relshp = TREE_REL_NEXT_SIBLING;
if (err != NSERROR_OK) {
- free(title);
-
return err;
}
@@ -624,18 +642,13 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
dom_string_caseless_lwc_isequal(name,
corestring_lwc_ul)) {
/* Directory handling, part 2: Make node, and handle children */
- char *title;
+ const char *title;
dom_string *id;
struct hotlist_folder *f;
hotlist_load_ctx new_ctx;
treeview_node *rel;
- title = strndup(dom_string_data(current_ctx->title),
- dom_string_byte_length(current_ctx->title));
- if (title == NULL) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
+ title = dom_string_data(current_ctx->title);
/* Add folder node */
err = hotlist_add_folder_internal(title, current_ctx->rel,
@@ -788,7 +801,7 @@ static nserror hotlist_generate(void)
int i;
struct hotlist_folder *f;
treeview_node *e;
- char *title;
+ const char *title;
nserror err;
nsurl *url;
static const struct {
@@ -808,7 +821,7 @@ static nserror hotlist_generate(void)
sizeof(default_entries[0]);
/* First make "NetSurf" folder for defualt entries */
- title = strdup("NetSurf");
+ title = "NetSurf";
err = hotlist_add_folder_internal(title, NULL,
TREE_REL_FIRST_CHILD, &f);
if (err != NSERROR_OK) {
@@ -823,7 +836,7 @@ static nserror hotlist_generate(void)
return NSERROR_NOMEM;
}
- title = strdup(messages_get(default_entries[i].msg_key));
+ title = messages_get(default_entries[i].msg_key);
/* Build the node */
err = hotlist_add_entry_internal(url, title,
@@ -831,7 +844,6 @@ static nserror hotlist_generate(void)
nsurl_unref(url);
if (err != NSERROR_OK) {
- free(title);
return NSERROR_NOMEM;
}
}
@@ -1095,11 +1107,8 @@ static nserror hotlist_populate(const char *path)
/* Load hotlist file */
err = hotlist_load(path, &loaded);
- /* Ignoring errors, since if there was an error, we want to generate
- * the default hotlist anyway. */
-
- if (loaded)
- return NSERROR_OK;
+ if (loaded && err == NSERROR_OK)
+ return err;
/* Couldn't load hotlist, generate a default one */
err = hotlist_generate();
@@ -1203,8 +1212,8 @@ nserror hotlist_add_url(nsurl *url)
if (hl_ctx.default_folder == NULL) {
const char *temp = messages_get("HotlistDefaultFolderName");
struct hotlist_folder *f;
- err = hotlist_add_folder_internal(strdup(temp),
- NULL, TREE_REL_FIRST_CHILD, &f);
+ err = hotlist_add_folder_internal(temp, NULL,
+ TREE_REL_FIRST_CHILD, &f);
if (err != NSERROR_OK)
return err;
@@ -1218,9 +1227,13 @@ nserror hotlist_add_url(nsurl *url)
err = hotlist_add_entry_internal(url, NULL, NULL,
hl_ctx.default_folder->folder,
TREE_REL_FIRST_CHILD, &entry);
+ if (err != NSERROR_OK)
+ return err;
/* Ensure default folder is expanded */
err = treeview_node_expand(hl_ctx.tree, hl_ctx.default_folder->folder);
+ if (err != NSERROR_OK)
+ return err;
return NSERROR_OK;
}
@@ -1345,8 +1358,7 @@ static nserror hotlist_update_url_walk_cb(void *ctx, void *node_data,
}
}
- err = hotlist_create_treeview_field_data(e,
- e->data[HL_TITLE].value, tw->data);
+ err = hotlist_create_treeview_field_visits_data(e, tw->data);
if (err != NSERROR_OK)
return err;
@@ -1397,14 +1409,6 @@ nserror hotlist_add_entry(nsurl *url, const char *title, bool at_y, int y)
nsurl_ref(url);
}
- if (title != NULL) {
- title = strdup(title);
- if (title == NULL) {
- nsurl_unref(url);
- return NSERROR_NOMEM;
- }
- }
-
err = treeview_get_relation(hl_ctx.tree, &relation, &rel, at_y, y);
if (err != NSERROR_OK) {
nsurl_unref(url);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 9b2e52b..7c967b6 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1809,7 +1809,7 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
const struct plotter_table *plot = ctx->plot;
int line0, line1, line, left, right, line_y;
int text_y_offset, text_y_offset_baseline;
- unsigned int b_pos, b_len, b_len_part, b_start, b_end, line_len;
+ unsigned int b_pos, b_len, b_len_part, b_end;
unsigned int sel_start, sel_end;
char *line_text;
struct rect r, s;
@@ -2002,10 +2002,8 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
fstyle.size = fsize;
line_text = &(ta->show->data[ta->lines[line].b_start]);
- line_len = ta->lines[line].b_length;
- /* find b_start and b_end for this part of the line */
- b_start = b_end;
+ /* find b_end for this part of the line */
b_end += b_len_part;
/* find clip left/right for this part of line */
diff --git a/desktop/treeview.c b/desktop/treeview.c
index f9b984c..0acd1fe 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -222,7 +222,7 @@ static inline treeview_node * treeview_node_next(treeview_node *node, bool full)
* go to next sibling if present, or nearest ancestor
* with a next sibling. */
- while (node != NULL && node->type != TREE_NODE_ROOT &&
+ while (node != NULL && node->parent != NULL &&
node->next_sib == NULL) {
node = node->parent;
}
@@ -1090,7 +1090,6 @@ static nserror treeview_delete_node_internal(treeview *tree, treeview_node *n,
static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
{
treeview_node *node, *child, *parent, *next_sibling, *p;
- treeview_node *root = tree->root;
bool abort = false;
nserror err;
struct treeview_node_delete nd = {
@@ -1099,7 +1098,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
.user_interaction = interaction
};
- node = root;
+ node = tree->root;
parent = node->parent;
next_sibling = node->next_sib;
child = (node->flags & TREE_NODE_EXPANDED) ? node->children : NULL;
@@ -1114,7 +1113,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
* go to next sibling if present, or nearest ancestor
* with a next sibling. */
- while (node != root &&
+ while (node->parent != NULL &&
next_sibling == NULL) {
if (node->type == TREE_NODE_FOLDER &&
node->children == NULL) {
@@ -1140,7 +1139,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
next_sibling = node->next_sib;
}
- if (node == root)
+ if (node->parent == NULL)
break;
if (node->type == TREE_NODE_FOLDER &&
@@ -1165,7 +1164,7 @@ static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
}
assert(node != NULL);
- assert(node != root);
+ assert(node->parent != NULL);
parent = node->parent;
next_sibling = node->next_sib;
@@ -2599,7 +2598,6 @@ bool treeview_keypress(treeview *tree, uint32_t key)
{
struct rect r; /**< Redraw rectangle */
bool redraw = false;
- nserror err;
assert(tree != NULL);
@@ -2633,7 +2631,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
int h = tree->root->height;
/* Delete any empty nodes */
- err = treeview_delete_empty_nodes(tree, false);
+ treeview_delete_empty_nodes(tree, false);
/* Inform front end of change in dimensions */
if (tree->root->height != h) {
@@ -2645,7 +2643,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
break;
case KEY_CR:
case KEY_NL:
- err = treeview_launch_selection(tree);
+ treeview_launch_selection(tree);
break;
case KEY_ESCAPE:
case KEY_CLEAR_SELECTION:
@@ -2941,7 +2939,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
}
tree->edit.node = n;
- tree->edit.field = ef->field;
+ tree->edit.field = field_desc->field;
/* Position the caret */
mouse_x -= field_x;
--
NetSurf Browser
9 years, 9 months
netsurf: branch master updated. release/3.0-520-g8641d5c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8641d5cbda03acf1cf833...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8641d5cbda03acf1cf8333c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8641d5cbda03acf1cf8333c3a...
The branch, master has been updated
via 8641d5cbda03acf1cf8333c3a94492182dc7bedd (commit)
from b646592928e518afcdc864fa22bcd3571f93af61 (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/commit/?id=8641d5cbda03acf1cf8...
commit 8641d5cbda03acf1cf8333c3a94492182dc7bedd
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix a potential leak.
diff --git a/render/imagemap.c b/render/imagemap.c
index e50ed6c..433ae68 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -564,14 +564,13 @@ imagemap_addtolist(dom_node *n, nsurl *base_url,
if (xcoords == NULL) {
goto bad_out;
}
+ new_map->bounds.poly.xcoords = xcoords;
ycoords = realloc(new_map->bounds.poly.ycoords,
num * sizeof(float));
if (ycoords == NULL) {
goto bad_out;
}
-
- new_map->bounds.poly.xcoords = xcoords;
new_map->bounds.poly.ycoords = ycoords;
new_map->bounds.poly.xcoords[num - 1] = x;
-----------------------------------------------------------------------
Summary of changes:
render/imagemap.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/render/imagemap.c b/render/imagemap.c
index e50ed6c..433ae68 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -564,14 +564,13 @@ imagemap_addtolist(dom_node *n, nsurl *base_url,
if (xcoords == NULL) {
goto bad_out;
}
+ new_map->bounds.poly.xcoords = xcoords;
ycoords = realloc(new_map->bounds.poly.ycoords,
num * sizeof(float));
if (ycoords == NULL) {
goto bad_out;
}
-
- new_map->bounds.poly.xcoords = xcoords;
new_map->bounds.poly.ycoords = ycoords;
new_map->bounds.poly.xcoords[num - 1] = x;
--
NetSurf Browser
9 years, 9 months
netsurf: branch master updated. release/3.0-519-gb646592
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b646592928e518afcdc86...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b646592928e518afcdc864f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b646592928e518afcdc864fa2...
The branch, master has been updated
via b646592928e518afcdc864fa22bcd3571f93af61 (commit)
from 267c630b880daa7fb1ae3c0c74479e62fbcfe091 (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/commit/?id=b646592928e518afcdc...
commit b646592928e518afcdc864fa22bcd3571f93af61
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Allocate correct amount of mem for pointers to imagemaps.
diff --git a/render/imagemap.c b/render/imagemap.c
index 379d658..e50ed6c 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -141,7 +141,7 @@ bool imagemap_create(html_content *c)
assert(c != NULL);
if (c->imagemaps == NULL) {
- c->imagemaps = calloc(HASH_SIZE, sizeof(struct imagemap));
+ c->imagemaps = calloc(HASH_SIZE, sizeof(struct imagemap *));
if (c->imagemaps == NULL) {
return false;
}
-----------------------------------------------------------------------
Summary of changes:
render/imagemap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/render/imagemap.c b/render/imagemap.c
index 379d658..e50ed6c 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -141,7 +141,7 @@ bool imagemap_create(html_content *c)
assert(c != NULL);
if (c->imagemaps == NULL) {
- c->imagemaps = calloc(HASH_SIZE, sizeof(struct imagemap));
+ c->imagemaps = calloc(HASH_SIZE, sizeof(struct imagemap *));
if (c->imagemaps == NULL) {
return false;
}
--
NetSurf Browser
9 years, 9 months
netsurf: branch master updated. release/3.0-518-g267c630
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/267c630b880daa7fb1ae3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/267c630b880daa7fb1ae3c0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/267c630b880daa7fb1ae3c0c7...
The branch, master has been updated
via 267c630b880daa7fb1ae3c0c74479e62fbcfe091 (commit)
from e8071e676c03320ee63719769987eb81980ab5c8 (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/commit/?id=267c630b880daa7fb1a...
commit 267c630b880daa7fb1ae3c0c74479e62fbcfe091
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Tidy up compatibility layer.
diff --git a/desktop/tree.c b/desktop/tree.c
index cb981b3..f64c390 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -103,6 +103,7 @@ static void treeview_test_drag_status(struct core_window *cw,
case CORE_WINDOW_DRAG_MOVE:
tree->drag = TREE_MOVE_DRAG;
+ break;
case CORE_WINDOW_DRAG_TEXT_SELECTION:
tree->drag = TREE_TEXTAREA_DRAG;
@@ -125,44 +126,34 @@ static bool treeview_test_init(struct tree *tree)
{
nserror err;
- if (tree->flags == TREE_SSLCERT) {
-
- treeview_inits++;
-
- if (treeview_inits == 1)
- treeview_init();
-
- err = sslcert_viewer_init(&cw_t, (struct core_window *)tree,
- ssl_current_session);
- if (err != NSERROR_OK) {
- warn_user("Couldn't init new sslcert viewer.", 0);
- }
- return true;
- }
-
treeview_inits++;
if (treeview_inits == 1)
treeview_init();
- if (tree->flags == TREE_COOKIES) {
+ switch (tree->flags) {
+ case TREE_COOKIES:
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't init new cookie manager.", 0);
- }
- }
- if (tree->flags == TREE_HISTORY) {
+ break;
+ case TREE_HISTORY:
err = global_history_init(&cw_t, (struct core_window *)tree);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't init new global history.", 0);
- }
- }
- if (tree->flags == TREE_HOTLIST) {
+ break;
+ case TREE_HOTLIST:
err = hotlist_init(&cw_t, (struct core_window *)tree,
tree_hotlist_path);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't init new hotlist.", 0);
- }
+ break;
+ case TREE_SSLCERT:
+ err = sslcert_viewer_init(&cw_t, (struct core_window *)tree,
+ ssl_current_session);
+ if (err != NSERROR_OK)
+ warn_user("Couldn't init new sslcert viewer.", 0);
+ break;
}
return true;
@@ -172,36 +163,27 @@ static bool treeview_test_fini(struct tree *tree)
{
nserror err;
- if (tree->flags == TREE_SSLCERT) {
- err = sslcert_viewer_fini(ssl_current_session);
- if (err != NSERROR_OK) {
- warn_user("Couldn't finalise sslcert viewer.", 0);
- }
-
- if (treeview_inits == 1)
- treeview_fini();
- treeview_inits--;
-
- return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ switch (tree->flags) {
+ case TREE_COOKIES:
err = cookie_manager_fini();
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't finalise cookie manager.", 0);
- }
- }
- if (tree->flags == TREE_HISTORY) {
+ break;
+ case TREE_HISTORY:
err = global_history_fini();
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't finalise cookie manager.", 0);
- }
- }
- if (tree->flags == TREE_HOTLIST) {
+ break;
+ case TREE_HOTLIST:
err = hotlist_fini(tree_hotlist_path);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't finalise hotlist.", 0);
- }
+ break;
+ case TREE_SSLCERT:
+ err = sslcert_viewer_fini(ssl_current_session);
+ if (err != NSERROR_OK)
+ warn_user("Couldn't finalise sslcert viewer.", 0);
+ break;
}
if (treeview_inits == 1)
@@ -222,20 +204,17 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
clip.x1 = clip_x + clip_width;
clip.y1 = clip_y + clip_height;
- if (tree->flags == TREE_SSLCERT) {
+ switch (tree->flags) {
+ case TREE_SSLCERT:
sslcert_viewer_redraw(ssl_current_session, x, y, &clip, ctx);
return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ case TREE_COOKIES:
cookie_manager_redraw(x, y, &clip, ctx);
return true;
- }
- if (tree->flags == TREE_HISTORY) {
+ case TREE_HISTORY:
global_history_redraw(x, y, &clip, ctx);
return true;
- }
- if (tree->flags == TREE_HOTLIST) {
+ case TREE_HOTLIST:
hotlist_redraw(x, y, &clip, ctx);
return true;
}
@@ -246,20 +225,17 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
static bool treeview_test_mouse_action(struct tree *tree,
browser_mouse_state mouse, int x, int y)
{
- if (tree->flags == TREE_SSLCERT) {
+ switch (tree->flags) {
+ case TREE_SSLCERT:
sslcert_viewer_mouse_action(ssl_current_session, mouse, x, y);
return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ case TREE_COOKIES:
cookie_manager_mouse_action(mouse, x, y);
return true;
- }
- if (tree->flags == TREE_HISTORY) {
+ case TREE_HISTORY:
global_history_mouse_action(mouse, x, y);
return true;
- }
- if (tree->flags == TREE_HOTLIST) {
+ case TREE_HOTLIST:
hotlist_mouse_action(mouse, x, y);
return true;
}
@@ -269,20 +245,17 @@ static bool treeview_test_mouse_action(struct tree *tree,
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
{
- if (tree->flags == TREE_SSLCERT) {
+ switch (tree->flags) {
+ case TREE_SSLCERT:
sslcert_viewer_keypress(ssl_current_session, key);
return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ case TREE_COOKIES:
cookie_manager_keypress(key);
return true;
- }
- if (tree->flags == TREE_HISTORY) {
+ case TREE_HISTORY:
global_history_keypress(key);
return true;
- }
- if (tree->flags == TREE_HOTLIST) {
+ case TREE_HOTLIST:
hotlist_keypress(key);
return true;
}
-----------------------------------------------------------------------
Summary of changes:
desktop/tree.c | 121 ++++++++++++++++++++++----------------------------------
1 files changed, 47 insertions(+), 74 deletions(-)
diff --git a/desktop/tree.c b/desktop/tree.c
index cb981b3..f64c390 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -103,6 +103,7 @@ static void treeview_test_drag_status(struct core_window *cw,
case CORE_WINDOW_DRAG_MOVE:
tree->drag = TREE_MOVE_DRAG;
+ break;
case CORE_WINDOW_DRAG_TEXT_SELECTION:
tree->drag = TREE_TEXTAREA_DRAG;
@@ -125,44 +126,34 @@ static bool treeview_test_init(struct tree *tree)
{
nserror err;
- if (tree->flags == TREE_SSLCERT) {
-
- treeview_inits++;
-
- if (treeview_inits == 1)
- treeview_init();
-
- err = sslcert_viewer_init(&cw_t, (struct core_window *)tree,
- ssl_current_session);
- if (err != NSERROR_OK) {
- warn_user("Couldn't init new sslcert viewer.", 0);
- }
- return true;
- }
-
treeview_inits++;
if (treeview_inits == 1)
treeview_init();
- if (tree->flags == TREE_COOKIES) {
+ switch (tree->flags) {
+ case TREE_COOKIES:
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't init new cookie manager.", 0);
- }
- }
- if (tree->flags == TREE_HISTORY) {
+ break;
+ case TREE_HISTORY:
err = global_history_init(&cw_t, (struct core_window *)tree);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't init new global history.", 0);
- }
- }
- if (tree->flags == TREE_HOTLIST) {
+ break;
+ case TREE_HOTLIST:
err = hotlist_init(&cw_t, (struct core_window *)tree,
tree_hotlist_path);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't init new hotlist.", 0);
- }
+ break;
+ case TREE_SSLCERT:
+ err = sslcert_viewer_init(&cw_t, (struct core_window *)tree,
+ ssl_current_session);
+ if (err != NSERROR_OK)
+ warn_user("Couldn't init new sslcert viewer.", 0);
+ break;
}
return true;
@@ -172,36 +163,27 @@ static bool treeview_test_fini(struct tree *tree)
{
nserror err;
- if (tree->flags == TREE_SSLCERT) {
- err = sslcert_viewer_fini(ssl_current_session);
- if (err != NSERROR_OK) {
- warn_user("Couldn't finalise sslcert viewer.", 0);
- }
-
- if (treeview_inits == 1)
- treeview_fini();
- treeview_inits--;
-
- return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ switch (tree->flags) {
+ case TREE_COOKIES:
err = cookie_manager_fini();
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't finalise cookie manager.", 0);
- }
- }
- if (tree->flags == TREE_HISTORY) {
+ break;
+ case TREE_HISTORY:
err = global_history_fini();
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't finalise cookie manager.", 0);
- }
- }
- if (tree->flags == TREE_HOTLIST) {
+ break;
+ case TREE_HOTLIST:
err = hotlist_fini(tree_hotlist_path);
- if (err != NSERROR_OK) {
+ if (err != NSERROR_OK)
warn_user("Couldn't finalise hotlist.", 0);
- }
+ break;
+ case TREE_SSLCERT:
+ err = sslcert_viewer_fini(ssl_current_session);
+ if (err != NSERROR_OK)
+ warn_user("Couldn't finalise sslcert viewer.", 0);
+ break;
}
if (treeview_inits == 1)
@@ -222,20 +204,17 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
clip.x1 = clip_x + clip_width;
clip.y1 = clip_y + clip_height;
- if (tree->flags == TREE_SSLCERT) {
+ switch (tree->flags) {
+ case TREE_SSLCERT:
sslcert_viewer_redraw(ssl_current_session, x, y, &clip, ctx);
return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ case TREE_COOKIES:
cookie_manager_redraw(x, y, &clip, ctx);
return true;
- }
- if (tree->flags == TREE_HISTORY) {
+ case TREE_HISTORY:
global_history_redraw(x, y, &clip, ctx);
return true;
- }
- if (tree->flags == TREE_HOTLIST) {
+ case TREE_HOTLIST:
hotlist_redraw(x, y, &clip, ctx);
return true;
}
@@ -246,20 +225,17 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
static bool treeview_test_mouse_action(struct tree *tree,
browser_mouse_state mouse, int x, int y)
{
- if (tree->flags == TREE_SSLCERT) {
+ switch (tree->flags) {
+ case TREE_SSLCERT:
sslcert_viewer_mouse_action(ssl_current_session, mouse, x, y);
return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ case TREE_COOKIES:
cookie_manager_mouse_action(mouse, x, y);
return true;
- }
- if (tree->flags == TREE_HISTORY) {
+ case TREE_HISTORY:
global_history_mouse_action(mouse, x, y);
return true;
- }
- if (tree->flags == TREE_HOTLIST) {
+ case TREE_HOTLIST:
hotlist_mouse_action(mouse, x, y);
return true;
}
@@ -269,20 +245,17 @@ static bool treeview_test_mouse_action(struct tree *tree,
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
{
- if (tree->flags == TREE_SSLCERT) {
+ switch (tree->flags) {
+ case TREE_SSLCERT:
sslcert_viewer_keypress(ssl_current_session, key);
return true;
- }
-
- if (tree->flags == TREE_COOKIES) {
+ case TREE_COOKIES:
cookie_manager_keypress(key);
return true;
- }
- if (tree->flags == TREE_HISTORY) {
+ case TREE_HISTORY:
global_history_keypress(key);
return true;
- }
- if (tree->flags == TREE_HOTLIST) {
+ case TREE_HOTLIST:
hotlist_keypress(key);
return true;
}
--
NetSurf Browser
9 years, 9 months