Ported library code to raise window in X to wayland 04/2804/1
authorJimmy Huang <jimmy.huang@intel.com>
Tue, 5 Mar 2013 00:58:48 +0000 (16:58 -0800)
committerJimmy Huang <jimmy.huang@intel.com>
Tue, 5 Mar 2013 00:58:48 +0000 (16:58 -0800)
Replaced call to x_raise_win() to make wayland equivalent calls.
It will call ecore_wl_window_shell_surface_raise() in ecore-wayland
in order to raise the shell surface that belongs to the app window.

Also removed ecore-x and added ecore-wayland build deps.

Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
CMakeLists.txt
include/appcore-internal.h
packaging/app-core.spec
src/appcore-wayland.c [new file with mode: 0755]
src/appcore.c

index 5bf46b0..c4f910e 100644 (file)
@@ -24,12 +24,13 @@ SET(CMAKE_SKIP_BUILD_RPATH TRUE)
 SET(APPCORE_COMMON "appcore-common")
 SET(SRCS_common src/appcore.c src/appcore-i18n.c src/appcore-measure.c
 #              src/appcore-noti.c src/appcore-pmcontrol.c 
-               src/appcore-rotation.c)
+               src/appcore-rotation.c
+               src/appcore-wayland.c)
 SET(HEADERS_common appcore-common.h)
 
 INCLUDE(FindPkgConfig)
 #pkg_check_modules(pkg_common REQUIRED pmapi vconf sensor aul rua dlog)
-pkg_check_modules(pkg_common REQUIRED vconf sensor aul dlog)
+pkg_check_modules(pkg_common REQUIRED vconf sensor aul dlog ecore-wayland)
 FOREACH(flag ${pkg_common_CFLAGS})
        SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} ${flag}")
 ENDFOREACH(flag)
@@ -57,7 +58,7 @@ SET(SRCS_efl src/appcore-efl.c)
 SET(HEADERS_efl appcore-efl.h)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkg_efl REQUIRED elementary dlog sysman ecore ecore-x gobject-2.0 glib-2.0)
+pkg_check_modules(pkg_efl REQUIRED elementary dlog sysman ecore ecore-wayland gobject-2.0 glib-2.0)
 FOREACH(flag ${pkg_efl_CFLAGS})
        SET(EXTRA_CFLAGS_efl "${EXTRA_CFLAGS_efl} ${flag}")
 ENDFOREACH(flag)
index 975d308..9b5ea9d 100755 (executable)
@@ -163,6 +163,9 @@ void update_region(void);
 /* appcore-X.c */
 extern int x_raise_win(pid_t pid);
 
+/* appcore-wayland.c */
+extern int wayland_raise_win(pid_t pid);
+
 /* appcore-util.c */
 /* extern void stack_trim(void);*/
 
index 7f3fd9f..3df02cf 100644 (file)
@@ -15,7 +15,7 @@ BuildRequires:  pkgconfig(x11)
 BuildRequires:  pkgconfig(sysman)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(ecore)
-BuildRequires:  pkgconfig(ecore-x)
+BuildRequires:  pkgconfig(ecore-wayland)
 BuildRequires:  pkgconfig(gobject-2.0)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  cmake
diff --git a/src/appcore-wayland.c b/src/appcore-wayland.c
new file mode 100755 (executable)
index 0000000..a8474fe
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ *  app-core
+ *
+ * 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.
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+
+#include "appcore-internal.h"
+
+/*
+ * Porting of x_raise_win(pid_t pid) in appcore-X.c
+ * to wayland equivalent.
+ *
+ * Require patched wayland/weston/ecore
+ * to support shell_surface_raise request
+ */
+
+/*
+ * the window id of an EFL app in wayland is always 1
+ */
+#define DEFAULT_WIN_ID 1
+
+int wayland_raise_win(pid_t pid)
+{
+
+       int r;
+       int found;
+       struct wl_display *d;
+       Ecore_Wl_Window *win;
+
+       if (pid < 1) {
+               errno = EINVAL;
+               return -1;
+       }
+
+        _DBG("pid > -1: %d", pid);
+
+       r = kill(pid, 0);
+       if (r == -1) {
+               errno = ESRCH;  /* No such process */
+               return -1;
+       }
+
+        _DBG("wayland get display:");
+       d = ecore_wl_display_get();
+       _retv_if(d == NULL, -1);
+
+       win = ecore_wl_window_find(DEFAULT_WIN_ID);
+
+        _DBG("window %d:", win);
+       if (!win) {
+               errno = ENOENT;
+               return -1;
+       }
+
+       ecore_wl_window_shell_surface_raise(win);
+
+       return 0;
+}
index da73801..004b76e 100755 (executable)
@@ -194,9 +194,15 @@ static int __app_reset(void *data, bundle * k)
 
 static int __app_resume(void *data)
 {
-       #if HAVE_X
+#if HAVE_X
        x_raise_win(getpid());
-       #endif
+#else
+       /*
+        * Resume app by raising window in wayland instead
+        */
+       wayland_raise_win(getpid());
+#endif
+
        return 0;
 }