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