typedef struct _Ecore_Wl_Event_Window_Iconify_State_Change Ecore_Wl_Event_Window_Iconify_State_Change;
typedef struct _Ecore_Wl_Event_Effect Ecore_Wl_Event_Effect_Start;
typedef struct _Ecore_Wl_Event_Effect Ecore_Wl_Event_Effect_End;
+typedef struct _Ecore_Wl_Display Ecore_Wl_Display;
+typedef struct _Ecore_Wl_Event_Global Ecore_Wl_Event_Global;
+typedef struct _Ecore_Wl_Event_Keymap_Update Ecore_Wl_Event_Keymap_Update;
+
+struct _Ecore_Wl_Event_Global
+{
+ Ecore_Wl_Display *display;
+ Eina_Stringshare *interface;
+ unsigned int id, version;
+};
+
+struct _Ecore_Wl_Event_Keymap_Update
+{
+ Ecore_Wl_Input *input;
+ struct xkb_keymap *keymap;
+};
enum _Ecore_Wl_Window_Type
{
EAPI extern int ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE;
EAPI extern int ECORE_WL_EVENT_EFFECT_START;
EAPI extern int ECORE_WL_EVENT_EFFECT_END;
+EAPI extern int ECORE_WL_EVENT_GLOBAL_ADDED;
+EAPI extern int ECORE_WL_EVENT_GLOBAL_REMOVED;
+EAPI extern int ECORE_WL_EVENT_KEYMAP_UPDATE;
/**
* @defgroup Ecore_Wl_Init_Group Wayland Library Init and Shutdown Functions
EAPI int ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE = 0;
EAPI int ECORE_WL_EVENT_EFFECT_START = 0;
EAPI int ECORE_WL_EVENT_EFFECT_END = 0;
+EAPI int ECORE_WL_EVENT_GLOBAL_ADDED = 0;
+EAPI int ECORE_WL_EVENT_GLOBAL_REMOVED = 0;
+EAPI int ECORE_WL_EVENT_KEYMAP_UPDATE = 0;
static void
_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE = ecore_event_type_new();
ECORE_WL_EVENT_EFFECT_START = ecore_event_type_new();
ECORE_WL_EVENT_EFFECT_END = ecore_event_type_new();
+ ECORE_WL_EVENT_GLOBAL_ADDED = ecore_event_type_new();
+ ECORE_WL_EVENT_GLOBAL_REMOVED = ecore_event_type_new();
+ ECORE_WL_EVENT_KEYMAP_UPDATE = ecore_event_type_new();
}
if (!(_ecore_wl_disp = calloc(1, sizeof(Ecore_Wl_Display))))
}
static void
+_cb_global_event_free(void *data EINA_UNUSED, void *event)
+{
+ Ecore_Wl_Event_Global *ev;
+
+ ev = event;
+ eina_stringshare_del(ev->interface);
+ free(ev);
+}
+
+static void
_ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version)
{
Ecore_Wl_Display *ewd;
Ecore_Wl_Global *global;
+ Ecore_Wl_Event_Global *ev;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
}
+
+ /* allocate space for event structure */
+ ev = calloc(1, sizeof(Ecore_Wl_Event_Global));
+ if (!ev) return;
+
+ ev->id = id;
+ ev->display = ewd;
+ ev->version = version;
+ ev->interface = eina_stringshare_add(interface);
+
+ /* raise an event saying a new global has been added */
+ ecore_event_add(ECORE_WL_EVENT_GLOBAL_ADDED, ev,
+ _cb_global_event_free, NULL);
}
static void
{
Ecore_Wl_Display *ewd;
Ecore_Wl_Global *global;
+ Ecore_Wl_Event_Global *ev;
Eina_Inlist *tmp;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
EINA_INLIST_FOREACH_SAFE(ewd->globals, tmp, global)
{
if (global->id != id) continue;
+
+ /* allocate space for event structure */
+ ev = calloc(1, sizeof(Ecore_Wl_Event_Global));
+ if (!ev) return;
+
+ ev->id = id;
+ ev->display = ewd;
+ ev->version = global->version;
+ ev->interface = eina_stringshare_add(global->interface);
+
+ /* raise an event saying a global has been removed */
+ ecore_event_add(ECORE_WL_EVENT_GLOBAL_REMOVED, ev,
+ _cb_global_event_free, NULL);
+
ewd->globals =
eina_inlist_remove(ewd->globals, EINA_INLIST_GET(global));
free(global->interface);
static void _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state);
static void _ecore_wl_input_cb_pointer_axis(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int timestamp, unsigned int axis, wl_fixed_t value);
static void _ecore_wl_input_cb_pointer_frame(void *data, struct wl_callback *callback, unsigned int timestamp EINA_UNUSED);
+static Eina_Bool _ecore_wl_input_keymap_update_send(Ecore_Wl_Input *input);
static void _ecore_wl_input_cb_keyboard_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int format, int fd, unsigned int size);
static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface, struct wl_array *keys EINA_UNUSED);
static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface);
}
}
+static Eina_Bool
+_ecore_wl_input_keymap_update_send(Ecore_Wl_Input *input)
+{
+ Ecore_Wl_Event_Keymap_Update *ev = NULL;
+
+ if (!input || !(input->xkb.keymap)) return EINA_FALSE;
+
+ /* allocate space for event structure */
+ ev = calloc(1, sizeof(Ecore_Wl_Event_Keymap_Update));
+ if (!ev) return EINA_FALSE;
+
+ ev->input = input;
+ ev->keymap = input->xkb.keymap;
+
+ /* raise an event saying the keymap has been updated */
+ ecore_event_add(ECORE_WL_EVENT_KEYMAP_UPDATE, ev, NULL, NULL);
+
+ return EINA_TRUE;
+}
+
static void
_ecore_wl_input_cb_keyboard_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int format, int fd, unsigned int size)
{
1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_CAPS);
input->xkb.altgr_mask =
1 << xkb_map_mod_get_index(input->xkb.keymap, "ISO_Level3_Shift");
+
+ if (!_ecore_wl_input_keymap_update_send(input))
+ {
+ xkb_map_unref(input->xkb.keymap);
+ input->xkb.keymap = NULL;
+ return;
+ }
}
static int