From b6937419e17c80613f5b1436ce9833e24d6221fa Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 9 Apr 2010 22:38:51 +0000 Subject: Fix broken event handling. Any structures attached to the window_list *must* have a struct nsObject * as their first entry, and handle events outside of gui.c. svn path=/trunk/netsurf/; revision=10332 --- amiga/download.c | 26 +++++++++++++++++++++++- amiga/download.h | 4 ++-- amiga/gui.c | 56 +++++++++++++++++++++++++++++++++------------------ amiga/gui.h | 2 +- amiga/gui_options.c | 3 +-- amiga/history_local.c | 14 ++++++------- amiga/history_local.h | 6 ++---- amiga/login.c | 29 ++++++++++++++++++++++++++ amiga/login.h | 4 ++-- amiga/print.h | 2 +- amiga/search.h | 3 +-- amiga/tree.h | 3 +-- 12 files changed, 108 insertions(+), 44 deletions(-) (limited to 'amiga') diff --git a/amiga/download.c b/amiga/download.c index 1929d163f..712689b10 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -214,7 +214,7 @@ void gui_download_window_done(struct gui_download_window *dw) TAG_DONE); } - if(bw) bw->download = false; + download_context_destroy(dw->ctx); if(dln = dw->dln) { @@ -235,6 +235,30 @@ void gui_download_window_done(struct gui_download_window *dw) if(queuedl) browser_window_download(bw,dln2->node.ln_Name,NULL); } +BOOL ami_download_window_event(struct gui_download_window *dw) +{ + /* return TRUE if window destroyed */ + ULONG class,result,relevent = 0; + uint16 code; + + while((result = RA_HandleInput(dw->objects[OID_MAIN], &code)) != WMHI_LASTMSG) + { + switch(result & WMHI_CLASSMASK) // class + { + case WMHI_GADGETUP: + switch(result & WMHI_GADGETMASK) + { + case GID_CANCEL: + ami_download_window_abort(dw); + return TRUE; + break; + } + break; + } + } + return FALSE; +} + void ami_free_download_list(struct List *dllist) { struct dlnode *node; diff --git a/amiga/download.h b/amiga/download.h index 9279869cb..f8ef121bc 100755 --- a/amiga/download.h +++ b/amiga/download.h @@ -29,10 +29,9 @@ struct dlnode }; struct gui_download_window { + struct nsObject *node; struct Window *win; Object *objects[GID_LAST]; - struct nsObject *node; - ULONG pad[5]; BPTR fh; uint32 size; uint32 downloaded; @@ -48,6 +47,7 @@ void *drag_save_data; struct gui_window *drag_save_gui; void ami_download_window_abort(struct gui_download_window *dw); +BOOL ami_download_window_event(struct gui_download_window *dw); void ami_drag_save(struct Window *win); void ami_free_download_list(struct List *dllist); void ami_superimpose_favicon(STRPTR path, struct hlcache_handle *icon, STRPTR type); diff --git a/amiga/gui.c b/amiga/gui.c index c6b382253..a5d696c36 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -939,6 +939,40 @@ void ami_handle_msg(void) continue; } } + else if(node->Type == AMINS_DLWINDOW) + { + if(ami_download_window_event((struct gui_download_window *)gwin)) + { + if(IsMinListEmpty(window_list)) + { + /* last window closed, so exit */ + ami_try_quit(); + } + break; + } + else + { + node = nnode; + continue; + } + } + else if(node->Type == AMINS_LOGINWINDOW) + { + if(ami_401login_event((struct gui_login_window *)gwin)) + { + if(IsMinListEmpty(window_list)) + { + /* last window closed, so exit */ + ami_try_quit(); + } + break; + } + else + { + node = nnode; + continue; + } + } while((result = RA_HandleInput(gwin->objects[OID_MAIN],&code)) != WMHI_LASTMSG) { @@ -1173,24 +1207,6 @@ void ami_handle_msg(void) ami_update_buttons(gwin); break; - case GID_LOGIN: - ami_401login_login((struct gui_login_window *)gwin); - win_destroyed = true; - break; - - case GID_CANCEL: - if(gwin->node->Type == AMINS_LOGINWINDOW) - { - ami_401login_close((struct gui_login_window *)gwin); - win_destroyed = true; - } - else if(gwin->node->Type == AMINS_DLWINDOW) - { - ami_download_window_abort((struct gui_download_window *)gwin); - win_destroyed = true; - } - break; - default: // printf("GADGET: %ld\n",(result & WMHI_GADGETMASK)); break; @@ -2975,7 +2991,7 @@ void ami_do_redraw_limits(struct gui_window *g, hlcache_handle *c,int x0, int y0 GetAttr(SPACE_AreaBox, g->shared->objects[GID_BROWSER], (ULONG *)&bbox); if(!c) return; -// if (c->locked) return; + if(content_is_locked(c)) return; current_redraw_browser = g->shared->bw; @@ -3091,7 +3107,7 @@ void ami_do_redraw(struct gui_window_2 *g) c = g->bw->current_content; if(!c) return; -// if (c->locked) return; + if(content_is_locked(c)) return; current_redraw_browser = g->bw; // currp = &browserglob.rp; diff --git a/amiga/gui.h b/amiga/gui.h index cac5143e5..e9944dda8 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -78,9 +78,9 @@ struct find_window; struct history_window; struct gui_window_2 { + struct nsObject *node; struct Window *win; Object *objects[GID_LAST]; - struct nsObject *node; struct browser_window *bw; bool redraw_required; int throbber_frame; diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 7b24ccc51..1b1048c05 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -181,10 +181,9 @@ enum #define OPTS_MAX_NATIVEBM 3 struct ami_gui_opts_window { + struct nsObject *node; struct Window *win; Object *objects[GID_OPTS_LAST]; - struct nsObject *node; - ULONG pad[6]; }; static struct ami_gui_opts_window *gow = NULL; diff --git a/amiga/history_local.c b/amiga/history_local.c index d68b6de1e..b129f358c 100755 --- a/amiga/history_local.c +++ b/amiga/history_local.c @@ -112,8 +112,8 @@ void ami_history_open(struct browser_window *bw, struct history *history) WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE, // WA_ReportMouse,TRUE, WA_IDCMP,IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE, // | IDCMP_MOUSEMOVE, - WINDOW_ParentGroup, hwindow->gadgets[GID_MAIN] = VGroupObject, - LAYOUT_AddChild, hwindow->gadgets[GID_BROWSER] = SpaceObject, + WINDOW_ParentGroup, hwindow->objects[GID_MAIN] = VGroupObject, + LAYOUT_AddChild, hwindow->objects[GID_BROWSER] = SpaceObject, GA_ID,GID_BROWSER, // SPACE_MinWidth,width, // SPACE_MinHeight,height, @@ -157,7 +157,7 @@ void ami_history_redraw(struct history_window *hw) struct IBox *bbox; ULONG xs,ys; - GetAttr(SPACE_AreaBox,hw->gadgets[GID_BROWSER],(ULONG *)&bbox); + GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox); GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs); GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys); @@ -188,7 +188,7 @@ bool ami_history_click(struct history_window *hw,uint16 code) struct IBox *bbox; ULONG width,height,xs,ys; - GetAttr(SPACE_AreaBox,hw->gadgets[GID_BROWSER],(ULONG *)&bbox); + GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox); GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs); x = hw->win->MouseX - bbox->Left +xs; @@ -252,7 +252,7 @@ BOOL ami_history_event(struct history_window *hw) */ case WMHI_MOUSEMOVE: - GetAttr(SPACE_AreaBox, hw->gadgets[GID_BROWSER], (ULONG *)&bbox); + GetAttr(SPACE_AreaBox, hw->objects[GID_BROWSER], (ULONG *)&bbox); GetAttr(SCROLLER_Top, hw->objects[OID_HSCROLL], (ULONG *)&xs); GetAttr(SCROLLER_Top, hw->objects[OID_VSCROLL], (ULONG *)&ys); @@ -260,7 +260,7 @@ BOOL ami_history_event(struct history_window *hw) hw->win->MouseX - bbox->Left + xs, hw->win->MouseY - bbox->Top + ys); - RefreshSetGadgetAttrs((APTR)hw->gadgets[GID_BROWSER], + RefreshSetGadgetAttrs((APTR)hw->objects[GID_BROWSER], hw->win, NULL, GA_HintInfo, url, TAG_DONE); @@ -289,7 +289,7 @@ void ami_history_update_extent(struct history_window *hw) int width, height; history_size(hw->bw->history, &width, &height); - GetAttr(SPACE_AreaBox,hw->gadgets[GID_BROWSER],(ULONG *)&bbox); + GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox); RefreshSetGadgetAttrs((APTR)hw->objects[OID_VSCROLL],hw->win,NULL, GA_ID,OID_VSCROLL, diff --git a/amiga/history_local.h b/amiga/history_local.h index e6e0b77f5..8f64920b8 100755 --- a/amiga/history_local.h +++ b/amiga/history_local.h @@ -24,12 +24,10 @@ #include "amiga/gui.h" struct history_window { - struct Window *win; - Object *objects[OID_LAST]; - struct Gadget *gadgets[GID_LAST]; // not used struct nsObject *node; + struct Window *win; + Object *objects[GID_LAST]; struct browser_window *bw; - ULONG pad[4]; struct Hook scrollerhook; struct gui_globals gg; }; diff --git a/amiga/login.c b/amiga/login.c index 85537937f..66c3d326d 100755 --- a/amiga/login.c +++ b/amiga/login.c @@ -147,3 +147,32 @@ void ami_401login_login(struct gui_login_window *lw) ami_401login_close(lw); } + +BOOL ami_401login_event(struct gui_login_window *lw) +{ + /* return TRUE if window destroyed */ + ULONG class,result,relevent = 0; + uint16 code; + + while((result = RA_HandleInput(lw->objects[OID_MAIN], &code)) != WMHI_LASTMSG) + { + switch(result & WMHI_CLASSMASK) // class + { + case WMHI_GADGETUP: + switch(result & WMHI_GADGETMASK) + { + case GID_LOGIN: + ami_401login_login(lw); + return TRUE; + break; + + case GID_CANCEL: + ami_401login_close(lw); + return TRUE; + break; + } + break; + } + } + return FALSE; +} diff --git a/amiga/login.h b/amiga/login.h index 0732c5082..1f0236d72 100755 --- a/amiga/login.h +++ b/amiga/login.h @@ -19,11 +19,10 @@ #ifndef AMIGA_LOGIN_H #define AMIGA_LOGIN_H struct gui_login_window { + struct nsObject *node; struct Window *win; Object *objects[GID_LAST]; - struct nsObject *node; struct browser_window *bw; - ULONG pad[3]; char *url; char *realm; char *host; @@ -31,4 +30,5 @@ struct gui_login_window { void ami_401login_close(struct gui_login_window *lw); void ami_401login_login(struct gui_login_window *lw); +BOOL ami_401login_event(struct gui_login_window *lw); #endif diff --git a/amiga/print.h b/amiga/print.h index 9091a6b63..f25890bda 100755 --- a/amiga/print.h +++ b/amiga/print.h @@ -23,10 +23,10 @@ struct content; struct ami_print_window { + struct nsObject *node; struct Window *win; Object *objects[OID_LAST]; struct Gadget *gadgets[GID_LAST]; - struct nsObject *node; struct hlcache_handle *c; }; diff --git a/amiga/search.h b/amiga/search.h index 5bc5ad012..d331e8b48 100755 --- a/amiga/search.h +++ b/amiga/search.h @@ -22,12 +22,11 @@ #include "amiga/gui.h" struct find_window { + struct nsObject *node; struct Window *win; Object *objects[OID_LAST]; struct Gadget *gadgets[GID_LAST]; - struct nsObject *node; struct gui_window *gwin; - ULONG pad[3]; }; void ami_search_open(struct gui_window *gwin); diff --git a/amiga/tree.h b/amiga/tree.h index 335bfd573..4129df1d2 100755 --- a/amiga/tree.h +++ b/amiga/tree.h @@ -24,11 +24,10 @@ #include "amiga/gui.h" struct treeview_window { + struct nsObject *node; struct Window *win; Object *objects[OID_LAST]; struct Gadget *gadgets[GID_LAST]; - struct nsObject *node; - ULONG pad[5]; struct tree *tree; struct List *listbrowser_list; }; -- cgit v1.2.3