From 56a5ad11f3e98ef50a8de243dc509c3a0c603e32 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 17 Oct 2014 23:18:58 +0100 Subject: remove unecessary include of browser.h in amiga frontend --- amiga/clipboard.c | 2 +- amiga/gui.c | 25 ++-- amiga/gui.h | 2 +- amiga/tree.c | 396 +++++++++++++++++++++++++++--------------------------- 4 files changed, 213 insertions(+), 212 deletions(-) (limited to 'amiga') diff --git a/amiga/clipboard.c b/amiga/clipboard.c index 8631bc498..031bf0b46 100644 --- a/amiga/clipboard.c +++ b/amiga/clipboard.c @@ -28,9 +28,9 @@ #include "utils/nsoption.h" #include "utils/utf8.h" +#include "desktop/browser.h" #include "desktop/plotters.h" #include "desktop/textinput.h" -#include "desktop/mouse.h" #include "desktop/gui_window.h" #include "desktop/gui_clipboard.h" diff --git a/amiga/gui.c b/amiga/gui.c index 6df5def83..3413dab28 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -201,7 +201,6 @@ void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs); void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys); static void ami_set_border_gadget_balance(struct gui_window_2 *gwin); static ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2); -void ami_try_quit(void); void ami_quit_netsurf_delayed(void); Object *ami_gui_splash_open(void); void ami_gui_splash_close(Object *win_obj); @@ -236,7 +235,7 @@ STRPTR ami_locale_langs(void) STRPTR acceptlangs = NULL; char *remapped; - if(locale = OpenLocale(NULL)) + if((locale = OpenLocale(NULL))) { for(int i = 0; i < 10; i++) { @@ -281,7 +280,8 @@ bool ami_gui_map_filename(char **remapped, const char *path, const char *file, c if(mapfile == NULL) return false; - if(fh = FOpen(mapfile, MODE_OLDFILE, 0)) + fh = FOpen(mapfile, MODE_OLDFILE, 0); + if(fh) { while(FGets(fh, buffer, 1024) != 0) { @@ -289,7 +289,8 @@ bool ami_gui_map_filename(char **remapped, const char *path, const char *file, c (buffer[0] == '\n') || (buffer[0] == '\0')) continue; - if(realfname = strchr(buffer, ':')) + realfname = strchr(buffer, ':'); + if(realfname) { if(strncmp(buffer, file, strlen(file)) == 0) { @@ -324,7 +325,8 @@ static bool ami_gui_check_resource(char *fullpath, const char *file) LOG(("Checking for %s", fullpath)); - if(lock = Lock(fullpath, ACCESS_READ)) + lock = Lock(fullpath, ACCESS_READ); + if(lock) { UnLock(lock); found = true; @@ -340,7 +342,6 @@ bool ami_locate_resource(char *fullpath, const char *file) { struct Locale *locale; int i; - BPTR lock = 0; bool found = false; char *remapped; size_t fullpath_len = 1024; @@ -4499,6 +4500,8 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) { ami_get_hscroll_pos(g->shared, (ULONG *)sx); ami_get_vscroll_pos(g->shared, (ULONG *)sy); + + return true; } static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) @@ -4580,17 +4583,12 @@ static void gui_window_get_dimensions(struct gui_window *g, int *width, int *hei static void gui_window_update_extent(struct gui_window *g) { - struct IBox *bbox, zbox; + struct IBox *bbox; ULONG cur_tab = 0; if(!g) return; if(!g->shared->bw->current_content) return; - /* - zbox.Top = ~0; - zbox.Left = ~0; - zbox.Width = (WORD)(content_get_width(g->shared->bw->current_content) * g->shared->bw->scale); - zbox.Height = (WORD)(content_get_height(g->shared->bw->current_content) * g->shared->bw->scale); - */ + if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS], (ULONG *)&cur_tab); @@ -4620,7 +4618,6 @@ static void gui_window_update_extent(struct gui_window *g) SCROLLER_Visible, bbox->Width, TAG_DONE); } - //SetWindowAttr(g->shared->win, WA_Zoom, &zbox, sizeof(ULONG)); } g->shared->new_content = true; } diff --git a/amiga/gui.h b/amiga/gui.h index 057124c3d..830ac95dd 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -18,10 +18,10 @@ #ifndef AMIGA_GUI_H #define AMIGA_GUI_H + #include #include "amiga/object.h" #include -#include "desktop/browser.h" #include #include #include "amiga/os3support.h" diff --git a/amiga/tree.c b/amiga/tree.c index ce922f83e..c8e6806d4 100644 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -52,10 +52,10 @@ #include "utils/messages.h" #include "content/urldb.h" #include "content/llcache.h" +#include "desktop/browser.h" #include "desktop/cookie_manager.h" #include "desktop/global_history.h" #include "desktop/hotlist.h" -#include "desktop/mouse.h" #include "desktop/gui_window.h" #include "desktop/sslcert_viewer.h" @@ -115,42 +115,13 @@ struct ami_tree_redraw_req { struct treeview_window *twin; }; +#if 0 void ami_tree_draw(struct treeview_window *twin); -static void ami_tree_redraw_request(int x, int y, int width, int height, - void *data); static void ami_tree_resized(struct tree *tree, int width, int height, void *data); static void ami_tree_scroll_visible(int y, int height, void *data); static void ami_tree_get_window_dimensions(int *width, int *height, void *data); - -const struct treeview_table ami_tree_callbacks = { - .redraw_request = ami_tree_redraw_request, - .resized = ami_tree_resized, - .scroll_visible = ami_tree_scroll_visible, - .get_window_dimensions = ami_tree_get_window_dimensions -}; - -struct treeview_window *ami_tree_create(int flags, - struct sslcert_session_data *ssl_data) -{ - struct treeview_window *twin; - - twin = AllocVecTags(sizeof(struct treeview_window), AVT_ClearWithValue, 0, TAG_DONE); - - if(!twin) - { - warn_user("NoMemory", 0); - return NULL; - } - - twin->ssl_data = ssl_data; - twin->tree = tree_create(flags, &ami_tree_callbacks, twin); - - NewMinList(&twin->shared_pens); - twin->globals.shared_pens = &twin->shared_pens; - - return twin; -} +#endif void ami_tree_destroy(struct treeview_window *twin) { @@ -163,7 +134,7 @@ struct tree *ami_tree_get_tree(struct treeview_window *twin) return twin->tree; } -void ami_tree_resized(struct tree *tree, int width, int height, void *data) +static void ami_tree_resized(struct tree *tree, int width, int height, void *data) { struct treeview_window *twin = data; struct IBox *bbox; @@ -206,7 +177,7 @@ void ami_tree_resized(struct tree *tree, int width, int height, void *data) * \param width will be updated to window width if not NULL * \param height will be updated to window height if not NULL */ -void ami_tree_get_window_dimensions(int *width, int *height, void *data) +static void ami_tree_get_window_dimensions(int *width, int *height, void *data) { struct treeview_window *twin = data; struct IBox *bbox; @@ -217,6 +188,168 @@ void ami_tree_get_window_dimensions(int *width, int *height, void *data) if(height) *height = bbox->Height; } +static void ami_tree_redraw_req_dr(void *p) +{ + struct ami_tree_redraw_req *atrr_data = (struct ami_tree_redraw_req *)p; + int x = atrr_data->x; + int y = atrr_data->y; + int width = atrr_data->width; + int height = atrr_data->height; + struct treeview_window *twin = atrr_data->twin; + struct IBox *bbox; + int pos_x, pos_y; + struct RastPort *temprp; + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &amiplot + }; + + if(!twin->win) return; + + ami_update_pointer(twin->win, GUI_POINTER_WAIT); + + glob = &twin->globals; + temprp = glob->rp; + glob->rp = twin->win->RPort; + + GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER], (ULONG *)&bbox); + GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&pos_x); + GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&pos_y); + + x += bbox->Left; + y += bbox->Top; + + if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x); + if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y); + + if(x < pos_x) { + width -= pos_x - x; + x = pos_x; + } + + if(y < pos_y) { + height -= pos_y - y; + y = pos_y; + } + + tree_draw(twin->tree, bbox->Left - pos_x, bbox->Top - pos_y, + atrr_data->x, atrr_data->y, + atrr_data->width, atrr_data->height, &ctx); + + FreeVec(atrr_data); + ami_update_pointer(twin->win, GUI_POINTER_DEFAULT); + ami_clearclipreg(glob); + glob->rp = temprp; + glob = &browserglob; +} + +static void ami_tree_redraw_req(void *p) +{ + struct ami_tree_redraw_req *atrr_data = (struct ami_tree_redraw_req *)p; + int x = atrr_data->x; + int y = atrr_data->y; + int width = atrr_data->width; + int height = atrr_data->height; + struct treeview_window *twin = atrr_data->twin; + struct IBox *bbox; + int pos_x, pos_y; + int tile_x, tile_y, tile_w, tile_h; + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &amiplot + }; + + if(!twin->win) return; + + ami_update_pointer(twin->win, GUI_POINTER_WAIT); + + glob = &twin->globals; + + GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER],(ULONG *)&bbox); + GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&pos_x); + GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&pos_y); + + if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x); + if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y); + + if(x < pos_x) { + width -= pos_x - x; + x = pos_x; + } + + if(y < pos_y) { + height -= pos_y - y; + y = pos_y; + } + + for(tile_y = y; tile_y < (y + height); tile_y += nsoption_int(redraw_tile_size_y)) { + tile_h = nsoption_int(redraw_tile_size_y); + if(((y + height) - tile_y) < nsoption_int(redraw_tile_size_y)) + tile_h = (y + height) - tile_y; + + for(tile_x = x; tile_x < (x + width); tile_x += nsoption_int(redraw_tile_size_x)) { + tile_w = nsoption_int(redraw_tile_size_x); + if(((x + width) - tile_x) < nsoption_int(redraw_tile_size_x)) + tile_w = (x + width) - tile_x; + + tree_draw(twin->tree, - tile_x, - tile_y, + tile_x, tile_y, tile_w, tile_h, &ctx); + + BltBitMapTags(BLITA_SrcType, BLITT_BITMAP, + BLITA_Source, twin->globals.bm, + BLITA_SrcX, 0, + BLITA_SrcY, 0, + BLITA_DestType, BLITT_RASTPORT, + BLITA_Dest, twin->win->RPort, + BLITA_DestX, bbox->Left + tile_x - pos_x, + BLITA_DestY, bbox->Top + tile_y - pos_y, + BLITA_Width, tile_w, + BLITA_Height, tile_h, + TAG_DONE); + } + } + + FreeVec(atrr_data); + ami_update_pointer(twin->win, GUI_POINTER_DEFAULT); + ami_clearclipreg(glob); + glob = &browserglob; +} + +static void ami_tree_redraw_request(int x, int y, int width, int height, void *data) +{ + struct ami_tree_redraw_req *atrr_data = AllocVecTagList(sizeof(struct ami_tree_redraw_req), NULL); + + atrr_data->x = x; + atrr_data->y = y; + atrr_data->width = width; + atrr_data->height = height; + atrr_data->twin = (struct treeview_window *)data; + + /** /todo Queue these requests properly like the main browser code does + **/ + + if(nsoption_bool(direct_render) == false) + ami_schedule(0, ami_tree_redraw_req, atrr_data); + else + ami_schedule(0, ami_tree_redraw_req_dr, atrr_data); +} + +static void ami_tree_draw(struct treeview_window *twin) +{ + struct IBox *bbox; + int x, y; + + if(!twin) return; + + GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&x); + GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&y); + GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER],(ULONG *)&bbox); + + ami_tree_redraw_request(x, y, bbox->Width, bbox->Height, twin); +} + /** * Scrolls the tree to make an element visible * @@ -224,7 +357,7 @@ void ami_tree_get_window_dimensions(int *width, int *height, void *data) * \param height height of the element * \param data user data assigned to the tree on tree creation */ -void ami_tree_scroll_visible(int y, int height, void *data) +static void ami_tree_scroll_visible(int y, int height, void *data) { ULONG sy, scrollset; struct IBox *bbox; @@ -245,7 +378,7 @@ void ami_tree_scroll_visible(int y, int height, void *data) ami_tree_draw(twin); } -void ami_tree_scroll(struct treeview_window *twin, int sx, int sy) +static void ami_tree_scroll(struct treeview_window *twin, int sx, int sy) { int x, y; @@ -271,7 +404,7 @@ void ami_tree_scroll(struct treeview_window *twin, int sx, int sy) ami_tree_draw(twin); } -void ami_tree_drag_icon_show(struct treeview_window *twin) +static void ami_tree_drag_icon_show(struct treeview_window *twin) { const char *type = "project"; nsurl *url = NULL; @@ -300,7 +433,7 @@ void ami_tree_drag_icon_show(struct treeview_window *twin) } } -void ami_tree_drag_end(struct treeview_window *twin, int x, int y) +static void ami_tree_drag_end(struct treeview_window *twin, int x, int y) { struct gui_window_2 *gwin; struct treeview_window *tw; @@ -309,7 +442,7 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y) const char *title = NULL; bool ok = false; - if(drag = ami_drag_in_progress()) ami_drag_icon_close(twin->win); + if((drag = ami_drag_in_progress())) ami_drag_icon_close(twin->win); if(drag && (twin != ami_window_at_pointer(AMINS_TVWINDOW))) { @@ -322,7 +455,7 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y) if((ok == false) || (url == NULL)) { DisplayBeep(scrn); } else if(url) { - if(gwin = ami_window_at_pointer(AMINS_WINDOW)) { + if((gwin = ami_window_at_pointer(AMINS_WINDOW))) { browser_window_navigate(gwin->bw, url, NULL, @@ -349,9 +482,9 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y) } } -void ami_tree_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg) +static void ami_tree_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg) { - ULONG gid,x,y; + ULONG gid; struct treeview_window *twin = hook->h_Data; struct IntuiWheelData *wheel; @@ -380,12 +513,12 @@ void ami_tree_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage } } -void ami_tree_menu(struct treeview_window *twin) +static void ami_tree_menu(struct treeview_window *twin) { if(twin->menu) return; - if(twin->menu = AllocVecTags(sizeof(struct NewMenu) * AMI_TREE_MENU_ITEMS, - AVT_ClearWithValue, 0, TAG_DONE)) + if((twin->menu = AllocVecTags(sizeof(struct NewMenu) * AMI_TREE_MENU_ITEMS, + AVT_ClearWithValue, 0, TAG_DONE))) { twin->menu[0].nm_Type = NM_TITLE; twin->menu_name[0] = ami_utf8_easy((char *)messages_get("Tree")); @@ -493,7 +626,7 @@ void ami_tree_menu(struct treeview_window *twin) } } -void ami_tree_update_buttons(struct treeview_window *twin) +static void ami_tree_update_buttons(struct treeview_window *twin) { if(twin->type == AMI_TREE_SSLCERT) return; @@ -717,7 +850,7 @@ void ami_tree_close(struct treeview_window *twin) ami_gui_hotlist_update_all(); } -void ami_tree_update_quals(struct treeview_window *twin) +static void ami_tree_update_quals(struct treeview_window *twin) { uint32 quals = 0; @@ -744,7 +877,7 @@ void ami_tree_update_quals(struct treeview_window *twin) BOOL ami_tree_event(struct treeview_window *twin) { /* return TRUE if window destroyed */ - ULONG class,result,storage = 0; + ULONG result,storage = 0; uint16 code; struct MenuItem *item; ULONG menunum=0,itemnum=0,subnum=0; @@ -1243,164 +1376,35 @@ BOOL ami_tree_event(struct treeview_window *twin) return FALSE; } -void ami_tree_draw(struct treeview_window *twin) -{ - struct IBox *bbox; - int x, y; - if(!twin) return; - GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&x); - GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&y); - GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER],(ULONG *)&bbox); - ami_tree_redraw_request(x, y, bbox->Width, bbox->Height, twin); -} -static void ami_tree_redraw_req_dr(void *p) -{ - struct ami_tree_redraw_req *atrr_data = (struct ami_tree_redraw_req *)p; - int x = atrr_data->x; - int y = atrr_data->y; - int width = atrr_data->width; - int height = atrr_data->height; - struct treeview_window *twin = atrr_data->twin; - struct IBox *bbox; - int pos_x, pos_y; - struct RastPort *temprp; - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &amiplot - }; - - if(!twin->win) return; - - ami_update_pointer(twin->win, GUI_POINTER_WAIT); - - glob = &twin->globals; - temprp = glob->rp; - glob->rp = twin->win->RPort; - - GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER], (ULONG *)&bbox); - GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&pos_x); - GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&pos_y); - - x += bbox->Left; - y += bbox->Top; - - if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x); - if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y); - - if(x < pos_x) { - width -= pos_x - x; - x = pos_x; - } - - if(y < pos_y) { - height -= pos_y - y; - y = pos_y; - } - - tree_draw(twin->tree, bbox->Left - pos_x, bbox->Top - pos_y, - atrr_data->x, atrr_data->y, - atrr_data->width, atrr_data->height, &ctx); - - FreeVec(atrr_data); - ami_update_pointer(twin->win, GUI_POINTER_DEFAULT); - ami_clearclipreg(glob); - glob->rp = temprp; - glob = &browserglob; -} +const struct treeview_table ami_tree_callbacks = { + .redraw_request = ami_tree_redraw_request, + .resized = ami_tree_resized, + .scroll_visible = ami_tree_scroll_visible, + .get_window_dimensions = ami_tree_get_window_dimensions +}; -static void ami_tree_redraw_req(void *p) +struct treeview_window *ami_tree_create(int flags, + struct sslcert_session_data *ssl_data) { - struct ami_tree_redraw_req *atrr_data = (struct ami_tree_redraw_req *)p; - int x = atrr_data->x; - int y = atrr_data->y; - int width = atrr_data->width; - int height = atrr_data->height; - struct treeview_window *twin = atrr_data->twin; - struct IBox *bbox; - int pos_x, pos_y; - int tile_x, tile_y, tile_w, tile_h; - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &amiplot - }; - - if(!twin->win) return; - - ami_update_pointer(twin->win, GUI_POINTER_WAIT); - - glob = &twin->globals; - - GetAttr(SPACE_AreaBox,twin->objects[GID_BROWSER],(ULONG *)&bbox); - GetAttr(SCROLLER_Top, twin->objects[OID_HSCROLL], (ULONG *)&pos_x); - GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&pos_y); - - if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x); - if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y); - - if(x < pos_x) { - width -= pos_x - x; - x = pos_x; - } - - if(y < pos_y) { - height -= pos_y - y; - y = pos_y; - } - - for(tile_y = y; tile_y < (y + height); tile_y += nsoption_int(redraw_tile_size_y)) { - tile_h = nsoption_int(redraw_tile_size_y); - if(((y + height) - tile_y) < nsoption_int(redraw_tile_size_y)) - tile_h = (y + height) - tile_y; - - for(tile_x = x; tile_x < (x + width); tile_x += nsoption_int(redraw_tile_size_x)) { - tile_w = nsoption_int(redraw_tile_size_x); - if(((x + width) - tile_x) < nsoption_int(redraw_tile_size_x)) - tile_w = (x + width) - tile_x; + struct treeview_window *twin; - tree_draw(twin->tree, - tile_x, - tile_y, - tile_x, tile_y, tile_w, tile_h, &ctx); + twin = AllocVecTags(sizeof(struct treeview_window), AVT_ClearWithValue, 0, TAG_DONE); - BltBitMapTags(BLITA_SrcType, BLITT_BITMAP, - BLITA_Source, twin->globals.bm, - BLITA_SrcX, 0, - BLITA_SrcY, 0, - BLITA_DestType, BLITT_RASTPORT, - BLITA_Dest, twin->win->RPort, - BLITA_DestX, bbox->Left + tile_x - pos_x, - BLITA_DestY, bbox->Top + tile_y - pos_y, - BLITA_Width, tile_w, - BLITA_Height, tile_h, - TAG_DONE); - } + if(!twin) + { + warn_user("NoMemory", 0); + return NULL; } - FreeVec(atrr_data); - ami_update_pointer(twin->win, GUI_POINTER_DEFAULT); - ami_clearclipreg(glob); - glob = &browserglob; -} + twin->ssl_data = ssl_data; + twin->tree = tree_create(flags, &ami_tree_callbacks, twin); -void ami_tree_redraw_request(int x, int y, int width, int height, void *data) -{ - struct ami_tree_redraw_req *atrr_data = AllocVecTagList(sizeof(struct ami_tree_redraw_req), NULL); - - atrr_data->x = x; - atrr_data->y = y; - atrr_data->width = width; - atrr_data->height = height; - atrr_data->twin = (struct treeview_window *)data; + NewMinList(&twin->shared_pens); + twin->globals.shared_pens = &twin->shared_pens; - /** /todo Queue these requests properly like the main browser code does - **/ - - if(nsoption_bool(direct_render) == false) - ami_schedule(0, ami_tree_redraw_req, atrr_data); - else - ami_schedule(0, ami_tree_redraw_req_dr, atrr_data); + return twin; } -- cgit v1.2.3