diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config-parser.c | 340 | ||||
-rw-r--r-- | src/ico_ivi_shell.c | 17 | ||||
-rw-r--r-- | src/ico_window_animation.c | 57 |
3 files changed, 229 insertions, 185 deletions
diff --git a/src/config-parser.c b/src/config-parser.c index 0397a38..261c425 100644 --- a/src/config-parser.c +++ b/src/config-parser.c @@ -37,187 +37,187 @@ static int handle_key(const struct config_key *key, const char *value) { - char *end, *s; - int i, len; - unsigned int ui; - - switch (key->type) { - case CONFIG_KEY_INTEGER: - i = strtol(value, &end, 0); - if (*end != '\n') { - fprintf(stderr, "invalid integer: %s\n", value); - return -1; - } - *(int *)key->data = i; - return 0; - - case CONFIG_KEY_UNSIGNED_INTEGER: - ui = strtoul(value, &end, 0); - if (*end != '\n') { - fprintf(stderr, "invalid integer: %s\n", value); - return -1; - } - *(unsigned int *)key->data = ui; - return 0; - - case CONFIG_KEY_STRING: - len = strlen(value); - while (len > 0 && isspace(value[len - 1])) - len--; - s = malloc(len + 1); - if (s == NULL) - return -1; - memcpy(s, value, len); - s[len] = '\0'; - *(char **)key->data = s; - return 0; - - case CONFIG_KEY_BOOLEAN: - if (strcmp(value, "false\n") == 0) - *(int *)key->data = 0; - else if (strcmp(value, "true\n") == 0) - *(int *)key->data = 1; - else { - fprintf(stderr, "invalid bool: %s\n", value); - return -1; - } - return 0; - - default: - assert(0); - break; - } - - return -1; + char *end, *s; + int i, len; + unsigned int ui; + + switch (key->type) { + case CONFIG_KEY_INTEGER: + i = strtol(value, &end, 0); + if (*end != '\n') { + fprintf(stderr, "invalid integer: %s\n", value); + return -1; + } + *(int *)key->data = i; + return 0; + + case CONFIG_KEY_UNSIGNED_INTEGER: + ui = strtoul(value, &end, 0); + if (*end != '\n') { + fprintf(stderr, "invalid integer: %s\n", value); + return -1; + } + *(unsigned int *)key->data = ui; + return 0; + + case CONFIG_KEY_STRING: + len = strlen(value); + while (len > 0 && isspace(value[len - 1])) + len--; + s = malloc(len + 1); + if (s == NULL) + return -1; + memcpy(s, value, len); + s[len] = '\0'; + *(char **)key->data = s; + return 0; + + case CONFIG_KEY_BOOLEAN: + if (strcmp(value, "false\n") == 0) + *(int *)key->data = 0; + else if (strcmp(value, "true\n") == 0) + *(int *)key->data = 1; + else { + fprintf(stderr, "invalid bool: %s\n", value); + return -1; + } + return 0; + + default: + assert(0); + break; + } + + return -1; } int parse_config_file(int fd, - const struct config_section *sections, int num_sections, - void *data) + const struct config_section *sections, int num_sections, + void *data) { - FILE *fp; - char line[512], *p; - const struct config_section *current = NULL; - int i; + FILE *fp; + char line[512], *p; + const struct config_section *current = NULL; + int i; - if (fd == -1) - return -1; + if (fd == -1) + return -1; - fp = fdopen(dup(fd), "r"); - if (fp == NULL) { + fp = fdopen(dup(fd), "r"); + if (fp == NULL) { perror("couldn't open config file"); - return -1; - } - - rewind(fp); - - while (fgets(line, sizeof line, fp)) { - if (line[0] == '#' || line[0] == '\n') { - continue; - } if (line[0] == '[') { - p = strchr(&line[1], ']'); - if (!p || p[1] != '\n') { - fprintf(stderr, "malformed " - "section header: %s\n", line); - fclose(fp); - return -1; - } - if (current && current->done) - current->done(data); - p[0] = '\0'; - for (i = 0; i < num_sections; i++) { - if (strcmp(sections[i].name, &line[1]) == 0) { - current = §ions[i]; - break; - } - } - if (i == num_sections) - current = NULL; - } else if (p = strchr(line, '='), p != NULL) { - if (current == NULL) - continue; - p[0] = '\0'; - for (i = 0; i < current->num_keys; i++) { - if (strcmp(current->keys[i].name, line) == 0) { - if (handle_key(¤t->keys[i], &p[1]) < 0) { - fclose(fp); - return -1; - } - break; - } - } - } else { - fprintf(stderr, "malformed config line: %s\n", line); - fclose(fp); - return -1; - } - } - - if (current && current->done) - current->done(data); - - fclose(fp); - - return 0; + return -1; + } + + rewind(fp); + + while (fgets(line, sizeof line, fp)) { + if (line[0] == '#' || line[0] == '\n') { + continue; + } if (line[0] == '[') { + p = strchr(&line[1], ']'); + if (!p || p[1] != '\n') { + fprintf(stderr, "malformed " + "section header: %s\n", line); + fclose(fp); + return -1; + } + if (current && current->done) + current->done(data); + p[0] = '\0'; + for (i = 0; i < num_sections; i++) { + if (strcmp(sections[i].name, &line[1]) == 0) { + current = §ions[i]; + break; + } + } + if (i == num_sections) + current = NULL; + } else if (p = strchr(line, '='), p != NULL) { + if (current == NULL) + continue; + p[0] = '\0'; + for (i = 0; i < current->num_keys; i++) { + if (strcmp(current->keys[i].name, line) == 0) { + if (handle_key(¤t->keys[i], &p[1]) < 0) { + fclose(fp); + return -1; + } + break; + } + } + } else { + fprintf(stderr, "malformed config line: %s\n", line); + fclose(fp); + return -1; + } + } + + if (current && current->done) + current->done(data); + + fclose(fp); + + return 0; } int open_config_file(const char *name) { - const char *config_dir = getenv("XDG_CONFIG_HOME"); - const char *home_dir = getenv("HOME"); - const char *config_dirs = getenv("XDG_CONFIG_DIRS"); - char path[PATH_MAX]; - const char *p, *next; - int fd; - - /* Precedence is given to config files in the home directory, - * and then to directories listed in XDG_CONFIG_DIRS and - * finally to the current working directory. */ - - /* $XDG_CONFIG_HOME */ - if (config_dir) { - snprintf(path, sizeof path, "%s/%s", config_dir, name); - fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd >= 0) - return fd; - } - - /* $HOME/.config */ - if (home_dir) { - snprintf(path, sizeof path, "%s/.config/%s", home_dir, name); - fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd >= 0) - return fd; - } - - /* For each $XDG_CONFIG_DIRS: weston/<config_file> */ - if (!config_dirs) - config_dirs = "/etc/xdg"; /* See XDG base dir spec. */ - - for (p = config_dirs; *p != '\0'; p = next) { - next = strchrnul(p, ':'); - snprintf(path, sizeof path, - "%.*s/weston/%s", (int)(next - p), p, name); - fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd >= 0) - return fd; - - if (*next == ':') - next++; - } - - /* Current working directory. */ - snprintf(path, sizeof path, "./%s", name); - fd = open(path, O_RDONLY | O_CLOEXEC); - - if (fd >= 0) - fprintf(stderr, - "using config in current working directory: %s\n", - path); - else - fprintf(stderr, "config file \"%s\" not found.\n", name); - - return fd; + const char *config_dir = getenv("XDG_CONFIG_HOME"); + const char *home_dir = getenv("HOME"); + const char *config_dirs = getenv("XDG_CONFIG_DIRS"); + char path[PATH_MAX]; + const char *p, *next; + int fd; + + /* Precedence is given to config files in the home directory, + * and then to directories listed in XDG_CONFIG_DIRS and + * finally to the current working directory. */ + + /* $XDG_CONFIG_HOME */ + if (config_dir) { + snprintf(path, sizeof path, "%s/%s", config_dir, name); + fd = open(path, O_RDONLY | O_CLOEXEC); + if (fd >= 0) + return fd; + } + + /* $HOME/.config */ + if (home_dir) { + snprintf(path, sizeof path, "%s/.config/%s", home_dir, name); + fd = open(path, O_RDONLY | O_CLOEXEC); + if (fd >= 0) + return fd; + } + + /* For each $XDG_CONFIG_DIRS: weston/<config_file> */ + if (!config_dirs) + config_dirs = "/etc/xdg"; /* See XDG base dir spec. */ + + for (p = config_dirs; *p != '\0'; p = next) { + next = strchrnul(p, ':'); + snprintf(path, sizeof path, + "%.*s/weston/%s", (int)(next - p), p, name); + fd = open(path, O_RDONLY | O_CLOEXEC); + if (fd >= 0) + return fd; + + if (*next == ':') + next++; + } + + /* Current working directory. */ + snprintf(path, sizeof path, "./%s", name); + fd = open(path, O_RDONLY | O_CLOEXEC); + + if (fd >= 0) + fprintf(stderr, + "using config in current working directory: %s\n", + path); + else + fprintf(stderr, "config file \"%s\" not found.\n", name); + + return fd; } diff --git a/src/ico_ivi_shell.c b/src/ico_ivi_shell.c index fb7a61c..64d7a0f 100644 --- a/src/ico_ivi_shell.c +++ b/src/ico_ivi_shell.c @@ -1019,6 +1019,10 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy) uifw_trace("shell_surface_configure: Enter(surf=%08x out=%08x buf=%08x)", (int)es, (int)es->output, (int)es->buffer); + if (! es->buffer) { + uifw_trace("shell_surface_configure: Leave(no buffer)"); + return; + } if (shsurf->restrain) { uifw_trace("shell_surface_configure: Leave(restrain)"); return; @@ -1043,7 +1047,7 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy) } } else { - if ((shsurf->mapped == 0) && (es->buffer != NULL)) { + if (shsurf->mapped == 0) { if ((es->geometry.width > 0) && (es->geometry.height >0)) { uifw_trace("shell_surface_configure: map Surface size(sx/sy=%d/%d w/h=%d/%d)", sx, sy, es->buffer->width, es->buffer->height); @@ -1468,11 +1472,12 @@ ivi_shell_restrain_configure(struct shell_surface *shsurf, const int restrain) /*--------------------------------------------------------------------------*/ /** - * @brief ivi_shell_set_active: surface active control + * @brief ivi_shell_is_restrain: check surface restrain * * @param[in] shsurf shell surface(if NULL, no active surface) - * @param[in] restrain restrain(1)/not restrain(0) - * @return none + * @return restrain + * @retval =1 surface currently restrain + * @retval =0 not restrain */ /*--------------------------------------------------------------------------*/ WL_EXPORT int @@ -1570,7 +1575,8 @@ ivi_shell_set_visible(struct shell_surface *shsurf, const int visible) struct ivi_shell *shell = shell_surface_get_shell(shsurf); int next; - uifw_trace("ivi_shell_set_visible: [%08x] visible=%d", (int)shsurf, (int)visible); + uifw_trace("ivi_shell_set_visible: [%08x] (%08x) visible=%d", + (int)shsurf, (int)shsurf->surface, (int)visible); if (visible < 0) { next = shell->win_visible_on_create; @@ -1640,7 +1646,6 @@ ivi_shell_set_layer(struct shell_surface *shsurf, const int layer) /* search existing layer */ wl_list_for_each (el, &shell->ivi_layer.link, link) { - uifw_trace("ivi_shell_set_layer: el=%08x(%d)", (int)el, el->layer); if (el->layer == layer) break; } diff --git a/src/ico_window_animation.c b/src/ico_window_animation.c index a63b647..8e27a69 100644 --- a/src/ico_window_animation.c +++ b/src/ico_window_animation.c @@ -64,8 +64,11 @@ struct animation_data { int width; /* original width */ int height; /* original height */ char geometry_saved; /* need geometry restor at end */ - char res[3]; /* (unused) */ + char transform_set; /* need transform reset at end */ + char res[2]; /* (unused) */ struct weston_transform transform; /* transform matrix */ + void (*end_function)(struct weston_animation *animation); + /* animation end function */ }; /* static valiables */ @@ -82,6 +85,8 @@ static void animation_slide(struct weston_animation *animation, /* fade animation */ static void animation_fade(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); + /* fade animation end */ +static void animation_fade_end(struct weston_animation *animation); /* continue animation */ static int animation_cont(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); @@ -289,8 +294,6 @@ animation_cont(struct weston_animation *animation, struct weston_output *output, animadata->width = usurf->width; animadata->height = usurf->height; animadata->geometry_saved = 1; - weston_matrix_init(&animadata->transform.matrix); - wl_list_init(&animadata->transform.link); } else if (! usurf->animadata) { animation_end(usurf, 0); @@ -338,6 +341,9 @@ animation_end(struct uifw_win_surface *usurf, const int disp) animadata = (struct animation_data *)usurf->animadata; if (animadata) { + if (animadata->end_function) { + (*animadata->end_function)(&usurf->animation.animation); + } if (animadata->geometry_saved > 1) { usurf->x = animadata->x; usurf->y = animadata->y; @@ -346,7 +352,11 @@ animation_end(struct uifw_win_surface *usurf, const int disp) animadata->geometry_saved = 0; } wl_list_remove(&usurf->animation.animation.link); - wl_list_init(&usurf->animation.animation.link); + if (animadata->transform_set) { + wl_list_remove(&animadata->transform.link); + animadata->transform_set = 0; + } + usurf->surface->geometry.dirty = 1; } if (disp) { if ((usurf->animation.visible == ANIMA_HIDE_AT_END) && @@ -361,9 +371,9 @@ animation_end(struct uifw_win_surface *usurf, const int disp) ivi_shell_set_visible(usurf->shsurf, 1); weston_surface_damage_below(usurf->surface); weston_surface_damage(usurf->surface); - weston_compositor_schedule_repaint(weston_ec); } ivi_shell_restrain_configure(usurf->shsurf, 0); + weston_compositor_schedule_repaint(weston_ec); } usurf->animation.visible = ANIMA_NOCONTROL_AT_END; usurf->animation.type = usurf->animation.type_next; @@ -519,15 +529,20 @@ animation_fade(struct weston_animation *animation, es = usurf->surface; par = usurf->animation.current; if (animation->frame_counter == 1) { - wl_list_insert(&es->geometry.transformation_list, - &animadata->transform.link); + if (animadata->transform_set == 0) { + animadata->transform_set = 1; + weston_matrix_init(&animadata->transform.matrix); + wl_list_init(&animadata->transform.link); + wl_list_insert(&es->geometry.transformation_list, + &animadata->transform.link); + } + animadata->end_function = animation_fade_end; } uifw_trace("animation_fade: usurf=%08x count=%d %d%% type=%d state=%d", (int)usurf, animation->frame_counter, par, usurf->animation.type, usurf->animation.state); - if (usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_IN) { /* fade in */ es->alpha = ((double)par) / ((double)100.0); @@ -546,7 +561,6 @@ animation_fade(struct weston_animation *animation, } if (par >= 100) { /* end of animation */ - wl_list_remove(&animadata->transform.link); animation_end(usurf, 1); uifw_trace("animation_fade: End of animation"); } @@ -558,6 +572,31 @@ animation_fade(struct weston_animation *animation, /*--------------------------------------------------------------------------*/ /** + * @brief animation_fade_end: fade animation end + * + * @param[in] animation weston animation table + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +animation_fade_end(struct weston_animation *animation) +{ + struct uifw_win_surface *usurf; + struct weston_surface *es; + + usurf = container_of(animation, struct uifw_win_surface, animation.animation); + es = usurf->surface; + es->alpha = 1.0; + + if ((es->output) && (es->buffer) && + (es->geometry.width > 0) && (es->geometry.height > 0)) { + weston_surface_damage_below(es); + weston_surface_damage(es); + } +} + +/*--------------------------------------------------------------------------*/ +/** * @brief module_init: initialize ico_window_animation * this function called from ico_pluign_loader * |