forked from enlightenment/enlightenment
e/music-control: Close popup of when user click out or type a key
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 81995
This commit is contained in:
parent
aa8015cdef
commit
5d3cff7af8
|
@ -28,6 +28,9 @@ typedef struct _E_Music_Control_Instance
|
||||||
Evas_Object *gadget;
|
Evas_Object *gadget;
|
||||||
E_Gadcon_Popup *popup;
|
E_Gadcon_Popup *popup;
|
||||||
Evas_Object *content_popup;
|
Evas_Object *content_popup;
|
||||||
|
Ecore_X_Window win;
|
||||||
|
Ecore_Event_Handler *mouse_up;
|
||||||
|
Ecore_Event_Handler *key_down;
|
||||||
} E_Music_Control_Instance;
|
} E_Music_Control_Instance;
|
||||||
|
|
||||||
void music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
|
void music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||||
|
|
|
@ -56,6 +56,59 @@ _player_name_update(E_Music_Control_Instance *inst)
|
||||||
edje_object_message_send(inst->content_popup, EDJE_MESSAGE_STRING, 0, &msg);
|
edje_object_message_send(inst->content_popup, EDJE_MESSAGE_STRING, 0, &msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_popup_input_window_mouse_up_cb(void *data, int type __UNUSED__, void *event)
|
||||||
|
{
|
||||||
|
Ecore_Event_Mouse_Button *ev = event;
|
||||||
|
E_Music_Control_Instance *inst = data;
|
||||||
|
if (ev->window == inst->win)
|
||||||
|
music_control_popup_del(inst);
|
||||||
|
return ECORE_CALLBACK_PASS_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_popup_input_window_key_down_cb(void *data, int type __UNUSED__, void *event)
|
||||||
|
{
|
||||||
|
Ecore_Event_Key *ev = event;
|
||||||
|
E_Music_Control_Instance *inst = data;
|
||||||
|
if (ev->window == inst->win)
|
||||||
|
music_control_popup_del(inst);
|
||||||
|
return ECORE_CALLBACK_PASS_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_popup_input_window_create(E_Music_Control_Instance *inst)
|
||||||
|
{
|
||||||
|
Ecore_X_Window_Configure_Mask mask;
|
||||||
|
Ecore_X_Window popup_w;
|
||||||
|
E_Manager *man = e_manager_current_get();
|
||||||
|
|
||||||
|
inst->win = ecore_x_window_input_new(man->root, 0, 0, man->w, man->h);
|
||||||
|
mask = (ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE |
|
||||||
|
ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING);
|
||||||
|
popup_w = inst->popup->win->evas_win;
|
||||||
|
ecore_x_window_configure(inst->win, mask, 0, 0, 0, 0, 0, popup_w,
|
||||||
|
ECORE_X_WINDOW_STACK_BELOW);
|
||||||
|
ecore_x_window_show(inst->win);
|
||||||
|
|
||||||
|
inst->mouse_up =
|
||||||
|
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
|
||||||
|
_popup_input_window_mouse_up_cb, inst);
|
||||||
|
inst->key_down =
|
||||||
|
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
|
||||||
|
_popup_input_window_key_down_cb, inst);
|
||||||
|
e_grabinput_get(0, 0, inst->win);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_popup_input_window_destroy(E_Music_Control_Instance *inst)
|
||||||
|
{
|
||||||
|
e_grabinput_release(0, inst->win);
|
||||||
|
ecore_x_window_free(inst->win);
|
||||||
|
ecore_event_handler_del(inst->mouse_up);
|
||||||
|
ecore_event_handler_del(inst->key_down);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_popup_new(E_Music_Control_Instance *inst)
|
_popup_new(E_Music_Control_Instance *inst)
|
||||||
{
|
{
|
||||||
|
@ -74,12 +127,14 @@ _popup_new(E_Music_Control_Instance *inst)
|
||||||
_player_name_update(inst);
|
_player_name_update(inst);
|
||||||
_play_state_update(inst, EINA_TRUE);
|
_play_state_update(inst, EINA_TRUE);
|
||||||
e_gadcon_popup_show(inst->popup);
|
e_gadcon_popup_show(inst->popup);
|
||||||
|
_popup_input_window_create(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
music_control_popup_del(E_Music_Control_Instance *inst)
|
music_control_popup_del(E_Music_Control_Instance *inst)
|
||||||
{
|
{
|
||||||
e_gadcon_popup_hide(inst->popup);
|
e_gadcon_popup_hide(inst->popup);
|
||||||
|
_popup_input_window_destroy(inst);
|
||||||
e_object_del(E_OBJECT(inst->popup));
|
e_object_del(E_OBJECT(inst->popup));
|
||||||
inst->popup = NULL;
|
inst->popup = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue