#include "e.h"
#include <Ecore_Drm.h>
+#define PATH "/org/enlightenment/wm"
+#define IFACE "org.enlightenment.wm.screen_rotation"
+
+static Eldbus_Connection *e_comp_screen_conn;
+static Eldbus_Service_Interface *e_comp_screen_iface;
+
static Eina_List *event_handlers = NULL;
static Eina_Bool session_state = EINA_FALSE;
E_API int E_EVENT_SCREEN_CHANGE = 0;
+enum
+{
+ E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED = 0
+};
+
typedef struct _E_Comp_Screen_Tzsr
{
struct wl_resource *resource; /* tizen_screen_rotation */
wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, NULL);
}
+static Eldbus_Message *
+_e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+ int rotation = 0;
+
+ if (e_comp && e_comp->e_comp_screen)
+ rotation = e_comp->e_comp_screen->rotation;
+
+ DBG("got screen-rotation 'get' request: %d", rotation);
+
+ eldbus_message_arguments_append(reply, "i", rotation);
+
+ return reply;
+}
+
+static const Eldbus_Method methods[] =
+{
+ {"get", NULL, ELDBUS_ARGS({"i", "int32"}), _e_comp_screen_dbus_get_cb, 0},
+ {}
+};
+
+static const Eldbus_Signal signals[] = {
+ [E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED] = {"changed", ELDBUS_ARGS({ "i", "rotation" }), 0},
+ {}
+};
+
+static const Eldbus_Service_Interface_Desc iface_desc = {
+ IFACE, methods, signals, NULL, NULL, NULL
+};
+
+static Eina_Bool
+_e_comp_screen_dbus_init(void *data EINA_UNUSED)
+{
+ E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
+
+ if (e_comp_screen_conn) return ECORE_CALLBACK_CANCEL;
+
+ if (!e_comp_screen_conn)
+ e_comp_screen_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
+
+ if(!e_comp_screen_conn)
+ {
+ ecore_timer_add(1, _e_comp_screen_dbus_init, NULL);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ e_comp_screen_iface = eldbus_service_interface_register(e_comp_screen_conn,
+ PATH,
+ &iface_desc);
+ EINA_SAFETY_ON_NULL_GOTO(e_comp_screen_iface, err);
+
+ if (e_comp_screen->rotation)
+ {
+ eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
+ ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, NULL, e_comp_screen->rotation);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+
+err:
+ if (e_comp_screen_conn)
+ {
+ eldbus_connection_unref(e_comp_screen_conn);
+ e_comp_screen_conn = NULL;
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
static char *
_layer_cap_to_str(tdm_layer_capability caps, tdm_layer_capability cap)
{
return EINA_FALSE;
}
+ _e_comp_screen_dbus_init(NULL);
+
tzsr_client_hook_del = e_client_hook_add(E_CLIENT_HOOK_DEL, _tz_screen_rotation_cb_client_del, NULL);
E_LIST_HANDLER_APPEND(event_handlers, ECORE_DRM_EVENT_ACTIVATE, _e_comp_screen_cb_activate, comp);
/* shutdown ecore_drm */
/* ecore_drm_shutdown(); */
+ if (e_comp_screen_iface)
+ {
+ eldbus_service_interface_unregister(e_comp_screen_iface);
+ e_comp_screen_iface = NULL;
+ }
+
+ if (e_comp_screen_conn)
+ {
+ eldbus_connection_unref(e_comp_screen_conn);
+ e_comp_screen_conn = NULL;
+ }
+
_e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
e_client_hook_del(tzsr_client_hook_del);
ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
+ if (e_comp_screen_iface)
+ {
+ eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
+ ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, NULL, e_comp_screen->rotation);
+ }
+
INF("EE Rotated and Resized: %d, %dx%d", e_comp_screen->rotation, w, h);
return EINA_TRUE;