mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
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.
This commit is contained in:
parent
a00e0f91c7
commit
ee8fb6f39f
22
riscos/gui.c
22
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;
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user