2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Weston(Wayland) IVI Shell
26 * @brief Shell for IVI(In-Vehicle Infotainment).
36 #include <linux/input.h>
40 #include <sys/types.h>
44 #include <wayland-server.h>
45 #include <weston/compositor.h>
46 #include "ico_ivi_common.h"
47 #include "ico_ivi_shell.h"
48 #include "ico_ivi_shell-server-protocol.h"
50 /* Layer management */
51 struct ivi_layer_list {
52 int layer; /* Layer.ID */
54 struct wl_list surface_list; /* Surfacae list */
55 struct wl_list link; /* Link pointer for layer list */
58 /* Static table for Shell */
61 struct weston_compositor *compositor;
62 struct wl_listener destroy_listener;
63 struct weston_layer surface; /* Surface list */
64 struct ivi_layer_list ivi_layer; /* Layer list */
65 char win_animation[ICO_WINDOW_ANIMATION_LEN];
66 /* Default animation name */
67 int win_animation_time; /* animation time(ms) */
68 int win_animation_fps; /* animation frame rate(fps) */
69 int win_visible_on_create; /* Visible on create surface */
70 struct shell_surface *active_pointer_shsurf;
71 /* Pointer active shell surface */
72 struct shell_surface *active_keyboard_shsurf;
73 /* Keyboard active shell surface*/
77 enum shell_surface_type {
78 SHELL_SURFACE_NONE, /* Surface type undefine */
79 SHELL_SURFACE_TOPLEVEL, /* Top level surface for application */
80 SHELL_SURFACE_TRANSIENT, /* Child surface */
81 SHELL_SURFACE_FULLSCREEN, /* Full screen surface */
82 SHELL_SURFACE_MAXIMIZED, /* maximum screen */
83 SHELL_SURFACE_POPUP /* pop up screen */
86 /* Shell surface table */
87 struct shell_surface {
88 struct wl_resource resource;
90 struct weston_surface *surface;
91 struct wl_listener surface_destroy_listener;
92 struct weston_surface *parent;
93 struct ivi_shell *shell;
95 enum shell_surface_type type;
96 enum shell_surface_type next_type;
108 struct ivi_layer_list *layer_list;
109 struct wl_list ivi_layer;
114 unsigned short width;
115 unsigned short height;
119 struct weston_transform transform;
120 struct weston_matrix rotation;
130 struct wl_client *wclient;
131 const struct weston_shell_client *client;
134 static struct ivi_shell *default_shell = NULL;
137 /* static function prototype */
138 static void bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id);
139 static void unbind_shell(struct wl_resource *resource);
140 static struct shell_surface *get_shell_surface(struct weston_surface *surface);
141 static struct ivi_shell *shell_surface_get_shell(struct shell_surface *shsurf);
142 static void ivi_shell_restack_ivi_layer(struct ivi_shell *shell,
143 struct shell_surface *shsurf);
145 static void (*shell_hook_bind)(struct wl_client *client) = NULL;
146 static void (*shell_hook_unbind)(struct wl_client *client) = NULL;
147 static void (*shell_hook_create)(struct wl_client *client, struct wl_resource *resource,
148 struct weston_surface *surface,
149 struct shell_surface *shsurf) = NULL;
150 static void (*shell_hook_destroy)(struct weston_surface *surface) = NULL;
151 static void (*shell_hook_map)(struct weston_surface *surface, int32_t *width,
152 int32_t *height, int32_t *sx, int32_t *sy) = NULL;
153 static void (*shell_hook_change)(struct weston_surface *surface, const int to,
154 const int manager) = NULL;
155 static void (*shell_hook_select)(struct weston_surface *surface) = NULL;
158 /*--------------------------------------------------------------------------*/
160 * @brief shell_configuration: initiale configuration ico_ivi_shell
162 * @param[in] shell ico_ivi_shell static table area
165 /*--------------------------------------------------------------------------*/
167 shell_configuration(struct ivi_shell *shell)
170 char *win_animation = NULL;
171 int win_animation_time = 800;
172 int win_animation_fps = 15;
174 struct config_key shell_keys[] = {
175 { "animation", CONFIG_KEY_STRING, &win_animation },
176 { "animation_time", CONFIG_KEY_INTEGER, &win_animation_time },
177 { "animation_fps", CONFIG_KEY_INTEGER, &win_animation_fps },
178 { "visible_on_create", CONFIG_KEY_INTEGER, &shell->win_visible_on_create },
181 struct config_section cs[] = {
182 { "shell", shell_keys, ARRAY_LENGTH(shell_keys), NULL },
185 config_fd = open_config_file(ICO_IVI_PLUGIN_CONFIG);
186 parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), shell);
190 strncpy(shell->win_animation, win_animation, sizeof(shell->win_animation)-1);
192 if (win_animation_time < 100) win_animation_time = 100;
193 shell->win_animation_time = win_animation_time;
194 if (win_animation_fps > 30) win_animation_fps = 30;
195 if (win_animation_fps < 5) win_animation_fps = 5;
196 shell->win_animation_fps = win_animation_fps;
197 uifw_info("shell_configuration: Anima=%s,%dms,%dfps Visible=%d Debug=%d",
198 shell->win_animation, shell->win_animation_time, shell->win_animation_fps,
199 shell->win_visible_on_create, ico_ivi_debuglevel());
202 /*--------------------------------------------------------------------------*/
204 * @brief send_configure: send configure(resize) event to client applicstion
206 * @param[in] surface weston surface
207 * @param[in] edges surface resize position
208 * @param[in] width surface width
209 * @param[in] height surface height
212 /*--------------------------------------------------------------------------*/
214 send_configure(struct weston_surface *surface,
215 uint32_t edges, int32_t width, int32_t height)
217 struct shell_surface *shsurf = get_shell_surface(surface);
219 uifw_trace("send_configure: %08x edges=%x w/h=%d/%d map=%d",
220 (int)shsurf->surface, edges, width, height, shsurf->mapped);
221 if (shsurf->mapped == 0) return;
223 shsurf->configure_app.width = width;
224 shsurf->configure_app.height = height;
225 wl_shell_surface_send_configure(&shsurf->resource,
226 edges, width, height);
229 static const struct weston_shell_client shell_client = {
233 /*--------------------------------------------------------------------------*/
235 * @brief reset_shell_surface_type: reset surface type
237 * @param[in] shsurf shell surface
240 /*--------------------------------------------------------------------------*/
242 reset_shell_surface_type(struct shell_surface *shsurf)
244 uifw_trace("reset_shell_surface_type: [%08x]", (int)shsurf);
245 shsurf->type = SHELL_SURFACE_NONE;
249 /*--------------------------------------------------------------------------*/
251 * @brief set_surface_type: set surface type
253 * @param[in] shsurf shell surface
256 /*--------------------------------------------------------------------------*/
258 set_surface_type(struct shell_surface *shsurf)
260 struct weston_surface *surface = shsurf->surface;
261 struct weston_surface *pes = shsurf->parent;
262 struct shell_surface *psh;
264 uifw_trace("set_surface_type: [%08x] (%08x) type=%x",
265 (int)shsurf, (int)surface, (int)shsurf->next_type);
267 reset_shell_surface_type(shsurf);
269 shsurf->type = shsurf->next_type;
270 shsurf->next_type = SHELL_SURFACE_NONE;
272 switch (shsurf->type) {
273 case SHELL_SURFACE_TOPLEVEL:
275 case SHELL_SURFACE_TRANSIENT:
276 psh = get_shell_surface(pes);
278 shsurf->geometry_x = psh->geometry_x + shsurf->transient.x;
279 shsurf->geometry_y = psh->geometry_y + shsurf->transient.y;
282 shsurf->geometry_x = pes->geometry.x + shsurf->transient.x;
283 shsurf->geometry_y = pes->geometry.y + shsurf->transient.y;
291 /*--------------------------------------------------------------------------*/
293 * @brief shell_surface_pong: recceive pong(ping reply) (NOP)
295 * @param[in] client wayland client
296 * @param[in] resource pong resource
297 * @param[in] serial event serial number
300 /*--------------------------------------------------------------------------*/
302 shell_surface_pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial)
304 uifw_trace("shell_surface_pong: NOP[%08x]", (int)resource->data);
307 /*--------------------------------------------------------------------------*/
309 * @brief shell_surface_move: recceive move request (NOP)
311 * @param[in] client wayland client
312 * @param[in] resource move request resource
313 * @param[in] seat_resource seat resource
314 * @param[in] serial event serial number
317 /*--------------------------------------------------------------------------*/
319 shell_surface_move(struct wl_client *client, struct wl_resource *resource,
320 struct wl_resource *seat_resource, uint32_t serial)
322 uifw_trace("shell_surface_move: [%08x] NOP", (int)resource->data);
325 /*--------------------------------------------------------------------------*/
327 * @brief shell_surface_resize: recceive resize request (NOP)
329 * @param[in] client wayland client
330 * @param[in] resource resize request resource
331 * @param[in] seat_resource seat resource
332 * @param[in] serial event serial number
333 * @param[in] edges resize position
336 /*--------------------------------------------------------------------------*/
338 shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
339 struct wl_resource *seat_resource, uint32_t serial,
342 uifw_trace("shell_surface_resize: [%08x] NOP", (int)resource->data);
345 /*--------------------------------------------------------------------------*/
347 * @brief set_toplevel: set surface to TopLevel
349 * @param[in] shsurf shell surface
352 /*--------------------------------------------------------------------------*/
354 set_toplevel(struct shell_surface *shsurf)
356 shsurf->next_type = SHELL_SURFACE_TOPLEVEL;
359 /*--------------------------------------------------------------------------*/
361 * @brief shell_surface_set_toplevel: set surface to TopLevel(client interface)
363 * @param[in] client wayland client
364 * @param[in] resource set toplevel request resource
367 /*--------------------------------------------------------------------------*/
369 shell_surface_set_toplevel(struct wl_client *client, struct wl_resource *resource)
371 struct shell_surface *shsurf = resource->data;
373 uifw_trace("shell_surface_set_toplevel: Set TopLevel[%08x] surf=%08x",
374 (int)shsurf, (int)shsurf->surface);
376 set_toplevel(shsurf);
379 /*--------------------------------------------------------------------------*/
381 * @brief set_transient: set surface to child
383 * @param[in] shsurf shell surface
384 * @param[in] parent parent surface
385 * @param[in] x relative X position from a parent
386 * @param[in] y relative Y position from a parent
387 * @param[in] flags flag(unused)
390 /*--------------------------------------------------------------------------*/
392 set_transient(struct shell_surface *shsurf,
393 struct weston_surface *parent, int x, int y, uint32_t flags)
395 /* assign to parents output */
396 shsurf->parent = parent;
397 shsurf->transient.x = x;
398 shsurf->transient.y = y;
399 shsurf->transient.flags = flags;
400 shsurf->next_type = SHELL_SURFACE_TRANSIENT;
403 /*--------------------------------------------------------------------------*/
405 * @brief shell_surface_set_transient: set surface to child(client interface)
407 * @param[in] client wayland client
408 * @param[in] resource set transient request resource
409 * @param[in] parent_resource parent surface resource
410 * @param[in] x relative X position from a parent
411 * @param[in] y relative Y position from a parent
412 * @param[in] flags flag(unused)
415 /*--------------------------------------------------------------------------*/
417 shell_surface_set_transient(struct wl_client *client, struct wl_resource *resource,
418 struct wl_resource *parent_resource,
419 int x, int y, uint32_t flags)
421 struct shell_surface *shsurf = resource->data;
422 struct weston_surface *parent = parent_resource->data;
424 uifw_trace("shell_surface_set_transient: Set Transient[%08x] surf=%08x",
425 (int)shsurf, (int)shsurf->surface);
426 set_transient(shsurf, parent, x, y, flags);
429 /*--------------------------------------------------------------------------*/
431 * @brief shell_surface_set_fullscreen: set surface to full screen(same as toplevel)
433 * @param[in] client wayland client
434 * @param[in] resource set fullscreen request resource
435 * @param[in] method method(unused)
436 * @param[in] framerate frame rate(unused)
437 * @param[in] output_resource output resource(unused)
440 /*--------------------------------------------------------------------------*/
442 shell_surface_set_fullscreen(struct wl_client *client, struct wl_resource *resource,
443 uint32_t method, uint32_t framerate,
444 struct wl_resource *output_resource)
446 struct shell_surface *shsurf = resource->data;
447 uifw_trace("shell_surface_set_fullscreen: "
448 "NOP(same as set_toplevel)[%08x]", (int)shsurf);
449 shsurf->next_type = SHELL_SURFACE_FULLSCREEN;
452 /*--------------------------------------------------------------------------*/
454 * @brief shell_surface_set_popup: set surface to popup(same as toplevel)
456 * @param[in] client wayland client
457 * @param[in] resource set popup request resource
458 * @param[in] seat_resource seat resource(unused)
459 * @param[in] serial event serial number(unused)
460 * @param[in] parent_resource parent resource(unused)
461 * @param[in] x relative X position from a parent(unused)
462 * @param[in] y relative Y position from a parent(unused)
463 * @param[in] flags flag(unused)
466 /*--------------------------------------------------------------------------*/
468 shell_surface_set_popup(struct wl_client *client, struct wl_resource *resource,
469 struct wl_resource *seat_resource, uint32_t serial,
470 struct wl_resource *parent_resource,
471 int32_t x, int32_t y, uint32_t flags)
473 struct shell_surface *shsurf = resource->data;
474 uifw_trace("shell_surface_set_popup: NOP(same as set_toplevel)[%08x]", (int)shsurf);
475 shsurf->next_type = SHELL_SURFACE_POPUP;
478 /*--------------------------------------------------------------------------*/
480 * @brief shell_surface_set_maximized: set surface to maximized(same as toplevel)
482 * @param[in] client wayland client
483 * @param[in] resource set maximized request resource
484 * @param[in] output_resource output resource(unused)
487 /*--------------------------------------------------------------------------*/
489 shell_surface_set_maximized(struct wl_client *client, struct wl_resource *resource,
490 struct wl_resource *output_resource )
492 struct shell_surface *shsurf = resource->data;
493 uifw_trace("shell_surface_set_maximized: NOP(same as set_toplevel)[%08x]", (int)shsurf);
494 shsurf->next_type = SHELL_SURFACE_MAXIMIZED;
497 /*--------------------------------------------------------------------------*/
499 * @brief shell_surface_set_title: set surface title
501 * @param[in] client wayland client
502 * @param[in] resource set title request resource
503 * @param[in] title surface title
506 /*--------------------------------------------------------------------------*/
508 shell_surface_set_title(struct wl_client *client,
509 struct wl_resource *resource, const char *title)
511 struct shell_surface *shsurf = resource->data;
513 uifw_trace("shell_surface_set_title: [%08x] %s", (int)shsurf, title);
518 shsurf->title = strdup(title);
521 /*--------------------------------------------------------------------------*/
523 * @brief shell_surface_set_class: set surface class name
525 * @param[in] client wayland client
526 * @param[in] resource set class request resource
527 * @param[in] class surface class name
530 /*--------------------------------------------------------------------------*/
532 shell_surface_set_class(struct wl_client *client,
533 struct wl_resource *resource, const char *class)
535 struct shell_surface *shsurf = resource->data;
537 uifw_trace("shell_surface_set_class: [%08x] %s", (int)shsurf, class);
542 shsurf->class = strdup(class);
545 /*--------------------------------------------------------------------------*/
547 * @brief shell_surface_raise: raise surface
549 * @param[in] client wayland client
550 * @param[in] resource set class request resource
553 /*--------------------------------------------------------------------------*/
555 shell_surface_raise(struct wl_client *client, struct wl_resource *resource)
557 struct shell_surface *shsurf = resource->data;
559 uifw_trace("shell_surface_raise: [%08x]", (int)shsurf);
561 ivi_shell_set_raise(shsurf, 1);
564 static const struct wl_shell_surface_interface shell_surface_implementation = {
567 shell_surface_resize,
568 shell_surface_set_toplevel,
569 shell_surface_set_transient,
570 shell_surface_set_fullscreen,
571 shell_surface_set_popup,
572 shell_surface_set_maximized,
573 shell_surface_set_title,
574 shell_surface_set_class,
578 /*--------------------------------------------------------------------------*/
580 * @brief shell_surface_get_shell: get ico_ivi_shell static table
582 * @param[in] shsurf shell surface(if NULL, return default)
583 * @return ico_ivi_shell static table address
585 /*--------------------------------------------------------------------------*/
586 static struct ivi_shell *
587 shell_surface_get_shell(struct shell_surface *shsurf)
590 return shsurf->shell;
592 return default_shell;
595 /*--------------------------------------------------------------------------*/
597 * @brief destroy_shell_surface: destroy surface
599 * @param[in] shsurf shell surface
602 /*--------------------------------------------------------------------------*/
604 destroy_shell_surface(struct shell_surface *shsurf)
606 uifw_trace("destroy_shell_surface: Enter[%08x]", (int)shsurf);
608 if (shsurf->visible != FALSE) {
609 shsurf->visible = FALSE;
610 ivi_shell_restack_ivi_layer(shell_surface_get_shell(shsurf), shsurf);
613 wl_list_remove(&shsurf->ivi_layer);
615 if (shell_hook_destroy) {
616 /* call sufrace destory hook routine */
617 uifw_trace("destroy_shell_surface: call ivi_shell_hook_destroy(%08x)",
618 (int)shsurf->surface);
619 (void) (*shell_hook_destroy) (shsurf->surface);
620 uifw_trace("destroy_shell_surface: ret");
623 wl_list_remove(&shsurf->surface_destroy_listener.link);
624 shsurf->surface->configure = NULL;
626 wl_list_remove(&shsurf->link);
629 uifw_trace("destroy_shell_surface: Leave");
632 /*--------------------------------------------------------------------------*/
634 * @brief shell_destroy_shell_surface: destroy surface(client interface)
636 * @param[in] resource destroy request resource
639 /*--------------------------------------------------------------------------*/
641 shell_destroy_shell_surface(struct wl_resource *resource)
643 struct shell_surface *shsurf = resource->data;
645 uifw_trace("shell_destroy_shell_surface: Enter [%08x]", (int)shsurf);
647 destroy_shell_surface(shsurf);
649 uifw_trace("shell_destroy_shell_surface: Leave");
652 /*--------------------------------------------------------------------------*/
654 * @brief shell_handle_surface_destroy: destroy surface(listener interface)
656 * @param[in] listener listener
657 * @param[in] data user data(unused)
660 /*--------------------------------------------------------------------------*/
662 shell_handle_surface_destroy(struct wl_listener *listener, void *data)
664 struct shell_surface *shsurf = container_of(listener, struct shell_surface,
665 surface_destroy_listener);
667 uifw_trace("shell_handle_surface_destroy: Enter [%08x] data=%08x",
668 (int)shsurf, (int)data);
670 if (shsurf->resource.client) {
671 wl_resource_destroy(&shsurf->resource);
673 wl_signal_emit(&shsurf->resource.destroy_signal, &shsurf->resource);
674 destroy_shell_surface(shsurf);
676 uifw_trace("shell_handle_surface_destroy: Leave");
680 shell_surface_configure(struct weston_surface *, int32_t, int32_t);
682 /*--------------------------------------------------------------------------*/
684 * @brief get_shell_surface: get shell surface
686 * @param[in] surface weston surface
687 * @return shell surface address
689 /*--------------------------------------------------------------------------*/
690 static struct shell_surface *
691 get_shell_surface(struct weston_surface *surface)
693 if (surface->configure == shell_surface_configure)
694 return surface->private;
699 /*--------------------------------------------------------------------------*/
701 * @brief create_shell_surface: create shell surface
703 * @param[in] surface weston surface
704 * @param[in] client client
705 * @return created shell surface address
707 /*--------------------------------------------------------------------------*/
708 static struct shell_surface *
709 create_shell_surface(void *shell, struct weston_surface *surface,
710 const struct weston_shell_client *client)
712 struct shell_surface *shsurf;
714 if (surface->configure) {
715 uifw_warn("create_shell_surface: surface->configure already set");
719 shsurf = calloc(1, sizeof *shsurf);
721 uifw_error("create_shell_surface: no memory to allocate shell surface");
725 uifw_trace("create_shell_surface: (%08x) [%08x] client=%08x (visible=%d)",
726 (int)surface, (int)shsurf, (int)client,
727 ((struct ivi_shell *)shell)->win_visible_on_create);
729 surface->configure = shell_surface_configure;
730 surface->private = shsurf;
732 shsurf->shell = (struct ivi_shell *) shell;
733 shsurf->surface = surface;
734 shsurf->visible = shsurf->shell->win_visible_on_create;
736 /* set default color and shader */
737 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
739 wl_signal_init(&shsurf->resource.destroy_signal);
740 shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
741 wl_signal_add(&surface->surface.resource.destroy_signal,
742 &shsurf->surface_destroy_listener);
744 /* init link so its safe to always remove it in destroy_shell_surface */
745 wl_list_init(&shsurf->link);
747 /* empty when not in use */
748 wl_list_init(&shsurf->rotation.transform.link);
749 weston_matrix_init(&shsurf->rotation.rotation);
751 shsurf->type = SHELL_SURFACE_NONE;
752 shsurf->next_type = SHELL_SURFACE_NONE;
754 shsurf->client = client;
756 wl_list_init(&shsurf->ivi_layer);
761 /*--------------------------------------------------------------------------*/
763 * @brief shell_get_shell_surface: create shell surface(client interface)
765 * @param[in] client client
766 * @param[in] resource get shell surface request resource
767 * @param[in] id created shell surface object id in the client
768 * @param[in] surface_resource weston surface resource
771 /*--------------------------------------------------------------------------*/
773 shell_get_shell_surface(struct wl_client *client, struct wl_resource *resource,
774 uint32_t id, struct wl_resource *surface_resource)
776 struct weston_surface *surface = surface_resource->data;
777 struct ivi_shell *shell = resource->data;
778 struct shell_surface *shsurf;
780 if (get_shell_surface(surface)) {
781 wl_resource_post_error(surface_resource,
782 WL_DISPLAY_ERROR_INVALID_OBJECT,
783 "ivi_shell::get_shell_surface already requested");
787 uifw_trace("shell_get_shell_surface: Enter (%08x) client=%08x",
788 (int)surface, (int)client);
790 shsurf = create_shell_surface(shell, surface, &shell_client);
792 wl_resource_post_error(surface_resource,
793 WL_DISPLAY_ERROR_INVALID_OBJECT,
794 "surface->configure already set");
798 shsurf->wclient = client;
799 shsurf->resource.destroy = shell_destroy_shell_surface;
800 shsurf->resource.object.id = id;
801 shsurf->resource.object.interface = &wl_shell_surface_interface;
802 shsurf->resource.object.implementation =
803 (void (**)(void)) &shell_surface_implementation;
804 shsurf->resource.data = shsurf;
806 wl_client_add_resource(client, &shsurf->resource);
808 wl_list_init(&shsurf->ivi_layer);
809 uifw_trace("shell_get_shell_surface: Init shsurf(%08x) weston_surf=%08x",
810 (int)shsurf, (int)surface);
812 if (shell_hook_create) {
813 /* call surface create hook routine */
814 uifw_trace("shell_get_shell_surface: call ivi_shell_hook_create(%08x,,%08x,%08x)",
815 (int)client, (int)surface, (int)shsurf);
816 (void) (*shell_hook_create)(client, resource, surface, shsurf);
817 uifw_trace("shell_get_shell_surface: ret ivi_shell_hook_create");
819 uifw_trace("shell_get_shell_surface: Leave");
822 static const struct wl_shell_interface shell_implementation = {
823 shell_get_shell_surface
826 /*--------------------------------------------------------------------------*/
828 * @brief weston_surface_set_initial_position: set surface initial position
830 * @param[in] surface weston surface
831 * @param[in] shell ico_ivi_shell static table address
834 /*--------------------------------------------------------------------------*/
836 weston_surface_set_initial_position(struct weston_surface *surface, struct ivi_shell *shell)
838 struct weston_output *output, *target_output;
840 if (shell->win_visible_on_create) {
841 wl_list_for_each (output, &shell->compositor->output_list, link) {
842 target_output = output;
845 if (! target_output) {
846 weston_surface_set_position(surface, (float)(10 + random() % 400),
847 (float)(10 + random() % 400));
850 int range_x = target_output->width - surface->geometry.width;
851 int range_y = target_output->height - surface->geometry.height;
852 if (range_x < 0) range_x = 400;
853 if (range_y < 0) range_y = 400;
854 weston_surface_set_position(surface, (float)(random() % range_x),
855 (float)(random() % range_y));
859 weston_surface_set_position(surface, (float)0.0, (float)0.0);
863 /*--------------------------------------------------------------------------*/
865 * @brief map: surface initial mapping to screen
867 * @param[in] shell ico_ivi_shell static table address
868 * @param[in] surface weston surface
869 * @param[in] width surface width
870 * @param[in] height surface height
871 * @param[in] sx surface upper-left X position on screen
872 * @param[in] sy surface upper-left Y position on screen
875 /*--------------------------------------------------------------------------*/
877 map(struct ivi_shell *shell, struct weston_surface *surface,
878 int32_t width, int32_t height, int32_t sx, int32_t sy)
880 struct shell_surface *shsurf = get_shell_surface(surface);
881 enum shell_surface_type surface_type = shsurf->type;
882 struct weston_surface *parent;
884 uifw_trace("map: Enter(%08x) sx/sy=%d/%d, w/h=%d/%d",
885 (int)surface, ((int)sx)/256, ((int)sy)/256, width, height);
888 surface->geometry.width = width;
889 surface->geometry.height = height;
890 shsurf->geometry_x = sx;
891 shsurf->geometry_y = sy;
892 shsurf->geometry_width = width;
893 shsurf->geometry_height = height;
894 surface->geometry.dirty = 1;
896 /* initial positioning, see also configure() */
897 switch (surface_type) {
898 case SHELL_SURFACE_TOPLEVEL:
899 weston_surface_set_initial_position(surface, shell);
900 uifw_trace("map: TopLevel x/y=%d/%d w/h=%d/%d",
901 (int)surface->geometry.x, (int)surface->geometry.y,
902 (int)surface->geometry.width, (int)surface->geometry.height);
903 shsurf->geometry_x = surface->geometry.x;
904 shsurf->geometry_x = surface->geometry.y;
906 case SHELL_SURFACE_NONE:
907 weston_surface_set_position(surface, (float)(surface->geometry.x + sx),
908 (float)(surface->geometry.y + sy));
913 if ((ico_option_flag() & ICO_OPTION_FLAG_UNVISIBLE) && (shsurf->visible == FALSE)) {
914 surface->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1);
915 surface->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1);
916 surface->geometry.dirty = 1;
919 switch (surface_type) {
920 case SHELL_SURFACE_TRANSIENT:
921 parent = shsurf->parent;
922 wl_list_insert(parent->layer_link.prev, &surface->layer_link);
924 case SHELL_SURFACE_NONE:
927 if (! shsurf->layer_list) {
928 ivi_shell_set_layer(shsurf, ICO_IVI_DEFAULT_LAYER);
933 if (surface_type != SHELL_SURFACE_NONE) {
934 weston_surface_update_transform(surface);
935 ivi_shell_restack_ivi_layer(shell, shsurf);
938 if (shell_hook_map) {
939 /* Surface map hook routine */
940 uifw_trace("map: call ivi_shell_hook_map(%08x, x/y=%d/%d, w/h=%d/%d)",
941 (int)surface, sx, sy, width, height);
942 (void) (*shell_hook_map) (surface, &width, &height, &sx, &sy);
943 uifw_trace("map: ret ivi_shell_hook_map(%08x, x/y=%d/%d, w/h=%d/%d)",
944 (int)surface, sx, sy, width, height);
947 if (shell_hook_change) {
948 /* Surface change hook routine */
949 uifw_trace("map: call ivi_shell_hook_change(%08x)", (int)surface);
950 (void) (*shell_hook_change)(surface, -1, 1); /* Send to Manager */
951 uifw_trace("map: ret ivi_shell_hook_change")
953 uifw_trace("map: Leave");
956 /*--------------------------------------------------------------------------*/
958 * @brief configure: surface change
960 * @param[in] shell ico_ivi_shell static table address
961 * @param[in] surface weston surface
962 * @param[in] x surface upper-left X position on screen
963 * @param[in] y surface upper-left Y position on screen
964 * @param[in] width surface width
965 * @param[in] height surface height
968 /*--------------------------------------------------------------------------*/
970 configure(struct ivi_shell *shell, struct weston_surface *surface,
971 GLfloat x, GLfloat y, int32_t width, int32_t height)
973 enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
974 struct shell_surface *shsurf;
976 shsurf = get_shell_surface(surface);
978 uifw_trace("configure: Enter(%08x) [%08x] x/y=%d/%d, w/h=%d/%d",
979 (int)surface, (int)shsurf, (int)x, (int)y, width, height);
982 surface_type = shsurf->type;
983 shsurf->geometry_x = (int)x;
984 shsurf->geometry_y = (int)y;
985 shsurf->geometry_width = width;
986 shsurf->geometry_height = height;
987 ivi_shell_surface_configure(shsurf, x, y, width, height);
990 weston_surface_configure(surface, x, y, width, height);
993 if (surface->output) {
994 weston_surface_update_transform(surface);
997 uifw_trace("configure: Leave");
1000 /*--------------------------------------------------------------------------*/
1002 * @brief shell_surface_configure: shell surface change
1004 * @param[in] es weston surface
1005 * @param[in] sx surface upper-left X position on screen
1006 * @param[in] sy surface upper-left Y position on screen
1009 /*--------------------------------------------------------------------------*/
1011 shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
1013 struct shell_surface *shsurf = get_shell_surface(es);
1014 struct ivi_shell *shell = shsurf->shell;
1015 int type_changed = 0;
1019 uifw_trace("shell_surface_configure: Enter(surf=%08x out=%08x buf=%08x)",
1020 (int)es, (int)es->output, (int)es->buffer);
1023 uifw_trace("shell_surface_configure: Leave(no buffer)");
1026 if (shsurf->restrain) {
1027 uifw_trace("shell_surface_configure: Leave(restrain)");
1031 if (shsurf->next_type != SHELL_SURFACE_NONE &&
1032 shsurf->type != shsurf->next_type) {
1033 set_surface_type(shsurf);
1037 if (! weston_surface_is_mapped(es)) {
1038 if ((es->geometry.width > 0) && (es->geometry.height >0)) {
1039 uifw_trace("shell_surface_configure: map Surface size(sx/sy=%d/%d w/h=%d/%d)",
1040 sx, sy, es->buffer->width, es->buffer->height);
1041 map(shell, es, es->geometry.width, es->geometry.height, sx, sy);
1044 uifw_trace("shell_surface_configure: map Buffer size(sx/sy=%d/%d w/h=%d/%d)",
1045 sx, sy, es->buffer->width, es->buffer->height);
1046 map(shell, es, es->buffer->width, es->buffer->height, sx, sy);
1050 if (shsurf->mapped == 0) {
1051 if ((es->geometry.width > 0) && (es->geometry.height >0)) {
1052 uifw_trace("shell_surface_configure: map Surface size(sx/sy=%d/%d w/h=%d/%d)",
1053 sx, sy, es->buffer->width, es->buffer->height);
1054 map(shell, es, es->geometry.width, es->geometry.height, sx, sy);
1057 uifw_trace("shell_surface_configure: map Buffer size(sx/sy=%d/%d w/h=%d/%d)",
1058 sx, sy, es->buffer->width, es->buffer->height);
1059 map(shell, es, es->buffer->width, es->buffer->height, sx, sy);
1063 GLfloat from_x, from_y;
1066 weston_surface_to_global_float(es, 0, 0, &from_x, &from_y);
1067 weston_surface_to_global_float(es, sx, sy, &to_x, &to_y);
1069 if ((es->geometry.width <= 0) || (es->geometry.height <= 0)) {
1073 /* Surface change request from App */
1074 uifw_trace("shell_surface_configure: App request change(sx/sy=%d/%d w/h=%d/%d)",
1075 sx, sy, es->buffer->width, es->buffer->height);
1076 dx = shsurf->geometry_x;
1077 dy = shsurf->geometry_y;
1078 dw = shsurf->geometry_width;
1079 dh = shsurf->geometry_height;
1080 if (dw > es->buffer->width) {
1081 dw = es->buffer->width;
1082 dx = shsurf->geometry_x + (shsurf->geometry_width - dw)/2;
1084 if (dh > es->buffer->height) {
1085 dh = es->buffer->height;
1086 dy = shsurf->geometry_y + (shsurf->geometry_height - dh)/2;
1088 weston_surface_configure(es, dx, dy, dw, dh);
1089 ivi_shell_surface_configure(shsurf, es->geometry.x, es->geometry.y,
1090 es->geometry.width, es->geometry.height);
1091 uifw_trace("shell_surface_configure: w/h=%d/%d->%d/%d x/y=%d/%d->%d/%d",
1092 shsurf->geometry_width, shsurf->geometry_height,
1093 es->geometry.width, es->geometry.height,
1094 shsurf->geometry_x, shsurf->geometry_y,
1095 (int)es->geometry.x, (int)es->geometry.y);
1096 num_mgr = ico_ivi_send_surface_change(es,
1097 shsurf->geometry_x + to_x -from_x,
1098 shsurf->geometry_y + to_y - from_y,
1099 es->buffer->width, es->buffer->height);
1100 uifw_trace("shell_surface_configure: ret ivi_shell_hook_change(%d)", num_mgr)
1103 /* manager not exist, change surface */
1104 uifw_trace("shell_surface_configure: configure to Buffer size(no Manager) "
1105 "x=%d+%d-%d y=%d+%d-%d",
1106 (int)es->geometry.x, (int)to_x, (int)from_x,
1107 (int)es->geometry.y, (int)to_y, (int)from_y);
1108 if ((es->geometry.x > ICO_IVI_MAX_COORDINATE) &&
1109 (es->geometry.y > ICO_IVI_MAX_COORDINATE) &&
1110 (shsurf->visible)) {
1113 es->geometry.dirty = 1;
1115 configure(shell, es,
1116 es->geometry.x + to_x - from_x,
1117 es->geometry.y + to_y - from_y,
1118 es->buffer->width, es->buffer->height);
1121 uifw_trace("shell_surface_configure: Leave(surf=%08x out=%08x buf=%08x)",
1122 (int)es, (int)es->output, (int)es->buffer);
1125 /*--------------------------------------------------------------------------*/
1127 * @brief bind_shell: client bind shell
1129 * @param[in] client client(ex.HomeScreen)
1130 * @param[in] data user data(ico_ivi_shell static table address)
1131 * @param[in] version interface version number(unused)
1132 * @param[in] id client object id
1135 /*--------------------------------------------------------------------------*/
1137 bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
1139 struct ivi_shell *shell = data;
1140 struct wl_resource *resource;
1142 uifw_trace("bind_shell: client=%08x id=%d", (int)client, (int)id);
1144 resource = wl_client_add_object(client, &wl_shell_interface,
1145 &shell_implementation, id, shell);
1147 resource->destroy = unbind_shell;
1149 if (shell_hook_bind) {
1150 (*shell_hook_bind)(client);
1154 /*--------------------------------------------------------------------------*/
1156 * @brief unbind_shell: client unbind shell
1158 * @param[in] resource unbind request resource
1161 /*--------------------------------------------------------------------------*/
1163 unbind_shell(struct wl_resource *resource)
1165 uifw_trace("unbind_shell");
1167 if (shell_hook_unbind) {
1168 (*shell_hook_unbind)(resource->client);
1173 /*--------------------------------------------------------------------------*/
1175 * @brief unbind_ivi_shell: client unbind ico_ivi_shell
1177 * @param[in] resource unbind request resource
1180 /*--------------------------------------------------------------------------*/
1182 unbind_ivi_shell(struct wl_resource *resource)
1184 uifw_trace("unbind_ivi_shell");
1188 /*--------------------------------------------------------------------------*/
1190 * @brief bind_ivi_shell: client bind ico_ivi_shell
1192 * @param[in] client client(ex.HomeScreen)
1193 * @param[in] data user data(ico_ivi_shell static table address)
1194 * @param[in] version interface version number(unused)
1195 * @param[in] id client object id
1198 /*--------------------------------------------------------------------------*/
1200 bind_ivi_shell(struct wl_client *client,
1201 void *data, uint32_t version, uint32_t id)
1203 struct ivi_shell *shell = data;
1204 struct wl_resource *resource;
1206 resource = wl_client_add_object(client, &ico_ivi_shell_interface,
1209 uifw_trace("bind_ivi_shell: client=%08x id=%d", (int)client, (int)id);
1211 resource->destroy = unbind_ivi_shell;
1214 /*--------------------------------------------------------------------------*/
1216 * @brief shell_destroy: destroy ico_ivi_shell
1218 * @param[in] listener shell destroy listener
1219 * @param[in] data user data(unused)
1222 /*--------------------------------------------------------------------------*/
1224 shell_destroy(struct wl_listener *listener, void *data)
1226 struct ivi_shell *shell =
1227 container_of(listener, struct ivi_shell, destroy_listener);
1229 uifw_trace("shell_destroy");
1234 /*--------------------------------------------------------------------------*/
1236 * @brief ivi_shell_restack_ivi_layer: rebuild compositor surface list
1238 * @param[in] shell ico_ivi_shell static table address
1239 * @param[in] shsurf target shell surface(if NULL, no need change surface)
1242 /*--------------------------------------------------------------------------*/
1244 ivi_shell_restack_ivi_layer(struct ivi_shell *shell, struct shell_surface *shsurf)
1246 struct shell_surface *es;
1247 struct ivi_layer_list *el;
1250 uifw_trace("ivi_shell_restack_ivi_layer: Enter[%08x]", (int)shsurf);
1252 /* make compositor surface list */
1253 wl_list_init(&shell->surface.surface_list);
1254 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1255 if (ico_option_flag() & ICO_OPTION_FLAG_UNVISIBLE) {
1256 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1257 if (es->surface != NULL) {
1258 if ((el->visible == FALSE) || (es->visible == FALSE)) {
1259 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1260 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1262 else if (es->surface->buffer) {
1263 if (es->geometry_width > es->surface->buffer->width) {
1264 new_x = (float)(es->geometry_x +
1265 (es->geometry_width - es->surface->geometry.width)/2);
1268 new_x = (float)es->geometry_x;
1270 if (es->geometry_height > es->surface->buffer->height) {
1271 new_y = (float) (es->geometry_y +
1272 (es->geometry_height - es->surface->geometry.height)/2);
1275 new_y = (float)es->geometry_y;
1279 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1280 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1282 wl_list_insert(shell->surface.surface_list.prev,
1283 &es->surface->layer_link);
1284 if ((new_x != es->surface->geometry.x) ||
1285 (new_y != es->surface->geometry.y)) {
1286 weston_surface_damage_below(es->surface);
1287 es->surface->geometry.x = new_x;
1288 es->surface->geometry.y = new_y;
1289 es->surface->geometry.dirty = 1;
1290 weston_surface_damage_below(es->surface);
1296 if (el->visible != FALSE) {
1297 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1298 if ((es->visible != FALSE) && (es->surface) &&
1299 (es->surface->output != NULL) &&
1300 (es->surface->shader != NULL)) {
1301 wl_list_insert(shell->surface.surface_list.prev,
1302 &es->surface->layer_link);
1309 /* damage(redraw) target surfacem if target exist */
1311 weston_surface_damage_below(shsurf->surface);
1314 /* composit and draw screen(plane) */
1315 weston_compositor_schedule_repaint(shell->compositor);
1317 uifw_trace("ivi_shell_restack_ivi_layer: Leave");
1320 /*--------------------------------------------------------------------------*/
1322 * @brief ivi_shell_set_active: surface active control
1324 * @param[in] shsurf shell surface(if NULL, no active surface)
1325 * @param[in] target target device
1328 /*--------------------------------------------------------------------------*/
1330 ivi_shell_set_active(struct shell_surface *shsurf, const int target)
1332 struct ivi_shell *shell;
1333 struct weston_seat *seat;
1334 struct weston_surface *surface;
1335 int object = target;
1338 uifw_trace("ivi_shell_set_active: Enter(%08x,%x)", (int)shsurf, target);
1341 shell = shell_surface_get_shell(shsurf);
1342 surface = shsurf->surface;
1345 if (shell->active_pointer_shsurf == shsurf) {
1346 object |= ICO_IVI_SHELL_ACTIVE_POINTER;
1348 if (shell->active_keyboard_shsurf == shsurf) {
1349 object |= ICO_IVI_SHELL_ACTIVE_KEYBOARD;
1353 if (object & ICO_IVI_SHELL_ACTIVE_POINTER) {
1354 shell->active_pointer_shsurf = shsurf;
1356 if (object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) {
1357 shell->active_keyboard_shsurf = shsurf;
1362 shell = default_shell;
1365 object = ICO_IVI_SHELL_ACTIVE_POINTER|ICO_IVI_SHELL_ACTIVE_KEYBOARD;
1367 if (object & ICO_IVI_SHELL_ACTIVE_POINTER) {
1368 shell->active_pointer_shsurf = NULL;
1370 if (object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) {
1371 shell->active_keyboard_shsurf = NULL;
1375 wl_list_for_each(seat, &shell->compositor->seat_list, link) {
1376 if ((object & ICO_IVI_SHELL_ACTIVE_POINTER) && (seat->seat.pointer)) {
1378 uifw_trace("ivi_shell_set_active: pointer set surface(%08x=>%08x)",
1379 (int)seat->seat.pointer->focus, (int)&surface->surface);
1380 if (seat->seat.pointer->focus != &surface->surface) {
1381 weston_surface_from_global_fixed(surface,
1382 seat->seat.pointer->x,
1383 seat->seat.pointer->y,
1385 wl_pointer_set_focus(seat->seat.pointer, &surface->surface, sx, sy);
1389 uifw_trace("ivi_shell_set_active: pointer reset surface(%08x)",
1390 (int)seat->seat.pointer->focus);
1391 wl_pointer_set_focus(seat->seat.pointer, NULL,
1392 wl_fixed_from_int(0), wl_fixed_from_int(0));
1395 if ((object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) && (seat->has_keyboard)) {
1397 uifw_trace("ivi_shell_set_active: keyboard set surface(%08x=>%08x)",
1398 (int)seat->seat.keyboard->focus, (int)&surface->surface);
1399 if (seat->seat.keyboard->focus != &surface->surface) {
1400 wl_keyboard_set_focus(seat->seat.keyboard, &surface->surface);
1404 uifw_trace("ivi_shell_set_active: keyboard reset surface(%08x)",
1405 (int)seat->seat.keyboard);
1406 wl_keyboard_set_focus(seat->seat.keyboard, NULL);
1410 uifw_trace("ivi_shell_set_active: seat[%08x] has no keyboard", (int)seat);
1413 uifw_trace("ivi_shell_set_active: Leave(%08x)", (int)shsurf);
1416 /*--------------------------------------------------------------------------*/
1418 * @brief ivi_shell_set_client_attr : set client ttribute
1420 * @param[in] client target client
1421 * @param[in] attr attribute
1422 * @param[in] value attribute value
1425 /*--------------------------------------------------------------------------*/
1427 ivi_shell_set_client_attr(struct wl_client *client, const int attr, const int value)
1429 struct shell_surface *es;
1430 struct ivi_layer_list *el;
1432 uifw_trace("ivi_shell_set_client_attr: Enter(%08x,%d,%d)", (int)client, attr, value);
1434 wl_list_for_each (el, &default_shell->ivi_layer.link, link) {
1435 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1436 if (es->wclient == client) {
1438 case ICO_CLEINT_ATTR_NOCONFIGURE:
1439 es->noconfigure = value;
1440 uifw_trace("ivi_shell_set_client_attr: set surface %08x", (int)es);
1448 uifw_trace("ivi_shell_set_client_attr: Leave");
1451 /*--------------------------------------------------------------------------*/
1453 * @brief ivi_shell_set_active: surface active control
1455 * @param[in] shsurf shell surface(if NULL, no active surface)
1456 * @param[in] restrain restrain(1)/not restrain(0)
1459 /*--------------------------------------------------------------------------*/
1461 ivi_shell_restrain_configure(struct shell_surface *shsurf, const int restrain)
1463 uifw_trace("ivi_shell_restrain_configure: set %08x to %d",
1464 (int)shsurf, restrain);
1465 shsurf->restrain = restrain;
1467 if (restrain == 0) {
1468 shell_surface_configure(shsurf->surface, shsurf->geometry_x, shsurf->geometry_y);
1469 ivi_shell_restack_ivi_layer(shell_surface_get_shell(shsurf), shsurf);
1473 /*--------------------------------------------------------------------------*/
1475 * @brief ivi_shell_is_restrain: check surface restrain
1477 * @param[in] shsurf shell surface(if NULL, no active surface)
1479 * @retval =1 surface currently restrain
1480 * @retval =0 not restrain
1482 /*--------------------------------------------------------------------------*/
1484 ivi_shell_is_restrain(struct shell_surface *shsurf)
1486 return shsurf->restrain;
1489 /*--------------------------------------------------------------------------*/
1491 * @brief ivi_shell_default_animation: window default animation
1493 * @param[out] msec animation time(ms)
1494 * @param[out] fps animation frame rate(fps)
1495 * @return default animation name
1497 /*--------------------------------------------------------------------------*/
1498 WL_EXPORT const char *
1499 ivi_shell_default_animation(int *msec, int *fps)
1502 *msec = default_shell->win_animation_time;
1505 *fps = default_shell->win_animation_fps;
1507 return default_shell->win_animation;
1510 /*--------------------------------------------------------------------------*/
1512 * @brief click_to_activate_binding: clieck and select surface
1514 * @param[in] seat clicked target seat
1515 * @param[in] button click button(unused)
1516 * @param[in] data user data(ico_ivi_shell static table address)
1519 /*--------------------------------------------------------------------------*/
1521 click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
1523 struct ivi_shell *shell = data;
1524 struct shell_surface *shsurf;
1525 struct weston_surface *surface;
1527 if ((! seat) || (! seat->pointer) || (! seat->pointer->focus)) {
1528 uifw_trace("click_to_activate_binding: Surface dose not exist");
1531 surface = (struct weston_surface *) seat->pointer->focus;
1532 shsurf = get_shell_surface(surface);
1534 uifw_trace("click_to_activate_binding: Shell surface dose not exist");
1536 else if ((shsurf->type == SHELL_SURFACE_NONE) ||
1537 (shsurf->visible == 0)) {
1538 uifw_trace("click_to_activate_binding: Surface[%08x] is not visible",
1541 else if (shell->active_pointer_shsurf != shsurf) {
1542 if (shell_hook_select) {
1543 /* surface select hook routine */
1544 uifw_trace("click_to_activate_binding: call ivi_shell_hook_select[%08x]",
1546 (void) (*shell_hook_select)(surface);
1547 uifw_trace("click_to_activate_binding: ret ivi_shell_hook_select")
1550 ivi_shell_set_active(shsurf,
1551 ICO_IVI_SHELL_ACTIVE_POINTER |
1552 ICO_IVI_SHELL_ACTIVE_KEYBOARD);
1553 uifw_trace("click_to_activate_binding: no hook[%08x]", (int)shsurf);
1557 uifw_trace("click_to_activate_binding: ShellSurface[%08x] already active",
1563 /*--------------------------------------------------------------------------*/
1565 * @brief ivi_shell_set_visible: surface visible control
1567 * @param[in] shsurf shell surface
1568 * @param[in] visible visibility(1=visible/0=unvisible/-1=system default)
1571 /*--------------------------------------------------------------------------*/
1573 ivi_shell_set_visible(struct shell_surface *shsurf, const int visible)
1575 struct ivi_shell *shell = shell_surface_get_shell(shsurf);
1578 uifw_trace("ivi_shell_set_visible: [%08x] (%08x) visible=%d",
1579 (int)shsurf, (int)shsurf->surface, (int)visible);
1582 next = shell->win_visible_on_create;
1588 if ((shsurf->visible != FALSE) && (next == 0)) {
1589 /* change show ==> hide */
1590 shsurf->visible = FALSE;
1591 ivi_shell_restack_ivi_layer(shell, shsurf);
1593 else if ((shsurf->visible == FALSE) && (next != 0)) {
1594 /* change hide ==> show */
1595 shsurf->visible = TRUE;
1596 ivi_shell_restack_ivi_layer(shell, shsurf);
1599 /* other case, no change */
1600 uifw_trace("ivi_shell_set_visible: No change");
1604 /*--------------------------------------------------------------------------*/
1606 * @brief ivi_shell_is_visible: get surface visibility
1608 * @param[in] shsurf shell surface
1609 * @return visibility
1610 * @retval true visible
1611 * @retval false unvisible
1613 /*--------------------------------------------------------------------------*/
1615 ivi_shell_is_visible(struct shell_surface *shsurf)
1617 return(shsurf->visible);
1620 /*--------------------------------------------------------------------------*/
1622 * @brief ivi_shell_set_layer: set(or change) surface layer
1624 * @param[in] shsurf shell surface
1625 * @param[in] layer layer id
1628 /*--------------------------------------------------------------------------*/
1630 ivi_shell_set_layer(struct shell_surface *shsurf, const int layer)
1632 struct ivi_shell *shell;
1633 struct ivi_layer_list *el;
1634 struct ivi_layer_list *new_el;
1636 uifw_trace("ivi_shell_set_layer: Enter([%08x],%08x,%d)",
1637 (int)shsurf, (int)shsurf->surface, layer);
1639 shell = shell_surface_get_shell(shsurf);
1641 /* check if same layer */
1642 if ((shsurf->layer_list != NULL) && (shsurf->layer_list->layer == layer)) {
1643 uifw_trace("ivi_shell_set_layer: Leave(Same Layer)");
1647 /* search existing layer */
1648 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1649 if (el->layer == layer) break;
1652 if (&el->link == &shell->ivi_layer.link) {
1653 /* layer not exist, create new layer */
1654 uifw_trace("ivi_shell_set_layer: New Layer %d", layer);
1655 new_el = malloc(sizeof(struct ivi_layer_list));
1657 uifw_trace("ivi_shell_set_layer: Leave(No Memory)");
1661 memset(new_el, 0, sizeof(struct ivi_layer_list));
1662 new_el->layer = layer;
1663 new_el->visible = TRUE;
1664 wl_list_init(&new_el->surface_list);
1665 wl_list_init(&new_el->link);
1667 wl_list_remove(&shsurf->ivi_layer);
1668 wl_list_insert(&new_el->surface_list, &shsurf->ivi_layer);
1669 shsurf->layer_list = new_el;
1671 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1672 if (layer >= el->layer) break;
1674 if (&el->link == &shell->ivi_layer.link) {
1675 wl_list_insert(shell->ivi_layer.link.prev, &new_el->link);
1678 wl_list_insert(el->link.prev, &new_el->link);
1682 uifw_trace("ivi_shell_set_layer: Add surface to Layer %d", layer);
1683 wl_list_remove(&shsurf->ivi_layer);
1684 wl_list_insert(&el->surface_list, &shsurf->ivi_layer);
1685 shsurf->layer_list = el;
1688 /* rebild compositor surface list */
1689 ivi_shell_restack_ivi_layer(shell, shsurf);
1691 uifw_trace("ivi_shell_set_layer: Leave");
1694 /*--------------------------------------------------------------------------*/
1696 * @brief ivi_shell_set_raise: surface stack control
1698 * @param[in] shsurf shell surface
1699 * @param[in] raise raise/lower(1=raise/0=lower)
1702 /*--------------------------------------------------------------------------*/
1704 ivi_shell_set_raise(struct shell_surface *shsurf, const int raise)
1706 uifw_trace("ivi_shell_set_raise: Enter(%08x,%d) layer_list=%08x",
1707 (int)shsurf->surface, raise, (int)shsurf->layer_list);
1709 wl_list_remove(&shsurf->ivi_layer);
1711 /* raise ... surface stack to top of layer */
1712 wl_list_insert(&shsurf->layer_list->surface_list, &shsurf->ivi_layer);
1713 uifw_trace("ivi_shell_set_raise: Raise Link to Top");
1716 /* Lower ... surface stack to bottom of layer */
1717 wl_list_insert(shsurf->layer_list->surface_list.prev, &shsurf->ivi_layer);
1718 uifw_trace("ivi_shell_set_raise: Lower Link to Bottom");
1721 /* rebild compositor surface list */
1722 ivi_shell_restack_ivi_layer(shell_surface_get_shell(shsurf), shsurf);
1724 uifw_trace("ivi_shell_set_raise: Leave");
1727 /*--------------------------------------------------------------------------*/
1729 * @brief ivi_shell_set_toplevel: set surface type toplevel
1731 * @param[in] shsurf shell surface
1734 /*--------------------------------------------------------------------------*/
1736 ivi_shell_set_toplevel(struct shell_surface *shsurf)
1738 uifw_trace("ivi_shell_set_toplevel: (%08x)", (int)shsurf->surface);
1739 set_toplevel(shsurf);
1742 /*--------------------------------------------------------------------------*/
1744 * @brief ivi_shell_set_surface_type: set surface type
1746 * @param[in] shsurf shell surface
1749 /*--------------------------------------------------------------------------*/
1751 ivi_shell_set_surface_type(struct shell_surface *shsurf)
1753 uifw_trace("ivi_shell_set_surfacetype: (%08x)", (int)shsurf->surface);
1754 set_surface_type(shsurf);
1757 /*--------------------------------------------------------------------------*/
1759 * @brief ivi_shell_send_configure: send surface resize event
1761 * @param[in] shsurf shell surface
1762 * @param[in] id client object id(unused)
1763 * @param[in] edges surface resize position
1764 * @param[in] width surface width
1765 * @param[in] height surface height
1768 /*--------------------------------------------------------------------------*/
1770 ivi_shell_send_configure(struct shell_surface *shsurf, const int id,
1771 const int edges, const int width, const int height)
1773 /* send cgange event to manager */
1774 uifw_trace("ivi_shell_send_configure: (%08x) edges=%x w/h=%d/%d map=%d",
1775 (int)shsurf->surface, edges, width, height, shsurf->mapped);
1777 shsurf->geometry_width = width;
1778 shsurf->geometry_height = height;
1780 if ((shsurf->mapped == 0) || (shsurf->noconfigure != 0) ||
1781 (width == 0) || (height == 0)) {
1785 /* send cgange event to application */
1786 uifw_trace("ivi_shell_send_configure: Send (%08x) w/h=%d/%d(old=%d/%d)",
1787 (int)shsurf->surface, width, height,
1788 shsurf->configure_app.width, shsurf->configure_app.height);
1789 shsurf->configure_app.width = width;
1790 shsurf->configure_app.height = height;
1792 wl_shell_surface_send_configure(&shsurf->resource,
1793 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
1797 /*--------------------------------------------------------------------------*/
1799 * @brief ivi_shell_get_positionsize: get surface position and size
1801 * @param[in] shsurf shell surface
1802 * @param[out] x surface upper-left X position on screen
1803 * @param[out] y surface upper-left Y position on screen
1804 * @param[out] width surface width
1805 * @param[out] height surface height
1808 /*--------------------------------------------------------------------------*/
1810 ivi_shell_get_positionsize(struct shell_surface *shsurf,
1811 int *x, int *y, int *width, int *height)
1813 *x = shsurf->geometry_x;
1814 *y = shsurf->geometry_y;
1815 *width = shsurf->geometry_width;
1816 *height = shsurf->geometry_height;
1819 /*--------------------------------------------------------------------------*/
1821 * @brief ivi_shell_set_positionsize: set surface position and size
1823 * @param[in] shsurf shell surface
1824 * @param[in] x surface upper-left X position on screen
1825 * @param[in] y surface upper-left Y position on screen
1826 * @param[in] width surface width
1827 * @param[in] height surface height
1830 /*--------------------------------------------------------------------------*/
1832 ivi_shell_set_positionsize(struct shell_surface *shsurf,
1833 const int x, const int y, const int width, const int height)
1835 shsurf->geometry_x = x;
1836 shsurf->geometry_y = y;
1837 shsurf->geometry_width = width;
1838 shsurf->geometry_height = height;
1840 weston_compositor_schedule_repaint(shell_surface_get_shell(shsurf)->compositor);
1843 /*--------------------------------------------------------------------------*/
1845 * @brief ivi_shell_set_layer_visible: layer visible control
1847 * @param[in] layer layer id
1848 * @param[in] visible visibility(1=visible/0=unvisible)
1851 /*--------------------------------------------------------------------------*/
1853 ivi_shell_set_layer_visible(const int layer, const int visible)
1855 struct ivi_shell *shell;
1856 struct ivi_layer_list *el;
1857 struct ivi_layer_list *new_el;
1858 struct shell_surface *es;
1860 uifw_trace("ivi_shell_set_layer_visible: Enter(layer=%d, visible=%d)", layer, visible);
1862 shell = shell_surface_get_shell(NULL);
1865 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1866 if (el->layer == layer) break;
1869 if (&el->link == &shell->ivi_layer.link) {
1870 /* layer not exist, create new layer */
1871 uifw_trace("ivi_shell_set_layer_visible: New Layer %d", layer);
1872 new_el = malloc(sizeof(struct ivi_layer_list));
1874 uifw_trace("ivi_shell_set_layer_visible: Leave(No Memory)");
1878 memset(new_el, 0, sizeof(struct ivi_layer_list));
1879 new_el->layer = layer;
1880 new_el->visible = TRUE;
1881 wl_list_init(&new_el->surface_list);
1882 wl_list_init(&new_el->link);
1884 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1885 if (layer >= el->layer) break;
1887 if (&el->link == &shell->ivi_layer.link) {
1888 wl_list_insert(shell->ivi_layer.link.prev, &new_el->link);
1891 wl_list_insert(el->link.prev, &new_el->link);
1893 uifw_trace("ivi_shell_set_layer_visible: Leave(new layer)");
1897 /* control all surface in layer */
1898 if ((el->visible != FALSE) && (visible == 0)) {
1899 /* layer change to NOT visible */
1900 uifw_trace("ivi_shell_set_layer_visible: change to not visible");
1901 el->visible = FALSE;
1903 else if ((el->visible == FALSE) && (visible != 0)) {
1904 /* layer change to visible */
1905 uifw_trace("ivi_shell_set_layer_visible: change to visible");
1910 uifw_trace("ivi_shell_set_layer_visible: Leave(no Change %d=>%d)",
1911 el->visible, visible);
1915 /* set damege area */
1916 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1917 if ((es->visible != FALSE) &&
1918 (es->surface->output != NULL) &&
1919 (es->surface->shader != NULL)) {
1920 /* Damage(redraw) target surface */
1921 weston_surface_damage_below(es->surface);
1925 /* rebild compositor surface list */
1926 ivi_shell_restack_ivi_layer(shell, NULL);
1928 uifw_trace("ivi_shell_set_layer_visible: Leave");
1931 /*--------------------------------------------------------------------------*/
1933 * @brief ivi_shell_surface_configure: surface change
1935 * @param[in] shsurf shell surface
1936 * @param[in] x surface upper-left X position on screen
1937 * @param[in] y surface upper-left Y position on screen
1938 * @param[in] width surface width
1939 * @param[in] height surface height
1942 /*--------------------------------------------------------------------------*/
1944 ivi_shell_surface_configure(struct shell_surface *shsurf, const int x,
1945 const int y, const int width, const int height)
1947 int set_unvisible = 0;
1949 if (ico_option_flag() & ICO_OPTION_FLAG_UNVISIBLE) {
1950 if ((shsurf->surface != NULL) && (shsurf->surface->buffer != NULL) &&
1951 (shsurf->surface->output != NULL) && (shsurf->surface->shader != NULL)) {
1952 if ((shsurf->visible == FALSE) ||
1953 ((shsurf->layer_list != NULL) &&
1954 (shsurf->layer_list->visible == FALSE))) {
1959 if (set_unvisible) {
1960 uifw_trace("ivi_shell_surface_configure: %08x %d,%d(%d/%d) unvisible",
1961 (int)shsurf, x, y, width, height);
1962 weston_surface_configure(shsurf->surface,
1963 ICO_IVI_MAX_COORDINATE+1, ICO_IVI_MAX_COORDINATE+1,
1967 uifw_trace("ivi_shell_surface_configure: %08x %d,%d(%d/%d) visible",
1968 (int)shsurf, x, y, width, height);
1969 weston_surface_configure(shsurf->surface, x, y, width, height);
1973 /*--------------------------------------------------------------------------*/
1975 * @brief ivi_shell_hook_bind: regist hook function for shell bind
1977 * @param[in] hook_bind hook function(if NULL, reset hook function)
1980 /*--------------------------------------------------------------------------*/
1982 ivi_shell_hook_bind(void (*hook_bind)(struct wl_client *client))
1984 uifw_trace("ivi_shell_hook_bind: Hook %08x", (int)hook_bind);
1985 shell_hook_bind = hook_bind;
1988 /*--------------------------------------------------------------------------*/
1990 * @brief ivi_shell_hook_unbind: regist hook function for shell unbind
1992 * @param[in] hook_unbind hook function(if NULL, reset hook function)
1995 /*--------------------------------------------------------------------------*/
1997 ivi_shell_hook_unbind(void (*hook_unbind)(struct wl_client *client))
1999 uifw_trace("ivi_shell_hook_unbind: Hook %08x", (int)hook_unbind);
2000 shell_hook_unbind = hook_unbind;
2003 /*--------------------------------------------------------------------------*/
2005 * @brief ivi_shell_hook_create: regist hook function for create shell surface
2007 * @param[in] hook_create hook function(if NULL, reset hook function)
2010 /*--------------------------------------------------------------------------*/
2012 ivi_shell_hook_create(void (*hook_create)(struct wl_client *client,
2013 struct wl_resource *resource, struct weston_surface *surface,
2014 struct shell_surface *shsurf))
2016 uifw_trace("ivi_shell_hook_create: Hook %08x", (int)hook_create);
2017 shell_hook_create = hook_create;
2020 /*--------------------------------------------------------------------------*/
2022 * @brief ivi_shell_hook_destroy: regist hook function for destroy shell surface
2024 * @param[in] hook_destroy hook function(if NULL, reset hook function)
2027 /*--------------------------------------------------------------------------*/
2029 ivi_shell_hook_destroy(void (*hook_destroy)(struct weston_surface *surface))
2031 uifw_trace("ivi_shell_hook_destroy: Hook %08x", (int)hook_destroy);
2032 shell_hook_destroy = hook_destroy;
2035 /*--------------------------------------------------------------------------*/
2037 * @brief ivi_shell_hook_map: regist hook function for map shell surface
2039 * @param[in] hook_map hook function(if NULL, reset hook function)
2042 /*--------------------------------------------------------------------------*/
2044 ivi_shell_hook_map(void (*hook_map)(struct weston_surface *surface,
2045 int32_t *width, int32_t *height, int32_t *sx, int32_t *sy))
2047 uifw_trace("ivi_shell_hook_map: Hook %08x", (int)hook_map);
2048 shell_hook_map = hook_map;
2051 /*--------------------------------------------------------------------------*/
2053 * @brief ivi_shell_hook_change: regist hook function for change shell surface
2055 * @param[in] hook_change hook function(if NULL, reset hook function)
2058 /*--------------------------------------------------------------------------*/
2060 ivi_shell_hook_change(void (*hook_change)(struct weston_surface *surface,
2061 const int to, const int manager))
2063 uifw_trace("ivi_shell_hook_change: Hook %08x", (int)hook_change);
2064 shell_hook_change = hook_change;
2067 /*--------------------------------------------------------------------------*/
2069 * @brief ivi_shell_hook_select: regist hook function for select(active) shell surface
2071 * @param[in] hook_select hook function(if NULL, reset hook function)
2074 /*--------------------------------------------------------------------------*/
2076 ivi_shell_hook_select(void (*hook_select)(struct weston_surface *surface))
2078 uifw_trace("ivi_shell_hook_select: Hook %08x", (int)hook_select);
2079 shell_hook_select = hook_select;
2082 /*--------------------------------------------------------------------------*/
2084 * @brief module_init: initialize ico_ivi_shell
2085 * this function called from ico_pluign_loader
2087 * @param[in] es weston compositor
2092 /*--------------------------------------------------------------------------*/
2094 module_init(struct weston_compositor *ec)
2096 struct ivi_shell *shell;
2098 uifw_info("ico_ivi_shell: Enter(module_init)");
2100 shell = malloc(sizeof *shell);
2101 if (shell == NULL) return -1;
2102 default_shell = shell;
2104 memset(shell, 0, sizeof *shell);
2105 shell->compositor = ec;
2107 shell->destroy_listener.notify = shell_destroy;
2108 wl_signal_add(&ec->destroy_signal, &shell->destroy_listener);
2109 ec->shell_interface.shell = shell;
2110 ec->shell_interface.create_shell_surface = create_shell_surface;
2111 ec->shell_interface.set_toplevel = set_toplevel;
2112 ec->shell_interface.set_transient = set_transient;
2114 wl_list_init(&shell->ivi_layer.link);
2115 weston_layer_init(&shell->surface, &ec->cursor_layer.link);
2117 uifw_trace("ico_ivi_shell: shell(%08x) ivi_layer.link.%08x=%08x/%08x",
2118 (int)shell, (int)&shell->ivi_layer.link,
2119 (int)shell->ivi_layer.link.next, (int)shell->ivi_layer.link.prev);
2121 shell_configuration(shell);
2123 if (wl_display_add_global(ec->wl_display, &wl_shell_interface, shell, bind_shell)
2127 if (wl_display_add_global(ec->wl_display, &ico_ivi_shell_interface,
2128 shell, bind_ivi_shell) == NULL) {
2132 weston_compositor_add_button_binding(ec, BTN_LEFT, 0,
2133 click_to_activate_binding, shell);
2135 uifw_info("ico_ivi_shell: Leave(module_init)");