summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorSteve Fryatt <stevef@netsurf-browser.org>2013-09-08 00:47:55 +0100
committerSteve Fryatt <stevef@netsurf-browser.org>2013-09-08 00:47:55 +0100
commite87596ad1f7755c50f7a00edc85e66908ad1ba10 (patch)
tree25bd6b8f87613de2fa0e054e8083237542ad71d9 /riscos
parent9871ca4a2d6ffc8f41634a05c177d5145c339959 (diff)
downloadnetsurf-e87596ad1f7755c50f7a00edc85e66908ad1ba10.tar.gz
netsurf-e87596ad1f7755c50f7a00edc85e66908ad1ba10.tar.bz2
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.
Diffstat (limited to 'riscos')
-rw-r--r--riscos/Makefile.target4
-rw-r--r--riscos/download.c14
-rw-r--r--riscos/gui.c74
-rw-r--r--riscos/gui.h5
-rw-r--r--riscos/mouse.c131
-rw-r--r--riscos/mouse.h69
-rw-r--r--riscos/save.c12
-rw-r--r--riscos/save.h1
-rw-r--r--riscos/textselection.c13
-rw-r--r--riscos/textselection.h1
-rw-r--r--riscos/treeview.c17
-rw-r--r--riscos/treeview.h3
-rw-r--r--riscos/window.c35
13 files changed, 277 insertions, 102 deletions
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index e73a5a3a1..b32590bfa 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 089714c11..3e7076735 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 58114540e..11ed3f406 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 b9e0647c1..8f165c027 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 000000000..12b4e3e54
--- /dev/null
+++ b/riscos/mouse.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2013 Stephen Fryatt <stevef@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 000000000..623c6dfaa
--- /dev/null
+++ b/riscos/mouse.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2013 Stephen Fryatt <stevef@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 ad2d4c467..ffda9c69a 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 b219de4c8..34a4a6ba9 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 094924bea..501ac97e6 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 a3763b46e..c6f96f0e9 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 51b6809c5..4641a6d0a 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 77505ac66..80ff7660f 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 d3375bebe..dbe505eb5 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.
*