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