From: Ning Tang <ning.t...@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 <tecto...@gmail.com>

---
 clients/tablet-shell.c    | 25 ++++++++++++++++++++++++-
 protocol/tablet-shell.xml |  1 +
 src/tablet-shell.c        | 12 ++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index abf0e7c..65627be 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 },
@@ -688,10 +690,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 695f7d3..8c51d29 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -988,6 +988,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)
 {
 }
@@ -1104,6 +1112,10 @@ shell_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,
-- 
1.7.11.5

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to