diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 114eaf34a..41d488e28 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -37,6 +37,7 @@ struct bitmap { int nativebmheight; char *url; /* temporary storage space */ char *title; /* temporary storage space */ + ULONG *icondata; /* for appicons */ }; struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm); diff --git a/amiga/gui.c b/amiga/gui.c index f97434cf2..640e044b6 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1630,38 +1630,15 @@ void ami_handle_msg(void) case WMHI_ICONIFY: { -/* struct DiskObject *dobj; struct bitmap *bm; - ULONG *argb; - bm = urldb_get_thumbnail(gwin->bw->current_content->url); - argb = AllocVec(bm->nativebmwidth * bm->nativebmheight, MEMF_CLEAR); - BltBitMapTags(BLITA_Width, bm->nativebmwidth, - BLITA_Height, bm->nativebmheight, - BLITA_SrcType, BLITT_BITMAP, - BLITA_Source, bm->nativebm, - BLITA_DestType, BLITT_ARGB32, - BLITA_Dest, argb, - TAG_DONE); - - // dobj = NewDiskObject(WBPROJECT); - dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBPROJECT, TAG_DONE); - IconControl(dobj, - ICONCTRLA_SetWidth, bm->nativebmwidth, - ICONCTRLA_SetHeight, bm->nativebmheight, - ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED, - ICONCTRLA_SetImageData1, argb, - ICONCTRLA_SetImageData2, argb, - TAG_DONE); -*/ - SetAttrs(gwin->objects[OID_MAIN], - WINDOW_IconTitle, gwin->win->Title, -// WINDOW_Icon, dobj, - TAG_DONE); - RA_Iconify(gwin->objects[OID_MAIN]); - if(locked_screen == FALSE) - screen_closed = CloseScreen(scrn); + bm = urldb_get_thumbnail(content_get_url(gwin->bw->current_content)); + gwin->dobj = amiga_icon_from_bitmap(bm); + HideWindow(gwin->win); + gwin->appicon = AddAppIcon(gwin->objects[OID_MAIN], NULL, + gwin->win->Title, appport, NULL, + gwin->dobj, NULL); } break; @@ -1723,6 +1700,16 @@ void ami_handle_msg(void) } while(node = nnode); } +void ami_gui_appicon_remove(struct gui_window_2 *gwin) +{ + if(gwin->appicon) + { + RemoveAppIcon(gwin->appicon); + amiga_icon_free(gwin->dobj); + gwin->appicon = NULL; + } +} + void ami_handle_appmsg(void) { struct AppMessage *appmsg; @@ -1741,22 +1728,12 @@ void ami_handle_appmsg(void) { 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(screen_closed) - { - ami_openscreen(); - screen_closed = FALSE; - } - gwin->win = (struct Window *)RA_OpenWindow(gwin->objects[OID_MAIN]); - gwin->redraw_required = true; - ScreenToFront(scrn); - WindowToFront(gwin->win); + ami_gui_appicon_remove(gwin); + ShowWindow(gwin->win, WINDOW_FRONTMOST); } - else - */ - if(appmsg->am_Type == AMTYPE_APPWINDOW) + else if(appmsg->am_Type == AMTYPE_APPWINDOW) { GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox); @@ -2525,7 +2502,11 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, if(!option_kiosk_mode) { ULONG addtabclosegadget = TAG_IGNORE; + ULONG iconifygadget = FALSE; + if(option_use_pubscreen && (locked_screen == TRUE) && + (strcmp(option_use_pubscreen,"Workbench") == 0)) + iconifygadget = TRUE; ami_create_menu(bw->browser_window_type, gwin->shared, dri); NewList(&gwin->shared->tab_list); @@ -2651,6 +2632,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_ACTIVEWINDOW | // IDCMP_INTUITICKS | IDCMP_EXTENDEDMOUSE, + WINDOW_IconifyGadget, iconifygadget, WINDOW_NewMenu, gwin->shared->menu, WINDOW_VertProp,1, WINDOW_IDCMPHook,&gwin->shared->scrollerhook, @@ -3100,6 +3082,7 @@ void gui_window_destroy(struct gui_window *g) } DisposeObject(g->shared->objects[OID_MAIN]); + ami_gui_appicon_remove(g->shared); /* These aren't freed by the above. * TODO: nav_west etc need freeing too */ diff --git a/amiga/gui.h b/amiga/gui.h index 2264a350e..500eceb9c 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -107,6 +107,8 @@ struct gui_window_2 { char *helphints[GID_LAST]; struct timeval lastclick; BOOL rmbtrapped; + struct AppIcon *appicon; /* iconify appicon */ + struct DiskObject *dobj; /* iconify appicon */ }; struct gui_window diff --git a/amiga/icon.c b/amiga/icon.c index 5205956f5..43ebe8da8 100644 --- a/amiga/icon.c +++ b/amiga/icon.c @@ -494,3 +494,48 @@ void ami_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type } } + +struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) +{ + struct DiskObject *dobj; + struct BitMap *bitmap; + + bitmap = ami_getcachenativebm(bm, bitmap_get_width(bm), + bitmap_get_height(bm), NULL); + bm->icondata = AllocVec(bitmap_get_rowstride(bm) * bitmap_get_height(bm), + MEMF_CLEAR); + + BltBitMapTags(BLITA_Width, bitmap_get_width(bm), + BLITA_Height, bitmap_get_height(bm), + BLITA_SrcType, BLITT_BITMAP, + BLITA_Source, bitmap, + BLITA_DestType, BLITT_ARGB32, + BLITA_DestBytesPerRow, bitmap_get_rowstride(bm), + BLITA_Dest, bm->icondata, + TAG_DONE); + + dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBPROJECT, TAG_DONE); + //dobj = NewDiskObject(WBPROJECT); + + IconControl(dobj, + ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED, + ICONCTRLA_SetWidth, bitmap_get_width(bm), + ICONCTRLA_SetHeight, bitmap_get_height(bm), + ICONCTRLA_SetImageData1, bm->icondata, + ICONCTRLA_SetImageData2, NULL, + TAG_DONE); + + dobj->do_Gadget.UserData = bm; + + LayoutIconA(dobj, (struct Screen *)~0UL, NULL); + + return dobj; +} + +void amiga_icon_free(struct DiskObject *dobj) +{ + struct bitmap *bm = dobj->do_Gadget.UserData; + + FreeDiskObject(dobj); + FreeVec(bm->icondata); +} diff --git a/amiga/icon.h b/amiga/icon.h index 646c50653..695d179c9 100644 --- a/amiga/icon.h +++ b/amiga/icon.h @@ -41,4 +41,6 @@ void amiga_icon_fini(void); struct hlcache_handle; void ami_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type); +struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm); +void amiga_icon_free(struct DiskObject *dobj); #endif