Ticket #282: screen_unblank.patch

File screen_unblank.patch, 9.8 KB (added by akashihi, 2 years ago)
  • navit/xpm/Makefile.am

     
    205205endif 
    206206 
    207207DESKTOPFILEdir=$(datadir)/applications 
     208if USE_HILDON  
     209DESKTOPFILE_DATA = desktop_icons/navit.desktop, desktop_icons/org.navit-project.Navit.service 
     210else 
    208211DESKTOPFILE_DATA = desktop_icons/navit.desktop 
     212endif 
    209213 
    210214ICON128dir=$(datadir)/icons/hicolor/128x128/apps 
    211215ICON128_DATA = desktop_icons/128x128/navit.png 
  • navit/font/freetype/font_freetype.c

     
    55#include <ft2build.h> 
    66#include <glib.h> 
    77#include FT_FREETYPE_H 
    8 #ifndef USE_CACHING 
    9 #define USE_CACHING 1 
     8#ifdef USE_CACHING 
     9#undef USE_CACHING 
    1010#endif 
    1111#if USE_CACHING 
    1212#include FT_CACHE_H 
  • navit/Makefile.am

     
    2121endif 
    2222 
    2323 
    24 AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit 
     24AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @LIBOSSO_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit 
    2525BUILT_SOURCES = version.h navit_config.h 
    2626 
    2727if BIN_NAVIT 
     
    9191 
    9292else 
    9393navit_SOURCES = start.c 
    94 navit_LDADD = libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib 
     94navit_LDADD = libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @LIBOSSO_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib 
    9595 
    9696endif 
    9797 
  • navit/attr_def.h

     
    274274ATTR(filter) 
    275275ATTR(daylayout) 
    276276ATTR(nightlayout) 
     277ATTR(screen_unblank)   /*  for N8x0 */ 
    277278ATTR(xml_text) 
    278279ATTR(layout_name) 
    279280ATTR(user_name) 
  • navit/gui/internal/gui_internal.c

     
    43654365                        graphics_draw_mode(this->gra, draw_mode_end); 
    43664366                        this->win->fullscreen(this->win, attr->u.num > 0); 
    43674367                        graphics_draw_mode(this->gra, draw_mode_begin); 
     4368#ifdef HAVE_OSSO 
     4369                        navit_osso_fullscreen(this->nav, attr->u.num > 0); 
     4370#endif 
    43684371                } 
    43694372                this->fullscreen=attr->u.num; 
    43704373                return 1; 
  • navit/navit.c

     
    6161#include "messages.h" 
    6262#include "vehicleprofile.h" 
    6363#include "sunriset.h" 
    64  
     64#ifdef HAVE_OSSO 
     65#include "libosso.h" 
     66#endif 
    6567/** 
    6668 * @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object 
    6769 * @{ 
     
    138140        int prevTs; 
    139141        int graphics_flags; 
    140142        int zoom_min, zoom_max; 
     143#ifdef HAVE_OSSO 
     144        osso_context_t *osso_context; 
     145        gboolean fullscreen;    // True=fullscreen 
     146        int screen_unblank; // 0=never, 1=GPS event, 2=fullscreen 
     147#endif 
    141148}; 
    142149 
     150struct navit *global_navit; 
     151 
    143152struct gui *main_loop_gui; 
    144153 
    145154struct attr_iter { 
     
    160169static void navit_cmd_announcer_toggle(struct navit *this_); 
    161170static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv); 
    162171 
     172#ifdef HAVE_OSSO 
     173/** 
     174 * Remember state of Fullscreen 
     175 * 
     176 * @param navit our context 
     177 * @param fullscreen indicates whether we have full screen 
     178 * @returns nothing 
     179 */ 
    163180void 
     181navit_osso_fullscreen(struct navit *this_, int fullscreen) 
     182{ 
     183       dbg(2,"setting fullscreen to %s\n", fullscreen == 0 ? "no":"yes"); 
     184       this_->fullscreen = (fullscreen == 1); 
     185} 
     186          
     187/** 
     188 * * Tell osso to unblank the screen 
     189 * * 
     190 * * @param navit our context 
     191 * * @returns nothing 
     192 **/ 
     193void 
     194navit_osso_display_on(struct navit *this_) 
     195{ 
     196        osso_return_t err; 
     197        dbg(2,"unblank screen: fs=%d, unblank on: %d\n", this_->fullscreen, this_->screen_unblank); 
     198        switch (this_->screen_unblank) { 
     199        case 0: // never 
     200               break; 
     201        case 1: // GPS event 
     202               //osso_display_state_on(this_->osso_context); 
     203               err=osso_display_blanking_pause(this_->osso_context); 
     204               dbg(1,"Unblank result: ", err == OSSO_OK ? "Ok" : (err == OSSO_ERROR ? "Error" : "Invalid context")); 
     205               break; 
     206        case 2: // fullscreen 
     207               if (this_->fullscreen) { 
     208                       //osso_display_state_on(this_->osso_context); 
     209                       err=osso_display_blanking_pause(this_->osso_context); 
     210                       dbg(1,"Unblank result: ", err == OSSO_OK ? "Ok" : (err == OSSO_ERROR ? "Error" : "Invalid context")); 
     211               } 
     212               break; 
     213        default: 
     214               break; 
     215        } 
     216} 
     217/** 
     218 * * Act on Osso event 
     219 * * @param state The oss  hardware state 
     220 * * @returns FALSE 
     221 * */ 
     222static gboolean 
     223osso_cb_hw_state_idle(osso_hw_state_t *state) 
     224{ 
     225    dbg(0,"(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)\n", 
     226            state->system_inactivity_ind, 
     227            state->save_unsaved_data_ind, state->shutdown_ind, 
     228            state->memory_low_ind, state->sig_device_mode_ind); 
     229 
     230    if(state->shutdown_ind) 
     231    { 
     232       /* we  are going  down, down,  down */ 
     233        navit_destroy(global_navit); 
     234        exit(1); 
     235    } 
     236/* figure this out later 
     237    if(state->save_unsaved_data_ind) 
     238    { 
     239    // save all our data, if any 
     240    } 
     241 
     242    if(state->memory_low_ind) 
     243    { 
     244    // do something to reduce memory needs 
     245    } 
     246*/ 
     247    g_free(state); 
     248 
     249    return FALSE; 
     250} 
     251 
     252/** 
     253 * * Handle osso events 
     254 * * @param state Osso hardware state 
     255 * * @param  data ptr to private data 
     256 * * @returns nothing 
     257 **/ 
     258static void 
     259osso_cb_hw_state(osso_hw_state_t *state, gpointer data) 
     260{ 
     261     osso_hw_state_t *state_copy = g_new(osso_hw_state_t, 1); 
     262     memcpy(state_copy, state, sizeof(osso_hw_state_t)); 
     263     g_idle_add((GSourceFunc)osso_cb_hw_state_idle, state_copy); 
     264} 
     265#endif 
     266 
     267 
     268void 
    164269navit_add_mapset(struct navit *this_, struct mapset *ms) 
    165270{ 
    166271        this_->mapsets = g_list_append(this_->mapsets, ms); 
     
    681786         
    682787        this_->prevTs=0; 
    683788 
     789#ifdef HAVE_OSSO 
     790       this_->screen_unblank = 1;      // 1=GPS 
     791#endif 
     792 
    684793        transform_setup(this_->trans, &center, zoom, (this_->orientation != -1) ? this_->orientation : 0); 
    685794        for (;*attrs; attrs++) { 
    686795                navit_set_attr_do(this_, *attrs, 1); 
     
    10311140        callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map); 
    10321141} 
    10331142 
    1034 struct navit *global_navit; 
    1035  
    10361143static void 
    10371144navit_add_bookmarks_from_file(struct navit *this_) 
    10381145{ 
     
    13951502        navit_window_items_new(this_); 
    13961503#endif 
    13971504 
     1505#ifdef HAVE_OSSO 
     1506      dbg(1,"Installing osso context for org.navit-project.navit\n"); 
     1507      this_->osso_context = osso_initialize("org.navit-project.navit", 
     1508                 VERSION, TRUE, NULL); 
     1509      if(this_->osso_context == NULL) { 
     1510                dbg(0, "error initiating osso context\n"); 
     1511      } 
     1512      osso_hw_set_event_cb(this_->osso_context, NULL, osso_cb_hw_state, NULL); 
     1513       
     1514      /* add callback to unblank screen on gps event */ 
     1515      navit_add_callback(this_, callback_new_attr_1(callback_cast(navit_osso_display_on), attr_position_coord_geo, this_)); 
     1516#endif 
     1517 
    13981518        messagelist_init(this_->messages); 
    13991519 
    14001520        navit_set_cursors(this_); 
     
    17461866                attr_updated=(this_->center_timeout != attr->u.num); 
    17471867                this_->center_timeout = attr->u.num; 
    17481868                break; 
     1869       // screen  unblank for Nokia N8x0 
     1870       case attr_screen_unblank: 
     1871                if (!strcmp(attr->u.str,"GPS")) 
     1872                   this_->screen_unblank = 1; 
     1873                if (!strcmp(attr->u.str, "fullscreen")) 
     1874                   this_->screen_unblank  = 2; 
     1875                dbg(1,"screen_unblank set to %d\n",this_->screen_unblank); 
     1876                break; 
    17491877        case attr_tracking: 
    17501878                attr_updated=(this_->tracking_flag != !!attr->u.num); 
    17511879                this_->tracking_flag=!!attr->u.num; 
     
    24472575void 
    24482576navit_destroy(struct navit *this_) 
    24492577{ 
     2578 
     2579#ifdef HAVE_OSSO 
     2580       dbg(1,"Disconnecting from osso\n"); 
     2581       osso_deinitialize(this_->osso_context); 
     2582#endif  
     2583 
    24502584        /* TODO: destroy objects contained in this_ */ 
    24512585        if (this_->vehicle) 
    24522586                vehicle_destroy(this_->vehicle->vehicle); 
  • navit/navit.h

     
    6161void navit_ignore_graphics_events(struct navit *this_, int ignore); 
    6262int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback); 
    6363void navit_handle_motion(struct navit *this_, struct point *p); 
     64#ifdef HAVE_OSSO 
     65void navit_osso_display_on(struct navit *this_); 
     66void navit_osso_fullscreen(struct navit *this_, int fullscreen); 
     67#endif 
    6468void navit_zoom_in(struct navit *this_, int factor, struct point *p); 
    6569void navit_zoom_out(struct navit *this_, int factor, struct point *p); 
    6670struct navit *navit_new(struct attr *parent, struct attr **attrs); 
  • configure.in

     
    203203                ], [ 
    204204                AC_MSG_RESULT(no) 
    205205        ]) 
     206        PKG_CHECK_MODULES(LIBOSSO, libosso, [ 
     207                AC_DEFINE(HAVE_OSSO, 1, [Have the osso library]) 
     208                AC_SUBST(OSSO_CFLAGS) 
     209                AC_SUBST(OSSO_LIBS) 
     210                ], [ 
     211                AC_MSG_RESULT(no) 
     212        ]) 
    206213        if test x"${enable_hildon}" = xyes ; then 
    207214                AC_DEFINE(USE_HILDON, 1, [Build with maemo/hildon support]) 
    208215                AC_SUBST(HILDON_CFLAGS)