summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon Park <jh9216.park@samsung.com>2017-02-13 14:38:05 +0900
committerJunghoon Park <jh9216.park@samsung.com>2017-02-13 19:46:21 +0900
commitd49e3a99bc71854dd62288bcaccea72ca1fd520f (patch)
tree0b0820afc5bb238106e41b78a2cfedc665d31841
parent42ce32bf7147248fdb752a716bb68986b3350e3e (diff)
downloadaul-1-d49e3a99bc71854dd62288bcaccea72ca1fd520f.tar.gz
aul-1-d49e3a99bc71854dd62288bcaccea72ca1fd520f.tar.bz2
aul-1-d49e3a99bc71854dd62288bcaccea72ca1fd520f.zip
Change-Id: If2efb62d384906d1c1331667f205869f2da6f161 Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r--CMakeLists.txt1
-rwxr-xr-xinclude/aul_window.h180
-rw-r--r--src/aul_window.c252
3 files changed, 433 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 60016214..888fb795 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_svc.h DESTINATION include/
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_cmd.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_app_com.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_screen_connector.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_window.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION ${SHARE_INSTALL_PREFIX}/aul )
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION ${SHARE_INSTALL_PREFIX}/aul )
diff --git a/include/aul_window.h b/include/aul_window.h
new file mode 100755
index 00000000..dfdebb4d
--- /dev/null
+++ b/include/aul_window.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *aul_window_info_h;
+typedef void *aul_window_stack_h;
+
+/**
+ * @par Description:
+ * This API creates the window stack handle.
+ * @par Purpose:
+ * To get information of windows, the stack handle is needed.
+ *
+ * @param[out] handle Handle for the window stack
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @see
+ * aul_window_stack_del
+ * @remark
+ * It should be freed by aul_window_stack_del function.
+*/
+int aul_window_stack_get(aul_window_stack_h *handle);
+
+/**
+ * @par Description:
+ * This API destroy the window stack handle.
+ *
+ * @param[in] handle Handle for the window stack
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @see
+ * aul_window_stack_get
+*/
+int aul_window_stack_del(aul_window_stack_h handle);
+
+/**
+ * @par Description:
+ * This API invokes iterator function for each window.
+ *
+ * @param[in] handle Handle for the window stack
+ * @param[in] iter_cb The iteration callback
+ * @param[in] data The data which will be sent to the iterator
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_stack_foreach(aul_window_stack_h *handle,
+ void (*iter_cb)(aul_window_info_h info, void *data), void *data);
+
+/**
+ * @par Description:
+ * This API gets the global resource ID from the window handle.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] rid Global resource ID
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_stack_info_get_resource_id(aul_window_info_h info, unsigned int *rid);
+
+/**
+ * @par Description:
+ * This API gets the process ID from the window handle.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] pid Process ID
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_info_get_pid(aul_window_info_h info, int *pid);
+
+/**
+ * @par Description:
+ * This API gets the process ID for its parent window from the window handle.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] pid Process ID
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @remark
+ * pid will be -1 when the parent window is not exist
+ *
+*/
+int aul_window_info_get_parent_pid(aul_window_info_h info, int *ppid);
+
+/**
+ * @par Description:
+ * This API gets the process ID for its ancestor window from the window handle.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] pid Process ID
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @remark
+ * pid will be -1 when the ancestor window is not exist
+ *
+*/
+int aul_window_info_get_ancestor_pid(aul_window_info_h info, int *apid);
+
+/**
+ * @par Description:
+ * This API gets the window visibility from the window handle.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] visibility visibility
+ * 0 Fully visible state
+ * 1 Partially visible state
+ * 2 Invisible state by other window
+ * -1 Invisible state
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_info_get_visibility(aul_window_info_h info, int *visibility);
+
+/**
+ * @par Description:
+ * This API gets the flag value of supporting alpha blending.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] alpha The flag value of supporting alpha blending
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_info_has_alpha(aul_window_info_h info, bool *alpha);
+
+/**
+ * @par Description:
+ * This API gets the flag value of the focused state.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] focused The flag value of the focused state
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_info_is_focused(aul_window_info_h info, bool *focused);
+
+/**
+ * @par Description:
+ * This API gets the location and the size from window handle.
+ *
+ * @param[in] info Handle for the window
+ * @param[out] x Position x
+ * @param[out] y Position y
+ * @param[out] w Width
+ * @param[out] h Height
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+*/
+int aul_window_info_get_geometry(aul_window_info_h info, int *x, int *y, int *w, int *h);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/aul_window.c b/src/aul_window.c
new file mode 100644
index 00000000..63caa8a0
--- /dev/null
+++ b/src/aul_window.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdbool.h>
+#include <gio/gio.h>
+#include <glib.h>
+#include <malloc.h>
+
+#include "aul_api.h"
+#include "aul_util.h"
+#include "aul_window.h"
+
+static GDBusConnection *system_conn;
+
+#define WM_BUS_NAME "org.enlightenment.wm"
+#define WM_OBJECT_PATH "/org/enlightenment/wm"
+#define WM_INTERFACE_NAME "org.enlightenment.wm.proc"
+#define WM_METHOD_NAME "GetVisibleWinInfo"
+
+typedef struct _window_info {
+ unsigned int gid;
+ int x;
+ int y;
+ int w;
+ int h;
+ gboolean alpha;
+ int visibility;
+ gboolean focused;
+ int pid;
+ int ppid;
+ int apid;
+} window_info;
+
+API int aul_window_stack_get(aul_window_stack_h *handle)
+{
+ GError *err = NULL;
+ GDBusMessage *msg;
+ GDBusMessage *reply;
+ GDBusConnection *conn;
+ int res = 0;
+ window_info *wi;
+ GVariant *body;
+ GVariantIter *iter = NULL;
+ GList *list = NULL;
+
+ if (system_conn == NULL) {
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (conn == NULL) {
+ _E("g_bus_get_sync() is failed. %s", err->message);
+ g_error_free(err);
+ return -1;
+ }
+ system_conn = conn;
+ }
+
+ msg = g_dbus_message_new_method_call(WM_BUS_NAME,
+ WM_OBJECT_PATH,
+ WM_INTERFACE_NAME,
+ WM_METHOD_NAME);
+ if (msg == NULL) {
+ _E("g_dbus_message_new_method_call() is failed.");
+ return -1;
+ }
+
+ reply = g_dbus_connection_send_message_with_reply_sync(system_conn, msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
+
+ if (!reply) {
+ if (err != NULL) {
+ _E("Failed to get info [%s]", err->message);
+ g_error_free(err);
+ }
+ res = -1;
+ goto out;
+ }
+
+ body = g_dbus_message_get_body(reply);
+ if (!body) {
+ res = -1;
+ goto out;
+ }
+
+ g_variant_get(body, "(a(uiiiibibiii))", &iter);
+ wi = malloc(sizeof(window_info));
+
+ while (g_variant_iter_loop(iter, "(uiiiibibiii)",
+ &wi->gid,
+ &wi->x,
+ &wi->y,
+ &wi->w,
+ &wi->h,
+ &wi->alpha,
+ &wi->visibility,
+ &wi->focused,
+ &wi->pid,
+ &wi->ppid,
+ &wi->apid)) {
+ list = g_list_append(list, wi);
+ wi = malloc(sizeof(window_info));
+ }
+
+ free(wi);
+ if (iter)
+ g_variant_iter_free(iter);
+ *handle = list;
+out:
+ if (msg)
+ g_object_unref(msg);
+ if (reply)
+ g_object_unref(reply);
+
+ return res;
+}
+
+static void __free_info(gpointer data)
+{
+ free(data);
+}
+
+API int aul_window_stack_del(aul_window_stack_h handle)
+{
+ if (!handle)
+ return -1;
+
+ g_list_free_full(handle, __free_info);
+ return 0;
+}
+
+API int aul_window_stack_foreach(aul_window_stack_h *handle,
+ void (*iter_cb)(aul_window_info_h info, void *data), void *data)
+{
+ GList *i = (GList*)handle;
+
+ if (!iter_cb || !handle)
+ return -1;
+
+ while (i) {
+ iter_cb(i->data, data);
+ i = g_list_next(i);
+ }
+
+ return 0;
+}
+
+API int aul_window_stack_info_get_resource_id(aul_window_info_h info, unsigned int *rid)
+{
+ window_info *wi = info;
+
+ if (!info || !rid)
+ return -1;
+
+ *rid = wi->gid;
+ return 0;
+}
+
+API int aul_window_info_get_pid(aul_window_info_h info, int *pid)
+{
+ window_info *wi = info;
+
+ if (!info || !pid)
+ return -1;
+
+ *pid = wi->pid;
+ return 0;
+}
+
+API int aul_window_info_get_parent_pid(aul_window_info_h info, int *ppid)
+{
+ window_info *wi = info;
+
+ if (!info || !ppid)
+ return -1;
+
+ *ppid = wi->ppid;
+ return 0;
+}
+
+API int aul_window_info_get_ancestor_pid(aul_window_info_h info, int *apid)
+{
+ window_info *wi = info;
+
+ if (!info || !apid)
+ return -1;
+
+ *apid = wi->apid;
+ return 0;
+}
+
+API int aul_window_info_get_visibility(aul_window_info_h info, int *visibility)
+{
+ window_info *wi = info;
+
+ if (!info || !visibility)
+ return -1;
+
+ *visibility = wi->visibility;
+ return 0;
+}
+
+API int aul_window_info_has_alpha(aul_window_info_h info, bool *alpha)
+{
+ window_info *wi = info;
+
+ if (!info || !alpha)
+ return -1;
+
+ *alpha = (bool)(wi->alpha);
+ return 0;
+}
+
+API int aul_window_info_is_focused(aul_window_info_h info, bool *focused)
+{
+ window_info *wi = info;
+
+ if (!info || !focused)
+ return -1;
+
+ *focused = (bool)(wi->focused);
+ return 0;
+}
+
+API int aul_window_info_get_geometry(aul_window_info_h info, int *x, int *y, int *w, int *h)
+{
+ window_info *wi = info;
+
+ if (!info || !x || !y || !w || !h)
+ return -1;
+
+ *x = wi->x;
+ *y = wi->y;
+ *w = wi->w;
+ *h = wi->h;
+ return 0;
+}
+
+