From f11b834daf4a51dff1f6307531c0e41e622a8c6f Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sat, 31 Dec 2005 04:38:27 +0000 Subject: [project @ 2005-12-31 04:38:27 by rjw] Don't buffer any events. Use new wimp_event system. svn path=/import/netsurf/; revision=1915 --- riscos/gui.c | 224 +++++++++++++---------------------------------------------- riscos/gui.h | 67 ++++++++---------- 2 files changed, 77 insertions(+), 214 deletions(-) (limited to 'riscos') diff --git a/riscos/gui.c b/riscos/gui.c index ed46b86eb..791e25d3b 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -48,6 +48,7 @@ #include "netsurf/render/html.h" #include "netsurf/riscos/bitmap.h" #include "netsurf/riscos/buffer.h" +#include "netsurf/riscos/dialog.h" #include "netsurf/riscos/filename.h" #include "netsurf/riscos/global_history.h" #include "netsurf/riscos/gui.h" @@ -72,6 +73,7 @@ #endif #include "netsurf/riscos/url_complete.h" #include "netsurf/riscos/wimp.h" +#include "netsurf/riscos/wimp_event.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/utils.h" @@ -191,12 +193,6 @@ static wimp_MESSAGE_LIST(38) task_messages = { { #endif 0 } }; -struct ro_gui_poll_block { - wimp_event_no event; - wimp_block *block; - struct ro_gui_poll_block *next; -}; -struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0; static void ro_gui_choose_language(void); static void ro_gui_sprites_init(void); @@ -206,14 +202,13 @@ static void ro_gui_icon_bar_create(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_poll_queue(wimp_event_no event, wimp_block *block); static void ro_gui_null_reason_code(void); static void ro_gui_redraw_window_request(wimp_draw *redraw); 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_mouse_click(wimp_pointer *pointer); -static void ro_gui_icon_bar_click(wimp_pointer *pointer); +static bool ro_gui_icon_bar_click(wimp_pointer *pointer); static void ro_gui_check_resolvers(void); static void ro_gui_drag_end(wimp_dragged *drag); static void ro_gui_keypress(wimp_key *key); @@ -295,6 +290,7 @@ void gui_init(int argc, char** argv) if (!option_toolbar_history) option_toolbar_history = strdup("01|23"); + ro_gui_sprites_init(); ro_gui_choose_language(); bitmap_initialise_memory(); @@ -347,7 +343,7 @@ void gui_init(int argc, char** argv) error->errnum, error->errmess)); die(error->errmess); } - ro_gui_dialog_init(); + ro_gui_dialog_init(); /* must be done after sprite loading */ ro_gui_download_init(); ro_gui_menu_init(); ro_gui_query_init(); @@ -356,7 +352,6 @@ void gui_init(int argc, char** argv) #endif ro_gui_history_init(); wimp_close_template(); - ro_gui_sprites_init(); ro_gui_tree_initialise(); /* must be done after sprite loading */ ro_gui_hotlist_initialise(); ro_gui_global_history_initialise(); @@ -492,6 +487,8 @@ void ro_gui_icon_bar_create(void) (wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT), { "!netsurf" } } }; wimp_create_icon(&icon); + ro_gui_wimp_event_register_mouse_click(wimp_ICON_BAR, + ro_gui_icon_bar_click); } #endif @@ -659,17 +656,6 @@ void gui_poll(bool active) wimp_block block; const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN; - /* Process queued events. */ - while (ro_gui_poll_queued_blocks) { - struct ro_gui_poll_block *next; - ro_gui_handle_event(ro_gui_poll_queued_blocks->event, - ro_gui_poll_queued_blocks->block); - next = ro_gui_poll_queued_blocks->next; - free(ro_gui_poll_queued_blocks->block); - free(ro_gui_poll_queued_blocks); - ro_gui_poll_queued_blocks = next; - } - /* Poll wimp. */ xhourglass_off(); if (active) { @@ -794,58 +780,9 @@ void gui_multitask(void) xhourglass_on(); gui_last_poll = clock(); - switch (event) { - case wimp_KEY_PRESSED: - case wimp_MENU_SELECTION: - ro_gui_poll_queue(event, &block); - break; - - default: - ro_gui_handle_event(event, &block); - break; - } -} - - -/** - * Add a wimp_block to the queue for later handling. - */ - -void ro_gui_poll_queue(wimp_event_no event, wimp_block *block) -{ - struct ro_gui_poll_block *q = - calloc(1, sizeof(struct ro_gui_poll_block)); - if (!q) { - LOG(("Insufficient memory for calloc")); - warn_user("NoMemory", 0); - return; - } - - q->event = event; - q->block = calloc(1, sizeof(*block)); - if (!q->block) { - free(q); - LOG(("Insufficient memory for calloc")); - warn_user("NoMemory", 0); - return; - } - memcpy(q->block, block, sizeof(*block)); - q->next = NULL; - - if (ro_gui_poll_queued_blocks == NULL) { - ro_gui_poll_queued_blocks = q; - return; - } else { - struct ro_gui_poll_block *current = - ro_gui_poll_queued_blocks; - while (current->next != NULL) - current = current->next; - current->next = q; - } - return; + ro_gui_handle_event(event, &block); } - /** * Handle Null_Reason_Code events. */ @@ -899,41 +836,12 @@ void ro_gui_redraw_window_request(wimp_draw *redraw) { struct gui_window *g; - if (redraw->w == history_window) - ro_gui_history_redraw(redraw); - else if (redraw->w == dialog_url_complete) - ro_gui_url_complete_redraw(redraw); - else if ((hotlist_tree) && (redraw->w == (wimp_w)hotlist_tree->handle)) - ro_gui_tree_redraw(redraw, hotlist_tree); - else if ((global_history_tree) && (redraw->w == (wimp_w)global_history_tree->handle)) - ro_gui_tree_redraw(redraw, global_history_tree); - else if ((hotlist_tree) && (hotlist_tree->toolbar) && - (hotlist_tree->toolbar->toolbar_handle == redraw->w)) - ro_gui_theme_redraw(hotlist_tree->toolbar, redraw); - else if ((hotlist_tree) && (hotlist_tree->toolbar) && - (hotlist_tree->toolbar->editor) && - (hotlist_tree->toolbar->editor->toolbar_handle == redraw->w)) - ro_gui_theme_redraw(hotlist_tree->toolbar->editor, redraw); - else if ((global_history_tree) && (global_history_tree->toolbar) && - (global_history_tree->toolbar->toolbar_handle == redraw->w)) - ro_gui_theme_redraw(global_history_tree->toolbar, redraw); - else if ((global_history_tree) && (global_history_tree->toolbar) && - (global_history_tree->toolbar->editor) && - (global_history_tree->toolbar->editor->toolbar_handle == redraw->w)) - ro_gui_theme_redraw(global_history_tree->toolbar->editor, redraw); - else if (redraw->w == dialog_debug) - ro_gui_debugwin_redraw(redraw); - else if ((g = ro_gui_window_lookup(redraw->w)) != NULL) + if (ro_gui_wimp_event_redraw_window(redraw)) + return; + + g = ro_gui_window_lookup(redraw->w); + if (g) ro_gui_window_redraw(g, redraw); - else if ((g = ro_gui_toolbar_lookup(redraw->w)) != NULL) { - if (g->toolbar->toolbar_handle == redraw->w) - ro_gui_theme_redraw(g->toolbar, redraw); - else if ((g->toolbar->editor) && - (g->toolbar->editor->toolbar_handle == redraw->w)) - ro_gui_theme_redraw(g->toolbar->editor, redraw); - } else { - ro_gui_dialog_redraw(redraw); - } } @@ -946,13 +854,12 @@ void ro_gui_open_window_request(wimp_open *open) struct gui_window *g; os_error *error; + if (ro_gui_wimp_event_open_window(open)) + return; + g = ro_gui_window_lookup(open->w); if (g) { ro_gui_window_open(g, open); - } else if ((hotlist_tree) && (open->w == (wimp_w)hotlist_tree->handle)){ - ro_gui_tree_open(open, hotlist_tree); - } else if ((global_history_tree) && (open->w == (wimp_w)global_history_tree->handle)){ - ro_gui_tree_open(open, global_history_tree); } else { error = xwimp_open_window(open); if (error) { @@ -982,16 +889,14 @@ void ro_gui_close_window_request(wimp_close *close) */ ro_gui_dialog_close_persistent(close->w); - if (close->w == dialog_debug) - ro_gui_debugwin_close(); - else if ((g = ro_gui_window_lookup(close->w)) != NULL) { + if ((g = ro_gui_window_lookup(close->w)) != NULL) { ro_gui_url_complete_close(NULL, 0); browser_window_destroy(g->bw); - } - else if ((dw = ro_gui_download_window_lookup(close->w)) != NULL) + } else if ((dw = ro_gui_download_window_lookup(close->w)) != NULL) { ro_gui_download_window_destroy(dw, false); - else + } else { ro_gui_dialog_close(close->w); + } } @@ -1048,44 +953,17 @@ void ro_gui_mouse_click(wimp_pointer *pointer) struct gui_download_window *dw; struct gui_query_window *qw; - if (pointer->w == wimp_ICON_BAR) - ro_gui_icon_bar_click(pointer); - else if (pointer->w == history_window) - ro_gui_history_click(pointer); - else if (pointer->w == dialog_url_complete) + if (ro_gui_wimp_event_mouse_click(pointer)) + return; + + if (pointer->w == dialog_url_complete) ro_gui_url_complete_mouse_at(pointer, true); - else if ((hotlist_tree) && (pointer->w == (wimp_w)hotlist_tree->handle)) - ro_gui_hotlist_click(pointer); - else if ((global_history_tree) && (pointer->w == (wimp_w)global_history_tree->handle)) - ro_gui_global_history_click(pointer); - else if (pointer->w == dialog_saveas) - ro_gui_save_click(pointer); - else if ((hotlist_tree) && (hotlist_tree->toolbar) && - (hotlist_tree->toolbar->toolbar_handle == pointer->w)) - ro_gui_tree_toolbar_click(pointer, hotlist_tree); - else if ((hotlist_tree) && (hotlist_tree->toolbar) && - (hotlist_tree->toolbar->editor) && - (hotlist_tree->toolbar->editor->toolbar_handle == pointer->w)) - ro_gui_tree_toolbar_click(pointer, hotlist_tree); - else if ((global_history_tree) && (global_history_tree->toolbar) && - (global_history_tree->toolbar->toolbar_handle == pointer->w)) - ro_gui_tree_toolbar_click(pointer, global_history_tree); - else if ((global_history_tree) && (global_history_tree->toolbar) && - (global_history_tree->toolbar->editor) && - (global_history_tree->toolbar->editor->toolbar_handle == pointer->w)) - ro_gui_tree_toolbar_click(pointer, global_history_tree); else if ((g = ro_gui_window_lookup(pointer->w)) != NULL) ro_gui_window_click(g, pointer); - else if ((g = ro_gui_toolbar_lookup(pointer->w)) != NULL) - ro_gui_toolbar_click(g, pointer); - else if ((g = ro_gui_status_lookup(pointer->w)) != NULL) - ro_gui_status_click(g, pointer); else if ((dw = ro_gui_download_window_lookup(pointer->w)) != NULL) ro_gui_download_window_click(dw, pointer); else if ((qw = ro_gui_query_window_lookup(pointer->w)) != NULL) ro_gui_query_window_click(qw, pointer); - else - ro_gui_dialog_click(pointer); } @@ -1093,7 +971,7 @@ void ro_gui_mouse_click(wimp_pointer *pointer) * Handle Mouse_Click events on the iconbar icon. */ -void ro_gui_icon_bar_click(wimp_pointer *pointer) +bool ro_gui_icon_bar_click(wimp_pointer *pointer) { char url[80]; int key_down = 0; @@ -1120,6 +998,7 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer) else ro_gui_debugwin_open(); } + return true; } @@ -1179,11 +1058,9 @@ void ro_gui_keypress(wimp_key *key) bool handled = false; struct gui_window *g; os_error *error; - - if ((hotlist_tree) && (key->w == (wimp_w)hotlist_tree->handle)) - handled = ro_gui_tree_keypress(key->c, hotlist_tree); - else if ((global_history_tree) && (key->w == (wimp_w)global_history_tree->handle)) - handled = ro_gui_tree_keypress(key->c, global_history_tree); + + if (ro_gui_wimp_event_keypress(key)) + handled = true; else if ((g = ro_gui_window_lookup(key->w)) != NULL) handled = ro_gui_window_keypress(g, key->c, false); else if ((g = ro_gui_toolbar_lookup(key->w)) != NULL) @@ -1192,8 +1069,6 @@ void ro_gui_keypress(wimp_key *key) handled = ro_gui_query_window_keypress(qw, key); else if ((dw = ro_gui_download_window_lookup(key->w)) != NULL) handled = ro_gui_download_window_keypress(dw, key); - else - handled = ro_gui_dialog_keypress(key); if (!handled) { error = xwimp_process_key(key->c); @@ -1263,7 +1138,7 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message) break; case message_MENUS_DELETED: - ro_gui_menu_closed(); + ro_gui_menu_closed(true); break; case message_MODE_CHANGE: @@ -1399,7 +1274,7 @@ void ro_msg_dataload(wimp_message *message) os_error *error; int x, y; bool before; - bool tree_edit = false; + struct url_content *data; g = ro_gui_window_lookup(message->data.data_xfer.w); if (g) { @@ -1455,26 +1330,25 @@ void ro_msg_dataload(wimp_message *message) browser_window_go(g->bw, url, 0); } else if ((hotlist_tree) && ((wimp_w)hotlist_tree->handle == message->data.data_xfer.w)) { - if (!title) { - tree_edit = true; - title = url; + data = url_store_find(url); + if (data) { + if ((title) && (!data->title)) + data->title = title; + if (!title) + title = strdup(url); + ro_gui_tree_get_tree_coordinates(hotlist_tree, + message->data.data_xfer.pos.x, + message->data.data_xfer.pos.y, + &x, &y); + link = tree_get_link_details(hotlist_tree, x, y, &before); + node = tree_create_URL_node(NULL, data, title); + tree_link_node(link, node, before); + tree_handle_node_changed(hotlist_tree, node, false, true); + tree_redraw_area(hotlist_tree, node->box.x - NODE_INSTEP, 0, + NODE_INSTEP, 16384); + if (!title) + ro_gui_tree_start_edit(hotlist_tree, &node->data, NULL); } - ro_gui_tree_get_tree_coordinates(hotlist_tree, - message->data.data_xfer.pos.x, - message->data.data_xfer.pos.y, - &x, &y); - link = tree_get_link_details(hotlist_tree, x, y, &before); - node = tree_create_URL_node(NULL, - title, url, tree_file_type, - time(NULL), -1, 0); - tree_link_node(link, node, before); - tree_handle_node_changed(hotlist_tree, node, false, true); - tree_redraw_area(hotlist_tree, node->box.x - NODE_INSTEP, 0, - NODE_INSTEP, 16384); - if (tree_edit) - ro_gui_tree_start_edit(hotlist_tree, &node->data, NULL); - else - free(title); } else { browser_window_create(url, 0, 0); } diff --git a/riscos/gui.h b/riscos/gui.h index a8df7dcd4..cdae349cd 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -24,6 +24,9 @@ #define RISCOS5 0xAA +#define THUMBNAIL_WIDTH 100 +#define THUMBNAIL_HEIGHT 86 + extern int os_version; extern const char * NETSURF_DIR; @@ -39,7 +42,10 @@ extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, dialog_config_th_pane, dialog_debug, dialog_folder, dialog_entry, dialog_search, dialog_print, dialog_config_font, dialog_theme_install, dialog_url_complete; +extern wimp_w current_menu_window; +extern bool current_menu_open; extern wimp_menu *font_menu; /* font.c */ +extern wimp_menu *recent_search_menu; /* search.c */ extern wimp_w history_window; extern struct form_control *current_gadget; extern bool gui_reformat_pending; @@ -100,26 +106,6 @@ void ro_gui_view_source(struct content *content); void ro_gui_drag_box_start(wimp_pointer *pointer); bool ro_gui_prequit(void); -/* in dialog.c */ -void ro_gui_dialog_init(void); -wimp_w ro_gui_dialog_create(const char *template_name); -wimp_window * ro_gui_dialog_load_template(const char *template_name); -void ro_gui_dialog_open(wimp_w w); -void ro_gui_dialog_open_persistent(wimp_w parent, wimp_w w, bool pointer); -void ro_gui_dialog_close_persistent(wimp_w parent); -void ro_gui_dialog_click(wimp_pointer *pointer); -void ro_gui_dialog_prepare_zoom(struct gui_window *g); -void ro_gui_dialog_prepare_open_url(void); -void ro_gui_save_options(void); -bool ro_gui_dialog_keypress(wimp_key *key); -void ro_gui_dialog_close(wimp_w close); -void ro_gui_dialog_open_config(void); -void ro_gui_dialog_proxyauth_menu_selection(int item); -void ro_gui_dialog_image_menu_selection(int item); -void ro_gui_dialog_languages_menu_selection(const char *lang); -void ro_gui_dialog_font_menu_selection(int item); -void ro_gui_dialog_redraw(wimp_draw *redraw); - /* in download.c */ void ro_gui_download_init(void); struct gui_download_window * ro_gui_download_window_lookup(wimp_w w); @@ -145,9 +131,6 @@ void ro_gui_selection_drag_claim(wimp_full_message_drag_claim *drag); /* in 401login.c */ #ifdef WITH_AUTH void ro_gui_401login_init(void); -void ro_gui_401login_open(wimp_w parent, char* host, char * realm, char* fetchurl); -void ro_gui_401login_click(wimp_pointer *pointer); -bool ro_gui_401login_keypress(wimp_key *key); #endif /* in window.c */ @@ -158,8 +141,8 @@ void ro_gui_window_update_dimensions(struct gui_window *g, int yscroll); void ro_gui_window_open(struct gui_window *g, wimp_open *open); void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw); void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer); -void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer); -void ro_gui_status_click(struct gui_window *g, wimp_pointer *pointer); +bool ro_gui_toolbar_click(wimp_pointer *pointer); +bool ro_gui_status_click(wimp_pointer *pointer); void ro_gui_throb(void); struct gui_window *ro_gui_window_lookup(wimp_w window); struct gui_window *ro_gui_toolbar_lookup(wimp_w window); @@ -188,33 +171,31 @@ void ro_gui_history_init(void); void ro_gui_history_quit(void); void ro_gui_history_mode_change(void); void ro_gui_history_open(struct browser_window *bw, struct history *history, bool pointer); -void ro_gui_history_redraw(wimp_draw *redraw); -void ro_gui_history_click(wimp_pointer *pointer); void ro_gui_history_mouse_at(wimp_pointer *pointer); /* in hotlist.c */ void ro_gui_hotlist_initialise(void); void ro_gui_hotlist_save(void); -void ro_gui_hotlist_click(wimp_pointer *pointer); void ro_gui_hotlist_prepare_folder_dialog(struct node *node); void ro_gui_hotlist_prepare_entry_dialog(struct node *node); -void ro_gui_hotlist_dialog_click(wimp_pointer *pointer); +bool ro_gui_hotlist_dialog_apply(wimp_w w); int ro_gui_hotlist_help(int x, int y); /* in save.c */ wimp_w ro_gui_saveas_create(const char *template_name); void ro_gui_saveas_quit(void); void ro_gui_save_prepare(gui_save_type save_type, struct content *c); -void ro_gui_save_click(wimp_pointer *pointer); +void ro_gui_save_start_drag(wimp_pointer *pointer); void ro_gui_drag_icon(int x, int y, const char *sprite); 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); -void ro_gui_save_ok(wimp_w w); +bool ro_gui_save_ok(wimp_w w); void ro_gui_convert_save_path(char *dp, size_t len, const char *p); /* in filetype.c */ int ro_content_filetype(struct content *content); +int ro_content_filetype_from_type(content_type type); /* in schedule.c */ extern bool sched_active; @@ -222,19 +203,16 @@ extern os_t sched_time; /* in debugwin.c */ void ro_gui_debugwin_open(void); -void ro_gui_debugwin_close(void); -void ro_gui_debugwin_redraw(wimp_draw *redraw); /* in search.c */ +void ro_gui_search_init(void); void ro_gui_search_prepare(struct gui_window *g); -void ro_gui_search_end(void); -void ro_gui_search_click(wimp_pointer *pointer); -bool ro_gui_search_keypress(wimp_key *key); +bool ro_gui_search_prepare_menu(void); +void ro_gui_search_end(wimp_w w); /* in print.c */ +void ro_gui_print_init(void); void ro_gui_print_prepare(struct gui_window *g); -void ro_gui_print_click(wimp_pointer *pointer); -bool ro_gui_print_keypress(wimp_key *key); /* in font.c */ void nsfont_init(void); @@ -251,7 +229,7 @@ extern int ro_plot_origin_y; void ro_plot_set_scale(float scale); /* in theme_install.c */ -void ro_gui_theme_install_click(wimp_pointer *pointer); +bool ro_gui_theme_install_apply(wimp_w w); /* icon numbers for browser toolbars */ #define ICON_TOOLBAR_BACK 0 @@ -403,6 +381,7 @@ void ro_gui_theme_install_click(wimp_pointer *pointer); #define ICON_SEARCH_FIND_PREV 3 #define ICON_SEARCH_CANCEL 4 #define ICON_SEARCH_STATUS 5 +#define ICON_SEARCH_MENU 8 #define ICON_PRINT_TO_BOTTOM 1 #define ICON_PRINT_SHEETS 2 @@ -431,4 +410,14 @@ void ro_gui_theme_install_click(wimp_pointer *pointer); #define ICON_OPENURL_OPEN 3 #define ICON_OPENURL_MENU 4 +#define ICON_ENTRY_NAME 1 +#define ICON_ENTRY_URL 3 +#define ICON_ENTRY_CANCEL 4 +#define ICON_ENTRY_OK 5 +#define ICON_ENTRY_RECENT 6 + +#define ICON_FOLDER_NAME 1 +#define ICON_FOLDER_CANCEL 2 +#define ICON_FOLDER_OK 3 + #endif -- cgit v1.2.3