pepper_efl_comp_t *comp;
int loop_fd, socket_fd = -1;
const char *sock_name;
+ const char *default_seat = "seat0";
DBG("create compositor");
goto err_tbm;
}
- comp->input = pepper_efl_input_create(comp);
+ comp->input = pepper_efl_input_create(comp, default_seat);
if (!comp->input)
{
ERR("failed to init input");
#include <pepper-xkb.h>
#include <pepper-input-backend.h>
-static Eina_List *_handlers = NULL;
+struct pepper_efl_input
+{
+ pepper_efl_comp_t *comp;
+
+ pepper_seat_t *seat;
+ pepper_input_device_t *device;
+ pepper_pointer_t *pointer;
+ pepper_keyboard_t *keyboard;
+ pepper_touch_t *touch;
+ pepper_xkb_t *xkb;
+
+ Eina_List *handlers;
+};
static Eina_Bool
_pepper_efl_input_cb_key_down(void *data, int ev_type EINA_UNUSED, Ecore_Event_Key *ev)
}
pepper_efl_input_t *
-pepper_efl_input_create(pepper_efl_comp_t *comp)
+pepper_efl_input_create(pepper_efl_comp_t *comp, const char *seat_name)
{
pepper_efl_input_t *input = NULL;
- const char *default_name = "seat0";
DBG("Create Input Device");
input = calloc(1, sizeof(*input));
-
if (!input)
{
ERR("failed to memory allocation");
- goto err_mem_alloc;
+ goto err_alloc;
}
- input->seat = pepper_compositor_add_seat(comp->pepper.comp, default_name);
+ input->seat = pepper_compositor_add_seat(comp->pepper.comp, seat_name);
if (!input->seat)
{
ERR("failed to add seat");
- goto err_add_seat;
+ goto err_seat;
}
/* create and add devices. */
if (!input->device)
{
ERR("failed to create input device");
- goto err_dev_create;
+ goto err_dev;
}
pepper_seat_add_input_device(input->seat, input->device);
if (input->xkb)
pepper_xkb_keyboard_set_keymap(input->xkb, input->keyboard, NULL);
- PE_LIST_HANDLER_APPEND(_handlers, ECORE_EVENT_KEY_DOWN, _pepper_efl_input_cb_key_down, input);
- PE_LIST_HANDLER_APPEND(_handlers, ECORE_EVENT_KEY_UP, _pepper_efl_input_cb_key_up, input);
+ PE_LIST_HANDLER_APPEND(input->handlers, ECORE_EVENT_KEY_DOWN, _pepper_efl_input_cb_key_down, input);
+ PE_LIST_HANDLER_APPEND(input->handlers, ECORE_EVENT_KEY_UP, _pepper_efl_input_cb_key_up, input);
return input;
-err_dev_create:
+err_dev:
pepper_seat_destroy(input->seat);
-
-err_add_seat:
+err_seat:
free(input);
-
-err_mem_alloc:
-
+err_alloc:
return NULL;
}
void
pepper_efl_input_destroy(pepper_efl_input_t *input)
{
- Eina_List *l, *ll;
Ecore_Event_Handler *hdl;
- EINA_LIST_FOREACH_SAFE(_handlers, l, ll, hdl)
- {
- if (input != ecore_event_handler_data_get(hdl)) continue;
-
- ecore_event_handler_del(hdl);
- _handlers = eina_list_remove(_handlers, hdl);
- }
+ EINA_LIST_FREE(input->handlers, hdl)
+ ecore_event_handler_del(hdl);
pepper_xkb_destroy(input->xkb);
pepper_seat_destroy(input->seat);
free(input);
}
+
+pepper_view_t *
+pepper_efl_input_keyboard_focus_view_get(pepper_efl_input_t *input)
+{
+ return pepper_keyboard_get_focus(input->keyboard);
+}
+
+void
+pepper_efl_input_keyboard_focus_view_set(pepper_efl_input_t *input, pepper_view_t *view)
+{
+ pepper_view_t *focused;
+
+ focused = pepper_keyboard_get_focus(input->keyboard);
+ if (focused == view)
+ {
+ // already focused view.
+ return;
+ }
+
+ if (focused)
+ {
+ // send leave message for pre-focused view.
+ pepper_keyboard_send_leave(input->keyboard, focused);
+ }
+
+ // replace focused view.
+ pepper_keyboard_set_focus(input->keyboard, view);
+
+ if (view)
+ {
+ // send enter message for newly focused view.
+ pepper_keyboard_send_enter(input->keyboard, view);
+ }
+}
+
+void
+pepper_efl_input_touch_down(pepper_efl_input_t *input, pepper_view_t *view, unsigned int timestamp, int device, int x, int y)
+{
+ pepper_touch_add_point(input->touch, device, x, y);
+ pepper_touch_send_down(input->touch, view, timestamp, device, x, y);
+}
+
+void
+pepper_efl_input_touch_up(pepper_efl_input_t *input, pepper_view_t *view, unsigned int timestamp, int device)
+{
+ pepper_touch_send_up(input->touch, view, timestamp, device);
+ pepper_touch_remove_point(input->touch, device);
+}
+
+void
+pepper_efl_input_touch_move(pepper_efl_input_t *input, pepper_view_t *view, unsigned int timestamp, int device, int x, int y)
+{
+ /* NOTE
+ * We need to add point here to send motion event before touch down.
+ * if do not, client doesn't know the position where touch down occur.
+ * This is how EFL translate touch event for now.
+ * I have no idea the other toolkit also does...
+ * if there already exist point, the API, pepper_touch_add_point has no effect.
+ * point will be removed when touch up or cancel is happen.
+ */
+ pepper_touch_add_point(input->touch, device, x, y);
+ pepper_touch_send_motion(input->touch, view, timestamp, device, x, y);
+}
+
+void
+pepper_efl_input_touch_cancel(pepper_efl_input_t *input, pepper_view_t *view)
+{
+ pepper_touch_send_cancel(input->touch, view);
+ pepper_touch_remove_point(input->touch, 0);
+}
+++ /dev/null
-#ifndef _PEPPER_EFL_INPUT_H_
-#define _PEPPER_EFL_INPUT_H_
-
-typedef struct pepper_efl_input pepper_efl_input_t;
-
-struct pepper_efl_input
-{
- pepper_efl_comp_t *comp;
-
- pepper_seat_t *seat;
- pepper_input_device_t *device;
- pepper_pointer_t *pointer;
- pepper_keyboard_t *keyboard;
- pepper_touch_t *touch;
- pepper_xkb_t *xkb;
-
- char *name;
-};
-
-pepper_efl_input_t *pepper_efl_input_create(pepper_efl_comp_t *comp);
-void pepper_efl_input_destroy(pepper_efl_input_t *seat);
-#endif
if (!view)
return;
- pepper_touch_add_point(po->input.touch, device, rel_x, rel_y);
- pepper_touch_send_down(po->input.touch, view, timestamp, device, rel_x, rel_y);
+ pepper_efl_input_touch_down(po->input, view, timestamp, device, rel_x, rel_y);
}
static void
if (!view)
return;
- pepper_touch_send_up(po->input.touch, view, timestamp, device);
- pepper_touch_remove_point(po->input.touch, device);
+ pepper_efl_input_touch_up(po->input, view, timestamp, device);
}
static void
if ((!_need_send_motion) && (!_need_send_released))
return;
- /* NOTE
- * We need to add point here to send motion event before touch down.
- * if do not, client doesn't know the position where touch down occur.
- * This is how EFL translate touch event for now.
- * I have no idea the other toolkit also does...
- * if there already exist point, the API, pepper_touch_add_point has no effect.
- * point will be removed when touch up or cancel is happen.
- */
- pepper_touch_add_point(po->input.touch, device, rel_x, rel_y);
- pepper_touch_send_motion(po->input.touch, view, timestamp, device, rel_x, rel_y);
+ pepper_efl_input_touch_move(po->input, view, timestamp, device, rel_x, rel_y);
}
static void
_pepper_efl_object_evas_cb_focus_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
pepper_efl_object_t *po;
- pepper_view_t *view, *focused_view;
+ pepper_view_t *view;
po = data;
DBG("[OBJECT] Focus In: obj %p", obj);
- focused_view = pepper_keyboard_get_focus(po->input.kbd);
-
- if (view == focused_view)
- {
- // already focused view.
- return;
- }
-
- if (focused_view)
- {
- // send leave message for pre-focused view.
- pepper_keyboard_send_leave(po->input.kbd, focused_view);
- }
-
- // replace focused view.
- pepper_keyboard_set_focus(po->input.kbd, view);
- // send enter message for newly focused view.
- pepper_keyboard_send_enter(po->input.kbd, view);
+ pepper_efl_input_keyboard_focus_view_set(po->input, view);
}
static void
DBG("[OBJECT] Focus Out: obj %p", obj);
- focused_view = pepper_keyboard_get_focus(po->input.kbd);
+ focused_view = pepper_efl_input_keyboard_focus_view_get(po->input);
if ((!focused_view) || (view != focused_view))
{
// I expect that already sends 'leave' message to this view,
return;
}
- // send leave message for pre-focused view.
- pepper_keyboard_send_leave(po->input.kbd, focused_view);
- // unset focus view.
- pepper_keyboard_set_focus(po->input.kbd, NULL);
+ pepper_efl_input_keyboard_focus_view_set(po->input, NULL);
}
static void
if (!po)
return NULL;
- po->input.ptr = output->comp->input->pointer;
- po->input.kbd = output->comp->input->keyboard;
- po->input.touch = output->comp->input->touch;
+ po->input = output->comp->input;
po->evas = evas;
po->parent = output->win;
po->surface = surface;
if ((_mouse_in_po) && (_need_send_released))
{
- pepper_touch_send_cancel(po->input.touch, view);
- pepper_touch_remove_point(po->input.touch, 0);
+ pepper_efl_input_touch_cancel(po->input, view);
_need_send_released = EINA_FALSE;
_need_send_motion = EINA_FALSE;
}
tbm_surface_h tbm_surface;
int x, y, w, h;
- struct
- {
- pepper_pointer_t *ptr;
- pepper_keyboard_t *kbd;
- pepper_touch_t *touch;
- } input;
+ pepper_efl_input_t *input;
};
Evas_Object *pepper_efl_object_get(pepper_efl_output_t *output, pepper_surface_t *surface);
#include <wayland-server.h>
#include <wayland-tbm-server.h>
-typedef struct pepper_efl_comp pepper_efl_comp_t;
+typedef struct pepper_efl_comp pepper_efl_comp_t;
typedef struct pepper_efl_output pepper_efl_output_t;
+typedef struct pepper_efl_input pepper_efl_input_t;
#include "Pepper_Efl.h"
#include "log.h"
#include "output.h"
-#include "input.h"
#include "shell.h"
#include "object.h"
# define PE_CHECK_RET(x, ret) EINA_SAFETY_ON_NULL_RETURN_VAL(x, ret)
#endif
+pepper_efl_input_t *pepper_efl_input_create(pepper_efl_comp_t *comp, const char *seat_name);
+void pepper_efl_input_destroy(pepper_efl_input_t *seat);
+pepper_view_t *pepper_efl_input_keyboard_focus_view_get(pepper_efl_input_t *input);
+void pepper_efl_input_keyboard_focus_view_set(pepper_efl_input_t *input, pepper_view_t *view);
+void pepper_efl_input_touch_down(pepper_efl_input_t *input, pepper_view_t *view, unsigned int timestamp, int device, int x, int y);
+void pepper_efl_input_touch_up(pepper_efl_input_t *input, pepper_view_t *view, unsigned int timestamp, int device);
+void pepper_efl_input_touch_move(pepper_efl_input_t *input, pepper_view_t *view, unsigned int timestamp, int device, int x, int y);
+void pepper_efl_input_touch_cancel(pepper_efl_input_t *input, pepper_view_t *view);
+
Eina_Bool tizen_policy_init(pepper_efl_comp_t *comp);
void tizen_policy_shutdown(pepper_efl_comp_t *comp);