enlightenment/src/bin/e_bg.c

533 lines
16 KiB
C
Raw Normal View History

#include "e.h"
/* local subsystem functions */
static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _e_bg_event_bg_update_free(void *data, void *event);
static void e_bg_handler_set(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *path);
static int e_bg_handler_test(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *path);
static void _e_bg_handler_image_imported(const char *image_path, void *data);
/* local subsystem globals */
E_API int E_EVENT_BG_UPDATE = 0;
static E_Fm2_Mime_Handler *bg_hdl = NULL;
/* externally accessible functions */
EINTERN int
2006-10-17 05:29:00 -07:00
e_bg_init(void)
{
Eina_List *l = NULL;
E_Config_Desktop_Background *cfbg = NULL;
2006-10-17 05:29:00 -07:00
/* Register mime handler */
bg_hdl = e_fm2_mime_handler_new(_("Set As Background"),
2012-07-09 04:50:08 -07:00
"preferences-desktop-wallpaper",
e_bg_handler_set, NULL,
e_bg_handler_test, NULL);
if (bg_hdl)
{
2012-07-09 04:50:08 -07:00
e_fm2_mime_handler_glob_add(bg_hdl, "*.edj");
e_fm2_mime_handler_mime_add(bg_hdl, "image/png");
e_fm2_mime_handler_mime_add(bg_hdl, "image/jpeg");
}
2006-10-17 05:29:00 -07:00
/* Register files in use */
if (e_config->desktop_default_background)
e_filereg_register(e_config->desktop_default_background);
2006-10-17 05:29:00 -07:00
EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
2006-10-17 05:29:00 -07:00
{
2012-07-09 04:50:08 -07:00
if (!cfbg) continue;
e_filereg_register(cfbg->file);
2006-10-17 05:29:00 -07:00
}
E_EVENT_BG_UPDATE = ecore_event_type_new();
2006-10-17 05:29:00 -07:00
return 1;
}
EINTERN int
2006-10-17 05:29:00 -07:00
e_bg_shutdown(void)
{
Eina_List *l = NULL;
E_Config_Desktop_Background *cfbg = NULL;
2006-10-17 05:29:00 -07:00
/* Deregister mime handler */
if (bg_hdl)
{
2012-07-09 04:50:08 -07:00
e_fm2_mime_handler_glob_del(bg_hdl, "*.edj");
e_fm2_mime_handler_free(bg_hdl);
}
/* Deregister files in use */
2006-10-17 05:29:00 -07:00
if (e_config->desktop_default_background)
e_filereg_deregister(e_config->desktop_default_background);
2006-10-17 05:29:00 -07:00
EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
2006-10-17 05:29:00 -07:00
{
2012-07-09 04:50:08 -07:00
if (!cfbg) continue;
e_filereg_deregister(cfbg->file);
2006-10-17 05:29:00 -07:00
}
return 1;
}
/**
* Find the configuration for a given desktop background
* Use -1 as a wild card for each parameter.
* The most specific match will be returned
*/
E_API const E_Config_Desktop_Background *
e_bg_config_get(int zone_num, int desk_x, int desk_y)
{
Eina_List *l, *entries;
E_Config_Desktop_Background *bg = NULL, *cfbg = NULL;
const char *bgfile = "";
char *entry;
int current_spec = 0; /* how specific the setting is - we want the least general one that applies */
/* look for desk specific background. */
if (zone_num >= 0 || desk_x >= 0 || desk_y >= 0)
{
2012-07-09 04:50:08 -07:00
EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
{
int spec;
if (!cfbg) continue;
spec = 0;
if (cfbg->zone == zone_num) spec++;
else if (cfbg->zone >= 0)
continue;
if (cfbg->desk_x == desk_x) spec++;
else if (cfbg->desk_x >= 0)
continue;
if (cfbg->desk_y == desk_y) spec++;
else if (cfbg->desk_y >= 0)
continue;
if (spec <= current_spec) continue;
bgfile = cfbg->file;
if (bgfile)
{
if (bgfile[0] != '/')
{
const char *bf;
bf = e_path_find(path_backgrounds, bgfile);
if (bf) bgfile = bf;
}
}
if (eina_str_has_extension(bgfile, ".edj"))
{
entries = edje_file_collection_list(bgfile);
EINA_LIST_FREE(entries, entry)
{
if (!strcmp(entry, "e/desktop/background"))
{
bg = cfbg;
current_spec = spec;
break;
}
eina_stringshare_del(entry);
}
E_FREE_LIST(entries, eina_stringshare_del);
}
else
{
bg = cfbg;
current_spec = spec;
}
2012-07-09 04:50:08 -07:00
}
}
return bg;
}
E_API Eina_Stringshare *
e_bg_file_get(int zone_num, int desk_x, int desk_y)
{
const E_Config_Desktop_Background *cfbg;
const char *bgfile = NULL;
int ok = 0;
cfbg = e_bg_config_get(zone_num, desk_x, desk_y);
/* fall back to default */
if (cfbg)
{
const char *bf;
2012-07-09 04:50:08 -07:00
bgfile = eina_stringshare_ref(cfbg->file);
if (!bgfile) return NULL;
if (bgfile[0] == '/') return bgfile;
bf = e_path_find(path_backgrounds, bgfile);
if (!bf) return bgfile;
eina_stringshare_del(bgfile);
return bf;
}
bgfile = e_config->desktop_default_background;
if (bgfile)
{
if (bgfile[0] != '/')
2012-07-09 04:50:08 -07:00
{
const char *bf;
2012-07-09 04:50:08 -07:00
bf = e_path_find(path_backgrounds, bgfile);
if (bf) bgfile = bf;
}
else
eina_stringshare_ref(bgfile);
}
if (bgfile && eina_str_has_extension(bgfile, ".edj"))
{
ok = edje_file_group_exists(bgfile, "e/desktop/background");
}
else if ((bgfile) && (bgfile[0]))
ok = 1;
if (!ok)
eina_stringshare_replace(&bgfile, e_theme_edje_file_get("base/theme/background",
"e/desktop/background"));
return bgfile;
}
E_API void
e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
{
Evas_Object *o;
const char *bgfile = "";
const char *trans = "";
E_Desk *desk;
if (transition == E_BG_TRANSITION_START) trans = e_config->transition_start;
2012-07-09 04:50:08 -07:00
else if (transition == E_BG_TRANSITION_DESK)
trans = e_config->transition_desk;
else if (transition == E_BG_TRANSITION_CHANGE)
trans = e_config->transition_change;
if ((!trans) || (!trans[0])) transition = E_BG_TRANSITION_NONE;
desk = e_desk_current_get(zone);
if (desk)
bgfile = e_bg_file_get(zone->num, desk->x, desk->y);
else
bgfile = e_bg_file_get(zone->num, -1, -1);
if (zone->bg_object)
{
const char *pfile = NULL;
2012-07-09 04:50:08 -07:00
edje_object_file_get(zone->bg_object, &pfile, NULL);
if (!pfile) e_icon_file_get(zone->bg_object, &pfile, NULL);
if (!pfile) pfile = e_video_file_get(zone->bg_object);
if (pfile)
{
if (!e_util_strcmp(pfile, bgfile)) goto end;
}
}
if (transition == E_BG_TRANSITION_NONE)
E_FREE_FUNC(zone->bg_object, evas_object_del);
else
{
2012-07-09 04:50:08 -07:00
char buf[4096];
if (zone->bg_object)
{
E_FREE_FUNC(zone->prev_bg_object, evas_object_del);
2012-07-09 04:50:08 -07:00
zone->prev_bg_object = zone->bg_object;
zone->bg_object = NULL;
E_FREE_FUNC(zone->transition_object, evas_object_del);
2012-07-09 04:50:08 -07:00
}
2015-03-13 14:44:24 -07:00
o = edje_object_add(e_comp->evas);
evas_object_repeat_events_set(o, 1);
2012-07-09 04:50:08 -07:00
zone->transition_object = o;
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
2014-01-14 17:19:12 -08:00
evas_object_name_set(zone->transition_object, "zone->transition_object");
2012-07-09 04:50:08 -07:00
/* FIXME: segv if zone is deleted while up??? */
evas_object_data_set(o, "e_zone", zone);
snprintf(buf, sizeof(buf), "e/transitions/%s", trans);
e_theme_edje_object_set(o, "base/theme/transitions", buf);
edje_object_preload(o, EINA_FALSE);
2012-07-09 04:50:08 -07:00
edje_object_signal_callback_add(o, "e,state,done", "*", _e_bg_signal, zone);
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
2014-01-14 17:19:12 -08:00
evas_object_move(o, zone->x, zone->y);
evas_object_resize(o, zone->w, zone->h);
evas_object_layer_set(o, E_LAYER_BG);
2012-07-09 04:50:08 -07:00
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_show(o);
}
if (eina_str_has_extension(bgfile, ".edj"))
{
2015-03-13 14:44:24 -07:00
o = edje_object_add(e_comp->evas);
edje_object_file_set(o, bgfile, "e/desktop/background");
edje_object_preload(o, EINA_FALSE);
if (edje_object_data_get(o, "noanimation"))
edje_object_animation_set(o, EINA_FALSE);
}
else if ((eina_str_has_extension(bgfile, ".gif")) ||
(eina_str_has_extension(bgfile, ".png")) ||
(eina_str_has_extension(bgfile, ".jpg")) ||
(eina_str_has_extension(bgfile, ".jpeg")) ||
(eina_str_has_extension(bgfile, ".bmp")))
{
2015-03-13 14:44:24 -07:00
o = e_icon_add(e_comp->evas);
2020-04-24 04:25:09 -07:00
if (!(eina_str_has_extension(bgfile, ".gif")))
e_icon_preload_set(o, EINA_TRUE);
e_icon_scale_size_set(o, 0);
e_icon_fill_inside_set(o, 0);
2020-04-24 04:21:18 -07:00
e_icon_file_key_set(o, bgfile, NULL);
}
else
{
o = e_video_add(e_comp->evas, bgfile, EINA_FALSE);
}
evas_object_data_set(o, "e_zone", zone);
evas_object_repeat_events_set(o, 1);
zone->bg_object = o;
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
2014-01-14 17:19:12 -08:00
evas_object_name_set(zone->bg_object, "zone->bg_object");
2007-10-30 21:18:20 -07:00
if (transition == E_BG_TRANSITION_NONE)
{
2012-07-09 04:50:08 -07:00
evas_object_move(o, zone->x, zone->y);
evas_object_resize(o, zone->w, zone->h);
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
2014-01-14 17:19:12 -08:00
evas_object_layer_set(o, E_LAYER_BG);
2007-10-30 21:18:20 -07:00
}
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_show(o);
if (transition != E_BG_TRANSITION_NONE)
{
2012-07-09 04:50:08 -07:00
edje_object_part_swallow(zone->transition_object, "e.swallow.bg.old",
zone->prev_bg_object);
edje_object_part_swallow(zone->transition_object, "e.swallow.bg.new",
zone->bg_object);
edje_object_signal_emit(zone->transition_object, "e,action,start", "e");
evas_object_name_set(zone->transition_object, "zone->transition_object");
evas_object_move(zone->transition_object, zone->x, zone->y);
evas_object_resize(zone->transition_object, zone->w, zone->h);
}
if (zone->bg_object) evas_object_name_set(zone->bg_object, "zone->bg_object");
if (zone->prev_bg_object) evas_object_name_set(zone->prev_bg_object, "zone->prev_bg_object");
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
2014-01-14 17:19:12 -08:00
e_comp_canvas_zone_update(zone);
end:
eina_stringshare_del(bgfile);
}
E_API void
e_bg_default_set(const char *file)
2006-10-17 05:29:00 -07:00
{
E_Event_Bg_Update *ev;
Eina_Bool changed;
file = eina_stringshare_add(file);
changed = file != e_config->desktop_default_background;
if (!changed)
{
2012-07-09 04:50:08 -07:00
eina_stringshare_del(file);
return;
}
if (e_config->desktop_default_background)
{
2012-07-09 04:50:08 -07:00
e_filereg_deregister(e_config->desktop_default_background);
eina_stringshare_del(e_config->desktop_default_background);
}
if (file)
{
2012-07-09 04:50:08 -07:00
e_filereg_register(file);
e_config->desktop_default_background = file;
}
else
e_config->desktop_default_background = NULL;
ev = E_NEW(E_Event_Bg_Update, 1);
ev->zone = -1;
ev->desk_x = -1;
ev->desk_y = -1;
ecore_event_add(E_EVENT_BG_UPDATE, ev, _e_bg_event_bg_update_free, NULL);
2006-10-17 05:29:00 -07:00
}
E_API void
e_bg_add(int zone, int desk_x, int desk_y, const char *file)
{
const Eina_List *l;
E_Config_Desktop_Background *cfbg;
E_Event_Bg_Update *ev;
file = eina_stringshare_add(file);
EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
{
2012-07-09 04:50:08 -07:00
if ((cfbg) &&
(cfbg->zone == zone) &&
(cfbg->desk_x == desk_x) &&
(cfbg->desk_y == desk_y) &&
(cfbg->file == file))
{
eina_stringshare_del(file);
return;
}
}
e_bg_del(zone, desk_x, desk_y);
cfbg = E_NEW(E_Config_Desktop_Background, 1);
cfbg->zone = zone;
cfbg->desk_x = desk_x;
cfbg->desk_y = desk_y;
cfbg->file = file;
e_config->desktop_backgrounds = eina_list_append(e_config->desktop_backgrounds, cfbg);
2006-10-17 05:29:00 -07:00
e_filereg_register(cfbg->file);
ev = E_NEW(E_Event_Bg_Update, 1);
ev->zone = zone;
ev->desk_x = desk_x;
ev->desk_y = desk_y;
ecore_event_add(E_EVENT_BG_UPDATE, ev, _e_bg_event_bg_update_free, NULL);
}
E_API void
e_bg_del(int zone, int desk_x, int desk_y)
{
Eina_List *l;
E_Config_Desktop_Background *cfbg;
E_Event_Bg_Update *ev;
EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
{
2012-07-09 04:50:08 -07:00
if (!cfbg) continue;
if ((cfbg->zone == zone) && (cfbg->desk_x == desk_x) && (cfbg->desk_y == desk_y))
2012-07-09 04:50:08 -07:00
{
e_config->desktop_backgrounds = eina_list_remove_list(e_config->desktop_backgrounds, l);
e_filereg_deregister(cfbg->file);
if (cfbg->file) eina_stringshare_del(cfbg->file);
free(cfbg);
break;
}
}
ev = E_NEW(E_Event_Bg_Update, 1);
ev->zone = zone;
ev->desk_x = desk_x;
ev->desk_y = desk_y;
ecore_event_add(E_EVENT_BG_UPDATE, ev, _e_bg_event_bg_update_free, NULL);
}
E_API void
e_bg_update(void)
{
const Eina_List *l;
E_Zone *zone;
2006-10-17 05:29:00 -07:00
EINA_LIST_FOREACH(e_comp->zones, l, zone)
e_zone_bg_reconfigure(zone);
}
/* local subsystem functions */
/**
* Set background to image, as required in e_fm2_mime_handler_new()
*/
static void
e_bg_handler_set(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *path)
{
char buf[4096];
int copy = 1;
if (!path) return;
if (!eina_str_has_extension(path, "edj"))
{
e_import_config_dialog_show(NULL, path, (Ecore_End_Cb)_e_bg_handler_image_imported, NULL);
return;
}
/* if not in system dir or user dir, copy to user dir */
e_prefix_data_concat_static(buf, "data/backgrounds");
if (!strncmp(buf, path, strlen(buf)))
copy = 0;
if (copy)
{
e_user_dir_concat_static(buf, "backgrounds");
if (!strncmp(buf, path, strlen(buf)))
2012-07-09 04:50:08 -07:00
copy = 0;
}
if (copy)
{
const char *file;
char *name;
file = ecore_file_file_get(path);
name = ecore_file_strip_ext(file);
e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s-%f.edj", name, ecore_time_unix_get());
free(name);
if (!ecore_file_exists(buf))
{
ecore_file_cp(path, buf);
e_bg_default_set(buf);
}
else
e_bg_default_set(path);
}
else
e_bg_default_set(path);
e_bg_update();
e_config_save_queue();
}
/**
* Test if possible to set background to file, as required in
* e_fm2_mime_handler_new()
*
* This handler tests for files that would be acceptable for setting
* background.
*
* You should just register it with "*.edj" (glob matching extension)
* or "image/" (mimetypes)that are acceptable with Evas loaders.
*
* Just edje files with "e/desktop/background" group are used.
*/
static int
e_bg_handler_test(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *path)
{
if (!path) return 0;
if (eina_str_has_extension(path, "edj"))
{
2012-07-09 04:50:08 -07:00
if (edje_file_group_exists(path, "e/desktop/background")) return 1;
return 0;
}
/* it's image/png or image/jpeg, we'll import it. */
return 1;
}
static void
_e_bg_signal(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
{
E_Zone *zone = data;
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
2014-01-14 17:19:12 -08:00
E_FREE_FUNC(zone->prev_bg_object, evas_object_del);
E_FREE_FUNC(zone->transition_object, evas_object_del);
e_comp_canvas_zone_update(zone);
evas_object_move(zone->bg_object, zone->x, zone->y);
evas_object_resize(zone->bg_object, zone->w, zone->h);
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
2014-01-14 17:19:12 -08:00
evas_object_layer_set(zone->bg_object, E_LAYER_BG);
evas_object_clip_set(zone->bg_object, zone->bg_clip_object);
evas_object_show(zone->bg_object);
}
2006-10-17 05:29:00 -07:00
static void
_e_bg_event_bg_update_free(void *data EINA_UNUSED, void *event)
{
free(event);
}
Larger backgrounds can now be set to scroll whenever a E changes between desks. Kind of like a transition, but uses only one (the first desk's), larger wallpaper instead of several wallpapers for all desks, and it overrides the transition settings if activated. The option can currently be activated from Virtual Desktops Settings -> Advanced. A better home and preview would be better for these settings. In more detail, this option can make a wallpaper, larger than the geometry of the zone, scroll appropriately with each desk change. Consider a nice panorama picture, which is as wide as the total desks' width. Then, at most, E will scroll the background by 1 / (number of desks) for each desk change. The direction of the scrolling is dependent on the desk change itself. Also, the user can specify a coefficient of maximum scrolling for each axis. If the coefficient is 0, the wallpaper will not move. More advanced animations can be constructed with edje. The data item "directional_freedom" "(1|0) (1|0)" can toggle the actual wallpaper scrolling done by E for each axis. A message with the current x/y position, panning w|h, and zone w|h is sent to the background edje with each desk change animation tick. An example embryo script that handles the message, and changes a hypothetical "a1" part in the "e/desktop/background" group is shown below: public message(Msg_Type:type, id, ...) { if (type == MSG_INT_SET) { new x = getarg(2); new y = getarg(3); // new max_x = getarg(4); // new max_y = getarg(5); // new w = getarg(6); // new h = getarg(7); custom_state(PART:"a1", "default", 0.0); set_state_val(PART:"a1", STATE_FILL_POS, 0.0, 0.0, -x / 4, -y / 4); set_state(PART:"a1", "custom", 0.0); } } SVN revision: 40543
2009-05-07 11:39:55 -07:00
static void
_e_bg_handler_image_imported(const char *image_path, void *data EINA_UNUSED)
{
e_bg_default_set(image_path);
e_bg_update();
e_config_save_queue();
}
2012-07-09 04:50:08 -07:00