[PATCH 1/5] tablet-shell: Add layout on home screen.
tecton69 at gmail.com
tecton69 at gmail.com
Tue Jul 17 02:04:51 PDT 2012
From: Ning Tang <tecton69 at gmail.com>
Add a structure of layout which is between homescreen and launchers.
The configuration of layout is also included.
Signed-off-by: Li Chen <cl.zhejiang.china at gmail.com>
Signed-off-by: Yi Yuan <harryyuan910702 at gmail.com>
Signed-off-by: Ning Tang <tecton69 at gmail.com>
---
clients/tablet-shell.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 65 insertions(+), 2 deletions(-)
diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index 0a66950..f6e3bd2 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,8 +55,27 @@ 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 offset;
+ int last_x;
+ int hmargin;
+ int vmargin;
+ uint32_t click_time; /* ms */
+ int switching; /* 0-no 1-right -1-left*/
+ int s_speed; /* switching speed */
+ struct wl_list *layout_list; /* we need know the number of list */
+};
+
struct launcher {
struct widget *widget;
+ struct layout *layout;
struct homescreen *homescreen;
cairo_surface_t *icon;
int focused, pressed;
@@ -69,6 +89,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 +107,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 +264,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;
}
@@ -389,6 +414,36 @@ launcher_redraw_handler(struct widget *widget, void *data)
}
static void
+tablet_shell_add_layout(struct tablet *tablet)
+{
+ fprintf(stderr, "add layout\n");
+ struct layout *layout;
+ struct homescreen *homescreen = tablet->homescreen;
+ struct rectangle allocation;
+ 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;
+ layout->switching = 0;
+ layout->s_speed = 20;
+ if (wl_list_empty(&homescreen->layout_list))
+ layout->showing = 1;
+ else
+ layout->showing = 0;
+ layout->offset = 0;
+
+ /* 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 +493,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)
{
@@ -472,7 +535,7 @@ int main(int argc, char *argv[])
tablet.homescreen = homescreen_create(&tablet);
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");
parse_config_file(config_file,
--
1.7.11.1
More information about the wayland-devel
mailing list