From: Enlightenment S. <no-...@en...> - 2011-02-21 15:52:32
|
Log: comp-scale: added 'show windows from all desk' scale mode + right click brings window from other desk to the current Author: jeffdameth Date: 2011-02-21 07:52:24 -0800 (Mon, 21 Feb 2011) New Revision: 57216 Trac: http://trac.enlightenment.org/e/changeset/57216 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/module.desktop.in trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-02-21 15:46:23 UTC (rev 57215) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-02-21 15:52:24 UTC (rev 57216) @@ -1,89 +1,163 @@ images { - image: "module_icon.png" COMP; + image: "module_icon.png" COMP; } collections { - group - { - name: "icon"; - max: 24 24; - parts - { - part - { - name: "image"; - mouse_events: 0; - type: IMAGE; - description - { - state: "default" 0.0; - image.normal: "module_icon.png"; - } - } - } - } - group - { - name: "modules/scale/main"; - max: 128 128; - parts - { - part - { - name: "icon"; - mouse_events: 0; - type: IMAGE; - description - { - state: "default" 0.0; - aspect: 1.0 1.0; - aspect_preference: BOTH; - rel1.offset: 2 2; - rel2.offset: -3 -3; - image.normal: "module_icon.png"; - } - description - { - state: "bigger" 0.0; - inherit: "default" 0.0; - rel1.offset: -2 -2; - rel2.offset: 3 3; - } - } - part - { - name: "event"; - mouse_events: 1; - type: RECT; - description - { - state: "default" 0.0; - color: 255 255 255 0; - } - } - } - programs - { - program - { - name: "mouse_in"; - signal: "mouse,in"; - source: "event"; - action: STATE_SET "bigger" 0.0; - transition: LINEAR 0.1; - target: "icon"; - } - program - { - name: "mouse_out"; - signal: "mouse,out"; - source: "event"; - action: STATE_SET "default" 0.0; - transition: LINEAR 0.2; - target: "icon"; - } - } - } + group { + name: "icon"; + max: 128 128; + parts { + part { + name: "image"; + mouse_events: 0; + type: IMAGE; + description { + state: "default" 0.0; + image.normal: "module_icon.png"; + } + } + } + } + group { + name: "modules/scale/main"; + max: 128 128; + parts { + part { + name: "icon"; + mouse_events: 0; + type: IMAGE; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + rel1.offset: 2 2; + rel2.offset: -3 -3; + image.normal: "module_icon.png"; + } + description { + state: "bigger" 0.0; + inherit: "default" 0.0; + rel1.offset: -2 -2; + rel2.offset: 3 3; + } + } + part { + name: "event"; + mouse_events: 1; + type: RECT; + description { + state: "default" 0.0; + color: 255 255 255 0; + } + } + } + programs { + program { + name: "mouse_in"; + signal: "mouse,in"; + source: "event"; + action: STATE_SET "bigger" 0.0; + transition: LINEAR 0.1; + target: "icon"; + } + program { + name: "mouse_out"; + signal: "mouse,out"; + source: "event"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.2; + target: "icon"; + } + } + } + + group { + name: "modules/scale/win"; + + parts { + + part { + name: "e.swallow.win"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + color: 255 255 255 0; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + + } + description { + state: "focused" 0.0; + color: 255 255 255 80; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + } + } + + /* part { + * name: "icon"; + * mouse_events: 0; + * type: IMAGE; + * description { + * state: "default" 0.0; + * aspect: 1.0 1.0; + * aspect_preference: BOTH; + * rel1.relative; + * + * rel1.offset: 2 2; + * rel2.offset: -3 -3; + * image.normal: "module_icon.png"; + * } + * description { + * state: "bigger" 0.0; + * inherit: "default" 0.0; + * rel1.offset: -2 -2; + * rel2.offset: 3 3; + * } + * } */ + /* part { + * name: "event"; + * mouse_events: 1; + * type: RECT; + * description { + * state: "default" 0.0; + * color: 255 255 255 100; + * } + * } */ + } + programs { + program { + name: "mouse_in"; + signal: "mouse,in"; + source: "e"; + action: STATE_SET "focused" 0.0; + transition: SINUSOIDAL 0.3; + target: "e.swallow.win"; + } + program { + name: "mouse_out"; + signal: "mouse,out"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.4; + target: "e.swallow.win"; + } + } + + } } Modified: trunk/E-MODULES-EXTRA/comp-scale/module.desktop.in =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/module.desktop.in 2011-02-21 15:46:23 UTC (rev 57215) +++ trunk/E-MODULES-EXTRA/comp-scale/module.desktop.in 2011-02-21 15:52:24 UTC (rev 57216) @@ -2,6 +2,6 @@ Type=Link Name=Scale Windows Icon=e-module-skel -Comment=Not meant for users. Basis for building new ones. +Comment=Scale windows down to see them all. Side by side. #Several different types available here. NEED TO DOC THESE. X-Enlightenment-ModuleType=look Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-02-21 15:46:23 UTC (rev 57215) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-02-21 15:52:24 UTC (rev 57216) @@ -7,6 +7,11 @@ int tight; double duration; double spacing; + double desks_duration; + double desks_spacing; + int fade_popups; + int fade_desktop; + int fade_windows; }; @@ -38,7 +43,7 @@ cfd = e_config_dialog_new(con, D_("Scale Windows Module"), "Scale", "appearance/comp-scale", buf, 0, v, NULL); - e_dialog_resizable_set(cfd->dia, 1); + e_dialog_resizable_set(cfd->dia, 0); scale_conf->cfd = cfd; return cfd; } @@ -63,21 +68,33 @@ static void _fill_data(E_Config_Dialog_Data *cfdata) { - cfdata->tight = scale_conf->tight; - cfdata->grow = scale_conf->grow; - cfdata->duration = scale_conf->scale_duration; - cfdata->spacing = scale_conf->spacing; + cfdata->tight = scale_conf->tight; + cfdata->grow = scale_conf->grow; + cfdata->duration = scale_conf->scale_duration; + cfdata->spacing = scale_conf->spacing; + cfdata->desks_duration = scale_conf->desks_duration; + cfdata->desks_spacing = scale_conf->desks_spacing; + cfdata->fade_popups = scale_conf->fade_popups; + cfdata->fade_desktop = scale_conf->fade_desktop; + cfdata->fade_windows = scale_conf->fade_windows; + cfdata->fade_desktop = scale_conf->fade_desktop; } static void _cb_test(void *data, void *data2) { E_Config_Dialog_Data *cfdata = data; - + scale_conf->grow = cfdata->grow; scale_conf->tight = cfdata->tight; scale_conf->scale_duration = cfdata->duration; scale_conf->spacing = cfdata->spacing; + scale_conf->desks_duration = cfdata->desks_duration; + scale_conf->desks_spacing = cfdata->desks_spacing; + scale_conf->fade_popups = cfdata->fade_popups; + scale_conf->fade_desktop = cfdata->fade_desktop; + scale_conf->fade_windows = cfdata->fade_windows; + scale_conf->fade_desktop = cfdata->fade_desktop; scale_run(e_manager_current_get()); } @@ -85,35 +102,66 @@ static Evas_Object * _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) { - Evas_Object *o = NULL, *of = NULL, *ow = NULL; + Evas_Object *o, *of, *ow, *ot; + ot = e_widget_table_add(evas, 0); + o = e_widget_list_add(evas, 0, 0); + of = e_widget_framelist_add(evas, D_("Current Desktop"), 0); + ow = e_widget_label_add (evas, D_("Minimum space between windows")); + e_widget_framelist_object_append (of, ow); + ow = e_widget_slider_add (evas, 1, 0, D_("%1.0f"), 2.0, 64.0, + 1.0, 0, &(cfdata->spacing), NULL,100); + e_widget_framelist_object_append (of, ow); + + ow = e_widget_label_add (evas, D_("Scale duration")); + e_widget_framelist_object_append (of, ow); + ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.1, 3.0, + 0.01, 0, &(cfdata->duration), NULL,100); + e_widget_framelist_object_append (of, ow); + e_widget_list_object_append(o, of, 1, 1, 0.5); + of = e_widget_framelist_add(evas, D_("Layout Options"), 0); e_widget_framelist_content_align_set(of, 0.0, 0.0); ow = e_widget_check_add(evas, D_("Grow more!"), &(cfdata->grow)); e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, D_("Keep it tight!"), &(cfdata->tight)); e_widget_framelist_object_append(of, ow); + e_widget_list_object_append(o, of, 1, 1, 0.5); + e_widget_table_object_append(ot, o, 0, 0, 1, 1, 1, 1, 0, 0); + + o = e_widget_list_add(evas, 0, 0); + of = e_widget_framelist_add(evas, D_("Show All Desktops"), 0); ow = e_widget_label_add (evas, D_("Minimum space between windows")); e_widget_framelist_object_append (of, ow); ow = e_widget_slider_add (evas, 1, 0, D_("%1.0f"), 2.0, 64.0, - 1.0, 0, &(cfdata->spacing), NULL,100); + 1.0, 0, &(cfdata->desks_spacing), NULL,100); e_widget_framelist_object_append (of, ow); ow = e_widget_label_add (evas, D_("Scale duration")); e_widget_framelist_object_append (of, ow); ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.1, 3.0, - 0.01, 0, &(cfdata->duration), NULL,100); + 0.01, 0, &(cfdata->desks_duration), NULL,100); e_widget_framelist_object_append (of, ow); + ow = e_widget_check_add(evas, D_("Fade in windows"), &(cfdata->fade_windows)); + e_widget_framelist_object_append(of, ow); + e_widget_list_object_append(o, of, 1, 1, 0.5); + of = e_widget_framelist_add(evas, D_(""), 0); + ow = e_widget_check_add(evas, D_("Fade out shelves and popups"), &(cfdata->fade_popups)); + e_widget_framelist_object_append(of, ow); + ow = e_widget_check_add(evas, D_("Darken desktop"), &(cfdata->fade_desktop)); + e_widget_framelist_object_append(of, ow); + e_widget_list_object_append(o, of, 1, 1, 0.5); + + e_widget_table_object_append(ot, o, 1, 0, 1, 1, 1, 1, 0, 0); + ow = e_widget_button_add(evas, D_("Test"), NULL, _cb_test, cfdata, NULL); - e_widget_framelist_object_append (of, ow); + e_widget_table_object_append(ot, ow, 0, 1, 2, 1, 0, 0, 0, 0); - e_widget_list_object_append(o, of, 1, 1, 0.5); - - return o; + return ot; } static int @@ -123,6 +171,12 @@ scale_conf->tight = cfdata->tight; scale_conf->scale_duration = cfdata->duration; scale_conf->spacing = cfdata->spacing; + scale_conf->desks_duration = cfdata->desks_duration; + scale_conf->desks_spacing = cfdata->desks_spacing; + scale_conf->fade_popups = cfdata->fade_popups; + scale_conf->fade_desktop = cfdata->fade_desktop; + scale_conf->fade_windows = cfdata->fade_windows; + scale_conf->fade_desktop = cfdata->fade_desktop; e_config_save_queue(); return 1; } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-02-21 15:46:23 UTC (rev 57215) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-02-21 15:52:24 UTC (rev 57216) @@ -1,14 +1,21 @@ #include <e.h> #include "e_mod_main.h" -// TODO +//TODO //~ handle add, delete border +//~ how to handle/disable possible desk show events +// while scale is active? +// +/* #define DBG(...) */ +#define DBG(...) printf(__VA_ARGS__) -#define DBG(...) -/* #define DBG(...) printf(__VA_ARGS__) */ +#define SPACING 64 +#define PLACE_RUNS 10000 +#define GROW_RUNS 1000 +#define SHRINK_RUNS 1000 +#define GROW 6.0 - static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); static void _gc_shutdown(E_Gadcon_Client *gcc); static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); @@ -23,30 +30,28 @@ static void _scale_gc_cb_menu_post(void *data, E_Menu *menu); static void _scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi); -/* static void _scale_win_movorig(void *data, Evas *e, Evas_Object *obj, void *event_info); - * static void _scale_win_reszorig(void *data, Evas *e, Evas_Object *obj, void *event_info); */ -static void _scale_win_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void _scale_finish(void); static void _scale_in(void); static void _scale_out(void); + static Eina_Bool _scale_cb_mouse_down(void *data, int type, void *event); +static Eina_Bool _scale_cb_mouse_move(void *data, int type, void *event); +static void _scale_win_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); static void _scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); +static void _scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a); +static void _scale_win_cb_intercept_layer(void *data, Evas_Object *obj, int l); -static E_Action *act = NULL; - typedef struct _Item Item; -typedef struct _E_Comp_Win E_Comp_Win; - struct _Item { - Evas_Object *o; + Evas_Object *o, *o_win; E_Border *bd; E_Comp_Win *cw; double scale; + int alpha; double x; double y; @@ -56,122 +61,63 @@ double mx; double my; + /* border origin (is moved when scale on another desk) */ double bd_x; double bd_y; + /* current position to draw by compositor */ int cur_x, cur_y, cur_w, cur_h; - + + /* borders' desk distance to the current desk */ + int dx, dy; + int overlaps; }; +static Ecore_X_Window input_win = 0; +static E_Msg_Handler *msg_handler = NULL; +static E_Action *act = NULL; + static Eina_List *items = NULL; static Eina_List *popups = NULL; static Eina_List *handlers = NULL; static Ecore_Animator *scale_animator = NULL; static Eina_Bool scale_state = EINA_FALSE; static double start_time; -static double current_scaling = 0; - +static E_Zone *zone = NULL; static int max_x; static int max_y; static int min_x; static int min_y; -static int width, height; +static int max_width, max_height; static int step_count; +static Item *background = NULL; +static Item *selected_item = NULL; +static E_Desk *current_desk = NULL; +static int show_all_desks = EINA_FALSE; +static int send_to_desk = EINA_FALSE; -static Ecore_X_Window input_win = 0; -static E_Msg_Handler *msg_handler = NULL; - -struct _E_Comp_Win -{ - EINA_INLIST; - - void *c; // parent compositor - Ecore_X_Window win; // raw window - for menus etc. - E_Border *bd; // if its a border - later - E_Popup *pop; // if its a popup - later - E_Menu *menu; // if it is a menu - later - int x, y, w, h; // geometry - struct { - int x, y, w, h; // hidden geometry (used when its unmapped and re-instated on map) - } hidden; - int pw, ph; // pixmap w/h - int border; // border width - Ecore_X_Pixmap pixmap; // the compositing pixmap - Ecore_X_Damage damage; // damage region - Ecore_X_Visual vis; // window visual - int depth; // window depth - Evas_Object *obj; // composite object - Evas_Object *shobj; // shadow object - Eina_List *obj_mirror; // extra mirror objects - Ecore_X_Image *xim; // x image - software fallback - void *up; // update handler - E_Object_Delfn *dfn; // delete function handle for objects being tracked - Ecore_X_Sync_Counter counter; // sync counter for syncronised drawing - Ecore_Timer *update_timeout; // max time between damage and "done" event - Ecore_Timer *ready_timeout; // max time on show (new window draw) to wait for window contents to be ready if sync protocol not handled. this is fallback. - int dmg_updates; // num of damage event updates since a redirect - Ecore_X_Rectangle *rects; // shape rects... if shaped :( - int rects_num; // num rects above - - Ecore_X_Pixmap cache_pixmap; // the cached pixmap (1/nth the dimensions) - int cache_w, cache_h; // cached pixmap size - int update_count; // how many updates have happened to this win - double last_visible_time; // last time window was visible - double last_draw_time; // last time window was damaged - - int pending_count; // pending event count - - char *title, *name, *clas, *role; // fetched for override-redirect windowa - Ecore_X_Window_Type primary_type; // fetched for override-redirect windowa - - Eina_Bool delete_pending : 1; // delete pendig - Eina_Bool hidden_override : 1; // hidden override - - Eina_Bool animating : 1; // it's busy animating - defer hides/dels - Eina_Bool force : 1; // force del/hide even if animating - Eina_Bool defer_hide : 1; // flag to get hide to work on deferred hide - Eina_Bool delete_me : 1; // delete me! - - Eina_Bool visible : 1; // is visible - Eina_Bool input_only : 1; // is input_only - Eina_Bool override : 1; // is override-redirect - Eina_Bool argb : 1; // is argb - Eina_Bool shaped : 1; // is shaped - Eina_Bool update : 1; // has updates to fetch - Eina_Bool redirected : 1; // has updates to fetch - Eina_Bool shape_changed : 1; // shape changed - Eina_Bool native : 1; // native - Eina_Bool drawme : 1; // drawme flag fo syncing rendering - Eina_Bool invalid : 1; // invalid depth used - just use as marker - Eina_Bool nocomp : 1; // nocomp applied - Eina_Bool needpix : 1; // need new pixmap - Eina_Bool needxim : 1; // need new xim - Eina_Bool real_hid : 1; // last hide was a real window unmap - Eina_Bool inhash : 1; // is in the windows hash - Eina_Bool show_ready : 1; // is this window ready for its first show -}; - - -#define GROW 6.0 - static int -_grow() +_scale_grow() { Item *it, *ot; Eina_List *l, *ll; int cont = 0; - int overlap; + int overlap, off; double grow_l, grow_r, grow_d, grow_u; - double mean = 0; - int off = scale_conf->spacing; - - EINA_LIST_FOREACH(items, l, it) - mean += it->scale; - - mean /= ((double) eina_list_count(items) /* + 0.5 */); + if (show_all_desks) + off = scale_conf->desks_spacing; + else + off = scale_conf->spacing; + + /* double mean = 0; */ + /* EINA_LIST_FOREACH(items, l, it) + * mean += it->scale; + * + * mean /= (double) eina_list_count(items); */ + EINA_LIST_FOREACH(items, l, it) { overlap = 0; @@ -213,23 +159,27 @@ { if (it == ot) continue; - if (grow_l && E_INTERSECTS(it->x - grow_l, it->y, it->w, it->h, - ot->x - off, ot->y - off, ot->w + grow_l + off*2, ot->h + off*2)) + if (grow_l && E_INTERSECTS(it->x - grow_l - off ,it->y, + it->w + off*2, it->h + off*2, + ot->x, ot->y, ot->w, ot->h)) grow_l = 0; - if (grow_r && E_INTERSECTS(it->x, it->y, it->w + grow_r, it->h, - ot->x - grow_r - off, ot->y - off, ot->w + off*2, ot->h + off*2)) + if (grow_r && E_INTERSECTS(it->x - off, it->y - off, + it->w + grow_r + off*2, it->h + off*2, + ot->x, ot->y, ot->w, ot->h)) grow_r = 0; if ((grow_l == 0) && (grow_r == 0) && (overlap = 1)) break; - if (grow_u && E_INTERSECTS(it->x, it->y - grow_u, it->w, it->h, - ot->x - off, ot->y - off, ot->w + off*2, ot->h + grow_u + off*2)) + if (grow_u && E_INTERSECTS(it->x - off, it->y - off - grow_u, + it->w + off*2, it->h + off*2, + ot->x, ot->y, ot->w, ot->h)) grow_u = 0; - if (grow_d && E_INTERSECTS(it->x, it->y, it->w, it->h + grow_d, - ot->x - off, ot->y - grow_d - off, ot->w + off*2, ot->h + off*2)) + if (grow_d && E_INTERSECTS(it->x - off, it->y - off, + it->w + off*2, it->h + grow_d + off*2, + ot->x, ot->y, ot->w, ot->h)) grow_d = 0; if ((grow_u == 0) && (grow_d == 0) && (overlap = 1)) @@ -241,12 +191,20 @@ if (it->bd->w > it->bd->h) { - it->w += ((grow_u > 0) && (grow_d > 0)) ? grow_l + grow_r : MAX(grow_l, grow_r); + if ((grow_u > 0) && (grow_d > 0)) + it->w += grow_l + grow_r; + else + it->w += MAX(grow_l, grow_r); + it->h = it->w * (double)it->bd->h / (double)it->bd->w; } else { - it->h += ((grow_r > 0) && (grow_l > 0)) ? grow_u + grow_d : MAX(grow_u, grow_d); + if ((grow_r > 0) && (grow_l > 0)) + it->h += grow_u + grow_d; + else + it->h += MAX(grow_u, grow_d); + it->w = it->h * (double)it->bd->w / (double)it->bd->h; } @@ -259,8 +217,67 @@ return cont; } +static void +_scale_displace(Item *it, Item *ot, int disp) +{ + /* cycle items with same center around to get even distribution. + dont try to understand this but these initial conditions + are important.. you can have up to 9 maximized windows. + if you can figure out more please tell me :) */ + + if (disp % 8 == 0) + { + // 1. + it->y -= 1; + it->x -= 1; + // 2. + ot->x += 1; + ot->y -= 1; + } + else if (disp % 8 == 1) + { + // 3. + ot->y += 1; + } + else if (disp % 8 == 2) + { + // 4. + ot->x -= 2; + ot->y += 2; + } + else if (disp % 8 == 3) + { + // 5. + ot->x += 2; + ot->y += 2; + } + else if (disp % 8 == 4) + { + // 6. + ot->x += 1; + ot->y += 1; + } + else if (disp % 8 == 5) + { + // 7. + ot->x -= 1; + ot->y += 1; + } + else if (disp % 8 == 6) + { + // 8. + ot->x -= 1; + ot->y -= 1; + } + else if (disp % 8 == 7) + { + ot->x += 1; + ot->y -= 1; + } +} + static int -_place(int offset) +_scale_place(int offset) { Item *it, *ot; Eina_List *l, *ll; @@ -274,7 +291,7 @@ } int disp = 0; - + EINA_LIST_FOREACH(items, l, it) { EINA_LIST_FOREACH(items, ll, ot) @@ -285,14 +302,15 @@ if (it == ot) continue; - if (!E_INTERSECTS(it->x - offset, it->y - offset, it->w + offset*2, it->h + offset*2, + if (!E_INTERSECTS(it->x - offset, it->y - offset, + it->w + offset*2, it->h + offset*2, ot->x, ot->y, ot->w, ot->h)) continue; overlap += 1; it->overlaps++; - + if (it->x < ot->x) w += it->x - ot->x; if (w < 0) w = 0; @@ -310,62 +328,9 @@ double dist_y = (it->y + it->h/2) - (ot->y + ot->h/2); double dist_x = (it->x + it->w/2) - (ot->x + ot->w/2); - /* cycle items with same center around to get even distribution. - dont try to understand this but these initial conditions - are important.. you can have up to 9 maximized windows. - if you can figure out more please tell me :) */ if (dist_x == 0 && dist_y == 0) { - if (disp % 8 == 0) - { - // 1. - it->y -= 1; - it->x -= 1; - // 2. - ot->x += 1; - ot->y -= 1; - } - else if (disp % 8 == 1) - { - // 3. - ot->y += 1; - } - else if (disp % 8 == 2) - { - // 4. - ot->x -= 2; - ot->y += 2; - } - else if (disp % 8 == 3) - { - // 5. - ot->x += 2; - ot->y += 2; - } - else if (disp % 8 == 4) - { - // 6. - ot->x += 1; - ot->y += 1; - } - else if (disp % 8 == 5) - { - // 7. - ot->x -= 1; - ot->y += 1; - } - else if (disp % 8 == 6) - { - // 8. - ot->x -= 1; - ot->y -= 1; - } - else if (disp % 8 == 7) - { - ot->x += 1; - ot->y -= 1; - } - + _scale_displace(it, ot, disp); disp++; } else if (w > h) @@ -397,9 +362,6 @@ } } - if (!overlap) - return 0; - EINA_LIST_FOREACH(items, l, it) { it->x = it->mx; @@ -430,21 +392,25 @@ } } + if (!(overlap || outside)) + return 0; + if (outside && (step_count++ > 50)) { - double zone_diag = sqrt(width * height); + double zone_diag = sqrt(zone->w * zone->h); double sw, sh; step_count = 0; EINA_LIST_FOREACH(items, l, it) { if (!it->overlaps) continue; - + if (it->scale <= 0.005) continue; - it->scale -= it->scale * (0.001 + (sqrt(it->bd->w * it->bd->h) / zone_diag) / 50.0); - + it->scale -= it->scale * + (0.001 + (sqrt(it->bd->w * it->bd->h) / zone_diag) / 50.0); + sw = (double)it->bd->w * it->scale; sh = (double)it->bd->h * it->scale; it->x += (it->w - sw)/2.0; @@ -460,112 +426,19 @@ return overlap || outside; } -#if 0 -static void -_bounding_box_get() -{ - Eina_List *l; - double x, y, w, h; - Item *it; - EINA_LIST_FOREACH(items, l, it) - { - - } -} - static int -_cb_sort_down(const void *d1, const void *d2) +_scale_shrink() { - const Item *it1 = d1; - const Item *it2 = d2; - return (it1->y < it2->y) ? -1 : 1; -} - -static int -_cb_sort_right(const void *d1, const void *d2) -{ - const Item *it1 = d1; - const Item *it2 = d2; - return (it1->x < it2->x) ? -1 : 1; -} - -static int -_shrink() -{ Eina_List *l, *ll; Item *it, *ot; - int last_offset, offset; - - items = eina_list_sort(items, eina_list_count(items), _cb_sort_down); - - EINA_LIST_REVERSE_FOREACH(items, l, it) - { - last_offset = offset = 100; - - while (last_offset > 10) - { - if (it->y + it->h + last_offset > height) - { - last_offset = height - (it->y + it->h); - continue; - } - - offset = last_offset; - - EINA_LIST_FOREACH(l->next, ll, ot) - { - if (!E_INTERSECTS(it->x, it->y + offset, it->w, it->h, - ot->x, ot->y, ot->w, ot->h)) - continue; + int shrunk = 0; + int off; - last_offset = offset / 2; - offset = 0; - break; - } - it->y += offset; - } - } - items = eina_list_sort(items, eina_list_count(items), _cb_sort_right); - - EINA_LIST_REVERSE_FOREACH(items, l, it) - { - last_offset = offset = 100; - - while (last_offset > 10) - { - if (it->x + it->w + last_offset > width) - { - last_offset = width - (it->x + it->w); - continue; - } - - offset = last_offset; - - EINA_LIST_FOREACH(l->next, ll, ot) - { - if (!E_INTERSECTS(it->x + offset, it->y, it->w, it->h, - ot->x, ot->y, ot->w, ot->h)) - continue; + if (show_all_desks) + off = scale_conf->desks_spacing; + else + off = scale_conf->spacing; - last_offset = offset / 2; - - offset = 0; - break; - } - it->x += offset; - } - } -} -#endif - -static int -_shrink() -{ - Eina_List *l, *ll; - Item *it, *ot; - int shrunk = 0; - int off = scale_conf->spacing; - EINA_LIST_REVERSE_FOREACH(items, l, it) { double move_x = ((it->x + it->w/2.0) - (double)(it->bd->x + it->bd->w/2.0)) / 10.0; @@ -573,7 +446,7 @@ if (!(move_y || move_x)) continue; - + EINA_LIST_FOREACH(items, ll, ot) { if (it == ot) continue; @@ -584,7 +457,7 @@ ot->x - off, ot->y - off, ot->w + off*2, ot->h + off*2)) move_x = move_x / 2.0; else break; - } + } while(move_y) { @@ -593,10 +466,10 @@ move_y = move_y / 2.0; else break; } - + if (!(move_y || move_x)) break; } - + it->x -= move_x; it->y -= move_y; @@ -608,80 +481,121 @@ } static Eina_Bool -_redraw(void *blah) +_scale_redraw(void *blah) { Eina_List *l; Item *it; - double scale; - + double scale, a, in, duration; + + if (show_all_desks) + duration = scale_conf->desks_duration; + else + duration = scale_conf->scale_duration; + if (scale_state) - scale = (ecore_time_get() - start_time) / scale_conf->scale_duration; + scale = (ecore_time_get() - start_time) / duration; else - scale = 1.0 - (ecore_time_get() - start_time) / scale_conf->scale_duration; + scale = 1.0 - (ecore_time_get() - start_time) / duration; if (scale > 1.0) scale = 1.0; if (scale < 0.0) scale = 0.0; - - current_scaling = scale; + /* in = cos(scale * M_PI_2); */ + + in = log(10) * scale; + in = 1.0 / exp(in*in); + EINA_LIST_FOREACH(items, l, it) { - /* it->cw->x = it->bd_x * (1.0 - scale) + it->x * scale; - * it->cw->y = it->bd_y * (1.0 - scale) + it->y * scale; */ + it->cur_w = it->bd->w * in + it->w * (1.0 - in); + it->cur_h = it->bd->h * in + it->h * (1.0 - in); + it->cur_x = it->bd_x * in + it->x * (1.0 - in); + it->cur_y = it->bd_y * in + it->y * (1.0 - in); - it->cur_w = it->bd->w * (1.0 - scale) + it->w * scale; - it->cur_h = it->bd->h * (1.0 - scale) + it->h * scale; - it->cur_x = it->bd_x * (1.0 - scale) + it->x * scale; - it->cur_y = it->bd_y * (1.0 - scale) + it->y * scale; + evas_object_move(it->o, it->cur_x, it->cur_y); + evas_object_resize(it->o, it->cur_w, it->cur_h); - /* printf("resize %d %d\n", it->cur_w, it->cur_h); */ + evas_object_move(it->o_win, it->cur_x, it->cur_y); + evas_object_resize(it->o_win, it->cur_w, it->cur_h); - evas_object_move(it->o, it->cur_x, it->cur_y); - evas_object_resize(it->o, it->cur_w, it->cur_h); + a = 255.0 * (1.0 - in); + evas_object_color_set(it->o, a, a, a, a); + + if (!scale_conf->fade_windows) + continue; + + if ((it->bd->desk != current_desk) && (selected_item != it)) + { + double ax = it->cur_x - it->x; + double ay = it->cur_y - it->y; + double bx = it->bd_x - it->x; + double by = it->bd_y - it->y; + + a = (1.0 - sqrt(ax*ax + ay*ay) / sqrt(bx*bx + by*by)) * 255; + } + else + { + a = 255.0; + } + + it->alpha = a; + evas_object_color_set(it->o_win, a, a, a, a); } - double a = 255.0 * (1.0 - scale); - - EINA_LIST_FOREACH(popups, l, it) - evas_object_color_set(it->o, a, a, a, a); + if (scale_conf->fade_popups) + { + a = 255.0 * in; - /* e = e_manager_comp_evas_get(e_manager_current_get()); */ - + EINA_LIST_FOREACH(popups, l, it) + evas_object_color_set(it->o_win, a, a, a, a); + } + + if (scale_conf->fade_desktop && background) + { + a = 255.0 * (0.5 + in/2.0); + + evas_object_color_set(background->o_win, a, a, a, 255); + } + + e_manager_comp_evas_update(e_manager_current_get()); + if (scale < 1.0 && scale > 0.0) return 1; - if (scale == 0.0) _scale_finish(); scale_animator = NULL; - return 0; } - static void _scale_in() { start_time = ecore_time_get(); scale_state = EINA_TRUE; - + if (!scale_animator) - scale_animator = ecore_animator_add(_redraw, NULL); + scale_animator = ecore_animator_add(_scale_redraw, NULL); } static void _scale_out() { - double now = ecore_time_get(); - - if (now - start_time < scale_conf->scale_duration) - start_time = now - (scale_conf->scale_duration - (now - start_time)); + double duration, now = ecore_time_get(); + + if (show_all_desks) + duration = scale_conf->desks_duration; else + duration = scale_conf->scale_duration; + + if (now - start_time < duration) + start_time = now - (duration - (now - start_time)); + else start_time = now; if (!scale_animator) - scale_animator = ecore_animator_add(_redraw, NULL); + scale_animator = ecore_animator_add(_scale_redraw, NULL); scale_state = EINA_FALSE; } @@ -691,37 +605,82 @@ { Ecore_Event_Handler *handler; Item *it; + E_Desk *desk; + e_grabinput_release(input_win, input_win); ecore_x_window_free(input_win); input_win = 0; - E_Zone *zone = e_util_zone_current_get(e_manager_current_get()); - E_Desk *desk = e_desk_current_get(zone); + desk = e_desk_current_get(zone); + if (selected_item && selected_item->bd->desk != desk) + { + if (send_to_desk) + { + e_border_desk_set(selected_item->bd, desk); + } + else + { + int tmp = e_config->desk_flip_animate_mode; + + desk = selected_item->bd->desk; + + e_config->desk_flip_animate_mode = 0; + e_desk_show(desk); + e_config->desk_flip_animate_mode = tmp; + } + } + EINA_LIST_FREE(items, it) { - if (it->bd->desk != desk) - e_border_hide(it->bd, 2); + evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); + evas_object_intercept_move_callback_del(it->o_win, _scale_win_cb_intercept_move); + evas_object_intercept_resize_callback_del(it->o_win, _scale_win_cb_intercept_resize); + evas_object_intercept_color_set_callback_del(it->o_win, _scale_win_cb_intercept_color); + evas_object_intercept_layer_set_callback_del(it->o_win, _scale_win_cb_intercept_layer); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_DEL, _scale_win_delorig); + /* evas_object_clip_unset(it->o_win); */ + /* edje_object_part_unswallow(it->o, it->o_win); */ + evas_object_del(it->o); - evas_object_intercept_move_callback_del(it->o, _scale_win_cb_intercept_move); - evas_object_intercept_resize_callback_del(it->o, _scale_win_cb_intercept_resize); + if (it->bd->desk != desk) + { + e_border_hide(it->bd, 2); + evas_object_hide(it->o_win); + evas_object_color_set(it->o_win, 255, 255, 255, 255); + evas_object_move(it->o_win, it->bd->x, it->bd->y); + evas_object_resize(it->o_win, it->cw->w, it->cw->h); + } + e_object_unref(E_OBJECT(it->bd)); E_FREE(it); } EINA_LIST_FREE(popups, it) { - evas_object_event_callback_del(it->o, EVAS_CALLBACK_DEL, _scale_win_delorig); + evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); + evas_object_color_set(it->o_win, 255, 255, 255, 255); E_FREE(it); } + if (scale_conf->fade_desktop && background) + { + it = background; + evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); + evas_object_color_set(it->o_win, 255, 255, 255, 255); + E_FREE(it); + } + EINA_LIST_FREE(handlers, handler) ecore_event_handler_del(handler); e_msg_handler_del(msg_handler); msg_handler = NULL; + zone = NULL; + selected_item = NULL; + current_desk = NULL; + send_to_desk = EINA_FALSE; + show_all_desks = EINA_FALSE; e_manager_comp_evas_update(e_manager_current_get()); } @@ -731,17 +690,29 @@ { Item *it = data; - items = eina_list_remove(items, it); - popups = eina_list_remove(popups, it); + evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); - evas_object_intercept_move_callback_del(it->o, _scale_win_cb_intercept_move); - evas_object_intercept_resize_callback_del(it->o, _scale_win_cb_intercept_resize); + if (it->bd) + { + e_object_unref(E_OBJECT(it->bd)); + _scale_out(); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_DEL, _scale_win_delorig); + evas_object_intercept_move_callback_del(it->o_win, _scale_win_cb_intercept_move); + evas_object_intercept_resize_callback_del(it->o_win, _scale_win_cb_intercept_resize); + evas_object_intercept_color_set_callback_del(it->o_win, _scale_win_cb_intercept_color); + evas_object_intercept_layer_set_callback_del(it->o_win, _scale_win_cb_intercept_layer); - if (it->bd) - _scale_out(); - + /* evas_object_clip_unset(it->o_win); */ + /* edje_object_part_unswallow(it->o, it->o_win); */ + evas_object_del(it->o); + + items = eina_list_remove(items, it); + } + else + { + popups = eina_list_remove(popups, it); + } + E_FREE(it); } @@ -759,11 +730,26 @@ Item *it = data; evas_object_resize(obj, it->cur_w, it->cur_h); +} - e_manager_comp_evas_update(e_manager_current_get()); +static void +_scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a) +{ + Item *it = data; + + evas_object_color_set(obj, it->alpha, it->alpha, it->alpha, it->alpha); } static void +_scale_win_cb_intercept_layer(void *data, Evas_Object *obj, int l) +{ + Item *it = data; + + evas_object_layer_set(it->o_win, l); + evas_object_stack_above(it->o, it->o_win); +} + +static void _scale_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src, E_Desk *desk) { Item *it; @@ -772,53 +758,88 @@ E_Comp_Win *cw = (void*)src; - if (cw->pop) + if (!cw->bd) { - it = E_NEW(Item, 1); - it->o = e_manager_comp_src_shadow_get(man, src); - evas_object_event_callback_add(it->o, EVAS_CALLBACK_DEL, _scale_win_delorig, it); + if (cw->win == zone->container->bg_win) + { + if (scale_conf->fade_desktop) + { + it = E_NEW(Item, 1); + it->o_win = e_manager_comp_src_shadow_get(man, src); + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it); + background = it; + } + } + else if (scale_conf->fade_popups) + { + it = E_NEW(Item, 1); + it->o_win = e_manager_comp_src_shadow_get(man, src); + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it); - popups = eina_list_append(popups, it); + popups = eina_list_append(popups, it); + } + return; } - + if (!cw->bd) return; - - if (cw->bd->desk != desk) + + if (cw->bd->zone != desk->zone) return; + if ((!show_all_desks) && (cw->bd->desk != desk)) + return; + if (cw->bd->iconic) return; it = E_NEW(Item, 1); it->scale = 1.0; - it->x = cw->bd->x + (cw->bd->desk->x - desk->x) * width; - it->y = cw->bd->y + (cw->bd->desk->y - desk->y) * height; - it->bd_x = it->x; - it->bd_y = it->y; + it->dx = cw->bd->desk->x - desk->x; + it->dy = cw->bd->desk->y - desk->y; + it->x = cw->bd->x + it->dx * desk->zone->w; + it->y = cw->bd->y + it->dy * desk->zone->h; it->w = cw->bd->w; it->h = cw->bd->h; + it->bd_x = it->x; + it->bd_y = it->y; + it->cur_x = it->x; it->cur_y = it->y; it->cur_w = it->w; it->cur_h = it->h; + e_object_ref(E_OBJECT(cw->bd)); it->bd = cw->bd; it->cw = cw; - it->o = e_manager_comp_src_shadow_get(man, src); - - evas_object_event_callback_add(it->o, EVAS_CALLBACK_DEL, _scale_win_delorig, it); - evas_object_intercept_move_callback_add(it->o, _scale_win_cb_intercept_move, it); - evas_object_intercept_resize_callback_add(it->o, _scale_win_cb_intercept_resize, it); + it->o_win = e_manager_comp_src_shadow_get(man, src); + it->o = edje_object_add(e); + if (!e_theme_edje_object_set(it->o, "base/theme/modules/scale", + "modules/scale/win")) + edje_object_file_set(it->o, scale_conf->theme_path, "modules/scale/win"); + evas_object_stack_above(it->o, it->o_win); + /* edje_object_part_swallow(it->o, "e.swallow.win", it->o_win); */ + /* evas_object_clip_set(it->o_win, it->o); + * evas_object_move(it->o, it->x, it->y); */ + + evas_object_show(it->o); + + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it); + + evas_object_intercept_move_callback_add(it->o_win, _scale_win_cb_intercept_move, it); + evas_object_intercept_resize_callback_add(it->o_win, _scale_win_cb_intercept_resize, it); + evas_object_intercept_color_set_callback_add(it->o_win, _scale_win_cb_intercept_color, it); + evas_object_intercept_layer_set_callback_add(it->o_win, _scale_win_cb_intercept_layer, it); + if (it->bd->desk != desk) { e_border_show(it->bd); - evas_object_move(it->o, it->x, it->y); + evas_object_move(it->o_win, it->x, it->y); } items = eina_list_append(items, it); @@ -830,26 +851,29 @@ const Item *it1 = d1; const Item *it2 = d2; - double dx1 = ((it1->x + it1->w/2.0) - (double)(width/2)); - double dy1 = ((it1->y + it1->h/2.0) - (double)(height/2)); + double dx1 = ((it1->bd_x + it1->w/2.0) - (double)(max_width/2)); + double dy1 = ((it1->bd_y + it1->h/2.0) - (double)(max_height/2)); - double dx2 = ((it2->x + it2->w/2.0) - (double)(width/2)); - double dy2 = ((it2->y + it2->h/2.0) - (double)(height/2)); - + double dx2 = ((it2->bd_x + it2->w/2.0) - (double)(max_width/2)); + double dy2 = ((it2->bd_y + it2->h/2.0) - (double)(max_height/2)); + return (sqrt(dx1*dx1 + dy1*dy1) < sqrt(dx2*dx2 + dy2*dy2)) ? -1 : 1; } void scale_run(E_Manager *man) { - Eina_List *list, *l; + Eina_List *l; E_Manager_Comp_Source *src; Evas *e; - int i, spacing; + int i, spacing, use_x, use_y, use_w, use_h; - E_Zone *zone = e_util_zone_current_get(e_manager_current_get()); - E_Desk *desk = e_desk_current_get(zone); + zone = e_util_zone_current_get(e_manager_current_get()); + current_desk = e_desk_current_get(zone); + Item *it; + start_time = ecore_time_get(); + input_win = ecore_x_window_input_new(zone->container->win, 0, 0, 1, 1); ecore_x_window_show(input_win); if (!e_grabinput_get(input_win, 0, input_win)) @@ -858,99 +882,272 @@ input_win = 0; return; } - e_zone_useful_geometry_get(zone, &min_x, &min_y, &width, &height); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_BUTTON_DOWN, _scale_cb_mouse_down, NULL)); + handlers = eina_list_append + (handlers, ecore_event_handler_add + (ECORE_EVENT_MOUSE_MOVE, _scale_cb_mouse_move, NULL)); + e = e_manager_comp_evas_get(man); - list = (Eina_List *)e_manager_comp_src_list(man); - EINA_LIST_FOREACH(list, l, src) - _scale_win_new(e, man, src, desk); + if (show_all_desks) + spacing = scale_conf->desks_spacing; + else + spacing = scale_conf->spacing; - items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); + EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) + { + _scale_win_new(e, man, src, current_desk); + } - max_x = width; - max_y = height; + if ((eina_list_count(items) < 2) && (!show_all_desks)) + { + _scale_finish(); + return; + } + if (!scale_conf->fade_popups) + { + e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); + use_x += spacing; + use_y += spacing; + use_w += use_x - spacing*2; + use_h += use_y - spacing*2; + } + else + { + use_x = use_y = spacing; + use_w = zone->w - spacing*2; + use_h = zone->h - spacing*2; + } - start_time = ecore_time_get(); - + max_width = zone->w; + max_height = zone->h; + + if (show_all_desks) + { + max_width = zone->h * zone->desk_x_count; + max_height = zone->w * zone->desk_y_count; + } + + min_x = -zone->w * zone->desk_x_current; + min_y = -zone->h * zone->desk_y_current; + max_x = zone->w + zone->w * ((zone->desk_x_count - 1) - zone->desk_x_current); + max_y = zone->h + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current); + + items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); + step_count = 0; i = 0; - spacing = scale_conf->spacing; - - if (scale_conf->grow && (spacing < 48)) spacing = 48; - if (scale_conf->tight && (spacing < 48)) spacing = 48; - while (i++ < 10000 && _place(spacing)); + if (scale_conf->grow && (spacing < SPACING)) + spacing = SPACING; + if (scale_conf->tight && (spacing < SPACING)) + spacing = SPACING; - DBG("place %d\n", i); + while ((i++ < PLACE_RUNS) && + (_scale_place(spacing) || + (min_x < use_x) || + (min_y < use_y) || + (max_x > use_w) || + (max_y > use_h))) + { + /* shrink region to visible region */ + if (min_x < use_x) min_x += 2; + if (min_y < use_y) min_y += 2; + if (min_x > use_x) min_x = use_x; + if (min_y > use_y) min_y = use_y; - if (i == 1) - { - _scale_finish(); - return; + if (max_x > use_w) max_x -= 2; + if (max_y > use_h) max_y -= 2; + if (max_x < use_w) max_x = use_w; + if (max_y < use_h) max_y = use_h; + + if (!show_all_desks) + continue; + + /* move other desks windows into visible region */ + EINA_LIST_FOREACH(items, l, it) + { + if ((min_x < use_x) && (it->dx < 0) && it->x < 0) it->x += 4.0; + if ((min_y < use_y) && (it->dy < 0) && it->y < 0) it->y += 4.0; + + if ((max_x > use_w) && (it->dx > 0) && it->x > zone->w) it->x -= 4.0; + if ((max_y > use_h) && (it->dy > 0) && it->y > zone->h) it->y -= 4.0; + } } + DBG("place %d\n", i); + if (scale_conf->grow) - { + { i = 0; - while (i++ < 1000 && _grow()); + while (i++ < GROW_RUNS && _scale_grow()); DBG("grow %d", i); } if (scale_conf->tight) { i = 0; - while (i++ < 1000 && _shrink()); + while (i++ < SHRINK_RUNS && _scale_shrink()); DBG("shrunk %d", i); + + if (scale_conf->grow) + { + i = 0; + while (i++ < GROW_RUNS && _scale_grow()); + DBG("grow %d", i); + } + } - + + if (show_all_desks) + { + /* center and move windows near visible desk + * to make the sliding smoother */ + + min_x = zone->w; + min_y = zone->h; + max_x = 0; + max_y = 0; + + EINA_LIST_FOREACH(items, l, it) + { + if (it->x < min_x) min_x = it->x; + if (it->y < min_y) min_y = it->y; + if (it->x + it->w > max_x) max_x = it->x + it->w; + if (it->y + it->h > max_y) max_y = it->y + it->h; + } + + EINA_LIST_FOREACH(items, l, it) + { + it->x = it->x - min_x + (use_w - (max_x - min_x))/2; + it->y = it->y - min_y + (use_h - (max_y - min_y))/2; + + if (it->dx > 0) it->bd_x = zone->w + it->bd->x/4; + if (it->dy > 0) it->bd_y = zone->h + it->bd->y/4; + if (it->dx < 0) it->bd_x = -(zone->w - it->bd->x)/4; + if (it->dy < 0) it->bd_y = -(zone->h + it->bd->y)/4; + } + } + DBG("time: %f\n", ecore_time_get() - start_time); - _scale_in(); + _scale_in(); } static Eina_Bool -_scale_cb_mouse_down(void *data, int type, void *event) +_scale_cb_mouse_move(void *data, int type, void *event) { - Ecore_Event_Mouse_Button *ev; + Ecore_Event_Mouse_Move *ev = event; Item *it; Eina_List *l; - ev = event; if (ev->window != input_win) return ECORE_CALLBACK_PASS_ON; if (!scale_state) return ECORE_CALLBACK_PASS_ON; - + EINA_LIST_FOREACH(items, l, it) + if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) + break; + + if (selected_item && (it != selected_item)) { - if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) + edje_object_signal_emit(selected_item->o, "mouse,out", "e"); + selected_item = NULL; + } + + if (it) + { + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; + } + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_scale_cb_mouse_down(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Button *ev = event; + Item *it, *ot; + Eina_List *l; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + EINA_LIST_FOREACH(items, l, it) + if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) + break; + + if (!it) + { + _scale_out(); + return ECORE_CALLBACK_PASS_ON; + } + + e_border_raise(it->bd); + + + if (it->bd->desk != e_desk_current_get(it->bd->zone)) + { + if (ev->buttons == 1) { - e_border_raise(it->bd); - break; + selected_item = it; + current_desk = it->bd->desk; + + EINA_LIST_FOREACH(items, l, ot) + { + if (ot->bd->desk == it->bd->desk) + { + ot->bd_x = ot->bd->x; + ot->bd_y = ot->bd->y; + } + else + { + if (ot->dx > it->dx) + ot->bd_x = ot->bd->x + zone->w; + else if (ot->dx < it->dx) + ot->bd_x = ot->bd->x - zone->w; + + if (ot->dy > it->dy) + ot->bd_y = ot->bd->y + zone->h; + else if (ot->dy < it->dy) + ot->bd_y = ot->bd->y - zone->h; + } + } } + else if (ev->buttons == 3) + { + send_to_desk = EINA_TRUE; + selected_item = it; + it->bd_x = it->bd->x; + it->bd_y = it->bd->y; + } } _scale_out(); - + return ECORE_CALLBACK_PASS_ON; } static void _scale_handler(void *data, const char *name, const char *info, int val, - E_Object *obj, void *msgdata) + E_Object *obj, void *msgdata) { E_Manager *man = (E_Manager *)obj; E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata; Evas *e; - DBG("handler... '%s' '%s'\n", name, info); + /* DBG("handler... '%s' '%s'\n", name, info); */ if (strcmp(name, "comp.manager")) return; e = e_manager_comp_evas_get(man); @@ -967,7 +1164,7 @@ { /* DBG("%s: %p | %p\n", info, man, src); */ _scale_win_new(e, man, src, e_desk_current_get(e_util_zone_current_get(man))); - + } else if (!strcmp(info, "del.src")) { @@ -978,10 +1175,10 @@ DBG("%s: %p | %p\n", info, man, src); } - else if (!strcmp(info, "visible.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } + /* else if (!strcmp(info, "visible.src")) + * { + * DBG("%s: %p | %p\n", info, man, src); + * } */ } static void @@ -992,6 +1189,12 @@ msg_handler = e_msg_handler_add(_scale_handler, NULL); list = e_manager_list(); + + if (params && !strcmp(params, "show_all_desks")) + show_all_desks = EINA_TRUE; + else + show_all_desks = EINA_FALSE; + EINA_LIST_FOREACH(list, l, man) { Evas *e = e_manager_comp_evas_get(man); @@ -1007,6 +1210,12 @@ msg_handler = e_msg_handler_add(_scale_handler, NULL); list = e_manager_list(); + + if (params && !strcmp(params, "show_all_desks")) + show_all_desks = EINA_TRUE; + else + show_all_desks = EINA_FALSE; + EINA_LIST_FOREACH(list, l, man) { Evas *e = e_manager_comp_evas_get(man); @@ -1075,8 +1284,14 @@ E_CONFIG_VAL(D, T, version, INT); E_CONFIG_VAL(D, T, grow, UCHAR); E_CONFIG_VAL(D, T, tight, UCHAR); + E_CONFIG_VAL(D, T, fade_popups, UCHAR); + E_CONFIG_VAL(D, T, fade_desktop, UCHAR); + E_CONFIG_VAL(D, T, fade_windows, UCHAR); + E_CONFIG_VAL(D, T, fade_desktop, UCHAR); E_CONFIG_VAL(D, T, scale_duration, DOUBLE); E_CONFIG_VAL(D, T, spacing, DOUBLE); + E_CONFIG_VAL(D, T, desks_duration, DOUBLE); + E_CONFIG_VAL(D, T, desks_spacing, DOUBLE); E_CONFIG_LIST(D, T, conf_items, conf_item_edd); scale_conf = e_config_domain_load("module.scale", conf_edd); @@ -1088,11 +1303,15 @@ MOD_CONFIG_FILE_VERSION)) _scale_conf_free(); } - + if (!scale_conf) _scale_conf_new(); scale_conf->module = m; + snprintf(buf, sizeof(buf), "%s/e-module-scale.edj", + scale_conf->module->dir); + scale_conf->theme_path = eina_stringshare_add(buf); + e_gadcon_provider_register(&_gc_class); act = e_action_add("scale-windows"); @@ -1101,6 +1320,7 @@ act->func.go = _e_mod_action_cb; act->func.go_edge = _e_mod_action_cb_edge; e_action_predef_name_set(D_("Desktop"), D_("Scale Windows"), "scale-windows", "", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Windows / All Desktops"), "scale-windows", "show_all_desks", NULL, 0); } return m; @@ -1132,6 +1352,7 @@ E_FREE(ci); } + eina_stringshare_del(scale_conf->theme_path); E_FREE(scale_conf); E_CONFIG_DD_FREE(conf_item_edd); @@ -1158,11 +1379,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) { Instance *inst = NULL; - char buf[4096]; - snprintf(buf, sizeof(buf), "%s/e-module-scale.edj", - scale_conf->module->dir); - inst = E_NEW(Instance, 1); inst->conf_item = _scale_conf_item_get(id); @@ -1170,7 +1387,7 @@ if (!e_theme_edje_object_set(inst->o_scale, "base/theme/modules/scale", "modules/scale/main")) - edje_object_file_set(inst->o_scale, buf, "modules/scale/main"); + edje_object_file_set(inst->o_scale, scale_conf->theme_path, "modules/scale/main"); inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_scale); inst->gcc->data = inst; @@ -1232,13 +1449,10 @@ _gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas) { Evas_Object *o = NULL; - char buf[4096]; - snprintf(buf, sizeof(buf), "%s/e-module-scale.edj", scale_conf->module->dir); - o = edje_object_add(evas); - edje_object_file_set(o, buf, "icon"); + edje_object_file_set(o, scale_conf->theme_path, "icon"); return o; } @@ -1246,18 +1460,22 @@ static void _scale_conf_new(void) { - scale_conf = E_NEW(Config, 1); scale_conf->version = (MOD_CONFIG_FILE_EPOCH << 16); #define IFMODCFG(v) if ((scale_conf->version & 0xffff) < v) { #define IFMODCFGEND } - IFMODCFG(0x008d); + IFMODCFG(0x0001); scale_conf->grow = 0; scale_conf->tight = 1; - scale_conf->scale_duration = 0.3; - scale_conf->spacing = 32; + scale_conf->scale_duration = 0.4; + scale_conf->spacing = 6; + scale_conf->fade_windows = 1; + scale_conf->fade_popups = 0; + scale_conf->fade_desktop = 1; + scale_conf->desks_duration = 0.6; + scale_conf->desks_spacing = 25; _scale_conf_item_get(NULL); IFMODCFGEND; @@ -1323,12 +1541,17 @@ if (!(inst = data)) return; ev = event; + if (ev->button == 1) { - _e_mod_action_cb_edge(NULL, NULL, NULL); + _e_mod_action_cb(NULL, NULL); } - else if ((ev->button == 3) && (!inst->menu)) + else if (ev->button == 2) { + _e_mod_action_cb(NULL, "show_all_desks"); + } + else if ((ev->button == 3) && (!inst->menu)) + { E_Menu *ma, *mg; zone = e_util_zone_current_get(e_manager_current_get()); @@ -1345,13 +1568,13 @@ e_menu_item_callback_set(mi, _scale_gc_cb_menu_configure, NULL); e_gadcon_client_util_menu_items_append(inst->gcc, ma, mg, 0); - e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, + e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, NULL, NULL); - e_menu_activate_mouse(ma, zone, (x + ev->output.x), - (y + ev->output.y), 1, 1, + e_menu_activate_mouse(ma, zone, (x + ev->output.x), + (y + ev->output.y), 1, 1, E_MENU_POP_DIRECTION_AUTO, ev->timestamp); - evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, + evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, EVAS_BUTTON_NONE, ev->timestamp, NULL); } } @@ -1375,3 +1598,4 @@ if (scale_conf->cfd) return; e_int_config_scale_module(mn->zone->container, NULL); } + Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-02-21 15:46:23 UTC (rev 57215) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-02-21 15:52:24 UTC (rev 57216) @@ -1,7 +1,7 @@ #ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H -#define MOD_CONFIG_FILE_EPOCH 0x0003 +#define MOD_CONFIG_FILE_EPOCH 0x0004 #define MOD_CONFIG_FILE_GENERATION 0x0001 #define MOD_CONFIG_FILE_VERSION \ ((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION) @@ -12,21 +12,25 @@ typedef struct _Config_Item Config_Item; typedef struct _Config Config; +typedef struct _E_Comp_Win E_Comp_Win; struct _Config { E_Module *module; Eina_List *conf_items; int version; - + E_Config_Dialog *cfd; + const char *theme_path; + unsigned char tight; unsigned char grow; - + unsigned char fade_popups; + unsigned char fade_windows; + unsigned char fade_desktop; double scale_duration; - double spacing; - - E_Config_Dialog *cfd; + double desks_duration; + double desks_spacing; }; @@ -36,6 +40,77 @@ int switch2; }; + +struct _E_Comp_Win +{ + EINA_INLIST; + + void *c; + Ecore_X_Window win; + E_Border *bd; + E_Popup *pop; + E_Menu *menu; + int x, y, w, h; + struct { + int x, y, w, h; + } hidden; + int pw, ph; + int border; + Ecore_X_Pixmap pixmap; + Ecore_X_Damage damage; + Ecore_X_Visual vis; + int depth; + Evas_Object *obj; + Evas_Object *shobj; + Eina_List *obj_mirror; + Ecore_X_Image *xim; + void *up; + E_Object_Delfn *dfn; + Ecore_X_Sync_Counter counter; + Ecore_Timer *update_timeout; + Ecore_Timer *ready_timeout; + int dmg_updates; + Ecore_X_Rectangle *rects; + int rects_num; + + Ecore_X_Pixmap cache_pixmap; + int cache_w, cache_h; + int update_count; + double last_visible_time; + double last_draw_time; + + int pending_count; + + char *title, *name, *clas, *role; + Ecore_X_Window_Type primary_type; + + Eina_Bool delete_pending : 1; + Eina_Bool hidden_override : 1; + + Eina_Bool animating : 1; + Eina_Bool force : 1; + Eina_Bool defer_hide : 1; + Eina_Bool delete_me : 1; + + Eina_Bool visible : 1; + Eina_Bool input_only : 1; + Eina_Bool override : 1; + Eina_Bool argb : 1; + Eina_Bool shaped : 1; + Eina_Bool update : 1; + Eina_Bool redirected : 1; + Eina_Bool shape_changed : 1; + Eina_Bool native : 1; + Eina_Bool drawme : 1; + Eina_Bool invalid : 1; + Eina_Bool nocomp : 1; + Eina_Bool needpix : 1; + Eina_Bool needxim : 1; + Eina_Bool real_hid : 1; + Eina_Bool inhash : 1; + Eina_Bool show_ready : 1; +}; + EAPI extern E_Module_Api e_modapi; EAPI void *e_modapi_init(E_Module *m); |
From: Enlightenment S. <no-...@en...> - 2011-02-26 06:57:50
|
Log: e-modules/comp-scale: added fullscreen pager changed internal action names, so bindings need to be setup again. Author: jeffdameth Date: 2011-02-25 22:57:41 -0800 (Fri, 25 Feb 2011) New Revision: 57330 Trac: http://trac.enlightenment.org/e/changeset/57330 Added: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/Makefile.am trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-02-26 05:23:09 UTC (rev 57329) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-02-26 06:57:41 UTC (rev 57330) @@ -1,9 +1,9 @@ -images +images { image: "module_icon.png" COMP; } -collections +collections { group { name: "icon"; @@ -72,40 +72,22 @@ } } } - + group { name: "modules/scale/win"; parts { - + part { name: "e.swallow.win"; - type: RECT; - mouse_events: 1; + type: SWALLOW; description { state: "default" 0.0; - color: 255 255 255 0; - rel1 { - relative: 0.0 0.0; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } - + color: 255 255 255 200; } description { state: "focused" 0.0; - color: 255 255 255 80; - rel1 { - relative: 0.0 0.0; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } + color: 255 255 255 255; } } @@ -118,7 +100,7 @@ * aspect: 1.0 1.0; * aspect_preference: BOTH; * rel1.relative; - * + * * rel1.offset: 2 2; * rel2.offset: -3 -3; * image.normal: "module_icon.png"; @@ -130,15 +112,20 @@ * rel2.offset: 3 3; * } * } */ - /* part { - * name: "event"; - * mouse_events: 1; - * type: RECT; - * description { - * state: "default" 0.0; - * color: 255 255 255 100; - * } - * } */ + part { + name: "event"; + mouse_events: 1; + type: RECT; + description { + state: "default" 0.0; + color: 200 200 200 10; + } + description { + state: "focused" 0.0; + color: 255 255 255 150; + } + + } } programs { program { @@ -147,7 +134,7 @@ source: "e"; action: STATE_SET "focused" 0.0; transition: SINUSOIDAL 0.3; - target: "e.swallow.win"; + target: "event"; } program { name: "mouse_out"; @@ -155,9 +142,99 @@ source: "e"; action: STATE_SET "default" 0.0; transition: SINUSOIDAL 0.4; - target: "e.swallow.win"; + target: "event"; } } } + group { + name: "modules/scale/desk"; + + parts { + part { + name: "left"; + mouse_events: 0; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 120; + rel2 { + relative: 0.0 1.0; + offset: 0 -1; + } + } + } + part { + name: "right"; + mouse_events: 0; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 120; + rel1 { + relative: 1.0 0.0; + offset: -1 0; + } + } + } + part { + name: "top"; + mouse_events: 0; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 120; + rel2 { + relative: 1.0 0.0; + offset: -1 0; + } + } + } + part { + name: "bottom"; + mouse_events: 0; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 100; + rel1 { + relative: 0.0 1.0; + offset: 0 -1; + } + + } + } + part { + name: "event"; + mouse_events: 1; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 100; + } + description { + state: "focused" 0.0; + color: 0 0 0 80; + } + } + } + programs { + program { + name: "mouse_in"; + signal: "mouse,in"; + source: "e"; + action: STATE_SET "focused" 0.0; + transition: SINUSOIDAL 0.3; + target: "event"; + } + program { + name: "mouse_out"; + signal: "mouse,out"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.4; + target: "event"; + } + } + } } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/Makefile.am =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/Makefile.am 2011-02-26 05:23:09 UTC (rev 57329) +++ trunk/E-MODULES-EXTRA/comp-scale/src/Makefile.am 2011-02-26 06:57:41 UTC (rev 57330) @@ -9,7 +9,9 @@ pkg_LTLIBRARIES = module.la module_la_SOURCES = e_mod_main.h \ e_mod_main.c \ - e_mod_config.c + e_mod_config.c \ + e_mod_scale.c \ + e_mod_pager.c module_la_LIBADD = @E_LIBS@ module_la_LDFLAGS = -module -avoid-version Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-02-26 05:23:09 UTC (rev 57329) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-02-26 06:57:41 UTC (rev 57330) @@ -18,6 +18,11 @@ int fade_popups; int fade_desktop; int fade_windows; + + double pager_duration; + int pager_fade_popups; + int pager_fade_desktop; + int pager_fade_windows; }; @@ -74,51 +79,32 @@ static void _fill_data(E_Config_Dialog_Data *cfdata) { - cfdata->tight = scale_conf->tight; - cfdata->grow = scale_conf->grow; - cfdata->duration = scale_conf->scale_duration; - cfdata->spacing = scale_conf->spacing; - cfdata->desks_duration = scale_conf->desks_duration; - cfdata->desks_spacing = scale_conf->desks_spacing; - cfdata->fade_popups = scale_conf->fade_popups; - cfdata->fade_desktop = scale_conf->fade_desktop; - cfdata->fade_windows = scale_conf->fade_windows; - cfdata->fade_desktop = scale_conf->fade_desktop; - cfdata->layout_mode = scale_conf->layout_mode; - cfdata->desks_layout_mode = scale_conf->desks_layout_mode; - cfdata->desks_tight = scale_conf->desks_tight; - cfdata->desks_grow = scale_conf->desks_grow; - + cfdata->tight = scale_conf->tight; + cfdata->grow = scale_conf->grow; + cfdata->duration = scale_conf->scale_duration; + cfdata->spacing = scale_conf->spacing; + cfdata->desks_duration = scale_conf->desks_duration; + cfdata->desks_spacing = scale_conf->desks_spacing; + cfdata->fade_popups = scale_conf->fade_popups; + cfdata->fade_desktop = scale_conf->fade_desktop; + cfdata->fade_windows = scale_conf->fade_windows; + cfdata->layout_mode = scale_conf->layout_mode; + cfdata->desks_layout_mode = scale_conf->desks_layout_mode; + cfdata->desks_tight = scale_conf->desks_tight; + cfdata->desks_grow = scale_conf->desks_grow; + cfdata->pager_duration = scale_conf->pager_duration; + cfdata->pager_fade_popups = scale_conf->pager_fade_popups; + cfdata->pager_fade_desktop = scale_conf->pager_fade_desktop; + cfdata->pager_fade_windows = scale_conf->pager_fade_windows; } -static void -_cb_test(void *data, void *data2) -{ - E_Config_Dialog_Data *cfdata = data; - - scale_conf->grow = cfdata->grow; - scale_conf->tight = cfdata->tight; - scale_conf->scale_duration = cfdata->duration; - scale_conf->spacing = cfdata->spacing; - scale_conf->desks_duration = cfdata->desks_duration; - scale_conf->desks_spacing = cfdata->desks_spacing; - scale_conf->fade_popups = cfdata->fade_popups; - scale_conf->fade_desktop = cfdata->fade_desktop; - scale_conf->fade_windows = cfdata->fade_windows; - scale_conf->fade_desktop = cfdata->fade_desktop; - scale_conf->layout_mode = cfdata->layout_mode; - scale_conf->desks_layout_mode = cfdata->desks_layout_mode; - scale_conf->desks_grow = cfdata->desks_grow; - scale_conf->desks_tight = cfdata->desks_tight; - - scale_run(e_manager_current_get()); -} - static Evas_Object * _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) { - Evas_Object *o, *of, *ow, *ot; + Evas_Object *o, *of, *ow, *ot, *otb; + otb = e_widget_toolbook_add(evas, 0, 0); + ot = e_widget_table_add(evas, 0); o = e_widget_list_add(evas, 0, 0); @@ -126,21 +112,24 @@ of = e_widget_framelist_add(evas, D_("Current Desktop"), 0); ow = e_widget_label_add (evas, D_("Minimum space between windows")); e_widget_framelist_object_append (of, ow); - ow = e_widget_slider_add (evas, 1, 0, D_("%1.0f"), 2.0, 64.0, - 1.0, 0, &(cfdata->spacing), NULL,100); + ow = e_widget_slider_add (evas, 1, 0, D_("%1.0f"), 2.0, 64.0, 1.0, 0, + &(cfdata->spacing), NULL,100); e_widget_framelist_object_append (of, ow); ow = e_widget_label_add (evas, D_("Scale duration")); e_widget_framelist_object_append (of, ow); - ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.1, 3.0, - 0.01, 0, &(cfdata->duration), NULL,100); + ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.01, 3.0, 0.01, 0, + &(cfdata->duration), NULL,100); e_widget_framelist_object_append (of, ow); - ow = e_widget_check_add(evas, D_("Slotted Layout"), &(cfdata->layout_mode)); + ow = e_widget_check_add(evas, D_("Slotted Layout"), + &(cfdata->layout_mode)); e_widget_framelist_object_append(of, ow); e_widget_framelist_content_align_set(of, 0.0, 0.0); - ow = e_widget_check_add(evas, D_("Grow more!"), &(cfdata->grow)); + ow = e_widget_check_add(evas, D_("Grow more!"), + &(cfdata->grow)); e_widget_framelist_object_append(of, ow); - ow = e_widget_check_add(evas, D_("Keep it tight!"), &(cfdata->tight)); + ow = e_widget_check_add(evas, D_("Keep it tight!"), + &(cfdata->tight)); e_widget_framelist_object_append(of, ow); e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_table_object_append(ot, o, 0, 0, 1, 1, 1, 1, 0, 0); @@ -155,50 +144,82 @@ ow = e_widget_label_add (evas, D_("Scale duration")); e_widget_framelist_object_append (of, ow); - ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.1, 3.0, - 0.01, 0, &(cfdata->desks_duration), NULL,100); + ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.01, 3.0, 0.01, 0, + &(cfdata->desks_duration), NULL,100); e_widget_framelist_object_append (of, ow); - ow = e_widget_check_add(evas, D_("Slotted Layout"), &(cfdata->desks_layout_mode)); + ow = e_widget_check_add(evas, D_("Slotted Layout"), + &(cfdata->desks_layout_mode)); e_widget_framelist_object_append(of, ow); - ow = e_widget_check_add(evas, D_("Grow more!"), &(cfdata->desks_grow)); + ow = e_widget_check_add(evas, D_("Grow more!"), + &(cfdata->desks_grow)); e_widget_framelist_object_append(of, ow); - ow = e_widget_check_add(evas, D_("Keep it tight!"), &(cfdata->desks_tight)); + ow = e_widget_check_add(evas, D_("Keep it tight!"), + &(cfdata->desks_tight)); e_widget_framelist_object_append(of, ow); - ow = e_widget_check_add(evas, D_("Fade in windows"), &(cfdata->fade_windows)); + ow = e_widget_check_add(evas, D_("Fade in windows"), + &(cfdata->fade_windows)); e_widget_framelist_object_append(of, ow); e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_table_object_append(ot, o, 1, 0, 1, 1, 1, 1, 0, 0); of = e_widget_framelist_add(evas, D_(""), 1); - ow = e_widget_check_add(evas, D_("Fade out shelves and popups"), &(cfdata->fade_popups)); + ow = e_widget_check_add(evas, D_("Fade out shelves and popups"), + &(cfdata->fade_popups)); e_widget_framelist_object_append(of, ow); - ow = e_widget_check_add(evas, D_("Darken desktop"), &(cfdata->fade_desktop)); + ow = e_widget_check_add(evas, D_("Darken desktop"), + &(cfdata->fade_desktop)); e_widget_framelist_object_append(of, ow); - ow = e_widget_button_add(evas, D_("Test"), NULL, _cb_test, cfdata, NULL); - e_widget_framelist_object_append(of, ow); e_widget_table_object_append(ot, of, 0, 1, 2, 1, 1, 1, 0, 0); + e_widget_toolbook_page_append(otb, NULL, "Scale Windows", ot, 1, 1, 1, 1, 0, 0); - return ot; + ot = e_widget_table_add(evas, 0); + of = e_widget_framelist_add(evas, D_("Pager Settings"), 0); + + ow = e_widget_label_add (evas, D_("Zoom duration")); + e_widget_framelist_object_append(of, ow); + ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.01, 3.0, 0.01, 0, + &(cfdata->pager_duration), NULL,100); + e_widget_framelist_object_append(of, ow); + ow = e_widget_check_add(evas, D_("Fade in windows"), + &(cfdata->pager_fade_windows)); + e_widget_framelist_object_append(of, ow); + ow = e_widget_check_add(evas, D_("Fade out shelves and popups"), + &(cfdata->pager_fade_popups)); + e_widget_framelist_object_append(of, ow); + ow = e_widget_check_add(evas, D_("Darken desktop"), + &(cfdata->fade_desktop)); + e_widget_framelist_object_append (of, ow); + e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 0); + + e_widget_toolbook_page_append(otb, NULL, "Pager", ot, 1, 1, 1, 1, 1, 1); + + e_widget_toolbook_page_show(otb, 0); + + return otb; } static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { - scale_conf->grow = cfdata->grow; - scale_conf->tight = cfdata->tight; - scale_conf->scale_duration = cfdata->duration; - scale_conf->spacing = cfdata->spacing; - scale_conf->desks_duration = cfdata->desks_duration; - scale_conf->desks_spacing = cfdata->desks_spacing; - scale_conf->fade_popups = cfdata->fade_popups; - scale_conf->fade_desktop = cfdata->fade_desktop; - scale_conf->fade_windows = cfdata->fade_windows; - scale_conf->fade_desktop = cfdata->fade_desktop; - scale_conf->layout_mode = cfdata->layout_mode; - scale_conf->desks_layout_mode = cfdata->desks_layout_mode; - scale_conf->desks_grow = cfdata->desks_grow; - scale_conf->desks_tight = cfdata->desks_tight; + scale_conf->grow = cfdata->grow; + scale_conf->tight = cfdata->tight; + scale_conf->scale_duration = cfdata->duration; + scale_conf->spacing = cfdata->spacing; + scale_conf->desks_duration = cfdata->desks_duration; + scale_conf->desks_spacing = cfdata->desks_spacing; + scale_conf->fade_popups = cfdata->fade_popups; + scale_conf->fade_desktop = cfdata->fade_desktop; + scale_conf->fade_windows = cfdata->fade_windows; + scale_conf->fade_desktop = cfdata->fade_desktop; + scale_conf->layout_mode = cfdata->layout_mode; + scale_conf->desks_layout_mode = cfdata->desks_layout_mode; + scale_conf->desks_grow = cfdata->desks_grow; + scale_conf->desks_tight = cfdata->desks_tight; + scale_conf->pager_duration = cfdata->pager_duration; + scale_conf->pager_fade_popups = cfdata->pager_fade_popups; + scale_conf->pager_fade_windows = cfdata->pager_fade_windows; + scale_conf->pager_fade_desktop = cfdata->pager_fade_desktop; e_config_save_queue(); return 1; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-02-26 05:23:09 UTC (rev 57329) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-02-26 06:57:41 UTC (rev 57330) @@ -7,15 +7,6 @@ // while scale is active? // -#define DBG(...) -/* #define DBG(...) printf(__VA_ARGS__) */ - -#define OFFSET 32 -#define PLACE_RUNS 10000 -#define GROW_RUNS 1000 -#define SHRINK_RUNS 2000 -#define GROW 6.0 - static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); static void _gc_shutdown(E_Gadcon_Client *gcc); static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); @@ -30,1513 +21,35 @@ static void _scale_gc_cb_menu_post(void *data, E_Menu *menu); static void _scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi); -static void _scale_finish(void); -static void _scale_in(void); -static void _scale_out(void); - -static Eina_Bool _scale_cb_mouse_down(void *data, int type, void *event); -static Eina_Bool _scale_cb_mouse_move(void *data, int type, void *event); - -static void _scale_win_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); -static void _scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); -static void _scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a); -static void _scale_win_cb_intercept_layer(void *data, Evas_Object *obj, int l); - -typedef struct _Item Item; -typedef struct _Slot Slot; - -struct _Item -{ - Evas_Object *o, *o_win; - E_Border *bd; - E_Comp_Win *cw; - double scale; - int alpha; - - double x; - double y; - double w; - double h; - - double mx; - double my; - - /* border origin (is moved when scale on another desk) */ - double bd_x; - double bd_y; - - /* current position to draw by compositor */ - int cur_x, cur_y, cur_w, cur_h; - - /* borders' desk distance to the current desk */ - int dx, dy; - - int overlaps; - - int in_slots; -}; - -struct _Slot -{ - Eina_List *items; - int x, y, w, h; - Item *it; - double min; -}; - -static Ecore_X_Window input_win = 0; -static E_Msg_Handler *msg_handler = NULL; static E_Action *act = NULL; -static Eina_List *items = NULL; -static Eina_List *popups = NULL; -static Eina_List *handlers = NULL; -static Ecore_Animator *scale_animator = NULL; -static Eina_Bool scale_state = EINA_FALSE; -static double start_time; -static E_Zone *zone = NULL; -static int max_x, max_y, min_x, min_y; -static int use_x, use_y, use_w, use_h; -static int max_width, max_height; -static int spacing; -static int step_count; -static Item *background = NULL; -static Item *selected_item = NULL; -static E_Desk *current_desk = NULL; -static int show_all_desks = EINA_FALSE; -static int send_to_desk = EINA_FALSE; - -static Eina_Bool -_scale_redraw(void *blah) -{ - Eina_List *l; - Item *it; - double scale, a, in, duration; - - if (show_all_desks) - duration = scale_conf->desks_duration; - else - duration = scale_conf->scale_duration; - - if (scale_state) - scale = (ecore_time_get() - start_time) / duration; - else - scale = 1.0 - (ecore_time_get() - start_time) / duration; - - if (scale > 1.0) scale = 1.0; - if (scale < 0.0) scale = 0.0; - - in = log(10) * scale; - in = 1.0 / exp(in*in); - - EINA_LIST_FOREACH(items, l, it) - { - it->cur_w = it->bd->w * in + it->w * (1.0 - in); - it->cur_h = it->bd->h * in + it->h * (1.0 - in); - it->cur_x = it->bd_x * in + it->x * (1.0 - in); - it->cur_y = it->bd_y * in + it->y * (1.0 - in); - - evas_object_move(it->o, it->cur_x, it->cur_y); - evas_object_resize(it->o, it->cur_w, it->cur_h); - - evas_object_move(it->o_win, it->cur_x, it->cur_y); - evas_object_resize(it->o_win, it->cur_w, it->cur_h); - - a = 255.0 * (1.0 - in); - evas_object_color_set(it->o, a, a, a, a); - - if (!scale_conf->fade_windows) - continue; - - if ((it->bd->desk != current_desk) && (selected_item != it)) - { - double ax = it->cur_x - it->x; - double ay = it->cur_y - it->y; - double bx = it->bd_x - it->x; - double by = it->bd_y - it->y; - - a = (1.0 - sqrt(ax*ax + ay*ay) / sqrt(bx*bx + by*by)) * 255; - } - else - { - a = 255.0; - } - - it->alpha = a; - evas_object_color_set(it->o_win, a, a, a, a); - } - - if (scale_conf->fade_popups) - { - a = 255.0 * in; - - EINA_LIST_FOREACH(popups, l, it) - evas_object_color_set(it->o_win, a, a, a, a); - } - - if (scale_conf->fade_desktop && background) - { - a = 255.0 * (0.5 + in/2.0); - - evas_object_color_set(background->o_win, a, a, a, 255); - } - - e_manager_comp_evas_update(e_manager_current_get()); - - if (scale < 1.0 && scale > 0.0) - return 1; - - if (scale == 0.0) - _scale_finish(); - - scale_animator = NULL; - return 0; -} - static void -_scale_in() +_e_mod_action(const char *params) { - start_time = ecore_time_get(); - scale_state = EINA_TRUE; + if (!params) return; - if (!scale_animator) - scale_animator = ecore_animator_add(_scale_redraw, NULL); -} - -static void -_scale_out() -{ - double duration, now = ecore_time_get(); - - if (show_all_desks) - duration = scale_conf->desks_duration; - else - duration = scale_conf->scale_duration; - - if (now - start_time < duration) - start_time = now - (duration - (now - start_time)); - else - start_time = now; - - if (!scale_animator) - scale_animator = ecore_animator_add(_scale_redraw, NULL); - - scale_state = EINA_FALSE; -} - -static void -_scale_finish() -{ - Ecore_Event_Handler *handler; - Item *it; - E_Desk *desk; - - e_grabinput_release(input_win, input_win); - ecore_x_window_free(input_win); - input_win = 0; - - desk = e_desk_current_get(zone); - - if (selected_item && selected_item->bd->desk != desk) + if (!strncmp(params, "go_pager", 8)) { - if (send_to_desk) - { - e_border_desk_set(selected_item->bd, desk); - } - else - { - int tmp = e_config->desk_flip_animate_mode; - - desk = selected_item->bd->desk; - - e_config->desk_flip_animate_mode = 0; - e_desk_show(desk); - e_config->desk_flip_animate_mode = tmp; - } + pager_run(params); } - - EINA_LIST_FREE(items, it) + else if (!strncmp(params, "go_scale", 8)) { - evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); - evas_object_intercept_move_callback_del(it->o_win, _scale_win_cb_intercept_move); - evas_object_intercept_resize_callback_del(it->o_win, _scale_win_cb_intercept_resize); - evas_object_intercept_color_set_callback_del(it->o_win, _scale_win_cb_intercept_color); - evas_object_intercept_layer_set_callback_del(it->o_win, _scale_win_cb_intercept_layer); - - /* evas_object_clip_unset(it->o_win); */ - /* edje_object_part_unswallow(it->o, it->o_win); */ - evas_object_del(it->o); - - if (it->bd->desk != desk) - { - e_border_hide(it->bd, 2); - evas_object_hide(it->o_win); - evas_object_color_set(it->o_win, 255, 255, 255, 255); - evas_object_move(it->o_win, it->bd->x, it->bd->y); - evas_object_resize(it->o_win, it->cw->w, it->cw->h); - } - - e_object_unref(E_OBJECT(it->bd)); - E_FREE(it); + scale_run(params); } - - EINA_LIST_FREE(popups, it) - { - evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); - evas_object_color_set(it->o_win, 255, 255, 255, 255); - E_FREE(it); - } - - if (scale_conf->fade_desktop && background) - { - it = background; - evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); - evas_object_color_set(it->o_win, 255, 255, 255, 255); - E_FREE(it); - } - - EINA_LIST_FREE(handlers, handler) - ecore_event_handler_del(handler); - - e_msg_handler_del(msg_handler); - msg_handler = NULL; - zone = NULL; - selected_item = NULL; - current_desk = NULL; - send_to_desk = EINA_FALSE; - show_all_desks = EINA_FALSE; - - e_manager_comp_evas_update(e_manager_current_get()); } - static void -_scale_win_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - Item *it = data; - - evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig); - - if (it->bd) - { - e_object_unref(E_OBJECT(it->bd)); - _scale_out(); - - evas_object_intercept_move_callback_del(it->o_win, _scale_win_cb_intercept_move); - evas_object_intercept_resize_callback_del(it->o_win, _scale_win_cb_intercept_resize); - evas_object_intercept_color_set_callback_del(it->o_win, _scale_win_cb_intercept_color); - evas_object_intercept_layer_set_callback_del(it->o_win, _scale_win_cb_intercept_layer); - - /* evas_object_clip_unset(it->o_win); */ - /* edje_object_part_unswallow(it->o, it->o_win); */ - evas_object_del(it->o); - - items = eina_list_remove(items, it); - } - else - { - popups = eina_list_remove(popups, it); - } - - E_FREE(it); -} - -static void -_scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y) -{ - Item *it = data; - - evas_object_move(obj, it->cur_x, it->cur_y); -} - -static void -_scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord w, Evas_Coord h) -{ - Item *it = data; - - evas_object_resize(obj, it->cur_w, it->cur_h); -} - -static void -_scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a) -{ - Item *it = data; - - evas_object_color_set(obj, it->alpha, it->alpha, it->alpha, it->alpha); -} - -static void -_scale_win_cb_intercept_layer(void *data, Evas_Object *obj, int l) -{ - Item *it = data; - - evas_object_layer_set(it->o_win, l); - evas_object_stack_above(it->o, it->o_win); -} - -static void -_scale_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src, E_Desk *desk) -{ - Item *it; - - if (!e_manager_comp_src_image_get(man, src)) return; - - E_Comp_Win *cw = (void*)src; - - if (!cw->bd) - { - if (cw->win == zone->container->bg_win) - { - if (scale_conf->fade_desktop) - { - it = E_NEW(Item, 1); - it->o_win = e_manager_comp_src_shadow_get(man, src); - evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_delorig, it); - background = it; - } - } - else if (scale_conf->fade_popups) - { - it = E_NEW(Item, 1); - it->o_win = e_manager_comp_src_shadow_get(man, src); - evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_delorig, it); - - popups = eina_list_append(popups, it); - } - - return; - } - - if (!cw->bd) return; - - if (cw->bd->zone != desk->zone) - return; - - if ((!show_all_desks) && (cw->bd->desk != desk)) - return; - - if (cw->bd->iconic) - return; - - it = E_NEW(Item, 1); - it->scale = 1.0; - - it->dx = cw->bd->desk->x - desk->x; - it->dy = cw->bd->desk->y - desk->y; - - it->x = cw->bd->x + it->dx * desk->zone->w; - it->y = cw->bd->y + it->dy * desk->zone->h; - it->w = cw->bd->w; - it->h = cw->bd->h; - - it->bd_x = it->x; - it->bd_y = it->y; - - it->cur_x = it->x; - it->cur_y = it->y; - it->cur_w = it->w; - it->cur_h = it->h; - - e_object_ref(E_OBJECT(cw->bd)); - it->bd = cw->bd; - it->cw = cw; - - it->o_win = e_manager_comp_src_shadow_get(man, src); - it->o = edje_object_add(e); - if (!e_theme_edje_object_set(it->o, "base/theme/modules/scale", - "modules/scale/win")) - edje_object_file_set(it->o, scale_conf->theme_path, "modules/scale/win"); - - evas_object_stack_above(it->o, it->o_win); - /* edje_object_part_swallow(it->o, "e.swallow.win", it->o_win); */ - /* evas_object_clip_set(it->o_win, it->o); - * evas_object_move(it->o, it->x, it->y); */ - - evas_object_show(it->o); - - evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_delorig, it); - - evas_object_intercept_move_callback_add(it->o_win, _scale_win_cb_intercept_move, it); - evas_object_intercept_resize_callback_add(it->o_win, _scale_win_cb_intercept_resize, it); - evas_object_intercept_color_set_callback_add(it->o_win, _scale_win_cb_intercept_color, it); - evas_object_intercept_layer_set_callback_add(it->o_win, _scale_win_cb_intercept_layer, it); - - if (it->bd->desk != desk) - { - e_border_show(it->bd); - evas_object_move(it->o_win, it->x, it->y); - } - - items = eina_list_append(items, it); -} - -static int -_scale_grow() -{ - Item *it, *ot; - Eina_List *l, *ll; - - int cont = 0; - int overlap; - double grow_l, grow_r, grow_d, grow_u; - - double mean = 0; - EINA_LIST_FOREACH(items, l, it) - { - it->scale = it->w / (double)it->bd->w; - mean += it->scale; - } - - mean /= (double) eina_list_count(items); - - EINA_LIST_FOREACH(items, l, it) - { - overlap = 0; - - if (it->scale > mean) - continue; - - if (it->w >= it->bd->w) - continue; - if (it->h >= it->bd->h) - continue; - - if (it->bd->w > it->bd->h) - { - grow_l = grow_r = GROW; - grow_u = grow_d = GROW * (double)it->bd->h/(double)it->bd->w; - } - else - { - grow_l = grow_r = GROW * (double)it->bd->w/(double)it->bd->h; - grow_u = grow_d = GROW; - } - - if (it->x - grow_l < min_x) - grow_l = 0; - if (it->y - grow_u < min_y) - grow_u = 0; - if (it->x + it->w + grow_r > max_x) - grow_r = 0; - if (it->y + it->h + grow_d > max_y) - grow_d = 0; - - if ((grow_l + grow_r) == 0) - continue; - if ((grow_u + grow_d) == 0) - continue; - - EINA_LIST_FOREACH(items, ll, ot) - { - if (it == ot) - continue; - if (grow_l && E_INTERSECTS(it->x - grow_l - spacing ,it->y, - it->w + spacing*2, it->h + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_l = 0; - - if (grow_r && E_INTERSECTS(it->x - spacing, it->y - spacing, - it->w + grow_r + spacing*2, it->h + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_r = 0; - - if ((grow_l == 0) && (grow_r == 0) && (overlap = 1)) - break; - - if (grow_u && E_INTERSECTS(it->x - spacing, it->y - spacing - grow_u, - it->w + spacing*2, it->h + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_u = 0; - - if (grow_d && E_INTERSECTS(it->x - spacing, it->y - spacing, - it->w + spacing*2, it->h + grow_d + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_d = 0; - - if ((grow_u == 0) && (grow_d == 0) && (overlap = 1)) - break; - } - - if (overlap) - continue; - - if (it->bd->w > it->bd->h) - { - if ((grow_u > 0) && (grow_d > 0)) - it->w += grow_l + grow_r; - else - it->w += MAX(grow_l, grow_r); - - it->h = it->w * (double)it->bd->h / (double)it->bd->w; - } - else - { - if ((grow_r > 0) && (grow_l > 0)) - it->h += grow_u + grow_d; - else - it->h += MAX(grow_u, grow_d); - - it->w = it->h * (double)it->bd->w / (double)it->bd->h; - } - it->x -= grow_l; - it->y -= grow_u; - - cont++; - } - - return cont; -} - -static void -_scale_displace(Item *it, Item *ot, int disp) -{ - /* cycle items with same center around to get even distribution. - dont try to understand this but these initial conditions - are important.. you can have up to 9 maximized windows. - if you can figure out more please tell me :) */ - - if (disp % 8 == 0) - { - // 1. - it->y -= 1; - it->x -= 1; - // 2. - ot->x += 1; - ot->y -= 1; - } - else if (disp % 8 == 1) - { - // 3. - ot->y += 1; - } - else if (disp % 8 == 2) - { - // 4. - ot->x -= 2; - ot->y += 2; - } - else if (disp % 8 == 3) - { - // 5. - ot->x += 2; - ot->y += 2; - } - else if (disp % 8 == 4) - { - // 6. - ot->x += 1; - ot->y += 1; - } - else if (disp % 8 == 5) - { - // 7. - ot->x -= 1; - ot->y += 1; - } - else if (disp % 8 == 6) - { - // 8. - ot->x -= 1; - ot->y -= 1; - } - else if (disp % 8 == 7) - { - ot->x += 1; - ot->y -= 1; - } -} - -static int -_scale_place(int offset) -{ - Item *it, *ot; - Eina_List *l, *ll; - int overlap = 0; - int outside = 0; - - EINA_LIST_FOREACH(items, l, it) - { - it->mx = it->x; - it->my = it->y; - } - - int disp = 0; - - EINA_LIST_FOREACH(items, l, it) - { - EINA_LIST_FOREACH(items, ll, ot) - { - int w = it->w; - int h = it->h; - - if (it == ot) - continue; - - if (!E_INTERSECTS(it->x - offset, it->y - offset, - it->w + offset*2, it->h + offset*2, - ot->x, ot->y, ot->w, ot->h)) - continue; - - overlap += 1; - - it->overlaps++; - - if (it->x < ot->x) - w += it->x - ot->x; - if (w < 0) w = 0; - - if (it->x + it->w > ot->x + ot->w) - w = ot->x + ot->w - it->x; - - if (it->y < ot->y) - h += it->y - ot->y; - if (h < 0) h = 0; - - if (it->y + it->h > ot->y + ot->h) - h = ot->y + ot->h - it->y; - - double dist_y = (it->y + it->h/2) - (ot->y + ot->h/2); - double dist_x = (it->x + it->w/2) - (ot->x + ot->w/2); - - if (dist_x == 0 && dist_y == 0) - { - _scale_displace(it, ot, disp); - disp++; - } - else if (w > h) - { - if (dist_y) - { - dist_y = (dist_y > 0 ? 2 : -2); - it->my += dist_y; - } - if (dist_x) - { - dist_x = (dist_x > 0 ? 1 : -1); - it->mx += dist_x; - } - } - else //if (w < h) - { - if (dist_y) - { - dist_y = (dist_y > 0 ? 1 : -1); - it->my += dist_y; - } - if (dist_x) - { - dist_x = (dist_x > 0 ? 2 : -2); - it->mx += dist_x; - } - } - } - } - - EINA_LIST_FOREACH(items, l, it) - { - it->x = it->mx; - it->y = it->my; - - if (it->x < min_x) - { - outside = 1; - it->x = min_x; - } - - if (it->y < min_y) - { - outside = 1; - it->y = min_y; - } - - if (it->x + it->w > max_x) - { - outside = 1; - it->x = max_x - it->w; - } - - if (it->y + it->h > max_y) - { - outside = 1; - it->y = max_y - it->h; - } - } - - if (!(overlap || outside)) - return 0; - - if (outside && (step_count++ > 50)) - { - double zone_diag = sqrt(zone->w * zone->h); - double sw, sh; - step_count = 0; - EINA_LIST_FOREACH(items, l, it) - { - if (!it->overlaps) - continue; - - if (it->scale <= 0.005) - continue; - - it->scale -= it->scale * - (0.001 + (sqrt(it->bd->w * it->bd->h) / zone_diag) / 50.0); - - sw = (double)it->bd->w * it->scale; - sh = (double)it->bd->h * it->scale; - it->x += (it->w - sw)/2.0; - it->y += (it->h - sh)/2.0; - it->w = sw; - it->h = sh; - - it->overlaps = 0; - } - return 1; - } - - return overlap || outside; -} - -static int -_scale_shrink() -{ - Eina_List *l, *ll; - Item *it, *ot; - int shrunk = 0; - double move_x; - double move_y; - - EINA_LIST_REVERSE_FOREACH(items, l, it) - { - if (show_all_desks) - { - move_x = ((it->x + it->w/2.0) - zone->w/2.0) / 5.0; - move_y = ((it->y + it->h/2.0) - zone->h/2.0) / 5.0; - } - else - { - move_x = ((it->x + it->w/2.0) - (double)(it->bd->x + it->bd->w/2.0)) / 10.0; - move_y = ((it->y + it->h/2.0) - (double)(it->bd->y + it->bd->h/2.0)) / 10.0; - } - - if (!(move_y || move_x)) - continue; - - EINA_LIST_FOREACH(items, ll, ot) - { - if (it == ot) continue; - - while(move_x) - { - if (E_INTERSECTS(it->x - move_x, it->y, it->w, it->h, - ot->x - spacing, ot->y - spacing, - ot->w + spacing*2, ot->h + spacing*2)) - move_x = move_x / 2.0; - else break; - } - - while(move_y) - { - if (E_INTERSECTS(it->x, it->y - move_y, it->w, it->h, - ot->x - spacing, ot->y - spacing, - ot->w + spacing*2, ot->h + spacing*2)) - move_y = move_y / 2.0; - else break; - } - - if (!(move_y || move_x)) break; - } - - it->x -= move_x; - it->y -= move_y; - - if (move_y > 1 || move_x > 1) - shrunk++; - } - - return shrunk; -} - - -/* TODO add slot item an calc distance only once */ -static Slot *cur_slot = NULL; - -static double -_slot_dist(const Item *it, const Slot *slot) -{ - double dx = it->x - slot->x; - double dy = it->y - slot->y; - double dw = (it->x + it->w) - (slot->x + slot->w); - double dh = (it->y + it->h) - (slot->y + slot->h); - - return (sqrt(dx*dx + dy*dy + dw*dw + dh*dh)); -} - -static int -_cb_sort_nearest(const void *d1, const void *d2) -{ - const Item *it1 = d1; - const Item *it2 = d2; - - return (_slot_dist(it1, cur_slot) < _slot_dist(it2, cur_slot)) ? -1 : 1; -} - -static int -_scale_place_slotted() -{ - Eina_List *l, *ll, *slots = NULL; - Slot *slot, *slot2; - Item *it; - int rows, cols, cnt, x, y, w, h, start; - int fast = 1; - int cont = 0, i = 0; - double min_x, max_x, min_y, max_y; - - cnt = eina_list_count(items); - - rows = sqrt(cnt); - cols = cnt/rows; - - if (cols*rows < cnt) - cols += 1; - - if (cnt <= 2) - { - cols = 2; - rows = 1; - } - else if (cnt <= 4) - { - cols = 2; - rows = 2; - } - else if (cnt <= 6) - { - cols = 3; - rows = 2; - } - else if (cnt <= 8) - { - cols = 3; - rows = 3; - } - - DBG("%d rows, %d cols -- cnt %d\n", rows, cols, cnt); - - max_x = max_y = 0; - min_x = min_y = 100000; - - EINA_LIST_FOREACH(items, l, it) - { - if (it->x < min_x) min_x = it->x; - if (it->y < min_y) min_y = it->y; - if (it->x + it->w > max_x) max_x = it->x + it->w; - if (it->y + it->h > max_y) max_y = it->y + it->h; - } - - w = (max_x - min_x) / cols; - h = (max_y - min_y) / rows; - l = items; - - for (y = 0; y < rows; y++) - { - for (x = 0; x < cols; x++) - { - if (fast && !l) break; - - slot = E_NEW(Slot, 1); - slot->x = min_x + x * w; - slot->y = min_y + y * h; - slot->w = w; - slot->h = h; - - if (fast) - { - slot->it = eina_list_data_get(l); - if (l) l = l->next; - } - else - { - cur_slot = slot; - slot->items = eina_list_clone(items); - slot->items = eina_list_sort(slot->items, cnt, _cb_sort_nearest); - slot->it = eina_list_data_get(slot->items); - slot->items = eina_list_remove_list(slot->items, slot->items); - slot->min = _slot_dist(slot->it, slot); - } - - slots = eina_list_append(slots, slot); - - DBG("add slot: %dx%d, \t%f -> %d:%d\n", slot->x, slot->y, slot->min, - (int)(slot->it->x), (int)(slot->it->y)); - } - } - - if (!fast) - { - cont = 1; - EINA_LIST_FOREACH(items, l, it) - it->in_slots = cols * rows; - } - - for (i = 0; (i < PLACE_RUNS) && cont; i++) - { - cont = 0; - EINA_LIST_FOREACH(slots, l, slot) - { - EINA_LIST_FOREACH(slots, ll, slot2) - { - if (slot == slot2) - continue; - - if (slot->it != slot2->it) - continue; - - Item *it1 = eina_list_data_get(slot->items); - Item *it2 = eina_list_data_get(slot2->items); - if (!it1 || !it2) - continue; - - double d1 = _slot_dist(it1, slot); - double d2 = _slot_dist(it2, slot2); - - cont = 1; - - DBG("%dx%d - compare:\n\ts1: %dx%d (%dx%d:%f),\n\ts2 %dx%d (%dx%d:%f)\n", - (int)slot->it->x, (int)slot->it->y, - slot->x, slot->y, (int)it1->x, (int)it1->y, d1, - slot2->x, slot2->y, (int)it2->x, (int)it2->y, d2); - - if (slot->it->in_slots > 1 && slot->min + d1 >= slot2->min + d2) - { - slot->it->in_slots--; - slot->it = it1; - slot->min = d1; - slot->items = eina_list_remove_list(slot->items, slot->items); - break; - } - } - } - } - - cont = 1; - - for (i = 0; (i < PLACE_RUNS) && ( fast && cont); i++) - { - cont = 0; - EINA_LIST_FOREACH(slots, l, slot) - { - EINA_LIST_FOREACH(l->next, ll, slot2) - { - double d1, d2; - - d1 = _slot_dist(slot->it, slot) + _slot_dist(slot2->it, slot2); - d2 = _slot_dist(slot->it, slot2) + _slot_dist(slot2->it, slot); - if (d1 > d2) - { - it = slot->it; - slot->it = slot2->it; - slot2->it = it; - cont = 1; - } - } - } - } - - EINA_LIST_FOREACH(slots, l, slot) - { - if (!slot->it) - continue; - - EINA_LIST_FOREACH(slots, ll, slot2) - { - if (slot == slot2) - continue; - - if (slot->it != slot2->it) - continue; - - if (_slot_dist(slot->it, slot) > _slot_dist(slot2->it, slot2)) - slot->it = NULL; - else - slot2->it = NULL; - } - } - - h = (zone->h - spacing) / rows; - w = (zone->w - spacing) / cols; - - for (y = 0, l = slots; l && (y < rows); y++) - { - ll = l; - for (x = 0, cnt = 0; l && x < cols; x++, l = eina_list_next(l)) - { - slot = eina_list_data_get(l); - if (slot->it) cnt++; - } - - if (cnt < cols) - start = (w * (cols - cnt))/2.0; - else - start = spacing/2.0; - - for (x = 0; ll && x < cnt; ll = eina_list_next(ll)) - { - slot = eina_list_data_get(ll); - if (!slot->it) continue; - - slot->x = start + x * w; - slot->y = y * h; - slot->w = w; - slot->h = h; - x++; - } - } - - EINA_LIST_FOREACH(slots, l, slot) - { - if (slot->it) - { - it = slot->it; - - if (it->w > slot->w - spacing) - { - it->w = slot->w - spacing; - it->h = it->w * (double)it->bd->h / (double)it->bd->w; - } - if (it->h > slot->h - spacing) - { - it->h = slot->h - spacing; - it->w = it->h * (double)it->bd->w / (double)it->bd->h; - } - it->x = slot->x + (slot->w - it->w)/2.0; - it->y = slot->y + (slot->h - it->h)/2.0; - - DBG("place: %d:%d %dx%d -> %d:%d %dx%d\n", - (int)it->bd_x, (int)it->bd_y, (int)it->bd->w, (int)it->bd->h, - (int)it->x, (int)it->y, (int)it->w, (int)it->h); - } - - EINA_LIST_FREE(slot->items, it); - E_FREE(slot); - } - - return 1; -} - - -static int -_cb_sort_center(const void *d1, const void *d2) -{ - const Item *it1 = d1; - const Item *it2 = d2; - - double dx1 = ((it1->x + it1->w/2.0) - (double)(max_width/2)); - double dy1 = ((it1->y + it1->h/2.0) - (double)(max_height/2)); - - double dx2 = ((it2->x + it2->w/2.0) - (double)(max_width/2)); - double dy2 = ((it2->y + it2->h/2.0) - (double)(max_height/2)); - - return (sqrt(dx1*dx1 + dy1*dy1) > sqrt(dx2*dx2 + dy2*dy2)) ? -1 : 1; -} - -static void -_scale_place_natural() -{ - Eina_List *l; - int offset, i = 0; - Item *it; - - max_width = zone->w; - max_height = zone->h; - - if (show_all_desks) - { - max_width = zone->h * zone->desk_x_count; - max_height = zone->w * zone->desk_y_count; - } - - items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); - - offset = spacing; - - if (scale_conf->grow && (spacing < OFFSET)) - offset = OFFSET; - if (scale_conf->tight && (spacing < OFFSET)) - offset = OFFSET; - - step_count = 0; - - while ((i++ < PLACE_RUNS) && - (_scale_place(offset) || - (min_x < use_x) || - (min_y < use_y) || - (max_x > use_w) || - (max_y > use_h))) - { - /* shrink region to visible region */ - if (min_x < use_x) min_x += 2; - if (min_y < use_y) min_y += 2; - if (min_x > use_x) min_x = use_x; - if (min_y > use_y) min_y = use_y; - - if (max_x > use_w) max_x -= 2; - if (max_y > use_h) max_y -= 2; - if (max_x < use_w) max_x = use_w; - if (max_y < use_h) max_y = use_h; - - if (!show_all_desks) - continue; - - /* move other desks windows into visible region */ - EINA_LIST_FOREACH(items, l, it) - { - if ((min_x < use_x) && (it->dx < 0) && it->x < 0) it->x += 4.0; - if ((min_y < use_y) && (it->dy < 0) && it->y < 0) it->y += 4.0; - - if ((max_x > use_w) && (it->dx > 0) && it->x > zone->w) it->x -= 4.0; - if ((max_y > use_h) && (it->dy > 0) && it->y > zone->h) it->y -= 4.0; - } - } -} - -void -scale_run(E_Manager *man) -{ - Eina_List *l; - E_Manager_Comp_Source *src; - Evas *e; - int i; - Item *it; - - zone = e_util_zone_current_get(e_manager_current_get()); - current_desk = e_desk_current_get(zone); - - start_time = ecore_time_get(); - - input_win = ecore_x_window_input_new(zone->container->win, 0, 0, 1, 1); - ecore_x_window_show(input_win); - if (!e_grabinput_get(input_win, 0, input_win)) - { - ecore_x_window_free(input_win); - input_win = 0; - return; - } - - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_BUTTON_DOWN, _scale_cb_mouse_down, NULL)); - - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_MOVE, _scale_cb_mouse_move, NULL)); - - e = e_manager_comp_evas_get(man); - - EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) - { - _scale_win_new(e, man, src, current_desk); - } - - if ((eina_list_count(items) < 2) && (!show_all_desks)) - { - _scale_finish(); - return; - } - - if (show_all_desks) - spacing = scale_conf->desks_spacing; - else - spacing = scale_conf->spacing; - - if (!scale_conf->fade_popups) - { - e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); - use_w += use_x - spacing*2; - use_h += use_y - spacing*2; - use_x += spacing; - use_y += spacing; - } - else - { - use_w = zone->w - spacing; - use_h = zone->h - spacing; - use_x = use_y = spacing; - } - - min_x = -zone->w * zone->desk_x_current; - min_y = -zone->h * zone->desk_y_current; - max_x = zone->w + zone->w * ((zone->desk_x_count - 1) - zone->desk_x_current); - max_y = zone->h + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current); - - /* scale all windows down to be next to each other on one zone */ - if (show_all_desks) - { - if (scale_conf->desks_layout_mode) - _scale_place_slotted(); - else - _scale_place_natural(); - } - else - { - if (scale_conf->layout_mode) - _scale_place_slotted(); - else - _scale_place_natural(); - } - - min_x = use_x; - min_y = use_y; - max_x = use_w; - max_y = use_h; - - if ((scale_conf->grow && !show_all_desks) || - (scale_conf->desks_grow && show_all_desks)) - { - i = 0; - while (i++ < GROW_RUNS && _scale_grow()); - DBG("grow %d", i); - } - - if ((scale_conf->tight && !show_all_desks) || - (scale_conf->desks_tight && show_all_desks)) - { - items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); - i = 0; - while (i++ < SHRINK_RUNS && _scale_shrink()); - DBG("shrunk %d", i); - - /* if (scale_conf->grow) - * { - * i = 0; - * while (i++ < GROW_RUNS && _scale_grow()); - * DBG("grow %d", i); - * } */ - } - - if (show_all_desks)//&& !scale_conf->desks_layout_mode) - { - /* center and move windows near visible desk - * to make the sliding smoother */ - - min_x = zone->w; - min_y = zone->h; - max_x = 0; - max_y = 0; - - EINA_LIST_FOREACH(items, l, it) - { - if (it->x < min_x) min_x = it->x; - if (it->y < min_y) min_y = it->y; - if (it->x + it->w > max_x) max_x = it->x + it->w; - if (it->y + it->h > max_y) max_y = it->y + it->h; - } - - EINA_LIST_FOREACH(items, l, it) - { - it->x = (it->x - min_x) + use_x + ((use_w - use_x) - (max_x - min_x))/2.0; - it->y = (it->y - min_y) + use_y + ((use_h - use_y) - (max_y - min_y))/2.0; - - if (it->dx > 0) it->bd_x = zone->w + it->bd->x/4; - if (it->dy > 0) it->bd_y = zone->h + it->bd->y/4; - if (it->dx < 0) it->bd_x = -(zone->w - it->bd->x)/4; - if (it->dy < 0) it->bd_y = -(zone->h + it->bd->y)/4; - } - } - - DBG("time: %f\n", ecore_time_get() - start_time); - - _scale_in(); -} - - -static Eina_Bool -_scale_cb_mouse_move(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Move *ev = event; - Item *it; - Eina_List *l; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - if (!scale_state) - return ECORE_CALLBACK_PASS_ON; - - EINA_LIST_FOREACH(items, l, it) - if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) - break; - - if (selected_item && (it != selected_item)) - { - edje_object_signal_emit(selected_item->o, "mouse,out", "e"); - selected_item = NULL; - } - - if (it) - { - edje_object_signal_emit(it->o, "mouse,in", "e"); - selected_item = it; - } - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_scale_cb_mouse_down(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Button *ev = event; - Item *it, *ot; - Eina_List *l; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - if (!scale_state) - return ECORE_CALLBACK_PASS_ON; - - EINA_LIST_FOREACH(items, l, it) - if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) - break; - - if (!it) - { - _scale_out(); - return ECORE_CALLBACK_PASS_ON; - } - - e_border_raise(it->bd); - - - if (it->bd->desk != e_desk_current_get(it->bd->zone)) - { - if (ev->buttons == 1) - { - selected_item = it; - current_desk = it->bd->desk; - - EINA_LIST_FOREACH(items, l, ot) - { - if (ot->bd->desk == it->bd->desk) - { - ot->bd_x = ot->bd->x; - ot->bd_y = ot->bd->y; - } - else - { - if (ot->dx > it->dx) - ot->bd_x = ot->bd->x + zone->w; - else if (ot->dx < it->dx) - ot->bd_x = ot->bd->x - zone->w; - - if (ot->dy > it->dy) - ot->bd_y = ot->bd->y + zone->h; - else if (ot->dy < it->dy) - ot->bd_y = ot->bd->y - zone->h; - } - } - } - else if (ev->buttons == 3) - { - send_to_desk = EINA_TRUE; - selected_item = it; - it->bd_x = it->bd->x; - it->bd_y = it->bd->y; - } - } - - _scale_out(); - - return ECORE_CALLBACK_PASS_ON; -} - -static void -_scale_handler(void *data, const char *name, const char *info, int val, - E_Object *obj, void *msgdata) -{ - E_Manager *man = (E_Manager *)obj; - E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata; - Evas *e; - - /* DBG("handler... '%s' '%s'\n", name, info); */ - if (strcmp(name, "comp.manager")) return; - - e = e_manager_comp_evas_get(man); - if (!strcmp(info, "change.comp")) - { - if (!e) DBG("TTT: No comp manager\n"); - else DBG("TTT: comp canvas = %p\n", e); - } - else if (!strcmp(info, "resize.comp")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "add.src")) - { - /* DBG("%s: %p | %p\n", info, man, src); */ - _scale_win_new(e, man, src, e_desk_current_get(e_util_zone_current_get(man))); - - } - else if (!strcmp(info, "del.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "config.src")) - { - - DBG("%s: %p | %p\n", info, man, src); - } - /* else if (!strcmp(info, "visible.src")) - * { - * DBG("%s: %p | %p\n", info, man, src); - * } */ -} - -static void _e_mod_action_cb_edge(E_Object *obj, const char *params, E_Event_Zone_Edge *ev) { - Eina_List *list, *l; - E_Manager *man; - - msg_handler = e_msg_handler_add(_scale_handler, NULL); - list = e_manager_list(); - - if (params && !strcmp(params, "show_all_desks")) - show_all_desks = EINA_TRUE; - else - show_all_desks = EINA_FALSE; - - EINA_LIST_FOREACH(list, l, man) - { - Evas *e = e_manager_comp_evas_get(man); - if (e) scale_run(man); - } + _e_mod_action(params); } static void _e_mod_action_cb(E_Object *obj, const char *params) { - Eina_List *list, *l; - E_Manager *man; - - msg_handler = e_msg_handler_add(_scale_handler, NULL); - list = e_manager_list(); - - if (params && !strcmp(params, "show_all_desks")) - show_all_desks = EINA_TRUE; - else - show_all_desks = EINA_FALSE; - - EINA_LIST_FOREACH(list, l, man) - { - Evas *e = e_manager_comp_evas_get(man); - if (e) scale_run(man); - } + _e_mod_action(params); } - /* Module and Gadcon stuff */ typedef struct _Instance Instance; @@ -1611,6 +124,11 @@ E_CONFIG_VAL(D, T, desks_spacing, DOUBLE); E_CONFIG_VAL(D, T, fade_windows, UCHAR); + E_CONFIG_VAL(D, T, pager_duration, DOUBLE); + E_CONFIG_VAL(D, T, pager_fade_windows, UCHAR); + E_CONFIG_VAL(D, T, pager_fade_popups, UCHAR); + E_CONFIG_VAL(D, T, pager_fade_desktop, UCHAR); + E_CONFIG_LIST(D, T, conf_items, conf_item_edd); scale_conf = e_config_domain_load("module.scale", conf_edd); @@ -1638,8 +156,12 @@ { act->func.go = _e_mod_action_cb; act->func.go_edge = _e_mod_action_cb_edge; - e_action_predef_name_set(D_("Desktop"), D_("Scale Windows"), "scale-windows", "", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Windows / All Desktops"), "scale-windows", "show_all_desks", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Windows"), + "scale-windows", "go_scale", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Windows (All Desktops)"), + "scale-windows", "go_scale_all", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager"), + "scale-windows", "go_pager", NULL, 0); } return m; @@ -1679,8 +201,9 @@ if (act) { - e_action_predef_name_del(D_("Desktop"), - D_("Scale Windows")); + e_action_predef_name_del(D_("Desktop"), D_("Scale Windows")); + e_action_predef_name_del(D_("Desktop"), D_("Scale Windows (All Desktops)")); + e_action_predef_name_del(D_("Desktop"), D_("Scale Pager")); e_action_del("scale-windows"); } @@ -1797,6 +320,10 @@ scale_conf->desks_spacing = 44; scale_conf->layout_mode = 0; scale_conf->desks_layout_mode = 1; + scale_conf->pager_duration = 0.4; + scale_conf->pager_fade_popups = 1; + scale_conf->pager_fade_desktop = 0; + scale_conf->pager_fade_windows = 1; _scale_conf_item_get(NULL); IFMODCFGEND; @@ -1911,7 +438,6 @@ inst->menu = NULL; } -/* call configure from popup */ static void _scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi) { Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-02-26 05:23:09 UTC (rev 57329) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-02-26 06:57:41 UTC (rev 57330) @@ -1,7 +1,7 @@ #ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H -#define MOD_CONFIG_FILE_EPOCH 0x0004 +#define MOD_CONFIG_FILE_EPOCH 0x0005 #define MOD_CONFIG_FILE_GENERATION 0x0001 #define MOD_CONFIG_FILE_VERSION \ ((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION) @@ -10,6 +10,9 @@ #include <libintl.h> #define D_(str) dgettext(PACKAGE, str) +#define DBG(...) +/* #define DBG(...) printf(__VA_ARGS__) */ + typedef struct _Config_Item Config_Item; typedef struct _Config Config; typedef struct _E_Comp_Win E_Comp_Win; @@ -22,12 +25,14 @@ E_Config_Dialog *cfd; const char *theme_path; + /* scale current desk */ int layout_mode; unsigned char tight; unsigned char grow; double scale_duration; double spacing; + /* scale all desk */ int desks_layout_mode; unsigned char desks_tight; unsigned char desks_grow; @@ -37,6 +42,12 @@ unsigned char fade_popups; unsigned char fade_desktop; + + /* pager */ + double pager_duration; + unsigned char pager_fade_windows; + unsigned char pager_fade_popups; + unsigned char pager_fade_desktop; }; struct _Config_Item @@ -123,7 +134,8 @@ E_Config_Dialog *e_int_config_scale_module(E_Container *con, const char *params); -void scale_run(E_Manager *man); +void scale_run(const char *params); +void pager_run(const char *params); extern Config *scale_conf; |
From: Enlightenment S. <no-...@en...> - 2011-02-27 13:28:06
|
Log: e-modules/comp-scale: fix compilation: how got that 'how' in there?, cleanup Author: jeffdameth Date: 2011-02-27 05:28:00 -0800 (Sun, 27 Feb 2011) New Revision: 57382 Trac: http://trac.enlightenment.org/e/changeset/57382 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-02-27 13:16:59 UTC (rev 57381) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-02-27 13:28:00 UTC (rev 57382) @@ -111,7 +111,7 @@ part { name: "over_clip"; mouse_events: 0; - how type: RECT; + type: RECT; description { state: "default" 0.0; color: 0 0 0 0; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-02-27 13:16:59 UTC (rev 57381) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-02-27 13:28:00 UTC (rev 57382) @@ -11,7 +11,6 @@ E_Border *bd; E_Desk *desk; E_Comp_Win *cw; - double scale; int alpha; double x; @@ -32,8 +31,6 @@ /* borders' desk distance to the current desk */ int dx, dy; - int layer; - int mouse_down; }; |
From: Enlightenment S. <no-...@en...> - 2011-03-02 16:15:14
|
Log: e-modules/comp-scale: start to add keybindings. + esc key in scale for k-s Author: jeffdameth Date: 2011-03-02 08:15:06 -0800 (Wed, 02 Mar 2011) New Revision: 57469 Trac: http://trac.enlightenment.org/e/changeset/57469 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-02 14:09:34 UTC (rev 57468) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-02 16:15:06 UTC (rev 57469) @@ -230,35 +230,35 @@ } } part { - name: "event"; + name: "bg"; mouse_events: 1; type: RECT; description { state: "default" 0.0; - color: 0 0 0 60; + color: 0 0 0 20; } description { - state: "focused" 0.0; - color: 0 0 0 80; + state: "unfocused" 0.0; + color: 0 0 0 70; } } } programs { program { - name: "mouse_in"; - signal: "mouse,in"; + name: "focused"; + signal: "focused"; source: "e"; - action: STATE_SET "focused" 0.0; - transition: SINUSOIDAL 0.3; - target: "event"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.2; + target: "bg"; } program { - name: "mouse_out"; - signal: "mouse,out"; + name: "unfocused"; + signal: "unfocused"; source: "e"; - action: STATE_SET "default" 0.0; - transition: SINUSOIDAL 0.4; - target: "event"; + action: STATE_SET "unfocused" 0.0; + transition: SINUSOIDAL 0.3; + target: "bg"; } } } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-02 14:09:34 UTC (rev 57468) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-02 16:15:06 UTC (rev 57469) @@ -22,34 +22,111 @@ static void _scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi); static E_Action *act = NULL; +static int _hold_count = 0; +static int _hold_mod = 0; +Eina_Bool +e_mod_hold_modifier_check(Ecore_Event_Key *ev) +{ + if (!_hold_mod) + return EINA_TRUE; + if ((_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) && (!strcmp(ev->key, "Shift_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) && (!strcmp(ev->key, "Shift_R"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_CTRL) && (!strcmp(ev->key, "Control_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_CTRL) && (!strcmp(ev->key, "Control_R"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Alt_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Alt_R"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Meta_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Meta_R"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Super_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Super_R"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Super_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Super_R"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Mode_switch"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Meta_L"))) + _hold_count--; + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Meta_R"))) + _hold_count--; + if (_hold_count <= 0) + { + return EINA_FALSE; + } + return EINA_TRUE; +} + + static void -_e_mod_action(const char *params) +_e_mod_action(const char *params, int modifiers) { + int active; + E_Manager *man; + Evas *e; + if (!params) return; + /* we expect that there is only one manager!!!*/ + man = eina_list_data_get(e_manager_list()); + if (!man) return; + + e = e_manager_comp_evas_get(man); + if (!e) return; + if (!strncmp(params, "go_pager", 8)) { - pager_run(params); + active = pager_run(man, params); } else if (!strncmp(params, "go_scale", 8)) { - scale_run(params); + active = scale_run(man, params); } + + if (active) + { + _hold_mod = modifiers; + _hold_count = 0; + if (_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) _hold_count++; + if (_hold_mod & ECORE_EVENT_MODIFIER_CTRL) _hold_count++; + if (_hold_mod & ECORE_EVENT_MODIFIER_ALT) _hold_count++; + if (_hold_mod & ECORE_EVENT_MODIFIER_WIN) _hold_count++; + } } static void _e_mod_action_cb_edge(E_Object *obj, const char *params, E_Event_Zone_Edge *ev) { - _e_mod_action(params); + _e_mod_action(params, 0); } static void _e_mod_action_cb(E_Object *obj, const char *params) { - _e_mod_action(params); + _e_mod_action(params, 0); } +static void +_e_mod_action_cb_key(E_Object *obj, const char *params, Ecore_Event_Key *ev) +{ + _e_mod_action(params, ev->modifiers); +} + +static void +_e_mod_action_cb_mouse(E_Object *obj, const char *params, Ecore_Event_Mouse_Button *ev) +{ + _e_mod_action(params, 0); +} /* Module and Gadcon stuff */ typedef struct _Instance Instance; @@ -155,13 +232,31 @@ if (act) { act->func.go = _e_mod_action_cb; + act->func.go_key = _e_mod_action_cb_key; + act->func.go_mouse = _e_mod_action_cb_mouse; act->func.go_edge = _e_mod_action_cb_edge; + e_action_predef_name_set(D_("Desktop"), D_("Scale Windows"), "scale-windows", "go_scale", NULL, 0); e_action_predef_name_set(D_("Desktop"), D_("Scale Windows (All Desktops)"), "scale-windows", "go_scale_all", NULL, 0); e_action_predef_name_set(D_("Desktop"), D_("Scale Pager"), "scale-windows", "go_pager", NULL, 0); + + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager"), + "scale-windows", "go_pager", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Next"), + "scale-windows", "go_pager_next", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Previous"), + "scale-windows", "go_pager_prev", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Left"), + "scale-windows", "go_pager_left", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Right"), + "scale-windows", "go_pager_right", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Up"), + "scale-windows", "go_pager_up", NULL, 0); + e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Down"), + "scale-windows", "go_pager_down", NULL, 0); } return m; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-03-02 14:09:34 UTC (rev 57468) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-03-02 16:15:06 UTC (rev 57469) @@ -134,9 +134,12 @@ E_Config_Dialog *e_int_config_scale_module(E_Container *con, const char *params); -void scale_run(const char *params); -void pager_run(const char *params); +Eina_Bool e_mod_hold_modifier_check(Ecore_Event_Key *ev); + +Eina_Bool scale_run(E_Manager *man, const char *params); +Eina_Bool pager_run(E_Manager *man, const char *params); + extern Config *scale_conf; #endif Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-02 14:09:34 UTC (rev 57468) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-02 16:15:06 UTC (rev 57469) @@ -54,8 +54,10 @@ static void _pager_win_del(Item *it); static void _pager_finish(); +static void _pager_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); + static Ecore_X_Window input_win = 0; static E_Msg_Handler *msg_handler = NULL; @@ -74,6 +76,7 @@ static int min_x, min_y, max_x, max_y; static double desk_w, desk_h; static double zoom = 0.0; +static int fade_windows; static void _pager_place_desks(double scale) @@ -151,7 +154,7 @@ _pager_place_desks(in); _pager_place_windows(in); - if (scale_conf->pager_fade_windows) + if (fade_windows) { EINA_LIST_FOREACH(items, l, it) { @@ -216,8 +219,11 @@ static void _pager_out() { - double duration, now = ecore_time_get(); + Item *it; + Eina_List *l; + double duration, now; + now = ecore_time_get(); duration = scale_conf->pager_duration; if (now - start_time < duration) @@ -231,6 +237,12 @@ if (selected_item) edje_object_signal_emit(selected_item->o, "hide", "e"); + EINA_LIST_FOREACH(items, l, it) + { + it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone->w; + it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone->h; + } + scale_state = EINA_FALSE; } @@ -336,16 +348,18 @@ static void _pager_desk_select(E_Desk *desk) { - Item *it; - Eina_List *l; + Evas_Object *o_desk; + if (current_desk && (desk != current_desk)) + { + o_desk = eina_list_nth(desks, current_desk->y * zone->desk_x_count + current_desk->x); + edje_object_signal_emit(o_desk, "unfocused", "e"); + } + current_desk = desk; - EINA_LIST_FOREACH(items, l, it) - { - it->bd_x = it->bd->x + (it->desk->x - desk->x) * zone->w; - it->bd_y = it->bd->y + (it->desk->y - desk->y) * zone->h; - } + o_desk = eina_list_nth(desks, desk->y * zone->desk_x_count + desk->x); + edje_object_signal_emit(o_desk, "focused", "e"); } static void @@ -369,6 +383,9 @@ else if (ev->button == 1) { e_border_raise(it->bd); + + if (current_desk != it->desk) + _pager_desk_select(it->desk); } it->mx = ev->canvas.x; @@ -470,6 +487,9 @@ y += (desk2->y - desk->y) * zone->h; } + if (current_desk != desk) + _pager_desk_select(desk); + e_border_move(it->bd, x, y); it->desk = desk; @@ -784,10 +804,9 @@ if (!it) { E_Desk *desk = _pager_desk_at_xy_get(ev->x, ev->y); - if (desk) current_desk = desk; + if (desk) + _pager_desk_select(desk); - _pager_desk_select(current_desk); - _pager_out(); return ECORE_CALLBACK_PASS_ON; } @@ -801,6 +820,162 @@ } static void +_pager_switch(const char *params) +{ + int max_x,max_y, desk_x, desk_y; + int x = 0, y = 0; + E_Desk *desk; + printf("switch %s\n", params); + + if (!params[0]) + { + _pager_out(); + return; + } + + e_zone_desk_count_get(zone, &max_x, &max_y); + + if (!strcmp(params, "_left")) + x = -1; + else if (!strcmp(params, "_right")) + x = 1; + else if (!strcmp(params, "_up")) + y = -1; + else if (!strcmp(params, "_down")) + y = 1; + else if (!strcmp(params, "_next")) + { + x = 1; + if (current_desk->x == max_x - 1) + y = 1; + } + else if (!strcmp(params, "_prev")) + { + x = -1; + if (current_desk->x == 0) + y = -1; + } + + desk_x = current_desk->x + x; + desk_y = current_desk->y + y; + + if (desk_x < 0) + desk_x = max_x - 1; + else if (desk_x >= max_x) + desk_x = 0; + + if (desk_y < 0) + desk_y = max_y - 1; + else if (desk_y >= max_y) + desk_y = 0; + + printf("selec %d %d\n", desk_x, desk_y); + + desk = e_desk_at_xy_get(zone, desk_x, desk_y); + if (desk) _pager_desk_select(desk); + + if (!scale_state) + { + Eina_List *l; + Item *it; + + fade_windows = 0; + EINA_LIST_FOREACH(items, l, it) + { + it->alpha = 255.0; + evas_object_color_set(it->o_win, 255.0, 255.0, 255.0, 255.0); + } + } +} + +static Eina_Bool +_pager_cb_key_down(void *data, int type, void *event) +{ + Ecore_Event_Key *ev = event; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + printf("%s\n", ev->key); + + if (!strcmp(ev->key, "Up")) + _pager_switch("_up"); + else if (!strcmp(ev->key, "Down")) + _pager_switch("_down"); + else if (!strcmp(ev->key, "Left")) + _pager_switch("_left"); + else if (!strcmp(ev->key, "Right")) + _pager_switch("_right"); + else if (!strcmp(ev->key, "p")) + _pager_switch("_prev"); + else if (!strcmp(ev->key, "n")) + _pager_switch("_next"); + else if (!strcmp(ev->key, "Return")) + _pager_out(); + else if (!strcmp(ev->key, "space")) + _pager_out(); + else if (!strcmp(ev->key, "Escape")) + { + _pager_desk_select(e_desk_current_get(zone)); + _pager_out(); + } + else + { + E_Action *act; + Eina_List *l; + E_Config_Binding_Key *bind; + E_Binding_Modifier mod; + + for (l = e_config->key_bindings; l; l = l->next) + { + bind = l->data; + + if (bind->action && strcmp(bind->action, "scale-windows")) continue; + if (!bind->params || strncmp(bind->params, "go_pager", 8)) continue; + printf("found action\n"); + + mod = 0; + + if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + mod |= E_BINDING_MODIFIER_SHIFT; + if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) + mod |= E_BINDING_MODIFIER_CTRL; + if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) + mod |= E_BINDING_MODIFIER_ALT; + if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) + mod |= E_BINDING_MODIFIER_WIN; + + if (bind->key && (!strcmp(bind->key, ev->keyname)) && + ((bind->modifiers == mod) || (bind->any_mod))) + { + if (!(act = e_action_find(bind->action))) continue; + if (act->func.go_key) + act->func.go_key(E_OBJECT(zone), bind->params, ev); + else if (act->func.go) + act->func.go(E_OBJECT(zone), bind->params); + } + } + } + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_pager_cb_key_up(void *data, int type, void *event) +{ + Ecore_Event_Key *ev = event; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + if (!e_mod_hold_modifier_check(event)) + _pager_out(); + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool _pager_run(E_Manager *man) { Eina_List *l; @@ -808,8 +983,10 @@ Ecore_Event_Handler *h; Evas *e; + if (input_win) return EINA_FALSE; + e = e_manager_comp_evas_get(man); - if (!e) return; + if (!e) return EINA_FALSE; zone = e_util_zone_current_get(man); current_desk = e_desk_current_get(zone); @@ -822,9 +999,11 @@ { ecore_x_window_free(input_win); input_win = 0; - return; + return EINA_FALSE; } + msg_handler = e_msg_handler_add(_pager_handler, NULL); + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _pager_cb_mouse_down, e); handlers = eina_list_append(handlers, h); @@ -837,6 +1016,14 @@ _pager_cb_mouse_move, e); handlers = eina_list_append(handlers, h); + h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, + _pager_cb_key_down, e); + handlers = eina_list_append(handlers, h); + + h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, + _pager_cb_key_up, e); + handlers = eina_list_append(handlers, h); + zoom = zone->desk_x_count; if (zoom < zone->desk_y_count) zoom = zone->desk_y_count; @@ -856,19 +1043,26 @@ if (background) { Evas_Object *o; - int i; + int x, y; - for (i = 0; i < zone->desk_x_count * zone->desk_y_count; i++) + for (y = 0; y < zone->desk_y_count; y++) { - o = edje_object_add(e); - if (!e_theme_edje_object_set(o, "base/theme/modules/scale", - "modules/scale/desk")) - edje_object_file_set(o, scale_conf->theme_path, - "modules/scale/desk"); - evas_object_stack_above(o, background->o_win); - evas_object_show(o); - desks = eina_list_append(desks, o); + for (x = 0; x < zone->desk_x_count; x++) + { + o = edje_object_add(e); + if (!e_theme_edje_object_set(o, "base/theme/modules/scale", + "modules/scale/desk")) + edje_object_file_set(o, scale_conf->theme_path, + "modules/scale/desk"); + evas_object_stack_above(o, background->o_win); + evas_object_show(o); + + desks = eina_list_append(desks, o); + + if ((x != zone->desk_x_current) || (y != zone->desk_y_current)) + edje_object_signal_emit(o, "unfocused", "e"); + } } _pager_place_desks(1.0); } @@ -876,62 +1070,79 @@ evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); evas_event_feed_mouse_move(e, -1000000, -1000000, ecore_x_current_time_get(), NULL); - _pager_in(); + + fade_windows = scale_conf->pager_fade_windows; + + return EINA_TRUE; } -static void -_pager_handler(void *data, const char *name, const char *info, int val, - E_Object *obj, void *msgdata) +Eina_Bool +pager_run(E_Manager *man, const char *params) { - E_Manager *man = (E_Manager *)obj; - E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata; - Evas *e; + Eina_Bool ret = EINA_FALSE; - /* DBG("handler... '%s' '%s'\n", name, info); */ - if (strcmp(name, "comp.manager")) return; + printf("run: %s\n", params); - e = e_manager_comp_evas_get(man); - if (!strcmp(info, "change.comp")) + if (scale_state) { - if (!e) DBG("TTT: No comp manager\n"); - else DBG("TTT: comp canvas = %p\n", e); + _pager_switch(params+8); } - else if (!strcmp(info, "resize.comp")) + else if (!scale_state) { - DBG("%s: %p | %p\n", info, man, src); + if (input_win) + return ret; + + ret = _pager_run(man); + + if (ret) + { + if (strlen(params) > 8) + _pager_switch(params+8); + + _pager_in(); + } } - else if (!strcmp(info, "add.src")) - { - /* DBG("%s: %p | %p\n", info, man, src); */ - _pager_win_new(e, man, src); - } - else if (!strcmp(info, "del.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "config.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } - /* else if (!strcmp(info, "visible.src")) - * { - * DBG("%s: %p | %p\n", info, man, src); - * } */ + return ret; } -void -pager_run(const char *params) +static void +_pager_handler(void *data, const char *name, const char *info, int val, + E_Object *obj, void *msgdata) { - Eina_List *l; - E_Manager *man; + E_Manager *man = (E_Manager *)obj; + E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata; + Evas *e; - msg_handler = e_msg_handler_add(_pager_handler, NULL); + /* DBG("handler... '%s' '%s'\n", name, info); */ + if (strcmp(name, "comp.manager")) return; - EINA_LIST_FOREACH(e_manager_list(), l, man) - { - Evas *e = e_manager_comp_evas_get(man); - if (e) _pager_run(man); - } + e = e_manager_comp_evas_get(man); + if (!strcmp(info, "change.comp")) + { + if (!e) DBG("TTT: No comp manager\n"); + else DBG("TTT: comp canvas = %p\n", e); + } + else if (!strcmp(info, "resize.comp")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "add.src")) + { + /* DBG("%s: %p | %p\n", info, man, src); */ + _pager_win_new(e, man, src); + } + else if (!strcmp(info, "del.src")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "config.src")) + { + + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "visible.src")) + { + DBG("%s: %p | %p\n", info, man, src); + } } - Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-02 14:09:34 UTC (rev 57468) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-02 16:15:06 UTC (rev 57469) @@ -71,6 +71,9 @@ static void _scale_in(void); static void _scale_out(void); +static void _scale_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); + + static Ecore_X_Window input_win = 0; static E_Msg_Handler *msg_handler = NULL; @@ -140,7 +143,7 @@ EINA_LIST_FOREACH(items, l, it) { a = 255.0; - + if ((it->bd->desk != current_desk) && (selected_item != it)) { double ax = it->cur_x - it->x; @@ -155,7 +158,7 @@ evas_object_color_set(it->o_win, a, a, a, a); } } - + if (scale_conf->fade_popups) { a = 255.0 * in; @@ -255,7 +258,7 @@ it->bd_x = it->bd->x; it->bd_y = it->bd->y; } - + _scale_place_windows(1.0); EINA_LIST_FREE(items, it) @@ -1339,19 +1342,106 @@ } } +static Eina_Bool +_scale_cb_key_down(void *data, int type, void *event) +{ + Ecore_Event_Key *ev = event; + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + printf("%s\n", ev->key); -static void + /* if (!strcmp(ev->key, "Up")) + * _scale_switch("_up"); + * else if (!strcmp(ev->key, "Down")) + * _scale_switch("_down"); + * else if (!strcmp(ev->key, "Left")) + * _scale_switch("_left"); + * else if (!strcmp(ev->key, "Right")) + * _scale_switch("_right"); + * else if (!strcmp(ev->key, "p")) + * _scale_switch("_prev"); + * else if (!strcmp(ev->key, "n")) + * _scale_switch("_next"); + * else if (!strcmp(ev->key, "Return")) + * _scale_out(); + * else */ + if (!strcmp(ev->key, "space")) + _scale_out(); + else if (!strcmp(ev->key, "Escape")) + { + /* TODO go to previously focused window */ + _scale_out(); + } + else + { + E_Action *act; + Eina_List *l; + E_Config_Binding_Key *bind; + E_Binding_Modifier mod; + + for (l = e_config->key_bindings; l; l = l->next) + { + bind = l->data; + + if (bind->action && strcmp(bind->action, "scale-windows")) continue; + if (!bind->params || strncmp(bind->params, "go_scale", 8)) continue; + printf("found action\n"); + + mod = 0; + + if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + mod |= E_BINDING_MODIFIER_SHIFT; + if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) + mod |= E_BINDING_MODIFIER_CTRL; + if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) + mod |= E_BINDING_MODIFIER_ALT; + if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) + mod |= E_BINDING_MODIFIER_WIN; + + if (bind->key && (!strcmp(bind->key, ev->keyname)) && + ((bind->modifiers == mod) || (bind->any_mod))) + { + if (!(act = e_action_find(bind->action))) continue; + if (act->func.go_key) + act->func.go_key(E_OBJECT(zone), bind->params, ev); + else if (act->func.go) + act->func.go(E_OBJECT(zone), bind->params); + } + } + } + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_scale_cb_key_up(void *data, int type, void *event) +{ + Ecore_Event_Key *ev = event; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + if (!e_mod_hold_modifier_check(event)) + _scale_out(); + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool _scale_run(E_Manager *man) { Eina_List *l; E_Manager_Comp_Source *src; + Ecore_Event_Handler *h; Evas *e; int i; Item *it; e = e_manager_comp_evas_get(man); - if (!e) return; + if (!e) return EINA_FALSE; zone = e_util_zone_current_get(e_manager_current_get()); current_desk = e_desk_current_get(zone); @@ -1364,34 +1454,42 @@ { ecore_x_window_free(input_win); input_win = 0; - return; + return EINA_FALSE; } - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_BUTTON_DOWN, _scale_cb_mouse_down, e)); + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, + _scale_cb_mouse_down, e); + handlers = eina_list_append(handlers, h); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_BUTTON_UP, _scale_cb_mouse_up, e)); + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, + _scale_cb_mouse_up, e); + handlers = eina_list_append(handlers, h); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_MOVE, _scale_cb_mouse_move, e)); + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, + _scale_cb_mouse_move, e); + handlers = eina_list_append(handlers, h); + h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, + _scale_cb_key_down, e); + handlers = eina_list_append(handlers, h); + + h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, + _scale_cb_key_up, e); + handlers = eina_list_append(handlers, h); + EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) _scale_win_new(e, man, src, current_desk); if (eina_list_count(items) < 1) { _scale_finish(); - return; + return EINA_FALSE; } - + if ((eina_list_count(items) < 2) && (!show_all_desks)) { _scale_finish(); - return; + return EINA_FALSE; } if (show_all_desks) @@ -1494,6 +1592,8 @@ ecore_x_current_time_get(), NULL); _scale_in(); + + return EINA_TRUE; } @@ -1543,6 +1643,33 @@ return ECORE_CALLBACK_PASS_ON; } +Eina_Bool +scale_run(E_Manager *man, const char *params) +{ + Eina_List *l; + Eina_Bool ret = EINA_FALSE; + + if (!strcmp(params, "go_scale_all")) + show_all_desks = EINA_TRUE; + else + show_all_desks = EINA_FALSE; + + if (scale_state) + { + /* _scale_action(params+8); */ + } + else + { + if (input_win) + return ret; + + ret = _scale_run(man); + } + + return ret; +} + + static void _scale_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata) @@ -1579,29 +1706,8 @@ DBG("%s: %p | %p\n", info, man, src); } - /* else if (!strcmp(info, "visible.src")) - * { - * DBG("%s: %p | %p\n", info, man, src); - * } */ -} - -void -scale_run(const char *params) -{ - Eina_List *l; - E_Manager *man; - - msg_handler = e_msg_handler_add(_scale_handler, NULL); - - if (!strcmp(params, "go_scale_all")) - show_all_desks = EINA_TRUE; - else - show_all_desks = EINA_FALSE; - - EINA_LIST_FOREACH(e_manager_list(), l, man) + else if (!strcmp(info, "visible.src")) { - Evas *e = e_manager_comp_evas_get(man); - if (e) _scale_run(man); + DBG("%s: %p | %p\n", info, man, src); } } - |
From: Enlightenment S. <no-...@en...> - 2011-03-02 21:14:25
|
Log: e-modules/comp-scale: bit more work on keybindings. actions now have their own Scale* category Author: jeffdameth Date: 2011-03-02 13:14:17 -0800 (Wed, 02 Mar 2011) New Revision: 57474 Trac: http://trac.enlightenment.org/e/changeset/57474 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-02 18:36:35 UTC (rev 57473) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-02 21:14:17 UTC (rev 57474) @@ -142,7 +142,7 @@ signal: "mouse,in"; source: "e"; action: STATE_SET "focused" 0.0; - transition: SINUSOIDAL 0.3; + transition: ACCELERATE 0.1; target: "over"; } program { @@ -150,7 +150,7 @@ signal: "mouse,out"; source: "e"; action: STATE_SET "default" 0.0; - transition: SINUSOIDAL 0.4; + transition: DECELERATE 0.1; target: "over"; } program { @@ -226,10 +226,99 @@ relative: 0.0 1.0; offset: 0 -1; } - } } part { + name: "left2"; + mouse_events: 0; + type: RECT; + clip_to: "focus_clip"; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + offset: -1 0; + } + rel2 { + relative: 0.0 1.0; + offset: -1 -1; + } + } + } + part { + name: "right2"; + mouse_events: 0; + type: RECT; + clip_to: "focus_clip"; + description { + state: "default" 0.0; + rel1 { + relative: 1.0 0.0; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + offset: 0 -1; + } + } + } + part { + name: "top2"; + mouse_events: 0; + type: RECT; + clip_to: "focus_clip"; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + offset: -1 -1; + } + rel2 { + relative: 1.0 0.0; + offset: -0 -1; + } + } + } + part { + name: "bottom2"; + mouse_events: 0; + type: RECT; + clip_to: "focus_clip"; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 1.0; + offset: -1 0; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + } + } + } + part { + name: "focus_clip"; + mouse_events: 0; + type: RECT; + description { + state: "default" 0.0; + color: 255 255 255 180; + rel1 { + relative: 0.0 0.0; + offset: -1 -1; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + } + } + description { + state: "unfocused" 0.0; + inherit: "default" 0.0; + color: 0 0 0 0; + } + } + part { name: "bg"; mouse_events: 1; type: RECT; @@ -251,6 +340,7 @@ action: STATE_SET "default" 0.0; transition: SINUSOIDAL 0.2; target: "bg"; + target: "focus_clip"; } program { name: "unfocused"; @@ -259,6 +349,7 @@ action: STATE_SET "unfocused" 0.0; transition: SINUSOIDAL 0.3; target: "bg"; + target: "focus_clip"; } } } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-02 18:36:35 UTC (rev 57473) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-02 21:14:17 UTC (rev 57474) @@ -69,7 +69,7 @@ static void -_e_mod_action(const char *params, int modifiers) +_e_mod_action(const char *params, int modifiers, int method) { int active; E_Manager *man; @@ -86,11 +86,11 @@ if (!strncmp(params, "go_pager", 8)) { - active = pager_run(man, params); + active = pager_run(man, params, method); } else if (!strncmp(params, "go_scale", 8)) { - active = scale_run(man, params); + active = scale_run(man, params, method); } if (active) @@ -107,25 +107,25 @@ static void _e_mod_action_cb_edge(E_Object *obj, const char *params, E_Event_Zone_Edge *ev) { - _e_mod_action(params, 0); + _e_mod_action(params, 0, 3); } static void _e_mod_action_cb(E_Object *obj, const char *params) { - _e_mod_action(params, 0); + _e_mod_action(params, 0, 2); } static void _e_mod_action_cb_key(E_Object *obj, const char *params, Ecore_Event_Key *ev) { - _e_mod_action(params, ev->modifiers); + _e_mod_action(params, ev->modifiers, 0); } static void _e_mod_action_cb_mouse(E_Object *obj, const char *params, Ecore_Event_Mouse_Button *ev) { - _e_mod_action(params, 0); + _e_mod_action(params, 0, 1); } /* Module and Gadcon stuff */ @@ -236,26 +236,30 @@ act->func.go_mouse = _e_mod_action_cb_mouse; act->func.go_edge = _e_mod_action_cb_edge; - e_action_predef_name_set(D_("Desktop"), D_("Scale Windows"), + e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows"), "scale-windows", "go_scale", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Windows (All Desktops)"), + e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows (All Desktops)"), "scale-windows", "go_scale_all", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager"), + e_action_predef_name_set(D_("Scale Windows"), D_("Scale Pager"), "scale-windows", "go_pager", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Next"), + "scale-windows", "go_scale_next", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous"), + "scale-windows", "go_scale_prev", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager"), + e_action_predef_name_set(D_("Scale Pager"), D_("Scale Pager"), "scale-windows", "go_pager", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Next"), + e_action_predef_name_set(D_("Scale Pager"), D_("Select Next"), "scale-windows", "go_pager_next", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Previous"), + e_action_predef_name_set(D_("Scale Pager"), D_("Select Previous"), "scale-windows", "go_pager_prev", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Left"), + e_action_predef_name_set(D_("Scale Pager"), D_("Select Left"), "scale-windows", "go_pager_left", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Right"), + e_action_predef_name_set(D_("Scale Pager"), D_("Select Right"), "scale-windows", "go_pager_right", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Up"), + e_action_predef_name_set(D_("Scale Pager"), D_("Select Up"), "scale-windows", "go_pager_up", NULL, 0); - e_action_predef_name_set(D_("Desktop"), D_("Scale Pager Down"), + e_action_predef_name_set(D_("Scale Pager"), D_("Select Down"), "scale-windows", "go_pager_down", NULL, 0); } @@ -296,9 +300,18 @@ if (act) { - e_action_predef_name_del(D_("Desktop"), D_("Scale Windows")); - e_action_predef_name_del(D_("Desktop"), D_("Scale Windows (All Desktops)")); - e_action_predef_name_del(D_("Desktop"), D_("Scale Pager")); + e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows")); + e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows (All Desktops)")); + e_action_predef_name_del(D_("Scale Windows"), D_("Select Next")); + e_action_predef_name_del(D_("Scale Windows"), D_("Select Previous")); + + e_action_predef_name_del(D_("Scale Pager"), D_("Scale Pager")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Next")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Previous")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Left")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Right")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Up")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Down")); e_action_del("scale-windows"); } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-03-02 18:36:35 UTC (rev 57473) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-03-02 21:14:17 UTC (rev 57474) @@ -137,8 +137,8 @@ Eina_Bool e_mod_hold_modifier_check(Ecore_Event_Key *ev); -Eina_Bool scale_run(E_Manager *man, const char *params); -Eina_Bool pager_run(E_Manager *man, const char *params); +Eina_Bool scale_run(E_Manager *man, const char *params, int init_method); +Eina_Bool pager_run(E_Manager *man, const char *params, int init_method); extern Config *scale_conf; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-02 18:36:35 UTC (rev 57473) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-02 21:14:17 UTC (rev 57474) @@ -72,11 +72,11 @@ static E_Zone *zone = NULL; static Item *background = NULL; static Item *selected_item = NULL; +static E_Desk *previous_desk = NULL; static E_Desk *current_desk = NULL; static int min_x, min_y, max_x, max_y; static double desk_w, desk_h; static double zoom = 0.0; -static int fade_windows; static void _pager_place_desks(double scale) @@ -154,11 +154,12 @@ _pager_place_desks(in); _pager_place_windows(in); - if (fade_windows) + if (scale_conf->pager_fade_windows) { EINA_LIST_FOREACH(items, l, it) { - if (it->desk != current_desk) + if ((it->desk != current_desk) && + (it->desk != previous_desk)) { double ax = it->cur_x - it->x; double ay = it->cur_y - it->y; @@ -170,7 +171,8 @@ } else { - a = 220.0 + (35.0 * in); + //a = 220.0 + (35.0 * in); + a = 255.0; } it->alpha = a; @@ -331,6 +333,7 @@ zone = NULL; selected_item = NULL; current_desk = NULL; + previous_desk = NULL; background = NULL; } @@ -356,6 +359,7 @@ edje_object_signal_emit(o_desk, "unfocused", "e"); } + previous_desk = current_desk; current_desk = desk; o_desk = eina_list_nth(desks, desk->y * zone->desk_x_count + desk->x); @@ -879,7 +883,6 @@ Eina_List *l; Item *it; - fade_windows = 0; EINA_LIST_FOREACH(items, l, it) { it->alpha = 255.0; @@ -1047,7 +1050,6 @@ for (y = 0; y < zone->desk_y_count; y++) { - for (x = 0; x < zone->desk_x_count; x++) { o = edje_object_add(e); @@ -1071,13 +1073,11 @@ evas_event_feed_mouse_move(e, -1000000, -1000000, ecore_x_current_time_get(), NULL); - fade_windows = scale_conf->pager_fade_windows; - return EINA_TRUE; } Eina_Bool -pager_run(E_Manager *man, const char *params) +pager_run(E_Manager *man, const char *params, int init_method) { Eina_Bool ret = EINA_FALSE; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-02 18:36:35 UTC (rev 57473) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-02 21:14:17 UTC (rev 57474) @@ -39,6 +39,12 @@ int overlaps; int in_slots; + + int slot_x; + int slot_y; + + Item *next; + Item *prev; }; struct _Slot @@ -69,7 +75,7 @@ static void _scale_finish(void); static void _scale_in(void); -static void _scale_out(void); +static void _scale_out(int mode); static void _scale_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); @@ -94,6 +100,7 @@ static E_Desk *current_desk = NULL; static int show_all_desks = EINA_FALSE; static int send_to_desk = EINA_FALSE; +static int scale_layout; static void _scale_place_windows(double scale) @@ -199,10 +206,48 @@ } static void -_scale_out() +_scale_out(int mode) { double duration, now = ecore_time_get(); + Item *ot, *it = selected_item; + Eina_List *l; + if (mode == 0) + { + selected_item = NULL; + } + else if (mode == 1) + { + /* goto selected windows desk */ + current_desk = it->bd->desk; + EINA_LIST_FOREACH(items, l, ot) + { + if (ot->bd->desk == it->bd->desk) + { + ot->bd_x = ot->bd->x; + ot->bd_y = ot->bd->y; + } + else + { + if (ot->dx > it->dx) + ot->bd_x = ot->bd->x + zone->w; + else if (ot->dx < it->dx) + ot->bd_x = ot->bd->x - zone->w; + + if (ot->dy > it->dy) + ot->bd_y = ot->bd->y + zone->h; + else if (ot->dy < it->dy) + ot->bd_y = ot->bd->y - zone->h; + } + } + } + else if (mode == 2) + { + send_to_desk = EINA_TRUE; + it->bd_x = it->bd->x; + it->bd_y = it->bd->y; + } + if (show_all_desks) duration = scale_conf->desks_duration; else @@ -217,7 +262,10 @@ scale_animator = ecore_animator_add(_scale_redraw, NULL); if (selected_item) - edje_object_signal_emit(selected_item->o, "hide", "e"); + { + e_border_raise(selected_item->bd); + edje_object_signal_emit(selected_item->o, "hide", "e"); + } scale_state = EINA_FALSE; } @@ -327,56 +375,27 @@ static void _scale_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) { - Item *ot, *it = data; + Item *it = data; Evas_Event_Mouse_Down *ev = event_info; - Eina_List *l; if (!scale_state) return; - e_border_raise(it->bd); - if (it->bd->desk == e_desk_current_get(it->bd->zone)) { - _scale_out(); - return; + selected_item = it; + _scale_out(1); } - - if (ev->button == 1) + else if (ev->button == 1) { selected_item = it; - current_desk = it->bd->desk; - - EINA_LIST_FOREACH(items, l, ot) - { - if (ot->bd->desk == it->bd->desk) - { - ot->bd_x = ot->bd->x; - ot->bd_y = ot->bd->y; - } - else - { - if (ot->dx > it->dx) - ot->bd_x = ot->bd->x + zone->w; - else if (ot->dx < it->dx) - ot->bd_x = ot->bd->x - zone->w; - - if (ot->dy > it->dy) - ot->bd_y = ot->bd->y + zone->h; - else if (ot->dy < it->dy) - ot->bd_y = ot->bd->y - zone->h; - } - } + _scale_out(1); } else if (ev->button == 3) { - send_to_desk = EINA_TRUE; selected_item = it; - it->bd_x = it->bd->x; - it->bd_y = it->bd->y; + _scale_out(2); } - - _scale_out(); } static void @@ -392,7 +411,7 @@ if (it->bd) { - _scale_out(); + _scale_out(0); items = eina_list_remove(items, it); } else @@ -1234,6 +1253,8 @@ x++; } } + Item *prev = NULL; + Item *first = NULL; EINA_LIST_FOREACH(slots, l, slot) { @@ -1241,6 +1262,18 @@ { it = slot->it; + it->prev = prev; + prev = it; + + if (it->prev) + it->prev->next = it; + + if (!first) + first = it; + + it->slot_x = slot->x; + it->slot_y = slot->y; + if (it->w > slot->w - spacing) { it->w = slot->w - spacing; @@ -1263,10 +1296,12 @@ E_FREE(slot); } + first->prev = prev; + prev->next = first; + return 1; } - static int _cb_sort_center(const void *d1, const void *d2) { @@ -1342,6 +1377,69 @@ } } + +#if 0 +static Item * +_scale_item_select(int direction) +{ + double min; + Item *last, *min; + Eina_List *l; + + if (direction == DIR_RIGHT) + { + EINA_LIST_FOREACH(items, l, it2) + { + + } + } + else if (direction == DIR_LEFT) + { + EINA_LIST_FOREACH(items, l, it2) + { + + } + } + else if (direction == DIR_UP) + { + EINA_LIST_FOREACH(items, l, it2) + { + + } + } + else if (direction == DIR_DOWN) + { + EINA_LIST_FOREACH(items, l, it2) + { + + } + } +} +#endif + +static void +_scale_switch(const char *params) +{ + Item *it; + + if (!strcmp(params, "_next")) + { + it = selected_item; + edje_object_signal_emit(it->o, "mouse,out", "e"); + it = it->next; + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; + } + else if (!strcmp(params, "_prev")) + { + it = selected_item; + edje_object_signal_emit(it->o, "mouse,out", "e"); + it = it->prev; + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; + } +} + static Eina_Bool _scale_cb_key_down(void *data, int type, void *event) { @@ -1359,19 +1457,20 @@ * _scale_switch("_left"); * else if (!strcmp(ev->key, "Right")) * _scale_switch("_right"); - * else if (!strcmp(ev->key, "p")) - * _scale_switch("_prev"); - * else if (!strcmp(ev->key, "n")) - * _scale_switch("_next"); - * else if (!strcmp(ev->key, "Return")) - * _scale_out(); * else */ + if (!strcmp(ev->key, "p")) + _scale_switch("_prev"); + else if (!strcmp(ev->key, "n")) + _scale_switch("_next"); + else if (!strcmp(ev->key, "Return")) + _scale_out(1); + else if (!strcmp(ev->key, "space")) - _scale_out(); + _scale_out(1); else if (!strcmp(ev->key, "Escape")) { /* TODO go to previously focused window */ - _scale_out(); + _scale_out(0); } else { @@ -1425,13 +1524,13 @@ return ECORE_CALLBACK_PASS_ON; if (!e_mod_hold_modifier_check(event)) - _scale_out(); + _scale_out(1); return ECORE_CALLBACK_PASS_ON; } static Eina_Bool -_scale_run(E_Manager *man) +_scale_run(E_Manager *man, int init_method) { Eina_List *l; E_Manager_Comp_Source *src; @@ -1518,20 +1617,10 @@ max_y = zone->h + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current); /* scale all windows down to be next to each other on one zone */ - if (show_all_desks) - { - if (scale_conf->desks_layout_mode) - _scale_place_slotted(); - else - _scale_place_natural(); - } + if (scale_layout) + _scale_place_slotted(); else - { - if (scale_conf->layout_mode) - _scale_place_slotted(); - else - _scale_place_natural(); - } + _scale_place_natural(); min_x = use_x; min_y = use_y; @@ -1591,6 +1680,21 @@ evas_event_feed_mouse_move(e, -1000000, -1000000, ecore_x_current_time_get(), NULL); + if (init_method == 0) + { + E_Border *bd = e_border_focused_get(); + + EINA_LIST_FOREACH(items, l , it) + if (it->bd == bd) break; + + if (it) + selected_item = it; + else + selected_item = eina_list_data_get(items); + + edje_object_signal_emit(selected_item->o, "mouse,in", "e"); + } + _scale_in(); return EINA_TRUE; @@ -1621,7 +1725,7 @@ if (!it) { - _scale_out(); + _scale_out(1); return ECORE_CALLBACK_PASS_ON; } @@ -1644,26 +1748,37 @@ } Eina_Bool -scale_run(E_Manager *man, const char *params) +scale_run(E_Manager *man, const char *params, int init_method) { Eina_List *l; Eina_Bool ret = EINA_FALSE; if (!strcmp(params, "go_scale_all")) - show_all_desks = EINA_TRUE; + { + scale_layout = scale_conf->desks_layout_mode; + show_all_desks = EINA_TRUE; + } + else - show_all_desks = EINA_FALSE; + { + scale_layout = scale_conf->layout_mode; + show_all_desks = EINA_FALSE; + } + /* FIXME means: if keyboard use slotted layout */ + if (init_method == 0) + scale_layout = 1; + if (scale_state) { - /* _scale_action(params+8); */ + _scale_switch(params+8); } else { if (input_win) return ret; - ret = _scale_run(man); + ret = _scale_run(man, init_method); } return ret; |
From: Enlightenment S. <no-...@en...> - 2011-03-02 21:56:30
|
Log: e-modules/comp-scale: - hilight selected desk when moving maximized windows too - slightly more hilight for selected window Author: jeffdameth Date: 2011-03-02 13:56:21 -0800 (Wed, 02 Mar 2011) New Revision: 57476 Trac: http://trac.enlightenment.org/e/changeset/57476 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-02 21:32:28 UTC (rev 57475) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-02 21:56:21 UTC (rev 57476) @@ -132,7 +132,7 @@ } description { state: "focused" 0.0; - color: 255 255 255 10; + color: 255 255 255 30; } } } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-02 21:32:28 UTC (rev 57475) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-02 21:56:21 UTC (rev 57476) @@ -236,11 +236,9 @@ if (!scale_animator) scale_animator = ecore_animator_add(_pager_redraw, NULL); - if (selected_item) - edje_object_signal_emit(selected_item->o, "hide", "e"); - EINA_LIST_FOREACH(items, l, it) { + edje_object_signal_emit(it->o, "hide", "e"); it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone->w; it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone->h; } @@ -500,9 +498,9 @@ } else if (desk && (desk != it->desk)) { - it->desk = desk; + _pager_desk_select(desk); _pager_win_final_position_set(it); it->cur_x = it->x; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-02 21:32:28 UTC (rev 57475) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-02 21:56:21 UTC (rev 57476) @@ -121,7 +121,7 @@ } static Eina_Bool -_scale_redraw(void *blah) +_scale_redraw(void *data) { Eina_List *l; Item *it; |
From: Enlightenment S. <no-...@en...> - 2011-03-03 23:24:15
|
Log: e-modules/comp-scale: - use comps' mirror objects instead of shobj fixes stacking issues and should be done like that anyway - slide mouse pointer to selected window when using scale with keybindings - focus currently selected border. for themes that have less sublime window focused theme than detour. TODO need to revert window focus order on finish Author: jeffdameth Date: 2011-03-03 15:24:08 -0800 (Thu, 03 Mar 2011) New Revision: 57508 Trac: http://trac.enlightenment.org/e/changeset/57508 Added: trunk/E-MODULES-EXTRA/comp-scale/sh.png Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-03 23:11:28 UTC (rev 57507) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-03 23:24:08 UTC (rev 57508) @@ -1,6 +1,7 @@ images { image: "module_icon.png" COMP; + image: "sh.png" COMP; } collections @@ -77,6 +78,55 @@ name: "modules/scale/win"; parts { + part { name: "clipper"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + visible: 1; + color: 255 255 255 255; + rel1 { + relative: -1.0 -1.0; + offset: -9999 -9999; + } + rel2 { + relative: 2.0 2.0; + offset: 9999 9999; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + part { name: "shadow"; + mouse_events: 0; + clip_to: "clipper"; + description { state: "default" 0.0; + image { + normal: "sh.png"; + border: 18 18 18 18; + middle: 0; + } + fill { + smooth: 0; + } + rel1 { + to: "e.swallow.win"; + relative: 0.0 0.0; + offset: -16 -14; + } + rel2 { + to: "e.swallow.win"; + relative: 1.0 1.0; + offset: 15 17; + } + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } part { name: "e.swallow.win"; Property changes on: trunk/E-MODULES-EXTRA/comp-scale/sh.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-03 23:11:28 UTC (rev 57507) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-03 23:24:08 UTC (rev 57508) @@ -107,25 +107,25 @@ static void _e_mod_action_cb_edge(E_Object *obj, const char *params, E_Event_Zone_Edge *ev) { - _e_mod_action(params, 0, 3); + _e_mod_action(params, 0, GO_EDGE); } static void _e_mod_action_cb(E_Object *obj, const char *params) { - _e_mod_action(params, 0, 2); + _e_mod_action(params, 0, GO_ACTION); } static void _e_mod_action_cb_key(E_Object *obj, const char *params, Ecore_Event_Key *ev) { - _e_mod_action(params, ev->modifiers, 0); + _e_mod_action(params, ev->modifiers, GO_KEY); } static void _e_mod_action_cb_mouse(E_Object *obj, const char *params, Ecore_Event_Mouse_Button *ev) { - _e_mod_action(params, 0, 1); + _e_mod_action(params, 0, GO_MOUSE); } /* Module and Gadcon stuff */ @@ -240,12 +240,14 @@ "scale-windows", "go_scale", NULL, 0); e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows (All Desktops)"), "scale-windows", "go_scale_all", NULL, 0); - e_action_predef_name_set(D_("Scale Windows"), D_("Scale Pager"), - "scale-windows", "go_pager", NULL, 0); e_action_predef_name_set(D_("Scale Windows"), D_("Select Next"), "scale-windows", "go_scale_next", NULL, 0); e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous"), "scale-windows", "go_scale_prev", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Next (All)"), + "scale-windows", "go_scale_all_next", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous (All)"), + "scale-windows", "go_scale_all_prev", NULL, 0); e_action_predef_name_set(D_("Scale Pager"), D_("Scale Pager"), "scale-windows", "go_pager", NULL, 0); Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-03-03 23:11:28 UTC (rev 57507) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-03-03 23:24:08 UTC (rev 57508) @@ -12,7 +12,12 @@ #define DBG(...) /* #define DBG(...) printf(__VA_ARGS__) */ +#define GO_KEY 0 +#define GO_MOUSE 1 +#define GO_EDGE 2 +#define GO_ACTION 3 + typedef struct _Config_Item Config_Item; typedef struct _Config Config; typedef struct _E_Comp_Win E_Comp_Win; @@ -56,37 +61,38 @@ int switch2; }; + struct _E_Comp_Win { EINA_INLIST; - void *c; - Ecore_X_Window win; - E_Border *bd; - E_Popup *pop; - E_Menu *menu; - int x, y, w, h; + void *c; + Ecore_X_Window win; + E_Border *bd; + E_Popup *pop; + E_Menu *menu; + int x, y, w, h; struct { - int x, y, w, h; + int x, y, w, h; } hidden; - int pw, ph; - int border; - Ecore_X_Pixmap pixmap; - Ecore_X_Damage damage; - Ecore_X_Visual vis; - int depth; - Evas_Object *obj; - Evas_Object *shobj; - Eina_List *obj_mirror; - Ecore_X_Image *xim; - void *up; - E_Object_Delfn *dfn; - Ecore_X_Sync_Counter counter; - Ecore_Timer *update_timeout; - Ecore_Timer *ready_timeout; - int dmg_updates; - Ecore_X_Rectangle *rects; - int rects_num; + int pw, ph; + int border; + Ecore_X_Pixmap pixmap; + Ecore_X_Damage damage; + Ecore_X_Visual vis; + int depth; + Evas_Object *obj; + Evas_Object *shobj; + Eina_List *obj_mirror; + Ecore_X_Image *xim; + void *up; + E_Object_Delfn *dfn; + Ecore_X_Sync_Counter counter; + Ecore_Timer *update_timeout; + Ecore_Timer *ready_timeout; + int dmg_updates; + Ecore_X_Rectangle *rects; + int rects_num; Ecore_X_Pixmap cache_pixmap; int cache_w, cache_h; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-03 23:11:28 UTC (rev 57507) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-03 23:24:08 UTC (rev 57508) @@ -11,6 +11,7 @@ E_Border *bd; E_Desk *desk; E_Comp_Win *cw; + E_Manager *man; int alpha; double x; @@ -43,12 +44,7 @@ static void _pager_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _pager_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _pager_win_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void _pager_win_cb_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _pager_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); -static void _pager_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); -static void _pager_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a); -static void _pager_win_cb_intercept_stack_above(void *data, Evas_Object *obj, Evas_Object *above); static void _pager_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src); static void _pager_win_del(Item *it); @@ -57,7 +53,6 @@ static void _pager_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); - static Ecore_X_Window input_win = 0; static E_Msg_Handler *msg_handler = NULL; @@ -285,23 +280,10 @@ e_config->desk_flip_animate_mode = tmp; } - EINA_LIST_FOREACH(items, l, it) - { - it->bd_x = it->bd->x; - it->bd_y = it->bd->y; - } + /* _pager_place_windows(1.0); */ - _pager_place_windows(1.0); - EINA_LIST_FREE(items, it) - { - if (it->bd->desk != current_desk) - { - e_border_hide(it->bd, 2); - evas_object_hide(it->o_win); - } - _pager_win_del(it); - } + _pager_win_del(it); EINA_LIST_FREE(desks, o) evas_object_del(o); @@ -312,20 +294,9 @@ if (background) _pager_win_del(background); - EINA_LIST_FREE(handlers, handler) ecore_event_handler_del(handler); - /* XXX fix stacking */ - E_Comp_Win *cw, *prev = NULL; - Eina_List *list = (Eina_List *)e_manager_comp_src_list(e_manager_current_get()); - EINA_LIST_FOREACH(list, l, cw) - { - if (!cw->shobj) continue; - if (prev) evas_object_stack_above(cw->shobj, prev->shobj); - prev = cw; - } - e_msg_handler_del(msg_handler); msg_handler = NULL; zone = NULL; @@ -378,14 +349,16 @@ selected_item = it; _pager_desk_select(it->desk); - _pager_out(); return; } else if (ev->button == 1) { e_border_raise(it->bd); + e_border_focus_set(it->bd, 1, 1); + evas_object_raise(it->o); + if (current_desk != it->desk) _pager_desk_select(it->desk); } @@ -587,47 +560,46 @@ static void _pager_win_del(Item *it) { - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, - _pager_win_cb_mouse_in); + evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, + _pager_win_cb_delorig); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, - _pager_win_cb_mouse_out); + if (it->bd) + { + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, + _pager_win_cb_mouse_in); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, - _pager_win_cb_mouse_down); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, + _pager_win_cb_mouse_out); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, - _pager_win_cb_mouse_up); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, + _pager_win_cb_mouse_down); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_MOVE, - _pager_win_cb_mouse_move); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, + _pager_win_cb_mouse_up); - evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, - _pager_win_cb_delorig); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_MOVE, + _pager_win_cb_mouse_move); - evas_object_intercept_move_callback_del - (it->o_win, _pager_win_cb_intercept_move); + e_manager_comp_src_hidden_set(it->man, + (E_Manager_Comp_Source *)it->cw, + EINA_FALSE); - evas_object_intercept_resize_callback_del - (it->o_win, _pager_win_cb_intercept_resize); + if (it->bd->desk != current_desk) + { + e_border_hide(it->bd, 2); + evas_object_hide(it->cw->shobj); + } - evas_object_intercept_color_set_callback_del - (it->o_win, _pager_win_cb_intercept_color); + evas_object_del(it->o_win); + evas_object_del(it->o); - evas_object_intercept_stack_above_callback_del - (it->o_win, _pager_win_cb_intercept_stack_above); - - if (it->bd) + e_object_unref(E_OBJECT(it->bd)); + } + else { - it->alpha = 255; evas_object_color_set(it->o_win, 255, 255, 255, 255); - edje_object_part_unswallow(it->o, it->o_win); - evas_object_stack_above(it->o_win, it->o); - e_object_unref(E_OBJECT(it->bd)); } - evas_object_del(it->o); - E_FREE(it); } @@ -649,19 +621,19 @@ if (cw->win == zone->container->bg_win) { it = E_NEW(Item, 1); + it->man = man; it->o_win = o; - evas_object_event_callback_add - (it->o_win, EVAS_CALLBACK_DEL, - _pager_win_cb_delorig, it); + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, + _pager_win_cb_delorig, it); background = it; } else if (scale_conf->pager_fade_popups) { it = E_NEW(Item, 1); + it->man = man; it->o_win = o; - evas_object_event_callback_add - (it->o_win, EVAS_CALLBACK_DEL, - _pager_win_cb_delorig, it); + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, + _pager_win_cb_delorig, it); popups = eina_list_append(popups, it); } @@ -677,11 +649,14 @@ it = E_NEW(Item, 1); it->bd = cw->bd; it->desk = it->bd->desk; + it->man = man; it->cw = cw; it->alpha = 255.0; e_object_ref(E_OBJECT(it->bd)); - it->o_win = e_manager_comp_src_shadow_get(man, src); + e_manager_comp_src_hidden_set(man, src, EINA_TRUE); + it->o_win = e_manager_comp_src_image_mirror_add(man, src); + it->o = edje_object_add(e); if (!e_theme_edje_object_set(it->o, "base/theme/modules/scale", "modules/scale/win")) @@ -695,18 +670,6 @@ evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _pager_win_cb_delorig, it); - evas_object_intercept_move_callback_add - (it->o_win, _pager_win_cb_intercept_move, it); - - evas_object_intercept_resize_callback_add - (it->o_win, _pager_win_cb_intercept_resize, it); - - evas_object_intercept_color_set_callback_add - (it->o_win, _pager_win_cb_intercept_color, it); - - evas_object_intercept_stack_above_callback_add - (it->o_win, _pager_win_cb_intercept_stack_above, it); - evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_IN, _pager_win_cb_mouse_in, it); @@ -739,17 +702,10 @@ if (it->desk != current_desk) { e_border_show(it->bd); - evas_object_move(it->o, it->cur_x, it->cur_y); - - if (scale_conf->pager_fade_windows) - { - it->alpha = 0.0; - evas_object_color_set(it->o_win, 0, 0, 0, 0); - } } _pager_win_final_position_set(it); - evas_object_color_set(it->o, 255, 255, 255, 255); + it->w = it->bd->w / zoom - OFFSET*2.0; it->h = it->bd->h / zoom - OFFSET*2.0; @@ -1067,6 +1023,17 @@ _pager_place_desks(1.0); } + _pager_place_windows(1.0); + + if (scale_conf->pager_fade_windows) + { + Item *it; + + EINA_LIST_FOREACH(items, l, it) + if (it->bd->desk != current_desk) + evas_object_color_set(it->o_win, 0, 0, 0, 0); + } + evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); evas_event_feed_mouse_move(e, -1000000, -1000000, ecore_x_current_time_get(), NULL); Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-03 23:11:28 UTC (rev 57507) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-03 23:24:08 UTC (rev 57508) @@ -15,6 +15,7 @@ Evas_Object *o, *o_win; E_Border *bd; E_Comp_Win *cw; + E_Manager *man; double scale; int alpha; @@ -36,10 +37,9 @@ /* borders' desk distance to the current desk */ int dx, dy; - int overlaps; + Eina_Bool overlaps; int in_slots; - int slot_x; int slot_y; @@ -63,12 +63,7 @@ static void _scale_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _scale_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _scale_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void _scale_win_cb_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); -static void _scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y); -static void _scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a); -static void _scale_win_cb_intercept_stack_above(void *data, Evas_Object *obj, Evas_Object *above); static void _scale_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src, E_Desk *desk); static void _scale_win_del(Item *it); @@ -76,7 +71,6 @@ static void _scale_finish(void); static void _scale_in(void); static void _scale_out(int mode); - static void _scale_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); @@ -101,6 +95,7 @@ static int show_all_desks = EINA_FALSE; static int send_to_desk = EINA_FALSE; static int scale_layout; +static int init_method = 0; static void _scale_place_windows(double scale) @@ -201,6 +196,8 @@ start_time = ecore_time_get(); scale_state = EINA_TRUE; + _scale_place_windows(1.0); + if (!scale_animator) scale_animator = ecore_animator_add(_scale_redraw, NULL); } @@ -215,9 +212,10 @@ { selected_item = NULL; } - else if (mode == 1) + else if (it && (mode == 1)) { /* goto selected windows desk */ + current_desk = it->bd->desk; EINA_LIST_FOREACH(items, l, ot) @@ -241,7 +239,7 @@ } } } - else if (mode == 2) + else if (it && (mode == 2)) { send_to_desk = EINA_TRUE; it->bd_x = it->bd->x; @@ -263,8 +261,28 @@ if (selected_item) { - e_border_raise(selected_item->bd); - edje_object_signal_emit(selected_item->o, "hide", "e"); + it = selected_item; + + evas_object_raise(it->o); + e_border_raise(it->bd); + + if ((init_method == GO_KEY) && (e_config->focus_policy != E_FOCUS_CLICK)) + { + int slide = e_config->pointer_slide; + int focus = e_config->focus_policy; + + e_config->pointer_slide = 1; + e_config->focus_policy = E_FOCUS_MOUSE; + + e_border_focus_set_with_pointer(it->bd); + + e_config->pointer_slide = slide; + e_config->focus_policy = focus; + } + else + e_border_focus_set(it->bd, 1, 1); + + edje_object_signal_emit(it->o, "hide", "e"); } scale_state = EINA_FALSE; @@ -298,26 +316,14 @@ e_config->desk_flip_animate_mode = 0; e_desk_show(desk); e_config->desk_flip_animate_mode = tmp; + current_desk = desk; } } - EINA_LIST_FOREACH(items, l, it) - { - it->bd_x = it->bd->x; - it->bd_y = it->bd->y; - } + /* _scale_place_windows(1.0); */ - _scale_place_windows(1.0); - EINA_LIST_FREE(items, it) - { - if (it->bd->desk != desk) - { - e_border_hide(it->bd, 2); - evas_object_hide(it->o_win); - } - _scale_win_del(it); - } + _scale_win_del(it); EINA_LIST_FREE(popups, it) _scale_win_del(it); @@ -328,16 +334,6 @@ EINA_LIST_FREE(handlers, handler) ecore_event_handler_del(handler); - /* XXX fix stacking */ - E_Comp_Win *cw, *prev = NULL; - Eina_List *list = (Eina_List *)e_manager_comp_src_list(e_manager_current_get()); - EINA_LIST_FOREACH(list, l, cw) - { - if (!cw->shobj) continue; - if (prev) evas_object_stack_above(cw->shobj, prev->shobj); - prev = cw; - } - e_msg_handler_del(msg_handler); msg_handler = NULL; zone = NULL; @@ -423,83 +419,43 @@ } static void -_scale_win_cb_intercept_stack_above(void *data, Evas_Object *obj, Evas_Object *above) -{ - Item *ot, *it = data; - Eina_List *l; - - EINA_LIST_FOREACH(items, l, ot) - if (ot->o_win == above) break; - - if (ot) - evas_object_stack_above(it->o, ot->o); -} - -static void -_scale_win_cb_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y) -{ - Item *it = data; - evas_object_move(obj, it->cur_x, it->cur_y); -} - -static void -_scale_win_cb_intercept_resize(void *data, Evas_Object *obj, Evas_Coord w, Evas_Coord h) -{ - Item *it = data; - evas_object_resize(obj, it->cur_w, it->cur_h); -} - -static void -_scale_win_cb_intercept_color(void *data, Evas_Object *obj, int r, int g, int b, int a) -{ - Item *it = data; - evas_object_color_set(obj, it->alpha, it->alpha, it->alpha, it->alpha); -} - -static void _scale_win_del(Item *it) { - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, - _scale_win_cb_mouse_in); - - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, - _scale_win_cb_mouse_out); - - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, - _scale_win_cb_mouse_down); - - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, - _scale_win_cb_mouse_up); - - /* evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_MOVE, - * _scale_win_cb_mouse_move); */ - evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, _scale_win_cb_delorig); - evas_object_intercept_move_callback_del - (it->o_win, _scale_win_cb_intercept_move); + if (it->bd) + { + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, + _scale_win_cb_mouse_in); - evas_object_intercept_resize_callback_del - (it->o_win, _scale_win_cb_intercept_resize); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, + _scale_win_cb_mouse_out); - evas_object_intercept_color_set_callback_del - (it->o_win, _scale_win_cb_intercept_color); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, + _scale_win_cb_mouse_down); - evas_object_intercept_stack_above_callback_del - (it->o_win, _scale_win_cb_intercept_stack_above); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, + _scale_win_cb_mouse_up); - evas_object_del(it->o); + e_manager_comp_src_hidden_set(it->man, + (E_Manager_Comp_Source *)it->cw, + EINA_FALSE); - evas_object_color_set(it->o_win, 255, 255, 255, 255); + if (it->bd->desk != current_desk) + { + e_border_hide(it->bd, 2); + evas_object_hide(it->cw->shobj); + } - if (it->bd) + evas_object_del(it->o_win); + evas_object_del(it->o); + + e_object_unref(E_OBJECT(it->bd)); + } + else { - it->alpha = 255; evas_object_color_set(it->o_win, 255, 255, 255, 255); - edje_object_part_unswallow(it->o, it->o_win); - evas_object_stack_above(it->o_win, it->o); - e_object_unref(E_OBJECT(it->bd)); } E_FREE(it); @@ -521,19 +477,20 @@ if (scale_conf->fade_desktop) { it = E_NEW(Item, 1); + it->man = man; it->o_win = e_manager_comp_src_shadow_get(man, src); evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_cb_delorig, it); + _scale_win_cb_delorig, it); background = it; } } else if (scale_conf->fade_popups) { it = E_NEW(Item, 1); + it->man = man; it->o_win = e_manager_comp_src_shadow_get(man, src); evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_cb_delorig, it); - + _scale_win_cb_delorig, it); popups = eina_list_append(popups, it); } return; @@ -555,33 +512,24 @@ e_object_ref(E_OBJECT(cw->bd)); it->bd = cw->bd; + it->man = man; it->cw = cw; - it->o_win = e_manager_comp_src_shadow_get(man, src); + e_manager_comp_src_hidden_set(man, src, EINA_TRUE); + it->o_win = e_manager_comp_src_image_mirror_add(man, src); + evas_object_show(it->o_win); it->o = edje_object_add(e); if (!e_theme_edje_object_set(it->o, "base/theme/modules/scale", "modules/scale/win")) edje_object_file_set(it->o, scale_conf->theme_path, "modules/scale/win"); - evas_object_stack_above(it->o, it->o_win); + evas_object_stack_below(it->o, it->o_win); evas_object_show(it->o); edje_object_part_swallow(it->o, "e.swallow.win", it->o_win); evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_cb_delorig, it); - evas_object_intercept_move_callback_add - (it->o_win, _scale_win_cb_intercept_move, it); - - evas_object_intercept_resize_callback_add - (it->o_win, _scale_win_cb_intercept_resize, it); - - evas_object_intercept_color_set_callback_add - (it->o_win, _scale_win_cb_intercept_color, it); - - evas_object_intercept_stack_above_callback_add - (it->o_win, _scale_win_cb_intercept_stack_above, it); - evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_IN, _scale_win_cb_mouse_in, it); @@ -614,10 +562,7 @@ it->cur_h = it->h; if (it->bd->desk != desk) - { - e_border_show(it->bd); - evas_object_move(it->o_win, it->x, it->y); - } + e_border_show(it->bd); edje_object_signal_emit(it->o, "show", "e"); @@ -1428,6 +1373,7 @@ edje_object_signal_emit(it->o, "mouse,out", "e"); it = it->next; edje_object_signal_emit(it->o, "mouse,in", "e"); + e_border_focus_set(it->bd, 1, 1); selected_item = it; } else if (!strcmp(params, "_prev")) @@ -1436,6 +1382,7 @@ edje_object_signal_emit(it->o, "mouse,out", "e"); it = it->prev; edje_object_signal_emit(it->o, "mouse,in", "e"); + e_border_focus_set(it->bd, 1, 1); selected_item = it; } } @@ -1530,7 +1477,7 @@ } static Eina_Bool -_scale_run(E_Manager *man, int init_method) +_scale_run(E_Manager *man) { Eina_List *l; E_Manager_Comp_Source *src; @@ -1680,7 +1627,7 @@ evas_event_feed_mouse_move(e, -1000000, -1000000, ecore_x_current_time_get(), NULL); - if (init_method == 0) + if (init_method == GO_KEY) { E_Border *bd = e_border_focused_get(); @@ -1695,6 +1642,13 @@ edje_object_signal_emit(selected_item->o, "mouse,in", "e"); } + if (scale_conf->pager_fade_windows) + { + EINA_LIST_FOREACH(items, l, it) + if (it->bd->desk != current_desk) + evas_object_color_set(it->o_win, 0, 0, 0, 0); + } + _scale_in(); return EINA_TRUE; @@ -1748,12 +1702,12 @@ } Eina_Bool -scale_run(E_Manager *man, const char *params, int init_method) +scale_run(E_Manager *man, const char *params, int _init_method) { Eina_List *l; Eina_Bool ret = EINA_FALSE; - if (!strcmp(params, "go_scale_all")) + if (!strncmp(params, "go_scale_all", 12)) { scale_layout = scale_conf->desks_layout_mode; show_all_desks = EINA_TRUE; @@ -1765,20 +1719,25 @@ show_all_desks = EINA_FALSE; } + init_method = _init_method; + /* FIXME means: if keyboard use slotted layout */ - if (init_method == 0) + if (init_method == GO_KEY) scale_layout = 1; if (scale_state) { - _scale_switch(params+8); + if (show_all_desks) + _scale_switch(params+12); + else + _scale_switch(params+8); } else { if (input_win) return ret; - ret = _scale_run(man, init_method); + ret = _scale_run(man); } return ret; |
From: Enlightenment S. <no-...@en...> - 2011-03-09 03:27:14
|
Log: e-modules/comp-scale: - when initiating scale with keyboard select the previous (winlist like switching between two windows) - added pointer warp to window when selecting with keyboard - fix scale fade window using setting from pager - fix handle input events only for input win Author: jeffdameth Date: 2011-03-08 19:27:07 -0800 (Tue, 08 Mar 2011) New Revision: 57611 Trac: http://trac.enlightenment.org/e/changeset/57611 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-09 03:09:59 UTC (rev 57610) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-09 03:27:07 UTC (rev 57611) @@ -82,7 +82,6 @@ type: RECT; mouse_events: 0; description { state: "default" 0.0; - visible: 1; color: 255 255 255 255; rel1 { relative: -1.0 -1.0; @@ -93,10 +92,9 @@ offset: 9999 9999; } } - description { state: "visible" 0.0; + description { state: "faded" 0.0; inherit: "default" 0.0; - visible: 1; - color: 255 255 255 255; + color: 200 200 200 235; } } part { name: "shadow"; @@ -131,96 +129,31 @@ part { name: "e.swallow.win"; type: SWALLOW; - description { + clip_to: "clipper"; + description { state: "default" 0.0; color: 255 255 255 255; } } - - /* part { - * name: "icon"; - * mouse_events: 0; - * type: IMAGE; - * description { - * state: "default" 0.0; - * aspect: 1.0 1.0; - * aspect_preference: BOTH; - * rel1.relative; - * - * rel1.offset: 2 2; - * rel2.offset: -3 -3; - * image.normal: "module_icon.png"; - * } - * description { - * state: "bigger" 0.0; - * inherit: "default" 0.0; - * rel1.offset: -2 -2; - * rel2.offset: 3 3; - * } - * } */ - part { - name: "over_clip"; - mouse_events: 0; - type: RECT; - description { - state: "default" 0.0; - color: 0 0 0 0; - } - description { - state: "visible" 0.0; - color: 255 255 255 255; - } - } - part { - name: "over"; - mouse_events: 1; - type: RECT; - clip_to: "over_clip"; - description { - state: "default" 0.0; - color: 0 0 0 30; - } - description { - state: "focused" 0.0; - color: 255 255 255 30; - } - } } programs { program { name: "mouse_in"; signal: "mouse,in"; source: "e"; - action: STATE_SET "focused" 0.0; - transition: ACCELERATE 0.1; - target: "over"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.2; + target: "clipper"; } program { name: "mouse_out"; signal: "mouse,out"; source: "e"; - action: STATE_SET "default" 0.0; - transition: DECELERATE 0.1; - target: "over"; + action: STATE_SET "faded" 0.0; + transition: LINEAR 0.4; + target: "clipper"; } - program { - name: "fade_in"; - signal: "show"; - source: "e"; - action: STATE_SET "visible" 0.0; - transition: DECELERATE 0.3; - target: "over_clip"; - } - program { - name: "fade_out"; - signal: "hide"; - source: "e"; - action: STATE_SET "default" 0.0; - transition: ACCELERATE 0.1; - target: "over_clip"; - } } - } group { name: "modules/scale/desk"; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-09 03:09:59 UTC (rev 57610) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-09 03:27:07 UTC (rev 57611) @@ -12,7 +12,6 @@ E_Desk *desk; E_Comp_Win *cw; E_Manager *man; - int alpha; double x; double y; @@ -72,6 +71,8 @@ static int min_x, min_y, max_x, max_y; static double desk_w, desk_h; static double zoom = 0.0; +static int mouse_activated = 0; +static int mouse_x, mouse_y; static void _pager_place_desks(double scale) @@ -153,7 +154,9 @@ { EINA_LIST_FOREACH(items, l, it) { - if ((it->desk != current_desk) && + a = 255.0; + + if ((it->desk != current_desk) && (it->desk != previous_desk)) { double ax = it->cur_x - it->x; @@ -162,16 +165,10 @@ double by = it->bd_y - it->y; a = (1.0 - sqrt(ax*ax + ay*ay) / - sqrt(bx*bx + by*by)) * 220; + sqrt(bx*bx + by*by)) * 255.0; } - else - { - //a = 220.0 + (35.0 * in); - a = 255.0; - } - it->alpha = a; - evas_object_color_set(it->o_win, a, a, a, a); + evas_object_color_set(it->o, a, a, a, a); } } @@ -234,6 +231,7 @@ EINA_LIST_FOREACH(items, l, it) { edje_object_signal_emit(it->o, "hide", "e"); + edje_object_signal_emit(it->o, "mouse,in", "e"); it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone->w; it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone->h; } @@ -280,8 +278,6 @@ e_config->desk_flip_animate_mode = tmp; } - /* _pager_place_windows(1.0); */ - EINA_LIST_FREE(items, it) _pager_win_del(it); @@ -355,7 +351,6 @@ else if (ev->button == 1) { e_border_raise(it->bd); - e_border_focus_set(it->bd, 1, 1); evas_object_raise(it->o); @@ -488,6 +483,11 @@ { Item *it = data; + if (!mouse_activated) + return; + + mouse_activated = 0; + if (selected_item && (it != selected_item)) { edje_object_signal_emit(selected_item->o, "mouse,out", "e"); @@ -502,6 +502,8 @@ _pager_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info) { /* Item *it = data; */ + if (!mouse_activated) + return; if (selected_item) { @@ -617,7 +619,6 @@ it->desk = it->bd->desk; it->man = man; it->cw = cw; - it->alpha = 255.0; e_object_ref(E_OBJECT(it->bd)); e_manager_comp_src_hidden_set(man, src, EINA_TRUE); @@ -666,9 +667,7 @@ it->cur_h = it->bd->h; if (it->desk != current_desk) - { - e_border_show(it->bd); - } + e_border_show(it->bd); _pager_win_final_position_set(it); @@ -679,6 +678,11 @@ edje_object_signal_emit(it->o, "show", "e"); + if (it->bd != e_border_focused_get()) + edje_object_signal_emit(it->o, "mouse,out", "e"); + else + selected_item = it; + if (scale_state) _pager_redraw(NULL); } @@ -688,6 +692,22 @@ { Ecore_Event_Mouse_Move *ev = event; + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + if (mouse_x < 0) + { + mouse_x = ev->x; + mouse_y = ev->y; + return ECORE_CALLBACK_PASS_ON; + } + if ((mouse_x == ev->x) || (mouse_y == ev->y)) + return ECORE_CALLBACK_PASS_ON; + mouse_activated = 1; + evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, ev->timestamp, NULL); @@ -700,6 +720,12 @@ Ecore_Event_Mouse_Button *ev = event; Evas_Button_Flags flags = EVAS_BUTTON_NONE; + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); @@ -735,7 +761,7 @@ if (desk) _pager_desk_select(desk); } - + _pager_out(); return ECORE_CALLBACK_PASS_ON; } @@ -800,17 +826,14 @@ desk = e_desk_at_xy_get(zone, desk_x, desk_y); if (desk) _pager_desk_select(desk); - if (!scale_state) - { - Eina_List *l; - Item *it; - - EINA_LIST_FOREACH(items, l, it) - { - it->alpha = 255.0; - evas_object_color_set(it->o_win, 255.0, 255.0, 255.0, 255.0); - } - } + /* if (!scale_state) + * { + * Eina_List *l; + * Item *it; + * + * EINA_LIST_FOREACH(items, l, it) + * evas_object_color_set(it->o, 255.0, 255.0, 255.0, 255.0); + * } */ } static Eina_Bool @@ -905,6 +928,10 @@ Ecore_Event_Handler *h; Evas *e; + mouse_activated = 0; + mouse_x = -1; + mouse_y = -1; + if (input_win) return EINA_FALSE; e = e_manager_comp_evas_get(man); @@ -996,7 +1023,7 @@ EINA_LIST_FOREACH(items, l, it) if (it->bd->desk != current_desk) - evas_object_color_set(it->o_win, 0, 0, 0, 0); + evas_object_color_set(it->o, 0, 0, 0, 0); } evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); @@ -1043,7 +1070,7 @@ Evas *e; if (!scale_state) return; - + if (strcmp(name, "comp.manager")) return; DBG("handler... '%s' '%s'\n", name, info); Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-09 03:09:59 UTC (rev 57610) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-09 03:27:07 UTC (rev 57611) @@ -96,6 +96,11 @@ static int send_to_desk = EINA_FALSE; static int scale_layout; static int init_method = 0; +static int mouse_activated = 0; +static int mouse_x, mouse_y; +static int warp_x, warp_y, warp_pointer; +static double warp_start; +static Ecore_Animator *warp_animator = NULL; static void _scale_place_windows(double scale) @@ -116,6 +121,28 @@ } static Eina_Bool +_scale_warp_pointer(void *data) +{ + Item *it = selected_item; + + if (it) + { + double in = (ecore_time_get() - warp_start) / 0.25; + if (in > 1.0) in = 1.0; + + ecore_x_pointer_warp(it->bd->zone->container->win, + (double)warp_x * (1.0 - in) + (double)(it->x + it->w/2) * in, + (double)warp_y * (1.0 - in) + (double)(it->y + it->h/2) * in); + + if (in < 1.0) + return ECORE_CALLBACK_RENEW; + } + + warp_animator = NULL; + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool _scale_redraw(void *data) { Eina_List *l; @@ -161,6 +188,14 @@ } } + if (warp_pointer && selected_item) + { + it = selected_item; + ecore_x_pointer_warp(it->bd->zone->container->win, + (double)warp_x * (1.0 - in) + (double)(it->bd->x + it->bd->w/2) * in, + (double)warp_y * (1.0 - in) + (double)(it->bd->y + it->bd->h/2) * in); + } + if (scale_conf->fade_popups) { a = 255.0 * in; @@ -259,6 +294,12 @@ if (!scale_animator) scale_animator = ecore_animator_add(_scale_redraw, NULL); + if (warp_animator) + { + ecore_animator_del(warp_animator); + warp_animator = NULL; + } + if (selected_item) { it = selected_item; @@ -268,23 +309,38 @@ if ((init_method == GO_KEY) && (e_config->focus_policy != E_FOCUS_CLICK)) { - int slide = e_config->pointer_slide; - int focus = e_config->focus_policy; + /* int slide = e_config->pointer_slide; + * int focus = e_config->focus_policy; + * double warp_speed = e_config->winlist_warp_speed; + * + * e_config->pointer_slide = 1; + * e_config->focus_policy = E_FOCUS_MOUSE; + * e_config->winlist_warp_speed = duration/2.0; + * + * e_border_focus_set_with_pointer(it->bd); + * + * e_config->pointer_slide = slide; + * e_config->focus_policy = focus; + * e_config->winlist_warp_speed = warp_speed; */ + /* ecore_x_pointer_warp(it->bd->zone->container->win, + * it->bd->zone->x + it->bd->x + bd->w/2, + * it->bd->zone->y + it->bd->y + bd->h/2); */ - e_config->pointer_slide = 1; - e_config->focus_policy = E_FOCUS_MOUSE; - - e_border_focus_set_with_pointer(it->bd); - - e_config->pointer_slide = slide; - e_config->focus_policy = focus; + warp_pointer = 1; + ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y); + e_border_focus_set(it->bd, 1, 1); } else - e_border_focus_set(it->bd, 1, 1); + { + e_border_focus_set(it->bd, 1, 1); + } edje_object_signal_emit(it->o, "hide", "e"); } + EINA_LIST_FOREACH(items, l, it) + edje_object_signal_emit(it->o, "mouse,in", "e"); + scale_state = EINA_FALSE; } @@ -350,10 +406,22 @@ { Item *it = data; + if (!mouse_activated) + return; + if (!scale_state) return; + if (it == selected_item) + return; + + mouse_activated = 0; + + if (selected_item) + edje_object_signal_emit(selected_item->o, "mouse,out", "e"); + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; } static void @@ -361,10 +429,14 @@ { Item *it = data; + if (!mouse_activated) + return; + if (!scale_state) return; - edje_object_signal_emit(it->o, "mouse,out", "e"); + if (it == selected_item) + edje_object_signal_emit(it->o, "mouse,out", "e"); } static void @@ -1321,45 +1393,15 @@ } } - -#if 0 -static Item * -_scale_item_select(int direction) +static void +_scale_warp_animator_run(Item *it) { - double min; - Item *last, *min; - Eina_List *l; + ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y); + warp_start = ecore_time_get(); - if (direction == DIR_RIGHT) - { - EINA_LIST_FOREACH(items, l, it2) - { - - } - } - else if (direction == DIR_LEFT) - { - EINA_LIST_FOREACH(items, l, it2) - { - - } - } - else if (direction == DIR_UP) - { - EINA_LIST_FOREACH(items, l, it2) - { - - } - } - else if (direction == DIR_DOWN) - { - EINA_LIST_FOREACH(items, l, it2) - { - - } - } + if (!warp_animator) + warp_animator = ecore_animator_add(_scale_warp_pointer, it); } -#endif static void _scale_switch(const char *params) @@ -1376,7 +1418,7 @@ if ((!sel->next) || (!sel->prev)) return; - + if (!strcmp(params, "_next")) { it = sel->next; @@ -1388,11 +1430,11 @@ else if (!strcmp(params, "_left")) { it = sel->prev; - + if (it->slot_y != sel->slot_y) { it = sel; - + while(sel->slot_y == it->next->slot_y) { it = it->next; @@ -1403,7 +1445,7 @@ else if (!strcmp(params, "_right")) { it = sel->next; - + if (it->slot_y != sel->slot_y) { it = sel; @@ -1417,7 +1459,7 @@ else if (!strcmp(params, "_up")) { it = sel; - + while((sel->slot_y == it->slot_y) || (sel->slot_x < it->slot_x)) { @@ -1428,7 +1470,7 @@ else if (!strcmp(params, "_down")) { it = sel; - + while((sel->slot_y == it->slot_y) || (sel->slot_x > it->slot_x)) { @@ -1442,14 +1484,17 @@ edje_object_signal_emit(sel->o, "mouse,out", "e"); edje_object_signal_emit(it->o, "mouse,in", "e"); - e_border_focus_set(it->bd, 1, 1); + selected_item = it; + + _scale_warp_animator_run(it); } static Eina_Bool _scale_cb_key_down(void *data, int type, void *event) { Ecore_Event_Key *ev = event; + printf("key down\n"); if (ev->window != input_win) return ECORE_CALLBACK_PASS_ON; @@ -1549,7 +1594,12 @@ int i; Item *it; E_Border *bd; - + + mouse_activated = 0; + mouse_x = -1; + mouse_y = -1; + warp_pointer = 0; + e = e_manager_comp_evas_get(man); if (!e) return EINA_FALSE; @@ -1689,31 +1739,59 @@ DBG("time: %f\n", ecore_time_get() - start_time); - evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); - evas_event_feed_mouse_move(e, -1000000, -1000000, - ecore_x_current_time_get(), NULL); + it = NULL; + bd = NULL; - bd = e_border_focused_get(); + if (init_method == GO_KEY) + { + E_Border *bd2 = NULL; - EINA_LIST_FOREACH(items, l , it) - if (it->bd == bd) break; + EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) + if ((bd != bd2) && (bd->desk == current_desk)) + { + if (!bd2) bd2 = bd; + else break; + } + if (!bd) bd = bd2; + } + else + { + EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) + if (bd->desk == current_desk) break; + } + if (bd) + { + EINA_LIST_FOREACH(items, l, it) + if (it->bd == bd) break; + } + if (it) selected_item = it; else selected_item = eina_list_data_get(items); - edje_object_signal_emit(selected_item->o, "mouse,in", "e"); + EINA_LIST_FOREACH(items, l, it) + { + if (it != selected_item) + edje_object_signal_emit(it->o, "mouse,out", "e"); - if (scale_conf->pager_fade_windows) - { - EINA_LIST_FOREACH(items, l, it) - if (it->bd->desk != current_desk) - evas_object_color_set(it->o, 0, 0, 0, 0); + if (scale_conf->fade_windows) + { + if (it->bd->desk != current_desk) + evas_object_color_set(it->o, 0, 0, 0, 0); + } } _scale_in(); + if (init_method == GO_KEY) + _scale_warp_animator_run(selected_item); + + evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); + evas_event_feed_mouse_move(e, -1000000, -1000000, + ecore_x_current_time_get(), NULL); + return EINA_TRUE; } @@ -1723,6 +1801,28 @@ { Ecore_Event_Mouse_Move *ev = event; + /* wtf?! dont need move events when nothing is moving */ + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + if (warp_animator) + return ECORE_CALLBACK_PASS_ON; + + if (mouse_x < 0) + { + mouse_x = ev->x; + mouse_y = ev->y; + return ECORE_CALLBACK_PASS_ON; + } + if ((mouse_x == ev->x) || (mouse_y == ev->y)) + return ECORE_CALLBACK_PASS_ON; + + mouse_activated = 1; + printf("mouse move %d %d\n", ev->x, ev->y); + evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; @@ -1736,6 +1836,9 @@ Eina_List *l; Item *it; + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + EINA_LIST_FOREACH(items, l, it) if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) break; @@ -1759,6 +1862,9 @@ Ecore_Event_Mouse_Button *ev = event; Evas_Button_Flags flags = EVAS_BUTTON_NONE; + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; @@ -1816,7 +1922,7 @@ if (strcmp(name, "comp.manager")) return; DBG("handler... '%s' '%s'\n", name, info); - + /* XXX disabled for now. */ return; |
From: Enlightenment S. <no-...@en...> - 2011-03-19 10:13:04
|
Log: e-modules/comp-scale: fix min/max regionsize in scale-layout. caused really bad layouting - added scale-by-window-class action Author: jeffdameth Date: 2011-03-19 03:12:55 -0700 (Sat, 19 Mar 2011) New Revision: 57892 Trac: http://trac.enlightenment.org/e/changeset/57892 Added: trunk/E-MODULES-EXTRA/comp-scale/label.png Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-19 07:20:33 UTC (rev 57891) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-19 10:12:55 UTC (rev 57892) @@ -2,6 +2,7 @@ { image: "module_icon.png" COMP; image: "sh.png" COMP; + image: "label.png" COMP; } collections @@ -120,10 +121,6 @@ offset: 15 17; } } - description { state: "hidden" 0.0; - inherit: "default" 0.0; - visible: 0; - } } part { @@ -135,6 +132,81 @@ color: 255 255 255 255; } } + + part { + name: "text.clipper"; + type: RECT; + description { + state: "default" 0.0; + rel1 { + to: "e.swallow.win"; + offset: 10 0; + } + rel2 { + to: "e.swallow.win"; + offset: -10 -1; + } + color: 255 255 255 0; + } + description { + state: "show" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + + part { + name: "text_bg"; + mouse_events: 0; + clip_to: "text.clipper"; + description { + state: "default" 0.0; + min: 60 22; + max: 9999 22; + color: 255 255 255 192; + rel1 { + to: "e.text.label"; + relative: 0.0 0.0; + offset: -10 0; + } + rel2 { + to: "e.text.label"; + relative: 1.0 1.0; + offset: 10 -1; + } + image { + normal: "label.png"; + border: 5 5 5 5; + } + } + } + part { + name: "e.text.label"; + type: TEXT; + mouse_events: 0; + clip_to: "text.clipper"; + description { + state: "default" 0.0; + rel1 { + to: "e.swallow.win"; + offset: 25 0; + } + rel2 { + to: "e.swallow.win"; + offset: -25 -1; + } + text { + font: "Sans:style=Bold"; + size: 7; + align: 0.5 0.5; + elipsis: 1.0; + /* min: 0 1; */ + max: 1 0; + text: ""; + text_class: "border_title_active"; + } + } + } } programs { program { @@ -142,7 +214,7 @@ signal: "mouse,in"; source: "e"; action: STATE_SET "default" 0.0; - transition: LINEAR 0.2; + transition: SINUSOIDAL 0.4; target: "clipper"; } program { @@ -150,9 +222,41 @@ signal: "mouse,out"; source: "e"; action: STATE_SET "faded" 0.0; - transition: LINEAR 0.4; + transition: SINUSOIDAL 0.4; target: "clipper"; } + /* program { + * name: "mouse_in2"; + * signal: "mouse,in"; + * source: "e"; + * action: STATE_SET "show" 0.0; + * transition: SINUSOIDAL 0.5; + * target: "text.clipper"; + * } */ + /* program { + * name: "mouse_out2"; + * signal: "mouse,out"; + * source: "e"; + * action: STATE_SET "default" 0.0; + * transition: SINUSOIDAL 0.5; + * target: "text.clipper"; + * } */ + program { + name: "hide"; + signal: "hide"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.2; + target: "clipper"; + } + /* program { + * name: "show"; + * signal: "show"; + * source: "e"; + * action: STATE_SET "default" 0.0; + * transition: SINUSOIDAL 0.2; + * target: "text.clipper"; + * } */ } } group { Property changes on: trunk/E-MODULES-EXTRA/comp-scale/label.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-19 07:20:33 UTC (rev 57891) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-03-19 10:12:55 UTC (rev 57892) @@ -244,6 +244,8 @@ "scale-windows", "go_scale", NULL, 0); e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows (All Desktops)"), "scale-windows", "go_scale_all", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows (By Class)"), + "scale-windows", NULL, "go_scale_class:E", 1); e_action_predef_name_set(D_("Scale Windows"), D_("Select Next"), "scale-windows", "go_scale_next", NULL, 0); e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous"), @@ -308,6 +310,7 @@ { e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows")); e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows (All Desktops)")); + e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows (By Class)")); e_action_predef_name_del(D_("Scale Windows"), D_("Select Next")); e_action_predef_name_del(D_("Scale Windows"), D_("Select Previous")); Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-19 07:20:33 UTC (rev 57891) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-19 10:12:55 UTC (rev 57892) @@ -233,7 +233,7 @@ EINA_LIST_FOREACH(items, l, it) { edje_object_signal_emit(it->o, "hide", "e"); - edje_object_signal_emit(it->o, "mouse,in", "e"); + /* edje_object_signal_emit(it->o, "mouse,in", "e"); */ it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone->w; it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone->h; } @@ -504,6 +504,9 @@ if (!mouse_activated) return; + if (!scale_state) + return; + mouse_activated = 0; if (selected_item && (it != selected_item)) @@ -699,6 +702,7 @@ items = eina_list_append(items, it); + edje_object_part_text_set(it->o, "e.text.label", e_border_name_get(it->bd)); edje_object_signal_emit(it->o, "show", "e"); if (it->bd != e_border_focused_get()) Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-19 07:20:33 UTC (rev 57891) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-19 10:12:55 UTC (rev 57892) @@ -17,8 +17,10 @@ E_Comp_Win *cw; E_Manager *man; double scale; - int alpha; + Eina_Bool was_hidden; + Eina_Bool fade; + double x; double y; double w; @@ -45,6 +47,7 @@ Item *next; Item *prev; + }; struct _Slot @@ -72,12 +75,19 @@ static void _scale_in(void); static void _scale_out(int mode); static void _scale_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); +static void _scale_place_natural(); +static int _scale_place_slotted(); +static int _scale_grow(); +static int _scale_place(int offset); +static int _scale_shrink(); +static int _cb_sort_center(const void *d1, const void *d2); static Ecore_X_Window input_win = 0; static E_Msg_Handler *msg_handler = NULL; static Eina_List *items = NULL; +static Eina_List *items_fade = NULL; static Eina_List *popups = NULL; static Eina_List *handlers = NULL; static Ecore_Animator *scale_animator = NULL; @@ -96,6 +106,7 @@ static int send_to_desk = EINA_FALSE; static int scale_layout; static int init_method = 0; +static const char *match_class = NULL; static int mouse_activated = 0; static int mouse_x, mouse_y; static int warp_x, warp_y, warp_pointer; @@ -165,8 +176,6 @@ in = log(10) * scale; in = 1.0 / exp(in*in); - /* in = 1.0 - (1.0 / exp(in*in)); - * in = 0.5 * (1.0 + cos(in * M_PI)); */ _scale_place_windows(in); @@ -186,7 +195,6 @@ a = (1.0 - sqrt(ax*ax + ay*ay) / sqrt(bx*bx + by*by)) * 255.0; } - it->alpha = a; evas_object_color_set(it->o, a, a, a, a); } } @@ -199,14 +207,20 @@ (double)warp_y * (1.0 - in) + (double)(it->bd->y + it->bd->h/2) * in); } + a = 255.0 * in; + + EINA_LIST_FOREACH(items_fade, l, it) + { + if ((it->bd->desk == current_desk) || (it->bd->sticky)) + evas_object_color_set(it->o, a, a, a, a); + } + if (scale_conf->fade_popups) { - a = 255.0 * in; - EINA_LIST_FOREACH(popups, l, it) evas_object_color_set(it->o_win, a, a, a, a); } - + if (scale_conf->fade_desktop && background) { a = 255.0 * (0.5 + in/2.0); @@ -320,12 +334,10 @@ { e_border_focus_set(it->bd, 1, 1); } - - edje_object_signal_emit(it->o, "hide", "e"); } EINA_LIST_FOREACH(items, l, it) - edje_object_signal_emit(it->o, "mouse,in", "e"); + edje_object_signal_emit(it->o, "hide", "e"); scale_state = EINA_FALSE; } @@ -361,11 +373,12 @@ } } - /* _scale_place_windows(1.0); */ - EINA_LIST_FREE(items, it) _scale_win_del(it); + EINA_LIST_FREE(items_fade, it) + _scale_win_del(it); + EINA_LIST_FREE(popups, it) _scale_win_del(it); @@ -394,7 +407,8 @@ background = NULL; send_to_desk = EINA_FALSE; show_all_desks = EINA_FALSE; - + eina_stringshare_replace(&match_class, NULL); + e_manager_comp_evas_update(e_manager_current_get()); } @@ -515,7 +529,12 @@ e_border_hide(it->bd, 2); evas_object_hide(it->cw->shobj); } - + else if (it->was_hidden) + { + e_border_hide(it->bd, 1); + evas_object_hide(it->cw->shobj); + } + evas_object_del(it->o_win); evas_object_del(it->o); @@ -575,9 +594,14 @@ if ((!show_all_desks) && (cw->bd->desk != desk)) return NULL; - if (cw->bd->iconic) - return NULL; + if (!match_class) + { + /* TODO make option */ + if (cw->bd->iconic) + return NULL; + } + it = E_NEW(Item, 1); it->scale = 1.0; @@ -601,6 +625,51 @@ evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, _scale_win_cb_delorig, it); + it->dx = cw->bd->desk->x - desk->x; + it->dy = cw->bd->desk->y - desk->y; + + it->bd_x = (it->bd->x - zone->x); + it->bd_y = (it->bd->y - zone->y); + + it->x = it->bd_x + it->dx * desk->zone->w; + it->y = it->bd_y + it->dy * desk->zone->h; + it->w = it->bd->w; + it->h = it->bd->h; + + it->cur_x = it->x; + it->cur_y = it->y; + it->cur_w = it->w; + it->cur_h = it->h; + + if (!it->bd->visible) + { + if (it->bd->iconic) + it->was_hidden = EINA_TRUE; + + e_border_show(it->bd); + } + + /* if (it->bd->shaded) + * e_border_unshade(it->bd, ); */ + + edje_object_part_text_set(it->o, "e.text.label", e_border_name_get(it->bd)); + edje_object_signal_emit(it->o, "show", "e"); + + if (match_class) + { + if ((!(cw->bd->client.icccm.class) || + (strcmp(cw->bd->client.icccm.class, match_class)))) + { + items_fade = eina_list_append(items_fade, it); + evas_object_move(it->o, it->bd->x, it->bd->y); + evas_object_resize(it->o, it->cw->pw, it->cw->ph); + evas_object_pass_events_set(it->o, 1); + if (it->bd->desk != desk) + evas_object_color_set(it->o, 0, 0, 0, 0); + return it; + } + } + evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_IN, _scale_win_cb_mouse_in, it); @@ -616,32 +685,607 @@ /* evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_MOVE, * _scale_win_cb_mouse_move, it); */ - it->dx = cw->bd->desk->x - desk->x; - it->dy = cw->bd->desk->y - desk->y; + printf("scale %s\n", e_border_name_get(it->bd)); + + items = eina_list_append(items, it); + + return it; +} - it->bd_x = (it->bd->x - zone->x); - it->bd_y = (it->bd->y - zone->y); - it->x = it->bd_x + it->dx * desk->zone->w; - it->y = it->bd_y + it->dy * desk->zone->h; - it->w = it->bd->w; - it->h = it->bd->h; +static void +_scale_warp_animator_run(Item *it) +{ + ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y); + warp_start = ecore_time_get(); - it->cur_x = it->x; - it->cur_y = it->y; - it->cur_w = it->w; - it->cur_h = it->h; + if (!warp_animator) + warp_animator = ecore_animator_add(_scale_warp_pointer, it); +} - if (it->bd->desk != desk) - e_border_show(it->bd); +static void +_scale_switch(const char *params) +{ + Item *it, *sel; - edje_object_signal_emit(it->o, "show", "e"); + sel = selected_item; - items = eina_list_append(items, it); + if (params[0] == 0) + { + _scale_out(1); + return; + } - return it; + if ((!sel->next) || (!sel->prev)) + return; + + if (!strcmp(params, "_next")) + { + it = sel->next; + } + else if (!strcmp(params, "_prev")) + { + it = sel->prev; + } + else if (!strcmp(params, "_left")) + { + it = sel->prev; + + if (it->slot_y != sel->slot_y) + { + it = sel; + + while(sel->slot_y == it->next->slot_y) + { + it = it->next; + if (it == sel) break; + } + } + } + else if (!strcmp(params, "_right")) + { + it = sel->next; + + if (it->slot_y != sel->slot_y) + { + it = sel; + while(sel->slot_y == it->prev->slot_y) + { + it = it->prev; + if (it == sel) break; + } + } + } + else if (!strcmp(params, "_up")) + { + it = sel; + + while((sel->slot_y == it->slot_y) || + (sel->slot_x < it->slot_x)) + { + it = it->prev; + if (it == sel) break; + } + } + else if (!strcmp(params, "_down")) + { + it = sel; + + while((sel->slot_y == it->slot_y) || + (sel->slot_x > it->slot_x)) + { + it = it->next; + if (it == sel) break; + } + } + + if (it == sel) + return; + + edje_object_signal_emit(sel->o, "mouse,out", "e"); + edje_object_signal_emit(it->o, "mouse,in", "e"); + + selected_item = it; + + _scale_warp_animator_run(it); } +static Eina_Bool +_scale_cb_key_down(void *data, int type, void *event) +{ + Ecore_Event_Key *ev = event; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!strcmp(ev->key, "Up")) + _scale_switch("_up"); + else if (!strcmp(ev->key, "Down")) + _scale_switch("_down"); + else if (!strcmp(ev->key, "Left")) + _scale_switch("_left"); + else if (!strcmp(ev->key, "Right")) + _scale_switch("_right"); + else if (!strcmp(ev->key, "h")) + _scale_switch("_left"); + else if (!strcmp(ev->key, "j")) + _scale_switch("_down"); + else if (!strcmp(ev->key, "k")) + _scale_switch("_up"); + else if (!strcmp(ev->key, "l")) + _scale_switch("_right"); + else if (!strcmp(ev->key, "p")) + _scale_switch("_prev"); + else if (!strcmp(ev->key, "n")) + _scale_switch("_next"); + else if (!strcmp(ev->key, "Return")) + _scale_out(1); + else + if (!strcmp(ev->key, "space")) + _scale_out(1); + else if (!strcmp(ev->key, "Escape")) + { + /* TODO go to previously focused window */ + _scale_out(0); + } + else + { + E_Action *act; + Eina_List *l; + E_Config_Binding_Key *bind; + E_Binding_Modifier mod; + + for (l = e_config->key_bindings; l; l = l->next) + { + bind = l->data; + mod = 0; + + if (bind->action && strcmp(bind->action, "scale-windows")) continue; + if (!bind->params || strncmp(bind->params, "go_scale", 8)) continue; + + if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + mod |= E_BINDING_MODIFIER_SHIFT; + if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) + mod |= E_BINDING_MODIFIER_CTRL; + if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) + mod |= E_BINDING_MODIFIER_ALT; + if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) + mod |= E_BINDING_MODIFIER_WIN; + + if (bind->key && (!strcmp(bind->key, ev->keyname)) && + ((bind->modifiers == mod) || (bind->any_mod))) + { + if (!(act = e_action_find(bind->action))) continue; + if (act->func.go_key) + act->func.go_key(E_OBJECT(zone), bind->params, ev); + else if (act->func.go) + act->func.go(E_OBJECT(zone), bind->params); + } + } + } + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_scale_cb_key_up(void *data, int type, void *event) +{ + Ecore_Event_Key *ev = event; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + if (!e_mod_hold_modifier_check(event)) + _scale_out(1); + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_scale_run(E_Manager *man) +{ + Eina_List *l; + E_Manager_Comp_Source *src; + Ecore_Event_Handler *h; + Evas *e; + int i; + Item *it; + E_Border *bd; + + mouse_activated = 0; + mouse_x = -1; + mouse_y = -1; + warp_pointer = 0; + + e = e_manager_comp_evas_get(man); + if (!e) return EINA_FALSE; + + zone = e_util_zone_current_get(e_manager_current_get()); + current_desk = e_desk_current_get(zone); + + start_time = ecore_time_get(); + + input_win = ecore_x_window_input_new(zone->container->win, 0, 0, 1, 1); + ecore_x_window_show(input_win); + if (!e_grabinput_get(input_win, 0, input_win)) + { + ecore_x_window_free(input_win); + input_win = 0; + return EINA_FALSE; + } + + msg_handler = e_msg_handler_add(_scale_handler, NULL); + + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, + _scale_cb_mouse_down, e); + handlers = eina_list_append(handlers, h); + + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, + _scale_cb_mouse_up, e); + handlers = eina_list_append(handlers, h); + + h = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, + _scale_cb_mouse_move, e); + handlers = eina_list_append(handlers, h); + + h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, + _scale_cb_key_down, e); + handlers = eina_list_append(handlers, h); + + h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, + _scale_cb_key_up, e); + handlers = eina_list_append(handlers, h); + + zone_clip = evas_object_rectangle_add(e); + evas_object_move(zone_clip, zone->x, zone->y); + evas_object_resize(zone_clip, zone->w, zone->h); + evas_object_show(zone_clip); + + EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) + { + Item *it = _scale_win_new(e, man, src, current_desk); + if (it) evas_object_clip_set(it->o, zone_clip); + } + + if (eina_list_count(items) < 1) + { + _scale_finish(); + return EINA_FALSE; + } + + if ((eina_list_count(items) < 2) && (!show_all_desks)) + { + _scale_finish(); + return EINA_FALSE; + } + + if (show_all_desks) + spacing = scale_conf->desks_spacing; + else + spacing = scale_conf->spacing; + + if (!scale_conf->fade_popups) + { + e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); + use_x -= zone->x; + use_y -= zone->y; + use_w += use_x - spacing*2; + use_h += use_y - spacing*2; + use_x += spacing; + use_y += spacing; + } + else + { + use_x = spacing; + use_y = spacing; + use_w = zone->w - spacing; + use_h = zone->h - spacing; + } + + /* XXX for what was this intended ??? */ + min_x = 0; //zone->w * zone->desk_x_current; + min_y = 0; //zone->h * zone->desk_y_current; + max_x = zone->w; // + zone->w * ((zone->desk_x_count - 1) - zone->desk_x_current); + max_y = zone->h; // + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current); + + /* scale all windows down to be next to each other on one zone */ + if (scale_layout) + _scale_place_slotted(); + else + _scale_place_natural(); + + min_x = use_x; + min_y = use_y; + max_x = use_w; + max_y = use_h; + + if ((scale_conf->grow && !show_all_desks) || + (scale_conf->desks_grow && show_all_desks)) + { + i = 0; + while (i++ < GROW_RUNS && _scale_grow()); + DBG("grow %d", i); + } + + if ((scale_conf->tight && !show_all_desks) || + (scale_conf->desks_tight && show_all_desks)) + { + items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); + i = 0; + while (i++ < SHRINK_RUNS && _scale_shrink()); + DBG("shrunk %d", i); + } + + if (show_all_desks) + { + /* center and move windows near visible desk + * to make the sliding smoother */ + + min_x = zone->w; + min_y = zone->h; + max_x = 0; + max_y = 0; + + EINA_LIST_FOREACH(items, l, it) + { + if (it->x < min_x) min_x = it->x; + if (it->y < min_y) min_y = it->y; + if (it->x + it->w > max_x) max_x = it->x + it->w; + if (it->y + it->h > max_y) max_y = it->y + it->h; + } + + EINA_LIST_FOREACH(items, l, it) + { + it->x = (it->x - min_x) + use_x + ((use_w - use_x) - (max_x - min_x))/2.0; + it->y = (it->y - min_y) + use_y + ((use_h - use_y) - (max_y - min_y))/2.0; + + if (it->dx > 0) it->bd_x = zone->w + it->bd->x/4; + if (it->dy > 0) it->bd_y = zone->h + it->bd->y/4; + if (it->dx < 0) it->bd_x = -zone->w + (zone->w - it->bd->w) + it->bd->x/4; + if (it->dy < 0) it->bd_y = -zone->h + (zone->h - it->bd->h) + it->bd->y/4; + } + } + + EINA_LIST_FOREACH(items, l, it) + { + it->x += zone->x; + it->y += zone->y; + it->bd_x += zone->x; + it->bd_y += zone->y; + } + + DBG("time: %f\n", ecore_time_get() - start_time); + + it = NULL; + bd = NULL; + + if (init_method == GO_KEY) + { + E_Border *bd2 = NULL; + + EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) + if ((bd != bd2) && (bd->desk == current_desk)) + { + if (!bd2) bd2 = bd; + else break; + } + if (!bd) bd = bd2; + } + else + { + EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) + if (bd->desk == current_desk) break; + } + + if (bd) + { + EINA_LIST_FOREACH(items, l, it) + if (it->bd == bd) break; + } + + if (it) + selected_item = it; + else + selected_item = eina_list_data_get(items); + + EINA_LIST_FOREACH(items, l, it) + { + if (it != selected_item) + edje_object_signal_emit(it->o, "mouse,out", "e"); + + if (scale_conf->fade_windows) + { + if (it->bd->desk != current_desk) + evas_object_color_set(it->o, 0, 0, 0, 0); + } + } + + _scale_in(); + + if (init_method == GO_KEY) + _scale_warp_animator_run(selected_item); + + evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); + evas_event_feed_mouse_move(e, -1000000, -1000000, + ecore_x_current_time_get(), NULL); + + return EINA_TRUE; +} + + +static Eina_Bool +_scale_cb_mouse_move(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Move *ev = event; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + if (!scale_state) + return ECORE_CALLBACK_PASS_ON; + + if (warp_animator) + return ECORE_CALLBACK_PASS_ON; + + if (mouse_x < 0) + { + mouse_x = ev->x; + mouse_y = ev->y; + return ECORE_CALLBACK_PASS_ON; + } + if ((mouse_x == ev->x) || (mouse_y == ev->y)) + return ECORE_CALLBACK_PASS_ON; + + mouse_activated = 1; + + evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, ev->timestamp, NULL); + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_scale_cb_mouse_down(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Button *ev = event; + Evas_Button_Flags flags = EVAS_BUTTON_NONE; + Eina_List *l; + Item *it; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + EINA_LIST_FOREACH(items, l, it) + if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) + break; + + if (!it) + { + _scale_out(1); + return ECORE_CALLBACK_PASS_ON; + } + + if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; + if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; + evas_event_feed_mouse_down((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_scale_cb_mouse_up(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Button *ev = event; + Evas_Button_Flags flags = EVAS_BUTTON_NONE; + + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; + + evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +scale_run(E_Manager *man, const char *params, int _init_method) +{ + Eina_Bool ret = EINA_FALSE; + const char *opt = params; + + if (!strncmp(params, "go_scale_all", 12)) + { + scale_layout = scale_conf->desks_layout_mode; + show_all_desks = EINA_TRUE; + opt = params+12; + } + else if (!strncmp(params, "go_scale_class:", 15)) + { + if (scale_state) + return ret; + + scale_layout = 1; /* slotted */ + show_all_desks = EINA_TRUE; + opt = params+15; + eina_stringshare_replace(&match_class, opt); + } + else if (!strncmp(params, "go_scale", 8)) + { + scale_layout = scale_conf->layout_mode; + show_all_desks = EINA_FALSE; + opt = params+8; + } + else + { + return ret; + } + + init_method = _init_method; + + if (init_method == GO_KEY) + scale_layout = 1; + + if (scale_state) + { + _scale_switch(opt); + } + else + { + if (input_win) + return ret; + + ret = _scale_run(man); + } + + return ret; +} + + +static void +_scale_handler(void *data, const char *name, const char *info, int val, + E_Object *obj, void *msgdata) +{ + E_Manager *man = (E_Manager *)obj; + E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata; + Evas *e; + + if (strcmp(name, "comp.manager")) return; + + DBG("handler... '%s' '%s'\n", name, info); + + /* XXX disabled for now. */ + /* return; */ + + e = e_manager_comp_evas_get(man); + if (!strcmp(info, "change.comp")) + { + if (!e) DBG("TTT: No comp manager\n"); + else DBG("TTT: comp canvas = %p\n", e); + } + else if (!strcmp(info, "resize.comp")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "add.src")) + { + DBG("%s: %p | %p\n", info, man, src); + e_manager_comp_src_hidden_set(man, src, EINA_TRUE); + } + else if (!strcmp(info, "del.src")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "config.src")) + { + + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "visibility.src")) + { + DBG("%s: %p | %p\n", info, man, src); + } +} + static int _scale_grow() { @@ -1394,583 +2038,3 @@ } } } - -static void -_scale_warp_animator_run(Item *it) -{ - ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y); - warp_start = ecore_time_get(); - - if (!warp_animator) - warp_animator = ecore_animator_add(_scale_warp_pointer, it); -} - -static void -_scale_switch(const char *params) -{ - Item *it, *sel; - - sel = selected_item; - - if (params[0] == 0) - { - _scale_out(1); - return; - } - - if ((!sel->next) || (!sel->prev)) - return; - - if (!strcmp(params, "_next")) - { - it = sel->next; - } - else if (!strcmp(params, "_prev")) - { - it = sel->prev; - } - else if (!strcmp(params, "_left")) - { - it = sel->prev; - - if (it->slot_y != sel->slot_y) - { - it = sel; - - while(sel->slot_y == it->next->slot_y) - { - it = it->next; - if (it == sel) break; - } - } - } - else if (!strcmp(params, "_right")) - { - it = sel->next; - - if (it->slot_y != sel->slot_y) - { - it = sel; - while(sel->slot_y == it->prev->slot_y) - { - it = it->prev; - if (it == sel) break; - } - } - } - else if (!strcmp(params, "_up")) - { - it = sel; - - while((sel->slot_y == it->slot_y) || - (sel->slot_x < it->slot_x)) - { - it = it->prev; - if (it == sel) break; - } - } - else if (!strcmp(params, "_down")) - { - it = sel; - - while((sel->slot_y == it->slot_y) || - (sel->slot_x > it->slot_x)) - { - it = it->next; - if (it == sel) break; - } - } - - if (it == sel) - return; - - edje_object_signal_emit(sel->o, "mouse,out", "e"); - edje_object_signal_emit(it->o, "mouse,in", "e"); - - selected_item = it; - - _scale_warp_animator_run(it); -} - -static Eina_Bool -_scale_cb_key_down(void *data, int type, void *event) -{ - Ecore_Event_Key *ev = event; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - if (!strcmp(ev->key, "Up")) - _scale_switch("_up"); - else if (!strcmp(ev->key, "Down")) - _scale_switch("_down"); - else if (!strcmp(ev->key, "Left")) - _scale_switch("_left"); - else if (!strcmp(ev->key, "Right")) - _scale_switch("_right"); - else if (!strcmp(ev->key, "h")) - _scale_switch("_left"); - else if (!strcmp(ev->key, "j")) - _scale_switch("_down"); - else if (!strcmp(ev->key, "k")) - _scale_switch("_up"); - else if (!strcmp(ev->key, "l")) - _scale_switch("_right"); - else if (!strcmp(ev->key, "p")) - _scale_switch("_prev"); - else if (!strcmp(ev->key, "n")) - _scale_switch("_next"); - else if (!strcmp(ev->key, "Return")) - _scale_out(1); - else - if (!strcmp(ev->key, "space")) - _scale_out(1); - else if (!strcmp(ev->key, "Escape")) - { - /* TODO go to previously focused window */ - _scale_out(0); - } - else - { - E_Action *act; - Eina_List *l; - E_Config_Binding_Key *bind; - E_Binding_Modifier mod; - - for (l = e_config->key_bindings; l; l = l->next) - { - bind = l->data; - mod = 0; - - if (bind->action && strcmp(bind->action, "scale-windows")) continue; - if (!bind->params || strncmp(bind->params, "go_scale", 8)) continue; - - if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) - mod |= E_BINDING_MODIFIER_SHIFT; - if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) - mod |= E_BINDING_MODIFIER_CTRL; - if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) - mod |= E_BINDING_MODIFIER_ALT; - if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) - mod |= E_BINDING_MODIFIER_WIN; - - if (bind->key && (!strcmp(bind->key, ev->keyname)) && - ((bind->modifiers == mod) || (bind->any_mod))) - { - if (!(act = e_action_find(bind->action))) continue; - if (act->func.go_key) - act->func.go_key(E_OBJECT(zone), bind->params, ev); - else if (act->func.go) - act->func.go(E_OBJECT(zone), bind->params); - } - } - } - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_scale_cb_key_up(void *data, int type, void *event) -{ - Ecore_Event_Key *ev = event; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - if (!scale_state) - return ECORE_CALLBACK_PASS_ON; - - if (!e_mod_hold_modifier_check(event)) - _scale_out(1); - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_scale_run(E_Manager *man) -{ - Eina_List *l; - E_Manager_Comp_Source *src; - Ecore_Event_Handler *h; - Evas *e; - int i; - Item *it; - E_Border *bd; - - mouse_activated = 0; - mouse_x = -1; - mouse_y = -1; - warp_pointer = 0; - - e = e_manager_comp_evas_get(man); - if (!e) return EINA_FALSE; - - zone = e_util_zone_current_get(e_manager_current_get()); - current_desk = e_desk_current_get(zone); - - start_time = ecore_time_get(); - - input_win = ecore_x_window_input_new(zone->container->win, 0, 0, 1, 1); - ecore_x_window_show(input_win); - if (!e_grabinput_get(input_win, 0, input_win)) - { - ecore_x_window_free(input_win); - input_win = 0; - return EINA_FALSE; - } - - msg_handler = e_msg_handler_add(_scale_handler, NULL); - - h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, - _scale_cb_mouse_down, e); - handlers = eina_list_append(handlers, h); - - h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, - _scale_cb_mouse_up, e); - handlers = eina_list_append(handlers, h); - - h = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, - _scale_cb_mouse_move, e); - handlers = eina_list_append(handlers, h); - - h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, - _scale_cb_key_down, e); - handlers = eina_list_append(handlers, h); - - h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, - _scale_cb_key_up, e); - handlers = eina_list_append(handlers, h); - - zone_clip = evas_object_rectangle_add(e); - evas_object_move(zone_clip, zone->x, zone->y); - evas_object_resize(zone_clip, zone->w, zone->h); - evas_object_show(zone_clip); - - EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) - { - Item *it = _scale_win_new(e, man, src, current_desk); - if (it) - evas_object_clip_set(it->o, zone_clip); - } - - if (eina_list_count(items) < 1) - { - _scale_finish(); - return EINA_FALSE; - } - - if ((eina_list_count(items) < 2) && (!show_all_desks)) - { - _scale_finish(); - return EINA_FALSE; - } - - if (show_all_desks) - spacing = scale_conf->desks_spacing; - else - spacing = scale_conf->spacing; - - if (!scale_conf->fade_popups) - { - e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); - use_x -= zone->x; - use_y -= zone->y; - use_w += use_x - spacing*2; - use_h += use_y - spacing*2; - use_x += spacing; - use_y += spacing; - } - else - { - use_x = spacing; - use_y = spacing; - use_w = zone->w - spacing; - use_h = zone->h - spacing; - } - - min_x = zone->w * zone->desk_x_current; - min_y = zone->h * zone->desk_y_current; - max_x = zone->w + zone->w * ((zone->desk_x_count - 1) - zone->desk_x_current); - max_y = zone->h + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current); - - /* scale all windows down to be next to each other on one zone */ - if (scale_layout) - _scale_place_slotted(); - else - _scale_place_natural(); - - min_x = use_x; - min_y = use_y; - max_x = use_w; - max_y = use_h; - - if ((scale_conf->grow && !show_all_desks) || - (scale_conf->desks_grow && show_all_desks)) - { - i = 0; - while (i++ < GROW_RUNS && _scale_grow()); - DBG("grow %d", i); - } - - if ((scale_conf->tight && !show_all_desks) || - (scale_conf->desks_tight && show_all_desks)) - { - items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); - i = 0; - while (i++ < SHRINK_RUNS && _scale_shrink()); - DBG("shrunk %d", i); - } - - if (show_all_desks) - { - /* center and move windows near visible desk - * to make the sliding smoother */ - - min_x = zone->w; - min_y = zone->h; - max_x = 0; - max_y = 0; - - EINA_LIST_FOREACH(items, l, it) - { - if (it->x < min_x) min_x = it->x; - if (it->y < min_y) min_y = it->y; - if (it->x + it->w > max_x) max_x = it->x + it->w; - if (it->y + it->h > max_y) max_y = it->y + it->h; - } - - EINA_LIST_FOREACH(items, l, it) - { - it->x = (it->x - min_x) + use_x + ((use_w - use_x) - (max_x - min_x))/2.0; - it->y = (it->y - min_y) + use_y + ((use_h - use_y) - (max_y - min_y))/2.0; - - if (it->dx > 0) it->bd_x = zone->w + it->bd->x/4; - if (it->dy > 0) it->bd_y = zone->h + it->bd->y/4; - if (it->dx < 0) it->bd_x = -zone->w + (zone->w - it->bd->w) + it->bd->x/4; - if (it->dy < 0) it->bd_y = -zone->h + (zone->h - it->bd->h) + it->bd->y/4; - } - } - - EINA_LIST_FOREACH(items, l, it) - { - it->x += zone->x; - it->y += zone->y; - it->bd_x += zone->x; - it->bd_y += zone->y; - } - - DBG("time: %f\n", ecore_time_get() - start_time); - - it = NULL; - bd = NULL; - - if (init_method == GO_KEY) - { - E_Border *bd2 = NULL; - - EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) - if ((bd != bd2) && (bd->desk == current_desk)) - { - if (!bd2) bd2 = bd; - else break; - } - if (!bd) bd = bd2; - } - else - { - EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) - if (bd->desk == current_desk) break; - } - - if (bd) - { - EINA_LIST_FOREACH(items, l, it) - if (it->bd == bd) break; - } - - if (it) - selected_item = it; - else - selected_item = eina_list_data_get(items); - - EINA_LIST_FOREACH(items, l, it) - { - if (it != selected_item) - edje_object_signal_emit(it->o, "mouse,out", "e"); - - if (scale_conf->fade_windows) - { - if (it->bd->desk != current_desk) - evas_object_color_set(it->o, 0, 0, 0, 0); - } - } - - _scale_in(); - - if (init_method == GO_KEY) - _scale_warp_animator_run(selected_item); - - evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); - evas_event_feed_mouse_move(e, -1000000, -1000000, - ecore_x_current_time_get(), NULL); - - return EINA_TRUE; -} - - -static Eina_Bool -_scale_cb_mouse_move(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Move *ev = event; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - if (!scale_state) - return ECORE_CALLBACK_PASS_ON; - - if (warp_animator) - return ECORE_CALLBACK_PASS_ON; - - if (mouse_x < 0) - { - mouse_x = ev->x; - mouse_y = ev->y; - return ECORE_CALLBACK_PASS_ON; - } - if ((mouse_x == ev->x) || (mouse_y == ev->y)) - return ECORE_CALLBACK_PASS_ON; - - mouse_activated = 1; - - evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, ev->timestamp, NULL); - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_scale_cb_mouse_down(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Button *ev = event; - Evas_Button_Flags flags = EVAS_BUTTON_NONE; - Eina_List *l; - Item *it; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - EINA_LIST_FOREACH(items, l, it) - if (E_INTERSECTS(ev->x, ev->y, 1, 1, it->x, it->y, it->w, it->h)) - break; - - if (!it) - { - _scale_out(1); - return ECORE_CALLBACK_PASS_ON; - } - - if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; - if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; - evas_event_feed_mouse_down((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_scale_cb_mouse_up(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Button *ev = event; - Evas_Button_Flags flags = EVAS_BUTTON_NONE; - - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; - - evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); - - return ECORE_CALLBACK_PASS_ON; -} - -Eina_Bool -scale_run(E_Manager *man, const char *params, int _init_method) -{ - Eina_Bool ret = EINA_FALSE; - - if (!strncmp(params, "go_scale_all", 12)) - { - scale_layout = scale_conf->desks_layout_mode; - show_all_desks = EINA_TRUE; - } - - else - { - scale_layout = scale_conf->layout_mode; - show_all_desks = EINA_FALSE; - } - - init_method = _init_method; - - if (init_method == GO_KEY) - scale_layout = 1; - - if (scale_state) - { - if (show_all_desks) - _scale_switch(params+12); - else - _scale_switch(params+8); - } - else - { - if (input_win) - return ret; - - ret = _scale_run(man); - } - - return ret; -} - - -static void -_scale_handler(void *data, const char *name, const char *info, int val, - E_Object *obj, void *msgdata) -{ - E_Manager *man = (E_Manager *)obj; - E_Manager_Comp_Source *src = (E_Manager_Comp_Source *)msgdata; - Evas *e; - - if (strcmp(name, "comp.manager")) return; - - DBG("handler... '%s' '%s'\n", name, info); - - /* XXX disabled for now. */ - /* return; */ - - e = e_manager_comp_evas_get(man); - if (!strcmp(info, "change.comp")) - { - if (!e) DBG("TTT: No comp manager\n"); - else DBG("TTT: comp canvas = %p\n", e); - } - else if (!strcmp(info, "resize.comp")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "add.src")) - { - DBG("%s: %p | %p\n", info, man, src); - e_manager_comp_src_hidden_set(man, src, EINA_TRUE); - } - else if (!strcmp(info, "del.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "config.src")) - { - - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "visibility.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } -} |
From: Enlightenment S. <no-...@en...> - 2011-03-22 00:29:01
|
Log: e-modules/comp-scale: allow moving windows in scale-windows mode when dragging them off. - added window label in theme Author: jeffdameth Date: 2011-03-21 17:28:54 -0700 (Mon, 21 Mar 2011) New Revision: 57949 Trac: http://trac.enlightenment.org/e/changeset/57949 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-21 23:37:13 UTC (rev 57948) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-03-22 00:28:54 UTC (rev 57949) @@ -127,6 +127,7 @@ name: "e.swallow.win"; type: SWALLOW; clip_to: "clipper"; + /* mouse_events: 0; */ description { state: "default" 0.0; color: 255 255 255 255; @@ -225,23 +226,23 @@ transition: SINUSOIDAL 0.4; target: "clipper"; } - /* program { - * name: "mouse_in2"; - * signal: "mouse,in"; - * source: "e"; - * action: STATE_SET "show" 0.0; - * transition: SINUSOIDAL 0.5; - * target: "text.clipper"; - * } */ - /* program { - * name: "mouse_out2"; - * signal: "mouse,out"; - * source: "e"; - * action: STATE_SET "default" 0.0; - * transition: SINUSOIDAL 0.5; - * target: "text.clipper"; - * } */ program { + name: "mouse_in2"; + signal: "mouse,in"; + source: "e"; + action: STATE_SET "show" 0.0; + transition: SINUSOIDAL 0.5; + target: "text.clipper"; + } + program { + name: "mouse_out2"; + signal: "mouse,out"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.5; + target: "text.clipper"; + } + program { name: "hide"; signal: "hide"; source: "e"; @@ -249,14 +250,14 @@ transition: SINUSOIDAL 0.2; target: "clipper"; } - /* program { - * name: "show"; - * signal: "show"; - * source: "e"; - * action: STATE_SET "default" 0.0; - * transition: SINUSOIDAL 0.2; - * target: "text.clipper"; - * } */ + program { + name: "show"; + signal: "show"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.2; + target: "text.clipper"; + } } } group { Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-21 23:37:13 UTC (rev 57948) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-03-22 00:28:54 UTC (rev 57949) @@ -530,20 +530,24 @@ selected_item = NULL; } - edje_object_signal_emit(it->o, "mouse,in", "e"); - selected_item = it; + if (it != selected_item) + { + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; + } } static void _pager_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info) { - /* Item *it = data; */ + Item *it = data; + if (!mouse_activated) return; - - if (selected_item) + + if (selected_item == it) { - edje_object_signal_emit(selected_item->o, "mouse,out", "e"); + edje_object_signal_emit(it->o, "mouse,out", "e"); selected_item = NULL; } } Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-21 23:37:13 UTC (rev 57948) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_scale.c 2011-03-22 00:28:54 UTC (rev 57949) @@ -20,7 +20,7 @@ Eina_Bool was_hidden; Eina_Bool fade; - + double x; double y; double w; @@ -48,6 +48,8 @@ Item *next; Item *prev; + int mouse_down; + int moved; }; struct _Slot @@ -66,6 +68,7 @@ static void _scale_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _scale_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _scale_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _scale_win_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _scale_win_cb_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); static Item *_scale_win_new(Evas *e, E_Manager *man, E_Manager_Comp_Source *src, E_Desk *desk); @@ -113,6 +116,7 @@ static double warp_start; static Ecore_Animator *warp_animator = NULL; static Evas_Object *zone_clip = NULL; +E_Border *bd_move = NULL; static void _scale_place_windows(double scale) @@ -132,6 +136,14 @@ } } +static void +_scale_warp_to_win(Item *it, double advance) +{ + ecore_x_pointer_warp(it->bd->zone->container->win, + (double)warp_x * (1.0 - advance) + (double)(it->x + it->w/2) * advance, + (double)warp_y * (1.0 - advance) + (double)(it->y + it->h/2) * advance); +} + static Eina_Bool _scale_warp_pointer(void *data) { @@ -141,11 +153,7 @@ { double in = (ecore_time_get() - warp_start) / 0.25; if (in > 1.0) in = 1.0; - - ecore_x_pointer_warp(it->bd->zone->container->win, - (double)warp_x * (1.0 - in) + (double)(it->x + it->w/2) * in, - (double)warp_y * (1.0 - in) + (double)(it->y + it->h/2) * in); - + _scale_warp_to_win(it, in); if (in < 1.0) return ECORE_CALLBACK_RENEW; } @@ -192,7 +200,7 @@ double bx = it->bd_x - it->x; double by = it->bd_y - it->y; - a = (1.0 - sqrt(ax*ax + ay*ay) / sqrt(bx*bx + by*by)) * 255.0; + a = (1.0 - (ax*ax + ay*ay) / (bx*bx + by*by)) * 255.0; } evas_object_color_set(it->o, a, a, a, a); @@ -200,27 +208,22 @@ } if (warp_pointer && selected_item) - { - it = selected_item; - ecore_x_pointer_warp(it->bd->zone->container->win, - (double)warp_x * (1.0 - in) + (double)(it->bd->x + it->bd->w/2) * in, - (double)warp_y * (1.0 - in) + (double)(it->bd->y + it->bd->h/2) * in); - } + _scale_warp_to_win(selected_item, in); a = 255.0 * in; - + EINA_LIST_FOREACH(items_fade, l, it) { if ((it->bd->desk == current_desk) || (it->bd->sticky)) - evas_object_color_set(it->o, a, a, a, a); + evas_object_color_set(it->o, a, a, a, a); } - + if (scale_conf->fade_popups) { EINA_LIST_FOREACH(popups, l, it) evas_object_color_set(it->o_win, a, a, a, a); } - + if (scale_conf->fade_desktop && background) { a = 255.0 * (0.5 + in/2.0); @@ -324,7 +327,8 @@ evas_object_raise(it->o); e_border_raise(it->bd); - if ((init_method == GO_KEY) && (e_config->focus_policy != E_FOCUS_CLICK)) + if ((!it->moved) &&(init_method == GO_KEY) && + (e_config->focus_policy != E_FOCUS_CLICK)) { warp_pointer = 1; ecore_x_pointer_xy_get(it->bd->zone->container->win, &warp_x, &warp_y); @@ -349,10 +353,6 @@ Item *it; E_Desk *desk; - e_grabinput_release(input_win, input_win); - ecore_x_window_free(input_win); - input_win = 0; - desk = e_desk_current_get(zone); if (selected_item && selected_item->bd->desk != desk) @@ -374,8 +374,12 @@ } EINA_LIST_FREE(items, it) - _scale_win_del(it); + { + if (it->moved) bd_move = it->bd; + _scale_win_del(it); + } + EINA_LIST_FREE(items_fade, it) _scale_win_del(it); @@ -389,14 +393,23 @@ Eina_List *l; E_Manager_Comp_Source *src; E_Manager *man = zone->container->manager; - + EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) e_manager_comp_src_hidden_set(man, src, EINA_FALSE); } - - EINA_LIST_FREE(handlers, handler) - ecore_event_handler_del(handler); + e_manager_comp_evas_update(e_manager_current_get()); + + if (!bd_move) + { + EINA_LIST_FREE(handlers, handler) + ecore_event_handler_del(handler); + + e_grabinput_release(input_win, input_win); + ecore_x_window_free(input_win); + input_win = 0; + } + evas_object_del(zone_clip); zone_clip = NULL; e_msg_handler_del(msg_handler); @@ -407,9 +420,7 @@ background = NULL; send_to_desk = EINA_FALSE; show_all_desks = EINA_FALSE; - eina_stringshare_replace(&match_class, NULL); - - e_manager_comp_evas_update(e_manager_current_get()); + eina_stringshare_replace(&match_class, NULL); } static void @@ -447,7 +458,11 @@ return; if (it == selected_item) - edje_object_signal_emit(it->o, "mouse,out", "e"); + { + edje_object_signal_emit(it->o, "mouse,out", "e"); + it->mouse_down = EINA_FALSE; + selected_item = NULL; + } } static void @@ -459,6 +474,25 @@ if (!scale_state) return; + it->mx = ev->canvas.x; + it->my = ev->canvas.y; + it->mouse_down = EINA_TRUE; +} + +static void +_scale_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Up *ev = event_info; + Item *it = data; + + if (!scale_state) + return; + + if (!it->mouse_down) + return; + + it->mouse_down = EINA_FALSE; + if (it->bd->desk == e_desk_current_get(it->bd->zone)) { selected_item = it; @@ -477,9 +511,41 @@ } static void -_scale_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +_scale_win_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info) { - /* Item *it = data; */ + Evas_Event_Mouse_Move *ev = event_info; + Item *it = data; + int x, y; + E_Desk *desk, *desk2; + + if (!it || !it->mouse_down) + return; + + if (it->bd->maximized || it->bd->fullscreen || it->bd->lock_user_location) + return; + + if (it->moved) + { + it->bd_x += (ev->cur.canvas.x - ev->prev.canvas.x); + it->bd_y += (ev->cur.canvas.y - ev->prev.canvas.y); + e_border_move(it->bd, it->bd_x, it->bd_y); + + mouse_x = ev->cur.canvas.x; + mouse_y = ev->cur.canvas.y; + } + else + { + if (abs(ev->cur.canvas.x - it->mx) + + abs(ev->cur.canvas.y - it->my) < 15) + return; + + it->moved = EINA_TRUE; + + _scale_out(2); + + it->bd_x = ev->cur.canvas.x - (ev->cur.canvas.x - it->bd_x); + it->bd_y = ev->cur.canvas.y - (ev->cur.canvas.y - it->bd_y); + } } static void @@ -534,7 +600,7 @@ e_border_hide(it->bd, 1); evas_object_hide(it->cw->shobj); } - + evas_object_del(it->o_win); evas_object_del(it->o); @@ -553,7 +619,7 @@ { Item *it; E_Comp_Win *cw = (void*)src; - + if (!e_manager_comp_src_image_get(man, src)) return NULL; @@ -576,7 +642,7 @@ { if ((cw->pop) && (cw->pop->zone != zone)) return NULL; - + it = E_NEW(Item, 1); it->man = man; it->o_win = e_manager_comp_src_shadow_get(man, src); @@ -601,7 +667,7 @@ if (cw->bd->iconic) return NULL; } - + it = E_NEW(Item, 1); it->scale = 1.0; @@ -642,17 +708,17 @@ it->cur_h = it->h; if (!it->bd->visible) - { + { if (it->bd->iconic) it->was_hidden = EINA_TRUE; e_border_show(it->bd); } - + /* if (it->bd->shaded) * e_border_unshade(it->bd, ); */ - - edje_object_part_text_set(it->o, "e.text.label", e_border_name_get(it->bd)); + + edje_object_part_text_set(it->o, "e.text.label", e_border_name_get(it->bd)); edje_object_signal_emit(it->o, "show", "e"); if (match_class) @@ -663,13 +729,13 @@ items_fade = eina_list_append(items_fade, it); evas_object_move(it->o, it->bd->x, it->bd->y); evas_object_resize(it->o, it->cw->pw, it->cw->ph); - evas_object_pass_events_set(it->o, 1); + evas_object_pass_events_set(it->o, 1); if (it->bd->desk != desk) evas_object_color_set(it->o, 0, 0, 0, 0); return it; } } - + evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_IN, _scale_win_cb_mouse_in, it); @@ -682,13 +748,11 @@ evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_UP, _scale_win_cb_mouse_up, it); - /* evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_MOVE, - * _scale_win_cb_mouse_move, it); */ + evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_MOVE, + _scale_win_cb_mouse_move, it); - printf("scale %s\n", e_border_name_get(it->bd)); - items = eina_list_append(items, it); - + return it; } @@ -946,12 +1010,12 @@ zone_clip = evas_object_rectangle_add(e); evas_object_move(zone_clip, zone->x, zone->y); evas_object_resize(zone_clip, zone->w, zone->h); - evas_object_show(zone_clip); + evas_object_show(zone_clip); EINA_LIST_FOREACH((Eina_List *)e_manager_comp_src_list(man), l, src) { Item *it = _scale_win_new(e, man, src, current_desk); - if (it) evas_object_clip_set(it->o, zone_clip); + if (it) evas_object_clip_set(it->o, zone_clip); } if (eina_list_count(items) < 1) @@ -1010,7 +1074,7 @@ if ((scale_conf->tight && !show_all_desks) || (scale_conf->desks_tight && show_all_desks)) spacing += 5; - + i = 0; while (i++ < GROW_RUNS && _scale_grow()); DBG("grow %d", i); @@ -1066,7 +1130,7 @@ it->bd_x += zone->x; it->bd_y += zone->y; } - + DBG("time: %f\n", ecore_time_get() - start_time); it = NULL; @@ -1134,9 +1198,20 @@ if (ev->window != input_win) return ECORE_CALLBACK_PASS_ON; - if (!scale_state) - return ECORE_CALLBACK_PASS_ON; + /* if (!scale_state) + * return ECORE_CALLBACK_PASS_ON; */ + if (bd_move) + { + e_border_move(bd_move, + bd_move->x + (ev->x - mouse_x), + bd_move->y + (ev->y - mouse_y)); + mouse_x = ev->x; + mouse_y = ev->y; + + return ECORE_CALLBACK_PASS_ON; + } + if (warp_animator) return ECORE_CALLBACK_PASS_ON; @@ -1193,6 +1268,20 @@ if (ev->window != input_win) return ECORE_CALLBACK_PASS_ON; + if (bd_move) + { + Ecore_Event_Handler *handler; + EINA_LIST_FREE(handlers, handler) + ecore_event_handler_del(handler); + + e_grabinput_release(input_win, input_win); + ecore_x_window_free(input_win); + input_win = 0; + bd_move = NULL; + + return ECORE_CALLBACK_PASS_ON; + } + evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; @@ -1203,7 +1292,7 @@ { Eina_Bool ret = EINA_FALSE; const char *opt = params; - + if (!strncmp(params, "go_scale_all", 12)) { scale_layout = scale_conf->desks_layout_mode; @@ -1214,7 +1303,7 @@ { if (scale_state) return ret; - + scale_layout = 1; /* slotted */ show_all_desks = EINA_TRUE; opt = params+15; @@ -1230,7 +1319,7 @@ { return ret; } - + init_method = _init_method; if (init_method == GO_KEY) @@ -1897,7 +1986,7 @@ { slot->it = NULL; break; - } + } else slot2->it = NULL; } |
From: Enlightenment S. <no-...@en...> - 2011-07-27 21:03:24
|
Log: e-modules/comp-scale: scale desktop background in pager, fix darken desktop option Author: jeffdameth Date: 2011-07-27 14:03:17 -0700 (Wed, 27 Jul 2011) New Revision: 61824 Trac: http://trac.enlightenment.org/e/changeset/61824 Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c Modified: trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-07-27 20:37:48 UTC (rev 61823) +++ trunk/E-MODULES-EXTRA/comp-scale/e-module-scale.edc 2011-07-27 21:03:17 UTC (rev 61824) @@ -409,6 +409,22 @@ } } part { + name: "e.swallow.desk"; + type: SWALLOW; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + } + } + part { name: "bg"; mouse_events: 1; type: RECT; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-07-27 20:37:48 UTC (rev 61823) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-07-27 21:03:17 UTC (rev 61824) @@ -205,7 +205,7 @@ &(cfdata->pager_fade_popups)); e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, D_("Darken desktop"), - &(cfdata->fade_desktop)); + &(cfdata->pager_fade_desktop)); e_widget_framelist_object_append (of, ow); e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 0); Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-07-27 20:37:48 UTC (rev 61823) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_pager.c 2011-07-27 21:03:17 UTC (rev 61824) @@ -82,13 +82,13 @@ int x, y; Eina_List *l = desks; int a = (1.0 - scale) * 255.0; - + for (y = 0; y < zone->desk_y_count; y++) { for (x = 0; x < zone->desk_x_count; x++) { - double x1 = min_x + (x - current_desk->x) * zone->w; - double y1 = min_y + (y - current_desk->y) * zone->h; + double x1 = (x - current_desk->x) * zone->w; + double y1 = (y - current_desk->y) * zone->h; double x2 = min_x + x * desk_w; double y2 = min_y + y * desk_h; double cur_x = (scale * x1) + (1.0 - scale) * x2; @@ -101,7 +101,8 @@ (scale * (zone->w)) + (1.0 - scale) * desk_w - OFFSET, (scale * (zone->h)) + (1.0 - scale) * desk_h - OFFSET); - evas_object_color_set(o, a, a, a, a); + if (scale_conf->pager_fade_desktop) + evas_object_color_set(o, a, a, a, a); l = eina_list_next(l); } @@ -131,7 +132,9 @@ { double in; Eina_Bool finish = EINA_FALSE; - + Eina_List *l; + Item *it; + in = (ecore_loop_time_get() - start_time) / scale_conf->pager_duration; if (in >= 1.0) @@ -155,24 +158,12 @@ if (scale_conf->pager_fade_windows) { - Eina_List *l; - Item *it; - EINA_LIST_FOREACH(items, l, it) { double a = 255.0; - if ((it->desk != current_desk) && - (it->desk != previous_desk)) - { - /* double ax = it->cur_x - it->x; - * double ay = it->cur_y - it->y; - * double bx = it->bd_x - it->x; - * double by = it->bd_y - it->y; - * - * a = (1.0 - sqrt(ax*ax + ay*ay) / - * sqrt(bx*bx + by*by)) * 255.0; */ - } + if ((it->desk != current_desk) && (it->desk != previous_desk)) + a = 255.0 * (1.0 - in); evas_object_color_set(it->o, a, a, a, a); } @@ -180,9 +171,6 @@ if (scale_conf->pager_fade_popups) { - Eina_List *l; - Item *it; - double a = 255.0 * in; EINA_LIST_FOREACH(popups, l, it) @@ -191,9 +179,9 @@ if (scale_conf->pager_fade_desktop && background) { - double a = 255.0 * (0.5 + in/2.0); - - evas_object_color_set(background->o_win, a, a, a, 255); + double a = (1.0 - in) * 155.0; + + evas_object_color_set(background->o, 0, 0, 0, a); } e_manager_comp_evas_update(e_manager_current_get()); @@ -254,7 +242,7 @@ Ecore_Event_Handler *handler; Item *it; E_Desk *desk; - Evas_Object *o; + Evas_Object *o, *oo; Eina_List *l; e_grabinput_release(input_win, input_win); @@ -291,13 +279,21 @@ _pager_win_del(it); EINA_LIST_FREE(desks, o) - evas_object_del(o); - + { + oo = edje_object_part_swallow_get(o, "e.swallow.desk"); + if (oo) evas_object_del(oo); + + evas_object_del(o); + } + EINA_LIST_FREE(popups, it) _pager_win_del(it); if (background) - _pager_win_del(background); + { + evas_object_del(background->o); + _pager_win_del(background); + } { Eina_List *l; @@ -1067,18 +1063,20 @@ if (background) { - Evas_Object *o; + Evas_Object *o, *oo; int x, y; - + for (y = 0; y < zone->desk_y_count; y++) { for (x = 0; x < zone->desk_x_count; x++) { o = edje_object_add(e); + if (!e_theme_edje_object_set(o, "base/theme/modules/scale", - "modules/scale/desk")) + "modules/scale/desk")) edje_object_file_set(o, scale_conf->theme_path, - "modules/scale/desk"); + "modules/scale/desk"); + evas_object_stack_above(o, background->o_win); evas_object_show(o); @@ -1087,8 +1085,30 @@ if ((x != zone->desk_x_current) || (y != zone->desk_y_current)) edje_object_signal_emit(o, "unfocused", "e"); evas_object_clip_set(o, zone_clip); + + if (edje_object_part_exists(o, "e.swallow.desk")) + { + oo = evas_object_image_filled_add(e); + evas_object_image_source_set(oo, background->o_win); + /* evas_object_image_source_set(oo, zone->bg_object); */ + evas_object_show(oo); + edje_object_part_swallow(o, "e.swallow.desk", oo); + } } } + + o = evas_object_rectangle_add(e); + evas_object_move(o, zone->x, zone->y); + evas_object_resize(o, zone->w, zone->h); + evas_object_show(o); + evas_object_stack_above(o, background->o_win); + background->o = o; + + if (scale_conf->pager_fade_desktop) + evas_object_color_set(o, 0, 0, 0, 0); + else + evas_object_color_set(o, 0, 0, 0, 255); + _pager_place_desks(1.0); } |