From: Ning Tang <ning.t...@intel.com>

 It is a base for further operations on layout. Launchers are put in a
 certain layout.

 Signed-off-by: Ning Tang <tecto...@gmail.com>

---
 clients/tablet-shell.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++---
 weston-tablet.ini      |  3 ++-
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index 0a66950..c4ec5e7 100644
--- a/clients/tablet-shell.c
+++ b/clients/tablet-shell.c
@@ -47,6 +47,7 @@ struct homescreen {
        struct window *window;
        struct widget *widget;
        struct wl_list launcher_list;
+       struct wl_list layout_list;
 };
 
 struct lockscreen {
@@ -54,9 +55,24 @@ struct lockscreen {
        struct widget *widget;
 };
 
+/* container of launchers on background */
+struct layout {
+       struct widget *widget;
+       struct homescreen *homescreen;
+       struct wl_list launcher_list;
+       struct wl_list link;
+       int pressed;
+       int showing;
+       int hmargin;
+       int vmargin;
+
+       struct wl_list *layout_list;    /* we need know the number of list */
+};
+
 struct launcher {
        struct widget *widget;
        struct homescreen *homescreen;
+       struct layout *layout;
        cairo_surface_t *icon;
        int focused, pressed;
        char *path;
@@ -69,6 +85,7 @@ static char *key_homescreen_background;
 static char *key_launcher_icon;
 static char *key_launcher_path;
 static void launcher_section_done(void *data);
+static void layout_section_done(void *data);
 
 static const struct config_key shell_config_keys[] = {
        { "lockscreen-icon", CONFIG_KEY_STRING, &key_lockscreen_icon },
@@ -86,7 +103,10 @@ static const struct config_section config_sections[] = {
          shell_config_keys, ARRAY_LENGTH(shell_config_keys) },
        { "launcher",
          launcher_config_keys, ARRAY_LENGTH(launcher_config_keys),
-         launcher_section_done }
+         launcher_section_done },
+       { "layout",
+         NULL, 0,
+         layout_section_done }
 };
 
 static void
@@ -240,6 +260,7 @@ homescreen_create(struct tablet *tablet)
        window_set_title(homescreen->window, "homescreen");
        widget_set_redraw_handler(homescreen->widget, homescreen_draw);
 
+       wl_list_init(&homescreen->layout_list);
        return homescreen;
 }
 
@@ -354,7 +375,7 @@ launcher_button_handler(struct widget *widget,
        if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
                launcher_activate(launcher);
                launcher->pressed = 0;
-       } else if (state == WL_POINTER_BUTTON_STATE_PRESSED) 
+       } else if (state == WL_POINTER_BUTTON_STATE_PRESSED)
                launcher->pressed = 1;
 }
 
@@ -389,6 +410,32 @@ launcher_redraw_handler(struct widget *widget, void *data)
 }
 
 static void
+tablet_shell_add_layout(struct tablet *tablet)
+{
+       struct layout *layout;
+       struct homescreen *homescreen = tablet->homescreen;
+       struct rectangle allocation;
+       char *index_image;
+       widget_get_allocation(homescreen->widget, &allocation);
+
+       layout = malloc(sizeof *layout);
+       memset(layout, 0, sizeof *layout);
+       wl_list_init(&layout->launcher_list);
+       layout->widget = widget_add_widget(homescreen->widget, layout);
+       layout->homescreen = homescreen;
+       layout->hmargin = 100;
+       layout->vmargin = 50;
+       if (wl_list_empty(&homescreen->layout_list)) {
+               layout->showing = 1;
+       }
+
+       /* let layout know number of layouts */
+       layout->layout_list = &homescreen->layout_list;
+
+       wl_list_insert(homescreen->layout_list.prev, &layout->link);
+}
+
+static void
 tablet_shell_add_launcher(struct tablet *tablet,
                          const char *icon, const char *path)
 {
@@ -438,6 +485,14 @@ launcher_section_done(void *data)
 }
 
 static void
+layout_section_done(void *data)
+{
+       struct tablet *tablet = data;
+
+       tablet_shell_add_layout(tablet);
+}
+
+static void
 global_handler(struct wl_display *display, uint32_t id,
                const char *interface, uint32_t version, void *data)
 {
@@ -473,8 +528,9 @@ int main(int argc, char *argv[])
        tablet_shell_set_homescreen(tablet.tablet_shell,
                        window_get_wl_surface(tablet.homescreen->window));
        wl_list_init(&tablet.homescreen->launcher_list);
+       wl_list_init(&tablet.homescreen->layout_list);
 
-       config_file = config_file_path("weston.ini");
+       config_file = config_file_path("weston-tablet.ini");
        parse_config_file(config_file,
                          config_sections, ARRAY_LENGTH(config_sections),
                          &tablet);
diff --git a/weston-tablet.ini b/weston-tablet.ini
index 9387bab..d38b87a 100644
--- a/weston-tablet.ini
+++ b/weston-tablet.ini
@@ -5,6 +5,7 @@ lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
 homescreen=/usr/share/backgrounds/gnome/Aqua.jpg
 animation=zoom
 
+[layout]
 [launcher]
 icon=/usr/share/weston/org.tizen.browser.png
 path=/home/wayland-packages/weston/clients/simple-egl
@@ -18,7 +19,7 @@ path=/home/wayland-packages/weston/clients/flower
 icon=/usr/share/weston/org.tizen.clock.png
 path=/home/wayland-packages/weston/clients/dnd
 
-
+[layout]
 
#=======================================================================================
 [launcher]
 icon=/usr/share/weston/org.tizen.efl-calendar.png
-- 
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