diff options
author | Nakamura Hayato <hayato.nakamura@mail.toyota-td.jp> | 2013-05-15 19:16:56 +0900 |
---|---|---|
committer | Nakamura Hayato <hayato.nakamura@mail.toyota-td.jp> | 2013-05-15 19:16:56 +0900 |
commit | d3c6e3bc511aa6e8883bc2999965d7155695ed1d (patch) | |
tree | 3155d75c0a08f0a7f6b3ddc61e97c786c5a6e1cc /src | |
parent | 9c403af2ad9845278e082262c215dabf15f4025c (diff) | |
download | ico-uxf-weston-plugin-d3c6e3bc511aa6e8883bc2999965d7155695ed1d.tar.gz ico-uxf-weston-plugin-d3c6e3bc511aa6e8883bc2999965d7155695ed1d.tar.bz2 ico-uxf-weston-plugin-d3c6e3bc511aa6e8883bc2999965d7155695ed1d.zip |
Update package changelog.submit/2.0alpha-wayland/20130516.061823accepted/2.0alpha-wayland/20130520.093312
Change-Id: I0d6111980820fd652858bc980dc3680fcb92379b
Signed-off-by: Nakamura Hayato <hayato.nakamura@mail.toyota-td.jp>
Diffstat (limited to 'src')
-rw-r--r-- | src/config-parser.c | 389 | ||||
-rw-r--r-- | src/config-parser.h | 73 | ||||
-rw-r--r-- | src/ico_ivi_common.c | 4 | ||||
-rw-r--r-- | src/ico_ivi_shell.c | 134 | ||||
-rw-r--r-- | src/ico_ivi_shell.h | 1 | ||||
-rw-r--r-- | src/ico_window_mgr.c | 103 |
6 files changed, 490 insertions, 214 deletions
diff --git a/src/config-parser.c b/src/config-parser.c index 261c425..d291ac6 100644 --- a/src/config-parser.c +++ b/src/config-parser.c @@ -32,192 +32,235 @@ #include <fcntl.h> #include <unistd.h> +#if 1 /* Build in old Weston(1.0.6) */ +#include "config-parser.h" +#else /* Build on new Weston */ #include <weston/config-parser.h> +#endif 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; - - if (fd == -1) - return -1; - - 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; + FILE *fp; + char line[512], *p; + const struct config_section *current = NULL; + int i; + + if (fd == -1) + return -1; + fp = fdopen(dup(fd), "r"); + if (fp == NULL) { + perror("couldn't open config flle"); + 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; } +#if 0 +char * +config_file_path(const char *name) +{ + const char dotconf[] = "/.config/"; + const char *config_dir; + const char *home_dir; + char *path; + size_t size; + + config_dir = getenv("XDG_CONFIG_HOME"); + if (!config_dir) { + home_dir = getenv("HOME"); + if (!home_dir) { + fprintf(stderr, "HOME is not set, using cwd.\n"); + return strdup(name); + } + + size = strlen(home_dir) + sizeof dotconf + strlen(name); + path = malloc(size); + if (!path) + return NULL; + + snprintf(path, size, "%s%s%s", home_dir, dotconf, name); + return path; + } + + size = strlen(config_dir) + 1 + strlen(name) + 1; + path = malloc(size); + if (!path) + return NULL; + + snprintf(path, size, "%s/%s", config_dir, name); + return path; +} +#endif + 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; + 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/config-parser.h b/src/config-parser.h new file mode 100644 index 0000000..456b9a7 --- /dev/null +++ b/src/config-parser.h @@ -0,0 +1,73 @@ +/* + * Copyright © 2008 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef CONFIGPARSER_H +#define CONFIGPARSER_H + +enum config_key_type { + CONFIG_KEY_INTEGER, /* typeof data = int */ + CONFIG_KEY_UNSIGNED_INTEGER, /* typeof data = unsigned int */ + CONFIG_KEY_STRING, /* typeof data = char* */ + CONFIG_KEY_BOOLEAN /* typeof data = int */ +}; + +struct config_key { + const char *name; + enum config_key_type type; + void *data; +}; + +struct config_section { + const char *name; + const struct config_key *keys; + int num_keys; + void (*done)(void *data); +}; + +int +parse_config_file(int fd, + const struct config_section *sections, int num_sections, + void *data); + +int +open_config_file(const char *name); + +enum weston_option_type { + WESTON_OPTION_INTEGER, + WESTON_OPTION_UNSIGNED_INTEGER, + WESTON_OPTION_STRING, + WESTON_OPTION_BOOLEAN +}; + +struct weston_option { + enum weston_option_type type; + const char *name; + int short_name; + void *data; +}; + +int +parse_options(const struct weston_option *options, + int count, int argc, char *argv[]); + +#endif /* CONFIGPARSER_H */ + diff --git a/src/ico_ivi_common.c b/src/ico_ivi_common.c index 5245b04..9f12614 100644 --- a/src/ico_ivi_common.c +++ b/src/ico_ivi_common.c @@ -307,7 +307,7 @@ ico_ivi_dispname_2_node(const char *dispname) WL_EXPORT int module_init(struct weston_compositor *ec) { - int config_fd; + int config_fd; uifw_info("ico_ivi_common: Enter(module_init)"); @@ -315,7 +315,7 @@ module_init(struct weston_compositor *ec) config_fd = open_config_file(ICO_IVI_PLUGIN_CONFIG); parse_config_file(config_fd, conf_debug, ARRAY_LENGTH(conf_debug), NULL); close(config_fd); - + uifw_info("ico_ivi_common: option flag=0x%08x debug=%d", ico_option_flag(), ico_ivi_debuglevel()); diff --git a/src/ico_ivi_shell.c b/src/ico_ivi_shell.c index 5e69387..735a53b 100644 --- a/src/ico_ivi_shell.c +++ b/src/ico_ivi_shell.c @@ -72,7 +72,10 @@ struct ivi_shell { struct ivi_layer_list ivi_layer; /* Layer list */ enum animation_type win_animation_type; /* Default animetion */ int win_visible_on_create; /* Visible on create surface */ - struct shell_surface *active_shsurf; /* Active shell surface */ + struct shell_surface *active_pointer_shsurf; + /* Pointer active shell surface */ + struct shell_surface *active_keyboard_shsurf; + /* Keyboard active shell surface*/ }; /* Surface type */ @@ -1017,7 +1020,7 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy) type_changed = 1; } - if (! weston_surface_is_mapped(es)) { + if (! weston_surface_is_mapped(es)) { 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); @@ -1301,6 +1304,102 @@ ivi_shell_restack_ivi_layer(struct ivi_shell *shell, struct shell_surface *shsur /*--------------------------------------------------------------------------*/ /** + * @brief ivi_shell_set_active: surface active control + * + * @param[in] shsurf shell surface(if NULL, no active surface) + * @param[in] target target device + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ivi_shell_set_active(struct shell_surface *shsurf, const int target) +{ + struct ivi_shell *shell; + struct weston_seat *seat; + struct weston_surface *surface; + int object = target; + wl_fixed_t sx, sy; + + uifw_trace("ivi_shell_set_active: Enter(%08x,%x)", (int)shsurf, target); + + if (shsurf) { + shell = shell_surface_get_shell(shsurf); + surface = shsurf->surface; + if (object == 0) { + surface = NULL; + if (shell->active_pointer_shsurf == shsurf) { + object |= ICO_IVI_SHELL_ACTIVE_POINTER; + } + if (shell->active_keyboard_shsurf == shsurf) { + object |= ICO_IVI_SHELL_ACTIVE_KEYBOARD; + } + } + else { + if (object & ICO_IVI_SHELL_ACTIVE_POINTER) { + shell->active_pointer_shsurf = shsurf; + } + if (object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) { + shell->active_keyboard_shsurf = shsurf; + } + } + } + else { + shell = default_shell; + surface = NULL; + if (target == 0) { + object = ICO_IVI_SHELL_ACTIVE_POINTER|ICO_IVI_SHELL_ACTIVE_KEYBOARD; + } + if (object & ICO_IVI_SHELL_ACTIVE_POINTER) { + shell->active_pointer_shsurf = NULL; + } + if (object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) { + shell->active_keyboard_shsurf = NULL; + } + } + + wl_list_for_each(seat, &shell->compositor->seat_list, link) { + if ((object & ICO_IVI_SHELL_ACTIVE_POINTER) && (seat->seat.pointer)) { + if (surface) { + uifw_trace("ivi_shell_set_active: pointer set surface(%08x=>%08x)", + (int)seat->seat.pointer->focus, (int)&surface->surface); + if (seat->seat.pointer->focus != &surface->surface) { + weston_surface_from_global_fixed(surface, + seat->seat.pointer->x, + seat->seat.pointer->y, + &sx, &sy); + wl_pointer_set_focus(seat->seat.pointer, &surface->surface, sx, sy); + } + } + else { + uifw_trace("ivi_shell_set_active: pointer reset surface(%08x)", + (int)seat->seat.pointer->focus); + wl_pointer_set_focus(seat->seat.pointer, NULL, + wl_fixed_from_int(0), wl_fixed_from_int(0)); + } + } + if ((object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) && (seat->has_keyboard)) { + if (surface) { + uifw_trace("ivi_shell_set_active: keyboard set surface(%08x=>%08x)", + (int)seat->seat.keyboard->focus, (int)&surface->surface); + if (seat->seat.keyboard->focus != &surface->surface) { + wl_keyboard_set_focus(seat->seat.keyboard, &surface->surface); + } + } + else { + uifw_trace("ivi_shell_set_active: keyboard reset surface(%08x)", + (int)seat->seat.keyboard); + wl_keyboard_set_focus(seat->seat.keyboard, NULL); + } + } + else { + uifw_trace("ivi_shell_set_active: seat[%08x] has no keyboard", (int)seat); + } + } + uifw_trace("ivi_shell_set_active: Leave(%08x)", (int)shsurf); +} + +/*--------------------------------------------------------------------------*/ +/** * @brief click_to_activate_binding: clieck and select surface * * @param[in] seat clicked target seat @@ -1330,9 +1429,8 @@ click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button, uifw_trace("click_to_activate_binding: Surface[%08x] is not visible", (int)shsurf); } - else if (shell_hook_select) { - if (shell->active_shsurf != shsurf) { - shell->active_shsurf = shsurf; + else if (shell->active_pointer_shsurf != shsurf) { + if (shell_hook_select) { /* surface select hook routine */ uifw_trace("click_to_activate_binding: call ivi_shell_hook_select[%08x]", (int)shsurf); @@ -1340,12 +1438,15 @@ click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button, uifw_trace("click_to_activate_binding: ret ivi_shell_hook_select") } else { - uifw_trace("click_to_activate_binding: ShellSurface[%08x] already active", - (int)shsurf); + ivi_shell_set_active(shsurf, + ICO_IVI_SHELL_ACTIVE_POINTER | + ICO_IVI_SHELL_ACTIVE_KEYBOARD); + uifw_trace("click_to_activate_binding: no hook[%08x]", (int)shsurf); } } else { - uifw_trace("click_to_activate_binding: no hook[%08x]", (int)shsurf); + uifw_trace("click_to_activate_binding: ShellSurface[%08x] already active", + (int)shsurf); } } } @@ -1353,7 +1454,6 @@ click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_visible: surface visible control - * API for other weston plugin * * @param[in] shsurf shell surface * @param[in] visible visibility(1=visible/0=unvisible) @@ -1394,7 +1494,6 @@ ivi_shell_set_visible(struct shell_surface *shsurf, const int visible) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_is_visible: get surface visibility - * API for other weston plugin * * @param[in] shsurf shell surface * @return visibility @@ -1411,7 +1510,6 @@ ivi_shell_is_visible(struct shell_surface *shsurf) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_layer: set(or change) surface layer - * API for other weston plugin * * @param[in] shsurf shell surface * @param[in] layer layer id @@ -1487,7 +1585,6 @@ ivi_shell_set_layer(struct shell_surface *shsurf, const int layer) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_raise: surface stack control - * API for other weston plugin * * @param[in] shsurf shell surface * @param[in] raise raise/lower(1=raise/0=lower) @@ -1521,7 +1618,6 @@ ivi_shell_set_raise(struct shell_surface *shsurf, const int raise) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_toplevel: set surface type toplevel - * API for other weston plugin * * @param[in] shsurf shell surface * @return none @@ -1537,7 +1633,6 @@ ivi_shell_set_toplevel(struct shell_surface *shsurf) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_surface_type: set surface type - * API for other weston plugin * * @param[in] shsurf shell surface * @return none @@ -1553,7 +1648,6 @@ ivi_shell_set_surface_type(struct shell_surface *shsurf) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_send_configure: send surface resize event - * API for other weston plugin * * @param[in] shsurf shell surface * @param[in] id client object id(unused) @@ -1578,7 +1672,6 @@ ivi_shell_send_configure(struct shell_surface *shsurf, const int id, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_positionsize: set surface position and size - * API for other weston plugin * * @param[in] shsurf shell surface * @param[in] x surface upper-left X position on screen @@ -1603,7 +1696,6 @@ ivi_shell_set_positionsize(struct shell_surface *shsurf, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_set_layer_visible: layer visible control - * API for other weston plugin * * @param[in] layer layer id * @param[in] visible visibility(1=visible/0=unvisible) @@ -1692,7 +1784,6 @@ ivi_shell_set_layer_visible(const int layer, const int visible) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_surface_configure: surface change - * API for other weston plugin * * @param[in] shsurf shell surface * @param[in] x surface upper-left X position on screen @@ -1735,7 +1826,6 @@ ivi_shell_surface_configure(struct shell_surface *shsurf, const int x, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_bind: regist hook function for shell bind - * API for other weston plugin * * @param[in] hook_bind hook function(if NULL, reset hook function) * @return none @@ -1751,7 +1841,6 @@ ivi_shell_hook_bind(void (*hook_bind)(struct wl_client *client)) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_unbind: regist hook function for shell unbind - * API for other weston plugin * * @param[in] hook_unbind hook function(if NULL, reset hook function) * @return none @@ -1767,7 +1856,6 @@ ivi_shell_hook_unbind(void (*hook_unbind)(struct wl_client *client)) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_create: regist hook function for create shell surface - * API for other weston plugin * * @param[in] hook_create hook function(if NULL, reset hook function) * @return none @@ -1785,7 +1873,6 @@ ivi_shell_hook_create(void (*hook_create)(struct wl_client *client, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_destroy: regist hook function for destroy shell surface - * API for other weston plugin * * @param[in] hook_destroy hook function(if NULL, reset hook function) * @return none @@ -1801,7 +1888,6 @@ ivi_shell_hook_destroy(void (*hook_destroy)(struct weston_surface *surface)) /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_map: regist hook function for map shell surface - * API for other weston plugin * * @param[in] hook_map hook function(if NULL, reset hook function) * @return none @@ -1818,7 +1904,6 @@ ivi_shell_hook_map(void (*hook_map)(struct weston_surface *surface, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_change: regist hook function for change shell surface - * API for other weston plugin * * @param[in] hook_change hook function(if NULL, reset hook function) * @return none @@ -1835,7 +1920,6 @@ ivi_shell_hook_change(void (*hook_change)(struct weston_surface *surface, /*--------------------------------------------------------------------------*/ /** * @brief ivi_shell_hook_select: regist hook function for select(active) shell surface - * API for other weston plugin * * @param[in] hook_select hook function(if NULL, reset hook function) * @return none diff --git a/src/ico_ivi_shell.h b/src/ico_ivi_shell.h index 2a0d9da..eaad346 100644 --- a/src/ico_ivi_shell.h +++ b/src/ico_ivi_shell.h @@ -49,6 +49,7 @@ void ivi_shell_set_positionsize(struct shell_surface *shsurf, const int x, void ivi_shell_set_layer_visible(const int layer, const int visible); void ivi_shell_surface_configure(struct shell_surface *shsurf, const int x, const int y, const int width, const int height); +void ivi_shell_set_active(struct shell_surface *shsurf, const int target); /* Prototypr for hook routine */ void ivi_shell_hook_bind(void (*hook_bind)(struct wl_client *client)); diff --git a/src/ico_window_mgr.c b/src/ico_window_mgr.c index 4a2b155..3c2d14e 100644 --- a/src/ico_window_mgr.c +++ b/src/ico_window_mgr.c @@ -103,7 +103,8 @@ struct ico_win_mgr { struct wl_list manager_list; /* Manager(ex.HomeScreen) list */ int num_manager; /* Number of managers */ struct wl_list surface_list; /* Surface list */ - struct uifw_win_surface *active_surface;/* Active Surface */ + struct uifw_win_surface *active_pointer_surface; /* Active Pointer Surface */ + struct uifw_win_surface *active_keyboard_surface; /* Active Keyboard Surface */ struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */ struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */ @@ -164,7 +165,7 @@ static void uifw_set_transition(struct wl_client *client, struct wl_resource *re uint32_t surfaceid, int32_t transition); /* set active surface (form HomeScreen) */ static void uifw_set_active(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid); + uint32_t surfaceid, uint32_t target); /* layer visibility control */ static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource, int32_t layer, int32_t visible); @@ -1101,32 +1102,106 @@ uifw_set_transition(struct wl_client *client, struct wl_resource *resource, * @param[in] client Weyland client * @param[in] resource resource of request * @param[in] surfaceid UIFW surface id + * @param[in] target target device * @return none */ /*--------------------------------------------------------------------------*/ static void -uifw_set_active(struct wl_client *client, struct wl_resource *resource, uint32_t surfaceid) +uifw_set_active(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, uint32_t target) { - struct uifw_win_surface* usurf = find_uifw_win_surface_by_id(surfaceid); + struct uifw_win_surface* usurf; - uifw_trace("uifw_set_active: Enter(surf=%08x)", surfaceid); + uifw_trace("uifw_set_active: Enter(surf=%08x,target=%x)", surfaceid, target); + if ((surfaceid > 0) && + ((target & (ICO_IVI_SHELL_ACTIVE_POINTER|ICO_IVI_SHELL_ACTIVE_KEYBOARD)) != 0)) { + usurf = find_uifw_win_surface_by_id(surfaceid); + } + else { + usurf = NULL; + } if (usurf) { - if (usurf != _ico_win_mgr->active_surface) { - if (_ico_win_mgr->active_surface) { + switch (target & (ICO_IVI_SHELL_ACTIVE_POINTER|ICO_IVI_SHELL_ACTIVE_KEYBOARD)) { + case ICO_IVI_SHELL_ACTIVE_POINTER: + if (usurf != _ico_win_mgr->active_pointer_surface) { + if (_ico_win_mgr->active_pointer_surface) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_pointer_surface->id, NULL, + (_ico_win_mgr->active_keyboard_surface == + _ico_win_mgr->active_pointer_surface) ? + ICO_IVI_SHELL_ACTIVE_KEYBOARD : + ICO_IVI_SHELL_ACTIVE_NONE, + 0,0,0,0,0); + } + _ico_win_mgr->active_pointer_surface = usurf; + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + surfaceid, NULL, + ICO_IVI_SHELL_ACTIVE_POINTER | + (_ico_win_mgr->active_keyboard_surface == usurf) ? + ICO_IVI_SHELL_ACTIVE_KEYBOARD : 0, + 0,0,0,0,0); + ivi_shell_set_active(usurf->shsurf, ICO_IVI_SHELL_ACTIVE_POINTER); + } + break; + case ICO_IVI_SHELL_ACTIVE_KEYBOARD: + if (usurf != _ico_win_mgr->active_keyboard_surface) { + if (_ico_win_mgr->active_keyboard_surface) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_keyboard_surface->id, NULL, + (_ico_win_mgr->active_keyboard_surface == + _ico_win_mgr->active_pointer_surface) ? + ICO_IVI_SHELL_ACTIVE_POINTER : + ICO_IVI_SHELL_ACTIVE_NONE, + 0,0,0,0,0); + } + _ico_win_mgr->active_keyboard_surface = usurf; + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + surfaceid, NULL, + ICO_IVI_SHELL_ACTIVE_KEYBOARD | + (_ico_win_mgr->active_pointer_surface == usurf) ? + ICO_IVI_SHELL_ACTIVE_POINTER : 0, + 0,0,0,0,0); + ivi_shell_set_active(usurf->shsurf, ICO_IVI_SHELL_ACTIVE_KEYBOARD); + } + break; + default: + if ((usurf != _ico_win_mgr->active_pointer_surface) || + (usurf != _ico_win_mgr->active_keyboard_surface)) { + if (_ico_win_mgr->active_pointer_surface) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_pointer_surface->id, + NULL, ICO_IVI_SHELL_ACTIVE_NONE, + 0,0,0,0,0); + if (_ico_win_mgr->active_keyboard_surface == + _ico_win_mgr->active_pointer_surface) { + _ico_win_mgr->active_keyboard_surface = NULL; + } + } + if (_ico_win_mgr->active_keyboard_surface) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_keyboard_surface->id, + NULL, ICO_IVI_SHELL_ACTIVE_NONE, + 0,0,0,0,0); + } + _ico_win_mgr->active_pointer_surface = usurf; + _ico_win_mgr->active_keyboard_surface = usurf; ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - surfaceid, NULL, ICO_WINDOW_MGR_ACTIVE_INACTIVE, + surfaceid, NULL, + ICO_IVI_SHELL_ACTIVE_POINTER | + ICO_IVI_SHELL_ACTIVE_KEYBOARD, 0,0,0,0,0); + ivi_shell_set_active(usurf->shsurf, + ICO_IVI_SHELL_ACTIVE_POINTER | + ICO_IVI_SHELL_ACTIVE_KEYBOARD); } - _ico_win_mgr->active_surface = usurf; - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - surfaceid, NULL, ICO_WINDOW_MGR_ACTIVE_ACTIVE, - 0,0,0,0,0); + break; } uifw_trace("uifw_set_active: Leave(Change Active)"); } else { - uifw_trace("uifw_set_active: Leave(Surface(%08x) Not exist)", surfaceid); + ivi_shell_set_active(NULL, target); + uifw_trace("uifw_set_active: Leave(Reset active surface)"); } } @@ -1258,7 +1333,7 @@ win_mgr_surface_select(struct weston_surface *surface) /* send active event to manager */ ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - usurf->id, NULL, ICO_WINDOW_MGR_ACTIVE_SELECT, 0,0,0,0,0); + usurf->id, NULL, ICO_IVI_SHELL_ACTIVE_SELECTED, 0,0,0,0,0); uifw_trace("win_mgr_surface_select: Leave(OK)"); } |