diff --git a/clutter/clutter/clutter-click-action.c b/clutter/clutter/clutter-click-action.c index 2f582a5d4..a9c0c8e9d 100644 --- a/clutter/clutter/clutter-click-action.c +++ b/clutter/clutter/clutter-click-action.c @@ -230,10 +230,9 @@ click_action_query_long_press (ClutterClickAction *action) if (result) { g_clear_handle_id (&priv->long_press_id, g_source_remove); - priv->long_press_id = - clutter_threads_add_timeout (timeout, - click_action_emit_long_press, - action); + priv->long_press_id = g_timeout_add (timeout, + click_action_emit_long_press, + action); } } diff --git a/clutter/clutter/clutter-input-pointer-a11y.c b/clutter/clutter/clutter-input-pointer-a11y.c index 8f0b45a9d..9a7221128 100644 --- a/clutter/clutter/clutter-input-pointer-a11y.c +++ b/clutter/clutter/clutter-input-pointer-a11y.c @@ -193,7 +193,7 @@ start_secondary_click_timeout (ClutterInputDevice *device) ClutterSeat *seat = clutter_input_device_get_seat (device); device->ptr_a11y_data->secondary_click_timer = - clutter_threads_add_timeout (delay, trigger_secondary_click, device); + g_timeout_add (delay, trigger_secondary_click, device); g_signal_emit_by_name (seat, "ptr-a11y-timeout-started", @@ -448,7 +448,7 @@ trigger_dwell_gesture (gpointer data) /* Do not clear the gesture right away, otherwise we'll start another one */ device->ptr_a11y_data->dwell_timer = - clutter_threads_add_timeout (delay, trigger_clear_dwell_gesture, device); + g_timeout_add (delay, trigger_clear_dwell_gesture, device); g_signal_emit_by_name (seat, "ptr-a11y-timeout-stopped", @@ -466,7 +466,7 @@ start_dwell_gesture_timeout (ClutterInputDevice *device) ClutterSeat *seat = clutter_input_device_get_seat (device); device->ptr_a11y_data->dwell_timer = - clutter_threads_add_timeout (delay, trigger_dwell_gesture, device); + g_timeout_add (delay, trigger_dwell_gesture, device); device->ptr_a11y_data->dwell_gesture_started = TRUE; g_signal_emit_by_name (seat, @@ -513,7 +513,7 @@ start_dwell_timeout (ClutterInputDevice *device) ClutterSeat *seat = clutter_input_device_get_seat (device); device->ptr_a11y_data->dwell_timer = - clutter_threads_add_timeout (delay, trigger_dwell_click, device); + g_timeout_add (delay, trigger_dwell_click, device); g_signal_emit_by_name (seat, "ptr-a11y-timeout-started", @@ -560,7 +560,7 @@ static void start_dwell_position_timeout (ClutterInputDevice *device) { device->ptr_a11y_data->dwell_position_timer = - clutter_threads_add_timeout (100, trigger_dwell_position_timeout, device); + g_timeout_add (100, trigger_dwell_position_timeout, device); } static void diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 7a93ec9be..1579e5645 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -43,13 +43,6 @@ #include "cogl/cogl.h" - -typedef struct -{ - GSourceFunc func; - gpointer data; -} ClutterThreadsDispatch; - G_DEFINE_QUARK (clutter_pipeline_capability, clutter_pipeline_capability) /* main context */ @@ -65,162 +58,6 @@ guint clutter_pick_debug_flags = 0; */ int clutter_max_render_time_constant_us = 1000; -static gboolean -_clutter_threads_dispatch (gpointer data) -{ - ClutterThreadsDispatch *dispatch = data; - gboolean ret = FALSE; - - if (!g_source_is_destroyed (g_main_current_source ())) - ret = dispatch->func (dispatch->data); - - return ret; -} - -static void -_clutter_threads_dispatch_free (gpointer data) -{ - ClutterThreadsDispatch *dispatch = data; - - g_free (dispatch); -} - -/** - * clutter_threads_add_idle: (skip) - * @func: function to call - * @data: data to pass to the function - * - * Adds a function to be called whenever there are no higher priority - * events pending. If the function returns %FALSE it is automatically - * removed from the list of event sources and will not be called again. - * - * This function can be considered a thread-safe variant of g_idle_add_full(): - * it will call @function while holding the Clutter lock. It is logically - * equivalent to the following implementation: - * - * ```c - * static gboolean - * idle_safe_callback (gpointer data) - * { - * SafeClosure *closure = data; - * gboolean res = FALSE; - * - * // the callback does not need to acquire the Clutter - * / lock itself, as it is held by the this proxy handler - * // - * res = closure->callback (closure->data); - * - * return res; - * } - * static gulong - * add_safe_idle (GSourceFunc callback, - * gpointer data) - * { - * SafeClosure *closure = g_new0 (SafeClosure, 1); - * - * closure->callback = callback; - * closure->data = data; - * - * return g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, - * idle_safe_callback, - * closure, - * g_free) - * } - * ``` - * - * This function should be used by threaded applications to make sure - * that @func is emitted under the Clutter threads lock and invoked - * from the same thread that started the Clutter main loop. For instance, - * it can be used to update the UI using the results from a worker - * thread: - * - * ```c - * static gboolean - * update_ui (gpointer data) - * { - * SomeClosure *closure = data; - * - * // it is safe to call Clutter API from this function because - * / it is invoked from the same thread that started the main - * / loop and under the Clutter thread lock - * // - * clutter_label_set_text (CLUTTER_LABEL (closure->label), - * closure->text); - * - * g_object_unref (closure->label); - * g_free (closure); - * - * return FALSE; - * } - * - * // within another thread // - * closure = g_new0 (SomeClosure, 1); - * // always take a reference on GObject instances // - * closure->label = g_object_ref (my_application->label); - * closure->text = g_strdup (processed_text_to_update_the_label); - * - * clutter_threads_add_idle (update_ui, - * closure); - * ``` - * - * Return value: the ID (greater than 0) of the event source. - */ -guint -clutter_threads_add_idle (GSourceFunc func, - gpointer data) -{ - ClutterThreadsDispatch *dispatch; - - g_return_val_if_fail (func != NULL, 0); - - dispatch = g_new0 (ClutterThreadsDispatch, 1); - dispatch->func = func; - dispatch->data = data; - - return g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, - _clutter_threads_dispatch, dispatch, - _clutter_threads_dispatch_free); -} - -/** - * clutter_threads_add_timeout: (skip) - * @interval: the time between calls to the function, in milliseconds - * @func: function to call - * @data: data to pass to the function - * - * Sets a function to be called at regular intervals holding the Clutter - * threads lock, with the given priority. The function is called repeatedly - * until it returns %FALSE, at which point the timeout is automatically - * removed and the function will not be called again. The @notify function - * is called when the timeout is removed. - * - * The first call to the function will be at the end of the first @interval. - * - * It is important to note that, due to how the Clutter main loop is - * implemented, the timing will not be accurate and it will not try to - * "keep up" with the interval. - * - * Return value: the ID (greater than 0) of the event source. - */ -guint -clutter_threads_add_timeout (guint interval, - GSourceFunc func, - gpointer data) -{ - ClutterThreadsDispatch *dispatch; - - g_return_val_if_fail (func != NULL, 0); - - dispatch = g_new0 (ClutterThreadsDispatch, 1); - dispatch->func = func; - dispatch->data = data; - - return g_timeout_add_full (G_PRIORITY_DEFAULT, - interval, - _clutter_threads_dispatch, dispatch, - _clutter_threads_dispatch_free); -} - ClutterContext * _clutter_context_get_default (void) diff --git a/clutter/clutter/clutter-main.h b/clutter/clutter/clutter-main.h index e4d0cf933..31c90003d 100644 --- a/clutter/clutter/clutter-main.h +++ b/clutter/clutter/clutter-main.h @@ -109,13 +109,6 @@ gboolean clutter_get_accessibility_enabled (void); /* Threading functions */ CLUTTER_EXPORT -guint clutter_threads_add_idle (GSourceFunc func, - gpointer data); -CLUTTER_EXPORT -guint clutter_threads_add_timeout (guint interval, - GSourceFunc func, - gpointer data); -CLUTTER_EXPORT guint clutter_threads_add_repaint_func (ClutterRepaintFlags flags, GSourceFunc func, gpointer data, diff --git a/clutter/clutter/clutter-text-accessible.c b/clutter/clutter/clutter-text-accessible.c index 79c60b6db..68bee0614 100644 --- a/clutter/clutter/clutter-text-accessible.c +++ b/clutter/clutter/clutter-text-accessible.c @@ -1598,8 +1598,7 @@ _cally_text_insert_text_cb (ClutterText *clutter_text, * or in an idle handler if it not updated. */ if (self->insert_idle_handler == 0) - self->insert_idle_handler = clutter_threads_add_idle (_idle_notify_insert, - self); + self->insert_idle_handler = g_idle_add (_idle_notify_insert, self); } /***** atkeditabletext.h ******/ diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index ab5e3e3f0..81c1e3d62 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -2561,9 +2561,9 @@ clutter_text_key_press (ClutterActor *actor, priv->password_hint_visible = TRUE; priv->password_hint_id = - clutter_threads_add_timeout (priv->password_hint_timeout, - clutter_text_remove_password_hint, - self); + g_timeout_add (priv->password_hint_timeout, + clutter_text_remove_password_hint, + self); } return CLUTTER_EVENT_STOP; diff --git a/clutter/clutter/clutter-timeline.c b/clutter/clutter/clutter-timeline.c index 3318b6d78..b6454bac1 100644 --- a/clutter/clutter/clutter-timeline.c +++ b/clutter/clutter/clutter-timeline.c @@ -35,8 +35,7 @@ * * It is important to note that #ClutterTimeline is not a generic API for * calling closures after an interval; each Timeline is tied into a frame - * clock used to drive the frame cycle. If you need to schedule a closure - * after an interval, see [func@threads_add_timeout] instead. + * clock used to drive the frame cycle. * * Users of #ClutterTimeline should connect to the [signal@Timeline::new-frame] * signal, which is emitted each time a timeline is advanced during the maste @@ -1259,9 +1258,11 @@ clutter_timeline_start (ClutterTimeline *timeline) priv->frame_clock); if (priv->delay) - priv->delay_id = clutter_threads_add_timeout (priv->delay, - delay_timeout_func, - timeline); + { + priv->delay_id = g_timeout_add (priv->delay, + delay_timeout_func, + timeline); + } else { priv->msecs_delta = 0; diff --git a/src/backends/x11/meta-input-device-x11.c b/src/backends/x11/meta-input-device-x11.c index 7bc089eb7..6c1623fd8 100644 --- a/src/backends/x11/meta-input-device-x11.c +++ b/src/backends/x11/meta-input-device-x11.c @@ -480,7 +480,7 @@ meta_input_device_x11_get_pointer_location (ClutterInputDevice *device, device_xi2->query_status = meta_input_device_x11_query_pointer_location (device_xi2); device_xi2->inhibit_pointer_query_timer = - clutter_threads_add_idle (clear_inhibit_pointer_query_cb, device_xi2); + g_idle_add (clear_inhibit_pointer_query_cb, device_xi2); } *x = device_xi2->current_x; diff --git a/src/backends/x11/meta-stage-x11.c b/src/backends/x11/meta-stage-x11.c index bb00455c6..4b60d53b7 100644 --- a/src/backends/x11/meta-stage-x11.c +++ b/src/backends/x11/meta-stage-x11.c @@ -665,9 +665,9 @@ meta_stage_x11_handle_event (MetaStageX11 *stage_x11, g_source_remove); stage_x11->clipped_redraws_cool_off = - clutter_threads_add_timeout (1000, - clipped_redraws_cool_off_cb, - stage_x11); + g_timeout_add (1000, + clipped_redraws_cool_off_cb, + stage_x11); /* Queue a relayout - we want glViewport to be called * with the correct values, and this is done in ClutterStage diff --git a/src/tests/clutter/conform/actor-pick.c b/src/tests/clutter/conform/actor-pick.c index 71faef084..90e755129 100644 --- a/src/tests/clutter/conform/actor-pick.c +++ b/src/tests/clutter/conform/actor-pick.c @@ -203,7 +203,7 @@ actor_pick (void) clutter_actor_show (state.stage); - clutter_threads_add_idle (on_timeout, &state); + g_idle_add (on_timeout, &state); clutter_test_main (); diff --git a/src/tests/clutter/conform/cally-text.c b/src/tests/clutter/conform/cally-text.c index 2dfd704a2..4ee9ec78f 100644 --- a/src/tests/clutter/conform/cally-text.c +++ b/src/tests/clutter/conform/cally-text.c @@ -314,7 +314,7 @@ cally_text (void) data.next = &data1; clutter_actor_show (data.stage); - clutter_threads_add_idle ((GSourceFunc) do_tests, &data); + g_idle_add ((GSourceFunc) do_tests, &data); clutter_test_main (); clutter_actor_destroy (data.stage); diff --git a/src/tests/clutter/conform/text-cache.c b/src/tests/clutter/conform/text-cache.c index 46501c680..d26246446 100644 --- a/src/tests/clutter/conform/text-cache.c +++ b/src/tests/clutter/conform/text-cache.c @@ -277,7 +277,7 @@ text_cache (void) clutter_actor_show (data.stage); - clutter_threads_add_idle ((GSourceFunc) do_tests, &data); + g_idle_add ((GSourceFunc) do_tests, &data); clutter_test_main (); diff --git a/src/tests/clutter/conform/timeline-rewind.c b/src/tests/clutter/conform/timeline-rewind.c index 6b0a96463..d86454adf 100644 --- a/src/tests/clutter/conform/timeline-rewind.c +++ b/src/tests/clutter/conform/timeline-rewind.c @@ -82,9 +82,9 @@ timeline_rewind (void) &state); g_test_message ("Installing a watchdog timeout " "to determine if this test hangs"); - clutter_threads_add_timeout (TEST_WATCHDOG_KICK_IN_SECONDS * 1000, - watchdog_timeout, - &state); + g_timeout_add (TEST_WATCHDOG_KICK_IN_SECONDS * 1000, + watchdog_timeout, + &state); state.rewind_count = 0; clutter_actor_show (stage); diff --git a/src/tests/clutter/conform/timeline.c b/src/tests/clutter/conform/timeline.c index 030212826..5fe01a9e8 100644 --- a/src/tests/clutter/conform/timeline.c +++ b/src/tests/clutter/conform/timeline.c @@ -176,7 +176,7 @@ delay_cb (gpointer data) static gboolean add_timeout_idle (gpointer user_data) { - clutter_threads_add_timeout (2000, timeout_cb, NULL); + g_timeout_add (2000, timeout_cb, NULL); return G_SOURCE_REMOVE; } @@ -295,8 +295,8 @@ timeline_base (void) clutter_timeline_start (timeline_2); clutter_timeline_start (timeline_3); - clutter_threads_add_timeout (2000, timeout_cb, NULL); - delay_tag = clutter_threads_add_timeout (99, delay_cb, NULL); + g_timeout_add (2000, timeout_cb, NULL); + delay_tag = g_timeout_add (99, delay_cb, NULL); clutter_test_main (); diff --git a/src/tests/clutter/interactive/test-cogl-point-sprites.c b/src/tests/clutter/interactive/test-cogl-point-sprites.c index c3c7eac94..009621e21 100644 --- a/src/tests/clutter/interactive/test-cogl-point-sprites.c +++ b/src/tests/clutter/interactive/test-cogl-point-sprites.c @@ -268,7 +268,7 @@ test_cogl_point_sprites_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_threads_add_idle (idle_cb, stage); + g_idle_add (idle_cb, stage); clutter_test_main (); diff --git a/src/tests/clutter/interactive/test-cogl-shader-glsl.c b/src/tests/clutter/interactive/test-cogl-shader-glsl.c index 34eeca3a9..bb1810269 100644 --- a/src/tests/clutter/interactive/test-cogl-shader-glsl.c +++ b/src/tests/clutter/interactive/test-cogl-shader-glsl.c @@ -347,9 +347,9 @@ test_cogl_shader_glsl_main (int argc, char *argv[]) g_signal_connect (stage, "delete-event", G_CALLBACK (destroy_window_cb), NULL); - timeout_id = clutter_threads_add_timeout (1000, timeout_cb, NULL); + timeout_id = g_timeout_add (1000, timeout_cb, NULL); - clutter_threads_add_idle (idle_cb, stage); + g_idle_add (idle_cb, stage); clutter_actor_show (stage); diff --git a/src/tests/clutter/micro-bench/test-cogl-perf.c b/src/tests/clutter/micro-bench/test-cogl-perf.c index e3d01f7ac..9dd1282ab 100644 --- a/src/tests/clutter/micro-bench/test-cogl-perf.c +++ b/src/tests/clutter/micro-bench/test-cogl-perf.c @@ -142,7 +142,7 @@ main (int argc, char *argv[]) &COGL_COLOR_INIT (255, 255, 255, 255)); /* We want continuous redrawing of the stage... */ - clutter_threads_add_idle (queue_redraw, stage); + g_idle_add (queue_redraw, stage); g_signal_connect (actor, "paint", G_CALLBACK (on_paint), &state); diff --git a/src/tests/clutter/micro-bench/test-picking.c b/src/tests/clutter/micro-bench/test-picking.c index b44f82e14..438b12db4 100644 --- a/src/tests/clutter/micro-bench/test-picking.c +++ b/src/tests/clutter/micro-bench/test-picking.c @@ -109,7 +109,7 @@ main (int argc, char **argv) clutter_actor_show (stage); - clutter_threads_add_idle (queue_redraw, stage); + g_idle_add (queue_redraw, stage); g_signal_connect (CLUTTER_STAGE (stage), "after-paint", G_CALLBACK (on_after_paint), NULL); diff --git a/src/tests/clutter/micro-bench/test-random-text.c b/src/tests/clutter/micro-bench/test-random-text.c index c20425b25..df6ddce61 100644 --- a/src/tests/clutter/micro-bench/test-random-text.c +++ b/src/tests/clutter/micro-bench/test-random-text.c @@ -94,7 +94,7 @@ main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_threads_add_idle (on_idle, stage); + g_idle_add (on_idle, stage); clutter_test_main (); diff --git a/src/tests/clutter/micro-bench/test-text-perf.c b/src/tests/clutter/micro-bench/test-text-perf.c index 14ef22984..3016dc535 100644 --- a/src/tests/clutter/micro-bench/test-text-perf.c +++ b/src/tests/clutter/micro-bench/test-text-perf.c @@ -183,7 +183,7 @@ main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_threads_add_idle (queue_redraw, stage); + g_idle_add (queue_redraw, stage); clutter_test_main (); diff --git a/src/tests/clutter/micro-bench/test-text.c b/src/tests/clutter/micro-bench/test-text.c index 722c52881..0742b1687 100644 --- a/src/tests/clutter/micro-bench/test-text.c +++ b/src/tests/clutter/micro-bench/test-text.c @@ -64,7 +64,7 @@ main (int argc, char *argv[]) clutter_actor_set_size (group, STAGE_WIDTH, STAGE_WIDTH); clutter_actor_add_child (stage, group); - clutter_threads_add_idle (queue_redraw, stage); + g_idle_add (queue_redraw, stage); g_signal_connect (CLUTTER_STAGE (stage), "after-paint", G_CALLBACK (on_after_paint), NULL); diff --git a/src/tests/clutter/performance/test-common.h b/src/tests/clutter/performance/test-common.h index df7d11cfc..ee4e2a571 100644 --- a/src/tests/clutter/performance/test-common.h +++ b/src/tests/clutter/performance/test-common.h @@ -43,7 +43,7 @@ clutter_perf_fps_start (ClutterStage *stage) static inline void clutter_perf_fake_mouse (ClutterStage *stage) { - clutter_threads_add_timeout (1000/60, perf_fake_mouse_cb, stage); + g_timeout_add (1000/60, perf_fake_mouse_cb, stage); } static inline void diff --git a/src/tests/clutter/performance/test-picking.c b/src/tests/clutter/performance/test-picking.c index e134d9594..a8e741c7a 100644 --- a/src/tests/clutter/performance/test-picking.c +++ b/src/tests/clutter/performance/test-picking.c @@ -102,7 +102,7 @@ main (int argc, char **argv) clutter_actor_show (stage); clutter_perf_fps_start (CLUTTER_STAGE (stage)); - clutter_threads_add_idle (queue_redraw, stage); + g_idle_add (queue_redraw, stage); clutter_test_main (); clutter_perf_fps_report ("test-picking"); diff --git a/src/tests/clutter/performance/test-text-perf.c b/src/tests/clutter/performance/test-text-perf.c index 2e7f0a2d6..0d4332f49 100644 --- a/src/tests/clutter/performance/test-text-perf.c +++ b/src/tests/clutter/performance/test-text-perf.c @@ -157,7 +157,7 @@ main (int argc, char *argv[]) clutter_actor_show (stage); clutter_perf_fps_start (CLUTTER_STAGE (stage)); - clutter_threads_add_idle (queue_redraw, stage); + g_idle_add (queue_redraw, stage); clutter_test_main (); clutter_perf_fps_report ("test-text-perf");