From e82e4f097279578b1663dcc4606dd48ebd83e964 Mon Sep 17 00:00:00 2001 From: skeezix Date: Tue, 22 Nov 2011 17:15:39 -0500 Subject: [PATCH] Added new mmenu.conf option, to have mmenu load all visible icons as needed; combine with load defered means icons will load in background, but visible ones loaded before render --- deployment/etc/pandora/conf/mmenu.conf | 5 +-- minimenu/mmenu.conf | 1 + minimenu/mmui.c | 44 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/deployment/etc/pandora/conf/mmenu.conf b/deployment/etc/pandora/conf/mmenu.conf index 7f9543b..7cd699b 100644 --- a/deployment/etc/pandora/conf/mmenu.conf +++ b/deployment/etc/pandora/conf/mmenu.conf @@ -20,12 +20,13 @@ pndrun /usr/pandora/scripts:./testdata/scripts # searchpath to locate "pnd_run load_previews_now 0 # if >0, will try to load preview pics from pnds at boot time, not defer till later load_previews_later 1 # if >0, will try to load preview pics sometime (see defer_timer_ms as well) load_icons_later 1 # if >0, will try to load icons after grid is showing, not during app scanning +load_visible_icons 1 # if >0, will try to load visible icons immediately (before render); combine with defered load for non-visible, say. defer_icon_us 100000 # when background loading icons (load_icons_later), time between icon loadsa threaded_preview 0 # if 1, will try to load the preview in background, to avoid slowing up navigation loglevel 0 # 0 is debug, lots of crap; 3 is better, means 'errors only'. Output may screw up the wrapper! x11_present_sh /bin/pidof X # command to invoke to determine if X11 is running or not; expects a number on X is present. -disco_pnds 1 # if nonzero, will do application discovery on pnd-files -disco_dotdesktop 0 # if nonzero, will do application discovery on .desktop files +disco_pnds 0 # if nonzero, will do application discovery on pnd-files +disco_dotdesktop 1 # if nonzero, will do application discovery on .desktop files disco_dotdesktop_all 0 # if nonzero, will include non-libpnd .desktop; if 0, just libpnd (pnd-found by pndnotifyd) will be included desktop_apps 1 # search the pnd standard desktop searchpath for apps menu_apps 1 # search the pnd standard menu searchpath for apps diff --git a/minimenu/mmenu.conf b/minimenu/mmenu.conf index 3902a21..227f3a4 100644 --- a/minimenu/mmenu.conf +++ b/minimenu/mmenu.conf @@ -20,6 +20,7 @@ pndrun /usr/pandora/scripts:./testdata/scripts # searchpath to locate "pnd_run load_previews_now 0 # if >0, will try to load preview pics from pnds at boot time, not defer till later load_previews_later 0 # if >0, will try to load preview pics sometime (see defer_timer_ms as well) load_icons_later 1 # if >0, will try to load icons after grid is showing, not during app scanning +load_visible_icons 1 # if >0, will try to load visible icons immediately (before render); combine with defered load for non-visible, say. defer_icon_us 100000 # when background loading icons (load_icons_later), time between icon loadsa threaded_preview 0 # if 1, will try to load the preview in background, to avoid slowing up navigation loglevel 0 # 0 is debug, lots of crap; 3 is better, means 'errors only'. Output may screw up the wrapper! diff --git a/minimenu/mmui.c b/minimenu/mmui.c index c7e02ea..66283b7 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -371,6 +371,12 @@ void ui_render ( void ) { ui_context_t *c = &ui_display_context; // for convenience and shorthand + // on demand icon loading + static int load_visible = -1; + if ( load_visible == -1 ) { + load_visible = pnd_conf_get_as_int_d ( g_conf, "minimenu.load_visible_icons", 0 ); + } + // how many total rows do we need? if ( g_categorycount ) { icon_rows = g_categories [ ui_category ] -> refcount / c -> col_max; @@ -745,6 +751,44 @@ void ui_render ( void ) { // show icon mm_cache_t *ic = cache_query_icon ( appiter -> ref -> unique_id ); SDL_Surface *iconsurface; + + // if icon not in cache, and its a pnd-file source, perhaps try to load it right now.. + if ( ( ! ic ) && + ( load_visible ) && + ( ! ( appiter -> ref -> object_flags & PND_DISCO_GENERATED ) ) + ) + { + // try to load any icons that.. + // - are not yet loaded + // - did not fail a previous load attempt + // this way user can upfront load all icons, or defer all icons, or even defer all icons + // and still try to load visible ones 'just before needed'; so not at mmenu load time, but + // as needed (only the ones needed.) + + if ( ( appiter -> ref -> pnd_icon_pos ) || + ( appiter -> ref -> icon && appiter -> ref -> object_flags & PND_DISCO_LIBPND_DD ) + ) + { + + // try to cache it? + if ( ! cache_icon ( appiter -> ref, ui_display_context.icon_max_width, ui_display_context.icon_max_width ) ) { + // erm.. + } + + // avoid churn + appiter -> ref -> pnd_icon_pos = 0; + if ( appiter -> ref -> icon ) { + free ( appiter -> ref -> icon ); + appiter -> ref -> icon = NULL; + } + + // pick up as if nothing happened.. + ic = cache_query_icon ( appiter -> ref -> unique_id ); + + } + + } // load icon during rendering? + if ( ic ) { iconsurface = ic -> i; } else { -- 2.39.2