summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Fryatt <stevef@netsurf-browser.org>2013-09-08 13:27:11 +0100
committerSteve Fryatt <stevef@netsurf-browser.org>2013-09-08 13:27:11 +0100
commitee8fb6f39f3014cf4e4c17a28904850a58f2f4f3 (patch)
tree768f2696348c8ed0038030b35217474fb2a29019
parenta00e0f91c7ccb27108cc396ca8afa3207935de4c (diff)
downloadnetsurf-ee8fb6f39f3014cf4e4c17a28904850a58f2f4f3.tar.gz
netsurf-ee8fb6f39f3014cf4e4c17a28904850a58f2f4f3.tar.bz2
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.
-rw-r--r--riscos/gui.c22
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/mouse.c41
-rw-r--r--riscos/mouse.h19
-rw-r--r--riscos/textselection.c6
-rw-r--r--riscos/treeview.c2
-rw-r--r--riscos/window.c9
7 files changed, 66 insertions, 34 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index 890c5ddc2..3ce44fd05 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 ea003cc3a..387fc952a 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 73535cae5..5ba1260b7 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 26fb72e5b..e78a37eed 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 501ac97e6..ab8ea5c3a 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 4756d8c2d..4fb2e1e7b 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 f3a6f05ce..65ac53616 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;