Fix some long-standing issues with events not getting captured, make sure the

timer.device version of the scheduler is working and make it the default.

svn path=/trunk/netsurf/; revision=11637
This commit is contained in:
Chris Young 2011-02-09 21:52:28 +00:00
parent 86c2948eb4
commit 4703d643f5
2 changed files with 49 additions and 46 deletions

View File

@ -1662,6 +1662,7 @@ void ami_handle_appmsg(void)
{ {
GetAttr(WINDOW_UserData, (Object *)appmsg->am_ID, (ULONG *)&gwin); GetAttr(WINDOW_UserData, (Object *)appmsg->am_ID, (ULONG *)&gwin);
/* AppIcons are for iconified windows - we don't have iconify yet.
if(appmsg->am_Type == AMTYPE_APPICON) if(appmsg->am_Type == AMTYPE_APPICON)
{ {
if(screen_closed) if(screen_closed)
@ -1674,7 +1675,9 @@ void ami_handle_appmsg(void)
ScreenToFront(scrn); ScreenToFront(scrn);
WindowToFront(gwin->win); WindowToFront(gwin->win);
} }
else if(appmsg->am_Type == AMTYPE_APPWINDOW) else
*/
if(appmsg->am_Type == AMTYPE_APPWINDOW)
{ {
GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER],
(ULONG *)&bbox); (ULONG *)&bbox);
@ -1699,8 +1702,8 @@ void ami_handle_appmsg(void)
AddPart(filename,appwinargs->wa_Name,1024); AddPart(filename,appwinargs->wa_Name,1024);
if((!gwin->bw->current_content || if(((gwin->bw->current_content == NULL) ||
content_get_type(gwin->bw->current_content) != CONTENT_HTML) || (content_get_type(gwin->bw->current_content) != CONTENT_HTML)) ||
(!((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys)))) (!((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))))
{ {
urlfilename = path_to_url(filename); urlfilename = path_to_url(filename);
@ -1735,7 +1738,7 @@ void ami_handle_appmsg(void)
} }
} }
if(!file_box && !text_box) if((!file_box) && (!text_box))
{ {
urlfilename = path_to_url(filename); urlfilename = path_to_url(filename);
browser_window_go(gwin->bw, urlfilename, NULL, true); browser_window_go(gwin->bw, urlfilename, NULL, true);
@ -1867,12 +1870,12 @@ void ami_handle_applib(void)
case APPLIBMT_CustomMsg: case APPLIBMT_CustomMsg:
{ {
struct ApplicationCustomMsg *applibcustmsg = applibmsg; struct ApplicationCustomMsg *applibcustmsg = applibmsg;
STRPTR tempmsg; // STRPTR tempmsg;
if(tempmsg = ASPrintf("\"%s\"",applibcustmsg->customMsg)) // if(tempmsg = ASPrintf("\"%s\"",applibcustmsg->customMsg))
{ // {
OpenWorkbenchObjectA(tempmsg, NULL); OpenWorkbenchObjectA(applibcustmsg->customMsg, NULL);
FreeVec(tempmsg); // FreeVec(tempmsg);
} // }
} }
break; break;
} }
@ -1894,30 +1897,30 @@ void ami_get_msg(void)
signal = Wait(signalmask); signal = Wait(signalmask);
if(signal & winsignal) if(signal & winsignal)
{
ami_handle_msg(); ami_handle_msg();
}
else if(signal & appsig) if(signal & appsig)
{
ami_handle_appmsg(); ami_handle_appmsg();
}
else if(signal & rxsig) if(signal & rxsig)
{
ami_arexx_handle(); ami_arexx_handle();
}
else if(signal & applibsig) if(signal & applibsig)
{
ami_handle_applib(); ami_handle_applib();
}
else if(signal & printsig) if(signal & printsig)
{ {
while(GetMsg(printmsgport)); //ReplyMsg while(GetMsg(printmsgport)); //ReplyMsg
ami_print_cont(); ami_print_cont();
} }
else if(signal & schedulesig)
if(signal & schedulesig)
{ {
while(GetMsg(msgport)); while(timermsg = GetMsg(msgport))
//schedule_run(); {
ReplyMsg(timermsg);
schedule_run();
}
} }
} }
@ -1935,17 +1938,12 @@ void gui_multitask(void)
void gui_poll(bool active) void gui_poll(bool active)
{ {
/* However, down here we are waiting for the user to do something or for a /* However, down here we are waiting for the user to do something or for a
scheduled event to kick in (scheduled events are signalled using scheduled event to kick in (the active variable seems to have no real
timer.device, but NetSurf seems to still be wanting to run code. We ask bearing on reality, but is supposed to indicate that NetSurf wants
Intuition to send IDCMP_INTUITICKS messages every 1/10s to our active control back ASAP, so we poll in that case).
window to break us out of ami_get_msg to stop NetSurf stalling (the active
variable seems to have no real bearing on reality, but is supposed to
indicate that NetSurf wants control back ASAP, so we poll in that case).
schedule_run checks every event, really they need to be sorted so only schedule_run checks every event, really they need to be sorted so only
the first event needs to be run on each signal. */ the first event needs to be run on each signal. */
if(active) if(active)
{ {
gui_multitask(); gui_multitask();
@ -1954,7 +1952,6 @@ void gui_poll(bool active)
else else
{ {
ami_get_msg(); ami_get_msg();
schedule_run(); // run on intuitick
} }
} }
@ -2398,7 +2395,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WA_SmartRefresh,TRUE, WA_SmartRefresh,TRUE,
WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS |
IDCMP_NEWSIZE | IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_SIZEVERIFY | IDCMP_NEWSIZE | IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_SIZEVERIFY |
IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | IDCMP_INTUITICKS, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE, // | IDCMP_INTUITICKS,
// WINDOW_IconifyGadget, TRUE, // WINDOW_IconifyGadget, TRUE,
// WINDOW_NewMenu,menu, // WINDOW_NewMenu,menu,
WINDOW_HorizProp,1, WINDOW_HorizProp,1,
@ -2556,14 +2553,13 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_RAWKEY | IDCMP_SIZEVERIFY | IDCMP_RAWKEY | IDCMP_SIZEVERIFY |
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_ACTIVEWINDOW | IDCMP_INTUITICKS | IDCMP_ACTIVEWINDOW | // IDCMP_INTUITICKS |
IDCMP_EXTENDEDMOUSE | IDCMP_GADGETDOWN, IDCMP_EXTENDEDMOUSE,
WINDOW_NewMenu, gwin->shared->menu, WINDOW_NewMenu, gwin->shared->menu,
WINDOW_VertProp,1, WINDOW_VertProp,1,
WINDOW_IDCMPHook,&gwin->shared->scrollerhook, WINDOW_IDCMPHook,&gwin->shared->scrollerhook,
WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE | WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE |
IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
IDCMP_GADGETDOWN,
WINDOW_AppPort, appport, WINDOW_AppPort, appport,
WINDOW_AppWindow,TRUE, WINDOW_AppWindow,TRUE,
WINDOW_SharedPort,sport, WINDOW_SharedPort,sport,
@ -2746,7 +2742,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WA_ReportMouse,TRUE, WA_ReportMouse,TRUE,
WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE | WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_RAWKEY | IDCMP_INTUITICKS | IDCMP_RAWKEY | // IDCMP_INTUITICKS |
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_EXTENDEDMOUSE, IDCMP_EXTENDEDMOUSE,
WINDOW_HorizProp,1, WINDOW_HorizProp,1,
@ -3828,6 +3824,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
ULONG gid,x,y; ULONG gid,x,y;
struct gui_window_2 *gwin = hook->h_Data; struct gui_window_2 *gwin = hook->h_Data;
struct IntuiWheelData *wheel; struct IntuiWheelData *wheel;
Object *reqrefresh = NULL;
gui_window_get_scroll(gwin->bw->window, gui_window_get_scroll(gwin->bw->window,
&gwin->bw->window->scrollx,&gwin->bw->window->scrolly); &gwin->bw->window->scrollx,&gwin->bw->window->scrolly);
@ -3837,6 +3834,13 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
case IDCMP_IDCMPUPDATE: case IDCMP_IDCMPUPDATE:
gid = GetTagData( GA_ID, 0, msg->IAddress ); gid = GetTagData( GA_ID, 0, msg->IAddress );
/*
if(reqrefresh = GetTagData( LAYOUT_RequestRefresh, 0, msg->IAddress ))
{
printf("LAYOUT_RequestRefresh\n");
}
*/
switch( gid ) switch( gid )
{ {
case GID_HSCROLL: case GID_HSCROLL:

View File

@ -20,6 +20,7 @@
#include "amiga/os3support.h" #include "amiga/os3support.h"
#include "amiga/object.h" #include "amiga/object.h"
#include "amiga/schedule.h" #include "amiga/schedule.h"
#include <proto/exec.h> #include <proto/exec.h>
/** /**
@ -63,7 +64,7 @@ void schedule(int t, void (*callback)(void *p), void *p)
GetSysTime(&tv); GetSysTime(&tv);
AddTime(&nscb->tv,&tv); // now contains time when event occurs AddTime(&nscb->tv,&tv); // now contains time when event occurs
#ifdef AMI_SCHEDULER_USES_TIMER
if(nscb->treq = AllocVec(sizeof(struct TimeRequest),MEMF_PRIVATE | MEMF_CLEAR)) if(nscb->treq = AllocVec(sizeof(struct TimeRequest),MEMF_PRIVATE | MEMF_CLEAR))
{ {
*nscb->treq = *tioreq; *nscb->treq = *tioreq;
@ -72,7 +73,7 @@ void schedule(int t, void (*callback)(void *p), void *p)
nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro
SendIO((struct IORequest *)nscb->treq); SendIO((struct IORequest *)nscb->treq);
} }
#endif
nscb->callback = callback; nscb->callback = callback;
nscb->p = p; nscb->p = p;
} }
@ -155,16 +156,14 @@ BOOL schedule_run(void)
void ami_remove_timer_event(struct nscallback *nscb) void ami_remove_timer_event(struct nscallback *nscb)
{ {
#ifdef AMI_SCHEDULER_USES_TIMER
if(!nscb) return; if(!nscb) return;
if(nscb->treq) if(nscb->treq)
{ {
if(CheckIO((struct IORequest *)nscb->treq)==NULL) // if(CheckIO((struct IORequest *)nscb->treq)==NULL)
AbortIO((struct IORequest *)nscb->treq); AbortIO((struct IORequest *)nscb->treq);
WaitIO((struct IORequest *)nscb->treq); WaitIO((struct IORequest *)nscb->treq);
FreeVec(nscb->treq); FreeVec(nscb->treq);
} }
#endif
} }