Initial Commit

This commit is contained in:
Gustavo Sverzut Barbieri 2013-11-13 18:57:28 -02:00
commit 3e5e849e30
15 changed files with 5690 additions and 0 deletions

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
*.o
.deps
.dirstamp
aclocal.m4
autom4te.cache
compile
config.h
config.h.in
config.log
config.status
configure
data/themes/*.edj
depcomp
eruler-*.tar.bz2
eruler-*.tar.gz
INSTALL
install-sh
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
Makefile
Makefile.in
missing
src/bin/eruler
stamp-h1

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Gustavo Sverzut Barbieri <barbieri@gmail.com>

339
COPYING Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

75
Makefile.am Normal file
View File

@ -0,0 +1,75 @@
ACLOCAL_AMFLAGS = -I m4
MAINTAINERCLEANFILES = \
Makefile.in \
$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz \
$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 \
aclocal.m4 \
config.guess \
config.h.in \
config.sub \
configure \
compile \
depcomp \
install-sh \
ltconfig \
ltmain.sh \
missing \
mkinstalldirs \
stamp-h.in \
stamp-h \
m4/libtool.m4 \
m4/lt~obsolete.m4 \
m4/ltoptions.m4 \
m4/ltsugar.m4 \
m4/ltversion.m4
bin_PROGRAMS = src/bin/eruler
src_bin_eruler_SOURCES = \
src/bin/main.c \
src/bin/private.h
if HAVE_ECORE_X
src_bin_eruler_SOURCES += src/bin/platform-x.c
endif
src_bin_eruler_LDADD = @ERULER_LIBS@
src_bin_eruler_CPPFLAGS = \
-I$(top_builddir) \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
@ERULER_CFLAGS@
desktopdir = $(datadir)/applications
desktop_DATA = data/desktop/eruler.desktop
iconsdir = $(datadir)/icons
icons_DATA = data/icons/eruler.png
EDJE_CC = @edje_cc@
EDJE_FLAGS_VERBOSE_ =
EDJE_FLAGS_VERBOSE_0 =
EDJE_FLAGS_VERBOSE_1 = -v
EDJE_FLAGS = $(EDJE_FLAGS_VERBOSE_$(V))
AM_V_EDJ = $(am__v_EDJ_$(V))
am__v_EDJ_ = $(am__v_EDJ_$(AM_DEFAULT_VERBOSITY))
am__v_EDJ_0 = @echo " EDJ " $@;
themesdir = $(pkgdatadir)/themes
themes_DATA = data/themes/default.edj
themes_sources = data/themes/default.edc
data/themes/default.edj: Makefile data/themes/default.edc
@$(MKDIR_P) $(top_builddir)/data/themes
$(AM_V_EDJ)$(EDJE_CC) $(EDJE_FLAGS) \
$(top_srcdir)/data/themes/default.edc \
$(top_builddir)/data/themes/default.edj
EXTRA_DIST = README AUTHORS COPYING autogen.sh \
$(desktop_DATA) \
$(icons_DATA) \
$(themes_sources)
clean-local:
rm -f $(themes_DATA)

79
README Normal file
View File

@ -0,0 +1,79 @@
ERuler - screen rule and measurement tools.
ERuler is a software that allows on-screen virtual rule and
measurement of areas.
USAGE
=====
The traditional use is to press your mouse's left-button to start
measuring, then move your mouse to the end point and release. This
will give you a box with both points, the origin coordinates as well
as the region size -- all in pixels.
One can also use the keyboard to do the above flow by using "Space"
key to mark start and end points, using the mouse or keyboard arrows
to move the cursor. While using the arrows one can press "Shift" key
modifier to use 10 pixels instead of a single one in that direction,
useful for large regions.
Alternatively one can type the coordinates during runtime by using "@"
shortcut, or using the "Type coordinates" button. This will give you a
text entry so you can type "x y width height" values (all separated by
spaces).
Last but not least you can use the command line argument "--ruler" (-r
for short) to pre-populate the screen. In the case of using multiple
screens you must specify the origin as absolute position in a global
scene (if you have two 800x600 screens side by side and want to
address the horizontal position 10 in right one, use 810 (800 + 10).
It is possible to change the type/style of the measurement box (ruler)
by using "t" shortcut or the Style selector in the toolbox.
One can create multiple measurements by using "c" shortcut or the
"Create Ruler" button in the toolbox. The operations will then all be
on the newly created ruler. The distance between all rulers are
displayed in semi-transparent colors and once mouse-over they become
bolder. If those distance hints are distracting you, use "d" ("Show
distances") to toggle its visibility.
NOTE ABOUT ZOOM
---------------
There is no way in X11 to zoom into a screen region, particularly if
we're not the compositor. To provide the zoom capability we take a
screenshot at the beginning and use this copy. However once the screen
is updated, the copy becomes out of sync and one must toggle zoom to
refresh it. You'll see that ERuler will hide itself for a moment then
restore automatically, this is an implementation annoyance we can't
get rid anytime soon :-(
KEYBOARD SHORTCUTS
------------------
* Escape: quit;
* F2: toggle ERuler visibility;
* p: print size to stdout;
* c: create new ruler;
* Control-c: clear current zone rulers;
* g: toggle display of guide lines;
* d: toggle display of distances between boxes;
* t: toggle ruler type (dark, light, filled...);
* z: toggle zoom;
* x: toggle display of colors in hexadecimal;
* @: open command box to type ruler placement;
* Space: start or stop measure using keyboard;
* Left: move ruler start point to the left (Shift to use 10px step);
* Control-Left: move ruler end point to the left (Shift to use 10px
step);
* Right: move ruler start point to the right (Shift to use 10px
step);
* Control-Right: move ruler end point to the right (Shift to use 10px
step);
* Up: move ruler start point up (Shift to use 10px step);
* Control-Up: move ruler end point up (Shift to use 10px step);
* Down: move ruler start point down (Shift to use 10px step);
* Control-Down: move ruler end point down (Shift to use 10px step).

16
autogen.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh
touch README
echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi

91
configure.ac Normal file
View File

@ -0,0 +1,91 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([eruler], [0.1.0], [enlightenment-devel@lists.sourceforge.net])
AC_PREREQ([2.60])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.6 dist-bzip2 foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AM_PROG_CC_C_O
AC_C___ATTRIBUTE__
efl_version="1.7.0"
AC_SUBST(efl_version)
requirements="\
elementary >= ${efl_version} \
eina >= ${efl_version} \
evas >= ${efl_version} \
ecore >= ${efl_version} \
ecore-file >= ${efl_version} \
edje >= ${efl_version} \
"
want_ecore_x="yes"
AC_ARG_ENABLE([ecore-x],
[AC_HELP_STRING([--disable-ecore-x], [disable ecore-x support. @<:@default=enabled@:>@])],
[want_ecore_x=$enableval], [])
if test "$want_ecore_x" != "no"; then
requirements="${requirements} ecore-x >= ${efl_version}"
fi
PKG_CHECK_MODULES([ERULER], [${requirements}])
if test "$want_ecore_x" != "no"; then
AC_DEFINE([HAVE_ECORE_X], [1], [Should use Ecore_X])
fi
AM_CONDITIONAL([HAVE_ECORE_X], [test "$want_ecore_x" != "no"])
EFL_WITH_BIN([edje], [edje-cc], [edje_cc])
with_max_log_level=""
AC_ARG_WITH(maximum-log-level,
[AC_HELP_STRING([--with-maximum-log-level=NUMBER],
[limit eruler log level to the given number, any call to EINA_LOG() with values greater than this will be compiled out, ignoring runtime settings, but saving function calls.])],
[
if test "x${withval}" != "xno"; then
if echo "${withval}" | grep -E '^[[0-9]]+$' >/dev/null 2>/dev/null; then
AC_MSG_NOTICE([ignoring any EINA_LOG() with level greater than ${withval}])
with_max_log_level="${withval}"
else
AC_MSG_ERROR([--with-maximum-log-level takes a decimal number, got "${withval}" instead.])
fi
fi
], [:])
if test -n "${with_max_log_level}"; then
AC_DEFINE_UNQUOTED(EINA_LOG_LEVEL_MAXIMUM, ${with_max_log_level}, [if set, logging is limited to this amount.])
fi
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
#####################################################################
## Info
echo
echo
echo
echo "------------------------------------------------------------------------"
echo "$PACKAGE $VERSION"
echo "------------------------------------------------------------------------"
echo
echo "Compilation................: make (or gmake)"
echo " CPPFLAGS.................: $CPPFLAGS"
echo " CFLAGS...................: $CFLAGS"
echo " LDFLAGS..................: $LDFLAGS"
echo
echo "Installation...............: make install (as root if needed, with 'su' or 'sudo')"
echo " prefix...................: $prefix"
echo
echo "Platforms:"
echo " X11......................: ${want_ecore_x}"

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ERuler
GenericName=Screen Ruler
Comment=On-Screen Rule and Measurement
Exec=eruler
Icon=eruler
Categories=Graphics
StartupWMClass=eruler

BIN
data/icons/eruler.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

1668
data/themes/default.edc Normal file

File diff suppressed because it is too large Load Diff

47
m4/ac_attribute.m4 Normal file
View File

@ -0,0 +1,47 @@
dnl Copyright (C) 2004-2008 Kim Woelders
dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
dnl That code is public domain and can be freely used or copied.
dnl Originally snatched from somewhere...
dnl Macro for checking if the compiler supports __attribute__
dnl Usage: AC_C___ATTRIBUTE__
dnl call AC_DEFINE for HAVE___ATTRIBUTE__ and __UNUSED__
dnl if the compiler supports __attribute__, HAVE___ATTRIBUTE__ is
dnl defined to 1 and __UNUSED__ is defined to __attribute__((unused))
dnl otherwise, HAVE___ATTRIBUTE__ is not defined and __UNUSED__ is
dnl defined to nothing.
AC_DEFUN([AC_C___ATTRIBUTE__],
[
AC_MSG_CHECKING([for __attribute__])
AC_CACHE_VAL([ac_cv___attribute__],
[AC_TRY_COMPILE(
[
#include <stdlib.h>
int func(int x);
int foo(int x __attribute__ ((unused)))
{
exit(1);
}
],
[],
[ac_cv___attribute__="yes"],
[ac_cv___attribute__="no"]
)])
AC_MSG_RESULT($ac_cv___attribute__)
if test "x${ac_cv___attribute__}" = "xyes" ; then
AC_DEFINE([HAVE___ATTRIBUTE__], [1], [Define to 1 if your compiler has __attribute__])
AC_DEFINE([__UNUSED__], [__attribute__((unused))], [Macro declaring a function argument to be unused])
else
AC_DEFINE([__UNUSED__], [], [Macro declaring a function argument to be unused])
fi
])
dnl End of ac_attribute.m4

71
m4/efl_binary.m4 Normal file
View File

@ -0,0 +1,71 @@
dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
dnl That code is public domain and can be freely used or copied.
dnl Macro that check if a binary is built or not
dnl Usage: EFL_ENABLE_BIN(binary)
dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _)
dnl Define have_binary (- is transformed into _)
dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _)
AC_DEFUN([EFL_ENABLE_BIN],
[
m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
m4_pushdef([DOWN], m4_translit([[$1]], [-A-Z], [_a-z]))dnl
have_[]m4_defn([DOWN])="yes"
dnl configure option
AC_ARG_ENABLE([$1],
[AC_HELP_STRING([--disable-$1], [disable building of ]DOWN)],
[
if test "x${enableval}" = "xyes" ; then
have_[]m4_defn([DOWN])="yes"
else
have_[]m4_defn([DOWN])="no"
fi
])
AC_MSG_CHECKING([whether to build ]DOWN[ binary])
AC_MSG_RESULT([$have_[]m4_defn([DOWN])])
if test "x$have_[]m4_defn([DOWN])" = "xyes"; then
UP[]_PRG=DOWN[${EXEEXT}]
fi
AC_SUBST(UP[]_PRG)
AM_CONDITIONAL(BUILD_[]UP, test "x$have_[]m4_defn([DOWN])" = "xyes")
AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$2], [$3])
])
dnl Macro that check if a binary is built or not
dnl Usage: EFL_WITH_BIN(package, binary, default_value)
dnl Call AC_SUBST(_binary) (_binary is the lowercase of binary, - being transformed into _ by default, or the value set by the user)
AC_DEFUN([EFL_WITH_BIN],
[
m4_pushdef([DOWN], m4_translit([[$2]], [-A-Z], [_a-z]))dnl
dnl configure option
AC_ARG_WITH([$2],
[AC_HELP_STRING([--with-$2=PATH], [specify a specific path to ]DOWN[ @<:@default=$3@:>@])],
[_efl_with_binary=${withval}],
[_efl_with_binary=$(pkg-config --variable=prefix $1)/bin/$3])
DOWN=${_efl_with_binary}
AC_MSG_NOTICE(DOWN[ set to ${_efl_with_binary}])
with_binary_[]m4_defn([DOWN])=${_efl_with_binary}
AC_SUBST(DOWN)
])

2663
src/bin/main.c Normal file

File diff suppressed because it is too large Load Diff

556
src/bin/platform-x.c Normal file
View File

@ -0,0 +1,556 @@
#include "private.h"
#include <Ecore_X.h>
static Eina_Bool has_xinerama = EINA_TRUE;
static Eina_Bool windows_visible = EINA_TRUE;
static Eina_List *zones;
static Eina_List *roots;
static Eina_List *key_grabs;
static const Zone *grabbed_zone;
static Ecore_X_Window temp_xwin;
static Ecore_Event_Handler *mouse_out_handler;
static Ecore_Event_Handler *key_down_handler;
typedef struct _X_Key_Grab X_Key_Grab;
struct _X_Key_Grab {
const char *keyname;
void (*cb)(void *data, const char *keyname);
const void *cb_data;
};
static X_Key_Grab *
_x_key_grab_new(const char *keyname, void (*cb)(void *data, const char *keyname), const void *data)
{
X_Key_Grab *kg = malloc(sizeof(X_Key_Grab));
EINA_SAFETY_ON_NULL_RETURN_VAL(kg, NULL);
kg->keyname = eina_stringshare_add(keyname);
kg->cb = cb;
kg->cb_data = data;
return kg;
}
static void
_x_key_grab_free(X_Key_Grab *kg)
{
eina_stringshare_del(kg->keyname);
free(kg);
}
static Eina_Bool
_x_zone_screen_copy_do(Zone *zone, Evas_Object *img)
{
Evas_Object *win = zone_win_get(zone);
Ecore_X_Window xid = elm_win_xwindow_get(win);
Ecore_X_Window root = ecore_x_window_root_get(xid);
Ecore_X_Image *capture;
Ecore_X_Window_Attributes watt;
int bpl = 0, rows = 0, bpp = 0, x, y, w, h;
Ecore_X_Colormap cmap;
Ecore_X_Screen *screen;
Ecore_X_Display *display;
void *src, *dst;
Eina_Bool ret;
if (!ecore_x_window_attributes_get(root, &watt))
return EINA_FALSE;
zone_geometry_get(zone, &x, &y, &w, &h);
capture = ecore_x_image_new(w, h, watt.visual, watt.depth);
EINA_SAFETY_ON_NULL_RETURN_VAL(capture, EINA_FALSE);
ret = ecore_x_image_get(capture, root, x, y, 0, 0, w, h);
EINA_SAFETY_ON_FALSE_GOTO(ret, error_clean_capture);
src = ecore_x_image_data_get(capture, &bpl, &rows, &bpp);
EINA_SAFETY_ON_NULL_GOTO(src, error_clean_capture);
display = ecore_x_display_get();
screen = ecore_x_default_screen_get();
cmap = ecore_x_default_colormap_get(display, screen);
evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
evas_object_image_alpha_set(img, EINA_FALSE);
evas_object_image_size_set(img, w, h);
dst = evas_object_image_data_get(img, EINA_TRUE);
ret = ecore_x_image_to_argb_convert(src, bpp, bpl, cmap, watt.visual,
0, 0, w, h,
dst, w * 4, 0, 0);
EINA_SAFETY_ON_FALSE_GOTO(ret, error_clean_dst);
evas_object_image_data_update_add(img, 0, 0, w, h);
evas_object_image_data_set(img, dst);
ecore_x_image_free(capture);
return EINA_TRUE;
error_clean_dst:
evas_object_image_data_set(img, dst);
error_clean_capture:
ecore_x_image_free(capture);
return EINA_FALSE;
}
static void
_x_grab(const Zone *zone)
{
Evas_Object *win = zone_win_get(zone);
Ecore_X_Window xid = elm_win_xwindow_get(win);
if (!ecore_x_pointer_grab(xid))
{
CRI("Could not grab pointer to xwin %#x", xid);
show_gui_error("ERuler couldn't grab the mouse pointer");
return;
}
if (!ecore_x_keyboard_grab(xid))
{
CRI("Could not grab keyboard to xwin %#x", xid);
show_gui_error("ERuler couldn't grab the keyboard");
ecore_x_pointer_ungrab();
return;
}
DBG("Grabbed pointer and keyboard to win %#x (elm_win %p)", xid, win);
grabbed_zone = zone;
}
static void
_x_ungrab(void)
{
if (!grabbed_zone) return;
ecore_x_pointer_ungrab();
ecore_x_keyboard_ungrab();
grabbed_zone = NULL;
}
static Eina_Bool
_x_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_X_Event_Mouse_Out *ev = event;
const Eina_List *l;
const Zone *zone;
DBG("Mouse out of zone %p, check new zone containing %d,%d",
grabbed_zone, ev->root.x, ev->root.y);
EINA_LIST_FOREACH(zones, l, zone)
{
int x, y, w, h;
if (zone == grabbed_zone) continue;
zone_geometry_get(zone, &x, &y, &w, &h);
if (((ev->root.x >= x) && (ev->root.x < x + w)) &&
((ev->root.y >= y) && (ev->root.y < y + h)))
{
DBG("Mouse now at zone %p (%d,%d + %dx%d)", zone, x, y, w, h);
_x_ungrab();
if (windows_visible)
_x_grab(zone);
return EINA_TRUE;
}
}
return EINA_TRUE;
}
static void
_x_grab_current(void)
{
const Eina_List *l;
const Zone *zone;
int mx, my;
ecore_x_pointer_root_xy_get(&mx, &my);
EINA_LIST_FOREACH(zones, l, zone)
{
int x, y, w, h;
zone_geometry_get(zone, &x, &y, &w, &h);
if (((mx >= x) && (mx < x + w)) &&
((my >= y) && (my < y + h)))
{
DBG("Current zone for mouse at %d,%d is %p (%d,%d + %dx%d)",
mx, my, zone, x, y, w, h);
_x_grab(zone);
return;
}
}
ERR("Couldn't find current zone for mouse at %d,%d", mx, my);
}
static void
_x_temp_grab(void)
{
if (mouse_out_handler)
{
ecore_event_handler_del(mouse_out_handler);
mouse_out_handler = NULL;
}
if (!temp_xwin)
temp_xwin = ecore_x_window_input_new(0, 0, 0, 1, 1);
ecore_x_window_show(temp_xwin);
ecore_x_pointer_ungrab();
ecore_x_keyboard_ungrab();
ecore_x_pointer_grab(temp_xwin);
ecore_x_keyboard_grab(temp_xwin);
DBG("Temporary grab for input window %#x", temp_xwin);
}
static void
_x_temp_ungrab(void)
{
DBG("Ungrab temporary for input window %#x", temp_xwin);
if ((eina_list_count(zones) > 1) && (!mouse_out_handler))
{
mouse_out_handler = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT,
_x_mouse_out, NULL);
}
if (temp_xwin)
{
ecore_x_pointer_ungrab();
ecore_x_keyboard_ungrab();
ecore_x_window_free(temp_xwin);
temp_xwin = 0;
}
_x_grab_current();
}
static Eina_Bool
x_pre_setup(void)
{
if (!ecore_x_screen_is_composited(0))
{
show_gui_error("ERuler needs a X11 Composite Manager!<br><br>"
"Consider running <hilight>xcompmgr</hilight> if your "
"Window Manager or Desktop Environment doesn't offer "
"you such feature.");
}
return EINA_TRUE;
}
static Eina_Bool
x_post_setup(void)
{
const Eina_List *l;
const Zone *zone;
void *ptr;
if (eina_list_count(zones) > 1)
{
mouse_out_handler = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT,
_x_mouse_out, NULL);
}
EINA_LIST_FOREACH(zones, l, zone)
{
Evas_Object *win = zone_win_get(zone);
Ecore_X_Window xid = elm_win_xwindow_get(win);
Ecore_X_Window root_xid;
int x, y, w, h;
zone_geometry_get(zone, &x, &y, &w, &h);
evas_object_show(win);
ecore_x_window_move_resize(xid, x, y, w, h);
root_xid = ecore_x_window_root_get(xid);
if (!eina_list_data_find(roots, (void*)(long)root_xid))
roots = eina_list_append(roots, (void*)(long)root_xid);
}
_x_grab_current();
return EINA_TRUE;
}
static int
x_zones_count(void)
{
int c = ecore_x_xinerama_screen_count_get();
if (c < 1)
{
ERR("No Xinerama support, assume single screen");
has_xinerama = EINA_FALSE;
c = 1;
}
return c;
}
static Eina_Bool
x_zone_geometry_get(int idx, int *x, int *y, int *w, int *h)
{
if (!has_xinerama)
{
if (x) *x = 0;
if (y) *y = 0;
ecore_x_screen_size_get(ecore_x_default_screen_get(), w, h);
return EINA_TRUE;
}
return ecore_x_xinerama_screen_geometry_get(idx, x, y, w, h);
}
static Eina_Bool
x_zone_setup(Zone *zone)
{
Evas_Object *win = zone_win_get(zone);
Evas_Object *img;
DBG("setup for zone %p", zone);
elm_win_override_set(win, EINA_TRUE);
img = zone_screen_copy_object_get(zone);
if (img)
zone_screen_copy_ready_set(zone, _x_zone_screen_copy_do(zone, img));
zones = eina_list_append(zones, zone);
return EINA_TRUE;
}
typedef struct _X_Zone_Screen_Copy_Data X_Zone_Screen_Copy_Data;
struct _X_Zone_Screen_Copy_Data
{
Zone *zone;
Evas_Object *img;
Ecore_X_Window xid;
void (*cb)(void *data, Eina_Bool success);
const void *cb_data;
Ecore_Timer *shot_timer;
};
static Eina_Bool
_x_zone_screen_copy_shot_timer_cb(void *data)
{
X_Zone_Screen_Copy_Data *ctx = data;
Eina_Bool ret;
DBG("do the screen shot to image %p", ctx->img);
ret = _x_zone_screen_copy_do(ctx->zone, ctx->img);
DBG("Screen shot done with ret=%d, show %#x, ungrab temporary %#x",
ret, ctx->xid, temp_xwin);
ecore_x_window_show(ctx->xid);
_x_temp_ungrab();
ctx->cb((void *)ctx->cb_data, ret);
free(ctx);
return EINA_FALSE;
}
static void
x_zone_screen_copy(Zone *zone, Evas_Object *img, void (*cb)(void *data, Eina_Bool success), const void *data)
{
X_Zone_Screen_Copy_Data *ctx;
Evas_Object *win = zone_win_get(zone);
Ecore_X_Window xid = elm_win_xwindow_get(win);
EINA_SAFETY_ON_NULL_RETURN(cb);
ctx = calloc(1, sizeof(X_Zone_Screen_Copy_Data));
EINA_SAFETY_ON_NULL_GOTO(ctx, error);
ctx->zone = zone;
ctx->img = img;
ctx->xid = xid;
ctx->cb = cb;
ctx->cb_data = data;
ctx->shot_timer = ecore_timer_add(1.0, _x_zone_screen_copy_shot_timer_cb,
ctx);
EINA_SAFETY_ON_NULL_GOTO(ctx->shot_timer, error_free_ctx);
_x_temp_grab();
ecore_x_window_hide(xid);
DBG("xid %#x hidden, grab to temporary %#x, start 1.0s shot timer %p",
xid, temp_xwin, ctx->shot_timer);
return;
error_free_ctx:
free(ctx);
error:
cb((void *)data, EINA_FALSE);
}
static void
_x_global_key_ungrab(const char *keyname)
{
const Eina_List *l;
const void *ptr;
EINA_LIST_FOREACH(roots, l, ptr)
{
Ecore_X_Window xid = (Ecore_X_Window)(long)ptr;
ecore_x_window_key_ungrab(xid, keyname, 0, 0);
}
}
static void
x_pre_teardown(void)
{
X_Key_Grab *kg;
_x_ungrab();
if (temp_xwin)
{
ecore_x_window_free(temp_xwin);
temp_xwin = 0;
}
if (mouse_out_handler)
{
ecore_event_handler_del(mouse_out_handler);
mouse_out_handler = NULL;
}
if (key_down_handler)
{
ecore_event_handler_del(key_down_handler);
key_down_handler = NULL;
}
EINA_LIST_FREE(key_grabs, kg)
{
_x_global_key_ungrab(kg->keyname);
_x_key_grab_free(kg);
}
eina_list_free(roots);
roots = NULL;
eina_list_free(zones);
zones = NULL;
grabbed_zone = NULL;
}
static void
x_mouse_move_by(Zone *zone, int dx, int dy)
{
Evas_Object *win = zone_win_get(zone);
Ecore_X_Window xid = elm_win_xwindow_get(win);
int x, y, zx, zy, zw, zh;
ecore_x_pointer_xy_get(xid, &x, &y);
zone_geometry_get(zone, &zx, &zy, &zw, &zh);
x += dx;
y += dy;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (x >= zw)
x = zw - 1;
if (y >= zh)
y = zh - 1;
ecore_x_pointer_warp(xid, x, y);
}
static void
x_windows_visibility_set(Eina_Bool visible)
{
const Zone *zone;
const Eina_List *l;
windows_visible = visible;
if (!visible)
_x_ungrab();
EINA_LIST_FOREACH(zones, l, zone)
{
Evas_Object *win = zone_win_get(zone);
Ecore_X_Window xid = elm_win_xwindow_get(win);
if (visible)
ecore_x_window_show(xid);
else
ecore_x_window_hide(xid);
}
if (visible)
_x_grab_current();
}
static Eina_Bool
_x_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Event_Key *ev = event;
const Eina_List *l;
const X_Key_Grab *kg;
if (!ev->key)
return ECORE_CALLBACK_PASS_ON;
EINA_LIST_FOREACH(key_grabs, l, kg)
{
if (strcmp(ev->key, kg->keyname) == 0)
kg->cb((void *)kg->cb_data, kg->keyname);
}
return ECORE_CALLBACK_PASS_ON;
}
static void
x_global_key_grab(const char *keyname, void (*cb)(void *data, const char *keyname), const void *data)
{
X_Key_Grab *kg;
const Eina_List *l;
const void *ptr;
if (!key_down_handler)
{
key_down_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
_x_key_down, NULL);
}
EINA_LIST_FOREACH(roots, l, ptr)
{
Ecore_X_Window xid = (Ecore_X_Window)(long)ptr;
ecore_x_window_key_grab(xid, keyname, 0, 0);
ecore_x_event_mask_set(xid, ECORE_X_EVENT_MASK_KEY_DOWN);
}
kg = _x_key_grab_new(keyname, cb, data);
key_grabs = eina_list_append(key_grabs, kg);
}
const Platform_Funcs *
platform_funcs_x_get(void)
{
static const Platform_Funcs funcs = {
x_pre_setup,
x_post_setup,
x_zones_count,
x_zone_geometry_get,
x_zone_setup,
x_zone_screen_copy,
x_pre_teardown,
x_mouse_move_by,
x_windows_visibility_set,
x_global_key_grab,
};
return &funcs;
}

46
src/bin/private.h Normal file
View File

@ -0,0 +1,46 @@
#ifndef _ERULER_PRIVATE_H_
#define _ERULER_PRIVATE_H_ 1
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Elementary.h>
extern int _log_dom;
#define CRI(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__)
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
void show_gui_error(const char *message);
typedef struct _Zone Zone;
typedef struct _Platform_Funcs Platform_Funcs;
struct _Platform_Funcs
{
Eina_Bool (*pre_setup)(void);
Eina_Bool (*post_setup)(void);
int (*zones_count)(void);
Eina_Bool (*zone_geometry_get)(int zone, int *x, int *y, int *w, int *h);
Eina_Bool (*zone_setup)(Zone *zone);
void (*zone_screen_copy)(Zone *zone, Evas_Object *img, void (*cb)(void *data, Eina_Bool success), const void *data);
void (*pre_teardown)(void);
void (*mouse_move_by)(Zone *zone, int dx, int dy);
void (*windows_visibility_set)(Eina_Bool visible);
void (*global_key_grab)(const char *keyname, void (*cb)(void *data, const char *keyname), const void *data);
};
Evas_Object *zone_win_get(const Zone *zone);
Evas_Object *zone_screen_copy_object_get(const Zone *zone);
void zone_screen_copy_ready_set(Zone *zone, Eina_Bool ready);
void zone_geometry_get(const Zone *zone, int *x, int *y, int *w, int *h);
int zone_index_get(const Zone *zone);
#ifdef HAVE_ECORE_X
const Platform_Funcs *platform_funcs_x_get(void);
#endif
#endif