summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2013-12-09 08:20:28 -0500
committerMike Blumenkrantz <zmike@samsung.com>2013-12-09 08:22:19 -0500
commit27d607d8639a303226673cd14de886e70b59b397 (patch)
treef4e0c32ab4e4a1d50bb1eacf4bf9ed8341052dba
parent93ddaf2846617c3429533f80d15223e9c1d50942 (diff)
remove physics modulev0.18.0-rc1
realistically I shouldn't have merged this into the release last year. failing that, I probably should have removed it after the release. even if I didn't remove it, I should have at least updated/tested it. I did none of these things, and neither did anyone else, and thus we have an unmaintained module in core. NOT ON MY WATCH
-rw-r--r--configure.ac33
-rw-r--r--po/POTFILES.in2
-rw-r--r--src/modules/Makefile.am4
-rw-r--r--src/modules/Makefile_physics.am25
-rw-r--r--src/modules/physics/TODO22
-rw-r--r--src/modules/physics/e-module-physics.edjbin11935 -> 0 bytes
-rw-r--r--src/modules/physics/e_mod_config.c183
-rw-r--r--src/modules/physics/e_mod_main.c127
-rw-r--r--src/modules/physics/e_mod_main.h33
-rw-r--r--src/modules/physics/e_mod_physics.c911
-rw-r--r--src/modules/physics/e_mod_physics.h11
-rw-r--r--src/modules/physics/e_mod_physics_cfdata.c48
-rw-r--r--src/modules/physics/e_mod_physics_cfdata.h32
-rw-r--r--src/modules/physics/module.desktop.in23
14 files changed, 0 insertions, 1454 deletions
diff --git a/configure.ac b/configure.ac
index 43e2503..171e6e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,37 +718,6 @@ define([CHECK_MODULE_NOTIFICATION],
718 fi 718 fi
719]) 719])
720 720
721have_ephysics=no
722AM_CONDITIONAL([HAVE_EPHYSICS], [false])
723AC_ARG_ENABLE([ephysics],
724 AC_HELP_STRING([--disable-ephysics], [disable Ephysics support @<:@default=detect@:>@]),
725 [e_cv_want_ephysics=$enableval],
726 AC_CACHE_VAL([e_cv_want_ephysics], [e_cv_want_ephysics=yes])
727)
728if test "x$e_cv_want_ephysics" != "xno" ; then
729 AC_E_CHECK_PKG(EPHYSICS, [ ephysics ],
730 [
731 AC_DEFINE_UNQUOTED([HAVE_EPHYSICS], [1], [enable ephysics])
732 ],
733 [
734 AC_MSG_NOTICE([ephysics disabled])
735 e_cv_want_ephysics=no
736 ])
737else
738 AC_MSG_NOTICE([ephysics disabled])
739 e_cv_want_ephysics=no
740fi
741AC_SUBST([EPHYSICS_CFLAGS])
742AC_SUBST([EPHYSICS_LIBS])
743
744AM_CONDITIONAL(HAVE_PHYSICS, false)
745define([CHECK_MODULE_PHYSICS],
746[
747 if test "x$e_cv_want_ephysics" = "xno" ; then
748 PHYSICS=false
749 fi
750])
751
752AM_CONDITIONAL(HAVE_ALSA, false) 721AM_CONDITIONAL(HAVE_ALSA, false)
753define([CHECK_MODULE_MIXER], 722define([CHECK_MODULE_MIXER],
754[ 723[
@@ -901,7 +870,6 @@ AC_E_OPTIONAL_MODULE([syscon], true)
901AC_E_OPTIONAL_MODULE([everything], true) 870AC_E_OPTIONAL_MODULE([everything], true)
902AC_E_OPTIONAL_MODULE([systray], true) 871AC_E_OPTIONAL_MODULE([systray], true)
903AC_E_OPTIONAL_MODULE([appmenu], true) 872AC_E_OPTIONAL_MODULE([appmenu], true)
904AC_E_OPTIONAL_MODULE([physics], true, [CHECK_MODULE_PHYSICS])
905AC_E_OPTIONAL_MODULE([quickaccess], true) 873AC_E_OPTIONAL_MODULE([quickaccess], true)
906AC_E_OPTIONAL_MODULE([teamwork], true) 874AC_E_OPTIONAL_MODULE([teamwork], true)
907AC_E_OPTIONAL_MODULE([shot], true) 875AC_E_OPTIONAL_MODULE([shot], true)
@@ -1025,7 +993,6 @@ src/modules/everything/everything.pc
1025src/modules/systray/module.desktop 993src/modules/systray/module.desktop
1026src/modules/appmenu/module.desktop 994src/modules/appmenu/module.desktop
1027src/modules/conf_comp/module.desktop 995src/modules/conf_comp/module.desktop
1028src/modules/physics/module.desktop
1029src/modules/quickaccess/module.desktop 996src/modules/quickaccess/module.desktop
1030src/modules/teamwork/module.desktop 997src/modules/teamwork/module.desktop
1031src/modules/shot/module.desktop 998src/modules/shot/module.desktop
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7e53461..ea89127 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -259,8 +259,6 @@ src/modules/notification/e_mod_config.c
259src/modules/notification/e_mod_main.c 259src/modules/notification/e_mod_main.c
260src/modules/pager/e_mod_config.c 260src/modules/pager/e_mod_config.c
261src/modules/pager/e_mod_main.c 261src/modules/pager/e_mod_main.c
262src/modules/physics/e_mod_config.c
263src/modules/physics/e_mod_main.c
264src/modules/quickaccess/e_mod_config.c 262src/modules/quickaccess/e_mod_config.c
265src/modules/quickaccess/e_mod_main.c 263src/modules/quickaccess/e_mod_main.c
266src/modules/quickaccess/e_mod_quickaccess.c 264src/modules/quickaccess/e_mod_quickaccess.c
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index af7a270..464144e 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -195,10 +195,6 @@ if USE_MODULE_APPMENU
195include Makefile_appmenu.am 195include Makefile_appmenu.am
196endif 196endif
197 197
198if USE_MODULE_PHYSICS
199include Makefile_physics.am
200endif
201
202if USE_MODULE_QUICKACCESS 198if USE_MODULE_QUICKACCESS
203include Makefile_quickaccess.am 199include Makefile_quickaccess.am
204endif 200endif
diff --git a/src/modules/Makefile_physics.am b/src/modules/Makefile_physics.am
deleted file mode 100644
index fcf1895..0000000
--- a/src/modules/Makefile_physics.am
+++ /dev/null
@@ -1,25 +0,0 @@
1physicsdir = $(MDIR)/physics
2physics_DATA = physics/e-module-physics.edj \
3 physics/module.desktop
4
5EXTRA_DIST += $(physics_DATA)
6
7physics_module_la_CFLAGS = $(AM_CFLAGS)
8physics_module_la_CFLAGS += @EPHYSICS_CFLAGS@
9
10physicspkgdir = $(MDIR)/physics/$(MODULE_ARCH)
11physicspkg_LTLIBRARIES = physics/module.la
12
13physics_module_la_SOURCES = physics/e_mod_main.c \
14 physics/e_mod_main.h \
15 physics/e_mod_config.c \
16 physics/e_mod_physics_cfdata.c \
17 physics/e_mod_physics_cfdata.h \
18 physics/e_mod_physics.c \
19 physics/e_mod_physics.h
20
21physics_module_la_LIBADD = @EPHYSICS_LIBS@
22
23.PHONY: physics install-physics
24physics: $(physicspkg_LTLIBRARIES) $(physics_DATA)
25install-physics: install-physicsDATA install-physicspkgLTLIBRARIES
diff --git a/src/modules/physics/TODO b/src/modules/physics/TODO
deleted file mode 100644
index f979f86..0000000
--- a/src/modules/physics/TODO
+++ /dev/null
@@ -1,22 +0,0 @@
1urgent:
2---------
3* make mouse drag intertia more accurate and responsive
4* fix boundaries to prevent windows from getting stuck
5
6
7needs more ephysics support:
8--------
9* window stacking
10
11
12features:
13--------
14* horizontal gravity (EASY)
15* configurable restitution/friction (bounciness+elasticity of collision) (EASY)
16* gravity based on accelerometer?
17* collision effects
18* window client collision notification for app collision effects
19* mass based on window client cpu load
20* explosion effect for new windows to knock nearby windows out of the way
21* window rotation using physics (HARD)
22???
diff --git a/src/modules/physics/e-module-physics.edj b/src/modules/physics/e-module-physics.edj
deleted file mode 100644
index 1401ab4..0000000
--- a/src/modules/physics/e-module-physics.edj
+++ /dev/null
Binary files differ
diff --git a/src/modules/physics/e_mod_config.c b/src/modules/physics/e_mod_config.c
deleted file mode 100644
index ace03a9..0000000
--- a/src/modules/physics/e_mod_config.c
+++ /dev/null
@@ -1,183 +0,0 @@
1#include "e.h"
2#include "e_mod_main.h"
3#include "e_mod_physics.h"
4
5struct _E_Config_Dialog_Data
6{
7 double delay; /* delay before applying physics */
8 double max_mass; /* maximum mass for a window */
9 double gravity; /* gravity for a window */
10 Eina_Bool ignore_fullscreen;
11 Eina_Bool ignore_maximized;
12 Eina_Bool ignore_shelves;
13 struct
14 {
15 Eina_Bool disable_rotate;
16 Eina_Bool disable_move;
17 } shelf;
18};
19
20/* Protos */
21static int _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
22static void *_create_data(E_Config_Dialog *cfd);
23static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
24static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
25static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
26
27E_Config_Dialog *
28e_int_config_physics_module(E_Container *con,
29 const char *params __UNUSED__)
30{
31 E_Config_Dialog *cfd;
32 E_Config_Dialog_View *v;
33 char buf[4096];
34 Mod *mod = _physics_mod;
35
36 if (mod->config_dialog) return NULL;
37 snprintf(buf, sizeof(buf), "%s/e-module-physics.edj", e_module_dir_get(mod->module));
38 v = E_NEW(E_Config_Dialog_View, 1);
39
40 v->create_cfdata = _create_data;
41 v->free_cfdata = _free_data;
42 v->basic.apply_cfdata = _basic_apply_data;
43 v->basic.create_widgets = _basic_create_widgets;
44 v->basic.check_changed = _basic_check_changed;
45
46 cfd = e_config_dialog_new(con, _("Physics Settings"),
47 "E", "appearance/physics", buf, 32, v, mod);
48 mod->config_dialog = cfd;
49 return cfd;
50}
51
52static void *
53_create_data(E_Config_Dialog *cfd __UNUSED__)
54{
55 E_Config_Dialog_Data *cfdata;
56
57 cfdata = E_NEW(E_Config_Dialog_Data, 1);
58
59 cfdata->delay = _physics_mod->conf->delay;
60 cfdata->max_mass = _physics_mod->conf->max_mass;
61 cfdata->gravity = _physics_mod->conf->gravity;
62
63 return cfdata;
64}
65
66static void
67_free_data(E_Config_Dialog *cfd __UNUSED__,
68 E_Config_Dialog_Data *cfdata)
69{
70 _physics_mod->config_dialog = NULL;
71 free(cfdata);
72}
73
74static int
75_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
76{
77#define CHECK(X) \
78 if (cfdata->X != _physics_mod->conf->X) return 1
79
80 CHECK(max_mass);
81 CHECK(gravity);
82 CHECK(ignore_fullscreen);
83 CHECK(ignore_maximized);
84 CHECK(ignore_shelves);
85 CHECK(shelf.disable_move);
86 CHECK(shelf.disable_rotate);
87 if ((unsigned int)cfdata->delay != _physics_mod->conf->delay) return 1;
88
89#undef CHECK
90 return 0;
91}
92
93static Evas_Object *
94_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__,
95 Evas *evas,
96 E_Config_Dialog_Data *cfdata)
97{
98 Evas_Object *ob, *ol, *otb, *tab;
99
100 tab = e_widget_table_add(evas, 0);
101 evas_object_name_set(tab, "dia_table");
102
103 otb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
104
105 ///////////////////////////////////////////
106
107 ol = e_widget_list_add(evas, 0, 0);
108 ob = e_widget_label_add(evas, _("Physics delay after drag"));
109 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
110 ob = e_widget_slider_add(evas, 1, 0, _("%2.0f Frames"), 5, 20, 1, 0, &(cfdata->delay), NULL, 150);
111 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
112 ob = e_widget_label_add(evas, _("Maximum window mass"));
113 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
114 ob = e_widget_slider_add(evas, 1, 0, _("%2.1f kg"), 1, 6, 1, 0, &(cfdata->max_mass), NULL, 150);
115 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
116 ob = e_widget_label_add(evas, _("Desktop gravity"));
117 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
118 ob = e_widget_slider_add(evas, 1, 0, _("%1.1f m/s^2"), -5, 5, 1, 0, &(cfdata->gravity), NULL, 150);
119 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
120
121 e_widget_toolbook_page_append(otb, NULL, _("General"), ol, 1, 1, 1, 1, 0.5, 0.5);
122
123 ///////////////////////////////////////////
124
125 ol = e_widget_list_add(evas, 0, 0);
126
127 ob = e_widget_check_add(evas, _("Disable Movement"), (int*)&(cfdata->shelf.disable_move));
128 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
129
130 ob = e_widget_check_add(evas, _("Disable Rotation"), (int*)&(cfdata->shelf.disable_rotate));
131 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
132
133 e_widget_toolbook_page_append(otb, NULL, _("Shelves"), ol, 1, 1, 1, 1, 0.5, 0.5);
134
135 ///////////////////////////////////////////
136
137 ol = e_widget_list_add(evas, 0, 0);
138 ob = e_widget_check_add(evas, _("Ignore Fullscreen"), (int*)&(cfdata->ignore_fullscreen));
139 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
140
141 ob = e_widget_check_add(evas, _("Ignore Maximized"), (int*)&(cfdata->ignore_maximized));
142 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
143
144 ob = e_widget_check_add(evas, _("Ignore Shelves"), (int*)&(cfdata->ignore_shelves));
145 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
146
147 e_widget_toolbook_page_append(otb, NULL, _("Ignore"), ol, 1, 1, 1, 1, 0.5, 0.5);
148
149 e_widget_toolbook_page_show(otb, 0);
150
151
152 e_widget_table_object_append(tab, otb, 0, 0, 1, 1, 1, 1, 1, 1);
153 return tab;
154}
155
156
157static int
158_basic_apply_data(E_Config_Dialog *cfd __UNUSED__,
159 E_Config_Dialog_Data *cfdata)
160{
161 if ((cfdata->delay != _physics_mod->conf->delay) ||
162 (cfdata->max_mass != _physics_mod->conf->max_mass) ||
163 (cfdata->ignore_fullscreen != _physics_mod->conf->ignore_fullscreen) ||
164 (cfdata->ignore_maximized != _physics_mod->conf->ignore_maximized) ||
165 (cfdata->gravity != _physics_mod->conf->gravity)
166 )
167 {
168#define SET(X) _physics_mod->conf->X = cfdata->X
169 _physics_mod->conf->delay = (unsigned int)cfdata->delay;
170 SET(max_mass);
171 SET(ignore_fullscreen);
172 SET(ignore_maximized);
173 SET(ignore_shelves);
174 SET(gravity);
175 SET(shelf.disable_move);
176 SET(shelf.disable_rotate);
177 e_mod_physics_shutdown();
178 e_mod_physics_init();
179 }
180 e_config_save_queue();
181 return 1;
182}
183
diff --git a/src/modules/physics/e_mod_main.c b/src/modules/physics/e_mod_main.c
deleted file mode 100644
index a7ae7b9..0000000
--- a/src/modules/physics/e_mod_main.c
+++ /dev/null
@@ -1,127 +0,0 @@
1#include "e.h"
2#include "e_mod_main.h"
3#include "e_mod_physics.h"
4#include <EPhysics.h>
5
6/* module private routines */
7Mod *_physics_mod = NULL;
8
9/* public module routines. all modules must have these */
10EAPI E_Module_Api e_modapi =
11{
12 E_MODULE_API_VERSION,
13 "Physics"
14};
15
16EAPI void *
17e_modapi_init(E_Module *m)
18{
19 Mod *mod;
20 char buf[4096];
21
22 {
23 Eina_List *l;
24 E_Module *m2;
25 EINA_LIST_FOREACH(e_module_list(), l, m2)
26 {
27 if (m2->enabled && (!strcmp(m2->name, "tiling")))
28 {
29 e_util_dialog_internal(_("Physics"),
30 _("Cowardly refusing to battle<br>"
31 "with the Tiling module for control<br>"
32 "of your windows. There can be only one!"));
33 return NULL;
34 }
35 }
36 }
37
38 if (!ephysics_init()) return NULL;
39 mod = calloc(1, sizeof(Mod));
40 m->data = mod;
41
42 mod->module = m;
43
44 snprintf(buf, sizeof(buf), "%s/e-module-physics.edj", e_module_dir_get(m));
45 e_configure_registry_category_add("appearance", 10, _("Look"), NULL,
46 "preferences-look");
47 e_configure_registry_item_add("appearance/physics", 120, _("Physics"), NULL,
48 buf, e_int_config_physics_module);
49 mod->conf_edd = e_mod_physics_cfdata_edd_init();
50
51 mod->conf = e_config_domain_load("module.physics", mod->conf_edd);
52 if (mod->conf)
53 {
54 if (!e_util_module_config_check(_("Physics"), mod->conf->config_version, MOD_CONFIG_FILE_VERSION))
55 {
56 e_mod_cfdata_config_free(mod->conf);
57 mod->conf = NULL;
58 }
59 }
60 if (!mod->conf)
61 _e_mod_config_new(m);
62 mod->conf->config_version = MOD_CONFIG_FILE_VERSION;
63 _physics_mod = mod;
64
65 if (!e_mod_physics_init())
66 {
67 e_util_dialog_internal(_("Physics Error"), _("The physics module could not be started"));
68 e_modapi_shutdown(mod->module);
69 return NULL;
70 }
71
72 e_module_delayed_set(m, 0);
73 e_module_priority_set(m, -1000);
74 return mod;
75}
76
77void
78_e_mod_config_new(E_Module *m)
79{
80 Mod *mod = m->data;
81
82 mod->conf = e_mod_physics_cfdata_config_new();
83}
84
85void
86_e_mod_config_free(E_Module *m)
87{
88 Mod *mod = m->data;
89
90 e_mod_cfdata_config_free(mod->conf);
91 mod->conf = NULL;
92}
93
94EAPI int
95e_modapi_shutdown(E_Module *m)
96{
97 Mod *mod = m->data;
98
99 e_mod_physics_shutdown();
100
101 e_configure_registry_item_del("appearance/physics");
102 e_configure_registry_category_del("appearance");
103
104 if (mod->config_dialog)
105 {
106 e_object_del(E_OBJECT(mod->config_dialog));
107 mod->config_dialog = NULL;
108 }
109 _e_mod_config_free(m);
110
111 E_CONFIG_DD_FREE(mod->conf_edd);
112 free(mod);
113
114 if (mod == _physics_mod) _physics_mod = NULL;
115
116 ephysics_shutdown();
117 return 1;
118}
119
120EAPI int
121e_modapi_save(E_Module *m)
122{
123 Mod *mod = m->data;
124 e_config_domain_save("module.physics", mod->conf_edd, mod->conf);
125 return 1;
126}
127
diff --git a/src/modules/physics/e_mod_main.h b/src/modules/physics/e_mod_main.h
deleted file mode 100644
index e2aaa07..0000000
--- a/src/modules/physics/e_mod_main.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef E_MOD_MAIN_H
2#define E_MOD_MAIN_H
3
4#include "e_mod_physics_cfdata.h"
5
6typedef struct _Mod Mod;
7
8struct _Mod
9{
10 E_Module *module;
11
12 E_Config_DD *conf_edd;
13 E_Config_DD *conf_match_edd;
14 Config *conf;
15
16 E_Config_Dialog *config_dialog;
17};
18
19extern Mod *_physics_mod;
20
21EAPI extern E_Module_Api e_modapi;
22
23EAPI void *e_modapi_init(E_Module *m);
24EAPI int e_modapi_shutdown(E_Module *m);
25EAPI int e_modapi_save(E_Module *m);
26EAPI int e_modapi_info(E_Module *m);
27
28void _e_mod_config_new(E_Module *m);
29void _e_mod_config_free(E_Module *m);
30
31E_Config_Dialog *e_int_config_physics_module(E_Container *con, const char *params __UNUSED__);
32
33#endif
diff --git a/src/modules/physics/e_mod_physics.c b/src/modules/physics/e_mod_physics.c
deleted file mode 100644
index a33592c..0000000
--- a/src/modules/physics/e_mod_physics.c
+++ /dev/null
@@ -1,911 +0,0 @@
1#include "e.h"
2#include "e_mod_main.h"
3#include "e_mod_physics.h"
4#include <EPhysics.h>
5
6typedef struct _E_Physics E_Physics;
7typedef struct _E_Physics_Win E_Physics_Win;
8typedef struct _E_Physics_Shelf E_Physics_Shelf;
9
10struct _E_Physics
11{
12 EPhysics_World *world;
13 Ecore_X_Window win;
14 E_Manager *man;
15 Eina_Inlist *wins;
16 Eina_Inlist *shelves;
17};
18
19struct _E_Physics_Shelf
20{
21 EINA_INLIST;
22
23 E_Physics *p;
24 E_Shelf *es;
25 EPhysics_Body *body;
26};
27
28struct _E_Physics_Win
29{
30 EINA_INLIST;
31
32 E_Physics *p; // parent physics
33 Ecore_X_Window win; // raw window - for menus etc.
34 E_Border *bd; // if its a border - later
35 E_Popup *pop; // if its a popup - later
36 E_Menu *menu; // if it is a menu - later
37 EPhysics_Body *body; // physics body
38 int x, y, w, h; // geometry
39 int ix, iy; // impulse geometry (next move coord */
40 struct
41 {
42 int x, y, w, h; // hidden geometry (used when its unmapped and re-instated on map)
43 } hidden;
44 int border; // border width
45
46 E_Border_Hook *begin; // begin move
47 E_Border_Hook *end; // end move
48 E_Maximize maximize;
49
50 unsigned int stopped; /* number of frames window has been stopped for */
51 unsigned int started; /* number of frames window has been moving for */
52 double impulse_x, impulse_y; /* x,y for impulse vector */
53
54 Eina_Bool visible : 1; // is visible
55 Eina_Bool inhash : 1; // is in the windows hash
56 Eina_Bool show_ready : 1; // is this window ready for its first show
57 Eina_Bool moving : 1;
58 Eina_Bool impulse : 1;
59};
60
61static Eina_List *handlers = NULL;
62static Eina_List *physicists = NULL;
63static Eina_Hash *borders = NULL;
64
65//////////////////////////////////////////////////////////////////////////
66#undef DBG
67#if 0
68#define DBG(f, x ...) printf(f, ##x)
69#else
70#define DBG(f, x ...)
71#endif
72
73static Eina_Bool _e_mod_physics_bd_fullscreen(void *data __UNUSED__, int type, void *event);
74static void _e_mod_physics_bd_move_intercept_cb(E_Border *bd, int x, int y);
75static void _e_mod_physics_win_update_cb(E_Physics_Win *pw, EPhysics_Body *body, void *event_info __UNUSED__);
76static void _e_mod_physics_win_del(E_Physics_Win *pw);
77static void _e_mod_physics_win_show(E_Physics_Win *pw);
78static void _e_mod_physics_win_hide(E_Physics_Win *pw);
79static void _e_mod_physics_win_configure(E_Physics_Win *pw,
80 int x,
81 int y,
82 int w,
83 int h,
84 int border);
85static void _e_mod_physics_shelf_new(E_Physics *p, E_Shelf *es);
86
87static void
88_e_mod_physics_move_end(void *p_w, void *b_d)
89{
90 E_Physics_Win *pw = p_w;
91 /* wrong border */
92 if (b_d != pw->bd) return;
93 DBG("PHYS: DRAG END %d\n", pw->win);
94 pw->impulse = pw->moving = EINA_FALSE;
95}
96
97static void
98_e_mod_physics_move_begin(void *p_w, void *b_d)
99{
100 E_Physics_Win *pw = p_w;
101 /* wrong border */
102 if (b_d != pw->bd) return;
103 DBG("PHYS: DRAG BEGIN %d\n", pw->win);
104 pw->moving = EINA_TRUE;
105 pw->started = 0;
106 /* hacks! */
107 if ((!pw->impulse_x) && (!pw->impulse_y)) return;
108 _e_mod_physics_win_hide(pw);
109 _e_mod_physics_win_show(pw);
110 pw->show_ready = 0;
111 _e_mod_physics_win_configure(pw, pw->bd->x, pw->bd->y, pw->bd->w, pw->bd->h, pw->border);
112 pw->impulse_x = pw->impulse_y = 0;
113}
114
115static E_Physics *
116_e_mod_physics_find(Ecore_X_Window root)
117{
118 Eina_List *l;
119 E_Physics *p;
120
121 // fixme: use hash if physicists list > 4
122 EINA_LIST_FOREACH (physicists, l, p)
123 {
124 if (p->man->root == root) return p;
125 }
126 return NULL;
127}
128
129static E_Physics_Win *
130_e_mod_physics_win_find(Ecore_X_Window win)
131{
132 return eina_hash_find(borders, e_util_winid_str_get(win));
133}
134
135static void
136_e_mod_physics_win_show(E_Physics_Win *pw)
137{
138 if (pw->visible) return;
139 DBG("PHYS: SHOW %d\n", pw->win);
140 pw->visible = 1;
141 pw->body = ephysics_body_box_add(pw->p->world);
142 ephysics_body_friction_set(pw->body, 1.0);
143 ephysics_body_angular_movement_enable_set(pw->body, EINA_FALSE, EINA_FALSE,
144 EINA_FALSE);
145 ephysics_body_event_callback_add(pw->body, EPHYSICS_CALLBACK_BODY_UPDATE, (EPhysics_Body_Event_Cb)_e_mod_physics_win_update_cb, pw);
146 pw->begin = e_border_hook_add(E_BORDER_HOOK_MOVE_BEGIN, _e_mod_physics_move_begin, pw);
147 pw->end = e_border_hook_add(E_BORDER_HOOK_MOVE_END, _e_mod_physics_move_end, pw);
148 e_border_move_intercept_cb_set(pw->bd, _e_mod_physics_bd_move_intercept_cb);
149}
150
151static void
152_e_mod_physics_bd_move_intercept_cb(E_Border *bd, int x, int y)
153{
154 E_Physics_Win *pw;
155
156 pw = _e_mod_physics_win_find(bd->client.win);
157 if ((bd->x == x) && (bd->y == y))
158 {
159 DBG("PHYS: STOPPED %d\n", pw->win);
160 if (pw->moving) pw->started = 0;
161 pw->show_ready = 0;
162 _e_mod_physics_win_configure(pw, x, y, pw->bd->w, pw->bd->h, pw->border);
163 return;
164 }
165 if (!pw) return;
166 DBG("PHYS: MOVE %d - (%d,%d) ->(WANT) (%d,%d)\n", pw->win, bd->x, bd->y, x, y);
167 if ((!pw->body) || (!pw->moving) || (pw->started < _physics_mod->conf->delay))
168 {
169 DBG("PHYS: MOVE THROUGH\n");
170 bd->x = x, bd->y = y;
171 if (pw->moving) pw->started++;
172 pw->show_ready = 0;
173 _e_mod_physics_win_configure(pw, x, y, pw->bd->w, pw->bd->h, pw->border);
174 return;
175 }
176 if (!pw->impulse)
177 {
178 DBG("PHYS: IMPULSE APPLY\n");
179 pw->impulse_x = (x - bd->x) * 5;
180 pw->impulse_y = (bd->y - y) * 5;
181 ephysics_body_central_impulse_apply(pw->body, pw->impulse_x, pw->impulse_y, 0);
182 bd->x = x, bd->y = y;
183 pw->impulse = EINA_TRUE;
184 return;
185 }
186 if ((pw->ix == x) && (pw->iy == y))
187 bd->x = x, bd->y = y;
188 else
189 {
190 if (E_INSIDE(bd->x, bd->y, pw->p->man->x, pw->p->man->y, pw->p->man->w, pw->p->man->h) &&
191 E_INSIDE(bd->x + bd->w, bd->y, pw->p->man->x, pw->p->man->y, pw->p->man->w, pw->p->man->h) &&
192 E_INSIDE(bd->x, bd->y + bd->h, pw->p->man->x, pw->p->man->y, pw->p->man->w, pw->p->man->h) &&
193 E_INSIDE(bd->x + bd->w, bd->y + bd->h, pw->p->man->x, pw->p->man->y, pw->p->man->w, pw->p->man->h))
194 DBG("REJECTED!\n");
195 else if (pw->moving)
196 {
197 DBG("UPDATE\n");
198 bd->x = x, bd->y = y;
199 pw->show_ready = 0;
200 _e_mod_physics_win_configure(pw, x, y, pw->bd->w, pw->bd->h, pw->border);
201 }
202 }
203}
204
205static E_Physics_Win *
206_e_mod_physics_win_add(E_Physics *p, E_Border *bd)
207{
208 Ecore_X_Window_Attributes att;
209 E_Physics_Win *pw;
210
211 memset((&att), 0, sizeof(Ecore_X_Window_Attributes));
212 if (!ecore_x_window_attributes_get(bd->client.win, &att))
213 return NULL;
214 /* don't physics on input grab windows or tooltips */
215 if (att.input_only || att.override) return NULL;
216
217 pw = calloc(1, sizeof(E_Physics_Win));
218 if (!pw) return NULL;
219 pw->win = bd->client.win;
220 pw->p = p;
221 pw->bd = bd;
222 eina_hash_add(borders, e_util_winid_str_get(pw->bd->client.win), pw);
223 if (pw->bd->visible)
224 _e_mod_physics_win_show(pw);
225 DBG("PHYS: WIN %d ADD\n", bd->client.win);
226 p->wins = eina_inlist_append(p->wins, EINA_INLIST_GET(pw));
227 return pw;
228}
229
230static void
231_e_mod_physics_win_del(E_Physics_Win *pw)
232{
233 eina_hash_del(borders, e_util_winid_str_get(pw->bd->client.win), pw);
234 e_border_move_intercept_cb_set(pw->bd, NULL);
235 pw->bd = NULL;
236 pw->p->wins = eina_inlist_remove(pw->p->wins, EINA_INLIST_GET(pw));
237 if (pw->body) ephysics_body_del(pw->body);
238 memset(pw, 0, sizeof(E_Physics_Win));
239 free(pw);
240}
241
242static void
243_e_mod_physics_win_hide(E_Physics_Win *pw)
244{
245 if (!pw->visible) return;
246 DBG("PHYS: HIDE %d\n", pw->win);
247 pw->show_ready = pw->visible = 0;
248 ephysics_body_del(pw->body);
249 pw->body = NULL;
250 e_border_hook_del(pw->begin);
251 e_border_hook_del(pw->end);
252 pw->begin = pw->end = NULL;
253 e_border_move_intercept_cb_set(pw->bd, NULL);
254}
255
256#if 0
257static void
258_e_mod_physics_win_raise_above(E_Physics_Win *pw,
259 E_Physics_Win *cw2)
260{
261 DBG(" [0x%x] abv [0x%x]\n", pw->win, cw2->win);
262 pw->p->wins_invalid = 1;
263 pw->p->wins = eina_inlist_remove(pw->p->wins, EINA_INLIST_GET(pw));
264 pw->p->wins = eina_inlist_append_relative(pw->p->wins,
265 EINA_INLIST_GET(pw),
266 EINA_INLIST_GET(cw2));
267 evas_object_stack_above(pw->shobj, cw2->shobj);
268 if (pw->bd)
269 {
270 Eina_List *l;
271 E_Border *tmp;
272
273 EINA_LIST_FOREACH (pw->bd->client.e.state.video_child, l, tmp)
274 {
275 E_Physics_Win *tcw;
276
277 tcw = eina_hash_find(borders, e_util_winid_str_get(tmp->client.win));
278 if (!tcw) continue;
279
280 evas_object_stack_below(tcw->shobj, pw->shobj);
281 }
282 }
283
284 _e_mod_physics_win_render_queue(pw);
285 pw->pending_count++;
286 e_manager_comp_event_src_config_send
287 (pw->p->man, (E_Manager_Comp_Source *)pw,
288 _e_mod_physics_cb_pending_after, pw->p);
289}
290
291static void
292_e_mod_physics_win_raise(E_Physics_Win *pw)
293{
294 DBG(" [0x%x] rai\n", pw->win);
295 pw->p->wins_invalid = 1;
296 pw->p->wins = eina_inlist_remove(pw->p->wins, EINA_INLIST_GET(pw));
297 pw->p->wins = eina_inlist_append(pw->p->wins, EINA_INLIST_GET(pw));
298 evas_object_raise(pw->shobj);
299 if (pw->bd)
300 {
301 Eina_List *l;
302 E_Border *tmp;
303
304 EINA_LIST_FOREACH (pw->bd->client.e.state.video_child, l, tmp)
305 {
306 E_Physics_Win *tcw;
307
308 tcw = eina_hash_find(borders, e_util_winid_str_get(tmp->client.win));
309 if (!tcw) continue;
310
311 evas_object_stack_below(tcw->shobj, pw->shobj);
312 }
313 }
314
315 _e_mod_physics_win_render_queue(pw);
316 pw->pending_count++;
317 e_manager_comp_event_src_config_send
318 (pw->p->man, (E_Manager_Comp_Source *)pw,
319 _e_mod_physics_cb_pending_after, pw->p);
320}
321
322static void
323_e_mod_physics_win_lower(E_Physics_Win *pw)
324{
325 DBG(" [0x%x] low\n", pw->win);
326 pw->p->wins_invalid = 1;
327 pw->p->wins = eina_inlist_remove(pw->p->wins, EINA_INLIST_GET(pw));
328 pw->p->wins = eina_inlist_prepend(pw->p->wins, EINA_INLIST_GET(pw));
329 evas_object_lower(pw->shobj);
330 if (pw->bd)
331 {
332 Eina_List *l;
333 E_Border *tmp;
334
335 EINA_LIST_FOREACH (pw->bd->client.e.state.video_child, l, tmp)
336 {
337 E_Physics_Win *tcw;
338
339 tcw = eina_hash_find(borders, e_util_winid_str_get(tmp->client.win));
340 if (!tcw) continue;
341
342 evas_object_stack_below(tcw->shobj, pw->shobj);
343 }
344 }
345
346 _e_mod_physics_win_render_queue(pw);
347 pw->pending_count++;
348 e_manager_comp_event_src_config_send
349 (pw->p->man, (E_Manager_Comp_Source *)pw,
350 _e_mod_physics_cb_pending_after, pw->p);
351}
352#endif
353
354static void
355_e_mod_physics_win_mass_set(E_Physics_Win *pw)
356{
357 double mass;
358 E_Border *bd = pw->bd;
359 if (!bd) return;
360 if (bd->remember)
361 {
362 if ((bd->remember->apply & E_REMEMBER_APPLY_POS) ||
363 (bd->remember->prop.lock_client_location) ||
364 (bd->remember->prop.lock_user_location))
365 ephysics_body_mass_set(pw->body, 50000);
366 return;
367 }
368 mass = _physics_mod->conf->max_mass * (((double)pw->w / (double)pw->p->man->w) + ((double)pw->h / (double)pw->p->man->h) / 2.);
369 DBG("PHYS: WIN %d MASS %g\n", pw->win, mass);
370 ephysics_body_mass_set(pw->body, mass);
371}
372
373static void
374_e_mod_physics_win_configure(E_Physics_Win *pw,
375 int x,
376 int y,
377 int w,
378 int h,
379 int border)
380{
381 //DBG("PHYS: CONFIG %d\n", pw->win);
382 if (!pw->visible)
383 {
384 pw->hidden.x = x;
385 pw->hidden.y = y;
386 pw->border = border;
387 }
388 else
389 {
390 if (!((x == pw->x) && (y == pw->y)))
391 {
392 pw->x = x;
393 pw->y = y;
394 }
395 pw->hidden.x = x;
396 pw->hidden.y = y;
397 }
398 pw->maximize = pw->bd->maximized;
399 pw->hidden.w = w;
400 pw->hidden.h = h;
401 if (!((w == pw->w) && (h == pw->h)))
402 {
403 pw->w = w;
404 pw->h = h;
405 }
406 if (pw->border != border)
407 {
408 pw->border = border;
409 }
410 if ((!pw->show_ready) && pw->body)
411 {
412 _e_mod_physics_win_mass_set(pw);
413 ephysics_body_geometry_set(pw->body, x, y, -15, w, border + h, 30);
414 pw->show_ready = 1;
415 }
416}
417
418static E_Physics_Shelf *
419_e_mod_physics_shelf_find(E_Physics *p, E_Shelf *es)
420{
421 E_Physics_Shelf *eps;
422 EINA_INLIST_FOREACH(p->shelves, eps)
423 if (eps->es == es) return eps;
424 return NULL;
425}
426
427static void
428_e_mod_physics_shelf_free(E_Physics *p, E_Shelf *es)
429{
430 E_Physics_Shelf *eps;
431
432 eps = _e_mod_physics_shelf_find(p, es);
433 if (!eps) return;
434 if (eps->body) ephysics_body_del(eps->body);
435 p->shelves = eina_inlist_remove(p->shelves, EINA_INLIST_GET(eps));
436 free(eps);
437}
438
439static void
440_e_mod_physics_shelf_new(E_Physics *p, E_Shelf *es)
441{
442 EPhysics_Body *eb;
443 E_Physics_Shelf *eps;
444
445 eps = E_NEW(E_Physics_Shelf, 1);
446 eps->p = p;
447 eps->es = es;
448 if (!_physics_mod->conf->ignore_shelves)
449 {
450 if (_physics_mod->conf->shelf.disable_move)
451 {
452 eps->body = eb = ephysics_body_box_add(p->world);
453 ephysics_body_evas_object_set(eb, es->o_base, EINA_TRUE);
454 ephysics_body_linear_movement_enable_set(eb, EINA_FALSE,
455 EINA_FALSE, EINA_FALSE);
456 ephysics_body_mass_set(eb, 50000);
457 }
458 else
459 {
460 eps->body = eb = ephysics_body_box_add(p->world);
461 ephysics_body_evas_object_set(eb, es->o_base, EINA_TRUE);
462 if (es->cfg->overlap || es->cfg->autohide)
463 ephysics_body_mass_set(eb, 0);
464 else
465 ephysics_body_mass_set(eb, 50000);
466 if (es->cfg->popup && (!_physics_mod->conf->shelf.disable_rotate))
467 ephysics_body_angular_movement_enable_set(eb, EINA_FALSE,
468 EINA_FALSE,
469 EINA_FALSE);
470 }
471 }
472 p->shelves = eina_inlist_append(p->shelves, EINA_INLIST_GET(eps));
473}
474
475//////////////////////////////////////////////////////////////////////////
476
477
478static Eina_Bool
479_e_mod_physics_bd_property(void *data __UNUSED__, int type __UNUSED__, void *event)
480{
481 E_Event_Border_Property *ev = event;
482 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
483 if (pw->maximize == ev->border->maximized) return ECORE_CALLBACK_PASS_ON;
484
485 if (ev->border->maximized)
486 _e_mod_physics_win_del(pw);
487 else
488 {
489 E_Physics *p = _e_mod_physics_find(ev->border->zone->container->manager->root);
490 pw = _e_mod_physics_win_add(p, ev->border);
491 if (!pw) return ECORE_CALLBACK_PASS_ON;
492 _e_mod_physics_win_configure(pw, pw->bd->x, pw->bd->y,
493 pw->bd->w, pw->bd->h,
494 ecore_x_window_border_width_get(pw->bd->client.win));
495 }
496
497 pw->maximize = ev->border->maximized;
498 return ECORE_CALLBACK_PASS_ON;
499}
500
501static Eina_Bool
502_e_mod_physics_bd_fullscreen(void *data __UNUSED__, int type, void *event)
503{
504 E_Event_Border_Fullscreen *ev = event;
505 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
506 if (type == E_EVENT_BORDER_FULLSCREEN)
507 {
508 if (pw)
509 _e_mod_physics_win_del(pw);
510 }
511 else
512 {
513 E_Physics *p = _e_mod_physics_find(ev->border->zone->container->manager->root);
514 if (!pw)
515 {
516 pw = _e_mod_physics_win_add(p, ev->border);
517 if (!pw) return ECORE_CALLBACK_PASS_ON;
518 _e_mod_physics_win_configure(pw, pw->bd->x, pw->bd->y,
519 pw->bd->w, pw->bd->h,
520 ecore_x_window_border_width_get(pw->bd->client.win));
521 }
522 }
523 return ECORE_CALLBACK_PASS_ON;
524}
525
526
527static Eina_Bool
528_e_mod_physics_bd_add(void *data __UNUSED__,
529 int type __UNUSED__,
530 void *event)
531{
532 E_Event_Border_Add *ev = event;
533 DBG("PHYS: NEW %d\n", ev->border->client.win);
534 E_Physics *p = _e_mod_physics_find(ev->border->zone->container->manager->root);
535 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
536 if (pw) return ECORE_CALLBACK_PASS_ON;
537 pw = _e_mod_physics_win_add(p, ev->border);
538 if (pw) _e_mod_physics_win_configure(pw, ev->border->x, ev->border->y, ev->border->w, ev->border->h,
539 ecore_x_window_border_width_get(ev->border->client.win));
540 return ECORE_CALLBACK_PASS_ON;
541}
542
543static Eina_Bool
544_e_mod_physics_bd_del(void *data __UNUSED__,
545 int type __UNUSED__,
546 void *event)
547{
548 E_Event_Border_Add *ev = event;
549 DBG("PHYS: DEL %d\n", ev->border->client.win);
550 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
551 if (!pw) return ECORE_CALLBACK_PASS_ON;
552 _e_mod_physics_win_del(pw);
553 return ECORE_CALLBACK_PASS_ON;
554}
555
556/*
557static Eina_Bool
558_e_mod_physics_reparent(void *data __UNUSED__,
559 int type __UNUSED__,
560 void *event)
561{
562 Ecore_X_Event_Window_Reparent *ev = event;
563 E_Physics_Win *pw = _e_mod_physics_win_find(ev->win);
564 if (!pw) return ECORE_CALLBACK_PASS_ON;
565 if (ev->parent != pw->p->man->root)
566 _e_mod_physics_win_del(pw);
567 return ECORE_CALLBACK_PASS_ON;
568}
569*/
570static Eina_Bool
571_e_mod_physics_configure(void *data __UNUSED__,
572 int type __UNUSED__,
573 void *event)
574{
575 Ecore_X_Event_Window_Configure *ev = event;
576 E_Physics_Win *pw = _e_mod_physics_win_find(ev->win);
577 if (!pw) return ECORE_CALLBACK_PASS_ON;
578/* TODO: stacking
579 if (ev->abovewin == 0)
580 {
581 if (EINA_INLIST_GET(pw)->prev) _e_mod_physics_win_lower(pw);
582 }
583 else
584 {
585 E_Physics_Win *cw2 = _e_mod_physics_win_find(ev->abovewin);
586
587 if (cw2)
588 {
589 E_Physics_Win *cw3 = (E_Physics_Win *)(EINA_INLIST_GET(pw)->prev);
590
591 if (cw3 != cw2) _e_mod_physics_win_raise_above(pw, cw2);
592 }
593 }
594*/
595 if (!((pw->x == ev->x) && (pw->y == ev->y) &&
596 (pw->w == ev->w) && (pw->h == ev->h) &&
597 (pw->border == ev->border)))
598 {
599 _e_mod_physics_win_configure(pw, ev->x, ev->y, ev->w, ev->h, ev->border);
600 }
601 return ECORE_CALLBACK_PASS_ON;
602}
603#if 0
604static Eina_Bool
605_e_mod_physics_stack(void *data __UNUSED__,
606 int type __UNUSED__,
607 void *event)
608{
609 Ecore_X_Event_Window_Stack *ev = event;
610 E_Physics_Win *pw = _e_mod_physics_win_find(ev->win);
611 if (!pw) return ECORE_CALLBACK_PASS_ON;
612 /* TODO
613 if (ev->detail == ECORE_X_WINDOW_STACK_ABOVE) _e_mod_physics_win_raise(pw);
614 else _e_mod_physics_win_lower(pw);
615 */
616 return ECORE_CALLBACK_PASS_ON;
617}
618#endif
619static Eina_Bool
620_e_mod_physics_randr(void *data __UNUSED__,
621 int type __UNUSED__,
622 __UNUSED__ void *event __UNUSED__)
623{
624 Eina_List *l;
625 E_Physics *p;
626
627 EINA_LIST_FOREACH(physicists, l, p)
628 ephysics_world_render_geometry_set(p->world, 0, 0, -5,
629 p->man->w, p->man->h, 10);
630 return ECORE_CALLBACK_PASS_ON;
631}
632
633static Eina_Bool
634_e_mod_physics_bd_resize(void *data __UNUSED__,
635 int type __UNUSED__,
636 void *event)
637{
638 E_Event_Border_Move *ev = event;
639 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
640 if (!pw) return ECORE_CALLBACK_PASS_ON;
641 if (!pw->visible) return ECORE_CALLBACK_PASS_ON;
642 pw->show_ready = 0;
643 _e_mod_physics_win_configure(pw, pw->x, pw->y, ev->border->w, ev->border->h, pw->border);
644 pw->show_ready = 1;
645 return ECORE_CALLBACK_PASS_ON;
646}
647
648static Eina_Bool
649_e_mod_physics_shelf_add(void *data __UNUSED__, int type __UNUSED__, void *event)
650{
651 E_Event_Shelf *ev = event;
652 E_Physics *p;
653 Eina_List *l;
654
655 EINA_LIST_FOREACH(physicists, l, p)
656 if (p->man == ev->shelf->zone->container->manager)
657 {
658 _e_mod_physics_shelf_new(p, ev->shelf);
659 break;
660 }
661 return ECORE_CALLBACK_RENEW;
662}
663
664static Eina_Bool
665_e_mod_physics_shelf_del(void *data __UNUSED__, int type __UNUSED__, void *event)
666{
667 E_Event_Shelf *ev = event;
668 E_Physics *p;
669 Eina_List *l;
670
671 EINA_LIST_FOREACH(physicists, l, p)
672 if (p->man == ev->shelf->zone->container->manager)
673 {
674 _e_mod_physics_shelf_free(p, ev->shelf);
675 break;
676 }
677 return ECORE_CALLBACK_RENEW;
678
679
680}
681
682static Eina_Bool
683_e_mod_physics_remember_update(void *data __UNUSED__, int type __UNUSED__, void *event)
684{
685 E_Event_Remember_Update *ev = event;
686 E_Border *bd = ev->border;
687 E_Physics_Win *pw = _e_mod_physics_win_find(bd->client.win);
688 if (!pw) return ECORE_CALLBACK_PASS_ON;
689 _e_mod_physics_win_mass_set(pw);
690 return ECORE_CALLBACK_PASS_ON;
691}
692/*
693static Eina_Bool
694_e_mod_physics_bd_move(void *data __UNUSED__,
695 int type __UNUSED__,
696 void *event)
697{
698 E_Event_Border_Move *ev = event;
699 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
700 if (!pw) return ECORE_CALLBACK_PASS_ON;
701 if (!pw->visible) return ECORE_CALLBACK_PASS_ON;
702 _e_mod_physics_win_configure(pw, pw->x, pw->y, ev->border->w, ev->border->h, pw->border);
703
704 return ECORE_CALLBACK_PASS_ON;
705}
706*/
707static Eina_Bool
708_e_mod_physics_bd_show(void *data __UNUSED__,
709 int type __UNUSED__,
710 void *event)
711{
712 E_Event_Border_Hide *ev = event;
713 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
714 if (!pw) return ECORE_CALLBACK_PASS_ON;
715 _e_mod_physics_win_show(pw);
716 _e_mod_physics_win_configure(pw, pw->bd->x, pw->bd->y, pw->bd->w, pw->bd->h, pw->border);
717 return ECORE_CALLBACK_PASS_ON;
718}
719
720static Eina_Bool
721_e_mod_physics_bd_hide(void *data __UNUSED__,
722 int type __UNUSED__,
723 void *event)
724{
725 E_Event_Border_Hide *ev = event;
726 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
727 if (!pw) return ECORE_CALLBACK_PASS_ON;
728 _e_mod_physics_win_hide(pw);
729 return ECORE_CALLBACK_PASS_ON;
730}
731#if 0
732static Eina_Bool
733_e_mod_physics_bd_iconify(void *data __UNUSED__,
734 int type __UNUSED__,
735 void *event)
736{
737 E_Event_Border_Iconify *ev = event;
738 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
739 if (!pw) return ECORE_CALLBACK_PASS_ON;
740 // fimxe: special iconfiy anim
741 return ECORE_CALLBACK_PASS_ON;
742}
743
744static Eina_Bool
745_e_mod_physics_bd_uniconify(void *data __UNUSED__,
746 int type __UNUSED__,
747 void *event)
748{
749 E_Event_Border_Uniconify *ev = event;
750 E_Physics_Win *pw = _e_mod_physics_win_find(ev->border->client.win);
751 if (!pw) return ECORE_CALLBACK_PASS_ON;
752 // fimxe: special uniconfiy anim
753 return ECORE_CALLBACK_PASS_ON;
754}
755#endif
756
757static E_Physics *
758_e_mod_physics_add(E_Manager *man)
759{
760 E_Physics *p;
761 EPhysics_Body *bound;
762 Eina_List *l;
763 E_Border *bd;
764 E_Shelf *es;
765
766 p = calloc(1, sizeof(E_Physics));
767 if (!p) return NULL;
768 p->man = man;
769 p->world = ephysics_world_new();
770 /* TODO: world per zone */
771 DBG("PHYS: world++ || %dx%d\n", man->w, man->h);
772 ephysics_world_render_geometry_set(p->world, 0, 0, -5, man->w, man->h, 10);
773 ephysics_world_gravity_set(p->world, 0, _physics_mod->conf->gravity, 0);
774
775 bound = ephysics_body_left_boundary_add(p->world);
776 ephysics_body_restitution_set(bound, 1);
777 ephysics_body_friction_set(bound, 3);
778 bound = ephysics_body_right_boundary_add(p->world);
779 ephysics_body_restitution_set(bound, 1);
780 ephysics_body_friction_set(bound, 3);
781 bound = ephysics_body_top_boundary_add(p->world);
782 ephysics_body_restitution_set(bound, 1);
783 ephysics_body_friction_set(bound, 3);
784 bound = ephysics_body_bottom_boundary_add(p->world);
785 ephysics_body_restitution_set(bound, 1);
786 ephysics_body_friction_set(bound, 3);
787
788 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
789 {
790 E_Physics_Win *pw;
791 int border;
792
793 pw = _e_mod_physics_win_add(p, bd);
794 if (!pw) continue;
795 border = ecore_x_window_border_width_get(bd->client.win);
796 _e_mod_physics_win_configure(pw, bd->x, bd->y, bd->w, bd->h, border);
797 }
798 l = e_shelf_list_all();
799 EINA_LIST_FREE(l, es)
800 _e_mod_physics_shelf_new(p, es);
801
802 return p;
803}
804
805static void
806_e_mod_physics_del(E_Physics *p)
807{
808 E_Physics_Win *pw;
809 Eina_Inlist *l;
810 E_Physics_Shelf *eps;
811
812 while (p->wins)
813 {
814 pw = (E_Physics_Win *)(p->wins);
815 _e_mod_physics_win_del(pw);
816 }
817 if (p->world)
818 ephysics_world_del(p->world);
819 EINA_INLIST_FOREACH_SAFE(p->shelves, l, eps)
820 {
821 free(eps);
822 }
823 free(p);
824}
825
826static void
827_e_mod_physics_win_update_cb(E_Physics_Win *pw, EPhysics_Body *body, void *event_info __UNUSED__)
828{
829 //DBG("PHYS: TICKER %d\n", pw->win);
830 if (pw->moving && (pw->started < _physics_mod->conf->delay))
831 {
832 pw->show_ready = 0;
833 _e_mod_physics_win_configure(pw, pw->x, pw->y, pw->w, pw->h, pw->border);
834 return;
835 }
836 ephysics_body_geometry_get(body, &pw->ix, &pw->iy, NULL, NULL, NULL, NULL);
837 e_border_move(pw->bd, pw->ix, pw->iy);
838}
839
840//////////////////////////////////////////////////////////////////////////
841
842void
843e_mod_physics_mass_update(void)
844{
845 Eina_List *l;
846 E_Physics *p;
847 E_Physics_Win *pw;
848 EINA_LIST_FOREACH(physicists, l, p)
849 EINA_INLIST_FOREACH(p->wins, pw)
850 _e_mod_physics_win_mass_set(pw);
851}
852
853Eina_Bool
854e_mod_physics_init(void)
855{
856 Eina_List *l;
857 E_Manager *man;
858
859 borders = eina_hash_string_superfast_new(NULL);
860
861// E_LIST_HANDLER_APPEND(handlers, ECORE_X_EVENT_WINDOW_REPARENT, _e_mod_physics_reparent, NULL);
862 E_LIST_HANDLER_APPEND(handlers, ECORE_X_EVENT_WINDOW_CONFIGURE, _e_mod_physics_configure, NULL);
863 //E_LIST_HANDLER_APPEND(handlers, ECORE_X_EVENT_WINDOW_STACK, _e_mod_physics_stack, NULL);
864
865 if (_physics_mod->conf->ignore_maximized)
866 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_PROPERTY, _e_mod_physics_bd_property, NULL);
867 if (_physics_mod->conf->ignore_fullscreen)
868 {
869 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_FULLSCREEN, _e_mod_physics_bd_fullscreen, NULL);
870 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_UNFULLSCREEN, _e_mod_physics_bd_fullscreen, NULL);
871 }
872 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CONTAINER_RESIZE, _e_mod_physics_randr, NULL);
873
874 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_ADD, _e_mod_physics_bd_add, NULL);
875 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_REMOVE, _e_mod_physics_bd_del, NULL);
876 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_SHOW, _e_mod_physics_bd_show, NULL);
877 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_HIDE, _e_mod_physics_bd_hide, NULL);
878// E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_MOVE, _e_mod_physics_bd_move, NULL);
879 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_RESIZE, _e_mod_physics_bd_resize, NULL);
880 E_LIST_HANDLER_APPEND(handlers, E_EVENT_REMEMBER_UPDATE, _e_mod_physics_remember_update, NULL);
881
882 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SHELF_ADD, _e_mod_physics_shelf_add, NULL);
883 E_LIST_HANDLER_APPEND(handlers, E_EVENT_SHELF_DEL, _e_mod_physics_shelf_del, NULL);
884
885#if 0
886 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_ICONIFY, _e_mod_physics_bd_iconify, NULL);
887 E_LIST_HANDLER_APPEND(handlers, E_EVENT_BORDER_UNICONIFY, _e_mod_physics_bd_uniconify, NULL);
888#endif
889 EINA_LIST_FOREACH (e_manager_list(), l, man)
890 {
891 E_Physics *p;
892
893 p = _e_mod_physics_add(man);
894 if (p) physicists = eina_list_append(physicists, p);
895 }
896
897 ecore_x_sync();
898
899 return 1;
900}
901
902void
903e_mod_physics_shutdown(void)
904{
905 E_FREE_LIST(physicists, _e_mod_physics_del);
906 E_FREE_LIST(handlers, ecore_event_handler_del);
907
908 if (borders) eina_hash_free(borders);
909 borders = NULL;
910}
911
diff --git a/src/modules/physics/e_mod_physics.h b/src/modules/physics/e_mod_physics.h
deleted file mode 100644
index 49731b2..0000000
--- a/src/modules/physics/e_mod_physics.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifdef E_TYPEDEFS
2#else
3#ifndef E_MOD_PHYSICS_H
4#define E_MOD_PHYSICS_H
5
6void e_mod_physics_mass_update(void);
7Eina_Bool e_mod_physics_init(void);
8void e_mod_physics_shutdown(void);
9
10#endif
11#endif
diff --git a/src/modules/physics/e_mod_physics_cfdata.c b/src/modules/physics/e_mod_physics_cfdata.c
deleted file mode 100644
index 8ef86d7..0000000
--- a/src/modules/physics/e_mod_physics_cfdata.c
+++ /dev/null
@@ -1,48 +0,0 @@
1#include "e.h"
2#include "e_mod_main.h"
3#include "e_mod_physics_cfdata.h"
4
5EAPI E_Config_DD *
6e_mod_physics_cfdata_edd_init(void)
7{
8 E_Config_DD *conf_edd;
9
10 conf_edd = E_CONFIG_DD_NEW("Physics_Config", Config);
11#undef T
12#undef D
13#define T Config
14#define D conf_edd
15 E_CONFIG_VAL(D, T, config_version, INT);
16 E_CONFIG_VAL(D, T, delay, UINT);
17 E_CONFIG_VAL(D, T, max_mass, DOUBLE);
18 E_CONFIG_VAL(D, T, gravity, DOUBLE);
19 E_CONFIG_VAL(D, T, ignore_fullscreen, UCHAR);
20 E_CONFIG_VAL(D, T, ignore_maximized, UCHAR);
21 E_CONFIG_VAL(D, T, ignore_shelves, UCHAR);
22 E_CONFIG_VAL(D, T, shelf.disable_move, UCHAR);
23 E_CONFIG_VAL(D, T, shelf.disable_rotate, UCHAR);
24 return conf_edd;
25}
26
27EAPI Config *
28e_mod_physics_cfdata_config_new(void)
29{
30 Config *cfg;
31
32 cfg = E_NEW(Config, 1);
33 cfg->delay = 10;
34 cfg->max_mass = 3.0;
35 cfg->gravity = 0.0;
36 cfg->ignore_fullscreen = EINA_TRUE;
37 cfg->ignore_maximized = EINA_TRUE;
38 cfg->ignore_shelves = EINA_TRUE;
39
40 return cfg;
41}
42
43EAPI void
44e_mod_cfdata_config_free(Config *cfg)
45{
46 free(cfg);
47}
48
diff --git a/src/modules/physics/e_mod_physics_cfdata.h b/src/modules/physics/e_mod_physics_cfdata.h
deleted file mode 100644
index 2cf5f45..0000000
--- a/src/modules/physics/e_mod_physics_cfdata.h
+++ /dev/null
@@ -1,32 +0,0 @@
1#ifndef E_MOD_PHYSICS_CFDATA_H
2#define E_MOD_PHYSICS_CFDATA_H
3
4typedef struct _Config Config;
5
6/* Increment for Major Changes */
7#define MOD_CONFIG_FILE_EPOCH 1
8/* Increment for Minor Changes (ie: user doesn't need a new config) */
9#define MOD_CONFIG_FILE_GENERATION 0
10#define MOD_CONFIG_FILE_VERSION ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION)
11
12struct _Config
13{
14 int config_version;
15 unsigned int delay; /* delay before applying physics */
16 double max_mass; /* maximum mass for a window */
17 double gravity; /* maximum mass for a window */
18 Eina_Bool ignore_fullscreen;
19 Eina_Bool ignore_maximized;
20 Eina_Bool ignore_shelves;
21 struct
22 {
23 Eina_Bool disable_rotate;
24 Eina_Bool disable_move;
25 } shelf;
26};
27
28EAPI E_Config_DD *e_mod_physics_cfdata_edd_init(void);
29EAPI Config *e_mod_physics_cfdata_config_new(void);
30EAPI void e_mod_cfdata_config_free(Config *cfg);
31
32#endif
diff --git a/src/modules/physics/module.desktop.in b/src/modules/physics/module.desktop.in
deleted file mode 100644
index 8e4fbfe..0000000
--- a/src/modules/physics/module.desktop.in
+++ /dev/null
@@ -1,23 +0,0 @@
1[Desktop Entry]
2Encoding=UTF-8
3Type=Link
4Name=Physics
5Name[ca]=Física
6Name[eo]=Fiziko
7Name[es]=Física
8Name[fr]=Physiques
9Name[gl]=Física
10Name[pt]=Física
11Name[ru]=Физика
12Name[sr]=Физика
13Comment=Enlightenment Physics Professor
14Comment[ca]=El professor de física de l'Enlightenment
15Comment[eo]=Profesoro de Enlightenment pri fiziko
16Comment[es]=El profesor de física de Enlightenment
17Comment[fr]=Professeur de physique pour Enlightenment
18Comment[gl]=O profesor de física de Enlightenment
19Comment[it]=Il professore di fisica di Enlightenment
20Comment[pt]=Professor de física do Enlightenment
21Comment[sr]=Професор физике Просвећења
22Icon=e-module-physics
23X-Enlightenment-ModuleType=look