From 5867fa4ef99a9e7ec98fa16058ca92d5684fad0e Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 23 Feb 2015 20:34:24 +0000 Subject: Avoid forward declarations Specify hook function with 68k registers when building for that target --- amiga/Makefile.target | 2 +- amiga/gui.c | 633 +++++++++++++++++++++++++------------------------- 2 files changed, 319 insertions(+), 316 deletions(-) diff --git a/amiga/Makefile.target b/amiga/Makefile.target index 7d858ef8a..32e076ca6 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -7,7 +7,7 @@ CFLAGS += -std=c99 -Dnsamiga ifneq ($(SUBTARGET),os3) CFLAGS += -O2 -finline-functions -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__ else - CFLAGS += -m68020 -O0 -DPATH_MAX=1024 + CFLAGS += -m68020-60 -O0 -DPATH_MAX=1024 endif NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE diff --git a/amiga/gui.c b/amiga/gui.c index 47a43b786..753f6901f 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -197,7 +197,6 @@ static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0"; const char * const versvn; const char * const verdate; -static void ami_scroller_hook(struct Hook *,Object *,struct IntuiMessage *); void ami_switch_tab(struct gui_window_2 *gwin,bool redraw); void ami_change_tab(struct gui_window_2 *gwin, int direction); void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs); @@ -3458,6 +3457,268 @@ nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin) return NSERROR_OK; } +static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy, + int left, int top, int width, int height, + int sx, int sy, struct IBox *bbox, struct redraw_context *ctx) +{ + int x, y; + struct rect clip; + int tile_x_scale = (int)(nsoption_int(redraw_tile_size_x) / gwin->gw->scale); + int tile_y_scale = (int)(nsoption_int(redraw_tile_size_y) / gwin->gw->scale); + + browserglob.shared_pens = &gwin->shared_pens; + + if(top < 0) { + height += top; + top = 0; + } + + if(left < 0) { + width += left; + left = 0; + } + + if(top < sy) { + height += (top - sy); + top = sy; + } + if(left < sx) { + width += (left - sx); + left = sx; + } + + if(((top - sy) + height) > bbox->Height) + height = bbox->Height - (top - sy); + + if(((left - sx) + width) > bbox->Width) + width = bbox->Width - (left - sx); + + if(width <= 0) return; + if(height <= 0) return; + + if(busy) ami_set_pointer(gwin, GUI_POINTER_WAIT, false); + + for(y = top; y < (top + height); y += tile_y_scale) { + clip.y0 = 0; + clip.y1 = nsoption_int(redraw_tile_size_y); + if(clip.y1 > height) clip.y1 = height; + if((((y - sy) * gwin->gw->scale) + clip.y1) > bbox->Height) + clip.y1 = bbox->Height - ((y - sy) * gwin->gw->scale); + + for(x = left; x < (left + width); x += tile_x_scale) { + clip.x0 = 0; + clip.x1 = nsoption_int(redraw_tile_size_x); + if(clip.x1 > width) clip.x1 = width; + if((((x - sx) * gwin->gw->scale) + clip.x1) > bbox->Width) + clip.x1 = bbox->Width - ((x - sx) * gwin->gw->scale); + + if(browser_window_redraw(gwin->gw->bw, + clip.x0 - (int)x, + clip.y0 - (int)y, + &clip, ctx)) + { + ami_clearclipreg(&browserglob); +#ifdef __amigaos4__ + BltBitMapTags(BLITA_SrcType, BLITT_BITMAP, + BLITA_Source, browserglob.bm, + BLITA_SrcX, 0, + BLITA_SrcY, 0, + BLITA_DestType, BLITT_RASTPORT, + BLITA_Dest, gwin->win->RPort, + BLITA_DestX, bbox->Left + (int)((x - sx) * gwin->gw->scale), + BLITA_DestY, bbox->Top + (int)((y - sy) * gwin->gw->scale), + BLITA_Width, (int)(clip.x1), + BLITA_Height, (int)(clip.y1), + TAG_DONE); +#else + BltBitMapRastPort(browserglob.bm, 0, 0, gwin->win->RPort, + bbox->Left + (int)((x - sx) * gwin->gw->scale), + bbox->Top + (int)((y - sy) * gwin->gw->scale), + (int)(clip.x1), (int)(clip.y1), 0xC0); +#endif + } + } + } + + if(busy) ami_reset_pointer(gwin); +} + + +/** + * Redraw an area of the browser window - Amiga-specific function + * + * \param g a struct gui_window + * \param bw a struct browser_window + * \param busy busy flag passed to tiled redraw. + * \param x0 top-left co-ordinate (in document co-ordinates) + * \param y0 top-left co-ordinate (in document co-ordinates) + * \param x1 bottom-right co-ordinate (in document co-ordinates) + * \param y1 bottom-right co-ordinate (in document co-ordinates) + */ + +static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw, bool busy, + int x0, int y0, int x1, int y1) +{ + struct IBox *bbox; + ULONG sx, sy; + + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &amiplot + }; + + if(!g) return; + if(browser_window_redraw_ready(bw) == false) return; + + sx = g->scrollx; + sy = g->scrolly; + + if(g != g->shared->gw) return; + + if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) { + warn_user("NoMemory", ""); + return; + } + + ami_do_redraw_tiled(g->shared, busy, x0, y0, + (x1 - x0) * g->scale, (y1 - y0) * g->scale, sx, sy, bbox, &ctx); + + ami_gui_free_space_box(bbox); + + return; +} + +static void ami_refresh_window(struct gui_window_2 *gwin) +{ + /* simplerefresh only */ + + struct IBox *bbox; + int x0, x1, y0, y1, sx, sy; + struct RegionRectangle *regrect; + + sx = gwin->gw->scrollx; + sy = gwin->gw->scrolly; + + ami_set_pointer(gwin, GUI_POINTER_WAIT, false); + + if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) { + warn_user("NoMemory", ""); + return; + } + + BeginRefresh(gwin->win); + + x0 = ((gwin->win->RPort->Layer->DamageList->bounds.MinX - bbox->Left) / + browser_window_get_scale(gwin->gw->bw)) + sx - 1; + x1 = ((gwin->win->RPort->Layer->DamageList->bounds.MaxX - bbox->Left) / + browser_window_get_scale(gwin->gw->bw)) + sx + 2; + y0 = ((gwin->win->RPort->Layer->DamageList->bounds.MinY - bbox->Top) / + browser_window_get_scale(gwin->gw->bw)) + sy - 1; + y1 = ((gwin->win->RPort->Layer->DamageList->bounds.MaxY - bbox->Top) / + browser_window_get_scale(gwin->gw->bw)) + sy + 2; + + regrect = gwin->win->RPort->Layer->DamageList->RegionRectangle; + + ami_do_redraw_limits(gwin->gw, gwin->gw->bw, false, x0, y0, x1, y1); + + while(regrect) + { + x0 = ((regrect->bounds.MinX - bbox->Left) / + browser_window_get_scale(gwin->gw->bw)) + sx - 1; + x1 = ((regrect->bounds.MaxX - bbox->Left) / + browser_window_get_scale(gwin->gw->bw)) + sx + 2; + y0 = ((regrect->bounds.MinY - bbox->Top) / + browser_window_get_scale(gwin->gw->bw)) + sy - 1; + y1 = ((regrect->bounds.MaxY - bbox->Top) / + browser_window_get_scale(gwin->gw->bw)) + sy + 2; + + regrect = regrect->Next; + + ami_do_redraw_limits(gwin->gw, gwin->gw->bw, false, x0, y0, x1, y1); + } + + EndRefresh(gwin->win, TRUE); + + ami_gui_free_space_box(bbox); + ami_reset_pointer(gwin); +} + +#ifdef __amigaos4__ +static void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg) +#else +static ASM void ami_scroller_hook(REG(a0, struct Hook *hook),REG(a2, Object *object), REG(a1, struct IntuiMessage *msg)) +#endif +{ + ULONG gid; + struct gui_window_2 *gwin = hook->h_Data; + struct IntuiWheelData *wheel; + struct Node *node = NULL; + nsurl *url; + + switch(msg->Class) + { + case IDCMP_IDCMPUPDATE: + gid = GetTagData( GA_ID, 0, msg->IAddress ); + + switch( gid ) + { + case GID_HSCROLL: + case GID_VSCROLL: + if(nsoption_bool(faster_scroll) == true) gwin->redraw_scroll = true; + else gwin->redraw_scroll = false; + + ami_schedule_redraw(gwin, true); + break; + + case GID_HOTLIST: + if((node = (struct Node *)GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress))) { + GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE); + + if(gwin->key_state & BROWSER_MOUSE_MOD_2) { + browser_window_create(BW_CREATE_TAB, + url, + NULL, + gwin->gw->bw, + NULL); + } else { + browser_window_navigate(gwin->gw->bw, + url, + NULL, + BW_NAVIGATE_HISTORY, + NULL, + NULL, + NULL); + + } + } + break; + } + break; +#ifdef __amigaos4__ + case IDCMP_EXTENDEDMOUSE: + if(msg->Code == IMSGCODE_INTUIWHEELDATA) + { + wheel = (struct IntuiWheelData *)msg->IAddress; + + ami_gui_scroll_internal(gwin, wheel->WheelX * 50, wheel->WheelY * 50); + } + break; +#endif + case IDCMP_SIZEVERIFY: + break; + + case IDCMP_REFRESHWINDOW: + ami_refresh_window(gwin); + break; + + default: + LOG(("IDCMP hook unhandled event: %d\n", msg->Class)); + break; + } +// ReplyMsg((struct Message *)msg); +} + static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, @@ -4257,210 +4518,78 @@ static void gui_window_set_title(struct gui_window *g, const char *title) { node = g->tab_node; - if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle))) - { - SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], - g->shared->win, NULL, - CLICKTAB_Labels, ~0, - TAG_DONE); - - if(g->tabtitle) ami_utf8_free(g->tabtitle); - g->tabtitle = strdup(utf8title); - - SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle, - TNA_HintInfo, g->tabtitle, - TAG_DONE); - - RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], - g->shared->win, NULL, - CLICKTAB_Labels, &g->shared->tab_list, - TAG_DONE); - - if(ClickTabBase->lib_Version < 53) - RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT], - g->shared->win, NULL, TRUE); - } - } - - if(g == g->shared->gw) { - if((g->shared->wintitle == NULL) || (strcmp(utf8title, g->shared->wintitle))) - { - if(g->shared->wintitle) free(g->shared->wintitle); - g->shared->wintitle = strdup(utf8title); - SetWindowTitles(g->shared->win, g->shared->wintitle, ami_gui_get_screen_title()); - } - } - - ami_utf8_free(utf8title); -} - -static void ami_redraw_callback(void *p) -{ - struct gui_window_2 *gwin = (struct gui_window_2 *)p; - - if(gwin->redraw_required) { - ami_do_redraw(gwin); - } - - ami_gui_window_update_box_deferred(gwin->gw, true); - - if(gwin->gw->c_h) - { - gui_window_place_caret(gwin->gw, gwin->gw->c_x, - gwin->gw->c_y, gwin->gw->c_h, NULL); - } -} - -/** - * Schedule a redraw of the browser window - Amiga-specific function - * - * \param gwin a struct gui_window_2 - * \param full_redraw set to true to schedule a full redraw, - should only be set to false when called from gui_window_update_box() - */ -void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw) -{ - int ms = 1; - - if(full_redraw) gwin->redraw_required = true; - ami_schedule(ms, ami_redraw_callback, gwin); -} - -static void ami_schedule_redraw_remove(struct gui_window_2 *gwin) -{ - ami_schedule(-1, ami_redraw_callback, gwin); -} - -static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy, - int left, int top, int width, int height, - int sx, int sy, struct IBox *bbox, struct redraw_context *ctx) -{ - int x, y; - struct rect clip; - int tile_x_scale = (int)(nsoption_int(redraw_tile_size_x) / gwin->gw->scale); - int tile_y_scale = (int)(nsoption_int(redraw_tile_size_y) / gwin->gw->scale); - - browserglob.shared_pens = &gwin->shared_pens; - - if(top < 0) { - height += top; - top = 0; - } - - if(left < 0) { - width += left; - left = 0; - } - - if(top < sy) { - height += (top - sy); - top = sy; - } - if(left < sx) { - width += (left - sx); - left = sx; - } - - if(((top - sy) + height) > bbox->Height) - height = bbox->Height - (top - sy); - - if(((left - sx) + width) > bbox->Width) - width = bbox->Width - (left - sx); - - if(width <= 0) return; - if(height <= 0) return; - - if(busy) ami_set_pointer(gwin, GUI_POINTER_WAIT, false); + if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle))) + { + SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], + g->shared->win, NULL, + CLICKTAB_Labels, ~0, + TAG_DONE); - for(y = top; y < (top + height); y += tile_y_scale) { - clip.y0 = 0; - clip.y1 = nsoption_int(redraw_tile_size_y); - if(clip.y1 > height) clip.y1 = height; - if((((y - sy) * gwin->gw->scale) + clip.y1) > bbox->Height) - clip.y1 = bbox->Height - ((y - sy) * gwin->gw->scale); + if(g->tabtitle) ami_utf8_free(g->tabtitle); + g->tabtitle = strdup(utf8title); - for(x = left; x < (left + width); x += tile_x_scale) { - clip.x0 = 0; - clip.x1 = nsoption_int(redraw_tile_size_x); - if(clip.x1 > width) clip.x1 = width; - if((((x - sx) * gwin->gw->scale) + clip.x1) > bbox->Width) - clip.x1 = bbox->Width - ((x - sx) * gwin->gw->scale); + SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle, + TNA_HintInfo, g->tabtitle, + TAG_DONE); - if(browser_window_redraw(gwin->gw->bw, - clip.x0 - (int)x, - clip.y0 - (int)y, - &clip, ctx)) - { - ami_clearclipreg(&browserglob); -#ifdef __amigaos4__ - BltBitMapTags(BLITA_SrcType, BLITT_BITMAP, - BLITA_Source, browserglob.bm, - BLITA_SrcX, 0, - BLITA_SrcY, 0, - BLITA_DestType, BLITT_RASTPORT, - BLITA_Dest, gwin->win->RPort, - BLITA_DestX, bbox->Left + (int)((x - sx) * gwin->gw->scale), - BLITA_DestY, bbox->Top + (int)((y - sy) * gwin->gw->scale), - BLITA_Width, (int)(clip.x1), - BLITA_Height, (int)(clip.y1), - TAG_DONE); -#else - BltBitMapRastPort(browserglob.bm, 0, 0, gwin->win->RPort, - bbox->Left + (int)((x - sx) * gwin->gw->scale), - bbox->Top + (int)((y - sy) * gwin->gw->scale), - (int)(clip.x1), (int)(clip.y1), 0xC0); -#endif - } + RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], + g->shared->win, NULL, + CLICKTAB_Labels, &g->shared->tab_list, + TAG_DONE); + + if(ClickTabBase->lib_Version < 53) + RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT], + g->shared->win, NULL, TRUE); } } - - if(busy) ami_reset_pointer(gwin); -} + if(g == g->shared->gw) { + if((g->shared->wintitle == NULL) || (strcmp(utf8title, g->shared->wintitle))) + { + if(g->shared->wintitle) free(g->shared->wintitle); + g->shared->wintitle = strdup(utf8title); + SetWindowTitles(g->shared->win, g->shared->wintitle, ami_gui_get_screen_title()); + } + } -/** - * Redraw an area of the browser window - Amiga-specific function - * - * \param g a struct gui_window - * \param bw a struct browser_window - * \param busy busy flag passed to tiled redraw. - * \param x0 top-left co-ordinate (in document co-ordinates) - * \param y0 top-left co-ordinate (in document co-ordinates) - * \param x1 bottom-right co-ordinate (in document co-ordinates) - * \param y1 bottom-right co-ordinate (in document co-ordinates) - */ + ami_utf8_free(utf8title); +} -static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw, bool busy, - int x0, int y0, int x1, int y1) +static void ami_redraw_callback(void *p) { - struct IBox *bbox; - ULONG sx, sy; - - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &amiplot - }; - - if(!g) return; - if(browser_window_redraw_ready(bw) == false) return; + struct gui_window_2 *gwin = (struct gui_window_2 *)p; - sx = g->scrollx; - sy = g->scrolly; + if(gwin->redraw_required) { + ami_do_redraw(gwin); + } - if(g != g->shared->gw) return; + ami_gui_window_update_box_deferred(gwin->gw, true); - if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) { - warn_user("NoMemory", ""); - return; + if(gwin->gw->c_h) + { + gui_window_place_caret(gwin->gw, gwin->gw->c_x, + gwin->gw->c_y, gwin->gw->c_h, NULL); } +} - ami_do_redraw_tiled(g->shared, busy, x0, y0, - (x1 - x0) * g->scale, (y1 - y0) * g->scale, sx, sy, bbox, &ctx); +/** + * Schedule a redraw of the browser window - Amiga-specific function + * + * \param gwin a struct gui_window_2 + * \param full_redraw set to true to schedule a full redraw, + should only be set to false when called from gui_window_update_box() + */ +void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw) +{ + int ms = 1; - ami_gui_free_space_box(bbox); + if(full_redraw) gwin->redraw_required = true; + ami_schedule(ms, ami_redraw_callback, gwin); +} - return; +static void ami_schedule_redraw_remove(struct gui_window_2 *gwin) +{ + ami_schedule(-1, ami_redraw_callback, gwin); } static void gui_window_redraw_window(struct gui_window *g) @@ -4694,61 +4823,6 @@ static void ami_do_redraw(struct gui_window_2 *gwin) ami_gui_free_space_box(bbox); } -static void ami_refresh_window(struct gui_window_2 *gwin) -{ - /* simplerefresh only */ - - struct IBox *bbox; - int x0, x1, y0, y1, sx, sy; - struct RegionRectangle *regrect; - - sx = gwin->gw->scrollx; - sy = gwin->gw->scrolly; - - ami_set_pointer(gwin, GUI_POINTER_WAIT, false); - - if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) { - warn_user("NoMemory", ""); - return; - } - - BeginRefresh(gwin->win); - - x0 = ((gwin->win->RPort->Layer->DamageList->bounds.MinX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx - 1; - x1 = ((gwin->win->RPort->Layer->DamageList->bounds.MaxX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx + 2; - y0 = ((gwin->win->RPort->Layer->DamageList->bounds.MinY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy - 1; - y1 = ((gwin->win->RPort->Layer->DamageList->bounds.MaxY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy + 2; - - regrect = gwin->win->RPort->Layer->DamageList->RegionRectangle; - - ami_do_redraw_limits(gwin->gw, gwin->gw->bw, false, x0, y0, x1, y1); - - while(regrect) - { - x0 = ((regrect->bounds.MinX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx - 1; - x1 = ((regrect->bounds.MaxX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx + 2; - y0 = ((regrect->bounds.MinY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy - 1; - y1 = ((regrect->bounds.MaxY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy + 2; - - regrect = regrect->Next; - - ami_do_redraw_limits(gwin->gw, gwin->gw->bw, false, x0, y0, x1, y1); - } - - EndRefresh(gwin->win, TRUE); - - ami_gui_free_space_box(bbox); - ami_reset_pointer(gwin); -} - void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs) { if(gwin->objects[GID_HSCROLL]) @@ -5101,77 +5175,6 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, return true; } -static void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg) -{ - ULONG gid; - struct gui_window_2 *gwin = hook->h_Data; - struct IntuiWheelData *wheel; - struct Node *node = NULL; - nsurl *url; - - switch(msg->Class) - { - case IDCMP_IDCMPUPDATE: - gid = GetTagData( GA_ID, 0, msg->IAddress ); - - switch( gid ) - { - case GID_HSCROLL: - case GID_VSCROLL: - if(nsoption_bool(faster_scroll) == true) gwin->redraw_scroll = true; - else gwin->redraw_scroll = false; - - ami_schedule_redraw(gwin, true); - break; - - case GID_HOTLIST: - if((node = (struct Node *)GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress))) { - GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE); - - if(gwin->key_state & BROWSER_MOUSE_MOD_2) { - browser_window_create(BW_CREATE_TAB, - url, - NULL, - gwin->gw->bw, - NULL); - } else { - browser_window_navigate(gwin->gw->bw, - url, - NULL, - BW_NAVIGATE_HISTORY, - NULL, - NULL, - NULL); - - } - } - break; - } - break; -#ifdef __amigaos4__ - case IDCMP_EXTENDEDMOUSE: - if(msg->Code == IMSGCODE_INTUIWHEELDATA) - { - wheel = (struct IntuiWheelData *)msg->IAddress; - - ami_gui_scroll_internal(gwin, wheel->WheelX * 50, wheel->WheelY * 50); - } - break; -#endif - case IDCMP_SIZEVERIFY: - break; - - case IDCMP_REFRESHWINDOW: - ami_refresh_window(gwin); - break; - - default: - LOG(("IDCMP hook unhandled event: %d\n", msg->Class)); - break; - } -// ReplyMsg((struct Message *)msg); -} - /* return the text box at posn x,y in window coordinates x,y are updated to be document co-ordinates */ -- cgit v1.2.3