Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/dab118b6f7e9a22ed0141...
...commit
http://git.netsurf-browser.org/netsurf.git/commit/dab118b6f7e9a22ed01413a...
...tree
http://git.netsurf-browser.org/netsurf.git/tree/dab118b6f7e9a22ed01413a2c...
The branch, chris/amiga-corewindow has been created
at dab118b6f7e9a22ed01413a2ce2fd60e4c4df97b (commit)
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=dab118b6f7e9a22ed01...
commit dab118b6f7e9a22ed01413a2ce2fd60e4c4df97b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Amga core window redraw
This almost certainly will not work properly
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 3e2757e..f05d47b 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -45,6 +45,7 @@
#include "netsurf/mouse.h"
#include "desktop/plot_style.h"
+#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/utility.h>
@@ -55,8 +56,31 @@
#include <reaction/reaction_macros.h>
#include "amiga/corewindow.h"
+#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/object.h"
+#include "amiga/schedule.h"
+
+/**
+ * Convert co-ordinates relative to space.gadget
+ * into document co-ordinates
+ *
+ * @param ami_cw core window
+ * @param x co-ordinate, will be updated to new x co-ordinate
+ * @param y co-ordinate, will be updated to new y co-ordinate
+ */
+static void
+ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *restrict
y)
+{
+ ULONG xs, ys;
+
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+
+ *x = *x + xs;
+ *y = *y + ys;
+}
+
/* get current mouse position in the draw area, adjusted for scroll.
* only works during OM_NOTIFY! at other times use last stored posn
@@ -64,16 +88,15 @@
static void
ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
{
- ULONG xs, ys;
ULONG xm, ym;
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
- GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
GetAttr(SPACE_MouseX, ami_cw->objects[GID_CW_DRAW], (ULONG *)&xm);
GetAttr(SPACE_MouseY, ami_cw->objects[GID_CW_DRAW], (ULONG *)&ym);
- ami_cw->mouse_x = xm + xs;
- ami_cw->mouse_y = ym + ys;
+ ami_cw_coord_amiga_to_ns(ami_cw, (int *)&xm, (int *)&ym);
+
+ ami_cw->mouse_x = xm;
+ ami_cw->mouse_y = ym;
*x = ami_cw->mouse_x;
*y = ami_cw->mouse_y;
}
@@ -94,6 +117,193 @@ ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
}
}
+
+/**
+ * Redraw functions
+ *
+ * This is slightly over-engineered as it was taken from the main browser/old tree
redraws
+ * and supports deferred drawing of rectangles and tiling
+ */
+
+/**
+ * Redraw an area of a core window
+ *
+ * \param g a struct ami_corewindow
+ * \param r rect (in document co-ordinates)
+ */
+
+static void
+ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
+{
+ struct IBox *bbox;
+ struct RastPort *temprp;
+ ULONG pos_x, pos_y;
+ struct rect draw_rect;
+ int tile_size_x = ami_cw->gg.width;
+ int tile_size_y = ami_cw->gg.height;
+ int tile_x, tile_y, tile_w, tile_h;
+
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &amiplot
+ };
+
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) !=
NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return;
+ }
+
+ int x0 = bbox->Left;
+ int y0 = bbox->Top;
+ ami_cw_coord_amiga_to_ns(ami_cw, &x0, &y0);
+ int x1 = x0 + bbox->Width;
+ int y1 = y0 + bbox->Height;
+
+ if((r->y1 < y0) || (r->x1 < x0) || (r->x0 > x1) || (r->y0 > y1))
{
+ /* rect not visible */
+ ami_gui_free_space_box(bbox);
+ return;
+ }
+
+ if(r->y0 < y0) r->y0 = y0;
+ if(r->x0 < x0) r->x0 = x0;
+ if(r->y1 > y1) r->y1 = y1;
+ if(r->x1 > x1) r->x1 = x1;
+
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&pos_x);
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&pos_y);
+
+ glob = &ami_cw->gg;
+ temprp = glob->rp; //??
+ glob->rp = ami_cw->win->RPort;
+
+ for(tile_y = r->y0; tile_y < r->y1; tile_y += tile_size_y) {
+ tile_h = tile_size_y;
+ if((r->y1 - tile_y) < tile_size_y)
+ tile_h = r->y1 - tile_y;
+
+ for(tile_x = r->x0; tile_x < r->x1; tile_x += tile_size_x) {
+ tile_w = tile_size_x;
+ if((r->x1 - tile_x) < tile_size_x)
+ tile_w = r->x1 - tile_x;
+
+ draw_rect.x0 = tile_x;
+ draw_rect.y0 = tile_y;
+ draw_rect.x1 = tile_x + tile_w;
+ draw_rect.y1 = tile_y + tile_h;
+
+ ami_cw->draw(ami_cw, &draw_rect, &ctx);
+#ifdef __amigaos4__
+ BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
+ BLITA_Source, ami_cw->gg.bm,
+ BLITA_SrcX, 0,
+ BLITA_SrcY, 0,
+ BLITA_DestType, BLITT_RASTPORT,
+ BLITA_Dest, ami_cw->win->RPort,
+ BLITA_DestX, bbox->Left + tile_x - pos_x,
+ BLITA_DestY, bbox->Top + tile_y - pos_y,
+ BLITA_Width, tile_w,
+ BLITA_Height, tile_h,
+ TAG_DONE);
+#else
+ BltBitMapRastPort(ami_cw->gg.bm, 0, 0,
+ ami_cw->win->RPort, bbox->Left + tile_x - pos_x, bbox->Top + tile_y -
pos_y,
+ tile_w, tile_h, 0xC0);
+#endif
+ }
+ }
+
+ ami_gui_free_space_box(bbox);
+ ami_clearclipreg(glob);
+ glob->rp = temprp;
+ ami_gui_set_default_gg();
+}
+
+
+/**
+ * Draw the deferred rectangles
+ *
+ * @param draw set to false to just delete the queue
+ */
+static void ami_cw_redraw_queue(struct ami_corewindow *ami_cw, bool draw)
+{
+ struct nsObject *node;
+ struct nsObject *nnode;
+ struct rect *rect;
+
+ if(IsMinListEmpty(ami_cw->deferred_rects)) return;
+
+ if(draw == false) {
+ LOG("Ignoring deferred box redraw queue");
+ } // else should probably show busy pointer
+
+ node = (struct nsObject *)GetHead((struct List *)ami_cw->deferred_rects);
+
+ do {
+ if(draw == true) {
+ rect = (struct rect *)node->objstruct;
+ ami_cw_redraw_rect(ami_cw, rect);
+ }
+ nnode = (struct nsObject *)GetSucc((struct Node *)node);
+ ami_memory_itempool_free(ami_cw->deferred_rects_pool, node->objstruct,
sizeof(struct rect));
+ DelObjectNoFree(node);
+ } while((node = nnode));
+}
+
+static void
+ami_cw_redraw_cb(void *p)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)p;
+
+ ami_cw_redraw_queue(ami_cw, true);
+}
+
+/**
+ * Queue a redraw of a rectangle
+ *
+ * @param ami_cw the core window to redraw
+ * @param r the rectangle (in doc coords) to redraw, or NULL for full window
+ */
+
+static void
+ami_cw_redraw(struct ami_corewindow *ami_cw, const struct rect *restrict r)
+{
+ struct nsObject *nsobj;
+ struct rect *restrict deferred_rect;
+ struct rect new_rect;
+
+ if(r == NULL) {
+ struct IBox *bbox;
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) !=
NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return;
+ }
+
+ new_rect.x0 = bbox->Left;
+ new_rect.y0 = bbox->Top;
+ ami_cw_coord_amiga_to_ns(ami_cw, &new_rect.x0, &new_rect.y0);
+ new_rect.x1 = new_rect.x0 + bbox->Width;
+ new_rect.y1 = new_rect.y0 + bbox->Height;
+
+ ami_gui_free_space_box(bbox);
+
+ r = &new_rect;
+ }
+
+ if(ami_gui_window_update_box_deferred_check(ami_cw->deferred_rects, r,
+ ami_cw->deferred_rects_pool)) {
+ deferred_rect = ami_memory_itempool_alloc(ami_cw->deferred_rects_pool, sizeof(struct
rect));
+ CopyMem(r, deferred_rect, sizeof(struct rect));
+ nsobj = AddObject(ami_cw->deferred_rects, AMINS_RECT);
+ nsobj->objstruct = deferred_rect;
+ } else {
+ LOG("Ignoring duplicate or subset of queued box redraw");
+ }
+ ami_schedule(1, ami_cw_redraw_cb, ami_cw);
+}
+
+
static void
ami_cw_close(void *w)
{
@@ -123,7 +333,7 @@ HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage
*)
case GID_CW_HSCROLL:
case GID_CW_VSCROLL:
- /* redraw */
+ ami_cw_redraw(ami_cw, NULL);
break;
}
break;
@@ -156,7 +366,7 @@ ami_cw_event(void *w)
uint16 code;
struct InputEvent *ie;
int nskey;
- int key_state;
+ int key_state = 0;
struct timeval curtime;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) !=
WMHI_LASTMSG) {
@@ -223,7 +433,7 @@ ami_cw_event(void *w)
break;
case WMHI_NEWSIZE:
- /* redraw */
+ ami_cw_redraw(ami_cw, NULL);
break;
case WMHI_CLOSEWINDOW:
@@ -235,7 +445,7 @@ ami_cw_event(void *w)
switch(result & WMHI_GADGETMASK) {
case GID_CW_HSCROLL:
case GID_CW_VSCROLL:
- /* redraw */
+ ami_cw_redraw(ami_cw, NULL);
break;
default:
@@ -269,11 +479,7 @@ ami_cw_redraw_request(struct core_window *cw, const struct rect *r)
{
struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
-/*
- toolkit_widget_queue_draw_area(example_cw->widget,
- r->x0, r->y0,
- r->x1 - r->x0, r->y1 - r->y0);
-*/
+ ami_cw_redraw(ami_cw, r);
}
@@ -353,6 +559,7 @@ ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
TAG_DONE);
/* probably need to redraw here */
+ ami_cw_redraw(ami_cw, NULL);
}
@@ -387,6 +594,9 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_init_layers(&ami_cw->gg, 0, 0, false);
ami_cw->gg.shared_pens = ami_AllocMinList();
+ ami_cw->deferred_rects = NewObjList();
+ ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
+
/* add the core window to our window list so we process events */
ami_gui_win_list_add(ami_cw, AMINS_COREWINDOW, &ami_cw_table);
@@ -425,6 +635,11 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
/* exported interface documented in example/corewindow.h */
nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
{
+ /* remove any pending redraws */
+ ami_schedule(-1, ami_cw_redraw_cb, ami_cw);
+ FreeObjList(ami_cw->deferred_rects);
+ ami_memory_itempool_delete(ami_cw->deferred_rects_pool);
+
/* remove the core window from our window list */
ami_gui_win_list_remove(ami_cw);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 3659a6a..d8f80d3 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -56,6 +56,9 @@ struct ami_corewindow {
int mouse_y;
int mouse_state;
+ APTR deferred_rects_pool;
+ struct MinList *deferred_rects;
+
/** stuff for our off-screen render bitmap */
struct gui_globals gg;
struct MinList *shared_pens;
@@ -73,7 +76,7 @@ struct ami_corewindow {
* \param r The rectangle of the window that needs updating.
* \return NSERROR_OK on success otherwise apropriate error code
*/
- nserror (*draw)(struct ami_corewindow *ami_cw, struct rect *r);
+ nserror (*draw)(struct ami_corewindow *ami_cw, struct rect *r, struct redraw_context
*ctx);
/**
* callback for keypress on Amiga core window
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 46961dd..9499ff8 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4741,7 +4741,7 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g,
bool draw)
if(draw == true) ami_reset_pointer(g->shared);
}
-static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
+bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
const struct rect *restrict new_rect, APTR mempool)
{
struct nsObject *node;
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index f9e62c5..4c3e586 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -287,5 +287,12 @@ void ami_gui_win_list_remove(void *win);
* Get which qualifier keys are being pressed
*/
int ami_gui_get_quals(Object *win_obj);
+
+/**
+ * Check rect is not already queued for redraw
+ */
+bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
+ const struct rect *restrict new_rect, APTR mempool);
+
#endif
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=3227ed655609e731f3d...
commit 3227ed655609e731f3d216706c524028f566f114
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
handle core window mouse buttons
todo: support drags
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index c7252b5..3e2757e 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -58,9 +58,11 @@
#include "amiga/misc.h"
#include "amiga/object.h"
-/* get current mouse position in the draw area, adjusted for scroll */
+/* get current mouse position in the draw area, adjusted for scroll.
+ * only works during OM_NOTIFY! at other times use last stored posn
+ */
static void
-ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *x, int *y)
+ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
{
ULONG xs, ys;
ULONG xm, ym;
@@ -69,8 +71,11 @@ ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *x, int *y)
GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
GetAttr(SPACE_MouseX, ami_cw->objects[GID_CW_DRAW], (ULONG *)&xm);
GetAttr(SPACE_MouseY, ami_cw->objects[GID_CW_DRAW], (ULONG *)&ym);
- *x = xm + xs;
- *y = ym + ys;
+
+ ami_cw->mouse_x = xm + xs;
+ ami_cw->mouse_y = ym + ys;
+ *x = ami_cw->mouse_x;
+ *y = ami_cw->mouse_y;
}
/* handle keypress */
@@ -151,6 +156,8 @@ ami_cw_event(void *w)
uint16 code;
struct InputEvent *ie;
int nskey;
+ int key_state;
+ struct timeval curtime;
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) !=
WMHI_LASTMSG) {
switch(result & WMHI_CLASSMASK) {
@@ -159,6 +166,51 @@ ami_cw_event(void *w)
break;
case WMHI_MOUSEBUTTONS:
+ key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
+
+ case SELECTDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
+ break;
+
+ case MIDDLEDOWN:
+ ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
+ break;
+
+ case SELECTUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
+ CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
+
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
+
+ if(ami_cw->lastclick.tv_sec) {
+ if(DoubleClick(ami_cw->lastclick.tv_sec,
+ ami_cw->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec))
+ ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
+ }
+
+ if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
+ ami_cw->lastclick.tv_sec = 0;
+ ami_cw->lastclick.tv_usec = 0;
+ } else {
+ ami_cw->lastclick.tv_sec = curtime.tv_sec;
+ ami_cw->lastclick.tv_usec = curtime.tv_usec;
+ }
+ }
+
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, ami_cw->mouse_x,
ami_cw->mouse_y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
+
+ case MIDDLEUP:
+ if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
+ ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
+
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, ami_cw->mouse_x,
ami_cw->mouse_y);
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ break;
+
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, ami_cw->mouse_x,
ami_cw->mouse_y);
break;
case WMHI_RAWKEY:
@@ -327,7 +379,9 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->cb_table = &ami_cw_cb_table;
/* clear some vars */
- ami_cw->mouse_state = 0;
+ ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
+ ami_cw->lastclick.tv_sec = 0;
+ ami_cw->lastclick.tv_usec = 0;
/* allocate drawing area etc */
ami_init_layers(&ami_cw->gg, 0, 0, false);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index fae5658..3659a6a 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -51,6 +51,9 @@ struct ami_corewindow {
struct Hook idcmp_hook;
struct timeval lastclick;
+
+ int mouse_x;
+ int mouse_y;
int mouse_state;
/** stuff for our off-screen render bitmap */
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=eb1f39fe7d80893b1f7...
commit eb1f39fe7d80893b1f7c804eb48ec61e89f17d78
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Process mouse moves and qualifier keys
NB: we are doing mouse moves differently by using an IDCMP hook on space.gadget, as
this gives us co-ordinates relative to the render area
GID_DRAW object when the window is defined will need tagging ICA_TARGET,
ICTARGET_IDCMP
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index a42f08d..c7252b5 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -50,6 +50,7 @@
#include <classes/window.h>
#include <gadgets/scroller.h>
+#include <gadgets/space.h>
#include <intuition/icclass.h>
#include <reaction/reaction_macros.h>
@@ -57,6 +58,37 @@
#include "amiga/misc.h"
#include "amiga/object.h"
+/* get current mouse position in the draw area, adjusted for scroll */
+static void
+ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *x, int *y)
+{
+ ULONG xs, ys;
+ ULONG xm, ym;
+
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&xs);
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&ys);
+ GetAttr(SPACE_MouseX, ami_cw->objects[GID_CW_DRAW], (ULONG *)&xm);
+ GetAttr(SPACE_MouseY, ami_cw->objects[GID_CW_DRAW], (ULONG *)&ym);
+ *x = xm + xs;
+ *y = ym + ys;
+}
+
+/* handle keypress */
+static void
+ami_cw_key(struct ami_corewindow *ami_cw, int nskey)
+{
+ ami_cw->key(ami_cw, nskey);
+
+ switch(nskey) {
+ case NS_KEY_COPY_SELECTION:
+ /* if we've copied a selection we need to clear it - style guide rules */
+ ami_cw->key(ami_cw, NS_KEY_CLEAR_SELECTION);
+ break;
+
+ /* we may need to deal with scroll-related keys here */
+ }
+}
+
static void
ami_cw_close(void *w)
{
@@ -67,17 +99,23 @@ ami_cw_close(void *w)
HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
{
- ULONG gid;
struct ami_corewindow *ami_cw = hook->h_Data;
struct IntuiWheelData *wheel;
+ ULONG gid = GetTagData( GA_ID, 0, msg->IAddress );
+ int x, y;
+ int key_state = 0;
switch(msg->Class)
{
case IDCMP_IDCMPUPDATE:
- gid = GetTagData( GA_ID, 0, msg->IAddress );
+ switch(gid)
+ {
+ case GID_CW_DRAW:
+ ami_cw_mouse_pos(ami_cw, &x, &y);
+ key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
+ ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
+ break;
- switch( gid )
- {
case GID_CW_HSCROLL:
case GID_CW_VSCROLL:
/* redraw */
@@ -97,6 +135,7 @@ HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage
*)
}
}
+
/**
* Main event loop for our core window
*
@@ -116,6 +155,7 @@ ami_cw_event(void *w)
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) !=
WMHI_LASTMSG) {
switch(result & WMHI_CLASSMASK) {
case WMHI_MOUSEMOVE:
+ /* in theory the mouse moves we care about are processed in our hook function... */
break;
case WMHI_MOUSEBUTTONS:
@@ -126,11 +166,8 @@ ami_cw_event(void *w)
GetAttr(WINDOW_InputEvent, ami_cw->objects[GID_CW_WIN], (ULONG *)&ie);
nskey = ami_key_to_nskey(storage, ie);
- ami_cw->key(ami_cw, nskey);
- if(nskey == NS_KEY_COPY_SELECTION) {
- /* if we've copied a selection we need to clear it - style guide rules */
- ami_cw->key(ami_cw, NS_KEY_CLEAR_SELECTION);
- }
+
+ ami_cw_key(ami_cw, nskey);
break;
case WMHI_NEWSIZE:
@@ -142,9 +179,24 @@ ami_cw_event(void *w)
return TRUE;
break;
+ case WMHI_GADGETUP:
+ switch(result & WMHI_GADGETMASK) {
+ case GID_CW_HSCROLL:
+ case GID_CW_VSCROLL:
+ /* redraw */
+ break;
+
+ default:
+ /* pass the event to the window owner */
+ if(ami_cw->event != NULL)
+ ami_cw->event(ami_cw, result);
+ break;
+ }
+
default:
/* pass the event to the window owner */
- ami_cw->event(ami_cw, result);
+ if(ami_cw->event != NULL)
+ ami_cw->event(ami_cw, result);
break;
}
};
@@ -274,6 +326,9 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
/* setup the core window callback table */
ami_cw->cb_table = &ami_cw_cb_table;
+ /* clear some vars */
+ ami_cw->mouse_state = 0;
+
/* allocate drawing area etc */
ami_init_layers(&ami_cw->gg, 0, 0, false);
ami_cw->gg.shared_pens = ami_AllocMinList();
@@ -289,7 +344,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
TAG_DONE); */
- /* attach the scrollbars for event processing if they are in the window border */
+ /* attach the scrollbars for event processing _if they are in the window border_ */
if(ami_cw->objects[GID_CW_HSCROLL] == NULL) {
GetAttr(WINDOW_HorizObject, ami_cw->objects[GID_CW_WIN],
(ULONG *)&ami_cw->objects[GID_CW_HSCROLL]);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 3c27e51..fae5658 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -50,6 +50,8 @@ struct ami_corewindow {
Object *objects[GID_CW_LAST];
struct Hook idcmp_hook;
+ struct timeval lastclick;
+ int mouse_state;
/** stuff for our off-screen render bitmap */
struct gui_globals gg;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index ba0a786..46961dd 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1376,27 +1376,34 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
return nskey;
}
-static void ami_update_quals(struct gui_window_2 *gwin)
+int ami_gui_get_quals(Object *win_obj)
{
uint32 quals = 0;
+ int key_state = 0;
#ifdef __amigaos4__
- GetAttr(WINDOW_Qualifier,gwin->objects[OID_MAIN],(uint32 *)&quals);
+ GetAttr(WINDOW_Qualifier, win_obj, (uint32 *)&quals);
#else
#warning qualifier needs fixing for OS3
#endif
- gwin->key_state = 0;
if(quals & NSA_QUAL_SHIFT) {
- gwin->key_state |= BROWSER_MOUSE_MOD_1;
+ key_state |= BROWSER_MOUSE_MOD_1;
}
if(quals & IEQUALIFIER_CONTROL) {
- gwin->key_state |= BROWSER_MOUSE_MOD_2;
+ key_state |= BROWSER_MOUSE_MOD_2;
}
if(quals & NSA_QUAL_ALT) {
- gwin->key_state |= BROWSER_MOUSE_MOD_3;
+ key_state |= BROWSER_MOUSE_MOD_3;
}
+
+ return key_state;
+}
+
+static void ami_update_quals(struct gui_window_2 *gwin)
+{
+ gwin->key_state = ami_gui_get_quals(gwin->objects[OID_MAIN]);
}
/* exported interface documented in amiga/gui.h */
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index eb39e9e..f9e62c5 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2017 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf,
http://www.netsurf-browser.org/
*
@@ -282,5 +282,10 @@ nserror ami_gui_win_list_add(void *win, int type, const struct
ami_win_event_tab
* Remove a window from the NetSurf window list
*/
void ami_gui_win_list_remove(void *win);
+
+/**
+ * Get which qualifier keys are being pressed
+ */
+int ami_gui_get_quals(Object *win_obj);
#endif
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=31c08f39be64f739cac...
commit 31c08f39be64f739cac727ab5a13fc513d1a61aa
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Basic event loop, only handles keypresses and window closure so far
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 5424b7b..a42f08d 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -51,6 +51,7 @@
#include <classes/window.h>
#include <gadgets/scroller.h>
#include <intuition/icclass.h>
+#include <reaction/reaction_macros.h>
#include "amiga/corewindow.h"
#include "amiga/misc.h"
@@ -98,12 +99,56 @@ HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage
*)
/**
* Main event loop for our core window
+ *
+ * \return TRUE if window destroyed
*/
static BOOL
ami_cw_event(void *w)
{
struct ami_corewindow *ami_cw = (struct ami_corewindow *)w;
-//event loop goes here
+
+ ULONG result;
+ ULONG storage;
+ uint16 code;
+ struct InputEvent *ie;
+ int nskey;
+
+ while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) !=
WMHI_LASTMSG) {
+ switch(result & WMHI_CLASSMASK) {
+ case WMHI_MOUSEMOVE:
+ break;
+
+ case WMHI_MOUSEBUTTONS:
+ break;
+
+ case WMHI_RAWKEY:
+ storage = result & WMHI_GADGETMASK;
+
+ GetAttr(WINDOW_InputEvent, ami_cw->objects[GID_CW_WIN], (ULONG *)&ie);
+ nskey = ami_key_to_nskey(storage, ie);
+ ami_cw->key(ami_cw, nskey);
+ if(nskey == NS_KEY_COPY_SELECTION) {
+ /* if we've copied a selection we need to clear it - style guide rules */
+ ami_cw->key(ami_cw, NS_KEY_CLEAR_SELECTION);
+ }
+ break;
+
+ case WMHI_NEWSIZE:
+ /* redraw */
+ break;
+
+ case WMHI_CLOSEWINDOW:
+ ami_cw_close(ami_cw);
+ return TRUE;
+ break;
+
+ default:
+ /* pass the event to the window owner */
+ ami_cw->event(ami_cw, result);
+ break;
+ }
+ };
+
return FALSE;
}
@@ -178,7 +223,7 @@ ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
int scrollsetx;
int scrollsety;
- int win_w, win_h;
+ int win_w = 0, win_h = 0;
int win_x0, win_x1;
int win_y0, win_y1;
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index 0729f12..3c27e51 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -95,9 +95,11 @@ struct ami_corewindow {
/**
* callback for unknown events on Amiga core window
* eg. buttons in the ssl cert window
- * PROBABLY NEED MORE VARS!
+ * (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 id gadget id
+ * \param result event as returned by RA_HandleInput()
* \return NSERROR_OK on sucess otherwise apropriate error code.
*/
nserror (*event)(struct ami_corewindow *ami_cw, ULONG id);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c40e8197c270b1600fa...
commit c40e8197c270b1600fa7b32056a2019cd83e6f3f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Allow for the prospect of in-window scrollbars
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index d8676fd..5424b7b 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -236,7 +236,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
/* add the core window to our window list so we process events */
ami_gui_win_list_add(ami_cw, AMINS_COREWINDOW, &ami_cw_table);
- /* attach the scrollbars for event processing */
+ /* set up the IDCMP hook for event processing (extended mouse, scrollbars) */
ami_cw->idcmp_hook.h_Entry = (void *)ami_cw_idcmp_hook;
ami_cw->idcmp_hook.h_Data = ami_cw;
/* probably set this when defining the window
@@ -244,20 +244,26 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
TAG_DONE); */
- GetAttr(WINDOW_HorizObject, ami_cw->objects[GID_CW_WIN],
- (ULONG *)&ami_cw->objects[GID_CW_HSCROLL]);
- GetAttr(WINDOW_VertObject, ami_cw->objects[GID_CW_WIN],
- (ULONG *)&ami_cw->objects[GID_CW_VSCROLL]);
+ /* attach the scrollbars for event processing if they are in the window border */
+ if(ami_cw->objects[GID_CW_HSCROLL] == NULL) {
+ GetAttr(WINDOW_HorizObject, ami_cw->objects[GID_CW_WIN],
+ (ULONG *)&ami_cw->objects[GID_CW_HSCROLL]);
- RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
- GA_ID, GID_CW_VSCROLL,
- ICA_TARGET, ICTARGET_IDCMP,
- TAG_DONE);
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ GA_ID, GID_CW_HSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+ }
- RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
- GA_ID, GID_CW_HSCROLL,
- ICA_TARGET, ICTARGET_IDCMP,
- TAG_DONE);
+ if(ami_cw->objects[GID_CW_VSCROLL] == NULL) {
+ GetAttr(WINDOW_VertObject, ami_cw->objects[GID_CW_WIN],
+ (ULONG *)&ami_cw->objects[GID_CW_VSCROLL]);
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ GA_ID, GID_CW_VSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+ }
return NSERROR_OK;
}
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index d6f842a..0729f12 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -93,6 +93,16 @@ struct ami_corewindow {
nserror (*mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x,
int y);
/**
+ * callback for unknown events on Amiga core window
+ * eg. buttons in the ssl cert window
+ * PROBABLY NEED MORE VARS!
+ * \param ami_cw The Amiga core window structure.
+ * \param id gadget id
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
+ */
+ nserror (*event)(struct ami_corewindow *ami_cw, ULONG id);
+
+ /**
* callback to close an Amiga core window
*
* \param ami_cw The Amiga core window structure.
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=8196f5b60241a6389ca...
commit 8196f5b60241a6389ca3b76446de131a3dd2e891
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Basic template for an Amiga core window
Drawing and event processing not written yet
diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile
index f3c178e..8115f2f 100644
--- a/frontends/amiga/Makefile
+++ b/frontends/amiga/Makefile
@@ -46,7 +46,7 @@ S_FRONTEND := gui.c tree.c history.c hotlist.c schedule.c file.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 desktop-tree.c
+ nsoption.c desktop-tree.c corewindow.c
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
new file mode 100644
index 0000000..d8676fd
--- /dev/null
+++ b/frontends/amiga/corewindow.c
@@ -0,0 +1,281 @@
+/*
+ * Copyright 2017 Chris Young <chris(a)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 core window interface.
+ *
+ * Provides interface for core renderers to the Amiga Intuition drawable area.
+ *
+ * This module is an object that must be encapsulated. Client users
+ * should embed a struct ami_corewindow at the beginning of their
+ * context for this display surface, fill in relevant data and then
+ * call ami_corewindow_init()
+ *
+ * The Amiga core window structure requires the callback for draw, key and
+ * mouse operations.
+ */
+
+#include "amiga/os3support.h"
+
+#include <assert.h>
+#include <string.h>
+#include <math.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/utf8.h"
+#include "netsurf/keypress.h"
+#include "netsurf/mouse.h"
+#include "desktop/plot_style.h"
+
+#include <proto/intuition.h>
+#include <proto/utility.h>
+
+#include <classes/window.h>
+#include <gadgets/scroller.h>
+#include <intuition/icclass.h>
+
+#include "amiga/corewindow.h"
+#include "amiga/misc.h"
+#include "amiga/object.h"
+
+static void
+ami_cw_close(void *w)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)w;
+
+ ami_cw->close(ami_cw);
+}
+
+HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
+{
+ ULONG gid;
+ struct ami_corewindow *ami_cw = hook->h_Data;
+ struct IntuiWheelData *wheel;
+
+ switch(msg->Class)
+ {
+ case IDCMP_IDCMPUPDATE:
+ gid = GetTagData( GA_ID, 0, msg->IAddress );
+
+ switch( gid )
+ {
+ case GID_CW_HSCROLL:
+ case GID_CW_VSCROLL:
+ /* redraw */
+ break;
+ }
+ break;
+#ifdef __amigaos4__
+ case IDCMP_EXTENDEDMOUSE:
+ if(msg->Code == IMSGCODE_INTUIWHEELDATA)
+ {
+ wheel = (struct IntuiWheelData *)msg->IAddress;
+
+ //ami_tree_scroll(twin, (wheel->WheelX * 20), (wheel->WheelY * 20));
+ }
+ break;
+#endif
+ }
+}
+
+/**
+ * Main event loop for our core window
+ */
+static BOOL
+ami_cw_event(void *w)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)w;
+//event loop goes here
+ return FALSE;
+}
+
+static const struct ami_win_event_table ami_cw_table = {
+ ami_cw_event,
+ ami_cw_close,
+};
+
+/**
+ * callback from core to request a redraw
+ */
+static void
+ami_cw_redraw_request(struct core_window *cw, const struct rect *r)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+
+/*
+ toolkit_widget_queue_draw_area(example_cw->widget,
+ r->x0, r->y0,
+ r->x1 - r->x0, r->y1 - r->y0);
+*/
+}
+
+
+static void
+ami_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+ struct IBox *bbox;
+
+ if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) !=
NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return;
+ }
+
+ *width = bbox->Width;
+ *height = bbox->Height;
+
+ ami_gui_free_space_box(bbox);
+}
+
+
+static void
+ami_cw_update_size(struct core_window *cw, int width, int height)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+
+ /* I'm assuming this is telling me the new page size, not wanting the window
physically resized */
+ int win_w, win_h;
+ ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
+
+ if(ami_cw->objects[GID_CW_VSCROLL]) {
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_VSCROLL],
ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)height,
+ SCROLLER_Visible, win_h,
+ TAG_DONE);
+ }
+
+ if(ami_cw->objects[GID_CW_HSCROLL]) {
+ RefreshSetGadgetAttrs((struct Gadget *)ami_cw->objects[GID_CW_HSCROLL],
ami_cw->win, NULL,
+ SCROLLER_Total, (ULONG)width,
+ SCROLLER_Visible, win_w,
+ TAG_DONE);
+ }
+}
+
+
+static void
+ami_cw_scroll_visible(struct core_window *cw, const struct rect *r)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)cw;
+
+ int scrollsetx;
+ int scrollsety;
+ int win_w, win_h;
+ int win_x0, win_x1;
+ int win_y0, win_y1;
+
+ ami_cw_get_window_dimensions((struct core_window *)ami_cw, &win_w, &win_h);
+
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_VSCROLL], (ULONG *)&win_y0);
+ GetAttr(SCROLLER_Top, ami_cw->objects[GID_CW_HSCROLL], (ULONG *)&win_x0);
+
+ win_x1 = win_x0 + win_w;
+ win_y1 = win_y0 + win_h;
+
+ 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;
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsety,
+ TAG_DONE);
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ SCROLLER_Top, scrollsetx,
+ TAG_DONE);
+
+ /* probably need to redraw here */
+}
+
+
+static void
+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;
+}
+
+
+struct core_window_callback_table ami_cw_cb_table = {
+ .redraw_request = ami_cw_redraw_request,
+ .update_size = ami_cw_update_size,
+ .scroll_visible = ami_cw_scroll_visible,
+ .get_window_dimensions = ami_cw_get_window_dimensions,
+ .drag_status = ami_cw_drag_status
+};
+
+/* 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;
+
+ /* allocate drawing area etc */
+ ami_init_layers(&ami_cw->gg, 0, 0, false);
+ ami_cw->gg.shared_pens = ami_AllocMinList();
+
+ /* add the core window to our window list so we process events */
+ ami_gui_win_list_add(ami_cw, AMINS_COREWINDOW, &ami_cw_table);
+
+ /* attach the scrollbars for event processing */
+ ami_cw->idcmp_hook.h_Entry = (void *)ami_cw_idcmp_hook;
+ ami_cw->idcmp_hook.h_Data = ami_cw;
+ /* probably set this when defining the window
+ SetAttrs(ami_cw->objects[GID_CW_WIN],
+ WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+ TAG_DONE); */
+
+ GetAttr(WINDOW_HorizObject, ami_cw->objects[GID_CW_WIN],
+ (ULONG *)&ami_cw->objects[GID_CW_HSCROLL]);
+ GetAttr(WINDOW_VertObject, ami_cw->objects[GID_CW_WIN],
+ (ULONG *)&ami_cw->objects[GID_CW_VSCROLL]);
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_VSCROLL], ami_cw->win, NULL,
+ GA_ID, GID_CW_VSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+
+ RefreshSetGadgetAttrs((APTR)ami_cw->objects[GID_CW_HSCROLL], ami_cw->win, NULL,
+ GA_ID, GID_CW_HSCROLL,
+ ICA_TARGET, ICTARGET_IDCMP,
+ TAG_DONE);
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in example/corewindow.h */
+nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
+{
+ /* remove the core window from our window list */
+ ami_gui_win_list_remove(ami_cw);
+
+ /* destroy the window */
+ ami_cw->win = NULL;
+ DisposeObject(ami_cw->objects[GID_CW_WIN]);
+
+ /* release off-screen bitmap stuff */
+ ami_plot_release_pens(ami_cw->gg.shared_pens);
+ ami_free_layers(&ami_cw->gg);
+
+ return NSERROR_OK;
+}
+
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
new file mode 100644
index 0000000..d6f842a
--- /dev/null
+++ b/frontends/amiga/corewindow.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2017 Chris Young <chris(a)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_COREWINDOW_H
+#define AMIGA_COREWINDOW_H
+
+#include "netsurf/core_window.h"
+
+#include "amiga/gui.h" /* need to know the size of ami_generic_window :( */
+#include "amiga/plotters.h"
+
+/**
+ * BOOPSI objects
+ */
+
+enum {
+ GID_CW_WIN = 0, /* window object */
+ GID_CW_MAIN, /* root layout object */
+ GID_CW_DRAW, /* drawing area (space.gadget) */
+ GID_CW_HSCROLL, /* horizontal scroller */
+ GID_CW_VSCROLL, /* vertical scroller */
+ GID_CW_LAST
+};
+
+/**
+ * Amiga core window state
+ */
+struct ami_corewindow {
+ /*
+ * Any variables common to any frontend window would go here.
+ * e.g. drawing area handles, toolkit pointers or other state
+ */
+ struct ami_generic_window w;
+ struct Window *win;
+ Object *objects[GID_CW_LAST];
+
+ struct Hook idcmp_hook;
+
+ /** stuff for our off-screen render bitmap */
+ struct gui_globals gg;
+ struct MinList *shared_pens;
+
+ /** 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
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+ nserror (*draw)(struct ami_corewindow *ami_cw, struct rect *r);
+
+ /**
+ * callback for keypress on Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param nskey The netsurf key code.
+ * \return NSERROR_OK if key processed,
+ * NSERROR_NOT_IMPLEMENTED if key not processed
+ * otherwise apropriate error code
+ */
+ nserror (*key)(struct ami_corewindow *ami_cw, uint32_t nskey);
+
+ /**
+ * callback for mouse event on Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state mouse state
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
+ */
+ nserror (*mouse)(struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x,
int y);
+
+ /**
+ * callback to close an Amiga core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ */
+ nserror (*close)(struct ami_corewindow *ami_cw);
+
+};
+
+/**
+ * initialise elements of Amiga core window.
+ *
+ * As a pre-requisite the draw, key and mouse callbacks must be defined
+ *
+ * \param example_cw An Amiga core window structure to initialise
+ * \return NSERROR_OK on successful initialisation otherwise error code.
+ */
+nserror ami_corewindow_init(struct ami_corewindow *ami_cw);
+
+/**
+ * finalise elements of Amiga core window.
+ *
+ * \param ami_cw An Amiga core window structure to finialise
+ * \return NSERROR_OK on successful finalisation otherwise error code.
+ */
+nserror ami_corewindow_fini(struct ami_corewindow *ami_cw);
+
+#endif
+
diff --git a/frontends/amiga/object.h b/frontends/amiga/object.h
index be96504..70bb550 100755
--- a/frontends/amiga/object.h
+++ b/frontends/amiga/object.h
@@ -33,6 +33,7 @@ enum
AMINS_HISTORYWINDOW,
AMINS_GUIOPTSWINDOW,
AMINS_PRINTWINDOW,
+ AMINS_COREWINDOW,
AMINS_FONT,
AMINS_MIME,
AMINS_RECT
-----------------------------------------------------------------------
--
NetSurf Browser