From f3f2c5b481c519d0ef4e501aa07c70baaaf7d86f Mon Sep 17 00:00:00 2001 From: Steve Fryatt Date: Sun, 8 Sep 2013 15:51:29 +0100 Subject: 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. --- riscos/download.c | 3 ++- riscos/gui.c | 2 ++ riscos/gui.h | 6 ++---- riscos/gui/button_bar.c | 17 +++++++++++++---- riscos/gui/button_bar.h | 9 --------- riscos/gui/status_bar.c | 1 - riscos/save.c | 11 +++-------- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/riscos/download.c b/riscos/download.c index 3e7076735..ebd981dca 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 3ce44fd05..69ec7e8a3 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 387fc952a..508931521 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 00e357457..7ca67f165 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 d92428859..9abae3151 100644 --- a/riscos/gui/button_bar.h +++ b/riscos/gui/button_bar.h @@ -290,15 +290,6 @@ bool ro_gui_button_bar_help_suffix(struct button_bar *button_bar, wimp_i i, wimp_mouse_state buttons, const char **suffix); -/** - * 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 diff --git a/riscos/gui/status_bar.c b/riscos/gui/status_bar.c index e01ae3c5d..899fe99b6 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 ffda9c69a..511af91f5 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); } -- cgit v1.2.3