From 97010ecef521de524846734e093db89a18f81f62 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 10 May 2019 20:59:30 +0100 Subject: Make screen pointer accesible through an accessor function only --- frontends/amiga/arexx.c | 2 +- frontends/amiga/bitmap.c | 1 + frontends/amiga/clipboard.c | 4 ++-- frontends/amiga/cookies.c | 2 +- frontends/amiga/corewindow.c | 1 + frontends/amiga/ctxmenu.c | 2 +- frontends/amiga/download.c | 8 ++++---- frontends/amiga/drag.c | 5 ++++- frontends/amiga/file.c | 4 ++-- frontends/amiga/font_scan.c | 2 +- frontends/amiga/gui.c | 12 +++++++++++- frontends/amiga/gui.h | 13 ++++++++++++- frontends/amiga/gui_menu.c | 2 +- frontends/amiga/gui_options.c | 6 +++--- frontends/amiga/history.c | 6 +++--- frontends/amiga/history_local.c | 2 +- frontends/amiga/hotlist.c | 6 +++--- frontends/amiga/login.c | 2 +- frontends/amiga/menu.c | 3 ++- frontends/amiga/plotters.c | 8 +++++++- frontends/amiga/print.c | 4 ++-- frontends/amiga/search.c | 2 +- frontends/amiga/sslcert.c | 1 + 23 files changed, 66 insertions(+), 32 deletions(-) diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c index 679890234..7497ff9ba 100644 --- a/frontends/amiga/arexx.c +++ b/frontends/amiga/arexx.c @@ -383,7 +383,7 @@ RXHOOKF(rx_quit) RXHOOKF(rx_tofront) { cmd->ac_RC = 0; - ScreenToFront(scrn); + ScreenToFront(ami_gui_get_screen()); } RXHOOKF(rx_geturl) diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c index 8341d41c8..6ad1610cf 100644 --- a/frontends/amiga/bitmap.c +++ b/frontends/amiga/bitmap.c @@ -490,6 +490,7 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int width, int height, struct BitMap *restrict friendbm, int type) { struct BitMap *restrict tbm = NULL; + struct Screen *scrn = ami_gui_get_screen(); if(bitmap->nativebm) { diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c index 731492bb3..00dba2d50 100644 --- a/frontends/amiga/clipboard.c +++ b/frontends/amiga/clipboard.c @@ -276,7 +276,7 @@ void ami_drag_selection(struct gui_window *g) if(!gwin) { - DisplayBeep(scrn); + ami_gui_beep(); return; } @@ -323,7 +323,7 @@ void ami_drag_selection(struct gui_window *g) } else { - DisplayBeep(scrn); + ami_gui_beep(); } } } diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c index 45e883fde..a0761e4ca 100644 --- a/frontends/amiga/cookies.c +++ b/frontends/amiga/cookies.c @@ -310,7 +310,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win) WA_Left, nsoption_int(cookies_window_xpos), WA_Width, nsoption_int(cookies_window_xsize), WA_Height, nsoption_int(cookies_window_ysize), - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c index 627d3286e..7ab6e8e14 100644 --- a/frontends/amiga/corewindow.c +++ b/frontends/amiga/corewindow.c @@ -587,6 +587,7 @@ static void ami_cw_drag_end(struct ami_corewindow *ami_cw, int x, int y) { if(ami_cw->dragging == false) return; + struct Screen *scrn = ami_gui_get_screen(); switch(ami_cw->drag_status) { case CORE_WINDOW_DRAG_SELECTION: diff --git a/frontends/amiga/ctxmenu.c b/frontends/amiga/ctxmenu.c index 92f399fe6..42826a3a5 100644 --- a/frontends/amiga/ctxmenu.c +++ b/frontends/amiga/ctxmenu.c @@ -402,7 +402,7 @@ static void ami_ctxmenu_alloc_item(int id, const char *label, const char *key, c if(image != NULL) { ctxmenu_item_image[id] = BitMapObj, - BITMAP_Screen, scrn, + BITMAP_Screen, ami_gui_get_screen(), BITMAP_SourceFile, image, BITMAP_Masking, TRUE, BitMapEnd; diff --git a/frontends/amiga/download.c b/frontends/amiga/download.c index ed7a166d7..c5365db0a 100644 --- a/frontends/amiga/download.c +++ b/frontends/amiga/download.c @@ -144,7 +144,7 @@ static struct gui_download_window *gui_download_window_create(download_context * ASLFR_Window, ami_gui_get_window(gui), ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, dl_filename, TAG_DONE)) { @@ -199,7 +199,7 @@ static struct gui_download_window *gui_download_window_create(download_context * WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen,scrn, + WA_PubScreen, ami_gui_get_screen(), WINDOW_SharedPort,sport, WINDOW_UserData,dw, WINDOW_IconifyGadget, FALSE, @@ -437,8 +437,8 @@ gui_window_save_link(struct gui_window *g, nsurl *url, const char *title) ASLFR_Window, ami_gui_get_window(g), ASLFR_SleepWindow, TRUE, ASLFR_TitleText,messages_get("NetSurf"), - ASLFR_Screen,scrn, - ASLFR_InitialFile,linkname, + ASLFR_Screen, ami_gui_get_screen(), + ASLFR_InitialFile, linkname, TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); diff --git a/frontends/amiga/drag.c b/frontends/amiga/drag.c index 049542770..ee831f43d 100644 --- a/frontends/amiga/drag.c +++ b/frontends/amiga/drag.c @@ -109,6 +109,7 @@ void ami_drag_save(struct Window *win) { ULONG which = WBO_NONE, type; char path[1025], dpath[1025]; + struct Screen *scrn = ami_gui_get_screen(); path[0] = 0; /* ensure path is terminated */ @@ -204,7 +205,7 @@ void ami_drag_icon_show(struct Window *win, const char *type) struct DiskObject *dobj = NULL; ULONG width, height; int deftype = WBPROJECT; - + struct Screen *scrn = ami_gui_get_screen(); drag_in_progress = TRUE; if(nsoption_bool(drag_save_icons) == false) @@ -255,6 +256,7 @@ void ami_drag_icon_show(struct Window *win, const char *type) bool ami_drag_icon_move(void) { if(drag_icon == NULL) return FALSE; + struct Screen *scrn = ami_gui_get_screen(); ChangeWindowBox(drag_icon, scrn->MouseX - (drag_icon_width / 2), scrn->MouseY - (drag_icon_height / 2), @@ -314,6 +316,7 @@ static void *ami_find_gwin_by_id(struct Window *win, uint32 type) void *ami_window_at_pointer(int type) { struct Layer *layer; + struct Screen *scrn = ami_gui_get_screen(); LockLayerInfo(&scrn->LayerInfo); diff --git a/frontends/amiga/file.c b/frontends/amiga/file.c index 1d74d6ff8..67866aa48 100644 --- a/frontends/amiga/file.c +++ b/frontends/amiga/file.c @@ -86,7 +86,7 @@ void ami_file_open(struct gui_window_2 *gwin) ASLFR_TitleText, messages_get("NetSurf"), ASLFR_Window, ami_gui2_get_window(gwin), ASLFR_SleepWindow, TRUE, - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_DoSaveMode, FALSE, ASLFR_RejectIcons, TRUE, ASLFR_FilterFunc, &aslhookfunc, @@ -260,7 +260,7 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin, ASLFR_Window, ami_gui2_get_window(gwin), ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, fname_with_ext ? fname_with_ext : "", TAG_DONE)) { diff --git a/frontends/amiga/font_scan.c b/frontends/amiga/font_scan.c index cb37f97fa..3fa71f737 100644 --- a/frontends/amiga/font_scan.c +++ b/frontends/amiga/font_scan.c @@ -114,7 +114,7 @@ static struct ami_font_scan_window *ami_font_scan_gui_open(int32 fonts) WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_BusyPointer, TRUE, WA_Width, 400, WINDOW_UserData, fsw, diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 4374521c1..6e60e6d9b 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -311,7 +311,7 @@ struct ami_gui_tb_userdata { }; struct MinList *window_list = NULL; -struct Screen *scrn = NULL; +static struct Screen *scrn = NULL; struct MsgPort *sport = NULL; static struct gui_window *cur_gw = NULL; @@ -382,6 +382,16 @@ struct gui_window *ami_gui_get_active_gw(void) return cur_gw; } +struct Screen *ami_gui_get_screen(void) +{ + return scrn; +} + +void ami_gui_beep(void) +{ + DisplayBeep(scrn); +} + 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 caa21c339..c4af98f93 100644 --- a/frontends/amiga/gui.h +++ b/frontends/amiga/gui.h @@ -77,7 +77,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; #define IS_CURRENT_GW(GWIN,GW) (ami_gui2_get_gui_window(GWIN) == GW) @@ -107,6 +106,11 @@ void ami_gui_set_scale(struct gui_window *gw, float scale); void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update); void ami_reset_pointer(struct gui_window_2 *gwin); +/** + * Beep + */ +void ami_gui_beep(void); + /** * Close a window and all tabs attached to it. * @@ -144,6 +148,13 @@ void ami_gui_free_space_box(struct IBox *bbox); */ uint32 ami_gui_get_app_id(void); +/** + * Get a pointer to the screen NetSurf is running on. + * + * @return Pointer to struct Screen. + */ +struct Screen *ami_gui_get_screen(void); + /** * Get the string for NetSurf's screen titlebar. * diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c index 7eda6bc15..64dd7fbc7 100644 --- a/frontends/amiga/gui_menu.c +++ b/frontends/amiga/gui_menu.c @@ -476,7 +476,7 @@ HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *) ASLFR_Window, ami_gui2_get_window(gwin), ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_DoSaveMode, FALSE, ASLFR_InitialDrawer, nsoption_charp(arexx_dir), ASLFR_InitialPattern, "#?.nsrx", diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c index d35c42b51..c731598e9 100755 --- a/frontends/amiga/gui_options.c +++ b/frontends/amiga/gui_options.c @@ -657,7 +657,7 @@ void ami_gui_opts_open(void) WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, FALSE, - WA_PubScreen,scrn, + WA_PubScreen, ami_gui_get_screen(), WINDOW_SharedPort,sport, WINDOW_UserData,gow, WINDOW_IconifyGadget, FALSE, @@ -2109,10 +2109,10 @@ static BOOL ami_gui_opts_event(void *w) case WMHI_GADGETHELP: if((result & WMHI_GADGETMASK) == 0) { /* Pointer not over our window */ - ami_help_open(AMI_HELP_MAIN, scrn); + ami_help_open(AMI_HELP_MAIN, ami_gui_get_screen()); } else { /* TODO: Make this sensitive to the tab the user is currently on */ - ami_help_open(AMI_HELP_PREFS, scrn); + ami_help_open(AMI_HELP_PREFS, ami_gui_get_screen()); } break; diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c index 2cd2f8466..a505101ae 100644 --- a/frontends/amiga/history.c +++ b/frontends/amiga/history.c @@ -200,7 +200,7 @@ ami_history_global_drag_end(struct ami_corewindow *ami_cw, int x, int y) } if((ok == false) || (url == NULL)) { - DisplayBeep(scrn); + DisplayBeep(ami_gui_get_screen()); } else if(url) { if((gwin = ami_window_at_pointer(AMINS_WINDOW))) { browser_window_navigate(ami_gui2_get_browser_window(gwin), @@ -233,7 +233,7 @@ HOOKF(void, ami_history_global_menu_item_project_export, APTR, window, struct In ASLFR_Window, ami_cw->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, "history.html", TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); @@ -384,7 +384,7 @@ ami_history_global_create_window(struct ami_history_global_window *history_win) WA_Left, nsoption_int(history_window_xpos), WA_Width, nsoption_int(history_window_xsize), WA_Height, nsoption_int(history_window_ysize), - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c index 95f422daa..f8a881693 100644 --- a/frontends/amiga/history_local.c +++ b/frontends/amiga/history_local.c @@ -209,7 +209,7 @@ ami_history_local_create_window(struct ami_history_local_window *history_local_w WA_SizeBRight, TRUE, WA_Width, 100, WA_Height, 100, - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c index e8cf3a14c..f8df8c823 100644 --- a/frontends/amiga/hotlist.c +++ b/frontends/amiga/hotlist.c @@ -251,7 +251,7 @@ ami_hotlist_drag_end(struct ami_corewindow *ami_cw, int x, int y) } if((ok == false) || (url == NULL)) { - DisplayBeep(scrn); + ami_gui_beep(); } else if(url) { if((gwin = ami_window_at_pointer(AMINS_WINDOW))) { browser_window_navigate(ami_gui2_get_browser_window(gwin), @@ -313,7 +313,7 @@ HOOKF(void, ami_hotlist_menu_item_project_export, APTR, window, struct IntuiMess ASLFR_Window, ami_cw->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), - ASLFR_Screen, scrn, + ASLFR_Screen, ami_gui_get_screen(), ASLFR_InitialFile, "hotlist.html", TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); @@ -487,7 +487,7 @@ ami_hotlist_create_window(struct ami_hotlist_window *hotlist_win) WA_Left, nsoption_int(hotlist_window_xpos), WA_Width, nsoption_int(hotlist_window_xsize), WA_Height, nsoption_int(hotlist_window_ysize), - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WA_ReportMouse, TRUE, refresh_mode, TRUE, WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | diff --git a/frontends/amiga/login.c b/frontends/amiga/login.c index 0948caaaa..6c0c1cd19 100755 --- a/frontends/amiga/login.c +++ b/frontends/amiga/login.c @@ -146,7 +146,7 @@ nserror gui_401login_open(nsurl *url, const char *realm, WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen,scrn, + WA_PubScreen, ami_gui_get_screen(), WINDOW_SharedPort,sport, WINDOW_UserData,lw, WINDOW_IconifyGadget, FALSE, diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c index 1f3f981ea..85b2ec43f 100644 --- a/frontends/amiga/menu.c +++ b/frontends/amiga/menu.c @@ -251,7 +251,7 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat MA_Image, BitMapObj, IA_Scalable, TRUE, - BITMAP_Screen, scrn, + BITMAP_Screen, ami_gui_get_screen(), BITMAP_SourceFile, md[j]->menuicon, BITMAP_Masking, TRUE, BitMapEnd, @@ -298,6 +298,7 @@ static struct Menu *ami_menu_layout_gt(struct ami_menu_data **md, int max) struct NewMenu *nm; struct Menu *imenu = NULL; struct VisualInfo *vi; + struct Screen *scrn = ami_gui_get_screen(); struct RastPort *rp = &scrn->RastPort; struct DrawInfo *dri = GetScreenDrawInfo(scrn); int space_width = TextLength(rp, " ", 1); diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c index 2e9f5cb2b..b6add47cb 100644 --- a/frontends/amiga/plotters.c +++ b/frontends/amiga/plotters.c @@ -115,6 +115,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit /* init shared bitmaps */ int depth = 32; struct BitMap *friend = NULL; + struct Screen *scrn = ami_gui_get_screen(); struct gui_globals *gg = malloc(sizeof(struct gui_globals)); @@ -295,6 +296,7 @@ void ami_plot_ra_set_pen_list(struct gui_globals *gg, struct MinList *pen_list) void ami_clearclipreg(struct gui_globals *gg) { struct Region *reg = NULL; + struct Screen *scrn = ami_gui_get_screen(); reg = InstallClipRegion(gg->rp->Layer,NULL); if(reg) DisposeRegion(reg); @@ -313,6 +315,8 @@ void ami_clearclipreg(struct gui_globals *gg) static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr) { struct ami_plot_pen *node; + struct Screen *scrn = ami_gui_get_screen(); + LONG pen = ObtainBestPenA(scrn->ViewPort.ColorMap, (colr & 0x000000ff) << 24, (colr & 0x0000ff00) << 16, @@ -336,6 +340,7 @@ static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr) void ami_plot_release_pens(struct MinList *shared_pens) { + struct Screen *scrn = ami_gui_get_screen(); struct ami_plot_pen *node; struct ami_plot_pen *nnode; @@ -429,7 +434,7 @@ static nserror ami_bitmap(struct gui_globals *glob, int x, int y, int width, int height, struct bitmap *bitmap) { NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_bitmap()"); - + struct Screen *scrn = ami_gui_get_screen(); struct BitMap *tbm; if (!width || !height) { @@ -519,6 +524,7 @@ HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage { int xf,yf; struct bfbitmap *bfbm = (struct bfbitmap *)hook->h_Data; + struct Screen *scrn = ami_gui_get_screen(); /* tile down and across to extents (msg->Bounds.MinX)*/ for (xf = -bfbm->offsetx; xf < msg->Bounds.MaxX; xf += bfbm->width) { diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c index 05f068b45..e0b52548f 100644 --- a/frontends/amiga/print.c +++ b/frontends/amiga/print.c @@ -276,7 +276,7 @@ void ami_print_ui(struct hlcache_handle *c) WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, FALSE, - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WINDOW_SharedPort, sport, WINDOW_UserData, pw, WINDOW_IconifyGadget, FALSE, @@ -565,7 +565,7 @@ void ami_print_progress(void) WA_DragBar, TRUE, WA_CloseGadget, FALSE, WA_SizeGadget, TRUE, - WA_PubScreen,scrn, + WA_PubScreen, ami_gui_get_screen(), //WINDOW_SharedPort,sport, WINDOW_UserData, &ami_print_info, WINDOW_IconifyGadget, FALSE, diff --git a/frontends/amiga/search.c b/frontends/amiga/search.c index aad8e4c2a..e46c9dfdb 100755 --- a/frontends/amiga/search.c +++ b/frontends/amiga/search.c @@ -169,7 +169,7 @@ void ami_search_open(struct gui_window *gwin) WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, TRUE, - WA_PubScreen, scrn, + WA_PubScreen, ami_gui_get_screen(), WINDOW_SharedPort, sport, WINDOW_UserData, fwin, WINDOW_IconifyGadget, FALSE, diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c index 136b918fc..92b06a17a 100644 --- a/frontends/amiga/sslcert.c +++ b/frontends/amiga/sslcert.c @@ -218,6 +218,7 @@ ami_crtvrfy_create_window(struct ami_crtvrfy_window *crtvrfy_win) { struct ami_corewindow *ami_cw = (struct ami_corewindow *)&crtvrfy_win->core; ULONG refresh_mode = WA_SmartRefresh; + struct Screen *scrn = ami_gui_get_screen(); if(nsoption_bool(window_simple_refresh) == true) { refresh_mode = WA_SimpleRefresh; -- cgit v1.2.3