Allow clicking on top panel to return to home screen
authorJimmy Huang <jimmy.huang@intel.com>
Thu, 28 Feb 2013 00:06:39 +0000 (16:06 -0800)
committerOssama Othman <ossama.othman@intel.com>
Fri, 19 Apr 2013 22:59:50 +0000 (15:59 -0700)
This is a work-around solution to allow us to return to the home screen in wayland since
there's no home button.

1. Defined new 'show_homescreen' request in desktop shell protocol.
2. Added handling in weston-shell to handle when show_homesreen is called, it raises
the surface belongs to the home screen (which is the org.tizen.menu-screen).
3. Registered click event when you click on the top launcher panel in the desktop shell,
it will return to the home screen, since the top launcher panel is always present in the
desktop shell client.

Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
clients/desktop-shell.c
protocol/desktop-shell.xml
src/shell.c

index 1cae789..51808a9 100644 (file)
@@ -44,6 +44,8 @@
 
 #include "desktop-shell-client-protocol.h"
 
+#define ENABLE_TIZEN
+
 extern char **environ; /* defined by libc */
 
 struct desktop {
@@ -72,6 +74,9 @@ struct panel {
        struct widget *widget;
        struct wl_list launcher_list;
        struct panel_clock *clock;
+#ifdef ENABLE_TIZEN
+       struct desktop *desktop;
+#endif
 };
 
 struct background {
@@ -418,6 +423,16 @@ panel_button_handler(struct widget *widget,
 
        if (button == BTN_RIGHT && state == WL_POINTER_BUTTON_STATE_PRESSED)
                show_menu(panel, input, time);
+#ifdef ENABLE_TIZEN
+       if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) {
+               /*
+                * Work-around to return to home menu screen 
+                * if the user click on the top taskbar panel
+                * since the taskbar don't have a home button icon
+                */
+               desktop_shell_show_homescreen(panel->desktop->shell);
+       }
+#endif
 }
 
 static void
@@ -512,6 +527,10 @@ panel_create(struct display *display)
        
        panel_add_clock(panel);
 
+#ifdef ENABLE_TIZEN
+       panel->desktop = display_get_user_data(display);
+#endif
+
        return panel;
 }
 
index 2b6afbd..6ecd405 100644 (file)
       <arg name="surface" type="object" interface="wl_surface"/>
     </request>
 
+    <request name="show_homescreen">
+      <description summary="show home screen">
+        Show the home screen
+      </description>
+    </request>
+
     <!-- We'll fold most of wl_shell into this interface and then
          they'll share the configure event.  -->
     <event name="configure">
index 2183ab4..9d0ae5e 100644 (file)
@@ -42,6 +42,9 @@
 
 #define DEFAULT_NUM_WORKSPACES 1
 #define DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH 200
+#ifdef ENABLE_TIZEN
+#define DEFAULT_HOMESCREEN_NAME "org.tizen.menu-screen"
+#endif
 
 enum animation_type {
        ANIMATION_NONE,
@@ -2361,12 +2364,58 @@ desktop_shell_set_grab_surface(struct wl_client *client,
        shell->grab_surface = surface_resource->data;
 }
 
+#ifdef ENABLE_TIZEN
+static void
+go_home(struct desktop_shell *shell, struct weston_seat *seat)
+{
+       struct weston_surface *surface;
+       struct shell_surface *shsurf;
+       struct weston_seat *s;
+       struct weston_compositor *ec = shell->compositor;
+
+       struct workspace *ws = get_current_workspace(shell);
+
+       /*
+        * Hack to show the home menu screen, since the shell doesn't really
+        * know which is the home surface, we check the title of surface to
+        * see if it is set to org.tizen.menu-screen and raise to the top
+        * of the stack
+        */
+       wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
+               shsurf = get_shell_surface(surface);
+               if (shsurf->title && !strcmp(DEFAULT_HOMESCREEN_NAME, shsurf->title)) {
+                       if (seat)
+                               activate(shell, surface, seat);
+                       else {
+                               wl_list_for_each(s, &ec->seat_list, link) {
+                                       activate(shell, surface, s);
+                               }
+                       }
+               }
+       }
+}
+
+/* Extended to show home screen */
+static void
+desktop_shell_show_homescreen(struct wl_client *client,
+                             struct wl_resource *resource)
+{
+       struct desktop_shell *shell = resource->data;
+       go_home(shell, NULL);
+}
+#endif
+
 static const struct desktop_shell_interface desktop_shell_implementation = {
        desktop_shell_set_background,
        desktop_shell_set_panel,
        desktop_shell_set_lock_surface,
        desktop_shell_unlock,
+#ifdef ENABLE_TIZEN
+       desktop_shell_set_grab_surface,
+       desktop_shell_show_homescreen,          // extended to show home screen
+#else
        desktop_shell_set_grab_surface
+#endif
 };
 
 static enum shell_surface_type