ecore_event_handler_add() returning NULL

Technical | Application Development | Gaurav Kalra | 3 months | 8 Replies | 1,727 Views

*

Gaurav Kalra

ecore_event_handler_add() returning NULL
« On:August 21, 2015, 08:35:31 PM »
I am trying to monitor mouse events with a service application with the below code.
However, in service_app_create(), h_down & h_up is always NULL.
There are no API and Privilege Violations.

Do I require some special permission to monitor mouse events with a service application?

Code: [Select]
#include <tizen.h>
#include <service_app.h>
#include "gestures.h"

#include <Ecore.h>
#include <Ecore_Input.h>

static Eina_Bool
__mouse_down(void *data, int type, void *event_info)
{
Ecore_Event_Mouse_Button *ev = event_info;

dlog_print(DLOG_ERROR, LOG_TAG, "MOUSE DOWN");

dlog_print(DLOG_ERROR, LOG_TAG, "root.x: [%d] root.y: [%d] double_click: [%u] timestamp: [%u]",
ev->root.x, ev->root.y, ev->double_click, ev->timestamp);

return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
__mouse_up(void *data, int type, void *event_info)
{
Ecore_Event_Mouse_Button *ev = event_info;

dlog_print(DLOG_ERROR, LOG_TAG, "MOUSE UP");

dlog_print(DLOG_ERROR, LOG_TAG, "root.x: [%d] root.y: [%d] double_click: [%u] timestamp: [%u]",
ev->root.x, ev->root.y, ev->double_click, ev->timestamp);

return ECORE_CALLBACK_PASS_ON;
}

bool service_app_create(void *data)
{
Ecore_Event_Handler *h_down = NULL, *h_up = NULL;
    dlog_print(DLOG_ERROR, LOG_TAG, "service_app_create() called");

    h_down = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __mouse_down, NULL);
h_up = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, __mouse_up, NULL);

dlog_print(DLOG_ERROR, LOG_TAG, "h_up: [%p] h_down: [%p]",
h_up, h_down);

    return true;
}

void service_app_terminate(void *data)
{
dlog_print(DLOG_ERROR, LOG_TAG, "service_app_terminate() called");
    return;
}

void service_app_control(app_control_h app_control, void *data)
{
dlog_print(DLOG_ERROR, LOG_TAG, "service_app_control() called");
    return;
}

int main(int argc, char* argv[])
{
    service_app_lifecycle_callback_s event_callback;

event_callback.create = service_app_create;
event_callback.terminate = service_app_terminate;
event_callback.app_control = service_app_control;

return service_app_main(argc, argv, &event_callback, ad);
}



*

Praveen Chikkappaiah

  • **
  • 34
  • 305 Points
    • View Website
Re: ecore_event_handler_add() returning NULL
« Reply #1 On:August 24, 2015, 10:33:57 AM »
Hi Gaurav,
For service apps I guess you need to initalise the ecore explicitly.
Could you please modify your main like this:


int main(int argc, char* argv[])
{
    service_app_lifecycle_callback_s event_callback;

   event_callback.create = service_app_create;
   event_callback.terminate = service_app_terminate;
   event_callback.app_control = service_app_control;


        if (!ecore_init())
       {
          printf("ERROR: Cannot init Ecore!\n");
          return -1;
       }

   return service_app_main(argc, argv, &event_callback, ad);
}

*

EFL

  • **
  • 59
  • 1310 Points
Re: ecore_event_handler_add() returning NULL
« Reply #2 On:August 24, 2015, 10:36:57 AM »
Gaurav,


Your service app will not have a window. AFAIK, even though you are registering ecore events, input event types like mouse events get initialized only when ecore evas engine is initialized.


In a service app, only the Ecore main loop is created, so the ecore_event_handler_add recognizes only the ecore event types defined in this link : https://developer.tizen.org/dev-guide/2.3.0/org.tizen.native.mobile.apireference/group__Ecore__Event__Group.html


Rgds,
Poornima
« Last Edit: August 28, 2015, 02:25:10 PM by Poornima Srinivasan »

*

Gaurav Kalra

Re: ecore_event_handler_add() returning NULL
« Reply #3 On:August 27, 2015, 10:46:47 PM »
Hi Poornima, Praveen

Thank You for your suggestions.
I'll give them a test ride tomorrow at office.

--
gvk

*

Gaurav Kalra

Re: ecore_event_handler_add() returning NULL
« Reply #4 On:September 01, 2015, 11:03:40 AM »
Gaurav -
Did you try Praveen's suggestion? I think that calling ecore_evas_init()as compared to ecore_init() should solve your problem, as that initializes all the input event types.
Pls check and let us know.

Hello Poornima, Praveen

I tried both ecore_init() and ecore_evas_init(). However, I still get the handles as NULL.

This is my code:
Code: [Select]
static Eina_Bool
__mouse_down(void *data, int type, void *event_info)
{
Ecore_Event_Mouse_Button *ev = event_info;

dlog_print(DLOG_ERROR, LOG_TAG, "MOUSE DOWN");

dlog_print(DLOG_ERROR, LOG_TAG, "root.x: [%d] root.y: [%d] double_click: [%u] timestamp: [%u]",
ev->root.x, ev->root.y, ev->double_click, ev->timestamp);

return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
__mouse_up(void *data, int type, void *event_info)
{
Ecore_Event_Mouse_Button *ev = event_info;

dlog_print(DLOG_ERROR, LOG_TAG, "MOUSE UP");

dlog_print(DLOG_ERROR, LOG_TAG, "root.x: [%d] root.y: [%d] double_click: [%u] timestamp: [%u]",
ev->root.x, ev->root.y, ev->double_click, ev->timestamp);

return ECORE_CALLBACK_PASS_ON;
}

bool service_app_create(void *data)
{
Ecore_Event_Handler *h_down = NULL, *h_up = NULL;
    dlog_print(DLOG_ERROR, LOG_TAG, "service_app_create() called");

    h_down = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __mouse_down, NULL);
h_up = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, __mouse_up, NULL);

dlog_print(DLOG_ERROR, LOG_TAG, "h_up: [%p] h_down: [%p]",
h_up, h_down);

    return true;
}

void service_app_terminate(void *data)
{
dlog_print(DLOG_ERROR, LOG_TAG, "service_app_terminate() called");
    return;
}

void service_app_control(app_control_h app_control, void *data)
{
dlog_print(DLOG_ERROR, LOG_TAG, "service_app_control() called");
    return;
}

int main(int argc, char* argv[])
{
    service_app_lifecycle_callback_s event_callback;

event_callback.create = service_app_create;
event_callback.terminate = service_app_terminate;
event_callback.app_control = service_app_control;

if (ecore_init())
dlog_print(DLOG_ERROR, LOG_TAG, "ecore_init() success");

if (ecore_evas_init() > 0)
dlog_print(DLOG_ERROR, LOG_TAG, "ecore_evas_init() success");

return service_app_main(argc, argv, &event_callback, NULL);
}

The logs from emulator (please ignore ERROR as I have set the level of all logs to ERROR):
Code: [Select]
09-01 14:29:48.075 : ERROR / gestures ( 2790 : 2790 ) : ecore_init() success
09-01 14:29:48.075 : ERROR / gestures ( 2790 : 2790 ) : ecore_evas_init() success
09-01 14:29:48.075 : ERROR / gestures ( 2790 : 2790 ) : service_app_create() called
09-01 14:29:48.075 : ERROR / gestures ( 2790 : 2790 ) : h_up: [(nil)] h_down: [(nil)]
09-01 14:29:48.085 : ERROR / gestures ( 2790 : 2790 ) : service_app_control() called
09-01 14:29:52.215 : ERROR / gestures ( 2559 : 2559 ) : service_app_control() called

*

Gaurav Kalra

Re: ecore_event_handler_add() returning NULL
« Reply #5 On:September 06, 2015, 11:18:15 PM »
Anyone visiting this thread in future, this is not possible.

Explanation on application-dev mailing list: https://lists.tizen.org/pipermail/application-dev/2015-September/000758.html

*

Praveen Chikkappaiah

  • **
  • 34
  • 305 Points
    • View Website
Re: ecore_event_handler_add() returning NULL
« Reply #6 On:September 07, 2015, 10:07:32 AM »
Nice. Thanks Gaurav :)

*

vikasagrawal86

  • *
  • 5
  • 140 Points
  • I Love Tizen
Re: ecore_event_handler_add() returning NULL
« Reply #7 On:October 13, 2015, 10:37:36 AM »
Service App does not have a window so it can not take user inputs...
Handle will always be null....

Try creating a UI app with transparent window... then you can get inputs as well see the underlying apps.

*

Olivier Nyssen

  • ****
  • 334
  • 4490 Points
    • View Website
Re: ecore_event_handler_add() returning NULL
« Reply #8 On:October 13, 2015, 12:05:55 PM »
Anyone visiting this thread in future, this is not possible.

Explanation on application-dev mailing list: https://lists.tizen.org/pipermail/application-dev/2015-September/000758.html
post all app dev questions in the dev forum: https://developer.tizen.org/forums
the app dev mailing list will be terminated
« Last Edit: October 13, 2015, 12:07:38 PM by Olivier Nyssen »

Tags:
 


Facebook Comments