Replace global current gui_window with an accessor function

This commit is contained in:
Chris Young 2019-05-10 20:32:40 +01:00
parent 8f9d434b12
commit c5a07fac76
5 changed files with 26 additions and 15 deletions

View File

@ -260,7 +260,7 @@ static struct gui_window *ami_find_tab(int window, int tab)
RXHOOKF(rx_open)
{
struct dlnode *dln;
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
nsurl *url;
cmd->ac_RC = 0;
@ -346,7 +346,7 @@ RXHOOKF(rx_open)
RXHOOKF(rx_save)
{
BPTR fh = 0;
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;
@ -388,7 +388,7 @@ RXHOOKF(rx_tofront)
RXHOOKF(rx_geturl)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;
@ -409,7 +409,7 @@ RXHOOKF(rx_geturl)
RXHOOKF(rx_gettitle)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;
@ -515,7 +515,7 @@ RXHOOKF(rx_pubscreen)
RXHOOKF(rx_back)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;
@ -527,7 +527,7 @@ RXHOOKF(rx_back)
RXHOOKF(rx_forward)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;
@ -540,7 +540,7 @@ RXHOOKF(rx_forward)
RXHOOKF(rx_home)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
nsurl *url;
cmd->ac_RC = 0;
@ -566,7 +566,7 @@ RXHOOKF(rx_home)
RXHOOKF(rx_reload)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;
@ -604,7 +604,7 @@ RXHOOKF(rx_windows)
RXHOOKF(rx_active)
{
int window = 0, tab = 0;
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
struct nsObject *node, *nnode;
struct gui_window_2 *gwin = NULL;
@ -646,7 +646,7 @@ RXHOOKF(rx_active)
RXHOOKF(rx_close)
{
struct gui_window *gw = cur_gw;
struct gui_window *gw = ami_gui_get_active_gw();
cmd->ac_RC = 0;

View File

@ -313,7 +313,7 @@ struct ami_gui_tb_userdata {
struct MinList *window_list = NULL;
struct Screen *scrn = NULL;
struct MsgPort *sport = NULL;
struct gui_window *cur_gw = NULL;
static struct gui_window *cur_gw = NULL;
static bool ami_quit = false;
@ -377,6 +377,11 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
nsoptions_default[NSOPTION_##OPTION].value.i = VALUE
/* Functions documented in gui.h */
struct gui_window *ami_gui_get_active_gw(void)
{
return cur_gw;
}
struct browser_window *ami_gui_get_browser_window(struct gui_window *gw)
{
assert(gw != NULL);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008-2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
* Copyright 2008-2019 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -79,7 +79,6 @@ struct ami_generic_window {
extern struct MinList *window_list; /**\todo stop arexx.c poking about in here */
extern struct Screen *scrn;
extern struct MsgPort *sport;
extern struct gui_window *cur_gw;
#define IS_CURRENT_GW(GWIN,GW) (ami_gui2_get_gui_window(GWIN) == GW)
@ -183,6 +182,12 @@ bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
*/
void ami_gui_adjust_scale(struct gui_window *gw, float adjustment);
/**
* Get a pointer to the gui_window which NetSurf considers
* to be the current/active one
*/
struct gui_window *ami_gui_get_active_gw(void);
/**
* Get browser window from gui_window
*/

View File

@ -2141,9 +2141,9 @@ static BOOL ami_gui_opts_event(void *w)
break;
case GID_OPTS_HOMEPAGE_CURRENT:
if(cur_gw) RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_HOMEPAGE],
if(ami_gui_get_active_gw()) RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_HOMEPAGE],
gow->win, NULL, STRINGA_TextVal,
nsurl_access(browser_window_access_url(ami_gui_get_browser_window(cur_gw))), TAG_DONE);
nsurl_access(browser_window_access_url(ami_gui_get_browser_window(ami_gui_get_active_gw()))), TAG_DONE);
break;
case GID_OPTS_HOMEPAGE_BLANK:

View File

@ -45,6 +45,7 @@
static LONG ami_misc_req(const char *message, uint32 type)
{
LONG ret = 0;
struct gui_window *cur_gw = ami_gui_get_active_gw();
NSLOG(netsurf, INFO, "%s", message);
#ifdef __amigaos4__