netsurf: branch master updated. release/3.6-169-g047b37d

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Thu Jan 5 18:57:12 GMT 2017


Gitweb links:

...log http://git.netsurf-browser.org/netsurf.git/shortlog/047b37d5f8c3810f8942f5744bb92640fbd4879f
...commit http://git.netsurf-browser.org/netsurf.git/commit/047b37d5f8c3810f8942f5744bb92640fbd4879f
...tree http://git.netsurf-browser.org/netsurf.git/tree/047b37d5f8c3810f8942f5744bb92640fbd4879f

The branch, master has been updated
       via  047b37d5f8c3810f8942f5744bb92640fbd4879f (commit)
       via  5687f6c27d40ec596b4d64c705d16a97bdb3c893 (commit)
       via  e98a05bb087fb5c2c2ee8d94b3011ae8b3aa5c7a (commit)
       via  6e957396a9bdc78a7d9823aaf76764bbb30c184a (commit)
       via  d6f6326ce9b6e60fcf9865e726b718ccfbbbea65 (commit)
       via  26b98ac51b2f5a7c3d35050fcf79f521bfdb05f8 (commit)
       via  57a2bb85992844b644433142e687940b3870ce40 (commit)
       via  2e11f7f3cbd7d563cb525a26ce79d76502ba7686 (commit)
       via  5eb7ee97ed641e152c488dab6c33c37d0635e48b (commit)
      from  695783e33b9c100b1ce28ef71a59a00f52cc374f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=047b37d5f8c3810f8942f5744bb92640fbd4879f
commit 047b37d5f8c3810f8942f5744bb92640fbd4879f
Merge: 695783e 5687f6c
Author: Chris Young <chris at unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris at unsatisfactorysoftware.co.uk>

    Merge branch 'chris/amiga-corewindow'
    Amiga cookie and SSL cert windows now migrated to corewindow



-----------------------------------------------------------------------

Summary of changes:
 desktop/cookie_manager.c     |    1 +
 frontends/amiga/cookies.c    |  373 ++++++++++++++++++++++++++++++++++++++++--
 frontends/amiga/cookies.h    |   11 +-
 frontends/amiga/corewindow.c |   59 ++++---
 frontends/amiga/corewindow.h |    4 +
 frontends/amiga/gui.c        |   13 +-
 frontends/amiga/menu.c       |   11 +-
 frontends/amiga/menu.h       |   22 ++-
 frontends/amiga/sslcert.c    |    2 +-
 9 files changed, 440 insertions(+), 56 deletions(-)
 mode change 100755 => 100644 frontends/amiga/cookies.c
 mode change 100755 => 100644 frontends/amiga/cookies.h

diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 6134fa5..5429f68 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -843,6 +843,7 @@ nserror cookie_manager_fini(void)
 
 	/* Destroy the cookie manager treeview */
 	err = treeview_destroy(cm_ctx.tree);
+	cm_ctx.tree = NULL;
 
 	/* Free cookie manager treeview entry fields */
 	for (i = 0; i < COOKIE_M_N_FIELDS; i++)
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
old mode 100755
new mode 100644
index 15f6dce..18ca425
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008, 2009 Chris Young <chris at unsatisfactorysoftware.co.uk>
+ * Copyright 2017 Chris Young <chris at unsatisfactorysoftware.co.uk>
  *
  * This file is part of NetSurf, http://www.netsurf-browser.org/
  *
@@ -16,26 +16,375 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <proto/exec.h>
+/**
+ * \file
+ * Implementation of Amiga cookie viewer using core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include <proto/intuition.h>
+
+#include <classes/window.h>
+#include <gadgets/layout.h>
+#include <gadgets/space.h>
+
+#include <reaction/reaction_macros.h>
 
 #include "desktop/cookie_manager.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
 
 #include "amiga/cookies.h"
-#include "amiga/tree.h"
+#include "amiga/corewindow.h"
+#include "amiga/libs.h"
+#include "amiga/utf8.h"
+
+enum {
+	/* Project menu */
+	AMI_COOKIE_M_PROJECT = 0,
+	 AMI_COOKIE_M_EXPAND,
+	  AMI_COOKIE_M_EXPAND_ALL,
+	  AMI_COOKIE_M_EXPAND_DOMAINS,
+	  AMI_COOKIE_M_EXPAND_COOKIES,
+	 AMI_COOKIE_M_COLLAPSE,
+	  AMI_COOKIE_M_COLLAPSE_ALL,
+	  AMI_COOKIE_M_COLLAPSE_DOMAINS,
+	  AMI_COOKIE_M_COLLAPSE_COOKIES,
+	 AMI_COOKIE_M_BAR_P1,
+	 AMI_COOKIE_M_SNAPSHOT,
+	 AMI_COOKIE_M_BAR_P2,
+	 AMI_COOKIE_M_CLOSE,
+	/* Edit menu */
+	AMI_COOKIE_M_EDIT,
+	 AMI_COOKIE_M_SELECTALL,
+	 AMI_COOKIE_M_CLEAR,
+	 AMI_COOKIE_M_BAR_E1,
+	 AMI_COOKIE_M_DELETE,
+	AMI_COOKIE_M_LAST
+};
+
+/**
+ * Amiga cookie viewer window context
+ */
+struct ami_cookie_window {
+	/** Amiga core window context */
+	struct ami_corewindow core;
+
+	struct ami_menu_data *menu_data[AMI_COOKIE_M_LAST + 1];
+	struct Menu *imenu; /* Intuition menu */
+};
+
+static struct ami_cookie_window *cookie_window = NULL;
+
+
+static void
+ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
+{
+	SetAttrs(cookie_win->core.objects[GID_CW_WIN],
+		WINDOW_MenuStrip, NULL,
+	TAG_DONE);
+	
+	ami_menu_free_menu(cookie_win->menu_data, AMI_COOKIE_M_LAST, cookie_win->imenu);
+}
+
+/**
+ * destroy a previously created cookie view
+ */
+static void
+ami_cookies_destroy(struct ami_corewindow *ami_cw)
+{
+	nserror res;
+
+	if(cookie_window == NULL)
+		return;
+
+	res = cookie_manager_fini();
+	if (res == NSERROR_OK) {
+		ami_cookies_menu_free(cookie_window);
+		res = ami_corewindow_fini(&cookie_window->core); /* closes the window for us, frees cookie_win */
+		cookie_window = NULL;
+	}
+}
+
+
+/**
+ * callback for mouse action for cookie viewer 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_cookies_mouse(struct ami_corewindow *ami_cw,
+					browser_mouse_state mouse_state,
+					int x, int y)
+{
+	cookie_manager_mouse_action(mouse_state, x, y);
+
+	return NSERROR_OK;
+}
+
+/**
+ * callback for keypress for cookies viewer on core window
+ *
+ * \param example_cw The Amiga core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_cookies_key(struct ami_corewindow *ami_cw, uint32_t nskey)
+{
+	if (cookie_manager_keypress(nskey)) {
+			return NSERROR_OK;
+	}
+	return NSERROR_NOT_IMPLEMENTED;
+}
+
+/**
+ * callback on draw event for cookies viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \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_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
+{
+	cookie_manager_redraw(x, y, r, ctx);
 
-struct treeview_window *cookies_window;
+	return NSERROR_OK;
+}
+
+/**
+ * menu stuff
+ */
+
+ /* menu hook functions */
+ 
+HOOKF(void, ami_cookies_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_expand(false);
+}
+ 
+HOOKF(void, ami_cookies_menu_item_project_expand_domains, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_expand(true);
+}
 
-void ami_cookies_initialise(void)
+HOOKF(void, ami_cookies_menu_item_project_expand_cookies, APTR, window, struct IntuiMessage *)
 {
-	cookies_window = ami_tree_create(TREE_COOKIES, NULL);
+	cookie_manager_expand(false);
+}
 
-	if(!cookies_window) return;
+HOOKF(void, ami_cookies_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_contract(true);
+}
+ 
+HOOKF(void, ami_cookies_menu_item_project_collapse_domains, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_contract(true);
 }
 
-void ami_cookies_free()
+HOOKF(void, ami_cookies_menu_item_project_collapse_cookies, APTR, window, struct IntuiMessage *)
 {
-	ami_tree_destroy(cookies_window);
-	cookies_window = NULL;
+	cookie_manager_contract(false);
 }
+
+HOOKF(void, ami_cookies_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
+{
+	struct ami_corewindow *ami_cw;
+	GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+	nsoption_set_int(cookies_window_ypos, ami_cw->win->TopEdge);
+	nsoption_set_int(cookies_window_xpos, ami_cw->win->LeftEdge);
+	nsoption_set_int(cookies_window_xsize, ami_cw->win->Width);
+	nsoption_set_int(cookies_window_ysize, ami_cw->win->Height);
+}
+
+HOOKF(void, ami_cookies_menu_item_project_close, APTR, window, struct IntuiMessage *)
+{
+	struct ami_corewindow *ami_cw;
+	GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+	
+	ami_cw->close_window = true;
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_keypress(NS_KEY_SELECT_ALL);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_keypress(NS_KEY_CLEAR_SELECTION);
+}
+
+HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
+{
+	cookie_manager_keypress(NS_KEY_DELETE_LEFT);
+}
+
+
+/* menu setup */
+
+static void ami_cookies_menulabs(struct ami_menu_data **md)
+{
+	ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Tree",       0, NULL, NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND,   NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_ALL,   NM_SUB, "All", '+', NULL,
+		ami_cookies_menu_item_project_expand_all, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS,   NM_SUB, "Domains", 0, NULL,
+		ami_cookies_menu_item_project_expand_domains, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_COOKIES,   NM_SUB, "Cookies", 0, NULL,
+		ami_cookies_menu_item_project_expand_cookies, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE,   NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_ALL,   NM_SUB, "All", '-', NULL,
+		ami_cookies_menu_item_project_collapse_all, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS,   NM_SUB, "Domains", 0, NULL,
+		ami_cookies_menu_item_project_collapse_domains, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_COOKIES,   NM_SUB, "Cookies", 0, NULL,
+		ami_cookies_menu_item_project_collapse_cookies, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT,   NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+		ami_cookies_menu_item_project_snapshot, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE,   NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
+		ami_cookies_menu_item_project_close, NULL, 0);
+
+	ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit",       0, NULL, NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_SELECTALL,   NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+		ami_cookies_menu_item_edit_select_all, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR,   NM_ITEM, "ClearNS", 0, NSA_SPACE,
+		ami_cookies_menu_item_edit_clear, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+	ami_menu_alloc_item(md, AMI_COOKIE_M_DELETE,   NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+		ami_cookies_menu_item_edit_delete, NULL, 0);
+
+	ami_menu_alloc_item(md, AMI_COOKIE_M_LAST,   NM_END, NULL,     0, NULL, NULL, NULL, 0);
+}
+
+static struct Menu *
+ami_cookies_menu_create(struct ami_cookie_window *cookie_win)
+{
+	ami_cookies_menulabs(cookie_win->menu_data);
+	cookie_win->imenu = ami_menu_layout(cookie_win->menu_data, AMI_COOKIE_M_LAST);
+	if(cookie_win->imenu == NULL) return NULL;
+
+	return cookie_win->imenu;
+}
+
+
+static nserror
+ami_cookies_create_window(struct ami_cookie_window *cookie_win)
+{
+	struct ami_corewindow *ami_cw = (struct ami_corewindow *)&cookie_win->core;
+
+	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, TRUE,
+       	WA_SizeGadget, TRUE,
+		WA_SizeBRight, TRUE,
+		WA_Top, nsoption_int(cookies_window_ypos),
+		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_ReportMouse, TRUE,
+       	WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+				IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+				IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
+		WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+		WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+		WINDOW_SharedPort, sport,
+		WINDOW_HorizProp, 1,
+		WINDOW_VertProp, 1,
+		WINDOW_UserData, cookie_win,
+		WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
+		WINDOW_MenuUserData, WGUD_HOOK,
+		WINDOW_IconifyGadget, FALSE,
+		WINDOW_Position, WPOS_CENTERSCREEN,
+		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_DISPLAY,
+				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/cookies.h */
+nserror ami_cookies_present(void)
+{
+	struct ami_cookie_window *ncwin;
+	nserror res;
+
+	if(cookie_window != NULL) {
+		//windowtofront()
+		return NSERROR_OK;
+	}
+
+	ncwin = calloc(1, sizeof(struct ami_cookie_window));
+	if (ncwin == NULL) {
+		return NSERROR_NOMEM;
+	}
+
+	ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("Cookies"));
+
+	res = ami_cookies_create_window(ncwin);
+	if (res != NSERROR_OK) {
+		LOG("SSL UI builder init failed");
+		ami_utf8_free(ncwin->core.wintitle);
+		free(ncwin);
+		return res;
+	}
+
+	/* initialise Amiga core window */
+	ncwin->core.draw = ami_cookies_draw;
+	ncwin->core.key = ami_cookies_key;
+	ncwin->core.mouse = ami_cookies_mouse;
+	ncwin->core.close = ami_cookies_destroy;
+	ncwin->core.event = NULL;
+
+	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 = cookie_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
+	if (res != NSERROR_OK) {
+		ami_utf8_free(ncwin->core.wintitle);
+		DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+		free(ncwin);
+		return res;
+	}
+
+	cookie_window = ncwin;
+
+	return NSERROR_OK;
+}
+
diff --git a/frontends/amiga/cookies.h b/frontends/amiga/cookies.h
old mode 100755
new mode 100644
index 157091d..6858e4c
--- a/frontends/amiga/cookies.h
+++ b/frontends/amiga/cookies.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008, 2009 Chris Young <chris at unsatisfactorysoftware.co.uk>
+ * Copyright 2017 Chris Young <chris at unsatisfactorysoftware.co.uk>
  *
  * This file is part of NetSurf, http://www.netsurf-browser.org/
  *
@@ -18,11 +18,8 @@
 
 #ifndef AMIGA_COOKIES_H
 #define AMIGA_COOKIES_H
-#include "amiga/desktop-tree.h"
-#include "amiga/tree.h"
 
-void ami_cookies_initialise(void);
-void ami_cookies_free(void);
-
-extern struct treeview_window *cookies_window;
+/** Open the cookie viewer */
+nserror ami_cookies_present(void);
 #endif
+
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 38b980a..1bfc537 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -34,6 +34,7 @@
 #include "amiga/os3support.h"
 
 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
 #include <math.h>
 
@@ -103,6 +104,17 @@ ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *re
 	*y = *y + ys;
 }
 
+/**
+ * check if mouse has moved since position was stored
+ * @return true if it has, false otherwise
+ */
+static bool
+ami_cw_mouse_moved(struct ami_corewindow *ami_cw, int x, int y)
+{
+	if(abs(x - ami_cw->mouse_x_click) > 5) return true;
+	if(abs(y - ami_cw->mouse_y_click) > 5) return true;
+	return false;
+}
 
 /* get current mouse position in the draw area, adjusted for scroll.
  * @return true if the mouse was in the draw area and co-ordinates updated
@@ -391,18 +403,14 @@ ami_cw_toggle_scrollbar(struct ami_corewindow *ami_cw, bool vert, bool visible)
 		}
 	}
 
-#if 0
-	/* in-window scrollbars aren't getting hidden until the window is resized
-	 * this code should fix it, but it isn't working */
 	if(ami_cw->in_border_scroll == false) {
 		FlushLayoutDomainCache((struct Gadget *)ami_cw->objects[GID_CW_WIN]);
 		RethinkLayout((struct Gadget *)ami_cw->objects[GID_CW_WIN],
 					ami_cw->win, NULL, TRUE);
-
-		/* probably need to redraw here */
-		ami_cw_redraw(ami_cw, NULL);
 	}
-#endif
+
+	/* probably need to redraw here */
+	ami_cw_redraw(ami_cw, NULL);
 }
 
 static void
@@ -464,6 +472,11 @@ ami_cw_event(void *w)
 	int x = 0, y = 0;
 
 	while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
+		if(ami_cw->close_window == true) {
+			ami_cw_close(ami_cw);
+			return TRUE;
+		}
+
 		switch(result & WMHI_CLASSMASK) {
 			case WMHI_MOUSEMOVE:
 				if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
@@ -494,12 +507,16 @@ ami_cw_event(void *w)
 							ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
 
 							if(ami_cw->lastclick.tv_sec) {
-								if(DoubleClick(ami_cw->lastclick.tv_sec,
+								if((ami_cw_mouse_moved(ami_cw, x, y) == false) &&
+										(DoubleClick(ami_cw->lastclick.tv_sec,
 											ami_cw->lastclick.tv_usec,
-											curtime.tv_sec, curtime.tv_usec))
+											curtime.tv_sec, curtime.tv_usec)))
 									ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
 							}
 
+							ami_cw->mouse_x_click = x;
+							ami_cw->mouse_y_click = y;
+
 							if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
 								ami_cw->lastclick.tv_sec = 0;
 								ami_cw->lastclick.tv_usec = 0;
@@ -616,28 +633,22 @@ ami_cw_update_size(struct core_window *cw, int width, int height)
 
 	if(width == -1) {
 		ami_cw_toggle_scrollbar(ami_cw, false, false);
-		return;
+	} else {
+		ami_cw_toggle_scrollbar(ami_cw, false, true);
+		RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+			SCROLLER_Total, (ULONG)width,
+			SCROLLER_Visible, win_w,
+		TAG_DONE);		
 	}
 
 	if(height == -1) {
 		ami_cw_toggle_scrollbar(ami_cw, true, false);
-		return;
-	}
-
-	if(ami_cw->objects[GID_CW_VSCROLL]) {
+	} else {
 		ami_cw_toggle_scrollbar(ami_cw, true, true);
 		RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
-			SCROLLER_Total, (ULONG)height,
+			SCROLLER_Total, height,
 			SCROLLER_Visible, win_h,
-		TAG_DONE);
-	}
-
-	if(ami_cw->objects[GID_CW_HSCROLL]) {
-		ami_cw_toggle_scrollbar(ami_cw, false, true);
-		RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
-			SCROLLER_Total, (ULONG)width,
-			SCROLLER_Visible, win_w,
-		TAG_DONE);
+		TAG_DONE);		
 	}
 }
 
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 8d93882..17af249 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -54,8 +54,12 @@ struct ami_corewindow {
 		struct Hook idcmp_hook;
 		struct timeval lastclick;
 
+		int mouse_x_click;
+		int mouse_y_click;
 		int mouse_state;
 
+		bool close_window; // set to true to close the window during event loop
+
 		APTR deferred_rects_pool;
 		struct MinList *deferred_rects;
 
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 74cd5a3..9fce681 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -536,6 +536,17 @@ STRPTR ami_gui_get_screen_title(void)
 
 static void ami_set_screen_defaults(struct Screen *screen)
 {
+	/* various window size/position defaults */
+	int width = screen->Width / 2;
+	int height = screen->Height / 2;
+	int top = (screen->Height / 2) - (height / 2);
+	int left = (screen->Width / 2) - (width / 2);
+
+	nsoption_default_set_int(cookies_window_ypos, top);
+	nsoption_default_set_int(cookies_window_xpos, left);
+	nsoption_default_set_int(cookies_window_xsize, width);
+	nsoption_default_set_int(cookies_window_ysize, height);
+
 	nsoption_default_set_int(window_x, 0);
 	nsoption_default_set_int(window_y, screen->BarHeight + 1);
 	nsoption_default_set_int(window_width, screen->Width);
@@ -1003,7 +1014,6 @@ static void gui_init2(int argc, char** argv)
 	/**/
 
 	ami_hotlist_initialise(nsoption_charp(hotlist_file));
-	ami_cookies_initialise();
 	ami_global_history_initialise();
 	search_web_select_provider(nsoption_int(search_provider));
 
@@ -3028,7 +3038,6 @@ static void gui_quit(void)
 	urldb_save(nsoption_charp(url_file));
 	urldb_save_cookies(nsoption_charp(cookie_file));
 	ami_hotlist_free(nsoption_charp(hotlist_file));
-	ami_cookies_free();
 	ami_global_history_free();
 #ifdef __amigaos4__
 	if(IApplication && ami_appid)
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 97b00f9..d88139d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -77,7 +77,6 @@
 #include "amiga/utf8.h"
 #include "amiga/schedule.h"
 
-#define NSA_SPACE "blankspace.png"
 #define NSA_MAX_HOTLIST_MENU_LEN 100
 
 enum {
@@ -368,7 +367,7 @@ HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessa
 
 HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
 {
-	ami_tree_open(cookies_window,AMI_TREE_COOKIES);
+	ami_cookies_present();
 }
 
 HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
@@ -545,7 +544,7 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
 
 
 /* menu creation code */
-void ami_menu_free_labs(struct ami_menu_data **md, int max)
+static void ami_menu_free_labs(struct ami_menu_data **md, int max)
 {
 	int i;
 
@@ -984,6 +983,12 @@ void ami_menu_free(struct gui_window_2 *gwin)
 	FreeMenus(gwin->imenu);
 }
 
+void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
+{
+	ami_menu_free_labs(md, max);
+	FreeMenus(imenu);
+}
+
 struct Menu *ami_menu_create(struct gui_window_2 *gwin)
 {
 	ami_init_menulabs(gwin->menu_data);
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 1f6f245..ad0e96d 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -26,6 +26,9 @@
 struct hlcache_handle;
 struct ami_menu_data;
 
+/** empty space */
+#define NSA_SPACE "blankspace.png"
+
 /** Maximum number of hotlist items (somewhat arbitrary value) */
 #define AMI_HOTLIST_ITEMS 60
 
@@ -133,18 +136,23 @@ enum {
 struct gui_window;
 struct gui_window_2;
 
-void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
-void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
-struct Menu *ami_menu_create(struct gui_window_2 *gwin);
-void ami_menu_refresh(struct gui_window_2 *gwin);
-void ami_menu_update_checked(struct gui_window_2 *gwin);
-void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
+/* cleanup */
 void ami_menu_free_glyphs(void);
-void ami_menu_free(struct gui_window_2 *gwin);
+
+/* generic menu alloc/free/layout */
 void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
 			const char *restrict label, char key, const char *restrict icon,
 			void *restrict func, void *restrict hookdata, UWORD flags);
 struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
+void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
+
+/* specific to browser windows */
+void ami_free_menulabs(struct ami_menu_data **md);
+struct Menu *ami_menu_create(struct gui_window_2 *gwin);
+void ami_menu_refresh(struct gui_window_2 *gwin);
+void ami_menu_update_checked(struct gui_window_2 *gwin);
+void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
+void ami_menu_free(struct gui_window_2 *gwin);
 
 /**
  * Sets that an item linked to a toggle menu item has been changed.
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index d56a1fe..28f3a4d 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -313,7 +313,7 @@ nserror ami_cert_verify(struct nsurl *url,
 		return res;
 	}
 
-	/* initialise example core window */
+	/* initialise Amiga core window */
 	ncwin->core.draw = ami_crtvrfy_draw;
 	ncwin->core.key = ami_crtvrfy_key;
 	ncwin->core.mouse = ami_crtvrfy_mouse;


-- 
NetSurf Browser



More information about the netsurf-commits mailing list