[PATCH 13/19] tablet-shell: add key binding to launch terminal.

ning.tang at intel.com ning.tang at intel.com
Mon Sep 24 19:39:58 PDT 2012


From: Ning Tang <ning.tang at intel.com>

Terminal is regarded as special application to tablet-shell. So use
ctrl+T to launch it.
The server will send an event to daemon, and it will launch terminal
according to the path in .ini file.

 Signed-off-by: Ning Tang <ning.tang at intel.com>
---
 clients/tablet-shell.c    | 25 ++++++++++++++++++++++++-
 protocol/tablet-shell.xml |  1 +
 src/tablet-shell.c        | 12 ++++++++++++
 weston-tablet.ini         |  1 +
 4 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index 39124a4..a19effa 100644
--- a/clients/tablet-shell.c
+++ b/clients/tablet-shell.c
@@ -108,6 +108,7 @@ static void launcher_section_done(void *data);
 static void layout_section_done(void *data);
 static char *key_layout_indicator_path;
 static char *key_trash_image;
+static char *key_terminal;
 /* launcher drag */
 struct launcher *gl_launcher_drag = NULL;
 static int launcher_size;
@@ -123,6 +124,7 @@ static const struct config_key shell_config_keys[] = {
 	{ "lockscreen", CONFIG_KEY_STRING, &key_lockscreen_background },
 	{ "homescreen", CONFIG_KEY_STRING, &key_homescreen_background },
 	{ "trash-image", CONFIG_KEY_STRING, &key_trash_image },
+	{ "terminal", CONFIG_KEY_STRING, &key_terminal },
 	{ "layout-indicator", CONFIG_KEY_STRING, &key_layout_indicator_path },
 	{ "layout-rows", CONFIG_KEY_UNSIGNED_INTEGER, &key_layout_rows },
 	{ "layout-columns", CONFIG_KEY_UNSIGNED_INTEGER, &key_layout_columns },
@@ -686,10 +688,31 @@ hide_switcher(void *data, struct tablet_shell *tablet_shell)
 {
 }
 
+static void
+launch_terminal(void *data, struct tablet_shell *tablet_shell)
+{
+	pid_t pid;
+
+	pid = fork();
+	if (pid < 0) {
+		fprintf(stderr, "fork failed: %m\n");
+		return;
+	}
+
+	if (pid)
+		return;
+
+	if (execl(key_terminal, key_terminal, NULL) < 0) {
+		fprintf(stderr, "execl '%s' failed: %m\n", key_terminal);
+		exit(1);
+	}
+}
+
 static const struct tablet_shell_listener tablet_shell_listener = {
 	show_lockscreen,
 	show_switcher,
-	hide_switcher
+	hide_switcher,
+	launch_terminal
 };
 
 static int
diff --git a/protocol/tablet-shell.xml b/protocol/tablet-shell.xml
index f226c01..24ca2fd 100644
--- a/protocol/tablet-shell.xml
+++ b/protocol/tablet-shell.xml
@@ -30,6 +30,7 @@
     <event name="show_lockscreen"/>
     <event name="show_switcher"/>
     <event name="hide_switcher"/>
+    <event name="launch_terminal"/>
   </interface>
 
   <interface name="tablet_client" version="1">
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index a12255e..0bd0120 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -978,6 +978,14 @@ force_kill_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
 }
 
 static void
+launch_terminal(struct wl_seat *seat, uint32_t time, uint32_t key,
+		void *data)
+{
+	struct tablet_shell *shell = data;
+	tablet_shell_send_launch_terminal(&shell->resource);
+}
+
+static void
 destroy_tablet_shell(struct wl_resource *resource)
 {
 }
@@ -1091,6 +1099,10 @@ module_init(struct weston_compositor *compositor)
 					     shell);
 	weston_compositor_add_key_binding(compositor, KEY_ESC, 0,
 					  force_kill_binding, shell);
+	weston_compositor_add_key_binding(compositor, KEY_T,
+					  MODIFIER_CTRL, launch_terminal,
+					  shell);
+
 	weston_layer_init(&shell->homescreen_layer,
 			  &compositor->cursor_layer.link);
 	weston_layer_init(&shell->application_layer,
diff --git a/weston-tablet.ini b/weston-tablet.ini
index f1f12ad..104a502 100644
--- a/weston-tablet.ini
+++ b/weston-tablet.ini
@@ -9,6 +9,7 @@ layout-columns=8
 icon-size=64
 trash-image=/usr/share/weston/trash.png
 layout-indicator=/usr/share/weston/
+terminal=/home/wayland-packages/weston/clients/weston-terminal
 
 [layout]
 [launcher]
-- 
1.7.12.1



More information about the wayland-devel mailing list