Attempt to fix some OS3 build errors in gui.c

This commit is contained in:
Chris Young 2015-01-17 17:06:48 +00:00
parent bf14b2ddb1
commit 0c4f942c2d
3 changed files with 155 additions and 37 deletions

View File

@ -35,24 +35,26 @@
#include <proto/keymap.h>
#include <proto/locale.h>
#include <proto/Picasso96API.h>
#ifdef __amigaos4__
#include <proto/popupmenu.h>
#endif
#include <proto/utility.h>
#include <proto/wb.h>
/* Other OS includes */
#include <datatypes/textclass.h>
#include <devices/inputevent.h>
#include <graphics/rpattr.h>
#ifdef __amigaos4__
#include <graphics/blitattr.h>
#include <intuition/gui.h>
#include <libraries/application.h>
#include <libraries/keymap.h>
#endif
#include <libraries/gadtools.h>
#include <intuition/icclass.h>
#include <graphics/rpattr.h>
#include <workbench/workbench.h>
#include <intuition/gui.h>
#include <intuition/screens.h>
#include <libraries/gadtools.h>
#include <workbench/workbench.h>
/* ReAction libraries */
#include <proto/bevel.h>
@ -427,11 +429,15 @@ static bool ami_open_resources(void)
static UWORD ami_system_colour_scrollbar_fgpen(struct DrawInfo *drinfo)
{
LONG scrollerfillpen = FALSE;
#ifdef __amigaos4__
GetGUIAttrs(NULL, drinfo, GUIA_PropKnobColor, &scrollerfillpen, TAG_DONE);
if(scrollerfillpen) return FILLPEN;
else return FOREGROUNDPEN;
#else
return FILLPEN;
#endif
}
/**
@ -498,7 +504,7 @@ static void ami_set_screen_defaults(struct Screen *screen)
nsoption_default_set_int(redraw_tile_size_x, screen->Width);
nsoption_default_set_int(redraw_tile_size_y, screen->Height);
#ifdef __amigaos4__
/* set system colours for amiga ui */
colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveBorder, screen, 0x00000000);
colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveCaption, screen, 0x00dddddd);
@ -528,6 +534,7 @@ static void ami_set_screen_defaults(struct Screen *screen)
colour_option_from_pen(BACKGROUNDPEN, NSOPTION_sys_colour_Window, screen, 0x00aaaaaa);
colour_option_from_pen(INACTIVEFILLPEN, NSOPTION_sys_colour_WindowFrame, screen, 0x00000000);
colour_option_from_pen(TEXTPEN, NSOPTION_sys_colour_WindowText, screen, 0x00000000);
#endif
}
@ -971,7 +978,7 @@ static void gui_init2(int argc, char** argv)
ami_quit=true;
return;
}
#ifdef __amigaos4__
if(IApplication)
{
if(argc == 0)
@ -1008,7 +1015,7 @@ static void gui_init2(int argc, char** argv)
GetApplicationAttrs(ami_appid, APPATTR_Port, (ULONG)&applibport, TAG_DONE);
if(applibport) applibsig = (1L << applibport->mp_SigBit);
}
#endif
if(!bw && (nsoption_bool(startup_no_window) == false)) {
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
@ -1233,9 +1240,11 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
static void ami_update_quals(struct gui_window_2 *gwin)
{
uint32 quals = 0;
#ifdef __amigaos4__
GetAttr(WINDOW_Qualifier,gwin->objects[OID_MAIN],(uint32 *)&quals);
#else
#warning qualifier needs fixing for OS3
#endif
gwin->key_state = 0;
if((quals & IEQUALIFIER_LSHIFT) || (quals & IEQUALIFIER_RSHIFT))
@ -1258,9 +1267,11 @@ static void ami_update_quals(struct gui_window_2 *gwin)
nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox)
{
if(LIB_IS_AT_LEAST((struct Library *)SpaceBase, 53, 6)) {
#ifdef __amigaos4__
*bbox = AllocVecTagList(sizeof(struct IBox), NULL);
if(*bbox == NULL) return NSERROR_NOMEM;
GetAttr(SPACE_RenderBox, obj, (ULONG *)*bbox);
#endif
} else {
GetAttr(SPACE_AreaBox, obj, (ULONG *)bbox);
}
@ -1431,6 +1442,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
static void ami_gui_trap_mouse(struct gui_window_2 *gwin)
{
#ifdef __amigaos4__
switch(gwin->drag_op)
{
case GDRAGGING_NONE:
@ -1446,6 +1458,7 @@ static void ami_gui_trap_mouse(struct gui_window_2 *gwin)
}
break;
}
#endif
}
static void ami_gui_menu_update_all(void)
@ -1511,23 +1524,26 @@ static bool ami_gui_hscroll_add(struct gui_window_2 *gwin)
SCROLLER_Orientation, SORIENT_HORIZ,
ICA_TARGET, ICTARGET_IDCMP,
ScrollerEnd;
#ifdef __amigaos4__
IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_ADDCHILD,
gwin->win, gwin->objects[GID_HSCROLL], attrs);
#else
#warning FIXME for OS3 - logically we should just permanently enable
#endif
return true;
}
/* Remove the horizontal scroller, if present */
static bool ami_gui_hscroll_remove(struct gui_window_2 *gwin)
{
#ifdef __amigaos4__
if(gwin->objects[GID_HSCROLL] == NULL) return false;
IDoMethod(gwin->objects[GID_HSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HSCROLL]);
gwin->objects[GID_HSCROLL] = NULL;
#endif
return true;
}
@ -1549,23 +1565,25 @@ static bool ami_gui_vscroll_add(struct gui_window_2 *gwin)
GA_RelVerify, TRUE,
ICA_TARGET, ICTARGET_IDCMP,
ScrollerEnd;
#ifdef __amigaos4__
#warning FIXME for OS3
IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_ADDCHILD,
gwin->win, gwin->objects[GID_VSCROLL], attrs);
#endif
return true;
}
/* Remove the vertical scroller, if present */
static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
{
#ifdef __amigaos4__
if(gwin->objects[GID_VSCROLL] == NULL) return false;
IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_VSCROLL]);
gwin->objects[GID_VSCROLL] = NULL;
#endif
return true;
}
@ -1692,7 +1710,7 @@ static void ami_gui_refresh_favicon(void *p)
static ULONG ami_get_border_gadget_size(struct gui_window_2 *gwin, ULONG *width, ULONG *height)
{
ULONG available_width;
#ifdef __amigaos4__
if((sz_gad_width == 0) || (sz_gad_height == 0)) {
struct DrawInfo *dri = GetScreenDrawInfo(scrn);
GetGUIAttrs(NULL, dri,
@ -1701,7 +1719,7 @@ static ULONG ami_get_border_gadget_size(struct gui_window_2 *gwin, ULONG *width,
TAG_DONE);
FreeScreenDrawInfo(scrn, dri);
}
#endif
available_width = gwin->win->Width - scrn->WBorLeft - sz_gad_width;
*width = available_width;
@ -2025,7 +2043,7 @@ static void ami_handle_msg(void)
gwin->prev_mouse_state = gwin->mouse_state;
gwin->mouse_state=0;
break;
#ifdef __amigaos4__
case SIDEUP:
ami_gui_history(gwin, true);
break;
@ -2033,6 +2051,7 @@ static void ami_handle_msg(void)
case EXTRAUP:
ami_gui_history(gwin, false);
break;
#endif
}
if(drag_save_data && !gwin->mouse_state)
@ -2413,7 +2432,7 @@ static void ami_handle_msg(void)
case WMHI_CLOSEWINDOW:
ami_close_all_tabs(gwin);
break;
#ifdef __amigaos4__
case WMHI_ICONIFY:
{
struct bitmap *bm;
@ -2431,7 +2450,7 @@ static void ami_handle_msg(void)
cur_gw = NULL;
}
break;
#endif
case WMHI_INACTIVE:
gwin->gw->c_h_temp = gwin->gw->c_h;
gui_window_remove_caret(gwin->gw);
@ -2618,6 +2637,7 @@ static void ami_handle_appmsg(void)
static void ami_handle_applib(void)
{
#ifdef __amigaos4__
struct ApplicationMsg *applibmsg;
struct browser_window *bw;
nsurl *url;
@ -2697,6 +2717,7 @@ static void ami_handle_applib(void)
}
ReplyMsg((struct Message *)applibmsg);
}
#endif
}
void ami_get_msg(void)
@ -2974,10 +2995,10 @@ static void gui_quit(void)
ami_hotlist_free(nsoption_charp(hotlist_file));
ami_cookies_free();
ami_global_history_free();
#ifdef __amigaos4__
if(IApplication && ami_appid)
UnregisterApplication(ami_appid, NULL);
#endif
ami_arexx_cleanup();
ami_free_layers(&browserglob);
@ -3108,6 +3129,7 @@ static int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_lis
static void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
{
#ifdef __amigaos4__
struct TagItem attrs[2];
attrs[0].ti_Tag = CHILD_MinWidth;
@ -3145,6 +3167,9 @@ static void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
ami_schedule_redraw(gwin, true);
}
#else
#warning FIXME for OS3
#endif
}
static void ami_gui_hotlist_toolbar_free(struct gui_window_2 *gwin, struct List *speed_button_list)
@ -3174,6 +3199,7 @@ static void ami_gui_hotlist_toolbar_free(struct gui_window_2 *gwin, struct List
static void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
{
#ifdef __amigaos4__
IDoMethod(gwin->objects[GID_HOTLISTLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_HOTLIST]);
@ -3186,6 +3212,7 @@ static void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
gwin->win, NULL, TRUE);
ami_schedule_redraw(gwin, true);
#endif
}
static void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
@ -3242,6 +3269,7 @@ static void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
{
if(ClickTabBase->lib_Version < 53) return;
#ifdef __amigaos4__
if(show)
{
struct TagItem attrs[3];
@ -3295,6 +3323,7 @@ static void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
gwin->win, NULL, TRUE);
if(gwin->gw && gwin->gw->bw) browser_window_update(gwin->gw->bw, false);
#endif
}
void ami_gui_tabs_toggle_all(void)
@ -3438,7 +3467,7 @@ gui_window_create(struct browser_window *bw,
if(curh > (scrn->Height - cury)) curh = scrn->Height - cury;
g = AllocVecTags(sizeof(struct gui_window), AVT_ClearWithValue, 0, TAG_DONE);
g = ami_misc_allocvec_clear(sizeof(struct gui_window), 0);
if(!g)
{
@ -3510,7 +3539,7 @@ gui_window_create(struct browser_window *bw,
return g;
}
g->shared = AllocVecTags(sizeof(struct gui_window_2), AVT_ClearWithValue, 0, TAG_DONE);
g->shared = ami_misc_allocvec_clear(sizeof(struct gui_window_2), 0);
if(!g->shared)
{
@ -3563,7 +3592,7 @@ gui_window_create(struct browser_window *bw,
g->shared->tabs=1;
g->shared->next_tab=1;
g->shared->svbuffer = AllocVecTags(2000, AVT_ClearWithValue, 0, TAG_DONE);
g->shared->svbuffer = ami_misc_allocvec_clear(2000, 0);
g->shared->helphints[GID_BACK] =
translate_escape_chars(messages_get("HelpToolbarBack"));
@ -4963,6 +4992,7 @@ static void gui_window_new_content(struct gui_window *g)
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
const struct rect *rect)
{
#ifdef __amigaos4__
g->shared->drag_op = type;
if(rect) g->shared->ptr_lock = ami_ns_rect_to_ibox(g->shared, rect);
@ -4977,7 +5007,7 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
g->shared->ptr_lock = NULL;
}
}
#endif
return true;
}
@ -5028,7 +5058,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
break;
}
break;
#ifdef __amigaos4__
case IDCMP_EXTENDEDMOUSE:
if(msg->Code == IMSGCODE_INTUIWHEELDATA)
{
@ -5037,7 +5067,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
ami_gui_scroll_internal(gwin, wheel->WheelX * 50, wheel->WheelY * 50);
}
break;
#endif
case IDCMP_SIZEVERIFY:
break;
@ -5287,8 +5317,9 @@ int main(int argc, char** argv)
.llcache = amiga_filesystem_llcache_table,
};
#ifdef __amigaos4__
signal(SIGINT, SIG_IGN);
#endif
ret = netsurf_register(&amiga_table);
if (ret != NSERROR_OK) {
ami_misc_fatal_error("NetSurf operation table failed registration");
@ -5313,6 +5344,7 @@ int main(int argc, char** argv)
* forcibly disable context menus if these are in use.
*/
popupmenu_lib_ok = FALSE;
#ifdef __amigaos4__
if((PopupMenuBase = OpenLibrary("popupmenu.library", 53))) {
LOG(("popupmenu.library v%d.%d",
PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision));
@ -5320,7 +5352,7 @@ int main(int argc, char** argv)
popupmenu_lib_ok = TRUE;
CloseLibrary(PopupMenuBase);
}
#endif
if (ami_open_resources() == false) { /* alloc message ports */
ami_misc_fatal_error("Unable to allocate resources");
return RETURN_FAIL;

View File

@ -37,6 +37,16 @@ int64 GetFileSize(BPTR fh)
return (int64)size;
}
void FreeSysObject(ULONG type, APTR obj)
{
switch(type) {
case ASOT_PORT:
DeleteMsgPort(obj);
break;
}
}
/* Exec */
struct Node *GetHead(struct List *list)
{
@ -49,6 +59,23 @@ struct Node *GetHead(struct List *list)
return res;
}
/* Intuition */
uint32 GetAttrs(Object *obj, Tag tag1, ...)
{
va_list ap;
Tag tag = tag1;
ULONG data = 0;
va_start(ap, tag1);
while(tag != TAG_DONE) {
data = va_arg(ap, ULONG);
GetAttr(tag, obj, (void *)data);
tag = va_arg(ap, Tag);
}
va_end(ap);
}
/* Utility */
struct FormatContext
{

View File

@ -1,5 +1,6 @@
/*
* Copyright 2010 John-Mark Bell <jmb@netsurf-browser.org>
* Copyright 2014 Chris Young <chris@unsatisfactorsysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -39,12 +40,54 @@
/* Macros */
#define IsMinListEmpty(L) (L)->mlh_Head->mln_Succ == 0
#define LIB_IS_AT_LEAST(B,V,R) ((B)->lib_Version>(V)) || \
((B)->lib_Version==(V) && (B)->lib_Revision>=(R))
/* Define extra memory type flags */
#define MEMF_PRIVATE MEMF_ANY
#define MEMF_SHARED MEMF_ANY
/* Ignore tags that aren't supported */
/* Ignore unsupported tags */
#define BITMAP_DisabledSourceFile TAG_IGNORE
#define CLICKTAB_CloseImage TAG_IGNORE
#define CLICKTAB_FlagImage TAG_IGNORE
#define CLICKTAB_LabelTruncate TAG_IGNORE
#define CLICKTAB_NodeClosed TAG_IGNORE
#define PDTA_PromoteMask TAG_IGNORE
#define RPTAG_APenColor TAG_IGNORE
#define GA_HintInfo TAG_IGNORE
#define GAUGEIA_Level TAG_IGNORE
#define IA_InBorder TAG_IGNORE
#define IA_Label TAG_IGNORE
#define SA_Compositing TAG_IGNORE
#define SBNA_Text TAG_IGNORE
#define TNA_CloseGadget TAG_IGNORE
#define TNA_HintInfo TAG_IGNORE
#define WA_ToolBox TAG_IGNORE
#define WINDOW_BuiltInScroll TAG_IGNORE
#define WINDOW_NewMenu TAG_IGNORE
#define WINDOW_NewPrefsHook TAG_IGNORE
/* raw keycodes */
#define RAWKEY_BACKSPACE 0x41
#define RAWKEY_TAB 0x42
#define RAWKEY_ESC 0x45
#define RAWKEY_DEL 0x46
#define RAWKEY_PAGEUP 0x48
#define RAWKEY_PAGEDOWN 0x49
#define RAWKEY_CRSRUP 0x4C
#define RAWKEY_CRSRDOWN 0x4D
#define RAWKEY_CRSRRIGHT 0x4E
#define RAWKEY_CRSRLEFT 0x4F
#define RAWKEY_F5 0x54
#define RAWKEY_HELP 0x5F
#define RAWKEY_HOME 0x70
#define RAWKEY_END 0x71
/* Other constants */
#define IDCMP_EXTENDEDMOUSE 0
#define WINDOW_BACKMOST 0
#define DN_FULLPATH 0
/* Renamed structures */
#define AnchorPathOld AnchorPath
@ -53,11 +96,6 @@
/* application */
#define Notify(...) (void)0
/* Exec */
/* AllocVecTagList with no tags */
#define AllocVecTagList(SZ,TAG) AllocVec(SZ,MEMF_ANY)
#define GetSucc(N) (N)->ln_Succ
/* diskfont */
/* Only used in one place we haven't ifdeffed, where it returns the charset name */
#define ObtainCharsetInfo(A,B,C) (const char *)"ISO-8859-1"
@ -65,12 +103,24 @@
/* DOS */
#define FOpen(A,B,C) Open(A,B)
#define FClose(A) Close(A)
#define CreateDirTree(D) CreateDir(D) /*\todo This isn't quite right */
#define DevNameFromLock(A,B,C,D) NameFromLock(A,B,C)
/* Exec */
#define AllocVecTagList(SZ,TAG) AllocVec(SZ,MEMF_ANY) /* AllocVecTagList with no tags */
#define GetPred(N) (N)->ln_Pred
#define GetSucc(N) (N)->ln_Succ
/* Gfx */
#define SetRPAttrs(...) (void)0 /*\todo Probably need to emulate this */
/* Intuition */
#define IDoMethod DoMethod
#define IDoMethodA DoMethodA
#define IDoSuperMethodA DoSuperMethodA
#define RefreshSetGadgetAttrs SetGadgetAttrs /*\todo This isn't quite right */
#define ShowWindow(...) (void)0
/* Utility */
#define SetMem memset
@ -117,13 +167,22 @@ struct TimeVal {
#define IDFMT_PALETTEMAPPED (1) /* Palette mapped icon (chunky, V44+) */
#define IDFMT_DIRECTMAPPED (2) /* Direct mapped icon (truecolor 0xAARRGGBB, V51+) */
/* Object types */
enum {
ASOT_PORT = 1
};
/* Functions */
/* DOS */
int64 GetFileSize(BPTR fh);
void FreeSysObject(ULONG type, APTR obj);
/* Exec */
struct Node *GetHead(struct List *list);
/* Intuition */
uint32 GetAttrs(Object *obj, Tag tag1, ...);
/* Utility */
char *ASPrintf(const char *fmt, ...);