1 #include <Elementary.h>
4 static Evas_Object *win = NULL;
5 static Evas_Object *rect = NULL;
12 static void *my_thread_mainloop_code(void *data);
14 static pthread_t thread_id;
16 // BEGIN - code running in my custom pthread instance
19 my_thread_run(void *arg)
25 struct info *inf = malloc(sizeof(struct info));
29 inf->x = 200 + (200 * sin(t));
30 inf->y = 200 + (200 * cos(t));
31 ecore_main_loop_thread_safe_call_sync
32 (my_thread_mainloop_code, inf);
41 // END - code running in my custom pthread instance
47 if (pthread_attr_init(&attr) != 0)
48 perror("pthread_attr_init");
49 if (pthread_create(&thread_id, &attr, my_thread_run, NULL) != 0)
50 perror("pthread_create");
54 my_thread_mainloop_code(void *data)
56 struct info *inf = data;
57 evas_object_move(rect, inf->x - 50, inf->y - 50);
63 elm_main(int argc, char **argv)
67 win = elm_win_add(NULL, "efl-thread-2", ELM_WIN_BASIC);
68 elm_win_title_set(win, "EFL Thread 2");
69 evas_object_resize(win, 400, 400);
70 evas_object_show(win);
73 elm_win_resize_object_add(win, bg);
74 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77 o = evas_object_rectangle_add(evas_object_evas_get(win));
78 evas_object_color_set(o, 50, 80, 180, 255);
79 evas_object_resize(o, 100, 100);
83 // create custom thread to do some "work on the side"