From c5a07fac76313c2d2d6348dee20d881a639c40c8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 10 May 2019 20:32:40 +0100 Subject: Replace global current gui_window with an accessor function --- frontends/amiga/arexx.c | 20 ++++++++++---------- frontends/amiga/gui.c | 7 ++++++- frontends/amiga/gui.h | 9 +++++++-- frontends/amiga/gui_options.c | 4 ++-- frontends/amiga/misc.c | 1 + 5 files changed, 26 insertions(+), 15 deletions(-) (limited to 'frontends') diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c index 24da3e7e5..679890234 100644 --- a/frontends/amiga/arexx.c +++ b/frontends/amiga/arexx.c @@ -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; diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index fec9ed35f..4374521c1 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -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); diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h index 0ce50112e..caa21c339 100644 --- a/frontends/amiga/gui.h +++ b/frontends/amiga/gui.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2017 Chris Young + * Copyright 2008-2019 Chris Young * * 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 */ diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c index 9b6cc8d20..d35c42b51 100755 --- a/frontends/amiga/gui_options.c +++ b/frontends/amiga/gui_options.c @@ -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: diff --git a/frontends/amiga/misc.c b/frontends/amiga/misc.c index 9bd8bfe60..63add6413 100755 --- a/frontends/amiga/misc.c +++ b/frontends/amiga/misc.c @@ -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__ -- cgit v1.2.3