1 #include "evas_common.h"
2 #include "evas_private.h"
5 static int _evas_init_count = 0;
6 int _evas_log_dom_global = -1;
10 * @return The init counter value.
12 * This function initialize evas, increments a counter of the number
13 * of calls to this function and returns this value.
15 * @see evas_shutdown().
22 if (++_evas_init_count != 1)
23 return _evas_init_count;
27 return --_evas_init_count;
33 _evas_log_dom_global = eina_log_domain_register("evas_main",EVAS_DEFAULT_LOG_COLOR);
34 if (_evas_log_dom_global < 0)
36 EINA_LOG_ERR("Evas could not create a default log domain\n");
41 #ifdef BUILD_ASYNC_EVENTS
42 if (!evas_async_events_init())
46 if (getenv("EVAS_CSERVE")) evas_cserve_init();
48 #ifdef BUILD_ASYNC_PRELOAD
49 _evas_preload_thread_init();
51 #ifdef EVAS_FRAME_QUEUING
52 evas_common_frameq_init();
55 return _evas_init_count;
57 #ifdef BUILD_ASYNC_EVENTS
59 evas_module_shutdown();
60 eina_log_domain_unregister(_evas_log_dom_global);
69 return --_evas_init_count;
75 * @return The init counter value.
77 * This function finalize evas, decrements the counter of the number
78 * of calls to the function evas_init() and returns this value.
87 if (--_evas_init_count != 0)
88 return _evas_init_count;
90 #ifdef EVAS_FRAME_QUEUING
91 if (evas_common_frameq_enabled())
93 evas_common_frameq_finish();
94 evas_common_frameq_destroy();
97 #ifdef BUILD_ASYNC_EVENTS
98 _evas_preload_thread_shutdown();
101 if (getenv("EVAS_CSERVE")) evas_cserve_shutdown();
103 #ifdef BUILD_ASYNC_EVENTS
104 evas_async_events_shutdown();
106 evas_font_dir_cache_free();
107 evas_common_shutdown();
108 evas_module_shutdown();
109 eina_log_domain_unregister(_evas_log_dom_global);
115 return _evas_init_count;
120 * Creates a new empty evas.
122 * Note that before you can use the evas, you will to at a minimum:
123 * @li Set its render method with @ref evas_output_method_set .
124 * @li Set its viewport size with @ref evas_output_viewport_set .
125 * @li Set its size of the canvas with @ref evas_output_size_set .
126 * @li Ensure that the render engine is given the correct settings
127 * with @ref evas_engine_info_set .
129 * This function should only fail if the memory allocation fails
131 * @note this function is very low level. Instead of using it
132 * directly, consider using the high level functions in
133 * Ecore_Evas such as @c ecore_evas_new(). See
134 * http://docs.enlightenment.org/auto/ecore/.
136 * @attention it is recommended that one calls evas_init() before
137 * creating new canvas.
139 * @return A new uninitialised Evas canvas on success. Otherwise, @c
141 * @ingroup Evas_Canvas
148 e = calloc(1, sizeof(Evas));
151 e->magic = MAGIC_EVAS;
152 e->output.render_method = RENDER_METHOD_INVALID;
155 e->hinting = EVAS_FONT_HINTING_BYTECODE;
156 e->name_hash = eina_hash_string_superfast_new(NULL);
158 eina_array_step_set(&e->delete_objects, 256);
159 eina_array_step_set(&e->active_objects, 256);
160 eina_array_step_set(&e->restack_objects, 256);
161 eina_array_step_set(&e->render_objects, 256);
162 eina_array_step_set(&e->pending_objects, 256);
163 eina_array_step_set(&e->obscuring_objects, 256);
164 eina_array_step_set(&e->temporary_objects, 256);
165 eina_array_step_set(&e->calculate_objects, 256);
166 eina_array_step_set(&e->clip_changes, 256);
172 * Frees the given evas and any objects created on it.
174 * Any objects with 'free' callbacks will have those callbacks called
177 * @param e The given evas.
179 * @ingroup Evas_Canvas
189 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
193 #ifdef EVAS_FRAME_QUEUING
194 evas_common_frameq_flush();
197 if (e->walking_list == 0) evas_render_idle_flush(e);
199 if (e->walking_list > 0) return;
200 if (!e->callbacks) return;
201 if (e->callbacks->deletions_waiting) return;
203 e->callbacks->deletions_waiting = 0;
204 evas_event_callback_list_post_free(&e->callbacks->callbacks);
205 if (!e->callbacks->callbacks)
211 _evas_post_event_callback_free(e);
219 EINA_INLIST_FOREACH(e->layers, lay)
223 evas_layer_pre_free(lay);
225 EINA_INLIST_FOREACH(lay->objects, o)
227 if ((o->callbacks) && (o->callbacks->walking_list))
239 EINA_INLIST_FOREACH(e->layers, lay)
240 evas_layer_free_objects(lay);
245 evas_font_path_clear(e);
246 e->pointer.object.in = eina_list_free(e->pointer.object.in);
248 if (e->name_hash) eina_hash_free(e->name_hash);
251 EINA_LIST_FREE(e->damages, r)
252 eina_rectangle_free(r);
253 EINA_LIST_FREE(e->obscures, r)
254 eina_rectangle_free(r);
256 evas_fonts_zero_free(e);
258 evas_event_callback_all_del(e);
259 evas_event_callback_cleanup(e);
263 e->engine.func->context_free(e->engine.data.output, e->engine.data.context);
264 e->engine.func->output_free(e->engine.data.output);
265 e->engine.func->info_free(e, e->engine.info);
268 for (i = 0; i < e->modifiers.mod.count; i++)
269 free(e->modifiers.mod.list[i]);
270 if (e->modifiers.mod.list) free(e->modifiers.mod.list);
272 for (i = 0; i < e->locks.lock.count; i++)
273 free(e->locks.lock.list[i]);
274 if (e->locks.lock.list) free(e->locks.lock.list);
276 if (e->engine.module) evas_module_unref(e->engine.module);
278 eina_array_flush(&e->delete_objects);
279 eina_array_flush(&e->active_objects);
280 eina_array_flush(&e->restack_objects);
281 eina_array_flush(&e->render_objects);
282 eina_array_flush(&e->pending_objects);
283 eina_array_flush(&e->obscuring_objects);
284 eina_array_flush(&e->temporary_objects);
285 eina_array_flush(&e->calculate_objects);
286 eina_array_flush(&e->clip_changes);
293 * Sets the output engine for the given evas.
295 * Once the output engine for an evas is set, any attempt to change it
296 * will be ignored. The value for @p render_method can be found using
297 * @ref evas_render_method_lookup .
299 * @attention it is mandatory that one calls evas_init() before
300 * setting the output method.
302 * @param e The given evas.
303 * @param render_method The numeric engine value to use.
304 * @ingroup Evas_Output_Method
307 evas_output_method_set(Evas *e, int render_method)
311 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
315 /* if our engine to set it to is invalid - abort */
316 if (render_method == RENDER_METHOD_INVALID) return;
317 /* if the engine is already set up - abort */
318 if (e->output.render_method != RENDER_METHOD_INVALID) return;
319 /* Request the right engine. */
320 em = evas_module_engine_get(render_method);
322 if (em->id_engine != render_method) return;
323 if (!evas_module_load(em)) return;
325 /* set the correct render */
326 e->output.render_method = render_method;
327 e->engine.func = (em->functions);
329 if (e->engine.module) evas_module_unref(e->engine.module);
330 e->engine.module = em;
332 /* get the engine info struct */
333 if (e->engine.func->info) e->engine.info = e->engine.func->info(e);
338 * Retrieves the number of the output engine used for the given evas.
339 * @param e The given evas.
340 * @return The ID number of the output engine being used. @c 0 is
341 * returned if there is an error.
342 * @ingroup Evas_Output_Method
345 evas_output_method_get(const Evas *e)
347 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
348 return RENDER_METHOD_INVALID;
351 return e->output.render_method;
355 * Retrieves the current render engine info struct from the given evas.
357 * The returned structure is publicly modifiable. The contents are
358 * valid until either @ref evas_engine_info_set or @ref evas_render
361 * This structure does not need to be freed by the caller.
363 * @param e The given evas.
364 * @return A pointer to the Engine Info structure. @c NULL is returned if
365 * an engine has not yet been assigned.
366 * @ingroup Evas_Output_Method
368 EAPI Evas_Engine_Info *
369 evas_engine_info_get(const Evas *e)
371 Evas_Engine_Info *info;
373 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
377 if (!e->engine.info) return NULL;
379 info = e->engine.info;
380 ((Evas *)e)->engine.info_magic = info->magic;
386 * Applies the engine settings for the given evas from the given @c
387 * Evas_Engine_Info structure.
389 * To get the Evas_Engine_Info structure to use, call @ref
390 * evas_engine_info_get . Do not try to obtain a pointer to an
391 * @c Evas_Engine_Info structure in any other way.
393 * You will need to call this function at least once before you can
394 * create objects on an evas or render that evas. Some engines allow
395 * their settings to be changed more than once.
397 * Once called, the @p info pointer should be considered invalid.
399 * @param e The pointer to the Evas Canvas
400 * @param info The pointer to the Engine Info to use
401 * @return 1 if no error occured, 0 otherwise
402 * @ingroup Evas_Output_Method
405 evas_engine_info_set(Evas *e, Evas_Engine_Info *info)
407 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
411 if (info != e->engine.info) return 0;
412 if (info->magic != e->engine.info_magic) return 0;
413 return e->engine.func->setup(e, info);
417 * Sets the output size of the render engine of the given evas.
419 * The evas will render to a rectangle of the given size once this
420 * function is called. The output size is independent of the viewport
421 * size. The viewport will be stretched to fill the given rectangle.
423 * The units used for @p w and @p h depend on the engine used by the
426 * @param e The given evas.
427 * @param w The width in output units, usually pixels.
428 * @param h The height in output units, usually pixels.
429 * @ingroup Evas_Output_Size
432 evas_output_size_set(Evas *e, int w, int h)
434 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
438 if ((w == e->output.w) && (h == e->output.h)) return;
442 #ifdef EVAS_FRAME_QUEUING
443 evas_common_frameq_flush();
448 e->output.changed = 1;
449 e->output_validity++;
451 evas_render_invalidate(e);
455 * Retrieve the output size of the render engine of the given evas.
457 * The output size is given in whatever the output units are for the
460 * If either @p w or @p h is @c NULL, then it is ignored. If @p e is
461 * invalid, the returned results are undefined.
463 * @param e The given evas.
464 * @param w The pointer to an integer to store the width in.
465 * @param h The pointer to an integer to store the height in.
466 * @ingroup Evas_Output_Size
469 evas_output_size_get(const Evas *e, int *w, int *h)
471 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
477 if (w) *w = e->output.w;
478 if (h) *h = e->output.h;
482 * Sets the output viewport of the given evas in evas units.
484 * The output viewport is the area of the evas that will be visible to
485 * the viewer. The viewport will be stretched to fit the output
486 * target of the evas when rendering is performed.
488 * @note The coordinate values do not have to map 1-to-1 with the output
489 * target. However, it is generally advised that it is done for ease
492 * @param e The given evas.
493 * @param x The top-left corner x value of the viewport.
494 * @param y The top-left corner y value of the viewport.
495 * @param w The width of the viewport. Must be greater than 0.
496 * @param h The height of the viewport. Must be greater than 0.
497 * @ingroup Evas_Output_Size
500 evas_output_viewport_set(Evas *e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
502 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
506 if ((x == e->viewport.x) && (y == e->viewport.y) &&
507 (w == e->viewport.w) && (h == e->viewport.h)) return;
510 if ((x != 0) || (y != 0))
512 ERR("Compat error. viewport x,y != 0,0 not supported");
520 e->viewport.changed = 1;
521 e->output_validity++;
526 * Get the render engine's output viewport co-ordinates in canvas units.
527 * @param e The pointer to the Evas Canvas
528 * @param x The pointer to a x variable to be filled in
529 * @param y The pointer to a y variable to be filled in
530 * @param w The pointer to a width variable to be filled in
531 * @param h The pointer to a height variable to be filled in
532 * @ingroup Evas_Output_Size
534 * Calling this function writes the current canvas output viewport
535 * size and location values into the variables pointed to by @p x, @p
536 * y, @p w and @p h. On success the variables have the output
537 * location and size values written to them in canvas units. Any of @p
538 * x, @p y, @p w or @p h that are NULL will not be written to. If @p e
539 * is invalid, the results are undefined.
544 * Evas_Coord x, y, width, height;
546 * evas_output_viewport_get(evas, &x, &y, &w, &h);
550 evas_output_viewport_get(const Evas *e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
552 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
560 if (x) *x = e->viewport.x;
561 if (y) *y = e->viewport.y;
562 if (w) *w = e->viewport.w;
563 if (h) *h = e->viewport.h;
567 * Convert/scale an ouput screen co-ordinate into canvas co-ordinates
569 * @param e The pointer to the Evas Canvas
570 * @param x The screen/output x co-ordinate
571 * @return The screen co-ordinate translated to canvas unit co-ordinates
572 * @ingroup Evas_Coord_Mapping_Group
574 * This function takes in a horizontal co-ordinate as the @p x
575 * parameter and converts it into canvas units, accounting for output
576 * size, viewport size and location, returning it as the function
577 * return value. If @p e is invalid, the results are undefined.
582 * extern int screen_x;
583 * Evas_Coord canvas_x;
585 * canvas_x = evas_coord_screen_x_to_world(evas, screen_x);
589 evas_coord_screen_x_to_world(const Evas *e, int x)
591 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
594 if (e->output.w == e->viewport.w) return e->viewport.x + x;
595 return (long long)e->viewport.x + (((long long)x * (long long)e->viewport.w) / (long long)e->output.w);
599 * Convert/scale an ouput screen co-ordinate into canvas co-ordinates
601 * @param e The pointer to the Evas Canvas
602 * @param y The screen/output y co-ordinate
603 * @return The screen co-ordinate translated to canvas unit co-ordinates
604 * @ingroup Evas_Coord_Mapping_Group
606 * This function takes in a vertical co-ordinate as the @p y parameter
607 * and converts it into canvas units, accounting for output size,
608 * viewport size and location, returning it as the function return
609 * value. If @p e is invalid, the results are undefined.
614 * extern int screen_y;
615 * Evas_Coord canvas_y;
617 * canvas_y = evas_coord_screen_y_to_world(evas, screen_y);
621 evas_coord_screen_y_to_world(const Evas *e, int y)
623 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
626 if (e->output.h == e->viewport.h) return e->viewport.y + y;
627 return (long long)e->viewport.y + (((long long)y * (long long)e->viewport.h) / (long long)e->output.h);
631 * Convert/scale a canvas co-ordinate into output screen co-ordinates
633 * @param e The pointer to the Evas Canvas
634 * @param x The canvas x co-ordinate
635 * @return The output/screen co-ordinate translated to output co-ordinates
636 * @ingroup Evas_Coord_Mapping_Group
638 * This function takes in a horizontal co-ordinate as the @p x
639 * parameter and converts it into output units, accounting for output
640 * size, viewport size and location, returning it as the function
641 * return value. If @p e is invalid, the results are undefined.
647 * extern Evas_Coord canvas_x;
649 * screen_x = evas_coord_world_x_to_screen(evas, canvas_x);
653 evas_coord_world_x_to_screen(const Evas *e, Evas_Coord x)
655 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
658 if (e->output.w == e->viewport.w) return x - e->viewport.x;
659 return (int)((((long long)x - (long long)e->viewport.x) * (long long)e->output.w) / (long long)e->viewport.w);
663 * Convert/scale a canvas co-ordinate into output screen co-ordinates
665 * @param e The pointer to the Evas Canvas
666 * @param y The canvas y co-ordinate
667 * @return The output/screen co-ordinate translated to output co-ordinates
668 * @ingroup Evas_Coord_Mapping_Group
670 * This function takes in a vertical co-ordinate as the @p x parameter
671 * and converts it into output units, accounting for output size,
672 * viewport size and location, returning it as the function return
673 * value. If @p e is invalid, the results are undefined.
679 * extern Evas_Coord canvas_y;
681 * screen_y = evas_coord_world_y_to_screen(evas, canvas_y);
685 evas_coord_world_y_to_screen(const Evas *e, Evas_Coord y)
687 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
690 if (e->output.h == e->viewport.h) return y - e->viewport.y;
691 return (int)((((long long)y - (long long)e->viewport.y) * (long long)e->output.h) / (long long)e->viewport.h);
695 * Look up a numeric ID from a string name of a rendering engine.
697 * @param name The string name of an engine
698 * @return A numeric (opaque) ID for the rendering engine
699 * @ingroup Evas_Output_Method
701 * This function looks up a numeric return value for the named engine
702 * in the string @p name. This is a normal C string, NUL byte
703 * terminated. The name is case sensitive. If the rendering engine is
704 * available, a numeric ID for that engine is returned that is not
705 * 0. If the engine is not available, 0 is returned, indicating an
708 * The programmer should NEVER rely on the numeric ID of an engine
709 * unless it is returned by this function. Programs should NOT be
710 * written accessing render method ID's directly, without first
711 * obtaining it from this function.
713 * @attention it is mandatory that one calls evas_init() before
714 * looking up the render method.
726 * fprintf(stderr, "ERROR: Canvas creation failed. Fatal error.\n");
729 * engine_id = evas_render_method_lookup("software_x11");
732 * fprintf(stderr, "ERROR: Requested rendering engine is absent.\n");
735 * evas_output_method_set(evas, engine_id);
739 evas_render_method_lookup(const char *name)
743 if (!name) return RENDER_METHOD_INVALID;
744 /* search on the engines list for the name */
745 em = evas_module_find_type(EVAS_MODULE_TYPE_ENGINE, name);
746 if (!em) return RENDER_METHOD_INVALID;
748 return em->id_engine;
752 * List all the rendering engines compiled into the copy of the Evas library
754 * @return A linked list whose data members are C strings of engine names
755 * @ingroup Evas_Output_Method
757 * Calling this will return a handle (pointer) to an Evas linked
758 * list. Each node in the linked list will have the data pointer be a
759 * (char *) pointer to the string name of the rendering engine
760 * available. The strings should never be modified, neither should the
761 * list be modified. This list should be cleaned up as soon as the
762 * program no longer needs it using evas_render_method_list_free(). If
763 * no engines are available from Evas, NULL will be returned.
767 * Eina_List *engine_list, *l;
770 * engine_list = evas_render_method_list();
773 * fprintf(stderr, "ERROR: Evas supports no engines! Exit.\n");
776 * printf("Availible Evas Engines:\n");
777 * EINA_LIST_FOREACH(engine_list, l, engine_name)
778 * printf("%s\n", engine_name);
779 * evas_render_method_list_free(engine_list);
783 evas_render_method_list(void)
785 Eina_List *methods = NULL;
787 /* FIXME: get from modules - this is currently coded-in */
788 #ifdef BUILD_ENGINE_SOFTWARE_GDI
789 methods = eina_list_append(methods, "software_gdi");
791 #ifdef BUILD_ENGINE_SOFTWARE_DDRAW
792 methods = eina_list_append(methods, "software_ddraw");
794 #ifdef BUILD_ENGINE_SOFTWARE_16_DDRAW
795 methods = eina_list_append(methods, "software_16_ddraw");
797 #ifdef BUILD_ENGINE_DIRECT3D
798 methods = eina_list_append(methods, "direct3d");
800 #ifdef BUILD_ENGINE_SOFTWARE_16_WINCE
801 methods = eina_list_append(methods, "software_16_wince");
803 #ifdef BUILD_ENGINE_SOFTWARE_X11
804 methods = eina_list_append(methods, "software_x11");
806 #ifdef BUILD_ENGINE_XRENDER_X11
807 methods = eina_list_append(methods, "xrender_x11");
809 #ifdef BUILD_ENGINE_XRENDER_XCB
810 methods = eina_list_append(methods, "xrender_xcb");
812 #ifdef BUILD_ENGINE_SOFTWARE_16_X11
813 methods = eina_list_append(methods, "software_16_x11");
815 #ifdef BUILD_ENGINE_GL_X11
816 methods = eina_list_append(methods, "gl_x11");
818 #ifdef BUILD_ENGINE_GL_GLEW
819 methods = eina_list_append(methods, "gl_glew");
821 #ifdef BUILD_ENGINE_CAIRO_X11
822 methods = eina_list_append(methods, "cairo_x11");
824 #ifdef BUILD_ENGINE_DIRECTFB
825 methods = eina_list_append(methods, "directfb");
827 #ifdef BUILD_ENGINE_FB
828 methods = eina_list_append(methods, "fb");
830 #ifdef BUILD_ENGINE_BUFFER
831 methods = eina_list_append(methods, "buffer");
833 #ifdef BUILD_ENGINE_SOFTWARE_WIN32_GDI
834 methods = eina_list_append(methods, "software_win32_gdi");
836 #ifdef BUILD_ENGINE_SOFTWARE_QTOPIA
837 methods = eina_list_append(methods, "software_qtopia");
839 #ifdef BUILD_ENGINE_SOFTWARE_SDL
840 methods = eina_list_append(methods, "software_sdl");
847 * This function should be called to free a list of engine names
849 * @param list The Eina_List base pointer for the engine list to be freed
850 * @ingroup Evas_Output_Method
852 * When this function is called it will free the engine list passed in
853 * as @p list. The list should only be a list of engines generated by
854 * calling evas_render_method_list(). If @p list is NULL, nothing will
859 * Eina_List *engine_list, *l;
862 * engine_list = evas_render_method_list();
865 * fprintf(stderr, "ERROR: Evas supports no engines! Exit.\n");
868 * printf("Availible Evas Engines:\n");
869 * EINA_LIST_FOREACH(engine_list, l, engine_name)
870 * printf("%s\n", engine_name);
871 * evas_render_method_list_free(engine_list);
875 evas_render_method_list_free(Eina_List *list)
877 eina_list_free(list);
881 * This function returns the current known pointer co-ordinates
883 * @param e The pointer to the Evas Canvas
884 * @param x The pointer to an integer to be filled in
885 * @param y The pointer to an integer to be filled in
886 * @ingroup Evas_Pointer_Group
888 * This function returns the current known screen/output co-ordinates
889 * of the mouse pointer and sets the contents of the integers pointed
890 * to by @p x and @p y to contain these co-ordinates. If @p e is not a
891 * valid canvas the results of this function are undefined.
896 * int mouse_x, mouse_y;
898 * evas_pointer_output_xy_get(evas, &mouse_x, &mouse_y);
899 * printf("Mouse is at screen position %i, %i\n", mouse_x, mouse_y);
903 evas_pointer_output_xy_get(const Evas *e, int *x, int *y)
905 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
910 if (x) *x = e->pointer.x;
911 if (y) *y = e->pointer.y;
915 * This function returns the current known pointer co-ordinates
917 * @param e The pointer to the Evas Canvas
918 * @param x The pointer to a Evas_Coord to be filled in
919 * @param y The pointer to a Evas_Coord to be filled in
920 * @ingroup Evas_Pointer_Group
922 * This function returns the current known canvas unit co-ordinates of
923 * the mouse pointer and sets the contents of the Evas_Coords pointed
924 * to by @p x and @p y to contain these co-ordinates. If @p e is not a
925 * valid canvas the results of this function are undefined.
930 * Evas_Coord mouse_x, mouse_y;
932 * evas_pointer_output_xy_get(evas, &mouse_x, &mouse_y);
933 * printf("Mouse is at canvas position %f, %f\n", mouse_x, mouse_y);
937 evas_pointer_canvas_xy_get(const Evas *e, Evas_Coord *x, Evas_Coord *y)
939 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
944 if (x) *x = e->pointer.x;
945 if (y) *y = e->pointer.y;
949 * Returns a bitmask with the mouse buttons currently pressed, set to 1
951 * @param e The pointer to the Evas Canvas
952 * @return A bitmask of the currently depressed buttons on the cavas
953 * @ingroup Evas_Pointer_Group
955 * Calling this function will return a 32-bit integer with the
956 * appropriate bits set to 1 that correspond to a mouse button being
957 * depressed. This limits Evas to a mouse devices with a maximum of 32
958 * buttons, but that is generally in excess of any host system's
959 * pointing device abilities.
961 * A canvas by default begins with no mouse buttons being pressed and
962 * only calls to evas_event_feed_mouse_down(),
963 * evas_event_feed_mouse_down_data(), evas_event_feed_mouse_up() and
964 * evas_event_feed_mouse_up_data() will alter that.
966 * The least significant bit corresponds to the first mouse button
967 * (button 1) and the most significant bit corresponds to the last
968 * mouse button (button 32).
970 * If @p e is not a valid canvas, the return value is undefined.
975 * int button_mask, i;
977 * button_mask = evas_pointer_button_down_mask_get(evas);
978 * printf("Buttons currently pressed:\n");
979 * for (i = 0; i < 32; i++)
981 * if ((button_mask & (1 << i)) != 0) printf("Button %i\n", i + 1);
986 evas_pointer_button_down_mask_get(const Evas *e)
988 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
991 return (int)e->pointer.button;
995 * Returns whether the mouse pointer is logically inside the canvas
997 * @param e The pointer to the Evas Canvas
998 * @return An integer that is 1 if the mouse is inside the canvas, 0 otherwise
999 * @ingroup Evas_Pointer_Group
1001 * When this function is called it will return a value of either 0 or
1002 * 1, depending on if evas_event_feed_mouse_in(),
1003 * evas_event_feed_mouse_in_data(), or evas_event_feed_mouse_out(),
1004 * evas_event_feed_mouse_out_data() have been called to feed in a
1005 * mouse enter event into the canvas.
1007 * A return value of 1 indicates the mouse is logically inside the
1008 * canvas, and 0 implies it is logically outside the canvas.
1010 * A canvas begins with the mouse being assumed outside (0).
1012 * If @p e is not a valid canvas, the return value is undefined.
1016 * extern Evas *evas;
1018 * if (evas_pointer_inside_get(evas)) printf("Mouse is in!\n");
1019 * else printf("Mouse is out!\n");
1023 evas_pointer_inside_get(const Evas *e)
1025 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1028 return (int)e->pointer.inside;
1032 * Attaches a specific pointer to the evas for fetching later
1034 * @param e The canvas to attach the pointer to
1035 * @param data The pointer to attach
1036 * @ingroup Evas_Canvas
1039 evas_data_attach_set(Evas *e, void *data)
1041 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1044 e->attach_data = data;
1048 * Returns the pointer attached by evas_data_attach_set()
1050 * @param e The canvas to attach the pointer to
1051 * @return The pointer attached
1052 * @ingroup Evas_Canvas
1055 evas_data_attach_get(const Evas *e)
1057 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1060 return e->attach_data;
1064 * Inform to the evas that it got the focus.
1066 * @param e The evas to change information.
1067 * @ingroup Evas_Canvas
1070 evas_focus_in(Evas *e)
1072 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1075 if (e->focus) return;
1077 evas_event_callback_call(e, EVAS_CALLBACK_CANVAS_FOCUS_IN, NULL);
1081 * Inform to the evas that it lost the focus.
1083 * @param e The evas to change information.
1084 * @ingroup Evas_Canvas
1087 evas_focus_out(Evas *e)
1089 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1092 if (!e->focus) return;
1094 evas_event_callback_call(e, EVAS_CALLBACK_CANVAS_FOCUS_OUT, NULL);
1098 * Get the focus state known by the given evas
1100 * @param e The evas to query information.
1101 * @ingroup Evas_Canvas
1104 evas_focus_state_get(const Evas *e)
1106 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1119 _evas_unwalk(Evas *e)
1122 if ((e->walking_list == 0) && (e->delete_me)) evas_free(e);
1126 * Converts the given error code into a string describing it in english.
1127 * @param error the error code.
1128 * @return Always return a valid string. If given @p error is not
1129 * supported "Unknown error" is returned.
1130 * @ingroup Evas_Utils
1133 evas_load_error_str(int error)
1137 case EVAS_LOAD_ERROR_NONE:
1138 return "No error on load";
1139 case EVAS_LOAD_ERROR_GENERIC:
1140 return "A non-specific error occured";
1141 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
1142 return "File (or file path) does not exist";
1143 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
1144 return "Permission deinied to an existing file (or path)";
1145 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
1146 return "Allocation of resources failure prevented load";
1147 case EVAS_LOAD_ERROR_CORRUPT_FILE:
1148 return "File corrupt (but was detected as a known format)";
1149 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
1150 return "File is not a known format";
1152 return "Unknown error";