By default will go for fast load now -- defer icons until later (as well as
authorskeezix <skeezix@flotsam-vm.(none)>
Sat, 20 Mar 2010 03:01:36 +0000 (23:01 -0400)
committerskeezix <skeezix@flotsam-vm.(none)>
Sat, 20 Mar 2010 03:01:36 +0000 (23:01 -0400)
deferred previews); icons will load in background thread, 1 every 1/10th second.
Configurable to make it load icons up front, or time between deferred loadso

deployment/etc/pandora/conf/mmenu.conf
minimenu/mmenu.c
minimenu/mmenu.conf
minimenu/mmui.c
minimenu/mmui.h

index 3530783..3e67c3f 100644 (file)
@@ -8,6 +8,8 @@ font_ptsize             24
 pndrun                 /usr/pandora/scripts:./testdata/scripts # searchpath to locate "pnd_run.sh"; why aren't I looking in /etc/pandora/conf/apps for this?
 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
+defer_icon_us          100000  # when background loading icons (load_icons_later), time between icon loadsa
 threaded_preview       1       # 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.
index 4230a29..d62bb63 100644 (file)
@@ -50,7 +50,7 @@
 #include "mmcat.h"
 #include "mmui.h"
 
-pnd_box_handle *g_active_apps = NULL;
+pnd_box_handle g_active_apps = NULL;
 unsigned int g_active_appcount = 0;
 char g_username [ 128 ]; // since we have to wait for login (!!), store username here
 pnd_conf_handle g_conf = 0;
@@ -365,11 +365,13 @@ void applications_scan ( void ) {
       ui_cachescreen ( 0 /* clear screen */, IFNULL(iter->title_en,"No Name") );
     }
 
-    // cache the icon
-    if ( iter -> pnd_icon_pos &&
-        ! cache_icon ( iter, maxwidth, maxheight ) )
-    {
-      pnd_log ( pndn_warning, "  Couldn't load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
+    // cache the icon, unless deferred
+    if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_icons_later", 0 ) == 0 ) {
+      if ( iter -> pnd_icon_pos &&
+          ! cache_icon ( iter, maxwidth, maxheight ) )
+      {
+       pnd_log ( pndn_warning, "  Couldn't load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
+      }
     }
 
     // cache the preview --> SHOULD DEFER
@@ -443,5 +445,8 @@ void applications_scan ( void ) {
   // dump categories
   //category_dump();
 
+  // let deferred icon cache go now
+  ui_post_scan();
+
   return;
 }
index af4570c..18ee313 100644 (file)
@@ -8,6 +8,8 @@ font_ptsize             24
 pndrun                 /usr/pandora/scripts:./testdata/scripts # searchpath to locate "pnd_run.sh"; why aren't I looking in /etc/pandora/conf/apps for this?
 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
+defer_icon_us          100000  # when background loading icons (load_icons_later), time between icon loadsa
 threaded_preview       1       # 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.
index 68ae3c8..e2acf7c 100644 (file)
@@ -32,7 +32,10 @@ SDL_Surface *sdl_realscreen = NULL;
 unsigned int sdl_ticks = 0;
 SDL_Thread *g_preview_thread = NULL;
 
-enum { sdl_user_ticker = 0, sdl_user_finishedpreview = 1 };
+enum { sdl_user_ticker = 0,
+       sdl_user_finishedpreview = 1,
+       sdl_user_finishedicon = 2,
+};
 
 /* app state
  */
@@ -392,17 +395,13 @@ void ui_render ( unsigned int render_mask ) {
       // draw tab line
       if ( col == ui_category ) {
        // no line for selected tab
-       printf ( "skipselevting L\n" );
       } else {
        if ( col - ui_catshift == 0 ) {
          s = g_imagecache [ IMG_TAB_LINEL ].i;
-         printf ( "selevting L\n" );
        } else if ( col - ui_catshift == maxtab - 1 ) {
          s = g_imagecache [ IMG_TAB_LINER ].i;
-         printf ( "selevting R\n" );
        } else {
          s = g_imagecache [ IMG_TAB_LINE ].i;
-         printf ( "selevting M\n" );
        }
        dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
        dest -> y = tab_offset_y + tab_height;
@@ -824,6 +823,10 @@ void ui_process_input ( unsigned char block_p ) {
          ui_event++;
        }
 
+      } else if ( event.user.code == sdl_user_finishedicon ) {
+       // redraw, so we can show the newly loaded icon
+       ui_event++;
+
       }
 
       break;
@@ -1926,3 +1929,58 @@ unsigned char ui_threaded_defered_preview ( pnd_disco_t *p ) {
 
   return ( 0 );
 }
+
+SDL_Thread *g_icon_thread = NULL;
+void ui_post_scan ( void ) {
+
+  // if deferred icon load, kick off the thread now
+  if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_icons_later", 0 ) == 1 ) {
+
+    g_icon_thread = SDL_CreateThread ( (void*)ui_threaded_defered_icon, NULL );
+
+    if ( ! g_icon_thread ) {
+      pnd_log ( pndn_error, "ERROR: Couldn't create icon thread\n" );
+    }
+
+  } // deferred icon load
+
+  return;
+}
+
+unsigned char ui_threaded_defered_icon ( void *p ) {
+  extern pnd_box_handle g_active_apps;
+  pnd_box_handle h = g_active_apps;
+
+  unsigned char maxwidth, maxheight;
+  maxwidth = pnd_conf_get_as_int_d ( g_conf, MMENU_DISP_ICON_MAX_WIDTH, 50 );
+  maxheight = pnd_conf_get_as_int_d ( g_conf, MMENU_DISP_ICON_MAX_HEIGHT, 50 );
+
+  pnd_disco_t *iter = pnd_box_get_head ( h );
+
+  while ( iter ) {
+
+    // cache it
+    if ( iter -> pnd_icon_pos &&
+        ! cache_icon ( iter, maxwidth, maxheight ) )
+    {
+      pnd_log ( pndn_warning, "  Couldn't load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
+    } else {
+
+      // trigger that we completed
+      SDL_Event e;
+      bzero ( &e, sizeof(SDL_Event) );
+      e.type = SDL_USEREVENT;
+      e.user.code = sdl_user_finishedicon;
+      SDL_PushEvent ( &e );
+
+      //pnd_log ( pndn_warning, "  Finished deferred load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
+      usleep ( pnd_conf_get_as_int_d ( g_conf, "minimenu.defer_icon_us", 50000 ) );
+
+    }
+
+    // next
+    iter = pnd_box_get_next ( iter );
+  } // while
+
+  return ( 0 );
+}
index f06458d..72c74c2 100644 (file)
@@ -67,6 +67,7 @@ void ui_render ( unsigned int render_mask );
 void ui_loadscreen ( void );        // show screen while loading the menu
 void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while scanning for apps
 void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode
+void ui_post_scan ( void );
 
 /* internal functions follow
  */
@@ -79,6 +80,7 @@ unsigned char ui_forkexec ( char *argv[] ); // argv[0] is proggy to exec; argv l
 
 // create a thread of this guy, and it'll try to load the preview pic in background and then signal the app
 unsigned char ui_threaded_defered_preview ( pnd_disco_t *p );
+unsigned char ui_threaded_defered_icon ( void * );
 
 // change the focus
 void ui_process_input ( unsigned char block_p );