diff options
Diffstat (limited to 'frontends/amiga')
71 files changed, 2663 insertions, 1770 deletions
diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile index ac05d1bf0..f537a1163 100644 --- a/frontends/amiga/Makefile +++ b/frontends/amiga/Makefile @@ -12,20 +12,27 @@ endif $(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon)) $(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes)) +$(eval $(call feature_enabled,AMISSL,-DWITH_AMISSL -DWITH_OPENSSL -D__NO_NET_API -D__NO_NETINCLUDE_ERRNO -I$(GCCSDK_INSTALL_ENV)/netinclude,-lamisslauto,AmiSSL)) CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include CFLAGS += $(shell $(PKG_CONFIG) --cflags tre) -LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl) +LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl) LDFLAGS += $(shell $(PKG_CONFIG) --libs tre) LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib LDFLAGS += -lpbl -liconv +ifeq ($(NETSURF_USE_OPENSSL),YES) + LDFLAGS += $(shell $(PKG_CONFIG) --static --libs openssl) +endif + ifeq ($(SUBTARGET),os3) LDFLAGS += -lamiga -lm endif +COMMON_WARNFLAGS += -Wno-cast-align + EXETARGET := NetSurf # The filter and target for split messages @@ -37,16 +44,16 @@ MESSAGES_FILTER=ami # sources purely for the Amiga build S_FRONTEND := gui.c history.c hotlist.c schedule.c file.c \ - misc.c bitmap.c font.c filetype.c utf8.c login.c memory.c \ + misc.c bitmap.c font.c filetype.c utf8.c memory.c \ plotters.c object.c menu.c save_pdf.c arexx.c version.c \ cookies.c ctxmenu.c clipboard.c help.c font_scan.c \ launch.c search.c history_local.c download.c iff_dr2d.c \ - sslcert.c gui_options.c print.c theme.c drag.c icon.c libs.c \ + gui_options.c print.c theme.c drag.c icon.c libs.c \ datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \ stringview/stringview.c stringview/urlhistory.c rtg.c \ agclass/amigaguide_class.c os3support.c font_diskfont.c \ selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \ - nsoption.c corewindow.c gui_menu.c + nsoption.c corewindow.c gui_menu.c pageinfo.c # This is the final source build list # Note this is deliberately *not* expanded here as common and image @@ -73,7 +80,7 @@ AMIGA_DISTRIBUTION_FILES := $(FRONTEND_SOURCE_DIR)/dist/* AMIGA_PKG_DIR := $(FRONTEND_SOURCE_DIR)/pkg AMIGA_INSTALL_TARGET_DIR := NetSurf_Amiga -netsurf.lha: $(EXETARGET) +netsurf.lha: $(EXETARGET) $(POSTEXES) $(VQ)echo Creating netsurf.lha $(Q)rm -rf $(AMIGA_INSTALL_TARGET_DIR) $(Q)$(MKDIR) -p $(AMIGA_INSTALL_TARGET_DIR)/NetSurf @@ -98,5 +105,5 @@ netsurf.lha: $(EXETARGET) $(Q)cp -p $(AMIGA_PKG_DIR)/netsurf.readme.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf endif $(Q)cd $(AMIGA_INSTALL_TARGET_DIR); \ - lha a netsurf.lha NetSurf NetSurf.info AutoInstall + lha ao6 netsurf.lha NetSurf NetSurf.info AutoInstall diff --git a/frontends/amiga/Makefile.defaults b/frontends/amiga/Makefile.defaults index f19d6e394..25e1f42e4 100644 --- a/frontends/amiga/Makefile.defaults +++ b/frontends/amiga/Makefile.defaults @@ -6,6 +6,12 @@ # Valid options: YES, NO NETSURF_USE_LIBICONV_PLUG := NO +# Use AmiSSL for secure connections. +# Either this or NETSURF_USE_OPENSSL should be specified, not both. +# libcurl must have been built against the same library. +# Valid options: YES, NO +NETSURF_USE_AMISSL := NO + # Enable NetSurf's use of librosprite for displaying RISC OS Sprites # Valid options: YES, NO, AUTO NETSURF_USE_ROSPRITE := NO @@ -28,5 +34,14 @@ NETSURF_USE_NSSVG := YES NETSURF_FS_BACKING_STORE := YES # Optimisation levels -CFLAGS += -fomit-frame-pointer -gstabs +CFLAGS += -fomit-frame-pointer + +# Target-specific +ifeq ($(SUBTARGET),os3) + NETSURF_USE_OPENSSL := NO + NETSURF_USE_AMISSL := YES + NETSURF_FS_BACKING_STORE := YES +else + CFLAGS += -gstabs +endif diff --git a/frontends/amiga/Makefile.tools b/frontends/amiga/Makefile.tools new file mode 100644 index 000000000..c16928783 --- /dev/null +++ b/frontends/amiga/Makefile.tools @@ -0,0 +1,21 @@ +# -*- mode: makefile-gmake -*- +## +## amiga target tool setup +## + +ifeq ($(findstring amiga,$(HOST)),amiga) + # building for amiga on amiga + PKG_CONFIG := pkg-config +else + ifeq ($(SUBTARGET),os3) + GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-unknown-amigaos/env + GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-unknown-amigaos/cross/bin + else + GCCSDK_INSTALL_ENV ?= /opt/netsurf/ppc-amigaos/env + GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/ppc-amigaos/cross/bin + endif + + CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc) + + PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config +endif diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c index acb0348fd..243e927f8 100644 --- a/frontends/amiga/arexx.c +++ b/frontends/amiga/arexx.c @@ -69,7 +69,8 @@ enum RX_ACTIVE, RX_CLOSE, RX_HOTLIST, - RX_SLABSTATS + RX_SLABSTATS, + RX_EXEC }; static Object *arexx_obj = NULL; @@ -98,6 +99,7 @@ RXHOOKF(rx_active); RXHOOKF(rx_close); RXHOOKF(rx_hotlist); RXHOOKF(rx_slabstats); +RXHOOKF(rx_exec); STATIC struct ARexxCmd Commands[] = { @@ -118,6 +120,7 @@ STATIC struct ARexxCmd Commands[] = {"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL }, {"HOTLIST", RX_HOTLIST, rx_hotlist, "A=ACTION/A", 0, NULL, 0, 0, NULL }, {"SLABSTATS", RX_SLABSTATS, rx_slabstats, "FILE", 0, NULL, 0, 0, NULL }, + {"EXEC", RX_EXEC, rx_exec, "W=WINDOW/K/N,T=TAB/K/N,COMMAND/A/F", 0, NULL, 0, 0, NULL }, { NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL } }; @@ -191,9 +194,9 @@ static struct gui_window *ami_find_tab_gwin(struct gui_window_2 *gwin, int tab) struct Node *ntab; struct gui_window *gw; - if((tab == 0) || (gwin->tabs == 0)) return gwin->gw; + if((tab == 0) || (ami_gui2_get_tabs(gwin) == 0)) return ami_gui2_get_gui_window(gwin); - ctab = GetHead(&gwin->tab_list); + ctab = GetHead(ami_gui2_get_tab_list(gwin)); do { @@ -215,9 +218,9 @@ static int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw) struct Node *ntab; struct gui_window *tgw = NULL; - if((bw == NULL) || (gwin->tabs == 0)) return 1; + if((bw == NULL) || (ami_gui2_get_tabs(gwin) == 0)) return 1; - ctab = GetHead(&gwin->tab_list); + ctab = GetHead(ami_gui2_get_tab_list(gwin)); do { @@ -226,7 +229,7 @@ static int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw) GetClickTabNodeAttrs(ctab, TNA_UserData, &tgw, TAG_DONE); - if(tgw->bw == bw) return tabs; + if(ami_gui_get_browser_window(tgw) == bw) return tabs; } while((ctab=ntab)); return 0; @@ -235,6 +238,7 @@ static int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw) static struct gui_window *ami_find_tab(int window, int tab) { struct nsObject *node, *nnode; + struct MinList *window_list = ami_gui_get_window_list(); if(!IsMinListEmpty(window_list)) { @@ -260,7 +264,7 @@ static struct gui_window *ami_find_tab(int window, int tab) RXHOOKF(rx_open) { struct dlnode *dln; - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); nsurl *url; cmd->ac_RC = 0; @@ -281,8 +285,8 @@ RXHOOKF(rx_open) dln->filename = strdup((char *)cmd->ac_ArgList[3]); dln->node.ln_Name = strdup((char *)cmd->ac_ArgList[0]); dln->node.ln_Type = NT_USER; - AddTail(&gw->dllist, (struct Node *)dln); - browser_window_navigate(gw->bw, + AddTail(ami_gui_get_download_list(gw), (struct Node *)dln); + browser_window_navigate(ami_gui_get_browser_window(gw), url, NULL, BW_NAVIGATE_DOWNLOAD, @@ -303,11 +307,11 @@ RXHOOKF(rx_open) BW_CREATE_TAB, url, NULL, - gw->bw, + ami_gui_get_browser_window(gw), NULL); if(cmd->ac_ArgList[6]) { - ami_gui_switch_to_new_tab(gw->shared); + ami_gui_switch_to_new_tab(ami_gui_get_gui_window_2(gw)); } } } @@ -323,7 +327,7 @@ RXHOOKF(rx_open) { if(gw) { - browser_window_navigate(gw->bw, + browser_window_navigate(ami_gui_get_browser_window(gw), url, NULL, BW_NAVIGATE_HISTORY, @@ -346,9 +350,7 @@ RXHOOKF(rx_open) RXHOOKF(rx_save) { BPTR fh = 0; - ULONG source_size; - const char *source_data; - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; @@ -357,19 +359,23 @@ RXHOOKF(rx_save) if(!gw) return; - ami_set_pointer(gw->shared, GUI_POINTER_WAIT, false); + ami_set_pointer(ami_gui_get_gui_window_2(gw), GUI_POINTER_WAIT, false); if((fh = FOpen((char *)cmd->ac_ArgList[0], MODE_NEWFILE, 0))) { - struct hlcache_handle *h = browser_window_get_content(gw->bw); - if((source_data = content_get_source_data(h, &source_size))) + const uint8_t *source_data; + size_t source_size; + struct hlcache_handle *h = browser_window_get_content(ami_gui_get_browser_window(gw)); + source_data = content_get_source_data(h, &source_size); + if (source_data != NULL) { FWrite(fh, source_data, 1, source_size); + } FClose(fh); - SetComment((char *)cmd->ac_ArgList[0], nsurl_access(browser_window_access_url(gw->bw))); + SetComment((char *)cmd->ac_ArgList[0], nsurl_access(browser_window_access_url(ami_gui_get_browser_window(gw)))); } - ami_reset_pointer(gw->shared); + ami_reset_pointer(ami_gui_get_gui_window_2(gw)); } RXHOOKF(rx_quit) @@ -381,21 +387,21 @@ RXHOOKF(rx_quit) RXHOOKF(rx_tofront) { cmd->ac_RC = 0; - ScreenToFront(scrn); + ScreenToFront(ami_gui_get_screen()); } RXHOOKF(rx_geturl) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1])) gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); - if(gw && gw->bw) + if(gw && ami_gui_get_browser_window(gw)) { - strcpy(result, nsurl_access(browser_window_access_url(gw->bw))); + strcpy(result, nsurl_access(browser_window_access_url(ami_gui_get_browser_window(gw)))); } else { @@ -407,7 +413,7 @@ RXHOOKF(rx_geturl) RXHOOKF(rx_gettitle) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; @@ -416,10 +422,10 @@ RXHOOKF(rx_gettitle) if(gw) { - if(gw->shared->tabs > 1) - strcpy(result, gw->tabtitle); + if(ami_gui2_get_tabs(ami_gui_get_gui_window_2(gw)) > 1) + strcpy(result, ami_gui_get_tab_title(gw)); else - strcpy(result, gw->shared->wintitle); + strcpy(result, ami_gui_get_win_title(gw)); } else { @@ -513,32 +519,32 @@ RXHOOKF(rx_pubscreen) RXHOOKF(rx_back) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1])) gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); - if(gw) ami_gui_history(gw->shared, true); + if(gw) ami_gui_history(ami_gui_get_gui_window_2(gw), true); } RXHOOKF(rx_forward) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1])) gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); - if(gw) ami_gui_history(gw->shared, false); + if(gw) ami_gui_history(ami_gui_get_gui_window_2(gw), false); } RXHOOKF(rx_home) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); nsurl *url; cmd->ac_RC = 0; @@ -551,7 +557,7 @@ RXHOOKF(rx_home) if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) { amiga_warn_user("NoMemory", 0); } else { - browser_window_navigate(gw->bw, + browser_window_navigate(ami_gui_get_browser_window(gw), url, NULL, BW_NAVIGATE_HISTORY, @@ -564,7 +570,7 @@ RXHOOKF(rx_home) RXHOOKF(rx_reload) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; @@ -575,11 +581,11 @@ RXHOOKF(rx_reload) { if(cmd->ac_ArgList[0]) /* FORCE */ { - browser_window_reload(gw->bw, true); + browser_window_reload(ami_gui_get_browser_window(gw), true); } else { - browser_window_reload(gw->bw, false); + browser_window_reload(ami_gui_get_browser_window(gw), false); } } } @@ -602,9 +608,10 @@ RXHOOKF(rx_windows) RXHOOKF(rx_active) { int window = 0, tab = 0; - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); struct nsObject *node, *nnode; struct gui_window_2 *gwin = NULL; + struct MinList *window_list = ami_gui_get_window_list(); cmd->ac_RC = 0; @@ -623,7 +630,7 @@ RXHOOKF(rx_active) if(node->Type == AMINS_WINDOW) { windows++; - if(gwin->gw == gw) + if(IS_CURRENT_GW(gwin,gw)) { window = windows; break; @@ -634,7 +641,7 @@ RXHOOKF(rx_active) if(cmd->ac_ArgList[0]) { - tab = ami_find_tab_bw(gwin, gw->bw); + tab = ami_find_tab_bw(gwin, ami_gui_get_browser_window(gw)); } if(cmd->ac_ArgList[0]) sprintf(result, "%d", tab); @@ -644,7 +651,7 @@ RXHOOKF(rx_active) RXHOOKF(rx_close) { - struct gui_window *gw = cur_gw; + struct gui_window *gw = ami_gui_get_active_gw(); cmd->ac_RC = 0; @@ -652,11 +659,11 @@ RXHOOKF(rx_close) gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); else if(cmd->ac_ArgList[0]) { - ami_gui_close_window(gw->shared); + ami_gui_close_window(ami_gui_get_gui_window_2(gw)); return; } - if(gw) browser_window_destroy(gw->bw); + if(gw) browser_window_destroy(ami_gui_get_browser_window(gw)); } RXHOOKF(rx_hotlist) @@ -670,6 +677,33 @@ RXHOOKF(rx_hotlist) } } +RXHOOKF(rx_exec) +{ + struct gui_window *gw = ami_gui_get_active_gw(); + bool res = false; + + if(nsoption_bool(arexx_allow_exec) == false) { + cmd->ac_RC = RETURN_FAIL; + return; + } + + if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1])) + gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); + + if(gw) { + NSLOG(netsurf, WARNING, "Executing js: %s", (char *)cmd->ac_ArgList[2]); + res = browser_window_exec(ami_gui_get_browser_window(gw), + (char *)cmd->ac_ArgList[2], strlen((char *)cmd->ac_ArgList[2])); + } + + if(res == false) { + cmd->ac_RC = RETURN_ERROR; + } else { + cmd->ac_RC = RETURN_OK; + } + +} + RXHOOKF(rx_slabstats) { #ifndef __amigaos4__ diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c index 0fde677ae..e8534a395 100644 --- a/frontends/amiga/bitmap.c +++ b/frontends/amiga/bitmap.c @@ -108,7 +108,7 @@ static APTR pool_bitmap = NULL; static bool guigfx_warned = false; /* exported function documented in amiga/bitmap.h */ -void *amiga_bitmap_create(int width, int height, unsigned int state) +void *amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags) { struct bitmap *bitmap; @@ -139,8 +139,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state) bitmap->width = width; bitmap->height = height; - if(state & BITMAP_OPAQUE) bitmap->opaque = true; - else bitmap->opaque = false; + bitmap->opaque = (flags & BITMAP_OPAQUE) == BITMAP_OPAQUE; bitmap->nativebm = NULL; bitmap->nativebmwidth = 0; @@ -307,25 +306,6 @@ void amiga_bitmap_set_opaque(void *bitmap, bool opaque) /* exported function documented in amiga/bitmap.h */ -bool amiga_bitmap_test_opaque(void *bitmap) -{ - struct bitmap *bm = bitmap; - uint32 p = bm->width * bm->height; - uint32 a = 0; - uint32 *bmi = (uint32 *)amiga_bitmap_get_buffer(bm); - - assert(bitmap); - - for(a=0;a<p;a+=4) - { - if ((*bmi & 0x000000ffU) != 0x000000ffU) return false; - bmi++; - } - return true; -} - - -/* exported function documented in amiga/bitmap.h */ bool amiga_bitmap_get_opaque(void *bitmap) { struct bitmap *bm = bitmap; @@ -367,40 +347,6 @@ int bitmap_get_height(void *bitmap) } } - -/** - * Find the bytes per pixel of a bitmap - * - * \param vbitmap a bitmap, as returned by bitmap_create() - * \return bytes per pixel - */ -static size_t bitmap_get_bpp(void *vbitmap) -{ - struct bitmap *bitmap = (struct bitmap *)vbitmap; - assert(bitmap); - return 4; -} - -static void ami_bitmap_argb_to_rgba(struct bitmap *bm) -{ - if(bm == NULL) return; - - ULONG *data = (ULONG *)amiga_bitmap_get_buffer(bm); - for(int i = 0; i < (bm->width * bm->height); i++) { - data[i] = (data[i] << 8) | (data[i] >> 24); - } -} - -static void ami_bitmap_rgba_to_argb(struct bitmap *bm) -{ - if(bm == NULL) return; - - ULONG *data = (ULONG *)amiga_bitmap_get_buffer(bm); - for(int i = 0; i < (bm->width * bm->height); i++) { - data[i] = (data[ i] >> 8) | (data[i] << 24); - } -} - #ifdef BITMAP_DUMP void bitmap_dump(struct bitmap *bitmap) { @@ -436,7 +382,7 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap) { bmhd->bmh_Width = (UWORD)bitmap_get_width(bitmap); bmhd->bmh_Height = (UWORD)bitmap_get_height(bitmap); - bmhd->bmh_Depth = (UBYTE)bitmap_get_bpp(bitmap) * 8; + bmhd->bmh_Depth = (UBYTE)32; if(!amiga_bitmap_get_opaque(bitmap)) bmhd->bmh_Masking = mskHasAlpha; } @@ -450,7 +396,7 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap) TAG_DONE); IDoMethod(dto, PDTM_WRITEPIXELARRAY, amiga_bitmap_get_buffer(bitmap), - PBPAFMT_RGBA, amiga_bitmap_get_rowstride(bitmap), 0, 0, + PBPAFMT_ARGB, amiga_bitmap_get_rowstride(bitmap), 0, 0, bitmap_get_width(bitmap), bitmap_get_height(bitmap)); } @@ -475,10 +421,10 @@ struct bitmap *ami_bitmap_from_datatype(char *filename) bm = amiga_bitmap_create(bmh->bmh_Width, bmh->bmh_Height, 0); IDoMethod(dto, PDTM_READPIXELARRAY, amiga_bitmap_get_buffer(bm), - PBPAFMT_RGBA, amiga_bitmap_get_rowstride(bm), 0, 0, + PBPAFMT_ARGB, amiga_bitmap_get_rowstride(bm), 0, 0, bmh->bmh_Width, bmh->bmh_Height); - amiga_bitmap_set_opaque(bm, amiga_bitmap_test_opaque(bm)); + amiga_bitmap_set_opaque(bm, bitmap_test_opaque(bm)); } DisposeDTObject(dto); } @@ -490,6 +436,7 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int width, int height, struct BitMap *restrict friendbm, int type) { struct BitMap *restrict tbm = NULL; + struct Screen *scrn = ami_gui_get_screen(); if(bitmap->nativebm) { @@ -530,19 +477,22 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, dithermode = DITHERMODE_FS; } - ami_bitmap_rgba_to_argb(bitmap); - bitmap->drawhandle = ObtainDrawHandle(NULL, - &rp, scrn->ViewPort.ColorMap, - GGFX_DitherMode, dithermode, - TAG_DONE); - - APTR ddh = CreateDirectDrawHandle(bitmap->drawhandle, - bitmap->width, bitmap->height, - width, height, NULL); - - DirectDrawTrueColor(ddh, (ULONG *)amiga_bitmap_get_buffer(bitmap), 0, 0, TAG_DONE); - DeleteDirectDrawHandle(ddh); - ami_bitmap_argb_to_rgba(bitmap); + bitmap->drawhandle = ObtainDrawHandle( + NULL, + &rp, + scrn->ViewPort.ColorMap, + GGFX_DitherMode, dithermode, + TAG_DONE); + if(bitmap->drawhandle) { + APTR ddh = CreateDirectDrawHandle(bitmap->drawhandle, + bitmap->width, bitmap->height, + width, height, NULL); + + DirectDrawTrueColor(ddh, (ULONG *)amiga_bitmap_get_buffer(bitmap), 0, 0, TAG_DONE); + DeleteDirectDrawHandle(ddh); + ReleaseDrawHandle(bitmap->drawhandle); + bitmap->drawhandle = NULL; + } } else { if(guigfx_warned == false) { amiga_warn_user("BMConvErr", NULL); @@ -692,7 +642,7 @@ PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, for(y=0; y<height; y++) { for(x=0; x<width; x++) { - if ((*bmi & 0x000000ffU) <= (ULONG)nsoption_int(mask_alpha)) maskbit = 0; + if ((*bmi & 0xff000000U) <= (ULONG)nsoption_int(mask_alpha)) maskbit = 0; else maskbit = 1; bmi++; bitmap->native_mask[(y*bpr) + (x/8)] |= @@ -769,8 +719,6 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte BLITA_DestY, 0, TAG_DONE); - ami_bitmap_argb_to_rgba(bitmap); - /**\todo In theory we should be able to move the bitmap to our native area to try to avoid re-conversion (at the expense of memory) */ @@ -818,13 +766,10 @@ static struct gui_bitmap_table bitmap_table = { .destroy = amiga_bitmap_destroy, .set_opaque = amiga_bitmap_set_opaque, .get_opaque = amiga_bitmap_get_opaque, - .test_opaque = amiga_bitmap_test_opaque, .get_buffer = amiga_bitmap_get_buffer, .get_rowstride = amiga_bitmap_get_rowstride, .get_width = bitmap_get_width, .get_height = bitmap_get_height, - .get_bpp = bitmap_get_bpp, - .save = amiga_bitmap_save, .modified = amiga_bitmap_modified, .render = bitmap_render, }; diff --git a/frontends/amiga/bitmap.h b/frontends/amiga/bitmap.h index aaec26ac2..a7dc9198f 100755 --- a/frontends/amiga/bitmap.h +++ b/frontends/amiga/bitmap.h @@ -25,7 +25,9 @@ #include <intuition/classusr.h> #include <libraries/Picasso96.h> -#define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8 +#include "netsurf/bitmap.h" + +#define AMI_BITMAP_FORMAT RGBFB_A8R8G8B8 #define AMI_BITMAP_SCALE_ICON 0xFF extern struct gui_bitmap_table *amiga_bitmap_table; @@ -101,10 +103,10 @@ void ami_bitmap_fini(void); * * \param width width of image in pixels * \param height width of image in pixels - * \param state a flag word indicating the initial state + * \param flags flags for bitmap creation * \return an opaque struct bitmap, or NULL on memory exhaustion */ -void *amiga_bitmap_create(int width, int height, unsigned int state); +void *amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags); /** * Return a pointer to the pixel data in a bitmap. @@ -174,14 +176,6 @@ void amiga_bitmap_modified(void *bitmap); void amiga_bitmap_set_opaque(void *bitmap, bool opaque); /** - * Tests whether a bitmap has an opaque alpha channel - * - * \param bitmap a bitmap, as returned by bitmap_create() - * \return whether the bitmap is opaque - */ -bool amiga_bitmap_test_opaque(void *bitmap); - -/** * Gets whether a bitmap should be plotted opaque * * \param bitmap a bitmap, as returned by bitmap_create() diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c index 27b801540..05a83606e 100644 --- a/frontends/amiga/clipboard.c +++ b/frontends/amiga/clipboard.c @@ -17,6 +17,7 @@ */ #include <stdlib.h> +#include <string.h> #include <proto/iffparse.h> #include <proto/intuition.h> #include <proto/exec.h> @@ -86,14 +87,14 @@ void ami_clipboard_free(void) void gui_start_selection(struct gui_window *g) { if(!g) return; - if(!g->shared->win) return; + if(!ami_gui_get_window(g)) return; if(nsoption_bool(kiosk_mode) == true) return; - ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false); - ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false); + ami_gui_menu_set_disabled(ami_gui_get_window(g), ami_gui_get_menu(g), M_COPY, false); + ami_gui_menu_set_disabled(ami_gui_get_window(g), ami_gui_get_menu(g), M_CLEAR, false); - if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT) - ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false); + if (browser_window_get_editor_flags(ami_gui_get_browser_window(g)) & BW_EDITOR_CAN_CUT) + ami_gui_menu_set_disabled(ami_gui_get_window(g), ami_gui_get_menu(g), M_CUT, false); } static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length) @@ -276,54 +277,54 @@ void ami_drag_selection(struct gui_window *g) if(!gwin) { - DisplayBeep(scrn); + ami_gui_beep(); return; } - x = gwin->win->MouseX; - y = gwin->win->MouseY; + x = ami_gui2_get_window(gwin)->MouseX; + y = ami_gui2_get_window(gwin)->MouseY; if(ami_text_box_at_point(gwin, (ULONG *)&x, (ULONG *)&y)) { iffh = ami_clipboard_init_internal(1); - browser_window_key_press(g->bw, NS_KEY_COPY_SELECTION); - browser_window_mouse_click(gwin->gw->bw, BROWSER_MOUSE_PRESS_1, x, y); - browser_window_key_press(gwin->gw->bw, NS_KEY_PASTE); + browser_window_key_press(ami_gui_get_browser_window(g), NS_KEY_COPY_SELECTION); + browser_window_mouse_click(ami_gui2_get_browser_window(gwin), BROWSER_MOUSE_PRESS_1, x, y); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_PASTE); ami_clipboard_free_internal(iffh); iffh = old_iffh; } else { - x = gwin->win->MouseX; - y = gwin->win->MouseY; + x = ami_gui2_get_window(gwin)->MouseX; + y = ami_gui2_get_window(gwin)->MouseY; - if(ami_gadget_hit(gwin->objects[GID_URL], x, y)) + if(ami_gadget_hit(ami_gui2_get_object(gwin, AMI_GAD_URL), x, y)) { - if((sel = browser_window_get_selection(g->bw))) + if((sel = browser_window_get_selection(ami_gui_get_browser_window(g)))) { utf8text = ami_utf8_easy(sel); - RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL], - gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE); + RefreshSetGadgetAttrs((struct Gadget *)ami_gui2_get_object(gwin, AMI_GAD_URL), + ami_gui2_get_window(gwin), NULL, STRINGA_TextVal, utf8text, TAG_DONE); free(sel); ami_utf8_free(utf8text); } } - else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y)) + else if(ami_gadget_hit(ami_gui2_get_object(gwin, AMI_GAD_SEARCH), x, y)) { - if((sel = browser_window_get_selection(g->bw))) + if((sel = browser_window_get_selection(ami_gui_get_browser_window(g)))) { utf8text = ami_utf8_easy(sel); - RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING], - gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE); + RefreshSetGadgetAttrs((struct Gadget *)ami_gui2_get_object(gwin, AMI_GAD_SEARCH), + ami_gui2_get_window(gwin), NULL, STRINGA_TextVal, utf8text, TAG_DONE); free(sel); ami_utf8_free(utf8text); } } else { - DisplayBeep(scrn); + ami_gui_beep(); } } } @@ -349,15 +350,22 @@ bool ami_easy_clipboard_bitmap(struct bitmap *bitmap) #ifdef WITH_NS_SVG bool ami_easy_clipboard_svg(struct hlcache_handle *c) { - const char *source_data; - ULONG source_size; + const uint8_t *source_data; + size_t source_size; - if(ami_mime_compare(c, "svg") == false) return false; - if((source_data = content_get_source_data(c, &source_size)) == NULL) return false; + if (ami_mime_compare(c, "svg") == false) { + return false; + } + source_data = content_get_source_data(c, &source_size); + if (source_data == NULL) { + return false; + } - if(!(OpenIFF(iffh,IFFF_WRITE))) - { - ami_svg_to_dr2d(iffh, source_data, source_size, nsurl_access(hlcache_handle_get_url(c))); + if (!(OpenIFF(iffh,IFFF_WRITE))) { + ami_svg_to_dr2d(iffh, + (const char *)source_data, + source_size, + nsurl_access(hlcache_handle_get_url(c))); CloseIFF(iffh); } diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c index 45e883fde..441e4003f 100644 --- a/frontends/amiga/cookies.c +++ b/frontends/amiga/cookies.c @@ -310,7 +310,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win) WA_Left, nsoption_int(cookies_window_xpos), WA_Width, nsoption_int(cookies_window_xsize), WA_Height, nsoption_int(cookies_window_ysize), - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | @@ -319,7 +319,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win) WINDOW_IDCMPHook, &ami_cw->idcmp_hook, WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, - WINDOW_SharedPort, sport, + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_HorizProp, 1, WINDOW_VertProp, 1, WINDOW_UserData, cookie_win, @@ -345,7 +345,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win) } /* exported interface documented in amiga/cookies.h */ -nserror ami_cookies_present(void) +nserror ami_cookies_present(const char *search_term) { struct ami_cookie_window *ncwin; nserror res; @@ -385,7 +385,7 @@ nserror ami_cookies_present(void) return res; } - res = cookie_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin); + res = cookie_manager_init((struct core_window *)ncwin); if (res != NSERROR_OK) { ami_utf8_free(ncwin->core.wintitle); DisposeObject(ncwin->core.objects[GID_CW_WIN]); @@ -395,6 +395,10 @@ nserror ami_cookies_present(void) cookie_window = ncwin; - return NSERROR_OK; + if (search_term != NULL) { + res = cookie_manager_set_search_string(search_term); + } + + return res; } diff --git a/frontends/amiga/cookies.h b/frontends/amiga/cookies.h index 6858e4cab..6eb525cbe 100644 --- a/frontends/amiga/cookies.h +++ b/frontends/amiga/cookies.h @@ -20,6 +20,6 @@ #define AMIGA_COOKIES_H /** Open the cookie viewer */ -nserror ami_cookies_present(void); +nserror ami_cookies_present(const char *search_term); #endif diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c index 42ee866ea..5fb77d2f9 100644 --- a/frontends/amiga/corewindow.c +++ b/frontends/amiga/corewindow.c @@ -68,17 +68,19 @@ #include "amiga/utf8.h" static void -ami_cw_scroller_top(struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y) +ami_cw_scroller_top(struct ami_corewindow *ami_cw, + ULONG *restrict x, + ULONG *restrict y) { ULONG xs = 0; ULONG ys = 0; if(ami_cw->scroll_x_visible == true) { - GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs); + GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], &xs); } if(ami_cw->scroll_y_visible == true) { - GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys); + GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], &ys); } *x = xs; @@ -243,15 +245,15 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r) ami_cw_scroller_top(ami_cw, &pos_x, &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 - (LONG)pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x); + if(y - (LONG)pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y); - if(x < pos_x) { + if(x < (LONG)pos_x) { width -= pos_x - x; x = pos_x; } - if(y < pos_y) { + if(y < (LONG)pos_y) { height -= pos_y - y; y = pos_y; } @@ -585,6 +587,7 @@ static void ami_cw_drag_end(struct ami_corewindow *ami_cw, int x, int y) { if(ami_cw->dragging == false) return; + struct Screen *scrn = ami_gui_get_screen(); switch(ami_cw->drag_status) { case CORE_WINDOW_DRAG_SELECTION: @@ -822,16 +825,18 @@ ami_cw_invalidate_area(struct core_window *cw, const struct rect *r) } -static void -ami_cw_get_window_dimensions(struct core_window *cw, int *width, int *height) +static nserror +ami_cw_get_window_dimensions(const struct core_window *cw, + int *width, int *height) { struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw; ami_cw_window_size(ami_cw, width, height); + return NSERROR_OK; } -static void +static nserror ami_cw_update_size(struct core_window *cw, int width, int height) { struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw; @@ -858,70 +863,71 @@ ami_cw_update_size(struct core_window *cw, int width, int height) SCROLLER_Visible, win_h, TAG_DONE); } + return NSERROR_OK; } -static void -ami_cw_scroll_visible(struct core_window *cw, const struct rect *r) +static nserror +ami_cw_get_scroll(const struct core_window *cw, int *x, int *y) { struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw; - - int scrollsetx; - int scrollsety; - int win_w = 0, win_h = 0; ULONG win_x0, win_y0; - int win_x1, win_y1; - - ami_cw_window_size(ami_cw, &win_w, &win_h); ami_cw_scroller_top(ami_cw, &win_x0, &win_y0); - win_x1 = win_x0 + win_w; - win_y1 = win_y0 + win_h; + *x = win_x0; + *y = win_y0; + return NSERROR_OK; +} + - if(r->y1 > win_y1) scrollsety = r->y1 - win_h; - if(r->y0 < win_y0) scrollsety = r->y0; - if(r->x1 > win_x1) scrollsetx = r->x1 - win_w; - if(r->x0 < win_x0) scrollsetx = r->x0; +static nserror +ami_cw_set_scroll(struct core_window *cw, int x, int y) +{ + struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw; if(ami_cw->scroll_y_visible == true) { RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL, - SCROLLER_Top, scrollsety, + SCROLLER_Top, y, TAG_DONE); } if(ami_cw->scroll_x_visible == true) { RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL, - SCROLLER_Top, scrollsetx, + SCROLLER_Top, x, TAG_DONE); } /* probably need to redraw here */ ami_cw_redraw(ami_cw, NULL); + return NSERROR_OK; } -static void +static nserror ami_cw_drag_status(struct core_window *cw, core_window_drag_status ds) { struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw; ami_cw->drag_status = ds; + return NSERROR_OK; } -struct core_window_callback_table ami_cw_cb_table = { +struct core_window_table ami_cw_cb_table = { .invalidate = ami_cw_invalidate_area, - .update_size = ami_cw_update_size, - .scroll_visible = ami_cw_scroll_visible, - .get_window_dimensions = ami_cw_get_window_dimensions, + .set_extent = ami_cw_update_size, + .set_scroll = ami_cw_set_scroll, + .get_scroll = ami_cw_get_scroll, + .get_dimensions = ami_cw_get_window_dimensions, .drag_status = ami_cw_drag_status }; +struct core_window_table *amiga_core_window_table = &ami_cw_cb_table; + /* exported function documented example/corewindow.h */ nserror ami_corewindow_init(struct ami_corewindow *ami_cw) { /* setup the core window callback table */ - ami_cw->cb_table = &ami_cw_cb_table; ami_cw->drag_status = CORE_WINDOW_DRAG_NONE; /* clear some vars */ diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h index ea01f67f1..421397984 100644 --- a/frontends/amiga/corewindow.h +++ b/frontends/amiga/corewindow.h @@ -24,6 +24,8 @@ #include "amiga/gui.h" /* need to know the size of ami_generic_window :( */ #include "amiga/plotters.h" +extern struct core_window_table *amiga_core_window_table; + /** * BOOPSI objects */ @@ -82,9 +84,6 @@ struct ami_corewindow { /** drag status set by core */ core_window_drag_status drag_status; - /** table of callbacks for core window operations */ - struct core_window_callback_table *cb_table; - /** * callback to draw on drawable area of Amiga core window * diff --git a/frontends/amiga/ctxmenu.c b/frontends/amiga/ctxmenu.c index f81e159c8..42826a3a5 100644 --- a/frontends/amiga/ctxmenu.c +++ b/frontends/amiga/ctxmenu.c @@ -107,8 +107,8 @@ HOOKF(void, ami_ctxmenu_item_selcopy, APTR, window, struct IntuiMessage *) { struct gui_window_2 *gwin = (struct gui_window_2 *)hook->h_Data; - browser_window_key_press(gwin->gw->bw, NS_KEY_COPY_SELECTION); - browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_COPY_SELECTION); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_CLEAR_SELECTION); } HOOKF(void, ami_ctxmenu_item_websearch, APTR, window, struct IntuiMessage *) @@ -117,11 +117,11 @@ HOOKF(void, ami_ctxmenu_item_websearch, APTR, window, struct IntuiMessage *) nsurl *url; struct gui_window_2 *gwin = (struct gui_window_2 *)hook->h_Data; - char *sel = browser_window_get_selection(gwin->gw->bw); + char *sel = browser_window_get_selection(ami_gui2_get_browser_window(gwin)); ret = search_web_omni(sel, SEARCH_WEB_OMNI_SEARCHONLY, &url); if (ret == NSERROR_OK) { - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), url, NULL, BW_NAVIGATE_HISTORY, @@ -146,8 +146,8 @@ HOOKF(void, ami_ctxmenu_item_urlopentab, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); nserror error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY | BW_CREATE_TAB, url, - browser_window_access_url(gwin->gw->bw), - gwin->gw->bw, + browser_window_access_url(ami_gui2_get_browser_window(gwin)), + ami_gui2_get_browser_window(gwin), &bw); if (error != NSERROR_OK) @@ -163,8 +163,8 @@ HOOKF(void, ami_ctxmenu_item_urlopenwin, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); nserror error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY, url, - browser_window_access_url(gwin->gw->bw), - gwin->gw->bw, + browser_window_access_url(ami_gui2_get_browser_window(gwin)), + ami_gui2_get_browser_window(gwin), &bw); if (error != NSERROR_OK) @@ -178,9 +178,9 @@ HOOKF(void, ami_ctxmenu_item_urldownload, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), url, - browser_window_access_url(gwin->gw->bw), + browser_window_access_url(ami_gui2_get_browser_window(gwin)), BW_NAVIGATE_DOWNLOAD, NULL, NULL, @@ -198,9 +198,9 @@ HOOKF(void, ami_ctxmenu_item_objshow, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), hlcache_handle_get_url(hook->h_Data), - browser_window_access_url(gwin->gw->bw), + browser_window_access_url(ami_gui2_get_browser_window(gwin)), BW_NAVIGATE_HISTORY, NULL, NULL, @@ -238,9 +238,9 @@ HOOKF(void, ami_ctxmenu_item_frameshow, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), hlcache_handle_get_url(hook->h_Data), - browser_window_access_url(gwin->gw->bw), + browser_window_access_url(ami_gui2_get_browser_window(gwin)), BW_NAVIGATE_HISTORY, NULL, NULL, @@ -271,7 +271,8 @@ HOOKF(void, ami_ctxmenu_item_history, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_history_go(gwin->gw->bw, (struct history_entry *)hook->h_Data, false); + browser_window_history_go(ami_gui2_get_browser_window(gwin), + (struct history_entry *)hook->h_Data, false); } @@ -300,7 +301,7 @@ static uint32 ami_ctxmenu_hook_func(struct Hook *hook, struct Window *window, st Object *root_menu; bool ctxmenu_has_content = false; struct gui_window_2 *gwin = hook->h_Data; - struct hlcache_handle *cc = browser_window_get_content(gwin->gw->bw); + struct hlcache_handle *cc = browser_window_get_content(ami_gui2_get_browser_window(gwin)); struct browser_window_features ccdata; int mx = window->MouseX; int my = window->MouseY; @@ -328,11 +329,11 @@ static uint32 ami_ctxmenu_hook_func(struct Hook *hook, struct Window *window, st return 0; } - browser_window_get_features(gwin->gw->bw, x, y, &ccdata); + browser_window_get_features(ami_gui2_get_browser_window(gwin), x, y, &ccdata); - if((browser_window_can_select(gwin->gw->bw)) && - ((browser_window_get_editor_flags(gwin->gw->bw) & BW_EDITOR_CAN_COPY)) && - (sel = browser_window_get_selection(gwin->gw->bw))) { + if((browser_window_can_select(ami_gui2_get_browser_window(gwin))) && + ((browser_window_get_editor_flags(ami_gui2_get_browser_window(gwin)) & BW_EDITOR_CAN_COPY)) && + (sel = browser_window_get_selection(ami_gui2_get_browser_window(gwin)))) { ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_SELCOPY, gwin); ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_WEBSEARCH, gwin); @@ -401,7 +402,7 @@ static void ami_ctxmenu_alloc_item(int id, const char *label, const char *key, c if(image != NULL) { ctxmenu_item_image[id] = BitMapObj, - BITMAP_Screen, scrn, + BITMAP_Screen, ami_gui_get_screen(), BITMAP_SourceFile, image, BITMAP_Masking, TRUE, BitMapEnd; @@ -498,15 +499,15 @@ void ami_ctxmenu_init(void) static bool ami_ctxmenu_history(int direction, struct gui_window_2 *gwin, const struct history_entry *entry) { Object *history_root; - int id = AMI_CTX_ID_HISTORY0 + gwin->temp; + int id = AMI_CTX_ID_HISTORY0 + ami_gui2_get_ctxmenu_history_tmp(gwin); if(direction == AMI_CTXMENU_HISTORY_FORWARD) id += 10; - if(gwin->temp >= 10) return false; + if(ami_gui2_get_ctxmenu_history_tmp(gwin) >= 10) return false; ctxmenu_item_hook[id].h_Entry = (HOOKFUNC)ami_ctxmenu_item_history; ctxmenu_item_hook[id].h_Data = (APTR)entry; - history_root = (Object *)IDoMethod(gwin->history_ctxmenu[direction], MM_FINDID, 0, AMI_CTX_ID_HISTORY); + history_root = (Object *)IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), MM_FINDID, 0, AMI_CTX_ID_HISTORY); IDoMethod(history_root, OM_ADDMEMBER, MStrip, MA_Type, T_ITEM, @@ -517,7 +518,7 @@ static bool ami_ctxmenu_history(int direction, struct gui_window_2 *gwin, const MA_UserData, &ctxmenu_item_hook[id], MEnd); - gwin->temp++; + ami_gui2_set_ctxmenu_history_tmp(gwin, ami_gui2_get_ctxmenu_history_tmp(gwin) + 1); return true; } @@ -543,11 +544,11 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin { Object *obj; - if(gwin->history_ctxmenu[direction] == NULL) { + if(ami_gui2_get_ctxmenu_history(gwin, direction) == NULL) { if(ctxmenu_item_label[AMI_CTX_ID_HISTORY] == NULL) ctxmenu_item_label[AMI_CTX_ID_HISTORY] = ami_utf8_easy(messages_get("History")); - gwin->history_ctxmenu[direction] = MStrip, + obj = MStrip, MA_Type, T_ROOT, MA_AddChild, MStrip, MA_Type, T_MENU, @@ -557,23 +558,26 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin //MA_FreeImage, FALSE, MEnd, MEnd; + + ami_gui2_set_ctxmenu_history(gwin, direction, obj); + } else { for (int i = 0; i < 20; i++) { - obj = (Object *)IDoMethod(gwin->history_ctxmenu[direction], + obj = (Object *)IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), MM_FINDID, 0, AMI_CTX_ID_HISTORY0 + i); - if(obj != NULL) IDoMethod(gwin->history_ctxmenu[direction], OM_REMMEMBER, obj); + if(obj != NULL) IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), OM_REMMEMBER, obj); } - gwin->temp = 0; + ami_gui2_set_ctxmenu_history_tmp(gwin, 0); if(direction == AMI_CTXMENU_HISTORY_BACK) { - browser_window_history_enumerate_back(gwin->gw->bw, ami_ctxmenu_history_back, gwin); + browser_window_history_enumerate_back(ami_gui2_get_browser_window(gwin), ami_ctxmenu_history_back, gwin); } else { - browser_window_history_enumerate_forward(gwin->gw->bw, ami_ctxmenu_history_forward, gwin); + browser_window_history_enumerate_forward(ami_gui2_get_browser_window(gwin), ami_ctxmenu_history_forward, gwin); } } - return (struct Menu *)gwin->history_ctxmenu[direction]; + return (struct Menu *)ami_gui2_get_ctxmenu_history(gwin, direction); } @@ -582,13 +586,16 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin **************************/ /** Exported interface documented in ctxmenu.h **/ -struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin) +struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin, Object **clicktab_obj) { Object *root_menu; + Object *clicktab; - if(gwin->clicktab_ctxmenu != NULL) return (struct Menu *)gwin->clicktab_ctxmenu; + if(*clicktab_obj != NULL) { + return (struct Menu *)*clicktab_obj; + } - gwin->clicktab_ctxmenu = MStrip, + clicktab = MStrip, MA_Type, T_ROOT, MA_AddChild, root_menu = MStrip, MA_Type, T_MENU, @@ -597,10 +604,12 @@ struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin) MEnd, MEnd; + *clicktab_obj = clicktab; + ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABNEW, gwin); ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABCLOSE_OTHER, gwin); - return (struct Menu *)gwin->clicktab_ctxmenu; + return (struct Menu *)clicktab; } diff --git a/frontends/amiga/ctxmenu.h b/frontends/amiga/ctxmenu.h index 08a5fe582..76beff5b0 100644 --- a/frontends/amiga/ctxmenu.h +++ b/frontends/amiga/ctxmenu.h @@ -75,10 +75,11 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin * Create ClickTab context menu * * \param gwin struct gui_window_2 * - * \returns pointer to menu (for convenience, is also stored in gwin structure) + * \param clicktab_obj ptr to memory to hold clicktab menu object + * \returns pointer to menu (for convenience) * The returned pointer MUST be disposed of with DisposeObject before program exit. */ -struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin); +struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin, Object **clicktab_obj); #else //__amigaos4__ inline void ami_ctxmenu_init(void) {} @@ -86,7 +87,7 @@ inline void ami_ctxmenu_free(void) {} inline struct Hook *ami_ctxmenu_get_hook(APTR data) {return NULL;} inline void ami_ctxmenu_release_hook(struct Hook *hook) {} inline struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin) {return NULL;} -inline struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin) {return NULL;} +inline struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin, Object **clicktab_obj) {return NULL;} #endif //__amigaos4__ #endif //AMIGA_CTXMENU_H diff --git a/frontends/amiga/dist/Rexx/YT_download_page.nsrx b/frontends/amiga/dist/Rexx/YT_download_page.nsrx new file mode 100644 index 000000000..fdc06923d --- /dev/null +++ b/frontends/amiga/dist/Rexx/YT_download_page.nsrx @@ -0,0 +1,21 @@ +/* YT play.nsrx by Chris Handley + This script shows download links for a YouTube video using YT (OS4Depot:video/misc/yt.lha) +*/ + +options results + +if ~open('yt','AppDir:YT','R') then do + GETSCREENNAME + address command 'requestchoice >NIL: "NetSurf" "YT must be installed for this script to function.*n*nIt can be downloaded from OS4Depot:video/misc/yt" "OK" PubScreen='||result + OPEN 'http://os4depot.net/?function=showfile&file=video/misc/yt.lha' NEWTAB ACTIVE /* This doesn't work due to a NetSurf(?) bug */ + exit +end +close('yt') + +GETURL +/*address command 'requestchoice >NIL: "TEST" "'||result||'" "OK"'*/ +address command 'AppDir:YT <>CON:0/30/640/256/YT/AUTO/CLOSE "'||result||'" html silent' + +/* Hack to activate the newest tab */ +OPEN 'file:///RAM:' NEWTAB ACTIVE +CLOSE diff --git a/frontends/amiga/dist/Rexx/YT_open.nsrx b/frontends/amiga/dist/Rexx/YT_open.nsrx new file mode 100644 index 000000000..4454f0c29 --- /dev/null +++ b/frontends/amiga/dist/Rexx/YT_open.nsrx @@ -0,0 +1,21 @@ +/* YT play.nsrx by Chris Handley + This script opens a YouTube video using YT (OS4Depot:video/misc/yt.lha) +*/ + +options results + +if ~open('yt','AppDir:YT','R') then do + GETSCREENNAME + address command 'requestchoice >NIL: "NetSurf" "YT must be installed for this script to function.*n*nIt can be downloaded from OS4Depot:video/misc/yt" "OK" PubScreen='||result + OPEN 'http://os4depot.net/?function=showfile&file=video/misc/yt.lha' NEWTAB ACTIVE /* This doesn't work due to a NetSurf(?) bug */ + exit +end +close('yt') + +address COMMAND 'Run >NIL: RequestChoice Title="NetSurf" BODY="When finished with YT, click OK to return to NetSurf" GADGETS="OK" INACTIVE >NIL:' /* Hack to get Workbench to front */ + +GETURL +/*address command 'requestchoice >NIL: "TEST" "'||result||'" "OK"'*/ +address command 'AppDir:YT <>CON:0/30/640/256/YT/AUTO/CLOSE "'||result||'"' + +/*TOBACK*/ /* ideally we'd bring Workbench to front */ diff --git a/frontends/amiga/dist/Rexx/YT_play.nsrx b/frontends/amiga/dist/Rexx/YT_play.nsrx new file mode 100644 index 000000000..a8e29162f --- /dev/null +++ b/frontends/amiga/dist/Rexx/YT_play.nsrx @@ -0,0 +1,19 @@ +/* YT play.nsrx by Chris Handley + This script auto-plays a YouTube video using YT (OS4Depot:video/misc/yt.lha) +*/ + +options results + +if ~open('yt','AppDir:YT','R') then do + GETSCREENNAME + address command 'requestchoice >NIL: "NetSurf" "YT must be installed for this script to function.*n*nIt can be downloaded from OS4Depot:video/misc/yt" "OK" PubScreen='||result + OPEN 'http://os4depot.net/?function=showfile&file=video/misc/yt.lha' NEWTAB ACTIVE /* This doesn't work due to a NetSurf(?) bug */ + exit +end +close('yt') + +GETURL +/*address command 'requestchoice >NIL: "TEST" "'||result||'" "OK"'*/ +address command 'AppDir:YT <>CON:0/30/640/256/YT/AUTO/CLOSE "'||result||'" AutoPlay' + +/*TOBACK*/ /* ideally we'd bring Workbench to front */ diff --git a/frontends/amiga/download.c b/frontends/amiga/download.c index 895d92903..cb9e99785 100644 --- a/frontends/amiga/download.c +++ b/frontends/amiga/download.c @@ -132,8 +132,8 @@ static struct gui_download_window *gui_download_window_create(download_context * dw = calloc(1, sizeof(struct gui_download_window)); - if(gui && (!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url))) - { + if(gui && (!IsListEmpty(ami_gui_get_download_list(gui)) && + (dw->dln = (struct dlnode *)FindName(ami_gui_get_download_list(gui), url)))) { strcpy(dw->fname, dw->dln->filename); free(dw->dln->node.ln_Name); dw->dln->node.ln_Name = NULL; @@ -141,16 +141,16 @@ static struct gui_download_window *gui_download_window_create(download_context * else { if(AslRequestTags(savereq, - ASLFR_Window, gui->shared->win, + ASLFR_Window, ami_gui_get_window(gui), ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, dl_filename, TAG_DONE)) { strlcpy(dw->fname, savereq->fr_Drawer, 1024); AddPart((STRPTR)&dw->fname,savereq->fr_File,1024); - if(!ami_download_check_overwrite(dw->fname, gui->shared->win, total_size)) + if(!ami_download_check_overwrite(dw->fname, ami_gui_get_window(gui), total_size)) { free(dw); return NULL; @@ -166,7 +166,7 @@ static struct gui_download_window *gui_download_window_create(download_context * if(dl_filename) ami_utf8_free(dl_filename); dw->size = total_size; dw->downloaded = 0; - if(gui) dw->bw = gui->bw; + if(gui) dw->bw = ami_gui_get_browser_window(gui); dw->url = url; va[0] = (APTR)dw->downloaded; @@ -199,8 +199,8 @@ static struct gui_download_window *gui_download_window_create(download_context * WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen,scrn, - WINDOW_SharedPort,sport, + WA_PubScreen, ami_gui_get_screen(), + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_UserData,dw, WINDOW_IconifyGadget, FALSE, WINDOW_LockHeight,TRUE, @@ -434,19 +434,19 @@ gui_window_save_link(struct gui_window *g, nsurl *url, const char *title) linkname = ASPrintf("Link_to_%s",FilePart(nsurl_access(url))); if(AslRequestTags(savereq, - ASLFR_Window, g->shared->win, + ASLFR_Window, ami_gui_get_window(g), ASLFR_SleepWindow, TRUE, ASLFR_TitleText,messages_get("NetSurf"), - ASLFR_Screen,scrn, - ASLFR_InitialFile,linkname, + ASLFR_Screen, ami_gui_get_screen(), + ASLFR_InitialFile, linkname, TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); AddPart(fname,savereq->fr_File,1024); - ami_set_pointer(g->shared, GUI_POINTER_WAIT, false); + ami_set_pointer(ami_gui_get_gui_window_2(g), GUI_POINTER_WAIT, false); - if(ami_download_check_overwrite(fname, g->shared->win, 0)) + if(ami_download_check_overwrite(fname, ami_gui_get_window(g), 0)) { BPTR fh; @@ -473,7 +473,7 @@ gui_window_save_link(struct gui_window *g, nsurl *url, const char *title) } FreeVec(linkname); } - ami_reset_pointer(g->shared); + ami_reset_pointer(ami_gui_get_gui_window_2(g)); } return NSERROR_OK; } diff --git a/frontends/amiga/drag.c b/frontends/amiga/drag.c index ec0ee3c6a..907d8f865 100644 --- a/frontends/amiga/drag.c +++ b/frontends/amiga/drag.c @@ -24,7 +24,6 @@ #include <proto/intuition.h> #include <proto/utility.h> #include <proto/icon.h> -#include <proto/layers.h> #include <graphics/blitattr.h> #include <workbench/icon.h> @@ -89,7 +88,7 @@ void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c, break; } - ami_drag_icon_show(g->shared->win, filetype); + ami_drag_icon_show(ami_gui_get_window(g), filetype); drag_save_data = c; drag_save_gui = g; @@ -98,7 +97,7 @@ void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c, void gui_drag_save_selection(struct gui_window *g, const char *selection) { - ami_drag_icon_show(g->shared->win, "ascii"); + ami_drag_icon_show(ami_gui_get_window(g), "ascii"); ami_autoscroll = true; drag_save_data = g; @@ -109,6 +108,7 @@ void ami_drag_save(struct Window *win) { ULONG which = WBO_NONE, type; char path[1025], dpath[1025]; + struct Screen *scrn = ami_gui_get_screen(); path[0] = 0; /* ensure path is terminated */ @@ -134,7 +134,7 @@ void ami_drag_save(struct Window *win) { if(drag_save == GUI_SAVE_TEXT_SELECTION) ami_drag_selection((struct gui_window *)drag_save_data); - else DisplayBeep(scrn); + else ami_gui_beep(); drag_save = 0; drag_save_data = NULL; @@ -143,7 +143,7 @@ void ami_drag_save(struct Window *win) if(path[0] == '\0') { - DisplayBeep(scrn); + ami_gui_beep(); drag_save = 0; drag_save_data = NULL; return; @@ -166,7 +166,7 @@ void ami_drag_save(struct Window *win) case GUI_SAVE_TEXT_SELECTION: // selection AddPart(path,"netsurf_text_selection",1024); struct gui_window *g = (struct gui_window *) drag_save_data; - ami_file_save(AMINS_SAVE_SELECTION, path, win, NULL, NULL, g->bw); + ami_file_save(AMINS_SAVE_SELECTION, path, win, NULL, NULL, ami_gui_get_browser_window(g)); break; case GUI_SAVE_COMPLETE: @@ -174,7 +174,7 @@ void ami_drag_save(struct Window *win) struct hlcache_handle *c = drag_save_data; AddPart(path, content_get_title(c), 1024); - ami_file_save(AMINS_SAVE_COMPLETE, path, win, c, drag_save_gui->favicon, NULL); + ami_file_save(AMINS_SAVE_COMPLETE, path, win, c, ami_gui_get_favicon(drag_save_gui), NULL); } break; @@ -204,7 +204,7 @@ void ami_drag_icon_show(struct Window *win, const char *type) struct DiskObject *dobj = NULL; ULONG width, height; int deftype = WBPROJECT; - + struct Screen *scrn = ami_gui_get_screen(); drag_in_progress = TRUE; if(nsoption_bool(drag_save_icons) == false) @@ -255,6 +255,7 @@ void ami_drag_icon_show(struct Window *win, const char *type) bool ami_drag_icon_move(void) { if(drag_icon == NULL) return FALSE; + struct Screen *scrn = ami_gui_get_screen(); ChangeWindowBox(drag_icon, scrn->MouseX - (drag_icon_width / 2), scrn->MouseY - (drag_icon_height / 2), @@ -288,44 +289,9 @@ bool ami_drag_has_data(void) else return false; } -static void *ami_find_gwin_by_id(struct Window *win, uint32 type) -{ - struct nsObject *node, *nnode; - struct gui_window_2 *gwin; - - if(!IsMinListEmpty(window_list)) - { - node = (struct nsObject *)GetHead((struct List *)window_list); - - do - { - nnode=(struct nsObject *)GetSucc((struct Node *)node); - - if(node->Type == type) - { - gwin = node->objstruct; - if(win == gwin->win) return gwin; - } - } while((node = nnode)); - } - return NULL; -} - -void *ami_window_at_pointer(int type) -{ - struct Layer *layer; - - LockLayerInfo(&scrn->LayerInfo); - - layer = WhichLayer(&scrn->LayerInfo, scrn->MouseX, scrn->MouseY); - - UnlockLayerInfo(&scrn->LayerInfo); - - if(layer) return ami_find_gwin_by_id(layer->Window, type); - else return NULL; -} - #else +#include <stddef.h> + #include "utils/errors.h" #include "amiga/drag.h" @@ -364,10 +330,5 @@ bool ami_drag_has_data(void) { return false; } - -void *ami_window_at_pointer(int type) -{ - return NULL; -} #endif diff --git a/frontends/amiga/drag.h b/frontends/amiga/drag.h index c0b040f72..1a546682c 100644 --- a/frontends/amiga/drag.h +++ b/frontends/amiga/drag.h @@ -35,8 +35,5 @@ void ami_drag_icon_close(struct Window *win); bool ami_drag_icon_move(void); BOOL ami_drag_in_progress(void); bool ami_drag_has_data(void); - -void *ami_window_at_pointer(int type); - #endif diff --git a/frontends/amiga/dt_anim.c b/frontends/amiga/dt_anim.c index bd049206c..1162d7214 100644 --- a/frontends/amiga/dt_anim.c +++ b/frontends/amiga/dt_anim.c @@ -40,7 +40,9 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "netsurf/content.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/llcache.h" #include "amiga/bitmap.h" @@ -72,9 +74,9 @@ static void amiga_dt_anim_destroy(struct content *c); static bool amiga_dt_anim_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx); -static void amiga_dt_anim_open(struct content *c, struct browser_window *bw, +static nserror amiga_dt_anim_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params); -static void amiga_dt_anim_close(struct content *c); +static nserror amiga_dt_anim_close(struct content *c); static nserror amiga_dt_anim_clone(const struct content *old, struct content **newc); static content_type amiga_dt_anim_content_type(void); @@ -167,15 +169,15 @@ bool amiga_dt_anim_convert(struct content *c) amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c; union content_msg_data msg_data; int width, height; - const uint8 *data; + const uint8_t *data; + size_t size; UBYTE *bm_buffer; - ULONG size; struct BitMapHeader *bmh; - unsigned int bm_flags = BITMAP_NEW | BITMAP_OPAQUE; + unsigned int bm_flags = BITMAP_OPAQUE; struct adtFrame adt_frame; APTR clut; - data = (uint8 *)content__get_source_data(c, &size); + data = content__get_source_data(c, &size); if((plugin->dto = NewDTObject(NULL, DTA_SourceType, DTST_MEMORY, @@ -189,7 +191,8 @@ bool amiga_dt_anim_convert(struct content *c) plugin->bitmap = amiga_bitmap_create(width, height, bm_flags); if (!plugin->bitmap) { - msg_data.error = messages_get("NoMemory"); + msg_data.errordata.errorcode = NSERROR_NOMEM; + msg_data.errordata.errormsg = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -287,18 +290,18 @@ bool amiga_dt_anim_redraw(struct content *c, * \param box box containing c, or 0 if not an object * \param params object parameters, or 0 if not an object */ -void amiga_dt_anim_open(struct content *c, struct browser_window *bw, +nserror amiga_dt_anim_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params) { NSLOG(netsurf, INFO, "amiga_dt_anim_open"); - return; + return NSERROR_OK; } -void amiga_dt_anim_close(struct content *c) +nserror amiga_dt_anim_close(struct content *c) { NSLOG(netsurf, INFO, "amiga_dt_anim_close"); - return; + return NSERROR_OK; } void amiga_dt_anim_reformat(struct content *c, int width, int height) diff --git a/frontends/amiga/dt_picture.c b/frontends/amiga/dt_picture.c index 88ce1c834..e13790d5c 100644 --- a/frontends/amiga/dt_picture.c +++ b/frontends/amiga/dt_picture.c @@ -25,6 +25,7 @@ #include <stdbool.h> #include <stdlib.h> +#include <string.h> #include <proto/datatypes.h> #include <proto/dos.h> #include <proto/intuition.h> @@ -36,7 +37,9 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "content/llcache.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/handlers/image/image_cache.h" #include "amiga/bitmap.h" @@ -131,11 +134,11 @@ nserror amiga_dt_picture_create(const content_handler *handler, static Object *amiga_dt_picture_newdtobject(struct amiga_dt_picture_content *adt) { - const uint8 *data; - ULONG size; + const uint8_t *data; + size_t size; if(adt->dto == NULL) { - data = (uint8 *)content__get_source_data((struct content *)adt, &size); + data = content__get_source_data((struct content *)adt, &size); adt->dto = NewDTObject(NULL, DTA_SourceType, DTST_MEMORY, @@ -152,12 +155,12 @@ static Object *amiga_dt_picture_newdtobject(struct amiga_dt_picture_content *adt static char *amiga_dt_picture_datatype(struct content *c) { - const uint8 *data; - ULONG size; + const uint8_t *data; + size_t size; struct DataType *dt; char *filetype = NULL; - data = (uint8 *)content__get_source_data(c, &size); + data = content__get_source_data(c, &size); if((dt = ObtainDataType(DTST_MEMORY, NULL, DTA_SourceAddress, data, @@ -184,9 +187,10 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c) if((dto = amiga_dt_picture_newdtobject(adt))) { - bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NEW); + bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NONE); if (!bitmap) { - msg_data.error = messages_get("NoMemory"); + msg_data.errordata.errorcode = NSERROR_NOMEM; + msg_data.errordata.errormsg = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return NULL; } @@ -198,7 +202,7 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c) amiga_bitmap_get_rowstride(bitmap), 0, 0, c->width, c->height); - amiga_bitmap_set_opaque(bitmap, amiga_bitmap_test_opaque(bitmap)); + amiga_bitmap_set_opaque(bitmap, bitmap_test_opaque(bitmap)); DisposeDTObject(dto); adt->dto = NULL; diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c index f3b365ddb..16b4f7c62 100644 --- a/frontends/amiga/dt_sound.c +++ b/frontends/amiga/dt_sound.c @@ -23,6 +23,8 @@ #ifdef WITH_AMIGA_DATATYPES #include "amiga/os3support.h" +#include <string.h> + #include <proto/datatypes.h> #include <proto/dos.h> #include <proto/intuition.h> @@ -36,6 +38,7 @@ #include "html/box.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "amiga/filetype.h" #include "amiga/datatypes.h" @@ -57,7 +60,7 @@ static void amiga_dt_sound_destroy(struct content *c); static bool amiga_dt_sound_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx); -static void amiga_dt_sound_open(struct content *c, struct browser_window *bw, +static nserror amiga_dt_sound_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params); static nserror amiga_dt_sound_clone(const struct content *old, struct content **newc); static content_type amiga_dt_sound_content_type(void); @@ -150,10 +153,10 @@ bool amiga_dt_sound_convert(struct content *c) amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c; int width = 50, height = 50; - const uint8 *data; - ULONG size; + const uint8_t *data; + size_t size; - data = (uint8 *)content__get_source_data(c, &size); + data = content__get_source_data(c, &size); plugin->dto = NewDTObject(NULL, DTA_SourceType, DTST_MEMORY, @@ -220,7 +223,7 @@ bool amiga_dt_sound_redraw(struct content *c, } -void amiga_dt_sound_open(struct content *c, struct browser_window *bw, +nserror amiga_dt_sound_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params) { amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c; @@ -247,7 +250,7 @@ void amiga_dt_sound_open(struct content *c, struct browser_window *bw, if(plugin->dto && (plugin->immediate == true)) amiga_dt_sound_play(plugin->dto); - return; + return NSERROR_OK; } diff --git a/frontends/amiga/file.c b/frontends/amiga/file.c index 0fd43781d..79acb1a21 100644 --- a/frontends/amiga/file.c +++ b/frontends/amiga/file.c @@ -22,6 +22,8 @@ #include <proto/icon.h> #include <workbench/icon.h> +#include <string.h> + #include "utils/utils.h" #include "utils/nsoption.h" #include "utils/file.h" @@ -29,6 +31,7 @@ #include "utils/nsurl.h" #include "netsurf/browser_window.h" #include "netsurf/content.h" +#include "content/content_factory.h" #include "desktop/save_complete.h" #include "desktop/save_pdf.h" #include "desktop/save_text.h" @@ -84,9 +87,9 @@ void ami_file_open(struct gui_window_2 *gwin) if(AslRequestTags(filereq, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Window, gwin->win, + ASLFR_Window, ami_gui2_get_window(gwin), ASLFR_SleepWindow, TRUE, - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_DoSaveMode, FALSE, ASLFR_RejectIcons, TRUE, ASLFR_FilterFunc, &aslhookfunc, @@ -100,7 +103,7 @@ void ami_file_open(struct gui_window_2 *gwin) if (netsurf_path_to_nsurl(temp, &url) != NSERROR_OK) { amiga_warn_user("NoMemory", 0); } else { - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), url, NULL, BW_NAVIGATE_HISTORY, @@ -146,8 +149,9 @@ void ami_file_save(int type, char *fname, struct Window *win, struct browser_window *bw) { BPTR lock, fh; - const char *source_data; - ULONG source_size; + const uint8_t *source_data; + char *selection; + size_t source_size; struct bitmap *bm; ami_update_pointer(win, GUI_POINTER_WAIT); @@ -155,7 +159,8 @@ void ami_file_save(int type, char *fname, struct Window *win, if(ami_download_check_overwrite(fname, win, 0)) { switch(type) { case AMINS_SAVE_SOURCE: - if((source_data = content_get_source_data(object, &source_size))) { + source_data = content_get_source_data(object, &source_size); + if(source_data) { BPTR fh; if((fh = FOpen(fname, MODE_NEWFILE,0))) { FWrite(fh, source_data, 1, source_size); @@ -197,12 +202,17 @@ void ami_file_save(int type, char *fname, struct Window *win, break; case AMINS_SAVE_SELECTION: - if((source_data = browser_window_get_selection(bw))) { - if((fh = FOpen(fname, MODE_NEWFILE,0))) { - FWrite(fh, source_data, 1, strlen(source_data)); + selection = browser_window_get_selection(bw); + if(selection) { + fh = FOpen(fname, MODE_NEWFILE,0); + if (fh) { + FWrite(fh, + selection, + 1, + strlen(selection)); FClose(fh); } - free((void *)source_data); + free(selection); } break; } @@ -250,17 +260,18 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin, } if(AslRequestTags(savereq, - ASLFR_Window, gwin->win, + ASLFR_Window, ami_gui2_get_window(gwin), ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, fname_with_ext ? fname_with_ext : "", TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); AddPart(fname, savereq->fr_File, 1024); - ami_file_save(type, fname, gwin->win, object, gwin->gw->favicon, gwin->gw->bw); + ami_file_save(type, fname, ami_gui2_get_window(gwin), object, + ami_gui_get_favicon(ami_gui2_get_gui_window(gwin)), ami_gui2_get_browser_window(gwin)); } if(fname) free(fname); diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c index e69ff55f0..65e791416 100644 --- a/frontends/amiga/font.c +++ b/frontends/amiga/font.c @@ -24,7 +24,7 @@ #include "utils/log.h" #include "utils/nsoption.h" -#include "netsurf/browser_window.h" +#include "netsurf/browser.h" #include "netsurf/layout.h" #include "amiga/font.h" diff --git a/frontends/amiga/font_bullet.c b/frontends/amiga/font_bullet.c index 62c2dde08..43f7b9488 100644 --- a/frontends/amiga/font_bullet.c +++ b/frontends/amiga/font_bullet.c @@ -1,5 +1,5 @@ /* - * Copyright 2008 - 2016 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008 - 2019 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -82,7 +82,7 @@ const uint16 sc_table[] = { 0x006E, 0x0274, /* n */ 0x006F, 0x1D0F, /* o */ 0x0070, 0x1D18, /* p */ - 0x0071, 0xA7EE, /* q (proposed) (Adobe codepoint 0xF771) */ + 0x0071, 0xA7AF, /* q */ 0x0072, 0x0280, /* r */ 0x0073, 0xA731, /* s */ 0x0074, 0x1D1B, /* t */ @@ -169,7 +169,9 @@ static nserror amiga_nsfont_width(const plot_font_style_t *fstyle, { *width = ami_font_unicode_width(string, length, fstyle, 0, 0, false); - if(*width <= 0) *width == length; // fudge + if(*width <= 0) { + *width = length; /* fudge */ + } return NSERROR_OK; } @@ -347,6 +349,11 @@ static nserror amiga_nsfont_split(const plot_font_style_t *fstyle, */ static struct ami_font_cache_node *ami_font_open(const char *font, bool critical) { + if(font == NULL) { + NSLOG(netsurf, INFO, "Requested NULL font"); + return NULL; + } + struct ami_font_cache_node *nodedata = ami_font_cache_locate(font); if(nodedata) return nodedata; @@ -547,6 +554,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo FIXED kern = 0; ULONG glyphmaptag; ULONG template_type; + bool skip_c2 = false; uint32 long_char_1 = 0, long_char_2 = 0; #ifndef __amigaos4__ struct BulletBase *BulletBase = ofont->BulletBase; @@ -564,6 +572,8 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo } #endif + if (*char2 < 0x0020) skip_c2 = true; + #ifdef __amigaos4__ if(__builtin_expect(aa == true, 1)) { glyphmaptag = OT_GlyphMap8Bit; @@ -626,7 +636,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo kern = 0; - if(*char2) EObtainInfo(AMI_OFONT_ENGINE, + if((*char2) && (!skip_c2)) EObtainInfo(AMI_OFONT_ENGINE, OT_TextKernPair, &kern, TAG_END); @@ -636,7 +646,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo glyphmaptag, glyph, TAG_END); - if(*char2) EReleaseInfo(AMI_OFONT_ENGINE, + if((*char2) && (!skip_c2)) EReleaseInfo(AMI_OFONT_ENGINE, OT_TextKernPair, kern, TAG_END); } diff --git a/frontends/amiga/font_diskfont.c b/frontends/amiga/font_diskfont.c index a587d6eaf..be1b89194 100644 --- a/frontends/amiga/font_diskfont.c +++ b/frontends/amiga/font_diskfont.c @@ -100,7 +100,10 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_st tattr.ta_YSize = fstyle->size / PLOT_STYLE_SCALE; NSLOG(netsurf, INFO, "font: %s/%d", tattr.ta_Name, tattr.ta_YSize); - if(prev_font != NULL) CloseFont(prev_font); + if(prev_font != NULL) { + CloseFont(prev_font); + prev_font = NULL; + } if((bmfont = OpenDiskFont(&tattr))) { SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE); @@ -300,7 +303,14 @@ void ami_font_diskfont_init(void) void ami_font_diskfont_fini(void) { - if(prev_font != NULL) CloseFont(prev_font); - if(prev_fstyle != NULL) free(prev_fstyle); + if(prev_font != NULL) { + CloseFont(prev_font); + prev_font = NULL; + } + + if(prev_fstyle != NULL) { + free(prev_fstyle); + prev_fstyle = NULL; + } } diff --git a/frontends/amiga/font_scan.c b/frontends/amiga/font_scan.c index cb37f97fa..3fa71f737 100644 --- a/frontends/amiga/font_scan.c +++ b/frontends/amiga/font_scan.c @@ -114,7 +114,7 @@ static struct ami_font_scan_window *ami_font_scan_gui_open(int32 fonts) WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_BusyPointer, TRUE, WA_Width, 400, WINDOW_UserData, fsw, diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index e08ef5962..7c5e1160d 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-2016 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008-2024 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -36,10 +36,17 @@ #include <proto/icon.h> #include <proto/intuition.h> #include <proto/keymap.h> +#include <proto/layers.h> #include <proto/locale.h> #include <proto/utility.h> #include <proto/wb.h> +#ifdef WITH_AMISSL +/* AmiSSL needs everything to use bsdsocket.library directly to avoid problems */ +#include <proto/bsdsocket.h> +#define waitselect WaitSelect +#endif + /* Other OS includes */ #include <datatypes/textclass.h> #include <devices/inputevent.h> @@ -65,6 +72,7 @@ #include <proto/clicktab.h> #include <proto/label.h> #include <proto/layout.h> +#include <proto/listbrowser.h> #include <proto/scroller.h> #include <proto/space.h> #include <proto/speedbar.h> @@ -76,6 +84,7 @@ #include <gadgets/chooser.h> #include <gadgets/clicktab.h> #include <gadgets/layout.h> +#include <gadgets/listbrowser.h> #include <gadgets/scroller.h> #include <gadgets/space.h> #include <gadgets/speedbar.h> @@ -139,11 +148,11 @@ #include "amiga/icon.h" #include "amiga/launch.h" #include "amiga/libs.h" -#include "amiga/login.h" #include "amiga/memory.h" #include "amiga/menu.h" #include "amiga/misc.h" #include "amiga/nsoption.h" +#include "amiga/pageinfo.h" #include "amiga/plotters.h" #include "amiga/plugin_hack.h" #include "amiga/print.h" @@ -152,7 +161,7 @@ #include "amiga/selectmenu.h" #include "amiga/theme.h" #include "amiga/utf8.h" -#include "amiga/sslcert.h" +#include "amiga/corewindow.h" #define AMINS_SCROLLERPEN NUMDRIPENS #define NSA_KBD_SCROLL_PX 10 @@ -187,16 +196,137 @@ extern struct gui_utf8_table *amiga_utf8_table; +enum +{ + OID_MAIN = 0, + OID_VSCROLL, + OID_HSCROLL, + GID_MAIN, + GID_TABLAYOUT, + GID_BROWSER, + GID_STATUS, + GID_URL, + GID_ICON, + GID_STOP, + GID_RELOAD, + GID_HOME, + GID_BACK, + GID_FORWARD, + GID_THROBBER, + GID_SEARCH_ICON, + GID_PAGEINFO, + GID_PAGEINFO_INSECURE_BM, + GID_PAGEINFO_INTERNAL_BM, + GID_PAGEINFO_LOCAL_BM, + GID_PAGEINFO_SECURE_BM, + GID_PAGEINFO_WARNING_BM, + GID_FAVE, + GID_FAVE_ADD, + GID_FAVE_RMV, + GID_CLOSETAB, + GID_CLOSETAB_BM, + GID_ADDTAB, + GID_ADDTAB_BM, + GID_TABS, + GID_TABS_FLAG, + GID_SEARCHSTRING, + GID_TOOLBARLAYOUT, + GID_HOTLIST, + GID_HOTLISTLAYOUT, + GID_HOTLISTSEPBAR, + GID_HSCROLL, + GID_HSCROLLLAYOUT, + GID_VSCROLL, + GID_VSCROLLLAYOUT, + GID_LOGLAYOUT, + GID_LOG, + GID_LAST +}; + +struct gui_window_2 { + struct ami_generic_window w; + struct Window *win; + Object *restrict objects[GID_LAST]; + struct gui_window *gw; /* currently-displayed gui_window */ + bool redraw_required; + int throbber_frame; + struct List tab_list; + ULONG tabs; + ULONG next_tab; + struct Node *last_new_tab; + struct Hook scrollerhook; + browser_mouse_state mouse_state; + browser_mouse_state key_state; + ULONG throbber_update_count; + struct find_window *searchwin; + ULONG oldh; + ULONG oldv; + int temp; + bool redraw_scroll; + bool new_content; + struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1]; /* only for GadTools menus */ + ULONG hotlist_items; + Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX]; + struct List hotlist_toolbar_list; + struct List *web_search_list; + Object *search_bm; + char *restrict svbuffer; + char *restrict status; + char *restrict wintitle; + char *restrict helphints[GID_LAST]; + browser_mouse_state prev_mouse_state; + struct timeval lastclick; + struct AppIcon *appicon; /* iconify appicon */ + struct DiskObject *dobj; /* iconify appicon */ + struct Hook favicon_hook; + struct Hook throbber_hook; + struct Hook browser_hook; + struct Hook *ctxmenu_hook; + Object *restrict history_ctxmenu[2]; + Object *clicktab_ctxmenu; + gui_drag_type drag_op; + struct IBox *ptr_lock; + struct AppWindow *appwin; + struct MinList *shared_pens; + gui_pointer_shape mouse_pointer; + struct Menu *imenu; /* Intuition menu */ + bool closed; /* Window has been closed (via menu) */ +}; + +struct gui_window +{ + struct gui_window_2 *shared; + int tab; + struct Node *tab_node; + int c_x; /* Caret X posn */ + int c_y; /* Caret Y posn */ + int c_w; /* Caret width */ + int c_h; /* Caret height */ + int c_h_temp; + int scrollx; + int scrolly; + struct ami_history_local_window *hw; + struct List dllist; + struct hlcache_handle *favicon; + bool throbbing; + char *tabtitle; + APTR deferred_rects_pool; + struct MinList *deferred_rects; + struct browser_window *bw; + struct ColumnInfo *logcolumns; + struct List loglist; +}; + struct ami_gui_tb_userdata { struct List *sblist; struct gui_window_2 *gw; int items; }; -struct MinList *window_list = NULL; -struct Screen *scrn = NULL; -struct MsgPort *sport = NULL; -struct gui_window *cur_gw = NULL; +static struct MinList *window_list = NULL; +static struct Screen *scrn = NULL; +static struct MsgPort *sport = NULL; +static struct gui_window *cur_gw = NULL; static bool ami_quit = false; @@ -231,17 +361,15 @@ static const __attribute__((used)) char *stack_cookie = "\0$STACK:196608\0"; const char * const versvn; const char * const verdate; -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); -void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys); -void ami_quit_netsurf_delayed(void); -Object *ami_gui_splash_open(void); -void ami_gui_splash_close(Object *win_obj); -HOOKF(uint32, ami_set_favicon_render_hook, APTR, space, struct gpRender *); -HOOKF(uint32, ami_set_throbber_render_hook, APTR, space, struct gpRender *); -bool ami_gui_map_filename(char **remapped, const char *restrict path, const char *restrict file, - const char *restrict map); +static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw); +static void ami_change_tab(struct gui_window_2 *gwin, int direction); +static void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs); +static void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys); +static void ami_quit_netsurf_delayed(void); +static Object *ami_gui_splash_open(void); +static void ami_gui_splash_close(Object *win_obj); +static bool ami_gui_map_filename(char **remapped, const char *restrict path, + const char *restrict file, const char *restrict map); static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw); static void ami_do_redraw(struct gui_window_2 *g); static void ami_schedule_redraw_remove(struct gui_window_2 *gwin); @@ -250,8 +378,10 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r 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 amiga_window_invalidate_area(struct gui_window *g, const struct rect *restrict rect); +HOOKF(uint32, ami_set_favicon_render_hook, APTR, space, struct gpRender *); +HOOKF(uint32, ami_set_throbber_render_hook, APTR, space, struct gpRender *); +HOOKF(uint32, ami_gui_browser_render_hook, APTR, space, struct gpRender *); /* accessors for default options - user option is updated if it is set as per default */ #define nsoption_default_set_int(OPTION, VALUE) \ @@ -259,6 +389,315 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh nsoptions[NSOPTION_##OPTION].value.i = VALUE; \ nsoptions_default[NSOPTION_##OPTION].value.i = VALUE +/* Functions documented in gui.h */ +struct MsgPort *ami_gui_get_shared_msgport(void) +{ + assert(sport != NULL); + return sport; +} + +struct gui_window *ami_gui_get_active_gw(void) +{ + return cur_gw; +} + +struct Screen *ami_gui_get_screen(void) +{ + return scrn; +} + +struct MinList *ami_gui_get_window_list(void) +{ + assert(window_list != NULL); + return window_list; +} + +void ami_gui_beep(void) +{ + DisplayBeep(scrn); +} + +struct browser_window *ami_gui_get_browser_window(struct gui_window *gw) +{ + assert(gw != NULL); + return gw->bw; +} + +struct browser_window *ami_gui2_get_browser_window(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return ami_gui_get_browser_window(gwin->gw); +} + +struct List *ami_gui_get_download_list(struct gui_window *gw) +{ + assert(gw != NULL); + return &gw->dllist; +} + +struct gui_window_2 *ami_gui_get_gui_window_2(struct gui_window *gw) +{ + assert(gw != NULL); + return gw->shared; +} + +struct gui_window *ami_gui2_get_gui_window(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->gw; +} + +const char *ami_gui_get_win_title(struct gui_window *gw) +{ + assert(gw != NULL); + assert(gw->shared != NULL); + return (const char *)gw->shared->wintitle; +} + +const char *ami_gui_get_tab_title(struct gui_window *gw) +{ + assert(gw != NULL); + return (const char *)gw->tabtitle; +} + +struct Node *ami_gui_get_tab_node(struct gui_window *gw) +{ + assert(gw != NULL); + return gw->tab_node; +} + +ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->tabs; +} + +struct List *ami_gui2_get_tab_list(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return &gwin->tab_list; +} + +struct hlcache_handle *ami_gui_get_favicon(struct gui_window *gw) +{ + assert(gw != NULL); + return gw->favicon; +} + +struct ami_history_local_window *ami_gui_get_history_window(struct gui_window *gw) +{ + assert(gw != NULL); + return gw->hw; +} + +void ami_gui_set_history_window(struct gui_window *gw, struct ami_history_local_window *hw) +{ + assert(gw != NULL); + gw->hw = hw; +} + +void ami_gui_set_find_window(struct gui_window *gw, struct find_window *fw) +{ + /* This needs to be in gui_window_2 as it is shared amongst tabs (I think), + * it just happens that the find code only knows of the gui_window + */ + assert(gw != NULL); + assert(gw->shared != NULL); + gw->shared->searchwin = fw; +} + +bool ami_gui_get_throbbing(struct gui_window *gw) +{ + assert(gw != NULL); + return gw->throbbing; +} + +void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing) +{ + assert(gw != NULL); + gw->throbbing = throbbing; +} + +int ami_gui_get_throbber_frame(struct gui_window *gw) +{ + assert(gw != NULL); + assert(gw->shared != NULL); + return gw->shared->throbber_frame; +} + +void ami_gui_set_throbber_frame(struct gui_window *gw, int frame) +{ + assert(gw != NULL); + assert(gw->shared != NULL); + gw->shared->throbber_frame = frame; +} + +Object *ami_gui2_get_object(struct gui_window_2 *gwin, int object_type) +{ + ULONG obj = 0; + + assert(gwin != NULL); + + switch(object_type) { + case AMI_WIN_MAIN: + obj = OID_MAIN; + break; + + case AMI_GAD_THROBBER: + obj = GID_THROBBER; + break; + + case AMI_GAD_TABS: + obj = GID_TABS; + break; + + case AMI_GAD_URL: + obj = GID_URL; + break; + + case AMI_GAD_SEARCH: + obj = GID_SEARCHSTRING; + break; + + default: + return NULL; + break; + } + + return gwin->objects[obj]; +} + + +struct Window *ami_gui2_get_window(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->win; +} + +struct Window *ami_gui_get_window(struct gui_window *gw) +{ + assert(gw != NULL); + return ami_gui2_get_window(gw->shared); +} + +struct Menu *ami_gui_get_menu(struct gui_window *gw) +{ + assert(gw != NULL); + assert(gw->shared != NULL); + return gw->shared->imenu; +} + +void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu) +{ + if(menu != NULL) { + gwin->imenu = menu; + } else { + ami_gui_menu_freemenus(gwin->imenu, gwin->menu_data); + } +} + +struct ami_menu_data **ami_gui2_get_menu_data(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->menu_data; +} + +void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp) +{ + assert(gwin != NULL); + gwin->temp = temp; +} + +int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->temp; +} + +Object *ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction) +{ + assert(gwin != NULL); + return gwin->history_ctxmenu[direction]; +} + +void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist) +{ + assert(gwin != NULL); + gwin->history_ctxmenu[direction] = ctx_hist; +} + +void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed) +{ + assert(gwin != NULL); + gwin->closed = closed; +} + +void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content) +{ + assert(gwin != NULL); + gwin->new_content = new_content; +} + +/** undocumented, or internal, or documented elsewhere **/ + +#ifdef __amigaos4__ +static void *ami_find_gwin_by_id(struct Window *win, uint32 type) +{ + struct nsObject *node, *nnode; + struct gui_window_2 *gwin; + + if(!IsMinListEmpty(window_list)) + { + node = (struct nsObject *)GetHead((struct List *)window_list); + + do + { + nnode=(struct nsObject *)GetSucc((struct Node *)node); + + if(node->Type == type) + { + gwin = node->objstruct; + if(win == ami_gui2_get_window(gwin)) return gwin; + } + } while((node = nnode)); + } + return NULL; +} + +void *ami_window_at_pointer(int type) +{ + struct Layer *layer; + struct Screen *scrn = ami_gui_get_screen(); + + LockLayerInfo(&scrn->LayerInfo); + + layer = WhichLayer(&scrn->LayerInfo, scrn->MouseX, scrn->MouseY); + + UnlockLayerInfo(&scrn->LayerInfo); + + if(layer) return ami_find_gwin_by_id(layer->Window, type); + else return NULL; +} +#else +/**\todo check if OS4 version of this function will build on OS3, even if it isn't called */ +void *ami_window_at_pointer(int type) +{ + return NULL; +} +#endif + +void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update) +{ + if(gwin->mouse_pointer == shape) return; + ami_update_pointer(ami_gui2_get_window(gwin), shape); + if(update == true) gwin->mouse_pointer = shape; +} + +/* reset the mouse pointer back to what NetSurf last set it as */ +void ami_reset_pointer(struct gui_window_2 *gwin) +{ + ami_update_pointer(ami_gui2_get_window(gwin), gwin->mouse_pointer); +} STRPTR ami_locale_langs(int *codeset) @@ -302,7 +741,7 @@ STRPTR ami_locale_langs(int *codeset) return acceptlangs; } -bool ami_gui_map_filename(char **remapped, const char *restrict path, +static bool ami_gui_map_filename(char **remapped, const char *restrict path, const char *restrict file, const char *restrict map) { BPTR fh = 0; @@ -657,6 +1096,7 @@ static nserror ami_set_options(struct nsoption_s *defaults) const char *encname = (const char *)ObtainCharsetInfo(DFCS_NUMBER, codeset, DFCS_MIMENAME); nsoption_set_charp(local_charset, strdup(encname)); + nsoption_set_int(local_codeset, codeset); #else nsoption_set_bool(download_notify, false); nsoption_set_bool(font_antialiasing, false); @@ -777,25 +1217,10 @@ static void ami_amiupdate(void) static nsurl *gui_get_resource_url(const char *path) { char buf[1024]; - char path2[1024]; nsurl *url = NULL; if(ami_locate_resource(buf, path) == false) - { - if((strncmp(path + strlen(path) - SLEN(".htm"), ".htm", SLEN(".htm")) == 0) || - (strncmp(path + strlen(path) - SLEN(".html"), ".html", SLEN(".html")) == 0)) - { - /* Try with RISC OS HTML filetype, might work */ - strcpy(path2, path); - strcat(path2, ",faf"); - - if(ami_locate_resource(buf, path2) == false) - { - return NULL; - } - } - else return NULL; - } + return NULL; netsurf_path_to_nsurl(buf, &url); @@ -1031,12 +1456,16 @@ static void gui_init2(int argc, char** argv) hotlist_init(nsoption_charp(hotlist_file), nsoption_charp(hotlist_file)); - search_web_select_provider(nsoption_int(search_provider)); + search_web_select_provider(nsoption_charp(search_web_provider)); if (notalreadyrunning && (nsoption_bool(startup_no_window) == false)) ami_openscreenfirst(); + if(cli_force == true) { + notalreadyrunning = TRUE; + } + if(temp_homepage_url && notalreadyrunning) { error = nsurl_create(temp_homepage_url, &url); if (error == NSERROR_OK) { @@ -1054,10 +1483,6 @@ static void gui_init2(int argc, char** argv) temp_homepage_url = NULL; } - if(cli_force == true) { - notalreadyrunning = TRUE; - } - if(argc == 0) { // WB struct WBStartup *WBenchMsg = (struct WBStartup *)argv; struct WBArg *wbarg; @@ -1359,6 +1784,7 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie) case RAWKEY_F8: case RAWKEY_F9: case RAWKEY_F10: + case RAWKEY_F12: case RAWKEY_HELP: // don't translate nskey = keycode; @@ -1461,9 +1887,6 @@ static bool ami_spacebox_to_ns_coords(struct gui_window_2 *gwin, int ns_x = space_x; int ns_y = space_y; - ns_x /= gwin->gw->scale; - ns_y /= gwin->gw->scale; - ns_x += gwin->gw->scrollx; ns_y += gwin->gw->scrolly; @@ -1506,8 +1929,7 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys) if(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true) { - if(browser_window_scroll_at_point(gwin->gw->bw, x, y, - xs, ys) == false) + if(browser_window_scroll_at_point(gwin->gw->bw, x, y, xs, ys) == false) { int width, height; @@ -1589,11 +2011,11 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct return NULL; } - ibox->Left = gwin->win->MouseX + (rect->x0 * gwin->gw->scale); - ibox->Top = gwin->win->MouseY + (rect->y0 * gwin->gw->scale); + ibox->Left = gwin->win->MouseX + (rect->x0); + ibox->Top = gwin->win->MouseY + (rect->y0); - ibox->Width = (rect->x1 - rect->x0) * gwin->gw->scale; - ibox->Height = (rect->y1 - rect->y0) * gwin->gw->scale; + ibox->Width = (rect->x1 - rect->x0); + ibox->Height = (rect->y1 - rect->y0); if(ibox->Left < bbox->Left) ibox->Left = bbox->Left; if(ibox->Top < bbox->Top) ibox->Top = bbox->Top; @@ -1659,18 +2081,20 @@ static void ami_gui_menu_update_all(void) * \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) +static nserror +gui_window_get_dimensions(struct gui_window *gw, + int *restrict width, + int *restrict height) { struct IBox *bbox; nserror res; - res = ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], &bbox); - if(res != NSERROR_OK) { + res = ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], + &bbox); + if (res != NSERROR_OK) { amiga_warn_user("NoMemory", ""); return res; } @@ -1680,11 +2104,6 @@ static nserror gui_window_get_dimensions(struct gui_window *gw, ami_gui_free_space_box(bbox); - if(scaled) { - *width /= gw->scale; - *height /= gw->scale; - } - return NSERROR_OK; } @@ -1801,7 +2220,7 @@ static void ami_gui_scroller_update(struct gui_window_2 *gwin) rethinkh = ami_gui_hscroll_remove(gwin); } else { if((browser_window_get_extents(gwin->gw->bw, false, &w, &h) == NSERROR_OK)) { - gui_window_get_dimensions(gwin->gw, &ww, &wh, false); + gui_window_get_dimensions(gwin->gw, &ww, &wh); } if(vscroll == BW_SCROLLING_NO) { @@ -1827,6 +2246,217 @@ static void ami_gui_scroller_update(struct gui_window_2 *gwin) } } +/* For future use +static void ami_gui_console_log_clear(struct gui_window *g) +{ + if(g->shared->objects[GID_LOG] != NULL) { + SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL, + LISTBROWSER_Labels, NULL, + TAG_DONE); + } + + FreeListBrowserList(&g->loglist); + + NewList(&g->loglist); + + if(g->shared->objects[GID_LOG] != NULL) { + SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL, + LISTBROWSER_Labels, &g->loglist, + TAG_DONE); + } +} +*/ + +static void ami_gui_console_log_add(struct gui_window *g) +{ + struct TagItem attrs[2]; + + if(g->shared->objects[GID_LOG] != NULL) return; + + attrs[0].ti_Tag = CHILD_MinHeight; + attrs[0].ti_Data = 50; + attrs[1].ti_Tag = TAG_DONE; + attrs[1].ti_Data = 0; + + g->shared->objects[GID_LOG] = ListBrowserObj, + GA_ID, GID_LOG, + LISTBROWSER_ColumnInfo, g->logcolumns, + LISTBROWSER_ColumnTitles, TRUE, + LISTBROWSER_Labels, &g->loglist, + LISTBROWSER_Striping, LBS_ROWS, + ListBrowserEnd; + +#ifdef __amigaos4__ + IDoMethod(g->shared->objects[GID_LOGLAYOUT], LM_ADDCHILD, + g->shared->win, g->shared->objects[GID_LOG], NULL); +#else + SetAttrs(g->shared->objects[GID_LOGLAYOUT], + LAYOUT_AddChild, g->shared->objects[GID_LOG], TAG_MORE, &attrs); +#endif + + FlushLayoutDomainCache((struct Gadget *)g->shared->objects[GID_MAIN]); + + RethinkLayout((struct Gadget *)g->shared->objects[GID_MAIN], + g->shared->win, NULL, TRUE); + + ami_schedule_redraw(g->shared, true); +} + +static void ami_gui_console_log_remove(struct gui_window *g) +{ + if(g->shared->objects[GID_LOG] == NULL) return; + +#ifdef __amigaos4__ + IDoMethod(g->shared->objects[GID_LOGLAYOUT], LM_REMOVECHILD, + g->shared->win, g->shared->objects[GID_LOG]); +#else + SetAttrs(g->shared->objects[GID_LOGLAYOUT], + LAYOUT_RemoveChild, g->shared->objects[GID_LOG], TAG_DONE); +#endif + + g->shared->objects[GID_LOG] = NULL; + + FlushLayoutDomainCache((struct Gadget *)g->shared->objects[GID_MAIN]); + + RethinkLayout((struct Gadget *)g->shared->objects[GID_MAIN], + g->shared->win, NULL, TRUE); + + ami_schedule_redraw(g->shared, true); +} + +static bool ami_gui_console_log_toggle(struct gui_window *g) +{ + if(g->shared->objects[GID_LOG] == NULL) { + ami_gui_console_log_add(g); + return true; + } else { + ami_gui_console_log_remove(g); + return false; + } +} + +static void ami_gui_console_log_switch(struct gui_window *g) +{ + if(g->shared->objects[GID_LOG] == NULL) return; + + RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL, + LISTBROWSER_ColumnInfo, g->logcolumns, + LISTBROWSER_Labels, &g->loglist, + TAG_DONE); +} + +static void +gui_window_console_log(struct gui_window *g, + browser_window_console_source src, + const char *msg, + size_t msglen, + browser_window_console_flags flags) +{ + bool foldable = !!(flags & BW_CS_FLAG_FOLDABLE); + const char *src_text; + const char *level_text; + struct Node *node; + ULONG style = 0; + ULONG fgpen = TEXTPEN; + ULONG lbflags = LBFLG_READONLY; + char timestamp[256]; + time_t now = time(NULL); + struct tm *timedata = localtime(&now); + + strftime(timestamp, 256, "%c", timedata); + + if(foldable) lbflags |= LBFLG_HASCHILDREN; + + switch (src) { + case BW_CS_INPUT: + src_text = "client-input"; + break; + case BW_CS_SCRIPT_ERROR: + src_text = "scripting-error"; + break; + case BW_CS_SCRIPT_CONSOLE: + src_text = "scripting-console"; + break; + default: + assert(0 && "Unknown scripting source"); + src_text = "unknown"; + break; + } + + switch (flags & BW_CS_FLAG_LEVEL_MASK) { + case BW_CS_FLAG_LEVEL_DEBUG: + level_text = "DEBUG"; + fgpen = DISABLEDTEXTPEN; + lbflags |= LBFLG_CUSTOMPENS; + break; + case BW_CS_FLAG_LEVEL_LOG: + level_text = "LOG"; + fgpen = DISABLEDTEXTPEN; + lbflags |= LBFLG_CUSTOMPENS; + break; + case BW_CS_FLAG_LEVEL_INFO: + level_text = "INFO"; + break; + case BW_CS_FLAG_LEVEL_WARN: + level_text = "WARN"; + break; + case BW_CS_FLAG_LEVEL_ERROR: + level_text = "ERROR"; + style = FSF_BOLD; + break; + default: + assert(0 && "Unknown console logging level"); + level_text = "unknown"; + break; + } + + if(g->shared->objects[GID_LOG] != NULL) { + SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL, + LISTBROWSER_Labels, NULL, + TAG_DONE); + } + + /* Add log entry to list irrespective of whether the log is open. */ + if((node = AllocListBrowserNode(4, + LBNA_Flags, lbflags, + LBNA_Column, 0, + LBNCA_SoftStyle, style, + LBNCA_FGPen, fgpen, + LBNCA_CopyText, TRUE, + LBNCA_Text, timestamp, + LBNA_Column, 1, + LBNCA_SoftStyle, style, + LBNCA_FGPen, fgpen, + LBNCA_CopyText, TRUE, + LBNCA_Text, src_text, + LBNA_Column, 2, + LBNCA_SoftStyle, style, + LBNCA_FGPen, fgpen, + LBNCA_CopyText, TRUE, + LBNCA_Text, level_text, + LBNA_Column, 3, + LBNCA_SoftStyle, style, + LBNCA_FGPen, fgpen, + LBNCA_CopyText, TRUE, + LBNCA_Text, msg, + TAG_DONE))) { + AddTail(&g->loglist, node); + } + + if(g->shared->objects[GID_LOG] != NULL) { + RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL, + LISTBROWSER_Labels, &g->loglist, + TAG_DONE); + } + +#ifdef __amigaos4__ + DebugPrintF("NETSURF: CONSOLE_LOG SOURCE %s %sFOLDABLE %s %.*s\n", + src_text, foldable ? "" : "NOT-", level_text, + (int)msglen, msg); +#endif +} + + /** * function to add retrieved favicon to gui */ @@ -2027,8 +2657,8 @@ static BOOL ami_gui_event(void *w) break; } - x = (ULONG)((gwin->win->MouseX - bbox->Left) / gwin->gw->scale); - y = (ULONG)((gwin->win->MouseY - bbox->Top) / gwin->gw->scale); + x = (ULONG)((gwin->win->MouseX - bbox->Left)); + y = (ULONG)((gwin->win->MouseY - bbox->Top)); ami_get_hscroll_pos(gwin, (ULONG *)&xs); ami_get_vscroll_pos(gwin, (ULONG *)&ys); @@ -2088,8 +2718,8 @@ static BOOL ami_gui_event(void *w) return FALSE; } - x = (ULONG)((gwin->win->MouseX - bbox->Left) / gwin->gw->scale); - y = (ULONG)((gwin->win->MouseY - bbox->Top) / gwin->gw->scale); + x = (ULONG)(gwin->win->MouseX - bbox->Left); + y = (ULONG)(gwin->win->MouseY - bbox->Top); ami_get_hscroll_pos(gwin, (ULONG *)&xs); ami_get_vscroll_pos(gwin, (ULONG *)&ys); @@ -2291,8 +2921,19 @@ static BOOL ami_gui_event(void *w) break; case GID_SEARCH_ICON: - GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage); - search_web_select_provider(storage); +#ifdef __amigaos4__ + { + char *prov = NULL; + GetAttr(CHOOSER_SelectedNode, gwin->objects[GID_SEARCH_ICON],(ULONG *)&storage); + if(storage != NULL) { + GetChooserNodeAttrs((struct Node *)storage, CNA_Text, (ULONG *)&prov, TAG_DONE); + nsoption_set_charp(search_web_provider, prov); + } + } +#else + /* TODO: Fix for OS<3.2 */ +#endif + search_web_select_provider(nsoption_charp(search_web_provider)); break; case GID_SEARCHSTRING: @@ -2371,6 +3012,25 @@ static BOOL ami_gui_event(void *w) ami_gui_history(gwin, false); break; + case GID_PAGEINFO: + { + ULONG w_top, w_left; + ULONG g_top, g_left, g_height; + + GetAttr(WA_Top, gwin->objects[OID_MAIN], &w_top); + GetAttr(WA_Left, gwin->objects[OID_MAIN], &w_left); + GetAttr(GA_Top, gwin->objects[GID_PAGEINFO], &g_top); + GetAttr(GA_Left, gwin->objects[GID_PAGEINFO], &g_left); + GetAttr(GA_Height, gwin->objects[GID_PAGEINFO], &g_height); + + if(ami_pageinfo_open(gwin->gw->bw, + w_left + g_left, + w_top + g_top + g_height) != NSERROR_OK) { + NSLOG(netsurf, INFO, "Unable to open page info window"); + } + } + break; + case GID_FAVE: GetAttr(STRINGA_TextVal, (Object *)gwin->objects[GID_URL], @@ -2493,13 +3153,17 @@ static BOOL ami_gui_event(void *w) break; case RAWKEY_F9: // decrease scale - ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1); + ami_gui_adjust_scale(gwin->gw, -0.1); break; case RAWKEY_F10: // increase scale - ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1); + ami_gui_adjust_scale(gwin->gw, +0.1); break; + case RAWKEY_F12: // console log + ami_gui_console_log_toggle(gwin->gw); + break; + case RAWKEY_HELP: // help ami_help_open(AMI_HELP_GUI, scrn); break; @@ -2602,6 +3266,56 @@ static void ami_gui_appicon_remove(struct gui_window_2 *gwin) } } +static nserror gui_page_info_change(struct gui_window *gw) +{ + int bm_idx; + browser_window_page_info_state pistate; + struct gui_window_2 *gwin = ami_gui_get_gui_window_2(gw); + struct browser_window *bw = ami_gui_get_browser_window(gw); + + /* if this isn't the visible tab, don't do anything */ + if((gwin == NULL) || (gwin->gw != gw)) return NSERROR_OK; + + pistate = browser_window_get_page_info_state(bw); + + switch(pistate) { + case PAGE_STATE_INTERNAL: + bm_idx = GID_PAGEINFO_INTERNAL_BM; + break; + + case PAGE_STATE_LOCAL: + bm_idx = GID_PAGEINFO_LOCAL_BM; + break; + + case PAGE_STATE_INSECURE: + bm_idx = GID_PAGEINFO_INSECURE_BM; + break; + + case PAGE_STATE_SECURE_OVERRIDE: + bm_idx = GID_PAGEINFO_WARNING_BM; + break; + + case PAGE_STATE_SECURE_ISSUES: + bm_idx = GID_PAGEINFO_WARNING_BM; + break; + + case PAGE_STATE_SECURE: + bm_idx = GID_PAGEINFO_SECURE_BM; + break; + + default: + bm_idx = GID_PAGEINFO_INTERNAL_BM; + break; + } + + RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_PAGEINFO], gwin->win, NULL, + BUTTON_RenderImage, gwin->objects[bm_idx], + GA_HintInfo, gwin->helphints[bm_idx], + TAG_DONE); + + return NSERROR_OK; +} + static void ami_handle_appmsg(void) { struct AppMessage *appmsg; @@ -2873,7 +3587,7 @@ void ami_get_msg(void) ami_quit_netsurf_delayed(); } -void ami_change_tab(struct gui_window_2 *gwin, int direction) +static void ami_change_tab(struct gui_window_2 *gwin, int direction) { struct Node *tab_node = gwin->gw->tab_node; struct Node *ptab = NULL; @@ -2895,7 +3609,136 @@ void ami_change_tab(struct gui_window_2 *gwin, int direction) ami_switch_tab(gwin, true); } -void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) + +static void gui_window_set_title(struct gui_window *g, const char *restrict title) +{ + struct Node *node; + char *restrict utf8title; + + if(!g) return; + if(!title) return; + + utf8title = ami_utf8_easy((char *)title); + + if(g->tab_node) { + 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) 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 gui_window_update_extent(struct gui_window *g) +{ + struct IBox *bbox; + + if(!g || !g->bw) return; + if(browser_window_has_content(g->bw) == false) return; + + if(g == g->shared->gw) { + int width, height; + if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) { + amiga_warn_user("NoMemory", ""); + return; + } + + if(g->shared->objects[GID_VSCROLL]) { + browser_window_get_extents(g->bw, true, &width, &height); + RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL],g->shared->win,NULL, + SCROLLER_Total, (ULONG)(height), + SCROLLER_Visible, bbox->Height, + TAG_DONE); + } + + if(g->shared->objects[GID_HSCROLL]) + { + browser_window_get_extents(g->bw, true, &width, &height); + RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL], + g->shared->win, NULL, + SCROLLER_Total, (ULONG)(width), + SCROLLER_Visible, bbox->Width, + TAG_DONE); + } + + ami_gui_free_space_box(bbox); + } + + ami_gui_scroller_update(g->shared); + g->shared->new_content = true; +} + + +/** + * 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_switch_tab(struct gui_window_2 *gwin, bool redraw) { struct Node *tabnode; struct IBox *bbox; @@ -2915,6 +3758,8 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) TAG_DONE); cur_gw = gwin->gw; + ami_gui_console_log_switch(gwin->gw); + if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) { amiga_warn_user("NoMemory", ""); return; @@ -2938,7 +3783,10 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) struct rect rect; ami_plot_clear_bbox(gwin->win->RPort, bbox); - browser_window_update(gwin->gw->bw, false); + gui_window_set_title(gwin->gw, + browser_window_get_title(gwin->gw->bw)); + gui_window_update_extent(gwin->gw); + amiga_window_invalidate_area(gwin->gw, NULL); rect.x0 = rect.x1 = gwin->gw->scrollx; rect.y0 = rect.y1 = gwin->gw->scrolly; @@ -2952,6 +3800,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) ami_throbber_redraw_schedule(0, gwin->gw); gui_window_set_icon(gwin->gw, gwin->gw->favicon); + gui_page_info_change(gwin->gw); } ami_gui_free_space_box(bbox); @@ -2991,7 +3840,7 @@ void ami_quit_netsurf(void) } } -void ami_quit_netsurf_delayed(void) +static void ami_quit_netsurf_delayed(void) { int res = -1; #ifdef __amigaos4__ @@ -3395,7 +4244,7 @@ static void ami_toggletabbar(struct gui_window_2 *gwin, bool show) GA_ID, GID_TABS, GA_RelVerify, TRUE, GA_Underscore, 13, // disable kb shortcuts - GA_ContextMenu, ami_ctxmenu_clicktab_create(gwin), + GA_ContextMenu, ami_ctxmenu_clicktab_create(gwin, &gwin->clicktab_ctxmenu), CLICKTAB_Labels, &gwin->tab_list, CLICKTAB_LabelTruncate, TRUE, CLICKTAB_CloseImage, gwin->objects[GID_CLOSETAB_BM], @@ -3444,7 +4293,12 @@ static void ami_toggletabbar(struct gui_window_2 *gwin, bool show) RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN], gwin->win, NULL, TRUE); - if(gwin->gw && gwin->gw->bw) browser_window_update(gwin->gw->bw, false); + if (gwin->gw && gwin->gw->bw) { + gui_window_set_title(gwin->gw, + browser_window_get_title(gwin->gw->bw)); + gui_window_update_extent(gwin->gw); + amiga_window_invalidate_area(gwin->gw, NULL); + } } void ami_gui_tabs_toggle_all(void) @@ -3517,9 +4371,14 @@ int ami_gui_count_windows(int window, int *tabs) */ void ami_gui_set_scale(struct gui_window *gw, float scale) { - if(scale <= 0.0) return; - gw->scale = scale; browser_window_set_scale(gw->bw, scale, true); + ami_schedule_redraw(gw->shared, true); +} + +void ami_gui_adjust_scale(struct gui_window *gw, float adjustment) +{ + browser_window_set_scale(gw->bw, adjustment, false); + ami_schedule_redraw(gw->shared, true); } void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin) @@ -3572,10 +4431,6 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy, 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); - ami_plot_ra_set_pen_list(glob, gwin->shared_pens); if(top < 0) { @@ -3608,19 +4463,19 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy, if(busy) ami_set_pointer(gwin, GUI_POINTER_WAIT, false); - for(y = top; y < (top + height); y += tile_y_scale) { + for(y = top; y < (top + height); y += tile_size_y) { clip.y0 = 0; clip.y1 = 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(((y - sy) + clip.y1) > bbox->Height) + clip.y1 = bbox->Height - (y - sy); - for(x = left; x < (left + width); x += tile_x_scale) { + for(x = left; x < (left + width); x += tile_size_x) { clip.x0 = 0; clip.x1 = 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(((x - sx) + clip.x1) > bbox->Width) + clip.x1 = bbox->Width - (x - sx); if(browser_window_redraw(gwin->gw->bw, clip.x0 - (int)x, @@ -3635,15 +4490,15 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy, 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_DestX, bbox->Left + (int)(x - sx), + BLITA_DestY, bbox->Top + (int)(y - sy), BLITA_Width, (int)(clip.x1), BLITA_Height, (int)(clip.y1), TAG_DONE); #else 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), + bbox->Left + (int)(x - sx), + bbox->Top + (int)(y - sy), (int)(clip.x1), (int)(clip.y1), 0xC0); #endif } @@ -3693,7 +4548,7 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw } ami_do_redraw_tiled(g->shared, busy, x0, y0, - (x1 - x0) * g->scale, (y1 - y0) * g->scale, sx, sy, bbox, &ctx); + x1 - x0, y1 - y0, sx, sy, bbox, &ctx); ami_gui_free_space_box(bbox); @@ -3701,44 +4556,6 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw } -/** - * 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 */ @@ -3760,14 +4577,10 @@ static void ami_refresh_window(struct gui_window_2 *gwin) BeginRefresh(gwin->win); - r.x0 = ((gwin->win->RPort->Layer->DamageList->bounds.MinX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx - 1; - r.x1 = ((gwin->win->RPort->Layer->DamageList->bounds.MaxX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx + 2; - r.y0 = ((gwin->win->RPort->Layer->DamageList->bounds.MinY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy - 1; - r.y1 = ((gwin->win->RPort->Layer->DamageList->bounds.MaxY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy + 2; + r.x0 = (gwin->win->RPort->Layer->DamageList->bounds.MinX - bbox->Left) + sx - 1; + r.x1 = (gwin->win->RPort->Layer->DamageList->bounds.MaxX - bbox->Left) + sx + 2; + r.y0 = (gwin->win->RPort->Layer->DamageList->bounds.MinY - bbox->Top) + sy - 1; + r.y1 = (gwin->win->RPort->Layer->DamageList->bounds.MaxY - bbox->Top) + sy + 2; regrect = gwin->win->RPort->Layer->DamageList->RegionRectangle; @@ -3775,14 +4588,10 @@ static void ami_refresh_window(struct gui_window_2 *gwin) while(regrect) { - r.x0 = ((regrect->bounds.MinX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx - 1; - r.x1 = ((regrect->bounds.MaxX - bbox->Left) / - browser_window_get_scale(gwin->gw->bw)) + sx + 2; - r.y0 = ((regrect->bounds.MinY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy - 1; - r.y1 = ((regrect->bounds.MaxY - bbox->Top) / - browser_window_get_scale(gwin->gw->bw)) + sy + 2; + r.x0 = (regrect->bounds.MinX - bbox->Left) + sx - 1; + r.x1 = (regrect->bounds.MaxX - bbox->Left) + sx + 2; + r.y0 = (regrect->bounds.MinY - bbox->Top) + sy - 1; + r.y1 = (regrect->bounds.MaxY - bbox->Top) + sy + 2; regrect = regrect->Next; @@ -3915,6 +4724,7 @@ gui_window_create(struct browser_window *bw, char closetab[100],closetab_s[100],closetab_g[100]; char addtab[100],addtab_s[100],addtab_g[100]; char fave[100], unfave[100]; + char pi_insecure[100], pi_internal[100], pi_local[100], pi_secure[100], pi_warning[100]; char tabthrobber[100]; ULONG refresh_mode = WA_SmartRefresh; ULONG defer_layout = TRUE; @@ -3956,7 +4766,38 @@ gui_window_create(struct browser_window *bw, g->deferred_rects = NewObjList(); g->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect)); g->bw = bw; - g->scale = browser_window_get_scale(bw); + + NewList(&g->loglist); +#ifdef __amigaos4__ + g->logcolumns = AllocLBColumnInfo(4, + LBCIA_Column, 0, + // LBCIA_CopyTitle, TRUE, + LBCIA_Title, "time", /**\TODO: add these to Messages */ + LBCIA_Weight, 10, + LBCIA_DraggableSeparator, TRUE, + LBCIA_Separator, TRUE, + LBCIA_Column, 1, + // LBCIA_CopyTitle, TRUE, + LBCIA_Title, "source", /**\TODO: add these to Messages */ + LBCIA_Weight, 10, + LBCIA_DraggableSeparator, TRUE, + LBCIA_Separator, TRUE, + LBCIA_Column, 2, + // LBCIA_CopyTitle, TRUE, + LBCIA_Title, "level", /**\TODO: add these to Messages */ + LBCIA_Weight, 5, + LBCIA_DraggableSeparator, TRUE, + LBCIA_Separator, TRUE, + LBCIA_Column, 3, + // LBCIA_CopyTitle, TRUE, + LBCIA_Title, "message", /**\TODO: add these to Messages */ + LBCIA_Weight, 75, + LBCIA_DraggableSeparator, TRUE, + LBCIA_Separator, TRUE, + TAG_DONE); +#else + /**\TODO write OS3-compatible version */ +#endif if((flags & GW_CREATE_TAB) && existing) { @@ -4037,6 +4878,9 @@ gui_window_create(struct browser_window *bw, g->shared->throbber_hook.h_Entry = (void *)ami_set_throbber_render_hook; g->shared->throbber_hook.h_Data = g->shared; + g->shared->browser_hook.h_Entry = (void *)ami_gui_browser_render_hook; + g->shared->browser_hook.h_Data = g->shared; + newprefs_hook.h_Entry = (void *)ami_gui_newprefs_hook; newprefs_hook.h_Data = 0; @@ -4077,7 +4921,7 @@ gui_window_create(struct browser_window *bw, TAG_DONE); AddTail(&g->shared->tab_list,g->tab_node); - g->shared->web_search_list = ami_gui_opts_websearch(); + g->shared->web_search_list = ami_gui_opts_websearch(NULL); g->shared->search_bm = NULL; g->shared->tabs=1; @@ -4102,6 +4946,12 @@ gui_window_create(struct browser_window *bw, g->shared->helphints[GID_ADDTAB] = translate_escape_chars(messages_get("HelpToolbarAddTab")); + g->shared->helphints[GID_PAGEINFO_INSECURE_BM] = ami_utf8_easy(messages_get("PageInfoInsecure")); + g->shared->helphints[GID_PAGEINFO_LOCAL_BM] = ami_utf8_easy(messages_get("PageInfoLocal")); + g->shared->helphints[GID_PAGEINFO_SECURE_BM] = ami_utf8_easy(messages_get("PageInfoSecure")); + g->shared->helphints[GID_PAGEINFO_WARNING_BM] = ami_utf8_easy(messages_get("PageInfoWarning")); + g->shared->helphints[GID_PAGEINFO_INTERNAL_BM] = ami_utf8_easy(messages_get("PageInfoInternal")); + ami_get_theme_filename(nav_west, "theme_nav_west", false); ami_get_theme_filename(nav_west_s, "theme_nav_west_s", false); ami_get_theme_filename(nav_west_g, "theme_nav_west_g", false); @@ -4126,6 +4976,11 @@ gui_window_create(struct browser_window *bw, ami_get_theme_filename(tabthrobber, "theme_tab_loading", false); ami_get_theme_filename(fave, "theme_fave", false); ami_get_theme_filename(unfave, "theme_unfave", false); + ami_get_theme_filename(pi_insecure, "theme_pageinfo_insecure", false); + ami_get_theme_filename(pi_internal, "theme_pageinfo_internal", false); + ami_get_theme_filename(pi_local, "theme_pageinfo_local", false); + ami_get_theme_filename(pi_secure, "theme_pageinfo_secure", false); + ami_get_theme_filename(pi_warning, "theme_pageinfo_warning", false); g->shared->objects[GID_FAVE_ADD] = BitMapObj, BITMAP_SourceFile, fave, @@ -4155,6 +5010,37 @@ gui_window_create(struct browser_window *bw, BITMAP_Masking, TRUE, BitMapEnd; + g->shared->objects[GID_PAGEINFO_INSECURE_BM] = BitMapObj, + BITMAP_SourceFile, pi_insecure, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_INTERNAL_BM] = BitMapObj, + BITMAP_SourceFile, pi_internal, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_LOCAL_BM] = BitMapObj, + BITMAP_SourceFile, pi_local, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_SECURE_BM] = BitMapObj, + BITMAP_SourceFile, pi_secure, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_WARNING_BM] = BitMapObj, + BITMAP_SourceFile, pi_warning, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + if(ClickTabBase->lib_Version < 53) { addtabclosegadget = LAYOUT_AddChild; @@ -4313,6 +5199,14 @@ gui_window_create(struct browser_window *bw, SpaceEnd, CHILD_WeightedWidth, 0, CHILD_WeightedHeight, 0, + LAYOUT_AddChild, g->shared->objects[GID_PAGEINFO] = ButtonObj, + GA_ID, GID_PAGEINFO, + GA_RelVerify, TRUE, + GA_ReadOnly, FALSE, + BUTTON_RenderImage, g->shared->objects[GID_PAGEINFO_INTERNAL_BM], + ButtonEnd, + CHILD_WeightedWidth, 0, + CHILD_WeightedHeight, 0, LAYOUT_AddChild, g->shared->objects[GID_URL] = #ifdef __amigaos4__ NewObject(urlStringClass, NULL, @@ -4401,10 +5295,15 @@ gui_window_create(struct browser_window *bw, LAYOUT_AddChild, g->shared->objects[GID_BROWSER] = SpaceObj, GA_ID,GID_BROWSER, SPACE_Transparent,TRUE, + SPACE_RenderHook, &g->shared->browser_hook, SpaceEnd, EndGroup, EndGroup, EndGroup, +// LAYOUT_WeightBar, TRUE, + LAYOUT_AddChild, g->shared->objects[GID_LOGLAYOUT] = LayoutVObj, + EndGroup, + CHILD_WeightedHeight, 0, #ifndef __amigaos4__ LAYOUT_AddChild, g->shared->objects[GID_STATUS] = StringObj, GA_ID, GID_STATUS, @@ -4650,6 +5549,11 @@ static void gui_window_destroy(struct gui_window *g) if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false)) ami_toggletabbar(g->shared, false); + FreeListBrowserList(&g->loglist); +#ifdef __amigaos4__ + FreeLBColumnInfo(g->logcolumns); +#endif + if(g->tabtitle) free(g->tabtitle); free(g); return; @@ -4672,6 +5576,11 @@ static void gui_window_destroy(struct gui_window *g) DisposeObject(g->shared->objects[GID_TABS_FLAG]); DisposeObject(g->shared->objects[GID_FAVE_ADD]); DisposeObject(g->shared->objects[GID_FAVE_RMV]); + DisposeObject(g->shared->objects[GID_PAGEINFO_INSECURE_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_INTERNAL_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_LOCAL_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_SECURE_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_WARNING_BM]); ami_gui_opts_websearch_free(g->shared->web_search_list); if(g->shared->search_bm) DisposeObject(g->shared->search_bm); @@ -4683,6 +5592,11 @@ static void gui_window_destroy(struct gui_window *g) ami_ctxmenu_release_hook(g->shared->ctxmenu_hook); ami_gui_menu_free(g->shared); + FreeListBrowserList(&g->loglist); +#ifdef __amigaos4__ + FreeLBColumnInfo(g->logcolumns); +#endif + free(g->shared->wintitle); ami_utf8_free(g->shared->status); free(g->shared->svbuffer); @@ -4707,55 +5621,6 @@ static void gui_window_destroy(struct gui_window *g) win_destroyed = true; } -static void gui_window_set_title(struct gui_window *g, const char *restrict title) -{ - struct Node *node; - char *restrict utf8title; - - if(!g) return; - if(!title) return; - - utf8title = ami_utf8_easy((char *)title); - - if(g->tab_node) { - 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) 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) { @@ -4893,7 +5758,6 @@ static void ami_do_redraw(struct gui_window_2 *gwin) gwin->redraw_scroll = false; if(gwin->new_content) gwin->redraw_scroll = false; -// if(gwin->gw->scale != 1.0) gwin->redraw_scroll = false; } if(gwin->redraw_scroll) @@ -4962,22 +5826,20 @@ static void ami_do_redraw(struct gui_window_2 *gwin) } -void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs) +static 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; } } -void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys) +static 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; } @@ -5046,7 +5908,7 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect) if(g->shared->objects[GID_VSCROLL]) { RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL], g->shared->win, NULL, - SCROLLER_Top, (ULONG)(sy * g->scale), + SCROLLER_Top, (ULONG)(sy), TAG_DONE); } @@ -5054,7 +5916,7 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect) { RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL], g->shared->win, NULL, - SCROLLER_Top, (ULONG)(sx * g->scale), + SCROLLER_Top, (ULONG)(sx), TAG_DONE); } @@ -5069,45 +5931,6 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect) return NSERROR_OK; } -static void gui_window_update_extent(struct gui_window *g) -{ - struct IBox *bbox; - - if(!g || !g->bw) return; - if(browser_window_has_content(g->bw) == false) return; - - if(g == g->shared->gw) { - int width, height; - if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) { - amiga_warn_user("NoMemory", ""); - return; - } - - if(g->shared->objects[GID_VSCROLL]) { - browser_window_get_extents(g->bw, true, &width, &height); - RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL],g->shared->win,NULL, - SCROLLER_Total, (ULONG)(height), - SCROLLER_Visible, bbox->Height, - TAG_DONE); - } - - if(g->shared->objects[GID_HSCROLL]) - { - browser_window_get_extents(g->bw, true, &width, &height); - RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL], - g->shared->win, NULL, - SCROLLER_Total, (ULONG)(width), - SCROLLER_Visible, bbox->Width, - TAG_DONE); - } - - ami_gui_free_space_box(bbox); - } - - ami_gui_scroller_update(g->shared); - g->shared->new_content = true; -} - static void gui_window_set_status(struct gui_window *g, const char *text) { char *utf8text; @@ -5248,6 +6071,19 @@ HOOKF(uint32, ami_set_throbber_render_hook, APTR, space, struct gpRender *) return 0; } +HOOKF(uint32, ami_gui_browser_render_hook, APTR, space, struct gpRender *) +{ + struct gui_window_2 *gwin = hook->h_Data; + + NSLOG(netsurf, DEBUG, "Render hook called with %ld (REDRAW=1)", msg->gpr_Redraw); + + if(msg->gpr_Redraw != GREDRAW_REDRAW) return 0; + + ami_schedule_redraw(gwin, true); + + return 0; +} + static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip) { @@ -5395,7 +6231,7 @@ BOOL ami_gadget_hit(Object *obj, int x, int y) else return FALSE; } -Object *ami_gui_splash_open(void) +static Object *ami_gui_splash_open(void) { Object *restrict win_obj, *restrict bm_obj; struct Window *win; @@ -5494,7 +6330,7 @@ Object *ami_gui_splash_open(void) return win_obj; } -void ami_gui_splash_close(Object *win_obj) +static void ami_gui_splash_close(Object *win_obj) { if(win_obj == NULL) return; @@ -5605,6 +6441,53 @@ static char *ami_gui_get_user_dir(STRPTR current_user) return current_user_dir; } + +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_NEW_CONTENT: + gui_window_new_content(gw); + break; + + case GW_EVENT_START_SELECTION: + gui_start_selection(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + case GW_EVENT_PAGE_INFO_CHANGE: + gui_page_info_change(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + + static struct gui_window_table amiga_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, @@ -5612,26 +6495,23 @@ static struct gui_window_table amiga_window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = gui_window_event, .set_icon = gui_window_set_icon, .set_title = gui_window_set_title, .set_url = gui_window_set_url, .set_status = gui_window_set_status, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, .drag_start = gui_window_drag_start, - .new_content = gui_window_new_content, .create_form_select_menu = gui_create_form_select_menu, .file_gadget_open = gui_file_gadget_open, .drag_save_object = gui_drag_save_object, - .drag_save_selection =gui_drag_save_selection, - .start_selection = gui_start_selection, + .drag_save_selection = gui_drag_save_selection, + + .console_log = gui_window_console_log, /* from theme */ .set_pointer = gui_window_set_pointer, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, /* from download */ .save_link = gui_window_save_link, @@ -5650,12 +6530,10 @@ static struct gui_search_web_table amiga_search_web_table = { static struct gui_misc_table amiga_misc_table = { .schedule = ami_schedule, - .warning = amiga_warn_user, .quit = gui_quit, .launch_url = gui_launch_url, - .cert_verify = ami_cert_verify, - .login = gui_401login_open, + .present_cookies = ami_cookies_present, }; /** Normal entry point from OS */ @@ -5675,6 +6553,7 @@ int main(int argc, char** argv) struct netsurf_table amiga_table = { .misc = &amiga_misc_table, .window = &amiga_window_table, + .corewindow = amiga_core_window_table, .clipboard = amiga_clipboard_table, .download = amiga_download_table, .fetch = &amiga_fetch_table, diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h index 62390ce4f..70f1c505e 100644 --- a/frontends/amiga/gui.h +++ b/frontends/amiga/gui.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2017 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008-2019 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -38,48 +38,21 @@ #define HOOKF(ret,func,type,ptr,msgtype) static ASM ret func(REG(a0, struct Hook *hook),REG(a2, type ptr), REG(a1, msgtype msg)) #endif -enum -{ - OID_MAIN = 0, - OID_VSCROLL, - OID_HSCROLL, - GID_MAIN, - GID_TABLAYOUT, - GID_BROWSER, - GID_STATUS, - GID_URL, - GID_ICON, - GID_STOP, - GID_RELOAD, - GID_HOME, - GID_BACK, - GID_FORWARD, - GID_THROBBER, - GID_SEARCH_ICON, - GID_FAVE, - GID_FAVE_ADD, - GID_FAVE_RMV, - GID_CLOSETAB, - GID_CLOSETAB_BM, - GID_ADDTAB, - GID_ADDTAB_BM, - GID_TABS, - GID_TABS_FLAG, - GID_SEARCHSTRING, - GID_TOOLBARLAYOUT, - GID_HOTLIST, - GID_HOTLISTLAYOUT, - GID_HOTLISTSEPBAR, - GID_HSCROLL, - GID_HSCROLLLAYOUT, - GID_VSCROLL, - GID_VSCROLLLAYOUT, - GID_LAST +/* valid options for ami_gui_get_object */ +enum { + AMI_GAD_THROBBER = 0, + AMI_GAD_TABS, + AMI_GAD_URL, + AMI_GAD_SEARCH, + AMI_WIN_MAIN }; struct find_window; struct ami_history_local_window; struct ami_menu_data; +struct gui_window; +struct gui_window_2; +struct IBox; #define AMI_GUI_TOOLBAR_MAX 20 @@ -102,83 +75,7 @@ struct ami_generic_window { const struct ami_win_event_table *tbl; }; -struct gui_window_2 { - struct ami_generic_window w; - struct Window *win; - Object *restrict objects[GID_LAST]; - struct gui_window *gw; /* currently-displayed gui_window */ - bool redraw_required; - int throbber_frame; - struct List tab_list; - ULONG tabs; - ULONG next_tab; - struct Node *last_new_tab; - struct Hook scrollerhook; - struct form_control *control; - browser_mouse_state mouse_state; - browser_mouse_state key_state; - ULONG throbber_update_count; - struct find_window *searchwin; - ULONG oldh; - ULONG oldv; - int temp; - bool redraw_scroll; - bool new_content; - struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1]; /* only for GadTools menus */ - ULONG hotlist_items; - Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX]; - struct List hotlist_toolbar_list; - struct List *web_search_list; - Object *search_bm; - char *restrict svbuffer; - char *restrict status; - char *restrict wintitle; - char *restrict helphints[GID_LAST]; - browser_mouse_state prev_mouse_state; - struct timeval lastclick; - struct AppIcon *appicon; /* iconify appicon */ - struct DiskObject *dobj; /* iconify appicon */ - struct Hook favicon_hook; - struct Hook throbber_hook; - struct Hook *ctxmenu_hook; - Object *restrict history_ctxmenu[2]; - Object *restrict clicktab_ctxmenu; - gui_drag_type drag_op; - struct IBox *ptr_lock; - struct AppWindow *appwin; - struct MinList *shared_pens; - gui_pointer_shape mouse_pointer; - struct Menu *imenu; /* Intuition menu */ - bool closed; /* Window has been closed (via menu) */ -}; - -struct gui_window -{ - struct gui_window_2 *shared; - int tab; - struct Node *tab_node; - int c_x; /* Caret X posn */ - int c_y; /* Caret Y posn */ - int c_w; /* Caret width */ - int c_h; /* Caret height */ - int c_h_temp; - int scrollx; - int scrolly; - struct ami_history_local_window *hw; - struct List dllist; - struct hlcache_handle *favicon; - bool throbbing; - char *tabtitle; - APTR deferred_rects_pool; - struct MinList *deferred_rects; - struct browser_window *bw; - float scale; -}; - -extern struct MinList *window_list; /**\todo stop arexx.c poking about in here */ -extern struct Screen *scrn; -extern struct MsgPort *sport; -extern struct gui_window *cur_gw; +#define IS_CURRENT_GW(GWIN,GW) (ami_gui2_get_gui_window(GWIN) == GW) /* The return value for these functions must be deallocated using FreeVec() */ STRPTR ami_locale_langs(int *codeset); @@ -202,7 +99,14 @@ void ami_gui_update_hotlist_button(struct gui_window_2 *gwin); nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin); int ami_gui_count_windows(int window, int *tabs); void ami_gui_set_scale(struct gui_window *gw, float scale); +void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update); +void ami_reset_pointer(struct gui_window_2 *gwin); +void *ami_window_at_pointer(int type); +/** + * Beep + */ +void ami_gui_beep(void); /** * Close a window and all tabs attached to it. @@ -235,6 +139,13 @@ nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox); void ami_gui_free_space_box(struct IBox *bbox); /** + * Get shared message port + * + * @return Pointer to an initialised MsgPort + */ +struct MsgPort *ami_gui_get_shared_msgport(void); + +/** * Get the application.library ID NetSurf is registered as. * * @return App ID. @@ -242,6 +153,13 @@ void ami_gui_free_space_box(struct IBox *bbox); uint32 ami_gui_get_app_id(void); /** + * Get a pointer to the screen NetSurf is running on. + * + * @return Pointer to struct Screen. + */ +struct Screen *ami_gui_get_screen(void); + +/** * Get the string for NetSurf's screen titlebar. * * @return String to use as the screen's titlebar text. @@ -264,6 +182,15 @@ nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_tab void ami_gui_win_list_remove(void *win); /** + * Get the window list. + * + *\TODO: Nothing should be poking around in this list, but we aren't + * assigning unique IDs to windows (ARexx interface needs this) + * ami_find_gwin_by_id() is close but not ARexx-friendly + */ +struct MinList *ami_gui_get_window_list(void); + +/** * Get which qualifier keys are being pressed */ int ami_gui_get_quals(Object *win_obj); @@ -274,5 +201,167 @@ int ami_gui_get_quals(Object *win_obj); bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, const struct rect *restrict new_rect, APTR mempool); +/** + * Adjust scale by specified amount + */ +void ami_gui_adjust_scale(struct gui_window *gw, float adjustment); + +/** + * Get a pointer to the gui_window which NetSurf considers + * to be the current/active one + */ +struct gui_window *ami_gui_get_active_gw(void); + +/** + * Get browser window from gui_window + */ +struct browser_window *ami_gui_get_browser_window(struct gui_window *gw); + +/** + * Get browser window from gui_window_2 + */ +struct browser_window *ami_gui2_get_browser_window(struct gui_window_2 *gwin); + +/** + * Get gui_window_2 from gui_window + */ +struct gui_window_2 *ami_gui_get_gui_window_2(struct gui_window *gw); + +/** + * Get gui_window from gui_window_2 + */ +struct gui_window *ami_gui2_get_gui_window(struct gui_window_2 *gwin); + +/** + * Get download list from gui_window + */ +struct List *ami_gui_get_download_list(struct gui_window *gw); + +/** + * Get tab title from gui_window + */ +const char *ami_gui_get_tab_title(struct gui_window *gw); + +/** + * Get window title from gui_window + */ +const char *ami_gui_get_win_title(struct gui_window *gw); + +/** + * Get tab node from gui_window + */ +struct Node *ami_gui_get_tab_node(struct gui_window *gw); + +/** + * Get tabs from gui_window_2 + */ +ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin); + +/** + * Get tab list from gui_window_2 + */ +struct List *ami_gui2_get_tab_list(struct gui_window_2 *gwin); + +/** + * Get favicon from gui_window + */ +struct hlcache_handle *ami_gui_get_favicon(struct gui_window *gw); + +/** + * Get local history window from gui_window + */ +struct ami_history_local_window *ami_gui_get_history_window(struct gui_window *gw); + +/** + * Set local history window in gui_window + */ +void ami_gui_set_history_window(struct gui_window *gw, struct ami_history_local_window *hw); + +/** + * Set search window in gui_window + */ +void ami_gui_set_find_window(struct gui_window *gw, struct find_window *fw); + +/** + * Get throbbing status from gui_window + */ +bool ami_gui_get_throbbing(struct gui_window *gw); + +/** + * Get throbbing frame from gui_window + */ +int ami_gui_get_throbber_frame(struct gui_window *gw); + +/** + * Set throbbing frame in gui_window + */ +void ami_gui_set_throbber_frame(struct gui_window *gw, int frame); + +/** + * Set throbbing status in gui_window + */ +void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing); + +/** + * Get object from gui_window + */ +Object *ami_gui2_get_object(struct gui_window_2 *gwin, int object_type); + +/** + * Get window from gui_window + */ +struct Window *ami_gui_get_window(struct gui_window *gw); + +/** + * Get window from gui_window_2 + */ +struct Window *ami_gui2_get_window(struct gui_window_2 *gwin); + +/** + * Get imenu from gui_window + */ +struct Menu *ami_gui_get_menu(struct gui_window *gw); + +/** + * Set imenu to gui_window_2. A value of NULL will free the menu (and menu_data!) + */ +void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu); + +/** + * Get menu_data from gui_window_2 + */ +struct ami_menu_data **ami_gui2_get_menu_data(struct gui_window_2 *gwin); + +/** + * Set ctxmenu history tmp in gui_window_2 + */ +void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp); + +/** + * Get ctxmenu history tmp from gui_window_2 + */ +int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin); + +/** + * Get ctxmenu history from gui_window_2 + */ +Object *ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction); + +/** + * Set ctxmenu history in gui_window_2 + */ +void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist); + +/** + * Set closed in gui_window_2 + */ +void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed); + +/** + * Set new_content in gui_window_2 + * Indicates the window needs redrawing + */ +void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content); + #endif diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c index 6dbacf1ba..dc1450fce 100644 --- a/frontends/amiga/gui_menu.c +++ b/frontends/amiga/gui_menu.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2017-2024 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -141,7 +141,7 @@ HOOKF(void, ami_menu_item_project_save, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_file_save_req(type, gwin, browser_window_get_content(gwin->gw->bw)); + ami_file_save_req(type, gwin, browser_window_get_content(ami_gui2_get_browser_window(gwin))); } HOOKF(void, ami_menu_item_project_closetab, APTR, window, struct IntuiMessage *) @@ -149,7 +149,7 @@ HOOKF(void, ami_menu_item_project_closetab, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_destroy(gwin->gw->bw); + browser_window_destroy(ami_gui2_get_browser_window(gwin)); } HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *) @@ -157,7 +157,7 @@ HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - gwin->closed = true; + ami_gui2_set_closed(gwin, true); } HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *) @@ -166,7 +166,7 @@ HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); ami_set_pointer(gwin, GUI_POINTER_WAIT, false); - ami_print_ui(browser_window_get_content(gwin->gw->bw)); + ami_print_ui(browser_window_get_content(ami_gui2_get_browser_window(gwin))); ami_reset_pointer(gwin); } @@ -191,7 +191,7 @@ HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *) #ifdef __amigaos4__ sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO, TDR_TitleString, messages_get("NetSurf"), - TDR_Window, gwin->win, + TDR_Window, ami_gui2_get_window(gwin), TDR_GadgetString, temp2, TDR_FormatString,"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org", TDR_Arg1,netsurf_version, @@ -206,7 +206,7 @@ HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *) temp2, }; - sel = EasyRequest(gwin->win, &about_req, NULL, netsurf_version, verdate); + sel = EasyRequest(ami_gui2_get_window(gwin), &about_req, NULL, netsurf_version, verdate); #endif free(temp2); @@ -243,7 +243,7 @@ HOOKF(void, ami_menu_item_edit_cut, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_key_press(gwin->gw->bw, NS_KEY_CUT_SELECTION); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_CUT_SELECTION); } HOOKF(void, ami_menu_item_edit_copy, APTR, window, struct IntuiMessage *) @@ -252,22 +252,22 @@ HOOKF(void, ami_menu_item_edit_copy, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - if(browser_window_can_select(gwin->gw->bw)) { - browser_window_key_press(gwin->gw->bw, NS_KEY_COPY_SELECTION); - browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION); + if(browser_window_can_select(ami_gui2_get_browser_window(gwin))) { + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_COPY_SELECTION); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_CLEAR_SELECTION); } - else if((bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw)))) { + else if((bm = content_get_bitmap(browser_window_get_content(ami_gui2_get_browser_window(gwin))))) { /** @todo It should be checked that the lifetime of * the objects containing the values returned (and the * constness cast away) is safe. */ - ami_bitmap_set_url(bm, browser_window_access_url(gwin->gw->bw)); - ami_bitmap_set_title(bm, browser_window_get_title(gwin->gw->bw)); + ami_bitmap_set_url(bm, browser_window_access_url(ami_gui2_get_browser_window(gwin))); + ami_bitmap_set_title(bm, browser_window_get_title(ami_gui2_get_browser_window(gwin))); ami_easy_clipboard_bitmap(bm); } #ifdef WITH_NS_SVG - else if(ami_mime_compare(browser_window_get_content(gwin->gw->bw), "svg") == true) { - ami_easy_clipboard_svg(browser_window_get_content(gwin->gw->bw)); + else if(ami_mime_compare(browser_window_get_content(ami_gui2_get_browser_window(gwin)), "svg") == true) { + ami_easy_clipboard_svg(browser_window_get_content(ami_gui2_get_browser_window(gwin))); } #endif } @@ -277,7 +277,7 @@ HOOKF(void, ami_menu_item_edit_paste, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_key_press(gwin->gw->bw, NS_KEY_PASTE); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_PASTE); } HOOKF(void, ami_menu_item_edit_selectall, APTR, window, struct IntuiMessage *) @@ -285,8 +285,8 @@ HOOKF(void, ami_menu_item_edit_selectall, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_key_press(gwin->gw->bw, NS_KEY_SELECT_ALL); - gui_start_selection(gwin->gw); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_SELECT_ALL); + gui_start_selection(ami_gui2_get_gui_window(gwin)); } HOOKF(void, ami_menu_item_edit_clearsel, APTR, window, struct IntuiMessage *) @@ -294,7 +294,7 @@ HOOKF(void, ami_menu_item_edit_clearsel, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_CLEAR_SELECTION); } HOOKF(void, ami_menu_item_edit_undo, APTR, window, struct IntuiMessage *) @@ -302,7 +302,7 @@ HOOKF(void, ami_menu_item_edit_undo, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_key_press(gwin->gw->bw, NS_KEY_UNDO); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_UNDO); } HOOKF(void, ami_menu_item_edit_redo, APTR, window, struct IntuiMessage *) @@ -310,7 +310,7 @@ HOOKF(void, ami_menu_item_edit_redo, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - browser_window_key_press(gwin->gw->bw, NS_KEY_REDO); + browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_REDO); } HOOKF(void, ami_menu_item_browser_find, APTR, window, struct IntuiMessage *) @@ -318,7 +318,7 @@ HOOKF(void, ami_menu_item_browser_find, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_search_open(gwin->gw); + ami_search_open(ami_gui2_get_gui_window(gwin)); } HOOKF(void, ami_menu_item_browser_localhistory, APTR, window, struct IntuiMessage *) @@ -326,7 +326,7 @@ HOOKF(void, ami_menu_item_browser_localhistory, APTR, window, struct IntuiMessag struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_history_local_present(gwin->gw); + ami_history_local_present(ami_gui2_get_gui_window(gwin)); } HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessage *) @@ -336,7 +336,7 @@ HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessa HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *) { - ami_cookies_present(); + ami_cookies_present(NULL); } HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *) @@ -375,12 +375,24 @@ HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *) ami_gui_menu_set_check_toggled(); } +HOOKF(void, ami_menu_item_browser_enablecss, APTR, window, struct IntuiMessage *) +{ + struct Menu *menustrip; + bool checked = false; + + GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip); + checked = ami_menu_get_selected(menustrip, msg); + + nsoption_set_bool(author_level_css, checked); + ami_gui_menu_set_check_toggled(); +} + HOOKF(void, ami_menu_item_browser_scale_decrease, APTR, window, struct IntuiMessage *) { struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1); + ami_gui_adjust_scale(ami_gui2_get_gui_window(gwin), -0.1); } HOOKF(void, ami_menu_item_browser_scale_normal, APTR, window, struct IntuiMessage *) @@ -388,7 +400,7 @@ HOOKF(void, ami_menu_item_browser_scale_normal, APTR, window, struct IntuiMessag struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_gui_set_scale(gwin->gw, 1.0); + ami_gui_set_scale(ami_gui2_get_gui_window(gwin), 1.0); } HOOKF(void, ami_menu_item_browser_scale_increase, APTR, window, struct IntuiMessage *) @@ -396,7 +408,7 @@ HOOKF(void, ami_menu_item_browser_scale_increase, APTR, window, struct IntuiMess struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1); + ami_gui_adjust_scale(ami_gui2_get_gui_window(gwin), +0.1); } HOOKF(void, ami_menu_item_browser_redraw, APTR, window, struct IntuiMessage *) @@ -405,7 +417,7 @@ HOOKF(void, ami_menu_item_browser_redraw, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); ami_schedule_redraw(gwin, true); - gwin->new_content = true; + ami_gui2_set_new_content(gwin, true); } HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *) @@ -414,7 +426,7 @@ HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - bw = gwin->gw->bw; + bw = ami_gui2_get_browser_window(gwin); if (bw == NULL || browser_window_has_content(bw) == false) return; @@ -436,7 +448,7 @@ HOOKF(void, ami_menu_item_hotlist_entries, APTR, window, struct IntuiMessage *) if(url == NULL) return; - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), url, NULL, BW_NAVIGATE_HISTORY, @@ -455,10 +467,10 @@ HOOKF(void, ami_menu_item_settings_snapshot, APTR, window, struct IntuiMessage * struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - nsoption_set_int(window_x, gwin->win->LeftEdge); - nsoption_set_int(window_y, gwin->win->TopEdge); - nsoption_set_int(window_width, gwin->win->Width); - nsoption_set_int(window_height, gwin->win->Height); + nsoption_set_int(window_x, ami_gui2_get_window(gwin)->LeftEdge); + nsoption_set_int(window_y, ami_gui2_get_window(gwin)->TopEdge); + nsoption_set_int(window_width, ami_gui2_get_window(gwin)->Width); + nsoption_set_int(window_height, ami_gui2_get_window(gwin)->Height); } HOOKF(void, ami_menu_item_settings_save, APTR, window, struct IntuiMessage *) @@ -473,10 +485,10 @@ HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); if(AslRequestTags(filereq, - ASLFR_Window, gwin->win, + ASLFR_Window, ami_gui2_get_window(gwin), ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_DoSaveMode, FALSE, ASLFR_InitialDrawer, nsoption_charp(arexx_dir), ASLFR_InitialPattern, "#?.nsrx", @@ -582,6 +594,10 @@ ULONG ami_gui_menu_number(int item) case M_JS: menu_num = FULLMENUNUM(2,9,0); break; + + case M_CSS: + menu_num = FULLMENUNUM(2,10,0); + break; default: NSLOG(netsurf, INFO, @@ -681,7 +697,7 @@ void ami_gui_menu_update_checked(struct gui_window_2 *gwin) struct Menu *menustrip; - GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip); + GetAttr(WINDOW_MenuStrip, ami_gui2_get_object(gwin, AMI_WIN_MAIN), (ULONG *)&menustrip); if(!menustrip) return; if(nsoption_bool(enable_javascript) == true) { if((ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags & CHECKED) == 0) @@ -690,6 +706,13 @@ void ami_gui_menu_update_checked(struct gui_window_2 *gwin) if(ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags & CHECKED) ItemAddress(menustrip, ami_gui_menu_number(M_JS))->Flags ^= CHECKED; } + if(nsoption_bool(author_level_css) == true) { + if((ItemAddress(menustrip, ami_gui_menu_number(M_CSS))->Flags & CHECKED) == 0) + ItemAddress(menustrip, ami_gui_menu_number(M_CSS))->Flags ^= CHECKED; + } else { + if(ItemAddress(menustrip, ami_gui_menu_number(M_CSS))->Flags & CHECKED) + ItemAddress(menustrip, ami_gui_menu_number(M_CSS))->Flags ^= CHECKED; + } if(nsoption_bool(foreground_images) == true) { if((ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags & CHECKED) == 0) ItemAddress(menustrip, ami_gui_menu_number(M_IMGFORE))->Flags ^= CHECKED; @@ -706,24 +729,24 @@ void ami_gui_menu_update_checked(struct gui_window_2 *gwin) ItemAddress(menustrip, ami_gui_menu_number(M_IMGBACK))->Flags ^= CHECKED; } - ResetMenuStrip(gwin->win, menustrip); + ResetMenuStrip(ami_gui2_get_window(gwin), menustrip); } void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c) { - struct Window *win = g->shared->win; + struct Window *win = ami_gui_get_window(g); if(nsoption_bool(kiosk_mode) == true) return; if(content_get_type(c) <= CONTENT_CSS) { - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVETXT, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVECOMP, false); #ifdef WITH_PDF_EXPORT - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVEPDF, false); #endif #if 0 - if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY) { + if(browser_window_get_editor_flags(ami_gui_get_browser_window(g)) & BW_EDITOR_CAN_COPY) { OnMenu(win,AMI_MENU_COPY); OnMenu(win,AMI_MENU_CLEAR); } else { @@ -731,39 +754,39 @@ void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c OffMenu(win,AMI_MENU_CLEAR); } - if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT) + if(browser_window_get_editor_flags(ami_gui_get_browser_window(g)) & BW_EDITOR_CAN_CUT) OnMenu(win,AMI_MENU_CUT); else OffMenu(win,AMI_MENU_CUT); - if(browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_PASTE) + if(browser_window_get_editor_flags(ami_gui_get_browser_window(g)) & BW_EDITOR_CAN_PASTE) OnMenu(win,AMI_MENU_PASTE); else OffMenu(win,AMI_MENU_PASTE); #else - ami_gui_menu_set_disabled(win, g->shared->imenu, M_CUT, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_PASTE, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_CLEAR, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_CUT, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_COPY, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_PASTE, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_CLEAR, false); #endif - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SELALL, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_FIND, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SELALL, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_FIND, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVEIFF, true); } else { - ami_gui_menu_set_disabled(win, g->shared->imenu, M_CUT, true); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_PASTE, true); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_CLEAR, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_CUT, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_PASTE, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_CLEAR, true); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVETXT, true); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVECOMP, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVETXT, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVECOMP, true); #ifdef WITH_PDF_EXPORT - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEPDF, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVEPDF, true); #endif - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SELALL, true); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_FIND, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SELALL, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_FIND, true); #ifdef WITH_NS_SVG if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true)) @@ -771,13 +794,13 @@ void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c if(content_get_bitmap(c)) #endif { - ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, false); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_COPY, false); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVEIFF, false); } else { - ami_gui_menu_set_disabled(win, g->shared->imenu, M_COPY, true); - ami_gui_menu_set_disabled(win, g->shared->imenu, M_SAVEIFF, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_COPY, true); + ami_gui_menu_set_disabled(win, ami_gui_get_menu(g), M_SAVEIFF, true); } } } @@ -919,6 +942,10 @@ static void ami_init_menulabs(struct ami_menu_data **md) if(nsoption_bool(enable_javascript) == true) js_flags |= CHECKED; + UWORD css_flags = CHECKIT | MENUTOGGLE; + if(nsoption_bool(author_level_css) == true) + css_flags |= CHECKED; + UWORD imgfore_flags = CHECKIT | MENUTOGGLE; if(nsoption_bool(foreground_images) == true) imgfore_flags |= CHECKED; @@ -1007,6 +1034,8 @@ static void ami_init_menulabs(struct ami_menu_data **md) ami_menu_item_browser_backimg, NULL, imgback_flags); ami_menu_alloc_item(md, M_JS, NM_ITEM, "EnableJS", NULL, NULL, ami_menu_item_browser_enablejs, NULL, js_flags); + ami_menu_alloc_item(md, M_CSS, NM_ITEM, "EnableCSS", NULL, NULL, + ami_menu_item_browser_enablecss, NULL, css_flags); ami_menu_alloc_item(md, M_BAR_B4, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0); ami_menu_alloc_item(md, M_REDRAW, NM_ITEM, "Redraw", NULL, "TBImages:list_wand", ami_menu_item_browser_redraw, NULL, 0); @@ -1035,26 +1064,32 @@ struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin) if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) { #ifdef __amigaos4__ if(gui_menu != NULL) { - gwin->imenu = gui_menu; + ami_gui2_set_menu(gwin, gui_menu); gui_menu_count++; - return gwin->imenu; + return gui_menu; } ami_init_menulabs(gui_menu_data); ami_menu_scan(gui_menu_data); ami_menu_arexx_scan(gui_menu_data); - gwin->imenu = ami_menu_layout(gui_menu_data, AMI_MENU_AREXX_MAX); + gui_menu = ami_menu_layout(gui_menu_data, AMI_MENU_AREXX_MAX); - gui_menu = gwin->imenu; + ami_gui2_set_menu(gwin, gui_menu); gui_menu_count++; + return gui_menu; #endif } else { - ami_init_menulabs(gwin->menu_data); - ami_menu_scan(gwin->menu_data); - ami_menu_arexx_scan(gwin->menu_data); - gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX); + struct Menu *temp_menu; + struct ami_menu_data **md = ami_gui2_get_menu_data(gwin); + + ami_init_menulabs(md); + ami_menu_scan(md); + ami_menu_arexx_scan(md); + temp_menu = ami_menu_layout(md, AMI_MENU_AREXX_MAX); + ami_gui2_set_menu(gwin, temp_menu); + return temp_menu; } - return gwin->imenu; + return NULL; // shouldn't get this far } static void ami_free_menulabs(struct ami_menu_data **md) @@ -1089,13 +1124,24 @@ static void ami_free_menulabs(struct ami_menu_data **md) } } +void ami_gui_menu_freemenus(struct Menu *menu, struct ami_menu_data **md) +{ + if(menu != NULL) { + FreeMenus(menu); + } + + if(md != NULL) { + ami_free_menulabs(md); + } +} + void ami_gui_menu_free(struct gui_window_2 *gwin) { if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) { #ifdef __amigaos4__ gui_menu_count--; - SetAttrs(gwin->objects[OID_MAIN], WINDOW_MenuStrip, NULL, TAG_DONE); + SetAttrs(ami_gui2_get_object(gwin, AMI_WIN_MAIN), WINDOW_MenuStrip, NULL, TAG_DONE); if(gui_menu_count == 0) { ami_free_menulabs(gui_menu_data); @@ -1105,8 +1151,7 @@ void ami_gui_menu_free(struct gui_window_2 *gwin) } #endif } else { - ami_free_menulabs(gwin->menu_data); - FreeMenus(gwin->imenu); + ami_gui2_set_menu(gwin, NULL); } } diff --git a/frontends/amiga/gui_menu.h b/frontends/amiga/gui_menu.h index 3490fe9c1..ae36397c5 100644 --- a/frontends/amiga/gui_menu.h +++ b/frontends/amiga/gui_menu.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2017 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008-2024 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -78,13 +78,14 @@ enum { M_IMGFORE, M_IMGBACK, M_JS, + M_CSS, M_BAR_B4, M_REDRAW, /* Hotlist menu */ M_HOTLIST, M_HLADD, M_HLSHOW, - M_BAR_H1, // 47 + M_BAR_H1, // 48 AMI_MENU_HOTLIST, /* Where the hotlist entries start */ AMI_MENU_HOTLIST_MAX = AMI_MENU_HOTLIST + AMI_HOTLIST_ITEMS, /* Settings menu */ @@ -109,6 +110,7 @@ struct gui_window; struct gui_window_2; struct hlcache_handle; struct Window; +struct ami_menu_data; ULONG ami_gui_menu_number(int item); struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin); @@ -154,5 +156,10 @@ void ami_gui_menu_refresh_hotlist(void); * \return true if NetSurf has been quit */ bool ami_gui_menu_quit_selected(void); + +/** + * Frees a menu. Only used on OS3 and old OS4. + */ +void ami_gui_menu_freemenus(struct Menu *menu, struct ami_menu_data **md); #endif diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c index fb214d0fb..def43cf04 100755 --- a/frontends/amiga/gui_options.c +++ b/frontends/amiga/gui_options.c @@ -1,5 +1,5 @@ /* - * Copyright 2009 - 2012 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2009 - 2024 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -83,7 +83,8 @@ enum { - GID_OPTS_MAIN = GID_MAIN, + OID_MAIN = 0, + GID_OPTS_MAIN, GID_OPTS_HOMEPAGE, GID_OPTS_HOMEPAGE_DEFAULT, GID_OPTS_HOMEPAGE_CURRENT, @@ -93,6 +94,7 @@ enum GID_OPTS_FROMLOCALE, GID_OPTS_HISTORY, GID_OPTS_JAVASCRIPT, + GID_OPTS_ENABLECSS, GID_OPTS_REFERRAL, GID_OPTS_DONOTTRACK, GID_OPTS_FASTSCROLL, @@ -101,6 +103,9 @@ enum GID_OPTS_SCREENNAME, GID_OPTS_WIN_SIMPLE, GID_OPTS_THEME, + GID_OPTS_THEMEPAGE, + GID_OPTS_DARK, + GID_OPTS_LIGHT, GID_OPTS_PTRTRUE, GID_OPTS_PTROS, GID_OPTS_PROXY, @@ -115,7 +120,6 @@ enum GID_OPTS_NATIVEBM, GID_OPTS_SCALEQ, GID_OPTS_DITHERQ, - GID_OPTS_ANIMSPEED, GID_OPTS_ANIMDISABLE, GID_OPTS_DPI_Y, GID_OPTS_FONT_SANS, @@ -210,6 +214,7 @@ enum #define OPTS_LAST LAB_OPTS_LAST #define OPTS_MAX_TABS 10 #define OPTS_MAX_SCREEN 4 +#define OPTS_MAX_THEMEPAGE 3 #define OPTS_MAX_PROXY 5 #define OPTS_MAX_NATIVEBM 4 #define OPTS_MAX_DITHER 4 @@ -227,11 +232,13 @@ struct ami_gui_opts_window { #ifndef __amigaos4__ struct List clicktablist; struct List screenoptslist; + struct List pagethemeoptslist; struct List proxyoptslist; struct List nativebmoptslist; struct List ditheroptslist; struct List fontoptslist; #endif + int websearch_idx; }; static BOOL ami_gui_opts_event(void *w); @@ -246,6 +253,7 @@ static struct ami_gui_opts_window *gow = NULL; static CONST_STRPTR tabs[OPTS_MAX_TABS]; static STRPTR screenopts[OPTS_MAX_SCREEN]; +static CONST_STRPTR pagethemeopts[OPTS_MAX_THEMEPAGE]; static CONST_STRPTR proxyopts[OPTS_MAX_PROXY]; static CONST_STRPTR nativebmopts[OPTS_MAX_NATIVEBM]; static CONST_STRPTR ditheropts[OPTS_MAX_DITHER]; @@ -333,6 +341,10 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) screenopts[2] = (char *)ami_utf8_easy((char *)messages_get("ScreenPublic")); screenopts[3] = NULL; + pagethemeopts[0] = (char *)ami_utf8_easy((char *)messages_get("Light")); + pagethemeopts[1] = (char *)ami_utf8_easy((char *)messages_get("Dark")); + pagethemeopts[2] = NULL; + proxyopts[0] = (char *)ami_utf8_easy((char *)messages_get("ProxyNone")); proxyopts[1] = (char *)ami_utf8_easy((char *)messages_get("ProxyNoAuth")); proxyopts[2] = (char *)ami_utf8_easy((char *)messages_get("ProxyBasic")); @@ -349,7 +361,8 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) ditheropts[2] = (char *)ami_utf8_easy((char *)messages_get("High")); ditheropts[3] = NULL; - websearch_list = ami_gui_opts_websearch(); + gow->websearch_idx = 0; + websearch_list = ami_gui_opts_websearch(&gow->websearch_idx); gadlab[GID_OPTS_HOMEPAGE] = (char *)ami_utf8_easy((char *)messages_get("HomePageURL")); gadlab[GID_OPTS_HOMEPAGE_DEFAULT] = (char *)ami_utf8_easy((char *)messages_get("HomePageDefault")); @@ -359,10 +372,15 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) gadlab[GID_OPTS_FROMLOCALE] = (char *)ami_utf8_easy((char *)messages_get("LocaleLang")); gadlab[GID_OPTS_HISTORY] = (char *)ami_utf8_easy((char *)messages_get("HistoryAge")); gadlab[GID_OPTS_JAVASCRIPT] = (char *)ami_utf8_easy((char *)messages_get("EnableJS")); + gadlab[GID_OPTS_ENABLECSS] = (char *)ami_utf8_easy((char *)messages_get("EnableCSS")); gadlab[GID_OPTS_REFERRAL] = (char *)ami_utf8_easy((char *)messages_get("SendReferer")); gadlab[GID_OPTS_DONOTTRACK] = (char *)ami_utf8_easy((char *)messages_get("DoNotTrack")); gadlab[GID_OPTS_FASTSCROLL] = (char *)ami_utf8_easy((char *)messages_get("FastScrolling")); gadlab[GID_OPTS_WIN_SIMPLE] = (char *)ami_utf8_easy((char *)messages_get("SimpleRefresh")); + gadlab[GID_OPTS_THEME] = (char *)ami_utf8_easy((char *)messages_get("ThemeGUI")); + gadlab[GID_OPTS_THEMEPAGE] = (char *)ami_utf8_easy((char *)messages_get("ThemePage")); + gadlab[GID_OPTS_DARK] = (char *)ami_utf8_easy((char *)messages_get("Dark")); + gadlab[GID_OPTS_LIGHT] = (char *)ami_utf8_easy((char *)messages_get("Light")); gadlab[GID_OPTS_PTRTRUE] = (char *)ami_utf8_easy((char *)messages_get("TrueColour")); gadlab[GID_OPTS_PTROS] = (char *)ami_utf8_easy((char *)messages_get("OSPointers")); gadlab[GID_OPTS_PROXY] = (char *)ami_utf8_easy((char *)messages_get("ProxyType")); @@ -376,7 +394,6 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) gadlab[GID_OPTS_NATIVEBM] = (char *)ami_utf8_easy((char *)messages_get("CacheNative")); gadlab[GID_OPTS_SCALEQ] = (char *)ami_utf8_easy((char *)messages_get("ScaleQuality")); gadlab[GID_OPTS_DITHERQ] = (char *)ami_utf8_easy((char *)messages_get("DitherQuality")); - gadlab[GID_OPTS_ANIMSPEED] = (char *)ami_utf8_easy((char *)messages_get("AnimSpeedLimit")); gadlab[GID_OPTS_DPI_Y] = (char *)ami_utf8_easy((char *)messages_get("ResolutionY")); gadlab[GID_OPTS_ANIMDISABLE] = (char *)ami_utf8_easy((char *)messages_get("AnimDisable")); gadlab[GID_OPTS_FONT_SANS] = (char *)ami_utf8_easy((char *)messages_get("FontSans")); @@ -422,7 +439,6 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) gadlab[LAB_OPTS_WINTITLE] = (char *)ami_utf8_easy((char *)messages_get("Preferences")); gadlab[LAB_OPTS_RESTART] = (char *)ami_utf8_easy((char *)messages_get("NeedRestart")); gadlab[LAB_OPTS_DAYS] = (char *)ami_utf8_easy((char *)messages_get("Days")); - gadlab[LAB_OPTS_SECS] = (char *)ami_utf8_easy((char *)messages_get("AnimSpeedFrames")); gadlab[LAB_OPTS_PT] = (char *)ami_utf8_easy((char *)messages_get("Pt")); gadlab[LAB_OPTS_MM] = (char *)ami_utf8_easy((char *)messages_get("MM")); gadlab[LAB_OPTS_MB] = (char *)ami_utf8_easy((char *)messages_get("MBytes")); @@ -468,6 +484,7 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) #ifndef __amigaos4__ ami_gui_opts_array_to_list(&gow->clicktablist, tabs, NSA_LIST_CLICKTAB); ami_gui_opts_array_to_list(&gow->screenoptslist, screenopts, NSA_LIST_RADIO); + ami_gui_opts_array_to_list(&gow->pagethemeoptslist, pagethemeopts, NSA_LIST_CHOOSER); ami_gui_opts_array_to_list(&gow->proxyoptslist, proxyopts, NSA_LIST_CHOOSER); ami_gui_opts_array_to_list(&gow->nativebmoptslist, nativebmopts, NSA_LIST_CHOOSER); ami_gui_opts_array_to_list(&gow->ditheroptslist, ditheropts, NSA_LIST_CHOOSER); @@ -499,6 +516,7 @@ static void ami_gui_opts_free(struct ami_gui_opts_window *gow) #ifndef __amigaos4__ ami_gui_opts_free_list(&gow->clicktablist, NSA_LIST_CLICKTAB); ami_gui_opts_free_list(&gow->screenoptslist, NSA_LIST_RADIO); + ami_gui_opts_free_list(&gow->pagethemeoptslist, NSA_LIST_CHOOSER); ami_gui_opts_free_list(&gow->proxyoptslist, NSA_LIST_CHOOSER); ami_gui_opts_free_list(&gow->nativebmoptslist, NSA_LIST_CHOOSER); ami_gui_opts_free_list(&gow->ditheroptslist, NSA_LIST_CHOOSER); @@ -513,12 +531,11 @@ void ami_gui_opts_open(void) ULONG proxytype = 0; BOOL screenmodedisabled = FALSE, screennamedisabled = FALSE; BOOL proxyhostdisabled = TRUE, proxyauthdisabled = TRUE, proxybypassdisabled = FALSE; - BOOL disableanims, animspeeddisabled = FALSE, acceptlangdisabled = FALSE; + BOOL disableanims, acceptlangdisabled = FALSE; BOOL scaleselected = nsoption_bool(scale_quality), scaledisabled = FALSE; BOOL ditherdisable = TRUE; BOOL download_notify_disabled = FALSE, tab_always_show_disabled = FALSE; BOOL ptr_disable = FALSE; - char animspeed[10]; char *homepage_url_lc = ami_utf8_easy(nsoption_charp(homepage_url)); struct TextAttr fontsans, fontserif, fontmono, fontcursive, fontfantasy; @@ -582,17 +599,13 @@ void ami_gui_opts_open(void) proxybypassdisabled = TRUE; } - sprintf(animspeed,"%.2f",(float)(nsoption_int(minimum_gif_delay)/100.0)); - if(nsoption_bool(animate_images)) { disableanims = FALSE; - animspeeddisabled = FALSE; } else { disableanims = TRUE; - animspeeddisabled = TRUE; } if(nsoption_bool(accept_lang_locale)) @@ -656,8 +669,8 @@ void ami_gui_opts_open(void) WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, FALSE, - WA_PubScreen,scrn, - WINDOW_SharedPort,sport, + WA_PubScreen, ami_gui_get_screen(), + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_UserData,gow, WINDOW_IconifyGadget, FALSE, WINDOW_Position, WPOS_CENTERSCREEN, @@ -865,6 +878,23 @@ void ami_gui_opts_open(void) GETFILE_ReadOnly, TRUE, GETFILE_FullFileExpand, FALSE, GetFileEnd, + CHILD_Label, LabelObj, + LABEL_Text, gadlab[GID_OPTS_THEME], + LabelEnd, + LAYOUT_AddChild, gow->objects[GID_OPTS_THEMEPAGE] = ChooserObj, + GA_ID, GID_OPTS_THEMEPAGE, + GA_RelVerify, TRUE, + CHOOSER_PopUp, TRUE, +#ifdef __amigaos4__ + CHOOSER_LabelArray, pagethemeopts, +#else + CHOOSER_Labels, &gow->pagethemeoptslist, +#endif + CHOOSER_Selected, nsoption_bool(prefer_dark_mode), + ChooserEnd, + CHILD_Label, LabelObj, + LABEL_Text, gadlab[GID_OPTS_THEMEPAGE], + LabelEnd, LayoutEnd, // theme CHILD_WeightedHeight, 0, LAYOUT_AddChild, LayoutVObj, @@ -1070,24 +1100,6 @@ void ami_gui_opts_open(void) LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, gadlab[GRP_OPTS_ANIMS], - LAYOUT_AddChild, LayoutHObj, - LAYOUT_LabelColumn, PLACETEXT_RIGHT, - LAYOUT_AddChild, gow->objects[GID_OPTS_ANIMSPEED] = StringObj, - GA_ID, GID_OPTS_ANIMSPEED, - GA_RelVerify, TRUE, - GA_Disabled, animspeeddisabled, - STRINGA_HookType, SHK_FLOAT, - STRINGA_TextVal, animspeed, - STRINGA_BufferPos,0, - StringEnd, - CHILD_WeightedWidth, 0, - CHILD_Label, LabelObj, - LABEL_Text, gadlab[LAB_OPTS_SECS], - LabelEnd, - LayoutEnd, - CHILD_Label, LabelObj, - LABEL_Text, gadlab[GID_OPTS_ANIMSPEED], - LabelEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_ANIMDISABLE] = CheckBoxObj, GA_ID, GID_OPTS_ANIMDISABLE, GA_RelVerify, TRUE, @@ -1464,7 +1476,7 @@ void ami_gui_opts_open(void) GA_RelVerify, TRUE, CHOOSER_PopUp, TRUE, CHOOSER_Labels, websearch_list, - CHOOSER_Selected, nsoption_int(search_provider), + CHOOSER_Selected, &gow->websearch_idx, CHOOSER_MaxLabels, 40, ChooserEnd, CHILD_Label, LabelObj, @@ -1491,6 +1503,12 @@ void ami_gui_opts_open(void) GA_Selected, !nsoption_bool(core_select_menu), GA_Disabled, !ami_selectmenu_is_safe(), CheckBoxEnd, + LAYOUT_AddChild, gow->objects[GID_OPTS_ENABLECSS] = CheckBoxObj, + GA_ID, GID_OPTS_ENABLECSS, + GA_RelVerify, TRUE, + GA_Text, gadlab[GID_OPTS_ENABLECSS], + GA_Selected, nsoption_bool(author_level_css), + CheckBoxEnd, LayoutEnd, // misc CHILD_WeightedHeight, 0, @@ -1683,7 +1701,7 @@ void ami_gui_opts_open(void) static void ami_gui_opts_use(bool save) { ULONG data, id = 0; - float animspeed; + struct Node *tmp_node = NULL; struct TextAttr *tattr; char *dot; bool rescan_fonts = false; @@ -1735,7 +1753,16 @@ static void ami_gui_opts_use(bool save) } else { nsoption_set_bool(do_not_track, false); } - + + GetAttr(GA_Selected,gow->objects[GID_OPTS_ENABLECSS],(ULONG *)&data); + if (data) { + nsoption_set_bool(author_level_css, true); + } else { + nsoption_set_bool(author_level_css, false); + } + + ami_gui_menu_set_checked(NULL, M_CSS, nsoption_bool(author_level_css)); + GetAttr(GA_Selected,gow->objects[GID_OPTS_FASTSCROLL],(ULONG *)&data); if (data) { nsoption_set_bool(faster_scroll, true); @@ -1780,6 +1807,13 @@ static void ami_gui_opts_use(bool save) GetAttr(GETFILE_Drawer,gow->objects[GID_OPTS_THEME],(ULONG *)&data); nsoption_set_charp(theme, (char *)strdup((char *)data)); + GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_THEMEPAGE],(ULONG *)&data); + if(data) { + nsoption_set_bool(prefer_dark_mode, true); + } else { + nsoption_set_bool(prefer_dark_mode, false); + } + GetAttr(GA_Selected,gow->objects[GID_OPTS_PTRTRUE],(ULONG *)&data); if (data) { nsoption_set_bool(truecolour_mouse_pointers, true); @@ -1834,10 +1868,6 @@ static void ami_gui_opts_use(bool save) GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_DITHERQ],(ULONG *)&nsoption_int(dither_quality)); - GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_ANIMSPEED],(ULONG *)&data); - animspeed = strtof((char *)data, NULL); - nsoption_set_int(minimum_gif_delay, (int)(animspeed * 100)); - GetAttr(GA_Selected,gow->objects[GID_OPTS_ANIMDISABLE],(ULONG *)&data); if(data) { nsoption_set_bool(animate_images, false); @@ -1982,8 +2012,18 @@ static void ami_gui_opts_use(bool save) if(old_tab_always_show != nsoption_bool(tab_always_show)) ami_gui_tabs_toggle_all(); - GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_SEARCH_PROV],(ULONG *)&nsoption_int(search_provider)); - search_web_select_provider(nsoption_int(search_provider)); +#ifdef __amigaos4__ + GetAttr(CHOOSER_SelectedNode, gow->objects[GID_OPTS_SEARCH_PROV],(ULONG *)&tmp_node); + if(tmp_node != NULL) { + GetChooserNodeAttrs(tmp_node, CNA_Text, (ULONG *)&data, TAG_DONE); + nsoption_set_charp(search_web_provider, (char *)data); + } +#else + GetAttr(CHOOSER_Selected, gow->objects[GID_OPTS_SEARCH_PROV],(ULONG *)&gow->websearch_idx); + /* TODO: convert back to string, only required OS<3.2 */ +#endif + + search_web_select_provider(nsoption_charp(search_web_provider)); GetAttr(GA_Selected,gow->objects[GID_OPTS_CLIPBOARD],(ULONG *)&data); if (data) { @@ -2108,10 +2148,10 @@ static BOOL ami_gui_opts_event(void *w) case WMHI_GADGETHELP: if((result & WMHI_GADGETMASK) == 0) { /* Pointer not over our window */ - ami_help_open(AMI_HELP_MAIN, scrn); + ami_help_open(AMI_HELP_MAIN, ami_gui_get_screen()); } else { /* TODO: Make this sensitive to the tab the user is currently on */ - ami_help_open(AMI_HELP_PREFS, scrn); + ami_help_open(AMI_HELP_PREFS, ami_gui_get_screen()); } break; @@ -2140,9 +2180,9 @@ static BOOL ami_gui_opts_event(void *w) break; case GID_OPTS_HOMEPAGE_CURRENT: - if(cur_gw) RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_HOMEPAGE], + if(ami_gui_get_active_gw()) RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_HOMEPAGE], gow->win, NULL, STRINGA_TextVal, - nsurl_access(browser_window_access_url(cur_gw->bw)), TAG_DONE); + nsurl_access(browser_window_access_url(ami_gui_get_browser_window(ami_gui_get_active_gw()))), TAG_DONE); break; case GID_OPTS_HOMEPAGE_BLANK: @@ -2249,8 +2289,6 @@ static BOOL ami_gui_opts_event(void *w) break; case GID_OPTS_ANIMDISABLE: - RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_ANIMSPEED], - gow->win,NULL, GA_Disabled, code, TAG_DONE); break; case GID_OPTS_FONT_SANS: @@ -2294,12 +2332,13 @@ static BOOL ami_gui_opts_event(void *w) return FALSE; } -struct List *ami_gui_opts_websearch(void) +struct List *ami_gui_opts_websearch(int *idx) { struct List *list; struct Node *node; const char *name; int iter; + int i = 0; list = malloc(sizeof(struct List)); NewList(list); @@ -2311,6 +2350,12 @@ struct List *ami_gui_opts_websearch(void) iter = search_web_iterate_providers(iter, &name)) { node = AllocChooserNode(CNA_Text, name, TAG_DONE); AddTail(list, node); + if(idx != NULL) { + if((nsoption_charp(search_web_provider)) && (strcmp(name, nsoption_charp(search_web_provider)) == 0)) { + *idx = i; + } + } + i++; } return list; diff --git a/frontends/amiga/gui_options.h b/frontends/amiga/gui_options.h index 7de35cc0d..82186dd7b 100755 --- a/frontends/amiga/gui_options.h +++ b/frontends/amiga/gui_options.h @@ -22,7 +22,8 @@ void ami_gui_opts_open(void); /* Web search list */ -struct List *ami_gui_opts_websearch(void); +/* Return s a list of web search provider, and optionally the current provider index */ +struct List *ami_gui_opts_websearch(int *idx); void ami_gui_opts_websearch_free(struct List *websearchlist); #endif diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c index e724f3e70..596e5ff12 100644 --- a/frontends/amiga/history.c +++ b/frontends/amiga/history.c @@ -200,10 +200,10 @@ ami_history_global_drag_end(struct ami_corewindow *ami_cw, int x, int y) } if((ok == false) || (url == NULL)) { - DisplayBeep(scrn); + ami_gui_beep(); } else if(url) { if((gwin = ami_window_at_pointer(AMINS_WINDOW))) { - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), url, NULL, BW_NAVIGATE_HISTORY, @@ -233,7 +233,7 @@ HOOKF(void, ami_history_global_menu_item_project_export, APTR, window, struct In ASLFR_Window, ami_cw->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, "history.html", TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); @@ -384,7 +384,7 @@ ami_history_global_create_window(struct ami_history_global_window *history_win) WA_Left, nsoption_int(history_window_xpos), WA_Width, nsoption_int(history_window_xsize), WA_Height, nsoption_int(history_window_ysize), - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | @@ -393,7 +393,7 @@ ami_history_global_create_window(struct ami_history_global_window *history_win) WINDOW_IDCMPHook, &ami_cw->idcmp_hook, WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, - WINDOW_SharedPort, sport, + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_HorizProp, 1, WINDOW_VertProp, 1, WINDOW_UserData, history_win, @@ -461,7 +461,7 @@ nserror ami_history_global_present(void) return res; } - res = global_history_init(ncwin->core.cb_table, (struct core_window *)ncwin); + res = global_history_init((struct core_window *)ncwin); if (res != NSERROR_OK) { ami_utf8_free(ncwin->core.wintitle); DisposeObject(ncwin->core.objects[GID_CW_WIN]); diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c index 0ae9cc040..f5149dcdb 100644 --- a/frontends/amiga/history_local.c +++ b/frontends/amiga/history_local.c @@ -81,13 +81,22 @@ ami_history_local_destroy(struct ami_history_local_window *history_local_win) res = local_history_fini(history_local_win->session); if (res == NSERROR_OK) { - history_local_win->gw->hw = NULL; + ami_gui_set_history_window(history_local_win->gw, NULL); res = ami_corewindow_fini(&history_local_win->core); /* closes the window for us */ history_local_window = NULL; } return res; } +static void ami_history_local_destroy_cw(struct ami_corewindow *ami_cw) +{ + struct ami_history_local_window *history_local_win; + /* technically degenerate container of */ + history_local_win = (struct ami_history_local_window *)ami_cw; + + ami_history_local_destroy(history_local_win); +} + /** * callback for mouse action for local history on core window * @@ -200,7 +209,7 @@ ami_history_local_create_window(struct ami_history_local_window *history_local_w WA_SizeBRight, TRUE, WA_Width, 100, WA_Height, 100, - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | @@ -209,7 +218,7 @@ ami_history_local_create_window(struct ami_history_local_window *history_local_w WINDOW_IDCMPHook, &ami_cw->idcmp_hook, WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, - WINDOW_SharedPort, sport, + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_HorizProp, 1, WINDOW_VertProp, 1, WINDOW_UserData, history_local_win, @@ -244,8 +253,8 @@ nserror ami_history_local_present(struct gui_window *gw) if(history_local_window != NULL) { //windowtofront() - if (gw->hw != NULL) { - res = local_history_set(gw->hw->session, gw->bw); + if (ami_gui_get_history_window(gw) != NULL) { + res = local_history_set(ami_gui_get_history_window(gw)->session, ami_gui_get_browser_window(gw)); return res; } @@ -271,7 +280,7 @@ nserror ami_history_local_present(struct gui_window *gw) ncwin->core.draw = ami_history_local_draw; ncwin->core.key = ami_history_local_key; ncwin->core.mouse = ami_history_local_mouse; - ncwin->core.close = ami_history_local_destroy; + ncwin->core.close = ami_history_local_destroy_cw; ncwin->core.event = NULL; ncwin->core.drag_end = NULL; ncwin->core.icon_drop = NULL; @@ -284,9 +293,8 @@ nserror ami_history_local_present(struct gui_window *gw) return res; } - res = local_history_init(ncwin->core.cb_table, - (struct core_window *)ncwin, - gw->bw, + res = local_history_init((struct core_window *)ncwin, + ami_gui_get_browser_window(gw), &ncwin->session); if (res != NSERROR_OK) { ami_utf8_free(ncwin->core.wintitle); @@ -308,7 +316,9 @@ nserror ami_history_local_present(struct gui_window *gw) ncwin->gw = gw; history_local_window = ncwin; - gw->hw = ncwin; + ami_gui_set_history_window(gw, ncwin); + + local_history_scroll_to_cursor(ncwin->session); return NSERROR_OK; } diff --git a/frontends/amiga/history_local.h b/frontends/amiga/history_local.h index 72ba7fa8b..0a265d821 100644 --- a/frontends/amiga/history_local.h +++ b/frontends/amiga/history_local.h @@ -16,8 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef AMIGA_HISTORY_GLOBAL_H -#define AMIGA_HISTORY_GLOBAL_H +#ifndef AMIGA_HISTORY_LOCAL_H +#define AMIGA_HISTORY_LOCAL_H struct gui_window; struct ami_history_local_window; diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c index c7efe9148..397fd6716 100644 --- a/frontends/amiga/hotlist.c +++ b/frontends/amiga/hotlist.c @@ -251,10 +251,10 @@ ami_hotlist_drag_end(struct ami_corewindow *ami_cw, int x, int y) } if((ok == false) || (url == NULL)) { - DisplayBeep(scrn); + ami_gui_beep(); } else if(url) { if((gwin = ami_window_at_pointer(AMINS_WINDOW))) { - browser_window_navigate(gwin->gw->bw, + browser_window_navigate(ami_gui2_get_browser_window(gwin), url, NULL, BW_NAVIGATE_HISTORY, @@ -313,7 +313,7 @@ HOOKF(void, ami_hotlist_menu_item_project_export, APTR, window, struct IntuiMess ASLFR_Window, ami_cw->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, "hotlist.html", TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); @@ -487,7 +487,7 @@ ami_hotlist_create_window(struct ami_hotlist_window *hotlist_win) WA_Left, nsoption_int(hotlist_window_xpos), WA_Width, nsoption_int(hotlist_window_xsize), WA_Height, nsoption_int(hotlist_window_ysize), - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | @@ -496,7 +496,7 @@ ami_hotlist_create_window(struct ami_hotlist_window *hotlist_win) WINDOW_IDCMPHook, &ami_cw->idcmp_hook, WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, - WINDOW_SharedPort, sport, + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_HorizProp, 1, WINDOW_VertProp, 1, WINDOW_UserData, hotlist_win, @@ -586,7 +586,7 @@ nserror ami_hotlist_present(void) return res; } - res = hotlist_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin); + res = hotlist_manager_init((struct core_window *)ncwin); if (res != NSERROR_OK) { ami_utf8_free(ncwin->core.wintitle); DisposeObject(ncwin->core.objects[GID_CW_WIN]); diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c index 582d355b6..2b7f61281 100644 --- a/frontends/amiga/icon.c +++ b/frontends/amiga/icon.c @@ -45,7 +45,10 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "netsurf/content.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" +#include "desktop/gui_internal.h" #include "amiga/os3support.h" #include "amiga/bitmap.h" @@ -85,6 +88,17 @@ static void *amiga_icon_get_internal(const struct content *c, void *context) return icon_c->bitmap; } +static bool amiga_icon_is_opaque(struct content *c) +{ + amiga_icon_content *icon_c = (amiga_icon_content *)c; + + if (icon_c->bitmap != NULL) { + return guit->bitmap->get_opaque(icon_c->bitmap); + } + + return false; +} + static const content_handler amiga_icon_content_handler = { .create = amiga_icon_create, .data_complete = amiga_icon_convert, @@ -93,6 +107,7 @@ static const content_handler amiga_icon_content_handler = { .clone = amiga_icon_clone, .get_internal = amiga_icon_get_internal, .type = amiga_icon_content_type, + .is_opaque = amiga_icon_is_opaque, .no_share = false, }; @@ -154,7 +169,8 @@ bool amiga_icon_convert(struct content *c) /* This loader will only work on local files, so fail if not a local path */ if(filename == NULL) { - msg_data.error = messages_get("NoMemory"); + msg_data.errordata.errorcode = NSERROR_NOMEM; + msg_data.errordata.errormsg = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -166,7 +182,8 @@ bool amiga_icon_convert(struct content *c) if(dobj == NULL) { - msg_data.error = messages_get("NoMemory"); + msg_data.errordata.errorcode = NSERROR_NOMEM; + msg_data.errordata.errormsg = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -184,16 +201,18 @@ bool amiga_icon_convert(struct content *c) return false; } - icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NEW); + icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NONE); if (!icon_c->bitmap) { - msg_data.error = messages_get("NoMemory"); + msg_data.errordata.errorcode = NSERROR_NOMEM; + msg_data.errordata.errormsg = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); if(dobj) FreeDiskObject(dobj); return false; } imagebuf = (ULONG *) amiga_bitmap_get_buffer(icon_c->bitmap); if (!imagebuf) { - msg_data.error = messages_get("NoMemory"); + msg_data.errordata.errorcode = NSERROR_NOMEM; + msg_data.errordata.errormsg = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); if(dobj) FreeDiskObject(dobj); return false; diff --git a/frontends/amiga/iff_dr2d.c b/frontends/amiga/iff_dr2d.c index a4c5855a1..624b501ff 100644 --- a/frontends/amiga/iff_dr2d.c +++ b/frontends/amiga/iff_dr2d.c @@ -120,6 +120,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer, if(!(PushChunk(iffh,0,ID_NAME,IFFSIZE_UNKNOWN))) { WriteChunkBytes(iffh,url,strlen(url)); + WriteChunkBytes(iffh,"\0",1); PopChunk(iffh); } @@ -185,6 +186,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer, attr->DashPattern = 1; attr->EdgeValue = findcolour(diagram->shape[i].stroke); } + attr->EdgeThick = (float) diagram->shape[i].stroke_width; if(!(PushChunk(iffh,0,ID_ATTR,IFFSIZE_UNKNOWN))) @@ -281,7 +283,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer, if(!(PushChunk(iffh, 0, ID_FONS, IFFSIZE_UNKNOWN))) { WriteChunkBytes(iffh, fons, sizeof(struct fons_struct)); - WriteChunkBytes(iffh, "Topaz\0", 6); + WriteChunkBytes(iffh, "Helvetica\0", 10); PopChunk(iffh); } free(fons); @@ -310,22 +312,27 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer, bool ami_save_svg(struct hlcache_handle *c,char *filename) { struct IFFHandle *iffh; - const char *source_data; - ULONG source_size; + const uint8_t *source_data; + size_t source_size; - if(!ami_download_check_overwrite(filename, NULL, 0)) return false; + if (!ami_download_check_overwrite(filename, NULL, 0)) return false; - if((iffh = AllocIFF())) { - if((iffh->iff_Stream = Open(filename,MODE_NEWFILE))) { + if ((iffh = AllocIFF())) { + if ((iffh->iff_Stream = Open(filename,MODE_NEWFILE))) { InitIFFasDOS(iffh); } else return false; } - if((OpenIFF(iffh,IFFF_WRITE))) return false; + if ((OpenIFF(iffh,IFFF_WRITE))) return false; - if((source_data = content_get_source_data(c, &source_size))) - ami_svg_to_dr2d(iffh, source_data, source_size, nsurl_access(hlcache_handle_get_url(c))); + source_data = content_get_source_data(c, &source_size); + if (source_data != NULL) { + ami_svg_to_dr2d(iffh, + (const char *)source_data, + source_size, + nsurl_access(hlcache_handle_get_url(c))); + } if(iffh) CloseIFF(iffh); if(iffh->iff_Stream) Close((BPTR)iffh->iff_Stream); diff --git a/frontends/amiga/launch.c b/frontends/amiga/launch.c index 10c32aeed..785f667ce 100755 --- a/frontends/amiga/launch.c +++ b/frontends/amiga/launch.c @@ -74,7 +74,7 @@ static void ami_openurl_free_list(struct MinList *list) struct ami_protocol *node; struct ami_protocol *nnode; - if(IsMinListEmpty(list) == NULL) { + if(!IsMinListEmpty(list)) { node = (struct ami_protocol *)GetHead((struct List *)list); do diff --git a/frontends/amiga/libs.c b/frontends/amiga/libs.c index cbef3c2fa..eb1f21617 100644 --- a/frontends/amiga/libs.c +++ b/frontends/amiga/libs.c @@ -1,5 +1,5 @@ /* - * Copyright 2014 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2014-2020 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -113,7 +113,9 @@ #define AMINS_CLASS_CLOSE(PREFIX) \ if(I##PREFIX) DropInterface((struct Interface *)I##PREFIX); \ - if(PREFIX##Base) CloseClass(PREFIX##Base); + if(PREFIX##Base) CloseClass(PREFIX##Base); \ + I##PREFIX = NULL; \ + PREFIX##Base = NULL; #define AMINS_CLASS_STRUCT(PREFIX) \ struct ClassLibrary *PREFIX##Base = NULL; \ @@ -136,7 +138,8 @@ } #define AMINS_LIB_CLOSE(PREFIX) \ - if(PREFIX##Base) CloseLibrary((struct Library *)PREFIX##Base); + if(PREFIX##Base) CloseLibrary((struct Library *)PREFIX##Base); \ + PREFIX##Base = NULL; #define AMINS_LIB_STRUCT(PREFIX) \ struct PREFIX##Base *PREFIX##Base = NULL; @@ -156,7 +159,8 @@ } #define AMINS_CLASS_CLOSE(PREFIX) \ - if(PREFIX##Base) CloseLibrary(PREFIX##Base); + if(PREFIX##Base) CloseLibrary(PREFIX##Base); \ + PREFIX##Base = NULL; #define AMINS_CLASS_STRUCT(PREFIX) \ struct Library *PREFIX##Base = NULL; \ @@ -185,6 +189,7 @@ AMINS_LIB_STRUCT(Locale); AMINS_LIB_STRUCT(P96); AMINS_LIB_STRUCT(Workbench); +AMINS_LIB_STRUCT(Codesets); AMINS_LIB_STRUCT(GuiGFX); AMINS_CLASS_STRUCT(ARexx); @@ -218,6 +223,7 @@ bool ami_libs_open(void) #ifdef __amigaos4__ /* Libraries only needed on OS4 */ AMINS_LIB_OPEN("application.library", 53, Application, "application", 2, false) + AMINS_LIB_OPEN("dos.library", 37, DOS, "main", 1, true) #else /* Libraries we get automatically on OS4 but not OS3 */ AMINS_LIB_OPEN("utility.library", 37, Utility, "main", 1, true) @@ -226,7 +232,6 @@ bool ami_libs_open(void) AMINS_LIB_OPEN("asl.library", 37, Asl, "main", 1, true) AMINS_LIB_OPEN("datatypes.library", 39, DataTypes, "main", 1, true) AMINS_LIB_OPEN("diskfont.library", 40, Diskfont, "main", 1, true) - AMINS_LIB_OPEN("dos.library", 37, DOS, "main", 1, true) AMINS_LIB_OPEN("gadtools.library", 37, GadTools, "main", 1, true) AMINS_LIB_OPEN("graphics.library", 40, Graphics, "main", 1, true) AMINS_LIB_OPEN("icon.library", 44, Icon, "main", 1, true) @@ -244,7 +249,8 @@ bool ami_libs_open(void) AMINS_LIB_OPEN("Picasso96API.library", 0, P96, "main", 1, false) /* Non-OS provided libraries */ - AMINS_LIB_OPEN("guigfx.library", 9, GuiGFX, "main", 1, false) + AMINS_LIB_OPEN("codesets.library", 6, Codesets, "main", 1, false) + AMINS_LIB_OPEN("guigfx.library", 9, GuiGFX, "main", 1, false) /* NB: timer.device is opened in schedule.c (ultimately by the scheduler process). * The library base and interface are obtained there, rather than here, due to @@ -276,6 +282,7 @@ bool ami_libs_open(void) AMINS_CLASS_OPEN("gadgets/integer.gadget", 41, Integer, INTEGER, false) AMINS_CLASS_OPEN("images/label.image", 41, Label, LABEL, false) AMINS_CLASS_OPEN("gadgets/layout.gadget", 43, Layout, LAYOUT, true) + AMINS_CLASS_OPEN("gadgets/listbrowser.gadget", 41, ListBrowser, LISTBROWSER, true) AMINS_CLASS_OPEN("gadgets/radiobutton.gadget", 41, RadioButton, RADIOBUTTON, false) AMINS_CLASS_OPEN("gadgets/scroller.gadget", 42, Scroller, SCROLLER, false) AMINS_CLASS_OPEN("gadgets/space.gadget", 41, Space, SPACE, false) @@ -283,10 +290,7 @@ bool ami_libs_open(void) AMINS_CLASS_OPEN("gadgets/string.gadget", 41, String, STRING, false) AMINS_CLASS_OPEN("window.class", 42, Window, WINDOW, false) -#ifdef __amigaos4__ - /* BOOPSI classes only required on OS4 */ - AMINS_CLASS_OPEN("gadgets/listbrowser.gadget", 45, ListBrowser, LISTBROWSER, true) -#else +#ifndef __amigaos4__ /* BOOPSI classes only required prior to OS4 */ PageClass = PAGE_GetClass(); #endif @@ -313,23 +317,21 @@ void ami_libs_close(void) AMINS_CLASS_CLOSE(Integer) AMINS_CLASS_CLOSE(Label) AMINS_CLASS_CLOSE(Layout) + AMINS_CLASS_CLOSE(ListBrowser) AMINS_CLASS_CLOSE(RadioButton) AMINS_CLASS_CLOSE(Scroller) AMINS_CLASS_CLOSE(Space) AMINS_CLASS_CLOSE(SpeedBar) AMINS_CLASS_CLOSE(String) AMINS_CLASS_CLOSE(Window) -#ifdef __amigaos4__ - AMINS_CLASS_CLOSE(ListBrowser) -#endif /* Libraries */ + AMINS_LIB_CLOSE(Codesets) AMINS_LIB_CLOSE(GuiGFX) AMINS_LIB_CLOSE(Asl) AMINS_LIB_CLOSE(DataTypes) AMINS_LIB_CLOSE(Diskfont) - AMINS_LIB_CLOSE(DOS) AMINS_LIB_CLOSE(GadTools) AMINS_LIB_CLOSE(Graphics) AMINS_LIB_CLOSE(Icon) @@ -342,6 +344,7 @@ void ami_libs_close(void) AMINS_LIB_CLOSE(Workbench) #ifdef __amigaos4__ AMINS_LIB_CLOSE(Application) + AMINS_LIB_CLOSE(DOS) #else AMINS_LIB_CLOSE(Utility) #endif diff --git a/frontends/amiga/libs.h b/frontends/amiga/libs.h index aa3622af2..db5b65c75 100644 --- a/frontends/amiga/libs.h +++ b/frontends/amiga/libs.h @@ -63,6 +63,7 @@ extern Class *WindowClass; #define LabelObj NewObject(LabelClass, NULL #define LayoutHObj NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ #define LayoutVObj NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT +#define ListBrowserObj NewObject(ListBrowserClass, NULL #ifdef __amigaos4__ #define PageObj NewObject(NULL, "page.gadget" #else diff --git a/frontends/amiga/login.c b/frontends/amiga/login.c deleted file mode 100755 index 0948caaaa..000000000 --- a/frontends/amiga/login.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "amiga/os3support.h" - -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include <proto/exec.h> -#include <proto/intuition.h> -#include <proto/utility.h> - -#include <proto/window.h> -#include <proto/layout.h> -#include <proto/string.h> -#include <proto/button.h> -#include <proto/label.h> -#include <classes/window.h> -#include <gadgets/layout.h> -#include <gadgets/string.h> -#include <gadgets/button.h> -#include <images/label.h> -#include <reaction/reaction_macros.h> - -#include "utils/messages.h" -#include "utils/nsurl.h" -#include "netsurf/mouse.h" -#include "netsurf/window.h" -#include "netsurf/url_db.h" - -#include "amiga/gui.h" -#include "amiga/libs.h" -#include "amiga/login.h" -#include "amiga/misc.h" -#include "amiga/object.h" -#include "amiga/utf8.h" - -enum { - AMI_LOGIN_MSG_HOST, - AMI_LOGIN_MSG_REALM, - AMI_LOGIN_MSG_USER, - AMI_LOGIN_MSG_PASS, - AMI_LOGIN_MSG_LOGIN, - AMI_LOGIN_MSG_CANCEL, - AMI_LOGIN_MSG_MAX -}; - -enum { - OID_L_MAIN = 0, - GID_L_MAIN, - GID_L_USER, - GID_L_PASS, - GID_L_LOGIN, - GID_L_CANCEL, - GID_L_LAST -}; - -struct gui_login_window { - struct ami_generic_window w; - struct Window *win; - Object *objects[GID_L_LAST]; - nserror (*cb)(const char *username, const char *password, void *pw); - void *cbpw; - nsurl *url; - char *realm; - lwc_string *host; - char uname[256]; - char pwd[256]; - char *messages[AMI_LOGIN_MSG_MAX]; -}; - -static BOOL ami_401login_event(void *w); -static void ami_401login_close(void *w); - -static const struct ami_win_event_table ami_login_table = { - ami_401login_event, - ami_401login_close, /* TODO: investigate why this doesn't get called on exit */ -}; - -nserror gui_401login_open(nsurl *url, const char *realm, - const char *username, const char *password, - nserror (*cb)(const char *username, - const char *password, - void *pw), - void *cbpw) -{ - struct gui_login_window *lw = calloc(1, sizeof(struct gui_login_window)); - lwc_string *host = nsurl_get_component(url, NSURL_HOST); - size_t len; - - assert(host != NULL); - assert(username != NULL); - assert(password != NULL); - - lw->host = host; - lw->url = nsurl_ref(url); - lw->realm = (realm != NULL) ? strdup(realm) : NULL; - lw->cb = cb; - lw->cbpw = cbpw; - - lw->messages[AMI_LOGIN_MSG_HOST] = ami_utf8_easy(messages_get("Host")); - lw->messages[AMI_LOGIN_MSG_REALM] = ami_utf8_easy(messages_get("Realm")); - lw->messages[AMI_LOGIN_MSG_USER] = ami_utf8_easy(messages_get("Username")); - lw->messages[AMI_LOGIN_MSG_PASS] = ami_utf8_easy(messages_get("Password")); - lw->messages[AMI_LOGIN_MSG_LOGIN] = ami_utf8_easy(messages_get("Login")); - lw->messages[AMI_LOGIN_MSG_CANCEL] = ami_utf8_easy(messages_get("Cancel")); - - /* Convert existing username and password to local charset */ - char *user_utf8 = ami_utf8_easy(username); - if(user_utf8 != NULL) { - len = strlen(user_utf8); - assert(len < sizeof(lw->uname)); - memcpy(lw->uname, user_utf8, len + 1); - ami_utf8_free(user_utf8); - } - - char *pass_utf8 = ami_utf8_easy(password); - if(pass_utf8 != NULL) { - len = strlen(pass_utf8); - assert(len < sizeof(lw->pwd)); - memcpy(lw->pwd, pass_utf8, len + 1); - ami_utf8_free(pass_utf8); - } - - lw->objects[OID_L_MAIN] = WindowObj, - WA_ScreenTitle, ami_gui_get_screen_title(), - WA_Title, nsurl_access(lw->url), - WA_Activate, TRUE, - WA_DepthGadget, TRUE, - WA_DragBar, TRUE, - WA_CloseGadget, FALSE, - WA_SizeGadget, TRUE, - WA_PubScreen,scrn, - WINDOW_SharedPort,sport, - WINDOW_UserData,lw, - WINDOW_IconifyGadget, FALSE, - WINDOW_LockHeight,TRUE, - WINDOW_Position, WPOS_CENTERSCREEN, - WINDOW_ParentGroup, lw->objects[GID_L_MAIN] = LayoutVObj, - LAYOUT_AddChild, StringObj, - STRINGA_TextVal, lwc_string_data(lw->host), - GA_ReadOnly,TRUE, - StringEnd, - CHILD_Label, LabelObj, - LABEL_Text, lw->messages[AMI_LOGIN_MSG_HOST], - LabelEnd, - CHILD_WeightedHeight,0, - LAYOUT_AddChild, StringObj, - STRINGA_TextVal,lw->realm, - GA_ReadOnly,TRUE, - StringEnd, - CHILD_Label, LabelObj, - LABEL_Text, lw->messages[AMI_LOGIN_MSG_REALM], - LabelEnd, - CHILD_WeightedHeight,0, - LAYOUT_AddChild, lw->objects[GID_L_USER] = StringObj, - GA_ID,GID_L_USER, - GA_TabCycle,TRUE, - STRINGA_TextVal, lw->uname, - StringEnd, - CHILD_Label, LabelObj, - LABEL_Text, lw->messages[AMI_LOGIN_MSG_USER], - LabelEnd, - CHILD_WeightedHeight,0, - LAYOUT_AddChild, lw->objects[GID_L_PASS] = StringObj, - GA_ID,GID_L_PASS, - STRINGA_HookType,SHK_PASSWORD, - GA_TabCycle,TRUE, - STRINGA_TextVal, lw->pwd, - StringEnd, - CHILD_Label, LabelObj, - LABEL_Text, lw->messages[AMI_LOGIN_MSG_PASS], - LabelEnd, - CHILD_WeightedHeight,0, - LAYOUT_AddChild, LayoutHObj, - LAYOUT_AddChild, lw->objects[GID_L_LOGIN] = ButtonObj, - GA_ID,GID_L_LOGIN, - GA_RelVerify,TRUE, - GA_Text, lw->messages[AMI_LOGIN_MSG_LOGIN], - GA_TabCycle,TRUE, - ButtonEnd, - CHILD_WeightedHeight,0, - LAYOUT_AddChild, lw->objects[GID_L_CANCEL] = ButtonObj, - GA_ID,GID_L_CANCEL, - GA_RelVerify,TRUE, - GA_Text, lw->messages[AMI_LOGIN_MSG_CANCEL], - GA_TabCycle,TRUE, - ButtonEnd, - LayoutEnd, - CHILD_WeightedHeight,0, - EndGroup, - EndWindow; - - lw->win = (struct Window *)RA_OpenWindow(lw->objects[OID_L_MAIN]); - ami_gui_win_list_add(lw, AMINS_LOGINWINDOW, &ami_login_table); - - return NSERROR_OK; -} - -static void ami_401login_close(void *w) -{ - struct gui_login_window *lw = (struct gui_login_window *)w; - - /* If continuation exists, then forbid refetch */ - if (lw->cb != NULL) - lw->cb(NULL, NULL, lw->cbpw); - - DisposeObject(lw->objects[OID_L_MAIN]); - lwc_string_unref(lw->host); - nsurl_unref(lw->url); - free(lw->realm); - - /* Free local charset version of messages */ - for(int i = 0; i < AMI_LOGIN_MSG_MAX; i++) { - ami_utf8_free(lw->messages[i]); - } - - ami_gui_win_list_remove(lw); -} - -static void ami_401login_login(struct gui_login_window *lw) -{ - char *user; - char *pass; - - /* Get username and password from string gadgets */ - GetAttr(STRINGA_TextVal,lw->objects[GID_L_USER],(ULONG *)&user); - GetAttr(STRINGA_TextVal,lw->objects[GID_L_PASS],(ULONG *)&pass); - - /* Convert from local charset to UTF-8 */ - char *user_utf8 = ami_to_utf8_easy(user); - char *pass_utf8 = ami_to_utf8_easy(pass); - - if(user_utf8 && pass_utf8) { - lw->cb(user_utf8, pass_utf8, lw->cbpw); - - ami_utf8_free(user_utf8); - ami_utf8_free(pass_utf8); - } else { - amiga_warn_user("NoMemory", ""); - } - - /* Invalidate continuation */ - lw->cb = NULL; - lw->cbpw = NULL; - - ami_401login_close(lw); -} - -static BOOL ami_401login_event(void *w) -{ - /* return TRUE if window destroyed */ - struct gui_login_window *lw = (struct gui_login_window *)w; - ULONG result; - uint16 code; - - while((result = RA_HandleInput(lw->objects[OID_L_MAIN], &code)) != WMHI_LASTMSG) - { - switch(result & WMHI_CLASSMASK) // class - { - case WMHI_GADGETUP: - switch(result & WMHI_GADGETMASK) - { - case GID_L_LOGIN: - ami_401login_login(lw); - return TRUE; - break; - - case GID_L_CANCEL: - ami_401login_close(lw); - return TRUE; - break; - } - break; - } - } - return FALSE; -} - diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c index 1f3f981ea..85b2ec43f 100644 --- a/frontends/amiga/menu.c +++ b/frontends/amiga/menu.c @@ -251,7 +251,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat MA_Image, BitMapObj, IA_Scalable, TRUE, - BITMAP_Screen, scrn, + BITMAP_Screen, ami_gui_get_screen(), BITMAP_SourceFile, md[j]->menuicon, BITMAP_Masking, TRUE, BitMapEnd, @@ -298,6 +298,7 @@ static struct Menu *ami_menu_layout_gt(struct ami_menu_data **md, int max) struct NewMenu *nm; struct Menu *imenu = NULL; struct VisualInfo *vi; + struct Screen *scrn = ami_gui_get_screen(); struct RastPort *rp = &scrn->RastPort; struct DrawInfo *dri = GetScreenDrawInfo(scrn); int space_width = TextLength(rp, " ", 1); diff --git a/frontends/amiga/misc.c b/frontends/amiga/misc.c index 822d640d0..57afbdd97 100755 --- a/frontends/amiga/misc.c +++ b/frontends/amiga/misc.c @@ -45,6 +45,7 @@ static LONG ami_misc_req(const char *message, uint32 type) { LONG ret = 0; + struct gui_window *cur_gw = ami_gui_get_active_gw(); NSLOG(netsurf, INFO, "%s", message); #ifdef __amigaos4__ @@ -53,7 +54,7 @@ static LONG ami_misc_req(const char *message, uint32 type) TDR_FormatString, message, TDR_GadgetString, messages_get("OK"), TDR_ImageType, type, - TDR_Window, cur_gw ? cur_gw->shared->win : NULL, + TDR_Window, cur_gw ? ami_gui_get_window(cur_gw) : NULL, TAG_DONE); #else struct EasyStruct easyreq = { @@ -64,7 +65,7 @@ static LONG ami_misc_req(const char *message, uint32 type) messages_get("OK"), }; - ret = EasyRequest(cur_gw ? cur_gw->shared->win : NULL, &easyreq, NULL); + ret = EasyRequest(cur_gw ? ami_gui_get_window(cur_gw) : NULL, &easyreq, NULL); #endif return ret; } @@ -246,6 +247,7 @@ char *translate_escape_chars(const char *s) { size_t i, ii, len; char *ret; + char *outs; len = strlen(s); ret = malloc(len + 1); if (ret == NULL) @@ -261,7 +263,9 @@ char *translate_escape_chars(const char *s) } ret[ii] = '\0'; - return ami_utf8_easy(ret); + outs = ami_utf8_easy(ret); + free(ret); + return outs; } /** diff --git a/frontends/amiga/options.h b/frontends/amiga/options.h index a23435ca6..101558f6a 100644 --- a/frontends/amiga/options.h +++ b/frontends/amiga/options.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 - 2012 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008 - 2020 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -47,6 +47,7 @@ NSOPTION_STRING(search_engines_file, "PROGDIR:Resources/SearchEngines") NSOPTION_STRING(arexx_dir, "PROGDIR:Rexx") NSOPTION_STRING(arexx_startup, "Startup.nsrx") NSOPTION_STRING(arexx_shutdown, "Shutdown.nsrx") +NSOPTION_BOOL(arexx_allow_exec, false) NSOPTION_STRING(download_dir, NULL) NSOPTION_BOOL(download_notify, true) NSOPTION_BOOL(download_notify_progress, false) @@ -80,7 +81,7 @@ NSOPTION_INTEGER(cookies_window_ypos, 0) NSOPTION_INTEGER(cookies_window_xsize, 0) NSOPTION_INTEGER(cookies_window_ysize, 0) NSOPTION_INTEGER(web_search_width, 0) -NSOPTION_BOOL(window_simple_refresh, false) +NSOPTION_BOOL(window_simple_refresh, true) NSOPTION_BOOL(resize_with_contents, false) NSOPTION_INTEGER(reformat_delay, 0) NSOPTION_INTEGER(redraw_tile_size_x, 0) @@ -88,12 +89,22 @@ 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) + +/* Local charset when using iconv */ NSOPTION_STRING(local_charset, "ISO-8859-1") + #ifdef __amigaos4__ -/* Options relevant for OS4 only */ +/** Options relevant for OS4 only **/ + +/* Local charset IANA number when using codesets */ +NSOPTION_INTEGER(local_codeset, 0) + +/* Use ExtMem */ NSOPTION_BOOL(use_extmem, true) + #else -/* Options relevant for OS3 only */ +/** Options relevant for OS3 only **/ + NSOPTION_BOOL(friend_bitmap, false) #endif diff --git a/frontends/amiga/os3support.c b/frontends/amiga/os3support.c index 645496b73..98843c702 100644 --- a/frontends/amiga/os3support.c +++ b/frontends/amiga/os3support.c @@ -28,7 +28,6 @@ #include <stdio.h> #include <stdlib.h> #include <ctype.h> -#include <dirent.h> #include <proto/bullet.h> #include <proto/exec.h> @@ -182,6 +181,12 @@ char *strsep(char **s1, const char *s2) return p1; } +int alphasort(const struct dirent **d1, const struct dirent **d2) +{ + /*\todo stub function, needs writing, preferably into clib2 */ + return 0; +} + int scandir(const char *dir, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)) diff --git a/frontends/amiga/os3support.h b/frontends/amiga/os3support.h index aa3027d36..dc4e06503 100644 --- a/frontends/amiga/os3support.h +++ b/frontends/amiga/os3support.h @@ -27,6 +27,7 @@ #ifndef __amigaos4__ #include <stdint.h> +#include <dirent.h> #include <proto/exec.h> #include <proto/dos.h> @@ -78,6 +79,8 @@ #define GAUGEIA_Level TAG_IGNORE #define IA_InBorder TAG_IGNORE #define IA_Label TAG_IGNORE +#define LBNCA_SoftStyle TAG_IGNORE +#define LISTBROWSER_Striping TAG_IGNORE #define SA_Compositing TAG_IGNORE #define SBNA_Text TAG_IGNORE #define SBNA_HintInfo TAG_IGNORE @@ -104,10 +107,15 @@ #define RAWKEY_F8 0x57 #define RAWKEY_F9 0x58 #define RAWKEY_F10 0x59 +#define RAWKEY_F12 0x6F #define RAWKEY_HELP 0x5F #define RAWKEY_HOME 0x70 #define RAWKEY_END 0x71 +/* New pens - these may not be equivalent */ +#define DISABLEDTEXTPEN HIGHLIGHTTEXTPEN +#define TITLEPEN FILLPEN + /* Other constants */ #define BVS_DISPLAY BVS_NONE #define IDCMP_EXTENDEDMOUSE 0 @@ -117,6 +125,7 @@ #define OFF_OPEN 0 #define AFF_OTAG 0 #define ML_SEPARATOR NM_BARLABEL +#define LBS_ROWS 0 /* Renamed structures */ #define AnchorPathOld AnchorPath @@ -249,6 +258,10 @@ char *ASPrintf(const char *fmt, ...); /* C */ char *strlwr(char *str); +int alphasort(const struct dirent **d1, const struct dirent **d2); +int scandir(const char *dir, struct dirent ***namelist, + int (*filter)(const struct dirent *), + int (*compar)(const struct dirent **, const struct dirent **)); #endif #endif diff --git a/frontends/amiga/pageinfo.c b/frontends/amiga/pageinfo.c new file mode 100644 index 000000000..3ff223d7d --- /dev/null +++ b/frontends/amiga/pageinfo.c @@ -0,0 +1,282 @@ +/* + * Copyright 2020 Chris Young <chris@unsatisfactorysoftware.co.uk> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file + * Amiga implementation of page info using core windows. + */ + +#include <stdint.h> +#include <stdlib.h> + +#include <proto/intuition.h> + +#include <classes/window.h> +#include <gadgets/layout.h> +#include <gadgets/scroller.h> +#include <gadgets/space.h> +#include <images/label.h> + +#include <intuition/icclass.h> +#include <reaction/reaction_macros.h> + +#include "utils/log.h" +#include "netsurf/keypress.h" +#include "netsurf/plotters.h" +#include "desktop/page-info.h" +#include "utils/messages.h" +#include "utils/nsoption.h" + +#include "amiga/corewindow.h" +#include "amiga/libs.h" +#include "amiga/pageinfo.h" +#include "amiga/schedule.h" +#include "amiga/utf8.h" + + +/** + * Amiga page info window context + */ +struct ami_pageinfo_window { + /** Amiga core window context */ + struct ami_corewindow core; + /** core pageinfo */ + struct page_info *pi; +}; + +/** + * destroy a previously created pageinfo window + */ +static void +ami_pageinfo_destroy(struct ami_corewindow *ami_cw) +{ + nserror res; + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + if(pageinfo_win->pi != NULL) { + res = page_info_destroy(pageinfo_win->pi); + + if (res == NSERROR_OK) { + pageinfo_win->pi = NULL; + ami_corewindow_fini(&pageinfo_win->core); /* closes the window for us */ + } + } +} + +/** + * close pageinfo window (callback) + */ +static void +ami_pageinfo_close_cb(void *p) +{ + ami_pageinfo_destroy((struct ami_corewindow *)p); +} + +/** + * callback for unknown events on Amiga core window + * (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP) + * (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT) + * + * \param ami_cw The Amiga core window structure. + * \param result event as returned by RA_HandleInput() + * \return TRUE if window closed during event processing + */ +static BOOL +ami_pageinfo_event(struct ami_corewindow *ami_cw, ULONG result) +{ + if((result & WMHI_CLASSMASK) == WMHI_INACTIVE) { + /* Window went inactive, so schedule to close it */ + ami_schedule(0, ami_pageinfo_close_cb, ami_cw); + /* NB: do not return TRUE here as we're still open for now */ + } + return FALSE; +} + +/** + * callback for mouse action for pageinfo on core window + * + * \param ami_cw The Amiga core window structure. + * \param mouse_state netsurf mouse state on event + * \param x location of event + * \param y location of event + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +ami_pageinfo_mouse(struct ami_corewindow *ami_cw, + browser_mouse_state mouse_state, + int x, int y) +{ + bool did_something = false; + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + + if(page_info_mouse_action(pageinfo_win->pi, mouse_state, x, y, &did_something) == NSERROR_OK) + if (did_something == true) { + /* Something happened so we need to close ourselves */ + ami_schedule(0, ami_pageinfo_close_cb, pageinfo_win); + } + + return NSERROR_OK; +} + +/** + * callback for keypress for pageinfo on core window + * + * \param ami_cw The Amiga core window structure. + * \param nskey The netsurf key code + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +ami_pageinfo_key(struct ami_corewindow *ami_cw, uint32_t nskey) +{ + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + + if (page_info_keypress(pageinfo_win->pi, nskey)) { + return NSERROR_OK; + } + return NSERROR_NOT_IMPLEMENTED; +} + +/** + * callback on draw event for pageinfo on core window + * + * \param ami_cw The Amiga core window structure. + * \param x the x coordinate to draw + * \param y the y coordinate to draw + * \param r The rectangle of the window that needs updating. + * \param ctx The drawing context + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +ami_pageinfo_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx) +{ + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + + page_info_redraw(pageinfo_win->pi, x, y, r, ctx); + + return NSERROR_OK; +} + +static nserror +ami_pageinfo_create_window(struct ami_pageinfo_window *pageinfo_win, ULONG left, ULONG top) +{ + struct ami_corewindow *ami_cw = (struct ami_corewindow *)&pageinfo_win->core; + ULONG refresh_mode = WA_SmartRefresh; + struct Screen *scrn = ami_gui_get_screen(); + + if(nsoption_bool(window_simple_refresh) == true) { + refresh_mode = WA_SimpleRefresh; + } + + ami_cw->objects[GID_CW_WIN] = WindowObj, + WA_ScreenTitle, ami_gui_get_screen_title(), + WA_Activate, TRUE, + WA_DepthGadget, FALSE, + WA_DragBar, FALSE, + WA_CloseGadget, FALSE, + WA_SizeGadget, FALSE, + WA_Borderless, TRUE, + WA_Left, left, + WA_Top, top, + WA_PubScreen, scrn, + WA_ReportMouse, TRUE, + refresh_mode, TRUE, + WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | + IDCMP_RAWKEY | IDCMP_IDCMPUPDATE | IDCMP_INACTIVEWINDOW | + IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, + WINDOW_IDCMPHook, &ami_cw->idcmp_hook, + WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | + IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, + WINDOW_SharedPort, ami_gui_get_shared_msgport(), + WINDOW_UserData, pageinfo_win, + WINDOW_IconifyGadget, FALSE, + WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj, + LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj, + GA_ID, GID_CW_DRAW, + SPACE_Transparent, TRUE, + SPACE_BevelStyle, BVS_BOX, + GA_RelVerify, TRUE, + SpaceEnd, + EndGroup, + EndWindow; + + if(ami_cw->objects[GID_CW_WIN] == NULL) { + return NSERROR_NOMEM; + } + + return NSERROR_OK; +} + +/* exported interface documented in amiga/pageinfo.h */ +nserror ami_pageinfo_open(struct browser_window *bw, ULONG left, ULONG top) +{ + struct ami_pageinfo_window *ncwin; + nserror res; + int width, height; + + ncwin = calloc(1, sizeof(struct ami_pageinfo_window)); + if (ncwin == NULL) { + return NSERROR_NOMEM; + } + + ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("PageInfo")); + + res = ami_pageinfo_create_window(ncwin, left, top); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, "Page info init failed"); + ami_utf8_free(ncwin->core.wintitle); + free(ncwin); + return res; + } + + /* initialise Amiga core window */ + ncwin->core.draw = ami_pageinfo_draw; + ncwin->core.key = ami_pageinfo_key; + ncwin->core.mouse = ami_pageinfo_mouse; + ncwin->core.close = ami_pageinfo_destroy; + ncwin->core.event = ami_pageinfo_event; + + res = ami_corewindow_init(&ncwin->core); + if (res != NSERROR_OK) { + ami_utf8_free(ncwin->core.wintitle); + DisposeObject(ncwin->core.objects[GID_CW_WIN]); + free(ncwin); + return res; + } + + res = page_info_create((struct core_window *)ncwin, + bw, + &ncwin->pi); + + if (res != NSERROR_OK) { + ami_utf8_free(ncwin->core.wintitle); + DisposeObject(ncwin->core.objects[GID_CW_WIN]); + free(ncwin); + return res; + } + + if(page_info_get_size(ncwin->pi, &width, &height) == NSERROR_OK) { + /* Set window to the correct size. + * TODO: this should really set the size of ncwin->core.objects[GID_CW_DRAW] + * and let the window adjust, here we've hardcoded to add 6x4px as that's + * what window.class does before v45. + */ + SetAttrs(ncwin->core.objects[GID_CW_WIN], WA_InnerWidth, width + 6, WA_InnerHeight, height + 4, TAG_DONE); + } + + return NSERROR_OK; +} + diff --git a/frontends/amiga/login.h b/frontends/amiga/pageinfo.h index e2fdf1705..e48925e26 100755..100644 --- a/frontends/amiga/login.h +++ b/frontends/amiga/pageinfo.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2020 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -16,18 +16,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef AMIGA_LOGIN_H -#define AMIGA_LOGIN_H +#ifndef AMIGA_PAGEINFO_H +#define AMIGA_PAGEINFO_H -#include <stdbool.h> - -struct gui_login_window; +/** + * Open the page info window + * + * \param bw the browser window + * \return NSERROR_OK or error code if window creation failed. + */ +nserror ami_pageinfo_open(struct browser_window *bw, ULONG left, ULONG top); -nserror gui_401login_open(nsurl *url, const char *realm, - const char *username, const char *password, - nserror (*cb)(const char *username, - const char *password, - void *pw), - void *cbpw); #endif diff --git a/frontends/amiga/pkg/SearchEngines b/frontends/amiga/pkg/SearchEngines index 3f4bdd95b..3095d43cf 100644 --- a/frontends/amiga/pkg/SearchEngines +++ b/frontends/amiga/pkg/SearchEngines @@ -1,2 +1,2 @@ -Aminet|www.aminet.net|http://aminet.net/search?query=%s|http://aminet.net/favicon.ico| +Aminet|www.aminet.net|https://aminet.net/search?query=%s|https://aminet.net/favicon.ico| OS4Depot|www.os4depot.net|http://www.os4depot.net/index.php?function=search&tool=simple&f_fields=%s|http://www.os4depot.net/favicon.ico| diff --git a/frontends/amiga/pkg/netsurf.readme b/frontends/amiga/pkg/netsurf.readme index a24eaf3b7..d2d83ac56 100755 --- a/frontends/amiga/pkg/netsurf.readme +++ b/frontends/amiga/pkg/netsurf.readme @@ -2,11 +2,11 @@ Short: Fast CSS capable web browser Uploader: chris@unsatisfactorysoftware.co.uk (Chris Young) Author: NetSurf contributors (OS4 port by Chris Young) Type: comm/www -Version: 3.9 +Version: 3.11 Requires: dev/misc/guigfxlib.lha Architecture: ppc-amigaos >= 4.0.0 -This is NetSurf 3.9 for AmigaOS 4 (native frontend). +This is NetSurf 3.11 for AmigaOS 4 (native frontend). For the latest version, visit http://www.netsurf-browser.org ******************************************* diff --git a/frontends/amiga/pkg/netsurf_os3.readme b/frontends/amiga/pkg/netsurf_os3.readme index 66774e6bc..53514f8db 100644 --- a/frontends/amiga/pkg/netsurf_os3.readme +++ b/frontends/amiga/pkg/netsurf_os3.readme @@ -2,14 +2,14 @@ Short: Fast CSS capable web browser Uploader: chris@unsatisfactorysoftware.co.uk (Chris Young) Author: NetSurf contributors (OS4 port by Chris Young) Type: comm/www -Version: 3.9 BETA -Requires: dev/misc/guigfxlib.lha -Architecture: m68k-amigaos >= 3.5.0 +Version: 3.11 BETA +Requires: dev/misc/guigfxlib.lha util/libs/AmiSSL-5.13-OS3.lha +Architecture: m68k-amigaos >= 3.2.0 -This is NetSurf 3.9 BETA for AmigaOS 3. +This is NetSurf 3.11 BETA for AmigaOS 3. It is built off of the OS4 (Reaction) frontend. -Requirements are AmigaOS 3.5 or 3.9, 32MB RAM. +Requirements are AmigaOS 3.2, 3.5 or 3.9, 32MB RAM. THIS IS EARLY BETA QUALITY SOFTWARE FOR TESTING ONLY. ALL USE IS AT YOUR OWN RISK. IT *WILL* CRASH! diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c index 2e9f5cb2b..8bc1712dd 100644 --- a/frontends/amiga/plotters.c +++ b/frontends/amiga/plotters.c @@ -115,6 +115,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit /* init shared bitmaps */ int depth = 32; struct BitMap *friend = NULL; + struct Screen *scrn = ami_gui_get_screen(); struct gui_globals *gg = malloc(sizeof(struct gui_globals)); @@ -125,11 +126,34 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit if(depth < 16) { gg->palette_mapped = true; if(force32bit == false) palette_mapped = true; + + bitmap_set_format(&(bitmap_fmt_t) { + .layout = BITMAP_LAYOUT_ARGB8888, + .pma = true, + }); + + NSLOG(netsurf, INFO, "Set bitmap format to 0xAARRGGBB (native endian) (PMA)"); + } else { gg->palette_mapped = false; - if(force32bit == false) palette_mapped = false; + + bitmap_set_format(&(bitmap_fmt_t) { + .layout = BITMAP_LAYOUT_ARGB8888, + .pma = false, + }); + + NSLOG(netsurf, INFO, "Set bitmap format to 0xAARRGGBB (native endian)"); + } #else + bitmap_set_format(&(bitmap_fmt_t) { + .layout = BITMAP_LAYOUT_ARGB8888, + .pma = true, + }); + + NSLOG(netsurf, INFO, "Set bitmap format to 0xAARRGGBB (native endian) (PMA)"); + + /* Friend BitMaps are weird. * For OS4, we shouldn't use a friend BitMap here (see below). * For OS3 AGA, we get no display blitted if we use a friend BitMap, @@ -143,16 +167,12 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap; } - /* OS3 is locked to using palette-mapped display even on RTG. - * To change this, comment out the below and build with the similar OS4 lines above. - * Various bits of RTG code are OS4-only and OS3 versions will need to be written, - * however a brief test reveals a negative performance benefit, so this lock to a - * palette-mapped display is most likely permanent. - */ -#warning OS3 locked to palette-mapped modes - gg->palette_mapped = true; - palette_mapped = true; - if(depth > 8) depth = 8; + if(depth < 16) { + gg->palette_mapped = true; + if(force32bit == false) palette_mapped = true; + } else { + gg->palette_mapped = false; + } #endif /* Probably need to fix this next line */ @@ -256,11 +276,7 @@ void ami_plot_ra_free(struct gui_globals *gg) ami_memory_chip_free(gg->tmprasbuf); free(gg->areabuf); DisposeLayerInfo(gg->layerinfo); - if(gg->palette_mapped == false) { - if(gg->bm) ami_rtg_freebitmap(gg->bm); - } else { - if(gg->bm) FreeBitMap(gg->bm); - } + if(gg->bm) ami_rtg_freebitmap(gg->bm); if(gg->managed_pen_list == true) { ami_plot_release_pens(gg->shared_pens); @@ -295,6 +311,7 @@ void ami_plot_ra_set_pen_list(struct gui_globals *gg, struct MinList *pen_list) void ami_clearclipreg(struct gui_globals *gg) { struct Region *reg = NULL; + struct Screen *scrn = ami_gui_get_screen(); reg = InstallClipRegion(gg->rp->Layer,NULL); if(reg) DisposeRegion(reg); @@ -313,6 +330,8 @@ void ami_clearclipreg(struct gui_globals *gg) static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr) { struct ami_plot_pen *node; + struct Screen *scrn = ami_gui_get_screen(); + LONG pen = ObtainBestPenA(scrn->ViewPort.ColorMap, (colr & 0x000000ff) << 24, (colr & 0x0000ff00) << 16, @@ -336,6 +355,7 @@ static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr) void ami_plot_release_pens(struct MinList *shared_pens) { + struct Screen *scrn = ami_gui_get_screen(); struct ami_plot_pen *node; struct ami_plot_pen *nnode; @@ -429,7 +449,7 @@ static nserror ami_bitmap(struct gui_globals *glob, int x, int y, int width, int height, struct bitmap *bitmap) { NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_bitmap()"); - + struct Screen *scrn = ami_gui_get_screen(); struct BitMap *tbm; if (!width || !height) { @@ -519,6 +539,7 @@ HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage { int xf,yf; struct bfbitmap *bfbm = (struct bfbitmap *)hook->h_Data; + struct Screen *scrn = ami_gui_get_screen(); /* tile down and across to extents (msg->Bounds.MinX)*/ for (xf = -bfbm->offsetx; xf < msg->Bounds.MaxX; xf += bfbm->width) { diff --git a/frontends/amiga/plugin_hack.c b/frontends/amiga/plugin_hack.c index 5d7ec19c1..a775936bb 100644 --- a/frontends/amiga/plugin_hack.c +++ b/frontends/amiga/plugin_hack.c @@ -35,6 +35,7 @@ #include "amiga/filetype.h" #include "amiga/plugin_hack.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/llcache.h" @@ -52,9 +53,9 @@ static void amiga_plugin_hack_destroy(struct content *c); static bool amiga_plugin_hack_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx); -static void amiga_plugin_hack_open(struct content *c, struct browser_window *bw, +static nserror amiga_plugin_hack_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params); -static void amiga_plugin_hack_close(struct content *c); +static nserror amiga_plugin_hack_close(struct content *c); static nserror amiga_plugin_hack_clone(const struct content *old, struct content **newc); static content_type amiga_plugin_hack_content_type(void); @@ -185,7 +186,7 @@ bool amiga_plugin_hack_redraw(struct content *c, * object within a page * \param params object parameters, or 0 if not an object */ -void amiga_plugin_hack_open(struct content *c, struct browser_window *bw, +nserror amiga_plugin_hack_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params) { NSLOG(netsurf, INFO, "amiga_plugin_hack_open %s", @@ -198,13 +199,13 @@ void amiga_plugin_hack_open(struct content *c, struct browser_window *bw, c->height = 0; } - return; + return NSERROR_OK; } -void amiga_plugin_hack_close(struct content *c) +nserror amiga_plugin_hack_close(struct content *c) { NSLOG(netsurf, INFO, "amiga_plugin_hack_close"); - return; + return NSERROR_OK; } void amiga_plugin_hack_reformat(struct content *c, int width, int height) diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c index 4b48805b5..97c70b96c 100644 --- a/frontends/amiga/print.c +++ b/frontends/amiga/print.c @@ -276,8 +276,8 @@ void ami_print_ui(struct hlcache_handle *c) WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, FALSE, - WA_PubScreen, scrn, - WINDOW_SharedPort, sport, + WA_PubScreen, ami_gui_get_screen(), + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_UserData, pw, WINDOW_IconifyGadget, FALSE, WINDOW_Position, WPOS_CENTERSCREEN, @@ -407,7 +407,7 @@ static BOOL ami_print_event(void *w) void ami_print(struct hlcache_handle *c, int copies) { - float height; + double height; float scale = nsoption_int(print_scale) / 100.0; if(ami_print_info.msgport == NULL) @@ -565,7 +565,7 @@ void ami_print_progress(void) WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen,scrn, + WA_PubScreen, ami_gui_get_screen(), //WINDOW_SharedPort,sport, WINDOW_UserData, &ami_print_info, WINDOW_IconifyGadget, FALSE, diff --git a/frontends/amiga/resources/Themes/AISS/Theme b/frontends/amiga/resources/Themes/AISS/Theme index 8c5af103c..f8265bf73 100755 --- a/frontends/amiga/resources/Themes/AISS/Theme +++ b/frontends/amiga/resources/Themes/AISS/Theme @@ -31,6 +31,11 @@ theme_tab_loading:*TBImages:list_download theme_search:*TBImages:list_search theme_fave:*TBImages:list_favouriteadd theme_unfave:*TBImages:list_favourite +theme_pageinfo_insecure:*TBImages:list_warning +theme_pageinfo_internal:*TBImages:list_info +theme_pageinfo_local:*TBImages:list_info +theme_pageinfo_secure:*TBImages:list_securezone +theme_pageinfo_warning:*TBImages:list_warning ptr_default:*PROGDIR:Resources/Pointers/Default ptr_point:*PROGDIR:Resources/Pointers/Point ptr_caret:*PROGDIR:Resources/Pointers/Caret diff --git a/frontends/amiga/resources/Themes/Default/Theme b/frontends/amiga/resources/Themes/Default/Theme index 141e84f54..7e8e9c8d6 100755 --- a/frontends/amiga/resources/Themes/Default/Theme +++ b/frontends/amiga/resources/Themes/Default/Theme @@ -44,6 +44,11 @@ theme_tab_loading: theme_search:search.png theme_fave:*PROGDIR:Resources/icons/hotlist-add.png theme_unfave:*PROGDIR:Resources/icons/hotlist-rmv.png +theme_pageinfo_insecure:*PROGDIR:Resources/icons/16x16/actions/page-info-insecure.png +theme_pageinfo_internal:*PROGDIR:Resources/icons/16x16/actions/page-info-internal.png +theme_pageinfo_local:*PROGDIR:Resources/icons/16x16/actions/page-info-local.png +theme_pageinfo_secure:*PROGDIR:Resources/icons/16x16/actions/page-info-secure.png +theme_pageinfo_warning:*PROGDIR:Resources/icons/16x16/actions/page-info-warning.png ptr_default:*PROGDIR:Resources/Pointers/Default ptr_point:*PROGDIR:Resources/Pointers/Point ptr_caret:*PROGDIR:Resources/Pointers/Caret diff --git a/frontends/amiga/rtg.c b/frontends/amiga/rtg.c index 5e1cac290..8618c0a33 100644 --- a/frontends/amiga/rtg.c +++ b/frontends/amiga/rtg.c @@ -26,9 +26,6 @@ struct BitMap *ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth, ULONG flags, struct BitMap *friend, RGBFTYPE format) { if(P96Base == NULL) { -#ifndef __amigaos4__ - if(depth > 8) depth = 8; -#endif return AllocBitMap(width, height, depth, flags, friend); } else { return p96AllocBitMap(width, height, depth, flags, friend, format); diff --git a/frontends/amiga/schedule.c b/frontends/amiga/schedule.c index 043edc7fe..307fff3e9 100644 --- a/frontends/amiga/schedule.c +++ b/frontends/amiga/schedule.c @@ -107,7 +107,8 @@ static nserror ami_schedule_add_timer_event(struct nscallback *nscb, int t) * A scheduled callback matching both callback and p is returned, or NULL if none present. */ -static struct nscallback *ami_schedule_locate(void (*callback)(void *p), void *p, bool remove) +static struct nscallback * +ami_schedule_locate(void (*callback)(void *p), void *p, bool remove) { PblIterator *iterator; struct nscallback *nscb; @@ -119,7 +120,7 @@ static struct nscallback *ami_schedule_locate(void (*callback)(void *p), void *p iterator = pblHeapIterator(schedule_list); - while ((nscb = pblIteratorNext(iterator)) != -1) { + while ((nscb = pblIteratorNext(iterator)) != (void *)-1) { if ((nscb->callback == callback) && (nscb->p == p)) { if (remove == true) pblIteratorRemove(iterator); found_cb = true; @@ -170,7 +171,11 @@ static nserror schedule_remove(void (*callback)(void *p), void *p, bool abort) if(nscb != NULL) { if(abort == true) ami_schedule_remove_timer_event(nscb); +#ifdef __amigaos4__ FreeSysObject(ASOT_IOREQUEST, nscb); +#else + FreeVec(nscb); +#endif pblHeapConstruct(schedule_list); } @@ -186,11 +191,14 @@ static void schedule_remove_all(void) iterator = pblHeapIterator(schedule_list); - while ((nscb = pblIteratorNext(iterator)) != -1) - { + while ((nscb = pblIteratorNext(iterator)) != (void *)-1) { ami_schedule_remove_timer_event(nscb); pblIteratorRemove(iterator); +#ifdef __amigaos4__ FreeSysObject(ASOT_IOREQUEST, nscb); +#else + FreeVec(nscb); +#endif }; pblIteratorFree(iterator); @@ -218,18 +226,17 @@ static void ami_schedule_dump(void) GetSysTime(&tv); Amiga2Date(tv.Seconds, &clockdata); - NSLOG(netsurf, INFO, "Current time = %d-%d-%d %d:%d:%d.%d", + NSLOG(netsurf, INFO, "Current time = %d-%d-%d %d:%d:%d.%lu", clockdata.mday, clockdata.month, clockdata.year, clockdata.hour, clockdata.min, clockdata.sec, tv.Microseconds); NSLOG(netsurf, INFO, "Events remaining in queue:"); iterator = pblHeapIterator(schedule_list); - while ((nscb = pblIteratorNext(iterator)) != -1) - { + while ((nscb = pblIteratorNext(iterator)) != (void *)-1) { Amiga2Date(nscb->tv.Seconds, &clockdata); NSLOG(netsurf, INFO, - "nscb: %p, at %d-%d-%d %d:%d:%d.%d, callback: %p, %p", + "nscb: %p, at %d-%d-%d %d:%d:%d.%lu, callback: %p, %p", nscb, clockdata.mday, clockdata.month, clockdata.year, clockdata.hour, clockdata.min, clockdata.sec, nscb->tv.Microseconds, nscb->callback, nscb->p); @@ -299,7 +306,10 @@ nserror ami_schedule_create(struct MsgPort *msgport) schedule_msgport = msgport; #endif schedule_list = pblHeapNew(); - if(schedule_list == PBL_ERROR_OUT_OF_MEMORY) return NSERROR_NOMEM; + + if (schedule_list == NULL) { + return NSERROR_NOMEM; + } pblHeapSetCompareFunction(schedule_list, ami_schedule_compare); @@ -335,11 +345,13 @@ nserror ami_schedule(int t, void (*callback)(void *p), void *p) nscb = AllocSysObjectTags(ASOT_IOREQUEST, ASOIOR_Duplicate, tioreq, TAG_DONE); + if(nscb == NULL) return NSERROR_NOMEM; #else - nscb = (struct nscallback *)CreateIORequest(schedule_msgport, sizeof(struct nscallback)); + if(schedule_msgport == NULL) return NSERROR_NOMEM; + nscb = AllocVec(sizeof(struct nscallback), MEMF_PUBLIC | MEMF_CLEAR); + if(nscb == NULL) return NSERROR_NOMEM; *nscb = *tioreq; #endif - if(!nscb) return NSERROR_NOMEM; if (ami_schedule_add_timer_event(nscb, t) != NSERROR_OK) return NSERROR_NOMEM; diff --git a/frontends/amiga/search.c b/frontends/amiga/search.c index e6333621b..853c06fef 100755 --- a/frontends/amiga/search.c +++ b/frontends/amiga/search.c @@ -143,10 +143,10 @@ void ami_search_open(struct gui_window *gwin) if(fwin) { - browser_window_search_clear(fwin->gwin->bw); - fwin->gwin->shared->searchwin = NULL; + browser_window_search_clear(ami_gui_get_browser_window(fwin->gwin)); + ami_gui_set_find_window(fwin->gwin, NULL); fwin->gwin = gwin; - gwin->shared->searchwin = fwin; + ami_gui_set_find_window(fwin->gwin, fwin); WindowToFront(fwin->win); ActivateWindow(fwin->win); return; @@ -169,8 +169,8 @@ void ami_search_open(struct gui_window *gwin) WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, TRUE, - WA_PubScreen, scrn, - WINDOW_SharedPort, sport, + WA_PubScreen, ami_gui_get_screen(), + WINDOW_SharedPort, ami_gui_get_shared_msgport(), WINDOW_UserData, fwin, WINDOW_IconifyGadget, FALSE, WINDOW_LockHeight, TRUE, @@ -220,7 +220,7 @@ void ami_search_open(struct gui_window *gwin) fwin->win = (struct Window *)RA_OpenWindow(fwin->objects[OID_S_MAIN]); fwin->gwin = gwin; ami_gui_win_list_add(fwin, AMINS_FINDWINDOW, &ami_search_table); - gwin->shared->searchwin = fwin; + ami_gui_set_find_window(fwin->gwin, fwin); ActivateLayoutGadget((struct Gadget *)fwin->objects[GID_S_MAIN], fwin->win, NULL, (ULONG)fwin->objects[GID_S_SEARCHSTRING]); @@ -228,8 +228,8 @@ void ami_search_open(struct gui_window *gwin) void ami_search_close(void) { - browser_window_search_clear(fwin->gwin->bw); - fwin->gwin->shared->searchwin = NULL; + browser_window_search_clear(ami_gui_get_browser_window(fwin->gwin)); + ami_gui_set_find_window(fwin->gwin, NULL); DisposeObject(fwin->objects[OID_S_MAIN]); /* Free local charset version of messages */ @@ -256,7 +256,7 @@ static BOOL ami_search_event(void *w) switch(result & WMHI_GADGETMASK) { case GID_S_SEARCHSTRING: - browser_window_search_clear(fwin->gwin->bw); + browser_window_search_clear(ami_gui_get_browser_window(fwin->gwin)); RefreshSetGadgetAttrs((struct Gadget *)fwin->objects[GID_S_PREV], fwin->win, NULL, @@ -275,10 +275,10 @@ static BOOL ami_search_event(void *w) flags = SEARCH_FLAG_FORWARDS | ami_search_flags(); browser_window_search( - fwin->gwin->bw, + ami_gui_get_browser_window(fwin->gwin), NULL, flags, ami_search_string()); - ActivateWindow(fwin->gwin->shared->win); + ActivateWindow(ami_gui_get_window(fwin->gwin)); break; case GID_S_PREV: @@ -286,10 +286,10 @@ static BOOL ami_search_event(void *w) flags = ~SEARCH_FLAG_FORWARDS & ami_search_flags(); browser_window_search( - fwin->gwin->bw, + ami_gui_get_browser_window(fwin->gwin), NULL, flags, ami_search_string()); - ActivateWindow(fwin->gwin->shared->win); + ActivateWindow(ami_gui_get_window(fwin->gwin)); break; } break; diff --git a/frontends/amiga/search.h b/frontends/amiga/search.h index f30352cd5..1815ef954 100755 --- a/frontends/amiga/search.h +++ b/frontends/amiga/search.h @@ -22,7 +22,7 @@ struct gui_search_table; struct gui_window; -struct gui_search_table *amiga_search_table; +extern struct gui_search_table *amiga_search_table; /** * Change the displayed search status. diff --git a/frontends/amiga/selectmenu.c b/frontends/amiga/selectmenu.c index 8a8614136..873871d3d 100644 --- a/frontends/amiga/selectmenu.c +++ b/frontends/amiga/selectmenu.c @@ -71,10 +71,10 @@ BOOL ami_selectmenu_is_safe(void) HOOKF(uint32, ami_popup_hook, Object *, item, APTR) { uint32 itemid = 0; - struct gui_window *gwin = hook->h_Data; + struct form_control *control = hook->h_Data; if(GetAttr(PMIA_ID, item, &itemid)) { - form_select_process_selection(gwin->shared->control, itemid); + form_select_process_selection(control, itemid); } return itemid; @@ -109,9 +109,7 @@ void gui_create_form_select_menu(struct gui_window *g, selectmenuhook.h_Entry = ami_popup_hook; selectmenuhook.h_SubEntry = NULL; - selectmenuhook.h_Data = g; - - g->shared->control = control; + selectmenuhook.h_Data = control; selectmenuobj = PMMENU(form_control_get_name(control)), PMA_MenuHandler, &selectmenuhook, End; @@ -166,9 +164,9 @@ void gui_create_form_select_menu(struct gui_window *g, ~0); } - ami_set_pointer(g->shared, GUI_POINTER_DEFAULT, false); // Clear the menu-style pointer + ami_set_pointer(ami_gui_get_gui_window_2(g), GUI_POINTER_DEFAULT, false); // Clear the menu-style pointer - IDoMethod(selectmenuobj, PM_OPEN, g->shared->win); + IDoMethod(selectmenuobj, PM_OPEN, ami_gui_get_window(g)); /* PM_OPEN is blocking, so dispose menu immediately... */ if(selectmenuobj) DisposeObject(selectmenuobj); diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c deleted file mode 100644 index 136b918fc..000000000 --- a/frontends/amiga/sslcert.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * \file - * Implementation of Amiga certificate viewing using core windows. - */ - -#include <stdint.h> -#include <stdlib.h> - -#include <proto/intuition.h> - -#include <classes/window.h> -#include <gadgets/button.h> -#include <gadgets/layout.h> -#include <gadgets/scroller.h> -#include <gadgets/space.h> -#include <images/label.h> - -#include <intuition/icclass.h> -#include <reaction/reaction_macros.h> - -#include "utils/log.h" -#include "netsurf/keypress.h" -#include "netsurf/plotters.h" -#include "desktop/sslcert_viewer.h" -#include "utils/messages.h" -#include "utils/nsoption.h" - -#include "amiga/corewindow.h" -#include "amiga/libs.h" -#include "amiga/sslcert.h" -#include "amiga/utf8.h" - - -/** - * Amiga certificate viewing window context - */ -enum { - GID_SSLCERT_ACCEPT = GID_CW_LAST, - GID_SSLCERT_REJECT, - GID_SSLCERT_LAST -}; - -#define GID_SSLCERT_SIZE GID_SSLCERT_LAST - GID_CW_LAST - -struct ami_crtvrfy_window { - /** Amiga core window context */ - struct ami_corewindow core; - - /** Amiga GUI stuff */ - Object *sslcert_objects[GID_SSLCERT_LAST]; // technically wasting a few bytes here - - char *sslerr; - char *sslaccept; - char *sslreject; - - /** SSL certificate viewer context data */ - struct sslcert_session_data *ssl_data; -}; - -/** - * destroy a previously created certificate view - */ -static nserror -ami_crtvrfy_destroy(struct ami_crtvrfy_window *crtvrfy_win) -{ - nserror res; - - res = sslcert_viewer_fini(crtvrfy_win->ssl_data); - if (res == NSERROR_OK) { - ami_utf8_free(crtvrfy_win->sslerr); - ami_utf8_free(crtvrfy_win->sslaccept); - ami_utf8_free(crtvrfy_win->sslreject); - res = ami_corewindow_fini(&crtvrfy_win->core); /* closes the window for us */ - } - return res; -} - -static void -ami_crtvrfy_accept(struct ami_corewindow *ami_cw) -{ - struct ami_crtvrfy_window *crtvrfy_win; - /* technically degenerate container of */ - crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw; - - sslcert_viewer_accept(crtvrfy_win->ssl_data); - - ami_crtvrfy_destroy(crtvrfy_win); -} - -static void -ami_crtvrfy_reject(struct ami_corewindow *ami_cw) -{ - struct ami_crtvrfy_window *crtvrfy_win; - /* technically degenerate container of */ - crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw; - - sslcert_viewer_reject(crtvrfy_win->ssl_data); - - ami_crtvrfy_destroy(crtvrfy_win); -} - -/** - * callback for unknown events on Amiga core window - * eg. buttons in the ssl cert window - * (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP) - * (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT) - * - * \param ami_cw The Amiga core window structure. - * \param result event as returned by RA_HandleInput() - * \return TRUE if window closed during event processing - */ -static BOOL -ami_crtvrfy_event(struct ami_corewindow *ami_cw, ULONG result) -{ - if((result & WMHI_CLASSMASK) == WMHI_GADGETUP) { - switch(result & WMHI_GADGETMASK) { - case GID_SSLCERT_ACCEPT: - ami_crtvrfy_accept(ami_cw); - return TRUE; - break; - - case GID_SSLCERT_REJECT: - ami_crtvrfy_reject(ami_cw); - return TRUE; - break; - } - } - return FALSE; -} - -/** - * callback for mouse action for certificate verify on core window - * - * \param ami_cw The Amiga core window structure. - * \param mouse_state netsurf mouse state on event - * \param x location of event - * \param y location of event - * \return NSERROR_OK on success otherwise apropriate error code - */ -static nserror -ami_crtvrfy_mouse(struct ami_corewindow *ami_cw, - browser_mouse_state mouse_state, - int x, int y) -{ - struct ami_crtvrfy_window *crtvrfy_win; - /* technically degenerate container of */ - crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw; - - sslcert_viewer_mouse_action(crtvrfy_win->ssl_data, mouse_state, x, y); - - return NSERROR_OK; -} - -/** - * callback for keypress for certificate verify on core window - * - * \param ami_cw The Amiga core window structure. - * \param nskey The netsurf key code - * \return NSERROR_OK on success otherwise apropriate error code - */ -static nserror -ami_crtvrfy_key(struct ami_corewindow *ami_cw, uint32_t nskey) -{ - struct ami_crtvrfy_window *crtvrfy_win; - - /* technically degenerate container of */ - crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw; - - if (sslcert_viewer_keypress(crtvrfy_win->ssl_data, nskey)) { - return NSERROR_OK; - } - return NSERROR_NOT_IMPLEMENTED; -} - -/** - * callback on draw event for certificate verify on core window - * - * \param ami_cw The Amiga core window structure. - * \param x the x coordinate to draw - * \param y the y coordinate to draw - * \param r The rectangle of the window that needs updating. - * \param ctx The drawing context - * \return NSERROR_OK on success otherwise apropriate error code - */ -static nserror -ami_crtvrfy_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx) -{ - struct ami_crtvrfy_window *crtvrfy_win; - - /* technically degenerate container of */ - crtvrfy_win = (struct ami_crtvrfy_window *)ami_cw; - - sslcert_viewer_redraw(crtvrfy_win->ssl_data, x, y, r, ctx); - - return NSERROR_OK; -} - -static nserror -ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win) -{ - struct ami_corewindow *ami_cw = (struct ami_corewindow *)&crtvrfy_win->core; - ULONG refresh_mode = WA_SmartRefresh; - - if(nsoption_bool(window_simple_refresh) == true) { - refresh_mode = WA_SimpleRefresh; - } - - ami_cw->objects[GID_CW_WIN] = WindowObj, - WA_ScreenTitle, ami_gui_get_screen_title(), - WA_Title, ami_cw->wintitle, - WA_Activate, TRUE, - WA_DepthGadget, TRUE, - WA_DragBar, TRUE, - WA_CloseGadget, FALSE, - WA_SizeGadget, TRUE, - WA_SizeBBottom, TRUE, - WA_Height, scrn->Height / 2, - WA_PubScreen, scrn, - WA_ReportMouse, TRUE, - refresh_mode, TRUE, - WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | - IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | - IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, - WINDOW_IDCMPHook, &ami_cw->idcmp_hook, - WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | - IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, - WINDOW_SharedPort, sport, - WINDOW_UserData, crtvrfy_win, - /* WINDOW_NewMenu, twin->menu, -> No menu for SSL Cert */ - WINDOW_IconifyGadget, FALSE, - WINDOW_Position, WPOS_CENTERSCREEN, - WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj, - LAYOUT_AddImage, LabelObj, - LABEL_Text, crtvrfy_win->sslerr, - LabelEnd, - LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLLLAYOUT] = LayoutVObj, - LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLLLAYOUT] = LayoutHObj, - LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj, - GA_ID, GID_CW_DRAW, - SPACE_Transparent, TRUE, - SPACE_BevelStyle, BVS_DISPLAY, - GA_RelVerify, TRUE, - SpaceEnd, - LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLL] = ScrollerObj, - GA_ID, GID_CW_VSCROLL, - GA_RelVerify, TRUE, - ICA_TARGET, ICTARGET_IDCMP, - ScrollerEnd, - LayoutEnd, - LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLL] = ScrollerObj, - GA_ID, GID_CW_HSCROLL, - GA_RelVerify, TRUE, - ICA_TARGET, ICTARGET_IDCMP, - SCROLLER_Orientation, SORIENT_HORIZ, - ScrollerEnd, - LayoutEnd, - LAYOUT_AddChild, LayoutHObj, - LAYOUT_AddChild, crtvrfy_win->sslcert_objects[GID_SSLCERT_ACCEPT] = ButtonObj, - GA_ID, GID_SSLCERT_ACCEPT, - GA_Text, crtvrfy_win->sslaccept, - GA_RelVerify, TRUE, - ButtonEnd, - LAYOUT_AddChild, crtvrfy_win->sslcert_objects[GID_SSLCERT_REJECT] = ButtonObj, - GA_ID, GID_SSLCERT_REJECT, - GA_Text, crtvrfy_win->sslreject, - GA_RelVerify, TRUE, - ButtonEnd, - EndGroup, - CHILD_WeightedHeight, 0, - EndGroup, - EndWindow; - - if(ami_cw->objects[GID_CW_WIN] == NULL) { - return NSERROR_NOMEM; - } - - return NSERROR_OK; -} - -/* exported interface documented in amiga/ssl_cert.h */ -nserror ami_cert_verify(struct nsurl *url, - const struct ssl_cert_info *certs, - unsigned long num, - nserror (*cb)(bool proceed, void *pw), - void *cbpw) -{ - struct ami_crtvrfy_window *ncwin; - nserror res; - - ncwin = calloc(1, sizeof(struct ami_crtvrfy_window)); - if (ncwin == NULL) { - return NSERROR_NOMEM; - } - - ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("SSLCerts")); - ncwin->sslerr = ami_utf8_easy((char *)messages_get("SSLError")); - ncwin->sslaccept = ami_utf8_easy((char *)messages_get("SSL_Certificate_Accept")); - ncwin->sslreject = ami_utf8_easy((char *)messages_get("SSL_Certificate_Reject")); - - res = ami_crtvrfy_create_window(ncwin); - if (res != NSERROR_OK) { - NSLOG(netsurf, INFO, "SSL UI builder init failed"); - ami_utf8_free(ncwin->core.wintitle); - ami_utf8_free(ncwin->sslerr); - ami_utf8_free(ncwin->sslaccept); - ami_utf8_free(ncwin->sslreject); - free(ncwin); - return res; - } - - /* initialise Amiga core window */ - ncwin->core.draw = ami_crtvrfy_draw; - ncwin->core.key = ami_crtvrfy_key; - ncwin->core.mouse = ami_crtvrfy_mouse; - ncwin->core.close = ami_crtvrfy_reject; - ncwin->core.event = ami_crtvrfy_event; - - res = ami_corewindow_init(&ncwin->core); - if (res != NSERROR_OK) { - ami_utf8_free(ncwin->core.wintitle); - ami_utf8_free(ncwin->sslerr); - ami_utf8_free(ncwin->sslaccept); - ami_utf8_free(ncwin->sslreject); - DisposeObject(ncwin->core.objects[GID_CW_WIN]); - free(ncwin); - return res; - } - - /* initialise certificate viewing interface */ - res = sslcert_viewer_create_session_data(num, url, cb, cbpw, certs, - &ncwin->ssl_data); - if (res != NSERROR_OK) { - ami_utf8_free(ncwin->core.wintitle); - ami_utf8_free(ncwin->sslerr); - ami_utf8_free(ncwin->sslaccept); - ami_utf8_free(ncwin->sslreject); - DisposeObject(ncwin->core.objects[GID_CW_WIN]); - free(ncwin); - return res; - } - - res = sslcert_viewer_init(ncwin->core.cb_table, - (struct core_window *)ncwin, - ncwin->ssl_data); - if (res != NSERROR_OK) { - ami_utf8_free(ncwin->core.wintitle); - ami_utf8_free(ncwin->sslerr); - ami_utf8_free(ncwin->sslaccept); - ami_utf8_free(ncwin->sslreject); - DisposeObject(ncwin->core.objects[GID_CW_WIN]); - free(ncwin); - return res; - } - - return NSERROR_OK; -} - diff --git a/frontends/amiga/sslcert.h b/frontends/amiga/sslcert.h deleted file mode 100644 index 392989f02..000000000 --- a/frontends/amiga/sslcert.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef AMIGA_SSLCERT_H -#define AMIGA_SSLCERT_H -struct nsurl; -struct ssl_cert_info; - -/** - * Prompt the user to verify a certificate with issues. - * - * \param url The URL being verified. - * \param certs The certificate to be verified - * \param num The number of certificates to be verified. - * \param cb Callback upon user decision. - * \param cbpw Context pointer passed to cb - * \return NSERROR_OK or error code if prompt creation failed. - */ -nserror ami_cert_verify(struct nsurl *url, - const struct ssl_cert_info *certs, unsigned long num, - nserror (*cb)(bool proceed, void *pw), void *cbpw); -#endif - diff --git a/frontends/amiga/stringview/stringview.c b/frontends/amiga/stringview/stringview.c index 245782b43..60c694a3c 100755 --- a/frontends/amiga/stringview/stringview.c +++ b/frontends/amiga/stringview/stringview.c @@ -161,7 +161,7 @@ static uint32 myStringSearch( Class *cl, Object *obj ) if(searchString) { searchString += 3; - if (bufpos >= searchString - data->SearchBuffer) + if (bufpos >= (uint32)(searchString - data->SearchBuffer)) bufpos -= searchString - data->SearchBuffer; } else @@ -848,7 +848,7 @@ Class *MakeStringClass( void ) if ( cl ) { - cl->cl_Dispatcher.h_Entry = (uint32(*)())myStringClassDispatcher; + cl->cl_Dispatcher.h_Entry = (uint32(*)(void))myStringClassDispatcher; } URLHistory_Init(); diff --git a/frontends/amiga/stringview/stringview.h b/frontends/amiga/stringview/stringview.h index 776705f0f..ecb53e802 100755 --- a/frontends/amiga/stringview/stringview.h +++ b/frontends/amiga/stringview/stringview.h @@ -41,8 +41,8 @@ struct myStringClassData Object * WindowObject; Object * ListviewObject; struct List ListviewHeader; - uint32 ListviewCount; - uint32 ListviewSelected; + int32 ListviewCount; + int32 ListviewSelected; struct List * SearchHeader; STRPTR SearchBuffer; }; diff --git a/frontends/amiga/theme.c b/frontends/amiga/theme.c index 63982c879..3e6ed8647 100644 --- a/frontends/amiga/theme.c +++ b/frontends/amiga/theme.c @@ -215,20 +215,7 @@ void ami_get_theme_filename(char *filename, const char *themestring, bool protoc void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) { - ami_set_pointer(g->shared, shape, true); -} - -void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update) -{ - if(gwin->mouse_pointer == shape) return; - ami_update_pointer(gwin->win, shape); - if(update == true) gwin->mouse_pointer = shape; -} - -/* reset the mouse pointer back to what NetSurf last set it as */ -void ami_reset_pointer(struct gui_window_2 *gwin) -{ - ami_update_pointer(gwin->win, gwin->mouse_pointer); + ami_set_pointer(ami_gui_get_gui_window_2(g), shape, true); } void ami_update_pointer(struct Window *win, gui_pointer_shape shape) @@ -429,16 +416,16 @@ void gui_window_start_throbber(struct gui_window *g) if(nsoption_bool(kiosk_mode)) return; #ifdef __amigaos4__ - if(g->tab_node && (g->shared->tabs > 1)) + if(ami_gui_get_tab_node(g) && (ami_gui2_get_tabs(ami_gui_get_gui_window_2(g)) > 1)) { - SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, TRUE, TAG_DONE); - RefreshGadgets((APTR)g->shared->objects[GID_TABS], - g->shared->win, NULL); + SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, TRUE, TAG_DONE); + RefreshGadgets((APTR)ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_TABS), + ami_gui_get_window(g), NULL); } #endif - g->throbbing = true; - if(g->shared->throbber_frame == 0) g->shared->throbber_frame = 1; + ami_gui_set_throbbing(g, true); + if(ami_gui_get_throbber_frame(g) == 0) ami_gui_set_throbber_frame(g, 1); ami_throbber_redraw_schedule(throbber_update_interval, g); } @@ -450,22 +437,22 @@ void gui_window_stop_throbber(struct gui_window *g) if(nsoption_bool(kiosk_mode)) return; #ifdef __amigaos4__ - if(g->tab_node && (g->shared->tabs > 1)) + if(ami_gui_get_tab_node(g) && (ami_gui2_get_tabs(ami_gui_get_gui_window_2(g)) > 1)) { - SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, FALSE, TAG_DONE); - RefreshGadgets((APTR)g->shared->objects[GID_TABS], - g->shared->win, NULL); + SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, FALSE, TAG_DONE); + RefreshGadgets((APTR)ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_TABS), + ami_gui_get_window(g), NULL); } #endif - if(g == g->shared->gw) { - if(ami_gui_get_space_box(g->shared->objects[GID_THROBBER], &bbox) != NSERROR_OK) { + if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g), g)) { + if(ami_gui_get_space_box(ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_THROBBER), &bbox) != NSERROR_OK) { amiga_warn_user("NoMemory", ""); return; } if(throbber != NULL) { - BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, + BltBitMapRastPort(throbber, 0, 0, ami_gui_get_window(g)->RPort, bbox->Left, bbox->Top, ami_theme_throbber_get_width(), ami_theme_throbber_get_height(), 0x0C0); @@ -473,7 +460,7 @@ void gui_window_stop_throbber(struct gui_window *g) ami_gui_free_space_box(bbox); } - g->throbbing = false; + ami_gui_set_throbbing(g, false); ami_throbber_redraw_schedule(-1, g); } @@ -484,17 +471,17 @@ static void ami_throbber_update(void *p) int frame = 0; if(!g) return; - if(!g->shared->objects[GID_THROBBER]) return; + if(!ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_THROBBER)) return; - 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; + if(ami_gui_get_throbbing(g) == true) { + frame = ami_gui_get_throbber_frame(g); + ami_gui_set_throbber_frame(g, frame + 1); + if(ami_gui_get_throbber_frame(g) > (throbber_frames-1)) + ami_gui_set_throbber_frame(g, 1); } - if(g->shared->gw == g) { - if(ami_gui_get_space_box(g->shared->objects[GID_THROBBER], &bbox) != NSERROR_OK) { + if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g),g)) { + if(ami_gui_get_space_box(ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_THROBBER), &bbox) != NSERROR_OK) { amiga_warn_user("NoMemory", ""); return; } @@ -508,14 +495,14 @@ static void ami_throbber_update(void *p) BLITA_Width, ami_theme_throbber_get_width(), BLITA_Height, ami_theme_throbber_get_height(), BLITA_Source, throbber, - BLITA_Dest, g->shared->win->RPort, + BLITA_Dest, ami_gui_get_window(g)->RPort, BLITA_SrcType, BLITT_BITMAP, BLITA_DestType, BLITT_RASTPORT, // BLITA_UseSrcAlpha, TRUE, TAG_DONE); #else BltBitMapRastPort(throbber, ami_theme_throbber_get_width() * frame, - 0, g->shared->win->RPort, + 0, ami_gui_get_window(g)->RPort, bbox->Left, bbox->Top, ami_theme_throbber_get_width(), ami_theme_throbber_get_height(), 0xC0); diff --git a/frontends/amiga/theme.h b/frontends/amiga/theme.h index 6de7bc150..6ab3c0ea8 100644 --- a/frontends/amiga/theme.h +++ b/frontends/amiga/theme.h @@ -40,8 +40,6 @@ void ami_update_throbber(struct gui_window_2 *g,bool redraw); void ami_init_mouse_pointers(void); void ami_mouse_pointers_free(void); -void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update); -void ami_reset_pointer(struct gui_window_2 *gwin); /* Use the following ONLY if nothing other than the Intuition window pointer is available, * and ALWAYS in preference to SetWindowPointer(), as it features more pointers and uses * the correct ones specified in user preferences. */ diff --git a/frontends/amiga/utf8.c b/frontends/amiga/utf8.c index 5d05e9535..fabb1e24c 100755 --- a/frontends/amiga/utf8.c +++ b/frontends/amiga/utf8.c @@ -1,5 +1,5 @@ /* - * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008-2021 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -22,6 +22,7 @@ #include <string.h> #include <sys/types.h> +#include <proto/codesets.h> #include <proto/exec.h> #include <proto/utility.h> @@ -31,20 +32,73 @@ #include "amiga/utf8.h" +static nserror ami_utf8_codesets(const char *string, size_t len, char **result, bool to_local) +{ + char *out; + ULONG utf8_tag = CSA_SourceCodeset, local_tag = CSA_DestCodeset, len_tag = CSA_SourceLen; + static struct codeset *utf8_cs = NULL; + static struct codeset *local_cs = NULL; + + if(local_cs == NULL) local_cs = CodesetsFind(NULL, +#ifdef __amigaos4__ + CSA_MIBenum, nsoption_int(local_codeset), +#else + NULL, +#endif + TAG_DONE); + + if(utf8_cs == NULL) utf8_cs = CodesetsFind(NULL, + CSA_MIBenum, CS_MIBENUM_UTF_8, + TAG_DONE); + + if(to_local == false) { + local_tag = CSA_SourceCodeset; + utf8_tag = CSA_DestCodeset; + } + + if(len == 0) len_tag = TAG_IGNORE; + + out = CodesetsConvertStr(CSA_Source, string, + len_tag, len, +#ifdef __amigaos4__ + local_tag, local_cs, +#endif + utf8_tag, utf8_cs, + CSA_MapForeignChars, TRUE, + TAG_DONE); + + if(out != NULL) { + *result = strdup(out); + CodesetsFreeA(out, NULL); + } else { + return NSERROR_BAD_ENCODING; + } + + return NSERROR_OK; +} + nserror utf8_from_local_encoding(const char *string, size_t len, char **result) { - return utf8_from_enc(string, nsoption_charp(local_charset), len, result, NULL); + if(__builtin_expect((CodesetsBase == NULL), 0)) { + return utf8_from_enc(string, nsoption_charp(local_charset), len, result, NULL); + } else { + return ami_utf8_codesets(string, len, result, false); + } } nserror utf8_to_local_encoding(const char *string, size_t len, char **result) { - nserror err = NSERROR_NOMEM; - char *local_charset = ASPrintf("%s//IGNORE", nsoption_charp(local_charset)); - if(local_charset) { - err = utf8_to_enc(string, local_charset, len, result); - FreeVec(local_charset); + if(__builtin_expect((CodesetsBase == NULL), 0)) { + nserror err = NSERROR_NOMEM; + char *local_charset = ASPrintf("%s//IGNORE", nsoption_charp(local_charset)); + if(local_charset) { + err = utf8_to_enc(string, local_charset, len, result); + FreeVec(local_charset); + } + return err; + } else { + return ami_utf8_codesets(string, len, result, true); } - return err; } void ami_utf8_free(char *ptr) diff --git a/frontends/amiga/version.c b/frontends/amiga/version.c index 61fbd7176..ae898cb83 100644 --- a/frontends/amiga/version.c +++ b/frontends/amiga/version.c @@ -25,7 +25,7 @@ * problems created by "0" not being a valid AmigaOS revision number. */ #define NETSURF_VERSION_MAJOR "3" -#define NETSURF_VERSION_MINOR_EXTERNAL "8" +#define NETSURF_VERSION_MINOR_EXTERNAL "12" #if defined(CI_BUILD) #define NETSURF_VERSION_MINOR CI_BUILD #else |