summaryrefslogtreecommitdiff
path: root/frontends/amiga/gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/amiga/gui.c')
-rw-r--r--frontends/amiga/gui.c403
1 files changed, 218 insertions, 185 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index b2a489e72..e337ede0c 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -17,10 +17,11 @@
*/
-
+#ifdef __amigaos4__
/* Custom StringView class */
#include "amiga/stringview/stringview.h"
#include "amiga/stringview/urlhistory.h"
+#endif
/* AmigaOS libraries */
#ifdef __amigaos4__
@@ -89,6 +90,7 @@
#include <math.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
/* NetSurf core includes */
#include "utils/log.h"
@@ -114,7 +116,6 @@
#include "desktop/hotlist.h"
#include "desktop/version.h"
#include "desktop/save_complete.h"
-#include "desktop/scrollbar.h"
#include "desktop/searchweb.h"
/* NetSurf Amiga platform includes */
@@ -157,6 +158,11 @@
#define NSA_KBD_SCROLL_PX 10
#define NSA_MAX_HOTLIST_BUTTON_LEN 20
+#define SCROLL_TOP INT_MIN
+#define SCROLL_PAGE_UP (INT_MIN + 1)
+#define SCROLL_PAGE_DOWN (INT_MAX - 1)
+#define SCROLL_BOTTOM (INT_MAX)
+
/* Extra mouse button defines to match those in intuition/intuition.h */
#define SIDEDOWN (IECODE_4TH_BUTTON)
#define SIDEUP (IECODE_4TH_BUTTON | IECODE_UP_PREFIX)
@@ -196,13 +202,15 @@ static bool ami_quit = false;
static struct MsgPort *schedulermsgport = NULL;
static struct MsgPort *appport;
+#ifdef __amigaos4__
static Class *urlStringClass;
+#endif
static BOOL locked_screen = FALSE;
static int screen_signal = -1;
static bool win_destroyed;
static STRPTR nsscreentitle;
-static struct gui_globals browserglob;
+static struct gui_globals *browserglob = NULL;
static struct MsgPort *applibport = NULL;
static uint32 ami_appid = 0;
@@ -239,10 +247,10 @@ static void ami_do_redraw(struct gui_window_2 *g);
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin);
static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy);
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
+static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect);
static void gui_window_remove_caret(struct gui_window *g);
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip);
-static void gui_window_update_box(struct gui_window *g, const struct rect *restrict rect);
+//static void amiga_window_invalidate_area(struct gui_window *g, const struct rect *restrict rect);
/* accessors for default options - user option is updated if it is set as per default */
@@ -334,7 +342,9 @@ bool ami_gui_map_filename(char **remapped, const char *restrict path,
}
if(found == false) *remapped = strdup(file);
- else LOG("Remapped %s to %s in path %s using %s", file, *remapped, path, map);
+ else NSLOG(netsurf, INFO,
+ "Remapped %s to %s in path %s using %s", file,
+ *remapped, path, map);
free(mapfile);
@@ -357,7 +367,7 @@ static bool ami_gui_check_resource(char *fullpath, const char *file)
found = true;
}
- if(found) LOG("Found %s", fullpath);
+ if(found) NSLOG(netsurf, INFO, "Found %s", fullpath);
free(remapped);
return found;
@@ -439,7 +449,9 @@ static void ami_gui_resources_free(void)
static bool ami_gui_resources_open(void)
{
+#ifdef __amigaos4__
urlStringClass = MakeStringClass();
+#endif
if(!(appport = AllocSysObjectTags(ASOT_PORT,
ASO_NoTrack, FALSE,
@@ -832,7 +844,7 @@ static void ami_openscreen(void)
}
if(screen_signal == -1) screen_signal = AllocSignal(-1);
- LOG("Screen signal %d", screen_signal);
+ NSLOG(netsurf, INFO, "Screen signal %d", screen_signal);
scrn = OpenScreenTags(NULL,
/**\todo specify screen depth */
SA_DisplayID, id,
@@ -885,7 +897,7 @@ static void ami_openscreen(void)
static void ami_openscreenfirst(void)
{
ami_openscreen();
- if(!browserglob.bm) ami_init_layers(&browserglob, 0, 0, false);
+ if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false, false);
ami_theme_throbber_setup();
}
@@ -908,19 +920,22 @@ static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv,
if((args = ReadArgs(template, rarray, NULL))) {
if(rarray[A_URL]) {
- LOG("URL %s specified on command line",
- (char *)rarray[A_URL]);
+ NSLOG(netsurf, INFO,
+ "URL %s specified on command line",
+ (char *)rarray[A_URL]);
temp_homepage_url = strdup((char *)rarray[A_URL]); /**\todo allow IDNs */
}
if(rarray[A_USERSDIR]) {
- LOG("USERSDIR %s specified on command line",
- (char *)rarray[A_USERSDIR]);
+ NSLOG(netsurf, INFO,
+ "USERSDIR %s specified on command line",
+ (char *)rarray[A_USERSDIR]);
users_dir = ASPrintf("%s", rarray[A_USERSDIR]);
}
if(rarray[A_FORCE]) {
- LOG("FORCE specified on command line");
+ NSLOG(netsurf, INFO,
+ "FORCE specified on command line");
cli_force = true;
}
@@ -940,7 +955,7 @@ static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv,
*/
}
} else {
- LOG("ReadArgs failed to parse command line");
+ NSLOG(netsurf, INFO, "ReadArgs failed to parse command line");
}
FreeArgs(args);
@@ -993,11 +1008,6 @@ static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
return current_user;
}
-void ami_gui_set_default_gg(void)
-{
- glob = &browserglob;
-}
-
static void gui_init2(int argc, char** argv)
{
struct Screen *screen;
@@ -1008,9 +1018,6 @@ static void gui_init2(int argc, char** argv)
notalreadyrunning = ami_arexx_init(&rxsig);
- /* Treeview init code ends up calling a font function which needs this */
- ami_gui_set_default_gg();
-
/* ...and this ensures the treeview at least gets the WB colour palette to work with */
if(scrn == NULL) {
if((screen = LockPubScreen("Workbench"))) {
@@ -1022,7 +1029,8 @@ static void gui_init2(int argc, char** argv)
}
/**/
- hotlist_init(nsoption_charp(hotlist_file));
+ hotlist_init(nsoption_charp(hotlist_file),
+ nsoption_charp(hotlist_file));
search_web_select_provider(nsoption_int(search_provider));
if (notalreadyrunning &&
@@ -1043,6 +1051,7 @@ static void gui_init2(int argc, char** argv)
amiga_warn_user(messages_get_errorcode(error), 0);
}
free(temp_homepage_url);
+ temp_homepage_url = NULL;
}
if(cli_force == true) {
@@ -1123,6 +1132,7 @@ static void gui_init2(int argc, char** argv)
if(temp_homepage_url) {
sendcmd = ASPrintf("OPEN \"%s\" NEW%s", temp_homepage_url, newtab);
free(temp_homepage_url);
+ temp_homepage_url = NULL;
} else {
sendcmd = ASPrintf("OPEN \"%s\" NEW%s", nsoption_charp(homepage_url), newtab);
}
@@ -1215,12 +1225,10 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
}
}
-#ifdef __amigaos4__
GetAttr(GA_Disabled, gwin->objects[GID_BACK], (uint32 *)&s_back);
GetAttr(GA_Disabled, gwin->objects[GID_FORWARD], (uint32 *)&s_forward);
GetAttr(GA_Disabled, gwin->objects[GID_RELOAD], (uint32 *)&s_reload);
GetAttr(GA_Disabled, gwin->objects[GID_STOP], (uint32 *)&s_stop);
-#endif
if(BOOL_MISMATCH(s_back, back))
SetGadgetAttrs((struct Gadget *)gwin->objects[GID_BACK],
@@ -1240,9 +1248,9 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
if(ClickTabBase->lib_Version < 53) {
if(gwin->tabs <= 1) tabclose = TRUE;
-#ifdef __amigaos4__
+
GetAttr(GA_Disabled, gwin->objects[GID_CLOSETAB], (uint32 *)&s_tabclose);
-#endif
+
if(BOOL_MISMATCH(s_tabclose, tabclose))
SetGadgetAttrs((struct Gadget *)gwin->objects[GID_CLOSETAB],
gwin->win, NULL, GA_Disabled, tabclose, TAG_DONE);
@@ -1494,6 +1502,7 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
{
struct IBox *bbox;
int x, y;
+ struct rect rect;
if(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true)
{
@@ -1560,8 +1569,9 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
}
ami_gui_free_space_box(bbox);
-
- gui_window_set_scroll(gwin->gw, xs, ys);
+ rect.x0 = rect.x1 = xs;
+ rect.y0 = rect.y1 = ys;
+ gui_window_set_scroll(gwin->gw, &rect);
}
}
}
@@ -1574,6 +1584,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
if(ibox == NULL) return NULL;
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ free(ibox);
amiga_warn_user("NoMemory", "");
return NULL;
}
@@ -1642,15 +1653,26 @@ static void ami_gui_menu_update_all(void)
} while((node = nnode));
}
-static void gui_window_get_dimensions(struct gui_window *g,
+/**
+ * Find the current dimensions of a amiga browser window content area.
+ *
+ * \param gw The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ * else error code.
+ */
+static nserror gui_window_get_dimensions(struct gui_window *gw,
int *restrict width, int *restrict height, bool scaled)
{
struct IBox *bbox;
- if(!g) return;
+ nserror res;
- if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ res = ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], &bbox);
+ if(res != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
- return;
+ return res;
}
*width = bbox->Width;
@@ -1658,11 +1680,12 @@ static void gui_window_get_dimensions(struct gui_window *g,
ami_gui_free_space_box(bbox);
- if(scaled)
- {
- *width /= g->scale;
- *height /= g->scale;
+ if(scaled) {
+ *width /= gw->scale;
+ *height /= gw->scale;
}
+
+ return NSERROR_OK;
}
/* Add a horizontal scroller, if not already present
@@ -1818,7 +1841,7 @@ static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *ico
if ((icon != NULL) && ((icon_bitmap = content_get_bitmap(icon)) != NULL))
{
- bm = ami_bitmap_get_native(icon_bitmap, 16, 16,
+ bm = ami_bitmap_get_native(icon_bitmap, 16, 16, ami_plot_screen_is_palettemapped(),
g->shared->win->RPort->BitMap);
}
@@ -2502,10 +2525,9 @@ static BOOL ami_gui_event(void *w)
#ifdef __amigaos4__
case WMHI_ICONIFY:
{
- struct bitmap *bm;
-
- bm = urldb_get_thumbnail(browser_window_get_url(gwin->gw->bw));
- if(!bm) bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw));
+ struct bitmap *bm = NULL;
+ browser_window_history_get_thumbnail(gwin->gw->bw,
+ &bm);
gwin->dobj = amiga_icon_from_bitmap(bm);
amiga_icon_superimpose_favicon_internal(gwin->gw->favicon,
gwin->dobj);
@@ -2548,12 +2570,15 @@ static BOOL ami_gui_event(void *w)
if(drag_x_move || drag_y_move)
{
+ struct rect rect;
+
gui_window_get_scroll(gwin->gw,
&gwin->gw->scrollx, &gwin->gw->scrolly);
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx + drag_x_move,
- gwin->gw->scrolly + drag_y_move);
+ rect.x0 = rect.x1 = gwin->gw->scrollx + drag_x_move;
+ rect.y0 = rect.y1 = gwin->gw->scrolly + drag_y_move;
+
+ gui_window_set_scroll(gwin->gw, &rect);
}
// ReplyMsg((struct Message *)message);
@@ -2767,8 +2792,11 @@ static void ami_handle_applib(void)
{
struct ApplicationCustomMsg *applibcustmsg =
(struct ApplicationCustomMsg *)applibmsg;
- LOG("Ringhio BackMsg received: %s", applibcustmsg->customMsg);
- OpenWorkbenchObjectA(applibcustmsg->customMsg, NULL);
+ NSLOG(netsurf, INFO,
+ "Ringhio BackMsg received: %s",
+ applibcustmsg->customMsg);
+
+ ami_download_parse_backmsg(applibcustmsg->customMsg);
}
break;
}
@@ -2802,7 +2830,7 @@ void ami_get_msg(void)
NULL, (unsigned int *)&signalmask) != -1) {
signal = signalmask;
} else {
- LOG("waitselect() returned error");
+ NSLOG(netsurf, INFO, "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.
@@ -2907,11 +2935,15 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
if(redraw)
{
+ struct rect rect;
+
ami_plot_clear_bbox(gwin->win->RPort, bbox);
browser_window_update(gwin->gw->bw, false);
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx, gwin->gw->scrolly);
+ rect.x0 = rect.x1 = gwin->gw->scrollx;
+ rect.y0 = rect.y1 = gwin->gw->scrolly;
+
+ gui_window_set_scroll(gwin->gw, &rect);
gwin->redraw_scroll = false;
browser_window_refresh_url_bar(gwin->gw->bw);
@@ -3007,11 +3039,13 @@ static void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL d
if(donotwait == TRUE) return;
ULONG scrnsig = 1 << screen_signal;
- LOG("Waiting for visitor windows to close... (signal)");
+ NSLOG(netsurf, INFO,
+ "Waiting for visitor windows to close... (signal)");
Wait(scrnsig);
while (CloseScreen(scrn) == FALSE) {
- LOG("Waiting for visitor windows to close... (polling)");
+ NSLOG(netsurf, INFO,
+ "Waiting for visitor windows to close... (polling)");
Delay(50);
}
@@ -3041,35 +3075,37 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
- hotlist_fini(nsoption_charp(hotlist_file));
+ hotlist_fini();
#ifdef __amigaos4__
if(IApplication && ami_appid)
UnregisterApplication(ami_appid, NULL);
#endif
ami_arexx_cleanup();
- ami_free_layers(&browserglob);
+ ami_plot_ra_free(browserglob);
ami_font_fini();
ami_help_free();
- LOG("Freeing menu items");
+ NSLOG(netsurf, INFO, "Freeing menu items");
ami_ctxmenu_free();
ami_menu_free_glyphs();
- LOG("Freeing mouse pointers");
+ NSLOG(netsurf, INFO, "Freeing mouse pointers");
ami_mouse_pointers_free();
ami_file_req_free();
ami_openurl_close();
+#ifdef __amigaos4__
FreeStringClass(urlStringClass);
+#endif
FreeObjList(window_list);
ami_clipboard_free();
ami_gui_resources_free();
- LOG("Closing screen");
+ NSLOG(netsurf, INFO, "Closing screen");
ami_gui_close_screen(scrn, locked_screen, FALSE);
if(nsscreentitle) FreeVec(nsscreentitle);
}
@@ -3079,7 +3115,7 @@ char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
STRPTR filename = NULL;
if ((filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url)))) {
- LOG("favicon cache location: %s", filename);
+ NSLOG(netsurf, INFO, "favicon cache location: %s", filename);
if (only_if_avail == true) {
BPTR lock = 0;
@@ -3529,15 +3565,18 @@ 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)
{
+ struct gui_globals *glob = (struct gui_globals *)ctx->priv;
int x, y;
struct rect clip;
- int tile_size_x = glob->width;
- int tile_size_y = glob->height;
+ int tile_size_x;
+ int tile_size_y;
+
+ ami_plot_ra_get_size(glob, &tile_size_x, &tile_size_y);
int tile_x_scale = (int)(tile_size_x / gwin->gw->scale);
int tile_y_scale = (int)(tile_size_y / gwin->gw->scale);
- browserglob.shared_pens = gwin->shared_pens; /* do we need this?? */
+ ami_plot_ra_set_pen_list(glob, gwin->shared_pens);
if(top < 0) {
height += top;
@@ -3588,10 +3627,10 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
clip.y0 - (int)y,
&clip, ctx))
{
- ami_clearclipreg(&browserglob);
+ ami_clearclipreg(glob);
#ifdef __amigaos4__
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
- BLITA_Source, browserglob.bm,
+ BLITA_Source, ami_plot_ra_get_bitmap(glob),
BLITA_SrcX, 0,
BLITA_SrcY, 0,
BLITA_DestType, BLITT_RASTPORT,
@@ -3602,7 +3641,7 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
BLITA_Height, (int)(clip.y1),
TAG_DONE);
#else
- BltBitMapRastPort(browserglob.bm, 0, 0, gwin->win->RPort,
+ BltBitMapRastPort(ami_plot_ra_get_bitmap(glob), 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);
@@ -3636,7 +3675,8 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw
struct redraw_context ctx = {
.interactive = true,
.background_images = true,
- .plot = &amiplot
+ .plot = &amiplot,
+ .priv = browserglob
};
if(!g) return;
@@ -3660,6 +3700,45 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw
return;
}
+
+/**
+ * Invalidates an area of an amiga browser window
+ *
+ * \param g gui_window
+ * \param rect area to redraw or NULL for the entire window area
+ * \return NSERROR_OK on success or appropriate error code
+ */
+static nserror amiga_window_invalidate_area(struct gui_window *g,
+ const struct rect *restrict rect)
+{
+ struct nsObject *nsobj;
+ struct rect *restrict deferred_rect;
+
+ if(!g) return NSERROR_BAD_PARAMETER;
+
+ if (rect == NULL) {
+ if (g != g->shared->gw) {
+ return NSERROR_OK;
+ }
+ } else {
+ if (ami_gui_window_update_box_deferred_check(g->deferred_rects, rect,
+ g->deferred_rects_pool)) {
+ deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool,
+ sizeof(struct rect));
+ CopyMem(rect, deferred_rect, sizeof(struct rect));
+ nsobj = AddObject(g->deferred_rects, AMINS_RECT);
+ nsobj->objstruct = deferred_rect;
+ } else {
+ NSLOG(netsurf, INFO,
+ "Ignoring duplicate or subset of queued box redraw");
+ }
+ }
+ ami_schedule_redraw(g->shared, false);
+
+ return NSERROR_OK;
+}
+
+
static void ami_refresh_window(struct gui_window_2 *gwin)
{
/* simplerefresh only */
@@ -3692,7 +3771,7 @@ static void ami_refresh_window(struct gui_window_2 *gwin)
regrect = gwin->win->RPort->Layer->DamageList->RegionRectangle;
- gui_window_update_box(gwin->gw, &r);
+ amiga_window_invalidate_area(gwin->gw, &r);
while(regrect)
{
@@ -3707,7 +3786,7 @@ static void ami_refresh_window(struct gui_window_2 *gwin)
regrect = regrect->Next;
- gui_window_update_box(gwin->gw, &r);
+ amiga_window_invalidate_area(gwin->gw, &r);
}
EndRefresh(gwin->win, TRUE);
@@ -3781,7 +3860,8 @@ HOOKF(void, ami_scroller_hook, Object *, object, struct IntuiMessage *)
break;
default:
- LOG("IDCMP hook unhandled event: %ld", msg->Class);
+ NSLOG(netsurf, INFO,
+ "IDCMP hook unhandled event: %ld", msg->Class);
break;
}
// ReplyMsg((struct Message *)msg);
@@ -3840,7 +3920,7 @@ gui_window_create(struct browser_window *bw,
ULONG defer_layout = TRUE;
ULONG idcmp_sizeverify = IDCMP_SIZEVERIFY;
- LOG("Creating window");
+ NSLOG(netsurf, INFO, "Creating window");
if (!scrn) ami_openscreenfirst();
@@ -3979,12 +4059,14 @@ gui_window_create(struct browser_window *bw,
ULONG addtabclosegadget = TAG_IGNORE;
ULONG iconifygadget = FALSE;
+#ifdef __amigaos4__
if (nsoption_charp(pubscreen_name) &&
(locked_screen == TRUE) &&
(strcmp(nsoption_charp(pubscreen_name), "Workbench") == 0))
iconifygadget = TRUE;
+#endif
- LOG("Creating menu");
+ NSLOG(netsurf, INFO, "Creating menu");
struct Menu *menu = ami_gui_menu_create(g->shared);
NewList(&g->shared->tab_list);
@@ -4106,7 +4188,7 @@ gui_window_create(struct browser_window *bw,
BitMapEnd;
}
- LOG("Creating window object");
+ NSLOG(netsurf, INFO, "Creating window object");
g->shared->objects[OID_MAIN] = WindowObj,
WA_ScreenTitle, ami_gui_get_screen_title(),
@@ -4384,11 +4466,11 @@ gui_window_create(struct browser_window *bw,
EndWindow;
}
- LOG("Opening window");
+ NSLOG(netsurf, INFO, "Opening window");
g->shared->win = (struct Window *)RA_OpenWindow(g->shared->objects[OID_MAIN]);
- LOG("Window opened, adding border gadgets");
+ NSLOG(netsurf, INFO, "Window opened, adding border gadgets");
if(!g->shared->win)
{
@@ -4459,8 +4541,6 @@ gui_window_create(struct browser_window *bw,
ami_gui_win_list_add(g->shared, AMINS_WINDOW, &ami_gui_table);
- ami_gui_set_default_gg();
-
if(locked_screen) {
UnlockPubScreen(NULL,scrn);
locked_screen = FALSE;
@@ -4480,9 +4560,7 @@ static void ami_gui_close_tabs(struct gui_window_2 *gwin, bool other_tabs)
struct gui_window *gw;
if((gwin->tabs > 1) && (nsoption_bool(tab_close_warn) == true)) {
- char *req_body = ami_utf8_easy(messages_get("MultiTabClose"));
- int32 res = amiga_warn_user_multi(req_body, "Yes", "No", gwin->win);
- free(req_body);
+ int32 res = amiga_warn_user_multi(messages_get("MultiTabClose"), "Yes", "No", gwin->win);
if(res == 0) return;
}
@@ -4531,7 +4609,7 @@ static void gui_window_destroy(struct gui_window *g)
if(g->hw)
{
- ami_history_close(g->hw);
+ ami_history_local_destroy(g->hw);
win_destroyed = true;
}
@@ -4701,7 +4779,7 @@ static void ami_redraw_callback(void *p)
*
* \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()
+ should only be set to false when called from amiga_window_invalidate_area()
*/
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
{
@@ -4716,14 +4794,6 @@ 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)
-{
- if(!g) return;
-
- if(g == g->shared->gw)
- ami_schedule_redraw(g->shared, true);
-}
-
static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
{
struct nsObject *node;
@@ -4736,7 +4806,7 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
if(draw == true) {
ami_set_pointer(g->shared, GUI_POINTER_WAIT, false);
} else {
- LOG("Ignoring deferred box redraw queue");
+ NSLOG(netsurf, INFO, "Ignoring deferred box redraw queue");
}
node = (struct nsObject *)GetHead((struct List *)g->deferred_rects);
@@ -4781,7 +4851,8 @@ bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
(new_rect->y0 <= rect->y0) &&
(new_rect->x1 >= rect->x1) &&
(new_rect->y1 >= rect->y1)) {
- LOG("Removing queued redraw that is a subset of new box redraw");
+ NSLOG(netsurf, INFO,
+ "Removing queued redraw that is a subset of new box redraw");
ami_memory_itempool_free(mempool, node->objstruct, sizeof(struct rect));
DelObjectNoFree(node);
/* Don't return - we might find more */
@@ -4791,50 +4862,12 @@ bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
return true;
}
-static void gui_window_update_box(struct gui_window *g, const struct rect *restrict rect)
-{
- struct nsObject *nsobj;
- struct rect *restrict deferred_rect;
- if(!g) return;
-
- if(ami_gui_window_update_box_deferred_check(g->deferred_rects, rect,
- g->deferred_rects_pool)) {
- deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, sizeof(struct rect));
- CopyMem(rect, deferred_rect, sizeof(struct rect));
- nsobj = AddObject(g->deferred_rects, AMINS_RECT);
- nsobj->objstruct = deferred_rect;
- } else {
- LOG("Ignoring duplicate or subset of queued box redraw");
- }
- 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;
-
- LOG("reformat window %p", gw);
-
- if (gw != NULL) {
- if(ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
- amiga_warn_user("NoMemory", "");
- return;
- }
- browser_window_reformat(gw->bw, false, bbox->Width, bbox->Height);
- gw->shared->redraw_scroll = false;
- ami_gui_free_space_box(bbox);
- }
-}
static void ami_do_redraw(struct gui_window_2 *gwin)
{
ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
struct IBox *bbox;
ULONG oldh = gwin->oldh, oldv=gwin->oldv;
- struct RastPort *temprp;
if(browser_window_redraw_ready(gwin->gw->bw) == false) return;
@@ -4879,63 +4912,39 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
{
ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, height - (vcurrent - oldv) - 1);
ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, height + 1);
- gui_window_update_box(gwin->gw, &rect);
+ amiga_window_invalidate_area(gwin->gw, &rect);
}
else if(vcurrent<oldv) /* Going up */
{
ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, 0);
ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, oldv - vcurrent + 1);
- gui_window_update_box(gwin->gw, &rect);
+ amiga_window_invalidate_area(gwin->gw, &rect);
}
if(hcurrent>oldh) /* Going right */
{
ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, width - (hcurrent - oldh), 0);
ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, height + 1);
- gui_window_update_box(gwin->gw, &rect);
+ amiga_window_invalidate_area(gwin->gw, &rect);
}
else if(hcurrent<oldh) /* Going left */
{
ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, 0);
ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, oldh - hcurrent + 1, height + 1);
- gui_window_update_box(gwin->gw, &rect);
+ amiga_window_invalidate_area(gwin->gw, &rect);
}
}
else
{
- struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.background_images = true,
- .plot = &amiplot
+ .plot = &amiplot,
+ .priv = browserglob
};
- ami_gui_set_default_gg();
+ ami_do_redraw_tiled(gwin, true, hcurrent, vcurrent, width, height, hcurrent, vcurrent, bbox, &ctx);
- if(nsoption_bool(direct_render) == false)
- {
- ami_do_redraw_tiled(gwin, true, hcurrent, vcurrent, width, height, hcurrent, vcurrent, bbox, &ctx);
- }
- else
- {
- browserglob.shared_pens = gwin->shared_pens;
- temprp = browserglob.rp;
- browserglob.rp = gwin->win->RPort;
- clip.x0 = bbox->Left;
- clip.y0 = bbox->Top;
- clip.x1 = bbox->Left + bbox->Width;
- clip.y1 = bbox->Top + bbox->Height;
-
- ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
-
- if(browser_window_redraw(gwin->gw->bw, clip.x0 - hcurrent, clip.y0 - vcurrent, &clip, &ctx))
- {
- ami_clearclipreg(&browserglob);
- browserglob.rp = temprp;
- }
-
- ami_reset_pointer(gwin);
- }
/* Tell NetSurf not to bother with the next queued box redraw, as we've redrawn everything. */
ami_gui_window_update_box_deferred(gwin->gw, false);
}
@@ -4952,27 +4961,26 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
ami_gui_free_space_box(bbox);
}
+
void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs)
{
if(gwin->objects[GID_HSCROLL])
{
GetAttr(SCROLLER_Top, (Object *)gwin->objects[GID_HSCROLL], xs);
+ *xs /= gwin->gw->scale;
} else {
*xs = 0;
}
-
- *xs /= gwin->gw->scale;
}
void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys)
{
if(gwin->objects[GID_VSCROLL]) {
GetAttr(SCROLLER_Top, gwin->objects[GID_VSCROLL], ys);
+ *ys /= gwin->gw->scale;
} else {
*ys = 0;
}
-
- *ys /= gwin->gw->scale;
}
static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy)
@@ -4983,21 +4991,44 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r
return true;
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a amiga browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The amiga implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param g gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
struct IBox *bbox;
int width, height;
+ nserror res;
+ int sx = 0, sy = 0;
- if(!g) return;
- if(!g->bw || browser_window_has_content(g->bw) == false) return;
+ if(!g) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if(!g->bw || browser_window_has_content(g->bw) == false) {
+ return NSERROR_BAD_PARAMETER;
+ }
- if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ res = ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox);
+ if(res != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
- return;
+ return res;
}
- if(sx < 0) sx=0;
- if(sy < 0) sy=0;
+ if (rect->x0 > 0) {
+ sx = rect->x0;
+ }
+ if (rect->y0 > 0) {
+ sy = rect->y0;
+ }
browser_window_get_extents(g->bw, false, &width, &height);
@@ -5035,6 +5066,7 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
g->scrollx = sx;
g->scrolly = sy;
}
+ return NSERROR_OK;
}
static void gui_window_update_extent(struct gui_window *g)
@@ -5166,7 +5198,7 @@ static nserror gui_search_web_provider_update(const char *provider_name,
if(nsoption_bool(kiosk_mode) == true) return NSERROR_BAD_PARAMETER;
if (ico_bitmap != NULL) {
- bm = ami_bitmap_get_native(ico_bitmap, 16, 16, NULL);
+ bm = ami_bitmap_get_native(ico_bitmap, 16, 16, ami_plot_screen_is_palettemapped(), NULL);
}
if(bm == NULL) return NSERROR_BAD_PARAMETER;
@@ -5282,7 +5314,7 @@ static void gui_window_new_content(struct gui_window *g)
c = browser_window_get_content(g->bw);
else return;
- ami_clearclipreg(&browserglob);
+ ami_clearclipreg(browserglob);
g->shared->new_content = true;
g->scrollx = 0;
g->scrolly = 0;
@@ -5391,20 +5423,20 @@ Object *ami_gui_splash_open(void)
EndWindow;
if(win_obj == NULL) {
- LOG("Splash window object not created");
+ NSLOG(netsurf, INFO, "Splash window object not created");
return NULL;
}
- LOG("Attempting to open splash window...");
+ NSLOG(netsurf, INFO, "Attempting to open splash window...");
win = RA_OpenWindow(win_obj);
if(win == NULL) {
- LOG("Splash window did not open");
+ NSLOG(netsurf, INFO, "Splash window did not open");
return NULL;
}
if(bm_obj == NULL) {
- LOG("BitMap object not created");
+ NSLOG(netsurf, INFO, "BitMap object not created");
return NULL;
}
@@ -5466,14 +5498,14 @@ void ami_gui_splash_close(Object *win_obj)
{
if(win_obj == NULL) return;
- LOG("Closing splash window");
+ NSLOG(netsurf, INFO, "Closing splash window");
DisposeObject(win_obj);
}
static void gui_file_gadget_open(struct gui_window *g, struct hlcache_handle *hl,
struct form_control *gadget)
{
- LOG("File open dialog request for %p/%p", g, gadget);
+ NSLOG(netsurf, INFO, "File open dialog request for %p/%p", g, gadget);
if(AslRequestTags(filereq,
ASLFR_Window, g->shared->win,
@@ -5508,7 +5540,7 @@ static char *ami_gui_get_user_dir(STRPTR current_user)
user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
}
- LOG("User: %s", current_user);
+ NSLOG(netsurf, INFO, "User: %s", current_user);
if(users_dir == NULL) {
users_dir = ASPrintf("%s", USERS_DIR);
@@ -5560,7 +5592,7 @@ static char *ami_gui_get_user_dir(STRPTR current_user)
FreeVec(users_dir);
FreeVec(current_user);
- LOG("User dir: %s", current_user_dir);
+ NSLOG(netsurf, INFO, "User dir: %s", current_user_dir);
if((lock = CreateDirTree(current_user_dir)))
UnLock(lock);
@@ -5576,13 +5608,11 @@ static char *ami_gui_get_user_dir(STRPTR current_user)
static struct gui_window_table amiga_window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,
- .redraw = gui_window_redraw_window,
- .update = gui_window_update_box,
+ .invalidate = amiga_window_invalidate_area,
.get_scroll = gui_window_get_scroll,
.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,
@@ -5789,7 +5819,7 @@ int main(int argc, char** argv)
AddPart(script, nsoption_charp(arexx_startup), 1024);
ami_arexx_execute(script);
- LOG("Entering main loop");
+ NSLOG(netsurf, INFO, "Entering main loop");
while (!ami_quit) {
ami_get_msg();
@@ -5808,6 +5838,9 @@ int main(int argc, char** argv)
free(current_user_dir);
FreeVec(current_user_faviconcache);
+ /* finalise logging */
+ nslog_finalise();
+
#ifndef __amigaos4__
/* OS3 low memory handler */
ami_memory_fini(memhandler);