summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore50
-rw-r--r--AUTHORS1
-rw-r--r--COPYING25
-rw-r--r--ChangeLog0
-rw-r--r--Makefile.am25
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh17
-rw-r--r--configure.ac51
-rw-r--r--e-module-contact.edjbin0 -> 9866 bytes
-rw-r--r--e_modules-contact.spec.in47
-rw-r--r--m4/.gitignore39
-rw-r--r--module.desktop.in17
-rw-r--r--src/Makefile.am26
-rw-r--r--src/e_edges.c241
-rw-r--r--src/e_edges.h20
-rw-r--r--src/e_mod_main.c133
-rw-r--r--src/e_mod_main.h8
-rw-r--r--src/e_policy.c285
-rw-r--r--src/e_policy.h10
20 files changed, 995 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..255b55c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,50 @@
1*~
2*.swo
3*.swp
4*.o
5*.lo
6*.la
7ABOUT-NLS
8INSTALL
9Makefile
10Makefile.in
11aclocal.m4
12autom4te.cache/
13config.guess
14config.h
15config.h.in
16config.log
17config.rpath
18config.status
19config.sub
20configure
21configure.ac.orig
22depcomp
23e_modules-contact.spec
24install-sh
25libtool
26ltmain.sh
27missing
28mkinstalldirs
29module.desktop
30po/Makefile
31po/Makefile.in
32po/Makefile.in.in
33po/Makevars.template
34po/POTFILES
35po/Rules-quot
36po/*.gmo
37po/boldquot.sed
38po/en@boldquot.header
39po/en@quot.header
40po/insert-header.sin
41po/quot.sed
42po/remove-potcdate.sed
43po/remove-potcdate.sin
44po/contact.pot
45po/stamp-po
46src/.deps/
47src/.libs/
48src/Makefile
49src/Makefile.in
50stamp-h1
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..73ebbe2
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
The Rasterman (Carsten Haitzler) <raster@rasterman.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..b633be5
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,25 @@
1Copyright notice for Contact:
2
3Copyright (C) 2013-2015 Carsten Haitzler and various contributors (see AUTHORS)
4
5All rights reserved.
6
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions are met:
9
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..b8bf065
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,25 @@
1ACLOCAL_AMFLAGS = -I m4
2MAINTAINERCLEANFILES = Makefile.in aclocal.m4 compile config.guess config.h.in \
3 config.sub configure depcomp install-sh ltmain.sh \
4 missing module.desktop config.rpath mkinstalldirs
5
6SUBDIRS = src
7
8#if HAVE_PO
9
10#SUBDIRS += po
11
12#endif
13
14filesdir = $(module_dir)/$(PACKAGE)
15files_DATA = module.desktop e-module-contact.edj
16
17EXTRA_DIST = module.desktop.in \
18 e_modules-contact.spec.in
19
20clean-local:
21 rm -rf *.edj module.desktop e_modules-contact.spec *~
22
23uninstall-local:
24 rm -rf $(DESTDIR)$(module_dir)/$(PACKAGE)
25
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..ae01364
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,17 @@
1#!/bin/sh
2
3rm -rf autom4te.cache
4rm -f aclocal.m4 ltmain.sh
5
6touch README
7
8echo "Running autopoint..." ; autopoint -f || :
9echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1
10echo "Running autoheader..." ; autoheader || exit 1
11echo "Running autoconf..." ; autoconf || exit 1
12echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
13echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
14
15if [ -z "$NOCONFIGURE" ]; then
16 ./configure "$@"
17fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..ef86faf
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,51 @@
1AC_INIT(contact, 0.0.0, raster@rasterman.com)
2AC_CONFIG_MACRO_DIR([m4])
3AC_PREREQ(2.52)
4AC_CONFIG_SRCDIR(configure.ac)
5AC_CANONICAL_BUILD
6AC_CANONICAL_HOST
7AC_ISC_POSIX
8
9AM_INIT_AUTOMAKE([1.8 dist-bzip2])
10AM_CONFIG_HEADER(config.h)
11m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
12
13AC_PROG_CC
14AM_PROG_CC_STDC
15
16define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
17define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
18AC_PROG_LIBTOOL
19
20#m4_ifdef([AM_GNU_GETTEXT_VERSION], [
21#AM_GNU_GETTEXT_VERSION([0.14])
22#])
23
24#m4_ifdef([AM_GNU_GETTEXT], [
25#AM_GNU_GETTEXT([external])
26#po_makefile_in=po/Makefile.in
27#AM_CONDITIONAL([HAVE_PO], [true])
28#],[
29#AM_CONDITIONAL([HAVE_PO], [false])
30#])
31#AC_SUBST(LTLIBINTL)
32
33PKG_CHECK_MODULES([E], [enlightenment >= 0.19.99])
34release=$(pkg-config --variable=release enlightenment)
35MODULE_ARCH="$host_os-$host_cpu-$release"
36AC_SUBST(MODULE_ARCH)
37AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
38
39module_dir="$(pkg-config --variable=modules enlightenment)"
40AC_SUBST(module_dir)
41
42AC_OUTPUT([
43Makefile
44src/Makefile
45module.desktop
46e_modules-contact.spec
47], [
48])
49
50#$po_makefile_in
51
diff --git a/e-module-contact.edj b/e-module-contact.edj
new file mode 100644
index 0000000..43d8150
--- /dev/null
+++ b/e-module-contact.edj
Binary files differ
diff --git a/e_modules-contact.spec.in b/e_modules-contact.spec.in
new file mode 100644
index 0000000..8662c7b
--- /dev/null
+++ b/e_modules-contact.spec.in
@@ -0,0 +1,47 @@
1%define module_name contact
2%{!?_rel:%{expand:%%global _rel 0.enl%{?dist}}}
3
4Summary: %{module_name} module for the Enlightenment window manager
5Name: e_modules-%{module_name}
6Version: @VERSION@
7Release: %{_rel}
8License: BSD
9Group: User Interface/Desktops
10URL: http://www.enlightenment.org/
11Source: ftp://ftp.enlightenment.org/pub/enlightenment/%{module_name}-%{version}.tar.gz
12Packager: %{?_packager:%{_packager}}%{!?_packager:Michael Jennings <mej@eterm.org>}
13Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)}
14Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
15BuildRequires: enlightenment-devel >= 0.19.999
16Requires: enlightenment >= 0.19.999
17BuildRoot: %{_tmppath}/%{name}-%{version}-root
18
19%description
20%{module_name} module for the Enlightenment window manager.
21
22%prep
23%setup -q -n %{module_name}-%{version}
24
25%build
26%{configure}
27%{__make} %{?_smp_mflags} %{?mflags}
28
29%install
30%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install
31%{find_lang} %{module_name} || true > %{module_name}.lang
32
33%clean
34test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
35
36%post
37/sbin/ldconfig
38
39%postun
40/sbin/ldconfig
41
42%files -f %{module_name}.lang
43%defattr(-, root, root)
44%doc AUTHORS ChangeLog COPYING* INSTALL NEWS README
45%{_libdir}/enlightenment/modules/%{module_name}*
46
47%changelog
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..73b287f
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,39 @@
1/codeset.m4
2/fcntl-o.m4
3/gettext.m4
4/glibc21.m4
5/iconv.m4
6/intdiv0.m4
7/inttypes-pri.m4
8/inttypes.m4
9/inttypes_h.m4
10/isc-posix.m4
11/lcmessage.m4
12/lib-ld.m4
13/lib-link.m4
14/lib-prefix.m4
15/libtool.m4
16/ltoptions.m4
17/ltsugar.m4
18/ltversion.m4
19/lt~obsolete.m4
20/nls.m4
21/po.m4
22/progtest.m4
23/stdint_h.m4
24/uintmax_t.m4
25/ulonglong.m4
26/glibc2.m4
27/intl.m4
28/intldir.m4
29/intlmacosx.m4
30/intmax.m4
31/lock.m4
32/longlong.m4
33/printf-posix.m4
34/size_max.m4
35/threadlib.m4
36/visibility.m4
37/wchar_t.m4
38/wint_t.m4
39/xsize.m4
diff --git a/module.desktop.in b/module.desktop.in
new file mode 100644
index 0000000..928c247
--- /dev/null
+++ b/module.desktop.in
@@ -0,0 +1,17 @@
1[Desktop Entry]
2Encoding=UTF-8
3Type=Link
4Name=Contact
5Name[ca]=Contacteu
6Name[de]=Kontakt
7Name[eo]=Kontakto
8Name[fr]=Contact
9Name[gl]=Contacto
10Name[ja]=コンタクト
11Name[ms]=Kenalan
12Name[pl]=Kontakt
13Name[sr]=Веза
14Name[tr]=Kişiler
15Comment=
16Icon=e-module-contact
17X-Enlightenment-ModuleType=mobile
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..477a4b5
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,26 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = -I. \
4 -I$(top_srcdir) \
5 -I$(includedir) \
6 -DLOCALEDIR=\"$(datadir)/locale\" \
7 -DPACKAGE_DATA_DIR=\"$(module_dir)/$(PACKAGE)\" \
8 -DNEED_X \
9 @E_CFLAGS@
10
11pkgdir = $(module_dir)/$(PACKAGE)/$(MODULE_ARCH)
12pkg_LTLIBRARIES = module.la
13module_la_SOURCES = \
14e_mod_main.c \
15e_mod_main.h \
16e_policy.c \
17e_policy.h \
18e_edges.c \
19e_edges.h
20
21module_la_LIBADD = @E_LIBS@
22module_la_LDFLAGS = -module -avoid-version
23module_la_DEPENDENCIES = $(top_builddir)/config.h
24
25clean-local:
26 rm -rf *~
diff --git a/src/e_edges.c b/src/e_edges.c
new file mode 100644
index 0000000..33bdaab
--- /dev/null
+++ b/src/e_edges.c
@@ -0,0 +1,241 @@
1#include "e_mod_main.h"
2
3typedef struct _Edgeset Edgeset;
4typedef struct _Edgehandler Edgehandler;
5
6struct _Edgeset
7{
8 E_Zone *zone;
9 struct {
10 Evas_Object *obj;
11 } l, r, t, b;
12 struct {
13 int button, x, y;
14 Eina_Bool recognized : 1;
15 } down;
16};
17
18struct _Edgehandler
19{
20 E_Edges_Event event;
21 void (*func) (void *data, int d, double v);
22 void *data;
23};
24
25static Edgehandler *_handler_find(E_Edges_Event event);
26static Evas_Object *_input_obj(Edgeset *es, int x, int y, int w, int h);
27static Edgeset *_edgeset_new(E_Zone *zone);
28static void _edgeset_free(Edgeset *es);
29static void _cb_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event);
30static void _cb_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event);
31static void _cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event);
32
33static Eina_List *edges = NULL;
34static Eina_List *handlers = NULL;
35
36void
37e_edges_init(void)
38{
39 const Eina_List *l;
40 E_Zone *zone;
41
42 EINA_LIST_FOREACH(e_comp->zones, l, zone)
43 {
44 Edgeset *es = _edgeset_new(zone);
45
46 if (es) edges = eina_list_append(edges, es);
47 }
48}
49
50void
51e_edges_shutdown(void)
52{
53 Edgeset *es;
54 Edgehandler *eh;
55
56 EINA_LIST_FREE(edges, es) _edgeset_free(es);
57 EINA_LIST_FREE(handlers, eh) free(eh);
58}
59
60void
61e_edges_handler_set(E_Edges_Event event, void (*func) (void *data, int d, double v), void *data)
62{
63 Edgehandler *eh;
64
65 eh = _handler_find(event);
66 if (!eh)
67 {
68 eh = calloc(1, sizeof(*eh));
69 if (!eh) return;
70 handlers = eina_list_append(handlers, eh);
71 }
72 eh->event = event;
73 eh->func = func;
74 eh->data = data;
75}
76
77static Edgehandler *
78_handler_find(E_Edges_Event event)
79{
80 Eina_List *l;
81 Edgehandler *eh;
82
83 EINA_LIST_FOREACH(handlers, l, eh)
84 {
85 if (eh->event == event)
86 {
87 handlers = eina_list_promote_list(handlers, l);
88 return eh;
89 }
90 }
91 return NULL;
92}
93
94static void
95_handler_call(E_Edges_Event event, int d, double v)
96{
97 Edgehandler *eh = _handler_find(event);
98
99 if (!eh) return;
100 if (!eh->func) return;
101 eh->func(eh->data, d, v);
102}
103
104static Evas_Object *
105_input_obj(Edgeset *es, int x, int y, int w, int h)
106{
107 Evas_Object *o = evas_object_rectangle_add(e_comp->evas);
108 evas_object_color_set(o, 0, 0, 0, 0);
109 evas_object_move(o, x, y);
110 evas_object_resize(o, w, h);
111 evas_object_layer_set(o, 999);
112 evas_object_show(o);
113 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _cb_down, es);
114 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _cb_up, es);
115 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _cb_move, es);
116 return o;
117}
118
119static Edgeset *
120_edgeset_new(E_Zone *zone)
121{
122 Edgeset *es = calloc(1, sizeof(*es));
123
124 if (!es) return NULL;
125 es->zone = zone;
126
127 es->t.obj = _input_obj(es, zone->x, zone->y, zone->w, 8);
128 es->b.obj = _input_obj(es, zone->x, zone->y + zone->h - 8, zone->w, 8);
129 es->l.obj = _input_obj(es, zone->x, zone->y, 8, zone->h);
130 es->r.obj = _input_obj(es, zone->x + zone->w - 8, zone->y, 8, zone->h);
131 return es;
132}
133
134static void
135_edgeset_free(Edgeset *es)
136{
137 evas_object_del(es->t.obj);
138 evas_object_del(es->b.obj);
139 evas_object_del(es->l.obj);
140 evas_object_del(es->r.obj);
141 free(es);
142}
143
144static void
145_cb_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
146{
147 Edgeset *es = data;
148 Evas_Event_Mouse_Down *ev = event;
149 if (ev->button != 1) return;
150 es->down.button = ev->button;
151 es->down.x = ev->canvas.x;
152 es->down.y = ev->canvas.y;
153 es->down.recognized = EINA_FALSE;
154}
155
156static void
157_cb_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
158{
159 Edgeset *es = data;
160 Evas_Event_Mouse_Up *ev = event;
161 if (ev->button != 1) return;
162 es->down.button = 0;
163}
164
165static void
166_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event)
167{
168 Edgeset *es = data;
169 Evas_Event_Mouse_Move *ev = event;
170 int dx, dy, d;
171 double v;
172
173 if (!es->down.button) return;
174 dx = ev->cur.canvas.x - es->down.x;
175 dy = ev->cur.canvas.y - es->down.y;
176 d = 40;
177 if (obj == es->l.obj)
178 {
179 if ((!es->down.recognized) && (dx > d) && (abs(dy) < d))
180 {
181 es->down.recognized = EINA_TRUE;
182 _handler_call(E_EDGES_LEFT_IN_BEGIN, 0, 0);
183 }
184 if (es->down.recognized)
185 {
186 d = (dx - d);
187 if (d < 0) d = 0;
188 if (es->zone->w > 1) v = (double)d / (es->zone->w / 2);
189 else v = 1.0;
190 _handler_call(E_EDGES_LEFT_IN_SLIDE, d, v);
191 }
192 }
193 else if (obj == es->r.obj)
194 {
195 if ((!es->down.recognized) && (-dx > d) && (abs(dy) < d))
196 {
197 es->down.recognized = EINA_TRUE;
198 _handler_call(E_EDGES_RIGHT_IN_BEGIN, 0, 0);
199 }
200 if (es->down.recognized)
201 {
202 d = (-dx - d);
203 if (d < 0) d = 0;
204 if (es->zone->w > 1) v = (double)d / (es->zone->w / 2);
205 else v = 1.0;
206 _handler_call(E_EDGES_RIGHT_IN_SLIDE, d, v);
207 }
208 }
209 else if (obj == es->t.obj)
210 {
211 if ((!es->down.recognized) && (dy > d) && (abs(dx) < d))
212 {
213 es->down.recognized = EINA_TRUE;
214 _handler_call(E_EDGES_TOP_IN_BEGIN, 0, 0);
215 }
216 if (es->down.recognized)
217 {
218 d = (dy - d);
219 if (d < 0) d = 0;
220 if (es->zone->h > 1) v = (double)d / (es->zone->h / 2);
221 else v = 1.0;
222 _handler_call(E_EDGES_TOP_IN_SLIDE, d, v);
223 }
224 }
225 else if (obj == es->b.obj)
226 {
227 if ((!es->down.recognized) && (-dy > d) && (abs(dx) < d))
228 {
229 es->down.recognized = EINA_TRUE;
230 _handler_call(E_EDGES_BOTTOM_IN_BEGIN, 0, 0);
231 }
232 if (es->down.recognized)
233 {
234 d = (-dy - d);
235 if (d < 0) d = 0;
236 if (es->zone->h > 1) v = (double)d / (es->zone->h / 2);
237 else v = 1.0;
238 _handler_call(E_EDGES_BOTTOM_IN_SLIDE, d, v);
239 }
240 }
241}
diff --git a/src/e_edges.h b/src/e_edges.h
new file mode 100644
index 0000000..3f8fad2
--- /dev/null
+++ b/src/e_edges.h
@@ -0,0 +1,20 @@
1#ifndef E_EDGES_H
2# define E_EDGES_H
3
4typedef enum
5{
6 E_EDGES_LEFT_IN_BEGIN,
7 E_EDGES_RIGHT_IN_BEGIN,
8 E_EDGES_TOP_IN_BEGIN,
9 E_EDGES_BOTTOM_IN_BEGIN,
10 E_EDGES_LEFT_IN_SLIDE,
11 E_EDGES_RIGHT_IN_SLIDE,
12 E_EDGES_TOP_IN_SLIDE,
13 E_EDGES_BOTTOM_IN_SLIDE
14} E_Edges_Event;
15
16void e_edges_init(void);
17void e_edges_shutdown(void);
18void e_edges_handler_set(E_Edges_Event event, void (*func) (void *data, int d, double v), void *data);
19
20#endif
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
new file mode 100644
index 0000000..90784a8
--- /dev/null
+++ b/src/e_mod_main.c
@@ -0,0 +1,133 @@
1#include "e_mod_main.h"
2
3EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Contact" };
4
5static void
6_cb_in_left(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
7{
8 // show PREV window in list from urrent focused window on top of current
9 // window but in an inital "off to the right" state in comp
10 Eina_List *clients = (Eina_List *)e_policy_clients_get();
11 E_Client *ec_active = (E_Client *)e_policy_client_active_get();
12 E_Client *ec = NULL;
13 Eina_List *ec_active_l = NULL;
14 if (!ec_active)
15 {
16 if (!clients) return;
17 ec = eina_list_last(clients)->data;
18 }
19 if (!ec)
20 {
21 if (ec_active)
22 ec_active_l = eina_list_data_find_list(clients, ec_active);
23 if ((ec_active_l) && (ec_active_l->prev)) ec = ec_active_l->prev->data;
24 }
25 if ((!ec) && (ec_active))
26 {
27 e_client_iconify(ec_active);
28 return;
29 }
30 if (!ec) return;
31 e_client_activate(ec, EINA_TRUE);
32}
33
34static void
35_cb_in_left_go(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
36{
37 // as v > 0 (and heads towards 1.0) flip/slide new window in unbtil v > 1.0
38 // and once over 1.0 just do transition until end
39}
40
41static void
42_cb_in_right(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
43{
44 // show NEXT window in list from urrent focused window on top of current
45 // window but in an inital "off to the right" state in comp
46 Eina_List *clients = (Eina_List *)e_policy_clients_get();
47 E_Client *ec_active = (E_Client *)e_policy_client_active_get();
48 E_Client *ec = NULL;
49 Eina_List *ec_active_l = NULL;
50 if (!ec_active)
51 {
52 if (!clients) return;
53 ec = clients->data;
54 }
55 if (!ec)
56 {
57 if (ec_active)
58 ec_active_l = eina_list_data_find_list(clients, ec_active);
59 if ((ec_active_l) && (ec_active_l->next)) ec = ec_active_l->next->data;
60 }
61 if ((!ec) && (ec_active))
62 {
63 e_client_iconify(ec_active);
64 return;
65 }
66 if (!ec) return;
67 e_client_activate(ec, EINA_TRUE);
68}
69
70static void
71_cb_in_right_go(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
72{
73 // as v > 0 (and heads towards 1.0) flip/slide new window in unbtil v > 1.0
74 // and once over 1.0 just do transition until end
75}
76
77static void
78_cb_in_top(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
79{
80 // show/populate top controls if not already there and start in offscreen
81 // state and beign slide in anim and place controls at final spot
82}
83
84static void
85_cb_in_top_go(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
86{
87 // for now nothing - but animation would be nice for top controls
88}
89
90static void
91_cb_in_bottom(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
92{
93 // force kbd activation if no kbd
94 e_policy_kbd_override_set(EINA_TRUE);
95 // if kbd already up... hmmm show app menu?
96}
97
98static void
99_cb_in_bottom_go(void *data EINA_UNUSED, int d EINA_UNUSED, double v EINA_UNUSED)
100{
101 // for now nothing - but slide animation is nice
102}
103
104EAPI void *
105e_modapi_init(E_Module *m EINA_UNUSED)
106{
107 e_policy_init();
108 e_edges_init();
109
110 e_edges_handler_set(E_EDGES_LEFT_IN_BEGIN, _cb_in_left, NULL);
111 e_edges_handler_set(E_EDGES_LEFT_IN_SLIDE, _cb_in_left_go, NULL);
112 e_edges_handler_set(E_EDGES_RIGHT_IN_BEGIN, _cb_in_right, NULL);
113 e_edges_handler_set(E_EDGES_RIGHT_IN_SLIDE, _cb_in_right_go, NULL);
114 e_edges_handler_set(E_EDGES_TOP_IN_BEGIN, _cb_in_top, NULL);
115 e_edges_handler_set(E_EDGES_TOP_IN_SLIDE, _cb_in_top_go, NULL);
116 e_edges_handler_set(E_EDGES_BOTTOM_IN_BEGIN, _cb_in_bottom, NULL);
117 e_edges_handler_set(E_EDGES_BOTTOM_IN_SLIDE, _cb_in_bottom_go, NULL);
118 return m;
119}
120
121EAPI int
122e_modapi_shutdown(E_Module *m EINA_UNUSED)
123{
124 e_edges_shutdown();
125 e_policy_shutdown();
126 return 1;
127}
128
129EAPI int
130e_modapi_save(E_Module *m EINA_UNUSED)
131{
132 return 1;
133}
diff --git a/src/e_mod_main.h b/src/e_mod_main.h
new file mode 100644
index 0000000..8e1527a
--- /dev/null
+++ b/src/e_mod_main.h
@@ -0,0 +1,8 @@
1#ifndef E_MOD_MAIN_H
2# define E_MOD_MAIN_H
3
4# include "e.h"
5# include "e_policy.h"
6# include "e_edges.h"
7
8#endif
diff --git a/src/e_policy.c b/src/e_policy.c
new file mode 100644
index 0000000..473ade7
--- /dev/null
+++ b/src/e_policy.c
@@ -0,0 +1,285 @@
1#define E_COMP_X
2
3#include "e_mod_main.h"
4
5static Eina_Bool _cb_event_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
6static Eina_Bool _cb_event_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
7static Eina_Bool _cb_event_focus_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
8static Eina_Bool _cb_event_focus_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
9static void _cb_hook_post_fetch(void *data EINA_UNUSED, E_Client *ec);
10static void _cb_hook_post_assign(void *data EINA_UNUSED, E_Client *ec);
11static void _cb_hook_layout(void);
12
13static Eina_List *hooks = NULL;
14static Eina_List *handlers = NULL;
15
16static Eina_Bool kbd_on = EINA_FALSE;
17static Eina_Bool kbd_override = EINA_FALSE;
18static Eina_List *clients = NULL;
19static E_Client *ec_active = NULL;
20
21#define LADD(l, f) l = eina_list_append(l, f)
22
23void
24e_policy_init(void)
25{
26 LADD(hooks, e_client_hook_add(E_CLIENT_HOOK_EVAL_POST_FETCH,
27 _cb_hook_post_fetch, NULL));
28 LADD(hooks, e_client_hook_add(E_CLIENT_HOOK_EVAL_POST_FRAME_ASSIGN,
29 _cb_hook_post_assign, NULL));
30 LADD(handlers, ecore_event_handler_add(E_EVENT_CLIENT_ADD,
31 _cb_event_add, NULL));
32 LADD(handlers, ecore_event_handler_add(E_EVENT_CLIENT_REMOVE,
33 _cb_event_del, NULL));
34 LADD(handlers, ecore_event_handler_add(E_EVENT_CLIENT_FOCUS_IN,
35 _cb_event_focus_in, NULL));
36 LADD(handlers, ecore_event_handler_add(E_EVENT_CLIENT_FOCUS_OUT,
37 _cb_event_focus_out, NULL));
38 e_client_layout_cb_set((E_Client_Layout_Cb)_cb_hook_layout);
39}
40
41void
42e_policy_shutdown(void)
43{
44 E_Client_Hook *bh;
45 Ecore_Event_Handler *eh;
46
47 EINA_LIST_FREE(hooks, bh) e_client_hook_del(bh);
48 EINA_LIST_FREE(handlers, eh) ecore_event_handler_del(eh);
49 e_client_layout_cb_set(NULL);
50}
51
52void
53e_policy_kbd_override_set(Eina_Bool override)
54{
55 const Eina_List *l;
56 E_Client *ec, *kbd = NULL;;
57
58 if (kbd_override == override) return;
59 kbd_override = override;
60 EINA_LIST_FOREACH(e_comp->clients, l, ec)
61 {
62 if (ec->vkbd.vkbd)
63 {
64 kbd = ec;
65 }
66 }
67 if (kbd)
68 {
69 ec = kbd;
70 e_client_uniconify(ec);
71 evas_object_raise(ec->frame);
72 evas_object_show(ec->frame);
73 }
74}
75
76const Eina_List *
77e_policy_clients_get(void)
78{
79 return clients;
80}
81
82const E_Client *
83e_policy_client_active_get(void)
84{
85 return ec_active;
86}
87
88static Eina_Bool
89_cb_event_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
90{
91 E_Event_Client *ev = event;
92 E_Client *ec = ev->ec;
93
94 if (ec_active) clients = eina_list_append_relative(clients, ec, ec_active);
95 else clients = eina_list_prepend(clients, ec);
96 return ECORE_CALLBACK_PASS_ON;
97}
98
99static Eina_Bool
100_cb_event_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
101{
102 E_Event_Client *ev = event;
103 E_Client *ec = ev->ec;
104
105 clients = eina_list_remove(clients, ec);
106 if (ec_active == ec) ec_active = NULL;
107 return ECORE_CALLBACK_PASS_ON;
108}
109
110static Eina_Bool
111_cb_event_focus_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
112{
113 E_Event_Client *ev = event;
114 E_Client *ec = ev->ec;
115
116 ec_active = ec;
117 return ECORE_CALLBACK_PASS_ON;
118}
119
120static Eina_Bool
121_cb_event_focus_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
122{
123 E_Event_Client *ev = event;
124 E_Client *ec = ev->ec;
125
126 if (ec_active == ec) ec_active = NULL;
127 if (kbd_on) e_policy_kbd_override_set(EINA_FALSE);
128 return ECORE_CALLBACK_PASS_ON;
129}
130
131static void
132_cb_hook_post_fetch(void *data EINA_UNUSED, E_Client *ec)
133{
134 /* NB: for this policy we disable all remembers set on a client */
135 if (ec->remember) e_remember_del(ec->remember);
136 ec->remember = NULL;
137
138 /* set this client to borderless */
139 ec->borderless = 1;
140 EC_CHANGED(ec);
141}
142
143static void
144_cb_hook_post_assign(void *data EINA_UNUSED, E_Client *ec)
145{
146 ec->internal_no_remember = 1;
147
148 /* do not allow client to change these properties */
149 ec->lock_client_size = 1;
150 ec->lock_client_shade = 1;
151 ec->lock_client_maximize = 1;
152 ec->lock_client_location = 1;
153 ec->lock_client_stacking = 1;
154
155 /* do not allow the user to change these properties */
156 ec->lock_user_location = 1;
157 ec->lock_user_size = 1;
158 ec->lock_user_shade = 1;
159
160 /* clear any centered states */
161 /* NB: this is mainly needed for E's main config dialog */
162 ec->e.state.centered = 0;
163
164 /* lock the border type so user/client cannot change */
165 ec->lock_border = 1;
166}
167
168static void
169_cb_hook_layout(void)
170{
171 Eina_List *l;
172 E_Client *ec, *kbd = NULL;;
173 Eina_Bool want_kbd = EINA_FALSE;
174 Eina_Bool have_focused = EINA_FALSE;
175 int kx = 0, ky = 0, kw = 0, kh = 0;
176
177 EINA_LIST_FOREACH(e_comp->clients, l, ec)
178 {
179 if (e_client_util_ignored_get(ec)) continue;
180 if (ec->focused) have_focused = EINA_TRUE;
181#ifndef HAVE_WAYLAND_ONLY
182 if ((ec->focused) &&
183 (ec->vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
184 want_kbd = EINA_TRUE;
185 if (ec->vkbd.vkbd) kbd = ec;
186#endif
187 }
188
189 if ((have_focused) && (kbd_override)) want_kbd = EINA_TRUE;
190
191 if (kbd)
192 {
193 kw = kbd->zone->w;
194 kh = kbd->icccm.min_h;
195 kx = kbd->zone->x;
196 ky = kbd->zone->y + kbd->zone->h - kh;
197 }
198 EINA_LIST_FOREACH(e_comp->clients, l, ec)
199 {
200 int x, y, w, h;
201
202 if (!ec->zone) continue;
203 if (e_client_util_ignored_get(ec)) continue;
204
205 w = ec->zone->w;
206 h = ec->zone->h;
207 x = ec->zone->x;
208 y = ec->zone->y;
209
210 if (ec->vkbd.vkbd)
211 {
212 x = kx; y = ky; w = kw; h = kh;
213 if (want_kbd)
214 {
215 e_client_uniconify(ec);
216 evas_object_raise(ec->frame);
217 evas_object_show(ec->frame);
218 }
219 else
220 {
221 e_client_iconify(ec);
222 }
223 }
224 else if (((ec->netwm.type == E_WINDOW_TYPE_DIALOG) ||
225 (ec->icccm.transient_for != 0)) &&
226 ((ec->icccm.min_w == ec->icccm.max_w) &&
227 (ec->icccm.min_h == ec->icccm.max_h)))
228 {
229 // center dialog at min size
230 w = ec->icccm.min_w;
231 h = ec->icccm.min_h;
232 if (w > (ec->zone->w)) w = ec->zone->w;
233 if (h > (ec->zone->h - kh)) h = (ec->zone->h - kh);
234 x = ec->zone->x + ((ec->zone->w - w) / 2);
235 y = ec->zone->y + ((ec->zone->h - kh - h) / 2);
236 }
237 else
238 {
239#warning X ONLY! SPANK! SPANK! SPANK!!!
240 if (ec->comp_data->illume.conformant.conformant)
241 {
242 if (kbd_on != want_kbd)
243 {
244 if (want_kbd)
245 ecore_x_e_illume_keyboard_geometry_set(e_client_util_win_get(ec),
246 kx, ky, kw, kh);
247 else
248 ecore_x_e_illume_keyboard_geometry_set(e_client_util_win_get(ec),
249 0, 0, 0, 0);
250 }
251 }
252 else
253 {
254 // just make all windows fill the zone...
255 if (want_kbd)
256 {
257 w = ec->zone->w;
258 h = ec->zone->h - kh;
259 x = ec->zone->x;
260 y = ec->zone->y;
261 }
262 }
263 }
264
265 // implement the positioning/sizing
266 if ((ec->x != x) || (ec->y != y))
267 {
268 ec->placed = 1;
269 ec->x = x;
270 ec->y = y;
271 ec->changes.pos = 1;
272 EC_CHANGED(ec);
273 }
274 if ((ec->w != w) || (ec->h != h))
275 {
276 ec->w = w;
277 ec->h = h;
278 e_comp_object_frame_wh_unadjust(ec->frame, ec->w, ec->h, &ec->client.w, &ec->client.h);
279 ec->changes.size = 1;
280 EC_CHANGED(ec);
281 }
282 }
283
284 kbd_on = want_kbd;
285}
diff --git a/src/e_policy.h b/src/e_policy.h
new file mode 100644
index 0000000..9f8a8ed
--- /dev/null
+++ b/src/e_policy.h
@@ -0,0 +1,10 @@
1#ifndef E_POLICY_H
2# define E_POLICY_H
3
4void e_policy_init(void);
5void e_policy_shutdown(void);
6void e_policy_kbd_override_set(Eina_Bool override);
7const Eina_List *e_policy_clients_get(void);
8const E_Client *e_policy_client_active_get(void);
9
10#endif