kopia lustrzana https://gitlab.com/Zwarf/picplanner
Fix stuttery touch screen input
Due to a to high amount of changes which are written into the settings file the input became laggy. Fixed by reducing the amount of values which are written into settings.main
rodzic
a6eecb4fdb
commit
2dc9ef40d5
|
@ -38,7 +38,7 @@ main (int argc,
|
|||
* application windows, integration with the window manager/compositor, and
|
||||
* desktop features such as file opening and single-instance applications.
|
||||
*/
|
||||
app = picplanner_application_new ("de.zwarf.picplanner", G_APPLICATION_FLAGS_NONE);
|
||||
app = picplanner_application_new ("de.zwarf.picplanner", G_APPLICATION_DEFAULT_FLAGS);
|
||||
|
||||
/*
|
||||
* Run the application. This function will block until the application
|
||||
|
|
|
@ -79,11 +79,87 @@ struct _PicplannerOverview
|
|||
PicplannerDrawLayer *pp_layer_milky_way_rise_set;
|
||||
|
||||
GSettings *settings;
|
||||
|
||||
gint input_timeout_id;
|
||||
gint input_rebounce_timeout_id;
|
||||
guint input_count;
|
||||
gboolean input_new;
|
||||
gboolean input_currently;
|
||||
|
||||
};
|
||||
|
||||
|
||||
G_DEFINE_TYPE (PicplannerOverview, picplanner_overview, GTK_TYPE_BOX)
|
||||
static gboolean
|
||||
input_rebounce_reset_signal (gpointer user_data)
|
||||
{
|
||||
PicplannerOverview *overview = PICPLANNER_OVERVIEW (user_data);
|
||||
overview->input_currently = FALSE;
|
||||
g_source_remove (overview->input_rebounce_timeout_id);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
input_timeout_signal (gpointer user_data)
|
||||
{
|
||||
PicplannerOverview *overview = PICPLANNER_OVERVIEW (user_data);
|
||||
|
||||
if (overview->input_count == 0)
|
||||
{
|
||||
g_print("Change if\n");
|
||||
overview->input_new = TRUE;
|
||||
overview->input_currently = TRUE;
|
||||
overview->input_rebounce_timeout_id = g_timeout_add (50,
|
||||
input_rebounce_reset_signal,
|
||||
overview);
|
||||
g_settings_set_double (overview->settings,
|
||||
"longitude" ,
|
||||
shumate_location_get_longitude (SHUMATE_LOCATION(overview->viewport)));
|
||||
g_settings_set_double (overview->settings,
|
||||
"latitude" ,
|
||||
shumate_location_get_latitude (SHUMATE_LOCATION(overview->viewport)));
|
||||
g_source_remove (overview->input_timeout_id);
|
||||
}
|
||||
overview->input_count = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
static void
|
||||
input_changed (GtkWidget *self,
|
||||
gpointer user_data,
|
||||
gpointer data_overview)
|
||||
{
|
||||
(void) user_data;
|
||||
PicplannerOverview *overview;
|
||||
overview = PICPLANNER_OVERVIEW (data_overview);
|
||||
|
||||
if (!overview->input_currently)
|
||||
{
|
||||
if (!G_IS_SETTINGS(self))
|
||||
{
|
||||
if (overview->input_new)
|
||||
{
|
||||
overview->input_new = FALSE;
|
||||
overview->input_timeout_id = g_timeout_add (200,
|
||||
input_timeout_signal,
|
||||
overview);
|
||||
|
||||
}
|
||||
overview->input_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
overview->input_currently = TRUE;
|
||||
g_print("Change Else\n");
|
||||
shumate_location_set_location (SHUMATE_LOCATION (overview->viewport),
|
||||
g_settings_get_double (overview->settings, "latitude"),
|
||||
g_settings_get_double (overview->settings, "longitude"));
|
||||
overview->input_rebounce_timeout_id = g_timeout_add (50,
|
||||
input_rebounce_reset_signal,
|
||||
overview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
picplanner_overview_map_fullscreen (PicplannerOverview *overview,
|
||||
|
@ -635,13 +711,31 @@ picplanner_overview_init (PicplannerOverview *overview)
|
|||
/*
|
||||
* Make all the bindings between widget properties and g_settings.
|
||||
*/
|
||||
g_settings_bind (overview->settings, "longitude",
|
||||
overview->viewport, "longitude",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
g_signal_connect (G_OBJECT (overview->viewport),
|
||||
"notify::longitude",
|
||||
G_CALLBACK (input_changed),
|
||||
overview);
|
||||
g_signal_connect (G_OBJECT (overview->viewport),
|
||||
"notify::latitude",
|
||||
G_CALLBACK (input_changed),
|
||||
overview);
|
||||
g_signal_connect (G_OBJECT (overview->settings),
|
||||
"changed::longitude",
|
||||
G_CALLBACK (input_changed),
|
||||
overview);
|
||||
g_signal_connect (G_OBJECT (overview->settings),
|
||||
"changed::latitude",
|
||||
G_CALLBACK (input_changed),
|
||||
overview);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
g_settings_bind (overview->settings, "latitude",
|
||||
overview->viewport, "latitude",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
*/
|
||||
|
||||
g_settings_bind (overview->settings, "zoom-level",
|
||||
overview->viewport, "zoom-level",
|
||||
|
@ -676,6 +770,15 @@ picplanner_overview_init (PicplannerOverview *overview)
|
|||
"changed::map-unit-imperial",
|
||||
G_CALLBACK (shumate_map_metric_imperial_scale),
|
||||
overview);
|
||||
|
||||
|
||||
/*
|
||||
* Initialisation of values needed to detect when a user input ends
|
||||
*/
|
||||
overview->input_new = true;
|
||||
overview->input_currently = false;
|
||||
overview->input_count = 0;
|
||||
overview->input_timeout_id = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Ładowanie…
Reference in New Issue