From 638af3e64fb8a1968f3710934da260ce74dd3dd5 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 17 Jun 2015 10:51:10 +0900 Subject: [PATCH 2/2] add initial code Change-Id: Ic4d1513780e19de915f158ad969d5e82fc0b3f22 --- COPYING | 25 +++++ Makefile.am | 8 ++ autogen.sh | 16 +++ configure.ac | 55 ++++++++++ packaging/e-mod-tizen-eom.spec | 61 +++++++++++ protocol/eom-client-protocol.h | 233 +++++++++++++++++++++++++++++++++++++++++ protocol/eom-protocol.c | 38 +++++++ protocol/eom-server-protocol.h | 194 ++++++++++++++++++++++++++++++++++ protocol/eom.xml | 102 ++++++++++++++++++ src/Makefile.am | 28 +++++ src/e_mod_main.c | 165 +++++++++++++++++++++++++++++ src/e_mod_main.h | 19 ++++ 12 files changed, 944 insertions(+) create mode 100644 COPYING create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 packaging/e-mod-tizen-eom.spec create mode 100644 protocol/eom-client-protocol.h create mode 100644 protocol/eom-protocol.c create mode 100644 protocol/eom-server-protocol.h create mode 100644 protocol/eom.xml create mode 100644 src/Makefile.am create mode 100755 src/e_mod_main.c create mode 100755 src/e_mod_main.h diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f3bbff3 --- /dev/null +++ b/COPYING @@ -0,0 +1,25 @@ +Copyright notice for Enlightenment: + +Copyright (C) 2000-2012 Carsten Haitzler and various contributors (see AUTHORS) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..a30d363 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,8 @@ +#maintainer-clean removes everything +MAINTAINERCLEANFILES = aclocal.m4 compile config.sub config.guess config.h.in \ + configure depcomp install-sh ltmain.sh Makefile.in missing + +SUBDIRS = src + +MAINTAINERCLEANFILES = \ + Makefile.in diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..1ac867a --- /dev/null +++ b/autogen.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +#rm -rf autom4te.cache +#rm -f aclocal.m4 ltmain.sh + +#echo "Running autoreconf..." ; autoreconf -v --install || exit 1 +#echo "Running configure..." ; ./configure --enable-maintainer-mode + +set -x +aclocal +autoconf +libtoolize --copy --force +autoheader +automake --foreign --add-missing --copy + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..39a2c1b --- /dev/null +++ b/configure.ac @@ -0,0 +1,55 @@ +dnl Process this file with autoconf to produce a configure script. + +# get rid of that stupid cache mechanism +rm -f config.cache + +AC_INIT(e-mod-tizen-eom, 0.1, sc1.lim@samsung.com) +AC_PREREQ(2.52) +AC_CONFIG_SRCDIR(configure.ac) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_ISC_POSIX + +AM_INIT_AUTOMAKE(1.8) +AM_CONFIG_HEADER(config.h) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +AC_PROG_CC +AM_PROG_CC_STDC +AM_PROG_CC_C_O +AC_HEADER_STDC +AC_C_CONST +AC_C___ATTRIBUTE__ + +define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl +define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl +AC_PROG_LIBTOOL + +#AM_GNU_GETTEXT([external]) +#AM_GNU_GETTEXT_VERSION(0.14) + +AC_PATH_PROG([wayland_scanner], [wayland-scanner]) +if test x$wayland_scanner = x; then + AC_MSG_ERROR([wayland-scanner is needed to compile]) +fi + +PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner) +PKG_CHECK_MODULES(WAYLAND, [wayland-server]) +PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment]) + +AC_SUBST(ENLIGHTENMENT_CFLAGS) +AC_SUBST(ENLIGHTENMENT_LIBS) + +AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl) +AC_SUBST(dlopen_libs) + +release=$(pkg-config --variable=release enlightenment) +MODULE_ARCH="$host_os-$host_cpu-$release" +AC_SUBST(MODULE_ARCH) +AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") + +datadir=$(pkg-config --variable=modules enlightenment)/${PACKAGE} + +AC_CONFIG_FILES([Makefile + src/Makefile]) +AC_OUTPUT diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec new file mode 100644 index 0000000..a290b5d --- /dev/null +++ b/packaging/e-mod-tizen-eom.spec @@ -0,0 +1,61 @@ +%bcond_with x +%bcond_with wayland + +Name: e-mod-tizen-eom +Version: 0.1.1 +Release: 1 +Summary: The Enlightenment eom Module for Tizen +URL: http://www.enlightenment.org +Group: Graphics & UI Framework/Other +Source0: %{name}-%{version}.tar.gz +License: BSD-2-Clause +BuildRequires: pkgconfig(enlightenment) +BuildRequires: gettext +%if %{with x} +%endif +%if %{with wayland} +BuildRequires: pkgconfig(wayland-server) +%endif +BuildRequires: pkgconfig(dlog) +%if "%{?profile}" == "common" +%else +BuildRequires: e-tizen-data +%endif +%description +This package is a the Enlightenment eom Module for Tizen. + +%prep +%setup -q + +%build + +export GC_SECTIONS_FLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections" +export CFLAGS+=" -Wall -g -fPIC -rdynamic ${GC_SECTIONS_FLAGS}" +export LDFLAGS+=" -Wl,--hash-style=both -Wl,--as-needed -Wl,--rpath=/usr/lib" + +%autogen +%if %{with wayland} +%configure --prefix=/usr +%else +%configure --prefix=/usr +%endif + +make + +%install +rm -rf %{buildroot} + +# for license notification +mkdir -p %{buildroot}/usr/share/license +cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/usr/share/license/%{name} + +# install +make install DESTDIR=%{buildroot} + +# clear useless textual files +find %{buildroot}%{_libdir}/enlightenment/modules/%{name} -name *.la | xargs rm + +%files +%defattr(-,root,root,-) +%{_libdir}/enlightenment/modules/e-mod-tizen-eom +/usr/share/license/%{name} diff --git a/protocol/eom-client-protocol.h b/protocol/eom-client-protocol.h new file mode 100644 index 0000000..404fe56 --- /dev/null +++ b/protocol/eom-client-protocol.h @@ -0,0 +1,233 @@ +#ifndef WL_EOM_CLIENT_PROTOCOL_H +#define WL_EOM_CLIENT_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-client.h" + +struct wl_client; +struct wl_resource; + +struct wl_eom; + +extern const struct wl_interface wl_eom_interface; + +#ifndef WL_EOM_ERROR_ENUM +#define WL_EOM_ERROR_ENUM +enum wl_eom_error { + WL_EOM_ERROR_NONE = 0, + WL_EOM_ERROR_NO_OUTPUT = 1, + WL_EOM_ERROR_NO_ATTRIBUTE = 2, + WL_EOM_ERROR_OUTPUT_OCCUPIED = 3, +}; +#endif /* WL_EOM_ERROR_ENUM */ + +#ifndef WL_EOM_TYPE_ENUM +#define WL_EOM_TYPE_ENUM +/** + * wl_eom_type - connector type of the external output + * @WL_EOM_TYPE_NONE: none + * @WL_EOM_TYPE_VGA: VGA output connector type + * @WL_EOM_TYPE_DIVI: VGA output connector type + * @WL_EOM_TYPE_DIVD: VGA output connector type + * @WL_EOM_TYPE_DIVA: VGA output connector type + * @WL_EOM_TYPE_COMPOSITE: VGA output connector type + * @WL_EOM_TYPE_SVIDEO: VGA output connector type + * @WL_EOM_TYPE_LVDS: VGA output connector type + * @WL_EOM_TYPE_COMPONENT: VGA output connector type + * @WL_EOM_TYPE_9PINDIN: VGA output connector type + * @WL_EOM_TYPE_DISPLAYPORT: VGA output connector type + * @WL_EOM_TYPE_HDMIA: VGA output connector type + * @WL_EOM_TYPE_HDMIB: VGA output connector type + * @WL_EOM_TYPE_TV: VGA output connector type + * @WL_EOM_TYPE_EDP: VGA output connector type + * @WL_EOM_TYPE_VIRTUAL: VGA output connector type + * @WL_EOM_TYPE_DSI: VGA output connector type + * + * ***** TODO ****** + */ +enum wl_eom_type { + WL_EOM_TYPE_NONE = 0, + WL_EOM_TYPE_VGA = 1, + WL_EOM_TYPE_DIVI = 2, + WL_EOM_TYPE_DIVD = 3, + WL_EOM_TYPE_DIVA = 4, + WL_EOM_TYPE_COMPOSITE = 5, + WL_EOM_TYPE_SVIDEO = 6, + WL_EOM_TYPE_LVDS = 7, + WL_EOM_TYPE_COMPONENT = 8, + WL_EOM_TYPE_9PINDIN = 9, + WL_EOM_TYPE_DISPLAYPORT = 10, + WL_EOM_TYPE_HDMIA = 11, + WL_EOM_TYPE_HDMIB = 12, + WL_EOM_TYPE_TV = 13, + WL_EOM_TYPE_EDP = 14, + WL_EOM_TYPE_VIRTUAL = 15, + WL_EOM_TYPE_DSI = 16, +}; +#endif /* WL_EOM_TYPE_ENUM */ + +#ifndef WL_EOM_STATUS_ENUM +#define WL_EOM_STATUS_ENUM +/** + * wl_eom_status - connection status of the external output + * @WL_EOM_STATUS_NONE: none + * @WL_EOM_STATUS_CONNECTION: output connected + * @WL_EOM_STATUS_DISCONNECTION: output disconnected + * + * ***** TODO ****** + */ +enum wl_eom_status { + WL_EOM_STATUS_NONE = 0, + WL_EOM_STATUS_CONNECTION = 1, + WL_EOM_STATUS_DISCONNECTION = 2, +}; +#endif /* WL_EOM_STATUS_ENUM */ + +#ifndef WL_EOM_MODE_ENUM +#define WL_EOM_MODE_ENUM +/** + * wl_eom_mode - mode of the external output + * @WL_EOM_MODE_NONE: none + * @WL_EOM_MODE_MIRROR: mirror mode + * @WL_EOM_MODE_PRESENTATION: presentation mode + * + * ***** TODO ****** + */ +enum wl_eom_mode { + WL_EOM_MODE_NONE = 0, + WL_EOM_MODE_MIRROR = 1, + WL_EOM_MODE_PRESENTATION = 2, +}; +#endif /* WL_EOM_MODE_ENUM */ + +#ifndef WL_EOM_ATTRIBUTE_ENUM +#define WL_EOM_ATTRIBUTE_ENUM +/** + * wl_eom_attribute - attribute of the external output + * @WL_EOM_ATTRIBUTE_NONE: none + * @WL_EOM_ATTRIBUTE_NORMAL: nomal attribute + * @WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED: exclusive shared attribute + * @WL_EOM_ATTRIBUTE_EXCLUSIVE: exclusive attribute + * + * ***** TODO ****** + */ +enum wl_eom_attribute { + WL_EOM_ATTRIBUTE_NONE = 0, + WL_EOM_ATTRIBUTE_NORMAL = 1, + WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED = 2, + WL_EOM_ATTRIBUTE_EXCLUSIVE = 3, +}; +#endif /* WL_EOM_ATTRIBUTE_ENUM */ + +#ifndef WL_EOM_ATTRIBUTE_STATE_ENUM +#define WL_EOM_ATTRIBUTE_STATE_ENUM +/** + * wl_eom_attribute_state - state of the external output attribute + * @WL_EOM_ATTRIBUTE_STATE_NONE: none + * @WL_EOM_ATTRIBUTE_STATE_ACTIVE: attribute is active on the output + * @WL_EOM_ATTRIBUTE_STATE_INACTIVE: attribute is inactive on the output + * @WL_EOM_ATTRIBUTE_STATE_LOST: the connection of output is lost + * + * ***** TODO ****** + */ +enum wl_eom_attribute_state { + WL_EOM_ATTRIBUTE_STATE_NONE = 0, + WL_EOM_ATTRIBUTE_STATE_ACTIVE = 1, + WL_EOM_ATTRIBUTE_STATE_INACTIVE = 2, + WL_EOM_ATTRIBUTE_STATE_LOST = 3, +}; +#endif /* WL_EOM_ATTRIBUTE_STATE_ENUM */ + +/** + * wl_eom - an interface to get the information of the external outputs + * @output_type: (none) + * @output_mode: (none) + * @output_attribute: (none) + * + * ***** TODO ****** + */ +struct wl_eom_listener { + /** + * output_type - (none) + * @output: (none) + * @type: (none) + * @status: (none) + * @error: (none) + */ + void (*output_type)(void *data, + struct wl_eom *wl_eom, + struct wl_output *output, + uint32_t type, + uint32_t status, + uint32_t error); + /** + * output_mode - (none) + * @output: (none) + * @mode: (none) + * @error: (none) + */ + void (*output_mode)(void *data, + struct wl_eom *wl_eom, + struct wl_output *output, + uint32_t mode, + uint32_t error); + /** + * output_attribute - (none) + * @output: (none) + * @attribute: (none) + * @attribute_state: (none) + * @error: (none) + */ + void (*output_attribute)(void *data, + struct wl_eom *wl_eom, + struct wl_output *output, + uint32_t attribute, + uint32_t attribute_state, + uint32_t error); +}; + +static inline int +wl_eom_add_listener(struct wl_eom *wl_eom, + const struct wl_eom_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) wl_eom, + (void (**)(void)) listener, data); +} + +#define WL_EOM_SET_ATTRIBUTE 0 + +static inline void +wl_eom_set_user_data(struct wl_eom *wl_eom, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wl_eom, user_data); +} + +static inline void * +wl_eom_get_user_data(struct wl_eom *wl_eom) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wl_eom); +} + +static inline void +wl_eom_destroy(struct wl_eom *wl_eom) +{ + wl_proxy_destroy((struct wl_proxy *) wl_eom); +} + +static inline void +wl_eom_set_attribute(struct wl_eom *wl_eom, struct wl_output *output, uint32_t attribute) +{ + wl_proxy_marshal((struct wl_proxy *) wl_eom, + WL_EOM_SET_ATTRIBUTE, output, attribute); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/protocol/eom-protocol.c b/protocol/eom-protocol.c new file mode 100644 index 0000000..8eafa37 --- /dev/null +++ b/protocol/eom-protocol.c @@ -0,0 +1,38 @@ +#include +#include +#include "wayland-util.h" + +extern const struct wl_interface wl_output_interface; + +static const struct wl_interface *types[] = { + &wl_output_interface, + NULL, + &wl_output_interface, + NULL, + NULL, + NULL, + &wl_output_interface, + NULL, + NULL, + &wl_output_interface, + NULL, + NULL, + NULL, +}; + +static const struct wl_message wl_eom_requests[] = { + { "set_attribute", "ou", types + 0 }, +}; + +static const struct wl_message wl_eom_events[] = { + { "output_type", "ouuu", types + 2 }, + { "output_mode", "ouu", types + 6 }, + { "output_attribute", "ouuu", types + 9 }, +}; + +WL_EXPORT const struct wl_interface wl_eom_interface = { + "wl_eom", 1, + 1, wl_eom_requests, + 3, wl_eom_events, +}; + diff --git a/protocol/eom-server-protocol.h b/protocol/eom-server-protocol.h new file mode 100644 index 0000000..07becce --- /dev/null +++ b/protocol/eom-server-protocol.h @@ -0,0 +1,194 @@ +#ifndef WL_EOM_SERVER_PROTOCOL_H +#define WL_EOM_SERVER_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-server.h" + +struct wl_client; +struct wl_resource; + +struct wl_eom; + +extern const struct wl_interface wl_eom_interface; + +#ifndef WL_EOM_ERROR_ENUM +#define WL_EOM_ERROR_ENUM +enum wl_eom_error { + WL_EOM_ERROR_NONE = 0, + WL_EOM_ERROR_NO_OUTPUT = 1, + WL_EOM_ERROR_NO_ATTRIBUTE = 2, + WL_EOM_ERROR_OUTPUT_OCCUPIED = 3, +}; +#endif /* WL_EOM_ERROR_ENUM */ + +#ifndef WL_EOM_TYPE_ENUM +#define WL_EOM_TYPE_ENUM +/** + * wl_eom_type - connector type of the external output + * @WL_EOM_TYPE_NONE: none + * @WL_EOM_TYPE_VGA: VGA output connector type + * @WL_EOM_TYPE_DIVI: VGA output connector type + * @WL_EOM_TYPE_DIVD: VGA output connector type + * @WL_EOM_TYPE_DIVA: VGA output connector type + * @WL_EOM_TYPE_COMPOSITE: VGA output connector type + * @WL_EOM_TYPE_SVIDEO: VGA output connector type + * @WL_EOM_TYPE_LVDS: VGA output connector type + * @WL_EOM_TYPE_COMPONENT: VGA output connector type + * @WL_EOM_TYPE_9PINDIN: VGA output connector type + * @WL_EOM_TYPE_DISPLAYPORT: VGA output connector type + * @WL_EOM_TYPE_HDMIA: VGA output connector type + * @WL_EOM_TYPE_HDMIB: VGA output connector type + * @WL_EOM_TYPE_TV: VGA output connector type + * @WL_EOM_TYPE_EDP: VGA output connector type + * @WL_EOM_TYPE_VIRTUAL: VGA output connector type + * @WL_EOM_TYPE_DSI: VGA output connector type + * + * ***** TODO ****** + */ +enum wl_eom_type { + WL_EOM_TYPE_NONE = 0, + WL_EOM_TYPE_VGA = 1, + WL_EOM_TYPE_DIVI = 2, + WL_EOM_TYPE_DIVD = 3, + WL_EOM_TYPE_DIVA = 4, + WL_EOM_TYPE_COMPOSITE = 5, + WL_EOM_TYPE_SVIDEO = 6, + WL_EOM_TYPE_LVDS = 7, + WL_EOM_TYPE_COMPONENT = 8, + WL_EOM_TYPE_9PINDIN = 9, + WL_EOM_TYPE_DISPLAYPORT = 10, + WL_EOM_TYPE_HDMIA = 11, + WL_EOM_TYPE_HDMIB = 12, + WL_EOM_TYPE_TV = 13, + WL_EOM_TYPE_EDP = 14, + WL_EOM_TYPE_VIRTUAL = 15, + WL_EOM_TYPE_DSI = 16, +}; +#endif /* WL_EOM_TYPE_ENUM */ + +#ifndef WL_EOM_STATUS_ENUM +#define WL_EOM_STATUS_ENUM +/** + * wl_eom_status - connection status of the external output + * @WL_EOM_STATUS_NONE: none + * @WL_EOM_STATUS_CONNECTION: output connected + * @WL_EOM_STATUS_DISCONNECTION: output disconnected + * + * ***** TODO ****** + */ +enum wl_eom_status { + WL_EOM_STATUS_NONE = 0, + WL_EOM_STATUS_CONNECTION = 1, + WL_EOM_STATUS_DISCONNECTION = 2, +}; +#endif /* WL_EOM_STATUS_ENUM */ + +#ifndef WL_EOM_MODE_ENUM +#define WL_EOM_MODE_ENUM +/** + * wl_eom_mode - mode of the external output + * @WL_EOM_MODE_NONE: none + * @WL_EOM_MODE_MIRROR: mirror mode + * @WL_EOM_MODE_PRESENTATION: presentation mode + * + * ***** TODO ****** + */ +enum wl_eom_mode { + WL_EOM_MODE_NONE = 0, + WL_EOM_MODE_MIRROR = 1, + WL_EOM_MODE_PRESENTATION = 2, +}; +#endif /* WL_EOM_MODE_ENUM */ + +#ifndef WL_EOM_ATTRIBUTE_ENUM +#define WL_EOM_ATTRIBUTE_ENUM +/** + * wl_eom_attribute - attribute of the external output + * @WL_EOM_ATTRIBUTE_NONE: none + * @WL_EOM_ATTRIBUTE_NORMAL: nomal attribute + * @WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED: exclusive shared attribute + * @WL_EOM_ATTRIBUTE_EXCLUSIVE: exclusive attribute + * + * ***** TODO ****** + */ +enum wl_eom_attribute { + WL_EOM_ATTRIBUTE_NONE = 0, + WL_EOM_ATTRIBUTE_NORMAL = 1, + WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED = 2, + WL_EOM_ATTRIBUTE_EXCLUSIVE = 3, +}; +#endif /* WL_EOM_ATTRIBUTE_ENUM */ + +#ifndef WL_EOM_ATTRIBUTE_STATE_ENUM +#define WL_EOM_ATTRIBUTE_STATE_ENUM +/** + * wl_eom_attribute_state - state of the external output attribute + * @WL_EOM_ATTRIBUTE_STATE_NONE: none + * @WL_EOM_ATTRIBUTE_STATE_ACTIVE: attribute is active on the output + * @WL_EOM_ATTRIBUTE_STATE_INACTIVE: attribute is inactive on the output + * @WL_EOM_ATTRIBUTE_STATE_LOST: the connection of output is lost + * + * ***** TODO ****** + */ +enum wl_eom_attribute_state { + WL_EOM_ATTRIBUTE_STATE_NONE = 0, + WL_EOM_ATTRIBUTE_STATE_ACTIVE = 1, + WL_EOM_ATTRIBUTE_STATE_INACTIVE = 2, + WL_EOM_ATTRIBUTE_STATE_LOST = 3, +}; +#endif /* WL_EOM_ATTRIBUTE_STATE_ENUM */ + +/** + * wl_eom - an interface to get the information of the external outputs + * @set_attribute: (none) + * + * ***** TODO ****** + */ +struct wl_eom_interface { + /** + * set_attribute - (none) + * @output: (none) + * @attribute: (none) + */ + void (*set_attribute)(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *output, + uint32_t attribute); +}; + +#define WL_EOM_OUTPUT_TYPE 0 +#define WL_EOM_OUTPUT_MODE 1 +#define WL_EOM_OUTPUT_ATTRIBUTE 2 + +#define WL_EOM_OUTPUT_TYPE_SINCE_VERSION 1 +#define WL_EOM_OUTPUT_MODE_SINCE_VERSION 1 +#define WL_EOM_OUTPUT_ATTRIBUTE_SINCE_VERSION 1 + +static inline void +wl_eom_send_output_type(struct wl_resource *resource_, struct wl_resource *output, uint32_t type, uint32_t status, uint32_t error) +{ + wl_resource_post_event(resource_, WL_EOM_OUTPUT_TYPE, output, type, status, error); +} + +static inline void +wl_eom_send_output_mode(struct wl_resource *resource_, struct wl_resource *output, uint32_t mode, uint32_t error) +{ + wl_resource_post_event(resource_, WL_EOM_OUTPUT_MODE, output, mode, error); +} + +static inline void +wl_eom_send_output_attribute(struct wl_resource *resource_, struct wl_resource *output, uint32_t attribute, uint32_t attribute_state, uint32_t error) +{ + wl_resource_post_event(resource_, WL_EOM_OUTPUT_ATTRIBUTE, output, attribute, attribute_state, error); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/protocol/eom.xml b/protocol/eom.xml new file mode 100644 index 0000000..ed162a9 --- /dev/null +++ b/protocol/eom.xml @@ -0,0 +1,102 @@ + + + + ***** TODO ****** + + + + + + + + + + + + ***** TODO ****** + + + + + + + + + + + + + + + + + + + + + + + ***** TODO ****** + + + + + + + + + ***** TODO ****** + + + + + + + + + ***** TODO ****** + + + + + + + + + + ***** TODO ****** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..cf6fbec --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,28 @@ +MAINTAINERCLEANFILES = Makefile.in +MODULE = e-mod-tizen-eom + +# data files for the module +filesdir = $(libdir)/enlightenment/modules/$(MODULE) + +pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la +module_la_SOURCES = e_mod_main.c +module_la_LIBADD = +module_la_CFLAGS = @WAYLAND_CFLAGS@ @ENLIGHTENMENT_CFLAGS@ -DHAVE_WAYLAND_ONLY +module_la_LDFLAGS = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ +module_la_DEPENDENCIES = $(top_builddir)/config.h + +BUILT_SOURCES = eom-protocol.c \ + eom-client-protocol.h \ + eom-server-protocol.h + +CLEANFILES = $(BUILT_SOURCES) + +%-protocol.c : $(top_srcdir)/protocol/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@ + +%-server-protocol.h : $(top_srcdir)/protocol/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@ + +%-client-protocol.h : $(top_srcdir)/protocol/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@ diff --git a/src/e_mod_main.c b/src/e_mod_main.c new file mode 100755 index 0000000..dcf653f --- /dev/null +++ b/src/e_mod_main.c @@ -0,0 +1,165 @@ +#define E_COMP_WL +#include "e.h" +#include "e_mod_main.h" +#include "eom-server-protocol.h" + +typedef struct _E_Eom E_Eom, *E_EomPtr; + +struct _E_Eom +{ + E_Comp_Data *cdata; + struct wl_global *global; + Eina_List *handlers; +}; + +E_EomPtr g_eom = NULL; + +EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; + +static Eina_Bool +_e_eom_e_client_remove_cb(void *data, int type, void *event) +{ + E_Event_Client *ev = event; + E_Client *ec = ev->ec; + + (void) type; + (void) event; + (void) data; + + EOM_DBG("e_client: %p is died\n", ec); + + return ECORE_CALLBACK_PASS_ON; +} + + +/* wl_eom_set_keygrab request handler */ +static void +_e_eom_wl_request_set_attribute_cb(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *output, + uint32_t attribute) +{ + (void) client; + (void) resource; + (void) output; + (void) attribute; + + EOM_DBG("attribute:%d\n", attribute); +} + +static const struct wl_eom_interface _e_eom_wl_implementation = { + _e_eom_wl_request_set_attribute_cb +}; + +/* wl_eom global object destroy function */ +static void +_e_eom_wl_resource_destory_cb(struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +/* wl_eom global object bind function */ +static void +_e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) +{ + E_EomPtr eom = data; + struct wl_resource *resource; + + resource = wl_resource_create(client, &wl_eom_interface, MIN(version, 1), id); + if (!resource) + { + EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, &_e_eom_wl_implementation, eom, _e_eom_wl_resource_destory_cb); + + EOM_DBG("create wl_eom global resource.\n"); +} + +static void +_e_eom_deinit() +{ + Ecore_Event_Handler *h = NULL; + + if (!g_eom) return; + + /* remove event handlers */ + if (g_eom->handlers) + { + EINA_LIST_FREE(g_eom->handlers, h) + ecore_event_handler_del(h); + } + + if (g_eom->global) wl_global_destroy(g_eom->global); + + E_FREE(g_eom); + g_eom = NULL; +} + +static Eina_Bool +_e_eom_init() +{ + E_Comp_Data *cdata = NULL; + + g_eom = E_NEW(E_Eom, 1); + if (!g_eom) + { + EOM_ERR("error. fail to allocate the memory.\n"); + return EINA_FALSE; + } + + if (!e_comp) + { + EOM_ERR("error. e_comp is null.\n"); + goto err; + } + + cdata = e_comp->wl_comp_data; + if (!cdata) + { + EOM_ERR("error. e_comp->wl_comp_data is null.\n"); + goto err; + } + + g_eom->cdata = cdata; + g_eom->global = wl_global_create(cdata->wl.disp, &wl_eom_interface, 1, g_eom, _e_eom_wl_bind_cb); + if (!g_eom->global) + { + EOM_ERR("error. g_eom->global is null.\n"); + goto err; + } + + /* add event hanlders */ + E_LIST_HANDLER_APPEND(g_eom->handlers, E_EVENT_CLIENT_REMOVE, _e_eom_e_client_remove_cb, g_eom); + + return EINA_TRUE; + +err: + _e_eom_deinit(); + + return EINA_FALSE; +} + +EAPI void * +e_modapi_init(E_Module *m) +{ + return (_e_eom_init() ? m : NULL); +} + +EAPI int +e_modapi_shutdown(E_Module *m EINA_UNUSED) +{ + _e_eom_deinit(); + + return 1; +} + +EAPI int +e_modapi_save(E_Module *m EINA_UNUSED) +{ + /* Save something to be kept */ + return 1; +} + diff --git a/src/e_mod_main.h b/src/e_mod_main.h new file mode 100755 index 0000000..14fb89f --- /dev/null +++ b/src/e_mod_main.h @@ -0,0 +1,19 @@ +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + +#define CHECK_ERR(val) if (WL_KEYROUTER_ERROR_NONE != val) return; +#define CHECK_ERR_VAL(val) if (WL_KEYROUTER_ERROR_NONE != val) return val; +#define CHECK_NULL(val) if (!val) return; +#define CHECK_NULL_VAL(val) if (!val) return val; + +#define EOM_ERR(msg, ARG...) ERR("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) +#define EOM_WARN(msg, ARG...) WARN("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) +#define EOM_DBG(msg, ARG...) DBG("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) + +/* E Module */ +EAPI extern E_Module_Api e_modapi; +EAPI void *e_modapi_init(E_Module *m); +EAPI int e_modapi_shutdown(E_Module *m); +EAPI int e_modapi_save(E_Module *m); + +#endif -- 2.7.4