NetSurf
gui.c
Go to the documentation of this file.
1/*
2 * Copyright 2008-2020 Chris Young <chris@unsatisfactorysoftware.co.uk>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20#ifdef __amigaos4__
21/* Custom StringView class */
24#endif
25
26/* AmigaOS libraries */
27#ifdef __amigaos4__
28#include <proto/application.h>
29#endif
30#include <proto/asl.h>
31#include <proto/datatypes.h>
32#include <proto/diskfont.h>
33#include <proto/dos.h>
34#include <proto/exec.h>
35#include <proto/graphics.h>
36#include <proto/icon.h>
37#include <proto/intuition.h>
38#include <proto/keymap.h>
39#include <proto/layers.h>
40#include <proto/locale.h>
41#include <proto/utility.h>
42#include <proto/wb.h>
43
44#ifdef WITH_AMISSL
45/* AmiSSL needs everything to use bsdsocket.library directly to avoid problems */
46#include <proto/bsdsocket.h>
47#define waitselect WaitSelect
48#endif
49
50/* Other OS includes */
51#include <datatypes/textclass.h>
52#include <devices/inputevent.h>
53#include <graphics/gfxbase.h>
54#include <graphics/rpattr.h>
55#ifdef __amigaos4__
56#include <diskfont/diskfonttag.h>
57#include <graphics/blitattr.h>
58#include <intuition/gui.h>
59#include <libraries/application.h>
60#include <libraries/keymap.h>
61#endif
62#include <intuition/icclass.h>
63#include <intuition/screens.h>
64#include <libraries/gadtools.h>
65#include <workbench/workbench.h>
66
67/* ReAction libraries */
68#include <proto/bevel.h>
69#include <proto/bitmap.h>
70#include <proto/button.h>
71#include <proto/chooser.h>
72#include <proto/clicktab.h>
73#include <proto/label.h>
74#include <proto/layout.h>
75#include <proto/listbrowser.h>
76#include <proto/scroller.h>
77#include <proto/space.h>
78#include <proto/speedbar.h>
79#include <proto/string.h>
80#include <proto/window.h>
81
82#include <classes/window.h>
83#include <gadgets/button.h>
84#include <gadgets/chooser.h>
85#include <gadgets/clicktab.h>
86#include <gadgets/layout.h>
87#include <gadgets/listbrowser.h>
88#include <gadgets/scroller.h>
89#include <gadgets/space.h>
90#include <gadgets/speedbar.h>
91#include <gadgets/string.h>
92#include <images/bevel.h>
93#include <images/bitmap.h>
94#include <images/label.h>
95
96#include <reaction/reaction_macros.h>
97
98/* newlib includes */
99#include <math.h>
100#include <string.h>
101#include <stdlib.h>
102#include <limits.h>
103
104/* NetSurf core includes */
105#include "utils/log.h"
106#include "utils/messages.h"
107#include "utils/nsoption.h"
108#include "utils/utf8.h"
109#include "utils/utils.h"
110#include "utils/nsurl.h"
111#include "utils/file.h"
112#include "netsurf/window.h"
113#include "netsurf/fetch.h"
114#include "netsurf/misc.h"
115#include "netsurf/mouse.h"
116#include "netsurf/netsurf.h"
117#include "netsurf/content.h"
119#include "netsurf/cookie_db.h"
120#include "netsurf/url_db.h"
121#include "netsurf/keypress.h"
123#include "content/fetch.h"
125#include "desktop/hotlist.h"
126#include "desktop/version.h"
128#include "desktop/searchweb.h"
129
130/* NetSurf Amiga platform includes */
131#include "amiga/gui.h"
132#include "amiga/arexx.h"
133#include "amiga/bitmap.h"
134#include "amiga/clipboard.h"
135#include "amiga/cookies.h"
136#include "amiga/ctxmenu.h"
137#include "amiga/datatypes.h"
138#include "amiga/download.h"
139#include "amiga/drag.h"
140#include "amiga/file.h"
141#include "amiga/filetype.h"
142#include "amiga/font.h"
143#include "amiga/gui_options.h"
144#include "amiga/help.h"
145#include "amiga/history.h"
146#include "amiga/history_local.h"
147#include "amiga/hotlist.h"
148#include "amiga/icon.h"
149#include "amiga/launch.h"
150#include "amiga/libs.h"
151#include "amiga/memory.h"
152#include "amiga/menu.h"
153#include "amiga/misc.h"
154#include "amiga/nsoption.h"
155#include "amiga/pageinfo.h"
156#include "amiga/plotters.h"
157#include "amiga/plugin_hack.h"
158#include "amiga/print.h"
159#include "amiga/schedule.h"
160#include "amiga/search.h"
161#include "amiga/selectmenu.h"
162#include "amiga/theme.h"
163#include "amiga/utf8.h"
164
165#define AMINS_SCROLLERPEN NUMDRIPENS
166#define NSA_KBD_SCROLL_PX 10
167#define NSA_MAX_HOTLIST_BUTTON_LEN 20
168
169#define SCROLL_TOP INT_MIN
170#define SCROLL_PAGE_UP (INT_MIN + 1)
171#define SCROLL_PAGE_DOWN (INT_MAX - 1)
172#define SCROLL_BOTTOM (INT_MAX)
173
174/* Extra mouse button defines to match those in intuition/intuition.h */
175#define SIDEDOWN (IECODE_4TH_BUTTON)
176#define SIDEUP (IECODE_4TH_BUTTON | IECODE_UP_PREFIX)
177#define EXTRADOWN (IECODE_5TH_BUTTON)
178#define EXTRAUP (IECODE_5TH_BUTTON | IECODE_UP_PREFIX)
179
180/* Left OR Right Shift/Alt keys */
181#define NSA_QUAL_SHIFT (IEQUALIFIER_RSHIFT | IEQUALIFIER_LSHIFT)
182#define NSA_QUAL_ALT (IEQUALIFIER_RALT | IEQUALIFIER_LALT)
183
184#ifdef __amigaos4__
185#define NSA_STATUS_TEXT GA_Text
186#else
187#define NSA_STATUS_TEXT STRINGA_TextVal
188#endif
189
190#ifdef __amigaos4__
191#define BOOL_MISMATCH(a,b) ((a == FALSE) && (b != FALSE)) || ((a != FALSE) && (b == FALSE))
192#else
193#define BOOL_MISMATCH(a,b) (1)
194#endif
195
196extern struct gui_utf8_table *amiga_utf8_table;
197
198enum
199{
244
247 struct Window *win;
248 Object *restrict objects[GID_LAST];
249 struct gui_window *gw; /* currently-displayed gui_window */
252 struct List tab_list;
253 ULONG tabs;
254 ULONG next_tab;
255 struct Node *last_new_tab;
256 struct Hook scrollerhook;
261 ULONG oldh;
262 ULONG oldv;
263 int temp;
266 struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1]; /* only for GadTools menus */
270 struct List *web_search_list;
271 Object *search_bm;
272 char *restrict svbuffer;
273 char *restrict status;
274 char *restrict wintitle;
275 char *restrict helphints[GID_LAST];
277 struct timeval lastclick;
278 struct AppIcon *appicon; /* iconify appicon */
279 struct DiskObject *dobj; /* iconify appicon */
280 struct Hook favicon_hook;
281 struct Hook throbber_hook;
282 struct Hook browser_hook;
283 struct Hook *ctxmenu_hook;
284 Object *restrict history_ctxmenu[2];
287 struct IBox *ptr_lock;
288 struct AppWindow *appwin;
289 struct MinList *shared_pens;
291 struct Menu *imenu; /* Intuition menu */
292 bool closed; /* Window has been closed (via menu) */
293};
294
296{
298 int tab;
299 struct Node *tab_node;
300 int c_x; /* Caret X posn */
301 int c_y; /* Caret Y posn */
302 int c_w; /* Caret width */
303 int c_h; /* Caret height */
308 struct List dllist;
311 char *tabtitle;
313 struct MinList *deferred_rects;
315 struct ColumnInfo *logcolumns;
316 struct List loglist;
317};
318
320 struct List *sblist;
322 int items;
323};
324
325static struct MinList *window_list = NULL;
326static struct Screen *scrn = NULL;
327static struct MsgPort *sport = NULL;
328static struct gui_window *cur_gw = NULL;
329
330static bool ami_quit = false;
331
332static struct MsgPort *schedulermsgport = NULL;
333static struct MsgPort *appport;
334#ifdef __amigaos4__
335static Class *urlStringClass;
336#endif
337
338static BOOL locked_screen = FALSE;
339static int screen_signal = -1;
340static bool win_destroyed;
341static STRPTR nsscreentitle;
342static struct gui_globals *browserglob = NULL;
343
344static struct MsgPort *applibport = NULL;
345static uint32 ami_appid = 0;
346static ULONG applibsig = 0;
347static ULONG rxsig = 0;
348static struct Hook newprefs_hook;
349
350static STRPTR temp_homepage_url = NULL;
351static bool cli_force = false;
352
353#define USERS_DIR "PROGDIR:Users"
354static char *users_dir = NULL;
355static char *current_user_dir;
357
358static const __attribute__((used)) char *stack_cookie = "\0$STACK:196608\0";
359
360const char * const versvn;
361const char * const verdate;
362
363static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw);
364static void ami_change_tab(struct gui_window_2 *gwin, int direction);
365static void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs);
366static void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys);
367static void ami_quit_netsurf_delayed(void);
368static Object *ami_gui_splash_open(void);
369static void ami_gui_splash_close(Object *win_obj);
370static bool ami_gui_map_filename(char **remapped, const char *restrict path,
371 const char *restrict file, const char *restrict map);
372static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw);
373static void ami_do_redraw(struct gui_window_2 *g);
374static void ami_schedule_redraw_remove(struct gui_window_2 *gwin);
375
376static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy);
377static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect);
378static void gui_window_remove_caret(struct gui_window *g);
379static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip);
380
381HOOKF(uint32, ami_set_favicon_render_hook, APTR, space, struct gpRender *);
382HOOKF(uint32, ami_set_throbber_render_hook, APTR, space, struct gpRender *);
383HOOKF(uint32, ami_gui_browser_render_hook, APTR, space, struct gpRender *);
384
385/* accessors for default options - user option is updated if it is set as per default */
386#define nsoption_default_set_int(OPTION, VALUE) \
387 if (nsoptions_default[NSOPTION_##OPTION].value.i == nsoptions[NSOPTION_##OPTION].value.i) \
388 nsoptions[NSOPTION_##OPTION].value.i = VALUE; \
389 nsoptions_default[NSOPTION_##OPTION].value.i = VALUE
390
391/* Functions documented in gui.h */
392struct MsgPort *ami_gui_get_shared_msgport(void)
393{
394 assert(sport != NULL);
395 return sport;
396}
397
399{
400 return cur_gw;
401}
402
403struct Screen *ami_gui_get_screen(void)
404{
405 return scrn;
406}
407
408struct MinList *ami_gui_get_window_list(void)
409{
410 assert(window_list != NULL);
411 return window_list;
412}
413
414void ami_gui_beep(void)
415{
416 DisplayBeep(scrn);
417}
418
420{
421 assert(gw != NULL);
422 return gw->bw;
423}
424
426{
427 assert(gwin != NULL);
428 return ami_gui_get_browser_window(gwin->gw);
429}
430
431struct List *ami_gui_get_download_list(struct gui_window *gw)
432{
433 assert(gw != NULL);
434 return &gw->dllist;
435}
436
438{
439 assert(gw != NULL);
440 return gw->shared;
441}
442
444{
445 assert(gwin != NULL);
446 return gwin->gw;
447}
448
449const char *ami_gui_get_win_title(struct gui_window *gw)
450{
451 assert(gw != NULL);
452 assert(gw->shared != NULL);
453 return (const char *)gw->shared->wintitle;
454}
455
456const char *ami_gui_get_tab_title(struct gui_window *gw)
457{
458 assert(gw != NULL);
459 return (const char *)gw->tabtitle;
460}
461
462struct Node *ami_gui_get_tab_node(struct gui_window *gw)
463{
464 assert(gw != NULL);
465 return gw->tab_node;
466}
467
469{
470 assert(gwin != NULL);
471 return gwin->tabs;
472}
473
474struct List *ami_gui2_get_tab_list(struct gui_window_2 *gwin)
475{
476 assert(gwin != NULL);
477 return &gwin->tab_list;
478}
479
481{
482 assert(gw != NULL);
483 return gw->favicon;
484}
485
487{
488 assert(gw != NULL);
489 return gw->hw;
490}
491
493{
494 assert(gw != NULL);
495 gw->hw = hw;
496}
497
499{
500 /* This needs to be in gui_window_2 as it is shared amongst tabs (I think),
501 * it just happens that the find code only knows of the gui_window
502 */
503 assert(gw != NULL);
504 assert(gw->shared != NULL);
505 gw->shared->searchwin = fw;
506}
507
509{
510 assert(gw != NULL);
511 return gw->throbbing;
512}
513
514void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing)
515{
516 assert(gw != NULL);
517 gw->throbbing = throbbing;
518}
519
521{
522 assert(gw != NULL);
523 assert(gw->shared != NULL);
524 return gw->shared->throbber_frame;
525}
526
528{
529 assert(gw != NULL);
530 assert(gw->shared != NULL);
531 gw->shared->throbber_frame = frame;
532}
533
534Object *ami_gui2_get_object(struct gui_window_2 *gwin, int object_type)
535{
536 ULONG obj = 0;
537
538 assert(gwin != NULL);
539
540 switch(object_type) {
541 case AMI_WIN_MAIN:
542 obj = OID_MAIN;
543 break;
544
545 case AMI_GAD_THROBBER:
546 obj = GID_THROBBER;
547 break;
548
549 case AMI_GAD_TABS:
550 obj = GID_TABS;
551 break;
552
553 case AMI_GAD_URL:
554 obj = GID_URL;
555 break;
556
557 case AMI_GAD_SEARCH:
558 obj = GID_SEARCHSTRING;
559 break;
560
561 default:
562 return NULL;
563 break;
564 }
565
566 return gwin->objects[obj];
567}
568
569
570struct Window *ami_gui2_get_window(struct gui_window_2 *gwin)
571{
572 assert(gwin != NULL);
573 return gwin->win;
574}
575
576struct Window *ami_gui_get_window(struct gui_window *gw)
577{
578 assert(gw != NULL);
579 return ami_gui2_get_window(gw->shared);
580}
581
582struct Menu *ami_gui_get_menu(struct gui_window *gw)
583{
584 assert(gw != NULL);
585 assert(gw->shared != NULL);
586 return gw->shared->imenu;
587}
588
589void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu)
590{
591 if(menu != NULL) {
592 gwin->imenu = menu;
593 } else {
595 }
596}
597
599{
600 assert(gwin != NULL);
601 return gwin->menu_data;
602}
603
605{
606 assert(gwin != NULL);
607 gwin->temp = temp;
608}
609
611{
612 assert(gwin != NULL);
613 return gwin->temp;
614}
615
616Object *ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction)
617{
618 assert(gwin != NULL);
619 return gwin->history_ctxmenu[direction];
620}
621
622void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist)
623{
624 assert(gwin != NULL);
625 gwin->history_ctxmenu[direction] = ctx_hist;
626}
627
628void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed)
629{
630 assert(gwin != NULL);
631 gwin->closed = closed;
632}
633
634void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content)
635{
636 assert(gwin != NULL);
637 gwin->new_content = new_content;
638}
639
640/** undocumented, or internal, or documented elsewhere **/
641
642#ifdef __amigaos4__
643static void *ami_find_gwin_by_id(struct Window *win, uint32 type)
644{
645 struct nsObject *node, *nnode;
646 struct gui_window_2 *gwin;
647
649 {
650 node = (struct nsObject *)GetHead((struct List *)window_list);
651
652 do
653 {
654 nnode=(struct nsObject *)GetSucc((struct Node *)node);
655
656 if(node->Type == type)
657 {
658 gwin = node->objstruct;
659 if(win == ami_gui2_get_window(gwin)) return gwin;
660 }
661 } while((node = nnode));
662 }
663 return NULL;
664}
665
667{
668 struct Layer *layer;
669 struct Screen *scrn = ami_gui_get_screen();
670
671 LockLayerInfo(&scrn->LayerInfo);
672
673 layer = WhichLayer(&scrn->LayerInfo, scrn->MouseX, scrn->MouseY);
674
675 UnlockLayerInfo(&scrn->LayerInfo);
676
677 if(layer) return ami_find_gwin_by_id(layer->Window, type);
678 else return NULL;
679}
680#else
681/**\todo check if OS4 version of this function will build on OS3, even if it isn't called */
683{
684 return NULL;
685}
686#endif
687
688void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update)
689{
690 if(gwin->mouse_pointer == shape) return;
692 if(update == true) gwin->mouse_pointer = shape;
693}
694
695/* reset the mouse pointer back to what NetSurf last set it as */
697{
699}
700
701
702STRPTR ami_locale_langs(int *codeset)
703{
704 struct Locale *locale;
705 STRPTR acceptlangs = NULL;
706 char *remapped = NULL;
707
708 if((locale = OpenLocale(NULL)))
709 {
710 if(codeset != NULL) *codeset = locale->loc_CodeSet;
711
712 for(int i = 0; i < 10; i++)
713 {
714 if(locale->loc_PrefLanguages[i])
715 {
716 if(ami_gui_map_filename(&remapped, "PROGDIR:Resources",
717 locale->loc_PrefLanguages[i], "LangNames"))
718 {
719 if(acceptlangs)
720 {
721 STRPTR acceptlangs2 = acceptlangs;
722 acceptlangs = ASPrintf("%s, %s",acceptlangs2, remapped);
723 FreeVec(acceptlangs2);
724 acceptlangs2 = NULL;
725 }
726 else
727 {
728 acceptlangs = ASPrintf("%s", remapped);
729 }
730 }
731 if(remapped != NULL) free(remapped);
732 }
733 else
734 {
735 continue;
736 }
737 }
738 CloseLocale(locale);
739 }
740 return acceptlangs;
741}
742
743static bool ami_gui_map_filename(char **remapped, const char *restrict path,
744 const char *restrict file, const char *restrict map)
745{
746 BPTR fh = 0;
747 char *mapfile = NULL;
748 size_t mapfile_size = 0;
749 char buffer[1024];
750 char *restrict realfname;
751 bool found = false;
752
753 netsurf_mkpath(&mapfile, &mapfile_size, 2, path, map);
754
755 if(mapfile == NULL) return false;
756
757 fh = FOpen(mapfile, MODE_OLDFILE, 0);
758 if(fh)
759 {
760 while(FGets(fh, buffer, 1024) != 0)
761 {
762 if((buffer[0] == '#') ||
763 (buffer[0] == '\n') ||
764 (buffer[0] == '\0')) continue;
765
766 realfname = strchr(buffer, ':');
767 if(realfname)
768 {
769 if(strncmp(buffer, file, strlen(file)) == 0)
770 {
771 if(realfname[strlen(realfname)-1] == '\n')
772 realfname[strlen(realfname)-1] = '\0';
773 *remapped = strdup(realfname + 1);
774 found = true;
775 break;
776 }
777 }
778 }
779 FClose(fh);
780 }
781
782 if(found == false) *remapped = strdup(file);
783 else NSLOG(netsurf, INFO,
784 "Remapped %s to %s in path %s using %s", file,
785 *remapped, path, map);
786
787 free(mapfile);
788
789 return found;
790}
791
792static bool ami_gui_check_resource(char *fullpath, const char *file)
793{
794 bool found = false;
795 char *remapped;
796 BPTR lock = 0;
797 size_t fullpath_len = 1024;
798
799 ami_gui_map_filename(&remapped, fullpath, file, "Resource.map");
800 netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
801
802 lock = Lock(fullpath, ACCESS_READ);
803 if(lock) {
804 UnLock(lock);
805 found = true;
806 }
807
808 if(found) NSLOG(netsurf, INFO, "Found %s", fullpath);
809 free(remapped);
810
811 return found;
812}
813
814bool ami_locate_resource(char *fullpath, const char *file)
815{
816 struct Locale *locale;
817 int i;
818 bool found = false;
819 char *remapped = NULL;
820 size_t fullpath_len = 1024;
821
822 /* Check NetSurf user data area first */
823
824 if(current_user_dir != NULL) {
825 strcpy(fullpath, current_user_dir);
826 found = ami_gui_check_resource(fullpath, file);
827 if(found) return true;
828 }
829
830 /* Check current theme directory */
831 if(nsoption_charp(theme)) {
832 strcpy(fullpath, nsoption_charp(theme));
833 found = ami_gui_check_resource(fullpath, file);
834 if(found) return true;
835 }
836
837 /* If not found, start on the user's preferred languages */
838
839 locale = OpenLocale(NULL);
840
841 for(i=0;i<10;i++) {
842 strcpy(fullpath, "PROGDIR:Resources/");
843
844 if(locale->loc_PrefLanguages[i]) {
845 if(ami_gui_map_filename(&remapped, "PROGDIR:Resources",
846 locale->loc_PrefLanguages[i], "LangNames") == true) {
847 netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
848 found = ami_gui_check_resource(fullpath, file);
849 free(remapped);
850 }
851 } else {
852 continue;
853 }
854
855 if(found) break;
856 }
857
858 if(!found) {
859 /* If not found yet, check in PROGDIR:Resources/en,
860 * might not be in user's preferred languages */
861
862 strcpy(fullpath, "PROGDIR:Resources/en/");
863 found = ami_gui_check_resource(fullpath, file);
864 }
865
866 CloseLocale(locale);
867
868 if(!found) {
869 /* Lastly check directly in PROGDIR:Resources */
870
871 strcpy(fullpath, "PROGDIR:Resources/");
872 found = ami_gui_check_resource(fullpath, file);
873 }
874
875 return found;
876}
877
878static void ami_gui_resources_free(void)
879{
882
886}
887
888static bool ami_gui_resources_open(void)
889{
890#ifdef __amigaos4__
891 urlStringClass = MakeStringClass();
892#endif
893
895 ASO_NoTrack, FALSE,
896 TAG_DONE))) return false;
897
899 ASO_NoTrack, FALSE,
900 TAG_DONE))) return false;
901
903 ASO_NoTrack, FALSE,
904 TAG_DONE))) return false;
905
907 ami_misc_fatal_error("Failed to initialise scheduler");
908 return false;
909 }
910
912
913 return true;
914}
915
916static UWORD ami_system_colour_scrollbar_fgpen(struct DrawInfo *drinfo)
917{
918 LONG scrollerfillpen = FALSE;
919#ifdef __amigaos4__
920 GetGUIAttrs(NULL, drinfo, GUIA_PropKnobColor, &scrollerfillpen, TAG_DONE);
921
922 if(scrollerfillpen) return FILLPEN;
923 else return FOREGROUNDPEN;
924#else
925 return FILLPEN;
926#endif
927
928}
929
930/**
931 * set option from pen
932 */
933static nserror
935 enum nsoption_e option,
936 struct Screen *screen,
937 colour def_colour)
938{
939 ULONG colr[3];
940 struct DrawInfo *drinfo;
941
942 if((option < NSOPTION_SYS_COLOUR_START) ||
943 (option > NSOPTION_SYS_COLOUR_END) ||
944 (nsoptions[option].type != OPTION_COLOUR)) {
946 }
947
948 if(screen != NULL) {
949 drinfo = GetScreenDrawInfo(screen);
950 if(drinfo != NULL) {
951
953
954 /* Get the colour of the pen being used for "pen" */
955 GetRGB32(screen->ViewPort.ColorMap, drinfo->dri_Pens[pen], 1, (ULONG *)&colr);
956
957 /* convert it to a color */
958 def_colour = ((colr[0] & 0xff000000) >> 24) |
959 ((colr[1] & 0xff000000) >> 16) |
960 ((colr[2] & 0xff000000) >> 8);
961
962 FreeScreenDrawInfo(screen, drinfo);
963 }
964 }
965
966 if (nsoptions_default[option].value.c == nsoptions[option].value.c)
967 nsoptions[option].value.c = def_colour;
968 nsoptions_default[option].value.c = def_colour;
969
970 return NSERROR_OK;
971}
972
973/* exported interface documented in amiga/gui.h */
975{
976 if(nsscreentitle == NULL) {
977 nsscreentitle = ASPrintf("NetSurf %s", netsurf_version);
978 /* If this fails it will be NULL, which means we'll get the screen's
979 * default titlebar text instead - so no need to check for error. */
980 }
981
982 return nsscreentitle;
983}
984
985static void ami_set_screen_defaults(struct Screen *screen)
986{
987 /* various window size/position defaults */
988 int width = screen->Width / 2;
989 int height = screen->Height / 2;
990 int top = (screen->Height / 2) - (height / 2);
991 int left = (screen->Width / 2) - (width / 2);
992
993 nsoption_default_set_int(cookies_window_ypos, top);
994 nsoption_default_set_int(cookies_window_xpos, left);
995 nsoption_default_set_int(cookies_window_xsize, width);
996 nsoption_default_set_int(cookies_window_ysize, height);
997
998 nsoption_default_set_int(history_window_ypos, top);
999 nsoption_default_set_int(history_window_xpos, left);
1000 nsoption_default_set_int(history_window_xsize, width);
1001 nsoption_default_set_int(history_window_ysize, height);
1002
1003 nsoption_default_set_int(hotlist_window_ypos, top);
1004 nsoption_default_set_int(hotlist_window_xpos, left);
1005 nsoption_default_set_int(hotlist_window_xsize, width);
1006 nsoption_default_set_int(hotlist_window_ysize, height);
1007
1008
1009 nsoption_default_set_int(window_x, 0);
1010 nsoption_default_set_int(window_y, screen->BarHeight + 1);
1011 nsoption_default_set_int(window_width, screen->Width);
1012 nsoption_default_set_int(window_height, screen->Height - screen->BarHeight - 1);
1013
1014#ifdef __amigaos4__
1015 nsoption_default_set_int(redraw_tile_size_x, screen->Width);
1016 nsoption_default_set_int(redraw_tile_size_y, screen->Height);
1017
1018 /* set system colours for amiga ui */
1019 colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveBorder, screen, 0x00000000);
1020 colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveCaption, screen, 0x00dddddd);
1021 colour_option_from_pen(BACKGROUNDPEN, NSOPTION_sys_colour_AppWorkspace, screen, 0x00eeeeee);
1022 colour_option_from_pen(BACKGROUNDPEN, NSOPTION_sys_colour_Background, screen, 0x00aa0000);
1023 colour_option_from_pen(FOREGROUNDPEN, NSOPTION_sys_colour_ButtonFace, screen, 0x00aaaaaa);
1024 colour_option_from_pen(FORESHINEPEN, NSOPTION_sys_colour_ButtonHighlight, screen, 0x00cccccc);
1025 colour_option_from_pen(FORESHADOWPEN, NSOPTION_sys_colour_ButtonShadow, screen, 0x00bbbbbb);
1026 colour_option_from_pen(TEXTPEN, NSOPTION_sys_colour_ButtonText, screen, 0x00000000);
1027 colour_option_from_pen(FILLTEXTPEN, NSOPTION_sys_colour_CaptionText, screen, 0x00000000);
1028 colour_option_from_pen(DISABLEDTEXTPEN, NSOPTION_sys_colour_GrayText, screen, 0x00777777);
1029 colour_option_from_pen(SELECTPEN, NSOPTION_sys_colour_Highlight, screen, 0x00ee0000);
1030 colour_option_from_pen(SELECTTEXTPEN, NSOPTION_sys_colour_HighlightText, screen, 0x00000000);
1031 colour_option_from_pen(INACTIVEFILLPEN, NSOPTION_sys_colour_InactiveBorder, screen, 0x00000000);
1032 colour_option_from_pen(INACTIVEFILLPEN, NSOPTION_sys_colour_InactiveCaption, screen, 0x00ffffff);
1033 colour_option_from_pen(INACTIVEFILLTEXTPEN, NSOPTION_sys_colour_InactiveCaptionText, screen, 0x00cccccc);
1034 colour_option_from_pen(BACKGROUNDPEN, NSOPTION_sys_colour_InfoBackground, screen, 0x00aaaaaa);/* This is wrong, HelpHint backgrounds are pale yellow but doesn't seem to be a DrawInfo pen defined for it. */
1035 colour_option_from_pen(TEXTPEN, NSOPTION_sys_colour_InfoText, screen, 0x00000000);
1036 colour_option_from_pen(MENUBACKGROUNDPEN, NSOPTION_sys_colour_Menu, screen, 0x00aaaaaa);
1037 colour_option_from_pen(MENUTEXTPEN, NSOPTION_sys_colour_MenuText, screen, 0x00000000);
1038 colour_option_from_pen(AMINS_SCROLLERPEN, NSOPTION_sys_colour_Scrollbar, screen, 0x00aaaaaa);
1039 colour_option_from_pen(FORESHADOWPEN, NSOPTION_sys_colour_ThreeDDarkShadow, screen, 0x00555555);
1040 colour_option_from_pen(FOREGROUNDPEN, NSOPTION_sys_colour_ThreeDFace, screen, 0x00dddddd);
1041 colour_option_from_pen(FORESHINEPEN, NSOPTION_sys_colour_ThreeDHighlight, screen, 0x00aaaaaa);
1042 colour_option_from_pen(HALFSHINEPEN, NSOPTION_sys_colour_ThreeDLightShadow, screen, 0x00999999);
1043 colour_option_from_pen(HALFSHADOWPEN, NSOPTION_sys_colour_ThreeDShadow, screen, 0x00777777);
1044 colour_option_from_pen(BACKGROUNDPEN, NSOPTION_sys_colour_Window, screen, 0x00aaaaaa);
1045 colour_option_from_pen(INACTIVEFILLPEN, NSOPTION_sys_colour_WindowFrame, screen, 0x00000000);
1046 colour_option_from_pen(TEXTPEN, NSOPTION_sys_colour_WindowText, screen, 0x00000000);
1047#else
1048 nsoption_default_set_int(redraw_tile_size_x, 100);
1049 nsoption_default_set_int(redraw_tile_size_y, 100);
1050#endif
1051}
1052
1053
1054/**
1055 * Set option defaults for amiga frontend
1056 *
1057 * @param defaults The option table to update.
1058 * @return error status.
1059 */
1061{
1062 STRPTR tempacceptlangs;
1063 char temp[1024];
1064 int codeset = 0;
1065
1066 /* The following line disables the popupmenu.class select menu.
1067 ** It's not recommended to use it!
1068 */
1069 nsoption_set_bool(core_select_menu, true);
1070
1071 /* ClickTab < 53 doesn't work with the auto show/hide tab-bar (for reasons forgotten) */
1072 if(ClickTabBase->lib_Version < 53)
1073 nsoption_set_bool(tab_always_show, true);
1074
1075 if((!nsoption_charp(accept_language)) ||
1076 (nsoption_charp(accept_language)[0] == '\0') ||
1077 (nsoption_bool(accept_lang_locale) == true))
1078 {
1079 if((tempacceptlangs = ami_locale_langs(&codeset)))
1080 {
1081 nsoption_set_charp(accept_language,
1082 (char *)strdup(tempacceptlangs));
1083 FreeVec(tempacceptlangs);
1084 }
1085 }
1086
1087 /* Some OS-specific overrides */
1088#ifdef __amigaos4__
1089 if(!LIB_IS_AT_LEAST((struct Library *)SysBase, 53, 89)) {
1090 /* Disable ExtMem usage pre-OS4.1FEU1 */
1091 nsoption_set_bool(use_extmem, false);
1092 }
1093
1094 if(codeset == 0) codeset = 4; /* ISO-8859-1 */
1095 const char *encname = (const char *)ObtainCharsetInfo(DFCS_NUMBER, codeset,
1096 DFCS_MIMENAME);
1097 nsoption_set_charp(local_charset, strdup(encname));
1098 nsoption_set_int(local_codeset, codeset);
1099#else
1100 nsoption_set_bool(download_notify, false);
1101 nsoption_set_bool(font_antialiasing, false);
1102 nsoption_set_bool(truecolour_mouse_pointers, false);
1103 nsoption_set_bool(use_openurl_lib, true);
1104 nsoption_set_bool(bitmap_fonts, true);
1105#endif
1106
1107 sprintf(temp, "%s/Cookies", current_user_dir);
1108 nsoption_setnull_charp(cookie_file,
1109 (char *)strdup(temp));
1110
1111 sprintf(temp, "%s/Hotlist", current_user_dir);
1112 nsoption_setnull_charp(hotlist_file,
1113 (char *)strdup(temp));
1114
1115 sprintf(temp, "%s/URLdb", current_user_dir);
1116 nsoption_setnull_charp(url_file,
1117 (char *)strdup(temp));
1118
1119 sprintf(temp, "%s/FontGlyphCache", current_user_dir);
1120 nsoption_setnull_charp(font_unicode_file,
1121 (char *)strdup(temp));
1122
1123 nsoption_setnull_charp(ca_bundle,
1124 (char *)strdup("PROGDIR:Resources/ca-bundle"));
1125
1126 /* font defaults */
1127#ifdef __amigaos4__
1128 nsoption_setnull_charp(font_sans, (char *)strdup("DejaVu Sans"));
1129 nsoption_setnull_charp(font_serif, (char *)strdup("DejaVu Serif"));
1130 nsoption_setnull_charp(font_mono, (char *)strdup("DejaVu Sans Mono"));
1131 nsoption_setnull_charp(font_cursive, (char *)strdup("DejaVu Sans"));
1132 nsoption_setnull_charp(font_fantasy, (char *)strdup("DejaVu Serif"));
1133#else
1134 nsoption_setnull_charp(font_sans, (char *)strdup("helvetica"));
1135 nsoption_setnull_charp(font_serif, (char *)strdup("times"));
1136 nsoption_setnull_charp(font_mono, (char *)strdup("topaz"));
1137 nsoption_setnull_charp(font_cursive, (char *)strdup("garnet"));
1138 nsoption_setnull_charp(font_fantasy, (char *)strdup("emerald"));
1139/* Default CG fonts for OS3 - these work with use_diskfont both on and off,
1140 however they are slow in both cases. The bitmap fonts don't work when
1141 use_diskfont is off. The bitmap fonts performance on 68k is far superior,
1142 so default to those for now whilst testing.
1143 \todo maybe add some buttons to the prefs GUI to toggle?
1144 nsoption_setnull_charp(font_sans, (char *)strdup("CGTriumvirate"));
1145 nsoption_setnull_charp(font_serif, (char *)strdup("CGTimes"));
1146 nsoption_setnull_charp(font_mono, (char *)strdup("LetterGothic"));
1147 nsoption_setnull_charp(font_cursive, (char *)strdup("CGTriumvirate"));
1148 nsoption_setnull_charp(font_fantasy, (char *)strdup("CGTimes"));
1149*/
1150#endif
1151
1152 if (nsoption_charp(font_unicode) == NULL)
1153 {
1154 BPTR lock = 0;
1155 /* Search for some likely candidates */
1156
1157 if((lock = Lock("FONTS:Code2000.otag", ACCESS_READ)))
1158 {
1159 UnLock(lock);
1160 nsoption_set_charp(font_unicode,
1161 (char *)strdup("Code2000"));
1162 }
1163 else if((lock = Lock("FONTS:Bitstream Cyberbit.otag", ACCESS_READ)))
1164 {
1165 UnLock(lock);
1166 nsoption_set_charp(font_unicode,
1167 (char *)strdup("Bitstream Cyberbit"));
1168 }
1169 }
1170
1171 if (nsoption_charp(font_surrogate) == NULL) {
1172 BPTR lock = 0;
1173 /* Search for some likely candidates -
1174 * Ideally we should pick a font during the scan process which announces it
1175 * contains UCR_SURROGATES, but nothing appears to have the tag.
1176 */
1177 if((lock = Lock("FONTS:Symbola.otag", ACCESS_READ))) {
1178 UnLock(lock);
1179 nsoption_set_charp(font_surrogate,
1180 (char *)strdup("Symbola"));
1181 }
1182 }
1183
1184 return NSERROR_OK;
1185}
1186
1187static void ami_amiupdate(void)
1188{
1189 /* Create AppPath location for AmiUpdate use */
1190
1191 BPTR lock = 0;
1192
1193 if(((lock = Lock("ENVARC:AppPaths",SHARED_LOCK)) == 0))
1194 {
1195 lock = CreateDir("ENVARC:AppPaths");
1196 }
1197
1198 UnLock(lock);
1199
1200 if((lock = Lock("PROGDIR:", ACCESS_READ)))
1201 {
1202 char filename[1024];
1203 BPTR amiupdatefh;
1204
1205 DevNameFromLock(lock, (STRPTR)&filename, 1024L, DN_FULLPATH);
1206
1207 if((amiupdatefh = FOpen("ENVARC:AppPaths/NetSurf", MODE_NEWFILE, 0))) {
1208 FPuts(amiupdatefh, (CONST_STRPTR)&filename);
1209 FClose(amiupdatefh);
1210 }
1211
1212 UnLock(lock);
1213 }
1214}
1215
1216static nsurl *gui_get_resource_url(const char *path)
1217{
1218 char buf[1024];
1219 nsurl *url = NULL;
1220
1221 if(ami_locate_resource(buf, path) == false)
1222 return NULL;
1223
1224 netsurf_path_to_nsurl(buf, &url);
1225
1226 return url;
1227}
1228
1229HOOKF(void, ami_gui_newprefs_hook, APTR, window, APTR)
1230{
1232}
1233
1234static void ami_openscreen(void)
1235{
1236 ULONG id = 0;
1237 ULONG compositing;
1238
1239 if (nsoption_int(screen_compositing) == -1)
1240 compositing = ~0UL;
1241 else compositing = nsoption_int(screen_compositing);
1242
1243 if (nsoption_charp(pubscreen_name) == NULL)
1244 {
1245 if((nsoption_charp(screen_modeid)) &&
1246 (strncmp(nsoption_charp(screen_modeid), "0x", 2) == 0))
1247 {
1248 id = strtoul(nsoption_charp(screen_modeid), NULL, 0);
1249 }
1250 else
1251 {
1252 struct ScreenModeRequester *screenmodereq = NULL;
1253
1254 if((screenmodereq = AllocAslRequest(ASL_ScreenModeRequest,NULL))) {
1255 if(AslRequestTags(screenmodereq,
1256 ASLSM_MinDepth, 0,
1257 ASLSM_MaxDepth, 32,
1258 TAG_DONE))
1259 {
1260 char *modeid = malloc(20);
1261 id = screenmodereq->sm_DisplayID;
1262 sprintf(modeid, "0x%lx", id);
1263 nsoption_set_charp(screen_modeid, modeid);
1265 }
1266 FreeAslRequest(screenmodereq);
1267 }
1268 }
1269
1270 if(screen_signal == -1) screen_signal = AllocSignal(-1);
1271 NSLOG(netsurf, INFO, "Screen signal %d", screen_signal);
1272 scrn = OpenScreenTags(NULL,
1273 /**\todo specify screen depth */
1274 SA_DisplayID, id,
1275 SA_Title, ami_gui_get_screen_title(),
1276 SA_Type, PUBLICSCREEN,
1277 SA_PubName, "NetSurf",
1278 SA_PubSig, screen_signal,
1279 SA_PubTask, FindTask(0),
1280 SA_LikeWorkbench, TRUE,
1281 SA_Compositing, compositing,
1282 TAG_DONE);
1283
1284 if(scrn)
1285 {
1286 PubScreenStatus(scrn,0);
1287 }
1288 else
1289 {
1290 FreeSignal(screen_signal);
1291 screen_signal = -1;
1292
1293 if((scrn = LockPubScreen("NetSurf")))
1294 {
1295 locked_screen = TRUE;
1296 }
1297 else
1298 {
1299 nsoption_set_charp(pubscreen_name,
1300 strdup("Workbench"));
1301 }
1302 }
1303 }
1304
1305 if (nsoption_charp(pubscreen_name) != NULL)
1306 {
1307 scrn = LockPubScreen(nsoption_charp(pubscreen_name));
1308
1309 if(scrn == NULL)
1310 {
1311 scrn = LockPubScreen("Workbench");
1312 }
1313 locked_screen = TRUE;
1314 }
1315
1319}
1320
1321static void ami_openscreenfirst(void)
1322{
1324 if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false, false);
1326}
1327
1328static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv,
1329 int *restrict nargc, char ** nargv)
1330{
1331 struct RDArgs *args;
1332 CONST_STRPTR template = "-v/S,NSOPTS/M,URL/K,USERSDIR/K,FORCE/S";
1333 long rarray[] = {0,0,0,0,0};
1334 enum
1335 {
1336 A_VERBOSE, /* ignored */
1337 A_NSOPTS, /* ignored */
1338 A_URL,
1339 A_USERSDIR,
1340 A_FORCE
1341 };
1342
1343 if(*argc == 0) return NULL; // argc==0 is started from wb
1344
1345 if((args = ReadArgs(template, rarray, NULL))) {
1346 if(rarray[A_URL]) {
1347 NSLOG(netsurf, INFO,
1348 "URL %s specified on command line",
1349 (char *)rarray[A_URL]);
1350 temp_homepage_url = strdup((char *)rarray[A_URL]); /**\todo allow IDNs */
1351 }
1352
1353 if(rarray[A_USERSDIR]) {
1354 NSLOG(netsurf, INFO,
1355 "USERSDIR %s specified on command line",
1356 (char *)rarray[A_USERSDIR]);
1357 users_dir = ASPrintf("%s", rarray[A_USERSDIR]);
1358 }
1359
1360 if(rarray[A_FORCE]) {
1361 NSLOG(netsurf, INFO,
1362 "FORCE specified on command line");
1363 cli_force = true;
1364 }
1365
1366 if(rarray[A_NSOPTS]) {
1367 /* The NSOPTS/M parameter specified in the ReadArgs template is
1368 * special. The /M means it collects all arguments that can't
1369 * be assigned to any other parameter, and stores them in an
1370 * array. We collect these and pass them as a fake argc/argv
1371 * to nsoption_commandline().
1372 * This trickery is necessary because if ReadArgs() is called
1373 * first, nsoption_commandline() can no longer parse (fetch?)
1374 * the arguments. If nsoption_commandline() is called first,
1375 * then ReadArgs cannot fetch the arguments.
1376 *\todo this was totally broken so to stop startup crashing
1377 * has been temporarily removed (core cli not called when func
1378 * returns NULL).
1379 */
1380 }
1381 } else {
1382 NSLOG(netsurf, INFO, "ReadArgs failed to parse command line");
1383 }
1384
1385 FreeArgs(args);
1386 return NULL;
1387}
1388
1389static char *ami_gui_read_tooltypes(struct WBArg *wbarg)
1390{
1391 struct DiskObject *dobj;
1392 STRPTR *toolarray;
1393 char *s;
1394 char *current_user = NULL;
1395
1396 if((*wbarg->wa_Name) && (dobj = GetDiskObject(wbarg->wa_Name))) {
1397 toolarray = (STRPTR *)dobj->do_ToolTypes;
1398
1399 if((s = (char *)FindToolType(toolarray,"USERSDIR"))) users_dir = ASPrintf("%s", s);
1400 if((s = (char *)FindToolType(toolarray,"USER"))) current_user = ASPrintf("%s", s);
1401
1402 FreeDiskObject(dobj);
1403 }
1404 return current_user;
1405}
1406
1407static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
1408{
1409 struct WBStartup *WBenchMsg;
1410 struct WBArg *wbarg;
1411 char i = 0;
1412 char *current_user = NULL;
1413 char *cur_user = NULL;
1414
1415 if(argc == 0) { /* Started from WB */
1416 WBenchMsg = (struct WBStartup *)argv;
1417 for(i = 0, wbarg = WBenchMsg->sm_ArgList; i < WBenchMsg->sm_NumArgs; i++,wbarg++) {
1418 LONG olddir =-1;
1419 if((wbarg->wa_Lock) && (*wbarg->wa_Name))
1420 olddir = SetCurrentDir(wbarg->wa_Lock);
1421
1422 cur_user = ami_gui_read_tooltypes(wbarg);
1423 if(cur_user != NULL) {
1424 if(current_user != NULL) FreeVec(current_user);
1425 current_user = cur_user;
1426 }
1427
1428 if(olddir !=-1) SetCurrentDir(olddir);
1429 }
1430 }
1431
1432 return current_user;
1433}
1434
1435static void gui_init2(int argc, char** argv)
1436{
1437 struct Screen *screen;
1438 BOOL notalreadyrunning;
1439 nsurl *url;
1440 nserror error;
1441 struct browser_window *bw = NULL;
1442
1443 notalreadyrunning = ami_arexx_init(&rxsig);
1444
1445 /* ...and this ensures the treeview at least gets the WB colour palette to work with */
1446 if(scrn == NULL) {
1447 if((screen = LockPubScreen("Workbench"))) {
1449 UnlockPubScreen(NULL, screen);
1450 }
1451 } else {
1453 }
1454 /**/
1455
1456 hotlist_init(nsoption_charp(hotlist_file),
1457 nsoption_charp(hotlist_file));
1459
1460 if (notalreadyrunning &&
1461 (nsoption_bool(startup_no_window) == false))
1463
1464 if(cli_force == true) {
1465 notalreadyrunning = TRUE;
1466 }
1467
1468 if(temp_homepage_url && notalreadyrunning) {
1469 error = nsurl_create(temp_homepage_url, &url);
1470 if (error == NSERROR_OK) {
1472 url,
1473 NULL,
1474 NULL,
1475 &bw);
1476 nsurl_unref(url);
1477 }
1478 if (error != NSERROR_OK) {
1480 }
1481 free(temp_homepage_url);
1482 temp_homepage_url = NULL;
1483 }
1484
1485 if(argc == 0) { // WB
1486 struct WBStartup *WBenchMsg = (struct WBStartup *)argv;
1487 struct WBArg *wbarg;
1488 int first=0,i=0;
1489 char fullpath[1024];
1490
1491 for(i=0,wbarg=WBenchMsg->sm_ArgList;i<WBenchMsg->sm_NumArgs;i++,wbarg++)
1492 {
1493 if(i==0) continue;
1494 if((wbarg->wa_Lock)&&(*wbarg->wa_Name))
1495 {
1496 DevNameFromLock(wbarg->wa_Lock,fullpath,1024,DN_FULLPATH);
1497 AddPart(fullpath,wbarg->wa_Name,1024);
1498
1499 if(!temp_homepage_url) {
1500 nsurl *temp_url;
1501 if (netsurf_path_to_nsurl(fullpath, &temp_url) == NSERROR_OK) {
1502 temp_homepage_url = strdup(nsurl_access(temp_url));
1503 nsurl_unref(temp_url);
1504 }
1505 }
1506
1507 if(notalreadyrunning)
1508 {
1509 error = nsurl_create(temp_homepage_url, &url);
1510
1511 if (error == NSERROR_OK) {
1512 if(!first)
1513 {
1515 url,
1516 NULL,
1517 NULL,
1518 &bw);
1519
1520 first=1;
1521 }
1522 else
1523 {
1525 url,
1526 NULL,
1527 bw,
1528 &bw);
1529
1530 }
1531 nsurl_unref(url);
1532
1533 }
1534 if (error != NSERROR_OK) {
1536 }
1537 free(temp_homepage_url);
1538 temp_homepage_url = NULL;
1539 }
1540 }
1541 /* this should be where we read tooltypes, but it's too late for that now */
1542 }
1543 }
1544
1545 nsoption_setnull_charp(homepage_url, (char *)strdup(NETSURF_HOMEPAGE));
1546
1547 if(!notalreadyrunning)
1548 {
1549 STRPTR sendcmd = NULL;
1550 char newtab[11] = "\0";
1551
1552 if(nsoption_bool(tab_new_session) == true) {
1553 strcpy(newtab, "TAB ACTIVE");
1554 }
1555
1556 if(temp_homepage_url) {
1557 sendcmd = ASPrintf("OPEN \"%s\" NEW%s", temp_homepage_url, newtab);
1558 free(temp_homepage_url);
1559 temp_homepage_url = NULL;
1560 } else {
1561 sendcmd = ASPrintf("OPEN \"%s\" NEW%s", nsoption_charp(homepage_url), newtab);
1562 }
1563 ami_arexx_self(sendcmd);
1564 FreeVec(sendcmd);
1565
1566 /* Bring the screen to the front. Intuition may have already done this, but it doesn't hurt. */
1567 ami_arexx_self("TOFRONT");
1568
1569 ami_quit=true;
1570 return;
1571 }
1572#ifdef __amigaos4__
1573 if(IApplication)
1574 {
1575 if(argc == 0)
1576 {
1577 ULONG noicon = TAG_IGNORE;
1578
1579 if (nsoption_bool(hide_docky_icon))
1580 noicon = REGAPP_NoIcon;
1581
1582 ami_appid = RegisterApplication(messages_get("NetSurf"),
1583 REGAPP_URLIdentifier, "netsurf-browser.org",
1584 REGAPP_WBStartup, (struct WBStartup *)argv,
1585 noicon, TRUE,
1586 REGAPP_HasPrefsWindow, TRUE,
1587 REGAPP_CanCreateNewDocs, TRUE,
1588 REGAPP_UniqueApplication, TRUE,
1589 REGAPP_Description, messages_get("NetSurfDesc"),
1590 TAG_DONE);
1591 }
1592 else
1593 {
1594/* TODO: Specify icon when run from Shell */
1595 ami_appid = RegisterApplication(messages_get("NetSurf"),
1596 REGAPP_URLIdentifier, "netsurf-browser.org",
1597 REGAPP_FileName, argv[0],
1598 REGAPP_NoIcon, TRUE,
1599 REGAPP_HasPrefsWindow, TRUE,
1600 REGAPP_CanCreateNewDocs, TRUE,
1601 REGAPP_UniqueApplication, TRUE,
1602 REGAPP_Description, messages_get("NetSurfDesc"),
1603 TAG_DONE);
1604 }
1605
1606 GetApplicationAttrs(ami_appid, APPATTR_Port, (ULONG)&applibport, TAG_DONE);
1607 if(applibport) applibsig = (1L << applibport->mp_SigBit);
1608 }
1609#endif
1610 if(!bw && (nsoption_bool(startup_no_window) == false)) {
1611 error = nsurl_create(nsoption_charp(homepage_url), &url);
1612 if (error == NSERROR_OK) {
1614 url,
1615 NULL,
1616 NULL,
1617 NULL);
1618 nsurl_unref(url);
1619 }
1620 if (error != NSERROR_OK) {
1622 }
1623 }
1624}
1625
1626static void ami_update_buttons(struct gui_window_2 *gwin)
1627{
1628 long back=FALSE, forward=FALSE, tabclose=FALSE, stop=FALSE, reload=FALSE;
1629 long s_back, s_forward, s_tabclose, s_stop, s_reload;
1630
1632 back=TRUE;
1633
1635 forward=TRUE;
1636
1638 stop=TRUE;
1639
1641 reload=TRUE;
1642
1643 if(nsoption_bool(kiosk_mode) == false) {
1644 if(gwin->tabs <= 1) {
1645 tabclose=TRUE;
1646 ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
1647 } else {
1648 ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
1649 }
1650 }
1651
1652 GetAttr(GA_Disabled, gwin->objects[GID_BACK], (uint32 *)&s_back);
1653 GetAttr(GA_Disabled, gwin->objects[GID_FORWARD], (uint32 *)&s_forward);
1654 GetAttr(GA_Disabled, gwin->objects[GID_RELOAD], (uint32 *)&s_reload);
1655 GetAttr(GA_Disabled, gwin->objects[GID_STOP], (uint32 *)&s_stop);
1656
1657 if(BOOL_MISMATCH(s_back, back))
1658 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_BACK],
1659 gwin->win, NULL, GA_Disabled, back, TAG_DONE);
1660
1661 if(BOOL_MISMATCH(s_forward, forward))
1662 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_FORWARD],
1663 gwin->win, NULL, GA_Disabled, forward, TAG_DONE);
1664
1665 if(BOOL_MISMATCH(s_reload, reload))
1666 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_RELOAD],
1667 gwin->win, NULL, GA_Disabled, reload, TAG_DONE);
1668
1669 if(BOOL_MISMATCH(s_stop, stop))
1670 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_STOP],
1671 gwin->win, NULL, GA_Disabled, stop, TAG_DONE);
1672
1673 if(ClickTabBase->lib_Version < 53) {
1674 if(gwin->tabs <= 1) tabclose = TRUE;
1675
1676 GetAttr(GA_Disabled, gwin->objects[GID_CLOSETAB], (uint32 *)&s_tabclose);
1677
1678 if(BOOL_MISMATCH(s_tabclose, tabclose))
1679 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_CLOSETAB],
1680 gwin->win, NULL, GA_Disabled, tabclose, TAG_DONE);
1681 }
1682
1683 /* Update the back/forward buttons history context menu */
1686}
1687
1688void ami_gui_history(struct gui_window_2 *gwin, bool back)
1689{
1690 if(back == true)
1691 {
1693 browser_window_history_back(gwin->gw->bw, false);
1694 }
1695 else
1696 {
1698 browser_window_history_forward(gwin->gw->bw, false);
1699 }
1700
1701 ami_update_buttons(gwin);
1702}
1703
1704int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
1705{
1706 int nskey = 0, chars;
1707 char buffer[20];
1708 char *utf8 = NULL;
1709
1710 if(keycode >= IECODE_UP_PREFIX) return 0;
1711
1712 switch(keycode)
1713 {
1714 case RAWKEY_CRSRUP:
1715 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1716 nskey = NS_KEY_PAGE_UP;
1717 } else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
1718 nskey = NS_KEY_TEXT_START;
1719 }
1720 else nskey = NS_KEY_UP;
1721 break;
1722 case RAWKEY_CRSRDOWN:
1723 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1724 nskey = NS_KEY_PAGE_DOWN;
1725 } else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
1726 nskey = NS_KEY_TEXT_END;
1727 }
1728 else nskey = NS_KEY_DOWN;
1729 break;
1730 case RAWKEY_CRSRLEFT:
1731 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1732 nskey = NS_KEY_LINE_START;
1733 }else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
1734 nskey = NS_KEY_WORD_LEFT;
1735 }
1736 else nskey = NS_KEY_LEFT;
1737 break;
1738 case RAWKEY_CRSRRIGHT:
1739 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1740 nskey = NS_KEY_LINE_END;
1741 }else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
1742 nskey = NS_KEY_WORD_RIGHT;
1743 }
1744 else nskey = NS_KEY_RIGHT;
1745 break;
1746 case RAWKEY_ESC:
1747 nskey = NS_KEY_ESCAPE;
1748 break;
1749 case RAWKEY_PAGEUP:
1750 nskey = NS_KEY_PAGE_UP;
1751 break;
1752 case RAWKEY_PAGEDOWN:
1753 nskey = NS_KEY_PAGE_DOWN;
1754 break;
1755 case RAWKEY_HOME:
1756 nskey = NS_KEY_TEXT_START;
1757 break;
1758 case RAWKEY_END:
1759 nskey = NS_KEY_TEXT_END;
1760 break;
1761 case RAWKEY_BACKSPACE:
1762 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1764 } else {
1765 nskey = NS_KEY_DELETE_LEFT;
1766 }
1767 break;
1768 case RAWKEY_DEL:
1769 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1770 nskey = NS_KEY_DELETE_LINE_END;
1771 } else {
1772 nskey = NS_KEY_DELETE_RIGHT;
1773 }
1774 break;
1775 case RAWKEY_TAB:
1776 if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
1777 nskey = NS_KEY_SHIFT_TAB;
1778 } else {
1779 nskey = NS_KEY_TAB;
1780 }
1781 break;
1782 case RAWKEY_F5:
1783 case RAWKEY_F8:
1784 case RAWKEY_F9:
1785 case RAWKEY_F10:
1786 case RAWKEY_F12:
1787 case RAWKEY_HELP:
1788 // don't translate
1789 nskey = keycode;
1790 break;
1791 default:
1792 if((chars = MapRawKey(ie,buffer,20,NULL)) > 0) {
1793 if(utf8_from_local_encoding(buffer, chars, &utf8) != NSERROR_OK) return 0;
1794 nskey = utf8_to_ucs4(utf8, utf8_char_byte_length(utf8));
1795 free(utf8);
1796
1797 if(ie->ie_Qualifier & IEQUALIFIER_RCOMMAND) {
1798 switch(nskey) {
1799 case 'a':
1800 nskey = NS_KEY_SELECT_ALL;
1801 break;
1802 case 'c':
1803 nskey = NS_KEY_COPY_SELECTION;
1804 break;
1805 case 'v':
1806 nskey = NS_KEY_PASTE;
1807 break;
1808 case 'x':
1809 nskey = NS_KEY_CUT_SELECTION;
1810 break;
1811 case 'y':
1812 nskey = NS_KEY_REDO;
1813 break;
1814 case 'z':
1815 nskey = NS_KEY_UNDO;
1816 break;
1817 }
1818 }
1819 }
1820 break;
1821 }
1822
1823 return nskey;
1824}
1825
1826int ami_gui_get_quals(Object *win_obj)
1827{
1828 uint32 quals = 0;
1829 int key_state = 0;
1830#ifdef __amigaos4__
1831 GetAttr(WINDOW_Qualifier, win_obj, (uint32 *)&quals);
1832#else
1833#warning qualifier needs fixing for OS3
1834#endif
1835
1836 if(quals & NSA_QUAL_SHIFT) {
1837 key_state |= BROWSER_MOUSE_MOD_1;
1838 }
1839
1840 if(quals & IEQUALIFIER_CONTROL) {
1841 key_state |= BROWSER_MOUSE_MOD_2;
1842 }
1843
1844 if(quals & NSA_QUAL_ALT) {
1845 key_state |= BROWSER_MOUSE_MOD_3;
1846 }
1847
1848 return key_state;
1849}
1850
1851static void ami_update_quals(struct gui_window_2 *gwin)
1852{
1854}
1855
1856/* exported interface documented in amiga/gui.h */
1857nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox)
1858{
1859#ifdef __amigaos4__
1860 if(LIB_IS_AT_LEAST((struct Library *)SpaceBase, 53, 6)) {
1861 *bbox = malloc(sizeof(struct IBox));
1862 if(*bbox == NULL) return NSERROR_NOMEM;
1863 GetAttr(SPACE_RenderBox, obj, (ULONG *)*bbox);
1864 } else
1865#endif
1866 {
1867 GetAttr(SPACE_AreaBox, obj, (ULONG *)bbox);
1868 }
1869
1870 return NSERROR_OK;
1871}
1872
1873/* exported interface documented in amiga/gui.h */
1874void ami_gui_free_space_box(struct IBox *bbox)
1875{
1876#ifdef __amigaos4__
1877 if(LIB_IS_AT_LEAST((struct Library *)SpaceBase, 53, 6)) {
1878 free(bbox);
1879 }
1880#endif
1881}
1882
1884 int *restrict x, int *restrict y, int space_x, int space_y)
1885{
1886 int ns_x = space_x;
1887 int ns_y = space_y;
1888
1889 ns_x += gwin->gw->scrollx;
1890 ns_y += gwin->gw->scrolly;
1891
1892 *x = ns_x;
1893 *y = ns_y;
1894
1895 return true;
1896}
1897
1898bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y,
1899 int mouse_x, int mouse_y)
1900{
1901 int ns_x, ns_y;
1902 struct IBox *bbox;
1903
1904 if(mouse_x == -1) mouse_x = gwin->win->MouseX;
1905 if(mouse_y == -1) mouse_y = gwin->win->MouseY;
1906
1907 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) == NSERROR_OK) {
1908 ns_x = (ULONG)(mouse_x - bbox->Left);
1909 ns_y = (ULONG)(mouse_y - bbox->Top);
1910
1911 if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
1912 return false;
1913
1915 } else {
1916 amiga_warn_user("NoMemory", "");
1917 return false;
1918 }
1919
1920 return ami_spacebox_to_ns_coords(gwin, x, y, ns_x, ns_y);
1921}
1922
1923static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
1924{
1925 struct IBox *bbox;
1926 int x, y;
1927 struct rect rect;
1928
1929 if(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true)
1930 {
1931 if(browser_window_scroll_at_point(gwin->gw->bw, x, y, xs, ys) == false)
1932 {
1933 int width, height;
1934
1936 &gwin->gw->scrollx,
1937 &gwin->gw->scrolly);
1938
1939 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
1940 amiga_warn_user("NoMemory", "");
1941 return;
1942 }
1943
1944 browser_window_get_extents(gwin->gw->bw, false, &width, &height);
1945
1946 switch(xs)
1947 {
1948 case SCROLL_PAGE_UP:
1949 xs = gwin->gw->scrollx - bbox->Width;
1950 break;
1951
1952 case SCROLL_PAGE_DOWN:
1953 xs = gwin->gw->scrollx + bbox->Width;
1954 break;
1955
1956 case SCROLL_TOP:
1957 xs = 0;
1958 break;
1959
1960 case SCROLL_BOTTOM:
1961 xs = width;
1962 break;
1963
1964 default:
1965 xs += gwin->gw->scrollx;
1966 break;
1967 }
1968
1969 switch(ys)
1970 {
1971 case SCROLL_PAGE_UP:
1972 ys = gwin->gw->scrolly - bbox->Height;
1973 break;
1974
1975 case SCROLL_PAGE_DOWN:
1976 ys = gwin->gw->scrolly + bbox->Height;
1977 break;
1978
1979 case SCROLL_TOP:
1980 ys = 0;
1981 break;
1982
1983 case SCROLL_BOTTOM:
1984 ys = height;
1985 break;
1986
1987 default:
1988 ys += gwin->gw->scrolly;
1989 break;
1990 }
1991
1993 rect.x0 = rect.x1 = xs;
1994 rect.y0 = rect.y1 = ys;
1995 gui_window_set_scroll(gwin->gw, &rect);
1996 }
1997 }
1998}
1999
2000static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct rect *rect)
2001{
2002 struct IBox *bbox, *ibox;
2003
2004 ibox = malloc(sizeof(struct IBox));
2005 if(ibox == NULL) return NULL;
2006
2007 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
2008 free(ibox);
2009 amiga_warn_user("NoMemory", "");
2010 return NULL;
2011 }
2012
2013 ibox->Left = gwin->win->MouseX + (rect->x0);
2014 ibox->Top = gwin->win->MouseY + (rect->y0);
2015
2016 ibox->Width = (rect->x1 - rect->x0);
2017 ibox->Height = (rect->y1 - rect->y0);
2018
2019 if(ibox->Left < bbox->Left) ibox->Left = bbox->Left;
2020 if(ibox->Top < bbox->Top) ibox->Top = bbox->Top;
2021
2022 if((ibox->Left > (bbox->Left + bbox->Width)) ||
2023 (ibox->Top > (bbox->Top + bbox->Height)) ||
2024 (ibox->Width < 0) || (ibox->Height < 0))
2025 {
2026 free(ibox);
2028 return NULL;
2029 }
2030
2032 return ibox;
2033}
2034
2035static void ami_gui_trap_mouse(struct gui_window_2 *gwin)
2036{
2037#ifdef __amigaos4__
2038 switch(gwin->drag_op)
2039 {
2040 case GDRAGGING_NONE:
2042 case GDRAGGING_OTHER:
2043 break;
2044
2045 default:
2046 if(gwin->ptr_lock)
2047 {
2048 SetWindowAttrs(gwin->win, WA_GrabFocus, 10,
2049 WA_MouseLimits, gwin->ptr_lock, TAG_DONE);
2050 }
2051 break;
2052 }
2053#endif
2054}
2055
2057{
2058 struct nsObject *node;
2059 struct nsObject *nnode;
2060 struct gui_window_2 *gwin;
2061
2062 if(IsMinListEmpty(window_list)) return;
2063
2064 node = (struct nsObject *)GetHead((struct List *)window_list);
2065
2066 do {
2067 nnode=(struct nsObject *)GetSucc((struct Node *)node);
2068 gwin = node->objstruct;
2069
2070 if(node->Type == AMINS_WINDOW)
2071 {
2073 }
2074 } while((node = nnode));
2075}
2076
2077/**
2078 * Find the current dimensions of a amiga browser window content area.
2079 *
2080 * \param gw The gui window to measure content area of.
2081 * \param width receives width of window
2082 * \param height receives height of window
2083 * \return NSERROR_OK on sucess and width and height updated
2084 * else error code.
2085 */
2086static nserror
2088 int *restrict width,
2089 int *restrict height)
2090{
2091 struct IBox *bbox;
2092 nserror res;
2093
2094 res = ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER],
2095 &bbox);
2096 if (res != NSERROR_OK) {
2097 amiga_warn_user("NoMemory", "");
2098 return res;
2099 }
2100
2101 *width = bbox->Width;
2102 *height = bbox->Height;
2103
2105
2106 return NSERROR_OK;
2107}
2108
2109/* Add a horizontal scroller, if not already present
2110 * Returns true if changed, false otherwise */
2111static bool ami_gui_hscroll_add(struct gui_window_2 *gwin)
2112{
2113 struct TagItem attrs[2];
2114
2115 if(gwin->objects[GID_HSCROLL] != NULL) return false;
2116
2117 attrs[0].ti_Tag = CHILD_MinWidth;
2118 attrs[0].ti_Data = 0;
2119 attrs[1].ti_Tag = TAG_DONE;
2120 attrs[1].ti_Data = 0;
2121
2123 GA_ID, GID_HSCROLL,
2124 GA_RelVerify, TRUE,
2125 SCROLLER_Orientation, SORIENT_HORIZ,
2126 ICA_TARGET, ICTARGET_IDCMP,
2127 ScrollerEnd;
2128#ifdef __amigaos4__
2129 IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_ADDCHILD,
2130 gwin->win, gwin->objects[GID_HSCROLL], attrs);
2131#else
2132 SetAttrs(gwin->objects[GID_HSCROLLLAYOUT],
2133 LAYOUT_AddChild, gwin->objects[GID_HSCROLL], TAG_MORE, &attrs);
2134#endif
2135 return true;
2136}
2137
2138/* Remove the horizontal scroller, if present */
2139static bool ami_gui_hscroll_remove(struct gui_window_2 *gwin)
2140{
2141 if(gwin->objects[GID_HSCROLL] == NULL) return false;
2142
2143#ifdef __amigaos4__
2144 IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_REMOVECHILD,
2145 gwin->win, gwin->objects[GID_HSCROLL]);
2146#else
2147 SetAttrs(gwin->objects[GID_HSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_HSCROLL], TAG_DONE);
2148#endif
2149
2150 gwin->objects[GID_HSCROLL] = NULL;
2151
2152 return true;
2153}
2154
2155/* Add a vertical scroller, if not already present
2156 * Returns true if changed, false otherwise */
2157static bool ami_gui_vscroll_add(struct gui_window_2 *gwin)
2158{
2159 struct TagItem attrs[2];
2160
2161 if(gwin->objects[GID_VSCROLL] != NULL) return false;
2162
2163 attrs[0].ti_Tag = CHILD_MinWidth;
2164 attrs[0].ti_Data = 0;
2165 attrs[1].ti_Tag = TAG_DONE;
2166 attrs[1].ti_Data = 0;
2167
2169 GA_ID, GID_VSCROLL,
2170 GA_RelVerify, TRUE,
2171 ICA_TARGET, ICTARGET_IDCMP,
2172 ScrollerEnd;
2173#ifdef __amigaos4__
2174 IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_ADDCHILD,
2175 gwin->win, gwin->objects[GID_VSCROLL], attrs);
2176#else
2177 SetAttrs(gwin->objects[GID_VSCROLLLAYOUT],
2178 LAYOUT_AddChild, gwin->objects[GID_VSCROLL], TAG_MORE, &attrs);
2179#endif
2180 return true;
2181}
2182
2183/* Remove the vertical scroller, if present */
2184static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
2185{
2186 if(gwin->objects[GID_VSCROLL] == NULL) return false;
2187
2188#ifdef __amigaos4__
2189 IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_REMOVECHILD,
2190 gwin->win, gwin->objects[GID_VSCROLL]);
2191#else
2192 SetAttrs(gwin->objects[GID_VSCROLLLAYOUT], LAYOUT_RemoveChild, gwin->objects[GID_VSCROLL], TAG_DONE);
2193#endif
2194
2195 gwin->objects[GID_VSCROLL] = NULL;
2196
2197 return true;
2198}
2199
2200/**
2201 * Check the scroll bar requirements for a browser window, and add/remove
2202 * the vertical scroller as appropriate. This should be the main entry
2203 * point used to perform this task.
2204 *
2205 * \param gwin "Shared" GUI window to check the state of
2206 */
2207static void ami_gui_scroller_update(struct gui_window_2 *gwin)
2208{
2209 int h = 1, w = 1, wh = 0, ww = 0;
2210 bool rethinkv = false;
2211 bool rethinkh = false;
2214
2215 browser_window_get_scrollbar_type(gwin->gw->bw, &hscroll, &vscroll);
2216
2217 if(browser_window_is_frameset(gwin->gw->bw) == true) {
2218 rethinkv = ami_gui_vscroll_remove(gwin);
2219 rethinkh = ami_gui_hscroll_remove(gwin);
2220 } else {
2221 if((browser_window_get_extents(gwin->gw->bw, false, &w, &h) == NSERROR_OK)) {
2222 gui_window_get_dimensions(gwin->gw, &ww, &wh);
2223 }
2224
2225 if(vscroll == BW_SCROLLING_NO) {
2226 rethinkv = ami_gui_vscroll_remove(gwin);
2227 } else {
2228 if (h > wh) rethinkv = ami_gui_vscroll_add(gwin);
2229 else rethinkv = ami_gui_vscroll_remove(gwin);
2230 }
2231
2232 if(hscroll == BW_SCROLLING_NO) {
2233 rethinkh = ami_gui_hscroll_remove(gwin);
2234 } else {
2235 if (w > ww) rethinkh = ami_gui_hscroll_add(gwin);
2236 else rethinkh = ami_gui_hscroll_remove(gwin);
2237 }
2238 }
2239
2240 if(rethinkv || rethinkh) {
2241 FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
2242 RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
2243 gwin->win, NULL, TRUE);
2245 }
2246}
2247
2248/* For future use
2249static void ami_gui_console_log_clear(struct gui_window *g)
2250{
2251 if(g->shared->objects[GID_LOG] != NULL) {
2252 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL,
2253 LISTBROWSER_Labels, NULL,
2254 TAG_DONE);
2255 }
2256
2257 FreeListBrowserList(&g->loglist);
2258
2259 NewList(&g->loglist);
2260
2261 if(g->shared->objects[GID_LOG] != NULL) {
2262 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL,
2263 LISTBROWSER_Labels, &g->loglist,
2264 TAG_DONE);
2265 }
2266}
2267*/
2268
2270{
2271 struct TagItem attrs[2];
2272
2273 if(g->shared->objects[GID_LOG] != NULL) return;
2274
2275 attrs[0].ti_Tag = CHILD_MinHeight;
2276 attrs[0].ti_Data = 50;
2277 attrs[1].ti_Tag = TAG_DONE;
2278 attrs[1].ti_Data = 0;
2279
2281 GA_ID, GID_LOG,
2282 LISTBROWSER_ColumnInfo, g->logcolumns,
2283 LISTBROWSER_ColumnTitles, TRUE,
2284 LISTBROWSER_Labels, &g->loglist,
2286 ListBrowserEnd;
2287
2288#ifdef __amigaos4__
2289 IDoMethod(g->shared->objects[GID_LOGLAYOUT], LM_ADDCHILD,
2290 g->shared->win, g->shared->objects[GID_LOG], NULL);
2291#else
2292 SetAttrs(g->shared->objects[GID_LOGLAYOUT],
2293 LAYOUT_AddChild, g->shared->objects[GID_LOG], TAG_MORE, &attrs);
2294#endif
2295
2296 FlushLayoutDomainCache((struct Gadget *)g->shared->objects[GID_MAIN]);
2297
2298 RethinkLayout((struct Gadget *)g->shared->objects[GID_MAIN],
2299 g->shared->win, NULL, TRUE);
2300
2301 ami_schedule_redraw(g->shared, true);
2302}
2303
2305{
2306 if(g->shared->objects[GID_LOG] == NULL) return;
2307
2308#ifdef __amigaos4__
2309 IDoMethod(g->shared->objects[GID_LOGLAYOUT], LM_REMOVECHILD,
2310 g->shared->win, g->shared->objects[GID_LOG]);
2311#else
2312 SetAttrs(g->shared->objects[GID_LOGLAYOUT],
2313 LAYOUT_RemoveChild, g->shared->objects[GID_LOG], TAG_DONE);
2314#endif
2315
2316 g->shared->objects[GID_LOG] = NULL;
2317
2318 FlushLayoutDomainCache((struct Gadget *)g->shared->objects[GID_MAIN]);
2319
2320 RethinkLayout((struct Gadget *)g->shared->objects[GID_MAIN],
2321 g->shared->win, NULL, TRUE);
2322
2323 ami_schedule_redraw(g->shared, true);
2324}
2325
2327{
2328 if(g->shared->objects[GID_LOG] == NULL) {
2330 return true;
2331 } else {
2333 return false;
2334 }
2335}
2336
2338{
2339 if(g->shared->objects[GID_LOG] == NULL) return;
2340
2341 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL,
2342 LISTBROWSER_ColumnInfo, g->logcolumns,
2343 LISTBROWSER_Labels, &g->loglist,
2344 TAG_DONE);
2345}
2346
2347static void
2350 const char *msg,
2351 size_t msglen,
2353{
2354 bool foldable = !!(flags & BW_CS_FLAG_FOLDABLE);
2355 const char *src_text;
2356 const char *level_text;
2357 struct Node *node;
2358 ULONG style = 0;
2359 ULONG fgpen = TEXTPEN;
2360 ULONG lbflags = LBFLG_READONLY;
2361 char timestamp[256];
2362 time_t now = time(NULL);
2363 struct tm *timedata = localtime(&now);
2364
2365 strftime(timestamp, 256, "%c", timedata);
2366
2367 if(foldable) lbflags |= LBFLG_HASCHILDREN;
2368
2369 switch (src) {
2370 case BW_CS_INPUT:
2371 src_text = "client-input";
2372 break;
2373 case BW_CS_SCRIPT_ERROR:
2374 src_text = "scripting-error";
2375 break;
2377 src_text = "scripting-console";
2378 break;
2379 default:
2380 assert(0 && "Unknown scripting source");
2381 src_text = "unknown";
2382 break;
2383 }
2384
2385 switch (flags & BW_CS_FLAG_LEVEL_MASK) {
2387 level_text = "DEBUG";
2388 fgpen = DISABLEDTEXTPEN;
2389 lbflags |= LBFLG_CUSTOMPENS;
2390 break;
2392 level_text = "LOG";
2393 fgpen = DISABLEDTEXTPEN;
2394 lbflags |= LBFLG_CUSTOMPENS;
2395 break;
2397 level_text = "INFO";
2398 break;
2400 level_text = "WARN";
2401 break;
2403 level_text = "ERROR";
2404 style = FSF_BOLD;
2405 break;
2406 default:
2407 assert(0 && "Unknown console logging level");
2408 level_text = "unknown";
2409 break;
2410 }
2411
2412 if(g->shared->objects[GID_LOG] != NULL) {
2413 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL,
2414 LISTBROWSER_Labels, NULL,
2415 TAG_DONE);
2416 }
2417
2418 /* Add log entry to list irrespective of whether the log is open. */
2419 if((node = AllocListBrowserNode(4,
2420 LBNA_Flags, lbflags,
2421 LBNA_Column, 0,
2422 LBNCA_SoftStyle, style,
2423 LBNCA_FGPen, fgpen,
2424 LBNCA_CopyText, TRUE,
2425 LBNCA_Text, timestamp,
2426 LBNA_Column, 1,
2427 LBNCA_SoftStyle, style,
2428 LBNCA_FGPen, fgpen,
2429 LBNCA_CopyText, TRUE,
2430 LBNCA_Text, src_text,
2431 LBNA_Column, 2,
2432 LBNCA_SoftStyle, style,
2433 LBNCA_FGPen, fgpen,
2434 LBNCA_CopyText, TRUE,
2435 LBNCA_Text, level_text,
2436 LBNA_Column, 3,
2437 LBNCA_SoftStyle, style,
2438 LBNCA_FGPen, fgpen,
2439 LBNCA_CopyText, TRUE,
2440 LBNCA_Text, msg,
2441 TAG_DONE))) {
2442 AddTail(&g->loglist, node);
2443 }
2444
2445 if(g->shared->objects[GID_LOG] != NULL) {
2446 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_LOG], g->shared->win, NULL,
2447 LISTBROWSER_Labels, &g->loglist,
2448 TAG_DONE);
2449 }
2450
2451#ifdef __amigaos4__
2452 DebugPrintF("NETSURF: CONSOLE_LOG SOURCE %s %sFOLDABLE %s %.*s\n",
2453 src_text, foldable ? "" : "NOT-", level_text,
2454 (int)msglen, msg);
2455#endif
2456}
2457
2458
2459/**
2460 * function to add retrieved favicon to gui
2461 */
2462static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
2463{
2464 struct BitMap *bm = NULL;
2465 struct IBox *bbox;
2466 struct bitmap *icon_bitmap = NULL;
2467
2468 if(nsoption_bool(kiosk_mode) == true) return;
2469 if(!g) return;
2470
2471 if ((icon != NULL) && ((icon_bitmap = content_get_bitmap(icon)) != NULL))
2472 {
2473 bm = ami_bitmap_get_native(icon_bitmap, 16, 16, ami_plot_screen_is_palettemapped(),
2474 g->shared->win->RPort->BitMap);
2475 }
2476
2477 if(g == g->shared->gw) {
2478 RefreshGList((struct Gadget *)g->shared->objects[GID_ICON],
2479 g->shared->win, NULL, 1);
2480
2481 if(bm)
2482 {
2483 ULONG tag, tag_data, minterm;
2484
2485 if(ami_plot_screen_is_palettemapped() == false) {
2486 tag = BLITA_UseSrcAlpha;
2487 tag_data = !amiga_bitmap_get_opaque(icon_bitmap);
2488 minterm = 0xc0;
2489 } else {
2490 tag = BLITA_MaskPlane;
2491 tag_data = (ULONG)ami_bitmap_get_mask(icon_bitmap, 16, 16, bm);
2492 minterm = MINTERM_SRCMASK;
2493 }
2494
2495 if(ami_gui_get_space_box((Object *)g->shared->objects[GID_ICON], &bbox) != NSERROR_OK) {
2496 amiga_warn_user("NoMemory", "");
2497 return;
2498 }
2499
2500 EraseRect(g->shared->win->RPort, bbox->Left, bbox->Top,
2501 bbox->Left + 16, bbox->Top + 16);
2502
2503#ifdef __amigaos4__
2504 BltBitMapTags(BLITA_SrcX, 0,
2505 BLITA_SrcY, 0,
2506 BLITA_DestX, bbox->Left,
2507 BLITA_DestY, bbox->Top,
2508 BLITA_Width, 16,
2509 BLITA_Height, 16,
2510 BLITA_Source, bm,
2511 BLITA_Dest, g->shared->win->RPort,
2512 BLITA_SrcType, BLITT_BITMAP,
2513 BLITA_DestType, BLITT_RASTPORT,
2514 BLITA_Minterm, minterm,
2515 tag, tag_data,
2516 TAG_DONE);
2517#else
2518 if(tag_data) {
2519 BltMaskBitMapRastPort(bm, 0, 0, g->shared->win->RPort,
2520 bbox->Left, bbox->Top, 16, 16, minterm, tag_data);
2521 } else {
2522 BltBitMapRastPort(bm, 0, 0, g->shared->win->RPort,
2523 bbox->Left, bbox->Top, 16, 16, 0xc0);
2524 }
2525#endif
2527 }
2528 }
2529
2530 g->favicon = icon;
2531}
2532
2533static void ami_gui_refresh_favicon(void *p)
2534{
2535 struct gui_window_2 *gwin = (struct gui_window_2 *)p;
2536 gui_window_set_icon(gwin->gw, gwin->gw->favicon);
2537}
2538
2539/* Gets the size that border gadget 1 (status) needs to be.
2540 * Returns the width of the size gadget as a convenience.
2541 */
2542#ifdef __amigaos4__
2543static ULONG ami_get_border_gadget_size(struct gui_window_2 *gwin,
2544 ULONG *restrict width, ULONG *restrict height)
2545{
2546 static ULONG sz_gad_width = 0;
2547 static ULONG sz_gad_height = 0;
2548 ULONG available_width;
2549
2550 if((sz_gad_width == 0) || (sz_gad_height == 0)) {
2551 struct DrawInfo *dri = GetScreenDrawInfo(scrn);
2552 GetGUIAttrs(NULL, dri,
2553 GUIA_SizeGadgetWidth, &sz_gad_width,
2554 GUIA_SizeGadgetHeight, &sz_gad_height,
2555 TAG_DONE);
2556 FreeScreenDrawInfo(scrn, dri);
2557 }
2558 available_width = gwin->win->Width - scrn->WBorLeft - sz_gad_width;
2559
2560 *width = available_width;
2561 *height = sz_gad_height;
2562
2563 return sz_gad_width;
2564}
2565#endif
2566
2568{
2569#ifdef __amigaos4__
2570 /* Reset gadget widths according to new calculation */
2571 ULONG size1, size2;
2572
2573 ami_get_border_gadget_size(gwin, &size1, &size2);
2574
2575 RefreshSetGadgetAttrs((struct Gadget *)(APTR)gwin->objects[GID_STATUS],
2576 gwin->win, NULL,
2577 GA_Width, size1,
2578 TAG_DONE);
2579
2580 RefreshWindowFrame(gwin->win);
2581#endif
2582}
2583
2584static BOOL ami_handle_msg(void)
2585{
2586 struct ami_generic_window *w = NULL;
2587 struct nsObject *node;
2588 struct nsObject *nnode;
2589 BOOL win_closed = FALSE;
2590
2592 /* no windows in list, so NetSurf should not be running */
2593 ami_try_quit();
2594 return FALSE;
2595 }
2596
2597 node = (struct nsObject *)GetHead((struct List *)window_list);
2598
2599 do {
2600 nnode=(struct nsObject *)GetSucc((struct Node *)node);
2601
2602 w = node->objstruct;
2603 if(w == NULL) continue;
2604
2605 if(w->tbl->event != NULL) {
2606 if((win_closed = w->tbl->event(w))) {
2607 if((node->Type != AMINS_GUIOPTSWINDOW) ||
2608 ((node->Type == AMINS_GUIOPTSWINDOW) && (scrn != NULL))) {
2609 ami_try_quit();
2610 break;
2611 }
2612 } else {
2613 node = nnode;
2614 continue;
2615 }
2616 }
2617 } while((node = nnode));
2618
2619 if(ami_gui_menu_quit_selected() == true) {
2621 }
2622
2623 if(ami_gui_menu_get_check_toggled() == true) {
2625 }
2626
2627 return win_closed;
2628}
2629
2630static BOOL ami_gui_event(void *w)
2631{
2632 struct gui_window_2 *gwin = (struct gui_window_2 *)w;
2633 ULONG result, storage = 0, x, y, xs, ys, width = 800, height = 600;
2634 uint16 code;
2635 struct IBox *bbox;
2636 struct InputEvent *ie;
2637 struct Node *tabnode;
2638 int nskey;
2639 struct timeval curtime;
2640 static int drag_x_move = 0, drag_y_move = 0;
2641 char *utf8 = NULL;
2642 nsurl *url;
2643 BOOL win_closed = FALSE;
2644
2645 while((result = RA_HandleInput(gwin->objects[OID_MAIN], &code)) != WMHI_LASTMSG) {
2646 switch(result & WMHI_CLASSMASK) // class
2647 {
2648 case WMHI_MOUSEMOVE:
2649 ami_gui_trap_mouse(gwin); /* re-assert mouse area */
2650
2651 drag_x_move = 0;
2652 drag_y_move = 0;
2653
2654 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
2655 amiga_warn_user("NoMemory", "");
2656 break;
2657 }
2658
2659 x = (ULONG)((gwin->win->MouseX - bbox->Left));
2660 y = (ULONG)((gwin->win->MouseY - bbox->Top));
2661
2662 ami_get_hscroll_pos(gwin, (ULONG *)&xs);
2663 ami_get_vscroll_pos(gwin, (ULONG *)&ys);
2664
2665 x += xs;
2666 y += ys;
2667
2668 width=bbox->Width;
2669 height=bbox->Height;
2670
2672 {
2673 if(ami_drag_icon_move() == TRUE) {
2674 if((gwin->win->MouseX < bbox->Left) &&
2675 ((gwin->win->MouseX - bbox->Left) > -AMI_DRAG_THRESHOLD))
2676 drag_x_move = gwin->win->MouseX - bbox->Left;
2677 if((gwin->win->MouseX > (bbox->Left + bbox->Width)) &&
2678 ((gwin->win->MouseX - (bbox->Left + bbox->Width)) < AMI_DRAG_THRESHOLD))
2679 drag_x_move = gwin->win->MouseX - (bbox->Left + bbox->Width);
2680 if((gwin->win->MouseY < bbox->Top) &&
2681 ((gwin->win->MouseY - bbox->Top) > -AMI_DRAG_THRESHOLD))
2682 drag_y_move = gwin->win->MouseY - bbox->Top;
2683 if((gwin->win->MouseY > (bbox->Top + bbox->Height)) &&
2684 ((gwin->win->MouseY - (bbox->Top + bbox->Height)) < AMI_DRAG_THRESHOLD))
2685 drag_y_move = gwin->win->MouseY - (bbox->Top + bbox->Height);
2686 }
2687 }
2688
2690
2691 if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
2692 {
2693 ami_update_quals(gwin);
2694
2696 {
2699 }
2700 else if(gwin->mouse_state & BROWSER_MOUSE_PRESS_2)
2701 {
2704 }
2705 else
2706 {
2707 browser_window_mouse_track(gwin->gw->bw,gwin->mouse_state | gwin->key_state,x,y);
2708 }
2709 } else {
2710 if(!gwin->mouse_state) ami_set_pointer(gwin, GUI_POINTER_DEFAULT, true);
2711 }
2712 break;
2713
2714 case WMHI_MOUSEBUTTONS:
2715 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
2716 amiga_warn_user("NoMemory", "");
2717 return FALSE;
2718 }
2719
2720 x = (ULONG)(gwin->win->MouseX - bbox->Left);
2721 y = (ULONG)(gwin->win->MouseY - bbox->Top);
2722
2723 ami_get_hscroll_pos(gwin, (ULONG *)&xs);
2724 ami_get_vscroll_pos(gwin, (ULONG *)&ys);
2725
2726 x += xs;
2727 y += ys;
2728
2729 width=bbox->Width;
2730 height=bbox->Height;
2731
2733
2734 ami_update_quals(gwin);
2735
2736 if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
2737 {
2738 //code = code>>16;
2739 switch(code)
2740 {
2741 case SELECTDOWN:
2744 break;
2745 case MIDDLEDOWN:
2748 break;
2749 }
2750 }
2751
2752 if(x<xs) x=xs;
2753 if(y<ys) y=ys;
2754 if(x>=width+xs) x=width+xs-1;
2755 if(y>=height+ys) y=height+ys-1;
2756
2757 switch(code)
2758 {
2759 case SELECTUP:
2761 {
2762 CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
2763
2765
2766 if(gwin->lastclick.tv_sec)
2767 {
2768 if(DoubleClick(gwin->lastclick.tv_sec,
2769 gwin->lastclick.tv_usec,
2770 curtime.tv_sec, curtime.tv_usec)) {
2773 } else {
2775 }
2776 }
2777 }
2778
2780 gwin->mouse_state | gwin->key_state,x,y);
2781
2783 {
2784 gwin->lastclick.tv_sec = 0;
2785 gwin->lastclick.tv_usec = 0;
2786 }
2787 else
2788 {
2789 gwin->lastclick.tv_sec = curtime.tv_sec;
2790 gwin->lastclick.tv_usec = curtime.tv_usec;
2791 }
2792 }
2793 else
2794 {
2795 browser_window_mouse_track(gwin->gw->bw, 0, x, y);
2796 }
2797 gwin->prev_mouse_state = gwin->mouse_state;
2798 gwin->mouse_state=0;
2799 break;
2800
2801 case MIDDLEUP:
2803 {
2804 CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
2805
2807
2808 if(gwin->lastclick.tv_sec)
2809 {
2810 if(DoubleClick(gwin->lastclick.tv_sec,
2811 gwin->lastclick.tv_usec,
2812 curtime.tv_sec, curtime.tv_usec)) {
2815 } else {
2817 }
2818 }
2819 }
2820
2822 gwin->mouse_state | gwin->key_state,x,y);
2823
2825 {
2826 gwin->lastclick.tv_sec = 0;
2827 gwin->lastclick.tv_usec = 0;
2828 }
2829 else
2830 {
2831 gwin->lastclick.tv_sec = curtime.tv_sec;
2832 gwin->lastclick.tv_usec = curtime.tv_usec;
2833 }
2834 }
2835 else
2836 {
2837 browser_window_mouse_track(gwin->gw->bw, 0, x, y);
2838 }
2839 gwin->prev_mouse_state = gwin->mouse_state;
2840 gwin->mouse_state=0;
2841 break;
2842#ifdef __amigaos4__
2843 case SIDEUP:
2844 ami_gui_history(gwin, true);
2845 break;
2846
2847 case EXTRAUP:
2848 ami_gui_history(gwin, false);
2849 break;
2850#endif
2851 }
2852
2853 if(ami_drag_has_data() && !gwin->mouse_state)
2854 ami_drag_save(gwin->win);
2855 break;
2856
2857 case WMHI_GADGETUP:
2858 switch(result & WMHI_GADGETMASK)
2859 {
2860 case GID_TABS:
2861 if(gwin->objects[GID_TABS] == NULL) break;
2862 if(ClickTabBase->lib_Version >= 53) {
2863 GetAttrs(gwin->objects[GID_TABS],
2864 CLICKTAB_NodeClosed, &tabnode, TAG_DONE);
2865 } else {
2866 tabnode = NULL;
2867 }
2868
2869 if(tabnode) {
2870 struct gui_window *closedgw;
2871
2872 GetClickTabNodeAttrs(tabnode,
2873 TNA_UserData, &closedgw,
2874 TAG_DONE);
2875
2876 browser_window_destroy(closedgw->bw);
2877 } else {
2878 ami_switch_tab(gwin, true);
2879 }
2880 break;
2881
2882 case GID_CLOSETAB:
2884 break;
2885
2886 case GID_ADDTAB:
2888 break;
2889
2890 case GID_URL:
2891 {
2892 nserror ret;
2893 nsurl *url;
2894 GetAttr(STRINGA_TextVal,
2895 (Object *)gwin->objects[GID_URL],
2896 (ULONG *)&storage);
2897 utf8 = ami_to_utf8_easy((const char *)storage);
2898
2900 ami_utf8_free(utf8);
2901 if (ret == NSERROR_OK) {
2903 url,
2904 NULL,
2906 NULL,
2907 NULL,
2908 NULL);
2910 }
2911 if (ret != NSERROR_OK) {
2913 }
2914 }
2915 break;
2916
2917 case GID_TOOLBARLAYOUT:
2918 /* Need fixing: never gets here */
2920 break;
2921
2922 case GID_SEARCH_ICON:
2923 GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage);
2925 break;
2926
2927 case GID_SEARCHSTRING:
2928 {
2929 nserror ret;
2930 nsurl *url;
2931
2932 GetAttr(STRINGA_TextVal,
2933 (Object *)gwin->objects[GID_SEARCHSTRING],
2934 (ULONG *)&storage);
2935
2936 utf8 = ami_to_utf8_easy((const char *)storage);
2937
2939 ami_utf8_free(utf8);
2940 if (ret == NSERROR_OK) {
2942 url,
2943 NULL,
2945 NULL,
2946 NULL,
2947 NULL);
2949 }
2950 if (ret != NSERROR_OK) {
2952 }
2953
2954 }
2955 break;
2956
2957 case GID_HOME:
2958 {
2959 if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
2960 amiga_warn_user("NoMemory", 0);
2961 } else {
2963 url,
2964 NULL,
2966 NULL,
2967 NULL,
2968 NULL);
2970 }
2971 }
2972 break;
2973
2974 case GID_STOP:
2976 browser_window_stop(gwin->gw->bw);
2977 break;
2978
2979 case GID_RELOAD:
2980 ami_update_quals(gwin);
2981
2983 {
2984 if(gwin->key_state & BROWSER_MOUSE_MOD_1)
2985 {
2986 browser_window_reload(gwin->gw->bw, true);
2987 }
2988 else
2989 {
2990 browser_window_reload(gwin->gw->bw, false);
2991 }
2992 }
2993 break;
2994
2995 case GID_BACK:
2996 ami_gui_history(gwin, true);
2997 break;
2998
2999 case GID_FORWARD:
3000 ami_gui_history(gwin, false);
3001 break;
3002
3003 case GID_PAGEINFO:
3004 {
3005 ULONG w_top, w_left;
3006 ULONG g_top, g_left, g_height;
3007
3008 GetAttr(WA_Top, gwin->objects[OID_MAIN], &w_top);
3009 GetAttr(WA_Left, gwin->objects[OID_MAIN], &w_left);
3010 GetAttr(GA_Top, gwin->objects[GID_PAGEINFO], &g_top);
3011 GetAttr(GA_Left, gwin->objects[GID_PAGEINFO], &g_left);
3012 GetAttr(GA_Height, gwin->objects[GID_PAGEINFO], &g_height);
3013
3014 if(ami_pageinfo_open(gwin->gw->bw,
3015 w_left + g_left,
3016 w_top + g_top + g_height) != NSERROR_OK) {
3017 NSLOG(netsurf, INFO, "Unable to open page info window");
3018 }
3019 }
3020 break;
3021
3022 case GID_FAVE:
3023 GetAttr(STRINGA_TextVal,
3024 (Object *)gwin->objects[GID_URL],
3025 (ULONG *)&storage);
3026 if(nsurl_create((const char *)storage, &url) == NSERROR_OK) {
3027 if(hotlist_has_url(url)) {
3029 } else {
3031 }
3033 }
3035 break;
3036
3037 case GID_HOTLIST:
3038 default:
3039// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
3040 break;
3041 }
3042 break;
3043
3044 case WMHI_RAWKEY:
3045 ami_update_quals(gwin);
3046
3047 storage = result & WMHI_GADGETMASK;
3048 if(storage >= IECODE_UP_PREFIX) break;
3049
3050 GetAttr(WINDOW_InputEvent,gwin->objects[OID_MAIN],(ULONG *)&ie);
3051
3052 nskey = ami_key_to_nskey(storage, ie);
3053
3054 if((ie->ie_Qualifier & IEQUALIFIER_RCOMMAND) &&
3055 ((31 < nskey) && (nskey < 127))) {
3056 /* NB: Some keypresses are converted to generic keypresses above
3057 * rather than being "menu-emulated" here. */
3058 switch(nskey)
3059 {
3060 /* The following aren't available from the menu at the moment */
3061
3062 case 'r': // reload
3064 browser_window_reload(gwin->gw->bw, false);
3065 break;
3066
3067 case 'u': // open url
3068 if((nsoption_bool(kiosk_mode) == false))
3069 ActivateLayoutGadget((struct Gadget *)gwin->objects[GID_MAIN],
3070 gwin->win, NULL, (uint32)gwin->objects[GID_URL]);
3071 break;
3072 }
3073 }
3074 else
3075 {
3076 if(!browser_window_key_press(gwin->gw->bw, nskey))
3077 {
3078 switch(nskey)
3079 {
3080 case NS_KEY_UP:
3082 break;
3083
3084 case NS_KEY_DOWN:
3086 break;
3087
3088 case NS_KEY_LEFT:
3090 break;
3091
3092 case NS_KEY_RIGHT:
3094 break;
3095
3096 case NS_KEY_PAGE_UP:
3098 break;
3099
3100 case NS_KEY_PAGE_DOWN:
3101 case ' ':
3103 break;
3104
3105 case NS_KEY_LINE_START: // page left
3107 break;
3108
3109 case NS_KEY_LINE_END: // page right
3111 break;
3112
3113 case NS_KEY_TEXT_START: // home
3115 break;
3116
3117 case NS_KEY_TEXT_END: // end
3119 break;
3120
3121 case NS_KEY_WORD_RIGHT: // alt+right
3122 ami_change_tab(gwin, 1);
3123 break;
3124
3125 case NS_KEY_WORD_LEFT: // alt+left
3126 ami_change_tab(gwin, -1);
3127 break;
3128
3129 case NS_KEY_DELETE_LEFT: // backspace
3130 ami_gui_history(gwin, true);
3131 break;
3132
3133 /* RawKeys. NB: These are passthrus in ami_key_to_nskey() */
3134 case RAWKEY_F5: // reload
3136 browser_window_reload(gwin->gw->bw,false);
3137 break;
3138
3139 case RAWKEY_F8: // scale 100%
3140 ami_gui_set_scale(gwin->gw, 1.0);
3141 break;
3142
3143 case RAWKEY_F9: // decrease scale
3144 ami_gui_adjust_scale(gwin->gw, -0.1);
3145 break;
3146
3147 case RAWKEY_F10: // increase scale
3148 ami_gui_adjust_scale(gwin->gw, +0.1);
3149 break;
3150
3151 case RAWKEY_F12: // console log
3153 break;
3154
3155 case RAWKEY_HELP: // help
3157 break;
3158 }
3159 } else if(nskey == NS_KEY_COPY_SELECTION) {
3160 /* if we've copied a selection we need to clear it - style guide rules */
3162 }
3163 }
3164 break;
3165
3166 case WMHI_NEWSIZE:
3171 break;
3172
3173 case WMHI_CLOSEWINDOW:
3175 win_closed = TRUE;
3176 break;
3177#ifdef __amigaos4__
3178 case WMHI_ICONIFY:
3179 {
3180 struct bitmap *bm = NULL;
3182 &bm);
3183 gwin->dobj = amiga_icon_from_bitmap(bm);
3185 gwin->dobj);
3186 HideWindow(gwin->win);
3187 gwin->appicon = AddAppIcon((ULONG)gwin->objects[OID_MAIN],
3188 (ULONG)gwin, gwin->win->Title, appport,
3189 0, gwin->dobj, NULL);
3190
3191 cur_gw = NULL;
3192 }
3193 break;
3194#endif
3195 case WMHI_INACTIVE:
3196 gwin->gw->c_h_temp = gwin->gw->c_h;
3198 break;
3199
3200 case WMHI_ACTIVE:
3201 if(gwin->gw->bw) cur_gw = gwin->gw;
3202 if(gwin->gw->c_h_temp)
3203 gwin->gw->c_h = gwin->gw->c_h_temp;
3204 break;
3205
3206 case WMHI_INTUITICK:
3207 break;
3208
3209 default:
3210 //printf("class: %ld\n",(result & WMHI_CLASSMASK));
3211 break;
3212 }
3213
3214 if(win_destroyed)
3215 {
3216 /* we can't be sure what state our window_list is in, so let's
3217 jump out of the function and start again */
3218
3219 win_destroyed = false;
3220 return TRUE;
3221 }
3222
3223 if(drag_x_move || drag_y_move)
3224 {
3225 struct rect rect;
3226
3228 &gwin->gw->scrollx, &gwin->gw->scrolly);
3229
3230 rect.x0 = rect.x1 = gwin->gw->scrollx + drag_x_move;
3231 rect.y0 = rect.y1 = gwin->gw->scrolly + drag_y_move;
3232
3233 gui_window_set_scroll(gwin->gw, &rect);
3234 }
3235
3236// ReplyMsg((struct Message *)message);
3237 }
3238
3239 if(gwin->closed == true) {
3240 win_closed = TRUE;
3242 }
3243
3244 return win_closed;
3245}
3246
3247static void ami_gui_appicon_remove(struct gui_window_2 *gwin)
3248{
3249 if(gwin->appicon)
3250 {
3251 RemoveAppIcon(gwin->appicon);
3252 amiga_icon_free(gwin->dobj);
3253 gwin->appicon = NULL;
3254 }
3255}
3256
3258{
3259 int bm_idx;
3263
3264 /* if this isn't the visible tab, don't do anything */
3265 if((gwin == NULL) || (gwin->gw != gw)) return NSERROR_OK;
3266
3268
3269 switch(pistate) {
3271 bm_idx = GID_PAGEINFO_INTERNAL_BM;
3272 break;
3273
3274 case PAGE_STATE_LOCAL:
3275 bm_idx = GID_PAGEINFO_LOCAL_BM;
3276 break;
3277
3279 bm_idx = GID_PAGEINFO_INSECURE_BM;
3280 break;
3281
3283 bm_idx = GID_PAGEINFO_WARNING_BM;
3284 break;
3285
3287 bm_idx = GID_PAGEINFO_WARNING_BM;
3288 break;
3289
3290 case PAGE_STATE_SECURE:
3291 bm_idx = GID_PAGEINFO_SECURE_BM;
3292 break;
3293
3294 default:
3295 bm_idx = GID_PAGEINFO_INTERNAL_BM;
3296 break;
3297 }
3298
3299 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_PAGEINFO], gwin->win, NULL,
3300 BUTTON_RenderImage, gwin->objects[bm_idx],
3301 GA_HintInfo, gwin->helphints[bm_idx],
3302 TAG_DONE);
3303
3304 return NSERROR_OK;
3305}
3306
3307static void ami_handle_appmsg(void)
3308{
3309 struct AppMessage *appmsg;
3310 struct gui_window_2 *gwin;
3311 int x, y;
3312 struct WBArg *appwinargs;
3313 STRPTR filename;
3314 int i = 0;
3315
3316 while((appmsg = (struct AppMessage *)GetMsg(appport)))
3317 {
3318 gwin = (struct gui_window_2 *)appmsg->am_UserData;
3319
3320 if(appmsg->am_Type == AMTYPE_APPICON)
3321 {
3323 ShowWindow(gwin->win, WINDOW_FRONTMOST);
3324 ActivateWindow(gwin->win);
3325 }
3326 else if(appmsg->am_Type == AMTYPE_APPWINDOW)
3327 {
3328 for(i = 0; i < appmsg->am_NumArgs; ++i)
3329 {
3330 if((appwinargs = &appmsg->am_ArgList[i]))
3331 {
3332 if((filename = malloc(1024)))
3333 {
3334 if(appwinargs->wa_Lock)
3335 {
3336 NameFromLock(appwinargs->wa_Lock, filename, 1024);
3337 }
3338
3339 AddPart(filename, appwinargs->wa_Name, 1024);
3340
3341 if(ami_mouse_to_ns_coords(gwin, &x, &y,
3342 appmsg->am_MouseX, appmsg->am_MouseY) == false)
3343 {
3344 nsurl *url;
3345
3346 if (netsurf_path_to_nsurl(filename, &url) != NSERROR_OK) {
3347 amiga_warn_user("NoMemory", 0);
3348 }
3349 else
3350 {
3351 if(i == 0)
3352 {
3354 url,
3355 NULL,
3357 NULL,
3358 NULL,
3359 NULL);
3360
3361 ActivateWindow(gwin->win);
3362 }
3363 else
3364 {
3367 url,
3368 NULL,
3369 gwin->gw->bw,
3370 NULL);
3371 }
3372 nsurl_unref(url);
3373 }
3374 }
3375 else
3376 {
3377 if(browser_window_drop_file_at_point(gwin->gw->bw, x, y, filename) == false)
3378 {
3379 nsurl *url;
3380
3381 if (netsurf_path_to_nsurl(filename, &url) != NSERROR_OK) {
3382 amiga_warn_user("NoMemory", 0);
3383 }
3384 else
3385 {
3386
3387 if(i == 0)
3388 {
3390 url,
3391 NULL,
3393 NULL,
3394 NULL,
3395 NULL);
3396
3397 ActivateWindow(gwin->win);
3398 }
3399 else
3400 {
3403 url,
3404 NULL,
3405 gwin->gw->bw,
3406 NULL);
3407
3408 }
3409 nsurl_unref(url);
3410 }
3411 }
3412 }
3413 free(filename);
3414 }
3415 }
3416 }
3417 }
3418 ReplyMsg((struct Message *)appmsg);
3419 }
3420}
3421
3422static void ami_handle_applib(void)
3423{
3424#ifdef __amigaos4__
3425 struct ApplicationMsg *applibmsg;
3426 struct browser_window *bw;
3427 nsurl *url;
3428 nserror error;
3429
3430 if(!applibport) return;
3431
3432 while((applibmsg=(struct ApplicationMsg *)GetMsg(applibport)))
3433 {
3434 switch (applibmsg->type)
3435 {
3436 case APPLIBMT_NewBlankDoc:
3437 {
3438
3439 error = nsurl_create(nsoption_charp(homepage_url), &url);
3440 if (error == NSERROR_OK) {
3442 url,
3443 NULL,
3444 NULL,
3445 &bw);
3446 nsurl_unref(url);
3447 }
3448 if (error != NSERROR_OK) {
3450 }
3451 }
3452 break;
3453
3454 case APPLIBMT_OpenDoc:
3455 {
3456 struct ApplicationOpenPrintDocMsg *applibopdmsg =
3457 (struct ApplicationOpenPrintDocMsg *)applibmsg;
3458
3459 error = netsurf_path_to_nsurl(applibopdmsg->fileName, &url);
3460 if (error == NSERROR_OK) {
3462 url,
3463 NULL,
3464 NULL,
3465 &bw);
3466 nsurl_unref(url);
3467 }
3468 if (error != NSERROR_OK) {
3470 }
3471 }
3472 break;
3473
3474 case APPLIBMT_ToFront:
3475 if(cur_gw)
3476 {
3477 ScreenToFront(scrn);
3478 WindowToFront(cur_gw->shared->win);
3479 ActivateWindow(cur_gw->shared->win);
3480 }
3481 break;
3482
3483 case APPLIBMT_OpenPrefs:
3484 ScreenToFront(scrn);
3486 break;
3487
3488 case APPLIBMT_Quit:
3489 case APPLIBMT_ForceQuit:
3491 break;
3492
3493 case APPLIBMT_CustomMsg:
3494 {
3495 struct ApplicationCustomMsg *applibcustmsg =
3496 (struct ApplicationCustomMsg *)applibmsg;
3497 NSLOG(netsurf, INFO,
3498 "Ringhio BackMsg received: %s",
3499 applibcustmsg->customMsg);
3500
3501 ami_download_parse_backmsg(applibcustmsg->customMsg);
3502 }
3503 break;
3504 }
3505 ReplyMsg((struct Message *)applibmsg);
3506 }
3507#endif
3508}
3509
3510void ami_get_msg(void)
3511{
3512 ULONG winsignal = 1L << sport->mp_SigBit;
3513 ULONG appsig = 1L << appport->mp_SigBit;
3514 ULONG schedulesig = 1L << schedulermsgport->mp_SigBit;
3515 ULONG ctrlcsig = SIGBREAKF_CTRL_C;
3516 uint32 signal = 0;
3517 fd_set read_fd_set, write_fd_set, except_fd_set;
3518 int max_fd = -1;
3519 struct MsgPort *printmsgport = ami_print_get_msgport();
3520 ULONG printsig = 0;
3521 ULONG helpsignal = ami_help_signal();
3522 if(printmsgport) printsig = 1L << printmsgport->mp_SigBit;
3523 uint32 signalmask = winsignal | appsig | schedulesig | rxsig |
3524 printsig | applibsig | helpsignal;
3525
3526 if ((fetch_fdset(&read_fd_set, &write_fd_set, &except_fd_set, &max_fd) == NSERROR_OK) &&
3527 (max_fd != -1)) {
3528 /* max_fd is the highest fd in use, but waitselect() needs to know how many
3529 * are in use, so we add 1. */
3530
3531 if (waitselect(max_fd + 1, &read_fd_set, &write_fd_set, &except_fd_set,
3532 NULL, (unsigned int *)&signalmask) != -1) {
3533 signal = signalmask;
3534 } else {
3535 NSLOG(netsurf, INFO, "waitselect() returned error");
3536 /* \todo Fix Ctrl-C handling.
3537 * WaitSelect() from bsdsocket.library returns -1 if the task was
3538 * signalled with a Ctrl-C. waitselect() from newlib.library does not.
3539 * Adding the Ctrl-C signal to our user signal mask causes a Ctrl-C to
3540 * occur sporadically. Otherwise we never get a -1 except on error.
3541 * NetSurf still terminates at the Wait() when network activity is over.
3542 */
3543 }
3544 } else {
3545 /* If fetcher_fdset fails or no network activity, do it the old fashioned way. */
3546 signalmask |= ctrlcsig;
3547 signal = Wait(signalmask);
3548 }
3549
3550 if(signal & winsignal)
3551 while(ami_handle_msg());
3552
3553 if(signal & appsig)
3555
3556 if(signal & rxsig)
3558
3559 if(signal & applibsig)
3561
3562 if(signal & printsig) {
3563 while(GetMsg(printmsgport)); //ReplyMsg
3565 }
3566
3567 if(signal & schedulesig) {
3569 }
3570
3571 if(signal & helpsignal)
3573
3574 if(signal & ctrlcsig)
3576}
3577
3578static void ami_change_tab(struct gui_window_2 *gwin, int direction)
3579{
3580 struct Node *tab_node = gwin->gw->tab_node;
3581 struct Node *ptab = NULL;
3582
3583 if(gwin->tabs <= 1) return;
3584
3585 if(direction > 0) {
3586 ptab = GetSucc(tab_node);
3587 } else {
3588 ptab = GetPred(tab_node);
3589 }
3590
3591 if(!ptab) return;
3592
3593 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_TABS], gwin->win, NULL,
3594 CLICKTAB_CurrentNode, ptab,
3595 TAG_DONE);
3596
3597 ami_switch_tab(gwin, true);
3598}
3599
3600
3601static void gui_window_set_title(struct gui_window *g, const char *restrict title)
3602{
3603 struct Node *node;
3604 char *restrict utf8title;
3605
3606 if(!g) return;
3607 if(!title) return;
3608
3609 utf8title = ami_utf8_easy((char *)title);
3610
3611 if(g->tab_node) {
3612 node = g->tab_node;
3613
3614 if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle)))
3615 {
3616 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
3617 g->shared->win, NULL,
3618 CLICKTAB_Labels, ~0,
3619 TAG_DONE);
3620
3621 if(g->tabtitle) free(g->tabtitle);
3622 g->tabtitle = strdup(utf8title);
3623
3624 SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle,
3626 TAG_DONE);
3627
3628 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
3629 g->shared->win, NULL,
3630 CLICKTAB_Labels, &g->shared->tab_list,
3631 TAG_DONE);
3632
3633 if(ClickTabBase->lib_Version < 53)
3634 RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT],
3635 g->shared->win, NULL, TRUE);
3636 }
3637 }
3638
3639 if(g == g->shared->gw) {
3640 if((g->shared->wintitle == NULL) || (strcmp(utf8title, g->shared->wintitle)))
3641 {
3642 if(g->shared->wintitle) free(g->shared->wintitle);
3643 g->shared->wintitle = strdup(utf8title);
3644 SetWindowTitles(g->shared->win, g->shared->wintitle, ami_gui_get_screen_title());
3645 }
3646 }
3647
3648 ami_utf8_free(utf8title);
3649}
3650
3652{
3653 struct IBox *bbox;
3654
3655 if(!g || !g->bw) return;
3656 if(browser_window_has_content(g->bw) == false) return;
3657
3658 if(g == g->shared->gw) {
3659 int width, height;
3660 if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
3661 amiga_warn_user("NoMemory", "");
3662 return;
3663 }
3664
3665 if(g->shared->objects[GID_VSCROLL]) {
3667 RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL],g->shared->win,NULL,
3668 SCROLLER_Total, (ULONG)(height),
3669 SCROLLER_Visible, bbox->Height,
3670 TAG_DONE);
3671 }
3672
3673 if(g->shared->objects[GID_HSCROLL])
3674 {
3676 RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL],
3677 g->shared->win, NULL,
3678 SCROLLER_Total, (ULONG)(width),
3679 SCROLLER_Visible, bbox->Width,
3680 TAG_DONE);
3681 }
3682
3684 }
3685
3687 g->shared->new_content = true;
3688}
3689
3690
3691/**
3692 * Invalidates an area of an amiga browser window
3693 *
3694 * \param g gui_window
3695 * \param rect area to redraw or NULL for the entire window area
3696 * \return NSERROR_OK on success or appropriate error code
3697 */
3699 const struct rect *restrict rect)
3700{
3701 struct nsObject *nsobj;
3702 struct rect *restrict deferred_rect;
3703
3704 if(!g) return NSERROR_BAD_PARAMETER;
3705
3706 if (rect == NULL) {
3707 if (g != g->shared->gw) {
3708 return NSERROR_OK;
3709 }
3710 } else {
3712 g->deferred_rects_pool)) {
3714 sizeof(struct rect));
3715 CopyMem(rect, deferred_rect, sizeof(struct rect));
3716 nsobj = AddObject(g->deferred_rects, AMINS_RECT);
3717 nsobj->objstruct = deferred_rect;
3718 } else {
3719 NSLOG(netsurf, INFO,
3720 "Ignoring duplicate or subset of queued box redraw");
3721 }
3722 }
3723 ami_schedule_redraw(g->shared, false);
3724
3725 return NSERROR_OK;
3726}
3727
3728
3729static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
3730{
3731 struct Node *tabnode;
3732 struct IBox *bbox;
3733
3734 /* Clear the last new tab list */
3735 gwin->last_new_tab = NULL;
3736
3737 if(gwin->tabs == 0) return;
3738
3740 &gwin->gw->scrollx, &gwin->gw->scrolly);
3741
3742 GetAttr(CLICKTAB_CurrentNode, (Object *)gwin->objects[GID_TABS],
3743 (ULONG *)&tabnode);
3744 GetClickTabNodeAttrs(tabnode,
3745 TNA_UserData, &gwin->gw,
3746 TAG_DONE);
3747 cur_gw = gwin->gw;
3748
3750
3751 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
3752 amiga_warn_user("NoMemory", "");
3753 return;
3754 }
3755
3756 if((gwin->gw->bw == NULL) || (browser_window_has_content(gwin->gw->bw)) == false) {
3757 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
3758 gwin->win, NULL, STRINGA_TextVal, "", TAG_DONE);
3759
3760 ami_plot_clear_bbox(gwin->win->RPort, bbox);
3762 return;
3763 }
3764
3766 ami_update_buttons(gwin);
3768
3769 if(redraw)
3770 {
3771 struct rect rect;
3772
3773 ami_plot_clear_bbox(gwin->win->RPort, bbox);
3777 amiga_window_invalidate_area(gwin->gw, NULL);
3778
3779 rect.x0 = rect.x1 = gwin->gw->scrollx;
3780 rect.y0 = rect.y1 = gwin->gw->scrolly;
3781
3782 gui_window_set_scroll(gwin->gw, &rect);
3783 gwin->redraw_scroll = false;
3784
3789
3790 gui_window_set_icon(gwin->gw, gwin->gw->favicon);
3791 gui_page_info_change(gwin->gw);
3792 }
3793
3795}
3796
3798{
3799 struct nsObject *node;
3800 struct nsObject *nnode;
3801 struct ami_generic_window *w;
3802
3803 /* Disable the multiple tabs open warning */
3804 nsoption_set_bool(tab_close_warn, false);
3805
3807 node = (struct nsObject *)GetHead((struct List *)window_list);
3808
3809 do {
3810 nnode=(struct nsObject *)GetSucc((struct Node *)node);
3811 w = node->objstruct;
3812
3813 if(w->tbl->close != NULL) {
3814 if(node->Type == AMINS_WINDOW) {
3815 struct gui_window_2 *gwin = (struct gui_window_2 *)w;
3816 ShowWindow(gwin->win, WINDOW_BACKMOST); // do we need this??
3817 }
3818 w->tbl->close(w);
3819 }
3820 } while((node = nnode));
3821
3822 win_destroyed = true;
3823 }
3824
3826 /* last window closed, so exit */
3827 ami_quit = true;
3828 }
3829}
3830
3832{
3833 int res = -1;
3834#ifdef __amigaos4__
3835 char *utf8text = ami_utf8_easy(messages_get("TCPIPShutdown"));
3836 char *utf8gadgets = ami_utf8_easy(messages_get("AbortShutdown"));
3837
3838 DisplayBeep(NULL);
3839
3840 res = TimedDosRequesterTags(TDR_ImageType, TDRIMAGE_INFO,
3841 TDR_TitleString, messages_get("NetSurf"),
3842 TDR_FormatString, utf8text,
3843 TDR_GadgetString, utf8gadgets,
3844 TDR_Timeout, 5,
3845 TDR_Inactive, TRUE,
3846 TAG_DONE);
3847
3848 free(utf8text);
3849 free(utf8gadgets);
3850#endif
3851 if(res == -1) { /* Requester timed out */
3853 }
3854}
3855
3856static void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL donotwait)
3857{
3858 if(scrn == NULL) return;
3859
3860 if(locked_screen) {
3861 UnlockPubScreen(NULL,scrn);
3862 locked_screen = FALSE;
3863 }
3864
3865 /* If this is our own screen, wait for visitor windows to close */
3866 if(screen_signal == -1) return;
3867
3868 if(CloseScreen(scrn) == TRUE) {
3869 if(screen_signal != -1) {
3870 FreeSignal(screen_signal);
3871 screen_signal = -1;
3872 scrn = NULL;
3873 }
3874 return;
3875 }
3876 if(donotwait == TRUE) return;
3877
3878 ULONG scrnsig = 1 << screen_signal;
3879 NSLOG(netsurf, INFO,
3880 "Waiting for visitor windows to close... (signal)");
3881 Wait(scrnsig);
3882
3883 while (CloseScreen(scrn) == FALSE) {
3884 NSLOG(netsurf, INFO,
3885 "Waiting for visitor windows to close... (polling)");
3886 Delay(50);
3887 }
3888
3889 FreeSignal(screen_signal);
3890 screen_signal = -1;
3891 scrn = NULL;
3892}
3893
3895{
3896 if(!IsMinListEmpty(window_list)) return;
3897
3898 if(nsoption_bool(close_no_quit) == false)
3899 {
3900 ami_quit = true;
3901 return;
3902 }
3903 else
3904 {
3906 }
3907}
3908
3909static void gui_quit(void)
3910{
3912
3913 urldb_save(nsoption_charp(url_file));
3914 urldb_save_cookies(nsoption_charp(cookie_file));
3915 hotlist_fini();
3916#ifdef __amigaos4__
3917 if(IApplication && ami_appid)
3918 UnregisterApplication(ami_appid, NULL);
3919#endif
3921
3923
3924 ami_font_fini();
3925 ami_help_free();
3926
3927 NSLOG(netsurf, INFO, "Freeing menu items");
3930
3931 NSLOG(netsurf, INFO, "Freeing mouse pointers");
3933
3936#ifdef __amigaos4__
3937 FreeStringClass(urlStringClass);
3938#endif
3939
3941
3944
3945 NSLOG(netsurf, INFO, "Closing screen");
3947 if(nsscreentitle) FreeVec(nsscreentitle);
3948}
3949
3950char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
3951{
3952 STRPTR filename = NULL;
3953
3954 if ((filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url)))) {
3955 NSLOG(netsurf, INFO, "favicon cache location: %s", filename);
3956
3957 if (only_if_avail == true) {
3958 BPTR lock = 0;
3959 if((lock = Lock(filename, ACCESS_READ))) {
3960 UnLock(lock);
3961 return filename;
3962 }
3963 } else {
3964 return filename;
3965 }
3966 }
3967 return NULL;
3968}
3969
3970static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon)
3971{
3972 STRPTR filename = NULL;
3973
3974 if ((filename = ami_gui_get_cache_favicon_name(url, false))) {
3975 if(favicon) amiga_bitmap_save(favicon, filename, AMI_BITMAP_SCALE_ICON);
3976 FreeVec(filename);
3977 }
3978}
3979
3981{
3982 char *url;
3983 nsurl *nsurl;
3984
3985 GetAttr(STRINGA_TextVal,
3986 (Object *)gwin->objects[GID_URL],
3987 (ULONG *)&url);
3988
3989 if(nsurl_create(url, &nsurl) == NSERROR_OK) {
3990 if(hotlist_has_url(nsurl)) {
3991 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL,
3992 BUTTON_RenderImage, gwin->objects[GID_FAVE_RMV], TAG_DONE);
3993
3994 if (gwin->gw->favicon)
3996 } else {
3997 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL,
3998 BUTTON_RenderImage, gwin->objects[GID_FAVE_ADD], TAG_DONE);
3999 }
4000
4002 }
4003}
4004
4005static bool ami_gui_hotlist_add(void *userdata, int level, int item,
4006 const char *title, nsurl *url, bool is_folder)
4007{
4008 struct ami_gui_tb_userdata *tb_userdata = (struct ami_gui_tb_userdata *)userdata;
4009 struct Node *speed_button_node;
4010 char menu_icon[1024];
4011 char *utf8title = NULL;
4012
4013 if(level != 1) return false;
4014 if(item > AMI_GUI_TOOLBAR_MAX) return false;
4015 if(is_folder == true) return false;
4016
4017 if(utf8_from_local_encoding(title,
4018 (strlen(title) < NSA_MAX_HOTLIST_BUTTON_LEN) ? strlen(title) : NSA_MAX_HOTLIST_BUTTON_LEN,
4019 &utf8title) != NSERROR_OK)
4020 return false;
4021
4022 char *iconname = ami_gui_get_cache_favicon_name(url, true);
4023 if (iconname == NULL) iconname = ASPrintf("icons/content.png");
4024 ami_locate_resource(menu_icon, iconname);
4025
4026 tb_userdata->gw->hotlist_toolbar_lab[item] = BitMapObj,
4027 IA_Scalable, TRUE,
4028 BITMAP_Screen, scrn,
4029 BITMAP_SourceFile, menu_icon,
4030 BITMAP_Masking, TRUE,
4031 BitMapEnd;
4032
4033 /* \todo make this scale the bitmap to these dimensions */
4034 SetAttrs(tb_userdata->gw->hotlist_toolbar_lab[item],
4035 BITMAP_Width, 16,
4036 BITMAP_Height, 16,
4037 TAG_DONE);
4038
4039 Object *lab_item = LabelObj,
4040 // LABEL_DrawInfo, dri,
4041 LABEL_DisposeImage, TRUE,
4042 LABEL_Image, tb_userdata->gw->hotlist_toolbar_lab[item],
4043 LABEL_Text, " ",
4044 LABEL_Text, utf8title,
4045 LabelEnd;
4046
4047 free(utf8title);
4048
4049 speed_button_node = AllocSpeedButtonNode(item,
4050 SBNA_Image, lab_item,
4052 SBNA_UserData, (void *)url,
4053 TAG_DONE);
4054
4055 AddTail(tb_userdata->sblist, speed_button_node);
4056
4057 tb_userdata->items++;
4058 return true;
4059}
4060
4061static int ami_gui_hotlist_scan(struct List *speed_button_list, struct gui_window_2 *gwin)
4062{
4063 struct ami_gui_tb_userdata userdata;
4064 userdata.gw = gwin;
4065 userdata.sblist = speed_button_list;
4066 userdata.items = 0;
4067
4068 ami_hotlist_scan((void *)&userdata, 0, messages_get("HotlistToolbar"), ami_gui_hotlist_add);
4069 return userdata.items;
4070}
4071
4073{
4074 struct TagItem attrs[2];
4075
4076 attrs[0].ti_Tag = CHILD_MinWidth;
4077 attrs[0].ti_Data = 0;
4078 attrs[1].ti_Tag = TAG_DONE;
4079 attrs[1].ti_Data = 0;
4080
4081 NewList(&gwin->hotlist_toolbar_list);
4082
4083 if(ami_gui_hotlist_scan(&gwin->hotlist_toolbar_list, gwin) > 0) {
4084 gwin->objects[GID_HOTLIST] =
4086 GA_ID, GID_HOTLIST,
4087 GA_RelVerify, TRUE,
4088 ICA_TARGET, ICTARGET_IDCMP,
4089 SPEEDBAR_BevelStyle, BVS_NONE,
4090 SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list,
4091 SpeedBarEnd;
4092
4093 gwin->objects[GID_HOTLISTSEPBAR] =
4094 BevelObj,
4095 BEVEL_Style, BVS_SBAR_VERT,
4096 BevelEnd;
4097#ifdef __amigaos4__
4098 IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_ADDCHILD,
4099 gwin->win, gwin->objects[GID_HOTLIST], attrs);
4100
4101 IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_ADDIMAGE,
4102 gwin->win, gwin->objects[GID_HOTLISTSEPBAR], NULL);
4103
4104#else
4105 SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
4106 LAYOUT_AddChild, gwin->objects[GID_HOTLIST], TAG_MORE, &attrs);
4107 SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
4108 LAYOUT_AddChild, gwin->objects[GID_HOTLISTSEPBAR], TAG_DONE);
4109#endif
4110
4111 FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
4112
4113 RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
4114 gwin->win, NULL, TRUE);
4115
4116 ami_schedule_redraw(gwin, true);
4117 }
4118}
4119
4120static void ami_gui_hotlist_toolbar_free(struct gui_window_2 *gwin, struct List *speed_button_list)
4121{
4122 int i;
4123 struct Node *node;
4124 struct Node *nnode;
4125
4126 if(nsoption_bool(kiosk_mode) == true) return;
4127
4128 if(IsListEmpty(speed_button_list)) return;
4129 node = GetHead(speed_button_list);
4130
4131 do {
4132 nnode = GetSucc(node);
4133 Remove(node);
4134 FreeSpeedButtonNode(node);
4135 } while((node = nnode));
4136
4137 for(i = 0; i < AMI_GUI_TOOLBAR_MAX; i++) {
4138 if(gwin->hotlist_toolbar_lab[i]) {
4139 DisposeObject(gwin->hotlist_toolbar_lab[i]);
4140 gwin->hotlist_toolbar_lab[i] = NULL;
4141 }
4142 }
4143}
4144
4146{
4147#ifdef __amigaos4__
4148 IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_REMOVECHILD,
4149 gwin->win, gwin->objects[GID_HOTLIST]);
4150
4151 IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_REMOVECHILD,
4152 gwin->win, gwin->objects[GID_HOTLISTSEPBAR]);
4153#else
4154 SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
4155 LAYOUT_RemoveChild, gwin->objects[GID_HOTLIST], TAG_DONE);
4156 SetAttrs(gwin->objects[GID_HOTLISTLAYOUT],
4157 LAYOUT_RemoveChild, gwin->objects[GID_HOTLISTSEPBAR], TAG_DONE);
4158#endif
4159 FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
4160
4161 RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
4162 gwin->win, NULL, TRUE);
4163
4164 ami_schedule_redraw(gwin, true);
4165}
4166
4168{
4169 if(IsListEmpty(&gwin->hotlist_toolbar_list)) {
4171 return;
4172 }
4173
4174 /* Below should be SetAttr according to Autodocs */
4175 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_HOTLIST],
4176 gwin->win, NULL,
4177 SPEEDBAR_Buttons, ~0,
4178 TAG_DONE);
4179
4181
4182 if(ami_gui_hotlist_scan(&gwin->hotlist_toolbar_list, gwin) > 0) {
4183 SetGadgetAttrs((struct Gadget *)gwin->objects[GID_HOTLIST],
4184 gwin->win, NULL,
4185 SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list,
4186 TAG_DONE);
4187 } else {
4189 }
4190}
4191
4192/**
4193 * Update hotlist toolbar and recreate the menu for all windows
4194 */
4196{
4197 struct nsObject *node;
4198 struct nsObject *nnode;
4199 struct gui_window_2 *gwin;
4200
4201 if(IsMinListEmpty(window_list)) return;
4202
4204
4205 node = (struct nsObject *)GetHead((struct List *)window_list);
4206
4207 do {
4208 nnode=(struct nsObject *)GetSucc((struct Node *)node);
4209 gwin = node->objstruct;
4210
4211 if(node->Type == AMINS_WINDOW) {
4213 }
4214 } while((node = nnode));
4215}
4216
4217static void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
4218{
4219 if(ClickTabBase->lib_Version < 53) return;
4220
4221 if(show) {
4222 struct TagItem attrs[3];
4223
4224 attrs[0].ti_Tag = CHILD_WeightedWidth;
4225 attrs[0].ti_Data = 0;
4226 attrs[1].ti_Tag = CHILD_WeightedHeight;
4227 attrs[1].ti_Data = 0;
4228 attrs[2].ti_Tag = TAG_DONE;
4229 attrs[2].ti_Data = 0;
4230
4231 gwin->objects[GID_TABS] = ClickTabObj,
4232 GA_ID, GID_TABS,
4233 GA_RelVerify, TRUE,
4234 GA_Underscore, 13, // disable kb shortcuts
4236 CLICKTAB_Labels, &gwin->tab_list,
4240 ClickTabEnd;
4241
4242 gwin->objects[GID_ADDTAB] = ButtonObj,
4243 GA_ID, GID_ADDTAB,
4244 GA_RelVerify, TRUE,
4246 GA_Text, "+",
4247 BUTTON_RenderImage, gwin->objects[GID_ADDTAB_BM],
4248 ButtonEnd;
4249#ifdef __amigaos4__
4250 IDoMethod(gwin->objects[GID_TABLAYOUT], LM_ADDCHILD,
4251 gwin->win, gwin->objects[GID_TABS], NULL);
4252
4253 IDoMethod(gwin->objects[GID_TABLAYOUT], LM_ADDCHILD,
4254 gwin->win, gwin->objects[GID_ADDTAB], attrs);
4255#else
4256 SetAttrs(gwin->objects[GID_TABLAYOUT],
4257 LAYOUT_AddChild, gwin->objects[GID_TABS], TAG_DONE);
4258 SetAttrs(gwin->objects[GID_TABLAYOUT],
4259 LAYOUT_AddChild, gwin->objects[GID_ADDTAB], TAG_MORE, &attrs);
4260#endif
4261 } else {
4262#ifdef __amigaos4__
4263 IDoMethod(gwin->objects[GID_TABLAYOUT], LM_REMOVECHILD,
4264 gwin->win, gwin->objects[GID_TABS]);
4265
4266 IDoMethod(gwin->objects[GID_TABLAYOUT], LM_REMOVECHILD,
4267 gwin->win, gwin->objects[GID_ADDTAB]);
4268#else
4269 SetAttrs(gwin->objects[GID_TABLAYOUT],
4270 LAYOUT_RemoveChild, gwin->objects[GID_TABS], TAG_DONE);
4271 SetAttrs(gwin->objects[GID_TABLAYOUT],
4272 LAYOUT_RemoveChild, gwin->objects[GID_ADDTAB], TAG_DONE);
4273#endif
4274
4275 gwin->objects[GID_TABS] = NULL;
4276 gwin->objects[GID_ADDTAB] = NULL;
4277 }
4278
4279 FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
4280
4281 RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
4282 gwin->win, NULL, TRUE);
4283
4284 if (gwin->gw && gwin->gw->bw) {
4288 amiga_window_invalidate_area(gwin->gw, NULL);
4289 }
4290}
4291
4293{
4294 struct nsObject *node;
4295 struct nsObject *nnode;
4296 struct gui_window_2 *gwin;
4297
4298 if(IsMinListEmpty(window_list)) return;
4299
4300 node = (struct nsObject *)GetHead((struct List *)window_list);
4301
4302 do {
4303 nnode=(struct nsObject *)GetSucc((struct Node *)node);
4304 gwin = node->objstruct;
4305
4306 if(node->Type == AMINS_WINDOW)
4307 {
4308 if(gwin->tabs == 1) {
4309 if(nsoption_bool(tab_always_show) == true) {
4310 ami_toggletabbar(gwin, true);
4311 } else {
4312 ami_toggletabbar(gwin, false);
4313 }
4314 }
4315 }
4316 } while((node = nnode));
4317}
4318
4319static void ami_gui_search_ico_refresh(void *p)
4320{
4322}
4323
4324/**
4325 * Count windows, and optionally tabs.
4326 *
4327 * \param window window to count tabs of
4328 * \param tabs if window > 0, will be updated to contain the number of tabs
4329 * in that window, unchanged otherwise
4330 * \return number of windows currently open
4331 */
4332int ami_gui_count_windows(int window, int *tabs)
4333{
4334 int windows = 0;
4335 struct nsObject *node, *nnode;
4336 struct gui_window_2 *gwin;
4337
4339 node = (struct nsObject *)GetHead((struct List *)window_list);
4340 do {
4341 nnode=(struct nsObject *)GetSucc((struct Node *)node);
4342
4343 gwin = node->objstruct;
4344
4345 if(node->Type == AMINS_WINDOW) {
4346 windows++;
4347 if(window == windows) *tabs = gwin->tabs;
4348 }
4349 } while((node = nnode));
4350 }
4351 return windows;
4352}
4353
4354/**
4355 * Set the scale of a gui window
4356 *
4357 * \param gw gui_window to set scale for
4358 * \param scale scale to set
4359 */
4360void ami_gui_set_scale(struct gui_window *gw, float scale)
4361{
4362 browser_window_set_scale(gw->bw, scale, true);
4363 ami_schedule_redraw(gw->shared, true);
4364}
4365
4366void ami_gui_adjust_scale(struct gui_window *gw, float adjustment)
4367{
4368 browser_window_set_scale(gw->bw, adjustment, false);
4369 ami_schedule_redraw(gw->shared, true);
4370}
4371
4373{
4374 if(nsoption_bool(new_tab_is_active) == true) return;
4375
4376 /* Switch to the just-opened tab (if new_tab_is_active, we already did!) */
4377 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_TABS],
4378 gwin->win, NULL,
4379 CLICKTAB_CurrentNode, gwin->last_new_tab,
4380 TAG_DONE);
4381
4382 ami_switch_tab(gwin, false);
4383}
4384
4386{
4387 nsurl *url;
4388 nserror error;
4389 struct browser_window *bw = NULL;
4390
4391 error = nsurl_create(nsoption_charp(homepage_url), &url);
4392 if (error == NSERROR_OK) {
4395 url,
4396 NULL,
4397 gwin->gw->bw,
4398 &bw);
4399 nsurl_unref(url);
4400 }
4401 if (error != NSERROR_OK) {
4403 return error;
4404 }
4405
4407
4408 return NSERROR_OK;
4409}
4410
4411static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
4412 int left, int top, int width, int height,
4413 int sx, int sy, struct IBox *bbox, struct redraw_context *ctx)
4414{
4415 struct gui_globals *glob = (struct gui_globals *)ctx->priv;
4416 int x, y;
4417 struct rect clip;
4418 int tile_size_x;
4419 int tile_size_y;
4420
4421 ami_plot_ra_get_size(glob, &tile_size_x, &tile_size_y);
4423
4424 if(top < 0) {
4425 height += top;
4426 top = 0;
4427 }
4428
4429 if(left < 0) {
4430 width += left;
4431 left = 0;
4432 }
4433
4434 if(top < sy) {
4435 height += (top - sy);
4436 top = sy;
4437 }
4438 if(left < sx) {
4439 width += (left - sx);
4440 left = sx;
4441 }
4442
4443 if(((top - sy) + height) > bbox->Height)
4444 height = bbox->Height - (top - sy);
4445
4446 if(((left - sx) + width) > bbox->Width)
4447 width = bbox->Width - (left - sx);
4448
4449 if(width <= 0) return;
4450 if(height <= 0) return;
4451
4452 if(busy) ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
4453
4454 for(y = top; y < (top + height); y += tile_size_y) {
4455 clip.y0 = 0;
4456 clip.y1 = tile_size_y;
4457 if(clip.y1 > height) clip.y1 = height;
4458 if(((y - sy) + clip.y1) > bbox->Height)
4459 clip.y1 = bbox->Height - (y - sy);
4460
4461 for(x = left; x < (left + width); x += tile_size_x) {
4462 clip.x0 = 0;
4463 clip.x1 = tile_size_x;
4464 if(clip.x1 > width) clip.x1 = width;
4465 if(((x - sx) + clip.x1) > bbox->Width)
4466 clip.x1 = bbox->Width - (x - sx);
4467
4468 if(browser_window_redraw(gwin->gw->bw,
4469 clip.x0 - (int)x,
4470 clip.y0 - (int)y,
4471 &clip, ctx))
4472 {
4473 ami_clearclipreg(glob);
4474#ifdef __amigaos4__
4475 BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
4476 BLITA_Source, ami_plot_ra_get_bitmap(glob),
4477 BLITA_SrcX, 0,
4478 BLITA_SrcY, 0,
4479 BLITA_DestType, BLITT_RASTPORT,
4480 BLITA_Dest, gwin->win->RPort,
4481 BLITA_DestX, bbox->Left + (int)(x - sx),
4482 BLITA_DestY, bbox->Top + (int)(y - sy),
4483 BLITA_Width, (int)(clip.x1),
4484 BLITA_Height, (int)(clip.y1),
4485 TAG_DONE);
4486#else
4487 BltBitMapRastPort(ami_plot_ra_get_bitmap(glob), 0, 0, gwin->win->RPort,
4488 bbox->Left + (int)(x - sx),
4489 bbox->Top + (int)(y - sy),
4490 (int)(clip.x1), (int)(clip.y1), 0xC0);
4491#endif
4492 }
4493 }
4494 }
4495
4496 if(busy) ami_reset_pointer(gwin);
4497}
4498
4499
4500/**
4501 * Redraw an area of the browser window - Amiga-specific function
4502 *
4503 * \param g a struct gui_window
4504 * \param bw a struct browser_window
4505 * \param busy busy flag passed to tiled redraw.
4506 * \param x0 top-left co-ordinate (in document co-ordinates)
4507 * \param y0 top-left co-ordinate (in document co-ordinates)
4508 * \param x1 bottom-right co-ordinate (in document co-ordinates)
4509 * \param y1 bottom-right co-ordinate (in document co-ordinates)
4510 */
4511
4512static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw, bool busy,
4513 int x0, int y0, int x1, int y1)
4514{
4515 struct IBox *bbox;
4516 ULONG sx, sy;
4517
4518 struct redraw_context ctx = {
4519 .interactive = true,
4520 .background_images = true,
4521 .plot = &amiplot,
4522 .priv = browserglob
4523 };
4524
4525 if(!g) return;
4526 if(browser_window_redraw_ready(bw) == false) return;
4527
4528 sx = g->scrollx;
4529 sy = g->scrolly;
4530
4531 if(g != g->shared->gw) return;
4532
4533 if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
4534 amiga_warn_user("NoMemory", "");
4535 return;
4536 }
4537
4538 ami_do_redraw_tiled(g->shared, busy, x0, y0,
4539 x1 - x0, y1 - y0, sx, sy, bbox, &ctx);
4540
4542
4543 return;
4544}
4545
4546
4547static void ami_refresh_window(struct gui_window_2 *gwin)
4548{
4549 /* simplerefresh only */
4550
4551 struct IBox *bbox;
4552 int sx, sy;
4553 struct RegionRectangle *regrect;
4554 struct rect r;
4555
4556 sx = gwin->gw->scrollx;
4557 sy = gwin->gw->scrolly;
4558
4559 ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
4560
4561 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
4562 amiga_warn_user("NoMemory", "");
4563 return;
4564 }
4565
4566 BeginRefresh(gwin->win);
4567
4568 r.x0 = (gwin->win->RPort->Layer->DamageList->bounds.MinX - bbox->Left) + sx - 1;
4569 r.x1 = (gwin->win->RPort->Layer->DamageList->bounds.MaxX - bbox->Left) + sx + 2;
4570 r.y0 = (gwin->win->RPort->Layer->DamageList->bounds.MinY - bbox->Top) + sy - 1;
4571 r.y1 = (gwin->win->RPort->Layer->DamageList->bounds.MaxY - bbox->Top) + sy + 2;
4572
4573 regrect = gwin->win->RPort->Layer->DamageList->RegionRectangle;
4574
4576
4577 while(regrect)
4578 {
4579 r.x0 = (regrect->bounds.MinX - bbox->Left) + sx - 1;
4580 r.x1 = (regrect->bounds.MaxX - bbox->Left) + sx + 2;
4581 r.y0 = (regrect->bounds.MinY - bbox->Top) + sy - 1;
4582 r.y1 = (regrect->bounds.MaxY - bbox->Top) + sy + 2;
4583
4584 regrect = regrect->Next;
4585
4587 }
4588
4589 EndRefresh(gwin->win, TRUE);
4590
4592 ami_reset_pointer(gwin);
4593}
4594
4595HOOKF(void, ami_scroller_hook, Object *, object, struct IntuiMessage *)
4596{
4597 ULONG gid;
4598 struct gui_window_2 *gwin = hook->h_Data;
4599 struct IntuiWheelData *wheel;
4600 struct Node *node = NULL;
4601 nsurl *url;
4602
4603 switch(msg->Class)
4604 {
4605 case IDCMP_IDCMPUPDATE:
4606 gid = GetTagData( GA_ID, 0, msg->IAddress );
4607
4608 switch( gid )
4609 {
4610 case GID_HSCROLL:
4611 case GID_VSCROLL:
4612 if(nsoption_bool(faster_scroll) == true) gwin->redraw_scroll = true;
4613 else gwin->redraw_scroll = false;
4614
4615 ami_schedule_redraw(gwin, true);
4616 break;
4617
4618 case GID_HOTLIST:
4619 if((node = (struct Node *)GetTagData(SPEEDBAR_SelectedNode, 0, msg->IAddress))) {
4620 GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
4621
4622 if(gwin->key_state & BROWSER_MOUSE_MOD_2) {
4624 url,
4625 NULL,
4626 gwin->gw->bw,
4627 NULL);
4628 } else {
4630 url,
4631 NULL,
4633 NULL,
4634 NULL,
4635 NULL);
4636
4637 }
4638 }
4639 break;
4640 }
4641 break;
4642#ifdef __amigaos4__
4644 if(msg->Code == IMSGCODE_INTUIWHEELDATA)
4645 {
4646 wheel = (struct IntuiWheelData *)msg->IAddress;
4647
4648 ami_gui_scroll_internal(gwin, wheel->WheelX * 50, wheel->WheelY * 50);
4649 }
4650 break;
4651#endif
4652 case IDCMP_SIZEVERIFY:
4653 break;
4654
4655 case IDCMP_REFRESHWINDOW:
4656 ami_refresh_window(gwin);
4657 break;
4658
4659 default:
4660 NSLOG(netsurf, INFO,
4661 "IDCMP hook unhandled event: %ld", msg->Class);
4662 break;
4663 }
4664// ReplyMsg((struct Message *)msg);
4665}
4666
4667/* exported function documented in gui.h */
4668nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table)
4669{
4670 struct nsObject *node = AddObject(window_list, type);
4671 if(node == NULL) return NSERROR_NOMEM;
4672 node->objstruct = win;
4673
4674 struct ami_generic_window *w = (struct ami_generic_window *)win;
4675 w->tbl = table;
4676 w->node = node;
4677
4678 return NSERROR_OK;
4679}
4680
4681/* exported function documented in gui.h */
4683{
4684 struct ami_generic_window *w = (struct ami_generic_window *)win;
4685
4686 if(w->node->Type == AMINS_TVWINDOW) {
4688 } else {
4689 DelObject(w->node);
4690 }
4691}
4692
4693static const struct ami_win_event_table ami_gui_table = {
4696};
4697
4698static struct gui_window *
4700 struct gui_window *existing,
4702{
4703 struct gui_window *g = NULL;
4704 ULONG offset = 0;
4705 ULONG curx = nsoption_int(window_x), cury = nsoption_int(window_y);
4706 ULONG curw = nsoption_int(window_width), curh = nsoption_int(window_height);
4707 char nav_west[100],nav_west_s[100],nav_west_g[100];
4708 char nav_east[100],nav_east_s[100],nav_east_g[100];
4709 char stop[100],stop_s[100],stop_g[100];
4710 char reload[100],reload_s[100],reload_g[100];
4711 char home[100],home_s[100],home_g[100];
4712 char closetab[100],closetab_s[100],closetab_g[100];
4713 char addtab[100],addtab_s[100],addtab_g[100];
4714 char fave[100], unfave[100];
4715 char pi_insecure[100], pi_internal[100], pi_local[100], pi_secure[100], pi_warning[100];
4716 char tabthrobber[100];
4717 ULONG refresh_mode = WA_SmartRefresh;
4718 ULONG defer_layout = TRUE;
4719 ULONG idcmp_sizeverify = IDCMP_SIZEVERIFY;
4720
4721 NSLOG(netsurf, INFO, "Creating window");
4722
4723 if (!scrn) ami_openscreenfirst();
4724
4725 if (nsoption_bool(kiosk_mode)) flags &= ~GW_CREATE_TAB;
4726 if (nsoption_bool(resize_with_contents)) idcmp_sizeverify = 0;
4727
4728 /* Offset the new window by titlebar + 1 as per AmigaOS style guide.
4729 * If we don't have a clone window we offset by all windows open. */
4730 offset = scrn->WBorTop + scrn->Font->ta_YSize + 1;
4731
4732 if(existing) {
4733 curx = existing->shared->win->LeftEdge;
4734 cury = existing->shared->win->TopEdge + offset;
4735 curw = existing->shared->win->Width;
4736 curh = existing->shared->win->Height;
4737 } else {
4738 if(nsoption_bool(kiosk_mode) == false) {
4739 cury += offset * ami_gui_count_windows(0, NULL);
4740 }
4741 }
4742
4743 if(curh > (scrn->Height - cury)) curh = scrn->Height - cury;
4744
4745 g = calloc(1, sizeof(struct gui_window));
4746
4747 if(!g)
4748 {
4749 amiga_warn_user("NoMemory","");
4750 return NULL;
4751 }
4752
4753 NewList(&g->dllist);
4756 g->bw = bw;
4757
4758 NewList(&g->loglist);
4759#ifdef __amigaos4__
4760 g->logcolumns = AllocLBColumnInfo(4,
4761 LBCIA_Column, 0,
4762 // LBCIA_CopyTitle, TRUE,
4763 LBCIA_Title, "time", /**\TODO: add these to Messages */
4764 LBCIA_Weight, 10,
4765 LBCIA_DraggableSeparator, TRUE,
4766 LBCIA_Separator, TRUE,
4767 LBCIA_Column, 1,
4768 // LBCIA_CopyTitle, TRUE,
4769 LBCIA_Title, "source", /**\TODO: add these to Messages */
4770 LBCIA_Weight, 10,
4771 LBCIA_DraggableSeparator, TRUE,
4772 LBCIA_Separator, TRUE,
4773 LBCIA_Column, 2,
4774 // LBCIA_CopyTitle, TRUE,
4775 LBCIA_Title, "level", /**\TODO: add these to Messages */
4776 LBCIA_Weight, 5,
4777 LBCIA_DraggableSeparator, TRUE,
4778 LBCIA_Separator, TRUE,
4779 LBCIA_Column, 3,
4780 // LBCIA_CopyTitle, TRUE,
4781 LBCIA_Title, "message", /**\TODO: add these to Messages */
4782 LBCIA_Weight, 75,
4783 LBCIA_DraggableSeparator, TRUE,
4784 LBCIA_Separator, TRUE,
4785 TAG_DONE);
4786#else
4787 /**\TODO write OS3-compatible version */
4788#endif
4789
4790 if((flags & GW_CREATE_TAB) && existing)
4791 {
4792 g->shared = existing->shared;
4793 g->tab = g->shared->next_tab;
4794 g->shared->tabs++; /* do this early so functions know to update the tabs */
4795
4796 if((g->shared->tabs == 2) && (nsoption_bool(tab_always_show) == false)) {
4797 ami_toggletabbar(g->shared, true);
4798 }
4799
4800 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
4801 g->shared->win, NULL,
4802 CLICKTAB_Labels, ~0,
4803 TAG_DONE);
4804
4805 g->tab_node = AllocClickTabNode(TNA_Text, messages_get("NetSurf"),
4806 TNA_Number, g->tab,
4807 TNA_UserData, g,
4808 TNA_CloseGadget, TRUE,
4809 TAG_DONE);
4810
4811 if(nsoption_bool(new_tab_last)) {
4812 AddTail(&g->shared->tab_list, g->tab_node);
4813 } else {
4814 struct Node *insert_after = existing->tab_node;
4815
4816 if(g->shared->last_new_tab)
4817 insert_after = g->shared->last_new_tab;
4818 Insert(&g->shared->tab_list, g->tab_node, insert_after);
4819 }
4820
4821 g->shared->last_new_tab = g->tab_node;
4822
4823 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
4824 g->shared->win, NULL,
4825 CLICKTAB_Labels, &g->shared->tab_list,
4826 TAG_DONE);
4827
4828 if(nsoption_bool(new_tab_is_active)) {
4829 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
4830 g->shared->win, NULL,
4831 CLICKTAB_Current, g->tab,
4832 TAG_DONE);
4833 }
4834
4835 if(ClickTabBase->lib_Version < 53) {
4836 RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT],
4837 g->shared->win, NULL, TRUE);
4838 }
4839
4840 g->shared->next_tab++;
4841
4842 if(nsoption_bool(new_tab_is_active)) ami_switch_tab(g->shared,false);
4843
4846
4847 return g;
4848 }
4849
4850 g->shared = calloc(1, sizeof(struct gui_window_2));
4851
4852 if(!g->shared)
4853 {
4854 amiga_warn_user("NoMemory","");
4855 return NULL;
4856 }
4857
4859
4860 g->shared->scrollerhook.h_Entry = (void *)ami_scroller_hook;
4861 g->shared->scrollerhook.h_Data = g->shared;
4862
4863 g->shared->favicon_hook.h_Entry = (void *)ami_set_favicon_render_hook;
4864 g->shared->favicon_hook.h_Data = g->shared;
4865
4866 g->shared->throbber_hook.h_Entry = (void *)ami_set_throbber_render_hook;
4867 g->shared->throbber_hook.h_Data = g->shared;
4868
4869 g->shared->browser_hook.h_Entry = (void *)ami_gui_browser_render_hook;
4870 g->shared->browser_hook.h_Data = g->shared;
4871
4872 newprefs_hook.h_Entry = (void *)ami_gui_newprefs_hook;
4873 newprefs_hook.h_Data = 0;
4874
4878 g->shared->clicktab_ctxmenu = NULL;
4879
4880 if(nsoption_bool(window_simple_refresh) == true) {
4881 refresh_mode = WA_SimpleRefresh;
4882 defer_layout = FALSE; /* testing reveals this does work with SimpleRefresh,
4883 but the docs say it doesn't so err on the side of caution. */
4884 } else {
4885 refresh_mode = WA_SmartRefresh;
4886 defer_layout = TRUE;
4887 }
4888
4889 if(!nsoption_bool(kiosk_mode))
4890 {
4891 ULONG addtabclosegadget = TAG_IGNORE;
4892 ULONG iconifygadget = FALSE;
4893
4894#ifdef __amigaos4__
4895 if (nsoption_charp(pubscreen_name) &&
4896 (locked_screen == TRUE) &&
4897 (strcmp(nsoption_charp(pubscreen_name), "Workbench") == 0))
4898 iconifygadget = TRUE;
4899#endif
4900
4901 NSLOG(netsurf, INFO, "Creating menu");
4902 struct Menu *menu = ami_gui_menu_create(g->shared);
4903
4904 NewList(&g->shared->tab_list);
4905 g->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
4906 TNA_Number, 0,
4907 TNA_UserData, g,
4908 TNA_CloseGadget, TRUE,
4909 TAG_DONE);
4910 AddTail(&g->shared->tab_list,g->tab_node);
4911
4913 g->shared->search_bm = NULL;
4914
4915 g->shared->tabs=1;
4916 g->shared->next_tab=1;
4917
4918 g->shared->svbuffer = calloc(1, 2000);
4919
4921 translate_escape_chars(messages_get("HelpToolbarBack"));
4923 translate_escape_chars(messages_get("HelpToolbarForward"));
4925 translate_escape_chars(messages_get("HelpToolbarStop"));
4927 translate_escape_chars(messages_get("HelpToolbarReload"));
4929 translate_escape_chars(messages_get("HelpToolbarHome"));
4930 g->shared->helphints[GID_URL] =
4931 translate_escape_chars(messages_get("HelpToolbarURL"));
4933 translate_escape_chars(messages_get("HelpToolbarWebSearch"));
4935 translate_escape_chars(messages_get("HelpToolbarAddTab"));
4936
4942
4943 ami_get_theme_filename(nav_west, "theme_nav_west", false);
4944 ami_get_theme_filename(nav_west_s, "theme_nav_west_s", false);
4945 ami_get_theme_filename(nav_west_g, "theme_nav_west_g", false);
4946 ami_get_theme_filename(nav_east, "theme_nav_east", false);
4947 ami_get_theme_filename(nav_east_s, "theme_nav_east_s", false);
4948 ami_get_theme_filename(nav_east_g, "theme_nav_east_g", false);
4949 ami_get_theme_filename(stop, "theme_stop", false);
4950 ami_get_theme_filename(stop_s, "theme_stop_s", false);
4951 ami_get_theme_filename(stop_g, "theme_stop_g", false);
4952 ami_get_theme_filename(reload, "theme_reload", false);
4953 ami_get_theme_filename(reload_s, "theme_reload_s", false);
4954 ami_get_theme_filename(reload_g, "theme_reload_g", false);
4955 ami_get_theme_filename(home, "theme_home", false);
4956 ami_get_theme_filename(home_s, "theme_home_s", false);
4957 ami_get_theme_filename(home_g, "theme_home_g", false);
4958 ami_get_theme_filename(closetab, "theme_closetab", false);
4959 ami_get_theme_filename(closetab_s, "theme_closetab_s", false);
4960 ami_get_theme_filename(closetab_g, "theme_closetab_g", false);
4961 ami_get_theme_filename(addtab, "theme_addtab", false);
4962 ami_get_theme_filename(addtab_s, "theme_addtab_s", false);
4963 ami_get_theme_filename(addtab_g, "theme_addtab_g", false);
4964 ami_get_theme_filename(tabthrobber, "theme_tab_loading", false);
4965 ami_get_theme_filename(fave, "theme_fave", false);
4966 ami_get_theme_filename(unfave, "theme_unfave", false);
4967 ami_get_theme_filename(pi_insecure, "theme_pageinfo_insecure", false);
4968 ami_get_theme_filename(pi_internal, "theme_pageinfo_internal", false);
4969 ami_get_theme_filename(pi_local, "theme_pageinfo_local", false);
4970 ami_get_theme_filename(pi_secure, "theme_pageinfo_secure", false);
4971 ami_get_theme_filename(pi_warning, "theme_pageinfo_warning", false);
4972
4974 BITMAP_SourceFile, fave,
4975 BITMAP_Screen, scrn,
4976 BITMAP_Masking, TRUE,
4977 BitMapEnd;
4978
4980 BITMAP_SourceFile, unfave,
4981 BITMAP_Screen, scrn,
4982 BITMAP_Masking, TRUE,
4983 BitMapEnd;
4984
4986 BITMAP_SourceFile, addtab,
4987 BITMAP_SelectSourceFile, addtab_s,
4988 BITMAP_DisabledSourceFile, addtab_g,
4989 BITMAP_Screen, scrn,
4990 BITMAP_Masking, TRUE,
4991 BitMapEnd;
4992
4994 BITMAP_SourceFile, closetab,
4995 BITMAP_SelectSourceFile, closetab_s,
4996 BITMAP_DisabledSourceFile, closetab_g,
4997 BITMAP_Screen, scrn,
4998 BITMAP_Masking, TRUE,
4999 BitMapEnd;
5000
5002 BITMAP_SourceFile, pi_insecure,
5003 BITMAP_Screen, scrn,
5004 BITMAP_Masking, TRUE,
5005 BitMapEnd;
5006
5008 BITMAP_SourceFile, pi_internal,
5009 BITMAP_Screen, scrn,
5010 BITMAP_Masking, TRUE,
5011 BitMapEnd;
5012
5014 BITMAP_SourceFile, pi_local,
5015 BITMAP_Screen, scrn,
5016 BITMAP_Masking, TRUE,
5017 BitMapEnd;
5018
5020 BITMAP_SourceFile, pi_secure,
5021 BITMAP_Screen, scrn,
5022 BITMAP_Masking, TRUE,
5023 BitMapEnd;
5024
5026 BITMAP_SourceFile, pi_warning,
5027 BITMAP_Screen, scrn,
5028 BITMAP_Masking, TRUE,
5029 BitMapEnd;
5030
5031
5032 if(ClickTabBase->lib_Version < 53)
5033 {
5034 addtabclosegadget = LAYOUT_AddChild;
5036 GA_ID, GID_CLOSETAB,
5037 GA_RelVerify, TRUE,
5038 BUTTON_RenderImage, g->shared->objects[GID_CLOSETAB_BM],
5039 ButtonEnd;
5040
5042 GA_ID,GID_TABS,
5043 GA_RelVerify,TRUE,
5044 GA_Underscore,13, // disable kb shortcuts
5045 CLICKTAB_Labels,&g->shared->tab_list,
5047 ClickTabEnd;
5048
5050 GA_ID, GID_ADDTAB,
5051 GA_RelVerify, TRUE,
5052 GA_Text, "+",
5053 BUTTON_RenderImage, g->shared->objects[GID_ADDTAB_BM],
5054 ButtonEnd;
5055 }
5056 else
5057 {
5059 BITMAP_SourceFile, tabthrobber,
5060 BITMAP_Screen,scrn,
5061 BITMAP_Masking,TRUE,
5062 BitMapEnd;
5063 }
5064
5065 NSLOG(netsurf, INFO, "Creating window object");
5066
5068 WA_ScreenTitle, ami_gui_get_screen_title(),
5069 WA_Activate, TRUE,
5070 WA_DepthGadget, TRUE,
5071 WA_DragBar, TRUE,
5072 WA_CloseGadget, TRUE,
5073 WA_SizeGadget, TRUE,
5074 WA_Top,cury,
5075 WA_Left,curx,
5076 WA_Width,curw,
5077 WA_Height,curh,
5078 WA_PubScreen,scrn,
5079 WA_ReportMouse,TRUE,
5080 refresh_mode, TRUE,
5081 WA_SizeBBottom, TRUE,
5083 WA_IDCMP, IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
5084 IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
5085 IDCMP_RAWKEY | idcmp_sizeverify |
5086 IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
5087 IDCMP_REFRESHWINDOW |
5088 IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE,
5089 WINDOW_IconifyGadget, iconifygadget,
5090 WINDOW_MenuStrip, menu,
5091 WINDOW_MenuUserData, WGUD_HOOK,
5093 WINDOW_IDCMPHook, &g->shared->scrollerhook,
5094 WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_REFRESHWINDOW |
5095 IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
5096 WINDOW_SharedPort, sport,
5098 WINDOW_GadgetHelp, TRUE,
5099 WINDOW_UserData, g->shared,
5100 WINDOW_ParentGroup, g->shared->objects[GID_MAIN] = LayoutVObj,
5101 LAYOUT_DeferLayout, defer_layout,
5102 LAYOUT_SpaceOuter, TRUE,
5103 LAYOUT_AddChild, g->shared->objects[GID_TOOLBARLAYOUT] = LayoutHObj,
5104 LAYOUT_VertAlignment, LALIGN_CENTER,
5105 LAYOUT_AddChild, g->shared->objects[GID_BACK] = ButtonObj,
5106 GA_ID, GID_BACK,
5107 GA_RelVerify, TRUE,
5108 GA_Disabled, TRUE,
5111 BUTTON_RenderImage,BitMapObj,
5112 BITMAP_SourceFile,nav_west,
5113 BITMAP_SelectSourceFile,nav_west_s,
5114 BITMAP_DisabledSourceFile,nav_west_g,
5115 BITMAP_Screen,scrn,
5116 BITMAP_Masking,TRUE,
5117 BitMapEnd,
5118 ButtonEnd,
5119 CHILD_WeightedWidth,0,
5120 CHILD_WeightedHeight,0,
5121 LAYOUT_AddChild, g->shared->objects[GID_FORWARD] = ButtonObj,
5122 GA_ID, GID_FORWARD,
5123 GA_RelVerify, TRUE,
5124 GA_Disabled, TRUE,
5127 BUTTON_RenderImage,BitMapObj,
5128 BITMAP_SourceFile,nav_east,
5129 BITMAP_SelectSourceFile,nav_east_s,
5130 BITMAP_DisabledSourceFile,nav_east_g,
5131 BITMAP_Screen,scrn,
5132 BITMAP_Masking,TRUE,
5133 BitMapEnd,
5134 ButtonEnd,
5135 CHILD_WeightedWidth,0,
5136 CHILD_WeightedHeight,0,
5137 LAYOUT_AddChild, g->shared->objects[GID_STOP] = ButtonObj,
5138 GA_ID,GID_STOP,
5139 GA_RelVerify,TRUE,
5141 BUTTON_RenderImage,BitMapObj,
5142 BITMAP_SourceFile,stop,
5143 BITMAP_SelectSourceFile,stop_s,
5145 BITMAP_Screen,scrn,
5146 BITMAP_Masking,TRUE,
5147 BitMapEnd,
5148 ButtonEnd,
5149 CHILD_WeightedWidth,0,
5150 CHILD_WeightedHeight,0,
5151 LAYOUT_AddChild, g->shared->objects[GID_RELOAD] = ButtonObj,
5152 GA_ID,GID_RELOAD,
5153 GA_RelVerify,TRUE,
5155 BUTTON_RenderImage,BitMapObj,
5156 BITMAP_SourceFile,reload,
5157 BITMAP_SelectSourceFile,reload_s,
5159 BITMAP_Screen,scrn,
5160 BITMAP_Masking,TRUE,
5161 BitMapEnd,
5162 ButtonEnd,
5163 CHILD_WeightedWidth,0,
5164 CHILD_WeightedHeight,0,
5165 LAYOUT_AddChild, g->shared->objects[GID_HOME] = ButtonObj,
5166 GA_ID,GID_HOME,
5167 GA_RelVerify,TRUE,
5169 BUTTON_RenderImage,BitMapObj,
5170 BITMAP_SourceFile,home,
5171 BITMAP_SelectSourceFile,home_s,
5173 BITMAP_Screen,scrn,
5174 BITMAP_Masking,TRUE,
5175 BitMapEnd,
5176 ButtonEnd,
5177 CHILD_WeightedWidth,0,
5178 CHILD_WeightedHeight,0,
5179 LAYOUT_AddChild, LayoutHObj, // FavIcon, URL bar and hotlist star
5180 LAYOUT_VertAlignment, LALIGN_CENTER,
5181 LAYOUT_AddChild, g->shared->objects[GID_ICON] = SpaceObj,
5182 GA_ID, GID_ICON,
5183 SPACE_MinWidth, 16,
5184 SPACE_MinHeight, 16,
5185 SPACE_Transparent, TRUE,
5186 // SPACE_RenderHook, &g->shared->favicon_hook,
5187 SpaceEnd,
5188 CHILD_WeightedWidth, 0,
5189 CHILD_WeightedHeight, 0,
5190 LAYOUT_AddChild, g->shared->objects[GID_PAGEINFO] = ButtonObj,
5191 GA_ID, GID_PAGEINFO,
5192 GA_RelVerify, TRUE,
5193 GA_ReadOnly, FALSE,
5194 BUTTON_RenderImage, g->shared->objects[GID_PAGEINFO_INTERNAL_BM],
5195 ButtonEnd,
5196 CHILD_WeightedWidth, 0,
5197 CHILD_WeightedHeight, 0,
5198 LAYOUT_AddChild, g->shared->objects[GID_URL] =
5199#ifdef __amigaos4__
5200 NewObject(urlStringClass, NULL,
5201#else
5202 StringObj,
5203#endif
5204 STRINGA_MaxChars, 2000,
5205 GA_ID, GID_URL,
5206 GA_RelVerify, TRUE,
5208 GA_TabCycle, TRUE,
5209 STRINGA_Buffer, g->shared->svbuffer,
5210#ifdef __amigaos4__
5212#endif
5213 TAG_DONE),
5214 LAYOUT_AddChild, g->shared->objects[GID_FAVE] = ButtonObj,
5215 GA_ID, GID_FAVE,
5216 GA_RelVerify, TRUE,
5217 // GA_HintInfo, g->shared->helphints[GID_FAVE],
5218 BUTTON_RenderImage, g->shared->objects[GID_FAVE_ADD],
5219 ButtonEnd,
5220 CHILD_WeightedWidth, 0,
5221 CHILD_WeightedHeight, 0,
5222 LayoutEnd,
5223 // GA_ID, GID_TOOLBARLAYOUT,
5224 // GA_RelVerify, TRUE,
5225 // LAYOUT_RelVerify, TRUE,
5226 LAYOUT_WeightBar, TRUE,
5227 LAYOUT_AddChild, LayoutHObj,
5228 LAYOUT_VertAlignment, LALIGN_CENTER,
5229 LAYOUT_AddChild, g->shared->objects[GID_SEARCH_ICON] = ChooserObj,
5230 GA_ID, GID_SEARCH_ICON,
5231 GA_RelVerify, TRUE,
5232 CHOOSER_DropDown, TRUE,
5233 CHOOSER_Labels, g->shared->web_search_list,
5234 CHOOSER_MaxLabels, 40, /* Same as options GUI */
5235 ChooserEnd,
5236 CHILD_WeightedWidth,0,
5237 CHILD_WeightedHeight,0,
5238 LAYOUT_AddChild, g->shared->objects[GID_SEARCHSTRING] = StringObj,
5239 GA_ID,GID_SEARCHSTRING,
5240 STRINGA_TextVal, NULL,
5241 GA_RelVerify,TRUE,
5243 StringEnd,
5244 LayoutEnd,
5245 CHILD_WeightedWidth, nsoption_int(web_search_width),
5246 LAYOUT_AddChild, g->shared->objects[GID_THROBBER] = SpaceObj,
5247 GA_ID,GID_THROBBER,
5248 SPACE_MinWidth, ami_theme_throbber_get_width(),
5249 SPACE_MinHeight, ami_theme_throbber_get_height(),
5250 SPACE_Transparent,TRUE,
5251 // SPACE_RenderHook, &g->shared->throbber_hook,
5252 SpaceEnd,
5253 CHILD_WeightedWidth,0,
5254 CHILD_WeightedHeight,0,
5255 LayoutEnd,
5256 CHILD_WeightedHeight,0,
5257 LAYOUT_AddImage, BevelObj,
5258 BEVEL_Style, BVS_SBAR_VERT,
5259 BevelEnd,
5260 CHILD_WeightedHeight, 0,
5261 LAYOUT_AddChild, g->shared->objects[GID_HOTLISTLAYOUT] = LayoutVObj,
5262 LAYOUT_SpaceInner, FALSE,
5263 LayoutEnd,
5264 CHILD_WeightedHeight,0,
5265 LAYOUT_AddChild, g->shared->objects[GID_TABLAYOUT] = LayoutHObj,
5266 LAYOUT_SpaceInner,FALSE,
5267 addtabclosegadget, g->shared->objects[GID_CLOSETAB],
5268 CHILD_WeightedWidth,0,
5269 CHILD_WeightedHeight,0,
5270
5271 addtabclosegadget, g->shared->objects[GID_TABS],
5272 CHILD_CacheDomain,FALSE,
5273
5274 addtabclosegadget, g->shared->objects[GID_ADDTAB],
5275 CHILD_WeightedWidth,0,
5276 CHILD_WeightedHeight,0,
5277 LayoutEnd,
5278 CHILD_WeightedHeight,0,
5279 LAYOUT_AddChild, LayoutVObj,
5280 LAYOUT_AddChild, g->shared->objects[GID_VSCROLLLAYOUT] = LayoutHObj,
5281 LAYOUT_AddChild, LayoutVObj,
5282 LAYOUT_AddChild, g->shared->objects[GID_HSCROLLLAYOUT] = LayoutVObj,
5283 LAYOUT_AddChild, g->shared->objects[GID_BROWSER] = SpaceObj,
5284 GA_ID,GID_BROWSER,
5285 SPACE_Transparent,TRUE,
5286 SPACE_RenderHook, &g->shared->browser_hook,
5287 SpaceEnd,
5288 EndGroup,
5289 EndGroup,
5290 EndGroup,
5291// LAYOUT_WeightBar, TRUE,
5292 LAYOUT_AddChild, g->shared->objects[GID_LOGLAYOUT] = LayoutVObj,
5293 EndGroup,
5294 CHILD_WeightedHeight, 0,
5295#ifndef __amigaos4__
5296 LAYOUT_AddChild, g->shared->objects[GID_STATUS] = StringObj,
5297 GA_ID, GID_STATUS,
5298 GA_ReadOnly, TRUE,
5299 STRINGA_TextVal, NULL,
5300 GA_RelVerify, TRUE,
5301 StringEnd,
5302#endif
5303 EndGroup,
5304 EndGroup,
5305 EndWindow;
5306 }
5307 else
5308 {
5309 /* borderless kiosk mode window */
5310 g->tab = 0;
5311 g->shared->tabs = 0;
5312 g->tab_node = NULL;
5313
5315 WA_ScreenTitle, ami_gui_get_screen_title(),
5316 WA_Activate, TRUE,
5317 WA_DepthGadget, FALSE,
5318 WA_DragBar, FALSE,
5319 WA_CloseGadget, FALSE,
5320 WA_Borderless,TRUE,
5321 WA_RMBTrap,TRUE,
5322 WA_Top,0,
5323 WA_Left,0,
5324 WA_Width, scrn->Width,
5325 WA_Height, scrn->Height,
5326 WA_SizeGadget, FALSE,
5327 WA_PubScreen, scrn,
5328 WA_ReportMouse, TRUE,
5329 refresh_mode, TRUE,
5330 WA_IDCMP, IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
5331 IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
5332 IDCMP_RAWKEY | IDCMP_REFRESHWINDOW |
5333 IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
5335 WINDOW_IDCMPHook,&g->shared->scrollerhook,
5336 WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE |
5337 IDCMP_EXTENDEDMOUSE | IDCMP_REFRESHWINDOW,
5338 WINDOW_SharedPort,sport,
5339 WINDOW_UserData,g->shared,
5341 WINDOW_ParentGroup, g->shared->objects[GID_MAIN] = LayoutHObj,
5342 LAYOUT_DeferLayout, defer_layout,
5343 LAYOUT_SpaceOuter, TRUE,
5344 LAYOUT_AddChild, g->shared->objects[GID_VSCROLLLAYOUT] = LayoutHObj,
5345 LAYOUT_AddChild, g->shared->objects[GID_HSCROLLLAYOUT] = LayoutVObj,
5346 LAYOUT_AddChild, g->shared->objects[GID_BROWSER] = SpaceObj,
5347 GA_ID,GID_BROWSER,
5348 SPACE_Transparent,TRUE,
5349 SpaceEnd,
5350 EndGroup,
5351 EndGroup,
5352 EndGroup,
5353 EndWindow;
5354 }
5355
5356 NSLOG(netsurf, INFO, "Opening window");
5357
5358 g->shared->win = (struct Window *)RA_OpenWindow(g->shared->objects[OID_MAIN]);
5359
5360 NSLOG(netsurf, INFO, "Window opened, adding border gadgets");
5361
5362 if(!g->shared->win)
5363 {
5364 amiga_warn_user("NoMemory","");
5365 free(g->shared);
5366 free(g);
5367 return NULL;
5368 }
5369
5370 if(nsoption_bool(kiosk_mode) == false)
5371 {
5372#ifdef __amigaos4__
5373 ULONG width, height;
5374 struct DrawInfo *dri = GetScreenDrawInfo(scrn);
5375
5376 ami_get_border_gadget_size(g->shared,
5377 (ULONG *)&width, (ULONG *)&height);
5378
5380 NULL,
5381 "frbuttonclass",
5382 GA_ID, GID_STATUS,
5383 GA_Left, scrn->WBorLeft + 2,
5384 GA_RelBottom, scrn->WBorBottom - (height/2),
5385 GA_BottomBorder, TRUE,
5386 GA_Width, width,
5387 GA_Height, 1 + height - scrn->WBorBottom,
5388 GA_DrawInfo, dri,
5389 GA_ReadOnly, TRUE,
5390 GA_Disabled, TRUE,
5391 GA_Image, (struct Image *)NewObject(
5392 NULL,
5393 "gaugeiclass",
5394 GAUGEIA_Level, 0,
5395 IA_Top, (int)(- ceil((scrn->WBorBottom + height) / 2)),
5396 IA_Left, -4,
5397 IA_Height, 2 + height - scrn->WBorBottom,
5398 IA_Label, NULL,
5399 IA_InBorder, TRUE,
5400 IA_Screen, scrn,
5401 TAG_DONE),
5402 TAG_DONE);
5403
5404 AddGList(g->shared->win, (struct Gadget *)g->shared->objects[GID_STATUS],
5405 (UWORD)~0, -1, NULL);
5406
5407 /* Apparently you can't set GA_Width on creation time for frbuttonclass */
5408
5409 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_STATUS],
5410 g->shared->win, NULL,
5411 GA_Width, width,
5412 TAG_DONE);
5413
5414 RefreshGadgets((APTR)g->shared->objects[GID_STATUS],
5415 g->shared->win, NULL);
5416
5417 FreeScreenDrawInfo(scrn, dri);
5418#endif //__amigaos4__
5419 ami_gui_hotlist_toolbar_add(g->shared); /* is this the right place for this? */
5420 if(nsoption_bool(tab_always_show)) ami_toggletabbar(g->shared, true);
5421 }
5422
5423 g->shared->gw = g;
5424 cur_gw = g;
5425
5426 g->shared->appwin = AddAppWindowA((ULONG)g->shared->objects[OID_MAIN],
5427 (ULONG)g->shared, g->shared->win, appport, NULL);
5428
5430
5431 if(locked_screen) {
5432 UnlockPubScreen(NULL,scrn);
5433 locked_screen = FALSE;
5434 }
5435
5437
5438 ScreenToFront(scrn);
5439
5440 return g;
5441}
5442
5443static void ami_gui_close_tabs(struct gui_window_2 *gwin, bool other_tabs)
5444{
5445 struct Node *tab;
5446 struct Node *ntab;
5447 struct gui_window *gw;
5448
5449 if((gwin->tabs > 1) && (nsoption_bool(tab_close_warn) == true)) {
5450 int32 res = amiga_warn_user_multi(messages_get("MultiTabClose"), "Yes", "No", gwin->win);
5451
5452 if(res == 0) return;
5453 }
5454
5455 if(gwin->tabs) {
5456 tab = GetHead(&gwin->tab_list);
5457
5458 do {
5459 ntab=GetSucc(tab);
5460 GetClickTabNodeAttrs(tab,
5461 TNA_UserData,&gw,
5462 TAG_DONE);
5463
5464 if((other_tabs == false) || (gwin->gw != gw)) {
5466 }
5467 } while((tab=ntab));
5468 } else {
5469 if(other_tabs == false) browser_window_destroy(gwin->gw->bw);
5470 }
5471}
5472
5474{
5475 struct gui_window_2 *gwin = (struct gui_window_2 *)w;
5476 ami_gui_close_tabs(gwin, false);
5477}
5478
5480{
5481 ami_gui_close_tabs(gwin, true);
5482}
5483
5484static void gui_window_destroy(struct gui_window *g)
5485{
5486 struct Node *ptab = NULL;
5487 int gid;
5488
5489 if(!g) return;
5490
5491 if (ami_search_get_gwin(g->shared->searchwin) == g)
5492 {
5494 win_destroyed = true;
5495 }
5496
5497 if(g->hw)
5498 {
5500 win_destroyed = true;
5501 }
5502
5507
5508 cur_gw = NULL;
5509
5510 if(g->shared->tabs > 1) {
5511 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],g->shared->win,NULL,
5512 CLICKTAB_Labels,~0,
5513 TAG_DONE);
5514
5515 GetAttr(CLICKTAB_CurrentNode, g->shared->objects[GID_TABS], (ULONG *)&ptab);
5516
5517 if(ptab == g->tab_node) {
5518 ptab = GetSucc(g->tab_node);
5519 if(!ptab) ptab = GetPred(g->tab_node);
5520 }
5521
5522 Remove(g->tab_node);
5523 FreeClickTabNode(g->tab_node);
5524 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], g->shared->win, NULL,
5525 CLICKTAB_Labels, &g->shared->tab_list,
5526 CLICKTAB_CurrentNode, ptab,
5527 TAG_DONE);
5528
5529 if(ClickTabBase->lib_Version < 53)
5530 RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT],
5531 g->shared->win, NULL, TRUE);
5532
5533 g->shared->tabs--;
5534 ami_switch_tab(g->shared,true);
5536
5537 if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
5538 ami_toggletabbar(g->shared, false);
5539
5540 FreeListBrowserList(&g->loglist);
5541#ifdef __amigaos4__
5542 FreeLBColumnInfo(g->logcolumns);
5543#endif
5544
5545 if(g->tabtitle) free(g->tabtitle);
5546 free(g);
5547 return;
5548 }
5549
5551 free(g->shared->shared_pens);
5554
5555 DisposeObject(g->shared->objects[OID_MAIN]);
5557 if(g->shared->appwin) RemoveAppWindow(g->shared->appwin);
5559
5560 /* These aren't freed by the above.
5561 * TODO: nav_west etc need freeing too? */
5562 DisposeObject(g->shared->objects[GID_ADDTAB_BM]);
5563 DisposeObject(g->shared->objects[GID_CLOSETAB_BM]);
5564 DisposeObject(g->shared->objects[GID_TABS_FLAG]);
5565 DisposeObject(g->shared->objects[GID_FAVE_ADD]);
5566 DisposeObject(g->shared->objects[GID_FAVE_RMV]);
5567 DisposeObject(g->shared->objects[GID_PAGEINFO_INSECURE_BM]);
5568 DisposeObject(g->shared->objects[GID_PAGEINFO_INTERNAL_BM]);
5569 DisposeObject(g->shared->objects[GID_PAGEINFO_LOCAL_BM]);
5570 DisposeObject(g->shared->objects[GID_PAGEINFO_SECURE_BM]);
5571 DisposeObject(g->shared->objects[GID_PAGEINFO_WARNING_BM]);
5572
5574 if(g->shared->search_bm) DisposeObject(g->shared->search_bm);
5575
5576 /* This appears to be disposed along with the ClickTab object
5577 if(g->shared->clicktab_ctxmenu) DisposeObject((Object *)g->shared->clicktab_ctxmenu); */
5578 DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_BACK]);
5579 DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
5582
5583 FreeListBrowserList(&g->loglist);
5584#ifdef __amigaos4__
5585 FreeLBColumnInfo(g->logcolumns);
5586#endif
5587
5588 free(g->shared->wintitle);
5590 free(g->shared->svbuffer);
5591
5592 for(gid = 0; gid < GID_LAST; gid++)
5593 ami_utf8_free(g->shared->helphints[gid]);
5594
5596 if(g->tab_node) {
5597 Remove(g->tab_node);
5598 FreeClickTabNode(g->tab_node);
5599 }
5600 if(g->tabtitle) free(g->tabtitle);
5601 free(g); // g->shared should be freed by DelObject()
5602
5604 {
5605 /* last window closed, so exit */
5606 ami_try_quit();
5607 }
5608
5609 win_destroyed = true;
5610}
5611
5612
5613static void ami_redraw_callback(void *p)
5614{
5615 struct gui_window_2 *gwin = (struct gui_window_2 *)p;
5616
5617 if(gwin->redraw_required) {
5618 ami_do_redraw(gwin);
5619 }
5620
5622
5623 if(gwin->gw->c_h)
5624 {
5625 gui_window_place_caret(gwin->gw, gwin->gw->c_x,
5626 gwin->gw->c_y, gwin->gw->c_h, NULL);
5627 }
5628}
5629
5630/**
5631 * Schedule a redraw of the browser window - Amiga-specific function
5632 *
5633 * \param gwin a struct gui_window_2
5634 * \param full_redraw set to true to schedule a full redraw,
5635 should only be set to false when called from amiga_window_invalidate_area()
5636 */
5637void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
5638{
5639 int ms = 1;
5640
5641 if(full_redraw) gwin->redraw_required = true;
5643}
5644
5646{
5648}
5649
5650static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
5651{
5652 struct nsObject *node;
5653 struct nsObject *nnode;
5654 struct rect *rect;
5655
5656 if(!g) return;
5657 if(IsMinListEmpty(g->deferred_rects)) return;
5658
5659 if(draw == true) {
5661 } else {
5662 NSLOG(netsurf, INFO, "Ignoring deferred box redraw queue");
5663 }
5664
5665 node = (struct nsObject *)GetHead((struct List *)g->deferred_rects);
5666
5667 do {
5668 if(draw == true) {
5669 rect = (struct rect *)node->objstruct;
5670 ami_do_redraw_limits(g, g->bw, false,
5671 rect->x0, rect->y0, rect->x1, rect->y1);
5672 }
5673 nnode=(struct nsObject *)GetSucc((struct Node *)node);
5675 DelObjectNoFree(node);
5676 } while((node = nnode));
5677
5678 if(draw == true) ami_reset_pointer(g->shared);
5679}
5680
5681bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
5682 const struct rect *restrict new_rect, APTR mempool)
5683{
5684 struct nsObject *node;
5685 struct nsObject *nnode;
5686 struct rect *restrict rect;
5687
5688 if(IsMinListEmpty(deferred_rects)) return true;
5689
5690 node = (struct nsObject *)GetHead((struct List *)deferred_rects);
5691
5692 do {
5693 nnode=(struct nsObject *)GetSucc((struct Node *)node);
5694 rect = (struct rect *)node->objstruct;
5695
5696 if((rect->x0 <= new_rect->x0) &&
5697 (rect->y0 <= new_rect->y0) &&
5698 (rect->x1 >= new_rect->x1) &&
5699 (rect->y1 >= new_rect->y1)) {
5700 return false;
5701 }
5702
5703 if ((new_rect->x0 <= rect->x0) &&
5704 (new_rect->y0 <= rect->y0) &&
5705 (new_rect->x1 >= rect->x1) &&
5706 (new_rect->y1 >= rect->y1)) {
5707 NSLOG(netsurf, INFO,
5708 "Removing queued redraw that is a subset of new box redraw");
5709 ami_memory_itempool_free(mempool, node->objstruct, sizeof(struct rect));
5710 DelObjectNoFree(node);
5711 /* Don't return - we might find more */
5712 }
5713 } while((node = nnode));
5714
5715 return true;
5716}
5717
5718
5719static void ami_do_redraw(struct gui_window_2 *gwin)
5720{
5721 ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
5722 struct IBox *bbox;
5723 ULONG oldh = gwin->oldh, oldv=gwin->oldv;
5724
5725 if(browser_window_redraw_ready(gwin->gw->bw) == false) return;
5726
5727 ami_get_hscroll_pos(gwin, (ULONG *)&hcurrent);
5728 ami_get_vscroll_pos(gwin, (ULONG *)&vcurrent);
5729
5730 gwin->gw->scrollx = hcurrent;
5731 gwin->gw->scrolly = vcurrent;
5732
5733 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
5734 amiga_warn_user("NoMemory", "");
5735 return;
5736 }
5737
5738 width=bbox->Width;
5739 height=bbox->Height;
5740 xoffset=bbox->Left;
5741 yoffset=bbox->Top;
5742
5743 if(gwin->redraw_scroll)
5744 {
5745 if((abs(vcurrent-oldv) > height) || (abs(hcurrent-oldh) > width))
5746 gwin->redraw_scroll = false;
5747
5748 if(gwin->new_content) gwin->redraw_scroll = false;
5749 }
5750
5751 if(gwin->redraw_scroll)
5752 {
5753 struct rect rect;
5754
5755 gwin->gw->c_h_temp = gwin->gw->c_h;
5757
5758 ScrollWindowRaster(gwin->win, hcurrent - oldh, vcurrent - oldv,
5759 xoffset, yoffset, xoffset + width - 1, yoffset + height - 1);
5760
5761 gwin->gw->c_h = gwin->gw->c_h_temp;
5762
5763 if(vcurrent>oldv) /* Going down */
5764 {
5765 ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, height - (vcurrent - oldv) - 1);
5766 ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, height + 1);
5768 }
5769 else if(vcurrent<oldv) /* Going up */
5770 {
5771 ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, 0);
5772 ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, oldv - vcurrent + 1);
5774 }
5775
5776 if(hcurrent>oldh) /* Going right */
5777 {
5778 ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, width - (hcurrent - oldh), 0);
5779 ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, height + 1);
5781 }
5782 else if(hcurrent<oldh) /* Going left */
5783 {
5784 ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, 0);
5785 ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, oldh - hcurrent + 1, height + 1);
5787 }
5788 }
5789 else
5790 {
5791 struct redraw_context ctx = {
5792 .interactive = true,
5793 .background_images = true,
5794 .plot = &amiplot,
5795 .priv = browserglob
5796 };
5797
5798 ami_do_redraw_tiled(gwin, true, hcurrent, vcurrent, width, height, hcurrent, vcurrent, bbox, &ctx);
5799
5800 /* Tell NetSurf not to bother with the next queued box redraw, as we've redrawn everything. */
5802 }
5803
5804 ami_update_buttons(gwin);
5805
5806 gwin->oldh = hcurrent;
5807 gwin->oldv = vcurrent;
5808
5809 gwin->redraw_scroll = false;
5810 gwin->redraw_required = false;
5811 gwin->new_content = false;
5812
5814}
5815
5816
5817static void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs)
5818{
5819 if(gwin->objects[GID_HSCROLL])
5820 {
5821 GetAttr(SCROLLER_Top, (Object *)gwin->objects[GID_HSCROLL], xs);
5822 } else {
5823 *xs = 0;
5824 }
5825}
5826
5827static void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys)
5828{
5829 if(gwin->objects[GID_VSCROLL]) {
5830 GetAttr(SCROLLER_Top, gwin->objects[GID_VSCROLL], ys);
5831 } else {
5832 *ys = 0;
5833 }
5834}
5835
5836static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy)
5837{
5838 ami_get_hscroll_pos(g->shared, (ULONG *)sx);
5839 ami_get_vscroll_pos(g->shared, (ULONG *)sy);
5840
5841 return true;
5842}
5843
5844/**
5845 * Set the scroll position of a amiga browser window.
5846 *
5847 * Scrolls the viewport to ensure the specified rectangle of the
5848 * content is shown. The amiga implementation scrolls the contents so
5849 * the specified point in the content is at the top of the viewport.
5850 *
5851 * \param g gui_window to scroll
5852 * \param rect The rectangle to ensure is shown.
5853 * \return NSERROR_OK on success or apropriate error code.
5854 */
5855static nserror
5857{
5858 struct IBox *bbox;
5859 int width, height;
5860 nserror res;
5861 int sx = 0, sy = 0;
5862
5863 if(!g) {
5864 return NSERROR_BAD_PARAMETER;
5865 }
5866 if(!g->bw || browser_window_has_content(g->bw) == false) {
5867 return NSERROR_BAD_PARAMETER;
5868 }
5869
5870 res = ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox);
5871 if(res != NSERROR_OK) {
5872 amiga_warn_user("NoMemory", "");
5873 return res;
5874 }
5875
5876 if (rect->x0 > 0) {
5877 sx = rect->x0;
5878 }
5879 if (rect->y0 > 0) {
5880 sy = rect->y0;
5881 }
5882
5884
5885 if(sx >= width - bbox->Width)
5886 sx = width - bbox->Width;
5887 if(sy >= height - bbox->Height)
5888 sy = height - bbox->Height;
5889
5890 if(width <= bbox->Width) sx = 0;
5891 if(height <= bbox->Height) sy = 0;
5892
5894
5895 if(g == g->shared->gw) {
5896 if(g->shared->objects[GID_VSCROLL]) {
5897 RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL],
5898 g->shared->win, NULL,
5899 SCROLLER_Top, (ULONG)(sy),
5900 TAG_DONE);
5901 }
5902
5903 if(g->shared->objects[GID_HSCROLL])
5904 {
5905 RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL],
5906 g->shared->win, NULL,
5907 SCROLLER_Top, (ULONG)(sx),
5908 TAG_DONE);
5909 }
5910
5911 ami_schedule_redraw(g->shared, true);
5912
5913 if(nsoption_bool(faster_scroll) == true) g->shared->redraw_scroll = true;
5914 else g->shared->redraw_scroll = false;
5915
5916 g->scrollx = sx;
5917 g->scrolly = sy;
5918 }
5919 return NSERROR_OK;
5920}
5921
5922static void gui_window_set_status(struct gui_window *g, const char *text)
5923{
5924 char *utf8text;
5925 ULONG size;
5926 UWORD chars;
5927 struct TextExtent textex;
5928
5929 if(!g) return;
5930 if(!text) return;
5931 if(!g->shared->objects[GID_STATUS]) return;
5932
5933 if(g == g->shared->gw) {
5934 utf8text = ami_utf8_easy((char *)text);
5935 if(utf8text == NULL) return;
5936
5937 GetAttr(GA_Width, g->shared->objects[GID_STATUS], (ULONG *)&size);
5938 chars = TextFit(&scrn->RastPort, utf8text, (UWORD)strlen(utf8text),
5939 &textex, NULL, 1, size - 4, scrn->RastPort.TxHeight);
5940
5941 utf8text[chars] = 0;
5942
5943 SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_STATUS],
5944 g->shared->win, NULL,
5945 NSA_STATUS_TEXT, utf8text,
5946 TAG_DONE);
5947
5948 RefreshGList((struct Gadget *)g->shared->objects[GID_STATUS],
5949 g->shared->win, NULL, 1);
5950
5952 g->shared->status = utf8text;
5953 }
5954}
5955
5957{
5958 size_t idn_url_l;
5959 char *idn_url_s = NULL;
5960 char *url_lc = NULL;
5961
5962 if(!g) return NSERROR_OK;
5963
5964 if(g == g->shared->gw) {
5965 if(nsoption_bool(display_decoded_idn) == true) {
5966 if (nsurl_get_utf8(url, &idn_url_s, &idn_url_l) == NSERROR_OK) {
5967 url_lc = ami_utf8_easy(idn_url_s);
5968 }
5969 }
5970
5971 RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
5972 g->shared->win, NULL,
5973 STRINGA_TextVal, url_lc ? url_lc : nsurl_access(url),
5974 TAG_DONE);
5975
5976 if(url_lc) {
5977 ami_utf8_free(url_lc);
5978 if(idn_url_s) free(idn_url_s);
5979 }
5980 }
5981
5983
5984 return NSERROR_OK;
5985}
5986
5987HOOKF(uint32, ami_set_favicon_render_hook, APTR, space, struct gpRender *)
5988{
5989 ami_schedule(0, ami_gui_refresh_favicon, hook->h_Data);
5990 return 0;
5991}
5992
5993/**
5994 * Gui callback when search provider details are updated.
5995 *
5996 * \param provider_name The providers name.
5997 * \param ico_bitmap The icon bitmap representing the provider.
5998 * \return NSERROR_OK on success else error code.
5999 */
6000static nserror gui_search_web_provider_update(const char *provider_name,
6001 struct bitmap *ico_bitmap)
6002{
6003 struct BitMap *bm = NULL;
6004 struct nsObject *node;
6005 struct nsObject *nnode;
6006 struct gui_window_2 *gwin;
6007
6009 if(nsoption_bool(kiosk_mode) == true) return NSERROR_BAD_PARAMETER;
6010
6011 if (ico_bitmap != NULL) {
6012 bm = ami_bitmap_get_native(ico_bitmap, 16, 16, ami_plot_screen_is_palettemapped(), NULL);
6013 }
6014
6015 if(bm == NULL) return NSERROR_BAD_PARAMETER;
6016
6017 node = (struct nsObject *)GetHead((struct List *)window_list);
6018
6019 do {
6020 nnode=(struct nsObject *)GetSucc((struct Node *)node);
6021 gwin = node->objstruct;
6022
6023 if(node->Type == AMINS_WINDOW)
6024 {
6025 if(gwin->search_bm != NULL)
6026 DisposeObject(gwin->search_bm);
6027
6028 ULONG bm_masking_tag = TAG_IGNORE;
6029
6030 if(LIB_IS_AT_LEAST((struct Library *)ChooserBase, 53, 21)) {
6031 /* Broken in earlier versions */
6032 bm_masking_tag = BITMAP_Masking;
6033 }
6034
6035 gwin->search_bm = BitMapObj,
6036 BITMAP_Screen, scrn,
6037 BITMAP_Width, 16,
6038 BITMAP_Height, 16,
6039 BITMAP_BitMap, bm,
6040 BITMAP_HasAlpha, TRUE,
6041 bm_masking_tag, TRUE,
6042 BitMapEnd;
6043
6044 RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCH_ICON],
6045 gwin->win, NULL,
6046 GA_HintInfo, provider_name,
6047 GA_Image, gwin->search_bm,
6048 TAG_DONE);
6049 }
6050 } while((node = nnode));
6051
6052 return NSERROR_OK;
6053}
6054
6055HOOKF(uint32, ami_set_throbber_render_hook, APTR, space, struct gpRender *)
6056{
6057 struct gui_window_2 *gwin = hook->h_Data;
6059 return 0;
6060}
6061
6062HOOKF(uint32, ami_gui_browser_render_hook, APTR, space, struct gpRender *)
6063{
6064 struct gui_window_2 *gwin = hook->h_Data;
6065
6066 NSLOG(netsurf, DEBUG, "Render hook called with %ld (REDRAW=1)", msg->gpr_Redraw);
6067
6068 if(msg->gpr_Redraw != GREDRAW_REDRAW) return 0;
6069
6070 ami_schedule_redraw(gwin, true);
6071
6072 return 0;
6073}
6074
6075static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
6076 const struct rect *clip)
6077{
6078 struct IBox *bbox;
6079 int xs,ys;
6080
6081 if(!g) return;
6082
6084
6085 xs = g->scrollx;
6086 ys = g->scrolly;
6087
6088 SetAPen(g->shared->win->RPort,3);
6089
6090 if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
6091 amiga_warn_user("NoMemory", "");
6092 return;
6093 }
6094
6095 if((y-ys+height) > (bbox->Height)) height = bbox->Height-y+ys;
6096
6097 if(((x-xs) <= 0) || ((x-xs+2) >= (bbox->Width)) || ((y-ys) <= 0) || ((y-ys) >= (bbox->Height))) {
6099 return;
6100 }
6101
6102 g->c_w = 2;
6103
6104 SetDrMd(g->shared->win->RPort,COMPLEMENT);
6105 RectFill(g->shared->win->RPort, x + bbox->Left - xs, y + bbox->Top - ys,
6106 x + bbox->Left + g->c_w - xs, y+bbox->Top + height - ys);
6107 SetDrMd(g->shared->win->RPort,JAM1);
6108
6110
6111 g->c_x = x;
6112 g->c_y = y;
6113 g->c_h = height;
6114
6115 if((nsoption_bool(kiosk_mode) == false))
6117}
6118
6120{
6121 if(!g) return;
6122 if(g->c_h == 0) return;
6123
6124 if((nsoption_bool(kiosk_mode) == false))
6126
6127 ami_do_redraw_limits(g, g->bw, false, g->c_x, g->c_y,
6128 g->c_x + g->c_w + 1, g->c_y + g->c_h + 1);
6129
6130 g->c_h = 0;
6131}
6132
6134{
6135 struct hlcache_handle *c;
6136
6137 if(g && g->shared && g->bw && browser_window_has_content(g->bw))
6139 else return;
6140
6142 g->shared->new_content = true;
6143 g->scrollx = 0;
6144 g->scrolly = 0;
6145 g->shared->oldh = 0;
6146 g->shared->oldv = 0;
6147 g->favicon = NULL;
6152}
6153
6155 const struct rect *rect)
6156{
6157#ifdef __amigaos4__
6158 g->shared->drag_op = type;
6160
6161 if(type == GDRAGGING_NONE)
6162 {
6163 SetWindowAttrs(g->shared->win, WA_GrabFocus, 0,
6164 WA_MouseLimits, NULL, TAG_DONE);
6165
6166 if(g->shared->ptr_lock)
6167 {
6168 free(g->shared->ptr_lock);
6169 g->shared->ptr_lock = NULL;
6170 }
6171 }
6172#endif
6173 return true;
6174}
6175
6176/* return the text box at posn x,y in window coordinates
6177 x,y are updated to be document co-ordinates */
6178
6179bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *restrict x, ULONG *restrict y)
6180{
6181 struct IBox *bbox;
6182 ULONG xs, ys;
6183 struct browser_window_features data;
6184
6185 if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
6186 amiga_warn_user("NoMemory", "");
6187 return false;
6188 }
6189
6190 ami_get_hscroll_pos(gwin, (ULONG *)&xs);
6191 *x = *x - (bbox->Left) +xs;
6192
6193 ami_get_vscroll_pos(gwin, (ULONG *)&ys);
6194 *y = *y - (bbox->Top) + ys;
6195
6197
6198 browser_window_get_features(gwin->gw->bw, *x, *y, &data);
6199
6200 if (data.form_features == CTX_FORM_TEXT)
6201 return true;
6202
6203 return false;
6204}
6205
6206BOOL ami_gadget_hit(Object *obj, int x, int y)
6207{
6208 int top, left, width, height;
6209
6210 GetAttrs(obj,
6211 GA_Left, &left,
6212 GA_Top, &top,
6213 GA_Width, &width,
6214 GA_Height, &height,
6215 TAG_DONE);
6216
6217 if((x >= left) && (x <= (left + width)) && (y >= top) && (y <= (top + height)))
6218 return TRUE;
6219 else return FALSE;
6220}
6221
6222static Object *ami_gui_splash_open(void)
6223{
6224 Object *restrict win_obj, *restrict bm_obj;
6225 struct Window *win;
6226 struct Screen *wbscreen = LockPubScreen("Workbench");
6227 uint32 top = 0, left = 0;
6228 struct TextAttr tattr;
6229 struct TextFont *tfont;
6230
6231 win_obj = WindowObj,
6232#ifdef __amigaos4__
6233 WA_ToolBox, TRUE,
6234#endif
6235 WA_Borderless, TRUE,
6236 WA_BusyPointer, TRUE,
6237 WINDOW_Position, WPOS_CENTERSCREEN,
6238 WINDOW_LockWidth, TRUE,
6239 WINDOW_LockHeight, TRUE,
6240 WINDOW_ParentGroup, LayoutVObj,
6241 LAYOUT_AddImage, bm_obj = BitMapObj,
6242 BITMAP_SourceFile, "PROGDIR:Resources/splash.png",
6243 BITMAP_Screen, wbscreen,
6244 BITMAP_Precision, PRECISION_IMAGE,
6245 BitMapEnd,
6246 LayoutEnd,
6247 EndWindow;
6248
6249 if(win_obj == NULL) {
6250 NSLOG(netsurf, INFO, "Splash window object not created");
6251 return NULL;
6252 }
6253
6254 NSLOG(netsurf, INFO, "Attempting to open splash window...");
6255 win = RA_OpenWindow(win_obj);
6256
6257 if(win == NULL) {
6258 NSLOG(netsurf, INFO, "Splash window did not open");
6259 return NULL;
6260 }
6261
6262 if(bm_obj == NULL) {
6263 NSLOG(netsurf, INFO, "BitMap object not created");
6264 return NULL;
6265 }
6266
6267 GetAttrs(bm_obj, IA_Top, &top,
6268 IA_Left, &left,
6269 TAG_DONE);
6270
6271 SetDrMd(win->RPort, JAM1);
6272#ifdef __amigaos4__
6273 SetRPAttrs(win->RPort, RPTAG_APenColor, 0xFF3F6DFE, TAG_DONE);
6274 tattr.ta_Name = "DejaVu Serif Italic.font";
6275#else
6276 SetAPen(win->RPort, 3); /* Pen 3 is usually blue */
6277 tattr.ta_Name = "ruby.font";
6278#endif
6279 tattr.ta_YSize = 24;
6280 tattr.ta_Style = 0;
6281 tattr.ta_Flags = 0;
6282
6283 if((tfont = ami_font_open_disk_font(&tattr)))
6284 {
6285 SetFont(win->RPort, tfont);
6286 }
6287 else
6288 {
6289 tattr.ta_Name = "DejaVu Serif Oblique.font";
6290 if((tfont = ami_font_open_disk_font(&tattr)))
6291 SetFont(win->RPort, tfont);
6292 }
6293
6294 Move(win->RPort, left + 5, top + 25);
6295 Text(win->RPort, "Initialising...", strlen("Initialising..."));
6296
6297 if(tfont) ami_font_close_disk_font(tfont);
6298
6299#ifdef __amigaos4__
6300 tattr.ta_Name = "DejaVu Sans.font";
6301#else
6302 tattr.ta_Name = "helvetica.font";
6303#endif
6304 tattr.ta_YSize = 16;
6305 tattr.ta_Style = 0;
6306 tattr.ta_Flags = 0;
6307
6308 if((tfont = ami_font_open_disk_font(&tattr)))
6309 SetFont(win->RPort, tfont);
6310
6311 Move(win->RPort, left + 185, top + 220);
6312 Text(win->RPort, netsurf_version, strlen(netsurf_version));
6313
6314 if(tfont) ami_font_close_disk_font(tfont);
6315
6316 UnlockPubScreen(NULL, wbscreen);
6317
6318 return win_obj;
6319}
6320
6321static void ami_gui_splash_close(Object *win_obj)
6322{
6323 if(win_obj == NULL) return;
6324
6325 NSLOG(netsurf, INFO, "Closing splash window");
6326 DisposeObject(win_obj);
6327}
6328
6329static void gui_file_gadget_open(struct gui_window *g, struct hlcache_handle *hl,
6330 struct form_control *gadget)
6331{
6332 NSLOG(netsurf, INFO, "File open dialog request for %p/%p", g, gadget);
6333
6334 if(AslRequestTags(filereq,
6335 ASLFR_Window, g->shared->win,
6336 ASLFR_SleepWindow, TRUE,
6337 ASLFR_TitleText, messages_get("NetSurf"),
6338 ASLFR_Screen, scrn,
6339 ASLFR_DoSaveMode, FALSE,
6340 TAG_DONE)) {
6341 char fname[1024];
6342 strlcpy(fname, filereq->fr_Drawer, 1024);
6343 AddPart(fname, filereq->fr_File, 1024);
6344 browser_window_set_gadget_filename(g->bw, gadget, fname);
6345 }
6346}
6347
6348/* exported function documented in amiga/gui.h */
6350{
6351 return ami_appid;
6352}
6353
6354/* Get current user directory for user-specific NetSurf data
6355 * Returns NULL on error
6356 */
6357static char *ami_gui_get_user_dir(STRPTR current_user)
6358{
6359 BPTR lock = 0;
6360 char temp[1024];
6361 int32 user = 0;
6362
6363 if(current_user == NULL) {
6364 user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
6365 current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
6366 }
6367 NSLOG(netsurf, INFO, "User: %s", current_user);
6368
6369 if(users_dir == NULL) {
6370 users_dir = ASPrintf("%s", USERS_DIR);
6371 if(users_dir == NULL) {
6372 ami_misc_fatal_error("Failed to allocate memory");
6373 FreeVec(current_user);
6374 return NULL;
6375 }
6376 }
6377
6378 if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
6379#ifdef __amigaos4__
6380 struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
6381 if(infodata == NULL) {
6382 ami_misc_fatal_error("Failed to allocate memory");
6383 FreeVec(current_user);
6384 return NULL;
6385 }
6386 GetDiskInfoTags(GDI_StringNameInput, users_dir,
6387 GDI_InfoData, infodata,
6388 TAG_DONE);
6389 if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
6390 FreeDosObject(DOS_INFODATA, infodata);
6391 ami_misc_fatal_error("User directory MUST be on a writeable volume");
6392 FreeVec(current_user);
6393 return NULL;
6394 }
6395 FreeDosObject(DOS_INFODATA, infodata);
6396#else
6397#warning FIXME for OS3 and older OS4
6398#endif
6399 } else {
6400//TODO: check volume write status using old API
6401 }
6402
6403 int len = strlen(current_user);
6404 len += strlen(users_dir);
6405 len += 2; /* for poss path sep and NULL term */
6406
6407 current_user_dir = malloc(len);
6408 if(current_user_dir == NULL) {
6409 ami_misc_fatal_error("Failed to allocate memory");
6410 FreeVec(current_user);
6411 return NULL;
6412 }
6413
6414 strlcpy(current_user_dir, users_dir, len);
6415 AddPart(current_user_dir, current_user, len);
6416 FreeVec(users_dir);
6417 FreeVec(current_user);
6418
6419 NSLOG(netsurf, INFO, "User dir: %s", current_user_dir);
6420
6421 if((lock = CreateDirTree(current_user_dir)))
6422 UnLock(lock);
6423
6425
6427 if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
6428
6429 return current_user_dir;
6430}
6431
6432
6433/**
6434 * process miscellaneous window events
6435 *
6436 * \param gw The window receiving the event.
6437 * \param event The event code.
6438 * \return NSERROR_OK when processed ok
6439 */
6440static nserror
6442{
6443 switch (event) {
6446 break;
6447
6450 break;
6451
6454 break;
6455
6458 break;
6459
6462 break;
6463
6466 break;
6467
6470 break;
6471
6472 default:
6473 break;
6474 }
6475 return NSERROR_OK;
6476}
6477
6478
6481 .destroy = gui_window_destroy,
6482 .invalidate = amiga_window_invalidate_area,
6483 .get_scroll = gui_window_get_scroll,
6484 .set_scroll = gui_window_set_scroll,
6485 .get_dimensions = gui_window_get_dimensions,
6486 .event = gui_window_event,
6487
6488 .set_icon = gui_window_set_icon,
6489 .set_title = gui_window_set_title,
6490 .set_url = gui_window_set_url,
6491 .set_status = gui_window_set_status,
6492 .place_caret = gui_window_place_caret,
6493 .drag_start = gui_window_drag_start,
6494 .create_form_select_menu = gui_create_form_select_menu,
6495 .file_gadget_open = gui_file_gadget_open,
6496 .drag_save_object = gui_drag_save_object,
6497 .drag_save_selection = gui_drag_save_selection,
6498
6499 .console_log = gui_window_console_log,
6500
6501 /* from theme */
6502 .set_pointer = gui_window_set_pointer,
6503
6504 /* from download */
6505 .save_link = gui_window_save_link,
6506};
6507
6508
6511
6512 .get_resource_url = gui_get_resource_url,
6513};
6514
6517};
6518
6521
6522 .quit = gui_quit,
6523 .launch_url = gui_launch_url,
6524 .present_cookies = ami_cookies_present,
6525};
6526
6527/** Normal entry point from OS */
6528int main(int argc, char** argv)
6529{
6530 setbuf(stderr, NULL);
6531 char messages[100];
6532 char script[1024];
6533 char temp[1024];
6534 STRPTR current_user_cache = NULL;
6535 STRPTR current_user = NULL;
6536 BPTR lock = 0;
6537 nserror ret;
6538 int nargc = 0;
6539 char *nargv = NULL;
6540
6541 struct netsurf_table amiga_table = {
6543 .window = &amiga_window_table,
6544 .clipboard = amiga_clipboard_table,
6545 .download = amiga_download_table,
6546 .fetch = &amiga_fetch_table,
6547 .file = amiga_file_table,
6548 .utf8 = amiga_utf8_table,
6549 .search = amiga_search_table,
6550 .search_web = &amiga_search_web_table,
6551 .llcache = filesystem_llcache_table,
6552 .bitmap = amiga_bitmap_table,
6553 .layout = ami_layout_table,
6554 };
6555
6556#ifdef __amigaos4__
6557 signal(SIGINT, SIG_IGN);
6558#endif
6559 ret = netsurf_register(&amiga_table);
6560 if (ret != NSERROR_OK) {
6561 ami_misc_fatal_error("NetSurf operation table failed registration");
6562 return RETURN_FAIL;
6563 }
6564
6565 /* initialise logging. Not fatal if it fails but not much we
6566 * can do about it either.
6567 */
6568 nslog_init(NULL, &argc, argv);
6569
6570 /* Need to do this before opening any splash windows etc... */
6571 if ((ami_libs_open() == false)) {
6572 return RETURN_FAIL;
6573 }
6574
6575 /* Open splash window */
6576 Object *splash_window = ami_gui_splash_open();
6577
6578#ifndef __amigaos4__
6579 /* OS3 low memory handler */
6580 struct Interupt *memhandler = ami_memory_init();
6581#endif
6582
6583 if (ami_gui_resources_open() == false) { /* alloc msgports, objects and other miscelleny */
6584 ami_misc_fatal_error("Unable to allocate resources");
6585 ami_gui_splash_close(splash_window);
6587 return RETURN_FAIL;
6588 }
6589
6590 current_user = ami_gui_read_all_tooltypes(argc, argv);
6591 struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv);
6592
6593 current_user_dir = ami_gui_get_user_dir(current_user);
6594 if(current_user_dir == NULL) {
6596 ami_gui_splash_close(splash_window);
6598 return RETURN_FAIL;
6599 }
6600
6601 ami_mime_init("PROGDIR:Resources/mimetypes");
6602 sprintf(temp, "%s/mimetypes.user", current_user_dir);
6603 ami_mime_init(temp);
6604
6605#ifdef __amigaos4__
6607
6608 /* DataTypes loader needs datatypes.library v45,
6609 * but for some reason that's not in OS3.9.
6610 * Skip it to ensure it isn't causing other problems. */
6611 ret = amiga_datatypes_init();
6612#endif
6613
6614 /* user options setup */
6616 if (ret != NSERROR_OK) {
6617 ami_misc_fatal_error("Options failed to initialise");
6619 ami_gui_splash_close(splash_window);
6621 return RETURN_FAIL;
6622 }
6624 if(args != NULL) {
6625 nsoption_commandline(&nargc, &nargv, NULL);
6626 FreeArgs(args);
6627 }
6628
6629 if (ami_locate_resource(messages, "Messages") == false) {
6630 ami_misc_fatal_error("Cannot open Messages file");
6634 ami_gui_splash_close(splash_window);
6636 return RETURN_FAIL;
6637 }
6638
6639 ret = messages_add_from_file(messages);
6640
6641 current_user_cache = ASPrintf("%s/Cache", current_user_dir);
6642 if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
6643
6644 ret = netsurf_init(current_user_cache);
6645
6646 if(current_user_cache != NULL) FreeVec(current_user_cache);
6647
6648 if (ret != NSERROR_OK) {
6649 ami_misc_fatal_error("NetSurf failed to initialise");
6653 ami_gui_splash_close(splash_window);
6655 return RETURN_FAIL;
6656 }
6657
6658 ret = amiga_icon_init();
6659
6660 search_web_init(nsoption_charp(search_engines_file));
6663 ami_amiupdate(); /* set env-vars for AmiUpdate */
6664 ami_font_init();
6669
6670 win_destroyed = false;
6671 ami_font_setdevicedpi(0); /* for early font requests, eg treeview init */
6672
6674
6675 urldb_load(nsoption_charp(url_file));
6676 urldb_load_cookies(nsoption_charp(cookie_file));
6677
6678 gui_init2(argc, argv);
6679
6680 ami_ctxmenu_init(); /* Requires screen pointer */
6681
6682 ami_gui_splash_close(splash_window);
6683
6684 strlcpy(script, nsoption_charp(arexx_dir), 1024);
6685 AddPart(script, nsoption_charp(arexx_startup), 1024);
6686 ami_arexx_execute(script);
6687
6688 NSLOG(netsurf, INFO, "Entering main loop");
6689
6690 while (!ami_quit) {
6691 ami_get_msg();
6692 }
6693
6694 strlcpy(script, nsoption_charp(arexx_dir), 1024);
6695 AddPart(script, nsoption_charp(arexx_shutdown), 1024);
6696 ami_arexx_execute(script);
6697
6698 ami_mime_free();
6699
6700 netsurf_exit();
6701
6704 free(current_user_dir);
6706
6707 /* finalise logging */
6709
6710#ifndef __amigaos4__
6711 /* OS3 low memory handler */
6712 ami_memory_fini(memhandler);
6713#endif
6714
6717
6718 return RETURN_OK;
6719}
6720
void ami_clipboard_free(void)
Definition: clipboard.c:82
void ami_clipboard_init(void)
Definition: clipboard.c:70
struct gui_clipboard_table * amiga_clipboard_table
Definition: clipboard.c:381
void gui_start_selection(struct gui_window *g)
Definition: clipboard.c:87
nserror ami_cookies_present(const char *search_term)
Open the cookie viewer.
Definition: cookies.c:348
Interface to Intuition-based context menu operations.
struct Menu * ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin, Object **clicktab_obj)
Definition: ctxmenu.h:90
struct Menu * ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin)
Definition: ctxmenu.h:89
struct Hook * ami_ctxmenu_get_hook(APTR data)
Definition: ctxmenu.h:87
void ami_ctxmenu_init(void)
Definition: ctxmenu.h:85
void ami_ctxmenu_release_hook(struct Hook *hook)
Definition: ctxmenu.h:88
@ AMI_CTXMENU_HISTORY_BACK
Definition: ctxmenu.h:30
@ AMI_CTXMENU_HISTORY_FORWARD
Definition: ctxmenu.h:31
void ami_ctxmenu_free(void)
Definition: ctxmenu.h:86
void ami_mime_free(void)
Definition: filetype.c:264
const char * fetch_filetype(const char *unix_path)
Determine the MIME type of a local file.
Definition: filetype.c:58
nserror ami_mime_init(const char *mimefile)
Definition: filetype.c:177
static void ami_gui_close_tabs(struct gui_window_2 *gwin, bool other_tabs)
Definition: gui.c:5443
static bool cli_force
Definition: gui.c:351
static void ami_gui_splash_close(Object *win_obj)
Definition: gui.c:6321
static nserror gui_window_get_dimensions(struct gui_window *gw, int *restrict width, int *restrict height)
Find the current dimensions of a amiga browser window content area.
Definition: gui.c:2087
static void ami_refresh_window(struct gui_window_2 *gwin)
Definition: gui.c:4547
static ULONG rxsig
Definition: gui.c:347
void ami_try_quit(void)
Definition: gui.c:3894
static void ami_gui_console_log_remove(struct gui_window *g)
Definition: gui.c:2304
bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, const struct rect *restrict new_rect, APTR mempool)
Check rect is not already queued for redraw.
Definition: gui.c:5681
struct ami_history_local_window * ami_gui_get_history_window(struct gui_window *gw)
Get local history window from gui_window.
Definition: gui.c:486
static void ami_update_buttons(struct gui_window_2 *gwin)
Definition: gui.c:1626
static void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
Definition: gui.c:4072
static STRPTR nsscreentitle
Definition: gui.c:341
struct Window * ami_gui_get_window(struct gui_window *gw)
Get window from gui_window.
Definition: gui.c:576
static void gui_window_set_status(struct gui_window *g, const char *text)
Definition: gui.c:5922
static nsurl * gui_get_resource_url(const char *path)
Definition: gui.c:1216
static nserror gui_window_event(struct gui_window *gw, enum gui_window_event event)
process miscellaneous window events
Definition: gui.c:6441
static void gui_window_destroy(struct gui_window *g)
Definition: gui.c:5484
static uint32 ami_appid
Definition: gui.c:345
static void ami_gui_refresh_favicon(void *p)
Definition: gui.c:2533
static void gui_window_remove_caret(struct gui_window *g)
Definition: gui.c:6119
static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon)
Definition: gui.c:3970
#define NSA_STATUS_TEXT
Definition: gui.c:187
#define EXTRAUP
Definition: gui.c:178
int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
Definition: gui.c:1704
static void ami_gui_scroller_update(struct gui_window_2 *gwin)
Check the scroll bar requirements for a browser window, and add/remove the vertical scroller as appro...
Definition: gui.c:2207
void ami_gui_set_find_window(struct gui_window *gw, struct find_window *fw)
Set search window in gui_window.
Definition: gui.c:498
static const __attribute__((used))
Definition: gui.c:358
static void gui_window_update_extent(struct gui_window *g)
Definition: gui.c:3651
static nserror ami_set_options(struct nsoption_s *defaults)
Set option defaults for amiga frontend.
Definition: gui.c:1060
static void ami_set_border_gadget_size(struct gui_window_2 *gwin)
Definition: gui.c:2567
int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin)
Get ctxmenu history tmp from gui_window_2.
Definition: gui.c:610
static void ami_gui_appicon_remove(struct gui_window_2 *gwin)
Definition: gui.c:3247
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
Definition: gui.c:403
struct gui_utf8_table * amiga_utf8_table
Definition: utf8.c:136
struct Node * ami_gui_get_tab_node(struct gui_window *gw)
Get tab node from gui_window.
Definition: gui.c:462
void ami_gui_hotlist_update_all(void)
Update hotlist toolbar and recreate the menu for all windows.
Definition: gui.c:4195
void ami_gui_close_inactive_tabs(struct gui_window_2 *gwin)
Close all tabs in a window except the active one.
Definition: gui.c:5479
static bool ami_quit
Definition: gui.c:330
static void ami_gui_console_log_switch(struct gui_window *g)
Definition: gui.c:2337
static void ami_gui_console_log_add(struct gui_window *g)
Definition: gui.c:2269
void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content)
Set new_content in gui_window_2 Indicates the window needs redrawing.
Definition: gui.c:634
static void ami_amiupdate(void)
Definition: gui.c:1187
static struct Screen * scrn
Definition: gui.c:326
static bool ami_gui_map_filename(char **remapped, const char *restrict path, const char *restrict file, const char *restrict map)
Definition: gui.c:743
static struct gui_misc_table amiga_misc_table
Definition: gui.c:6519
static int screen_signal
Definition: gui.c:339
@ GID_TABLAYOUT
Definition: gui.c:204
@ GID_HOTLISTSEPBAR
Definition: gui.c:235
@ GID_SEARCHSTRING
Definition: gui.c:231
@ OID_HSCROLL
Definition: gui.c:202
@ GID_HSCROLLLAYOUT
Definition: gui.c:237
@ GID_MAIN
Definition: gui.c:203
@ GID_ICON
Definition: gui.c:208
@ GID_PAGEINFO_INSECURE_BM
Definition: gui.c:217
@ GID_FAVE_ADD
Definition: gui.c:223
@ OID_VSCROLL
Definition: gui.c:201
@ GID_ADDTAB_BM
Definition: gui.c:228
@ GID_FAVE_RMV
Definition: gui.c:224
@ GID_PAGEINFO_INTERNAL_BM
Definition: gui.c:218
@ GID_PAGEINFO_SECURE_BM
Definition: gui.c:220
@ GID_FORWARD
Definition: gui.c:213
@ GID_STOP
Definition: gui.c:209
@ GID_PAGEINFO_LOCAL_BM
Definition: gui.c:219
@ GID_CLOSETAB_BM
Definition: gui.c:226
@ OID_MAIN
Definition: gui.c:200
@ GID_LOG
Definition: gui.c:241
@ GID_STATUS
Definition: gui.c:206
@ GID_HSCROLL
Definition: gui.c:236
@ GID_HOME
Definition: gui.c:211
@ GID_LAST
Definition: gui.c:242
@ GID_FAVE
Definition: gui.c:222
@ GID_PAGEINFO
Definition: gui.c:216
@ GID_TABS
Definition: gui.c:229
@ GID_RELOAD
Definition: gui.c:210
@ GID_SEARCH_ICON
Definition: gui.c:215
@ GID_ADDTAB
Definition: gui.c:227
@ GID_TABS_FLAG
Definition: gui.c:230
@ GID_LOGLAYOUT
Definition: gui.c:240
@ GID_TOOLBARLAYOUT
Definition: gui.c:232
@ GID_CLOSETAB
Definition: gui.c:225
@ GID_HOTLISTLAYOUT
Definition: gui.c:234
@ GID_VSCROLLLAYOUT
Definition: gui.c:239
@ GID_THROBBER
Definition: gui.c:214
@ GID_PAGEINFO_WARNING_BM
Definition: gui.c:221
@ GID_URL
Definition: gui.c:207
@ GID_HOTLIST
Definition: gui.c:233
@ GID_BACK
Definition: gui.c:212
@ GID_VSCROLL
Definition: gui.c:238
@ GID_BROWSER
Definition: gui.c:205
void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp)
Set ctxmenu history tmp in gui_window_2.
Definition: gui.c:604
static void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
Definition: gui.c:4145
static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Definition: gui.c:4699
static void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
Definition: gui.c:4167
int main(int argc, char **argv)
Normal entry point from OS.
Definition: gui.c:6528
nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table)
Add a window to the NetSurf window list (to enable event processing)
Definition: gui.c:4668
static nserror gui_search_web_provider_update(const char *provider_name, struct bitmap *ico_bitmap)
Gui callback when search provider details are updated.
Definition: gui.c:6000
static void ami_update_quals(struct gui_window_2 *gwin)
Definition: gui.c:1851
static void ami_handle_appmsg(void)
Definition: gui.c:3307
uint32 ami_gui_get_app_id(void)
Get the application.library ID NetSurf is registered as.
Definition: gui.c:6349
static void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
Definition: gui.c:4217
static STRPTR temp_homepage_url
Definition: gui.c:350
static struct IBox * ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct rect *rect)
Definition: gui.c:2000
void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin)
Switch to the most-recently-opened tab.
Definition: gui.c:4372
void ami_gui_history(struct gui_window_2 *gwin, bool back)
Definition: gui.c:1688
static void ami_set_screen_defaults(struct Screen *screen)
Definition: gui.c:985
bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *restrict x, ULONG *restrict y)
Definition: gui.c:6179
void * ami_window_at_pointer(int type)
undocumented, or internal, or documented elsewhere
Definition: gui.c:682
void ami_gui_close_window(void *w)
Close a window and all tabs attached to it.
Definition: gui.c:5473
static nserror amiga_window_invalidate_area(struct gui_window *g, const struct rect *restrict rect)
Invalidates an area of an amiga browser window.
Definition: gui.c:3698
struct Menu * ami_gui_get_menu(struct gui_window *gw)
Get imenu from gui_window.
Definition: gui.c:582
static void gui_file_gadget_open(struct gui_window *g, struct hlcache_handle *hl, struct form_control *gadget)
Definition: gui.c:6329
void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing)
Set throbbing status in gui_window.
Definition: gui.c:514
void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update)
Definition: gui.c:688
static void ami_do_redraw(struct gui_window_2 *gwin)
Definition: gui.c:5719
static void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys)
Definition: gui.c:5827
#define SCROLL_BOTTOM
Definition: gui.c:172
static nserror gui_window_set_url(struct gui_window *g, nsurl *url)
Definition: gui.c:5956
static UWORD ami_system_colour_scrollbar_fgpen(struct DrawInfo *drinfo)
Definition: gui.c:916
void ami_gui_adjust_scale(struct gui_window *gw, float adjustment)
Adjust scale by specified amount.
Definition: gui.c:4366
static struct MinList * window_list
Definition: gui.c:325
bool ami_locate_resource(char *fullpath, const char *file)
Definition: gui.c:814
#define SIDEUP
Definition: gui.c:176
static bool ami_gui_vscroll_add(struct gui_window_2 *gwin)
Definition: gui.c:2157
static ULONG applibsig
Definition: gui.c:346
bool ami_gui_get_throbbing(struct gui_window *gw)
Get throbbing status from gui_window.
Definition: gui.c:508
struct gui_window * ami_gui_get_active_gw(void)
Get a pointer to the gui_window which NetSurf considers to be the current/active one.
Definition: gui.c:398
static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy, int left, int top, int width, int height, int sx, int sy, struct IBox *bbox, struct redraw_context *ctx)
Definition: gui.c:4411
struct browser_window * ami_gui2_get_browser_window(struct gui_window_2 *gwin)
Get browser window from gui_window_2.
Definition: gui.c:425
static void gui_init2(int argc, char **argv)
Definition: gui.c:1435
static bool ami_gui_console_log_toggle(struct gui_window *g)
Definition: gui.c:2326
static BOOL locked_screen
Definition: gui.c:338
static Object * ami_gui_splash_open(void)
Definition: gui.c:6222
void ami_reset_pointer(struct gui_window_2 *gwin)
Definition: gui.c:696
static bool ami_gui_resources_open(void)
Definition: gui.c:888
void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist)
Set ctxmenu history in gui_window_2.
Definition: gui.c:622
static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
Definition: gui.c:2184
static struct MsgPort * applibport
Definition: gui.c:344
static void gui_quit(void)
Definition: gui.c:3909
#define USERS_DIR
Definition: gui.c:353
static struct gui_fetch_table amiga_fetch_table
Definition: gui.c:6509
void ami_get_msg(void)
Definition: gui.c:3510
STRPTR ami_gui_get_screen_title(void)
Get the string for NetSurf's screen titlebar.
Definition: gui.c:974
static bool ami_gui_hscroll_remove(struct gui_window_2 *gwin)
Definition: gui.c:2139
static void ami_redraw_callback(void *p)
Definition: gui.c:5613
#define NSA_QUAL_ALT
Definition: gui.c:182
static void ami_change_tab(struct gui_window_2 *gwin, int direction)
Definition: gui.c:3578
static void gui_window_set_title(struct gui_window *g, const char *restrict title)
Definition: gui.c:3601
struct ami_menu_data ** ami_gui2_get_menu_data(struct gui_window_2 *gwin)
Get menu_data from gui_window_2.
Definition: gui.c:598
static struct gui_globals * browserglob
Definition: gui.c:342
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
Definition: gui.c:4385
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin)
Definition: gui.c:5645
#define SCROLL_PAGE_UP
Definition: gui.c:170
static char * ami_gui_read_tooltypes(struct WBArg *wbarg)
Definition: gui.c:1389
void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu)
Set imenu to gui_window_2.
Definition: gui.c:589
static struct MsgPort * sport
Definition: gui.c:327
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip)
Definition: gui.c:6075
void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed)
Set closed in gui_window_2.
Definition: gui.c:628
nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox)
Compatibility function to get space.gadget render area.
Definition: gui.c:1857
Object * ami_gui2_get_object(struct gui_window_2 *gwin, int object_type)
Get object from gui_window.
Definition: gui.c:534
const char * ami_gui_get_win_title(struct gui_window *gw)
Get window title from gui_window.
Definition: gui.c:449
static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
Definition: gui.c:5650
static int ami_gui_hotlist_scan(struct List *speed_button_list, struct gui_window_2 *gwin)
Definition: gui.c:4061
static struct gui_window * cur_gw
Definition: gui.c:328
#define NSA_KBD_SCROLL_PX
Definition: gui.c:166
static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
Set the scroll position of a amiga browser window.
Definition: gui.c:5856
int ami_gui_get_throbber_frame(struct gui_window *gw)
Get throbbing frame from gui_window.
Definition: gui.c:520
static char * users_dir
Definition: gui.c:354
const char * ami_gui_get_tab_title(struct gui_window *gw)
Get tab title from gui_window.
Definition: gui.c:456
static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
function to add retrieved favicon to gui
Definition: gui.c:2462
static char * current_user_dir
Definition: gui.c:355
static void ami_gui_resources_free(void)
Definition: gui.c:878
void ami_gui_set_history_window(struct gui_window *gw, struct ami_history_local_window *hw)
Set local history window in gui_window.
Definition: gui.c:492
struct gui_window * ami_gui2_get_gui_window(struct gui_window_2 *gwin)
Get gui_window from gui_window_2.
Definition: gui.c:443
static void ami_handle_applib(void)
Definition: gui.c:3422
STRPTR ami_locale_langs(int *codeset)
Definition: gui.c:702
struct List * ami_gui_get_download_list(struct gui_window *gw)
Get download list from gui_window.
Definition: gui.c:431
#define NSA_QUAL_SHIFT
Definition: gui.c:181
Object * ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction)
Get ctxmenu history from gui_window_2.
Definition: gui.c:616
static void gui_window_new_content(struct gui_window *g)
Definition: gui.c:6133
static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy)
Definition: gui.c:5836
static void ami_gui_search_ico_refresh(void *p)
Definition: gui.c:4319
#define AMINS_SCROLLERPEN
Definition: gui.c:165
#define BOOL_MISMATCH(a, b)
Definition: gui.c:193
static bool ami_spacebox_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y, int space_x, int space_y)
Definition: gui.c:1883
static void ami_openscreen(void)
Definition: gui.c:1234
#define SCROLL_PAGE_DOWN
Definition: gui.c:171
static struct Hook newprefs_hook
Definition: gui.c:348
ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin)
Get tabs from gui_window_2.
Definition: gui.c:468
void ami_gui_beep(void)
Beep.
Definition: gui.c:414
void ami_gui_free_space_box(struct IBox *bbox)
Free any data obtained via ami_gui_get_space_box().
Definition: gui.c:1874
bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y, int mouse_x, int mouse_y)
Definition: gui.c:1898
static nserror colour_option_from_pen(UWORD pen, enum nsoption_e option, struct Screen *screen, colour def_colour)
set option from pen
Definition: gui.c:934
static bool ami_gui_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
Definition: gui.c:4005
static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
Definition: gui.c:3729
static void ami_gui_trap_mouse(struct gui_window_2 *gwin)
Definition: gui.c:2035
static void ami_gui_hotlist_toolbar_free(struct gui_window_2 *gwin, struct List *speed_button_list)
Definition: gui.c:4120
struct hlcache_handle * ami_gui_get_favicon(struct gui_window *gw)
Get favicon from gui_window.
Definition: gui.c:480
HOOKF(void, ami_gui_newprefs_hook, APTR, window, APTR)
Definition: gui.c:1229
static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw, bool busy, int x0, int y0, int x1, int y1)
Redraw an area of the browser window - Amiga-specific function.
Definition: gui.c:4512
void ami_gui_set_scale(struct gui_window *gw, float scale)
Set the scale of a gui window.
Definition: gui.c:4360
struct List * ami_gui2_get_tab_list(struct gui_window_2 *gwin)
Get tab list from gui_window_2.
Definition: gui.c:474
static const struct ami_win_event_table ami_gui_table
Definition: gui.c:4693
void ami_gui_win_list_remove(void *win)
Remove a window from the NetSurf window list.
Definition: gui.c:4682
int ami_gui_count_windows(int window, int *tabs)
Count windows, and optionally tabs.
Definition: gui.c:4332
static BOOL ami_gui_event(void *w)
Definition: gui.c:2630
static bool win_destroyed
Definition: gui.c:340
static void ami_quit_netsurf_delayed(void)
Definition: gui.c:3831
int ami_gui_get_quals(Object *win_obj)
Get which qualifier keys are being pressed.
Definition: gui.c:1826
static BOOL ami_handle_msg(void)
Definition: gui.c:2584
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin)
Definition: gui.c:3980
static nserror gui_page_info_change(struct gui_window *gw)
Definition: gui.c:3257
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
Schedule a redraw of the browser window - Amiga-specific function.
Definition: gui.c:5637
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect)
Definition: gui.c:6154
static void gui_window_console_log(struct gui_window *g, browser_window_console_source src, const char *msg, size_t msglen, browser_window_console_flags flags)
Definition: gui.c:2348
static void ami_openscreenfirst(void)
Definition: gui.c:1321
static bool ami_gui_check_resource(char *fullpath, const char *file)
Definition: gui.c:792
static void ami_gui_menu_update_all(void)
Definition: gui.c:2056
static void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL donotwait)
Definition: gui.c:3856
static bool ami_gui_hscroll_add(struct gui_window_2 *gwin)
Definition: gui.c:2111
struct Window * ami_gui2_get_window(struct gui_window_2 *gwin)
Get window from gui_window_2.
Definition: gui.c:570
#define SCROLL_TOP
Definition: gui.c:169
struct browser_window * ami_gui_get_browser_window(struct gui_window *gw)
Get browser window from gui_window.
Definition: gui.c:419
static struct MsgPort * schedulermsgport
Definition: gui.c:332
static struct MsgPort * appport
Definition: gui.c:333
static struct RDArgs * ami_gui_commandline(int *restrict argc, char **argv, int *restrict nargc, char **nargv)
Definition: gui.c:1328
static char * current_user_faviconcache
Definition: gui.c:356
static struct gui_window_table amiga_window_table
Definition: gui.c:6479
struct MinList * ami_gui_get_window_list(void)
Get the window list.
Definition: gui.c:408
char * ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
Definition: gui.c:3950
struct gui_window_2 * ami_gui_get_gui_window_2(struct gui_window *gw)
Get gui_window_2 from gui_window.
Definition: gui.c:437
static struct gui_search_web_table amiga_search_web_table
Definition: gui.c:6515
void ami_gui_tabs_toggle_all(void)
Definition: gui.c:4292
static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
Definition: gui.c:1407
static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
Definition: gui.c:1923
static char * ami_gui_get_user_dir(STRPTR current_user)
Definition: gui.c:6357
BOOL ami_gadget_hit(Object *obj, int x, int y)
Definition: gui.c:6206
#define nsoption_default_set_int(OPTION, VALUE)
void ami_gui_set_throbber_frame(struct gui_window *gw, int frame)
Set throbbing frame in gui_window.
Definition: gui.c:527
static void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs)
Definition: gui.c:5817
void ami_quit_netsurf(void)
Definition: gui.c:3797
#define NSA_MAX_HOTLIST_BUTTON_LEN
Definition: gui.c:167
#define AMI_GUI_TOOLBAR_MAX
Definition: gui.h:57
struct MsgPort * ami_gui_get_shared_msgport(void)
Get shared message port.
@ AMI_WIN_MAIN
Definition: gui.h:47
@ AMI_GAD_URL
Definition: gui.h:45
@ AMI_GAD_TABS
Definition: gui.h:44
@ AMI_GAD_SEARCH
Definition: gui.h:46
@ AMI_GAD_THROBBER
Definition: gui.h:43
void ami_help_new_screen(struct Screen *screen)
Definition: help.c:66
ULONG ami_help_signal(void)
Definition: help.c:72
void ami_help_process(void)
Definition: help.c:80
void ami_help_open(ULONG node, struct Screen *screen)
Definition: help.c:50
void ami_help_free(void)
Definition: help.c:57
@ AMI_HELP_GUI
Definition: help.h:26
void ami_menu_free_glyphs(void)
Definition: menu.c:182
void ami_misc_fatal_error(const char *message)
Definition: misc.c:73
int32 amiga_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win)
Definition: misc.c:93
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
Definition: misc.c:79
char * translate_escape_chars(const char *s)
returns a string with escape chars translated and string converted to local charset (based on remove_...
Definition: misc.c:246
struct gui_file_table * amiga_file_table
Definition: misc.c:463
nserror ami_pageinfo_open(struct browser_window *bw, ULONG left, ULONG top)
Open the page info window.
Definition: pageinfo.c:224
const struct plotter_table amiplot
Definition: plotters.c:1180
bool ami_plot_screen_is_palettemapped(void)
Definition: plotters.c:610
void ami_plot_ra_free(struct gui_globals *gg)
Free a plotter render area.
Definition: plotters.c:258
struct BitMap * ami_plot_ra_get_bitmap(struct gui_globals *gg)
Get a drawing BitMap associated with a render area.
Definition: plotters.c:295
void ami_plot_clear_bbox(struct RastPort *rp, struct IBox *bbox)
Definition: plotters.c:412
void ami_plot_ra_set_pen_list(struct gui_globals *gg, struct MinList *pen_list)
Set a list of shared pens for a render area to use Only relevant for palette-mapped screens.
Definition: plotters.c:306
void ami_plot_ra_get_size(struct gui_globals *gg, int *width, int *height)
Get size of BitMap associated with a render area.
Definition: plotters.c:300
void ami_clearclipreg(struct gui_globals *gg)
Definition: plotters.c:311
struct gui_globals * ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
Alloc a plotter render area.
Definition: plotters.c:113
void ami_plot_release_pens(struct MinList *shared_pens)
Definition: plotters.c:356
void ami_schedule_free(void)
Finalise amiga scheduler.
Definition: schedule.c:320
nserror ami_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
Definition: schedule.c:331
void ami_schedule_handle(struct MsgPort *nsmsgport)
Handle a message received from the scheduler process.
Definition: schedule.c:369
nserror ami_schedule_create(struct MsgPort *msgport)
Initialise amiga scheduler.
Definition: schedule.c:302
void ami_mouse_pointers_free(void)
Definition: theme.c:396
void ami_theme_throbber_free(void)
Definition: theme.c:191
int ami_theme_throbber_get_width(void)
Definition: theme.c:163
void ami_theme_init(void)
Definition: theme.c:134
void ami_init_mouse_pointers(void)
Definition: theme.c:284
void ami_theme_throbber_setup(void)
Definition: theme.c:173
void ami_throbber_redraw_schedule(int t, struct gui_window *g)
Definition: theme.c:517
int ami_theme_throbber_get_height(void)
Definition: theme.c:168
void ami_update_pointer(struct Window *win, gui_pointer_shape shape)
Definition: theme.c:221
void ami_get_theme_filename(char *filename, const char *themestring, bool protocol)
Definition: theme.c:198
void ami_arexx_cleanup(void)
Definition: arexx.c:185
STATIC char result[100]
Definition: arexx.c:77
bool ami_arexx_init(ULONG *rxsig)
Definition: arexx.c:127
void ami_arexx_self(const char *cmd)
Definition: arexx.c:167
void ami_arexx_execute(char *script)
Definition: arexx.c:172
void ami_arexx_handle(void)
Definition: arexx.c:156
void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
set the pointer shape
Definition: gui.c:481
Low-level source data cache backing store interface.
struct gui_llcache_table * filesystem_llcache_table
nserror browser_window_history_get_thumbnail(struct browser_window *bw, struct bitmap **bitmap_out)
Get the thumbnail bitmap for the current history entry.
nserror browser_window_history_forward(struct browser_window *bw, bool new_window)
Go forward in the history.
nserror browser_window_history_back(struct browser_window *bw, bool new_window)
Go back in the history.
Interface to browser history operations.
Browser window creation and manipulation interface.
nserror browser_window_schedule_reformat(struct browser_window *bw)
Reformat the browser window contents in a safe context.
bool browser_window_redraw_ready(struct browser_window *bw)
Check whether browser window is ready for redraw.
nserror browser_window_refresh_url_bar(struct browser_window *bw)
Update URL bar for a given browser window to bw's content's URL.
nserror browser_window_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data)
Get access to any page features at the given coordinates.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
bool browser_window_redraw(struct browser_window *bw, int x, int y, const struct rect *clip, const struct redraw_context *ctx)
Redraw an area of a window.
bool browser_window_has_content(struct browser_window *bw)
Find out if a browser window is currently showing a content.
bool browser_window_back_available(struct browser_window *bw)
Check availability of Back action for a given browser window.
nserror browser_window_get_scrollbar_type(struct browser_window *bw, browser_scrolling *h, browser_scrolling *v)
Get the browser window's scrollbar details.
void browser_window_mouse_click(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks in a browser window.
bool browser_window_scroll_at_point(struct browser_window *bw, int x, int y, int scrx, int scry)
Send a scroll request to a browser window at a particular point.
void browser_window_destroy(struct browser_window *bw)
Close and destroy a browser window.
nserror browser_window_reload(struct browser_window *bw, bool all)
Reload the page in a browser window.
browser_scrolling
@ BW_SCROLLING_NO
@ BW_SCROLLING_YES
bool browser_window_reload_available(struct browser_window *bw)
Check availability of Reload action for a given browser window.
bool browser_window_forward_available(struct browser_window *bw)
Check availability of Forward action for a given browser window.
browser_window_page_info_state
Browser window page information states.
@ PAGE_STATE_INSECURE
Insecure page load.
@ PAGE_STATE_SECURE_ISSUES
Secure load, but has insecure elements.
@ PAGE_STATE_SECURE
Secure load.
@ PAGE_STATE_SECURE_OVERRIDE
Secure load, but had to override.
@ PAGE_STATE_LOCAL
Page loaded from file:/// etc.
@ PAGE_STATE_INTERNAL
Page loaded from internal handler.
const char * browser_window_get_title(struct browser_window *bw)
Get the title of a browser_window.
nserror browser_window_get_extents(struct browser_window *bw, bool scaled, int *width, int *height)
Get a browser window's content extents.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
void browser_window_stop(struct browser_window *bw)
Stop all fetching activity in a browser window.
bool browser_window_is_frameset(struct browser_window *bw)
Find out if a browser window contains a frameset.
nserror browser_window_set_scale(struct browser_window *bw, float scale, bool absolute)
Sets the scale of a browser window.
browser_window_page_info_state browser_window_get_page_info_state(const struct browser_window *bw)
Request the current browser window page info state.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_CREATE_TAB
New gui_window to be tab in same window as "existing" gui_window.
@ BW_CREATE_CLONE
New gui_window to be clone of "existing" gui_window.
bool browser_window_stop_available(struct browser_window *bw)
Check availability of Stop action for a given browser window.
bool browser_window_drop_file_at_point(struct browser_window *bw, int x, int y, char *file)
Drop a file onto a browser window at a particular point, or determine if a file may be dropped onto t...
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
void browser_window_mouse_track(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle non-click mouse action in a browser window.
void browser_window_set_gadget_filename(struct browser_window *bw, struct form_control *gadget, const char *fn)
set filename on form control.
static osspriteop_area * buffer
The buffer characteristics.
Definition: buffer.c:55
browser_window_console_source
Sources of messages which end up in the browser window console.
Definition: console.h:30
@ BW_CS_SCRIPT_CONSOLE
Logging from some running script.
Definition: console.h:33
@ BW_CS_INPUT
Input from the client.
Definition: console.h:31
@ BW_CS_SCRIPT_ERROR
Error from some running script.
Definition: console.h:32
browser_window_console_flags
Flags for browser window console logging.
Definition: console.h:41
@ BW_CS_FLAG_LEVEL_LOG
Logged at the 'log' level, please only use one of the LEVEL flags.
Definition: console.h:55
@ BW_CS_FLAG_LEVEL_DEBUG
Logged at the 'debug' level, please use only one of the LEVEL flags.
Definition: console.h:53
@ BW_CS_FLAG_LEVEL_INFO
Logged at the 'info' level, please use only one of the LEVEL flags.
Definition: console.h:57
@ BW_CS_FLAG_LEVEL_MASK
Mask for the error level to allow easy comparison using the above.
Definition: console.h:64
@ BW_CS_FLAG_LEVEL_WARN
Logged at the 'warn' level, please use only one of the LEVEL flags.
Definition: console.h:59
@ BW_CS_FLAG_LEVEL_ERROR
Logged at the 'error' level, please use only one of the LEVEL flags.
Definition: console.h:61
@ BW_CS_FLAG_FOLDABLE
The log entry is foldable.
Definition: console.h:50
nserror fetch_fdset(fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *maxfd_out)
Get the set of file descriptors the fetchers are currently using.
Definition: fetch.c:385
Fetching of data from a URL (interface).
Unified cookie database public interface.
void urldb_save_cookies(const char *filename)
Save persistent cookies to file.
Definition: urldb.c:4448
void urldb_load_cookies(const char *filename)
Load a cookie file into the database.
Definition: urldb.c:4281
#define amiga_datatypes_init()
Definition: datatypes.h:37
nserror hotlist_fini(void)
Finalise the hotlist.
Definition: hotlist.c:1388
nserror hotlist_add_url(nsurl *url)
Add an entry to the hotlist for given URL.
Definition: hotlist.c:1431
nserror hotlist_init(const char *load_path, const char *save_path)
Initialise the hotlist.
Definition: hotlist.c:1290
bool hotlist_has_url(nsurl *url)
Check whether given URL is present in hotlist.
Definition: hotlist.c:1494
void hotlist_remove_url(nsurl *url)
Remove any entries matching the given URL from the hotlist.
Definition: hotlist.c:1536
#define NSOPTION_SYS_COLOUR_END
Definition: options.h:38
#define NSOPTION_SYS_COLOUR_START
Definition: options.h:37
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out)
Generate a nsurl from a search term.
Definition: searchweb.c:318
nserror search_web_init(const char *provider_fname)
Initialise the web search operations.
Definition: searchweb.c:517
nserror search_web_select_provider(int selection)
Change the currently selected web search provider.
Definition: searchweb.c:397
bool ami_drag_has_data(void)
Definition: drag.c:329
void gui_drag_save_selection(struct gui_window *g, const char *selection)
Definition: drag.c:303
void ami_drag_save(struct Window *win)
Definition: drag.c:307
bool ami_drag_icon_move(void)
Definition: drag.c:319
void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c, gui_save_type type)
Definition: drag.c:298
#define AMI_DRAG_THRESHOLD
Definition: drag.h:28
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_BAD_PARAMETER
Bad Parameter.
Definition: errors.h:48
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
const char * type
Definition: filetype.cpp:44
static void gui_window_start_throbber(struct gui_window *g)
Definition: gui.c:2055
static void gui_window_stop_throbber(struct gui_window *gw)
Definition: gui.c:2062
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm)
Definition: bitmap.c:666
void ami_bitmap_fini(void)
Cleanup bitmap allocations.
Definition: bitmap.c:678
bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
Save a bitmap in the platform's native format.
Definition: bitmap.c:255
PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height, struct BitMap *n_bm)
Definition: bitmap.c:626
struct gui_bitmap_table * amiga_bitmap_table
Definition: bitmap.c:777
bool amiga_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.c:309
#define AMI_BITMAP_SCALE_ICON
Definition: bitmap.h:31
void ami_free_download_list(struct List *dllist)
Definition: download.c:407
nserror gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
Definition: download.c:428
struct gui_download_table * amiga_download_table
Definition: download.c:534
void ami_download_parse_backmsg(const char *backmsg)
Definition: download.c:520
struct FileRequester * filereq
Definition: file.c:52
void ami_file_req_free(void)
Definition: file.c:300
void ami_file_req_init(void)
Definition: file.c:281
struct TextFont * ami_font_open_disk_font(struct TextAttr *tattr)
Definition: font.c:101
void ami_font_close_disk_font(struct TextFont *tfont)
Definition: font.c:107
void ami_font_init(void)
Definition: font.c:113
struct gui_layout_table * ami_layout_table
Definition: font.c:162
void ami_font_setdevicedpi(int id)
Definition: font.c:48
void ami_font_fini(void)
Definition: font.c:122
nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder, bool(*cb_add_item)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder))
Scan the hotlist.
Definition: hotlist.c:151
nserror ami_nsoption_read(void)
Definition: nsoption.c:29
nserror ami_nsoption_set_location(const char *current_user_dir)
Definition: nsoption.c:39
void ami_nsoption_free(void)
Definition: nsoption.c:52
nserror ami_nsoption_write(void)
Definition: nsoption.c:34
struct MinList * ami_AllocMinList(void)
List abstraction as OS3 appears to have problems with NewMinList()
Definition: object.c:63
struct MinList * NewObjList(void)
Definition: object.c:71
void FreeObjList(struct MinList *objlist)
Definition: object.c:117
void ami_object_fini(void)
Definition: object.c:50
bool ami_object_init(void)
Initialisation for itempool.
Definition: object.c:42
void DelObject(struct nsObject *dtzo)
Definition: object.c:107
struct nsObject * AddObject(struct MinList *objlist, ULONG otype)
Definition: object.c:77
void DelObjectNoFree(struct nsObject *dtzo)
Definition: object.c:112
@ AMINS_WINDOW
Definition: object.h:28
@ AMINS_GUIOPTSWINDOW
Definition: object.h:34
@ AMINS_TVWINDOW
Definition: object.h:31
@ AMINS_RECT
Definition: object.h:39
bool ami_print_cont(void)
Definition: print.c:460
struct MsgPort * ami_print_get_msgport(void)
Definition: print.c:494
struct gui_window * ami_search_get_gwin(struct find_window *fw)
Obtain gui window associated with find window.
Definition: search.c:127
struct gui_search_table * amiga_search_table
Definition: search.c:125
void ami_search_close(void)
Close search.
Definition: search.c:229
void ami_utf8_free(char *ptr)
Definition: utf8.c:104
char * ami_to_utf8_easy(const char *string)
Definition: utf8.c:119
char * ami_utf8_easy(const char *string)
Definition: utf8.c:109
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
Definition: utf8.c:80
struct atari_hotlist hl
Definition: hotlist.c:47
void ami_gui_menu_update_checked(struct gui_window_2 *gwin)
Definition: gui_menu.c:691
void ami_gui_menu_refresh_hotlist(void)
Refresh the Hotlist menu.
Definition: gui_menu.c:1163
void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
Definition: gui_menu.c:735
struct Menu * ami_gui_menu_create(struct gui_window_2 *gwin)
Definition: gui_menu.c:1062
bool ami_gui_menu_get_check_toggled(void)
Gets if the menu needs updating because an item linked to a toggle menu item has been changed.
Definition: gui_menu.c:818
void ami_gui_menu_freemenus(struct Menu *menu, struct ami_menu_data **md)
Frees a menu.
Definition: gui_menu.c:1127
bool ami_gui_menu_quit_selected(void)
Gets if NetSurf has been quit from the menu.
Definition: gui_menu.c:1158
void ami_gui_menu_free(struct gui_window_2 *gwin)
Definition: gui_menu.c:1138
void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable)
Set disabled state of a menu item almost generic, but not quite.
Definition: gui_menu.c:679
const char *const verdate
Definition: gui_menu.c:93
const char *const netsurf_version
User friendly version string.
Definition: gui_menu.c:92
@ AMI_MENU_AREXX_MAX
Definition: gui_menu.h:102
@ M_CLOSETAB
Definition: gui_menu.h:47
@ M_PASTE
Definition: gui_menu.h:57
static CONST_STRPTR tabs[OPTS_MAX_TABS]
Definition: gui_options.c:253
void ami_gui_opts_websearch_free(struct List *websearchlist)
Definition: gui_options.c:2344
struct List * ami_gui_opts_websearch(void)
Definition: gui_options.c:2322
void ami_gui_opts_open(void)
Definition: gui_options.c:525
nserror ami_history_local_destroy(struct ami_history_local_window *history_local_win)
destroy a previously created local history view
Definition: history_local.c:74
struct DiskObject * amiga_icon_from_bitmap(struct bitmap *bm)
Definition: icon.c:521
void amiga_icon_free(struct DiskObject *dobj)
Definition: icon.c:569
void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct DiskObject *dobj)
Definition: icon.c:390
Content for image/x-amiga-icon (icon.library interface).
#define amiga_icon_init()
Definition: icon.h:36
struct fbtk_bitmap reload_g
struct fbtk_bitmap reload
Public content interface.
struct bitmap * content_get_bitmap(struct hlcache_handle *h)
Retrieve the bitmap contained in an image content.
Definition: content.c:1264
Interface to platform-specific fetcher operations.
Interface to platform-specific miscellaneous browser operation table.
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
@ BROWSER_MOUSE_PRESS_1
button 1 pressed
Definition: mouse.h:50
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
Definition: mouse.h:57
@ BROWSER_MOUSE_PRESS_2
button 2 pressed
Definition: mouse.h:52
@ BROWSER_MOUSE_TRIPLE_CLICK
button triple clicked
Definition: mouse.h:62
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
Definition: mouse.h:55
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
Definition: mouse.h:80
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
Definition: mouse.h:60
@ BROWSER_MOUSE_MOD_3
3rd modifier key pressed (eg.
Definition: mouse.h:82
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
Definition: mouse.h:78
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
Definition: mouse.h:65
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
Definition: mouse.h:75
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
Definition: mouse.h:73
@ BROWSER_MOUSE_DRAG_ON
a drag operation was started and a mouse button is still pressed
Definition: mouse.h:70
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Definition: mouse.h:67
gui_pointer_shape
Definition: mouse.h:89
@ GUI_POINTER_WAIT
Definition: mouse.h:104
@ GUI_POINTER_DEFAULT
Definition: mouse.h:90
Interface to platform-specific graphical user interface window operations.
gui_window_create_flags
Window creation control flags.
Definition: window.h:66
@ GW_CREATE_TAB
Create tab in same window as existing.
Definition: window.h:69
gui_drag_type
Definition: window.h:56
@ GDRAGGING_NONE
Definition: window.h:57
@ GDRAGGING_SCROLLBAR
Definition: window.h:58
@ GDRAGGING_OTHER
Definition: window.h:60
gui_window_event
Window events.
Definition: window.h:80
@ GW_EVENT_PAGE_INFO_CHANGE
Page status has changed and so the padlock should be updated.
Definition: window.h:129
@ GW_EVENT_REMOVE_CARET
Remove the caret, if present.
Definition: window.h:98
@ GW_EVENT_NEW_CONTENT
Called when the gui_window has new content.
Definition: window.h:118
@ GW_EVENT_STOP_THROBBER
stop the navigation throbber.
Definition: window.h:108
@ GW_EVENT_UPDATE_EXTENT
Update the extent of the inside of a browser window to that of the current content.
Definition: window.h:93
@ GW_EVENT_START_SELECTION
selection started
Definition: window.h:123
@ GW_EVENT_START_THROBBER
start the navigation throbber.
Definition: window.h:103
Interface to key press operations.
@ NS_KEY_REDO
Definition: keypress.h:71
@ NS_KEY_DELETE_LINE_START
Definition: keypress.h:68
@ NS_KEY_SHIFT_TAB
Definition: keypress.h:39
@ NS_KEY_LINE_START
Definition: keypress.h:57
@ NS_KEY_RIGHT
Definition: keypress.h:51
@ NS_KEY_LEFT
Definition: keypress.h:50
@ NS_KEY_SELECT_ALL
Definition: keypress.h:32
@ NS_KEY_PASTE
Definition: keypress.h:43
@ NS_KEY_TAB
Definition: keypress.h:36
@ NS_KEY_COPY_SELECTION
Definition: keypress.h:33
@ NS_KEY_DOWN
Definition: keypress.h:53
@ NS_KEY_CUT_SELECTION
Definition: keypress.h:44
@ NS_KEY_WORD_LEFT
Definition: keypress.h:61
@ NS_KEY_DELETE_LINE_END
Definition: keypress.h:67
@ NS_KEY_PAGE_UP
Definition: keypress.h:65
@ NS_KEY_PAGE_DOWN
Definition: keypress.h:66
@ NS_KEY_UNDO
Definition: keypress.h:70
@ NS_KEY_TEXT_START
Definition: keypress.h:59
@ NS_KEY_LINE_END
Definition: keypress.h:58
@ NS_KEY_TEXT_END
Definition: keypress.h:60
@ NS_KEY_DELETE_RIGHT
Definition: keypress.h:55
@ NS_KEY_CLEAR_SELECTION
Definition: keypress.h:45
@ NS_KEY_WORD_RIGHT
Definition: keypress.h:63
@ NS_KEY_DELETE_LEFT
Definition: keypress.h:35
@ NS_KEY_UP
Definition: keypress.h:52
@ NS_KEY_ESCAPE
Definition: keypress.h:47
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
Handle key presses in a browser window.
Definition: textinput.c:107
void ami_openurl_open(void)
Initialise the fetcher.
Definition: launch.c:127
void ami_openurl_close(void)
Definition: launch.c:140
Fetching of data from a URL (Registration).
bool ami_libs_open(void)
Definition: libs.c:221
void ami_libs_close(void)
Definition: libs.c:301
#define SpeedBarObj
Definition: libs.h:75
#define LayoutHObj
Definition: libs.h:64
#define ListBrowserObj
Definition: libs.h:66
#define LabelObj
Definition: libs.h:63
#define WindowObj
Definition: libs.h:77
#define BitMapObj
Definition: libs.h:53
#define ChooserObj
Definition: libs.h:56
#define LayoutVObj
Definition: libs.h:65
#define ScrollerObj
Definition: libs.h:73
#define SpaceObj
Definition: libs.h:74
#define ButtonObj
Definition: libs.h:54
#define BevelObj
Definition: libs.h:52
#define StringObj
Definition: libs.h:76
#define ClickTabObj
Definition: libs.h:57
nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
Initialise the logging system.
Definition: log.c:190
void nslog_finalise(void)
Shut down the logging system.
Definition: log.c:299
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
void ami_memory_fini(struct Interrupt *memhandler)
Definition: memory.c:179
struct Interrupt * ami_memory_init(void)
Definition: memory.c:165
#define ami_memory_itempool_create(s)
Definition: memory.h:54
#define ami_memory_itempool_alloc(p, s)
Definition: memory.h:56
#define ami_memory_itempool_free(p, i, s)
Definition: memory.h:57
#define ami_memory_itempool_delete(p)
Definition: memory.h:55
nserror messages_add_from_file(const char *path)
Read keys and values from messages file into the standard Messages hash.
Definition: messages.c:177
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
NetSurf core interface registration, construction and destruction.
void netsurf_exit(void)
Finalise NetSurf core.
Definition: netsurf.c:232
nserror netsurf_init(const char *store_path)
Initialise netsurf core.
Definition: netsurf.c:107
nserror netsurf_register(struct netsurf_table *table)
Register operation table.
Definition: gui_factory.c:707
NetSurf URL handling (interface).
nserror nsurl_get_utf8(const nsurl *url, char **url_s, size_t *url_l)
Get a UTF-8 string (for human readable IDNs) from a NetSurf URL object.
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
uint32_t nsurl_hash(const nsurl *url)
Get a URL's hash value.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
struct Node * GetPred(struct Node *node)
Definition: os3support.c:375
void FreeSysObject(ULONG type, APTR obj)
Definition: os3support.c:350
APTR NewObject(struct IClass *classPtr, CONST_STRPTR classID, ULONG tagList,...)
Definition: os3support.c:434
char * ASPrintf(const char *fmt,...)
Definition: os3support.c:139
uint32 GetAttrs(Object *obj, Tag tag1,...)
Definition: os3support.c:389
struct Node * GetHead(struct List *list)
Definition: os3support.c:364
ULONG RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1,...)
Definition: os3support.c:429
struct Node * GetSucc(struct Node *node)
Definition: os3support.c:381
#define AllocSysObjectTags(A, B, C, D)
Definition: os3support.h:157
#define LBS_ROWS
Definition: os3support.h:128
#define MINTERM_SRCMASK
Definition: os3support.h:139
#define SetCurrentDir(L)
Definition: os3support.h:161
#define RAWKEY_DEL
Definition: os3support.h:99
#define LBNCA_SoftStyle
Definition: os3support.h:82
#define RAWKEY_BACKSPACE
Definition: os3support.h:96
#define RAWKEY_F12
Definition: os3support.h:110
#define LIB_IS_AT_LEAST(B, V, R)
Definition: os3support.h:55
#define DN_FULLPATH
Definition: os3support.h:123
#define RAWKEY_PAGEUP
Definition: os3support.h:100
#define TNA_HintInfo
Definition: os3support.h:88
#define RAWKEY_ESC
Definition: os3support.h:98
#define RAWKEY_CRSRRIGHT
Definition: os3support.h:104
#define ASO_NoTrack
Definition: os3support.h:64
#define GA_ContextMenu
Definition: os3support.h:77
#define CLICKTAB_LabelTruncate
Definition: os3support.h:71
#define RAWKEY_F8
Definition: os3support.h:107
#define WINDOW_NewPrefsHook
Definition: os3support.h:93
#define WA_ContextMenuHook
Definition: os3support.h:89
#define WINDOW_BuiltInScroll
Definition: os3support.h:91
#define RAWKEY_END
Definition: os3support.h:113
#define IDoMethod
Definition: os3support.h:169
#define CLICKTAB_FlagImage
Definition: os3support.h:70
#define RAWKEY_F10
Definition: os3support.h:109
#define RPTAG_APenColor
Definition: os3support.h:76
#define RAWKEY_HOME
Definition: os3support.h:112
#define BITMAP_HasAlpha
Definition: os3support.h:66
#define RAWKEY_CRSRUP
Definition: os3support.h:102
#define RAWKEY_TAB
Definition: os3support.h:97
#define CLICKTAB_CloseImage
Definition: os3support.h:69
#define RAWKEY_F9
Definition: os3support.h:108
#define RAWKEY_CRSRLEFT
Definition: os3support.h:105
#define IDCMP_EXTENDEDMOUSE
Definition: os3support.h:121
#define IA_InBorder
Definition: os3support.h:80
#define SBNA_HintInfo
Definition: os3support.h:86
#define BLITA_UseSrcAlpha
Definition: os3support.h:67
#define BLITA_MaskPlane
Definition: os3support.h:68
#define CLICKTAB_NodeClosed
Definition: os3support.h:72
#define GAUGEIA_Level
Definition: os3support.h:79
#define DevNameFromLock(A, B, C, D)
Definition: os3support.h:162
#define IA_Label
Definition: os3support.h:81
#define RAWKEY_CRSRDOWN
Definition: os3support.h:103
#define BITMAP_DisabledSourceFile
Definition: os3support.h:65
#define RAWKEY_HELP
Definition: os3support.h:111
#define DISABLEDTEXTPEN
Definition: os3support.h:116
@ ASOT_PORT
Definition: os3support.h:226
#define GA_HintInfo
Definition: os3support.h:78
#define FOpen(A, B, C)
Definition: os3support.h:158
int32_t int32
Definition: os3support.h:183
#define ObtainCharsetInfo(A, B, C)
Definition: os3support.h:154
uint16_t uint16
Definition: os3support.h:182
#define IsMinListEmpty(L)
Definition: os3support.h:54
#define TNA_CloseGadget
Definition: os3support.h:87
uint32_t uint32
Definition: os3support.h:184
#define RAWKEY_PAGEDOWN
Definition: os3support.h:101
#define ShowWindow(...)
Definition: os3support.h:172
#define LISTBROWSER_Striping
Definition: os3support.h:83
#define WINDOW_BACKMOST
Definition: os3support.h:122
#define CreateDirTree(D)
Definition: os3support.h:160
#define WA_ToolBox
Definition: os3support.h:90
#define RAWKEY_F5
Definition: os3support.h:106
#define FClose(A)
Definition: os3support.h:159
#define SA_Compositing
Definition: os3support.h:84
nserror amiga_plugin_hack_init(void)
Definition: plugin_hack.c:75
int width
Definition: gui.c:159
static nserror gui_launch_url(struct nsurl *url)
Broadcast an URL that we can't handle.
Definition: gui.c:2033
int height
Definition: gui.c:160
void save_complete_init(void)
Initialise save complete module.
Save HTML document with dependencies (interface).
core web search facilities interface.
@ SEARCH_WEB_OMNI_NONE
no changes to default operation
Definition: searchweb.h:50
@ SEARCH_WEB_OMNI_SEARCHONLY
The search does not attempt to interpret the url as a url before using it as a search term.
Definition: searchweb.h:55
void gui_create_form_select_menu(struct gui_window *g, struct form_control *control)
Definition: selectmenu.c:190
Interface to utility string handling.
Class * MakeStringClass(void)
#define STRINGVIEW_Header
Definition: stringview.h:50
void FreeStringClass(Class *)
struct nsObject * node
Definition: gui.h:74
const struct ami_win_event_table * tbl
Definition: gui.h:75
struct gui_window_2 * gw
Definition: gui.c:321
struct List * sblist
Definition: gui.c:320
Amiga local history viewing window context.
Definition: history_local.c:57
struct gui_window * gw
Amiga GUI stuff.
Definition: history_local.c:62
BOOL(* event)(void *w)
Definition: gui.h:65
void(* close)(void *w)
Definition: gui.h:70
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
Page features at a specific spatial location.
enum browser_window_features::@56 form_features
type of form feature.
Browser window data.
struct browser_window * bw
Form control.
Definition: form_internal.h:73
function table for fetcher operations.
Definition: fetch.h:33
const char *(* filetype)(const char *unix_path)
Determine the MIME type of a local file.
Definition: fetch.h:45
Graphical user interface browser misc function table.
Definition: misc.h:39
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
Definition: misc.h:58
Graphical user interface browser web search function table.
Definition: searchweb.h:34
nserror(* provider_update)(const char *provider_name, struct bitmap *ico_bitmap)
called when the search provider details are updated.
Definition: searchweb.h:42
User interface utf8 characterset conversion routines.
Definition: utf8.h:31
browser_mouse_state mouse_state
Definition: gui.c:257
char *restrict helphints[GID_LAST]
Definition: gui.c:275
browser_mouse_state prev_mouse_state
Definition: gui.c:276
int throbber_frame
Definition: gui.c:251
Object *restrict objects[GID_LAST]
Definition: gui.c:248
struct List hotlist_toolbar_list
Definition: gui.c:269
bool closed
Definition: gui.c:292
char *restrict wintitle
Definition: gui.c:274
ULONG oldh
Definition: gui.c:261
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX]
Definition: gui.c:268
ULONG tabs
Definition: gui.c:253
struct ami_menu_data * menu_data[AMI_MENU_AREXX_MAX+1]
Definition: gui.c:266
ULONG oldv
Definition: gui.c:262
gui_pointer_shape mouse_pointer
Definition: gui.c:290
Object * search_bm
Definition: gui.c:271
char *restrict status
Definition: gui.c:273
gui_drag_type drag_op
Definition: gui.c:286
struct DiskObject * dobj
Definition: gui.c:279
browser_mouse_state key_state
Definition: gui.c:258
ULONG hotlist_items
Definition: gui.c:267
struct find_window * searchwin
Definition: gui.c:260
ULONG next_tab
Definition: gui.c:254
struct Hook * ctxmenu_hook
Definition: gui.c:283
struct Menu * imenu
Definition: gui.c:291
struct Hook throbber_hook
Definition: gui.c:281
bool new_content
Definition: gui.c:265
Object * clicktab_ctxmenu
Definition: gui.c:285
struct ami_generic_window w
Definition: gui.c:246
struct List * web_search_list
Definition: gui.c:270
struct gui_window * gw
Definition: gui.c:249
ULONG throbber_update_count
Definition: gui.c:259
struct AppIcon * appicon
Definition: gui.c:278
struct Hook browser_hook
Definition: gui.c:282
struct Hook scrollerhook
Definition: gui.c:256
struct Node * last_new_tab
Definition: gui.c:255
Object *restrict history_ctxmenu[2]
Definition: gui.c:284
bool redraw_scroll
Definition: gui.c:264
struct AppWindow * appwin
Definition: gui.c:288
struct timeval lastclick
Definition: gui.c:277
struct List tab_list
Definition: gui.c:252
int temp
Definition: gui.c:263
struct Hook favicon_hook
Definition: gui.c:280
struct IBox * ptr_lock
Definition: gui.c:287
struct MinList * shared_pens
Definition: gui.c:289
char *restrict svbuffer
Definition: gui.c:272
struct Window * win
Definition: gui.c:247
bool redraw_required
Definition: gui.c:250
Graphical user interface window function table.
Definition: window.h:137
struct gui_window *(* create)(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Create and open a gui window for a browsing context.
Definition: window.h:164
first entry in window list
Definition: gui.c:296
int c_h_temp
Definition: gui.c:304
struct gui_window_2 * shared
Definition: gui.c:297
bool throbbing
whether currently throbbing
Definition: gui.c:310
struct ColumnInfo * logcolumns
Definition: gui.c:315
char * tabtitle
Definition: gui.c:311
struct MinList * deferred_rects
Definition: gui.c:313
char * url
Definition: gui.h:154
APTR deferred_rects_pool
Definition: gui.c:312
int scrollx
current scroll location
Definition: gui.c:305
int tab
Definition: gui.c:298
struct List loglist
Definition: gui.c:316
int c_y
Definition: gui.c:301
struct List dllist
Definition: gui.c:308
struct hlcache_handle * favicon
Definition: gui.c:309
struct fbtk_widget_s * stop
Definition: gui.h:37
struct ami_history_local_window * hw
Definition: gui.c:307
int c_h
Definition: gui.c:303
struct Node * tab_node
Definition: gui.c:299
int scrolly
current scroll location
Definition: gui.c:306
int c_x
Definition: gui.c:300
int c_w
Definition: gui.c:302
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
Definition: gui.c:314
High-level cache handle.
Definition: hlcache.c:66
NetSurf operation function table.
Definition: gui_table.h:48
struct gui_misc_table * misc
Browser table.
Definition: gui_table.h:57
ULONG Type
Definition: object.h:45
void * objstruct
Definition: object.h:46
union nsoption_s::@149 value
colour c
Definition: nsoption.h:120
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
void * priv
Private context.
Definition: plotters.h:81
Definition: theme.h:64
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
struct rect rect
Rectangle coordinates.
static int mouse_x
Definition: url_complete.c:66
static int mouse_y
Definition: url_complete.c:67
Unified URL information database public interface.
nserror urldb_save(const char *filename)
Export the current database to file.
Definition: urldb.c:3094
nserror urldb_load(const char *filename)
Import an URL database from file, replacing any existing database.
Definition: urldb.c:2876
struct List * URLHistory_GetList(void)
nserror netsurf_path_to_nsurl(const char *path, struct nsurl **url)
Create a nsurl from a path.
Definition: file.c:307
nserror netsurf_mkpath(char **str, size_t *size, size_t nelm,...)
Generate a path from one or more component elemnts.
Definition: file.c:288
Default operations table for files.
struct nsoption_s * nsoptions_default
global default option table.
Definition: nsoption.c:46
static struct nsoption_s defaults[]
The table of compiled in default options.
Definition: nsoption.c:64
struct nsoption_s * nsoptions
global active option table.
Definition: nsoption.c:45
nserror nsoption_commandline(int *pargc, char **argv, struct nsoption_s *opts)
Process commandline and set options approriately.
Definition: nsoption.c:824
nserror nsoption_init(nsoption_set_default_t *set_defaults, struct nsoption_s **popts, struct nsoption_s **pdefs)
Initialise option system.
Definition: nsoption.c:629
nserror nsoption_finalise(struct nsoption_s *opts, struct nsoption_s *defs)
Finalise option system.
Definition: nsoption.c:684
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:297
#define nsoption_setnull_charp(OPTION, VALUE)
set string option in default table if currently unset
Definition: nsoption.h:342
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:279
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
Definition: nsoption.h:314
nsoption_e
Definition: nsoption.h:131
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
Definition: nsoption.h:310
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Definition: nsoption.h:338
@ OPTION_COLOUR
Option is a netsurf colour.
Definition: nsoption.h:107
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:270
uint32_t utf8_to_ucs4(const char *s_in, size_t l)
Convert a UTF-8 multibyte sequence into a single UCS4 character.
Definition: utf8.c:41
size_t utf8_char_byte_length(const char *s)
Calculate the length (in bytes) of a UTF-8 character.
Definition: utf8.c:104
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
Version information interface.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357