summaryrefslogtreecommitdiff
path: root/frontends/amiga/gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/amiga/gui.c')
-rw-r--r--frontends/amiga/gui.c1370
1 files changed, 1118 insertions, 252 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e337ede0c..8eb34fb92 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-2020 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,6 @@
#include "amiga/selectmenu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
-#include "amiga/sslcert.h"
#define AMINS_SCROLLERPEN NUMDRIPENS
#define NSA_KBD_SCROLL_PX 10
@@ -187,16 +195,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 +360,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 +377,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 +388,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 +740,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 +1095,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 +1216,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);
@@ -1037,6 +1461,10 @@ static void gui_init2(int argc, char** argv)
(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 +1482,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 +1783,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 +1886,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 +1928,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 +2010,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 +2080,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 +2103,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 +2219,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 +2245,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 +2656,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 +2717,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);
@@ -2371,6 +3000,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 +3141,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 +3254,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 +3575,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 +3597,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 +3746,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 +3771,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 +3788,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 +3828,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 +4232,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 +4281,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 +4359,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 +4419,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 +4451,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 +4478,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 +4536,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 +4544,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 +4565,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 +4576,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 +4712,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 +4754,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 +4866,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;
@@ -4102,6 +4934,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 +4964,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 +4998,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 +5187,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 +5283,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 +5537,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 +5564,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,12 +5580,17 @@ 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);
for(gid = 0; gid < GID_LAST; gid++)
- free(g->shared->helphints[gid]);
+ ami_utf8_free(g->shared->helphints[gid]);
ami_gui_win_list_remove(g->shared);
if(g->tab_node) {
@@ -4707,55 +5609,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 +5746,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 +5814,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 +5896,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 +5904,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 +5919,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 +6059,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 +6219,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 +6318,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 +6429,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 +6483,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 +6518,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 */