move core window callbacks to the standard gui tables

This commit is contained in:
Vincent Sanders 2024-05-26 18:41:56 +01:00
parent 15d3de0d37
commit f01a948329
58 changed files with 245 additions and 215 deletions

View File

@ -788,8 +788,7 @@ struct treeview_callback_table cm_tree_cb_t = {
/* Exported interface, documented in cookie_manager.h */
nserror cookie_manager_init(struct core_window_callback_table *cw_t,
void *core_window_handle)
nserror cookie_manager_init(void *core_window_handle)
{
nserror err;
@ -817,7 +816,7 @@ nserror cookie_manager_init(struct core_window_callback_table *cw_t,
/* Create the cookie manager treeview */
err = treeview_create(&cm_ctx.tree, &cm_tree_cb_t,
COOKIE_M_N_FIELDS, cm_ctx.fields,
cw_t, core_window_handle,
core_window_handle,
TREEVIEW_NO_MOVES |
TREEVIEW_DEL_EMPTY_DIRS |
TREEVIEW_SEARCHABLE);

View File

@ -31,7 +31,6 @@
struct redraw_context;
struct cookie_data;
struct core_window_callback_table;
struct rect;
/**
@ -42,12 +41,10 @@ struct rect;
*
* This must be called before any other cookie_manager_* function.
*
* \param cw_t Callback table for core_window containing the treeview
* \param core_window_handle The core_window in which the treeview is shown
* \param core_window_handle The core_window in which the cookie view is shown
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror cookie_manager_init(struct core_window_callback_table *cw_t,
void *core_window_handle);
nserror cookie_manager_init(void *core_window_handle);
/**
* Finalise the cookie manager.

View File

@ -29,12 +29,10 @@
#include "netsurf/types.h"
#include "css/utils.h"
#include "desktop/cw_helper.h"
#include "desktop/gui_internal.h"
/* exported interface documented in cw_helper.h */
nserror cw_helper_scroll_visible(
const struct core_window_callback_table *cw_t,
struct core_window *cw_h,
const struct rect *r)
nserror cw_helper_scroll_visible(struct core_window *cw_h, const struct rect *r)
{
nserror err;
int height;
@ -44,18 +42,14 @@ nserror cw_helper_scroll_visible(
int x1;
int y1;
assert(cw_t != NULL);
assert(cw_h != NULL);
assert(cw_t->get_scroll != NULL);
assert(cw_t->set_scroll != NULL);
assert(cw_t->get_window_dimensions != NULL);
err = cw_t->get_window_dimensions(cw_h, &width, &height);
err = guit->corewindow->get_dimensions(cw_h, &width, &height);
if (err != NSERROR_OK) {
return err;
}
cw_t->get_scroll(cw_h, &x0, &y0);
guit->corewindow->get_scroll(cw_h, &x0, &y0);
if (err != NSERROR_OK) {
return err;
}
@ -88,5 +82,5 @@ nserror cw_helper_scroll_visible(
x0 = r->x0;
}
return cw_t->set_scroll(cw_h, x0, y0);
return guit->corewindow->set_scroll(cw_h, x0, y0);
}

View File

@ -27,7 +27,6 @@
struct rect;
struct core_window;
struct core_window_callback_table;
/**
* Scroll a core window to make the given rectangle visible.
@ -37,9 +36,6 @@ struct core_window_callback_table;
* \param[in] r The rectangle to make visisble by scrolling.
* \return NSERROR_OK on success or appropriate error code
*/
nserror cw_helper_scroll_visible(
const struct core_window_callback_table *cw_t,
struct core_window *cw_h,
const struct rect *r);
nserror cw_helper_scroll_visible(struct core_window *cw_h, const struct rect *r);
#endif

View File

@ -723,8 +723,7 @@ struct treeview_callback_table gh_tree_cb_t = {
/* Exported interface, documented in global_history.h */
nserror global_history_init(struct core_window_callback_table *cw_t,
void *core_window_handle)
nserror global_history_init(void *core_window_handle)
{
nserror err;
@ -755,7 +754,7 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
/* Create the global history treeview */
err = treeview_create(&gh_ctx.tree, &gh_tree_cb_t,
N_FIELDS, gh_ctx.fields,
cw_t, core_window_handle,
core_window_handle,
TREEVIEW_NO_MOVES | TREEVIEW_DEL_EMPTY_DIRS |
TREEVIEW_SEARCHABLE);
if (err != NSERROR_OK) {

View File

@ -25,7 +25,6 @@
#include "utils/errors.h"
#include "netsurf/mouse.h"
struct core_window_callback_table;
struct redraw_context;
struct nsurl;
struct rect;
@ -38,12 +37,10 @@ struct rect;
*
* This must be called before any other global_history_* function.
*
* \param cw_t Callback table for core_window containing the treeview.
* \param core_window_handle The core_window in which the treeview is shown.
* \param core_window_handle The core_window in which the global history is shown.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror global_history_init(struct core_window_callback_table *cw_t,
void *core_window_handle);
nserror global_history_init(void *core_window_handle);
/**
* Finalise the global history.

View File

@ -37,6 +37,7 @@
#include "netsurf/fetch.h"
#include "netsurf/misc.h"
#include "netsurf/window.h"
#include "netsurf/core_window.h"
#include "netsurf/search.h"
#include "netsurf/clipboard.h"
#include "netsurf/utf8.h"
@ -204,6 +205,75 @@ static nserror verify_window_register(struct gui_window_table *gwt)
}
static nserror gui_default_corewindow_invalidate(struct core_window *cw, const struct rect *rect)
{
return NSERROR_OK;
}
static nserror gui_default_corewindow_set_extent(struct core_window *cw, int width, int height)
{
return NSERROR_OK;
}
static nserror gui_default_corewindow_set_scroll(struct core_window *cw, int x, int y)
{
return NSERROR_OK;
}
static nserror gui_default_corewindow_get_scroll(const struct core_window *cw, int *x, int *y)
{
return NSERROR_OK;
}
static nserror gui_default_corewindow_get_dimensions(const struct core_window *cw, int *width, int *height)
{
return NSERROR_OK;
}
static nserror gui_default_corewindow_dragstatus(struct core_window *cw, core_window_drag_status ds)
{
return NSERROR_OK;
}
static struct core_window_table default_corewindow_table = {
.invalidate = gui_default_corewindow_invalidate,
.set_extent = gui_default_corewindow_set_extent,
.set_scroll = gui_default_corewindow_set_scroll,
.get_scroll = gui_default_corewindow_get_scroll,
.get_dimensions = gui_default_corewindow_get_dimensions,
.drag_status = gui_default_corewindow_dragstatus,
};
/** verify corewindow window table is valid */
static nserror verify_corewindow_register(struct core_window_table *cwt)
{
/* check table is present */
if (cwt == NULL) {
return NSERROR_BAD_PARAMETER;
}
/* all enties are mandantory */
if (cwt->invalidate == NULL) {
return NSERROR_BAD_PARAMETER;
}
if (cwt->set_extent == NULL) {
return NSERROR_BAD_PARAMETER;
}
if (cwt->set_scroll == NULL) {
return NSERROR_BAD_PARAMETER;
}
if (cwt->get_scroll == NULL) {
return NSERROR_BAD_PARAMETER;
}
if (cwt->get_dimensions == NULL) {
return NSERROR_BAD_PARAMETER;
}
if (cwt->drag_status == NULL) {
return NSERROR_BAD_PARAMETER;
}
return NSERROR_OK;
}
static struct gui_download_window *
gui_default_download_create(download_context *ctx, struct gui_window *parent)
@ -752,6 +822,17 @@ nserror netsurf_register(struct netsurf_table *gt)
/* optional tables */
/* core window table */
if (gt->corewindow == NULL) {
/* set default core window table */
gt->corewindow = &default_corewindow_table;
}
err = verify_corewindow_register(gt->corewindow);
if (err != NSERROR_OK) {
return err;
}
/* file table */
if (gt->file == NULL) {
gt->file = default_file_table;

View File

@ -65,6 +65,15 @@ struct netsurf_table {
*/
struct gui_window_table *window;
/**
* Core window table.
*
* Provides all operations which affect core ui windows of a frontend.
*
* The table is optional and may be NULL which does nothing.
*/
struct core_window_table *corewindow;
/**
* Download table.
*

View File

@ -1324,7 +1324,7 @@ nserror hotlist_init(
/* Create the hotlist treeview */
err = treeview_create(&hl_ctx.tree, &hl_tree_cb_t,
HL_N_FIELDS, hl_ctx.fields, NULL, NULL,
HL_N_FIELDS, hl_ctx.fields, NULL,
TREEVIEW_SEARCHABLE);
if (err != NSERROR_OK) {
free(hl_ctx.save_path);
@ -1351,13 +1351,12 @@ nserror hotlist_init(
/* Exported interface, documented in hotlist.h */
nserror hotlist_manager_init(struct core_window_callback_table *cw_t,
void *core_window_handle)
nserror hotlist_manager_init(void *core_window_handle)
{
nserror err;
/* Create the hotlist treeview */
err = treeview_cw_attach(hl_ctx.tree, cw_t, core_window_handle);
err = treeview_cw_attach(hl_ctx.tree, core_window_handle);
if (err != NSERROR_OK) {
return err;
}

View File

@ -25,7 +25,6 @@
#include "utils/errors.h"
#include "netsurf/mouse.h"
struct core_window_callback_table;
struct redraw_context;
struct nsurl;
struct rect;
@ -47,9 +46,7 @@ struct rect;
* \param save_path The path to save hotlist to, or NULL for read-only mode.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_init(
const char *load_path,
const char *save_path);
nserror hotlist_init(const char *load_path, const char *save_path);
/**
* Initialise the hotlist manager.
@ -58,12 +55,10 @@ nserror hotlist_init(
*
* The provided core window handle must be valid until hotlist_fini is called.
*
* \param cw_t Callback table for core_window containing the treeview
* \param core_window_handle The handle in which the treeview is shown
* \param core_window_handle The handle in which the hotlist is shown
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_manager_init(struct core_window_callback_table *cw_t,
void *core_window_handle);
nserror hotlist_manager_init(void *core_window_handle);
/**

View File

@ -49,7 +49,6 @@
*/
struct local_history_session {
struct browser_window *bw;
struct core_window_callback_table *cw_t;
void *core_window_handle;
struct history_entry *cursor;
};
@ -302,15 +301,12 @@ local_history_scroll_to_cursor(struct local_history_session *session)
cursor.y1 = cursor.y0 + LOCAL_HISTORY_HEIGHT +
LOCAL_HISTORY_BOTTOM_MARGIN / 2;
return cw_helper_scroll_visible(session->cw_t,
session->core_window_handle,
&cursor);
return cw_helper_scroll_visible(session->core_window_handle, &cursor);
}
/* exported interface documented in desktop/local_history.h */
nserror
local_history_init(struct core_window_callback_table *cw_t,
void *core_window_handle,
local_history_init(void *core_window_handle,
struct browser_window *bw,
struct local_history_session **session)
{
@ -333,7 +329,6 @@ local_history_init(struct core_window_callback_table *cw_t,
return NSERROR_NOMEM;
}
nses->cw_t = cw_t;
nses->core_window_handle = core_window_handle;
local_history_set(nses, bw);
@ -469,7 +464,7 @@ local_history_keypress(struct local_history_session *session, uint32_t key)
browser_window_history_go(session->bw, session->cursor,
false);
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle, NULL);
guit->corewindow->invalidate(session->core_window_handle, NULL);
}
/* We have handled this keypress */
return true;
@ -478,7 +473,7 @@ local_history_keypress(struct local_history_session *session, uint32_t key)
if (session->cursor->back != NULL) {
session->cursor = session->cursor->back;
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle, NULL);
guit->corewindow->invalidate(session->core_window_handle, NULL);
}
/* We have handled this keypress */
return true;
@ -487,7 +482,7 @@ local_history_keypress(struct local_history_session *session, uint32_t key)
if (session->cursor->forward_pref != NULL) {
session->cursor = session->cursor->forward_pref;
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle, NULL);
guit->corewindow->invalidate(session->core_window_handle, NULL);
}
/* We have handled this keypress */
return true;
@ -509,7 +504,7 @@ local_history_keypress(struct local_history_session *session, uint32_t key)
}
/* We have handled this keypress */
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle, NULL);
guit->corewindow->invalidate(session->core_window_handle, NULL);
return true;
case NS_KEY_UP:
/* Go to next sibling up, if there is one */
@ -538,7 +533,7 @@ local_history_keypress(struct local_history_session *session, uint32_t key)
}
/* We have handled this keypress */
local_history_scroll_to_cursor(session);
session->cw_t->invalidate(session->core_window_handle, NULL);
guit->corewindow->invalidate(session->core_window_handle, NULL);
return true;
}
return false;
@ -556,9 +551,9 @@ local_history_set(struct local_history_session *session,
assert(session->bw->history != NULL);
session->cursor = bw->history->current;
session->cw_t->update_size(session->core_window_handle,
session->bw->history->width,
session->bw->history->height);
guit->corewindow->set_extent(session->core_window_handle,
session->bw->history->width,
session->bw->history->height);
local_history_scroll_to_cursor(session);
}

View File

@ -25,7 +25,6 @@
#include "utils/errors.h"
#include "netsurf/mouse.h"
struct core_window_callback_table;
struct redraw_context;
struct nsurl;
struct rect;
@ -47,8 +46,7 @@ struct browser_window;
* \param[out] session The created local history session context.
* \return NSERROR_OK on success and session set, appropriate error code otherwise
*/
nserror local_history_init(struct core_window_callback_table *cw_t,
void *core_window_handle,
nserror local_history_init(void *core_window_handle,
struct browser_window *bw,
struct local_history_session **session);

View File

@ -236,7 +236,6 @@ struct page_info_entry pi__entries[PI_ENTRY__COUNT] = {
* The page info window structure.
*/
struct page_info {
const struct core_window_callback_table *cw_t;
struct core_window *cw_h;
struct browser_window *bw;
@ -531,15 +530,13 @@ static nserror page_info__layout(
pi->width = max_x;
pi->height = cur_y;
return pi->cw_t->update_size(pi->cw_h, max_x, cur_y);
return guit->corewindow->set_extent(pi->cw_h, max_x, cur_y);
}
/* Exported interface documented in desktop/page_info.h */
nserror page_info_create(
const struct core_window_callback_table *cw_t,
struct core_window *cw_h,
struct browser_window *bw,
struct page_info **pi_out)
nserror page_info_create(struct core_window *cw_h,
struct browser_window *bw,
struct page_info **pi_out)
{
struct page_info *pi;
nserror err;
@ -549,7 +546,6 @@ nserror page_info_create(
return NSERROR_NOMEM;
}
pi->cw_t = cw_t;
pi->cw_h = cw_h;
memcpy(pi->entries, pi__entries, sizeof(pi__entries));
@ -800,11 +796,10 @@ nserror page_info_mouse_action(
.y0 = cur_y,
.y1 = cur_y + height,
};
pi->cw_t->get_window_dimensions(
pi->cw_h, &w, &h);
guit->corewindow->get_dimensions(pi->cw_h, &w, &h);
r.x1 = (pi->width > w) ? pi->width : w;
pi->cw_t->invalidate(pi->cw_h, &r);
guit->corewindow->invalidate(pi->cw_h, &r);
}
entry->u.item.hover = hovering;
cur_y += height;

View File

@ -36,7 +36,6 @@ struct page_info;
struct core_window;
struct browser_window;
struct redraw_context;
struct core_window_callback_table;
/**
* Initialise the page_info module.
@ -59,17 +58,14 @@ nserror page_info_fini(void);
* It can be destroyed before the browser window is destroyed by calling
* \ref page_info_destroy.
*
* \param[in] cw_t Callback table for the containing core_window.
* \param[in] cw_h Handle for the containing core_window.
* \param[in] bw Browser window to show page info for.
* \param[out] pi_out The created page info window handle.
* \return NSERROR_OK on success, appropriate error code otherwise.
*/
nserror page_info_create(
const struct core_window_callback_table *cw_t,
struct core_window *cw_h,
struct browser_window *bw,
struct page_info **pi_out);
nserror page_info_create(struct core_window *cw_h,
struct browser_window *bw,
struct page_info **pi_out);
/**
* Destroy a page info corewindow.

View File

@ -248,7 +248,6 @@ struct treeview {
const struct treeview_callback_table *callbacks; /**< For node events */
const struct core_window_callback_table *cw_t; /**< Window cb table */
struct core_window *cw_h; /**< Core window handle */
};
@ -355,8 +354,8 @@ static inline void treeview__cw_invalidate_area(
const struct treeview *tree,
const struct rect *r)
{
if (tree->cw_t != NULL) {
tree->cw_t->invalidate(tree->cw_h, r);
if (tree->cw_h != NULL) {
guit->corewindow->invalidate(tree->cw_h, r);
}
}
@ -369,14 +368,14 @@ static inline void treeview__cw_invalidate_area(
static inline void treeview__cw_full_redraw(
const struct treeview *tree)
{
if (tree->cw_t != NULL) {
if (tree->cw_h != NULL) {
static const struct rect r = {
.x0 = 0,
.y0 = 0,
.x1 = REDRAW_MAX,
.y1 = REDRAW_MAX,
};
tree->cw_t->invalidate(tree->cw_h, &r);
guit->corewindow->invalidate(tree->cw_h, &r);
}
}
@ -406,9 +405,10 @@ static inline void treeview__cw_update_size(
const struct treeview *tree,
int width, int height)
{
if (tree->cw_t != NULL) {
tree->cw_t->update_size(tree->cw_h, width,
height + treeview__get_search_height(tree));
if (tree->cw_h != NULL) {
guit->corewindow->set_extent(tree->cw_h,
width,
height + treeview__get_search_height(tree));
}
}
@ -428,10 +428,9 @@ static inline void treeview__cw_scroll_top(
.y1 = tree_g.line_height,
};
cw_helper_scroll_visible(tree->cw_t, tree->cw_h, &r);
cw_helper_scroll_visible(tree->cw_h, &r);
}
/**
* Corewindow callback wrapper: Get window viewport dimensions
*
@ -443,8 +442,8 @@ static inline void treeview__cw_get_window_dimensions(
const struct treeview *tree,
int *width, int *height)
{
if (tree->cw_t != NULL) {
tree->cw_t->get_window_dimensions(tree->cw_h, width, height);
if (tree->cw_h != NULL) {
guit->corewindow->get_dimensions(tree->cw_h, width, height);
}
}
@ -459,8 +458,8 @@ static inline void treeview__cw_drag_status(
const struct treeview *tree,
core_window_drag_status ds)
{
if (tree->cw_t != NULL) {
tree->cw_t->drag_status(tree->cw_h, ds);
if (tree->cw_h != NULL) {
guit->corewindow->drag_status(tree->cw_h, ds);
}
}
@ -606,7 +605,7 @@ static inline void treeview__cw_scroll_to_node(
r.y1 += r.y0; /* Apply the Y offset to the second Y coordinate */
cw_helper_scroll_visible(tree->cw_t, tree->cw_h, &r);
cw_helper_scroll_visible(tree->cw_h, &r);
}
@ -2024,14 +2023,12 @@ treeview_create(treeview **tree,
const struct treeview_callback_table *callbacks,
int n_fields,
struct treeview_field_desc fields[],
const struct core_window_callback_table *cw_t,
struct core_window *cw,
treeview_flags flags)
{
nserror error;
int i;
assert((cw_t == NULL && cw == NULL) || (cw_t != NULL && cw != NULL));
assert(callbacks != NULL);
assert(fields != NULL);
@ -2117,7 +2114,6 @@ treeview_create(treeview **tree,
(*tree)->flags = flags;
(*tree)->cw_t = cw_t;
(*tree)->cw_h = cw;
return NSERROR_OK;
@ -2126,18 +2122,14 @@ treeview_create(treeview **tree,
/* Exported interface, documented in treeview.h */
nserror
treeview_cw_attach(treeview *tree,
const struct core_window_callback_table *cw_t,
struct core_window *cw)
treeview_cw_attach(treeview *tree, struct core_window *cw)
{
assert(cw_t != NULL);
assert(cw != NULL);
if (tree->cw_t != NULL || tree->cw_h != NULL) {
if (tree->cw_h != NULL) {
NSLOG(netsurf, INFO, "Treeview already attached.");
return NSERROR_UNKNOWN;
}
tree->cw_t = cw_t;
tree->cw_h = cw;
return NSERROR_OK;
@ -2147,7 +2139,6 @@ treeview_cw_attach(treeview *tree,
/* Exported interface, documented in treeview.h */
nserror treeview_cw_detach(treeview *tree)
{
tree->cw_t = NULL;
tree->cw_h = NULL;
treeview__search_cancel(tree, true);

View File

@ -32,7 +32,6 @@
struct redraw_context;
struct core_window;
struct core_window_callback_table;
typedef struct treeview treeview;
typedef struct treeview_node treeview_node;
@ -189,9 +188,10 @@ nserror treeview_fini(void);
*/
nserror treeview_create(treeview **tree,
const struct treeview_callback_table *callbacks,
int n_fields, struct treeview_field_desc fields[],
const struct core_window_callback_table *cw_t,
struct core_window *cw, treeview_flags flags);
int n_fields,
struct treeview_field_desc fields[],
struct core_window *cw,
treeview_flags flags);
/**
@ -204,9 +204,7 @@ nserror treeview_create(treeview **tree,
* \param cw The core_window in which the treeview is shown
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror treeview_cw_attach(treeview *tree,
const struct core_window_callback_table *cw_t,
struct core_window *cw);
nserror treeview_cw_attach(treeview *tree, struct core_window *cw);
/**

View File

@ -385,7 +385,7 @@ nserror ami_cookies_present(const char *search_term)
return res;
}
res = cookie_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
res = cookie_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
ami_utf8_free(ncwin->core.wintitle);
DisposeObject(ncwin->core.objects[GID_CW_WIN]);

View File

@ -913,20 +913,21 @@ ami_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
}
struct core_window_callback_table ami_cw_cb_table = {
struct core_window_table ami_cw_cb_table = {
.invalidate = ami_cw_invalidate_area,
.update_size = ami_cw_update_size,
.set_extent = ami_cw_update_size,
.set_scroll = ami_cw_set_scroll,
.get_scroll = ami_cw_get_scroll,
.get_window_dimensions = ami_cw_get_window_dimensions,
.get_dimensions = ami_cw_get_window_dimensions,
.drag_status = ami_cw_drag_status
};
struct core_window_table *amiga_core_window_table = &ami_cw_cb_table;
/* exported function documented example/corewindow.h */
nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
{
/* setup the core window callback table */
ami_cw->cb_table = &ami_cw_cb_table;
ami_cw->drag_status = CORE_WINDOW_DRAG_NONE;
/* clear some vars */

View File

@ -24,6 +24,8 @@
#include "amiga/gui.h" /* need to know the size of ami_generic_window :( */
#include "amiga/plotters.h"
extern struct core_window_table *amiga_core_window_table;
/**
* BOOPSI objects
*/
@ -82,9 +84,6 @@ struct ami_corewindow {
/** drag status set by core */
core_window_drag_status drag_status;
/** table of callbacks for core window operations */
struct core_window_callback_table *cb_table;
/**
* callback to draw on drawable area of Amiga core window
*

View File

@ -161,6 +161,7 @@
#include "amiga/selectmenu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
#include "amiga/corewindow.h"
#define AMINS_SCROLLERPEN NUMDRIPENS
#define NSA_KBD_SCROLL_PX 10
@ -6541,6 +6542,7 @@ int main(int argc, char** argv)
struct netsurf_table amiga_table = {
.misc = &amiga_misc_table,
.window = &amiga_window_table,
.corewindow = amiga_core_window_table,
.clipboard = amiga_clipboard_table,
.download = amiga_download_table,
.fetch = &amiga_fetch_table,

View File

@ -461,7 +461,7 @@ nserror ami_history_global_present(void)
return res;
}
res = global_history_init(ncwin->core.cb_table, (struct core_window *)ncwin);
res = global_history_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
ami_utf8_free(ncwin->core.wintitle);
DisposeObject(ncwin->core.objects[GID_CW_WIN]);

View File

@ -293,8 +293,7 @@ nserror ami_history_local_present(struct gui_window *gw)
return res;
}
res = local_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin,
res = local_history_init((struct core_window *)ncwin,
ami_gui_get_browser_window(gw),
&ncwin->session);
if (res != NSERROR_OK) {

View File

@ -586,7 +586,7 @@ nserror ami_hotlist_present(void)
return res;
}
res = hotlist_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
res = hotlist_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
ami_utf8_free(ncwin->core.wintitle);
DisposeObject(ncwin->core.objects[GID_CW_WIN]);

View File

@ -257,10 +257,9 @@ nserror ami_pageinfo_open(struct browser_window *bw, ULONG left, ULONG top)
return res;
}
res = page_info_create(ncwin->core.cb_table,
(struct core_window *)ncwin,
bw,
&ncwin->pi);
res = page_info_create((struct core_window *)ncwin,
bw,
&ncwin->pi);
if (res != NSERROR_OK) {
ami_utf8_free(ncwin->core.wintitle);

View File

@ -36,8 +36,7 @@ struct atari_cookie_manager_s atari_cookie_manager;
/* Setup Atari Treeview Callbacks: */
static nserror atari_cookie_manager_init_phase2(struct core_window *cw,
struct core_window_callback_table * default_callbacks);
static nserror atari_cookie_manager_init_phase2(struct core_window *cw);
static void atari_cookie_manager_finish(struct core_window *cw);
static void atari_cookie_manager_keypress(struct core_window *cw,
uint32_t ucs4);
@ -60,11 +59,10 @@ static struct atari_treeview_callbacks atari_cookie_manager_treeview_callbacks =
static nserror
atari_cookie_manager_init_phase2(struct core_window *cw,
struct core_window_callback_table *cb_t)
atari_cookie_manager_init_phase2(struct core_window *cw)
{
NSLOG(netsurf, INFO, "cw %p", cw);
return(cookie_manager_init(cb_t, cw));
return(cookie_manager_init(cw));
}

View File

@ -33,6 +33,7 @@
#include "netsurf/browser_window.h"
#include "netsurf/layout.h"
#include "netsurf/window.h"
#include "netsurf/treeview.h"
#include "netsurf/clipboard.h"
#include "netsurf/fetch.h"
#include "netsurf/misc.h"
@ -1107,6 +1108,7 @@ int main(int argc, char** argv)
struct netsurf_table atari_table = {
.misc = &atari_misc_table,
.window = &atari_window_table,
.corewindow = atari_core_window_table,
.clipboard = &atari_clipboard_table,
.download = atari_download_table,
.fetch = &atari_fetch_table,

View File

@ -36,11 +36,10 @@ struct atari_global_history_s atari_global_history;
/* Setup Atari Treeview Callbacks: */
static nserror
atari_global_history_init_phase2(struct core_window *cw,
struct core_window_callback_table *cb_t)
atari_global_history_init_phase2(struct core_window *cw)
{
NSLOG(netsurf, INFO, "cw %p", cw);
return(global_history_init(cb_t, cw));
return(global_history_init(cw));
}
static void atari_global_history_finish(struct core_window *cw)

View File

@ -47,8 +47,7 @@ const char *tree_hotlist_path;
struct atari_hotlist hl;
/* Setup Atari Treeview Callbacks: */
static nserror atari_hotlist_init_phase2(struct core_window *cw,
struct core_window_callback_table * default_callbacks);
static nserror atari_hotlist_init_phase2(struct core_window *cw);
static void atari_hotlist_finish(struct core_window *cw);
static void atari_hotlist_keypress(struct core_window *cw,
uint32_t ucs4);
@ -69,11 +68,10 @@ static struct atari_treeview_callbacks atari_hotlist_treeview_callbacks = {
.gemtk_user_func = handle_event
};
static nserror atari_hotlist_init_phase2(struct core_window *cw,
struct core_window_callback_table *cb_t)
static nserror atari_hotlist_init_phase2(struct core_window *cw)
{
NSLOG(netsurf, INFO, "cw:%p", cw);
return hotlist_manager_init(cb_t, cw);
return hotlist_manager_init(cw);
}
static void atari_hotlist_finish(struct core_window *cw)

View File

@ -531,15 +531,16 @@ atari_treeview_drag_status(struct core_window *cw, core_window_drag_status ds)
/**
* Declare Core Window Callbacks:
*/
static struct core_window_callback_table cw_t = {
static struct core_window_table cw_t = {
.invalidate = atari_treeview_invalidate_area,
.update_size = atari_treeview_update_size,
.set_extent = atari_treeview_update_size,
.set_scroll = atari_treeview_set_scroll,
.get_scroll = atari_treeview_get_scroll,
.get_window_dimensions = atari_treeview_get_window_dimensions,
.get_dimensions = atari_treeview_get_window_dimensions,
.drag_status = atari_treeview_drag_status
};
struct core_window_table *atari_core_window_table = &cw_t;
/* exported interface documented in atari/treeview.h */
struct core_window *
@ -586,7 +587,7 @@ atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks,
/* event handlers of the treeview: */
/* It would be more simple to not pass around the callbacks */
/* but the treeview constructor requires them for initialization... */
nserror err = tv->io->init_phase2((struct core_window *)tv, &cw_t);
nserror err = tv->io->init_phase2((struct core_window *)tv);
if (err != NSERROR_OK) {
free(tv);
tv = NULL;

View File

@ -22,7 +22,7 @@
#include "atari/gui.h"
#include "atari/gemtk/gemtk.h"
struct core_window_callback_table;
extern struct core_window_table *atari_core_window_table;
/**
* Default AES Window widgets for a treeview window, can be passed to
@ -50,7 +50,7 @@ struct atari_treeview_window;
*/
/** \todo atari add drag_status callback */
typedef nserror (*atari_treeview_init2_callback)(struct core_window *cw, struct core_window_callback_table * default_callbacks);
typedef nserror (*atari_treeview_init2_callback)(struct core_window *cw);
typedef void (*atari_treeview_finish_callback)(struct core_window *cw);
typedef void (*atari_treeview_keypress_callback)(struct core_window *cw, uint32_t ucs4);
typedef void (*atari_treeview_mouse_action_callback)(struct core_window *cw, browser_mouse_state mouse, int x, int y);

View File

@ -192,15 +192,17 @@ fb_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
}
struct core_window_callback_table fb_cw_cb_table = {
struct core_window_table fb_cw_cb_table = {
.invalidate = fb_cw_invalidate,
.update_size = fb_cw_update_size,
.set_extent = fb_cw_update_size,
.set_scroll = fb_cw_set_scroll,
.get_scroll = fb_cw_get_scroll,
.get_window_dimensions = fb_cw_get_window_dimensions,
.get_dimensions = fb_cw_get_window_dimensions,
.drag_status = fb_cw_drag_status
};
struct core_window_table *framebuffer_core_window_table = &fb_cw_cb_table;
/* exported function documented fb/corewindow.h */
nserror fb_corewindow_init(fbtk_widget_t *parent, struct fb_corewindow *fb_cw)
{
@ -209,7 +211,6 @@ nserror fb_corewindow_init(fbtk_widget_t *parent, struct fb_corewindow *fb_cw)
furniture_width = nsoption_int(fb_furniture_size);
/* setup the core window callback table */
fb_cw->cb_table = &fb_cw_cb_table;
fb_cw->drag_status = CORE_WINDOW_DRAG_NONE;
/* container window */

View File

@ -21,6 +21,8 @@
#include "netsurf/core_window.h"
extern struct core_window_table *framebuffer_core_window_table;
/**
* fb core window state
*/
@ -49,9 +51,6 @@ struct fb_corewindow {
/** drag status set by core */
core_window_drag_status drag_status;
/** table of callbacks for core window operations */
struct core_window_callback_table *cb_table;
/**
* callback to draw on drawable area of fb core window
*

View File

@ -55,6 +55,7 @@
#include "framebuffer/fetch.h"
#include "framebuffer/bitmap.h"
#include "framebuffer/local_history.h"
#include "framebuffer/corewindow.h"
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
@ -2188,6 +2189,7 @@ main(int argc, char** argv)
struct netsurf_table framebuffer_table = {
.misc = &framebuffer_misc_table,
.window = &framebuffer_window_table,
.corewindow = framebuffer_core_window_table,
.clipboard = framebuffer_clipboard_table,
.fetch = framebuffer_fetch_table,
.utf8 = framebuffer_utf8_table,

View File

@ -160,8 +160,7 @@ fb_local_history_init(fbtk_widget_t *parent,
return res;
}
res = local_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin,
res = local_history_init((struct core_window *)ncwin,
bw,
&ncwin->session);
if (res != NSERROR_OK) {

View File

@ -292,8 +292,7 @@ static nserror nsgtk_cookies_init(void)
return res;
}
res = cookie_manager_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = cookie_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -718,20 +718,20 @@ nsgtk_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
/**
* core window callback table for nsgtk
*/
static struct core_window_callback_table nsgtk_cw_cb_table = {
static struct core_window_table nsgtk_cw_cb_table = {
.invalidate = nsgtk_cw_invalidate_area,
.update_size = nsgtk_cw_update_size,
.set_extent = nsgtk_cw_update_size,
.set_scroll = nsgtk_cw_set_scroll,
.get_scroll = nsgtk_cw_get_scroll,
.get_window_dimensions = nsgtk_cw_get_window_dimensions,
.get_dimensions = nsgtk_cw_get_window_dimensions,
.drag_status = nsgtk_cw_drag_status
};
struct core_window_table *nsgtk_core_window_table = &nsgtk_cw_cb_table;
/* exported function documented gtk/corewindow.h */
nserror nsgtk_corewindow_init(struct nsgtk_corewindow *nsgtk_cw)
{
nsgtk_cw->cb_table = &nsgtk_cw_cb_table;
nsgtk_cw->drag_status = CORE_WINDOW_DRAG_NONE;
/* input method setup */

View File

@ -21,6 +21,8 @@
#include "netsurf/core_window.h"
extern struct core_window_table *nsgtk_core_window_table;
/**
* nsgtk core window mouse state
*/
@ -46,10 +48,10 @@ struct nsgtk_corewindow {
/* private variables */
/** Input method */
GtkIMContext *input_method;
/** table of callbacks for core window operations */
struct core_window_callback_table *cb_table;
/** mouse state */
struct nsgtk_corewindow_mouse mouse_state;
/** drag status set by core */
core_window_drag_status drag_status;

View File

@ -349,8 +349,7 @@ static nserror nsgtk_global_history_init(void)
return res;
}
res = global_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = global_history_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -65,6 +65,7 @@
#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/corewindow.h"
#include "gtk/schedule.h"
#include "gtk/selection.h"
#include "gtk/search.h"
@ -1184,6 +1185,7 @@ int main(int argc, char** argv)
struct netsurf_table nsgtk_table = {
.misc = nsgtk_misc_table,
.window = nsgtk_window_table,
.corewindow = nsgtk_core_window_table,
.clipboard = nsgtk_clipboard_table,
.download = nsgtk_download_table,
.fetch = nsgtk_fetch_table,

View File

@ -363,8 +363,7 @@ static nserror nsgtk_hotlist_init(void)
return res;
}
res = hotlist_manager_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = hotlist_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -199,8 +199,7 @@ nsgtk_local_history_init(struct browser_window *bw,
return res;
}
res = local_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin,
res = local_history_init((struct core_window *)ncwin,
bw,
&ncwin->session);
if (res != NSERROR_OK) {

View File

@ -232,9 +232,7 @@ nserror nsgtk_page_info(struct browser_window *bw)
return res;
}
res = page_info_create(ncwin->core.cb_table,
(struct core_window *)ncwin,
bw, &ncwin->pi);
res = page_info_create((struct core_window *)ncwin, bw, &ncwin->pi);
if (res != NSERROR_OK) {
g_object_unref(G_OBJECT(ncwin->dlg));
free(ncwin);

View File

@ -414,8 +414,7 @@ static nserror ro_cookie_init(void)
return res;
}
res = cookie_manager_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = cookie_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -962,15 +962,17 @@ ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
}
struct core_window_callback_table ro_cw_cb_table = {
struct core_window_table ro_cw_cb_table = {
.invalidate = ro_cw_invalidate,
.update_size = ro_cw_update_size,
.set_extent = ro_cw_update_size,
.set_scroll = ro_cw_set_scroll,
.get_scroll = ro_cw_get_scroll,
.get_window_dimensions = ro_cw_get_window_dimensions,
.get_dimensions = ro_cw_get_window_dimensions,
.drag_status = ro_cw_drag_status
};
struct core_window_table *riscos_core_window_table = &ro_cw_cb_table;
/**
* dummy toolbar click callback
*
@ -1004,9 +1006,6 @@ ro_corewindow_init(struct ro_corewindow *ro_cw,
theme_style tb_style,
const char *tb_help)
{
/* setup the core window callback table */
ro_cw->cb_table = &ro_cw_cb_table;
/* start with the content area being as small as possible */
ro_cw->content_width = -1;
ro_cw->content_height = -1;

View File

@ -31,6 +31,8 @@
#include "netsurf/core_window.h"
extern struct core_window_table *riscos_core_window_table;
/**
* ro core window state
*/
@ -53,9 +55,6 @@ struct ro_corewindow {
/** drag status set by core */
core_window_drag_status drag_status;
/** table of callbacks for core window operations */
struct core_window_callback_table *cb_table;
/**
* callback to draw on drawable area of ro core window
*

View File

@ -447,8 +447,7 @@ static nserror ro_global_history_init(void)
NSLOG(netsurf, INFO, "Created global history corewindow: %p",
&ncwin->core);
res = global_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = global_history_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -72,6 +72,8 @@
#include "riscos/help.h"
#include "riscos/query.h"
#include "riscos/window.h"
#include "riscos/toolbar.h"
#include "riscos/corewindow.h"
#include "riscos/iconbar.h"
#include "riscos/local_history.h"
#include "riscos/global_history.h"
@ -84,7 +86,6 @@
#include "riscos/ucstables.h"
#include "riscos/filetype.h"
#include "riscos/font.h"
#include "riscos/toolbar.h"
#include "riscos/content-handlers/artworks.h"
#include "riscos/content-handlers/draw.h"
#include "riscos/content-handlers/sprite.h"
@ -2433,6 +2434,7 @@ int main(int argc, char** argv)
struct netsurf_table riscos_table = {
.misc = &riscos_misc_table,
.window = riscos_window_table,
.corewindow = riscos_core_window_table,
.clipboard = riscos_clipboard_table,
.download = riscos_download_table,
.fetch = &riscos_fetch_table,

View File

@ -504,8 +504,7 @@ static nserror ro_hotlist_init(void)
return res;
}
res = hotlist_manager_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = hotlist_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -333,8 +333,7 @@ ro_local_history_init(struct browser_window *bw,
return res;
}
res = local_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin,
res = local_history_init((struct core_window *)ncwin,
bw,
&ncwin->session);
if (res != NSERROR_OK) {

View File

@ -197,10 +197,9 @@ ro_pageinfo_init(struct browser_window *bw,
return res;
}
res = page_info_create(ncwin->core.cb_table,
(struct core_window *)ncwin,
bw,
&ncwin->pgi);
res = page_info_create((struct core_window *)ncwin,
bw,
&ncwin->pgi);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -154,8 +154,7 @@ static nserror nsw32_cookie_init(HINSTANCE hInstance)
return res;
}
res = cookie_manager_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = cookie_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -503,15 +503,17 @@ nsw32_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
}
struct core_window_callback_table nsw32_cw_cb_table = {
struct core_window_table nsw32_cw_cb_table = {
.invalidate = nsw32_cw_invalidate_area,
.update_size = nsw32_cw_update_size,
.set_extent = nsw32_cw_update_size,
.set_scroll = nsw32_cw_set_scroll,
.get_scroll = nsw32_cw_get_scroll,
.get_window_dimensions = nsw32_cw_get_window_dimensions,
.get_dimensions = nsw32_cw_get_window_dimensions,
.drag_status = nsw32_cw_drag_status
};
struct core_window_table *win32_core_window_table = &nsw32_cw_cb_table;
/* exported function documented nsw32/corewindow.h */
nserror
nsw32_corewindow_init(HINSTANCE hInstance,
@ -521,7 +523,6 @@ nsw32_corewindow_init(HINSTANCE hInstance,
DWORD dwStyle;
/* setup the core window callback table */
nsw32_cw->cb_table = &nsw32_cw_cb_table;
nsw32_cw->drag_status = CORE_WINDOW_DRAG_NONE;
/* start with the content area being as small as possible */

View File

@ -21,6 +21,8 @@
#include "netsurf/core_window.h"
extern struct core_window_table *win32_core_window_table;
/**
* nsw32 core window state
*/
@ -39,9 +41,6 @@ struct nsw32_corewindow {
/** drag status set by core */
core_window_drag_status drag_status;
/** table of callbacks for core window operations */
struct core_window_callback_table *cb_table;
/**
* callback to draw on drawable area of nsw32 core window

View File

@ -143,8 +143,7 @@ static nserror nsw32_global_history_init(HINSTANCE hInstance)
return res;
}
res = global_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = global_history_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -147,8 +147,7 @@ static nserror nsw32_hotlist_init(HINSTANCE hInstance)
return res;
}
res = hotlist_manager_init(ncwin->core.cb_table,
(struct core_window *)ncwin);
res = hotlist_manager_init((struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;

View File

@ -160,8 +160,7 @@ nsw32_local_history_init(HINSTANCE hInstance,
return res;
}
res = local_history_init(ncwin->core.cb_table,
(struct core_window *)ncwin,
res = local_history_init((struct core_window *)ncwin,
bw,
&ncwin->session);
if (res != NSERROR_OK) {

View File

@ -390,6 +390,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
struct netsurf_table win32_table = {
.misc = &win32_misc_table,
.window = win32_window_table,
.corewindow = win32_core_window_table,
.clipboard = win32_clipboard_table,
.download = win32_download_table,
.fetch = win32_fetch_table,

View File

@ -46,9 +46,11 @@ typedef enum {
} core_window_drag_status;
/**
* Callbacks to achieve various core window functionality.
* Core user interface window function table.
*
* function table implementing core window operations
*/
struct core_window_callback_table {
struct core_window_table {
/**
* Invalidate an area of a window.
*
@ -69,14 +71,14 @@ struct core_window_callback_table {
nserror (*invalidate)(struct core_window *cw, const struct rect *rect);
/**
* Update the limits of the window
* Update the logical extent of the window
*
* \param[in] cw the core window object
* \param[in] width the width in px, or negative if don't care
* \param[in] height the height in px, or negative if don't care
* \return NSERROR_OK on success or appropriate error code
*/
nserror (*update_size)(struct core_window *cw, int width, int height);
nserror (*set_extent)(struct core_window *cw, int width, int height);
/**
* Scroll the window to given scroll offsets
@ -110,7 +112,7 @@ struct core_window_callback_table {
* \param[out] height to be set to viewport height in px
* \return NSERROR_OK on success or appropriate error code
*/
nserror (*get_window_dimensions)(const struct core_window *cw,
nserror (*get_dimensions)(const struct core_window *cw,
int *width, int *height);
/**