\hypertarget{evas-events_8c-example}{}\section{evas-\/events.\+c}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}
\textcolor{preprocessor}{#include "config.h"}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{#define PACKAGE\_EXAMPLES\_DIR "."}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}>}
\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <errno.h>}
\textcolor{preprocessor}{#include "evas-common.h"}

\textcolor{preprocessor}{#define WIDTH  (320)}
\textcolor{preprocessor}{#define HEIGHT (240)}

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *img\_path = PACKAGE\_EXAMPLES\_DIR EVAS\_IMAGE\_FOLDER \textcolor{stringliteral}{"/enlightenment.png"};

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *commands = \(\backslash\)
  \textcolor{stringliteral}{"commands are:\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)ta - toggle animation timer\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tc - cycle between focus and key grabs for key input\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)td - delete canvas callbacks\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tf - freeze input for 3 seconds\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tp - toggle precise point collision detection on image\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tControl + o - add an obscured rectangle\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)th - print help\(\backslash\)n"};

\textcolor{keyword}{struct }test\_data
\{
   Ecore\_Evas  *ee;
   \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *canvas;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *img, *bg;
   \hyperlink{group__Ecore__Timer__Group_gaf96ffb609956658ec038e54bd39f46f0}{Ecore\_Timer} *resize\_timer, *freeze\_timer;
   \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}    obscured, focus;
\};

\textcolor{keyword}{static} \textcolor{keyword}{struct }test\_data d = \{0\};

\textcolor{comment}{/* here to keep our example's window size and background image's}
\textcolor{comment}{ * size in synchrony */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_canvas\_resize\_cb(Ecore\_Evas *ee)
\{
   \textcolor{keywordtype}{int} w, h;

   \hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}(ee, NULL, NULL, &w, &h);
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(d.bg, w, h);
\}

\textcolor{comment}{/* called when our rectangle gets focus */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_object\_focus\_in\_cb(\textcolor{keywordtype}{void} *data EINA\_UNUSED,
                    \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e,
                    \textcolor{keywordtype}{void} *event\_info)
\{
   fprintf(stdout, \textcolor{stringliteral}{"An object got focused: %s\(\backslash\)n"},
           evas\_object\_name\_get(event\_info));

   fprintf(stdout, \textcolor{stringliteral}{"Let's recheck it: %s\(\backslash\)n"},
           evas\_object\_name\_get(\hyperlink{group__Evas__Object__Group__Find_gaf5a6ebc4c45f1297e816ff809e5d7d0c}{evas\_focus\_get}(e)));

   fprintf(stdout, \textcolor{stringliteral}{"And again: %s\(\backslash\)n"}, evas\_object\_focus\_get(event\_info) ?
           \textcolor{stringliteral}{"OK!"} : \textcolor{stringliteral}{"Oops, something is bad."});
\}

\textcolor{comment}{/* render flush callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_render\_flush\_cb(\textcolor{keywordtype}{void} *data EINA\_UNUSED,
                 \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED,
                 \textcolor{keywordtype}{void} *event\_info EINA\_UNUSED)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Canvas is about to flush its rendering pipeline!\(\backslash\)n"});
\}

\textcolor{comment}{/* put some action in the canvas */}
\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_resize\_cb(\textcolor{keywordtype}{void} *data EINA\_UNUSED)
\{
   \textcolor{keywordtype}{int} w, h, cw, ch;

   \hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}(d.img, NULL, NULL, &w, &h);
   \hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}(d.ee, NULL, NULL, &cw, &ch);

   \textcolor{keywordflow}{if} (w < cw)
     \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(d.img, cw, ch);
   \textcolor{keywordflow}{else}
     \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(d.img, cw / 2, ch / 2);

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}; \textcolor{comment}{/* re-issue the timer */}
\}

\textcolor{comment}{/* let's have our events back */}
\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_thaw\_cb(\textcolor{keywordtype}{void} *data EINA\_UNUSED)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Canvas was frozen %d times, now thawing.\(\backslash\)n"},
           \hyperlink{group__Evas__Event__Feeding__Group_gaca66af7f9b72ddbd63104d59c1fdf894}{evas\_event\_freeze\_get}(d.canvas));
   \hyperlink{group__Evas__Event__Feeding__Group_ga376918c56c3dc588a059da7fe8629b70}{evas\_event\_thaw}(d.canvas);
   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}; \textcolor{comment}{/* do not re-issue the timer */}
\}

\textcolor{comment}{/* mouse enters the object's area */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_in(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
             \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *evas EINA\_UNUSED,
             \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED,
             \textcolor{keywordtype}{void}        *einfo EINA\_UNUSED)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Enlightenment logo has had the mouse in.\(\backslash\)n"});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_out(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
              \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *evas EINA\_UNUSED,
              \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED,
              \textcolor{keywordtype}{void}        *einfo EINA\_UNUSED)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Enlightenment logo has had the mouse out.\(\backslash\)n"});
\} \textcolor{comment}{/* mouse exits the object's area */}

\textcolor{comment}{/* examine the keys pressed */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_keydown(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
            \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *evas,
            \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED,
            \textcolor{keywordtype}{void}        *einfo)
\{
   \textcolor{keyword}{const} \hyperlink{Evas__Common_8h_a198d0b10861c1da456004688d3443e96}{Evas\_Modifier} *mods;
   \hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down} *ev = einfo;

   fprintf(stdout, \textcolor{stringliteral}{"We've got key input: %s\(\backslash\)n"}, ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key});
   fprintf(stdout, \textcolor{stringliteral}{"It actually came from %s\(\backslash\)n"}, d.focus ?
           \textcolor{stringliteral}{"focus"} : \textcolor{stringliteral}{"key grab"});

   \textcolor{keywordflow}{if} (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"h"}) == 0) \textcolor{comment}{/* print help */}
     \{
        puts(commands);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"a"}) == 0) \textcolor{comment}{/* toggle animation timer */}
     \{
        \textcolor{keywordflow}{if} (d.resize\_timer != NULL)
          \{
             fprintf(stdout, \textcolor{stringliteral}{"Stopping animation timer\(\backslash\)n"});
             \hyperlink{group__Ecore__Timer__Group_gaba2b599c7aabe3ab664dc3d47f62a33a}{ecore\_timer\_del}(d.resize\_timer);
             d.resize\_timer = NULL;
          \}
        \textcolor{keywordflow}{else}
          \{
             fprintf(stdout, \textcolor{stringliteral}{"Re-issuing animation timer\(\backslash\)n"});
             d.resize\_timer = \hyperlink{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}{ecore\_timer\_add}(2, \_resize\_cb, NULL);
          \}
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"c"}) == 0) \textcolor{comment}{/* cycle between focus and key}
\textcolor{comment}{                                       * grabs for key input */}
     \{
        \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} ret;
        \hyperlink{Evas__Common_8h_a111c7333a7d49e44698bd19dd5bc9059}{Evas\_Modifier\_Mask} mask =
          evas\_key\_modifier\_mask\_get(d.canvas, \textcolor{stringliteral}{"Control"});

        fprintf(stdout, \textcolor{stringliteral}{"Switching to %s for key input\(\backslash\)n"}, d.focus ?
                \textcolor{stringliteral}{"key grabs"} : \textcolor{stringliteral}{"focus"});

        \textcolor{keywordflow}{if} (d.focus)
          \{
             evas\_object\_focus\_set(d.bg, \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE});
             fprintf(stdout, \textcolor{stringliteral}{"Focused object is now %s\(\backslash\)n"},
                     \hyperlink{group__Evas__Object__Group__Find_gaf5a6ebc4c45f1297e816ff809e5d7d0c}{evas\_focus\_get}(d.canvas) ?
                     \textcolor{stringliteral}{"still valid! Something went wrong."} : \textcolor{stringliteral}{"none."});

             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"a"}, 0, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"c"}, 0, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"d"}, 0, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"f"}, 0, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"p"}, 0, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"o"}, mask, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
             ret = evas\_object\_key\_grab(d.bg, \textcolor{stringliteral}{"h"}, 0, 0, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
             \textcolor{keywordflow}{if} (!ret)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Something went wrong with key grabs.\(\backslash\)n"});
                  \textcolor{keywordflow}{goto} c\_end;
               \}
          \}
        \textcolor{keywordflow}{else} \textcolor{comment}{/* got here by key grabs */}
          \{
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"a"}, 0, 0);
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"c"}, 0, 0);
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"d"}, 0, 0);
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"f"}, 0, 0);
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"p"}, 0, 0);
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"o"}, mask, 0);
             evas\_object\_key\_ungrab(d.bg, \textcolor{stringliteral}{"h"}, 0, 0);

             evas\_object\_focus\_set(d.bg, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
          \}

c\_end:
        d.focus = !d.focus;

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"d"}) == 0) \textcolor{comment}{/* delete canvas' callbacks */}
     \{
        fprintf(stdout, \textcolor{stringliteral}{"Deleting canvas event callbacks\(\backslash\)n"});
        \hyperlink{group__Evas__Canvas__Events_ga48b6d066830a1350bd5c8770070cd3f9}{evas\_event\_callback\_del\_full}(evas, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa5a68e4f5dccdc18a393ef4a4773236c3}{EVAS\_CALLBACK\_RENDER\_FLUSH\_PRE},
                                     \_render\_flush\_cb, NULL);
        \hyperlink{group__Evas__Canvas__Events_ga48b6d066830a1350bd5c8770070cd3f9}{evas\_event\_callback\_del\_full}(
          evas, \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa7380ca16bf87762e96309473d3d306c5}{EVAS\_CALLBACK\_CANVAS\_OBJECT\_FOCUS\_IN},
          \_object\_focus\_in\_cb, NULL);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"f"}) == 0) \textcolor{comment}{/* freeze input for 3 seconds */}
     \{
        fprintf(stdout, \textcolor{stringliteral}{"Freezing input for 3 seconds\(\backslash\)n"});
        \hyperlink{group__Evas__Event__Feeding__Group_ga4f6046343eab8b062e5509d984100ec8}{evas\_event\_freeze}(evas);
        d.freeze\_timer = \hyperlink{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}{ecore\_timer\_add}(3, \_thaw\_cb, NULL);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"p"}) == 0) \textcolor{comment}{/* toggle precise point}
\textcolor{comment}{                                       * collision detection */}
     \{
        \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} precise = \hyperlink{group__Evas__Object__Group__Extras_ga4d2551c3265c013448f2b7cbb6bdf74d}{evas\_object\_precise\_is\_inside\_get}(d.
      img);

        fprintf(stdout, \textcolor{stringliteral}{"Toggling precise point collision detection %s on"}
                        \textcolor{stringliteral}{" Enlightenment logo\(\backslash\)n"}, precise ? \textcolor{stringliteral}{"off"} : \textcolor{stringliteral}{"on"});
        \hyperlink{group__Evas__Object__Group__Extras_ga9a344285f070ad36b899d8819e285579}{evas\_object\_precise\_is\_inside\_set}(d.img, !precise);

        \textcolor{keywordflow}{return};
     \}

   mods = evas\_key\_modifier\_get(evas);
   \textcolor{keywordflow}{if} (\hyperlink{group__Evas__Keys_ga6cc24a5ea4b39b84c7a3e617de3db261}{evas\_key\_modifier\_is\_set}(mods, \textcolor{stringliteral}{"Control"}) &&
       (strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"o"}) == 0)) \textcolor{comment}{/* add an obscured}
\textcolor{comment}{                                        * rectangle to the middle}
\textcolor{comment}{                                        * of the canvas */}
     \{
        fprintf(stdout, \textcolor{stringliteral}{"Toggling obscured rectangle on canvas\(\backslash\)n"});
        \textcolor{keywordflow}{if} (!d.obscured)
          \{
             \textcolor{keywordtype}{int} w, h;
             evas\_output\_viewport\_get(evas, NULL, NULL, &w, &h);
             \hyperlink{group__Evas__Canvas_ga163f9df9ba453f2f731c4bea12bb946b}{evas\_obscured\_rectangle\_add}(evas, w / 4, h / 4, w / 2, h / 2);
          \}
        \textcolor{keywordflow}{else}
          \{
             \textcolor{keywordtype}{int} w, h;
             \hyperlink{struct__Eina__Rectangle}{Eina\_Rectangle} *rect;
             \hyperlink{struct__Eina__List}{Eina\_List} *updates, *l;

             evas\_output\_viewport\_get(evas, NULL, NULL, &w, &h);
             \hyperlink{group__Evas__Canvas_ga6bd5caa330850f63f4e9d91271fefc62}{evas\_obscured\_clear}(evas);

             \textcolor{comment}{/* we have to flag a damage region here because}
\textcolor{comment}{              * evas\_obscured\_clear() doesn't change the canvas'}
\textcolor{comment}{              * state. we'd have to wait for an animation step, for}
\textcolor{comment}{              * example, to get the result, without it */}
             \hyperlink{group__Evas__Canvas_gab1482931249c640efb25453b54950a16}{evas\_damage\_rectangle\_add}(evas, 0, 0, w, h);

             updates = \hyperlink{group__Evas__Canvas_ga1867d9f5f97545418598496af93e4c71}{evas\_render\_updates}(evas);

             \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(updates, l, rect)
               \{
                  fprintf(stdout, \textcolor{stringliteral}{"Rectangle (%d, %d, %d, %d) on canvas got a"}
                                  \textcolor{stringliteral}{" rendering update.\(\backslash\)n"}, rect->\hyperlink{struct__Eina__Rectangle_a8358c0791dcf476432687510ca4e5d5c}{x}, rect->\hyperlink{struct__Eina__Rectangle_ae74dc834fb71a1f4cd9e3fe11dec3940}{y},
                          rect->\hyperlink{struct__Eina__Rectangle_af6a92d51ec25ee3464c81297ffc3a330}{w},
                          rect->\hyperlink{struct__Eina__Rectangle_a7570ed17f58fc94be997414a86130074}{h});
               \}
             \hyperlink{group__Evas__Canvas_ga038d98c7c13a86b6ba4de51f8aba3595}{evas\_render\_updates\_free}(updates);
          \}
        d.obscured = !d.obscured;
     \} \textcolor{comment}{/* end of obscured region command */}
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keywordtype}{int} err;

   \textcolor{keywordflow}{if} (!\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}())
     \textcolor{keywordflow}{return} EXIT\_FAILURE;

   \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   d.ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 10, 10, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!d.ee)
     \textcolor{keywordflow}{goto} \hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error};

   \hyperlink{group__Ecore__Evas__Group_gaac67f679c9027059a34519fbdea360df}{ecore\_evas\_callback\_resize\_set}(d.ee, \_canvas\_resize\_cb);
   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(d.ee);

   \textcolor{comment}{/* the canvas pointer, de facto */}
   d.canvas = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(d.ee);

   \hyperlink{group__Evas__Canvas__Events_gaf236cc76039a654de4df734f8875ba1a}{evas\_event\_callback\_add}(d.canvas, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa5a68e4f5dccdc18a393ef4a4773236c3}{EVAS\_CALLBACK\_RENDER\_FLUSH\_PRE},
                           \_render\_flush\_cb, NULL);
   \textcolor{keywordflow}{if} (\hyperlink{group__Evas__Main__Group_gacfae4f589c777003f58d51e502c52835}{evas\_alloc\_error}() != \hyperlink{Evas__Common_8h_a1adf9f604f763f2a8db12a484ca199cba22bbdd0a96a670bbddd6789f91921af8}{EVAS\_ALLOC\_ERROR\_NONE})
     \{
        fprintf(stderr, \textcolor{stringliteral}{"ERROR: Callback registering failed! Aborting.\(\backslash\)n"});
        \textcolor{keywordflow}{goto} panic;
     \}

   \hyperlink{group__Evas__Canvas__Events_gaf236cc76039a654de4df734f8875ba1a}{evas\_event\_callback\_add}(d.canvas, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa7380ca16bf87762e96309473d3d306c5}{EVAS\_CALLBACK\_CANVAS\_OBJECT\_FOCUS\_IN},
                           \_object\_focus\_in\_cb, NULL);
   \textcolor{keywordflow}{if} (\hyperlink{group__Evas__Main__Group_gacfae4f589c777003f58d51e502c52835}{evas\_alloc\_error}() != \hyperlink{Evas__Common_8h_a1adf9f604f763f2a8db12a484ca199cba22bbdd0a96a670bbddd6789f91921af8}{EVAS\_ALLOC\_ERROR\_NONE})
     \{
        fprintf(stderr, \textcolor{stringliteral}{"ERROR: Callback registering failed! Aborting.\(\backslash\)n"});
        \textcolor{keywordflow}{goto} panic;
     \} \textcolor{comment}{/* two canvas event callbacks */}

   d.bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(d.canvas);
   evas\_object\_name\_set(d.bg, \textcolor{stringliteral}{"our dear rectangle"});
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(d.bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(d.bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(d.bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(d.bg);

   evas\_object\_focus\_set(d.bg, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}); \textcolor{comment}{/* so we get input events */}
   d.focus = \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};

   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(
     d.bg, \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}, \_on\_keydown, NULL);
   \textcolor{keywordflow}{if} (\hyperlink{group__Evas__Main__Group_gacfae4f589c777003f58d51e502c52835}{evas\_alloc\_error}() != \hyperlink{Evas__Common_8h_a1adf9f604f763f2a8db12a484ca199cba22bbdd0a96a670bbddd6789f91921af8}{EVAS\_ALLOC\_ERROR\_NONE})
     \{
        fprintf(stderr, \textcolor{stringliteral}{"ERROR: Callback registering failed! Aborting.\(\backslash\)n"});
        \textcolor{keywordflow}{goto} panic;
     \}

   d.img = \hyperlink{group__Evas__Object__Image_ga0e8cb83d31d02bf583c75925b7cd14d7}{evas\_object\_image\_filled\_add}(d.canvas);
   \hyperlink{group__Evas__Object__Image_gac27fd0ceabe5f56607b7a86d71577df1}{evas\_object\_image\_file\_set}(d.img, img\_path, NULL);
   err = evas\_object\_image\_load\_error\_get(d.img);
   \textcolor{keywordflow}{if} (err != EVAS\_LOAD\_ERROR\_NONE)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"ERROR: Image loading failed! Aborting.\(\backslash\)n"});
        \textcolor{keywordflow}{goto} panic;
     \}
   \textcolor{keywordflow}{else}
     \{
        \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(d.img, 0, 0);
        \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(d.img, WIDTH, HEIGHT);
        \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(d.img);
        \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(
          d.img, \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa598c57bc146639618157159a319f11af}{EVAS\_CALLBACK\_MOUSE\_IN}, \_on\_mouse\_in, NULL);
        \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(
          d.img, \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa91aaa30a57047d0ee8a734e603751c25}{EVAS\_CALLBACK\_MOUSE\_OUT}, \_on\_mouse\_out, NULL);
     \}

   d.resize\_timer = \hyperlink{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}{ecore\_timer\_add}(2, \_resize\_cb, NULL);

   puts(commands);
   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(d.ee);
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \textcolor{keywordflow}{return} 0;

\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}:
   fprintf(stderr, \textcolor{stringliteral}{"you got to have at least one evas engine built and linked"}
                   \textcolor{stringliteral}{" up to ecore-evas for this example to run properly.\(\backslash\)n"});
panic:
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \textcolor{keywordflow}{return} -1;
\}
\end{DoxyCodeInclude}
 