NetSurf
Functions | Variables
corewindow.c File Reference

Amiga core window interface. More...

#include "amiga/os3support.h"
#include <assert.h>
#include <stdlib.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 "netsurf/plot_style.h"
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/layout.h>
#include <proto/utility.h>
#include <classes/window.h>
#include <gadgets/layout.h>
#include <gadgets/scroller.h>
#include <gadgets/space.h>
#include <intuition/icclass.h>
#include <reaction/reaction_macros.h>
#include "amiga/corewindow.h"
#include "amiga/drag.h"
#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/object.h"
#include "amiga/schedule.h"
#include "amiga/utf8.h"
Include dependency graph for corewindow.c:

Go to the source code of this file.

Functions

static void ami_cw_scroller_top (struct ami_corewindow *ami_cw, ULONG *restrict x, ULONG *restrict y)
 
static void ami_cw_window_size (struct ami_corewindow *ami_cw, int *width, int *height)
 
static void ami_cw_coord_amiga_to_ns (struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
 Convert co-ordinates relative to space.gadget into document co-ordinates. More...
 
static bool ami_cw_mouse_moved (struct ami_corewindow *ami_cw, int x, int y, bool click)
 check if mouse has moved since position was stored More...
 
static bool ami_cw_mouse_pos (struct ami_corewindow *ami_cw, int *restrict x, int *restrict y)
 
static void ami_cw_key (struct ami_corewindow *ami_cw, int nskey)
 
static void ami_cw_redraw_rect (struct ami_corewindow *ami_cw, struct rect *r)
 Redraw functions. More...
 
static void ami_cw_redraw_queue (struct ami_corewindow *ami_cw, bool draw)
 Draw the deferred rectangles. More...
 
static void ami_cw_redraw_cb (void *p)
 
static void ami_cw_redraw (struct ami_corewindow *ami_cw, const struct rect *restrict r)
 Queue a redraw of a rectangle. More...
 
static void ami_cw_simplerefresh (struct ami_corewindow *ami_cw)
 
static void ami_cw_toggle_scrollbar (struct ami_corewindow *ami_cw, bool vert, bool visible)
 
static void ami_cw_close (void *w)
 
 HOOKF (void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
 
static void ami_cw_drag_start (struct ami_corewindow *ami_cw, int x, int y)
 Drag start. More...
 
static void ami_cw_drag_progress (struct ami_corewindow *ami_cw, int x, int y)
 Drag progress. More...
 
static void ami_cw_drag_end (struct ami_corewindow *ami_cw, int x, int y)
 Drag end. More...
 
static void ami_cw_newsize (struct ami_corewindow *ami_cw)
 User has resized window. More...
 
static BOOL ami_cw_event (void *w)
 Main event loop for our core window. More...
 
static nserror ami_cw_invalidate_area (struct core_window *cw, const struct rect *r)
 callback from core to request an invalidation of a amiga core window area. More...
 
static nserror ami_cw_get_window_dimensions (const struct core_window *cw, int *width, int *height)
 
static nserror ami_cw_update_size (struct core_window *cw, int width, int height)
 
static nserror ami_cw_get_scroll (const struct core_window *cw, int *x, int *y)
 
static nserror ami_cw_set_scroll (struct core_window *cw, int x, int y)
 
static nserror ami_cw_drag_status (struct core_window *cw, core_window_drag_status ds)
 
nserror ami_corewindow_init (struct ami_corewindow *ami_cw)
 initialise elements of Amiga core window. More...
 
nserror ami_corewindow_fini (struct ami_corewindow *ami_cw)
 finalise elements of Amiga core window. More...
 

Variables

static const struct ami_win_event_table ami_cw_table
 
struct core_window_table ami_cw_cb_table
 
struct core_window_tableamiga_core_window_table = &ami_cw_cb_table
 

Detailed Description

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.

Definition in file corewindow.c.

Function Documentation

◆ ami_corewindow_fini()

nserror ami_corewindow_fini ( struct ami_corewindow ami_cw)

finalise elements of Amiga core window.

Parameters
ami_cwAn Amiga core window structure to finialise
Returns
NSERROR_OK on successful finalisation otherwise error code.

Definition at line 987 of file corewindow.c.

References ami_cw_redraw_cb(), ami_gui_win_list_remove(), ami_memory_itempool_delete, ami_plot_ra_free(), ami_schedule(), ami_utf8_free(), ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, FreeObjList(), ami_corewindow::gg, GID_CW_HSCROLL, GID_CW_VSCROLL, GID_CW_WIN, ami_corewindow::in_border_scroll, NSERROR_OK, ami_corewindow::objects, ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, ami_corewindow::win, and ami_corewindow::wintitle.

Referenced by ami_cookies_destroy(), ami_history_global_destroy(), ami_history_local_destroy(), ami_hotlist_destroy(), and ami_pageinfo_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_corewindow_init()

nserror ami_corewindow_init ( struct ami_corewindow ami_cw)

initialise elements of Amiga core window.

As a pre-requisite the draw, key and mouse callbacks must be defined

Parameters
ami_cwAn Amiga core window structure to initialise
Returns
NSERROR_OK on successful initialisation otherwise error code.

Definition at line 928 of file corewindow.c.

References ami_cw_table, ami_gui_win_list_add(), ami_memory_itempool_create, ami_plot_ra_alloc(), AMINS_COREWINDOW, BROWSER_MOUSE_HOVER, CORE_WINDOW_DRAG_NONE, ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, ami_corewindow::drag_status, ami_corewindow::dragging, ami_corewindow::gg, GID_CW_HSCROLL, GID_CW_VSCROLL, GID_CW_WIN, ami_corewindow::idcmp_hook, ami_corewindow::in_border_scroll, ami_corewindow::lastclick, ami_corewindow::mouse_state, NewObjList(), NSERROR_OK, ami_corewindow::objects, RefreshSetGadgetAttrs(), ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, and ami_corewindow::win.

Referenced by ami_cookies_present(), ami_history_global_present(), ami_history_local_present(), ami_hotlist_present(), and ami_pageinfo_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_close()

static void ami_cw_close ( void *  w)
static

Definition at line 488 of file corewindow.c.

References ami_corewindow::close, and ami_corewindow::w.

Referenced by ami_cw_event().

Here is the caller graph for this function:

◆ ami_cw_coord_amiga_to_ns()

static void ami_cw_coord_amiga_to_ns ( struct ami_corewindow ami_cw,
int *restrict  x,
int *restrict  y 
)
static

Convert co-ordinates relative to space.gadget into document co-ordinates.

Parameters
ami_cwcore window
xco-ordinate, will be updated to new x co-ordinate
yco-ordinate, will be updated to new y co-ordinate

Definition at line 116 of file corewindow.c.

References ami_cw_scroller_top().

Referenced by ami_cw_redraw(), and ami_cw_simplerefresh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_drag_end()

static void ami_cw_drag_end ( struct ami_corewindow ami_cw,
int  x,
int  y 
)
static

Drag end.

Definition at line 587 of file corewindow.c.

References ami_drag_icon_close(), ami_gui_get_screen(), ami_window_at_pointer(), AMINS_COREWINDOW, CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_NONE, CORE_WINDOW_DRAG_SELECTION, ami_corewindow::drag_end, ami_corewindow::drag_status, ami_corewindow::dragging, scrn, and ami_corewindow::win.

Referenced by ami_cw_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_drag_progress()

static void ami_cw_drag_progress ( struct ami_corewindow ami_cw,
int  x,
int  y 
)
static

Drag progress.

Definition at line 566 of file corewindow.c.

References ami_drag_icon_move(), CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_SELECTION, ami_corewindow::drag_status, and ami_corewindow::dragging.

Referenced by ami_cw_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_drag_start()

static void ami_cw_drag_start ( struct ami_corewindow ami_cw,
int  x,
int  y 
)
static

Drag start.

Definition at line 541 of file corewindow.c.

References ami_drag_icon_show(), CORE_WINDOW_DRAG_MOVE, CORE_WINDOW_DRAG_SELECTION, ami_corewindow::drag_status, ami_corewindow::drag_x_start, ami_corewindow::drag_y_start, ami_corewindow::dragging, and ami_corewindow::win.

Referenced by ami_cw_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_drag_status()

static nserror ami_cw_drag_status ( struct core_window *  cw,
core_window_drag_status  ds 
)
static

Definition at line 908 of file corewindow.c.

References ami_corewindow::drag_status, and NSERROR_OK.

◆ ami_cw_event()

static BOOL ami_cw_event ( void *  w)
static

◆ ami_cw_get_scroll()

static nserror ami_cw_get_scroll ( const struct core_window *  cw,
int *  x,
int *  y 
)
static

Definition at line 871 of file corewindow.c.

References ami_cw_scroller_top(), and NSERROR_OK.

Here is the call graph for this function:

◆ ami_cw_get_window_dimensions()

static nserror ami_cw_get_window_dimensions ( const struct core_window *  cw,
int *  width,
int *  height 
)
static

Definition at line 829 of file corewindow.c.

References ami_cw_window_size(), height, NSERROR_OK, and width.

Here is the call graph for this function:

◆ ami_cw_invalidate_area()

static nserror ami_cw_invalidate_area ( struct core_window *  cw,
const struct rect r 
)
static

callback from core to request an invalidation of a amiga core window area.

The specified area of the window should now be considered out of date. If the area is NULL the entire window must be invalidated.

Parameters
[in]cwThe core window to invalidate.
[in]rarea to redraw or NULL for the entire window area.
Returns
NSERROR_OK on success or appropriate error code.

Definition at line 818 of file corewindow.c.

References ami_cw_redraw(), and NSERROR_OK.

Here is the call graph for this function:

◆ ami_cw_key()

static void ami_cw_key ( struct ami_corewindow ami_cw,
int  nskey 
)
static

Definition at line 190 of file corewindow.c.

References ami_corewindow::key, NS_KEY_CLEAR_SELECTION, and NS_KEY_COPY_SELECTION.

Referenced by ami_cw_event().

Here is the caller graph for this function:

◆ ami_cw_mouse_moved()

static bool ami_cw_mouse_moved ( struct ami_corewindow ami_cw,
int  x,
int  y,
bool  click 
)
static

check if mouse has moved since position was stored

Parameters
ami_cwcorewindow
xcurrent x position
ycurrent y position
clicktrue to check since last click, false since last drag (press)
Returns
true if it has, false otherwise

Definition at line 136 of file corewindow.c.

References ami_corewindow::drag_x_start, ami_corewindow::drag_y_start, ami_corewindow::mouse_x_click, and ami_corewindow::mouse_y_click.

Referenced by ami_cw_event().

Here is the caller graph for this function:

◆ ami_cw_mouse_pos()

static bool ami_cw_mouse_pos ( struct ami_corewindow ami_cw,
int *restrict  x,
int *restrict  y 
)
static

Definition at line 157 of file corewindow.c.

References ami_cw_scroller_top(), ami_gui_free_space_box(), ami_gui_get_space_box(), amiga_warn_user(), GID_CW_DRAW, NSERROR_OK, ami_corewindow::objects, and ami_corewindow::win.

Referenced by ami_cw_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_newsize()

static void ami_cw_newsize ( struct ami_corewindow ami_cw)
static

User has resized window.

Definition at line 616 of file corewindow.c.

References ami_cw_redraw(), ami_cw_window_size(), GID_CW_HSCROLL, GID_CW_VSCROLL, ami_corewindow::objects, RefreshSetGadgetAttrs(), and ami_corewindow::win.

Referenced by ami_cw_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_redraw()

static void ami_cw_redraw ( struct ami_corewindow ami_cw,
const struct rect *restrict  r 
)
static

Queue a redraw of a rectangle.

Parameters
ami_cwthe core window to redraw
rthe rectangle (in doc coords) to redraw, or NULL for full window

Definition at line 352 of file corewindow.c.

References AddObject(), ami_cw_coord_amiga_to_ns(), ami_cw_redraw_cb(), ami_gui_free_space_box(), ami_gui_get_space_box(), ami_gui_window_update_box_deferred_check(), ami_memory_itempool_alloc, ami_schedule(), amiga_warn_user(), AMINS_RECT, ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, GID_CW_DRAW, NSERROR_OK, NSLOG, ami_corewindow::objects, nsObject::objstruct, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by ami_cw_invalidate_area(), ami_cw_newsize(), ami_cw_set_scroll(), ami_cw_simplerefresh(), ami_cw_toggle_scrollbar(), and HOOKF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_redraw_cb()

static void ami_cw_redraw_cb ( void *  p)
static

Definition at line 337 of file corewindow.c.

References ami_cw_redraw_queue().

Referenced by ami_corewindow_fini(), and ami_cw_redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_redraw_queue()

static void ami_cw_redraw_queue ( struct ami_corewindow ami_cw,
bool  draw 
)
static

Draw the deferred rectangles.

Parameters
ami_cwAn Amiga core window structure to queue redraw
drawset to false to just delete the queue

Definition at line 311 of file corewindow.c.

References ami_cw_redraw_rect(), ami_memory_itempool_free, ami_corewindow::deferred_rects, ami_corewindow::deferred_rects_pool, DelObjectNoFree(), GetHead(), GetSucc(), IsMinListEmpty, NSLOG, and nsObject::objstruct.

Referenced by ami_cw_redraw_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_redraw_rect()

static void ami_cw_redraw_rect ( struct ami_corewindow ami_cw,
struct rect r 
)
static

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

Parameters
ami_cwAn Amiga core window structure
rrect (in document co-ordinates)

Definition at line 221 of file corewindow.c.

References ami_clearclipreg(), ami_cw_scroller_top(), ami_gui_free_space_box(), ami_gui_get_space_box(), ami_plot_ra_get_bitmap(), ami_plot_ra_get_size(), amiga_warn_user(), amiplot, ami_corewindow::draw, ami_corewindow::gg, GID_CW_DRAW, height, redraw_context::interactive, NSERROR_OK, ami_corewindow::objects, width, ami_corewindow::win, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by ami_cw_redraw_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_scroller_top()

static void ami_cw_scroller_top ( struct ami_corewindow ami_cw,
ULONG *restrict  x,
ULONG *restrict  y 
)
static

Definition at line 71 of file corewindow.c.

References GID_CW_HSCROLL, GID_CW_VSCROLL, ami_corewindow::objects, ami_corewindow::scroll_x_visible, and ami_corewindow::scroll_y_visible.

Referenced by ami_cw_coord_amiga_to_ns(), ami_cw_get_scroll(), ami_cw_mouse_pos(), and ami_cw_redraw_rect().

Here is the caller graph for this function:

◆ ami_cw_set_scroll()

static nserror ami_cw_set_scroll ( struct core_window *  cw,
int  x,
int  y 
)
static

Definition at line 885 of file corewindow.c.

References ami_cw_redraw(), GID_CW_HSCROLL, GID_CW_VSCROLL, NSERROR_OK, ami_corewindow::objects, RefreshSetGadgetAttrs(), ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, and ami_corewindow::win.

Here is the call graph for this function:

◆ ami_cw_simplerefresh()

static void ami_cw_simplerefresh ( struct ami_corewindow ami_cw)
static

Definition at line 389 of file corewindow.c.

References ami_cw_coord_amiga_to_ns(), ami_cw_redraw(), ami_corewindow::win, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by HOOKF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_toggle_scrollbar()

static void ami_cw_toggle_scrollbar ( struct ami_corewindow ami_cw,
bool  vert,
bool  visible 
)
static

Definition at line 425 of file corewindow.c.

References ami_cw_redraw(), GID_CW_HSCROLL, GID_CW_HSCROLLLAYOUT, GID_CW_VSCROLL, GID_CW_VSCROLLLAYOUT, GID_CW_WIN, IDoMethod, ami_corewindow::in_border_scroll, ami_corewindow::objects, ami_corewindow::scroll_x_visible, ami_corewindow::scroll_y_visible, and ami_corewindow::win.

Referenced by ami_cw_update_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_cw_update_size()

static nserror ami_cw_update_size ( struct core_window *  cw,
int  width,
int  height 
)
static

Definition at line 840 of file corewindow.c.

References ami_cw_toggle_scrollbar(), ami_cw_window_size(), GID_CW_HSCROLL, GID_CW_VSCROLL, height, NSERROR_OK, ami_corewindow::objects, RefreshSetGadgetAttrs(), width, and ami_corewindow::win.

Here is the call graph for this function:

◆ ami_cw_window_size()

static void ami_cw_window_size ( struct ami_corewindow ami_cw,
int *  width,
int *  height 
)
static

Definition at line 91 of file corewindow.c.

References ami_gui_free_space_box(), ami_gui_get_space_box(), amiga_warn_user(), GID_CW_DRAW, height, NSERROR_OK, ami_corewindow::objects, and width.

Referenced by ami_cw_get_window_dimensions(), ami_cw_newsize(), and ami_cw_update_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HOOKF()

HOOKF ( void  ,
ami_cw_idcmp_hook  ,
Object *  ,
object  ,
struct IntuiMessage *   
)

Definition at line 495 of file corewindow.c.

References ami_cw_redraw(), ami_cw_simplerefresh(), GID_CW_HSCROLL, GID_CW_VSCROLL, IDCMP_EXTENDEDMOUSE, and NSLOG.

Here is the call graph for this function:

Variable Documentation

◆ ami_cw_cb_table

struct core_window_table ami_cw_cb_table
Initial value:
= {
.invalidate = ami_cw_invalidate_area,
.set_extent = ami_cw_update_size,
.set_scroll = ami_cw_set_scroll,
.get_scroll = ami_cw_get_scroll,
.get_dimensions = ami_cw_get_window_dimensions,
.drag_status = ami_cw_drag_status
}
static nserror ami_cw_update_size(struct core_window *cw, int width, int height)
Definition: corewindow.c:840
static nserror ami_cw_get_scroll(const struct core_window *cw, int *x, int *y)
Definition: corewindow.c:871
static nserror ami_cw_get_window_dimensions(const struct core_window *cw, int *width, int *height)
Definition: corewindow.c:829
static nserror ami_cw_invalidate_area(struct core_window *cw, const struct rect *r)
callback from core to request an invalidation of a amiga core window area.
Definition: corewindow.c:818
static nserror ami_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
Definition: corewindow.c:908
static nserror ami_cw_set_scroll(struct core_window *cw, int x, int y)
Definition: corewindow.c:885

Definition at line 916 of file corewindow.c.

◆ ami_cw_table

const struct ami_win_event_table ami_cw_table
static
Initial value:
= {
}
static BOOL ami_cw_event(void *w)
Main event loop for our core window.
Definition: corewindow.c:642
static void ami_cw_close(void *w)
Definition: corewindow.c:488

Definition at line 800 of file corewindow.c.

Referenced by ami_corewindow_init().

◆ amiga_core_window_table

struct core_window_table* amiga_core_window_table = &ami_cw_cb_table

Definition at line 925 of file corewindow.c.

Referenced by main().