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