aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common.h6
-rw-r--r--src/location-corelocation.m14
-rw-r--r--src/location-geoclue2.c18
-rw-r--r--src/location-manual.c2
-rw-r--r--src/options.c6
-rw-r--r--src/redshift.c23
6 files changed, 32 insertions, 37 deletions
diff --git a/src/common.h b/src/common.h
index e63e15b..3eaf697 100644
--- a/src/common.h
+++ b/src/common.h
@@ -82,13 +82,13 @@ enum program_mode {
};
struct location {
- float lat, lon;
+ double lat, lon;
};
struct color_setting {
int temperature;
- float gamma[3];
- float brightness;
+ double gamma[3];
+ double brightness;
};
/* Time range.
diff --git a/src/location-corelocation.m b/src/location-corelocation.m
index 87eb0de..bf899ee 100644
--- a/src/location-corelocation.m
+++ b/src/location-corelocation.m
@@ -29,8 +29,7 @@ struct location_state {
int pipe_fd_write;
int available;
int error;
- float latitude;
- float longitude;
+ struct location location;
};
@@ -90,8 +89,8 @@ struct location_state {
[self.state->lock lock];
- self.state->latitude = newLocation.coordinate.latitude;
- self.state->longitude = newLocation.coordinate.longitude;
+ self.state->location.lat = newLocation.coordinate.latitude;
+ self.state->location.lon = newLocation.coordinate.longitude;
self.state->available = 1;
[self.state->lock unlock];
@@ -192,8 +191,8 @@ location_corelocation_start(struct location_state *state)
state->available = 0;
state->error = 0;
- state->latitude = 0;
- state->longitude = 0;
+ state->location.lat = 0;
+ state->location.lon = 0;
int pipefds[2];
int r = pipeutils_create_nonblocking(pipefds);
@@ -258,8 +257,7 @@ location_corelocation_handle(
[state->lock lock];
int error = state->error;
- location->lat = state->latitude;
- location->lon = state->longitude;
+ *location->lat = state->location;
*available = state->available;
[state->lock unlock];
diff --git a/src/location-geoclue2.c b/src/location-geoclue2.c
index 835b4c4..329348e 100644
--- a/src/location-geoclue2.c
+++ b/src/location-geoclue2.c
@@ -34,8 +34,7 @@ struct location_state {
int pipe_fd_write;
int available;
int error;
- float latitude;
- float longitude;
+ struct location location;
};
@@ -104,11 +103,11 @@ geoclue_client_signal_cb(GDBusProxy *client, gchar *sender_name,
/* Read location properties */
GVariant *lat_v = g_dbus_proxy_get_cached_property(
location, "Latitude");
- state->latitude = g_variant_get_double(lat_v);
+ state->location.lat = g_variant_get_double(lat_v);
GVariant *lon_v = g_dbus_proxy_get_cached_property(
location, "Longitude");
- state->longitude = g_variant_get_double(lon_v);
+ state->location.lon = g_variant_get_double(lon_v);
state->available = 1;
@@ -344,8 +343,8 @@ location_geoclue2_start(struct location_state *state)
state->available = 0;
state->error = 0;
- state->latitude = 0;
- state->longitude = 0;
+ state->location.lat = 0;
+ state->location.lon = 0;
int pipefds[2];
int r = pipeutils_create_nonblocking(pipefds);
@@ -408,13 +407,14 @@ location_geoclue2_handle(
struct location_state *state,
struct location *location, int *available)
{
+ int error;
+
pipeutils_handle_signal(state->pipe_fd_read);
g_mutex_lock(&state->lock);
- int error = state->error;
- location->lat = state->latitude;
- location->lon = state->longitude;
+ error = state->error;
+ *location = state->location;
*available = state->available;
g_mutex_unlock(&state->lock);
diff --git a/src/location-manual.c b/src/location-manual.c
index 0048128..b07ca4f 100644
--- a/src/location-manual.c
+++ b/src/location-manual.c
@@ -79,7 +79,7 @@ location_manual_set_option(struct location_state *state, const char *key,
/* Parse float value */
char *end;
errno = 0;
- float v = strtof(value, &end);
+ double v = strtod(value, &end);
if (errno != 0 || *end != '\0') {
fputs(_("Malformed argument.\n"), stderr);
return -1;
diff --git a/src/options.c b/src/options.c
index bbc6435..0f94c3c 100644
--- a/src/options.c
+++ b/src/options.c
@@ -37,7 +37,7 @@
or two values separated by a colon. */
static void
parse_brightness_string(
- const char *str, float *bright_day, float *bright_night)
+ const char *str, double *bright_day, double *bright_night)
{
char *s = strchr(str, ':');
if (s == NULL) {
@@ -53,12 +53,12 @@ parse_brightness_string(
/* A gamma string contains either one floating point value,
or three values separated by colon. */
static int
-parse_gamma_string(const char *str, float gamma[])
+parse_gamma_string(const char *str, double gamma[3])
{
char *s = strchr(str, ':');
if (s == NULL) {
/* Use value for all channels */
- float g = atof(str);
+ double g = atof(str);
gamma[0] = gamma[1] = gamma[2] = g;
} else {
/* Parse separate value for each channel */
diff --git a/src/redshift.c b/src/redshift.c
index ca8e66b..be97912 100644
--- a/src/redshift.c
+++ b/src/redshift.c
@@ -187,8 +187,8 @@ print_location(const struct location *location)
The string following each number is an abreviation for
north, source, east or west (N, S, E, W). */
printf(_("Location: %.2f %s, %.2f %s\n"),
- fabs(location->lat), location->lat >= 0.f ? north : south,
- fabs(location->lon), location->lon >= 0.f ? east : west);
+ fabs(location->lat), location->lat >= 0.0 ? north : south,
+ fabs(location->lon), location->lon >= 0.0 ? east : west);
}
/* Interpolate color setting structs given alpha. */
@@ -233,10 +233,10 @@ color_setting_diff_is_major(
const struct color_setting *second)
{
return (abs(first->temperature - second->temperature) > 25 ||
- fabsf(first->brightness - second->brightness) > 0.1 ||
- fabsf(first->gamma[0] - second->gamma[0]) > 0.1 ||
- fabsf(first->gamma[1] - second->gamma[1]) > 0.1 ||
- fabsf(first->gamma[2] - second->gamma[2]) > 0.1);
+ fabs(first->brightness - second->brightness) > 0.1 ||
+ fabs(first->gamma[0] - second->gamma[0]) > 0.1 ||
+ fabs(first->gamma[1] - second->gamma[1]) > 0.1 ||
+ fabs(first->gamma[2] - second->gamma[2]) > 0.1);
}
/* Reset color setting to default values. */
@@ -424,14 +424,11 @@ method_try_start(const struct gamma_method *method, GAMMA_STATE **state,
/* Check whether gamma is within allowed levels. */
static int
-gamma_is_valid(const float gamma[3])
+gamma_is_valid(const double gamma[3])
{
- return !(gamma[0] < MIN_GAMMA ||
- gamma[0] > MAX_GAMMA ||
- gamma[1] < MIN_GAMMA ||
- gamma[1] > MAX_GAMMA ||
- gamma[2] < MIN_GAMMA ||
- gamma[2] > MAX_GAMMA);
+ return !(gamma[0] < MIN_GAMMA || gamma[0] > MAX_GAMMA ||
+ gamma[1] < MIN_GAMMA || gamma[1] > MAX_GAMMA ||
+ gamma[2] < MIN_GAMMA || gamma[2] > MAX_GAMMA);
}
/* Check whether location is valid.