diff options
Diffstat (limited to 'amiga')
-rw-r--r-- | amiga/Makefile.target | 2 | ||||
-rw-r--r-- | amiga/bitmap.c | 4 | ||||
-rwxr-xr-x | amiga/bitmap.h | 1 | ||||
-rw-r--r-- | amiga/gui.c | 180 | ||||
-rwxr-xr-x | amiga/gui.h | 3 | ||||
-rwxr-xr-x | amiga/launch.c | 1 | ||||
-rw-r--r-- | amiga/menu.c | 115 | ||||
-rwxr-xr-x | amiga/misc.c | 6 | ||||
-rw-r--r-- | amiga/options.h | 2 | ||||
-rwxr-xr-x | amiga/schedule.c | 171 | ||||
-rw-r--r-- | amiga/theme.c | 103 | ||||
-rw-r--r-- | amiga/theme.h | 4 | ||||
-rw-r--r-- | amiga/tree.c | 2 |
13 files changed, 366 insertions, 228 deletions
diff --git a/amiga/Makefile.target b/amiga/Makefile.target index c90027465..ea765af36 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -2,7 +2,7 @@ # Amiga target setup # ---------------------------------------------------------------------------- -CFLAGS += -std=c99 -Dnsamiga -DFETCHER_CURLL_SCHEDULED +CFLAGS += -std=c99 -Dnsamiga ifneq ($(SUBTARGET),os3) CFLAGS += -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__ diff --git a/amiga/bitmap.c b/amiga/bitmap.c index f25ac2b81..271978b2e 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -152,7 +152,9 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags) int err = 0; Object *dto = NULL; - if(!ami_download_check_overwrite(path, NULL, 0)) return false; + if ((flags & AMI_BITMAP_FORCE_OVERWRITE) == 0) { + if(!ami_download_check_overwrite(path, NULL, 0)) return false; + } if(dto = ami_datatype_object_from_bitmap(bitmap)) { diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 0435aec5b..6657d2f8a 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -26,6 +26,7 @@ #include <libraries/Picasso96.h> #define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8 +#define AMI_BITMAP_FORCE_OVERWRITE 0xFF struct bitmap { int width; diff --git a/amiga/gui.c b/amiga/gui.c index 756ed63e2..9bf049a15 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -18,6 +18,7 @@ /* NetSurf core includes */ #include "content/backing_store.h" +#include "content/fetchers.h" #include "content/fetchers/resource.h" #include "content/urldb.h" #include "css/utils.h" @@ -171,9 +172,6 @@ ULONG screen_signal = -1; struct MsgPort *applibport = NULL; ULONG applibsig = 0; -BOOL refresh_search_ico = FALSE; -BOOL refresh_favicon = FALSE; -BOOL refresh_throbber = FALSE; struct Hook newprefs_hook; STRPTR temp_homepage_url = NULL; @@ -181,6 +179,7 @@ bool cli_force = false; static char *current_user; static char *current_user_dir; +static char *current_user_faviconcache; static const __attribute__((used)) char *stack_cookie = "\0$STACK:262144\0"; @@ -1418,6 +1417,12 @@ static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) g->favicon = icon; } +static void ami_gui_refresh_favicon(void *p) +{ + struct gui_window_2 *gwin = (struct gui_window_2 *)p; + gui_window_set_icon(gwin->bw->window, gwin->bw->window->favicon); +} + void ami_handle_msg(void) { ULONG class,result,storage = 0,x,y,xs,ys,width=800,height=600; @@ -2115,7 +2120,7 @@ void ami_handle_msg(void) case AMINS_WINDOW: ami_set_border_gadget_balance(gwin); - ami_update_throbber(gwin,true); + ami_throbber_redraw_schedule(0, gwin->bw->window); if(gwin->tabs) { @@ -2127,12 +2132,11 @@ void ami_handle_msg(void) GetClickTabNodeAttrs(tab, TNA_UserData, &bw, TAG_DONE); - bw->reformat_pending = true; } while(tab=ntab); } - refresh_favicon = TRUE; - gwin->bw->reformat_pending = true; + ami_schedule(0, ami_gui_refresh_favicon, gwin); + browser_window_schedule_reformat(gwin->bw); ami_schedule_redraw(gwin, true); break; } @@ -2201,36 +2205,8 @@ void ami_handle_msg(void) // ReplyMsg((struct Message *)message); } - if(node->Type == AMINS_WINDOW) - { - /* Catch any reformats tagged by the core - only used by scale? */ - if(gwin->bw->reformat_pending) { - ami_schedule_redraw(gwin, true); - } - - if(gwin->bw->window->throbbing) - ami_update_throbber(gwin,false); - } } while(node = nnode); - if(refresh_search_ico) - { - search_web_select_provider(-1); - refresh_search_ico = FALSE; - } - - if(refresh_favicon) - { - gui_window_set_icon(gwin->bw->window, gwin->bw->window->favicon); - refresh_favicon = FALSE; - } - - if(refresh_throbber) - { - ami_update_throbber(gwin, true); - refresh_throbber = FALSE; - } - if(ami_menu_window_close) { if(ami_menu_window_close == (void *)AMI_MENU_WINDOW_CLOSE_ALL) @@ -2461,15 +2437,39 @@ void ami_get_msg(void) ULONG appsig = 1L << appport->mp_SigBit; ULONG schedulesig = 1L << msgport->mp_SigBit; ULONG ctrlcsig = SIGBREAKF_CTRL_C; - ULONG signal; + uint32 signal = 0; + fd_set read_fd_set, write_fd_set, except_fd_set; + int max_fd = -1; struct TimerRequest *timermsg = NULL; struct MsgPort *printmsgport = ami_print_get_msgport(); ULONG printsig = 0; ULONG helpsignal = ami_help_signal(); if(printmsgport) printsig = 1L << printmsgport->mp_SigBit; - ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig | helpsignal; - - signal = Wait(signalmask); + uint32 signalmask = winsignal | appsig | schedulesig | rxsig | + printsig | applibsig | helpsignal; + + if ((fetcher_fdset(&read_fd_set, &write_fd_set, &except_fd_set, &max_fd) == NSERROR_OK) && + (max_fd != -1)) { + /* max_fd is the highest fd in use, but waitselect() needs to know how many + * are in use, so we add 1. */ + if (waitselect(max_fd + 1, &read_fd_set, &write_fd_set, &except_fd_set, + NULL, (unsigned int *)&signalmask) != -1) { + signal = signalmask; + } else { + LOG(("waitselect() returned error")); + /* \todo Fix Ctrl-C handling. + * WaitSelect() from bsdsocket.library returns -1 if the task was + * signalled with a Ctrl-C. waitselect() from newlib.library does not. + * Adding the Ctrl-C signal to our user signal mask causes a Ctrl-C to + * occur sporadically. Otherwise we never get a -1 except on error. + * NetSurf still terminates at the Wait() when network activity is over. + */ + } + } else { + /* If fetcher_fdset fails or no network activity, do it the old fashioned way. */ + signalmask |= ctrlcsig; + signal = Wait(signalmask); + } if(signal & winsignal) ami_handle_msg(); @@ -2502,18 +2502,9 @@ void ami_get_msg(void) ami_quit_netsurf_delayed(); } -static void ami_gui_fetch_callback(void *p) -{ - /* This doesn't need to do anything - the scheduled event will - * send a message to trigger Wait() to return, thereby causing - * the event function to return, and NetSurf to call - * hlcache_poll() as part of the usual fetch/event loop. - */ -} static void gui_poll(bool active) { - if(active) ami_schedule(0, ami_gui_fetch_callback, NULL); ami_get_msg(); } @@ -2561,8 +2552,8 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw) GetAttr(CLICKTAB_CurrentNode, (Object *)gwin->objects[GID_TABS], (ULONG *)&tabnode); GetClickTabNodeAttrs(tabnode, - TNA_UserData, &gwin->bw, - TAG_DONE); + TNA_UserData, &gwin->bw, + TAG_DONE); curbw = gwin->bw; GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox); @@ -2586,7 +2577,6 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw) p96RectFill(gwin->win->RPort, bbox->Left, bbox->Top, bbox->Width+bbox->Left, bbox->Height+bbox->Top, 0xffffffff); - browser_window_update(gwin->bw, false); gui_window_set_scroll(gwin->bw->window, @@ -2594,8 +2584,8 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw) gwin->redraw_scroll = false; browser_window_refresh_url_bar(gwin->bw); - ami_gui_update_hotlist_button(gwin); + ami_throbber_redraw_schedule(0, gwin->bw->window); } } @@ -2769,9 +2759,40 @@ static void gui_quit(void) FreeVec(current_user_options); FreeVec(current_user_dir); + FreeVec(current_user_faviconcache); FreeVec(current_user); } +char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail) +{ + STRPTR filename = NULL; + BPTR lock = 0; + + if (filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url))) { + LOG(("favicon cache location: %s", filename)); + + if (only_if_avail == true) { + if(lock = Lock(filename, ACCESS_READ)) { + UnLock(lock); + return filename; + } + } else { + return filename; + } + } + return NULL; +} + +static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon) +{ + STRPTR filename = NULL; + + if (filename = ami_gui_get_cache_favicon_name(url, false)) { + if(favicon) bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE); + FreeVec(filename); + } +} + void ami_gui_update_hotlist_button(struct gui_window_2 *gwin) { char *url; @@ -2785,6 +2806,9 @@ void ami_gui_update_hotlist_button(struct gui_window_2 *gwin) if(hotlist_has_url(nsurl)) { RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL, BUTTON_RenderImage, gwin->objects[GID_FAVE_RMV], TAG_DONE); + + if (gwin->bw->window->favicon) + ami_gui_cache_favicon(nsurl, content_get_bitmap(gwin->bw->window->favicon)); } else { RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL, BUTTON_RenderImage, gwin->objects[GID_FAVE_ADD], TAG_DONE); @@ -2924,7 +2948,6 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin) gwin->win, NULL, TRUE); if(gwin->bw) { - gwin->bw->reformat_pending = true; ami_schedule_redraw(gwin, true); } } @@ -2966,7 +2989,6 @@ void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin) RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN], gwin->win, NULL, TRUE); - gwin->bw->reformat_pending = true; ami_schedule_redraw(gwin, true); } @@ -2995,7 +3017,10 @@ void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin) } } -void ami_gui_hotlist_toolbar_update_all(void) +/** + * Update hotlist toolbar and recreate the menu for all windows + */ +void ami_gui_hotlist_update_all(void) { struct nsObject *node; struct nsObject *nnode; @@ -3012,6 +3037,7 @@ void ami_gui_hotlist_toolbar_update_all(void) if(node->Type == AMINS_WINDOW) { ami_gui_hotlist_toolbar_update(gwin); + ami_menu_refresh(gwin); } } while(node = nnode); } @@ -3075,7 +3101,6 @@ void ami_toggletabbar(struct gui_window_2 *gwin, bool show) gwin->win, NULL, TRUE); if(gwin->bw) { - gwin->bw->reformat_pending = true; ami_schedule_redraw(gwin, true); } } @@ -3107,6 +3132,11 @@ void ami_gui_tabs_toggle_all(void) } while(node = nnode); } +void ami_gui_search_ico_refresh(void *p) +{ + search_web_select_provider(-1); +} + nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin) { nsurl *url; @@ -3229,6 +3259,7 @@ gui_window_create(struct browser_window *bw, if(nsoption_bool(new_tab_is_active)) ami_switch_tab(g->shared,false); ami_update_buttons(g->shared); + ami_schedule(0, ami_gui_refresh_favicon, g->shared); return g; } @@ -3751,7 +3782,7 @@ gui_window_create(struct browser_window *bw, if(locked_screen) UnlockPubScreen(NULL,scrn); - refresh_search_ico = TRUE; + ami_schedule(0, ami_gui_search_ico_refresh, NULL); ScreenToFront(scrn); @@ -4001,7 +4032,7 @@ static void ami_redraw_callback(void *p) { struct gui_window_2 *gwin = (struct gui_window_2 *)p; - if(gwin->redraw_required || gwin->bw->reformat_pending) { + if(gwin->redraw_required) { ami_do_redraw(gwin); } @@ -4030,7 +4061,6 @@ void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw) if(full_redraw) gwin->redraw_required = true; if(gwin->redraw_scheduled == true) return; - if(gwin->bw->reformat_pending) ms = nsoption_int(reformat_delay) * 10; ami_schedule(ms, ami_redraw_callback, gwin); gwin->redraw_scheduled = true; } @@ -4261,6 +4291,21 @@ static void gui_window_update_box(struct gui_window *g, const struct rect *rect) ami_schedule_redraw(g->shared, false); } +/** + * callback from core to reformat a window. + */ +static void amiga_window_reformat(struct gui_window *gw) +{ + struct IBox *bbox; + + if (gw != NULL) { + GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox); + browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height); + + gw->shared->redraw_scroll = false; + } +} + static void ami_do_redraw(struct gui_window_2 *gwin) { struct Rectangle rect; @@ -4283,13 +4328,6 @@ static void ami_do_redraw(struct gui_window_2 *gwin) xoffset=bbox->Left; yoffset=bbox->Top; - if(gwin->bw->reformat_pending) - { - browser_window_reformat(gwin->bw, false, width, height); - gwin->bw->reformat_pending = false; - gwin->redraw_scroll = false; - } - if(gwin->redraw_scroll) { if((abs(vcurrent-oldv) > height) || (abs(hcurrent-oldh) > width)) @@ -4648,7 +4686,7 @@ static void gui_window_set_url(struct gui_window *g, const char *url) static uint32 ami_set_favicon_render_hook(struct Hook *hook, APTR space, struct gpRender *msg) { - refresh_favicon = TRUE; + ami_schedule(0, ami_gui_refresh_favicon, hook->h_Data); return 0; } @@ -4708,7 +4746,8 @@ static nserror gui_search_web_provider_update(const char *provider_name, static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space, struct gpRender *msg) { - refresh_throbber = TRUE; + struct gui_window_2 *gwin = hook->h_Data; + ami_throbber_redraw_schedule(0, gwin->bw->window); return 0; } @@ -5030,6 +5069,7 @@ static struct gui_window_table amiga_window_table = { .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, .update_extent = gui_window_update_extent, + .reformat = amiga_window_reformat, .set_icon = gui_window_set_icon, .set_title = gui_window_set_title, @@ -5100,6 +5140,8 @@ int main(int argc, char** argv) .llcache = filesystem_llcache_table, }; + signal(SIGINT, SIG_IGN); + ret = netsurf_register(&amiga_table); if (ret != NSERROR_OK) { die("NetSurf operation table failed registration"); @@ -5127,8 +5169,10 @@ int main(int argc, char** argv) current_user_options = ASPrintf("%s/Choices", current_user_dir); current_user_cache = ASPrintf("%s/Cache", current_user_dir); + current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir); if(lock = CreateDirTree(current_user_cache)) UnLock(lock); + if(lock = CreateDirTree(current_user_faviconcache)) UnLock(lock); ami_mime_init("PROGDIR:Resources/mimetypes"); sprintf(temp, "%s/mimetypes.user", current_user_dir); diff --git a/amiga/gui.h b/amiga/gui.h index f5a9030c9..c106455d1 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -162,11 +162,12 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie); bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y); BOOL ami_gadget_hit(Object *obj, int x, int y); void ami_gui_history(struct gui_window_2 *gwin, bool back); -void ami_gui_hotlist_toolbar_update_all(void); +void ami_gui_hotlist_update_all(void); void ami_gui_tabs_toggle_all(void); bool ami_locate_resource(char *fullpath, const char *file); void ami_gui_update_hotlist_button(struct gui_window_2 *gwin); nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin); +char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail); struct TextFont *origrpfont; struct MinList *window_list; diff --git a/amiga/launch.c b/amiga/launch.c index 1405d6a71..d3c9ff11e 100755 --- a/amiga/launch.c +++ b/amiga/launch.c @@ -31,6 +31,7 @@ #include <proto/openurl.h> #include "utils/nsoption.h" +#include "utils/nsurl.h" #include "utils/url.h" struct Library *OpenURLBase = NULL; diff --git a/amiga/menu.c b/amiga/menu.c index 43c8c188b..70028af68 100644 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -35,8 +35,6 @@ #include <images/label.h> #include <proto/bitmap.h> #include <images/bitmap.h> -#include <proto/glyph.h> -#include <images/glyph.h> #include <reaction/reaction_macros.h> @@ -358,13 +356,34 @@ void ami_menu_free_glyphs(void) menu_glyphs_loaded = false; } +static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct RastPort *rp) +{ + int space_width = TextLength(rp, " ", 1); + int item_size; + + item_size = TextLength(rp, gwin->menulab[j], strlen(gwin->menulab[j])); + item_size += space_width; + + if(gwin->menukey[j]) { + item_size += TextLength(rp, &gwin->menukey[j], 1); + item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY]; + /**TODO: take account of the size of other imagery too + */ + } + + return item_size; +} + + static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin) { int i, j; - int txtlen = 0; + int txtlen = 0, subtxtlen = 0; + int left_posn; struct RastPort *rp = &scrn->RastPort; struct DrawInfo *dri = GetScreenDrawInfo(scrn); - + int space_width = TextLength(rp, " ", 1); + if(menu_glyphs_loaded == false) ami_menu_load_glyphs(dri); @@ -373,18 +392,10 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin) if(gwin->menutype[i] == NM_TITLE) { j = i + 1; txtlen = 0; - int item_size = 0; do { if(gwin->menulab[j] != NM_BARLABEL) { if(gwin->menutype[j] == NM_ITEM) { - item_size = TextLength(rp, gwin->menulab[j], strlen(gwin->menulab[j])); - if(gwin->menukey[j]) { - item_size += TextLength(rp, &gwin->menukey[j], 1); - item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY]; - /**TODO: take account of the size of other imagery too - */ - } - + int item_size = ami_menu_calc_item_width(gwin, j, rp); if(item_size > txtlen) { txtlen = item_size; } @@ -399,32 +410,75 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin) using label.image if there's a bitmap associated with the item. */ if((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) { int icon_width = 0; + Object *blank_space = NULL; Object *submenuarrow = NULL; Object *icon = BitMapObject, BITMAP_Screen, scrn, BITMAP_SourceFile, gwin->menuicon[i], BITMAP_Masking, TRUE, BitMapEnd; + + /* \todo make this scale the bitmap to these dimensions */ + SetAttrs(icon, + BITMAP_Width, 16, + BITMAP_Height, 16, + TAG_DONE); + GetAttr(IA_Width, icon, (ULONG *)&icon_width); - + + if(gwin->menutype[i] == NM_SUB) { + left_posn = subtxtlen; + } else { + left_posn = txtlen; + } + + left_posn = left_posn - + TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) - + icon_width - space_width; + if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) { + left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU]; + submenuarrow = NewObject(NULL, "sysiclass", - SYSIA_Which, MENUSUB, - SYSIA_DrawInfo, dri, - IA_Left, txtlen - TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) - - menu_glyph_width[NSA_GLYPH_SUBMENU] - icon_width, + SYSIA_Which, MENUSUB, + SYSIA_DrawInfo, dri, + IA_Left, left_posn, TAG_DONE); + + j = i + 1; + subtxtlen = 0; + do { + if(gwin->menulab[j] != NM_BARLABEL) { + if(gwin->menutype[j] == NM_SUB) { + int item_size = ami_menu_calc_item_width(gwin, j, rp); + if(item_size > subtxtlen) { + subtxtlen = item_size; + } + } + } + j++; + } while((gwin->menutype[j] == NM_SUB)); } /**TODO: Checkmark/MX images and keyboard shortcuts */ + + if(gwin->menutype[i] == NM_SUB) { + blank_space = NewObject(NULL, "fillrectclass", + IA_Height, 0, + IA_Width, left_posn + icon_width, + TAG_DONE); + } gwin->menuobj[i] = LabelObject, LABEL_DrawInfo, dri, LABEL_DisposeImage, TRUE, LABEL_Image, icon, + LABEL_Text, " ", LABEL_Text, gwin->menulab[i], LABEL_DisposeImage, TRUE, + LABEL_Image, blank_space, + LABEL_DisposeImage, TRUE, LABEL_Image, submenuarrow, LabelEnd; @@ -478,14 +532,6 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin) if(nsoption_bool(background_images) == true) gwin->menu[M_IMGBACK].nm_Flags |= CHECKED; - /* Set up scheduler to refresh the hotlist menu */ - if(nsoption_int(menu_refresh) > 0) - { - ami_schedule(nsoption_int(menu_refresh) * 10, - (void *)ami_menu_refresh, - gwin); - } - return(gwin->menu); } @@ -551,7 +597,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin) static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder) { UBYTE type; - char *icon; + STRPTR icon; struct gui_window_2 *gw = (struct gui_window_2 *)userdata; if(item >= AMI_MENU_HOTLIST_MAX) return false; @@ -570,9 +616,10 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char } if(is_folder == true) { - icon = "icons/directory.png"; + icon = ASPrintf("icons/directory.png"); } else { - icon = "icons/content.png"; + icon = ami_gui_get_cache_favicon_name(url, true); + if (icon == NULL) icon = ASPrintf("icons/content.png"); } ami_menu_alloc_item(gw, item, type, title, @@ -580,6 +627,8 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char if((is_folder == true) && (type == NM_SUB)) gw->menu[item].nm_Flags = NM_ITEMDISABLED; + if(icon) FreeVec(icon); + return true; } @@ -844,8 +893,12 @@ static void ami_menu_item_edit_copy(struct Hook *hook, APTR window, struct Intui } else if(bm = content_get_bitmap(gwin->bw->current_content)) { - bm->url = (char *)nsurl_access(hlcache_handle_get_url(gwin->bw->current_content)); - bm->title = (char *)content_get_title(gwin->bw->current_content); + /** @todo It should be checked that the lifetime of + * the objects containing the values returned (and the + * constness cast away) is safe. + */ + bm->url = (char *)nsurl_access(browser_window_get_url(gwin->bw)); + bm->title = (char *)browser_window_get_title(gwin->bw); ami_easy_clipboard_bitmap(bm); } #ifdef WITH_NS_SVG diff --git a/amiga/misc.c b/amiga/misc.c index 67240006d..7d126c906 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -112,7 +112,7 @@ void die(const char *error) /** * Create a path from a nsurl using amiga file handling. * - * @parm[in] url The url to encode. + * @param[in] url The url to encode. * @param[out] path_out A string containing the result path which should * be freed by the caller. * @return NSERROR_OK and the path is written to \a path or error code @@ -254,8 +254,8 @@ char *translate_escape_chars(const char *s) * @param[in,out] size The size of the space available if \a str not * NULL on input and if not NULL set to the total * output length on output. - * @param[in] nemb The number of elements. - * @param[in] ... The elements of the path as string pointers. + * @param[in] nelm The number of elements. + * @param[in] ap The elements of the path as string pointers. * @return NSERROR_OK and the complete path is written to str * or error code on faliure. */ diff --git a/amiga/options.h b/amiga/options.h index e383dcf9a..868e28fdb 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -86,6 +86,4 @@ NSOPTION_INTEGER(redraw_tile_size_y, 0) NSOPTION_INTEGER(monitor_aspect_x, 0) NSOPTION_INTEGER(monitor_aspect_y, 0) NSOPTION_BOOL(accept_lang_locale, true) -NSOPTION_INTEGER(menu_refresh, 0) - diff --git a/amiga/schedule.c b/amiga/schedule.c index 9aa74881f..6222917cf 100755 --- a/amiga/schedule.c +++ b/amiga/schedule.c @@ -39,7 +39,15 @@ struct nscallback PblHeap *schedule_list; -static void ami_remove_timer_event(struct nscallback *nscb) +/** + * Remove timer event + * + * \param nscb callback + * + * The timer event for the callback is aborted + */ + +static void ami_schedule_remove_timer_event(struct nscallback *nscb) { if(!nscb) return; @@ -54,48 +62,112 @@ static void ami_remove_timer_event(struct nscallback *nscb) } /** - * Unschedule a callback. + * Add timer event + * + * \param nscb callback + * \param t time in ms + * + * NetSurf will be signalled in t ms for this event. + */ + +static nserror ami_schedule_add_timer_event(struct nscallback *nscb, int t) +{ + struct TimeVal tv; + ULONG time_us = t * 1000; /* t converted to µs */ + + nscb->tv.Seconds = time_us / 1000000; + nscb->tv.Microseconds = time_us % 1000000; + + GetSysTime(&tv); + AddTime(&nscb->tv,&tv); // now contains time when event occurs + + if(nscb->treq = AllocVecTagList(sizeof(struct TimeRequest), NULL)) { + *nscb->treq = *tioreq; + nscb->treq->Request.io_Command=TR_ADDREQUEST; + nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs + nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro + SendIO((struct IORequest *)nscb->treq); + } else { + return NSERROR_NOMEM; + } + + return NSERROR_OK; +} + +/** + * Locate a scheduled callback * * \param callback callback function * \param p user parameter, passed to callback function + * \param remove remove callback from the heap * - * All scheduled callbacks matching both callback and p are removed. + * A scheduled callback matching both callback and p is returned, or NULL if none present. */ -static nserror schedule_remove(void (*callback)(void *p), void *p) +static struct nscallback *ami_schedule_locate(void (*callback)(void *p), void *p, bool remove) { PblIterator *iterator; struct nscallback *nscb; - bool restoreheap = false; - - /* check there is something on the list to remove */ - if (schedule_list == NULL) - { - return NSERROR_OK; - } + bool found_cb = false; - if(pblHeapIsEmpty(schedule_list)) - { - return NSERROR_OK; - } + /* check there is something on the list */ + if (schedule_list == NULL) return NULL; + if(pblHeapIsEmpty(schedule_list)) return NULL; iterator = pblHeapIterator(schedule_list); - while ((nscb = pblIteratorNext(iterator)) != -1) - { - if((nscb->callback == callback) && (nscb->p == p)) - { - ami_remove_timer_event(nscb); - pblIteratorRemove(iterator); - FreeVec(nscb); - restoreheap = true; + while ((nscb = pblIteratorNext(iterator)) != -1) { + if ((nscb->callback == callback) && (nscb->p == p)) { + if (remove == true) pblIteratorRemove(iterator); + found_cb = true; + break; } }; pblIteratorFree(iterator); - if(restoreheap) - { + if (found_cb == true) return nscb; + else return NULL; +} + +/** + * Reschedule a callback. + * + * \param nscb callback + * \param t time in ms + * + * The nscallback will be rescheduled for t ms. + */ + +static nserror ami_schedule_reschedule(struct nscallback *nscb, int t) +{ + ami_schedule_remove_timer_event(nscb); + if (ami_schedule_add_timer_event(nscb, t) != NSERROR_OK) + return NSERROR_NOMEM; + + pblHeapConstruct(schedule_list); + return NSERROR_OK; +} + +/** + * Unschedule a callback. + * + * \param callback callback function + * \param p user parameter, passed to callback function + * + * All scheduled callbacks matching both callback and p are removed. + */ + +static nserror schedule_remove(void (*callback)(void *p), void *p) +{ + PblIterator *iterator; + struct nscallback *nscb; + + nscb = ami_schedule_locate(callback, p, true); + + if(nscb != NULL) { + ami_schedule_remove_timer_event(nscb); + FreeVec(nscb); pblHeapConstruct(schedule_list); } @@ -113,7 +185,7 @@ static void schedule_remove_all(void) while ((nscb = pblIteratorNext(iterator)) != -1) { - ami_remove_timer_event(nscb); + ami_schedule_remove_timer_event(nscb); pblIteratorRemove(iterator); FreeVec(nscb); }; @@ -155,7 +227,7 @@ void schedule_run(BOOL poll) callback = nscb->callback; p = nscb->p; - ami_remove_timer_event(nscb); + ami_schedule_remove_timer_event(nscb); pblHeapRemoveFirst(schedule_list); FreeVec(nscb); callback(p); @@ -200,11 +272,7 @@ void ami_schedule_open_timer(void) /* exported function documented in amiga/schedule.h */ void ami_schedule_close_timer(void) { - if(ITimer) - { - DropInterface((struct Interface *)ITimer); - } - + if(ITimer) DropInterface((struct Interface *)ITimer); CloseDevice((struct IORequest *) tioreq); FreeSysObject(ASOT_IOREQUEST,tioreq); FreeSysObject(ASOT_PORT,msgport); @@ -214,41 +282,19 @@ void ami_schedule_close_timer(void) nserror ami_schedule(int t, void (*callback)(void *p), void *p) { struct nscallback *nscb; - struct TimeVal tv; - ULONG time_us = 0; - - if(schedule_list == NULL) - { - return NSERROR_INIT_FAILED; - } - if(t < 0) - { - return schedule_remove(callback, p); + if(schedule_list == NULL) return NSERROR_INIT_FAILED; + if (t < 0) return schedule_remove(callback, p); + + if (nscb = ami_schedule_locate(callback, p, false)) { + return ami_schedule_reschedule(nscb, t); } nscb = AllocVecTagList(sizeof(struct nscallback), NULL); - if(!nscb) - { - return NSERROR_NOMEM; - } - - time_us = t * 1000; /* t converted to µs */ - - nscb->tv.Seconds = time_us / 1000000; - nscb->tv.Microseconds = time_us % 1000000; + if(!nscb) return NSERROR_NOMEM; - GetSysTime(&tv); - AddTime(&nscb->tv,&tv); // now contains time when event occurs - - if(nscb->treq = AllocVecTagList(sizeof(struct TimeRequest), NULL)) - { - *nscb->treq = *tioreq; - nscb->treq->Request.io_Command=TR_ADDREQUEST; - nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs - nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro - SendIO((struct IORequest *)nscb->treq); - } + if (ami_schedule_add_timer_event(nscb, t) != NSERROR_OK) + return NSERROR_NOMEM; nscb->callback = callback; nscb->p = p; @@ -257,3 +303,4 @@ nserror ami_schedule(int t, void (*callback)(void *p), void *p) return NSERROR_OK; } + diff --git a/amiga/theme.c b/amiga/theme.c index 29c72574b..cc8b55d7f 100644 --- a/amiga/theme.c +++ b/amiga/theme.c @@ -36,11 +36,12 @@ #include "amiga/bitmap.h" #include "amiga/drag.h" -#include "desktop/browser_private.h" -#include "utils/nsoption.h" +#include "amiga/schedule.h" #include "amiga/theme.h" +#include "desktop/browser_private.h" #include "desktop/searchweb.h" #include "utils/messages.h" +#include "utils/nsoption.h" #include "utils/utils.h" struct BitMap *throbber = NULL; @@ -157,7 +158,7 @@ void ami_theme_throbber_setup(void) ami_get_theme_filename(throbberfile,"theme_throbber",false); throbber_frames=atoi(messages_get("theme_throbber_frames")); throbber_update_interval = atoi(messages_get("theme_throbber_delay")); - if(throbber_update_interval == 0) throbber_update_interval = 100; + if(throbber_update_interval == 0) throbber_update_interval = 250; bm = ami_bitmap_from_datatype(throbberfile); throbber = ami_bitmap_get_native(bm, bm->width, bm->height, NULL); @@ -423,16 +424,8 @@ void gui_window_start_throbber(struct gui_window *g) } g->throbbing = true; - - if((cur_tab == g->tab) || (g->shared->tabs <= 1)) - { - GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], - (ULONG *)&bbox); - - if(g->shared->throbber_frame == 0) g->shared->throbber_frame=1; - - BltBitMapRastPort(throbber,throbber_width,0,g->shared->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0); - } + if(g->shared->throbber_frame == 0) g->shared->throbber_frame = 1; + ami_throbber_redraw_schedule(throbber_update_interval, g); } void gui_window_stop_throbber(struct gui_window *g) @@ -452,8 +445,6 @@ void gui_window_stop_throbber(struct gui_window *g) g->shared->win, NULL); } - g->throbbing = false; - if((cur_tab == g->tab) || (g->shared->tabs <= 1)) { GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], @@ -462,60 +453,58 @@ void gui_window_stop_throbber(struct gui_window *g) BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, bbox->Left, bbox->Top, throbber_width, throbber_height, 0x0C0); } -// g->shared->throbber_frame = 0; + + g->throbbing = false; + ami_throbber_redraw_schedule(-1, g); } -void ami_update_throbber(struct gui_window_2 *g, bool redraw) +static void ami_throbber_update(void *p) { + struct gui_window *g = (struct gui_window *)p; struct IBox *bbox; - int frame; + int frame = 0; + ULONG cur_tab = 0; if(!g) return; - if(!g->objects[GID_THROBBER]) return; + if(!g->shared->objects[GID_THROBBER]) return; - if(g->bw->window->throbbing == false) - { - frame = 0; - g->throbber_frame = 1; + if(g->throbbing == true) { + frame = g->shared->throbber_frame; + g->shared->throbber_frame++; + if(g->shared->throbber_frame > (throbber_frames-1)) + g->shared->throbber_frame=1; } - else - { - frame = g->throbber_frame; - if(!redraw) - { - if(g->throbber_update_count < throbber_update_interval) - { - g->throbber_update_count++; - return; - } - - g->throbber_update_count = 0; + if(g->tab_node && (g->shared->tabs > 1)) + { + GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS], + (ULONG *)&cur_tab); + } - g->throbber_frame++; - if(g->throbber_frame > (throbber_frames-1)) - g->throbber_frame=1; + if((cur_tab == g->tab) || (g->shared->tabs <= 1)) + { + GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], + (ULONG *)&bbox); - } + BltBitMapTags(BLITA_SrcX, throbber_width * frame, + BLITA_SrcY, 0, + BLITA_DestX, bbox->Left, + BLITA_DestY, bbox->Top, + BLITA_Width, throbber_width, + BLITA_Height, throbber_height, + BLITA_Source, throbber, + BLITA_Dest, g->shared->win->RPort, + BLITA_SrcType, BLITT_BITMAP, + BLITA_DestType, BLITT_RASTPORT, + // BLITA_UseSrcAlpha, TRUE, + TAG_DONE); } - GetAttr(SPACE_AreaBox,(Object *)g->objects[GID_THROBBER],(ULONG *)&bbox); + if(frame > 0) ami_throbber_redraw_schedule(throbber_update_interval, g); +} -/* - EraseRect(g->win->RPort,bbox->Left,bbox->Top, - bbox->Left+throbber_width,bbox->Top+throbber_height); -*/ - - BltBitMapTags(BLITA_SrcX, throbber_width * frame, - BLITA_SrcY,0, - BLITA_DestX,bbox->Left, - BLITA_DestY,bbox->Top, - BLITA_Width,throbber_width, - BLITA_Height,throbber_height, - BLITA_Source,throbber, - BLITA_Dest,g->win->RPort, - BLITA_SrcType,BLITT_BITMAP, - BLITA_DestType,BLITT_RASTPORT, -// BLITA_UseSrcAlpha,TRUE, - TAG_DONE); +void ami_throbber_redraw_schedule(int t, struct gui_window *g) +{ + ami_schedule(t, ami_throbber_update, g); } + diff --git a/amiga/theme.h b/amiga/theme.h index e81db33dd..c1aca15d7 100644 --- a/amiga/theme.h +++ b/amiga/theme.h @@ -44,6 +44,8 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape); void gui_window_start_throbber(struct gui_window *g); void gui_window_stop_throbber(struct gui_window *g); -void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape); +void ami_throbber_redraw_schedule(int t, struct gui_window *g); +void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape); #endif + diff --git a/amiga/tree.c b/amiga/tree.c index 04c799603..18b071de3 100644 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -711,7 +711,7 @@ void ami_tree_close(struct treeview_window *twin) ami_ssl_free(twin); } - ami_gui_hotlist_toolbar_update_all(); + ami_gui_hotlist_update_all(); } void ami_tree_update_quals(struct treeview_window *twin) |