/** CACHED SCREEN INFORMATION THAT IS DEPENDENT ON THE CURRENT VIEW. */
-gint _screen_width_pixels = 0;
-gint _screen_height_pixels = 0;
-gint _screen_halfwidth_pixels = 0;
-gint _screen_halfheight_pixels = 0;
+gint _view_width_pixels = 0;
+gint _view_height_pixels = 0;
+gint _view_halfwidth_pixels = 0;
+gint _view_halfheight_pixels = 0;
/** The current track and route. */
Path _track;
GtkWidget *_download_banner = NULL;
/** DOWNLOAD PROGRESS. */
+gboolean _conic_is_connected = FALSE;
GMutex *_mapdb_mutex = NULL;
GMutex *_mouse_mutex = NULL;
volatile gint _num_downloads = 0;
/** CACHED SCREEN INFORMATION THAT IS DEPENDENT ON THE CURRENT VIEW. */
-extern gint _screen_width_pixels;
-extern gint _screen_height_pixels;
-extern gint _screen_halfwidth_pixels;
-extern gint _screen_halfheight_pixels;
+extern gint _view_width_pixels;
+extern gint _view_height_pixels;
+extern gint _view_halfwidth_pixels;
+extern gint _view_halfheight_pixels;
/** The current track and route. */
extern GtkWidget *_download_banner;
/** DOWNLOAD PROGRESS. */
+extern gboolean _conic_is_connected;
extern GMutex *_mapdb_mutex;
extern GMutex *_mouse_mutex;
extern volatile gint _num_downloads;
#include <string.h>
#include <libosso.h>
#include <glib.h>
+#include "dbus/dbus.h"
#define DBUS_API_SUBJECT_TO_CHANGE
#include "display.h"
#include "dbus-ifc.h"
+/***********************
+ * BELOW: DBUS METHODS *
+ ***********************/
+
static gint
dbus_ifc_cb_default(const gchar *interface, const gchar *method,
GArray *args, gpointer data, osso_rpc_t *retval)
}
static gboolean
-dbus_ifc_set_view_center_idle(SetViewCenterArgs *args)
+dbus_ifc_set_view_position_idle(SetViewPositionArgs *args)
{
Point center;
- printf("%s(%f, %f, %d)\n", __PRETTY_FUNCTION__,
- args->lat, args->lon, args->zoom);
+ printf("%s(%f, %f, %d, %f)\n", __PRETTY_FUNCTION__, args->new_lat,
+ args->new_lon, args->new_zoom, args->new_viewing_angle);
- latlon2unit(args->lat, args->lon, center.unitx, center.unity);
+ if(!_mouse_is_down)
+ {
+ if(_center_mode > 0)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+ _menu_view_ac_none_item), TRUE);
- map_center_unit_full(center, args->zoom,
- _center_mode > 0 && _center_rotate
- ? _gps.heading : _next_map_rotate_angle);
+ latlon2unit(args->new_lat, args->new_lon, center.unitx, center.unity);
+
+ map_center_unit_full(center, args->new_zoom, args->new_viewing_angle);
+ }
g_free(args);
dbus_ifc_handle_set_view_center(GArray *args, osso_rpc_t *retval)
{
printf("%s()\n", __PRETTY_FUNCTION__);
- SetViewCenterArgs *svca = g_new(SetViewCenterArgs, 1);
+ SetViewPositionArgs *svca = g_new(SetViewPositionArgs, 1);
+
+ /* Argument 3: int: zoom. Get this first because we might need it to
+ * calculate the next latitude and/or longitude. */
+ if(args->len >= 3
+ && g_array_index(args, osso_rpc_t, 2).type == DBUS_TYPE_INT32)
+ {
+ svca->new_zoom = CLAMP(g_array_index(args, osso_rpc_t, 2).value.i,
+ MIN_ZOOM, MAX_ZOOM);
+ }
+ else
+ svca->new_zoom = _next_zoom;
+
+ if(args->len < 2)
+ {
+ /* Latitude and/or Longitude are not defined. Calculate next. */
+ Point new_center = map_calc_new_center(svca->new_zoom);
+ unit2latlon(new_center.unitx, new_center.unity, svca->new_lat, svca->new_lon);
+ }
/* Argument 1: double: latitude. */
if(args->len >= 1
&& g_array_index(args, osso_rpc_t, 0).type == DBUS_TYPE_DOUBLE)
{
- svca->lat = CLAMP(g_array_index(args, osso_rpc_t, 0).value.d,
+ svca->new_lat = CLAMP(g_array_index(args, osso_rpc_t, 0).value.d,
-90.0, 90.0);
}
- else
- {
- gdouble tmp;
- unit2latlon(_center.unitx, _center.unity, svca->lat, tmp);
- }
/* Argument 2: double: longitude. */
if(args->len >= 2
&& g_array_index(args, osso_rpc_t, 1).type == DBUS_TYPE_DOUBLE)
{
- svca->lon = CLAMP(g_array_index(args, osso_rpc_t, 1).value.d,
+ svca->new_lon = CLAMP(g_array_index(args, osso_rpc_t, 1).value.d,
-180.0, 180.0);
}
- else
- {
- gdouble tmp;
- unit2latlon(_center.unitx, _center.unity, tmp, svca->lon);
- }
- /* Argument 2 (optional): int: zoom. */
- if(args->len >= 3
- && g_array_index(args, osso_rpc_t, 2).type == DBUS_TYPE_INT32)
+ /* Argument 4: double: viewing angle. */
+ if(args->len >= 4
+ && g_array_index(args, osso_rpc_t, 3).type == DBUS_TYPE_DOUBLE)
{
- svca->zoom = CLAMP(g_array_index(args, osso_rpc_t, 2).value.i,
- MIN_ZOOM, MAX_ZOOM);
+ svca->new_viewing_angle
+ = (gint)(g_array_index(args, osso_rpc_t, 2).value.d + 0.5) % 360;
}
else
- svca->zoom = _zoom;
+ svca->new_viewing_angle = _center_mode > 0 && _center_rotate
+ ? _gps.heading : _next_map_rotate_angle;
- g_idle_add((GSourceFunc)dbus_ifc_set_view_center_idle, svca);
+ g_idle_add((GSourceFunc)dbus_ifc_set_view_position_idle, svca);
retval->type = DBUS_TYPE_INVALID;
vprintf("%s(): return OSSO_OK\n", __PRETTY_FUNCTION__);
printf("%s(%s)\n", __PRETTY_FUNCTION__, method);
/* Method: set_view_center */
- if(!strcmp(method, MM_DBUS_METHOD_SET_VIEW_CENTER))
+ if(!strcmp(method, MM_DBUS_METHOD_SET_VIEW_POSITION))
return dbus_ifc_handle_set_view_center(args, retval);
vprintf("%s(): return OSSO_ERROR\n", __PRETTY_FUNCTION__);
return OSSO_ERROR;
}
+/***********************
+ * ABOVE: DBUS METHODS *
+ ***********************/
+
+
+/***********************
+ * BELOW: DBUS SIGNALS *
+ ***********************/
+
+static gboolean
+dbus_ifc_view_position_changed_idle(ViewPositionChangedArgs *args)
+{
+ DBusConnection *bus = NULL;
+ DBusError error;
+ DBusMessage *message = NULL;
+ printf("%s(%f, %f, %d, %f)\n", __PRETTY_FUNCTION__, args->new_lat,
+ args->new_lon, args->new_zoom, args->new_viewing_angle);
+
+ dbus_error_init(&error);
+
+ if(NULL == (bus = dbus_bus_get(DBUS_BUS_SESSION, &error))
+ || NULL == (message = dbus_message_new_signal(MM_DBUS_PATH,
+ MM_DBUS_INTERFACE, MM_DBUS_SIGNAL_VIEW_POSITION_CHANGED))
+ || !dbus_message_append_args(message,
+ DBUS_TYPE_DOUBLE, &args->new_lat,
+ DBUS_TYPE_DOUBLE, &args->new_lon,
+ DBUS_TYPE_INT32, &args->new_zoom,
+ DBUS_TYPE_DOUBLE, &args->new_viewing_angle,
+ DBUS_TYPE_INVALID)
+ || !dbus_connection_send(bus, message, NULL))
+ {
+ g_printerr("Error sending view_position_changed signal: %s: %s\n",
+ (dbus_error_is_set(&error)
+ ? error.name : "<no error message>"),
+ (dbus_error_is_set(&error)
+ ? error.message : ""));
+ }
+
+ if(message)
+ dbus_message_unref(message);
+ if(bus)
+ dbus_connection_unref(bus);
+
+ vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
+ return FALSE;
+}
+
+void
+dbus_ifc_fire_view_position_changed(
+ Point new_center, gint new_zoom, gdouble new_viewing_angle)
+{
+ ViewPositionChangedArgs *args;
+ printf("%s(%d, %d, %d, %f)\n", __PRETTY_FUNCTION__, new_center.unitx,
+ new_center.unity, new_zoom, new_viewing_angle);
+
+ args = g_new(ViewPositionChangedArgs, 1);
+ unit2latlon(new_center.unitx, new_center.unity,
+ args->new_lat, args->new_lon);
+ args->new_zoom = new_zoom;
+ args->new_viewing_angle = new_viewing_angle;
+
+ g_idle_add((GSourceFunc)dbus_ifc_view_position_changed_idle, args);
+
+ vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+}
+
+static gboolean
+dbus_ifc_view_dimensions_changed_idle(ViewDimensionsChangedArgs *args)
+{
+ DBusConnection *bus = NULL;
+ DBusError error;
+ DBusMessage *message = NULL;
+ printf("%s(%d, %d)\n", __PRETTY_FUNCTION__,
+ args->new_view_width_pixels, args->new_view_height_pixels);
+
+ dbus_error_init(&error);
+
+ if(NULL == (bus = dbus_bus_get(DBUS_BUS_SESSION, &error))
+ || NULL == (message = dbus_message_new_signal(MM_DBUS_PATH,
+ MM_DBUS_INTERFACE, MM_DBUS_SIGNAL_VIEW_DIMENSIONS_CHANGED))
+ || !dbus_message_append_args(message,
+ DBUS_TYPE_INT32, &args->new_view_width_pixels,
+ DBUS_TYPE_INT32, &args->new_view_height_pixels,
+ DBUS_TYPE_INVALID)
+ || !dbus_connection_send(bus, message, NULL))
+ {
+ g_printerr("Error sending view_dimensions_changed signal: %s: %s\n",
+ (dbus_error_is_set(&error)
+ ? error.name : "<no error message>"),
+ (dbus_error_is_set(&error)
+ ? error.message : ""));
+ }
+
+ if(message)
+ dbus_message_unref(message);
+ if(bus)
+ dbus_connection_unref(bus);
+
+ vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
+ return FALSE;
+}
+
+void
+dbus_ifc_fire_view_dimensions_changed(
+ gint new_view_width_pixels, gint new_view_height_pixels)
+{
+ ViewDimensionsChangedArgs *args;
+ printf("%s(%d, %d)\n", __PRETTY_FUNCTION__,
+ new_view_width_pixels, new_view_height_pixels);
+
+ args = g_new(ViewDimensionsChangedArgs, 1);
+ args->new_view_width_pixels = new_view_width_pixels;
+ args->new_view_height_pixels = new_view_height_pixels;
+
+ g_idle_add((GSourceFunc)dbus_ifc_view_dimensions_changed_idle, args);
+
+ vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+}
+
+/***********************
+ * ABOVE: DBUS SIGNALS *
+ ***********************/
+
void
dbus_ifc_init()
{
#define MM_DBUS_PATH "/com/gnuite/maemo_mapper"
#define MM_DBUS_INTERFACE "com.gnuite.maemo_mapper"
-#define MM_DBUS_METHOD_SET_VIEW_CENTER "set_view_center"
-typedef struct _SetViewCenterArgs SetViewCenterArgs;
-struct _SetViewCenterArgs
+/**
+ * Sets the view center (including zoom and viewing angle). All of the
+ * fields are optional, although (due to the requirements of DBUS), if you
+ * specify one value, you must specify all the values preceding it. I.e. if
+ * you specify new_viewing_angle, you must specify all the fields.
+ *
+ * A screen refresh is performed regardless of whether or not any of the
+ * fields are specified or different from previous values. Thus, you can
+ * force a refresh of the screen simply by calling this method with no
+ * arguments.
+ *
+ * This method has no effect if the user is currently tap-and-holding or
+ * dragging on the screen.
+ *
+ * Note that, if this method causes the refresh of the screen, then
+ * Auto-Center will always become disabled.
+ */
+#define MM_DBUS_METHOD_SET_VIEW_POSITION "set_view_center"
+typedef struct _SetViewPositionArgs SetViewPositionArgs;
+struct _SetViewPositionArgs
{
- gdouble lat;
- gdouble lon;
- gint zoom; /* Optional - omit to keep zoom the same. */
+ gdouble new_lat;
+ gdouble new_lon;
+ gint new_zoom;
+ gdouble new_viewing_angle; /* i.e. rotation */
};
+/**
+ * Occurs whenever the view center (including zoom and viewing angle)
+ * changes. This signal is not necessarily fired when the screen size is
+ * changed. Not all of the given information may necessarily have changed,
+ * but at least one is guaranteed to have changed.
+ */
+#define MM_DBUS_SIGNAL_VIEW_POSITION_CHANGED "view_position_changed"
+typedef struct _ViewPositionChangedArgs ViewPositionChangedArgs;
+struct _ViewPositionChangedArgs
+{
+ gdouble new_lat;
+ gdouble new_lon;
+ gint new_zoom;
+ gdouble new_viewing_angle; /* i.e. rotation */
+};
+void dbus_ifc_fire_view_position_changed(
+ Point new_center, gint new_zoom, gdouble new_viewing_angle);
+
+/**
+ * Occurs whenever the dimensions (width and height) of the map change. The
+ * dimensions do not include any sidebars (like the GPS info panel). If the
+ * GPS info panel is hidden or unhidden, this event will be fired.
+ */
+#define MM_DBUS_SIGNAL_VIEW_DIMENSIONS_CHANGED "view_dimensions_changed"
+typedef struct _ViewDimensionsChangedArgs ViewDimensionsChangedArgs;
+struct _ViewDimensionsChangedArgs
+{
+ gint new_view_width_pixels;
+ gint new_view_height_pixels;
+};
+void dbus_ifc_fire_view_dimensions_changed(
+ gint new_view_width_pixels, gint new_view_height_pixels);
+
+
void dbus_ifc_init(void);
#endif /* ifndef MAEMO_MAPPER_GPS_H */
gdk_pixbuf_rotate_vector(&fdevx, &fdevy, (MATRIX), \
(gint)((UNITX) - (CENTER).unitx), \
(gint)((UNITY) - (CENTER).unity)); \
- (BUFX) = unit2pixel((gint)(fdevx)) + _screen_halfwidth_pixels; \
- (BUFY) = unit2pixel((gint)(fdevy)) + _screen_halfheight_pixels; \
+ (BUFX) = unit2pixel((gint)(fdevx)) + _view_halfwidth_pixels; \
+ (BUFY) = unit2pixel((gint)(fdevy)) + _view_halfheight_pixels; \
}
#define unit2buf(UNITX, UNITY, BUFX, BUFY) \
gdk_pixbuf_rotate_vector(&fdevx, &fdevy, MATRIX, \
(gint)((PIXELX) - unit2zpixel((CENTER).unitx, (ZOOM))), \
(gint)((PIXELY) - unit2zpixel((CENTER).unity, (ZOOM)))); \
- (BUFX) = fdevx + _screen_halfwidth_pixels; \
- (BUFY) = fdevy + _screen_halfheight_pixels; \
+ (BUFX) = fdevx + _view_halfwidth_pixels; \
+ (BUFY) = fdevy + _view_halfheight_pixels; \
}
#define pixel2buf(PIXELX, PIXELY, BUFX, BUFY) \
#define buf2unit_full(BUFX, BUFY, UNITX, UNITY, CENTER, MATRIX) { \
gfloat funitx, funity; \
gdk_pixbuf_rotate_vector(&funitx, &funity, MATRIX, \
- pixel2unit((gint)((BUFX) - _screen_halfwidth_pixels)), \
- pixel2unit((gint)((BUFY) - _screen_halfheight_pixels))); \
+ pixel2unit((gint)((BUFX) - _view_halfwidth_pixels)), \
+ pixel2unit((gint)((BUFY) - _view_halfheight_pixels))); \
(UNITX) = (CENTER).unitx + (gint)funitx; \
(UNITY) = (CENTER).unity + (gint)funity; \
}
#define buf2pixel_full(BUFX, BUFY, PIXELX, PIXELY, CENTER, MATRIX) { \
gfloat fpixelx, fpixely; \
gdk_pixbuf_rotate_vector(&fpixelx, &fpixely, MATRIX, \
- (gint)(BUFX) - _screen_halfwidth_pixels, \
- (gint)(BUFY) - _screen_halfheight_pixels); \
+ (gint)(BUFX) - _view_halfwidth_pixels, \
+ (gint)(BUFY) - _view_halfheight_pixels); \
(PIXELX) = unit2pixel((CENTER).unitx) + (gint)fpixelx; \
(PIXELY) = unit2pixel((CENTER).unity) + (gint)fpixely; \
}
gtk_widget_queue_draw_area( \
_map_widget, \
0, 0, \
- _screen_width_pixels, \
- _screen_height_pixels)
+ _view_width_pixels, \
+ _view_height_pixels)
/* Render all on-map metadata an annotations, including POI and paths. */
#define MACRO_MAP_RENDER_DATA() { \
if(!_fullscreen) \
break; \
case UNBLANK_WHEN_MOVING: \
- if(!MOVING) \
+ if(!(MOVING)) \
break; \
case UNBLANK_WITH_GPS: \
printf("Unblanking screen...\n"); \
#include "data.h"
#include "defines.h"
+#include "dbus-ifc.h"
#include "display.h"
#include "gdk-pixbuf-rotate.h"
#include "gps.h"
{
gint x2, y2;
unit2buf(unitx2, unity2, x2, y2);
- if(((unsigned)(x2+_draw_width) <= _screen_width_pixels+2*_draw_width)
- &&((unsigned)(y2+_draw_width) <= _screen_height_pixels+2*_draw_width))
+ if(((unsigned)(x2+_draw_width) <= _view_width_pixels+2*_draw_width)
+ &&((unsigned)(y2+_draw_width) <= _view_height_pixels+2*_draw_width))
{
gdk_draw_arc(_map_pixmap, gc_alt,
FALSE, /* FALSE: not filled. */
{
gint x1, y1;
unit2buf(unitx1, unity1, x1, y1);
- if(((unsigned)(x1+_draw_width) <= _screen_width_pixels+2*_draw_width)
- &&((unsigned)(y1+_draw_width) <= _screen_height_pixels+2*_draw_width))
+ if(((unsigned)(x1+_draw_width) <= _view_width_pixels+2*_draw_width)
+ &&((unsigned)(y1+_draw_width) <= _view_height_pixels+2*_draw_width))
{
gdk_draw_arc(_map_pixmap, gc_alt,
FALSE, /* FALSE: not filled. */
unit2buf(unitx1, unity1, x1, y1);
unit2buf(unitx2, unity2, x2, y2);
/* Make sure this line could possibly be visible. */
- if(!((x1 > _screen_width_pixels && x2 > _screen_width_pixels)
+ if(!((x1 > _view_width_pixels && x2 > _view_width_pixels)
|| (x1 < 0 && x2 < 0)
- || (y1 > _screen_height_pixels && y2 > _screen_height_pixels)
+ || (y1 > _view_height_pixels && y2 > _view_height_pixels)
|| (y1 < 0 && y2 < 0)))
gdk_draw_line(_map_pixmap, gc_norm, x1, y1, x2, y2);
}
_map_pixbuf,
0, 0,
0, 0,
- _screen_width_pixels, _screen_height_pixels,
+ _view_width_pixels, _view_height_pixels,
GDK_RGB_DITHER_NONE, 0, 0);
MACRO_MAP_RENDER_DATA();
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
-static Point
+Point
map_calc_new_center(gint zoom)
{
Point new_center;
case CENTER_LEAD:
{
gfloat tmp = deg2rad(_gps.heading);
- gfloat screen_pixels = _screen_width_pixels
- + (((gint)_screen_height_pixels
- - (gint)_screen_width_pixels)
+ gfloat screen_pixels = _view_width_pixels
+ + (((gint)_view_height_pixels
+ - (gint)_view_width_pixels)
* fabsf(cosf(deg2rad(
ROTATE_DIR_ENUM_DEGREES[_rotate_dir] -
(_center_rotate ? 0
mrt->old_offsetx = _map_offset_devx;
mrt->old_offsety = _map_offset_devy;
mrt->new_center = _next_center = new_center;
- mrt->screen_width_pixels = _screen_width_pixels;
- mrt->screen_height_pixels = _screen_height_pixels;
+ mrt->screen_width_pixels = _view_width_pixels;
+ mrt->screen_height_pixels = _view_height_pixels;
mrt->zoom = _next_zoom = zoom;
mrt->rotate_angle = _next_map_rotate_angle = rotate_angle;
new_center_devx, new_center_devy);
if(force_redraw || (_center_mode > 0
&& (UNITS_CONVERT[_units] * _gps.speed) >= _ac_min_speed &&
- (((unsigned)(new_center_devx - (_screen_width_pixels * _center_ratio / 20))
- > ((10 - _center_ratio) * _screen_width_pixels / 10))
- || ((unsigned)(new_center_devy - (_screen_height_pixels * _center_ratio / 20))
- > ((10 - _center_ratio) * _screen_height_pixels / 10))
+ (((unsigned)(new_center_devx - (_view_width_pixels * _center_ratio / 20))
+ > ((10 - _center_ratio) * _view_width_pixels / 10))
+ || ((unsigned)(new_center_devy - (_view_height_pixels * _center_ratio / 20))
+ > ((10 - _center_ratio) * _view_height_pixels / 10))
|| (_center_rotate &&
abs(_next_map_rotate_angle - _gps.heading)
> (4*(10-_rotate_sens))))))
printf("%s()\n", __PRETTY_FUNCTION__);
if(!_mouse_is_down
- && mrt->screen_width_pixels == _screen_width_pixels
- && mrt->screen_height_pixels == _screen_height_pixels)
+ && mrt->screen_width_pixels == _view_width_pixels
+ && mrt->screen_height_pixels == _view_height_pixels)
{
g_object_unref(_map_pixbuf);
_map_pixbuf = mrt->pixbuf;
+
+ if(_center.unitx != mrt->new_center.unitx
+ || _center.unity != mrt->new_center.unity
+ || _zoom != mrt->zoom
+ || _map_rotate_angle != mrt->rotate_angle)
+ {
+ dbus_ifc_fire_view_position_changed(
+ mrt->new_center, mrt->zoom, mrt->rotate_angle);
+ }
+
_center = mrt->new_center;
_zoom = mrt->zoom;
-
_map_rotate_angle = mrt->rotate_angle;
+
gdk_pixbuf_rotate_matrix_fill_for_rotation(
_map_rotate_matrix,
deg2rad(ROTATE_DIR_ENUM_DEGREES[_rotate_dir]
- ROTATE_DIR_ENUM_DEGREES[_rotate_dir]));
g_slice_free(MapRenderTask, mrt);
+
--_redraw_count;
_map_offset_devx = 0;
map_set_mark();
map_force_redraw();
+
}
else
{
/* Skip this tile under the following conditions:
* devx < -tile_rothalf_pixels
- * devx > _screen_width_pixels + tile_rothalf_pixels
+ * devx > _view_width_pixels + tile_rothalf_pixels
* devy < -tile_rothalf_pixels
- * devy > _screen_height_pixels + tile_rothalf_pixels
+ * devy > _view_height_pixels + tile_rothalf_pixels
*/
if(((unsigned)(devx + tile_rothalf_pixels))
- < (_screen_width_pixels + (2 * tile_rothalf_pixels))
+ < (_view_width_pixels + (2 * tile_rothalf_pixels))
&& ((unsigned)(devy + tile_rothalf_pixels))
- < (_screen_height_pixels + (2 * tile_rothalf_pixels)))
+ < (_view_height_pixels + (2 * tile_rothalf_pixels)))
{
tile_dev[2 * (y * num_tilex + x)] = devx;
tile_dev[2 * (y * num_tilex + x) + 1] = devy;
gboolean
map_cb_configure(GtkWidget *widget, GdkEventConfigure *event)
{
- gint old_screen_width_pixels, old_screen_height_pixels;
+ gint old_view_width_pixels, old_view_height_pixels;
GdkPixbuf *old_map_pixbuf;
printf("%s(%d, %d)\n", __PRETTY_FUNCTION__,
_map_widget->allocation.width, _map_widget->allocation.height);
/* Special case - first allocation - not persistent. */
return TRUE;
- old_screen_width_pixels = _screen_width_pixels;
- old_screen_height_pixels = _screen_height_pixels;
- _screen_width_pixels = _map_widget->allocation.width;
- _screen_height_pixels = _map_widget->allocation.height;
- _screen_halfwidth_pixels = _screen_width_pixels / 2;
- _screen_halfheight_pixels = _screen_height_pixels / 2;
+ old_view_width_pixels = _view_width_pixels;
+ old_view_height_pixels = _view_height_pixels;
+ _view_width_pixels = _map_widget->allocation.width;
+ _view_height_pixels = _map_widget->allocation.height;
+ _view_halfwidth_pixels = _view_width_pixels / 2;
+ _view_halfheight_pixels = _view_height_pixels / 2;
g_object_unref(_map_pixmap);
_map_pixmap = gdk_pixmap_new(
_map_widget->window,
- _screen_width_pixels, _screen_height_pixels,
+ _view_width_pixels, _view_height_pixels,
-1); /* -1: use bit depth of widget->window. */
old_map_pixbuf = _map_pixbuf;
_map_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
- _screen_width_pixels, _screen_height_pixels);
+ _view_width_pixels, _view_height_pixels);
{
- gint oldnew_diffx = (gint)(_screen_width_pixels
- - old_screen_width_pixels) / 2;
- gint oldnew_diffy = (gint)(_screen_height_pixels
- - old_screen_height_pixels) / 2;
+ gint oldnew_diffx = (gint)(_view_width_pixels
+ - old_view_width_pixels) / 2;
+ gint oldnew_diffy = (gint)(_view_height_pixels
+ - old_view_height_pixels) / 2;
gdk_pixbuf_copy_area(old_map_pixbuf,
MAX(0, -oldnew_diffx), MAX(0, -oldnew_diffy),
- MIN(_screen_width_pixels, old_screen_width_pixels),
- MIN(_screen_height_pixels, old_screen_height_pixels),
+ MIN(_view_width_pixels, old_view_width_pixels),
+ MIN(_view_height_pixels, old_view_height_pixels),
_map_pixbuf,
MAX(0, oldnew_diffx), MAX(0, oldnew_diffy));
}
g_object_unref(old_map_pixbuf);
/* Set _scale_rect. */
- _scale_rect.x = (_screen_width_pixels - SCALE_WIDTH) / 2;
+ _scale_rect.x = (_view_width_pixels - SCALE_WIDTH) / 2;
_scale_rect.width = SCALE_WIDTH;
pango_layout_set_text(_scale_layout, "0", -1);
pango_layout_get_pixel_size(_scale_layout, NULL, &_scale_rect.height);
- _scale_rect.y = _screen_height_pixels - _scale_rect.height - 1;
+ _scale_rect.y = _view_height_pixels - _scale_rect.height - 1;
/* Set _zoom rect. */
pango_layout_set_text(_zoom_layout, "00", -1);
pango_layout_set_width(_zoom_layout, _zoom_rect.width);
pango_layout_context_changed(_zoom_layout);
_zoom_rect.x = _scale_rect.x - _zoom_rect.width;
- _zoom_rect.y = _screen_height_pixels - _zoom_rect.height - 1;
+ _zoom_rect.y = _view_height_pixels - _zoom_rect.height - 1;
/* Set _comprose_rect. */
- _comprose_rect.x = _screen_width_pixels - 25 - _comprose_rect.width;
- _comprose_rect.y = _screen_height_pixels - 25 - _comprose_rect.height;
+ _comprose_rect.x = _view_width_pixels - 25 - _comprose_rect.width;
+ _comprose_rect.y = _view_height_pixels - 25 - _comprose_rect.height;
map_set_mark();
map_force_redraw();
+ /* Fire the screen_dimensions_changed DBUS signal. */
+ dbus_ifc_fire_view_dimensions_changed(
+ _view_width_pixels, _view_height_pixels);
+
/* If Auto-Center is set to Lead, then recalc center. */
if(_center_mode == CENTER_LEAD)
map_center_unit(map_calc_new_center(_next_zoom));
/* Draw the mark. */
if((((unsigned)(_mark_bufx1 + _draw_width)
- <= _screen_width_pixels+2*_draw_width)
+ <= _view_width_pixels+2*_draw_width)
&&((unsigned)(_mark_bufy1 + _draw_width)
- <= _screen_height_pixels+2*_draw_width))
+ <= _view_height_pixels+2*_draw_width))
|| (((unsigned)(_mark_bufx2 + _draw_width)
- <= _screen_width_pixels+2*_draw_width)
+ <= _view_width_pixels+2*_draw_width)
&&((unsigned)(_mark_bufy2 + _draw_width)
- <= _screen_height_pixels+2*_draw_width)))
+ <= _view_height_pixels+2*_draw_width)))
{
gdk_draw_arc(
_map_widget->window,
void map_center_unit(Point new_center);
void map_rotate(gint rotate_angle);
void map_center_zoom(gint zoom);
+Point map_calc_new_center(gint zoom);
gboolean map_download_refresh_idle(MapUpdateTask *mut);
void map_set_zoom(gint new_zoom);
BOUND(fraction, 0.0, 1.0);
hildon_banner_set_fraction(
HILDON_BANNER(_fix_banner), fraction);
+
+ /* Keep awake while they watch the progress bar. */
+ UNBLANK_SCREEN(TRUE, FALSE);
}
running_total = 0;
num_sats_used = 0;
}
satcnt = 0;
-
- /* Keep awake while they watch the progress bar. */
- UNBLANK_SCREEN(TRUE, FALSE);
}
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
_mouse_is_dragging = FALSE;
- screen2unit(_screen_halfwidth_pixels, _screen_halfheight_pixels,
+ screen2unit(_view_halfwidth_pixels, _view_halfheight_pixels,
clkpt.unitx, clkpt.unity);
if(_center_mode > 0)
static ConIcConnection *_conic_conn = NULL;
static gboolean _conic_is_connecting = FALSE;
-static volatile gboolean _conic_is_connected = FALSE;
static gboolean _conic_conn_failed = FALSE;
static GMutex *_conic_connection_mutex = NULL;
static GCond *_conic_connection_cond = NULL;
/* We're connected. */
_conic_conn_failed = FALSE;
if(_download_banner != NULL)
- {
gtk_widget_show(_download_banner);
- }
}
else
{
/* Mark as a failed connection, if we had been trying to connect. */
_conic_conn_failed = _conic_is_connecting;
if(_download_banner != NULL)
- {
gtk_widget_hide(_download_banner);
- }
}
_conic_is_connecting = FALSE; /* No longer trying to connect. */
DBusGConnection *bus;
DBusGProxy *proxy;
- bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if(!bus || error)
{
g_printerr("Error: %s\n", error->message);
g_printerr("Failed to parse string as integer: %s\n", argv[3]);
return 3;
}
- if(!dbus_g_proxy_call(proxy, MM_DBUS_METHOD_SET_VIEW_CENTER,&error,
+ if(!dbus_g_proxy_call(proxy, MM_DBUS_METHOD_SET_VIEW_POSITION,
+ &error,
G_TYPE_DOUBLE, lat, G_TYPE_DOUBLE, lon,
G_TYPE_INT, zoom, G_TYPE_INVALID,
G_TYPE_INVALID)
else
{
/* Not specifying a zoom. */
- if(!dbus_g_proxy_call(proxy, MM_DBUS_METHOD_SET_VIEW_CENTER, &error,
+ if(!dbus_g_proxy_call(proxy, MM_DBUS_METHOD_SET_VIEW_POSITION,
+ &error,
G_TYPE_DOUBLE, lat, G_TYPE_DOUBLE, lon, G_TYPE_INVALID,
G_TYPE_INVALID)
|| error)
mapdb_initiate_update_banner_idle()
{
if(!_download_banner && _num_downloads != _curr_download)
+ {
_download_banner = hildon_banner_show_progress(
_window, NULL, _("Processing Maps"));
+ /* If we're not connected, then hide the banner immediately. It will
+ * be unhidden if/when we're connected. */
+ if(!_conic_is_connected)
+ gtk_widget_hide(_download_banner);
+ }
return FALSE;
}
/* Initialize to the bounds of the screen. */
unit2latlon(
- _center.unitx - pixel2unit(MAX(_screen_width_pixels,
- _screen_height_pixels) / 2),
- _center.unity - pixel2unit(MAX(_screen_width_pixels,
- _screen_height_pixels) / 2), lat, lon);
+ _center.unitx - pixel2unit(MAX(_view_width_pixels,
+ _view_height_pixels) / 2),
+ _center.unity - pixel2unit(MAX(_view_width_pixels,
+ _view_height_pixels) / 2), lat, lon);
BOUND(lat, -90.f, 90.f);
BOUND(lon, -180.f, 180.f);
lat_format(lat, buffer);
gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_topleft_lon), buffer);
unit2latlon(
- _center.unitx + pixel2unit(MAX(_screen_width_pixels,
- _screen_height_pixels) / 2),
- _center.unity + pixel2unit(MAX(_screen_width_pixels,
- _screen_height_pixels) / 2), lat, lon);
+ _center.unitx + pixel2unit(MAX(_view_width_pixels,
+ _view_height_pixels) / 2),
+ _center.unity + pixel2unit(MAX(_view_width_pixels,
+ _view_height_pixels) / 2), lat, lon);
BOUND(lat, -90.f, 90.f);
BOUND(lon, -180.f, 180.f);
lat_format(lat, buffer);
announce_thres_unsquared = (20+_gps.speed) * _announce_notice_ratio*32;
- if(!_track.tail->unity || (_pos.unitx - _track.tail->unitx)
- || (_pos.unity - _track.tail->unity))
+ if(!_track.tail->unity || (_pos.unitx != _track.tail->unitx)
+ || (_pos.unity != _track.tail->unity))
{
ret = TRUE;
/* Update the nearest-waypoint data. */
/** Instead of calling map_render_paths(), we'll just add the waypoint
* ourselves. */
/* Make sure this circle will be visible. */
- if((x1 < _screen_width_pixels) && (y1 < _screen_height_pixels))
+ if((x1 < _view_width_pixels) && (y1 < _view_height_pixels))
gdk_draw_arc(_map_pixmap, _gc[COLORABLE_TRACK_BREAK],
FALSE, /* FALSE: not filled. */
x1 - _draw_width,
G_TYPE_BOOLEAN,/* Selected */
G_TYPE_INT, /* POI ID */
G_TYPE_INT, /* Category ID */
- G_TYPE_FLOAT, /* Latitude */
- G_TYPE_FLOAT, /* Longitude */
+ G_TYPE_DOUBLE, /* Latitude */
+ G_TYPE_DOUBLE, /* Longitude */
G_TYPE_STRING, /* Lat/Lon */
G_TYPE_FLOAT, /* Bearing */
G_TYPE_FLOAT, /* Distance */
G_TYPE_BOOLEAN,/* Selected */
G_TYPE_INT, /* POI ID */
G_TYPE_INT, /* Category ID */
- G_TYPE_FLOAT, /* Latitude */
- G_TYPE_FLOAT, /* Longitude */
+ G_TYPE_DOUBLE, /* Latitude */
+ G_TYPE_DOUBLE, /* Longitude */
G_TYPE_STRING, /* Lat/Lon */
G_TYPE_FLOAT, /* Bearing */
G_TYPE_FLOAT, /* Distance */
if(_poi_db && _poi_zoom > _zoom)
{
- gint diag_offset = pixel2unit(MAX(_screen_width_pixels,
- _screen_height_pixels) / 2);
- buf2unit(0, _screen_height_pixels, unitx, unity);
+ gint diag_offset = pixel2unit(MAX(_view_width_pixels,
+ _view_height_pixels) / 2);
+ buf2unit(0, _view_height_pixels, unitx, unity);
unitx = _center.unitx - diag_offset;
unity = _center.unity + diag_offset;
unit2latlon(unitx, unity, lat1, lon1);