summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2000-12-08 22:54:42 +0000
committerCarsten Haitzler <raster@rasterman.com>2000-12-08 22:54:42 +0000
commitdfe5d7091ac85950555b83eaa1eea77967192e5d (patch)
tree5d1317616b77690cb3d3acdab6cd57b77644d7ef
e 0.17 ...... :)
SVN revision: 3961
-rw-r--r--AUTHORS1
-rw-r--r--COPYING20
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL14
-rw-r--r--Makefile.am31
-rw-r--r--NEWS0
-rw-r--r--README3
-rwxr-xr-xautogen.sh148
-rw-r--r--config.h.in133
-rw-r--r--configure.in74
-rw-r--r--e.spec66
-rw-r--r--po/ChangeLog0
-rw-r--r--po/POTFILES.in3
-rw-r--r--po/e.pot15
-rw-r--r--src/Makefile.am20
-rw-r--r--src/actions.c748
-rw-r--r--src/border.c1803
-rw-r--r--src/desktops.c508
-rw-r--r--src/e.h337
-rw-r--r--src/icccm.c403
-rw-r--r--src/main.c55
-rw-r--r--src/resist.c129
-rw-r--r--src/util.c10
23 files changed, 4521 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..186ceed
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
The Rasterman <raster@rasterman.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..dee3047
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,20 @@
1Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS)
2
3Permission is hereby granted, free of charge, to any person obtaining a copy
4of this software and associated documentation files (the "Software"), to
5deal in the Software without restriction, including without limitation the
6rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7sell copies of the Software, and to permit persons to whom the Software is
8furnished to do so, subject to the following conditions:
9
10The above copyright notice and this permission notice shall be included in
11all copies of the Software, its documentation and marketing & publicity
12materials, and acknowledgment shall be given in the documentation, materials
13and software packages that this Software was used.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..e507f3c
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,14 @@
1COMPILING and INSTALLING:
2
3If you got a official release tar archive do:
4 ./configure
5
6( otherwise if you got this from enlightenment cvs do: ./autogen.sh )
7
8Then to compile:
9 make
10
11To install (run this as root, or the user who handles installs):
12 make install
13
14NOTE: You MUST make install Etcher for it to run properly.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..c6b6c2a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,31 @@
1## Process this file with automake to produce Makefile.in
2
3SUBDIRS = intl po src
4
5MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
6 config.h.in config.sub configure install-sh \
7 ltconfig ltmain.sh missing mkinstalldirs \
8 stamp-h.in
9
10install-data-local:
11 @$(NORMAL_INSTALL)
12 if test -d $(srcdir)/data; then \
13 $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/data; \
14 for d in $(srcdir)/data/*; do \
15 if test -f $$d; then \
16 $(INSTALL_DATA) $$d $(DESTDIR)$(pkgdatadir)/data; \
17 fi \
18 done \
19 fi
20
21dist-hook:
22 if test -d data; then \
23 mkdir $(distdir)/data; \
24 for d in data/*; do \
25 if test -f $$d; then \
26 cp -p $$d $(distdir)/d; \
27 fi \
28 done \
29 fi
30
31EXTRA_DIST = README AUTHORS COPYING e.spec
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..32dbee6
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
1-------------------------------------------------------------------------------
2 Enlightenment 0.17.0 PRE-RELEASE....
3-------------------------------------------------------------------------------
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..293b797
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,148 @@
1#!/bin/sh
2# Run this to generate all the initial makefiles, etc.
3
4srcdir=`dirname $0`
5PKG_NAME="the package."
6
7DIE=0
8
9(autoconf --version) < /dev/null > /dev/null 2>&1 || {
10 echo
11 echo "**Error**: You must have \`autoconf' installed to."
12 echo "Download the appropriate package for your distribution,"
13 echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
14 DIE=1
15}
16
17(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
18 (libtool --version) < /dev/null > /dev/null 2>&1 || {
19 echo
20 echo "**Error**: You must have \`libtool' installed."
21 echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
22 echo "(or a newer version if it is available)"
23 DIE=1
24 }
25}
26
27grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
28 grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
29 (gettext --version) < /dev/null > /dev/null 2>&1 || {
30 echo
31 echo "**Error**: You must have \`gettext' installed."
32 echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
33 echo "(or a newer version if it is available)"
34 DIE=1
35 }
36}
37
38grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && {
39 grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
40 (gettext --version) < /dev/null > /dev/null 2>&1 || {
41 echo
42 echo "**Error**: You must have \`gettext' installed."
43 echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
44 echo "(or a newer version if it is available)"
45 DIE=1
46 }
47}
48
49(automake --version) < /dev/null > /dev/null 2>&1 || {
50 echo
51 echo "**Error**: You must have \`automake' installed."
52 echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
53 echo "(or a newer version if it is available)"
54 DIE=1
55 NO_AUTOMAKE=yes
56}
57
58
59# if no automake, don't bother testing for aclocal
60test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
61 echo
62 echo "**Error**: Missing \`aclocal'. The version of \`automake'"
63 echo "installed doesn't appear recent enough."
64 echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
65 echo "(or a newer version if it is available)"
66 DIE=1
67}
68
69if test "$DIE" -eq 1; then
70 exit 1
71fi
72
73if test -z "$*"; then
74 echo "**Warning**: I am going to run \`configure' with no arguments."
75 echo "If you wish to pass any to it, please specify them on the"
76 echo \`$0\'" command line."
77 echo
78fi
79
80case $CC in
81xlc )
82 am_opt=--include-deps;;
83esac
84
85for coin in `find $srcdir -name configure.in -print`
86do
87 dr=`dirname $coin`
88 if test -f $dr/NO-AUTO-GEN; then
89 echo skipping $dr -- flagged as no auto-gen
90 else
91 echo processing $dr
92 macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
93 ( cd $dr
94 aclocalinclude="$ACLOCAL_FLAGS"
95 for k in $macrodirs; do
96 if test -d $k; then
97 aclocalinclude="$aclocalinclude -I $k"
98 ##else
99 ## echo "**Warning**: No such directory \`$k'. Ignored."
100 fi
101 done
102 if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then
103 if grep "sed.*POTFILES" configure.in >/dev/null; then
104 : do nothing -- we still have an old unmodified configure.in
105 else
106 echo "Creating $dr/aclocal.m4 ..."
107 test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
108 echo "Running gettextize... Ignore non-fatal messages."
109 echo "no" | gettextize --force --copy
110 echo "Making $dr/aclocal.m4 writable ..."
111 test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
112 fi
113 fi
114 if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then
115 echo "Creating $dr/aclocal.m4 ..."
116 test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
117 echo "Running gettextize... Ignore non-fatal messages."
118 echo "no" | gettextize --force --copy
119 echo "Making $dr/aclocal.m4 writable ..."
120 test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
121 fi
122 if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
123 echo "Running libtoolize..."
124 libtoolize --force --copy
125 fi
126 echo "Running aclocal $aclocalinclude ..."
127 aclocal $aclocalinclude
128 if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
129 echo "Running autoheader..."
130 autoheader
131 fi
132 echo "Running automake --gnu $am_opt ..."
133 automake --add-missing --gnu $am_opt
134 echo "Running autoconf ..."
135 autoconf
136 )
137 fi
138done
139
140#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
141
142if test x$NOCONFIGURE = x; then
143 echo Running $srcdir/configure $conf_flags "$@" ...
144 $srcdir/configure $conf_flags "$@" \
145 && echo Now type \`make\' to compile $PKG_NAME
146else
147 echo Skipping configure process.
148fi
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..3f449a9
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,133 @@
1/* config.h.in. Generated automatically from configure.in by autoheader. */
2
3/* Define if using alloca.c. */
4#undef C_ALLOCA
5
6/* Define to empty if the keyword does not work. */
7#undef const
8
9/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
10 This function is required for alloca.c support on those systems. */
11#undef CRAY_STACKSEG_END
12
13/* Define if you have alloca, as a function or macro. */
14#undef HAVE_ALLOCA
15
16/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
17#undef HAVE_ALLOCA_H
18
19/* Define if you have a working `mmap' system call. */
20#undef HAVE_MMAP
21
22/* Define as __inline if that's what the C compiler calls it. */
23#undef inline
24
25/* Define to `long' if <sys/types.h> doesn't define. */
26#undef off_t
27
28/* Define if you need to in order for stat and other things to work. */
29#undef _POSIX_SOURCE
30
31/* Define to `unsigned' if <sys/types.h> doesn't define. */
32#undef size_t
33
34/* If using the C implementation of alloca, define if you know the
35 direction of stack growth for your system; otherwise it will be
36 automatically deduced at run-time.
37 STACK_DIRECTION > 0 => grows toward higher addresses
38 STACK_DIRECTION < 0 => grows toward lower addresses
39 STACK_DIRECTION = 0 => direction of growth unknown
40 */
41#undef STACK_DIRECTION
42
43/* Define if you have the ANSI C header files. */
44#undef STDC_HEADERS
45
46#undef ENABLE_NLS
47#undef HAVE_CATGETS
48#undef HAVE_GETTEXT
49#undef HAVE_LC_MESSAGES
50#undef HAVE_STPCPY
51#undef HAVE_LIBSM
52#undef PACKAGE_LOCALE_DIR
53#undef PACKAGE_DATA_DIR
54#undef PACKAGE_SOURCE_DIR
55
56/* Define if you have the __argz_count function. */
57#undef HAVE___ARGZ_COUNT
58
59/* Define if you have the __argz_next function. */
60#undef HAVE___ARGZ_NEXT
61
62/* Define if you have the __argz_stringify function. */
63#undef HAVE___ARGZ_STRINGIFY
64
65/* Define if you have the dcgettext function. */
66#undef HAVE_DCGETTEXT
67
68/* Define if you have the getcwd function. */
69#undef HAVE_GETCWD
70
71/* Define if you have the getpagesize function. */
72#undef HAVE_GETPAGESIZE
73
74/* Define if you have the munmap function. */
75#undef HAVE_MUNMAP
76
77/* Define if you have the putenv function. */
78#undef HAVE_PUTENV
79
80/* Define if you have the setenv function. */
81#undef HAVE_SETENV
82
83/* Define if you have the setlocale function. */
84#undef HAVE_SETLOCALE
85
86/* Define if you have the stpcpy function. */
87#undef HAVE_STPCPY
88
89/* Define if you have the strcasecmp function. */
90#undef HAVE_STRCASECMP
91
92/* Define if you have the strchr function. */
93#undef HAVE_STRCHR
94
95/* Define if you have the strdup function. */
96#undef HAVE_STRDUP
97
98/* Define if you have the <argz.h> header file. */
99#undef HAVE_ARGZ_H
100
101/* Define if you have the <limits.h> header file. */
102#undef HAVE_LIMITS_H
103
104/* Define if you have the <locale.h> header file. */
105#undef HAVE_LOCALE_H
106
107/* Define if you have the <malloc.h> header file. */
108#undef HAVE_MALLOC_H
109
110/* Define if you have the <nl_types.h> header file. */
111#undef HAVE_NL_TYPES_H
112
113/* Define if you have the <string.h> header file. */
114#undef HAVE_STRING_H
115
116/* Define if you have the <sys/param.h> header file. */
117#undef HAVE_SYS_PARAM_H
118
119/* Define if you have the <unistd.h> header file. */
120#undef HAVE_UNISTD_H
121
122/* Define if you have the i library (-li). */
123#undef HAVE_LIBI
124
125/* Name of package */
126#undef PACKAGE
127
128/* Version number of package */
129#undef VERSION
130
131/* Define if using the dmalloc debugging malloc package */
132#undef WITH_DMALLOC
133
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..b6a7ac1
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,74 @@
1dnl Process this file with autoconf to produce a configure script.
2
3AC_INIT(configure.in)
4AM_INIT_AUTOMAKE(enlightenment, 0.17.0)
5AM_CONFIG_HEADER(config.h)
6
7AC_ISC_POSIX
8AC_PROG_CC
9AM_PROG_CC_STDC
10AC_HEADER_STDC
11
12AM_WITH_DMALLOC
13
14dnl Add the languages which your application supports here.
15ALL_LINGUAS=""
16AM_GNU_GETTEXT
17
18dnl Set PACKAGE_LOCALE_DIR in config.h.
19if test "x${prefix}" = "xNONE"; then
20 AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale")
21else
22 AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${prefix}/${DATADIRNAME}/locale")
23fi
24
25dnl Set PACKAGE_DATA_DIR in config.h.
26if test "x${datadir}" = 'x${prefix}/share'; then
27 if test "x${prefix}" = "xNONE"; then
28 AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}")
29 else
30 AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}")
31 fi
32else
33 AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}")
34fi
35
36dnl Set PACKAGE_SOURCE_DIR in config.h.
37packagesrcdir=`cd $srcdir && pwd`
38AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}")
39
40dnl Use -Wall if we have gcc.
41changequote(,)dnl
42if test "x$GCC" = "xyes"; then
43 case " $CFLAGS " in
44 *[\ \ ]-Wall[\ \ ]*) ;;
45 *) CFLAGS="$CFLAGS -Wall" ;;
46 esac
47fi
48changequote([,])dnl
49
50evas_cflags=`evas-config --cflags`
51evas_libs=`evas-config --libs`
52edb_cflags=`edb-config --cflags`
53edb_libs=`edb-config --libs`
54ebits_cflags=`ebits-config --cflags`
55ebits_libs=`ebits-config --libs`
56ecore_cflags=`ecore-config --cflags`
57ecore_libs=`ecore-config --libs`
58
59AC_SUBST(evas_cflags)
60AC_SUBST(evas_libs)
61AC_SUBST(edb_cflags)
62AC_SUBST(edb_libs)
63AC_SUBST(ebits_cflags)
64AC_SUBST(ebits_libs)
65AC_SUBST(ecore_cflags)
66AC_SUBST(ecore_libs)
67
68AC_OUTPUT([
69Makefile
70src/Makefile
71intl/Makefile
72po/Makefile.in
73])
74
diff --git a/e.spec b/e.spec
new file mode 100644
index 0000000..7b168f1
--- /dev/null
+++ b/e.spec
@@ -0,0 +1,66 @@
1# Note that this is NOT a relocatable package
2%define ver 1.0
3%define rel 1
4%define prefix /usr/local
5
6Summary: Enlightenment DR0.17's new "bit" editor
7Name: etcher
8Version: %ver
9Release: %rel
10Copyright: BSD
11Group: X11/Libraries
12Source: ftp://ftp.enlightenment.org/pub/enlightenment/etcher-%{ver}.tar.gz
13BuildRoot: /var/tmp/etcher-root
14Packager: Term <kempler@utdallas.edu>
15URL: http://www.enlightenment.org/
16Requires: evas >= 0.0.1
17Requires: edb >= 1.0.0
18Requires: imlib2 >= 1.0.0
19
20Docdir: %{prefix}/doc
21
22%description
23Etcher is a new application devised to assist would-be theme developers in
24designin "bits", that is, window borders, icons, whatever, for
25Enlightenment. Since Enlightenment DR0.17 uses drag-and-drop instead of
26texual configuration files, this application will become instrumental for
27themeing under the new Enlightenment version.
28
29%prep
30%setup
31
32%build
33./configure --prefix=%prefix
34
35if [ "$SMP" != "" ]; then
36 (make "MAKE=make -k -j $SMP"; exit 0)
37 make
38else
39 make
40fi
41###########################################################################
42
43%install
44rm -rf $RPM_BUILD_ROOT
45make prefix=$RPM_BUILD_ROOT%{prefix} install
46
47%clean
48rm -rf $RPM_BUILD_ROOT
49
50%post
51
52%postun
53
54%files
55%defattr(-,root,root)
56%doc README COPYING ChangeLog
57%attr(755,root,root) %{prefix}/bin/etcher
58%{prefix}/share/etcher/*
59
60%doc AUTHORS
61%doc COPYING
62%doc README
63
64%changelog
65* Mon Aug 28 2000 Lyle Kempler <kempler@utdallas.edu>
66- Created spec file
diff --git a/po/ChangeLog b/po/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/po/ChangeLog
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..a0b3c55
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,3 @@
1# List of source files containing translatable strings.
2
3src/main.c
diff --git a/po/e.pot b/po/e.pot
new file mode 100644
index 0000000..a3edd95
--- /dev/null
+++ b/po/e.pot
@@ -0,0 +1,15 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR Free Software Foundation, Inc.
3# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4#
5#, fuzzy
6msgid ""
7msgstr ""
8"Project-Id-Version: PACKAGE VERSION\n"
9"POT-Creation-Date: 2000-11-02 16:32-0800\n"
10"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12"Language-Team: LANGUAGE <LL@li.org>\n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=CHARSET\n"
15"Content-Transfer-Encoding: ENCODING\n"
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..eb7caf2
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,20 @@
1## Process this file with automake to produce Makefile.in
2
3INCLUDES = \
4 -I$(top_srcdir)/intl \
5 @evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@
6
7bin_PROGRAMS = e
8
9e_SOURCES = \
10actions.c \
11border.c \
12desktops.c \
13icccm.c \
14main.c \
15resist.c \
16util.c \
17e.h
18
19e_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ -lecore -lm $(INTLLIBS)
20
diff --git a/src/actions.c b/src/actions.c
new file mode 100644
index 0000000..1679c2f
--- /dev/null
+++ b/src/actions.c
@@ -0,0 +1,748 @@
1#include "e.h"
2
3static Evas_List action_protos = NULL;
4static Evas_List current_actions = NULL;
5
6static void _e_action_find(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o);
7static void _e_action_free(E_Action *a);
8
9static void e_act_move_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
10static void e_act_move_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
11static void e_act_move_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy);
12
13static void e_act_resize_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
14static void e_act_resize_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
15static void e_act_resize_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy);
16
17static void e_act_resize_h_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
18static void e_act_resize_h_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
19static void e_act_resize_h_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy);
20
21static void e_act_resize_v_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
22static void e_act_resize_v_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
23static void e_act_resize_v_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy);
24
25static void e_act_close_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
26
27static void e_act_kill_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
28
29static void e_act_shade_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
30
31static void e_act_raise_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
32
33static void e_act_lower_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
34
35static void e_act_raise_lower_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
36
37static void e_act_exec_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
38
39static void e_act_menu_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
40
41static void e_act_exit_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
42
43static void e_act_restart_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
44
45static void e_act_stick_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
46
47static void e_act_sound_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
48
49static void e_act_iconify_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
50
51static void e_act_max_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
52
53static void e_act_snap_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
54
55static void e_act_zoom_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
56
57static void
58_e_action_find(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o)
59{
60 char *actions_db = "./actions.db";
61 E_DB_File *db;
62 int i, num;
63 char *a_name = NULL;
64 char *a_action = NULL;
65 char *a_params = NULL;
66 int a_event = 0;
67 int a_button = 0;
68 char *a_key = NULL;
69 int a_modifiers = 0;
70 E_Action *a;
71
72 db = e_db_open_read(actions_db);
73 if (!db) return;
74 if (!e_db_int_get(db, "/actions/count", &num)) goto error;
75 for (i = 0; i < num; i++)
76 {
77 char buf[4096];
78 Evas_List l;
79 a = NULL;
80
81 a = NULL;
82 sprintf(buf, "/actions/%i/name", i);
83 a_name = e_db_str_get(db, buf);
84 sprintf(buf, "/actions/%i/action", i);
85 a_action = e_db_str_get(db, buf);
86 sprintf(buf, "/actions/%i/params", i);
87 a_params = e_db_str_get(db, buf);
88 sprintf(buf, "/actions/%i/event", i);
89 e_db_int_get(db, buf, &a_event);
90 sprintf(buf, "/actions/%i/button", i);
91 e_db_int_get(db, buf, &a_button);
92 sprintf(buf, "/actions/%i/key", i);
93 a_key = e_db_str_get(db, buf);
94 sprintf(buf, "/actions/%i/modifiers", i);
95 e_db_int_get(db, buf, &a_modifiers);
96
97 if (act != a_event) goto next;
98 if (!((a_name) &&
99 (action) &&
100 (!strcmp(a_name, action)))) goto next;
101 if ((act >= ACT_MOUSE_CLICK) &&
102 (act <= ACT_MOUSE_CLICKED) &&
103 (!((a_button == -1) ||
104 (a_button == button)))) goto next;
105 if ((act >= ACT_KEY_DOWN) &&
106 (act <= ACT_KEY_UP) &&
107 (!((a_key) && (key) &&
108 (!strcmp(a_key, key))))) goto next;
109 if ((act >= ACT_MOUSE_CLICK) &&
110 (act <= ACT_KEY_UP) &&
111 (!((a_modifiers == -1) ||
112 (a_modifiers == (int)mods)))) goto next;
113 for (l = action_protos; l; l = l->next)
114 {
115 E_Action_Proto *ap;
116
117 ap = l->data;
118 if (!strcmp(ap->action, a_action))
119 {
120
121 a = NEW(E_Action, 1);
122 ZERO(a, E_Action, 1);
123
124 OBJ_INIT(a, _e_action_free);
125
126 a->name = a_name;
127 a->action = a_action;
128 a->params = a_params;
129 a->event = a_event;
130 a->button = a_button;
131 a->key = a_key;
132 a->modifiers = a_modifiers;
133 a->action_proto = ap;
134 a->object = o;
135 a->started = 0;
136 current_actions = evas_list_append(current_actions, a);
137 }
138 }
139 next:
140 if (!a)
141 {
142 IF_FREE(a_name);
143 IF_FREE(a_action);
144 IF_FREE(a_params);
145 IF_FREE(a_key);
146 }
147 }
148 error:
149 e_db_close(db);
150}
151
152static void
153_e_action_free(E_Action *a)
154{
155 IF_FREE(a->name);
156 IF_FREE(a->action);
157 IF_FREE(a->params);
158 IF_FREE(a->key);
159 FREE(a);
160}
161
162void
163e_action_start(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry)
164{
165 Evas_List l;
166
167 _e_action_find(action, act, button, key, mods, o);
168 again:
169 for (l = current_actions; l; l = l->next)
170 {
171 E_Action *a;
172
173 a = l->data;
174 if (!a->started)
175 {
176 if (a->action_proto->func_stop)
177 a->started = 1;
178 if (a->action_proto->func_start)
179 {
180 E_Object *obj;
181
182 if (a->object)
183 {
184 obj = a->object;
185 if (a->started)
186 OBJ_REF(obj);
187 }
188 a->action_proto->func_start(a->object, a, data, x, y, rx, ry);
189 }
190 }
191 if (!a->started)
192 {
193 current_actions = evas_list_remove(current_actions, a);
194 OBJ_DO_FREE(a);
195 goto again;
196 }
197 }
198}
199
200void
201e_action_stop(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry)
202{
203 Evas_List l;
204
205 again:
206 for (l = current_actions; l; l = l->next)
207 {
208 E_Action *a;
209
210 a = l->data;
211 if ((a->started) && (a->action_proto->func_stop))
212 {
213 int ok = 0;
214
215 if ((a->event == ACT_MOUSE_IN) &&
216 (act == ACT_MOUSE_OUT))
217 ok = 1;
218 if ((a->event == ACT_MOUSE_OUT) &&
219 (act == ACT_MOUSE_IN))
220 ok = 1;
221 if ((a->event >= ACT_MOUSE_CLICK) &&
222 (a->event <= ACT_MOUSE_TRIPLE) &&
223 (act >= ACT_MOUSE_UP) &&
224 (act <= ACT_MOUSE_CLICKED) &&
225 (a->button == button))
226 ok = 1;
227 if ((a->event == ACT_MOUSE_MOVE) &&
228 ((act == ACT_MOUSE_OUT) ||
229 (act == ACT_MOUSE_IN) ||
230 ((act >= ACT_MOUSE_CLICK) &&
231 (act <= ACT_MOUSE_TRIPLE)) ||
232 (act >= ACT_MOUSE_UP)))
233 ok = 1;
234 if ((a->event == ACT_KEY_DOWN) &&
235 (act == ACT_KEY_UP) &&
236 (key) && (a->key) && (!strcmp(key, a->key)))
237 ok = 1;
238 if ((a->event == ACT_KEY_UP) &&
239 (act == ACT_KEY_DOWN))
240 ok = 1;
241 if (ok)
242 {
243 E_Object *obj;
244
245 if (a->object)
246 {
247 obj = a->object;
248 OBJ_UNREF(obj);
249 }
250 a->action_proto->func_stop(a->object, a, data, x, y, rx, ry);
251 a->started = 0;
252 }
253 }
254 if (!a->started)
255 {
256 current_actions = evas_list_remove(current_actions, a);
257 OBJ_DO_FREE(a);
258 goto again;
259 }
260 }
261}
262
263void
264e_action_go(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry, int dx, int dy)
265{
266 Evas_List l;
267
268 for (l = current_actions; l; l = l->next)
269 {
270 E_Action *a;
271
272 a = l->data;
273 if ((a->started) && (a->action_proto->func_go))
274 a->action_proto->func_go(a->object, a, data, x, y, rx, ry, dx, dy);
275 }
276}
277
278void
279e_action_stop_by_object(void *o, void *data, int x, int y, int rx, int ry)
280{
281 Evas_List l;
282
283 again:
284 for (l = current_actions; l; l = l->next)
285 {
286 E_Action *a;
287
288 a = l->data;
289 if ((a->started) && (o == a->object))
290 {
291 E_Object *obj;
292
293 if (a->object)
294 {
295 obj = a->object;
296 OBJ_UNREF(obj);
297 }
298 if (a->action_proto->func_stop)
299 a->action_proto->func_stop(a->object, a, data, x, y, rx, ry);
300 a->started = 0;
301 current_actions = evas_list_remove(current_actions, a);
302 OBJ_DO_FREE(a);
303 goto again;
304 }
305 }
306}
307
308void
309e_action_add_proto(char *action,
310 void (*func_start) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry),
311 void (*func_stop) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry),
312 void (*func_go) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy))
313{
314 E_Action_Proto *ap;
315
316 ap = NEW(E_Action_Proto, 1);
317
318 OBJ_INIT(ap, NULL);
319
320 ap->action = strdup(action);
321 ap->func_start = func_start;
322 ap->func_stop = func_stop;
323 ap->func_go = func_go;
324 action_protos = evas_list_append(action_protos, ap);
325}
326
327void
328e_actions_init(void)
329{
330 e_action_add_proto("Window_Move", e_act_move_start, e_act_move_stop, e_act_move_go);
331 e_action_add_proto("Window_Resize", e_act_resize_start, e_act_resize_stop, e_act_resize_go);
332 e_action_add_proto("Window_Resize_Horizontal", e_act_resize_h_start, e_act_resize_h_stop, e_act_resize_h_go);
333 e_action_add_proto("Window_Resize_Vertical", e_act_resize_v_start, e_act_resize_v_stop, e_act_resize_v_go);
334 e_action_add_proto("Window_Close", e_act_close_start, NULL, NULL);
335 e_action_add_proto("Window_Kill", e_act_kill_start, NULL, NULL);
336 e_action_add_proto("Window_Shade", e_act_shade_start, NULL, NULL);
337 e_action_add_proto("Window_Raise", e_act_raise_start, NULL, NULL);
338 e_action_add_proto("Window_Lower", e_act_lower_start, NULL, NULL);
339 e_action_add_proto("Window_Raise_Lower", e_act_raise_lower_start, NULL, NULL);
340 e_action_add_proto("Execute", e_act_exec_start, NULL, NULL);
341 e_action_add_proto("Menu", e_act_menu_start, NULL, NULL);
342 e_action_add_proto("Exit", e_act_exit_start, NULL, NULL);
343 e_action_add_proto("Restart", e_act_restart_start, NULL, NULL);
344 e_action_add_proto("Window_Stick", e_act_stick_start, NULL, NULL);
345 e_action_add_proto("Sound", e_act_sound_start, NULL, NULL);
346 e_action_add_proto("Window_Iconify", e_act_iconify_start, NULL, NULL);
347 e_action_add_proto("Window_Max_Size", e_act_max_start, NULL, NULL);
348 e_action_add_proto("Winodw_Snap", e_act_snap_start, NULL, NULL);
349 e_action_add_proto("Window_Zoom", e_act_zoom_start, NULL, NULL);
350}
351
352
353
354
355
356
357
358
359static void
360e_act_move_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
361{
362 E_Border *b;
363
364 b = o;
365 b->mode.move = 1;
366 b->current.requested.dx = 0;
367 b->current.requested.dy = 0;
368 b->previous.requested.dx = 0;
369 b->previous.requested.dy = 0;
370}
371
372static void
373e_act_move_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
374{
375 E_Border *b;
376
377 b = o;
378 b->current.requested.x = b->current.x;
379 b->current.requested.y = b->current.y;
380 b->changed = 1;
381 b->mode.move = 0;
382 b->current.requested.dx = 0;
383 b->current.requested.dy = 0;
384 b->previous.requested.dx = 0;
385 b->previous.requested.dy = 0;
386 e_border_adjust_limits(b);
387}
388
389static void
390e_act_move_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy)
391{
392 E_Border *b;
393
394 b = o;
395 b->current.requested.x += dx;
396 b->current.requested.y += dy;
397 if (dx != 0) b->current.requested.dx = dx;
398 if (dy != 0) b->current.requested.dy = dy;
399 b->changed = 1;
400 e_border_adjust_limits(b);
401}
402
403
404static void
405e_act_resize_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
406{
407 E_Border *b;
408
409 b = o;
410 /* 0 | 1 */
411 /* --+-- */
412 /* 2 | 3 */
413 if (x > (b->current.w / 2))
414 {
415 if (y > (b->current.h / 2))
416 {
417 b->mode.resize = 3;
418 SET_BORDER_GRAVITY(b, NorthWestGravity);
419 }
420 else
421 {
422 b->mode.resize = 1;
423 SET_BORDER_GRAVITY(b, SouthWestGravity);
424 }
425 }
426 else
427 {
428 if (y > (b->current.h / 2))
429 {
430 b->mode.resize = 2;
431 SET_BORDER_GRAVITY(b, NorthEastGravity);
432 }
433 else
434 {
435 b->mode.resize = 0;
436 SET_BORDER_GRAVITY(b, SouthEastGravity);
437 }
438 }
439}
440
441static void
442e_act_resize_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
443{
444 E_Border *b;
445
446 b = o;
447 b->current.requested.x = b->current.x;
448 b->current.requested.y = b->current.y;
449 b->current.requested.w = b->current.w;
450 b->current.requested.h = b->current.h;
451 b->mode.resize = 0;
452 b->changed = 1;
453 e_border_adjust_limits(b);
454}
455
456static void
457e_act_resize_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy)
458{
459 E_Border *b;
460
461 b = o;
462 if (b->mode.resize == 0)
463 {
464 b->current.requested.w -= dx;
465 b->current.requested.h -= dy;
466 b->current.requested.x += dx;
467 b->current.requested.y += dy;
468 }
469 else if (b->mode.resize == 1)
470 {
471 b->current.requested.w += dx;
472 b->current.requested.h -= dy;
473 b->current.requested.y += dy;
474 }
475 else if (b->mode.resize == 2)
476 {
477 b->current.requested.w -= dx;
478 b->current.requested.h += dy;
479 b->current.requested.x += dx;
480 }
481 else if (b->mode.resize == 3)
482 {
483 b->current.requested.w += dx;
484 b->current.requested.h += dy;
485 }
486 b->changed = 1;
487 e_border_adjust_limits(b);
488}
489
490
491static void
492e_act_resize_h_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
493{
494 E_Border *b;
495
496 b = o;
497 /* 4 | 5 */
498 if (x > (b->current.w / 2))
499 {
500 b->mode.resize = 5;
501 SET_BORDER_GRAVITY(b, NorthWestGravity);
502 }
503 else
504 {
505 b->mode.resize = 4;
506 SET_BORDER_GRAVITY(b, NorthEastGravity);
507 }
508}
509
510static void
511e_act_resize_h_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
512{
513 E_Border *b;
514
515 b = o;
516 b->current.requested.x = b->current.x;
517 b->current.requested.y = b->current.y;
518 b->current.requested.w = b->current.w;
519 b->current.requested.h = b->current.h;
520 b->mode.resize = 0;
521 b->changed = 1;
522 e_border_adjust_limits(b);
523}
524
525static void
526e_act_resize_h_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy)
527{
528 E_Border *b;
529
530 b = o;
531 if (b->mode.resize == 4)
532 {
533 b->current.requested.w -= dx;
534 b->current.requested.x += dx;
535 }
536 else if (b->mode.resize == 5)
537 {
538 b->current.requested.w += dx;
539 }
540 b->changed = 1;
541 e_border_adjust_limits(b);
542}
543
544
545static void
546e_act_resize_v_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
547{
548 E_Border *b;
549
550 b = o;
551 /* 6 */
552 /* - */
553 /* 7 */
554 if (y > (b->current.h / 2))
555 {
556 b->mode.resize = 7;
557 SET_BORDER_GRAVITY(b, NorthWestGravity);
558 }
559 else
560 {
561 b->mode.resize = 6;
562 SET_BORDER_GRAVITY(b, SouthWestGravity);
563 }
564}
565
566static void
567e_act_resize_v_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
568{
569 E_Border *b;
570
571 b = o;
572 b->current.requested.x = b->current.x;
573 b->current.requested.y = b->current.y;
574 b->current.requested.w = b->current.w;
575 b->current.requested.h = b->current.h;
576 b->mode.resize = 0;
577 e_border_adjust_limits(b);
578 b->changed = 1;
579}
580
581static void
582e_act_resize_v_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy)
583{
584 E_Border *b;
585
586 b = o;
587 if (b->mode.resize == 6)
588 {
589 b->current.requested.h -= dy;
590 b->current.requested.y += dy;
591 }
592 else if (b->mode.resize == 7)
593 {
594 b->current.requested.h += dy;
595 }
596 e_border_adjust_limits(b);
597 b->changed = 1;
598}
599
600
601static void
602e_act_close_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
603{
604 E_Border *b;
605
606 b = o;
607 if (b->win.client) e_icccm_delete(b->win.client);
608}
609
610
611static void
612e_act_kill_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
613{
614 E_Border *b;
615
616 b = o;
617 if (b->win.client) e_window_kill_client(b->win.client);
618}
619
620
621static void
622e_act_shade_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
623{
624 E_Border *b;
625
626 b = o;
627}
628
629
630static void
631e_act_raise_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
632{
633 E_Border *b;
634
635 b = o;
636 e_border_raise(b);
637}
638
639
640static void
641e_act_lower_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
642{
643 E_Border *b;
644
645 b = o;
646 e_border_lower(b);
647}
648
649
650static void
651e_act_raise_lower_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
652{
653 E_Border *b;
654
655 b = o;
656}
657
658
659static void
660e_act_exec_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
661{
662 E_Border *b;
663
664 b = o;
665}
666
667
668static void
669e_act_menu_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
670{
671 E_Border *b;
672
673 b = o;
674}
675
676
677static void
678e_act_exit_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
679{
680 E_Border *b;
681
682 b = o;
683 exit(0);
684}
685
686
687static void
688e_act_restart_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
689{
690 E_Border *b;
691
692 b = o;
693}
694
695
696static void
697e_act_stick_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
698{
699 E_Border *b;
700
701 b = o;
702}
703
704
705static void
706e_act_sound_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
707{
708 E_Border *b;
709
710 b = o;
711}
712
713
714static void
715e_act_iconify_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
716{
717 E_Border *b;
718
719 b = o;
720}
721
722
723static void
724e_act_max_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
725{
726 E_Border *b;
727
728 b = o;
729}
730
731
732static void
733e_act_snap_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
734{
735 E_Border *b;
736
737 b = o;
738}
739
740
741static void
742e_act_zoom_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
743{
744 E_Border *b;
745
746 b = o;
747}
748
diff --git a/src/border.c b/src/border.c
new file mode 100644
index 0000000..dcb645e
--- /dev/null
+++ b/src/border.c
@@ -0,0 +1,1803 @@
1#include "e.h"
2
3/* Window border rendering, querying, setting & modification code */
4
5/* globals local to window borders */
6static Evas_List evases = NULL;
7static Evas_List borders = NULL;
8
9static int mouse_x, mouse_y, mouse_win_x, mouse_win_y;
10static int mouse_buttons = 0;
11
12static int border_mouse_x = 0;
13static int border_mouse_y = 0;
14static int border_mouse_buttons = 0;
15
16static Eevent *current_ev = NULL;
17
18static void e_idle(void *data);
19static void e_map_request(Eevent * ev);
20static void e_configure_request(Eevent * ev);
21static void e_property(Eevent * ev);
22static void e_unmap(Eevent * ev);
23static void e_destroy(Eevent * ev);
24static void e_circulate_request(Eevent * ev);
25static void e_reparent(Eevent * ev);
26static void e_shape(Eevent * ev);
27static void e_focus_in(Eevent * ev);
28static void e_focus_out(Eevent * ev);
29static void e_colormap(Eevent * ev);
30static void e_mouse_down(Eevent * ev);
31static void e_mouse_up(Eevent * ev);
32static void e_mouse_in(Eevent * ev);
33static void e_mouse_out(Eevent * ev);
34static void e_window_expose(Eevent * ev);
35
36static void e_cb_mouse_in(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
37static void e_cb_mouse_out(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
38static void e_cb_mouse_down(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
39static void e_cb_mouse_up(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
40static void e_cb_mouse_move(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
41
42static void e_cb_border_mouse_in(E_Border *b, Eevent *e);
43static void e_cb_border_mouse_out(E_Border *b, Eevent *e);
44static void e_cb_border_mouse_down(E_Border *b, Eevent *e);
45static void e_cb_border_mouse_up(E_Border *b, Eevent *e);
46static void e_cb_border_mouse_move(E_Border *b, Eevent *e);
47static void e_cb_border_move_resize(E_Border *b);
48static void e_cb_border_visibility(E_Border *b);
49
50static void e_border_poll(int val, void *data);
51
52/* what to dowhen we're idle */
53static void
54e_idle(void *data)
55{
56 Evas_List l;
57
58 for (l = borders; l; l = l->next)
59 {
60 E_Border *b;
61
62 b = l->data;
63 e_border_update(b);
64 }
65 for (l = evases; l; l = l->next)
66 {
67 Evas evas;
68
69 evas = l->data;
70 evas_render(evas);
71 }
72 e_db_runtime_flush();
73}
74
75/* */
76static void
77e_map_request(Eevent * ev)
78{
79 Ev_Window_Map_Request *e;
80
81 current_ev = ev;
82 e = ev->event;
83 {
84 E_Border *b;
85
86 printf("map request %x\n", e->win);
87 b = e_border_find_by_window(e->win);
88 if (!b)
89 {
90 b = e_border_adopt(e->win, 0);
91 }
92 }
93 current_ev = NULL;
94}
95
96/* */
97static void
98e_configure_request(Eevent * ev)
99{
100 Ev_Window_Configure_Request *e;
101
102 current_ev = ev;
103 e = ev->event;
104 {
105 Evas_List l;
106 E_Border *b;
107
108 b = e_border_find_by_window(e->win);
109 if (b)
110 {
111 int pl, pr, pt, pb;
112
113 pl = pr = pt = pb = 0;
114 if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
115 if (e->mask & EV_VALUE_X)
116 {
117 printf("request move to %i %i\n", e->x, e->y);
118 }
119 if (e->mask & EV_VALUE_X)
120 b->current.requested.x = e->x;
121 if (e->mask & EV_VALUE_Y)
122 b->current.requested.y = e->y;
123 if (e->mask & EV_VALUE_W)
124 b->current.requested.w = e->w + pl + pr;
125 if (e->mask & EV_VALUE_H)
126 b->current.requested.h = e->h + pt + pb;
127 if ((e->mask & EV_VALUE_SIBLING) && (e->mask & EV_VALUE_STACKING))
128 {
129 E_Border *b_rel;
130
131 b_rel = e_border_find_by_window(e->stack_win);
132 if (b_rel)
133 {
134 if (e->detail == EV_STACK_ABOVE) e_border_raise_above(b, b_rel);
135 else if (e->detail == EV_STACK_BELOW) e_border_lower_below(b, b_rel);
136 /* FIXME: need to handle & fix
137 * EV_STACK_TOP_IF
138 * EV_STACK_BOTTOM_IF
139 * EV_STACK_OPPOSITE
140 */
141 else if (e->detail == EV_STACK_TOP_IF) e_border_raise(b);
142 else if (e->detail == EV_STACK_BOTTOM_IF) e_border_lower(b);
143 }
144 }
145 else if (e->mask & EV_VALUE_STACKING)
146 {
147 if (e->detail == EV_STACK_ABOVE) e_border_raise(b);
148 else if (e->detail == EV_STACK_BELOW) e_border_lower(b);
149 /* FIXME: need to handle & fix
150 * EV_STACK_TOP_IF
151 * EV_STACK_BOTTOM_IF
152 * EV_STACK_OPPOSITE
153 */
154 else if (e->detail == EV_STACK_TOP_IF) e_border_raise(b);
155 else if (e->detail == EV_STACK_BOTTOM_IF) e_border_lower(b);
156 }
157 b->changed = 1;
158 e_border_adjust_limits(b);
159 }
160 else
161 {
162 if ((e->mask & EV_VALUE_X) && (e->mask & EV_VALUE_W))
163 e_window_move_resize(e->win, e->x, e->y, e->w, e->h);
164 else if ((e->mask & EV_VALUE_W))
165 e_window_resize(e->win, e->w, e->h);
166 else if ((e->mask & EV_VALUE_X))
167 e_window_move(e->win, e->x, e->y);
168 }
169 }
170 current_ev = NULL;
171}
172
173/* */
174static void
175e_property(Eevent * ev)
176{
177 Ev_Window_Property *e;
178
179 current_ev = ev;
180 e = ev->event;
181 {
182 Evas_List l;
183 E_Border *b;
184
185 b = e_border_find_by_window(e->win);
186 if (b)
187 {
188 }
189 }
190 current_ev = NULL;
191}
192
193/* */
194static void
195e_unmap(Eevent * ev)
196{
197 Ev_Window_Unmap *e;
198
199 current_ev = ev;
200 e = ev->event;
201 {
202 Evas_List l;
203 E_Border *b;
204
205 b = e_border_find_by_window(e->win);
206 if (b)
207 {
208 if (b->win.client == e->win)
209 {
210 if (b->ignore_unmap > 0) b->ignore_unmap--;
211 else
212 {
213 printf("unmap %x\n", e->win);
214 e_action_stop_by_object(b, NULL,
215 mouse_win_x, mouse_win_y,
216 border_mouse_x, border_mouse_y);
217 OBJ_UNREF(b);
218 OBJ_IF_FREE(b)
219 {
220 e_window_reparent(e->win, 0, 0, 0);
221 e_icccm_release(e->win);
222 OBJ_FREE(b);
223 }
224 }
225 }
226 }
227 }
228 current_ev = NULL;
229}
230
231/* */
232static void
233e_destroy(Eevent * ev)
234{
235 Ev_Window_Destroy *e;
236
237 current_ev = ev;
238 e = ev->event;
239 {
240 Evas_List l;
241 E_Border *b;
242
243 b = e_border_find_by_window(e->win);
244 if (b)
245 {
246 printf("destroy %x\n", e->win);
247 if (b->win.client == e->win)
248 {
249 e_action_stop_by_object(b, NULL,
250 mouse_win_x, mouse_win_y,
251 border_mouse_x, border_mouse_y);
252 OBJ_UNREF(b);
253 OBJ_IF_FREE(b)
254 {
255 e_window_reparent(e->win, 0, 0, 0);
256 e_icccm_release(e->win);
257 OBJ_FREE(b);
258 }
259 }
260 }
261 }
262 current_ev = NULL;
263}
264
265/* */
266static void
267e_circulate_request(Eevent * ev)
268{
269 Ev_Window_Circulate_Request *e;
270
271 current_ev = ev;
272 e = ev->event;
273 {
274 Evas_List l;
275 E_Border *b;
276
277 b = e_border_find_by_window(e->win);
278 if (b)
279 {
280 if (e->lower) e_border_lower(b);
281 else e_border_raise(b);
282 }
283 }
284 current_ev = NULL;
285}
286
287/* */
288static void
289e_reparent(Eevent * ev)
290{
291 Ev_Window_Reparent *e;
292
293 current_ev = ev;
294 e = ev->event;
295#if 0
296 {
297 Evas_List l;
298 E_Border *b;
299
300 b = e_border_find_by_window(e->win);
301 if ((b) && (e->parent_from == b->win.container))
302 {
303 if (b)
304 {
305 e_action_stop_by_object(b, NULL,
306 mouse_win_x, mouse_win_y,
307 border_mouse_x, border_mouse_y);
308 OBJ_UNREF(b);
309 OBJ_IF_FREE(b)
310 {
311 e_window_reparent(e->win, 0, 0, 0);
312 e_icccm_release(e->win);
313 OBJ_FREE(b);
314 }
315 }
316 }
317 }
318#endif
319 current_ev = NULL;
320}
321
322/* */
323static void
324e_shape(Eevent * ev)
325{
326 Ev_Window_Shape *e;
327
328 current_ev = ev;
329 e = ev->event;
330 {
331 Evas_List l;
332 E_Border *b;
333
334 b = e_border_find_by_window(e->win);
335 if (b)
336 {
337 }
338 }
339 current_ev = NULL;
340}
341
342/* */
343static void
344e_focus_in(Eevent * ev)
345{
346 Ev_Window_Focus_In *e;
347
348 current_ev = ev;
349 e = ev->event;
350 {
351 Evas_List l;
352 E_Border *b;
353
354 b = e_border_find_by_window(e->win);
355 if (b)
356 {
357 b->current.selected = 1;
358 b->changed = 1;
359 }
360 }
361 current_ev = NULL;
362}
363
364/* */
365static void
366e_focus_out(Eevent * ev)
367{
368 Ev_Window_Focus_Out *e;
369
370 current_ev = ev;
371 e = ev->event;
372 {
373 Evas_List l;
374 E_Border *b;
375
376 b = e_border_find_by_window(e->win);
377 if (b)
378 {
379 char *settings_db = "./settings.db";
380 E_DB_File *db;
381 int focus_mode;
382 char buf[4096];
383
384 b->current.selected = 0;
385 /* settings - click to focus would affect grabs */
386 db = e_db_open_read(settings_db);
387 sprintf(buf, "/focus/mode");
388 if ((db) && (e_db_int_get(db, buf, &focus_mode)) && (!b->current.selected))
389 {
390 if (focus_mode == 2) /* click to focus */
391 {
392 E_Grab *g;
393
394 g = NEW(E_Grab, 1);
395 ZERO(g, E_Grab, 1);
396 g->button = 0;
397 g->mods = 0;
398 g->any_mod = 1;
399 g->remove_after = 1;
400 b->grabs = evas_list_append(b->grabs, g);
401 e_button_grab(b->win.main, 0, XEV_BUTTON | XEV_MOUSE_MOVE, EV_KEY_MODIFIER_NONE, 1);
402 e_db_close(db);
403 }
404 }
405 b->changed = 1;
406 }
407 }
408 current_ev = NULL;
409}
410
411/* */
412static void
413e_colormap(Eevent * ev)
414{
415 Ev_Colormap *e;
416
417 current_ev = ev;
418 e = ev->event;
419 {
420 Evas_List l;
421 E_Border *b;
422
423 b = e_border_find_by_window(e->win);
424 if (b)
425 {
426 }
427 }
428 current_ev = NULL;
429}
430
431/* handling mouse down events */
432static void
433e_mouse_down(Eevent * ev)
434{
435 Ev_Mouse_Down *e;
436
437 current_ev = ev;
438 e = ev->event;
439 {
440 Evas_List l;
441 E_Border *b;
442
443 mouse_win_x = e->x;
444 mouse_win_y = e->y;
445 mouse_x = e->rx;
446 mouse_y = e->ry;
447 mouse_buttons |= (1 << e->button);
448 b = e_border_find_by_window(e->win);
449 if (b)
450 {
451 if (e->win == b->win.main) e_cb_border_mouse_down(b, ev);
452 else
453 {
454 Evas evas;
455 int x, y;
456
457 evas = b->evas.l;
458 e_window_get_root_relative_location(evas_get_window(evas),
459 &x, &y);
460 x = e->rx - x;
461 y = e->ry - y;
462 evas_event_button_down(evas, x, y, e->button);
463 evas = b->evas.r;
464 e_window_get_root_relative_location(evas_get_window(evas),
465 &x, &y);
466 x = e->rx - x;
467 y = e->ry - y;
468 evas_event_button_down(evas, x, y, e->button);
469 evas = b->evas.t;
470 e_window_get_root_relative_location(evas_get_window(evas),
471 &x, &y);
472 x = e->rx - x;
473 y = e->ry - y;
474 evas_event_button_down(evas, x, y, e->button);
475 evas = b->evas.b;
476 e_window_get_root_relative_location(evas_get_window(evas),
477 &x, &y);
478 x = e->rx - x;
479 y = e->ry - y;
480 evas_event_button_down(evas, x, y, e->button);
481 }
482 }
483 }
484 current_ev = NULL;
485}
486
487/* handling mouse up events */
488static void
489e_mouse_up(Eevent * ev)
490{
491 Ev_Mouse_Up *e;
492
493 current_ev = ev;
494 e = ev->event;
495 {
496 Evas_List l;
497 E_Border *b;
498
499 mouse_win_x = e->x;
500 mouse_win_y = e->y;
501 mouse_x = e->rx;
502 mouse_y = e->ry;
503 mouse_buttons &= ~(1 << e->button);
504 b = e_border_find_by_window(e->win);
505 if (b)
506 {
507 if (e->win == b->win.main) e_cb_border_mouse_up(b, ev);
508 else
509 {
510 Evas evas;
511 int x, y;
512
513 evas = b->evas.l;
514 e_window_get_root_relative_location(evas_get_window(evas),
515 &x, &y);
516 x = e->rx - x;
517 y = e->ry - y;
518 evas_event_button_up(evas, x, y, e->button);
519 evas = b->evas.r;
520 e_window_get_root_relative_location(evas_get_window(evas),
521 &x, &y);
522 x = e->rx - x;
523 y = e->ry - y;
524 evas_event_button_up(evas, x, y, e->button);
525 evas = b->evas.t;
526 e_window_get_root_relative_location(evas_get_window(evas),
527 &x, &y);
528 x = e->rx - x;
529 y = e->ry - y;
530 evas_event_button_up(evas, x, y, e->button);
531 evas = b->evas.b;
532 e_window_get_root_relative_location(evas_get_window(evas),
533 &x, &y);
534 x = e->rx - x;
535 y = e->ry - y;
536 evas_event_button_up(evas, x, y, e->button);
537 }
538 }
539 }
540 current_ev = NULL;
541}
542
543/* handling mouse move events */
544static void
545e_mouse_move(Eevent * ev)
546{
547 Ev_Mouse_Move *e;
548
549 current_ev = ev;
550 e = ev->event;
551 {
552 Evas_List l;
553 E_Border *b;
554
555 mouse_win_x = e->x;
556 mouse_win_y = e->y;
557 mouse_x = e->rx;
558 mouse_y = e->ry;
559 b = e_border_find_by_window(e->win);
560 if (b)
561 {
562 if (e->win == b->win.main) e_cb_border_mouse_move(b, ev);
563 else
564 {
565 Evas evas;
566 int x, y;
567
568 evas = b->evas.l;
569 e_window_get_root_relative_location(evas_get_window(evas),
570 &x, &y);
571 x = e->rx - x;
572 y = e->ry - y;
573 evas_event_move(evas, x, y);
574 evas = b->evas.r;
575 e_window_get_root_relative_location(evas_get_window(evas),
576 &x, &y);
577 x = e->rx - x;
578 y = e->ry - y;
579 evas_event_move(evas, x, y);
580 evas = b->evas.t;
581 e_window_get_root_relative_location(evas_get_window(evas),
582 &x, &y);
583 x = e->rx - x;
584 y = e->ry - y;
585 evas_event_move(evas, x, y);
586 evas = b->evas.b;
587 e_window_get_root_relative_location(evas_get_window(evas),
588 &x, &y);
589 x = e->rx - x;
590 y = e->ry - y;
591 evas_event_move(evas, x, y);
592 }
593 }
594 }
595 current_ev = NULL;
596}
597
598/* handling mouse enter events */
599static void
600e_mouse_in(Eevent * ev)
601{
602 Ev_Window_Enter *e;
603
604 current_ev = ev;
605 e = ev->event;
606 {
607 E_Border *b;
608
609 b = e_border_find_by_window(e->win);
610 if (b)
611 {
612 if (e->win == b->win.main) e_cb_border_mouse_in(b, ev);
613 if (e->win == b->win.input)
614 {
615 int x, y;
616 Evas evas;
617
618 evas = b->evas.l;
619 e_window_get_root_relative_location(evas_get_window(evas), &x, &y);
620 x = e->rx - x;
621 y = e->ry - y;
622 evas_event_move(evas, x, y);
623 evas_event_enter(evas);
624
625 evas = b->evas.r;
626 e_window_get_root_relative_location(evas_get_window(evas), &x, &y);
627 x = e->rx - x;
628 y = e->ry - y;
629 evas_event_move(evas, x, y);
630 evas_event_enter(evas);
631
632 evas = b->evas.t;
633 e_window_get_root_relative_location(evas_get_window(evas), &x, &y);
634 x = e->rx - x;
635 y = e->ry - y;
636 evas_event_move(evas, x, y);
637 evas_event_enter(evas);
638
639 evas = b->evas.b;
640 e_window_get_root_relative_location(evas_get_window(evas), &x, &y);
641 x = e->rx - x;
642 y = e->ry - y;
643 evas_event_move(evas, x, y);
644 evas_event_enter(evas);
645 }
646 }
647 }
648 current_ev = NULL;
649}
650
651/* handling mouse leave events */
652static void
653e_mouse_out(Eevent * ev)
654{
655 Ev_Window_Leave *e;
656
657 current_ev = ev;
658 e = ev->event;
659 {
660 E_Border *b;
661
662 b = e_border_find_by_window(e->win);
663 if (b)
664 {
665 if (e->win == b->win.main) e_cb_border_mouse_out(b, ev);
666 if (e->win == b->win.input)
667 {
668 evas_event_leave(b->evas.l);
669 evas_event_leave(b->evas.r);
670 evas_event_leave(b->evas.t);
671 evas_event_leave(b->evas.b);
672 }
673 }
674 }
675 current_ev = NULL;
676 current_ev = NULL;
677}
678
679/* handling expose events */
680static void
681e_window_expose(Eevent * ev)
682{
683 Ev_Window_Expose *e;
684
685 current_ev = ev;
686 e = ev->event;
687 {
688 Evas_List l;
689
690 for (l = evases; l; l = l->next)
691 {
692 Evas evas;
693
694 evas = l->data;
695 if (evas_get_window(evas) == e->win)
696 evas_update_rect(evas, e->x, e->y, e->w, e->h);
697 }
698 }
699 current_ev = NULL;
700}
701
702/* what to do with border events */
703
704static void
705e_cb_mouse_in(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
706{
707 E_Border *b;
708
709 b = data;
710 if (border_mouse_buttons) return;
711 border_mouse_x = mouse_x;
712 border_mouse_y = mouse_y;
713 if (!current_ev) return;
714 e_action_stop(class, ACT_MOUSE_IN, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
715 e_action_start(class, ACT_MOUSE_IN, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
716}
717
718static void
719e_cb_mouse_out(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
720{
721 E_Border *b;
722
723 b = data;
724 if (border_mouse_buttons) return;
725 border_mouse_x = mouse_x;
726 border_mouse_y = mouse_y;
727 if (!current_ev) return;
728 e_action_stop(class, ACT_MOUSE_OUT, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
729 e_action_start(class, ACT_MOUSE_OUT, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
730}
731
732static void
733e_cb_mouse_down(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
734{
735 E_Border *b;
736
737 b = data;
738 border_mouse_x = mouse_x;
739 border_mouse_y = mouse_y;
740 border_mouse_buttons = mouse_buttons;
741 if (!current_ev) return;
742 {
743 int act;
744 Ev_Key_Modifiers mods;
745
746 mods = ((Ev_Mouse_Down *)(current_ev->event))->mods;
747 act = ACT_MOUSE_CLICK;
748 if (((Ev_Mouse_Down *)(current_ev->event))->double_click) act = ACT_MOUSE_DOUBLE;
749 else if (((Ev_Mouse_Down *)(current_ev->event))->triple_click) act = ACT_MOUSE_TRIPLE;
750 e_action_stop(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
751 e_action_start(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
752 }
753}
754
755static void
756e_cb_mouse_up(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
757{
758 E_Border *b;
759
760 b = data;
761 border_mouse_x = mouse_x;
762 border_mouse_y = mouse_y;
763 border_mouse_buttons = mouse_buttons;
764 if (!current_ev) return;
765 {
766 int act;
767 Ev_Key_Modifiers mods;
768
769 mods = ((Ev_Mouse_Up *)(current_ev->event))->mods;
770 act = ACT_MOUSE_UP;
771 if ((x >= ox) && (x < (ox + ow)) && (y >= oy) && (y < (oy + oh)))
772 act = ACT_MOUSE_CLICKED;
773 e_action_stop(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
774 e_action_start(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
775 }
776}
777
778static void
779e_cb_mouse_move(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh)
780{
781 E_Border *b;
782 int dx, dy;
783
784 b = data;
785 dx = mouse_x - border_mouse_x;
786 dy = mouse_y - border_mouse_y;
787 border_mouse_x = mouse_x;
788 border_mouse_y = mouse_y;
789 if (!current_ev) return;
790 e_action_go(class, ACT_MOUSE_MOVE, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y, dx, dy);
791}
792
793/* callbacks for certain things */
794static void
795e_cb_border_mouse_in(E_Border *b, Eevent *e)
796{
797 E_Action *a;
798 int x, y;
799 char *class = "Window_Grab";
800
801 if (border_mouse_buttons) return;
802 /* pointer focus stuff */
803 e_focus_to_window(b->win.client);
804
805 border_mouse_x = mouse_x;
806 border_mouse_y = mouse_y;
807 border_mouse_buttons = mouse_buttons;
808 if (!current_ev) return;
809 x = ((Ev_Window_Enter *)(e->event))->x;
810 y = ((Ev_Window_Enter *)(e->event))->y;
811 e_action_stop(class, ACT_MOUSE_IN, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
812 e_action_start(class, ACT_MOUSE_IN, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
813}
814
815static void
816e_cb_border_mouse_out(E_Border *b, Eevent *e)
817{
818 E_Action *a;
819 int x, y;
820 char *class = "Window_Grab";
821
822 if (border_mouse_buttons) return;
823 /* pointer focus stuff */
824 e_focus_to_window(0);
825
826 border_mouse_x = mouse_x;
827 border_mouse_y = mouse_y;
828 border_mouse_buttons = mouse_buttons;
829 if (!current_ev) return;
830 e_action_stop(class, ACT_MOUSE_OUT, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
831 e_action_start(class, ACT_MOUSE_OUT, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y);
832}
833
834static void
835e_cb_border_mouse_down(E_Border *b, Eevent *e)
836{
837 E_Action *a;
838 int x, y, bt;
839 char *class = "Window_Grab";
840
841 e_pointer_grab(b->win.main, CurrentTime);
842 border_mouse_x = mouse_x;
843 border_mouse_y = mouse_y;
844 if (border_mouse_buttons) return;
845 border_mouse_buttons = mouse_buttons;
846 if (!current_ev) return;
847 x = ((Ev_Mouse_Down *)(e->event))->x;
848 y = ((Ev_Mouse_Down *)(e->event))->y;
849 bt = ((Ev_Mouse_Down *)(e->event))->button;
850 {
851 Evas_List l;
852
853 again:
854 for (l = b->grabs; l; l = l->next)
855 {
856 E_Grab *g;
857
858 g = l->data;
859 /* find a grab that triggered this */
860 if ((((Ev_Mouse_Down *)(e->event))->button == g->button) &&
861 ((g->any_mod) ||
862 (((Ev_Mouse_Down *)(e->event))->mods == g->mods)))
863 {
864 if (g->allow)
865 e_pointer_replay(((Ev_Mouse_Down *)(e->event))->time);
866 if (g->remove_after)
867 {
868 e_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
869 free(g);
870 b->grabs = evas_list_remove(b->grabs, g);
871 goto again;
872 }
873 }
874 }
875 }
876 {
877 int act;
878 Ev_Key_Modifiers mods;
879
880 mods = ((Ev_Mouse_Down *)(current_ev->event))->mods;
881 act = ACT_MOUSE_CLICK;
882 if (((Ev_Mouse_Down *)(current_ev->event))->double_click) act = ACT_MOUSE_DOUBLE;
883 else if (((Ev_Mouse_Down *)(current_ev->event))->triple_click) act = ACT_MOUSE_TRIPLE;
884 e_action_stop(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
885 e_action_start(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
886 }
887/*
888 * e_pointer_ungrab(((Ev_Mouse_Up *)(e->event))->time);
889 * e_pointer_replay(((Ev_Mouse_Up *)(e->event))->time);
890 */
891}
892
893static void
894e_cb_border_mouse_up(E_Border *b, Eevent *e)
895{
896 E_Action *a;
897 int x, y, bt;
898 char *class = "Window_Grab";
899
900 e_pointer_ungrab(CurrentTime);
901 border_mouse_x = mouse_x;
902 border_mouse_y = mouse_y;
903 border_mouse_buttons = mouse_buttons;
904 if (!current_ev) return;
905 x = ((Ev_Mouse_Up *)(e->event))->x;
906 y = ((Ev_Mouse_Up *)(e->event))->y;
907 bt = ((Ev_Mouse_Up *)(e->event))->button;
908 {
909 int act;
910 Ev_Key_Modifiers mods;
911
912 mods = ((Ev_Mouse_Up *)(current_ev->event))->mods;
913 act = ACT_MOUSE_UP;
914 e_action_stop(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
915 e_action_start(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y);
916 }
917}
918
919static void
920e_cb_border_mouse_move(E_Border *b, Eevent *e)
921{
922 int dx, dy;
923 int x, y;
924 char *class = "Window_Grab";
925
926 dx = mouse_x - border_mouse_x;
927 dy = mouse_y - border_mouse_y;
928 border_mouse_x = mouse_x;
929 border_mouse_y = mouse_y;
930 if (!current_ev) return;
931 x = ((Ev_Mouse_Move *)(e->event))->x;
932 y = ((Ev_Mouse_Move *)(e->event))->y;
933 e_action_go(class, ACT_MOUSE_MOVE, 0, NULL, EV_KEY_MODIFIER_NONE, b, NULL, x, y, border_mouse_x, border_mouse_y, dx, dy);
934}
935
936static void
937e_cb_border_move_resize(E_Border *b)
938{
939}
940
941static void
942e_cb_border_visibility(E_Border *b)
943{
944}
945
946static void e_border_poll(int val, void *data)
947{
948 e_add_event_timer("e_border_poll()", 1.00, e_border_poll, val + 1, NULL);
949}
950
951/* border creation, deletion, modification and general queries */
952
953void
954e_border_apply_border(E_Border *b)
955{
956 int pl, pr, pt, pb;
957
958 if ((!b->client.titlebar) &&
959 (!b->client.border)) e_border_set_bits(b, "../data/borderless.bits.db");
960 else if (b->current.selected) e_border_set_bits(b, "../data/border.bits.db");
961 else e_border_set_bits(b, "../data/border2.bits.db");
962
963 pl = pr = pt = pb = 0;
964 if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
965 e_icccm_set_frame_size(b->win.client, pl, pr, pt, pb);
966}
967
968E_Border *
969e_border_adopt(Window win, int use_client_pos)
970{
971 E_Border *b;
972
973 printf("adopt %x\n", win);
974 /* create the struct */
975 b = e_border_new();
976 /* set the right event on the client */
977 e_window_set_events(win,
978 XEV_VISIBILITY |
979 ResizeRedirectMask |
980 XEV_CONFIGURE |
981 XEV_FOCUS |
982 XEV_PROPERTY |
983 XEV_COLORMAP);
984 /* parent of the client window listens for these */
985 e_window_set_events(b->win.container, XEV_CHILD_CHANGE | XEV_CHILD_REDIRECT);
986 /* add to save set & border of 0 */
987 e_icccm_adopt(win);
988 e_window_set_border_width(win, 0);
989 b->win.client = win;
990 b->current.requested.visible = 1;
991 /* get size & location hints */
992 e_icccm_get_size_info(win, b);
993 e_icccm_get_mwm_hints(win, b);
994 e_icccm_get_layer(win, b);
995 printf("%i\n", b->client.layer);
996 /* desk area */
997 e_icccm_set_desk_area(win, 0, 0);
998 e_icccm_set_desk(win, e_desktops_get_current());
999 if (use_client_pos)
1000 {
1001 int x, y;
1002
1003 e_window_get_geometry(win, &x, &y, NULL, NULL);
1004 b->current.requested.x = x;
1005 b->current.requested.y = y;
1006 }
1007 /* reparent the window finally */
1008 e_window_reparent(win, b->win.container, 0, 0);
1009 /* figure what border to use */
1010 e_border_apply_border(b);
1011 {
1012 int pl, pr, pt, pb;
1013
1014 pl = pr = pt = pb = 0;
1015 if (b->bits.l) ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb);
1016 b->current.requested.x += pl;
1017 b->current.requested.y += pt;
1018 b->changed = 1;
1019 }
1020 /* show the client */
1021 e_icccm_state_mapped(win);
1022 /* fix size so it matches the hints a client asks for */
1023 b->changed = 1;
1024 e_border_adjust_limits(b);
1025 e_border_raise(b);
1026 e_window_show(win);
1027 return b;
1028}
1029
1030E_Border *
1031e_border_new(void)
1032{
1033 E_Border *b;
1034 int max_colors = 216;
1035 int font_cache = 1024 * 1024;
1036 int image_cache = 8192 * 1024;
1037 char *font_dir = "./fnt";
1038 E_Desktop *desk;
1039
1040 b = NEW(E_Border, 1);
1041 ZERO(b, E_Border, 1);
1042
1043 OBJ_INIT(b, e_border_free);
1044
1045 b->current.requested.w = 1;
1046 b->current.requested.h = 1;
1047 b->client.min.w = 1;
1048 b->client.min.h = 1;
1049 b->client.max.w = 1000000;
1050 b->client.max.h = 1000000;
1051 b->client.min.aspect = -1000000;
1052 b->client.max.aspect = 1000000;
1053 b->client.step.w = 1;
1054 b->client.step.h = 1;
1055 b->client.layer = 4;
1056 b->client.border = 1;
1057 b->client.handles = 1;
1058 b->client.titlebar = 1;
1059
1060 desk = e_desktops_get(e_desktops_get_current());
1061 e_desktops_add_border(desk, b);
1062 b->win.main = e_window_override_new(desk->win.container, 0, 0, 1, 1);
1063 b->win.input = e_window_input_new(b->win.main, 0, 0, 1, 1);
1064 b->win.container = e_window_override_new(b->win.main, 0, 0, 1, 1);
1065 e_window_set_events(b->win.input, XEV_MOUSE_MOVE | XEV_BUTTON | XEV_IN_OUT);
1066 e_window_show(b->win.input);
1067 e_window_show(b->win.container);
1068
1069 b->evas.l = evas_new_all(e_display_get(),
1070 b->win.main,
1071 0, 0, 1, 1,
1072 RENDER_METHOD_ALPHA_SOFTWARE,
1073 max_colors,
1074 font_cache,
1075 image_cache,
1076 font_dir);
1077 b->win.l = evas_get_window(b->evas.l);
1078 e_add_child(b->win.main, b->win.l);
1079 b->evas.r = evas_new_all(e_display_get(),
1080 b->win.main,
1081 0, 0, 1, 1,
1082 RENDER_METHOD_ALPHA_SOFTWARE,
1083 max_colors,
1084 font_cache,
1085 image_cache,
1086 font_dir);
1087 b->win.r = evas_get_window(b->evas.r);
1088 e_add_child(b->win.main, b->win.r);
1089 b->evas.t = evas_new_all(e_display_get(),
1090 b->win.main,
1091 0, 0, 1, 1,
1092 RENDER_METHOD_ALPHA_SOFTWARE,
1093 max_colors,
1094 font_cache,
1095 image_cache,
1096 font_dir);
1097 b->win.t = evas_get_window(b->evas.t);
1098 e_add_child(b->win.main, b->win.t);
1099 b->evas.b = evas_new_all(e_display_get(),
1100 b->win.main,
1101 0, 0, 1, 1,
1102 RENDER_METHOD_ALPHA_SOFTWARE,
1103 max_colors,
1104 font_cache,
1105 image_cache,
1106 font_dir);
1107 b->win.b = evas_get_window(b->evas.b);
1108 e_add_child(b->win.main, b->win.b);
1109
1110 e_window_raise(b->win.input);
1111 e_window_raise(b->win.container);
1112
1113 evases = evas_list_append(evases, b->evas.l);
1114 evases = evas_list_append(evases, b->evas.r);
1115 evases = evas_list_append(evases, b->evas.t);
1116 evases = evas_list_append(evases, b->evas.b);
1117
1118 e_window_set_events(b->win.l, XEV_EXPOSE);
1119 e_window_set_events(b->win.r, XEV_EXPOSE);
1120 e_window_set_events(b->win.t, XEV_EXPOSE);
1121 e_window_set_events(b->win.b, XEV_EXPOSE);
1122
1123 e_window_show(b->win.l);
1124 e_window_show(b->win.r);
1125 e_window_show(b->win.t);
1126 e_window_show(b->win.b);
1127
1128 e_border_attach_mouse_grabs(b);
1129
1130 borders = evas_list_prepend(borders, b);
1131
1132 return b;
1133}
1134
1135void
1136e_border_free(E_Border *b)
1137{
1138 Evas_List l;
1139
1140 e_desktops_del_border(b->desk, b);
1141 if (b->bits.l) ebits_free(b->bits.l);
1142 if (b->bits.r) ebits_free(b->bits.r);
1143 if (b->bits.t) ebits_free(b->bits.t);
1144 if (b->bits.b) ebits_free(b->bits.b);
1145 evases = evas_list_remove(evases, b->evas.l);
1146 evases = evas_list_remove(evases, b->evas.r);
1147 evases = evas_list_remove(evases, b->evas.t);
1148 evases = evas_list_remove(evases, b->evas.b);
1149 evas_free(b->evas.l);
1150 evas_free(b->evas.r);
1151 evas_free(b->evas.t);
1152 evas_free(b->evas.b);
1153 e_window_destroy(b->win.container);
1154 e_window_destroy(b->win.input);
1155 e_window_destroy(b->win.main);
1156 borders = evas_list_remove(borders, b);
1157
1158 if (b->grabs)
1159 {
1160 for (l = b->grabs; l; l = l->next)
1161 {
1162 FREE(l->data);
1163 }
1164 evas_list_free(b->grabs);
1165 }
1166
1167 free(b);
1168}
1169
1170void
1171e_border_remove_mouse_grabs(E_Border *b)
1172{
1173 Evas_List l;
1174
1175 if (b->grabs)
1176 {
1177 for (l = b->grabs; l; l = l->next)
1178 {
1179 E_Grab *g;
1180
1181 g = l->data;
1182 e_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
1183 FREE(g);
1184 }
1185 evas_list_free(b->grabs);
1186 b->grabs = NULL;
1187 }
1188}
1189
1190void
1191e_border_attach_mouse_grabs(E_Border *b)
1192{
1193 char *grabs_db = "./grabs.db";
1194 char *settings_db = "./settings.db";
1195 E_DB_File *db;
1196 int focus_mode;
1197 char buf[4096];
1198
1199 /* settings - click to focus would affect grabs */
1200 db = e_db_open_read(settings_db);
1201 sprintf(buf, "/focus/mode");
1202 if ((db) && (e_db_int_get(db, buf, &focus_mode)) && (!b->current.selected))
1203 {
1204 if (focus_mode == 2) /* click to focus */
1205 {
1206 E_Grab *g;
1207
1208 g = NEW(E_Grab, 1);
1209 ZERO(g, E_Grab, 1);
1210 g->button = 0;
1211 g->mods = 0;
1212 g->any_mod = 1;
1213 g->remove_after = 1;
1214 b->grabs = evas_list_append(b->grabs, g);
1215 e_button_grab(b->win.main, 0, XEV_BUTTON | XEV_MOUSE_MOVE, EV_KEY_MODIFIER_NONE, 1);
1216 e_db_close(db);
1217 }
1218 }
1219
1220 /* other grabs - liek alt+left to move */
1221 db = e_db_open_read(grabs_db);
1222 if (db)
1223 {
1224 int i, num;
1225
1226 sprintf(buf, "/grabs/count");
1227 if (!e_db_int_get(db, buf, &num))
1228 {
1229 e_db_close(db);
1230 return;
1231 }
1232 for (i = 0; i < num; i++)
1233 {
1234 int button, any_mod, mod;
1235 Ev_Key_Modifiers mods;
1236
1237 button = -1;
1238 mods = EV_KEY_MODIFIER_NONE;
1239 any_mod = 0;
1240 sprintf(buf, "/grabs/%i/button", i);
1241 if (!e_db_int_get(db, buf, &button)) continue;
1242 sprintf(buf, "/grabs/%i/modifiers", i);
1243 if (!e_db_int_get(db, buf, &mod)) continue;
1244 if (mod == -1) any_mod = 1;
1245 mods = (Ev_Key_Modifiers)mod;
1246
1247 if (button >= 0)
1248 {
1249 E_Grab *g;
1250
1251 g = NEW(E_Grab, 1);
1252 ZERO(g, E_Grab, 1);
1253 g->button = button;
1254 g->mods = mods;
1255 g->any_mod = any_mod;
1256 g->remove_after = 0;
1257 b->grabs = evas_list_append(b->grabs, g);
1258 e_button_grab(b->win.main, button, XEV_BUTTON | XEV_MOUSE_MOVE, mods, 0);
1259 }
1260 }
1261 e_db_close(db);
1262 }
1263}
1264
1265void
1266e_border_remove_all_mouse_grabs(void)
1267{
1268 Evas_List l;
1269
1270 for (l = borders; l; l = l->next)
1271 e_border_remove_mouse_grabs((E_Border *)l->data);
1272}
1273
1274void
1275e_border_attach_all_mouse_grabs(void)
1276{
1277 Evas_List l;
1278
1279 for (l = borders; l; l = l->next)
1280 e_border_attach_mouse_grabs((E_Border *)l->data);
1281}
1282
1283void
1284e_border_redo_grabs(void)
1285{
1286 char *grabs_db = "./grabs.db";
1287 char *settings_db = "./settings.db";
1288 static time_t mod_date_grabs = 0;
1289 static time_t mod_date_settings = 0;
1290 time_t mod;
1291 int changed = 0;
1292 Evas_List l;
1293
1294 mod = e_file_modified_time(grabs_db);
1295 if (mod != mod_date_grabs) changed = 1;
1296 mod_date_grabs = mod;
1297 if (!changed)
1298 {
1299 mod = e_file_modified_time(settings_db);
1300 if (mod != mod_date_settings) changed = 1;
1301 mod_date_settings = mod;
1302 }
1303 if (!changed) return;
1304 for (l = borders; l; l = l->next)
1305 {
1306 E_Border *b;
1307
1308 b = l->data;
1309 e_border_remove_mouse_grabs(b);
1310 e_border_attach_mouse_grabs(b);
1311 }
1312}
1313
1314E_Border *
1315e_border_find_by_window(Window win)
1316{
1317 Evas_List l;
1318
1319 for (l = borders; l; l = l->next)
1320 {
1321 E_Border *b;
1322
1323 b = l->data;
1324
1325 if ((win == b->win.main) ||
1326 (win == b->win.client) ||
1327 (win == b->win.container) ||
1328 (win == b->win.input) ||
1329 (win == b->win.l) ||
1330 (win == b->win.r) ||
1331 (win == b->win.t) ||
1332 (win == b->win.b))
1333 return b;
1334 }
1335 return NULL;
1336}
1337
1338void
1339e_border_set_bits(E_Border *b, char *file)
1340{
1341 int pl, pr, pt, pb, ppl, ppr, ppt, ppb;
1342
1343 pl = pr = pt = pb = 0;
1344 ppl = ppr = ppt = ppb = 0;
1345
1346 if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
1347
1348 if (b->bits.l) ebits_free(b->bits.l);
1349 if (b->bits.r) ebits_free(b->bits.r);
1350 if (b->bits.t) ebits_free(b->bits.t);
1351 if (b->bits.b) ebits_free(b->bits.b);
1352
1353 b->bits.l = ebits_load(file);
1354 b->bits.r = ebits_load(file);
1355 b->bits.t = ebits_load(file);
1356 b->bits.b = ebits_load(file);
1357
1358 b->bits.new = 1;
1359 b->changed = 1;
1360
1361 if (b->bits.t) ebits_get_insets(b->bits.l, &ppl, &ppr, &ppt, &ppb);
1362 b->current.requested.w -= (pl + pr) - (ppl + ppr);
1363 b->current.requested.h -= (pt + pb) - (ppt + ppb);
1364 b->current.requested.x += (pl - ppl);
1365 b->current.requested.y += (pt - ppt);
1366
1367 if (b->bits.t)
1368 {
1369 ebits_add_to_evas(b->bits.l, b->evas.l);
1370 ebits_move(b->bits.l, 0, 0);
1371 ebits_show(b->bits.l);
1372
1373 ebits_add_to_evas(b->bits.r, b->evas.r);
1374 ebits_move(b->bits.r, 0, 0);
1375 ebits_show(b->bits.r);
1376
1377 ebits_add_to_evas(b->bits.t, b->evas.t);
1378 ebits_move(b->bits.t, 0, 0);
1379 ebits_show(b->bits.t);
1380
1381 ebits_add_to_evas(b->bits.b, b->evas.b);
1382 ebits_move(b->bits.b, 0, 0);
1383 ebits_show(b->bits.b);
1384
1385 e_border_set_color_class(b, "Title BG", 100, 200, 255, 255);
1386
1387#define HOOK_CB(_class) \
1388ebits_set_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_IN, e_cb_mouse_in, b); \
1389ebits_set_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_OUT, e_cb_mouse_out, b); \
1390ebits_set_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_DOWN, e_cb_mouse_down, b); \
1391ebits_set_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_UP, e_cb_mouse_up, b); \
1392ebits_set_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_MOVE, e_cb_mouse_move, b);
1393 HOOK_CB("Title_Bar");
1394 HOOK_CB("Resize");
1395 HOOK_CB("Resize_Horizontal");
1396 HOOK_CB("Resize_Vertical");
1397 HOOK_CB("Close");
1398 HOOK_CB("Iconify");
1399 HOOK_CB("Max_Size");
1400 HOOK_CB("Menu");
1401
1402 e_border_adjust_limits(b);
1403 }
1404}
1405
1406void
1407e_border_set_color_class(E_Border *b, char *class, int rr, int gg, int bb, int aa)
1408{
1409 ebits_set_color_class(b->bits.l, class, rr, gg, bb, aa);
1410 ebits_set_color_class(b->bits.r, class, rr, gg, bb, aa);
1411 ebits_set_color_class(b->bits.t, class, rr, gg, bb, aa);
1412 ebits_set_color_class(b->bits.b, class, rr, gg, bb, aa);
1413}
1414
1415void
1416e_border_adjust_limits(E_Border *b)
1417{
1418 int w, h, pl, pr, pt, pb, mx, my;
1419
1420 if (b->mode.move) e_resist_border(b);
1421 else
1422 {
1423 b->current.x = b->current.requested.x;
1424 b->current.y = b->current.requested.y;
1425 }
1426
1427 b->current.w = b->current.requested.w;
1428 b->current.h = b->current.requested.h;
1429
1430 pl = pr = pt = pb = 0;
1431 if (b->current.w < 1) b->current.w = 1;
1432 if (b->current.h < 1) b->current.h = 1;
1433
1434 if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
1435
1436 if (b->current.w < (pl + pr + 1)) b->current.w = pl + pr + 1;
1437 if (b->current.h < (pt + pb + 1)) b->current.h = pt + pb + 1;
1438
1439 w = b->current.w - pl - pr;
1440 h = b->current.h - pt - pb;
1441
1442 mx = my = 1;
1443 if (b->bits.t) ebits_get_min_size(b->bits.t, &mx, &my);
1444 if (b->current.w < mx) b->current.w = mx;
1445 if (b->current.h < my) b->current.h = my;
1446 mx = my = 999999;
1447 if (b->bits.t) ebits_get_max_size(b->bits.t, &mx, &my);
1448 if (b->current.w > mx) b->current.w = mx;
1449 if (b->current.h > my) b->current.h = my;
1450
1451 if (w < b->client.min.w) w = b->client.min.w;
1452 if (h < b->client.min.h) h = b->client.min.h;
1453 if (w > b->client.max.w) w = b->client.max.w;
1454 if (h > b->client.max.h) h = b->client.max.h;
1455 if ((w > 0) && (h > 0))
1456 {
1457 w -= b->client.base.w;
1458 h -= b->client.base.h;
1459 if ((w > 0) && (h > 0))
1460 {
1461 int i, j;
1462 double aspect;
1463
1464 aspect = ((double)w) / ((double)h);
1465 if ((b->mode.resize == 4) || (b->mode.resize == 5))
1466 {
1467 if (aspect < b->client.min.aspect)
1468 h = (int)((double)w / b->client.min.aspect);
1469 if (aspect > b->client.max.aspect)
1470 h = (int)((double)w / b->client.max.aspect);
1471 }
1472 else if ((b->mode.resize == 6) || (b->mode.resize == 7))
1473 {
1474 if (aspect < b->client.min.aspect)
1475 w = (int)((double)h * b->client.min.aspect);
1476 if (aspect > b->client.max.aspect)
1477 w = (int)((double)h * b->client.max.aspect);
1478 }
1479 else
1480 {
1481 if (aspect < b->client.min.aspect)
1482 w = (int)((double)h * b->client.min.aspect);
1483 if (aspect > b->client.max.aspect)
1484 h = (int)((double)w / b->client.max.aspect);
1485 }
1486 i = w / b->client.step.w;
1487 j = h / b->client.step.h;
1488 w = i * b->client.step.w;
1489 h = j * b->client.step.h;
1490 }
1491 w += b->client.base.w;
1492 h += b->client.base.h;
1493 }
1494 b->current.w = w + pl + pr;
1495 b->current.h = h + pt + pb;
1496
1497 if ((b->mode.resize == 3) || (b->mode.resize == 5) || (b->mode.resize == 7))
1498 {
1499 }
1500 else if ((b->mode.resize == 0) || (b->mode.resize == 4))
1501 {
1502 b->current.x += (b->current.requested.w - b->current.w);
1503 b->current.y += (b->current.requested.h - b->current.h);
1504 }
1505 else if ((b->mode.resize == 1) || (b->mode.resize == 6))
1506 {
1507 b->current.y += (b->current.requested.h - b->current.h);
1508 }
1509 else if ((b->mode.resize == 2))
1510 {
1511 b->current.x += (b->current.requested.w - b->current.w);
1512 }
1513}
1514
1515void
1516e_border_update(E_Border *b)
1517{
1518 int location_changed = 0;
1519 int size_changed = 0;
1520 int shape_changed = 0;
1521 int border_changed = 0;
1522 int visibility_changed = 0;
1523 int state_changed = 0;
1524
1525 if (!b->changed) return;
1526
1527 b->current.visible = b->current.requested.visible;
1528
1529 if ((b->current.x != b->previous.x) || (b->current.y != b->previous.y))
1530 location_changed = 1;
1531 if ((b->current.w != b->previous.w) || (b->current.h != b->previous.h))
1532 size_changed = 1;
1533 if ((size_changed) && (b->has_shape))
1534 shape_changed = 1;
1535 if (b->bits.new)
1536 {
1537 e_window_gravity_set(b->win.container, StaticGravity);
1538 border_changed = 1;
1539 }
1540 if ((border_changed) && (b->has_shape))
1541 shape_changed = 1;
1542 if (b->current.visible != b->previous.visible)
1543 visibility_changed = 1;
1544 if (b->current.selected != b->previous.selected)
1545 state_changed = 1;
1546
1547 if (state_changed)
1548 {
1549 e_border_apply_border(b);
1550 if (!border_changed)
1551 {
1552 e_window_gravity_set(b->win.container, StaticGravity);
1553 border_changed = 1;
1554 size_changed = 1;
1555 }
1556 }
1557 if ((location_changed) && (!size_changed))
1558 {
1559 int pl, pr, pt, pb;
1560
1561 e_window_move(b->win.main, b->current.x, b->current.y);
1562 pl = pr = pt = pb = 0;
1563 if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
1564 e_icccm_move_resize(b->win.client,
1565 b->current.x + pl, b->current.y + pt,
1566 b->current.w - pl - pr, b->current.h - pt - pb);
1567 e_cb_border_move_resize(b);
1568 }
1569 else if (size_changed)
1570 {
1571 int pl, pr, pt, pb, x, y, w, h;
1572 int smaller;
1573
1574 smaller = 0;
1575 if ((b->current.w < b->previous.w) || (b->current.h < b->previous.h))
1576 smaller = 1;
1577 pl = pr = pt = pb = 0;
1578 if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb);
1579 e_window_resize(b->win.client, b->current.w - pl - pr, b->current.h - pt - pb);
1580 e_window_move_resize(b->win.input,
1581 0, 0, b->current.w, b->current.h);
1582 e_window_move_resize(b->win.main,
1583 b->current.x, b->current.y,
1584 b->current.w, b->current.h);
1585 e_window_move_resize(b->win.container, pl, pt,
1586 b->current.w - pl - pr, b->current.h - pt -pb);
1587 x = 0, y = pt, w = pl, h = (b->current.h - pt - pb);
1588 e_window_move_resize(b->win.l, x, y, w, h);
1589 evas_set_output_size(b->evas.l, w, h);
1590 evas_set_output_viewport(b->evas.l, x, y, w, h);
1591
1592 x = 0, y = 0, w = b->current.w, h = pt;
1593 e_window_move_resize(b->win.t, x, y, w, h);
1594 evas_set_output_size(b->evas.t, w, h);
1595 evas_set_output_viewport(b->evas.t, x, y, w, h);
1596
1597 x = b->current.w - pr, y = pt, w = pr, h = (b->current.h - pt - pb);
1598 e_window_move_resize(b->win.r, x, y, w, h);
1599 evas_set_output_size(b->evas.r, w, h);
1600 evas_set_output_viewport(b->evas.r, x, y, w, h);
1601
1602 x = 0, y = b->current.h - pb, w = b->current.w, h = pb;
1603 e_window_move_resize(b->win.b, x, y, w, h);
1604 evas_set_output_size(b->evas.b, w, h);
1605 evas_set_output_viewport(b->evas.b, x, y, w, h);
1606
1607 if (b->bits.l) ebits_resize(b->bits.l, b->current.w, b->current.h);
1608 if (b->bits.r) ebits_resize(b->bits.r, b->current.w, b->current.h);
1609 if (b->bits.t) ebits_resize(b->bits.t, b->current.w, b->current.h);
1610 if (b->bits.b) ebits_resize(b->bits.b, b->current.w, b->current.h);
1611
1612 e_icccm_move_resize(b->win.client,
1613 b->current.x + pl, b->current.y + pt,
1614 b->current.w - pl - pr, b->current.h - pt - pb);
1615 e_cb_border_move_resize(b);
1616 }
1617 if (visibility_changed)
1618 {
1619 if (b->current.visible)
1620 e_window_show(b->win.main);
1621 else
1622 e_window_hide(b->win.main);
1623 e_cb_border_visibility(b);
1624 }
1625
1626 if (border_changed)
1627 e_window_gravity_set(b->win.container, NorthWestGravity);
1628 b->bits.new = 0;
1629 b->previous = b->current;
1630 b->changed = 0;
1631}
1632
1633void
1634e_border_set_layer(E_Border *b, int layer)
1635{
1636 Evas_List l;
1637 E_Border *rel = NULL;
1638 int dl;
1639
1640 if (b->client.layer == layer) return;
1641 dl = layer - b->client.layer;
1642 b->client.layer = layer;
1643 if (dl > 0) e_border_lower(b);
1644 else e_border_raise(b);
1645}
1646
1647void
1648e_border_raise(E_Border *b)
1649{
1650 Evas_List l;
1651 E_Border *rel;
1652
1653 if (!b->desk->windows)
1654 {
1655 b->desk->windows = evas_list_append(b->desk->windows, b);
1656 b->desk->changed = 1;
1657 e_window_raise(b->win.main);
1658 return;
1659 }
1660 for (l = b->desk->windows; l; l = l->next)
1661 {
1662 rel = l->data;
1663 if (rel->client.layer > b->client.layer)
1664 {
1665 b->desk->windows = evas_list_remove(b->desk->windows, b);
1666 b->desk->windows = evas_list_prepend_relative(b->desk->windows, b, rel);
1667 b->desk->changed = 1;
1668 e_window_stack_below(b->win.main, rel->win.main);
1669 return;
1670 }
1671 if ((!l->next) && (l->data != b))
1672 {
1673 b->desk->windows = evas_list_remove(b->desk->windows, b);
1674 b->desk->windows = evas_list_append(b->desk->windows, b);
1675 b->desk->changed = 1;
1676 e_window_raise(b->win.main);
1677 return;
1678 }
1679 }
1680}
1681
1682void
1683e_border_lower(E_Border *b)
1684{
1685 Evas_List l;
1686 E_Border *rel;
1687
1688 if (!b->desk->windows)
1689 {
1690 b->desk->windows = evas_list_append(b->desk->windows, b);
1691 b->desk->changed = 1;
1692 e_window_raise(b->win.main);
1693 return;
1694 }
1695 for (l = b->desk->windows; l; l = l->next)
1696 {
1697 rel = l->data;
1698 if (rel->client.layer == b->client.layer)
1699 {
1700 if (b == rel) return;
1701 b->desk->windows = evas_list_remove(b->desk->windows, b);
1702 b->desk->windows = evas_list_prepend_relative(b->desk->windows, b, rel);
1703 b->desk->changed = 1;
1704 e_window_stack_below(b->win.main, rel->win.main);
1705 return;
1706 }
1707 }
1708}
1709
1710void
1711e_border_raise_above(E_Border *b, E_Border *above)
1712{
1713 if (!b->desk->windows)
1714 {
1715 b->desk->windows = evas_list_append(b->desk->windows, b);
1716 b->desk->changed = 1;
1717 e_window_raise(b->win.main);
1718 return;
1719 }
1720 if (!evas_list_find(b->desk->windows, above)) return;
1721 if (b->client.layer < above->client.layer) b->client.layer = above->client.layer;
1722 b->desk->windows = evas_list_remove(b->desk->windows, b);
1723 b->desk->windows = evas_list_append_relative(b->desk->windows, b, above);
1724 b->desk->changed = 1;
1725 e_window_stack_above(b->win.main, above->win.main);
1726}
1727
1728void
1729e_border_lower_below(E_Border *b, E_Border *below)
1730{
1731 if (!b->desk->windows)
1732 {
1733 b->desk->windows = evas_list_append(b->desk->windows, b);
1734 b->desk->changed = 1;
1735 return;
1736 }
1737 if (!evas_list_find(b->desk->windows, below)) return;
1738 if (b->client.layer > below->client.layer) b->client.layer = below->client.layer;
1739 b->desk->windows = evas_list_remove(b->desk->windows, b);
1740 b->desk->windows = evas_list_prepend_relative(b->desk->windows, b, below);
1741 b->desk->changed = 1;
1742 e_window_stack_below(b->win.main, below->win.main);
1743}
1744
1745void
1746e_border_init(void)
1747{
1748 e_event_filter_handler_add(EV_MOUSE_DOWN, e_mouse_down);
1749 e_event_filter_handler_add(EV_MOUSE_UP, e_mouse_up);
1750 e_event_filter_handler_add(EV_MOUSE_MOVE, e_mouse_move);
1751 e_event_filter_handler_add(EV_MOUSE_IN, e_mouse_in);
1752 e_event_filter_handler_add(EV_MOUSE_OUT, e_mouse_out);
1753 e_event_filter_handler_add(EV_WINDOW_EXPOSE, e_window_expose);
1754 e_event_filter_handler_add(EV_WINDOW_MAP_REQUEST, e_map_request);
1755 e_event_filter_handler_add(EV_WINDOW_CONFIGURE_REQUEST, e_configure_request);
1756 e_event_filter_handler_add(EV_WINDOW_PROPERTY, e_property);
1757 e_event_filter_handler_add(EV_WINDOW_UNMAP, e_unmap);
1758 e_event_filter_handler_add(EV_WINDOW_DESTROY, e_destroy);
1759 e_event_filter_handler_add(EV_WINDOW_CIRCULATE_REQUEST, e_circulate_request);
1760 e_event_filter_handler_add(EV_WINDOW_REPARENT, e_reparent);
1761 e_event_filter_handler_add(EV_WINDOW_SHAPE, e_shape);
1762 e_event_filter_handler_add(EV_WINDOW_FOCUS_IN, e_focus_in);
1763 e_event_filter_handler_add(EV_WINDOW_FOCUS_OUT, e_focus_out);
1764 e_event_filter_handler_add(EV_COLORMAP, e_colormap);
1765 e_event_filter_idle_handler_add(e_idle, NULL);
1766
1767 e_add_event_timer("e_border_poll()", 1.00, e_border_poll, 0, NULL);
1768}
1769
1770void
1771e_border_adopt_children(Window win)
1772{
1773 Window *wins;
1774 int i, num;
1775
1776 wins = e_window_get_children(win, &num);
1777 if (wins)
1778 {
1779 for (i = 0; i < num; i++)
1780 {
1781 if (e_window_is_manageable(wins[i]))
1782 {
1783 E_Border *b;
1784
1785 printf("manage %x\n", wins[i]);
1786 b = e_border_adopt(wins[i], 1);
1787 {
1788 int pl, pr, pt, pb;
1789
1790 pl = pr = pt = pb = 0;
1791 if (b->bits.l) ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb);
1792 b->current.requested.x -= pl;
1793 b->current.requested.y -= pt;
1794 printf("back %i %i\n", pl, pt);
1795 b->changed = 1;
1796 e_border_adjust_limits(b);
1797 }
1798 b->ignore_unmap = 2;
1799 }
1800 }
1801 free(wins);
1802 }
1803}
diff --git a/src/desktops.c b/src/desktops.c
new file mode 100644
index 0000000..74dc908
--- /dev/null
+++ b/src/desktops.c
@@ -0,0 +1,508 @@
1#include "e.h"
2
3static Evas_List desktops = NULL;
4static Window e_base_win = 0;
5static int screen_w, screen_h;
6static int current_desk = 0;
7
8static void e_idle(void *data);
9static void e_mouse_down(Eevent * ev);
10static void e_mouse_up(Eevent * ev);
11static void e_mouse_in(Eevent * ev);
12static void e_mouse_out(Eevent * ev);
13static void e_window_expose(Eevent * ev);
14
15static void
16e_idle(void *data)
17{
18 Evas_List l;
19
20 for (l = desktops; l; l = l->next)
21 {
22 E_Desktop *desk;
23
24 desk = l->data;
25 e_desktops_update(desk);
26 }
27 e_db_runtime_flush();
28}
29
30/* handling mouse down events */
31static void
32e_mouse_down(Eevent * ev)
33{
34 Ev_Mouse_Down *e;
35
36 e = ev->event;
37 {
38 Evas_List l;
39
40 for (l = desktops; l; l = l->next)
41 {
42 E_Desktop *desk;
43
44 desk = l->data;
45
46 if (desk->win.desk == e->win)
47 {
48 Evas evas;
49 int x, y;
50
51 evas = desk->evas.desk;
52 e_window_get_root_relative_location(evas_get_window(evas),
53 &x, &y);
54 x = e->rx - x;
55 y = e->ry - y;
56 evas_event_button_down(evas, x, y, e->button);
57 return;
58 }
59 }
60 }
61}
62/* handling mouse up events */
63static void
64e_mouse_up(Eevent * ev)
65{
66 Ev_Mouse_Up *e;
67
68 e = ev->event;
69 {
70 Evas_List l;
71
72 for (l = desktops; l; l = l->next)
73 {
74 E_Desktop *desk;
75
76 desk = l->data;
77
78 if (desk->win.desk == e->win)
79 {
80 Evas evas;
81 int x, y;
82
83 evas = desk->evas.desk;
84 e_window_get_root_relative_location(evas_get_window(evas),
85 &x, &y);
86 x = e->rx - x;
87 y = e->ry - y;
88 evas_event_button_up(evas, x, y, e->button);
89 return;
90 }
91 }
92 }
93}
94/* handling mouse move events */
95static void
96e_mouse_move(Eevent * ev)
97{
98 Ev_Mouse_Move *e;
99
100 e = ev->event;
101 {
102 Evas_List l;
103
104 for (l = desktops; l; l = l->next)
105 {
106 E_Desktop *desk;
107
108 desk = l->data;
109
110 if (desk->win.desk == e->win)
111 {
112 Evas evas;
113 int x, y;
114
115 evas = desk->evas.desk;
116 e_window_get_root_relative_location(evas_get_window(evas),
117 &x, &y);
118 x = e->rx - x;
119 y = e->ry - y;
120 evas_event_move(evas, x, y);
121 return;
122 }
123 }
124 }
125}
126
127/* handling mouse enter events */
128static void
129e_mouse_in(Eevent * ev)
130{
131 Ev_Window_Enter *e;
132
133 e = ev->event;
134 {
135 Evas_List l;
136
137 for (l = desktops; l; l = l->next)
138 {
139 E_Desktop *desk;
140
141 desk = l->data;
142
143 if (desk->win.desk == e->win)
144 {
145 Evas evas;
146 int x, y;
147
148 evas = desk->evas.desk;
149 e_window_get_root_relative_location(evas_get_window(evas),
150 &x, &y);
151 x = e->rx - x;
152 y = e->ry - y;
153 evas_event_move(evas, x, y);
154 evas_event_enter(evas);
155 return;
156 }
157 }
158 }
159}
160/* handling mouse leave events */
161static void
162e_mouse_out(Eevent * ev)
163{
164 Ev_Window_Leave *e;
165
166 e = ev->event;
167 {
168 Evas_List l;
169
170 for (l = desktops; l; l = l->next)
171 {
172 E_Desktop *desk;
173
174 desk = l->data;
175
176 if (desk->win.desk == e->win)
177 {
178 Evas evas;
179 int x, y;
180
181 evas = desk->evas.desk;
182 e_window_get_root_relative_location(evas_get_window(evas),
183 &x, &y);
184 x = e->rx - x;
185 y = e->ry - y;
186 evas_event_move(evas, x, y);
187 evas_event_leave(evas);
188 return;
189 }
190 }
191 }
192}
193
194/* handling expose events */
195static void
196e_window_expose(Eevent * ev)
197{
198 Ev_Window_Expose *e;
199
200 e = ev->event;
201 {
202 Evas_List l;
203
204 for (l = desktops; l; l = l->next)
205 {
206 E_Desktop *desk;
207
208 desk = l->data;
209 if (!desk->evas.pmap)
210 {
211 if (evas_get_window(desk->evas.desk) == e->win)
212 evas_update_rect(desk->evas.desk, e->x, e->y, e->w, e->h);
213 }
214 }
215 }
216}
217
218void
219e_desktops_init(void)
220{
221 E_Desktop *desk;
222
223 e_window_get_geometry(0, NULL, NULL, &screen_w, &screen_h);
224 e_base_win = e_window_override_new(0, 0, 0, screen_w, screen_h);
225 e_window_show(e_base_win);
226 desk = e_desktops_new();
227 e_desktops_show(desk);
228 e_event_filter_handler_add(EV_MOUSE_DOWN, e_mouse_down);
229 e_event_filter_handler_add(EV_MOUSE_UP, e_mouse_up);
230 e_event_filter_handler_add(EV_MOUSE_MOVE, e_mouse_move);
231 e_event_filter_handler_add(EV_MOUSE_IN, e_mouse_in);
232 e_event_filter_handler_add(EV_MOUSE_OUT, e_mouse_out);
233 e_event_filter_handler_add(EV_WINDOW_EXPOSE, e_window_expose);
234 e_event_filter_idle_handler_add(e_idle, NULL);
235
236 e_icccm_advertise_e_compat();
237 e_icccm_advertise_mwm_compat();
238 e_icccm_advertise_gnome_compat();
239 e_icccm_advertise_kde_compat();
240 e_icccm_advertise_net_compat();
241
242 e_icccm_set_desk_area_size(0, 1, 1);
243 e_icccm_set_desk_area(0, 0, 0);
244 e_icccm_set_desk(0, 0);
245}
246
247void
248e_desktops_scroll(E_Desktop *desk, int dx, int dy)
249{
250 Evas_List l;
251 int xd, yd, wd, hd;
252 int grav, grav_stick;
253
254 /* set grav */
255 if ((dx ==0) && (dy == 0)) return;
256 desk->x -= dx;
257 desk->y -= dy;
258 xd = yd = wd = hd = 0;
259 grav = NorthWestGravity;
260 grav_stick= SouthEastGravity;
261 if ((dx <= 0) && (dy <= 0))
262 {
263 grav = NorthWestGravity;
264 grav_stick = SouthEastGravity;
265 xd = dx;
266 yd = dy;
267 wd = -dx;
268 hd = -dy;
269 }
270 else if ((dx >= 0) && (dy <= 0))
271 {
272 grav = NorthEastGravity;
273 grav_stick = SouthWestGravity;
274 xd = 0;
275 yd = dy;
276 wd = dx;
277 hd = -dy;
278 }
279 else if ((dx >= 0) && (dy >= 0))
280 {
281 grav = SouthEastGravity;
282 grav_stick = NorthWestGravity;
283 xd = 0;
284 yd = 0;
285 wd = dx;
286 hd = dy;
287 }
288 else if ((dx <= 0) && (dy >= 0))
289 {
290 grav = SouthWestGravity;
291 grav_stick = NorthEastGravity;
292 xd = dx;
293 yd = 0;
294 wd = -dx;
295 hd = dy;
296 }
297 for (l = desk->windows; l; l = l->next)
298 {
299 E_Border *b;
300
301 b = l->data;
302 /* if sticky */
303/* e_window_gravity_set(b->win.main, StaticGravity); */
304 e_window_gravity_set(b->win.main, grav);
305 }
306 grav_stick = StaticGravity;
307 e_window_gravity_set(desk->win.desk, grav_stick);
308 /* scroll */
309 e_window_move_resize(desk->win.container,
310 xd, yd,
311 screen_w + wd, screen_h + hd);
312 /* reset */
313 for (l = desk->windows; l; l = l->next)
314 {
315 E_Border *b;
316
317 b = l->data;
318 e_window_gravity_set(b->win.main, grav_stick);
319 }
320 e_window_move_resize(desk->win.container, 0, 0, screen_w, screen_h);
321 e_window_gravity_reset(desk->win.desk);
322 for (l = desk->windows; l; l = l->next)
323 {
324 E_Border *b;
325
326 b = l->data;
327 e_window_gravity_reset(b->win.main);
328 b->current.requested.x += dx;
329 b->current.requested.y += dy;
330 b->current.x = b->current.requested.x;
331 b->current.y = b->current.requested.y;
332 b->previous.requested.x = b->current.requested.x;
333 b->previous.requested.y = b->current.requested.y;
334 b->previous.x = b->current.x;
335 b->previous.y = b->current.y;
336 b->changed = 1;
337 }
338 e_sync();
339}
340
341void
342e_desktops_free(E_Desktop *desk)
343{
344 e_window_destroy(desk->win.main);
345 IF_FREE(desk->name);
346 IF_FREE(desk->dir);
347 FREE(desk);
348}
349
350void
351e_desktops_init_file_display(E_Desktop *desk)
352{
353 int max_colors = 216;
354 int font_cache = 1024 * 1024;
355 int image_cache = 8192 * 1024;
356 char *font_dir = "./fnt";
357
358 /* software */
359 desk->evas.desk = evas_new_all(e_display_get(),
360 desk->win.container,
361 0, 0, screen_w, screen_h,
362 RENDER_METHOD_ALPHA_SOFTWARE,
363 max_colors,
364 font_cache,
365 image_cache,
366 font_dir);
367 desk->win.desk = evas_get_window(desk->evas.desk);
368 e_add_child(desk->win.container, desk->win.desk);
369 /* pixmap backing for desktop */
370 desk->evas.pmap = e_pixmap_new(desk->win.desk, screen_w, screen_h, 0);
371 evas_set_output(desk->evas.desk, e_display_get(), desk->evas.pmap,
372 evas_get_visual(desk->evas.desk), evas_get_colormap(desk->evas.desk));
373 e_window_set_background_pixmap(desk->win.desk, desk->evas.pmap);
374 /* normal stuff */
375 e_window_set_events(desk->win.desk, XEV_EXPOSE | XEV_MOUSE_MOVE | XEV_BUTTON | XEV_IN_OUT);
376 e_window_show(desk->win.desk);
377 {
378 Evas_Object o;
379 Evas e;
380
381 e = desk->evas.desk;
382 o = evas_add_image_from_file(e, "../data/bg.png");
383 evas_move(e, o, 0, 0);
384 evas_resize(e, o, screen_w, screen_h);
385 evas_show(e, o);
386 o = evas_add_image_from_file(e, "../data/e_logo.png");
387 evas_move(e, o, 0, 0);
388 evas_show(e, o);
389 }
390}
391
392E_Desktop *
393e_desktops_new(void)
394{
395 E_Desktop *desk;
396
397 desk = NEW(E_Desktop, 1);
398 ZERO(desk, E_Desktop, 1);
399
400 OBJ_INIT(desk, e_desktops_free);
401
402 desk->win.main = e_window_override_new(e_base_win, 0, 0, screen_w, screen_h);
403 desk->win.container = e_window_override_new(desk->win.main, 0, 0, screen_w, screen_h);
404
405 e_window_show(desk->win.container);
406
407 desk->x = 0;
408 desk->y = 0;
409 desk->real.w = screen_w;
410 desk->real.h = screen_h;
411 desk->virt.w = screen_w;
412 desk->virt.h = screen_h;
413
414 desktops = evas_list_append(desktops, desk);
415
416 e_desktops_init_file_display(desk);
417
418 return desk;
419}
420
421void
422e_desktops_add_border(E_Desktop *d, E_Border *b)
423{
424 if ((!d) || (!b)) return;
425 b->desk = d;
426 e_border_raise(b);
427}
428
429void
430e_desktops_del_border(E_Desktop *d, E_Border *b)
431{
432 if ((!d) || (!b)) return;
433 d->windows = evas_list_remove(d->windows, b);
434 b->desk = NULL;
435}
436
437void
438e_desktops_delete(E_Desktop *d)
439{
440 OBJ_DO_FREE(d);
441}
442
443void
444e_desktops_show(E_Desktop *d)
445{
446 e_window_show(d->win.main);
447}
448
449void
450e_desktops_hide(E_Desktop *d)
451{
452 e_window_hide(d->win.main);
453}
454
455int
456e_desktops_get_num(void)
457{
458 Evas_List l;
459 int i;
460
461 for (i = 0, l = desktops; l; l = l->next, i++);
462 return i;
463}
464
465E_Desktop *
466e_desktops_get(int d)
467{
468 Evas_List l;
469 int i;
470
471 for (i = 0, l = desktops; l; l = l->next, i++)
472 {
473 if (i == d) return (E_Desktop *)l->data;
474 }
475 return NULL;
476}
477
478int
479e_desktops_get_current(void)
480{
481 return current_desk;
482}
483
484void
485e_desktops_update(E_Desktop *desk)
486{
487 Imlib_Updates up;
488
489 up = evas_render_updates(desk->evas.desk);
490 if (up)
491 {
492 Imlib_Updates u;
493
494 printf("rendered desktop\n");
495 for (u = up; u; u = imlib_updates_get_next(u))
496 {
497 int x, y, w, h;
498
499 imlib_updates_get_coordinates(u, &x, &y, &w, &h);
500 e_window_clear_area(desk->win.desk, x, y, w, h);
501 }
502 imlib_updates_free(up);
503 }
504 if (desk->changed)
505 {
506 desk->changed = 0;
507 }
508}
diff --git a/src/e.h b/src/e.h
new file mode 100644
index 0000000..41565f7
--- /dev/null
+++ b/src/e.h
@@ -0,0 +1,337 @@
1#include <X11/Xlib.h>
2#include <Imlib2.h>
3#include <Evas.h>
4#include <Ebits.h>
5#include <Ecore.h>
6#include <Edb.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <unistd.h>
10#include <string.h>
11#include <math.h>
12#include <sys/stat.h>
13#include <sys/types.h>
14#include <sys/ipc.h>
15#include <sys/msg.h>
16#include <dirent.h>
17#include <errno.h>
18#include <signal.h>
19
20#define E_PROF 1
21#ifdef E_PROF
22extern Evas_List __e_profiles;
23
24typedef struct _e_prof
25{
26 char *func;
27 double total;
28 double t1, t2;
29} E_Prof;
30#define E_PROF_START(_prof_func) \
31{ \
32E_Prof __p, *__pp; \
33Evas_List __pl; \
34__p.func = _prof_func; \
35__p.total = 0.0; \
36__p.t1 = e_get_time(); \
37__p.t2 = 0.0;
38
39#define E_PROF_STOP \
40__p.t2 = e_get_time(); \
41for (__pl = __e_profiles; __pl; __pl = __pl->next) \
42{ \
43__pp = __pl->data; \
44if (!strcmp(__p.func, __pp->func)) \
45{ \
46__pp->total += (__p.t2 - __p.t1); \
47break; \
48} \
49} \
50if (!__pl) \
51{ \
52__pp = NEW(E_Prof, 1); \
53__pp->func = __p.func; \
54__pp->total = __p.t2 - __p.t1; \
55__pp->t1 = 0.0; \
56__pp->t2 = 0.0; \
57__e_profiles = evas_list_append(__e_profiles, __pp); \
58} \
59}
60#define E_PROF_DUMP \
61{ \
62Evas_List __pl; \
63for (__pl = __e_profiles; __pl; __pl = __pl->next) \
64{ \
65E_Prof *__p; \
66__p = __pl->data; \
67printf("%3.3f : %s()\n", __p->total, __p->func); \
68} \
69}
70#else
71#define E_PROF_START(_prof_func)
72#define E_PROF_STOP
73#define E_PROF_DUMP
74#endif
75
76
77#define OBJ_REF(_e_obj) _e_obj->references++
78#define OBJ_UNREF(_e_obj) _e_obj->references--;
79#define OBJ_IF_FREE(_e_obj) if (_e_obj->references == 0)
80#define OBJ_FREE(_e_obj) _e_obj->e_obj_free(_e_obj)
81#define OBJ_DO_FREE(_e_obj) \
82OBJ_UNREF(_e_obj); \
83OBJ_IF_FREE(_e_obj) \
84{ \
85OBJ_FREE(_e_obj); \
86}
87
88#define OBJ_PROPERTIES \
89int references; \
90void (*e_obj_free) (void *e_obj);
91#define OBJ_INIT(_e_obj, _e_obj_free_func) \
92{ \
93_e_obj->references = 1; \
94_e_obj->e_obj_free = (void *) _e_obj_free_func; \
95}
96
97#define SPANS_COMMON(x1, w1, x2, w2) \
98 (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
99
100#define ACT_MOUSE_IN 0
101#define ACT_MOUSE_OUT 1
102#define ACT_MOUSE_CLICK 2
103#define ACT_MOUSE_DOUBLE 3
104#define ACT_MOUSE_TRIPLE 4
105#define ACT_MOUSE_UP 5
106#define ACT_MOUSE_CLICKED 6
107#define ACT_MOUSE_MOVE 7
108#define ACT_KEY_DOWN 8
109#define ACT_KEY_UP 9
110
111#define SET_BORDER_GRAVITY(_b, _grav) \
112e_window_gravity_set(_b->win.container, _grav); \
113e_window_gravity_set(_b->win.input, _grav); \
114e_window_gravity_set(_b->win.l, _grav); \
115e_window_gravity_set(_b->win.r, _grav); \
116e_window_gravity_set(_b->win.t, _grav); \
117e_window_gravity_set(_b->win.b, _grav);
118
119typedef struct _E_Object E_Object;
120typedef struct _E_Border E_Border;
121typedef struct _E_Grab E_Grab;
122typedef struct _E_Action E_Action;
123typedef struct _E_Action_Proto E_Action_Proto;
124typedef struct _E_Desktop E_Desktop;
125typedef struct _E_Rect E_Rect;
126
127struct _E_Object
128{
129 OBJ_PROPERTIES;
130};
131
132struct _E_Border
133{
134 OBJ_PROPERTIES;
135
136 struct {
137 Window main;
138 Window l, r, t, b;
139 Window input;
140 Window container;
141 Window client;
142 } win;
143 struct {
144 Evas l, r, t, b;
145 } evas;
146 struct {
147 Pixmap l, r, t, b;
148 } pixmap;
149 struct {
150 int new;
151 Ebits_Object l, r, t, b;
152 } bits;
153
154 struct {
155 struct {
156 int x, y, w, h;
157 int visible;
158 int dx, dy;
159 } requested;
160 int x, y, w, h;
161 int visible;
162 int selected;
163 } current, previous;
164
165 struct {
166 struct {
167 int w, h;
168 double aspect;
169 } base, min, max, step;
170 int layer;
171 int shaped;
172 char *title;
173 char *name;
174 char *class;
175 char *command;
176 Window group;
177 int sticky;
178 Colormap colormap;
179 int fixed;
180 int arrange_ignore;
181 int shaded;
182 int hidden;
183 int borderless;
184 int titlebar;
185 int border;
186 int handles;
187 } client;
188
189 struct {
190 int move, resize;
191 } mode;
192
193 int has_shape;
194 int shape_changes;
195
196 int ignore_unmap;
197
198 Evas_List grabs;
199 E_Desktop *desk;
200
201 int changed;
202};
203
204struct _E_Grab
205{
206 int button;
207 Ev_Key_Modifiers mods;
208 int any_mod;
209 int remove_after;
210 int allow;
211};
212
213struct _E_Action
214{
215 OBJ_PROPERTIES;
216
217 char *name;
218 char *action;
219 char *params;
220 int event;
221 int button;
222 char *key;
223 int modifiers;
224 E_Action_Proto *action_proto;
225 void *object;
226 int started;
227};
228
229struct _E_Action_Proto
230{
231 OBJ_PROPERTIES;
232
233 char *action;
234 void (*func_start) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
235 void (*func_stop) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry);
236 void (*func_go) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy);
237};
238
239struct _E_Desktop
240{
241 OBJ_PROPERTIES;
242
243 char *name;
244 char *dir;
245 struct {
246 Window main;
247 Window container;
248 Window desk;
249 } win;
250 struct {
251 Pixmap pmap;
252 Evas desk;
253 } evas;
254 int x, y;
255 struct {
256 int w, h;
257 } real, virt;
258 Evas_List windows;
259 int changed;
260};
261
262struct _E_Rect
263{
264 int x, y, w, h;
265 int v1, v2, v3, v4;
266};
267
268void e_action_add_proto(char *action,
269 void (*func_start) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry),
270 void (*func_stop) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry),
271 void (*func_go) (void *o, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy));
272void e_actions_init(void);
273void e_action_start(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry);
274void e_action_stop(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry);
275void e_action_go(char *action, int act, int button, char *key, Ev_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry, int dx, int dy);
276void e_action_stop_by_object(void *o, void *data, int x, int y, int rx, int ry);
277
278void e_border_apply_border(E_Border *b);
279E_Border * e_border_new(void);
280E_Border * e_border_adopt(Window win, int use_client_pos);
281void e_border_free(E_Border *b);
282void e_border_remove_mouse_grabs(E_Border *b);
283void e_border_attach_mouse_grabs(E_Border *b);
284void e_border_remove_all_mouse_grabs(void);
285void e_border_attach_all_mouse_grabs(void);
286void e_border_redo_grabs(void);
287E_Border * e_border_find_by_window(Window win);
288void e_border_set_bits(E_Border *b, char *file);
289void e_border_set_color_class(E_Border *b, char *class, int rr, int gg, int bb, int aa);
290void e_border_adjust_limits(E_Border *b);
291void e_border_update(E_Border *b);
292void e_border_set_layer(E_Border *b, int layer);
293void e_border_raise(E_Border *b);
294void e_border_lower(E_Border *b);
295void e_border_raise_above(E_Border *b, E_Border *above);
296void e_border_lower_below(E_Border *b, E_Border *below);
297void e_border_init(void);
298
299void e_icccm_move_resize(Window win, int x, int y, int w, int h);
300void e_icccm_delete(Window win);
301void e_icccm_state_mapped(Window win);
302void e_icccm_state_iconified(Window win);
303void e_icccm_state_withdrawn(Window win);
304void e_icccm_adopt(Window win);
305void e_icccm_release(Window win);
306void e_icccm_get_size_info(Window win, E_Border *b);
307void e_icccm_get_mwm_hints(Window win, E_Border *b);
308void e_icccm_get_layer(Window win, E_Border *b);
309void e_icccm_set_frame_size(Window win, int l, int r, int t, int b);
310void e_icccm_set_desk_area(Window win, int ax, int ay);
311void e_icccm_set_desk_area_size(Window win, int ax, int ay);
312void e_icccm_set_desk(Window win, int d);
313void e_icccm_advertise_e_compat(void);
314void e_icccm_advertise_mwm_compat(void);
315void e_icccm_advertise_gnome_compat(void);
316void e_icccm_advertise_kde_compat(void);
317void e_icccm_advertise_net_compat(void);
318
319void e_desktops_init(void);
320void e_desktops_scroll(E_Desktop *desk, int dx, int dy);
321void e_desktops_free(E_Desktop *desk);
322void e_desktops_init_file_display(E_Desktop *desk);
323E_Desktop * e_desktops_new(void);
324void e_desktops_add_border(E_Desktop *d, E_Border *b);
325void e_desktops_del_border(E_Desktop *d, E_Border *b);
326void e_desktops_delete(E_Desktop *d);
327void e_desktops_show(E_Desktop *d);
328void e_desktops_hide(E_Desktop *d);
329int e_desktops_get_num(void);
330E_Desktop * e_desktops_get(int d);
331int e_desktops_get_current(void);
332void e_desktops_update(E_Desktop *desk);
333
334void e_resist_border(E_Border *b);
335
336time_t e_file_modified_time(char *file);
337
diff --git a/src/icccm.c b/src/icccm.c
new file mode 100644
index 0000000..e81f449
--- /dev/null
+++ b/src/icccm.c
@@ -0,0 +1,403 @@
1#include "e.h"
2
3/* Motif window hints */
4#define MWM_HINTS_FUNCTIONS (1L << 0)
5#define MWM_HINTS_DECORATIONS (1L << 1)
6#define MWM_HINTS_INPUT_MODE (1L << 2)
7#define MWM_HINTS_STATUS (1L << 3)
8
9/* bit definitions for MwmHints.functions */
10#define MWM_FUNC_ALL (1L << 0)
11#define MWM_FUNC_RESIZE (1L << 1)
12#define MWM_FUNC_MOVE (1L << 2)
13#define MWM_FUNC_MINIMIZE (1L << 3)
14#define MWM_FUNC_MAXIMIZE (1L << 4)
15#define MWM_FUNC_CLOSE (1L << 5)
16
17/* bit definitions for MwmHints.decorations */
18#define MWM_DECOR_ALL (1L << 0)
19#define MWM_DECOR_BORDER (1L << 1)
20#define MWM_DECOR_RESIZEH (1L << 2)
21#define MWM_DECOR_TITLE (1L << 3)
22#define MWM_DECOR_MENU (1L << 4)
23#define MWM_DECOR_MINIMIZE (1L << 5)
24#define MWM_DECOR_MAXIMIZE (1L << 6)
25
26/* bit definitions for MwmHints.inputMode */
27#define MWM_INPUT_MODELESS 0
28#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
29#define MWM_INPUT_SYSTEM_MODAL 2
30#define MWM_INPUT_FULL_APPLICATION_MODAL 3
31
32#define PROP_MWM_HINTS_ELEMENTS 5
33
34/* Motif window hints */
35typedef struct _mwmhints
36{
37 int flags;
38 int functions;
39 int decorations;
40 int inputMode;
41 int status;
42}
43MWMHints;
44
45void
46e_icccm_move_resize(Window win, int x, int y, int w, int h)
47{
48 e_window_send_event_move_resize(win, x, y, w, h);
49}
50
51void
52e_icccm_delete(Window win)
53{
54 static Atom a_wm_delete_window = 0;
55 static Atom a_wm_protocols = 0;
56 int *props;
57 int size;
58 int del_win = 0;
59
60 E_ATOM(a_wm_delete_window, "WM_DELETE_WINDOW");
61 E_ATOM(a_wm_protocols, "WM_PROTOCOLS");
62
63 props = e_window_property_get(win, a_wm_protocols, XA_ATOM, &size);
64 if (props)
65 {
66 int i, num;
67
68 num = size / sizeof(int);
69 for (i = 0; i < num; i++)
70 {
71 if (props[i] == (int)a_wm_delete_window) del_win = 1;
72 }
73 FREE(props);
74 }
75 if (del_win)
76 {
77 unsigned int data[5];
78
79 data[0] = a_wm_delete_window;
80 data[1] = CurrentTime;
81 e_window_send_client_message(win, a_wm_protocols, 32, data);
82 }
83 else
84 {
85 e_window_kill_client(win);
86 }
87}
88
89void
90e_icccm_state_mapped(Window win)
91{
92 static Atom a_wm_state = 0;
93 unsigned int data[2];
94
95 E_ATOM(a_wm_state, "WM_STATE");
96 data[0] = NormalState;
97 data[1] = 0;
98 e_window_property_set(win, a_wm_state, a_wm_state, 32, data, 2);
99}
100
101void
102e_icccm_state_iconified(Window win)
103{
104 static Atom a_wm_state = 0;
105 unsigned int data[2];
106
107 E_ATOM(a_wm_state, "WM_STATE");
108 data[0] = IconicState;
109 data[1] = 0;
110 e_window_property_set(win, a_wm_state, a_wm_state, 32, data, 2);
111}
112
113void
114e_icccm_state_withdrawn(Window win)
115{
116 static Atom a_wm_state = 0;
117 unsigned int data[2];
118
119 E_ATOM(a_wm_state, "WM_STATE");
120 data[0] = WithdrawnState;
121 data[1] = 0;
122 e_window_property_set(win, a_wm_state, a_wm_state, 32, data, 2);
123}
124
125void
126e_icccm_adopt(Window win)
127{
128 e_window_add_to_save_set(win);
129}
130
131void
132e_icccm_release(Window win)
133{
134 e_window_del_from_save_set(win);
135}
136