You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
4.7 KiB

#include "e.h"
/* local subsystem functions */
static void _e_obj_dialog_free(E_Obj_Dialog *od);
static void _e_obj_dialog_cb_delete(E_Obj_Dialog *od, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
static void _e_obj_dialog_cb_close(void *data, Evas_Object *obj, const char *emission, const char *source);
/* local subsystem globals */
/* externally accessible functions */
static void
_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
{
Evas_Event_Key_Down *ev = event;
if (!strcmp(ev->key, "Escape") && data)
_e_obj_dialog_cb_delete(data, NULL, NULL, NULL);
}
static void
_focus_in_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
edje_object_signal_emit(data, "e,state,focused", "e");
}
static void
_focus_out_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
edje_object_signal_emit(data, "e,state,unfocused", "e");
}
E_API E_Obj_Dialog *
e_obj_dialog_new(char *title, char *class_name, char *class_class)
{
E_Obj_Dialog *od;
Evas_Object *o;
Eina_Bool kg;
Evas_Modifier_Mask mask;
od = E_OBJECT_ALLOC(E_Obj_Dialog, E_OBJ_DIALOG_TYPE, _e_obj_dialog_free);
if (!od) return NULL;
od->win = elm_win_add(NULL, NULL, ELM_WIN_DIALOG_BASIC);
if (!od->win)
{
free(od);
return NULL;
}
evas_object_event_callback_add(od->win, EVAS_CALLBACK_DEL, (Evas_Object_Event_Cb)_e_obj_dialog_cb_delete, od);
ecore_evas_name_class_set(e_win_ee_get(od->win), class_name, class_class);
elm_win_title_set(od->win, title);
o = edje_object_add(evas_object_evas_get(od->win));
elm_win_resize_object_add(od->win, o);
od->bg_object = o;
evas_object_smart_callback_add(od->win, "focus,in",
_focus_in_cb, od->bg_object);
evas_object_smart_callback_add(od->win, "focus,out",
_focus_out_cb, od->bg_object);
elm_win_center(od->win, 1, 1);
od->cb_delete = NULL;
mask = 0;
kg = evas_object_key_grab(o, "Escape", mask, ~mask, 0);
if (!kg)
fprintf(stderr, "ERROR: unable to redirect \"Escape\" key events to object %p.\n", o);
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN,
_key_down_cb, od);
return od;
}
E_API void
e_obj_dialog_cb_delete_set(E_Obj_Dialog *od, void (*func)(E_Obj_Dialog *od))
{
od->cb_delete = func;
}
E_API void
e_obj_dialog_icon_set(E_Obj_Dialog *od, char *icon)
{
E_OBJECT_CHECK(od);
E_OBJECT_TYPE_CHECK(od, E_OBJ_DIALOG_TYPE);
e_win_client_icon_set(od->win, icon);
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
9 years ago
}
E_API void
e_obj_dialog_show(E_Obj_Dialog *od)
{
Evas_Coord w, h, mw, mh;
const char *s;
E_OBJECT_CHECK(od);
E_OBJECT_TYPE_CHECK(od, E_OBJ_DIALOG_TYPE);
edje_object_size_min_get(od->bg_object, &mw, &mh);
edje_object_size_min_restricted_calc(od->bg_object, &mw, &mh, mw, mh);
evas_object_resize(od->bg_object, mw, mh);
evas_object_resize(od->win, mw, mh);
evas_object_size_hint_min_set(od->win, mw, mh);
edje_object_size_max_get(od->bg_object, &w, &h);
if ((w > 0) && (h > 0))
{
if (w < mw) w = mw;
if (h < mh) h = mh;
evas_object_size_hint_max_set(od->win, w, h);
}
s = edje_object_data_get(od->bg_object, "borderless");
if (s && (!strcmp(s, "1")))
elm_win_borderless_set(od->win, 1);
evas_object_show(od->win);
}
E_API void
e_obj_dialog_obj_part_text_set(E_Obj_Dialog *od, const char *part, const char *text)
{
E_OBJECT_CHECK(od);
E_OBJECT_TYPE_CHECK(od, E_OBJ_DIALOG_TYPE);
edje_object_part_text_set(od->bg_object, part, text);
}
E_API void
e_obj_dialog_obj_theme_set(E_Obj_Dialog *od, char *theme_cat, char *theme_obj)
{
E_OBJECT_CHECK(od);
E_OBJECT_TYPE_CHECK(od, E_OBJ_DIALOG_TYPE);
e_theme_edje_object_set(od->bg_object, theme_cat, theme_obj);
evas_object_move(od->bg_object, 0, 0);
evas_object_show(od->bg_object);
edje_object_signal_callback_add(od->bg_object, "e,action,close", "",
_e_obj_dialog_cb_close, od);
}
/* local subsystem functions */
static void
_e_obj_dialog_free(E_Obj_Dialog *od)
{
if (od->bg_object) evas_object_del(od->bg_object);
evas_object_del(od->win);
free(od);
}
static void
_e_obj_dialog_cb_delete(E_Obj_Dialog *od, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
if (od->cb_delete)
od->cb_delete(od);
e_object_del(E_OBJECT(od));
}
static void
_e_obj_dialog_cb_close(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
{
E_Obj_Dialog *od;
od = data;
if (od->cb_delete)
od->cb_delete(od);
e_util_defer_object_del(E_OBJECT(od));
}