From: Masayuki Sasaki Date: Mon, 24 Feb 2014 12:10:11 +0000 (+0900) Subject: 0.9.21 release -- It changes so that the layer controlling function of GENIVI may... X-Git-Tag: accepted/tizen/ivi/panda/20140326.234219~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=1be10588c0767a0382d0066f176530f69fe35506;p=profile%2Fivi%2Fico-uxf-weston-plugin.git 0.9.21 release -- It changes so that the layer controlling function of GENIVI may be used for surface management and layer management. But it has not been tested yet.Because function of GENIVI was not released yet. Change-Id: I53ac395c6807147d952df06ebd865b69ced8fba5 Signed-off-by: Masayuki Sasaki --- diff --git a/configure.ac b/configure.ac index 7f28765..9583cfa 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.68]) AC_INIT([ico-uxf-weston-plugin], - [0.9.14], + [0.9.21], [https://BUG-REPORT-ADDRESS]) AC_CONFIG_HEADERS([config.h]) @@ -30,9 +30,7 @@ AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_FUNCS([mkostemp strchrnul]) -PKG_CHECK_MODULES([PLUGIN], [wayland-server >= 1.3.0 weston >= 1.3.0 pixman-1 xkbcommon]) - -PKG_CHECK_MODULES([EGL], [egl]) +PKG_CHECK_MODULES([PLUGIN], [weston >= 1.1.1 pixman-1 xkbcommon]) if test "x$GCC" = "xyes"; then my_common_gcc_flags="-Wall -Wextra -Wno-unused-parameter \ diff --git a/packaging/ico-uxf-weston-plugin.spec b/packaging/ico-uxf-weston-plugin.spec index 7af2372..d741e57 100644 --- a/packaging/ico-uxf-weston-plugin.spec +++ b/packaging/ico-uxf-weston-plugin.spec @@ -1,6 +1,6 @@ Name: ico-uxf-weston-plugin Summary: Weston Plugins for IVI -Version: 0.9.14 +Version: 0.9.21 Release: 1.1 Group: Graphics & UI Framework/Automotive UI License: MIT @@ -18,7 +18,9 @@ BuildRequires: pkgconfig(ecore-wayland) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(ecore) BuildRequires: mesa-devel +BuildRequires: genivi-shell Requires: weston >= 1.4.0 +Requires: genivi-shell Requires: weekeyboard Conflicts: weston-ivi-config @@ -66,12 +68,7 @@ install -m 0644 settings/weston.ini %{buildroot}%{weston_conf} %files devel %manifest %{name}.manifest %defattr(-,root,root,-) -%{_includedir}/%{name}/desktop-shell-client-protocol.h -%{_includedir}/%{name}/xdg-shell-client-protocol.h -%{_includedir}/%{name}/input-method-client-protocol.h -%{_includedir}/%{name}/workspaces-client-protocol.h %{_includedir}/%{name}/ico_input_mgr-client-protocol.h %{_includedir}/%{name}/ico_window_mgr-client-protocol.h -%{_includedir}/%{name}/ico_window_mgr.h %{_includedir}/%{name}/ico_input_mgr.h %{_libdir}/libico-uxf-weston-plugin.so diff --git a/protocol/ico_input_mgr.xml b/protocol/ico_input_mgr.xml index a9cbdc6..a2d8219 100644 --- a/protocol/ico_input_mgr.xml +++ b/protocol/ico_input_mgr.xml @@ -6,15 +6,6 @@ to Multi Input Manager from HomeScreen. - - - Declare touch event code for send_input_event. - - - - - - Assign input switch to application from HomeScreen. @@ -34,19 +25,6 @@ - - - - Mouse, Touch or Keyboard event sent to application. - - - - - - - - - diff --git a/protocol/ico_window_mgr.xml b/protocol/ico_window_mgr.xml index 65e47fc..1422a1d 100644 --- a/protocol/ico_window_mgr.xml +++ b/protocol/ico_window_mgr.xml @@ -5,57 +5,6 @@ for IVI SystemController interface. - - - General values for ico_window_mgr. - - - - - - - - Declare manager application(ex. SystemController). - - - - - - - - Surface show/hide control define. - - - - - - - - Surface raise/lower control define. - - - - - - - - Flags for ico_window_mgr_set_positionsize and ico_window_mgr_set_visible API. - - - - - - - - Flags for surface attributes. - - - - - - - - Type of the cutaway for surface animation. @@ -66,95 +15,6 @@ - - - Buffer type of mapped surface. - - - - - - - - - Event type of mapped surface change. - - - - - - - - - - - Set surface active target device. - - - - - - - - - - Surafce change hint information. - - - - - - - - Surafce layer type. - - - - - - - - - - - - - Set manager application(ex.SystemController). - - - - - - - Surface belong to a layer. - - - - - - - - Set surface display position and surface size. - - - - - - - - - - - - - Show/Hide and Raise/Lower surface. - - - - - - - Set surface animation type. @@ -165,163 +25,72 @@ - - - Set surface attributes. - - - - - - - - Show/Hide surface with Animation. + + + Surface active select device. - - - - - - - + + + + - - - Set active surface. + + + Surface active change event to manager. - - - - - - Show/Hide layer. - - - - + + - - - Get surfaces of the application. + + + Buffer type of mapped surface. - - - + + + + - - - Set shared memory surfaces image buffer. + + + Event type of mapped surface change. - - - - + + + + + + - - Shared surfaces to system application(ex.HomeScreen). + + Set event of surface image(contents) change to system application(ex.HomeScreen). + - - Unshared surfaces. + + Unset event of surface image(contents) change to system application(ex.HomeScreen). - - - Surface create event to manager. - - - - - - - - - - - Surface name event to manager. - - - - - - - - Surface destory event to manager. - - - - - - - Surface visibility change event to manager. - - - - - - - - - - Surface attribute change event to manager. - - - - - - - - - - - - - - - Surface active change event to manager. - - - - - - - - Layer visibility change event to manager. - - - - - - - - Reply of app_surfaces request. - - - - - - - + Event of shared surface. - + diff --git a/protocol/ivi-application.xml b/protocol/ivi-application.xml new file mode 100644 index 0000000..5dd619b --- /dev/null +++ b/protocol/ivi-application.xml @@ -0,0 +1,93 @@ + + + + + Copyright (C) 2013 DENSO CORPORATION + Copyright (c) 2013 BMW Car IT GmbH + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + + + + + + + + + + + The new visibility state is provided in argument visibility. + If visibility is 0, the surface has become invisible. + If visibility is not 0, the surface has become visible. + + + + + + + + + + + + surface_create will create a new surface with surface_id in ivi compositor, + if it does not yet exists. If the surface with surface_id already exists in + ivi compositor, the application content provided in argument surface will + be used as surface content. If an other ivi application already registered + content for surface with surface_id, an error event will indicate the problem. + + + + + + + + + These error codes define all possible error codes returned by ivi compositor + on server-side errors. + + + + + + + + The ivi compositor encountered error while processing a request by this + application. The error is defined by argument error_code and optional + error_text. + If the application requires to associate this error event to a request, + it can + 1. send request + 2. force display roundtrip + 3. check, if error event was received + but this restricts the application to have only one open request at a time. + + + + + + + + + + + + + diff --git a/protocol/ivi-controller.xml b/protocol/ivi-controller.xml new file mode 100644 index 0000000..7c6aa0b --- /dev/null +++ b/protocol/ivi-controller.xml @@ -0,0 +1,636 @@ + + + + + Copyright (C) 2013 DENSO CORPORATION + Copyright (c) 2013 BMW Car IT GmbH + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + + + + + + + If visibility argument is 0, the surface in the ivi compositor is set to invisible. + If visibility argument is not 0, the surface in the ivi compositor is set to visible. + + + + + + + The valid range for opacity is 0.0 (fully transparent) to 1.0 (fully opaque). + + + + + + + The source rectangle defines the part of the surface content, that is used for + compositing the surface. It can be used, if valid content of the surface is smaller + than the surface. Effectively it can be used to zoom the content of the surface. + x: horizontal start position of scanout area within the surface + y: vertical start position of scanout area within the surface + width: width of scanout area within the surface + height: height of scanout area within the surface + + + + + + + + + + The destination rectangle defines the position and size of a surface on a layer. + The surface will be scaled to this rectangle for rendering. + x: horizontal start position of surface within the layer + y: vertical start position of surface within the layer + width : width of surface within the layer + height: height of surface within the layer + + + + + + + + + + Request the client providing content for this surface, to resize of the buffers + provided as surface content. + + + + + + + + The orientation of a surface in ivi compositor can be rotated in 90 degree steps, + as defined in orientation enum. + + + + + + + Store a screenshot of the surface content in the file provided by argument filename. + + + + + + + The new visibility state is provided in argument visibility. + If visibility is 0, the surface has become invisible. + If visibility is not 0, the surface has become visible. + + + + + + + The new opacity state is provided in argument opacity. + The valid range for opactiy is 0.0 (fully transparent) to 1.0 (fully opaque). + + + + + + + The scanout region of the surface content has changed. + The new values for source rectangle are provided by + x: new horizontal start position of scanout area within the surface + y: new vertical start position of scanout area within the surface + width: new width of scanout area within the surface + height: new height of scanout area within the surface + + + + + + + + + + The new values for source rectangle are provided by + x: new horizontal start position of surface within the layer + y: new vertical start position of surface within the layer + width : new width of surface within the layer + height: new height of surface within the layer + + + + + + + + + + The client providing content for this surface was requested to resize the buffer + provided as surface content. The requested buffer size is provided by arguments + width and height. + + + + + + + + The surfaces in ivi controller can be rotated in 90 degrees steps. + This enum defines all valid orientations for surfaces. + + + + + + + + + + The new orientation status is provided by argument orientation. + + + + + + + Applications can provide buffers as surface content with differernt buffer + properties. This enum defines all supported buffer configurations. + + + + + + + + + + + + + + When client attach buffers as surface content, these buffers have a pixelformat + configuration. If the pixelformat of a newly attached buffer is different from + the previous buffer configuration, this event is raised. + This is also done, when the first buffer is provided by application. + + + + + + + This surface was added to the render order of the layer defined by argument layer. + This is essential for a surface to become visible on screen, since ivi compositors + will only render layers (or more precise all surfaces in the render order of a layer). + + + + + + + These stats contain information required for monitoring, debugging, logging + and tracing. + + + + + + The information contained in this event is essential for monitoring, debugging, + logging and tracing support in IVI systems. + + + + + + + + + + + Request to destroy the ivi_controller_surface. If argument + destroy_scene_object id not 0, the surface will be destroyed in + ivi compositor. If argument is 0, only the proxy object is destroyed. + + + + + + + + + + + This enum defines all possible content states of a surface. This is + required, since surfaces in ivi compositor can exist without applications + providing content for them. + + + + + + + + Surfaces in ivi compositor can exist without any application or controller + referencing it. All surfaces initially have no content. This event indicates + when content state has changed. All possible content states are defined + in enum content_state. + + + + + + + Set input focus state of surface in ivi compositor. If the surface has input + focus, all non-graphical inputs (e.g. keyboard) are directed to the application + providing the content for this surface. + Only one surface can have input focus at a time, so if input focus is enabled + for one surface, any other surface with input focus will loose focus. + If argument enabled is 0, the input focus from this surface is removed, no + surface will have input focus. + If argument enabled is not 0, input focus for this surface is enabled. + + + + + + + The new input focus state is provided in argument enabled: If enabled is 0, + this surface has no longer the input focus. If enbaled is not 0, this surface + now has input focus enabled. + + + + + + + + + + + + If visibility argument is 0, the layer in the ivi compositor is set to invisible. + If visibility argument is not 0, the layer in the ivi compositor is set to visible. + + + + + + + The valid range for opacity is 0.0 (fully transparent) to 1.0 (fully opaque). + + + + + + + The source rectangle defines the part of the layer content, that is used for + compositing the screen. It can be used, if valid content of the layer is smaller + than the layer. Effectively it can be used to zoom the content of the layer. + x: horizontal start position of scanout area within the layer + y: vertical start position of scanout area within the layer + width: width of scanout area within the layer + height: height of scanout area within the layer + + + + + + + + + + The destination rectangle defines the position and size of a layer on a screen. + The layer will be scaled to this rectangle for rendering. + x: horizontal start position of layer within the screen + y: vertical start position of layer within the screen + width : width of surface within the screen + height: height of surface within the screen + + + + + + + + + + Layers are created with an initial size, but they can be resized at runtime. + This request changes the widht and height of a layer. + + + + + + + + The orientation of a layer in ivi compositor can be rotated in 90 degree steps, + as defined in orientation enum. + + + + + + + Store a screenshot of the layer content in the file provided by argument filename. + + + + + + + A layer has no content assigned to itself, it is a container for surfaces. + This request removes all surfaces from the layer render order. + Note: the surfaces are not destroyed, they are just no longer contained by + the layer. + + + + + + A layer has no content assigned to itself, it is a container for surfaces. + This request adds a surface to the topmost position of the layer render order. + The added surface will cover all other surfaces of the layer. + + + + + + + A layer has no content assigned to itself, it is a container for surfaces. + This request removes one surfaces from the layer render order. + Note: the surface is not destroyed, it is just no longer contained by + the layer. + + + + + + + A layer has no content assigned to itself, it is a container for surfaces. + This request removes all surfaces from the layer render order and set a + completely new render order. + + + + + + + The new visibility state is provided in argument visibility. + If visibility is 0, the layer has become invisible. + If visibility is not 0, the layer has become visible. + + + + + + + The new opacity state is provided in argument opacity. + The valid range for opactiy is 0.0 (fully transparent) to 1.0 (fully opaque). + + + + + + + The scanout region of the layer content has changed. + The new values for source rectangle are provided by + x: new horizontal start position of scanout area within the layer + y: new vertical start position of scanout area within the layer + width: new width of scanout area within the layer + height: new height of scanout area within the layer + + + + + + + + + + The new values for source rectangle are provided by + x: new horizontal start position of layer within the screen + y: new vertical start position of layer within the screen + width : new width of layer within the screen + height: new height of layer within the screen + + + + + + + + + + The layer was resized. The new layer size is provided by arguments + width and height. + + + + + + + + The new orientation status is provided by argument orientation. + + + + + + + This layer was added to the render order of the screen defined by argument screen. + This is essential for a layer to become visible on screen, since ivi compositors + will only render screens (or more precise all layers in the render order of a screen). + + + + + + + Request to destroy the ivi_controller_layer. If argument + destroy_scene_object id not 0, the layer will be destroyed in + ivi compositor. If argument is 0, only the proxy object is destroyed. + + + + + + + + + + + + + + + + + + + + A screen has no content assigned to itself, it is a container for layers. + This request removes all layers from the screen render order. + Note: the layers are not destroyed, they are just no longer contained by + the screen. + + + + + + A screen has no content assigned to itself, it is a container for layers. + This request adds a layers to the topmost position of the screen render order. + The added layer will cover all other layers of the screen. + + + + + + + Store a screenshot of the screen content in the file provided by argument filename. + + + + + + + A screen has no content assigned to itself, it is a container for layers. + This request removes all layers from the screen render order and set a + completely new render order. + + + + + + + + + + + + All requests are not applied directly to scene object, so a controller + can set different properties and apply the changes all at once. + Note: there's an exception to this. Creation and destruction of + scene objects is executed immediately. + + + + + + A new screen is announced to the controller. This is typically + the case in two cases: + 1. controller was just started, ivi compositor announces existing screen + 2. a new screen was added to the system at runtime + + + + + + + + layer_create will create a new layer with id_layer in ivi compositor, + if it does not yet exists. If the layer with id_layer already exists in + ivi compositor, a handle to the existing layer is returned and width and + height properties are ignored. + + + + + + + + + + A new layer is announced to the controller. + + + + + + + surface_create will create a new surface with id_surface in ivi compositor, + if it does not yet exists. If the surface with id_surface already exists in + ivi compositor, a handle to the existing surface is returned. + + + + + + + + A new surface is announced to the controller. + + + + + + + This enum defines all scene object available in ivi compositor. + + + + + + + + + These error codes define all possible error codes returned by ivi compositor + on server-side errors. + + + + + + + + + The ivi compositor encountered error while processing a request by this + controller. The error is defined by argument error_code and optional + error_text. Additionally the object type and id is contained in the error + event to provide some detailes to handle the error. + If the controller requires to associate this error event to a request, + it can + 1. send request + 2. force display roundtrip + 3. check, if error event was received + but this restricts the controller to have only one open request at a time. + + + + + + + + + + + + + + + + + + + + diff --git a/settings/weston.ini b/settings/weston.ini index 673fbc4..8188e0c 100644 --- a/settings/weston.ini +++ b/settings/weston.ini @@ -44,56 +44,23 @@ name=UNKNOWN1 transform=90 [ivi-plugin] -modules=ico_ivi_shell.so,ico_window_mgr.so,ico_window_animation.so,ico_input_mgr.so +modules=ivi-shell.so,ivi-controller.so,ico_window_mgr.so,ico_window_animation.so,ico_input_mgr.so [ivi-display] # logical display number list displayno=1,0 -# default input panel display -inputpanel=0 - -[ivi-layer] -# background layer id -background=0 -# default(panel) layer id -default=1 -# touch panel layer id -touch=101 -# cursor layer id -cursor=102 -# layer id at the time of the system startup -startup=103 -# input panel layer decoration (magnification rate(%);difference from the bottom) -inputpaneldeco=120;132 [ivi-animation] -# default animation name;time;rate(frame/sec) -default=fade;500;30 -# input panel surface animation(name;time) -inputpanel=fade;200 - -[ivi-thumbnail] -gpu_accel_fps=15 -shm_buffer_fps=2 -no_accel_fps=10 - -##[ivi-access-control] -##access_api.0=User::SystemApp;* -##access_api.1=User::MakerApp;set_window_layer,set_positionsize,set_visible -##access_api.2=User::MakerApp;set_map_buffer,map_sirface,unmap_surface -##access_api.3=User::MakerApp;device_configure_input,device_configure_code,device_input_event -##access_api.4=User::AuthenticatedApp;set_positionsize,set_visible -##access_api.5=*;set_input_region,unset_input_region +# default animation name +default=fade +# default animation time(ms) +time=500 +# default animation frame rate(frame/sec) +fps=30 [ivi-option] -# option flags -# 0x0001 1=show surface at screen create if HomeScreen exist/0=not show surface at create -# 0x0002 1=1=show if display not exist/0=not show if display not exist -# 0x0004 1=show input panel automatically/0=not show automaticaly -# 0x0010 1=support shm_buffer thumbnail/not support shm_buffer -# 0x0080 1=surface fixed aspect rate/0=not fixed aspect rate -# 0x8000 1=Acceleration depending on GPU(intel GPU only)/0=independing GPU -flag=0x0004 +# option flags (but not used) +flag=0x0000 # debug log output level and debug flag # lower 16 bit: log level(0=no/1=err/2=warn/3=info/4=trace/5=debug) diff --git a/src/Makefile.am b/src/Makefile.am index b82a9bf..35ff2b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,22 +1,15 @@ lib_LTLIBRARIES = libico-uxf-weston-plugin.la pkginclude_HEADERS = \ - desktop-shell-client-protocol.h \ - xdg-shell-client-protocol.h \ - input-method-client-protocol.h \ - workspaces-client-protocol.h \ ico_window_mgr-client-protocol.h \ ico_input_mgr-client-protocol.h \ - ico_window_mgr.h \ ico_input_mgr.h libico_uxf_weston_plugin_la_LIBADD = -ldrm_intel -lrt -lm libico_uxf_weston_plugin_la_LDFLAGS = -version-info 0:9:0 libico_uxf_weston_plugin_la_SOURCES = \ - desktop-shell-protocol.c \ - xdg-shell-protocol.c \ - input-method-protocol.c \ - workspaces-protocol.c \ + ivi-application-protocol.c \ + ivi-controller-protocol.c \ ico_window_mgr-protocol.c \ ico_input_mgr-protocol.c @@ -37,7 +30,6 @@ git-version.h : .FORCE moduledir = @libdir@/weston module_LTLIBRARIES = \ $(ico_plugin_loader) \ - $(ico_ivi_shell) \ $(ico_window_mgr) \ $(ico_window_animation) \ $(ico_input_mgr) @@ -52,34 +44,15 @@ ico_plugin_loader_la_SOURCES = \ ico_ivi_common_private.h \ ico_plugin_version.h -# IVI-Shell -ico_ivi_shell = ico_ivi_shell.la -ico_ivi_shell_la_LDFLAGS = -module -avoid-version -ico_ivi_shell_la_LIBADD = $(PLUGIN_LIBS) -ico_ivi_shell_la_CFLAGS = $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) -ico_ivi_shell_la_SOURCES = \ - ico_ivi_shell.h \ - ico_ivi_shell.c \ - ico_exposay.c \ - ico_input-panel.c \ - ico_ivi_shell_private.h \ - ico_ivi_common_private.h \ - desktop-shell-protocol.c \ - desktop-shell-server-protocol.h \ - xdg-shell-protocol.c \ - xdg-shell-server-protocol.h - # Multi Window Manager ico_window_mgr = ico_window_mgr.la ico_window_mgr_la_LDFLAGS = -module -avoid-version -ico_window_mgr_la_LIBADD = -lEGL -lGLESv2 -ldrm_intel $(PLUGIN_LIBS) $(AUL_LIBS) +ico_window_mgr_la_LIBADD = -ldrm_intel $(PLUGIN_LIBS) $(AUL_LIBS) ico_window_mgr_la_CFLAGS = -I/usr/include/libdrm $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) ico_window_mgr_la_SOURCES = \ ico_window_mgr.c \ ico_window_mgr_private.h \ - ico_window_mgr.h \ ico_ivi_common_private.h \ - ico_ivi_shell_private.h \ ico_window_mgr-protocol.c \ ico_window_mgr-server-protocol.h # @@ -108,18 +81,12 @@ ico_input_mgr_la_SOURCES = \ # Wayland protocol(Build by wayland-scanner) BUILT_SOURCES = \ - desktop-shell-protocol.c \ - desktop-shell-server-protocol.h \ - desktop-shell-client-protocol.h \ - xdg-shell-protocol.c \ - xdg-shell-server-protocol.h \ - xdg-shell-client-protocol.h \ - input-method-protocol.c \ - input-method-server-protocol.h \ - input-method-client-protocol.h \ - workspaces-protocol.c \ - workspaces-server-protocol.h \ - workspaces-client-protocol.h \ + ivi-application-protocol.c \ + ivi-application-server-protocol.h \ + ivi-application-client-protocol.h \ + ivi-controller-protocol.c \ + ivi-controller-server-protocol.h \ + ivi-controller-client-protocol.h \ ico_window_mgr-protocol.c \ ico_window_mgr-server-protocol.h \ ico_window_mgr-client-protocol.h \ diff --git a/src/ico_exposay.c b/src/ico_exposay.c deleted file mode 100644 index 21f306f..0000000 --- a/src/ico_exposay.c +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright © 2010-2012 Intel Corporation - * Copyright © 2011-2012 Collabora, Ltd. - * Copyright © 2013 Raspberry Pi Foundation - * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION. - * - * 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. - */ - -#include - -#include "ico_ivi_shell.h" - -struct exposay_surface { - struct desktop_shell *shell; - struct weston_surface *surface; - struct weston_view *view; - struct wl_list link; - - int x; - int y; - int width; - int height; - double scale; - - int row; - int column; - - /* The animations only apply a transformation for their own lifetime, - * and don't have an option to indefinitely maintain the - * transformation in a steady state - so, we apply our own once the - * animation has finished. */ - struct weston_transform transform; -}; - -static void exposay_set_state(struct desktop_shell *shell, - enum exposay_target_state state, - struct weston_seat *seat); -static void exposay_check_state(struct desktop_shell *shell); - -static void -exposay_in_flight_inc(struct desktop_shell *shell) -{ - shell->exposay.in_flight++; -} - -static void -exposay_in_flight_dec(struct desktop_shell *shell) -{ - if (--shell->exposay.in_flight > 0) - return; - - exposay_check_state(shell); -} - -static void -exposay_animate_in_done(struct weston_view_animation *animation, void *data) -{ - struct exposay_surface *esurface = data; - - wl_list_insert(&esurface->view->geometry.transformation_list, - &esurface->transform.link); - weston_matrix_init(&esurface->transform.matrix); - weston_matrix_scale(&esurface->transform.matrix, - esurface->scale, esurface->scale, 1.0f); - weston_matrix_translate(&esurface->transform.matrix, - esurface->x - esurface->view->geometry.x, - esurface->y - esurface->view->geometry.y, - 0); - - weston_view_geometry_dirty(esurface->view); - weston_compositor_schedule_repaint(esurface->view->surface->compositor); - - exposay_in_flight_dec(esurface->shell); -} - -static void -exposay_animate_in(struct exposay_surface *esurface) -{ - exposay_in_flight_inc(esurface->shell); - - weston_move_scale_run(esurface->view, - esurface->x - esurface->view->geometry.x, - esurface->y - esurface->view->geometry.y, - 1.0, esurface->scale, 0, - exposay_animate_in_done, esurface); -} - -static void -exposay_animate_out_done(struct weston_view_animation *animation, void *data) -{ - struct exposay_surface *esurface = data; - struct desktop_shell *shell = esurface->shell; - - wl_list_remove(&esurface->link); - free(esurface); - - exposay_in_flight_dec(shell); -} - -static void -exposay_animate_out(struct exposay_surface *esurface) -{ - exposay_in_flight_inc(esurface->shell); - - /* Remove the static transformation set up by - * exposay_transform_in_done(). */ - wl_list_remove(&esurface->transform.link); - weston_view_geometry_dirty(esurface->view); - - weston_move_scale_run(esurface->view, - esurface->x - esurface->view->geometry.x, - esurface->y - esurface->view->geometry.y, - 1.0, esurface->scale, 1, - exposay_animate_out_done, esurface); -} - -static void -exposay_highlight_surface(struct desktop_shell *shell, - struct exposay_surface *esurface) -{ - struct weston_view *view = esurface->view; - - shell->exposay.row_current = esurface->row; - shell->exposay.column_current = esurface->column; - - activate(shell, view->surface, shell->exposay.seat); - shell->exposay.focus_current = view; -} - -static int -exposay_is_animating(struct desktop_shell *shell) -{ - if (shell->exposay.state_cur == EXPOSAY_LAYOUT_INACTIVE || - shell->exposay.state_cur == EXPOSAY_LAYOUT_OVERVIEW) - return 0; - - return (shell->exposay.in_flight > 0); -} - -static void -exposay_pick(struct desktop_shell *shell, int x, int y) -{ - struct exposay_surface *esurface; - - if (exposay_is_animating(shell)) - return; - - wl_list_for_each(esurface, &shell->exposay.surface_list, link) { - if (x < esurface->x || x > esurface->x + esurface->width) - continue; - if (y < esurface->y || y > esurface->y + esurface->height) - continue; - - exposay_highlight_surface(shell, esurface); - return; - } -} - -/* Pretty lame layout for now; just tries to make a square. Should take - * aspect ratio into account really. Also needs to be notified of surface - * addition and removal and adjust layout/animate accordingly. */ -static enum exposay_layout_state -exposay_layout(struct desktop_shell *shell) -{ - struct workspace *workspace = shell->exposay.workspace; - struct weston_compositor *compositor = shell->compositor; - struct weston_output *output = get_default_output(compositor); - struct weston_view *view; - struct exposay_surface *esurface, *highlight = NULL; - int w, h; - int i; - int last_row_removed = 0; - - wl_list_init(&shell->exposay.surface_list); - - shell->exposay.num_surfaces = 0; - wl_list_for_each(view, &workspace->layer.view_list, layer_link) { - if (!get_shell_surface(view->surface)) - continue; - shell->exposay.num_surfaces++; - } - - if (shell->exposay.num_surfaces == 0) { - shell->exposay.grid_size = 0; - shell->exposay.hpadding_outer = 0; - shell->exposay.vpadding_outer = 0; - shell->exposay.padding_inner = 0; - shell->exposay.surface_size = 0; - return EXPOSAY_LAYOUT_OVERVIEW; - } - - /* Lay the grid out as square as possible, losing surfaces from the - * bottom row if required. Start with fixed padding of a 10% margin - * around the outside and 80px internal padding between surfaces, and - * maximise the area made available to surfaces after this, but only - * to a maximum of 1/3rd the total output size. - * - * If we can't make a square grid, add one extra row at the bottom - * which will have a smaller number of columns. - * - * XXX: Surely there has to be a better way to express this maths, - * right?! - */ - shell->exposay.grid_size = floor(sqrtf(shell->exposay.num_surfaces)); - if (pow(shell->exposay.grid_size, 2) != shell->exposay.num_surfaces) - shell->exposay.grid_size++; - last_row_removed = pow(shell->exposay.grid_size, 2) - shell->exposay.num_surfaces; - - shell->exposay.hpadding_outer = (output->width / 10); - shell->exposay.vpadding_outer = (output->height / 10); - shell->exposay.padding_inner = 80; - - w = output->width - (shell->exposay.hpadding_outer * 2); - w -= shell->exposay.padding_inner * (shell->exposay.grid_size - 1); - w /= shell->exposay.grid_size; - - h = output->height - (shell->exposay.vpadding_outer * 2); - h -= shell->exposay.padding_inner * (shell->exposay.grid_size - 1); - h /= shell->exposay.grid_size; - - shell->exposay.surface_size = (w < h) ? w : h; - if (shell->exposay.surface_size > (output->width / 2)) - shell->exposay.surface_size = output->width / 2; - if (shell->exposay.surface_size > (output->height / 2)) - shell->exposay.surface_size = output->height / 2; - - i = 0; - wl_list_for_each(view, &workspace->layer.view_list, layer_link) { - int pad; - - pad = shell->exposay.surface_size + shell->exposay.padding_inner; - - if (!get_shell_surface(view->surface)) - continue; - - esurface = malloc(sizeof(*esurface)); - if (!esurface) { - exposay_set_state(shell, EXPOSAY_TARGET_CANCEL, - shell->exposay.seat); - break; - } - - wl_list_insert(&shell->exposay.surface_list, &esurface->link); - esurface->shell = shell; - esurface->view = view; - - esurface->row = i / shell->exposay.grid_size; - esurface->column = i % shell->exposay.grid_size; - - esurface->x = shell->exposay.hpadding_outer; - esurface->x += pad * esurface->column; - esurface->y = shell->exposay.vpadding_outer; - esurface->y += pad * esurface->row; - - if (esurface->row == shell->exposay.grid_size - 1) - esurface->x += (shell->exposay.surface_size + shell->exposay.padding_inner) * last_row_removed / 2; - - if (view->surface->width > view->surface->height) - esurface->scale = shell->exposay.surface_size / (float) view->surface->width; - else - esurface->scale = shell->exposay.surface_size / (float) view->surface->height; - esurface->width = view->surface->width * esurface->scale; - esurface->height = view->surface->height * esurface->scale; - - if (shell->exposay.focus_current == esurface->view) - highlight = esurface; - - set_alpha_if_fullscreen(get_shell_surface(view->surface)); - - exposay_animate_in(esurface); - - i++; - } - - if (highlight) - exposay_highlight_surface(shell, highlight); - - weston_compositor_schedule_repaint(shell->compositor); - - return EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW; -} - -static void -exposay_focus(struct weston_pointer_grab *grab) -{ -} - -static void -exposay_motion(struct weston_pointer_grab *grab, uint32_t time, - wl_fixed_t x, wl_fixed_t y) -{ - struct desktop_shell *shell = - container_of(grab, struct desktop_shell, exposay.grab_ptr); - - weston_pointer_move(grab->pointer, x, y); - - exposay_pick(shell, - wl_fixed_to_int(grab->pointer->x), - wl_fixed_to_int(grab->pointer->y)); -} - -static void -exposay_button(struct weston_pointer_grab *grab, uint32_t time, uint32_t button, - uint32_t state_w) -{ - struct desktop_shell *shell = - container_of(grab, struct desktop_shell, exposay.grab_ptr); - struct weston_seat *seat = grab->pointer->seat; - enum wl_pointer_button_state state = state_w; - - if (button != BTN_LEFT) - return; - - /* Store the surface we clicked on, and don't do anything if we end up - * releasing on a different surface. */ - if (state == WL_POINTER_BUTTON_STATE_PRESSED) { - shell->exposay.clicked = shell->exposay.focus_current; - return; - } - - if (shell->exposay.focus_current == shell->exposay.clicked) - exposay_set_state(shell, EXPOSAY_TARGET_SWITCH, seat); - else - shell->exposay.clicked = NULL; -} - -static void -exposay_pointer_grab_cancel(struct weston_pointer_grab *grab) -{ - struct desktop_shell *shell = - container_of(grab, struct desktop_shell, exposay.grab_ptr); - - exposay_set_state(shell, EXPOSAY_TARGET_CANCEL, shell->exposay.seat); -} - -static const struct weston_pointer_grab_interface exposay_ptr_grab = { - exposay_focus, - exposay_motion, - exposay_button, - exposay_pointer_grab_cancel, -}; - -static int -exposay_maybe_move(struct desktop_shell *shell, int row, int column) -{ - struct exposay_surface *esurface; - - wl_list_for_each(esurface, &shell->exposay.surface_list, link) { - if (esurface->row != row || esurface->column != column) - continue; - - exposay_highlight_surface(shell, esurface); - return 1; - } - - return 0; -} - -static void -exposay_key(struct weston_keyboard_grab *grab, uint32_t time, uint32_t key, - uint32_t state_w) -{ - struct weston_seat *seat = grab->keyboard->seat; - struct desktop_shell *shell = - container_of(grab, struct desktop_shell, exposay.grab_kbd); - enum wl_keyboard_key_state state = state_w; - - if (state != WL_KEYBOARD_KEY_STATE_RELEASED) - return; - - switch (key) { - case KEY_ESC: - exposay_set_state(shell, EXPOSAY_TARGET_CANCEL, seat); - break; - case KEY_ENTER: - exposay_set_state(shell, EXPOSAY_TARGET_SWITCH, seat); - break; - case KEY_UP: - exposay_maybe_move(shell, shell->exposay.row_current - 1, - shell->exposay.column_current); - break; - case KEY_DOWN: - /* Special case for trying to move to the bottom row when it - * has fewer items than all the others. */ - if (!exposay_maybe_move(shell, shell->exposay.row_current + 1, - shell->exposay.column_current) && - shell->exposay.row_current < (shell->exposay.grid_size - 1)) { - exposay_maybe_move(shell, shell->exposay.row_current + 1, - (shell->exposay.num_surfaces % - shell->exposay.grid_size) - 1); - } - break; - case KEY_LEFT: - exposay_maybe_move(shell, shell->exposay.row_current, - shell->exposay.column_current - 1); - break; - case KEY_RIGHT: - exposay_maybe_move(shell, shell->exposay.row_current, - shell->exposay.column_current + 1); - break; - case KEY_TAB: - /* Try to move right, then down (and to the leftmost column), - * then if all else fails, to the top left. */ - if (!exposay_maybe_move(shell, shell->exposay.row_current, - shell->exposay.column_current + 1) && - !exposay_maybe_move(shell, shell->exposay.row_current + 1, 0)) - exposay_maybe_move(shell, 0, 0); - break; - default: - break; - } -} - -static void -exposay_modifier(struct weston_keyboard_grab *grab, uint32_t serial, - uint32_t mods_depressed, uint32_t mods_latched, - uint32_t mods_locked, uint32_t group) -{ - struct desktop_shell *shell = - container_of(grab, struct desktop_shell, exposay.grab_kbd); - struct weston_seat *seat = (struct weston_seat *) grab->keyboard->seat; - - /* We want to know when mod has been pressed and released. - * FIXME: There is a problem here: if mod is pressed, then a key - * is pressed and released, then mod is released, we will treat that - * as if only mod had been pressed and released. */ - if (seat->modifier_state) { - if (seat->modifier_state == shell->binding_modifier) { - shell->exposay.mod_pressed = true; - } else { - shell->exposay.mod_invalid = true; - } - } else { - if (shell->exposay.mod_pressed && !shell->exposay.mod_invalid) - exposay_set_state(shell, EXPOSAY_TARGET_CANCEL, seat); - - shell->exposay.mod_invalid = false; - shell->exposay.mod_pressed = false; - } - - return; -} - -static void -exposay_cancel(struct weston_keyboard_grab *grab) -{ - struct desktop_shell *shell = - container_of(grab, struct desktop_shell, exposay.grab_kbd); - - exposay_set_state(shell, EXPOSAY_TARGET_CANCEL, shell->exposay.seat); -} - -static const struct weston_keyboard_grab_interface exposay_kbd_grab = { - exposay_key, - exposay_modifier, - exposay_cancel, -}; - -/** - * Called when the transition from overview -> inactive has completed. - */ -static enum exposay_layout_state -exposay_set_inactive(struct desktop_shell *shell) -{ - struct weston_seat *seat = shell->exposay.seat; - - weston_keyboard_end_grab(seat->keyboard); - weston_pointer_end_grab(seat->pointer); - if (seat->keyboard->input_method_resource) - seat->keyboard->grab = &seat->keyboard->input_method_grab; - - return EXPOSAY_LAYOUT_INACTIVE; -} - -/** - * Begins the transition from overview to inactive. */ -static enum exposay_layout_state -exposay_transition_inactive(struct desktop_shell *shell, int switch_focus) -{ - struct exposay_surface *esurface; - - /* Call activate() before we start the animations to avoid - * animating back the old state and then immediately transitioning - * to the new. */ - if (switch_focus && shell->exposay.focus_current) - activate(shell, shell->exposay.focus_current->surface, - shell->exposay.seat); - else if (shell->exposay.focus_prev) - activate(shell, shell->exposay.focus_prev->surface, - shell->exposay.seat); - - wl_list_for_each(esurface, &shell->exposay.surface_list, link) - exposay_animate_out(esurface); - weston_compositor_schedule_repaint(shell->compositor); - - return EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE; -} - -static enum exposay_layout_state -exposay_transition_active(struct desktop_shell *shell) -{ - struct weston_seat *seat = shell->exposay.seat; - - shell->exposay.workspace = get_current_workspace(shell); - shell->exposay.focus_prev = get_default_view (seat->keyboard->focus); - shell->exposay.focus_current = get_default_view (seat->keyboard->focus); - shell->exposay.clicked = NULL; - wl_list_init(&shell->exposay.surface_list); - - lower_fullscreen_layer(shell); - shell->exposay.grab_kbd.interface = &exposay_kbd_grab; - weston_keyboard_start_grab(seat->keyboard, - &shell->exposay.grab_kbd); - weston_keyboard_set_focus(seat->keyboard, NULL); - - shell->exposay.grab_ptr.interface = &exposay_ptr_grab; - weston_pointer_start_grab(seat->pointer, - &shell->exposay.grab_ptr); - weston_pointer_set_focus(seat->pointer, NULL, - seat->pointer->x, seat->pointer->y); - - return exposay_layout(shell); -} - -static void -exposay_check_state(struct desktop_shell *shell) -{ - enum exposay_layout_state state_new = shell->exposay.state_cur; - int do_switch = 0; - - /* Don't do anything whilst animations are running, just store up - * target state changes and only act on them when the animations have - * completed. */ - if (exposay_is_animating(shell)) - return; - - switch (shell->exposay.state_target) { - case EXPOSAY_TARGET_OVERVIEW: - switch (shell->exposay.state_cur) { - case EXPOSAY_LAYOUT_OVERVIEW: - goto out; - case EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW: - state_new = EXPOSAY_LAYOUT_OVERVIEW; - break; - default: - state_new = exposay_transition_active(shell); - break; - } - break; - - case EXPOSAY_TARGET_SWITCH: - do_switch = 1; /* fallthrough */ - case EXPOSAY_TARGET_CANCEL: - switch (shell->exposay.state_cur) { - case EXPOSAY_LAYOUT_INACTIVE: - goto out; - case EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE: - state_new = exposay_set_inactive(shell); - break; - default: - state_new = exposay_transition_inactive(shell, do_switch); - break; - } - - break; - } - -out: - shell->exposay.state_cur = state_new; -} - -static void -exposay_set_state(struct desktop_shell *shell, enum exposay_target_state state, - struct weston_seat *seat) -{ - shell->exposay.state_target = state; - shell->exposay.seat = seat; - exposay_check_state(shell); -} - -void -exposay_binding(struct weston_seat *seat, enum weston_keyboard_modifier modifier, - void *data) -{ - struct desktop_shell *shell = data; - - exposay_set_state(shell, EXPOSAY_TARGET_OVERVIEW, seat); -} diff --git a/src/ico_input-panel.c b/src/ico_input-panel.c deleted file mode 100644 index e58bcac..0000000 --- a/src/ico_input-panel.c +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Copyright © 2010-2012 Intel Corporation - * Copyright © 2011-2012 Collabora, Ltd. - * Copyright © 2013 Raspberry Pi Foundation - * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION. - * - * 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. - */ - -#include -#include -#include - -#include "ico_ivi_shell.h" -#include "ico_ivi_shell_private.h" -#include "desktop-shell-server-protocol.h" -#include "input-method-server-protocol.h" - -struct input_panel_surface { - struct wl_resource *resource; - struct wl_signal destroy_signal; - - struct desktop_shell *shell; - - struct wl_list link; - struct weston_surface *surface; - struct weston_view *view; - struct wl_listener surface_destroy_listener; - - struct weston_output *output; - uint32_t panel; -}; - -extern int ico_debug_level; - -/* debug log macros */ -#define uifw_debug(fmt,...) \ - { if (ico_debug_level >= 5) {weston_log("DBG>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_trace(fmt,...) \ - { if (ico_debug_level >= 4) {weston_log("TRC>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_info(fmt,...) \ - { if (ico_debug_level >= 3) {weston_log("INF>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_warn(fmt,...) \ - { if (ico_debug_level >= 2) {weston_log("WRN>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_error(fmt,...) \ - { if (ico_debug_level >= 1) {weston_log("ERR>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } - -static void -show_input_panels(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, - show_input_panel_listener); - struct input_panel_surface *ipsurf, *next; - - shell->text_input.surface = (struct weston_surface*)data; - - uifw_trace("show_input_panels: Enter(surface=%08x[%d])", - (int)data, shell->showing_input_panels); - - if (shell->showing_input_panels) { - uifw_trace("show_input_panels: Leave(already)"); - return; - } - shell->showing_input_panels = true; - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_show_layer) { - (*shell_hook_show_layer)(LAYER_TYPE_INPUTPANEL, 1, data); - return; - } - - if (!shell->locked) - wl_list_insert(&shell->panel_layer.link, - &shell->input_panel_layer.link); - wl_list_for_each_safe(ipsurf, next, - &shell->input_panel.surfaces, link) { - if (ipsurf->surface->width == 0) - continue; - uifw_debug("show_input_panels: insert view=%08x surf=%08x", - (int)ipsurf->view, (int)ipsurf->surface); - wl_list_remove(&ipsurf->view->layer_link); - wl_list_init(&ipsurf->view->layer_link); - wl_list_insert(&shell->input_panel_layer.view_list, - &ipsurf->view->layer_link); - weston_view_geometry_dirty(ipsurf->view); - weston_view_update_transform(ipsurf->view); - weston_surface_damage(ipsurf->surface); - weston_slide_run(ipsurf->view, ipsurf->surface->height * 0.9, - 0, NULL, NULL); - } - uifw_trace("show_input_panels: Leave"); -} - -static void -hide_input_panels(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, - hide_input_panel_listener); - struct weston_view *view, *next; - - uifw_trace("hide_input_panels: Enter(surface=%08x[%d])", - (int)data, shell->showing_input_panels); - - if (!shell->showing_input_panels) { - uifw_trace("hide_input_panels: Leave(not show)"); - return; - } - shell->showing_input_panels = false; - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_show_layer) { - (*shell_hook_show_layer)(LAYER_TYPE_INPUTPANEL, 0, NULL); - return; - } - - if (!shell->locked) - wl_list_remove(&shell->input_panel_layer.link); - - wl_list_for_each_safe(view, next, - &shell->input_panel_layer.view_list, layer_link) - weston_view_unmap(view); - uifw_trace("hide_input_panels: Leave"); -} - -static void -update_input_panels(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, - update_input_panel_listener); - - memcpy(&shell->text_input.cursor_rectangle, data, sizeof(pixman_box32_t)); -} - -static void -input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy) -{ - struct input_panel_surface *ip_surface = surface->configure_private; - struct desktop_shell *shell = ip_surface->shell; - struct weston_view *view; - float x, y; - - uifw_trace("input_panel_configure: Enter(surface=%08x x/y=%d/%d w/h=%d/%d)", - (int)surface, sx, sy, surface->width, surface->height); - - if (surface->width == 0) { - uifw_trace("input_panel_configure: Leave(width==0)"); - return; - } - if (ip_surface->panel) { - view = get_default_view(shell->text_input.surface); - if (view == NULL) { - uifw_trace("input_panel_configure: Leave(no view)"); - return; - } - x = view->geometry.x + shell->text_input.cursor_rectangle.x2; - y = view->geometry.y + shell->text_input.cursor_rectangle.y2; - } else { - x = ip_surface->output->x + (ip_surface->output->width - surface->width) / 2; - y = ip_surface->output->y + ip_surface->output->height - surface->height; - if (! shell_hook_map) { - y -= 132.0f; - } - } - - weston_view_set_position(ip_surface->view, x, y); - - if (!weston_surface_is_mapped(surface) && shell->showing_input_panels) { - wl_list_insert(&shell->input_panel_layer.view_list, - &ip_surface->view->layer_link); - weston_view_update_transform(ip_surface->view); - weston_surface_damage(surface); - weston_slide_run(ip_surface->view, ip_surface->view->surface->height * 0.9, 0, NULL, NULL); - } - - if (shell_hook_map) { - int wx, wy; - int ww, wh; - wx = (int)x; - wy = (int)y; - ww = ip_surface->output->width; - wh = ip_surface->output->height; - (*shell_hook_map)(surface, &ww, &wh, &wx, &wy); - } - if (shell_hook_configure) { - (*shell_hook_configure)(surface); - } - uifw_trace("input_panel_configure: Leave"); -} - -static void -destroy_input_panel_surface(struct input_panel_surface *input_panel_surface) -{ - wl_signal_emit(&input_panel_surface->destroy_signal, input_panel_surface); - - wl_list_remove(&input_panel_surface->surface_destroy_listener.link); - wl_list_remove(&input_panel_surface->link); - - uifw_trace("destroy_input_panel_surface: Enter(surface=%08x)", - (int)input_panel_surface->surface); - - input_panel_surface->surface->configure = NULL; - weston_view_destroy(input_panel_surface->view); - - free(input_panel_surface); - uifw_trace("destroy_input_panel_surface: Leave"); -} - -static struct input_panel_surface * -get_input_panel_surface(struct weston_surface *surface) -{ - if (surface->configure == input_panel_configure) { - return surface->configure_private; - } else { - return NULL; - } -} - -static void -input_panel_handle_surface_destroy(struct wl_listener *listener, void *data) -{ - struct input_panel_surface *ipsurface = container_of(listener, - struct input_panel_surface, - surface_destroy_listener); - - if (ipsurface->resource) { - wl_resource_destroy(ipsurface->resource); - } else { - destroy_input_panel_surface(ipsurface); - } -} - -static struct input_panel_surface * -create_input_panel_surface(struct desktop_shell *shell, - struct weston_surface *surface) -{ - struct input_panel_surface *input_panel_surface; - - input_panel_surface = calloc(1, sizeof *input_panel_surface); - if (!input_panel_surface) - return NULL; - - uifw_trace("create_input_panel_surface: Enter(surface=%08x)", (int)surface); - - surface->configure = input_panel_configure; - surface->configure_private = input_panel_surface; - - input_panel_surface->shell = shell; - - input_panel_surface->surface = surface; - input_panel_surface->view = weston_view_create(surface); - - wl_signal_init(&input_panel_surface->destroy_signal); - input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy; - wl_signal_add(&surface->destroy_signal, - &input_panel_surface->surface_destroy_listener); - - wl_list_init(&input_panel_surface->link); - - uifw_trace("create_input_panel_surface: Leave(ipsurf=%08x)", (int)input_panel_surface); - - return input_panel_surface; -} - -static void -input_panel_surface_set_toplevel(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output_resource, - uint32_t position) -{ - struct input_panel_surface *input_panel_surface = - wl_resource_get_user_data(resource); - struct desktop_shell *shell = input_panel_surface->shell; - - wl_list_insert(&shell->input_panel.surfaces, - &input_panel_surface->link); - - input_panel_surface->output = wl_resource_get_user_data(output_resource); - input_panel_surface->panel = 0; -} - -static void -input_panel_surface_set_overlay_panel(struct wl_client *client, - struct wl_resource *resource) -{ - struct input_panel_surface *input_panel_surface = - wl_resource_get_user_data(resource); - struct desktop_shell *shell = input_panel_surface->shell; - - wl_list_insert(&shell->input_panel.surfaces, - &input_panel_surface->link); - - input_panel_surface->panel = 1; -} - -static const struct wl_input_panel_surface_interface input_panel_surface_implementation = { - input_panel_surface_set_toplevel, - input_panel_surface_set_overlay_panel -}; - -static void -destroy_input_panel_surface_resource(struct wl_resource *resource) -{ - struct input_panel_surface *ipsurf = - wl_resource_get_user_data(resource); - - destroy_input_panel_surface(ipsurf); -} - -static void -input_panel_get_input_panel_surface(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct input_panel_surface *ipsurf; - - uifw_trace("input_panel_get_input_panel_surface: Enter"); - - if (get_input_panel_surface(surface)) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "wl_input_panel::get_input_panel_surface already requested"); - return; - } - - ipsurf = create_input_panel_surface(shell, surface); - if (!ipsurf) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "surface->configure already set"); - return; - } - - ipsurf->resource = - wl_resource_create(client, - &wl_input_panel_surface_interface, 1, id); - wl_resource_set_implementation(ipsurf->resource, - &input_panel_surface_implementation, - ipsurf, - destroy_input_panel_surface_resource); - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_create) { - (*shell_hook_create)(LAYER_TYPE_INPUTPANEL, - surface, client, (struct shell_surface *)ipsurf); - } - uifw_trace("input_panel_get_input_panel_surface: Leave"); -} - -static const struct wl_input_panel_interface input_panel_implementation = { - input_panel_get_input_panel_surface -}; - -static void -unbind_input_panel(struct wl_resource *resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - shell->input_panel.binding = NULL; -} - -static void -bind_input_panel(struct wl_client *client, - void *data, uint32_t version, uint32_t id) -{ - struct desktop_shell *shell = data; - struct wl_resource *resource; - - resource = wl_resource_create(client, - &wl_input_panel_interface, 1, id); - - if (shell->input_panel.binding == NULL) { - wl_resource_set_implementation(resource, - &input_panel_implementation, - shell, unbind_input_panel); - shell->input_panel.binding = resource; - return; - } - - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "interface object already bound"); - wl_resource_destroy(resource); -} - -void -input_panel_destroy(struct desktop_shell *shell) -{ - wl_list_remove(&shell->show_input_panel_listener.link); - wl_list_remove(&shell->hide_input_panel_listener.link); -} - -int -input_panel_setup(struct desktop_shell *shell) -{ - struct weston_compositor *ec = shell->compositor; - - shell->show_input_panel_listener.notify = show_input_panels; - wl_signal_add(&ec->show_input_panel_signal, - &shell->show_input_panel_listener); - shell->hide_input_panel_listener.notify = hide_input_panels; - wl_signal_add(&ec->hide_input_panel_signal, - &shell->hide_input_panel_listener); - shell->update_input_panel_listener.notify = update_input_panels; - wl_signal_add(&ec->update_input_panel_signal, - &shell->update_input_panel_listener); - - wl_list_init(&shell->input_panel.surfaces); - - if (wl_global_create(shell->compositor->wl_display, - &wl_input_panel_interface, 1, - shell, bind_input_panel) == NULL) - return -1; - - return 0; -} - -WL_EXPORT struct weston_view * -ico_input_panel_get_view(void *ipsurf) -{ - return ((struct input_panel_surface *)ipsurf)->view; -} diff --git a/src/ico_input_mgr.c b/src/ico_input_mgr.c index 17b0fab..61283f0 100644 --- a/src/ico_input_mgr.c +++ b/src/ico_input_mgr.c @@ -24,7 +24,7 @@ /** * @brief Multi Input Manager (Weston(Wayland) PlugIn) * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #include @@ -43,9 +43,7 @@ #include #include #include "ico_ivi_common_private.h" -#include "ico_ivi_shell_private.h" #include "ico_input_mgr.h" -#include "ico_window_mgr.h" #include "ico_window_mgr_private.h" #include "ico_window_mgr-server-protocol.h" #include "ico_input_mgr-server-protocol.h" @@ -167,11 +165,6 @@ static void ico_mgr_add_input_app(struct wl_client *client, struct wl_resource * /* delete input event to application */ static void ico_mgr_del_input_app(struct wl_client *client, struct wl_resource *resource, const char *appid, const char *device, int32_t input); - /* send input event from manager */ -static void ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, - const char *target, uint32_t surfaceid, int32_t type, - int32_t deviceno, uint32_t time, - int32_t code, int32_t value); /* set input region */ static void ico_mgr_set_input_region(struct wl_client *client, struct wl_resource *resource, const char *target, int32_t x, int32_t y, @@ -209,8 +202,7 @@ static void ico_input_send_region_event(struct wl_array *array); /* Input Manager Control interface */ static const struct ico_input_mgr_control_interface ico_input_mgr_implementation = { ico_mgr_add_input_app, - ico_mgr_del_input_app, - ico_mgr_send_input_event + ico_mgr_del_input_app }; /* Extended Input interface */ @@ -249,7 +241,6 @@ ico_mgr_add_input_app(struct wl_client *client, struct wl_resource *resource, const char *appid, const char *device, int32_t input, int32_t fix, int32_t keycode) { - struct uifw_client *uclient; struct ico_ictl_mgr *pIctlMgr; struct ico_ictl_input *pInput; struct ico_app_mgr *pAppMgr; @@ -257,23 +248,6 @@ ico_mgr_add_input_app(struct wl_client *client, struct wl_resource *resource, uifw_trace("ico_mgr_add_input_app: Enter(appid=%s,dev=%s,input=%d,fix=%d,key=%d)", appid, device, input, fix, keycode); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_control_add_input_app: unknown client"); - uifw_trace("ico_mgr_add_input_app: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_INPUT_MGR_CONTROL_ADD_INPUT_APP) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_control_add_input_app: not permitted"); - uifw_trace("ico_mgr_add_input_app: Leave(%s not permitted)", uclient->appid); - return; - } - } pIctlMgr = find_ictlmgr_by_device(device); if (! pIctlMgr) { /* not configure input controller, create */ @@ -335,7 +309,6 @@ static void ico_mgr_del_input_app(struct wl_client *client, struct wl_resource *resource, const char *appid, const char *device, int32_t input) { - struct uifw_client *uclient; int alldev = 0; struct ico_ictl_mgr *pIctlMgr = NULL; struct ico_ictl_input *pInput = NULL; @@ -344,23 +317,6 @@ ico_mgr_del_input_app(struct wl_client *client, struct wl_resource *resource, uifw_trace("ico_mgr_del_input_app: Enter(appid=%s,dev=%s,input=%d)", appid ? appid : "(NULL)", device ? device : "(NULL)", input); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_control_del_input_app: unknown client"); - uifw_trace("ico_mgr_del_input_app: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_INPUT_MGR_CONTROL_DEL_INPUT_APP) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_control_del_input_app: not permitted"); - uifw_trace("ico_mgr_del_input_app: Leave(%s not permitted)", uclient->appid); - return; - } - } if ((device != NULL) && (*device != 0)) { pIctlMgr = find_ictlmgr_by_device(device); if (! pIctlMgr) { @@ -464,448 +420,6 @@ ico_mgr_del_input_app(struct wl_client *client, struct wl_resource *resource, /*--------------------------------------------------------------------------*/ /** - * @brief ico_mgr_send_input_event: send input event from manager - * - * @param[in] client client(HomeScreen) - * @param[in] resource resource of request - * @param[in] target target window name and application id - * @param[in] surfaceid target surface id - * @param[in] type event device type - * @param[in] deviceno device number - * @param[in] time event time (if 0, generate) - * @param[in] code event code - * @param[in] value event value - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, - const char *target, uint32_t surfaceid, int32_t type, - int32_t deviceno, uint32_t time, int32_t code, int32_t value) -{ - struct uifw_client *uclient; - struct uifw_win_surface *usurf; /* UIFW surface */ - struct uifw_input_device *dev; /* device control table */ - struct wl_resource *cres; /* event send client resource */ - struct wl_array dummy_array; /* dummy array for wayland API */ - uint32_t ctime; /* current time(ms) */ - uint32_t serial; /* event serial number */ - int event; /* event flag */ - wl_fixed_t fix_x; /* wayland X coordinate */ - wl_fixed_t fix_y; /* wayland Y coordinate */ - wl_fixed_t dx, dy; /* relative coordinate (dummy) */ - struct weston_view *grabsave; /* real grab surface view */ - int keyboard_active; /* keyborad active surface flag */ - -#if 0 /* too many log */ - uifw_debug("ico_mgr_send_input_event: Enter(target=%s surf=%x dev=%d.%d " - "time=%d code=%x value=%d)", - target ? target : "(NULL)", surfaceid, type, deviceno, - time, code, value); -#endif - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_control_send_input_event: unknown client"); - uifw_trace("ico_mgr_send_input_event: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_INPUT_MGR_CONTROL_ADD_INPUT_APP) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_control_send_input_event: not permitted"); - uifw_trace("ico_mgr_send_input_event: Leave(%s not permitted)", uclient->appid); - return; - } - } - /* search pseudo input device */ - wl_list_for_each (dev, &pInputMgr->dev_list, link) { - if ((dev->type == type) && (dev->no == deviceno)) break; - } - if (&dev->link == &pInputMgr->dev_list) { - /* device not exist, create new device */ - uifw_trace("ico_mgr_send_input_event: new device=%d no=%d", type, deviceno); - dev = malloc(sizeof(struct uifw_input_device)); - if (! dev) { - uifw_error("ico_mgr_send_input_event: Leave(No Memory)"); - return; - } - memset(dev, 0, sizeof(struct uifw_input_device)); - dev->type = type; - dev->no = deviceno; - if ((type == ICO_INPUT_MGR_DEVICE_TYPE_POINTER) || - (type == ICO_INPUT_MGR_DEVICE_TYPE_TOUCH) || - (type == ICO_INPUT_MGR_DEVICE_TYPE_HAPTIC)) { - ico_window_mgr_get_display_coordinate(deviceno, &dev->disp_x, &dev->disp_y); - } - wl_list_insert(pInputMgr->dev_list.prev, &dev->link); - } - - /* convert pending event */ - event = 0; - if ((code & 0xffff0000) != (EV_REL << 16)) { - code &= 0x0000ffff; - } - switch (type) { - case ICO_INPUT_MGR_DEVICE_TYPE_POINTER: /* mouse */ - case ICO_INPUT_MGR_DEVICE_TYPE_TOUCH: /* touch panel */ - case ICO_INPUT_MGR_DEVICE_TYPE_HAPTIC: /* haptic */ - switch (code) { - case ABS_X: - if (dev->pending & PENDING_Y) { - dev->x = value; - dev->y = dev->pend_y; - dev->pending = 0; - dev->pend_x = 0; - dev->pend_y = 0; - event = EVENT_MOTION; - } - else { - dev->pend_x = value; - dev->pending |= PENDING_X; - event = EVENT_PENDING; - } - break; - case ABS_Y: - if (dev->pending & PENDING_X) { - dev->x = dev->pend_x; - dev->y = value; - dev->pending = 0; - dev->pend_x = 0; - dev->pend_y = 0; - event = EVENT_MOTION; - } - else { - dev->pend_y = value; - dev->pending |= PENDING_Y; - event = EVENT_PENDING; - } - break; - case ABS_Z: - dev->x = (short)(value >> 16); - dev->y = (short)(value & 0x0ffff); - dev->pending = 0; - dev->pend_x = 0; - dev->pend_y = 0; - event = EVENT_MOTION; - break; - case ((EV_REL << 16) | REL_X): - if (dev->pending & PENDING_Y) { - dev->x += value; - dev->y = dev->pend_y; - dev->pending = 0; - dev->pend_x = 0; - dev->pend_y = 0; - event = EVENT_MOTION; - } - else { - dev->pend_x = dev->x + value; - dev->pending |= PENDING_X; - event = EVENT_PENDING; - } - break; - case ((EV_REL << 16) | REL_Y): - if (dev->pending & PENDING_X) { - dev->x = dev->pend_x; - dev->y += value; - dev->pending = 0; - dev->pend_x = 0; - dev->pend_y = 0; - event = EVENT_MOTION; - } - else { - dev->pend_x = dev->y + value; - dev->pending |= PENDING_Y; - event = EVENT_PENDING; - } - break; - case ((EV_REL << 16) | REL_Z): - dev->x += (short)(value >> 16); - dev->y += (short)(value & 0x0ffff); - dev->pending = 0; - dev->pend_x = 0; - dev->pend_y = 0; - event = EVENT_MOTION; - break; - default: - if (type == ICO_INPUT_MGR_DEVICE_TYPE_TOUCH) { - event = EVENT_TOUCH; - } - else { - event = EVENT_BUTTON; - } - break; - } - break; - default: - event = EVENT_KEY; - break; - } - - if (event == EVENT_PENDING) { -#if 0 /* too many log */ - uifw_debug("ico_mgr_send_input_event: Leave(event pending)"); -#endif - return; - } - - if (time) { - ctime = time; - } - else { - ctime = weston_compositor_get_time(); - } - fix_x = wl_fixed_from_int(dev->x + dev->disp_x); - fix_y = wl_fixed_from_int(dev->y + dev->disp_y); - - if ((surfaceid == 0) && ((target == NULL) || (*target == 0) || (*target == ' '))) { - /* send event to surface via weston */ - - /* disable the event transmission to a input layer */ - if (type == ICO_INPUT_MGR_DEVICE_TYPE_TOUCH) { - ico_window_mgr_touch_layer(TRUE); - } - - if ((event == EVENT_TOUCH) && (pInputMgr->seat->touch == NULL)) { - /* system has no touch, change to pointer event */ - if (pInputMgr->seat->pointer == NULL) { - uifw_trace("ico_mgr_send_input_event: Leave(no touch & no pointerr)"); - return; - } - event = EVENT_BUTTON; - code = BTN_LEFT; - } - else if ((event == EVENT_BUTTON) && (pInputMgr->seat->pointer == NULL)) { - /* system has no pointer, change to touch event */ - if (pInputMgr->seat->touch == NULL) { - uifw_trace("ico_mgr_send_input_event: Leave(no touch & no pointerr)"); - return; - } - event = EVENT_TOUCH; - } - - switch (event) { - case EVENT_MOTION: - if ((type == ICO_INPUT_MGR_DEVICE_TYPE_TOUCH) && - (pInputMgr->seat->touch)) { - if (pInputMgr->seat->touch->num_tp > 10) { - uifw_debug("ico_mgr_send_input_event: num=%d reset", - pInputMgr->seat->touch->num_tp); - pInputMgr->seat->touch->num_tp = 0; /* safty gard */ - } - grabsave = pInputMgr->seat->touch->focus; - uifw_debug("ico_mgr_send_input_event: MOTION(%d/%d) grab %08x org %08x", - fix_x/256, fix_y/256, (int)dev->grab, (int)grabsave); - if ((grabsave != dev->grab) && (dev->grab != NULL)) { - weston_touch_set_focus(pInputMgr->seat, dev->grab); - } - notify_touch(pInputMgr->seat, ctime, 0, fix_x, fix_y, WL_TOUCH_MOTION); - if ((grabsave != dev->grab) && (dev->grab != NULL)) { - weston_touch_set_focus(pInputMgr->seat, grabsave); - } - } - else if (pInputMgr->seat->pointer) { -#if 0 /* too many log */ - uifw_debug("ico_mgr_send_input_event: notify_motion_absolute(%d/%d)", - fix_x/256, fix_y/256); -#endif - notify_motion_absolute(pInputMgr->seat, ctime, fix_x, fix_y); - } - break; - case EVENT_BUTTON: - uifw_trace("ico_mgr_send_input_event: notify_button(%d,%d)", code, value); - if (pInputMgr->seat->pointer) { - if (value) { - dev->grab = weston_compositor_pick_view( - pInputMgr->compositor, fix_x, fix_y, &dx, &dy); - weston_pointer_set_focus(pInputMgr->seat->pointer, dev->grab, dx, dy); - ico_window_mgr_active_surface(dev->grab->surface); - } - else { - dev->grab = NULL; - } - notify_button(pInputMgr->seat, ctime, code, - value ? WL_POINTER_BUTTON_STATE_PRESSED : - WL_POINTER_BUTTON_STATE_RELEASED); - } - break; - case EVENT_TOUCH: - if (value == ICO_INPUT_MGR_CONTROL_TOUCH_EVENT_RESET) { - /* reset touch focus */ - grabsave = pInputMgr->seat->touch->focus; - uifw_trace("ico_mgr_send_input_event: notify_touch(UnGrab dev=%08x sys=%08x)", - (int)dev->grab, (int)grabsave); - dev->grab = NULL; - if (grabsave) { - weston_touch_set_focus(pInputMgr->seat, NULL); - if (pInputMgr->seat->touch->num_tp > 0) { - uifw_debug("ico_mgr_send_input_event: num=%d reset for reset focuse", - pInputMgr->seat->touch->num_tp); - pInputMgr->seat->touch->num_tp = 0; - } - } - } - else if (value == ICO_INPUT_MGR_CONTROL_TOUCH_EVENT_DOWN) { - grabsave = pInputMgr->seat->touch->focus; - dev->grab = weston_compositor_pick_view( - pInputMgr->compositor, fix_x, fix_y, &dx, &dy); - uifw_trace("ico_mgr_send_input_event: notify_touch(DOWN=%d/%d) " - "grab=%08x org=%08x", fix_x/256, fix_y/256, - (int)dev->grab, (int)grabsave); - if (grabsave != dev->grab) { - weston_touch_set_focus(pInputMgr->seat, dev->grab); - } - if (pInputMgr->seat->touch->num_tp > 0) { - uifw_debug("ico_mgr_send_input_event: touch_down illegal num, modify"); - weston_touch_set_focus(pInputMgr->seat, NULL); - pInputMgr->seat->touch->num_tp = 0; - } - notify_touch(pInputMgr->seat, ctime, 0, fix_x, fix_y, WL_TOUCH_DOWN); - ico_window_mgr_active_surface(dev->grab->surface); - } - else { - grabsave = pInputMgr->seat->touch->focus; - uifw_trace("ico_mgr_send_input_event: notify_touch(UP) org=%08x", - (int)grabsave); - if ((grabsave != dev->grab) && (dev->grab != NULL)) { - weston_touch_set_focus(pInputMgr->seat, dev->grab); - } - if ((pInputMgr->seat->touch->num_tp == 0) || - (pInputMgr->seat->touch->num_tp > 10)) { - uifw_debug("ico_mgr_send_input_event: num=%d reset", - pInputMgr->seat->touch->num_tp); - pInputMgr->seat->touch->num_tp = 1; - } - notify_touch(pInputMgr->seat, ctime, 0, 0, 0, WL_TOUCH_UP); - if (grabsave == dev->grab) grabsave = NULL; - weston_touch_set_focus(pInputMgr->seat, grabsave); - dev->grab = NULL; - } - break; - case EVENT_KEY: - uifw_trace("ico_mgr_send_input_event: notify_key(%d,%d)", code, value); - notify_key(pInputMgr->seat, ctime, code, - value ? WL_KEYBOARD_KEY_STATE_PRESSED : - WL_KEYBOARD_KEY_STATE_RELEASED, STATE_UPDATE_NONE); - break; - default: - uifw_trace("ico_mgr_send_input_event: unknown event=%d", event); - break; - } - /* enable the event transmission to a input layer */ - if (type == ICO_INPUT_MGR_DEVICE_TYPE_TOUCH) { - ico_window_mgr_touch_layer(FALSE); - } - } - else { - if ((target != NULL) && (*target != 0) && (*target != ' ')) { - /* send event to fixed application */ - - /* get application surface */ - usurf = ico_window_mgr_get_client_usurf(target); - if (! usurf) { - uifw_trace("ico_mgr_send_input_event: Leave(window=%s dose not exist)", - target); - return; - } - } - else { - /* get UIFW surface */ - usurf = ico_window_mgr_get_usurf(surfaceid); - if (! usurf) { - uifw_trace("ico_mgr_send_input_event: Leave(surface dose not exist)"); - return; - } - } - - /* send event */ - switch (event) { - case EVENT_MOTION: - if (type == ICO_INPUT_MGR_DEVICE_TYPE_TOUCH) { - cres = wl_resource_find_for_client( - &pInputMgr->seat->touch->resource_list, - wl_resource_get_client(usurf->surface->resource)); - if (cres) { - wl_touch_send_motion(cres, ctime, 0, fix_x, fix_y); - } - } - else { - cres = wl_resource_find_for_client( - &pInputMgr->seat->pointer->resource_list, - wl_resource_get_client(usurf->surface->resource)); - if (cres) { - wl_pointer_send_motion(cres, ctime, fix_x, fix_y); - } - } - break; - case EVENT_BUTTON: - cres = wl_resource_find_for_client( - &pInputMgr->seat->pointer->resource_list, - wl_resource_get_client(usurf->surface->resource)); - if (cres) { - serial = wl_display_next_serial(pInputMgr->compositor->wl_display); - wl_pointer_send_button(cres, serial, ctime, code, - value ? WL_POINTER_BUTTON_STATE_PRESSED : - WL_POINTER_BUTTON_STATE_RELEASED); - } - break; - case EVENT_TOUCH: - cres = wl_resource_find_for_client( - &pInputMgr->seat->touch->resource_list, - wl_resource_get_client(usurf->surface->resource)); - if (cres) { - serial = wl_display_next_serial(pInputMgr->compositor->wl_display); - if (value) { - wl_touch_send_down(cres, serial, ctime, usurf->surface->resource, 0, - fix_x, fix_y); - } - else { - wl_touch_send_up(cres, serial, ctime, 0); - } - } - break; - case EVENT_KEY: - cres = wl_resource_find_for_client( - &pInputMgr->seat->keyboard->resource_list, - wl_resource_get_client(usurf->surface->resource)); - if (cres) { - keyboard_active = ico_window_mgr_ismykeyboard(usurf); - if (! keyboard_active) { - wl_array_init(&dummy_array); - serial = wl_display_next_serial(pInputMgr->compositor->wl_display); - wl_keyboard_send_enter(cres, serial, - usurf->surface->resource, &dummy_array); - } - serial = wl_display_next_serial(pInputMgr->compositor->wl_display); - uifw_trace("ico_mgr_send_input_event: send Key (%d, %d) to %08x", - code, value, usurf->surfaceid); - wl_keyboard_send_key(cres, serial, ctime, code, - value ? WL_KEYBOARD_KEY_STATE_PRESSED : - WL_KEYBOARD_KEY_STATE_RELEASED); - if (! keyboard_active) { - serial = wl_display_next_serial(pInputMgr->compositor->wl_display); - wl_keyboard_send_leave(cres, serial, usurf->surface->resource); - } - } - else { - uifw_trace("ico_mgr_send_input_event: Key client %08x dose not exist", - (int)usurf->surface->resource); - } - break; - default: - break; - } - } -#if 0 /* too many log */ - uifw_debug("ico_mgr_send_input_event: Leave"); -#endif -} - -/*--------------------------------------------------------------------------*/ -/** * @brief ico_mgr_set_input_region: set input region for haptic devcie * * @param[in] client client(Device Input Controller) @@ -932,30 +446,12 @@ ico_mgr_set_input_region(struct wl_client *client, struct wl_resource *resource, int32_t hotspot_y, int32_t cursor_x, int32_t cursor_y, int32_t cursor_width, int32_t cursor_height, uint32_t attr) { - struct uifw_client *uclient; struct uifw_win_surface *usurf; /* UIFW surface */ uifw_trace("ico_mgr_set_input_region: Enter(%s %d/%d-%d/%d(%d/%d) %d/%d-%d/%d)", target, x, y, width, height, hotspot_x, hotspot_y, cursor_x, cursor_y, cursor_width, cursor_height); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_exapi_input_set_input_region: unknown client"); - uifw_trace("ico_mgr_set_input_region: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_EXINPUT_SET_INPUT_REGION) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_exapi_input_set_input_region: not permitted"); - uifw_trace("ico_mgr_set_input_region: Leave(%s not permitted)", uclient->appid); - return; - } - } /* get target surface */ usurf = ico_window_mgr_get_client_usurf(target); if (! usurf) { @@ -988,29 +484,11 @@ ico_mgr_unset_input_region(struct wl_client *client, struct wl_resource *resourc const char *target, int32_t x, int32_t y, int32_t width, int32_t height) { - struct uifw_client *uclient; struct uifw_win_surface *usurf; /* UIFW surface */ uifw_trace("ico_mgr_unset_input_region: Enter(%s %d/%d-%d/%d)", target, x, y, width, height); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_exapi_input_unset_input_region: unknown client"); - uifw_trace("ico_mgr_unset_input_region: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_EXINPUT_UNSET_INPUT_REGION) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_exapi_input_unset_input_region: not permitted"); - uifw_trace("ico_mgr_unset_input_region: Leave(%s not permitted)", uclient->appid); - return; - } - } /* get target surface */ usurf = ico_window_mgr_get_client_usurf(target); if (! usurf) { @@ -1040,13 +518,12 @@ ico_input_hook_region_change(struct uifw_win_surface *usurf) int chgcount = 0; int visible; - visible = ico_window_mgr_is_visible(usurf); - - uifw_trace("ico_input_hook_region_change: Entery(surf=%08x, visible=%d)", - usurf->surfaceid, visible); + uifw_trace("ico_input_hook_region_change: Entery(surf=%08x)", usurf->surfaceid); wl_array_init(&array); + visible = /* get visiblety form weston_layout */ 0; + wl_list_for_each(p, &usurf->input_region, link) { if (((p->region.change > 0) && (visible <= 0)) || ((p->region.change <= 0) && (visible > 0))) { @@ -1214,7 +691,7 @@ ico_set_input_region(int set, struct uifw_win_surface *usurf, p->region.cursor_width = cursor_width; p->region.cursor_height = cursor_height; } - p->region.change = ico_window_mgr_is_visible(usurf); + p->region.change = /* get form weston_layout */ 1; wl_list_insert(usurf->input_region.prev, &p->link); /* send input region to haptic device input controller */ @@ -1314,7 +791,6 @@ ico_device_configure_input(struct wl_client *client, struct wl_resource *resourc const char *device, int32_t type, const char *swname, int32_t input, const char *codename, int32_t code) { - struct uifw_client *uclient; struct ico_ictl_mgr *pIctlMgr; struct ico_ictl_mgr *psameIctlMgr; struct ico_ictl_input *pInput; @@ -1324,23 +800,6 @@ ico_device_configure_input(struct wl_client *client, struct wl_resource *resourc "input=%d,code=%d[%s])", (int)client, device, type, swname ? swname : "(NULL)", input, code, codename ? codename : " "); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_device_configure_input: unknown client"); - uifw_trace("ico_device_configure_input: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_INPUT) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_device_configure_input: not permitted"); - uifw_trace("ico_device_configure_input: Leave(%s not permitted)", uclient->appid); - return; - } - } pIctlMgr = find_ictlmgr_by_device(device); if (! pIctlMgr) { /* search binded table */ @@ -1453,7 +912,6 @@ ico_device_configure_code(struct wl_client *client, struct wl_resource *resource const char *device, int32_t input, const char *codename, int32_t code) { - struct uifw_client *uclient; int i; struct ico_ictl_mgr *pIctlMgr; struct ico_ictl_input *pInput; @@ -1462,23 +920,6 @@ ico_device_configure_code(struct wl_client *client, struct wl_resource *resource uifw_trace("ico_device_configure_code: Enter(client=%08x,dev=%s,input=%d,code=%d[%s])", (int)client, device, input, code, codename ? codename : " "); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_device_configure_code: unknown client"); - uifw_trace("ico_device_configure_code: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_CODE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_device_configure_code: not permitted"); - uifw_trace("ico_device_configure_code: Leave(%s not permitted)", uclient->appid); - return; - } - } pIctlMgr = find_ictlmgr_by_device(device); if (! pIctlMgr) { uifw_warn("ico_device_configure_code: Leave(dev=%s dose not exist)", device); @@ -1543,30 +984,12 @@ ico_device_input_event(struct wl_client *client, struct wl_resource *resource, uint32_t time, const char *device, int32_t input, int32_t code, int32_t state) { - struct uifw_client *uclient; struct ico_ictl_mgr *pIctlMgr; struct ico_ictl_input *pInput; uifw_trace("ico_device_input_event: Enter(time=%d,dev=%s,input=%d,code=%d,state=%d)", time, device, input, code, state); - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_device_input_event: unknown client"); - uifw_trace("ico_device_input_event: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_INPUT_MGR_DEVICE_INPUT_EVENT) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_input_mgr_device_input_event: not permitted"); - uifw_trace("ico_device_input_event: Leave(%s not permitted)", uclient->appid); - return; - } - } /* find input devcie by client */ pIctlMgr = find_ictlmgr_by_device(device); if (! pIctlMgr) { diff --git a/src/ico_input_mgr.h b/src/ico_input_mgr.h index 095128f..a4c332e 100644 --- a/src/ico_input_mgr.h +++ b/src/ico_input_mgr.h @@ -22,7 +22,7 @@ /** * @brief Multi Input Manager header for Device Input Controller * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #ifndef _ICO_INPUT_MGR_H_ diff --git a/src/ico_ivi_common_private.h b/src/ico_ivi_common_private.h index bf95e02..497f0c2 100644 --- a/src/ico_ivi_common_private.h +++ b/src/ico_ivi_common_private.h @@ -24,7 +24,7 @@ /** * @brief The common functions that each Plugin is available. * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #ifndef _ICO_IVI_COMMON_PRIVATE_H_ @@ -48,6 +48,7 @@ #define ICO_IVI_APPID_LENGTH (80) /* Maximum length of applicationId(AppCore) */ /* (with terminate NULL) */ #define ICO_IVI_WINNAME_LENGTH (40) /* Maximum length of window name (with NULL)*/ +#define ICO_IVI_FILEPATH_LENGTH (80) /* Maximum length of file path (with NULL)*/ #define ICO_IVI_ANIMATION_LENGTH (16) /* Maximum length of animation name (w NULL)*/ #define ICO_IVI_MAX_COORDINATE (16383) /* Maximum X or Y coordinate */ diff --git a/src/ico_ivi_shell.c b/src/ico_ivi_shell.c deleted file mode 100644 index e794554..0000000 --- a/src/ico_ivi_shell.c +++ /dev/null @@ -1,6204 +0,0 @@ -/* - * Copyright © 2010-2012 Intel Corporation - * Copyright © 2011-2012 Collabora, Ltd. - * Copyright © 2013 Raspberry Pi Foundation - * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION. - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ico_ivi_shell.h" -#include "ico_ivi_shell_private.h" -#include "desktop-shell-server-protocol.h" -#include "workspaces-server-protocol.h" -#include -#include "xdg-shell-server-protocol.h" - -#ifndef WESTON_SHELL_CLIENT -#define WESTON_SHELL_CLIENT "weston-desktop-shell" -#endif -#define DEFAULT_NUM_WORKSPACES 1 -#define DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH 200 - -#ifndef static_assert -#define static_assert(cond, msg) -#endif - -struct focus_state { - struct weston_seat *seat; - struct workspace *ws; - struct weston_surface *keyboard_focus; - struct wl_list link; - struct wl_listener seat_destroy_listener; - struct wl_listener surface_destroy_listener; -}; - -struct shell_output { - struct desktop_shell *shell; - struct weston_output *output; - struct wl_listener destroy_listener; - struct wl_list link; -}; - -#if 0 /* move to ico_ivi_shell_private.h */ -enum shell_surface_type { - SHELL_SURFACE_NONE, - SHELL_SURFACE_TOPLEVEL, - SHELL_SURFACE_POPUP, - SHELL_SURFACE_XWAYLAND -}; -#endif - -struct ping_timer { - struct wl_event_source *source; - uint32_t serial; -}; - -/* - * Surface stacking and ordering. - * - * This is handled using several linked lists of surfaces, organised into - * ‘layers’. The layers are ordered, and each of the surfaces in one layer are - * above all of the surfaces in the layer below. The set of layers is static and - * in the following order (top-most first): - * • Lock layer (only ever displayed on its own) - * • Cursor layer - * • Fullscreen layer - * • Panel layer - * • Input panel layer - * • Workspace layers - * • Background layer - * - * The list of layers may be manipulated to remove whole layers of surfaces from - * display. For example, when locking the screen, all layers except the lock - * layer are removed. - * - * A surface’s layer is modified on configuring the surface, in - * set_surface_type() (which is only called when the surface’s type change is - * _committed_). If a surface’s type changes (e.g. when making a window - * fullscreen) its layer changes too. - * - * In order to allow popup and transient surfaces to be correctly stacked above - * their parent surfaces, each surface tracks both its parent surface, and a - * linked list of its children. When a surface’s layer is updated, so are the - * layers of its children. Note that child surfaces are *not* the same as - * subsurfaces — child/parent surfaces are purely for maintaining stacking - * order. - * - * The children_link list of siblings of a surface (i.e. those surfaces which - * have the same parent) only contains weston_surfaces which have a - * shell_surface. Stacking is not implemented for non-shell_surface - * weston_surfaces. This means that the following implication does *not* hold: - * (shsurf->parent != NULL) ⇒ !wl_list_is_empty(shsurf->children_link) - */ - -struct shell_surface { - struct wl_resource *resource; - struct wl_signal destroy_signal; - - struct weston_surface *surface; - struct weston_view *view; - int32_t last_width, last_height; - struct wl_listener surface_destroy_listener; - struct weston_surface *parent; - struct wl_list children_list; /* child surfaces of this one */ - struct wl_list children_link; /* sibling surfaces of this one */ - struct desktop_shell *shell; - - enum shell_surface_type type; - char *title, *class; - int32_t saved_x, saved_y; - int32_t saved_width, saved_height; - bool saved_position_valid; - bool saved_size_valid; - bool saved_rotation_valid; - char layertype; /* surface layer type for ico_window_mgr */ - int unresponsive, grabbed; - - struct { - struct weston_transform transform; - struct weston_matrix rotation; - } rotation; - - struct { - struct wl_list grab_link; - int32_t x, y; - struct shell_seat *shseat; - uint32_t serial; - } popup; - - struct { - int32_t x, y; - uint32_t flags; - } transient; - - struct { - enum wl_shell_surface_fullscreen_method type; - struct weston_transform transform; /* matrix from x, y */ - uint32_t framerate; - struct weston_view *black_view; - } fullscreen; - - struct ping_timer *ping_timer; - - struct weston_transform workspace_transform; - - struct weston_output *fullscreen_output; - struct weston_output *output; - struct weston_output *recommended_output; - struct wl_list link; - - const struct weston_shell_client *client; - - struct { - bool maximized; - bool fullscreen; - bool relative; - } state, next_state; /* surface states */ - bool state_changed; -}; - -struct shell_grab { - struct weston_pointer_grab grab; - struct shell_surface *shsurf; - struct wl_listener shsurf_destroy_listener; -}; - -struct shell_touch_grab { - struct weston_touch_grab grab; - struct shell_surface *shsurf; - struct wl_listener shsurf_destroy_listener; - struct weston_touch *touch; -}; - -struct weston_move_grab { - struct shell_grab base; - wl_fixed_t dx, dy; -}; - -struct weston_touch_move_grab { - struct shell_touch_grab base; - int active; - wl_fixed_t dx, dy; -}; - -struct rotate_grab { - struct shell_grab base; - struct weston_matrix rotation; - struct { - float x; - float y; - } center; -}; - -struct shell_seat { - struct weston_seat *seat; - struct wl_listener seat_destroy_listener; - - struct { - struct weston_pointer_grab grab; - struct wl_list surfaces_list; - struct wl_client *client; - int32_t initial_up; - } popup_grab; -}; - -void -set_alpha_if_fullscreen(struct shell_surface *shsurf) -{ - if (shsurf && shsurf->state.fullscreen) - shsurf->fullscreen.black_view->alpha = 0.25; -} - -static struct desktop_shell * -shell_surface_get_shell(struct shell_surface *shsurf); - -static void -surface_rotate(struct shell_surface *surface, struct weston_seat *seat); - -static void -shell_fade_startup(struct desktop_shell *shell); - -static struct shell_seat * -get_shell_seat(struct weston_seat *seat); - -static void -shell_surface_update_child_surface_layers(struct shell_surface *shsurf); - -static bool -shell_surface_is_wl_shell_surface(struct shell_surface *shsurf); - -static bool -shell_surface_is_xdg_surface(struct shell_surface *shsurf); - -static bool -shell_surface_is_xdg_popup(struct shell_surface *shsurf); - -static void -shell_surface_set_parent(struct shell_surface *shsurf, - struct weston_surface *parent); - -/* shell management table */ -static struct desktop_shell *_ico_ivi_shell = NULL; - -/* shell program path for ico-ivi */ -#define DEFAULT_DEBUG_LEVEL 4 -int ico_debug_level = DEFAULT_DEBUG_LEVEL; /* Debug Level */ - -/* default display */ -static struct weston_output *default_inputpanel = NULL; - -/* debug log macros */ -#define uifw_debug(fmt,...) \ - { if (ico_debug_level >= 5) {weston_log("DBG>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_trace(fmt,...) \ - { if (ico_debug_level >= 4) {weston_log("TRC>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_info(fmt,...) \ - { if (ico_debug_level >= 3) {weston_log("INF>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_warn(fmt,...) \ - { if (ico_debug_level >= 2) {weston_log("WRN>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#define uifw_error(fmt,...) \ - { if (ico_debug_level >= 1) {weston_log("ERR>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } - -/* hook functions */ -WL_EXPORT void (*shell_hook_bind)(struct wl_client *client, void *shell) = NULL; -WL_EXPORT void (*shell_hook_unbind)(struct wl_client *client) = NULL; -WL_EXPORT void (*shell_hook_create)(int layertype, struct weston_surface *surface, - struct wl_client *client, - struct shell_surface *shsurf) = NULL; -WL_EXPORT void (*shell_hook_destroy)(struct weston_surface *surface) = NULL; -WL_EXPORT void (*shell_hook_map)(struct weston_surface *surface, int32_t *width, - int32_t *height, int32_t *sx, int32_t *sy) = NULL; -WL_EXPORT void (*shell_hook_configure)(struct weston_surface *surface) = NULL; -WL_EXPORT void (*shell_hook_select)(struct weston_surface *surface) = NULL; -WL_EXPORT char *(*shell_hook_title)(struct weston_surface *surface, - const char *title) = NULL; -WL_EXPORT void (*shell_hook_move)(struct weston_surface *surface, int *dx, int *dy) = NULL; -WL_EXPORT void (*shell_hook_show_layer)(int layertype, int show, void *data) = NULL; -WL_EXPORT int (*shell_hook_fullscreen)(int event, struct weston_surface *surface) = NULL; - -static bool -shell_surface_is_top_fullscreen(struct shell_surface *shsurf) -{ - struct desktop_shell *shell; - struct weston_view *top_fs_ev; - - if (shell_hook_fullscreen) { - return (*shell_hook_fullscreen)(SHELL_FULLSCREEN_ISTOP, shsurf->surface); - } - - shell = shell_surface_get_shell(shsurf); - - if (wl_list_empty(&shell->fullscreen_layer.view_list)) - return false; - - top_fs_ev = container_of(shell->fullscreen_layer.view_list.next, - struct weston_view, - layer_link); - return (shsurf == get_shell_surface(top_fs_ev->surface)); -} - -static void -destroy_shell_grab_shsurf(struct wl_listener *listener, void *data) -{ - struct shell_grab *grab; - - grab = container_of(listener, struct shell_grab, - shsurf_destroy_listener); - - grab->shsurf = NULL; -} - -struct weston_view * -get_default_view(struct weston_surface *surface) -{ - struct shell_surface *shsurf; - struct weston_view *view; - - if (!surface || wl_list_empty(&surface->views)) - return NULL; - - shsurf = get_shell_surface(surface); - if (shsurf) - return shsurf->view; - - wl_list_for_each(view, &surface->views, surface_link) - if (weston_view_is_mapped(view)) - return view; - - return container_of(surface->views.next, struct weston_view, surface_link); -} - -static void -popup_grab_end(struct weston_pointer *pointer); - -static void -shell_grab_start(struct shell_grab *grab, - const struct weston_pointer_grab_interface *interface, - struct shell_surface *shsurf, - struct weston_pointer *pointer, - enum desktop_shell_cursor cursor) -{ - struct desktop_shell *shell = shsurf->shell; - - /* if ico_window_mgr hook, not change grab */ - if (shell_hook_select) { - return; - } - - popup_grab_end(pointer); - - grab->grab.interface = interface; - grab->shsurf = shsurf; - grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf; - wl_signal_add(&shsurf->destroy_signal, - &grab->shsurf_destroy_listener); - - shsurf->grabbed = 1; - weston_pointer_start_grab(pointer, &grab->grab); - if (shell->child.desktop_shell) { - desktop_shell_send_grab_cursor(shell->child.desktop_shell, - cursor); - weston_pointer_set_focus(pointer, - get_default_view(shell->grab_surface), - wl_fixed_from_int(0), - wl_fixed_from_int(0)); - } -} - -static void -shell_grab_end(struct shell_grab *grab) -{ - if (grab->shsurf) { - wl_list_remove(&grab->shsurf_destroy_listener.link); - grab->shsurf->grabbed = 0; - } - - weston_pointer_end_grab(grab->grab.pointer); -} - -static void -shell_touch_grab_start(struct shell_touch_grab *grab, - const struct weston_touch_grab_interface *interface, - struct shell_surface *shsurf, - struct weston_touch *touch) -{ - struct desktop_shell *shell = shsurf->shell; - - grab->grab.interface = interface; - grab->shsurf = shsurf; - grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf; - wl_signal_add(&shsurf->destroy_signal, - &grab->shsurf_destroy_listener); - - grab->touch = touch; - shsurf->grabbed = 1; - - weston_touch_start_grab(touch, &grab->grab); - if (shell->child.desktop_shell) - weston_touch_set_focus(touch->seat, - get_default_view(shell->grab_surface)); -} - -static void -shell_touch_grab_end(struct shell_touch_grab *grab) -{ - if (grab->shsurf) { - wl_list_remove(&grab->shsurf_destroy_listener.link); - grab->shsurf->grabbed = 0; - } - - weston_touch_end_grab(grab->touch); -} - -static void -center_on_output(struct weston_view *view, - struct weston_output *output); - -static enum weston_keyboard_modifier -get_modifier(char *modifier) -{ - if (!modifier) - return MODIFIER_SUPER; - - if (!strcmp("ctrl", modifier)) - return MODIFIER_CTRL; - else if (!strcmp("alt", modifier)) - return MODIFIER_ALT; - else if (!strcmp("super", modifier)) - return MODIFIER_SUPER; - else - return MODIFIER_SUPER; -} - -static enum animation_type -get_animation_type(char *animation) -{ - if (!animation) - return ANIMATION_NONE; - - if (!strcmp("zoom", animation)) - return ANIMATION_ZOOM; - else if (!strcmp("fade", animation)) - return ANIMATION_FADE; - else if (!strcmp("dim-layer", animation)) - return ANIMATION_DIM_LAYER; - else - return ANIMATION_NONE; -} - -static void -shell_configuration(struct desktop_shell *shell) -{ - struct weston_config_section *section; - int duration; - char *s; - - section = weston_config_get_section(shell->compositor->config, - "screensaver", NULL, NULL); - weston_config_section_get_string(section, - "path", &shell->screensaver.path, NULL); - weston_config_section_get_int(section, "duration", &duration, 60); - shell->screensaver.duration = duration * 1000; - - section = weston_config_get_section(shell->compositor->config, - "shell", NULL, NULL); - weston_config_section_get_string(section, - "client", &s, LIBEXECDIR "/" WESTON_SHELL_CLIENT); - shell->client = s; - weston_config_section_get_string(section, - "binding-modifier", &s, "super"); - shell->binding_modifier = get_modifier(s); - free(s); - - weston_config_section_get_string(section, - "exposay-modifier", &s, "none"); - if (strcmp(s, "none") == 0) - shell->exposay_modifier = 0; - else - shell->exposay_modifier = get_modifier(s); - free(s); - - weston_config_section_get_string(section, "animation", &s, "none"); - shell->win_animation_type = get_animation_type(s); - free(s); - weston_config_section_get_string(section, - "startup-animation", &s, "fade"); - shell->startup_animation_type = get_animation_type(s); - free(s); - if (shell->startup_animation_type == ANIMATION_ZOOM) - shell->startup_animation_type = ANIMATION_NONE; - weston_config_section_get_string(section, "focus-animation", &s, "none"); - shell->focus_animation_type = get_animation_type(s); - free(s); - weston_config_section_get_uint(section, "num-workspaces", - &shell->workspaces.num, - DEFAULT_NUM_WORKSPACES); - - weston_log("workspaces=%d manager client=<%s>\n", shell->workspaces.num, - shell->client ? shell->client : "NULL"); - - /* get debug level for ivi debug */ - section = weston_config_get_section(shell->compositor->config, "ivi-option", NULL, NULL); - if (section) { - weston_config_section_get_int(section, "log", - &ico_debug_level, DEFAULT_DEBUG_LEVEL); - ico_debug_level &= 0x0ffff; - } -} - -struct weston_output * -get_default_output(struct weston_compositor *compositor) -{ - /* support multi display, default fullscreen output display */ - if (default_inputpanel) { - return default_inputpanel; - } - return container_of(compositor->output_list.next, - struct weston_output, link); -} - - -/* no-op func for checking focus surface */ -static void -focus_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy) -{ -} - -static struct focus_surface * -get_focus_surface(struct weston_surface *surface) -{ - if (surface->configure == focus_surface_configure) - return surface->configure_private; - else - return NULL; -} - -static bool -is_focus_surface (struct weston_surface *es) -{ - return (es->configure == focus_surface_configure); -} - -static bool -is_focus_view (struct weston_view *view) -{ - return is_focus_surface (view->surface); -} - -static struct focus_surface * -create_focus_surface(struct weston_compositor *ec, - struct weston_output *output) -{ - struct focus_surface *fsurf = NULL; - struct weston_surface *surface = NULL; - - fsurf = malloc(sizeof *fsurf); - if (!fsurf) - return NULL; - - fsurf->surface = weston_surface_create(ec); - surface = fsurf->surface; - if (surface == NULL) { - free(fsurf); - return NULL; - } - - surface->configure = focus_surface_configure; - surface->output = output; - surface->configure_private = fsurf; - - fsurf->view = weston_view_create(surface); - if (fsurf->view == NULL) { - weston_surface_destroy(surface); - free(fsurf); - return NULL; - } - fsurf->view->output = output; - - weston_surface_set_size(surface, output->width, output->height); - weston_view_set_position(fsurf->view, output->x, output->y); - weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0); - pixman_region32_fini(&surface->opaque); - pixman_region32_init_rect(&surface->opaque, output->x, output->y, - output->width, output->height); - pixman_region32_fini(&surface->input); - pixman_region32_init(&surface->input); - - wl_list_init(&fsurf->workspace_transform.link); - - return fsurf; -} - -static void -focus_surface_destroy(struct focus_surface *fsurf) -{ - weston_surface_destroy(fsurf->surface); - free(fsurf); -} - -static void -focus_animation_done(struct weston_view_animation *animation, void *data) -{ - struct workspace *ws = data; - - ws->focus_animation = NULL; -} - -static void -focus_state_destroy(struct focus_state *state) -{ - wl_list_remove(&state->seat_destroy_listener.link); - wl_list_remove(&state->surface_destroy_listener.link); - free(state); -} - -static void -focus_state_seat_destroy(struct wl_listener *listener, void *data) -{ - struct focus_state *state = container_of(listener, - struct focus_state, - seat_destroy_listener); - - wl_list_remove(&state->link); - focus_state_destroy(state); -} - -static void -focus_state_surface_destroy(struct wl_listener *listener, void *data) -{ - struct focus_state *state = container_of(listener, - struct focus_state, - surface_destroy_listener); - struct desktop_shell *shell; - struct weston_surface *main_surface, *next; - struct weston_view *view; - - main_surface = weston_surface_get_main_surface(state->keyboard_focus); - - next = NULL; - wl_list_for_each(view, &state->ws->layer.view_list, layer_link) { - if (view->surface == main_surface) - continue; - if (is_focus_view(view)) - continue; - - next = view->surface; - break; - } - - /* if the focus was a sub-surface, activate its main surface */ - if (main_surface != state->keyboard_focus) - next = main_surface; - - shell = state->seat->compositor->shell_interface.shell; - if (next) { - state->keyboard_focus = NULL; - activate(shell, next, state->seat); - } else { - if (shell->focus_animation_type == ANIMATION_DIM_LAYER) { - if (state->ws->focus_animation) - weston_view_animation_destroy(state->ws->focus_animation); - - state->ws->focus_animation = weston_fade_run( - state->ws->fsurf_front->view, - state->ws->fsurf_front->view->alpha, 0.0, 300, - focus_animation_done, state->ws); - } - - wl_list_remove(&state->link); - focus_state_destroy(state); - } -} - -static struct focus_state * -focus_state_create(struct weston_seat *seat, struct workspace *ws) -{ - struct focus_state *state; - - state = malloc(sizeof *state); - if (state == NULL) - return NULL; - - state->keyboard_focus = NULL; - state->ws = ws; - state->seat = seat; - wl_list_insert(&ws->focus_list, &state->link); - - state->seat_destroy_listener.notify = focus_state_seat_destroy; - state->surface_destroy_listener.notify = focus_state_surface_destroy; - wl_signal_add(&seat->destroy_signal, - &state->seat_destroy_listener); - wl_list_init(&state->surface_destroy_listener.link); - - return state; -} - -static struct focus_state * -ensure_focus_state(struct desktop_shell *shell, struct weston_seat *seat) -{ - struct workspace *ws = get_current_workspace(shell); - struct focus_state *state; - - wl_list_for_each(state, &ws->focus_list, link) - if (state->seat == seat) - break; - - if (&state->link == &ws->focus_list) - state = focus_state_create(seat, ws); - - return state; -} - -static void -focus_state_set_focus(struct focus_state *state, - struct weston_surface *surface) -{ - if (state->keyboard_focus) { - wl_list_remove(&state->surface_destroy_listener.link); - wl_list_init(&state->surface_destroy_listener.link); - } - - state->keyboard_focus = surface; - if (surface) - wl_signal_add(&surface->destroy_signal, - &state->surface_destroy_listener); -} - -static void -restore_focus_state(struct desktop_shell *shell, struct workspace *ws) -{ - struct focus_state *state, *next; - struct weston_surface *surface; - - wl_list_for_each_safe(state, next, &ws->focus_list, link) { - if (state->seat->keyboard == NULL) - continue; - - surface = state->keyboard_focus; - - weston_keyboard_set_focus(state->seat->keyboard, surface); - } -} - -static void -replace_focus_state(struct desktop_shell *shell, struct workspace *ws, - struct weston_seat *seat) -{ - struct focus_state *state; - - wl_list_for_each(state, &ws->focus_list, link) { - if (state->seat == seat) { - focus_state_set_focus(state, seat->keyboard->focus); - return; - } - } -} - -static void -drop_focus_state(struct desktop_shell *shell, struct workspace *ws, - struct weston_surface *surface) -{ - struct focus_state *state; - - wl_list_for_each(state, &ws->focus_list, link) - if (state->keyboard_focus == surface) - focus_state_set_focus(state, NULL); -} - -static void -animate_focus_change(struct desktop_shell *shell, struct workspace *ws, - struct weston_view *from, struct weston_view *to) -{ - struct weston_output *output; - bool focus_surface_created = false; - - /* FIXME: Only support dim animation using two layers */ - if (from == to || shell->focus_animation_type != ANIMATION_DIM_LAYER) - return; - - output = get_default_output(shell->compositor); - if (ws->fsurf_front == NULL && (from || to)) { - ws->fsurf_front = create_focus_surface(shell->compositor, output); - if (ws->fsurf_front == NULL) - return; - ws->fsurf_front->view->alpha = 0.0; - - ws->fsurf_back = create_focus_surface(shell->compositor, output); - if (ws->fsurf_back == NULL) { - focus_surface_destroy(ws->fsurf_front); - return; - } - ws->fsurf_back->view->alpha = 0.0; - - focus_surface_created = true; - } else { - wl_list_remove(&ws->fsurf_front->view->layer_link); - wl_list_remove(&ws->fsurf_back->view->layer_link); - } - - if (ws->focus_animation) { - weston_view_animation_destroy(ws->focus_animation); - ws->focus_animation = NULL; - } - - if (to) - wl_list_insert(&to->layer_link, - &ws->fsurf_front->view->layer_link); - else if (from) - wl_list_insert(&ws->layer.view_list, - &ws->fsurf_front->view->layer_link); - - if (focus_surface_created) { - ws->focus_animation = weston_fade_run( - ws->fsurf_front->view, - ws->fsurf_front->view->alpha, 0.6, 300, - focus_animation_done, ws); - } else if (from) { - wl_list_insert(&from->layer_link, - &ws->fsurf_back->view->layer_link); - ws->focus_animation = weston_stable_fade_run( - ws->fsurf_front->view, 0.0, - ws->fsurf_back->view, 0.6, - focus_animation_done, ws); - } else if (to) { - wl_list_insert(&ws->layer.view_list, - &ws->fsurf_back->view->layer_link); - ws->focus_animation = weston_stable_fade_run( - ws->fsurf_front->view, 0.0, - ws->fsurf_back->view, 0.6, - focus_animation_done, ws); - } -} - -static void -workspace_destroy(struct workspace *ws) -{ - struct focus_state *state, *next; - - wl_list_for_each_safe(state, next, &ws->focus_list, link) - focus_state_destroy(state); - - if (ws->fsurf_front) - focus_surface_destroy(ws->fsurf_front); - if (ws->fsurf_back) - focus_surface_destroy(ws->fsurf_back); - - free(ws); -} - -static void -seat_destroyed(struct wl_listener *listener, void *data) -{ - struct weston_seat *seat = data; - struct focus_state *state, *next; - struct workspace *ws = container_of(listener, - struct workspace, - seat_destroyed_listener); - - wl_list_for_each_safe(state, next, &ws->focus_list, link) - if (state->seat == seat) - wl_list_remove(&state->link); -} - -static struct workspace * -workspace_create(void) -{ - struct workspace *ws = malloc(sizeof *ws); - if (ws == NULL) - return NULL; - - weston_layer_init(&ws->layer, NULL); - - wl_list_init(&ws->focus_list); - wl_list_init(&ws->seat_destroyed_listener.link); - ws->seat_destroyed_listener.notify = seat_destroyed; - ws->fsurf_front = NULL; - ws->fsurf_back = NULL; - ws->focus_animation = NULL; - - return ws; -} - -static int -workspace_is_empty(struct workspace *ws) -{ - return wl_list_empty(&ws->layer.view_list); -} - -static struct workspace * -get_workspace(struct desktop_shell *shell, unsigned int index) -{ - struct workspace **pws = shell->workspaces.array.data; - assert(index < shell->workspaces.num); - pws += index; - return *pws; -} - -struct workspace * -get_current_workspace(struct desktop_shell *shell) -{ - return get_workspace(shell, shell->workspaces.current); -} - -static void -activate_workspace(struct desktop_shell *shell, unsigned int index) -{ - struct workspace *ws; - - ws = get_workspace(shell, index); - wl_list_insert(&shell->panel_layer.link, &ws->layer.link); - - shell->workspaces.current = index; -} - -static unsigned int -get_output_height(struct weston_output *output) -{ - return abs(output->region.extents.y1 - output->region.extents.y2); -} - -static void -view_translate(struct workspace *ws, struct weston_view *view, double d) -{ - struct weston_transform *transform; - - if (is_focus_view(view)) { - struct focus_surface *fsurf = get_focus_surface(view->surface); - transform = &fsurf->workspace_transform; - } else { - struct shell_surface *shsurf = get_shell_surface(view->surface); - transform = &shsurf->workspace_transform; - } - - if (wl_list_empty(&transform->link)) - wl_list_insert(view->geometry.transformation_list.prev, - &transform->link); - - weston_matrix_init(&transform->matrix); - weston_matrix_translate(&transform->matrix, - 0.0, d, 0.0); - weston_view_geometry_dirty(view); -} - -static void -workspace_translate_out(struct workspace *ws, double fraction) -{ - struct weston_view *view; - unsigned int height; - double d; - - wl_list_for_each(view, &ws->layer.view_list, layer_link) { - height = get_output_height(view->surface->output); - d = height * fraction; - - view_translate(ws, view, d); - } -} - -static void -workspace_translate_in(struct workspace *ws, double fraction) -{ - struct weston_view *view; - unsigned int height; - double d; - - wl_list_for_each(view, &ws->layer.view_list, layer_link) { - height = get_output_height(view->surface->output); - - if (fraction > 0) - d = -(height - height * fraction); - else - d = height + height * fraction; - - view_translate(ws, view, d); - } -} - -static void -broadcast_current_workspace_state(struct desktop_shell *shell) -{ - struct wl_resource *resource; - - wl_resource_for_each(resource, &shell->workspaces.client_list) - workspace_manager_send_state(resource, - shell->workspaces.current, - shell->workspaces.num); -} - -static void -reverse_workspace_change_animation(struct desktop_shell *shell, - unsigned int index, - struct workspace *from, - struct workspace *to) -{ - shell->workspaces.current = index; - - shell->workspaces.anim_to = to; - shell->workspaces.anim_from = from; - shell->workspaces.anim_dir = -1 * shell->workspaces.anim_dir; - shell->workspaces.anim_timestamp = 0; - - weston_compositor_schedule_repaint(shell->compositor); -} - -static void -workspace_deactivate_transforms(struct workspace *ws) -{ - struct weston_view *view; - struct weston_transform *transform; - - wl_list_for_each(view, &ws->layer.view_list, layer_link) { - if (is_focus_view(view)) { - struct focus_surface *fsurf = get_focus_surface(view->surface); - transform = &fsurf->workspace_transform; - } else { - struct shell_surface *shsurf = get_shell_surface(view->surface); - transform = &shsurf->workspace_transform; - } - - if (!wl_list_empty(&transform->link)) { - wl_list_remove(&transform->link); - wl_list_init(&transform->link); - } - weston_view_geometry_dirty(view); - } -} - -static void -finish_workspace_change_animation(struct desktop_shell *shell, - struct workspace *from, - struct workspace *to) -{ - weston_compositor_schedule_repaint(shell->compositor); - - wl_list_remove(&shell->workspaces.animation.link); - workspace_deactivate_transforms(from); - workspace_deactivate_transforms(to); - shell->workspaces.anim_to = NULL; - - wl_list_remove(&shell->workspaces.anim_from->layer.link); -} - -static void -animate_workspace_change_frame(struct weston_animation *animation, - struct weston_output *output, uint32_t msecs) -{ - struct desktop_shell *shell = - container_of(animation, struct desktop_shell, - workspaces.animation); - struct workspace *from = shell->workspaces.anim_from; - struct workspace *to = shell->workspaces.anim_to; - uint32_t t; - double x, y; - - if (workspace_is_empty(from) && workspace_is_empty(to)) { - finish_workspace_change_animation(shell, from, to); - return; - } - - if (shell->workspaces.anim_timestamp == 0) { - if (shell->workspaces.anim_current == 0.0) - shell->workspaces.anim_timestamp = msecs; - else - shell->workspaces.anim_timestamp = - msecs - - /* Invers of movement function 'y' below. */ - (asin(1.0 - shell->workspaces.anim_current) * - DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH * - M_2_PI); - } - - t = msecs - shell->workspaces.anim_timestamp; - - /* - * x = [0, π/2] - * y(x) = sin(x) - */ - x = t * (1.0/DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH) * M_PI_2; - y = sin(x); - - if (t < DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH) { - weston_compositor_schedule_repaint(shell->compositor); - - workspace_translate_out(from, shell->workspaces.anim_dir * y); - workspace_translate_in(to, shell->workspaces.anim_dir * y); - shell->workspaces.anim_current = y; - - weston_compositor_schedule_repaint(shell->compositor); - } - else - finish_workspace_change_animation(shell, from, to); -} - -static void -animate_workspace_change(struct desktop_shell *shell, - unsigned int index, - struct workspace *from, - struct workspace *to) -{ - struct weston_output *output; - - int dir; - - if (index > shell->workspaces.current) - dir = -1; - else - dir = 1; - - shell->workspaces.current = index; - - shell->workspaces.anim_dir = dir; - shell->workspaces.anim_from = from; - shell->workspaces.anim_to = to; - shell->workspaces.anim_current = 0.0; - shell->workspaces.anim_timestamp = 0; - - output = container_of(shell->compositor->output_list.next, - struct weston_output, link); - wl_list_insert(&output->animation_list, - &shell->workspaces.animation.link); - - wl_list_insert(from->layer.link.prev, &to->layer.link); - - workspace_translate_in(to, 0); - - restore_focus_state(shell, to); - - weston_compositor_schedule_repaint(shell->compositor); -} - -static void -update_workspace(struct desktop_shell *shell, unsigned int index, - struct workspace *from, struct workspace *to) -{ - shell->workspaces.current = index; - wl_list_insert(&from->layer.link, &to->layer.link); - wl_list_remove(&from->layer.link); -} - -static void -change_workspace(struct desktop_shell *shell, unsigned int index) -{ - struct workspace *from; - struct workspace *to; - struct focus_state *state; - - if (index == shell->workspaces.current) - return; - - /* Don't change workspace when there is any fullscreen surfaces. */ - if (!wl_list_empty(&shell->fullscreen_layer.view_list)) - return; - - from = get_current_workspace(shell); - to = get_workspace(shell, index); - - if (shell->workspaces.anim_from == to && - shell->workspaces.anim_to == from) { - restore_focus_state(shell, to); - reverse_workspace_change_animation(shell, index, from, to); - broadcast_current_workspace_state(shell); - return; - } - - if (shell->workspaces.anim_to != NULL) - finish_workspace_change_animation(shell, - shell->workspaces.anim_from, - shell->workspaces.anim_to); - - restore_focus_state(shell, to); - - if (shell->focus_animation_type != ANIMATION_NONE) { - wl_list_for_each(state, &from->focus_list, link) - if (state->keyboard_focus) - animate_focus_change(shell, from, - get_default_view(state->keyboard_focus), NULL); - - wl_list_for_each(state, &to->focus_list, link) - if (state->keyboard_focus) - animate_focus_change(shell, to, - NULL, get_default_view(state->keyboard_focus)); - } - - if (workspace_is_empty(to) && workspace_is_empty(from)) - update_workspace(shell, index, from, to); - else - animate_workspace_change(shell, index, from, to); - - broadcast_current_workspace_state(shell); -} - -static bool -workspace_has_only(struct workspace *ws, struct weston_surface *surface) -{ - struct wl_list *list = &ws->layer.view_list; - struct wl_list *e; - - if (wl_list_empty(list)) - return false; - - e = list->next; - - if (e->next != list) - return false; - - return container_of(e, struct weston_view, layer_link)->surface == surface; -} - -static void -move_surface_to_workspace(struct desktop_shell *shell, - struct shell_surface *shsurf, - uint32_t workspace) -{ - struct workspace *from; - struct workspace *to; - struct weston_seat *seat; - struct weston_surface *focus; - struct weston_view *view; - - if (workspace == shell->workspaces.current) - return; - - view = get_default_view(shsurf->surface); - if (!view) - return; - - assert(weston_surface_get_main_surface(view->surface) == view->surface); - - if (workspace >= shell->workspaces.num) - workspace = shell->workspaces.num - 1; - - from = get_current_workspace(shell); - to = get_workspace(shell, workspace); - - wl_list_remove(&view->layer_link); - wl_list_insert(&to->layer.view_list, &view->layer_link); - - shell_surface_update_child_surface_layers(shsurf); - - drop_focus_state(shell, from, view->surface); - wl_list_for_each(seat, &shell->compositor->seat_list, link) { - if (!seat->keyboard) - continue; - - focus = weston_surface_get_main_surface(seat->keyboard->focus); - if (focus == view->surface) - weston_keyboard_set_focus(seat->keyboard, NULL); - } - - weston_view_damage_below(view); -} - -static void -take_surface_to_workspace_by_seat(struct desktop_shell *shell, - struct weston_seat *seat, - unsigned int index) -{ - struct weston_surface *surface; - struct weston_view *view; - struct shell_surface *shsurf; - struct workspace *from; - struct workspace *to; - struct focus_state *state; - - surface = weston_surface_get_main_surface(seat->keyboard->focus); - view = get_default_view(surface); - if (view == NULL || - index == shell->workspaces.current || - is_focus_view(view)) - return; - - from = get_current_workspace(shell); - to = get_workspace(shell, index); - - wl_list_remove(&view->layer_link); - wl_list_insert(&to->layer.view_list, &view->layer_link); - - shsurf = get_shell_surface(surface); - if (shsurf != NULL) - shell_surface_update_child_surface_layers(shsurf); - - replace_focus_state(shell, to, seat); - drop_focus_state(shell, from, surface); - - if (shell->workspaces.anim_from == to && - shell->workspaces.anim_to == from) { - wl_list_remove(&to->layer.link); - wl_list_insert(from->layer.link.prev, &to->layer.link); - - reverse_workspace_change_animation(shell, index, from, to); - broadcast_current_workspace_state(shell); - - return; - } - - if (shell->workspaces.anim_to != NULL) - finish_workspace_change_animation(shell, - shell->workspaces.anim_from, - shell->workspaces.anim_to); - - if (workspace_is_empty(from) && - workspace_has_only(to, surface)) - update_workspace(shell, index, from, to); - else { - if (shsurf != NULL && - wl_list_empty(&shsurf->workspace_transform.link)) - wl_list_insert(&shell->workspaces.anim_sticky_list, - &shsurf->workspace_transform.link); - - animate_workspace_change(shell, index, from, to); - } - - broadcast_current_workspace_state(shell); - - state = ensure_focus_state(shell, seat); - if (state != NULL) - focus_state_set_focus(state, surface); -} - -static void -workspace_manager_move_surface(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource, - uint32_t workspace) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct weston_surface *main_surface; - struct shell_surface *shell_surface; - - main_surface = weston_surface_get_main_surface(surface); - shell_surface = get_shell_surface(main_surface); - if (shell_surface == NULL) - return; - - move_surface_to_workspace(shell, shell_surface, workspace); -} - -static const struct workspace_manager_interface workspace_manager_implementation = { - workspace_manager_move_surface, -}; - -static void -unbind_resource(struct wl_resource *resource) -{ - wl_list_remove(wl_resource_get_link(resource)); -} - -static void -bind_workspace_manager(struct wl_client *client, - void *data, uint32_t version, uint32_t id) -{ - struct desktop_shell *shell = data; - struct wl_resource *resource; - - resource = wl_resource_create(client, - &workspace_manager_interface, 1, id); - - if (resource == NULL) { - weston_log("couldn't add workspace manager object"); - return; - } - - wl_resource_set_implementation(resource, - &workspace_manager_implementation, - shell, unbind_resource); - wl_list_insert(&shell->workspaces.client_list, - wl_resource_get_link(resource)); - - workspace_manager_send_state(resource, - shell->workspaces.current, - shell->workspaces.num); -} - -static void -touch_move_grab_down(struct weston_touch_grab *grab, uint32_t time, - int touch_id, wl_fixed_t sx, wl_fixed_t sy) -{ -} - -static void -touch_move_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id) -{ - struct weston_touch_move_grab *move = - (struct weston_touch_move_grab *) container_of( - grab, struct shell_touch_grab, grab); - - if (touch_id == 0) - move->active = 0; - - if (grab->touch->num_tp == 0) { - shell_touch_grab_end(&move->base); - free(move); - } -} - -static void -touch_move_grab_motion(struct weston_touch_grab *grab, uint32_t time, - int touch_id, wl_fixed_t sx, wl_fixed_t sy) -{ - struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) grab; - struct shell_surface *shsurf = move->base.shsurf; - struct weston_surface *es; - int dx = wl_fixed_to_int(grab->touch->grab_x + move->dx); - int dy = wl_fixed_to_int(grab->touch->grab_y + move->dy); - - if (!shsurf || !move->active) - return; - - es = shsurf->surface; - - /* ico-ivi-shell hook move */ - if (shell_hook_move) { - (*shell_hook_move)(es, &dx, &dy); - } - - weston_view_set_position(shsurf->view, dx, dy); - - weston_compositor_schedule_repaint(es->compositor); -} - -static void -touch_move_grab_cancel(struct weston_touch_grab *grab) -{ - struct weston_touch_move_grab *move = - (struct weston_touch_move_grab *) container_of( - grab, struct shell_touch_grab, grab); - - shell_touch_grab_end(&move->base); - free(move); -} - -static const struct weston_touch_grab_interface touch_move_grab_interface = { - touch_move_grab_down, - touch_move_grab_up, - touch_move_grab_motion, - touch_move_grab_cancel, -}; - -static int -surface_touch_move(struct shell_surface *shsurf, struct weston_seat *seat) -{ - struct weston_touch_move_grab *move; - - if (!shsurf) - return -1; - - if (shsurf->state.fullscreen) - return 0; - if (shsurf->grabbed) - return 0; - - move = malloc(sizeof *move); - if (!move) - return -1; - - move->active = 1; - move->dx = wl_fixed_from_double(shsurf->view->geometry.x) - - seat->touch->grab_x; - move->dy = wl_fixed_from_double(shsurf->view->geometry.y) - - seat->touch->grab_y; - - shell_touch_grab_start(&move->base, &touch_move_grab_interface, shsurf, - seat->touch); - - return 0; -} - -static void -noop_grab_focus(struct weston_pointer_grab *grab) -{ -} - -static void -move_grab_motion(struct weston_pointer_grab *grab, uint32_t time, - wl_fixed_t x, wl_fixed_t y) -{ - struct weston_move_grab *move = (struct weston_move_grab *) grab; - struct weston_pointer *pointer = grab->pointer; - struct shell_surface *shsurf = move->base.shsurf; - int dx, dy; - - weston_pointer_move(pointer, x, y); - dx = wl_fixed_to_int(pointer->x + move->dx); - dy = wl_fixed_to_int(pointer->y + move->dy); - - if (!shsurf) - return; - - weston_view_set_position(shsurf->view, dx, dy); - - weston_compositor_schedule_repaint(shsurf->surface->compositor); -} - -static void -move_grab_button(struct weston_pointer_grab *grab, - uint32_t time, uint32_t button, uint32_t state_w) -{ - struct shell_grab *shell_grab = container_of(grab, struct shell_grab, - grab); - struct weston_pointer *pointer = grab->pointer; - enum wl_pointer_button_state state = state_w; - - if (pointer->button_count == 0 && - state == WL_POINTER_BUTTON_STATE_RELEASED) { - shell_grab_end(shell_grab); - free(grab); - } -} - -static void -move_grab_cancel(struct weston_pointer_grab *grab) -{ - struct shell_grab *shell_grab = - container_of(grab, struct shell_grab, grab); - - shell_grab_end(shell_grab); - free(grab); -} - -static const struct weston_pointer_grab_interface move_grab_interface = { - noop_grab_focus, - move_grab_motion, - move_grab_button, - move_grab_cancel, -}; - -static int -surface_move(struct shell_surface *shsurf, struct weston_seat *seat) -{ - struct weston_move_grab *move; - - if (!shsurf) - return -1; - - if (shsurf->grabbed) - return 0; - if (shsurf->state.fullscreen || shsurf->state.maximized) - return 0; - - move = malloc(sizeof *move); - if (!move) - return -1; - - move->dx = wl_fixed_from_double(shsurf->view->geometry.x) - - seat->pointer->grab_x; - move->dy = wl_fixed_from_double(shsurf->view->geometry.y) - - seat->pointer->grab_y; - - shell_grab_start(&move->base, &move_grab_interface, shsurf, - seat->pointer, DESKTOP_SHELL_CURSOR_MOVE); - - return 0; -} - -static void -common_surface_move(struct wl_resource *resource, - struct wl_resource *seat_resource, uint32_t serial) -{ - struct weston_seat *seat = wl_resource_get_user_data(seat_resource); - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_surface *surface; - - if (seat->pointer && - seat->pointer->focus && - seat->pointer->button_count > 0 && - seat->pointer->grab_serial == serial) { - surface = weston_surface_get_main_surface(seat->pointer->focus->surface); - if ((surface == shsurf->surface) && - (surface_move(shsurf, seat) < 0)) - wl_resource_post_no_memory(resource); - } else if (seat->touch && - seat->touch->focus && - seat->touch->grab_serial == serial) { - surface = weston_surface_get_main_surface(seat->touch->focus->surface); - if ((surface == shsurf->surface) && - (surface_touch_move(shsurf, seat) < 0)) - wl_resource_post_no_memory(resource); - } -} - -static void -shell_surface_move(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat_resource, uint32_t serial) -{ - common_surface_move(resource, seat_resource, serial); -} - -struct weston_resize_grab { - struct shell_grab base; - uint32_t edges; - int32_t width, height; -}; - -static void -resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time, - wl_fixed_t x, wl_fixed_t y) -{ - struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; - struct weston_pointer *pointer = grab->pointer; - struct shell_surface *shsurf = resize->base.shsurf; - int32_t width, height; - wl_fixed_t from_x, from_y; - wl_fixed_t to_x, to_y; - - weston_pointer_move(pointer, x, y); - - if (!shsurf) - return; - - weston_view_from_global_fixed(shsurf->view, - pointer->grab_x, pointer->grab_y, - &from_x, &from_y); - weston_view_from_global_fixed(shsurf->view, - pointer->x, pointer->y, &to_x, &to_y); - - width = resize->width; - if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) { - width += wl_fixed_to_int(from_x - to_x); - } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) { - width += wl_fixed_to_int(to_x - from_x); - } - - height = resize->height; - if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) { - height += wl_fixed_to_int(from_y - to_y); - } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) { - height += wl_fixed_to_int(to_y - from_y); - } - - shsurf->client->send_configure(shsurf->surface, - resize->edges, width, height); -} - -static void -send_configure(struct weston_surface *surface, - uint32_t edges, int32_t width, int32_t height) -{ - struct shell_surface *shsurf = get_shell_surface(surface); - - assert(shsurf); - - uifw_trace("send_configure: send %08x %x w/h=%d/%d", - (int)shsurf->surface, edges, width, height); - - wl_shell_surface_send_configure(shsurf->resource, - edges, width, height); -} - -static const struct weston_shell_client shell_client = { - send_configure -}; - -static void -resize_grab_button(struct weston_pointer_grab *grab, - uint32_t time, uint32_t button, uint32_t state_w) -{ - struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; - struct weston_pointer *pointer = grab->pointer; - enum wl_pointer_button_state state = state_w; - - if (pointer->button_count == 0 && - state == WL_POINTER_BUTTON_STATE_RELEASED) { - shell_grab_end(&resize->base); - free(grab); - } -} - -static void -resize_grab_cancel(struct weston_pointer_grab *grab) -{ - struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; - - shell_grab_end(&resize->base); - free(grab); -} - -static const struct weston_pointer_grab_interface resize_grab_interface = { - noop_grab_focus, - resize_grab_motion, - resize_grab_button, - resize_grab_cancel, -}; - -/* - * Returns the bounding box of a surface and all its sub-surfaces, - * in the surface coordinates system. */ -static void -surface_subsurfaces_boundingbox(struct weston_surface *surface, int32_t *x, - int32_t *y, int32_t *w, int32_t *h) { - pixman_region32_t region; - pixman_box32_t *box; - struct weston_subsurface *subsurface; - - pixman_region32_init_rect(®ion, 0, 0, - surface->width, - surface->height); - - wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) { - pixman_region32_union_rect(®ion, ®ion, - subsurface->position.x, - subsurface->position.y, - subsurface->surface->width, - subsurface->surface->height); - } - - box = pixman_region32_extents(®ion); - if (x) - *x = box->x1; - if (y) - *y = box->y1; - if (w) - *w = box->x2 - box->x1; - if (h) - *h = box->y2 - box->y1; - - pixman_region32_fini(®ion); -} - -static int -surface_resize(struct shell_surface *shsurf, - struct weston_seat *seat, uint32_t edges) -{ - struct weston_resize_grab *resize; - - if (shsurf->state.fullscreen || shsurf->state.maximized) - return 0; - - if (edges == 0 || edges > 15 || - (edges & 3) == 3 || (edges & 12) == 12) - return 0; - - resize = malloc(sizeof *resize); - if (!resize) - return -1; - - resize->edges = edges; - surface_subsurfaces_boundingbox(shsurf->surface, NULL, NULL, - &resize->width, &resize->height); - - shell_grab_start(&resize->base, &resize_grab_interface, shsurf, - seat->pointer, edges); - - return 0; -} - -static void -common_surface_resize(struct wl_resource *resource, - struct wl_resource *seat_resource, uint32_t serial, - uint32_t edges) -{ - struct weston_seat *seat = wl_resource_get_user_data(seat_resource); - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_surface *surface; - - if (shsurf->state.fullscreen) - return; - - if (seat->pointer->button_count == 0 || - seat->pointer->grab_serial != serial || - seat->pointer->focus == NULL) - return; - - surface = weston_surface_get_main_surface(seat->pointer->focus->surface); - if (surface != shsurf->surface) - return; - - if (surface_resize(shsurf, seat, edges) < 0) - wl_resource_post_no_memory(resource); -} - -static void -shell_surface_resize(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat_resource, uint32_t serial, - uint32_t edges) -{ - common_surface_resize(resource, seat_resource, serial, edges); -} - -static void -end_busy_cursor(struct shell_surface *shsurf, struct weston_pointer *pointer); - -static void -busy_cursor_grab_focus(struct weston_pointer_grab *base) -{ - struct shell_grab *grab = (struct shell_grab *) base; - struct weston_pointer *pointer = base->pointer; - struct weston_view *view; - wl_fixed_t sx, sy; - - view = weston_compositor_pick_view(pointer->seat->compositor, - pointer->x, pointer->y, - &sx, &sy); - - if (!grab->shsurf || grab->shsurf->surface != view->surface) - end_busy_cursor(grab->shsurf, pointer); -} - -static void -busy_cursor_grab_motion(struct weston_pointer_grab *grab, uint32_t time, - wl_fixed_t x, wl_fixed_t y) -{ - weston_pointer_move(grab->pointer, x, y); -} - -static void -busy_cursor_grab_button(struct weston_pointer_grab *base, - uint32_t time, uint32_t button, uint32_t state) -{ - struct shell_grab *grab = (struct shell_grab *) base; - struct shell_surface *shsurf = grab->shsurf; - struct weston_seat *seat = grab->grab.pointer->seat; - - if (shsurf && button == BTN_LEFT && state) { - activate(shsurf->shell, shsurf->surface, seat); - surface_move(shsurf, seat); - } else if (shsurf && button == BTN_RIGHT && state) { - activate(shsurf->shell, shsurf->surface, seat); - surface_rotate(shsurf, seat); - } -} - -static void -busy_cursor_grab_cancel(struct weston_pointer_grab *base) -{ - struct shell_grab *grab = (struct shell_grab *) base; - - shell_grab_end(grab); - free(grab); -} - -static const struct weston_pointer_grab_interface busy_cursor_grab_interface = { - busy_cursor_grab_focus, - busy_cursor_grab_motion, - busy_cursor_grab_button, - busy_cursor_grab_cancel, -}; - -static void -set_busy_cursor(struct shell_surface *shsurf, struct weston_pointer *pointer) -{ - struct shell_grab *grab; - - grab = malloc(sizeof *grab); - if (!grab) - return; - - shell_grab_start(grab, &busy_cursor_grab_interface, shsurf, pointer, - DESKTOP_SHELL_CURSOR_BUSY); -} - -static void -end_busy_cursor(struct shell_surface *shsurf, struct weston_pointer *pointer) -{ - struct shell_grab *grab = (struct shell_grab *) pointer->grab; - - if (grab->grab.interface == &busy_cursor_grab_interface && - grab->shsurf == shsurf) { - shell_grab_end(grab); - free(grab); - } -} - -static void -ping_timer_destroy(struct shell_surface *shsurf) -{ - if (!shsurf || !shsurf->ping_timer) - return; - - if (shsurf->ping_timer->source) - wl_event_source_remove(shsurf->ping_timer->source); - - free(shsurf->ping_timer); - shsurf->ping_timer = NULL; -} - -static int -ping_timeout_handler(void *data) -{ - struct shell_surface *shsurf = data; - struct weston_seat *seat; - - /* Client is not responding */ - shsurf->unresponsive = 1; - - wl_list_for_each(seat, &shsurf->surface->compositor->seat_list, link) - if (seat->pointer && seat->pointer->focus && - seat->pointer->focus->surface == shsurf->surface) - set_busy_cursor(shsurf, seat->pointer); - - return 1; -} - -static void -ping_handler(struct weston_surface *surface, uint32_t serial) -{ - struct shell_surface *shsurf = get_shell_surface(surface); - struct wl_event_loop *loop; - int ping_timeout = 200; - - if (!shsurf) - return; - if (!shsurf->resource) - return; - - if (shsurf->surface == shsurf->shell->grab_surface) - return; - - if (!shsurf->ping_timer) { - shsurf->ping_timer = malloc(sizeof *shsurf->ping_timer); - if (!shsurf->ping_timer) - return; - - shsurf->ping_timer->serial = serial; - loop = wl_display_get_event_loop(surface->compositor->wl_display); - shsurf->ping_timer->source = - wl_event_loop_add_timer(loop, ping_timeout_handler, shsurf); - wl_event_source_timer_update(shsurf->ping_timer->source, ping_timeout); - - if (shell_surface_is_wl_shell_surface(shsurf)) - wl_shell_surface_send_ping(shsurf->resource, serial); - else if (shell_surface_is_xdg_surface(shsurf)) - xdg_surface_send_ping(shsurf->resource, serial); - else if (shell_surface_is_xdg_popup(shsurf)) - xdg_popup_send_ping(shsurf->resource, serial); - } -} - -static void -handle_pointer_focus(struct wl_listener *listener, void *data) -{ - struct weston_pointer *pointer = data; - struct weston_view *view = pointer->focus; - struct weston_compositor *compositor; - struct shell_surface *shsurf; - uint32_t serial; - - if (!view) - return; - - compositor = view->surface->compositor; - shsurf = get_shell_surface(view->surface); - - if (shsurf && shsurf->unresponsive) { - set_busy_cursor(shsurf, pointer); - } else { - serial = wl_display_next_serial(compositor->wl_display); - ping_handler(view->surface, serial); - } -} - -static void -create_pointer_focus_listener(struct weston_seat *seat) -{ - struct wl_listener *listener; - - if (!seat->pointer) - return; - - listener = malloc(sizeof *listener); - listener->notify = handle_pointer_focus; - wl_signal_add(&seat->pointer->focus_signal, listener); -} - -static void -xdg_surface_set_transient_for(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent_resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_surface *parent; - - if (parent_resource) - parent = wl_resource_get_user_data(parent_resource); - else - parent = NULL; - - shell_surface_set_parent(shsurf, parent); -} - -static void -surface_pong(struct shell_surface *shsurf, uint32_t serial) -{ - struct weston_compositor *ec = shsurf->surface->compositor; - struct weston_seat *seat; - - if (shsurf->ping_timer == NULL) - /* Just ignore unsolicited pong. */ - return; - - if (shsurf->ping_timer->serial == serial) { - shsurf->unresponsive = 0; - wl_list_for_each(seat, &ec->seat_list, link) { - if(seat->pointer) - end_busy_cursor(shsurf, seat->pointer); - } - ping_timer_destroy(shsurf); - } -} - -static void -shell_surface_pong(struct wl_client *client, struct wl_resource *resource, - uint32_t serial) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - surface_pong(shsurf, serial); - -} - -static void -set_title(struct shell_surface *shsurf, const char *title) -{ - char *p; - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_title) { - p = (*shell_hook_title)(shsurf->surface, title); - if (p) { - free(shsurf->title); - shsurf->title = strdup(p); - } - } - else { - free(shsurf->title); - shsurf->title = strdup(title); - } -} - -static void -shell_surface_set_title(struct wl_client *client, - struct wl_resource *resource, const char *title) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - set_title(shsurf, title); -} - -static void -shell_surface_set_class(struct wl_client *client, - struct wl_resource *resource, const char *class) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - free(shsurf->class); - shsurf->class = strdup(class); -} - -static void -restore_output_mode(struct weston_output *output) -{ - if (output->current_mode != output->original_mode || - (int32_t)output->current_scale != output->original_scale) - weston_output_switch_mode(output, - output->original_mode, - output->original_scale, - WESTON_MODE_SWITCH_RESTORE_NATIVE); -} - -static void -restore_all_output_modes(struct weston_compositor *compositor) -{ - struct weston_output *output; - - wl_list_for_each(output, &compositor->output_list, link) - restore_output_mode(output); -} - -static int -get_output_panel_height(struct desktop_shell *shell, - struct weston_output *output) -{ - struct weston_view *view; - int panel_height = 0; - - if (!output) - return 0; - - wl_list_for_each(view, &shell->panel_layer.view_list, layer_link) { - if (view->surface->output == output) { - panel_height = view->surface->height; - break; - } - } - - return panel_height; -} - -/* The surface will be inserted into the list immediately after the link - * returned by this function (i.e. will be stacked immediately above the - * returned link). */ -static struct wl_list * -shell_surface_calculate_layer_link (struct shell_surface *shsurf) -{ - struct workspace *ws; - struct weston_view *parent; - - switch (shsurf->type) { - case SHELL_SURFACE_POPUP: - case SHELL_SURFACE_TOPLEVEL: - if (shsurf->state.fullscreen) { - return &shsurf->shell->fullscreen_layer.view_list; - } else if (shsurf->parent) { - /* Move the surface to its parent layer so - * that surfaces which are transient for - * fullscreen surfaces don't get hidden by the - * fullscreen surfaces. */ - - /* TODO: Handle a parent with multiple views */ - parent = get_default_view(shsurf->parent); - if (parent) - return parent->layer_link.prev; - } - break; - - case SHELL_SURFACE_XWAYLAND: - return &shsurf->shell->fullscreen_layer.view_list; - - case SHELL_SURFACE_NONE: - default: - /* Go to the fallback, below. */ - break; - } - - /* Move the surface to a normal workspace layer so that surfaces - * which were previously fullscreen or transient are no longer - * rendered on top. */ - ws = get_current_workspace(shsurf->shell); - return &ws->layer.view_list; -} - -static void -shell_surface_update_child_surface_layers (struct shell_surface *shsurf) -{ - struct shell_surface *child; - - /* Move the child layers to the same workspace as shsurf. They will be - * stacked above shsurf. */ - wl_list_for_each_reverse(child, &shsurf->children_list, children_link) { - if (shsurf->view->layer_link.prev != &child->view->layer_link) { - weston_view_geometry_dirty(child->view); - wl_list_remove(&child->view->layer_link); - wl_list_insert(shsurf->view->layer_link.prev, - &child->view->layer_link); - weston_view_geometry_dirty(child->view); - weston_surface_damage(child->surface); - - /* Recurse. We don’t expect this to recurse very far (if - * at all) because that would imply we have transient - * (or popup) children of transient surfaces, which - * would be unusual. */ - shell_surface_update_child_surface_layers(child); - } - } -} - -/* Update the surface’s layer. Mark both the old and new views as having dirty - * geometry to ensure the changes are redrawn. - * - * If any child surfaces exist and are mapped, ensure they’re in the same layer - * as this surface. */ -static void -shell_surface_update_layer(struct shell_surface *shsurf) -{ - struct wl_list *new_layer_link; - - new_layer_link = shell_surface_calculate_layer_link(shsurf); - - if (new_layer_link == &shsurf->view->layer_link) - return; - - weston_view_geometry_dirty(shsurf->view); - wl_list_remove(&shsurf->view->layer_link); - wl_list_insert(new_layer_link, &shsurf->view->layer_link); - weston_view_geometry_dirty(shsurf->view); - weston_surface_damage(shsurf->surface); - - shell_surface_update_child_surface_layers(shsurf); -} - -static void -shell_surface_set_parent(struct shell_surface *shsurf, - struct weston_surface *parent) -{ - shsurf->parent = parent; - - wl_list_remove(&shsurf->children_link); - wl_list_init(&shsurf->children_link); - - /* Insert into the parent surface’s child list. */ - if (parent != NULL) { - struct shell_surface *parent_shsurf = get_shell_surface(parent); - if (parent_shsurf != NULL) - wl_list_insert(&parent_shsurf->children_list, - &shsurf->children_link); - } -} - -static void -shell_surface_set_output(struct shell_surface *shsurf, - struct weston_output *output) -{ - struct weston_surface *es = shsurf->surface; - - /* get the default output, if the client set it as NULL - check whether the ouput is available */ - if (output) - shsurf->output = output; - else if (es->output) - shsurf->output = es->output; - else - shsurf->output = get_default_output(es->compositor); -} - -static void -surface_clear_next_states(struct shell_surface *shsurf) -{ - shsurf->next_state.maximized = false; - shsurf->next_state.fullscreen = false; - - if ((shsurf->next_state.maximized != shsurf->state.maximized) || - (shsurf->next_state.fullscreen != shsurf->state.fullscreen)) - shsurf->state_changed = true; -} - -static void -set_toplevel(struct shell_surface *shsurf) -{ - shell_surface_set_parent(shsurf, NULL); - surface_clear_next_states(shsurf); - shsurf->type = SHELL_SURFACE_TOPLEVEL; - - /* The layer_link is updated in set_surface_type(), - * called from configure. */ -} - -static void -shell_surface_set_toplevel(struct wl_client *client, - struct wl_resource *resource) -{ - struct shell_surface *surface = wl_resource_get_user_data(resource); - - set_toplevel(surface); -} - -static void -set_transient(struct shell_surface *shsurf, - struct weston_surface *parent, int x, int y, uint32_t flags) -{ - assert(parent != NULL); - - shell_surface_set_parent(shsurf, parent); - - surface_clear_next_states(shsurf); - - shsurf->transient.x = x; - shsurf->transient.y = y; - shsurf->transient.flags = flags; - - shsurf->next_state.relative = true; - shsurf->state_changed = true; - shsurf->type = SHELL_SURFACE_TOPLEVEL; - - /* The layer_link is updated in set_surface_type(), - * called from configure. */ -} - -static void -shell_surface_set_transient(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent_resource, - int x, int y, uint32_t flags) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_surface *parent = - wl_resource_get_user_data(parent_resource); - - set_transient(shsurf, parent, x, y, flags); -} - -static void -set_fullscreen(struct shell_surface *shsurf, - uint32_t method, - uint32_t framerate, - struct weston_output *output) -{ - shell_surface_set_output(shsurf, output); - - shsurf->fullscreen_output = shsurf->output; - shsurf->fullscreen.type = method; - shsurf->fullscreen.framerate = framerate; - - shsurf->next_state.fullscreen = true; - shsurf->state_changed = true; - shsurf->type = SHELL_SURFACE_TOPLEVEL; - - if (shell_hook_fullscreen) { - (*shell_hook_fullscreen)(SHELL_FULLSCREEN_SET, shsurf->surface); - return; - } - - shsurf->client->send_configure(shsurf->surface, 0, - shsurf->output->width, - shsurf->output->height); - - /* The layer_link is updated in set_surface_type(), - * called from configure. */ -} - -static void -weston_view_set_initial_position(struct weston_view *view, - struct desktop_shell *shell); - -static void -unset_fullscreen(struct shell_surface *shsurf) -{ - /* Unset the fullscreen output, driver configuration and transforms. */ - if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER && - shell_surface_is_top_fullscreen(shsurf)) { - restore_output_mode(shsurf->fullscreen_output); - } - shsurf->fullscreen_output = NULL; - - shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT; - shsurf->fullscreen.framerate = 0; - - if (shell_hook_fullscreen) { - (*shell_hook_fullscreen)(SHELL_FULLSCREEN_UNSET, shsurf->surface); - } - - wl_list_remove(&shsurf->fullscreen.transform.link); - wl_list_init(&shsurf->fullscreen.transform.link); - - if (shsurf->fullscreen.black_view) - weston_surface_destroy(shsurf->fullscreen.black_view->surface); - shsurf->fullscreen.black_view = NULL; - - if (shsurf->saved_position_valid) - weston_view_set_position(shsurf->view, - shsurf->saved_x, shsurf->saved_y); - else - weston_view_set_initial_position(shsurf->view, shsurf->shell); - - if (shsurf->saved_rotation_valid) { - wl_list_insert(&shsurf->view->geometry.transformation_list, - &shsurf->rotation.transform.link); - shsurf->saved_rotation_valid = false; - } - - /* Layer is updated in set_surface_type(). */ -} - -static void -shell_surface_set_fullscreen(struct wl_client *client, - struct wl_resource *resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output_resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_output *output; - - if (output_resource) - output = wl_resource_get_user_data(output_resource); - else - output = NULL; - - shell_surface_set_parent(shsurf, NULL); - - surface_clear_next_states(shsurf); - set_fullscreen(shsurf, method, framerate, output); -} - -static void -set_popup(struct shell_surface *shsurf, - struct weston_surface *parent, - struct weston_seat *seat, - uint32_t serial, - int32_t x, - int32_t y) -{ - assert(parent != NULL); - - shsurf->popup.shseat = get_shell_seat(seat); - shsurf->popup.serial = serial; - shsurf->popup.x = x; - shsurf->popup.y = y; - - shsurf->type = SHELL_SURFACE_POPUP; -} - -static void -shell_surface_set_popup(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat_resource, - uint32_t serial, - struct wl_resource *parent_resource, - int32_t x, int32_t y, uint32_t flags) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_surface *parent = - wl_resource_get_user_data(parent_resource); - - shell_surface_set_parent(shsurf, parent); - - surface_clear_next_states(shsurf); - set_popup(shsurf, - parent, - wl_resource_get_user_data(seat_resource), - serial, x, y); -} - -static void -set_maximized(struct shell_surface *shsurf, - struct weston_output *output) -{ - struct desktop_shell *shell; - uint32_t edges = 0, panel_height = 0; - - shell_surface_set_output(shsurf, output); - - shell = shell_surface_get_shell(shsurf); - panel_height = get_output_panel_height(shell, shsurf->output); - edges = WL_SHELL_SURFACE_RESIZE_TOP | WL_SHELL_SURFACE_RESIZE_LEFT; - - shsurf->client->send_configure(shsurf->surface, edges, - shsurf->output->width, - shsurf->output->height - panel_height); - - shsurf->next_state.maximized = true; - shsurf->state_changed = true; - shsurf->type = SHELL_SURFACE_TOPLEVEL; -} - -static void -unset_maximized(struct shell_surface *shsurf) -{ - /* undo all maximized things here */ - shsurf->output = get_default_output(shsurf->surface->compositor); - - if (shsurf->saved_position_valid) - weston_view_set_position(shsurf->view, - shsurf->saved_x, shsurf->saved_y); - else - weston_view_set_initial_position(shsurf->view, shsurf->shell); - - if (shsurf->saved_rotation_valid) { - wl_list_insert(&shsurf->view->geometry.transformation_list, - &shsurf->rotation.transform.link); - shsurf->saved_rotation_valid = false; - } - - /* Layer is updated in set_surface_type(). */ -} - -static void -shell_surface_set_maximized(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output_resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_output *output; - - if (output_resource) - output = wl_resource_get_user_data(output_resource); - else - output = NULL; - - shell_surface_set_parent(shsurf, NULL); - - surface_clear_next_states(shsurf); - set_maximized(shsurf, output); -} - -/* This is only ever called from set_surface_type(), so there’s no need to - * update layer_links here, since they’ll be updated when we return. */ -static int -reset_surface_type(struct shell_surface *surface) -{ - if (surface->state.fullscreen) - unset_fullscreen(surface); - if (surface->state.maximized) - unset_maximized(surface); - - return 0; -} - -static void -set_full_output(struct shell_surface *shsurf) -{ - shsurf->saved_x = shsurf->view->geometry.x; - shsurf->saved_y = shsurf->view->geometry.y; - shsurf->saved_width = shsurf->surface->width; - shsurf->saved_height = shsurf->surface->height; - shsurf->saved_size_valid = true; - shsurf->saved_position_valid = true; - - if (!wl_list_empty(&shsurf->rotation.transform.link)) { - wl_list_remove(&shsurf->rotation.transform.link); - wl_list_init(&shsurf->rotation.transform.link); - weston_view_geometry_dirty(shsurf->view); - shsurf->saved_rotation_valid = true; - } -} - -static void -set_surface_type(struct shell_surface *shsurf) -{ - struct weston_surface *pes = shsurf->parent; - struct weston_view *pev = get_default_view(pes); - - reset_surface_type(shsurf); - - shsurf->state = shsurf->next_state; - shsurf->state_changed = false; - - switch (shsurf->type) { - case SHELL_SURFACE_TOPLEVEL: - if (shsurf->state.maximized || shsurf->state.fullscreen) { - set_full_output(shsurf); - } else if (shsurf->state.relative && pev) { - weston_view_set_position(shsurf->view, - pev->geometry.x + shsurf->transient.x, - pev->geometry.y + shsurf->transient.y); - } - break; - - case SHELL_SURFACE_XWAYLAND: - weston_view_set_position(shsurf->view, shsurf->transient.x, - shsurf->transient.y); - break; - - case SHELL_SURFACE_POPUP: - case SHELL_SURFACE_NONE: - default: - break; - } - - /* Update the surface’s layer. */ - shell_surface_update_layer(shsurf); -} - -static struct desktop_shell * -shell_surface_get_shell(struct shell_surface *shsurf) -{ - return shsurf->shell; -} - -static void -black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy); - -static struct weston_view * -create_black_surface(struct weston_compositor *ec, - struct weston_surface *fs_surface, - float x, float y, int w, int h) -{ - struct weston_surface *surface = NULL; - struct weston_view *view; - - surface = weston_surface_create(ec); - if (surface == NULL) { - weston_log("no memory\n"); - return NULL; - } - view = weston_view_create(surface); - if (surface == NULL) { - weston_log("no memory\n"); - weston_surface_destroy(surface); - return NULL; - } - - surface->configure = black_surface_configure; - surface->configure_private = fs_surface; - weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1); - pixman_region32_fini(&surface->opaque); - pixman_region32_init_rect(&surface->opaque, 0, 0, w, h); - pixman_region32_fini(&surface->input); - pixman_region32_init_rect(&surface->input, 0, 0, w, h); - - weston_surface_set_size(surface, w, h); - weston_view_set_position(view, x, y); - - return view; -} - -static void -shell_ensure_fullscreen_black_view(struct shell_surface *shsurf) -{ - struct weston_output *output = shsurf->fullscreen_output; - - assert(shsurf->state.fullscreen); - - if (!shsurf->fullscreen.black_view) - shsurf->fullscreen.black_view = - create_black_surface(shsurf->surface->compositor, - shsurf->surface, - output->x, output->y, - output->width, - output->height); - - weston_view_geometry_dirty(shsurf->fullscreen.black_view); - wl_list_remove(&shsurf->fullscreen.black_view->layer_link); - wl_list_insert(&shsurf->view->layer_link, - &shsurf->fullscreen.black_view->layer_link); - weston_view_geometry_dirty(shsurf->fullscreen.black_view); - weston_surface_damage(shsurf->surface); -} - -/* Create black surface and append it to the associated fullscreen surface. - * Handle size dismatch and positioning according to the method. */ -static void -shell_configure_fullscreen(struct shell_surface *shsurf) -{ - struct weston_output *output = shsurf->fullscreen_output; - struct weston_surface *surface = shsurf->surface; - struct weston_matrix *matrix; - float scale, output_aspect, surface_aspect, x, y; - int32_t surf_x, surf_y, surf_width, surf_height; - - if (shell_hook_fullscreen) { - (*shell_hook_fullscreen)(SHELL_FULLSCREEN_CONF, shsurf->surface); - } - - if (shsurf->fullscreen.type != WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER) - restore_output_mode(output); - - shell_ensure_fullscreen_black_view(shsurf); - - surface_subsurfaces_boundingbox(shsurf->surface, &surf_x, &surf_y, - &surf_width, &surf_height); - - switch (shsurf->fullscreen.type) { - case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT: - if (surface->buffer_ref.buffer) - center_on_output(shsurf->view, shsurf->fullscreen_output); - break; - case WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE: - /* 1:1 mapping between surface and output dimensions */ - if (output->width == surf_width && - output->height == surf_height) { - weston_view_set_position(shsurf->view, - output->x - surf_x, - output->y - surf_y); - break; - } - - matrix = &shsurf->fullscreen.transform.matrix; - weston_matrix_init(matrix); - - output_aspect = (float) output->width / - (float) output->height; - /* XXX: Use surf_width and surf_height here? */ - surface_aspect = (float) surface->width / - (float) surface->height; - if (output_aspect < surface_aspect) - scale = (float) output->width / - (float) surf_width; - else - scale = (float) output->height / - (float) surf_height; - - weston_matrix_scale(matrix, scale, scale, 1); - wl_list_remove(&shsurf->fullscreen.transform.link); - wl_list_insert(&shsurf->view->geometry.transformation_list, - &shsurf->fullscreen.transform.link); - x = output->x + (output->width - surf_width * scale) / 2 - surf_x; - y = output->y + (output->height - surf_height * scale) / 2 - surf_y; - weston_view_set_position(shsurf->view, x, y); - - break; - case WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER: - if (shell_surface_is_top_fullscreen(shsurf)) { - struct weston_mode mode = {0, - surf_width * surface->buffer_viewport.scale, - surf_height * surface->buffer_viewport.scale, - shsurf->fullscreen.framerate}; - - if (weston_output_switch_mode(output, &mode, surface->buffer_viewport.scale, - WESTON_MODE_SWITCH_SET_TEMPORARY) == 0) { - weston_view_set_position(shsurf->view, - output->x - surf_x, - output->y - surf_y); - shsurf->fullscreen.black_view->surface->width = output->width; - shsurf->fullscreen.black_view->surface->height = output->height; - weston_view_set_position(shsurf->fullscreen.black_view, - output->x - surf_x, - output->y - surf_y); - break; - } else { - restore_output_mode(output); - center_on_output(shsurf->view, output); - } - } - break; - case WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL: - center_on_output(shsurf->view, output); - break; - default: - break; - } -} - -static void -shell_map_fullscreen(struct shell_surface *shsurf) -{ - shell_configure_fullscreen(shsurf); -} - -static void -set_xwayland(struct shell_surface *shsurf, int x, int y, uint32_t flags) -{ - /* XXX: using the same fields for transient type */ - surface_clear_next_states(shsurf); - shsurf->transient.x = x; - shsurf->transient.y = y; - shsurf->transient.flags = flags; - - shell_surface_set_parent(shsurf, NULL); - - shsurf->type = SHELL_SURFACE_XWAYLAND; - shsurf->state_changed = true; -} - -static const struct weston_pointer_grab_interface popup_grab_interface; - -static void -destroy_shell_seat(struct wl_listener *listener, void *data) -{ - struct shell_seat *shseat = - container_of(listener, - struct shell_seat, seat_destroy_listener); - struct shell_surface *shsurf, *prev = NULL; - - if (shseat->popup_grab.grab.interface == &popup_grab_interface) { - weston_pointer_end_grab(shseat->popup_grab.grab.pointer); - shseat->popup_grab.client = NULL; - - wl_list_for_each(shsurf, &shseat->popup_grab.surfaces_list, popup.grab_link) { - shsurf->popup.shseat = NULL; - if (prev) { - wl_list_init(&prev->popup.grab_link); - } - prev = shsurf; - } - wl_list_init(&prev->popup.grab_link); - } - - wl_list_remove(&shseat->seat_destroy_listener.link); - free(shseat); -} - -static struct shell_seat * -create_shell_seat(struct weston_seat *seat) -{ - struct shell_seat *shseat; - - shseat = calloc(1, sizeof *shseat); - if (!shseat) { - weston_log("no memory to allocate shell seat\n"); - return NULL; - } - - shseat->seat = seat; - wl_list_init(&shseat->popup_grab.surfaces_list); - - shseat->seat_destroy_listener.notify = destroy_shell_seat; - wl_signal_add(&seat->destroy_signal, - &shseat->seat_destroy_listener); - - return shseat; -} - -static struct shell_seat * -get_shell_seat(struct weston_seat *seat) -{ - struct wl_listener *listener; - - listener = wl_signal_get(&seat->destroy_signal, destroy_shell_seat); - if (listener == NULL) - return create_shell_seat(seat); - - return container_of(listener, - struct shell_seat, seat_destroy_listener); -} - -static void -popup_grab_focus(struct weston_pointer_grab *grab) -{ - struct weston_pointer *pointer = grab->pointer; - struct weston_view *view; - struct shell_seat *shseat = - container_of(grab, struct shell_seat, popup_grab.grab); - struct wl_client *client = shseat->popup_grab.client; - wl_fixed_t sx, sy; - - view = weston_compositor_pick_view(pointer->seat->compositor, - pointer->x, pointer->y, - &sx, &sy); - - if (view && view->surface->resource && - wl_resource_get_client(view->surface->resource) == client) { - weston_pointer_set_focus(pointer, view, sx, sy); - } else { - weston_pointer_set_focus(pointer, NULL, - wl_fixed_from_int(0), - wl_fixed_from_int(0)); - } -} - -static void -popup_grab_motion(struct weston_pointer_grab *grab, uint32_t time, - wl_fixed_t x, wl_fixed_t y) -{ - struct weston_pointer *pointer = grab->pointer; - struct wl_resource *resource; - wl_fixed_t sx, sy; - - weston_pointer_move(pointer, x, y); - - wl_resource_for_each(resource, &pointer->focus_resource_list) { - weston_view_from_global_fixed(pointer->focus, - pointer->x, pointer->y, - &sx, &sy); - wl_pointer_send_motion(resource, time, sx, sy); - } -} - -static void -popup_grab_button(struct weston_pointer_grab *grab, - uint32_t time, uint32_t button, uint32_t state_w) -{ - struct wl_resource *resource; - struct shell_seat *shseat = - container_of(grab, struct shell_seat, popup_grab.grab); - struct wl_display *display = shseat->seat->compositor->wl_display; - enum wl_pointer_button_state state = state_w; - uint32_t serial; - struct wl_list *resource_list; - - resource_list = &grab->pointer->focus_resource_list; - if (!wl_list_empty(resource_list)) { - serial = wl_display_get_serial(display); - wl_resource_for_each(resource, resource_list) { - wl_pointer_send_button(resource, serial, - time, button, state); - } - } else if (state == WL_POINTER_BUTTON_STATE_RELEASED && - (shseat->popup_grab.initial_up || - time - shseat->seat->pointer->grab_time > 500)) { - popup_grab_end(grab->pointer); - } - - if (state == WL_POINTER_BUTTON_STATE_RELEASED) - shseat->popup_grab.initial_up = 1; -} - -static void -popup_grab_cancel(struct weston_pointer_grab *grab) -{ - popup_grab_end(grab->pointer); -} - -static const struct weston_pointer_grab_interface popup_grab_interface = { - popup_grab_focus, - popup_grab_motion, - popup_grab_button, - popup_grab_cancel, -}; - -static void -shell_surface_send_popup_done(struct shell_surface *shsurf) -{ - if (shell_surface_is_wl_shell_surface(shsurf)) - wl_shell_surface_send_popup_done(shsurf->resource); - else if (shell_surface_is_xdg_popup(shsurf)) - xdg_popup_send_popup_done(shsurf->resource, - shsurf->popup.serial); -} - -static void -popup_grab_end(struct weston_pointer *pointer) -{ - struct weston_pointer_grab *grab = pointer->grab; - struct shell_seat *shseat = - container_of(grab, struct shell_seat, popup_grab.grab); - struct shell_surface *shsurf; - struct shell_surface *prev = NULL; - - if (pointer->grab->interface == &popup_grab_interface) { - weston_pointer_end_grab(grab->pointer); - shseat->popup_grab.client = NULL; - shseat->popup_grab.grab.interface = NULL; - assert(!wl_list_empty(&shseat->popup_grab.surfaces_list)); - /* Send the popup_done event to all the popups open */ - wl_list_for_each(shsurf, &shseat->popup_grab.surfaces_list, popup.grab_link) { - shell_surface_send_popup_done(shsurf); - shsurf->popup.shseat = NULL; - if (prev) { - wl_list_init(&prev->popup.grab_link); - } - prev = shsurf; - } - wl_list_init(&prev->popup.grab_link); - wl_list_init(&shseat->popup_grab.surfaces_list); - } -} - -static void -add_popup_grab(struct shell_surface *shsurf, struct shell_seat *shseat) -{ - struct weston_seat *seat = shseat->seat; - - if (wl_list_empty(&shseat->popup_grab.surfaces_list)) { - shseat->popup_grab.client = wl_resource_get_client(shsurf->resource); - shseat->popup_grab.grab.interface = &popup_grab_interface; - /* We must make sure here that this popup was opened after - * a mouse press, and not just by moving around with other - * popups already open. */ - if (shseat->seat->pointer->button_count > 0) - shseat->popup_grab.initial_up = 0; - - wl_list_insert(&shseat->popup_grab.surfaces_list, &shsurf->popup.grab_link); - weston_pointer_start_grab(seat->pointer, &shseat->popup_grab.grab); - } else { - wl_list_insert(&shseat->popup_grab.surfaces_list, &shsurf->popup.grab_link); - } -} - -static void -remove_popup_grab(struct shell_surface *shsurf) -{ - struct shell_seat *shseat = shsurf->popup.shseat; - - wl_list_remove(&shsurf->popup.grab_link); - wl_list_init(&shsurf->popup.grab_link); - if (wl_list_empty(&shseat->popup_grab.surfaces_list)) { - weston_pointer_end_grab(shseat->popup_grab.grab.pointer); - shseat->popup_grab.grab.interface = NULL; - } -} - -static void -shell_map_popup(struct shell_surface *shsurf) -{ - struct shell_seat *shseat = shsurf->popup.shseat; - struct weston_view *parent_view = get_default_view(shsurf->parent); - - shsurf->surface->output = parent_view->output; - shsurf->view->output = parent_view->output; - - weston_view_set_transform_parent(shsurf->view, parent_view); - weston_view_set_position(shsurf->view, shsurf->popup.x, shsurf->popup.y); - weston_view_update_transform(shsurf->view); - - if (shseat->seat->pointer->grab_serial == shsurf->popup.serial) { - add_popup_grab(shsurf, shseat); - } else { - shell_surface_send_popup_done(shsurf); - shseat->popup_grab.client = NULL; - } -} - -static const struct wl_shell_surface_interface shell_surface_implementation = { - shell_surface_pong, - shell_surface_move, - shell_surface_resize, - shell_surface_set_toplevel, - shell_surface_set_transient, - shell_surface_set_fullscreen, - shell_surface_set_popup, - shell_surface_set_maximized, - shell_surface_set_title, - shell_surface_set_class -}; - -static void -destroy_shell_surface(struct shell_surface *shsurf) -{ - struct shell_surface *child, *next; - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_destroy) { - (*shell_hook_destroy)(shsurf->surface); - } - - wl_signal_emit(&shsurf->destroy_signal, shsurf); - - if (!wl_list_empty(&shsurf->popup.grab_link)) { - remove_popup_grab(shsurf); - } - - if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER && - shell_surface_is_top_fullscreen(shsurf)) - restore_output_mode (shsurf->fullscreen_output); - - if (shsurf->fullscreen.black_view) - weston_surface_destroy(shsurf->fullscreen.black_view->surface); - - /* As destroy_resource() use wl_list_for_each_safe(), - * we can always remove the listener. - */ - wl_list_remove(&shsurf->surface_destroy_listener.link); - shsurf->surface->configure = NULL; - ping_timer_destroy(shsurf); - free(shsurf->title); - - weston_view_destroy(shsurf->view); - - wl_list_remove(&shsurf->children_link); - wl_list_for_each_safe(child, next, &shsurf->children_list, children_link) { - wl_list_remove(&child->children_link); - child->parent = NULL; - } - - wl_list_remove(&shsurf->link); - free(shsurf); -} - -static void -shell_destroy_shell_surface(struct wl_resource *resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - destroy_shell_surface(shsurf); -} - -static void -shell_handle_surface_destroy(struct wl_listener *listener, void *data) -{ - struct shell_surface *shsurf = container_of(listener, - struct shell_surface, - surface_destroy_listener); - - if (shsurf->resource) - wl_resource_destroy(shsurf->resource); - else - destroy_shell_surface(shsurf); -} - -static void -shell_surface_configure(struct weston_surface *, int32_t, int32_t); -static void -shell_surface_output_destroyed(struct weston_surface *); - -struct shell_surface * -get_shell_surface(struct weston_surface *surface) -{ - if (surface->configure == shell_surface_configure) - return surface->configure_private; - else - return NULL; -} - -static struct shell_surface * -create_common_surface(void *shell, struct weston_surface *surface, - const struct weston_shell_client *client) -{ - struct shell_surface *shsurf; - - if (surface->configure) { - weston_log("surface->configure already set\n"); - return NULL; - } - - shsurf = calloc(1, sizeof *shsurf); - if (!shsurf) { - weston_log("no memory to allocate shell surface\n"); - return NULL; - } - - shsurf->view = weston_view_create(surface); - if (!shsurf->view) { - weston_log("no memory to allocate shell surface\n"); - free(shsurf); - return NULL; - } - - surface->configure = shell_surface_configure; - surface->configure_private = shsurf; - surface->output_destroyed = shell_surface_output_destroyed; - - shsurf->shell = (struct desktop_shell *) shell; - shsurf->unresponsive = 0; - shsurf->saved_position_valid = false; - shsurf->saved_size_valid = false; - shsurf->saved_rotation_valid = false; - shsurf->surface = surface; - shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT; - shsurf->fullscreen.framerate = 0; - shsurf->fullscreen.black_view = NULL; - shsurf->ping_timer = NULL; - - /* set default color and shader because weston original bug(some time crash weston) */ - weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0); - - wl_list_init(&shsurf->fullscreen.transform.link); - - wl_signal_init(&shsurf->destroy_signal); - shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy; - wl_signal_add(&surface->destroy_signal, - &shsurf->surface_destroy_listener); - - /* init link so its safe to always remove it in destroy_shell_surface */ - wl_list_init(&shsurf->link); - wl_list_init(&shsurf->popup.grab_link); - - /* empty when not in use */ - wl_list_init(&shsurf->rotation.transform.link); - weston_matrix_init(&shsurf->rotation.rotation); - - wl_list_init(&shsurf->workspace_transform.link); - - wl_list_init(&shsurf->children_link); - wl_list_init(&shsurf->children_list); - shsurf->parent = NULL; - - shsurf->type = SHELL_SURFACE_NONE; - - shsurf->client = client; - - return shsurf; -} - -static struct shell_surface * -create_shell_surface(void *shell, struct weston_surface *surface, - const struct weston_shell_client *client) -{ - return create_common_surface(shell, surface, client); -} - -static struct weston_view * -get_primary_view(void *shell, struct shell_surface *shsurf) -{ - return shsurf->view; -} - -static void -shell_get_shell_surface(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct shell_surface *shsurf; - - if (get_shell_surface(surface)) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "desktop_shell::get_shell_surface already requested"); - return; - } - - shsurf = create_shell_surface(shell, surface, &shell_client); - if (!shsurf) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "surface->configure already set"); - return; - } - - /* if ico_window_mgr hook, call hook routine */ - shsurf->layertype = LAYER_TYPE_PANEL; - if (shell_hook_create) { - (*shell_hook_create)(LAYER_TYPE_PANEL, surface, client, shsurf); - } - - shsurf->resource = - wl_resource_create(client, - &wl_shell_surface_interface, 1, id); - wl_resource_set_implementation(shsurf->resource, - &shell_surface_implementation, - shsurf, shell_destroy_shell_surface); -} - -static bool -shell_surface_is_wl_shell_surface(struct shell_surface *shsurf) -{ - return wl_resource_instance_of(shsurf->resource, - &wl_shell_surface_interface, - &shell_surface_implementation); -} - -static const struct wl_shell_interface shell_implementation = { - shell_get_shell_surface -}; - -/**************************** - * xdg-shell implementation */ - -static void -xdg_surface_destroy(struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void -xdg_surface_pong(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - surface_pong(shsurf, serial); -} - -static void -xdg_surface_set_app_id(struct wl_client *client, - struct wl_resource *resource, - const char *app_id) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - free(shsurf->class); - shsurf->class = strdup(app_id); -} - -static void -xdg_surface_set_title(struct wl_client *client, - struct wl_resource *resource, const char *title) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - set_title(shsurf, title); -} - -static void -xdg_surface_move(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat_resource, uint32_t serial) -{ - common_surface_move(resource, seat_resource, serial); -} - -static void -xdg_surface_resize(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat_resource, uint32_t serial, - uint32_t edges) -{ - common_surface_resize(resource, seat_resource, serial, edges); -} - -static void -xdg_surface_set_output(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output_resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - struct weston_output *output; - - if (output_resource) - output = wl_resource_get_user_data(output_resource); - else - output = NULL; - - shsurf->recommended_output = output; -} - -static void -xdg_surface_set_fullscreen(struct wl_client *client, - struct wl_resource *resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - if (shsurf->type != SHELL_SURFACE_TOPLEVEL) - return; - - if (!shsurf->next_state.fullscreen) - set_fullscreen(shsurf, - WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, - 0, shsurf->recommended_output); -} - -static void -xdg_surface_unset_fullscreen(struct wl_client *client, - struct wl_resource *resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - int32_t width, height; - - if (shsurf->type != SHELL_SURFACE_TOPLEVEL) - return; - - if (!shsurf->next_state.fullscreen) - return; - - shsurf->next_state.fullscreen = false; - shsurf->state_changed = true; - - if (shsurf->saved_size_valid) { - width = shsurf->saved_width; - height = shsurf->saved_height; - shsurf->saved_size_valid = false; - } else { - width = shsurf->surface->width; - height = shsurf->surface->height; - } - - if (shell_hook_fullscreen) { - (*shell_hook_fullscreen)(SHELL_FULLSCREEN_UNSET, shsurf->surface); - } - - shsurf->client->send_configure(shsurf->surface, 0, width, height); -} - -static void -xdg_surface_set_maximized(struct wl_client *client, - struct wl_resource *resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - if (shsurf->type != SHELL_SURFACE_TOPLEVEL) - return; - - if (!shsurf->next_state.maximized) - set_maximized(shsurf, NULL); -} - -static void -xdg_surface_unset_maximized(struct wl_client *client, - struct wl_resource *resource) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - int32_t width, height; - - if (shsurf->type != SHELL_SURFACE_TOPLEVEL) - return; - - if (!shsurf->next_state.maximized) - return; - - shsurf->next_state.maximized = false; - shsurf->state_changed = true; - - if (shsurf->saved_size_valid) { - width = shsurf->saved_width; - height = shsurf->saved_height; - shsurf->saved_size_valid = false; - } else { - width = shsurf->surface->width; - height = shsurf->surface->height; - } - - shsurf->client->send_configure(shsurf->surface, 0, width, height); -} - -static const struct xdg_surface_interface xdg_surface_implementation = { - xdg_surface_destroy, - xdg_surface_set_transient_for, - xdg_surface_set_title, - xdg_surface_set_app_id, - xdg_surface_pong, - xdg_surface_move, - xdg_surface_resize, - xdg_surface_set_output, - xdg_surface_set_fullscreen, - xdg_surface_unset_fullscreen, - xdg_surface_set_maximized, - xdg_surface_unset_maximized, - NULL /* set_minimized */ -}; - -static void -xdg_send_configure(struct weston_surface *surface, - uint32_t edges, int32_t width, int32_t height) -{ - struct shell_surface *shsurf = get_shell_surface(surface); - - assert(shsurf); - - xdg_surface_send_configure(shsurf->resource, edges, width, height); -} - -static const struct weston_shell_client xdg_client = { - xdg_send_configure -}; - -static void -xdg_use_unstable_version(struct wl_client *client, - struct wl_resource *resource, - int32_t version) -{ - if (version > 1) { - wl_resource_post_error(resource, - 1, - "xdg-shell:: version not implemented yet."); - return; - } -} - -static struct shell_surface * -create_xdg_surface(void *shell, struct weston_surface *surface, - const struct weston_shell_client *client) -{ - struct shell_surface *shsurf; - - shsurf = create_common_surface(shell, surface, client); - shsurf->type = SHELL_SURFACE_TOPLEVEL; - - return shsurf; -} - -static void -xdg_get_xdg_surface(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct shell_surface *shsurf; - - if (get_shell_surface(surface)) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "desktop_shell::get_shell_surface already requested"); - return; - } - - shsurf = create_xdg_surface(shell, surface, &xdg_client); - if (!shsurf) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "surface->configure already set"); - return; - } - - /* if ico_window_mgr hook, call hook routine */ - shsurf->layertype = LAYER_TYPE_PANEL; - if (shell_hook_create) { - (*shell_hook_create)(LAYER_TYPE_PANEL, surface, client, shsurf); - } - - shsurf->resource = - wl_resource_create(client, - &xdg_surface_interface, 1, id); - wl_resource_set_implementation(shsurf->resource, - &xdg_surface_implementation, - shsurf, shell_destroy_shell_surface); -} - -static bool -shell_surface_is_xdg_surface(struct shell_surface *shsurf) -{ - return wl_resource_instance_of(shsurf->resource, - &xdg_surface_interface, - &xdg_surface_implementation); -} - -/* xdg-popup implementation */ - -static void -xdg_popup_destroy(struct wl_client *client, - struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void -xdg_popup_pong(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - surface_pong(shsurf, serial); -} - -static const struct xdg_popup_interface xdg_popup_implementation = { - xdg_popup_destroy, - xdg_popup_pong -}; - -static void -xdg_popup_send_configure(struct weston_surface *surface, - uint32_t edges, int32_t width, int32_t height) -{ -} - -static const struct weston_shell_client xdg_popup_client = { - xdg_popup_send_configure -}; - -static struct shell_surface * -create_xdg_popup(void *shell, struct weston_surface *surface, - const struct weston_shell_client *client, - struct weston_surface *parent, - struct shell_seat *seat, - uint32_t serial, - int32_t x, int32_t y) -{ - struct shell_surface *shsurf; - - shsurf = create_common_surface(shell, surface, client); - shsurf->type = SHELL_SURFACE_POPUP; - shsurf->popup.shseat = seat; - shsurf->popup.serial = serial; - shsurf->popup.x = x; - shsurf->popup.y = y; - shell_surface_set_parent(shsurf, parent); - - return shsurf; -} - -static void -xdg_get_xdg_popup(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface_resource, - struct wl_resource *parent_resource, - struct wl_resource *seat_resource, - uint32_t serial, - int32_t x, int32_t y, uint32_t flags) -{ - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct shell_surface *shsurf; - struct weston_surface *parent; - struct shell_seat *seat; - - if (get_shell_surface(surface)) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "desktop_shell::get_shell_surface already requested"); - return; - } - - if (!parent_resource) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "xdg_shell::get_xdg_popup requires a parent shell surface"); - } - - parent = wl_resource_get_user_data(parent_resource); - seat = get_shell_seat(wl_resource_get_user_data(seat_resource));; - - shsurf = create_xdg_popup(shell, surface, &xdg_popup_client, - parent, seat, serial, x, y); - if (!shsurf) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "surface->configure already set"); - return; - } - - /* if ico_window_mgr hook, call hook routine */ - shsurf->layertype = LAYER_TYPE_PANEL; - if (shell_hook_create) { - (*shell_hook_create)(LAYER_TYPE_PANEL, surface, client, shsurf); - } - - shsurf->resource = - wl_resource_create(client, - &xdg_popup_interface, 1, id); - wl_resource_set_implementation(shsurf->resource, - &xdg_popup_implementation, - shsurf, shell_destroy_shell_surface); -} - -static bool -shell_surface_is_xdg_popup(struct shell_surface *shsurf) -{ - return wl_resource_instance_of(shsurf->resource, - &xdg_popup_interface, - &xdg_popup_implementation); -} - -static const struct xdg_shell_interface xdg_implementation = { - xdg_use_unstable_version, - xdg_get_xdg_surface, - xdg_get_xdg_popup -}; - -static int -xdg_shell_unversioned_dispatch(const void *implementation, - void *_target, uint32_t opcode, - const struct wl_message *message, - union wl_argument *args) -{ - struct wl_resource *resource = _target; - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - if (opcode != 0) { - wl_resource_post_error(resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "must call use_unstable_version first"); - return 0; - } - -#define XDG_SERVER_VERSION 1 - - static_assert(XDG_SERVER_VERSION == XDG_SHELL_VERSION_CURRENT, - "shell implementation doesn't match protocol version"); - - if (args[0].i != XDG_SERVER_VERSION) { - wl_resource_post_error(resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "incompatible version, server is %d " - "client wants %d", - XDG_SERVER_VERSION, args[0].i); - return 0; - } - - wl_resource_set_implementation(resource, &xdg_implementation, - shell, NULL); - - return 1; -} - -/* end of xdg-shell implementation */ -/***********************************/ - -static void -shell_fade(struct desktop_shell *shell, enum fade_type type); - -static int -screensaver_timeout(void *data) -{ - struct desktop_shell *shell = data; - - shell_fade(shell, FADE_OUT); - - return 1; -} - -static void -handle_screensaver_sigchld(struct weston_process *proc, int status) -{ - struct desktop_shell *shell = - container_of(proc, struct desktop_shell, screensaver.process); - - proc->pid = 0; - - if (shell->locked) - weston_compositor_sleep(shell->compositor); -} - -static void -launch_screensaver(struct desktop_shell *shell) -{ - if (shell->screensaver.binding) - return; - - if (!shell->screensaver.path) { - weston_compositor_sleep(shell->compositor); - return; - } - - if (shell->screensaver.process.pid != 0) { - weston_log("old screensaver still running\n"); - return; - } - - weston_client_launch(shell->compositor, - &shell->screensaver.process, - shell->screensaver.path, - handle_screensaver_sigchld); -} - -static void -terminate_screensaver(struct desktop_shell *shell) -{ - if (shell->screensaver.process.pid == 0) - return; - - kill(shell->screensaver.process.pid, SIGTERM); -} - -static void -configure_static_view(struct weston_view *ev, struct weston_layer *layer) -{ - struct weston_view *v, *next; - - wl_list_for_each_safe(v, next, &layer->view_list, layer_link) { - if (v->output == ev->output && v != ev) { - weston_view_unmap(v); - v->surface->configure = NULL; - } - } - - weston_view_set_position(ev, ev->output->x, ev->output->y); - - if (wl_list_empty(&ev->layer_link)) { - wl_list_insert(&layer->view_list, &ev->layer_link); - weston_compositor_schedule_repaint(ev->surface->compositor); - } - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_configure) { - (*shell_hook_configure)(ev->surface); - } -} - -static void -background_configure(struct weston_surface *es, int32_t sx, int32_t sy) -{ - struct desktop_shell *shell = es->configure_private; - struct weston_view *view; - - view = container_of(es->views.next, struct weston_view, surface_link); - - configure_static_view(view, &shell->background_layer); -} - -static void -desktop_shell_set_background(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output_resource, - struct wl_resource *surface_resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct weston_view *view, *next; - - if (surface->configure) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "surface role already assigned"); - return; - } - - wl_list_for_each_safe(view, next, &surface->views, surface_link) - weston_view_destroy(view); - view = weston_view_create(surface); - - surface->configure = background_configure; - surface->configure_private = shell; - surface->output = wl_resource_get_user_data(output_resource); - view->output = surface->output; - desktop_shell_send_configure(resource, 0, - surface_resource, - surface->output->width, - surface->output->height); -} - -static void -panel_configure(struct weston_surface *es, int32_t sx, int32_t sy) -{ - struct desktop_shell *shell = es->configure_private; - struct weston_view *view; - - view = container_of(es->views.next, struct weston_view, surface_link); - - configure_static_view(view, &shell->panel_layer); -} - -static void -desktop_shell_set_panel(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output_resource, - struct wl_resource *surface_resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct weston_view *view, *next; - - if (surface->configure) { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "surface role already assigned"); - return; - } - - wl_list_for_each_safe(view, next, &surface->views, surface_link) - weston_view_destroy(view); - view = weston_view_create(surface); - - surface->configure = panel_configure; - surface->configure_private = shell; - surface->output = wl_resource_get_user_data(output_resource); - view->output = surface->output; - desktop_shell_send_configure(resource, 0, - surface_resource, - surface->output->width, - surface->output->height); -} - -static void -lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy) -{ - struct desktop_shell *shell = surface->configure_private; - struct weston_view *view; - - view = container_of(surface->views.next, struct weston_view, surface_link); - - if (surface->width == 0) - return; - - center_on_output(view, get_default_output(shell->compositor)); - - if (!weston_surface_is_mapped(surface)) { - wl_list_insert(&shell->lock_layer.view_list, - &view->layer_link); - weston_view_update_transform(view); - shell_fade(shell, FADE_IN); - } -} - -static void -handle_lock_surface_destroy(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, lock_surface_listener); - - weston_log("lock surface gone\n"); - shell->lock_surface = NULL; -} - -static void -desktop_shell_set_lock_surface(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - - shell->prepare_event_sent = false; - - if (!shell->locked) - return; - - shell->lock_surface = surface; - - shell->lock_surface_listener.notify = handle_lock_surface_destroy; - wl_signal_add(&surface->destroy_signal, - &shell->lock_surface_listener); - - weston_view_create(surface); - surface->configure = lock_surface_configure; - surface->configure_private = shell; -} - -static void -resume_desktop(struct desktop_shell *shell) -{ - struct workspace *ws = get_current_workspace(shell); - - terminate_screensaver(shell); - - wl_list_remove(&shell->lock_layer.link); - wl_list_insert(&shell->compositor->cursor_layer.link, - &shell->fullscreen_layer.link); - wl_list_insert(&shell->fullscreen_layer.link, - &shell->panel_layer.link); - if (shell->showing_input_panels) { - wl_list_insert(&shell->panel_layer.link, - &shell->input_panel_layer.link); - wl_list_insert(&shell->input_panel_layer.link, - &ws->layer.link); - } else { - wl_list_insert(&shell->panel_layer.link, &ws->layer.link); - } - - restore_focus_state(shell, get_current_workspace(shell)); - - shell->locked = false; - shell_fade(shell, FADE_IN); - weston_compositor_damage_all(shell->compositor); -} - -static void -desktop_shell_unlock(struct wl_client *client, - struct wl_resource *resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - shell->prepare_event_sent = false; - - if (shell->locked) - resume_desktop(shell); -} - -static void -desktop_shell_set_grab_surface(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - shell->grab_surface = wl_resource_get_user_data(surface_resource); - weston_view_create(shell->grab_surface); -} - -static void -desktop_shell_desktop_ready(struct wl_client *client, - struct wl_resource *resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - shell_fade_startup(shell); -} - -static const struct desktop_shell_interface desktop_shell_implementation = { - desktop_shell_set_background, - desktop_shell_set_panel, - desktop_shell_set_lock_surface, - desktop_shell_unlock, - desktop_shell_set_grab_surface, - desktop_shell_desktop_ready -}; - -static enum shell_surface_type -get_shell_surface_type(struct weston_surface *surface) -{ - struct shell_surface *shsurf; - - shsurf = get_shell_surface(surface); - if (!shsurf) - return SHELL_SURFACE_NONE; - return shsurf->type; -} - -static void -move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data) -{ - struct weston_surface *focus; - struct weston_surface *surface; - struct shell_surface *shsurf; - - if (seat->pointer->focus == NULL) - return; - - focus = seat->pointer->focus->surface; - - surface = weston_surface_get_main_surface(focus); - if (surface == NULL) - return; - - shsurf = get_shell_surface(surface); - if (shsurf == NULL || shsurf->state.fullscreen || - shsurf->state.maximized) - return; - - surface_move(shsurf, (struct weston_seat *) seat); -} - -static void -maximize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data) -{ - struct weston_surface *focus = seat->pointer->focus->surface; - struct weston_surface *surface; - struct shell_surface *shsurf; - - surface = weston_surface_get_main_surface(focus); - if (surface == NULL) - return; - - shsurf = get_shell_surface(surface); - if (shsurf == NULL) - return; - - if (!shell_surface_is_xdg_surface(shsurf)) - return; - - if (shsurf->state.maximized) - xdg_surface_send_request_unset_maximized(shsurf->resource); - else - xdg_surface_send_request_set_maximized(shsurf->resource); -} - -static void -fullscreen_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data) -{ - struct weston_surface *focus = seat->pointer->focus->surface; - struct weston_surface *surface; - struct shell_surface *shsurf; - - surface = weston_surface_get_main_surface(focus); - if (surface == NULL) - return; - - shsurf = get_shell_surface(surface); - if (shsurf == NULL) - return; - - if (!shell_surface_is_xdg_surface(shsurf)) - return; - - if (shsurf->state.fullscreen) - xdg_surface_send_request_unset_fullscreen(shsurf->resource); - else - xdg_surface_send_request_set_fullscreen(shsurf->resource); -} - -static void -touch_move_binding(struct weston_seat *seat, uint32_t time, void *data) -{ - struct weston_surface *focus = seat->touch->focus->surface; - struct weston_surface *surface; - struct shell_surface *shsurf; - - surface = weston_surface_get_main_surface(focus); - if (surface == NULL) - return; - - shsurf = get_shell_surface(surface); - if (shsurf == NULL || shsurf->state.fullscreen || - shsurf->state.maximized) - return; - - surface_touch_move(shsurf, (struct weston_seat *) seat); -} - -static void -resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data) -{ - struct weston_surface *focus; - struct weston_surface *surface; - uint32_t edges = 0; - int32_t x, y; - struct shell_surface *shsurf; - - if (seat->pointer->focus == NULL) - return; - - focus = seat->pointer->focus->surface; - - surface = weston_surface_get_main_surface(focus); - if (surface == NULL) - return; - - shsurf = get_shell_surface(surface); - if (shsurf == NULL || shsurf->state.fullscreen || - shsurf->state.maximized) - return; - - weston_view_from_global(shsurf->view, - wl_fixed_to_int(seat->pointer->grab_x), - wl_fixed_to_int(seat->pointer->grab_y), - &x, &y); - - if (x < shsurf->surface->width / 3) - edges |= WL_SHELL_SURFACE_RESIZE_LEFT; - else if (x < 2 * shsurf->surface->width / 3) - edges |= 0; - else - edges |= WL_SHELL_SURFACE_RESIZE_RIGHT; - - if (y < shsurf->surface->height / 3) - edges |= WL_SHELL_SURFACE_RESIZE_TOP; - else if (y < 2 * shsurf->surface->height / 3) - edges |= 0; - else - edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM; - - surface_resize(shsurf, (struct weston_seat *) seat, edges); -} - -static void -surface_opacity_binding(struct weston_seat *seat, uint32_t time, uint32_t axis, - wl_fixed_t value, void *data) -{ - float step = 0.005; - struct shell_surface *shsurf; - struct weston_surface *focus = seat->pointer->focus->surface; - struct weston_surface *surface; - - /* XXX: broken for windows containing sub-surfaces */ - surface = weston_surface_get_main_surface(focus); - if (surface == NULL) - return; - - shsurf = get_shell_surface(surface); - if (!shsurf) - return; - - shsurf->view->alpha -= wl_fixed_to_double(value) * step; - - if (shsurf->view->alpha > 1.0) - shsurf->view->alpha = 1.0; - if (shsurf->view->alpha < step) - shsurf->view->alpha = step; - - weston_view_geometry_dirty(shsurf->view); - weston_surface_damage(surface); -} - -static void -do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis, - wl_fixed_t value) -{ - struct weston_seat *ws = (struct weston_seat *) seat; - struct weston_compositor *compositor = ws->compositor; - struct weston_output *output; - float increment; - - wl_list_for_each(output, &compositor->output_list, link) { - if (pixman_region32_contains_point(&output->region, - wl_fixed_to_double(seat->pointer->x), - wl_fixed_to_double(seat->pointer->y), - NULL)) { - if (key == KEY_PAGEUP) - increment = output->zoom.increment; - else if (key == KEY_PAGEDOWN) - increment = -output->zoom.increment; - else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - /* For every pixel zoom 20th of a step */ - increment = output->zoom.increment * - -wl_fixed_to_double(value) / 20.0; - else - increment = 0; - - output->zoom.level += increment; - - if (output->zoom.level < 0.0) - output->zoom.level = 0.0; - else if (output->zoom.level > output->zoom.max_level) - output->zoom.level = output->zoom.max_level; - else if (!output->zoom.active) { - weston_output_activate_zoom(output); - } - - output->zoom.spring_z.target = output->zoom.level; - - weston_output_update_zoom(output); - } - } -} - -static void -zoom_axis_binding(struct weston_seat *seat, uint32_t time, uint32_t axis, - wl_fixed_t value, void *data) -{ - do_zoom(seat, time, 0, axis, value); -} - -static void -zoom_key_binding(struct weston_seat *seat, uint32_t time, uint32_t key, - void *data) -{ - do_zoom(seat, time, key, 0, 0); -} - -static void -terminate_binding(struct weston_seat *seat, uint32_t time, uint32_t key, - void *data) -{ - struct weston_compositor *compositor = data; - - wl_display_terminate(compositor->wl_display); -} - -static void -rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time, - wl_fixed_t x, wl_fixed_t y) -{ - struct rotate_grab *rotate = - container_of(grab, struct rotate_grab, base.grab); - struct weston_pointer *pointer = grab->pointer; - struct shell_surface *shsurf = rotate->base.shsurf; - float cx, cy, dx, dy, cposx, cposy, dposx, dposy, r; - - weston_pointer_move(pointer, x, y); - - if (!shsurf) - return; - - cx = 0.5f * shsurf->surface->width; - cy = 0.5f * shsurf->surface->height; - - dx = wl_fixed_to_double(pointer->x) - rotate->center.x; - dy = wl_fixed_to_double(pointer->y) - rotate->center.y; - r = sqrtf(dx * dx + dy * dy); - - wl_list_remove(&shsurf->rotation.transform.link); - weston_view_geometry_dirty(shsurf->view); - - if (r > 20.0f) { - struct weston_matrix *matrix = - &shsurf->rotation.transform.matrix; - - weston_matrix_init(&rotate->rotation); - weston_matrix_rotate_xy(&rotate->rotation, dx / r, dy / r); - - weston_matrix_init(matrix); - weston_matrix_translate(matrix, -cx, -cy, 0.0f); - weston_matrix_multiply(matrix, &shsurf->rotation.rotation); - weston_matrix_multiply(matrix, &rotate->rotation); - weston_matrix_translate(matrix, cx, cy, 0.0f); - - wl_list_insert( - &shsurf->view->geometry.transformation_list, - &shsurf->rotation.transform.link); - } else { - wl_list_init(&shsurf->rotation.transform.link); - weston_matrix_init(&shsurf->rotation.rotation); - weston_matrix_init(&rotate->rotation); - } - - /* We need to adjust the position of the surface - * in case it was resized in a rotated state before */ - cposx = shsurf->view->geometry.x + cx; - cposy = shsurf->view->geometry.y + cy; - dposx = rotate->center.x - cposx; - dposy = rotate->center.y - cposy; - if (dposx != 0.0f || dposy != 0.0f) { - weston_view_set_position(shsurf->view, - shsurf->view->geometry.x + dposx, - shsurf->view->geometry.y + dposy); - } - - /* Repaint implies weston_surface_update_transform(), which - * lazily applies the damage due to rotation update. - */ - weston_compositor_schedule_repaint(shsurf->surface->compositor); -} - -static void -rotate_grab_button(struct weston_pointer_grab *grab, - uint32_t time, uint32_t button, uint32_t state_w) -{ - struct rotate_grab *rotate = - container_of(grab, struct rotate_grab, base.grab); - struct weston_pointer *pointer = grab->pointer; - struct shell_surface *shsurf = rotate->base.shsurf; - enum wl_pointer_button_state state = state_w; - - if (pointer->button_count == 0 && - state == WL_POINTER_BUTTON_STATE_RELEASED) { - if (shsurf) - weston_matrix_multiply(&shsurf->rotation.rotation, - &rotate->rotation); - shell_grab_end(&rotate->base); - free(rotate); - } -} - -static void -rotate_grab_cancel(struct weston_pointer_grab *grab) -{ - struct rotate_grab *rotate = - container_of(grab, struct rotate_grab, base.grab); - - shell_grab_end(&rotate->base); - free(rotate); -} - -static const struct weston_pointer_grab_interface rotate_grab_interface = { - noop_grab_focus, - rotate_grab_motion, - rotate_grab_button, - rotate_grab_cancel, -}; - -static void -surface_rotate(struct shell_surface *surface, struct weston_seat *seat) -{ - struct rotate_grab *rotate; - float dx, dy; - float r; - - rotate = malloc(sizeof *rotate); - if (!rotate) - return; - - weston_view_to_global_float(surface->view, - surface->surface->width * 0.5f, - surface->surface->height * 0.5f, - &rotate->center.x, &rotate->center.y); - - dx = wl_fixed_to_double(seat->pointer->x) - rotate->center.x; - dy = wl_fixed_to_double(seat->pointer->y) - rotate->center.y; - r = sqrtf(dx * dx + dy * dy); - if (r > 20.0f) { - struct weston_matrix inverse; - - weston_matrix_init(&inverse); - weston_matrix_rotate_xy(&inverse, dx / r, -dy / r); - weston_matrix_multiply(&surface->rotation.rotation, &inverse); - - weston_matrix_init(&rotate->rotation); - weston_matrix_rotate_xy(&rotate->rotation, dx / r, dy / r); - } else { - weston_matrix_init(&surface->rotation.rotation); - weston_matrix_init(&rotate->rotation); - } - - shell_grab_start(&rotate->base, &rotate_grab_interface, surface, - seat->pointer, DESKTOP_SHELL_CURSOR_ARROW); -} - -static void -rotate_binding(struct weston_seat *seat, uint32_t time, uint32_t button, - void *data) -{ - struct weston_surface *focus; - struct weston_surface *base_surface; - struct shell_surface *surface; - - if (seat->pointer->focus == NULL) - return; - - focus = seat->pointer->focus->surface; - - base_surface = weston_surface_get_main_surface(focus); - if (base_surface == NULL) - return; - - surface = get_shell_surface(base_surface); - if (surface == NULL || surface->state.fullscreen || - surface->state.maximized) - return; - - surface_rotate(surface, seat); -} - -/* Move all fullscreen layers down to the current workspace in a non-reversible - * manner. This should be used when implementing shell-wide overlays, such as - * the alt-tab switcher, which need to de-promote fullscreen layers. */ -void -lower_fullscreen_layer(struct desktop_shell *shell) -{ - struct workspace *ws; - struct weston_view *view, *prev; - - if (shell_hook_fullscreen) { - (*shell_hook_fullscreen)(SHELL_FULLSCREEN_HIDEALL, NULL); - return; - } - - ws = get_current_workspace(shell); - wl_list_for_each_reverse_safe(view, prev, - &shell->fullscreen_layer.view_list, - layer_link) { - wl_list_remove(&view->layer_link); - wl_list_insert(&ws->layer.view_list, &view->layer_link); - weston_view_damage_below(view); - weston_surface_damage(view->surface); - } -} - -void -activate(struct desktop_shell *shell, struct weston_surface *es, - struct weston_seat *seat) -{ - struct weston_surface *main_surface; - struct focus_state *state; - struct workspace *ws; - struct weston_surface *old_es; - struct shell_surface *shsurf; - - main_surface = weston_surface_get_main_surface(es); - - weston_surface_activate(es, seat); - - state = ensure_focus_state(shell, seat); - if (state == NULL) - return; - - old_es = state->keyboard_focus; - focus_state_set_focus(state, es); - - shsurf = get_shell_surface(main_surface); - assert(shsurf); - - /* if ico_window_mgr hook, not change surface stack */ - if (shell_hook_select) { - return; - } - - if (shsurf->state.fullscreen) - shell_configure_fullscreen(shsurf); - else - restore_all_output_modes(shell->compositor); - - if (shell->focus_animation_type != ANIMATION_NONE) { - ws = get_current_workspace(shell); - animate_focus_change(shell, ws, get_default_view(old_es), get_default_view(es)); - } - - /* Update the surface’s layer. This brings it to the top of the stacking - * order as appropriate. */ - shell_surface_update_layer(shsurf); -} - -/* no-op func for checking black surface */ -static void -black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy) -{ -} - -static bool -is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface) -{ - if (es->configure == black_surface_configure) { - if (fs_surface) - *fs_surface = (struct weston_surface *)es->configure_private; - return true; - } - return false; -} - -static void -activate_binding(struct weston_seat *seat, - struct desktop_shell *shell, - struct weston_surface *focus) -{ - struct weston_surface *main_surface; - - if (!focus) - return; - - if (is_black_surface(focus, &main_surface)) - focus = main_surface; - - main_surface = weston_surface_get_main_surface(focus); - if (get_shell_surface_type(main_surface) == SHELL_SURFACE_NONE) - return; - - activate(shell, focus, seat); - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_select) { - (*shell_hook_select)(focus); - } -} - -static void -click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t button, - void *data) -{ - if (seat->pointer->grab != &seat->pointer->default_grab) - return; - if (seat->pointer->focus == NULL) - return; - - activate_binding(seat, data, seat->pointer->focus->surface); -} - -static void -touch_to_activate_binding(struct weston_seat *seat, uint32_t time, void *data) -{ - if (seat->touch->grab != &seat->touch->default_grab) - return; - if (seat->touch->focus == NULL) - return; - - activate_binding(seat, data, seat->touch->focus->surface); -} - -static void -lock(struct desktop_shell *shell) -{ - struct workspace *ws = get_current_workspace(shell); - - if (shell->locked) { - weston_compositor_sleep(shell->compositor); - return; - } - - shell->locked = true; - - /* Hide all surfaces by removing the fullscreen, panel and - * toplevel layers. This way nothing else can show or receive - * input events while we are locked. */ - - wl_list_remove(&shell->panel_layer.link); - wl_list_remove(&shell->fullscreen_layer.link); - if (shell->showing_input_panels) - wl_list_remove(&shell->input_panel_layer.link); - wl_list_remove(&ws->layer.link); - wl_list_insert(&shell->compositor->cursor_layer.link, - &shell->lock_layer.link); - - launch_screensaver(shell); - - /* TODO: disable bindings that should not work while locked. */ - - /* All this must be undone in resume_desktop(). */ -} - -static void -unlock(struct desktop_shell *shell) -{ - if (!shell->locked || shell->lock_surface) { - shell_fade(shell, FADE_IN); - return; - } - - /* If desktop-shell client has gone away, unlock immediately. */ - if (!shell->child.desktop_shell) { - resume_desktop(shell); - return; - } - - if (shell->prepare_event_sent) - return; - - desktop_shell_send_prepare_lock_surface(shell->child.desktop_shell); - shell->prepare_event_sent = true; -} - -static void -shell_fade_done(struct weston_view_animation *animation, void *data) -{ - struct desktop_shell *shell = data; - - shell->fade.animation = NULL; - - switch (shell->fade.type) { - case FADE_IN: - weston_surface_destroy(shell->fade.view->surface); - shell->fade.view = NULL; - break; - case FADE_OUT: - lock(shell); - break; - default: - break; - } -} - -static struct weston_view * -shell_fade_create_surface(struct desktop_shell *shell) -{ - struct weston_compositor *compositor = shell->compositor; - struct weston_surface *surface; - struct weston_view *view; - - surface = weston_surface_create(compositor); - if (!surface) - return NULL; - - view = weston_view_create(surface); - if (!view) { - weston_surface_destroy(surface); - return NULL; - } - - weston_surface_set_size(surface, 8192, 8192); - weston_view_set_position(view, 0, 0); - weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0); - wl_list_insert(&compositor->fade_layer.view_list, - &view->layer_link); - pixman_region32_init(&surface->input); - - return view; -} - -static void -shell_fade(struct desktop_shell *shell, enum fade_type type) -{ - float tint; - - switch (type) { - case FADE_IN: - tint = 0.0; - break; - case FADE_OUT: - tint = 1.0; - break; - default: - weston_log("shell: invalid fade type\n"); - return; - } - - shell->fade.type = type; - - if (shell->fade.view == NULL) { - shell->fade.view = shell_fade_create_surface(shell); - if (!shell->fade.view) - return; - - shell->fade.view->alpha = 1.0 - tint; - weston_view_update_transform(shell->fade.view); - } - - if (shell->fade.view->output == NULL) { - /* If the black view gets a NULL output, we lost the - * last output and we'll just cancel the fade. This - * happens when you close the last window under the - * X11 or Wayland backends. */ - shell->locked = false; - weston_surface_destroy(shell->fade.view->surface); - shell->fade.view = NULL; - } else if (shell->fade.animation) { - weston_fade_update(shell->fade.animation, tint); - } else { - shell->fade.animation = - weston_fade_run(shell->fade.view, - 1.0 - tint, tint, 300.0, - shell_fade_done, shell); - } -} - -static void -do_shell_fade_startup(void *data) -{ - struct desktop_shell *shell = data; - - if (shell->startup_animation_type == ANIMATION_FADE) - shell_fade(shell, FADE_IN); - else if (shell->startup_animation_type == ANIMATION_NONE) { - weston_surface_destroy(shell->fade.view->surface); - shell->fade.view = NULL; - } -} - -static void -shell_fade_startup(struct desktop_shell *shell) -{ - struct wl_event_loop *loop; - - if (!shell->fade.startup_timer) - return; - - wl_event_source_remove(shell->fade.startup_timer); - shell->fade.startup_timer = NULL; - - loop = wl_display_get_event_loop(shell->compositor->wl_display); - wl_event_loop_add_idle(loop, do_shell_fade_startup, shell); -} - -static int -fade_startup_timeout(void *data) -{ - struct desktop_shell *shell = data; - - shell_fade_startup(shell); - return 0; -} - -static void -shell_fade_init(struct desktop_shell *shell) -{ - /* Make compositor output all black, and wait for the desktop-shell - * client to signal it is ready, then fade in. The timer triggers a - * fade-in, in case the desktop-shell client takes too long. - */ - - struct wl_event_loop *loop; - - if (shell->fade.view != NULL) { - weston_log("%s: warning: fade surface already exists\n", - __func__); - return; - } - - shell->fade.view = shell_fade_create_surface(shell); - if (!shell->fade.view) - return; - - weston_view_update_transform(shell->fade.view); - weston_surface_damage(shell->fade.view->surface); - - loop = wl_display_get_event_loop(shell->compositor->wl_display); - shell->fade.startup_timer = - wl_event_loop_add_timer(loop, fade_startup_timeout, shell); - wl_event_source_timer_update(shell->fade.startup_timer, 15000); -} - -static void -idle_handler(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, idle_listener); - struct weston_seat *seat; - - wl_list_for_each(seat, &shell->compositor->seat_list, link) - if (seat->pointer) - popup_grab_end(seat->pointer); - - shell_fade(shell, FADE_OUT); - /* lock() is called from shell_fade_done() */ -} - -static void -wake_handler(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, wake_listener); - - unlock(shell); -} - -static void -center_on_output(struct weston_view *view, struct weston_output *output) -{ - int32_t surf_x, surf_y, width, height; - float x, y; - - surface_subsurfaces_boundingbox(view->surface, &surf_x, &surf_y, &width, &height); - - x = output->x + (output->width - width) / 2 - surf_x / 2; - y = output->y + (output->height - height) / 2 - surf_y / 2; - - weston_view_set_position(view, x, y); -} - -static void -weston_view_set_initial_position(struct weston_view *view, - struct desktop_shell *shell) -{ - struct weston_compositor *compositor = shell->compositor; - int ix = 0, iy = 0; - int range_x, range_y; - int dx, dy, x, y, panel_height; - struct weston_output *output, *target_output = NULL; - struct weston_seat *seat; - - /* As a heuristic place the new window on the same output as the - * pointer. Falling back to the output containing 0, 0. - * - * TODO: Do something clever for touch too? - */ - wl_list_for_each(seat, &compositor->seat_list, link) { - if (seat->pointer) { - ix = wl_fixed_to_int(seat->pointer->x); - iy = wl_fixed_to_int(seat->pointer->y); - break; - } - } - - wl_list_for_each(output, &compositor->output_list, link) { - if (pixman_region32_contains_point(&output->region, ix, iy, NULL)) { - target_output = output; - break; - } - } - - if (!target_output) { - weston_view_set_position(view, 10 + random() % 400, - 10 + random() % 400); - return; - } - - /* Valid range within output where the surface will still be onscreen. - * If this is negative it means that the surface is bigger than - * output. - */ - panel_height = get_output_panel_height(shell, target_output); - range_x = target_output->width - view->surface->width; - range_y = (target_output->height - panel_height) - - view->surface->height; - - if (range_x > 0) - dx = random() % range_x; - else - dx = 0; - - if (range_y > 0) - dy = panel_height + random() % range_y; - else - dy = panel_height; - - x = target_output->x + dx; - y = target_output->y + dy; - - weston_view_set_position(view, x, y); -} - -static void -map(struct desktop_shell *shell, struct shell_surface *shsurf, - int32_t sx, int32_t sy) -{ - struct weston_compositor *compositor = shell->compositor; - struct weston_seat *seat; - int panel_height = 0; - int32_t surf_x, surf_y; - - /* initial positioning, see also configure() */ - switch (shsurf->type) { - case SHELL_SURFACE_TOPLEVEL: - if (shsurf->state.fullscreen) { - center_on_output(shsurf->view, shsurf->fullscreen_output); - shell_map_fullscreen(shsurf); - } else if (shsurf->state.maximized) { - /* use surface configure to set the geometry */ - panel_height = get_output_panel_height(shell, shsurf->output); - surface_subsurfaces_boundingbox(shsurf->surface, - &surf_x, &surf_y, NULL, NULL); - weston_view_set_position(shsurf->view, - shsurf->output->x - surf_x, - shsurf->output->y + - panel_height - surf_y); - } else if (!shsurf->state.relative) { - weston_view_set_initial_position(shsurf->view, shell); - } - break; - case SHELL_SURFACE_POPUP: - shell_map_popup(shsurf); - break; - case SHELL_SURFACE_NONE: - if (shsurf->layertype == LAYER_TYPE_INPUTPANEL) { - weston_view_set_initial_position(shsurf->view, shell); - } - else { - weston_view_set_position(shsurf->view, - shsurf->view->geometry.x + sx, - shsurf->view->geometry.y + sy); - } - break; - case SHELL_SURFACE_XWAYLAND: - default: - ; - } - - /* Surface stacking order, see also activate(). */ - shell_surface_update_layer(shsurf); - - if (shsurf->type != SHELL_SURFACE_NONE) { - weston_view_update_transform(shsurf->view); - if (shsurf->state.maximized) { - shsurf->surface->output = shsurf->output; - shsurf->view->output = shsurf->output; - } - } - - if ((shsurf->type == SHELL_SURFACE_XWAYLAND || shsurf->state.relative) && - shsurf->transient.flags == WL_SHELL_SURFACE_TRANSIENT_INACTIVE) { - } - - switch (shsurf->type) { - /* XXX: xwayland's using the same fields for transient type */ - case SHELL_SURFACE_XWAYLAND: - if (shsurf->transient.flags == - WL_SHELL_SURFACE_TRANSIENT_INACTIVE) - break; - case SHELL_SURFACE_TOPLEVEL: - if (shsurf->state.relative && - shsurf->transient.flags == WL_SHELL_SURFACE_TRANSIENT_INACTIVE) - break; - if (shell->locked) - break; - wl_list_for_each(seat, &compositor->seat_list, link) - activate(shell, shsurf->surface, seat); - break; - case SHELL_SURFACE_POPUP: - case SHELL_SURFACE_NONE: - default: - break; - } - - if (shsurf->type == SHELL_SURFACE_TOPLEVEL && - !shsurf->state.maximized && !shsurf->state.fullscreen) - { - switch (shell->win_animation_type) { - case ANIMATION_FADE: - weston_fade_run(shsurf->view, 0.0, 1.0, 300.0, NULL, NULL); - break; - case ANIMATION_ZOOM: - weston_zoom_run(shsurf->view, 0.5, 1.0, NULL, NULL); - break; - case ANIMATION_NONE: - default: - break; - } - } - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_map) { - sx = shsurf->view->geometry.x; - sy = shsurf->view->geometry.y; - (*shell_hook_map)(shsurf->surface, - &shsurf->surface->width, &shsurf->surface->height, &sx, &sy); - } - if (shell_hook_configure) { - (*shell_hook_configure)(shsurf->surface); /* send event to manager */ - } -} - -static void -configure(struct desktop_shell *shell, struct weston_surface *surface, - float x, float y) -{ - struct shell_surface *shsurf; - struct weston_view *view; - int32_t mx, my, surf_x, surf_y; - - shsurf = get_shell_surface(surface); - - assert(shsurf); - - if (shsurf->state.fullscreen) - shell_configure_fullscreen(shsurf); - else if (shsurf->state.maximized) { - /* setting x, y and using configure to change that geometry */ - surface_subsurfaces_boundingbox(shsurf->surface, &surf_x, &surf_y, - NULL, NULL); - mx = shsurf->output->x - surf_x; - my = shsurf->output->y + - get_output_panel_height(shell,shsurf->output) - surf_y; - weston_view_set_position(shsurf->view, mx, my); - } else { - weston_view_set_position(shsurf->view, x, y); - } - - /* XXX: would a fullscreen surface need the same handling? */ - if (surface->output) { - wl_list_for_each(view, &surface->views, surface_link) - weston_view_update_transform(view); - - if (shsurf->state.maximized) - surface->output = shsurf->output; - } - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_configure) { - (*shell_hook_configure)(surface); - } -} - -static void -shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy) -{ - struct shell_surface *shsurf = get_shell_surface(es); - struct desktop_shell *shell; - int type_changed = 0; - - assert(shsurf); - - shell = shsurf->shell; - - if (!weston_surface_is_mapped(es) && - !wl_list_empty(&shsurf->popup.grab_link)) { - remove_popup_grab(shsurf); - } - - if (es->width == 0) - return; - - if (shsurf->state_changed) { - set_surface_type(shsurf); - type_changed = 1; - } - - if (!weston_surface_is_mapped(es)) { - map(shell, shsurf, sx, sy); - } else if (type_changed || sx != 0 || sy != 0 || - shsurf->last_width != es->width || - shsurf->last_height != es->height) { - shsurf->last_width = es->width; - shsurf->last_height = es->height; - float from_x, from_y; - float to_x, to_y; - - weston_view_to_global_float(shsurf->view, 0, 0, &from_x, &from_y); - weston_view_to_global_float(shsurf->view, sx, sy, &to_x, &to_y); - configure(shell, es, - shsurf->view->geometry.x + to_x - from_x, - shsurf->view->geometry.y + to_y - from_y); - } -} - -static void -shell_surface_output_destroyed(struct weston_surface *es) -{ - struct shell_surface *shsurf = get_shell_surface(es); - - assert(shsurf); - - shsurf->saved_position_valid = false; - shsurf->next_state.maximized = false; - shsurf->next_state.fullscreen = false; - shsurf->state_changed = true; -} - -static void launch_desktop_shell_process(void *data); - -static void -desktop_shell_sigchld(struct weston_process *process, int status) -{ - uint32_t time; - struct desktop_shell *shell = - container_of(process, struct desktop_shell, child.process); - - shell->child.process.pid = 0; - shell->child.client = NULL; /* already destroyed by wayland */ - - /* if desktop-shell dies more than 5 times in 30 seconds, give up */ - time = weston_compositor_get_time(); - if (time - shell->child.deathstamp > 30000) { - shell->child.deathstamp = time; - shell->child.deathcount = 0; - } - - shell->child.deathcount++; - if (shell->child.deathcount > 5) { - weston_log("%s died, giving up.\n", shell->client); - return; - } - - weston_log("%s died, respawning...\n", shell->client); - launch_desktop_shell_process(shell); - shell_fade_startup(shell); -} - -static void -desktop_shell_client_destroy(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell; - - shell = container_of(listener, struct desktop_shell, - child.client_destroy_listener); - - shell->child.client = NULL; -} - -static void -launch_desktop_shell_process(void *data) -{ - struct desktop_shell *shell = data; - - /* if shell client(ex. desktop-shell) not exsit, not launch */ - if ((shell->client == NULL) || (shell->client[0] == 0) || (shell->client[0] == ' ')) { - weston_log("no shell program\n"); - } - else { - uifw_trace("launch_desktop_shell_process: launch %s", shell->client); - shell->child.client = weston_client_launch(shell->compositor, - &shell->child.process, - shell->client, - desktop_shell_sigchld); - - if (!shell->child.client) - weston_log("not able to start %s\n", shell->client); - else - weston_log("shell %s started\n", shell->client); - shell->child.client_destroy_listener.notify = - desktop_shell_client_destroy; - wl_client_add_destroy_listener(shell->child.client, - &shell->child.client_destroy_listener); - } -} - -static void -bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - struct desktop_shell *shell = data; - struct wl_resource *resource; - - resource = wl_resource_create(client, &wl_shell_interface, 1, id); - if (resource) - wl_resource_set_implementation(resource, &shell_implementation, - shell, NULL); - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_bind) { - (*shell_hook_bind)(client, data); - } -} - -static void -bind_xdg_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - struct desktop_shell *shell = data; - struct wl_resource *resource; - - resource = wl_resource_create(client, &xdg_shell_interface, 1, id); - if (resource) - wl_resource_set_dispatcher(resource, - xdg_shell_unversioned_dispatch, - NULL, shell, NULL); - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_bind) { - (*shell_hook_bind)(client, data); - } -} - -static void -unbind_desktop_shell(struct wl_resource *resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_unbind) { - (*shell_hook_unbind)(wl_resource_get_client(resource)); - } - - if (shell->locked) - resume_desktop(shell); - - shell->child.desktop_shell = NULL; - shell->prepare_event_sent = false; -} - -static void -bind_desktop_shell(struct wl_client *client, - void *data, uint32_t version, uint32_t id) -{ - struct desktop_shell *shell = data; - struct wl_resource *resource; - - resource = wl_resource_create(client, &desktop_shell_interface, - MIN(version, 2), id); - - if (client == shell->child.client) { - wl_resource_set_implementation(resource, - &desktop_shell_implementation, - shell, unbind_desktop_shell); - shell->child.desktop_shell = resource; - - if (version < 2) - shell_fade_startup(shell); - - return; - } - - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "permission to bind desktop_shell denied"); - wl_resource_destroy(resource); -} - -static void -screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy) -{ - struct desktop_shell *shell = surface->configure_private; - struct weston_view *view; - - if (surface->width == 0) - return; - - /* XXX: starting weston-screensaver beforehand does not work */ - if (!shell->locked) - return; - - view = container_of(surface->views.next, struct weston_view, surface_link); - center_on_output(view, surface->output); - - if (wl_list_empty(&view->layer_link)) { - wl_list_insert(shell->lock_layer.view_list.prev, - &view->layer_link); - weston_view_update_transform(view); - wl_event_source_timer_update(shell->screensaver.timer, - shell->screensaver.duration); - shell_fade(shell, FADE_IN); - } -} - -static void -screensaver_set_surface(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource, - struct wl_resource *output_resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct weston_output *output = wl_resource_get_user_data(output_resource); - struct weston_view *view, *next; - - /* Make sure we only have one view */ - wl_list_for_each_safe(view, next, &surface->views, surface_link) - weston_view_destroy(view); - weston_view_create(surface); - - surface->configure = screensaver_configure; - surface->configure_private = shell; - surface->output = output; -} - -static const struct screensaver_interface screensaver_implementation = { - screensaver_set_surface -}; - -static void -unbind_screensaver(struct wl_resource *resource) -{ - struct desktop_shell *shell = wl_resource_get_user_data(resource); - - shell->screensaver.binding = NULL; -} - -static void -bind_screensaver(struct wl_client *client, - void *data, uint32_t version, uint32_t id) -{ - struct desktop_shell *shell = data; - struct wl_resource *resource; - - resource = wl_resource_create(client, &screensaver_interface, 1, id); - - if (shell->screensaver.binding == NULL) { - wl_resource_set_implementation(resource, - &screensaver_implementation, - shell, unbind_screensaver); - shell->screensaver.binding = resource; - return; - } - - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "interface object already bound"); - wl_resource_destroy(resource); -} - -struct switcher { - struct desktop_shell *shell; - struct weston_surface *current; - struct wl_listener listener; - struct weston_keyboard_grab grab; -}; - -static void -switcher_next(struct switcher *switcher) -{ - struct weston_view *view; - struct weston_surface *first = NULL, *prev = NULL, *next = NULL; - struct shell_surface *shsurf; - struct workspace *ws = get_current_workspace(switcher->shell); - - wl_list_for_each(view, &ws->layer.view_list, layer_link) { - shsurf = get_shell_surface(view->surface); - if (shsurf && - shsurf->type == SHELL_SURFACE_TOPLEVEL && - shsurf->parent == NULL) { - if (first == NULL) - first = view->surface; - if (prev == switcher->current) - next = view->surface; - prev = view->surface; - view->alpha = 0.25; - weston_view_geometry_dirty(view); - weston_surface_damage(view->surface); - } - - if (is_black_surface(view->surface, NULL)) { - view->alpha = 0.25; - weston_view_geometry_dirty(view); - weston_surface_damage(view->surface); - } - } - - if (next == NULL) - next = first; - - if (next == NULL) - return; - - wl_list_remove(&switcher->listener.link); - wl_signal_add(&next->destroy_signal, &switcher->listener); - - switcher->current = next; - wl_list_for_each(view, &next->views, surface_link) - view->alpha = 1.0; - - shsurf = get_shell_surface(switcher->current); - if (shsurf && shsurf->state.fullscreen) - shsurf->fullscreen.black_view->alpha = 1.0; -} - -static void -switcher_handle_surface_destroy(struct wl_listener *listener, void *data) -{ - struct switcher *switcher = - container_of(listener, struct switcher, listener); - - switcher_next(switcher); -} - -static void -switcher_destroy(struct switcher *switcher) -{ - struct weston_view *view; - struct weston_keyboard *keyboard = switcher->grab.keyboard; - struct workspace *ws = get_current_workspace(switcher->shell); - - wl_list_for_each(view, &ws->layer.view_list, layer_link) { - if (is_focus_view(view)) - continue; - - view->alpha = 1.0; - weston_surface_damage(view->surface); - } - - if (switcher->current) - activate(switcher->shell, switcher->current, - (struct weston_seat *) keyboard->seat); - wl_list_remove(&switcher->listener.link); - weston_keyboard_end_grab(keyboard); - if (keyboard->input_method_resource) - keyboard->grab = &keyboard->input_method_grab; - free(switcher); -} - -static void -switcher_key(struct weston_keyboard_grab *grab, - uint32_t time, uint32_t key, uint32_t state_w) -{ - struct switcher *switcher = container_of(grab, struct switcher, grab); - enum wl_keyboard_key_state state = state_w; - - if (key == KEY_TAB && state == WL_KEYBOARD_KEY_STATE_PRESSED) - switcher_next(switcher); -} - -static void -switcher_modifier(struct weston_keyboard_grab *grab, uint32_t serial, - uint32_t mods_depressed, uint32_t mods_latched, - uint32_t mods_locked, uint32_t group) -{ - struct switcher *switcher = container_of(grab, struct switcher, grab); - struct weston_seat *seat = (struct weston_seat *) grab->keyboard->seat; - - if ((seat->modifier_state & switcher->shell->binding_modifier) == 0) - switcher_destroy(switcher); -} - -static void -switcher_cancel(struct weston_keyboard_grab *grab) -{ - struct switcher *switcher = container_of(grab, struct switcher, grab); - - switcher_destroy(switcher); -} - -static const struct weston_keyboard_grab_interface switcher_grab = { - switcher_key, - switcher_modifier, - switcher_cancel, -}; - -static void -switcher_binding(struct weston_seat *seat, uint32_t time, uint32_t key, - void *data) -{ - struct desktop_shell *shell = data; - struct switcher *switcher; - - switcher = malloc(sizeof *switcher); - switcher->shell = shell; - switcher->current = NULL; - switcher->listener.notify = switcher_handle_surface_destroy; - wl_list_init(&switcher->listener.link); - - restore_all_output_modes(shell->compositor); - lower_fullscreen_layer(switcher->shell); - switcher->grab.interface = &switcher_grab; - weston_keyboard_start_grab(seat->keyboard, &switcher->grab); - weston_keyboard_set_focus(seat->keyboard, NULL); - switcher_next(switcher); -} - -static void -backlight_binding(struct weston_seat *seat, uint32_t time, uint32_t key, - void *data) -{ - struct weston_compositor *compositor = data; - struct weston_output *output; - long backlight_new = 0; - - /* TODO: we're limiting to simple use cases, where we assume just - * control on the primary display. We'd have to extend later if we - * ever get support for setting backlights on random desktop LCD - * panels though */ - output = get_default_output(compositor); - if (!output) - return; - - if (!output->set_backlight) - return; - - if (key == KEY_F9 || key == KEY_BRIGHTNESSDOWN) - backlight_new = output->backlight_current - 25; - else if (key == KEY_F10 || key == KEY_BRIGHTNESSUP) - backlight_new = output->backlight_current + 25; - - if (backlight_new < 5) - backlight_new = 5; - if (backlight_new > 255) - backlight_new = 255; - - output->backlight_current = backlight_new; - output->set_backlight(output, output->backlight_current); -} - -struct debug_binding_grab { - struct weston_keyboard_grab grab; - struct weston_seat *seat; - uint32_t key[2]; - int key_released[2]; -}; - -static void -debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time, - uint32_t key, uint32_t state) -{ - struct debug_binding_grab *db = (struct debug_binding_grab *) grab; - struct weston_compositor *ec = db->seat->compositor; - struct wl_display *display = ec->wl_display; - struct wl_resource *resource; - uint32_t serial; - int send = 0, terminate = 0; - int check_binding = 1; - int i; - struct wl_list *resource_list; - - if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { - /* Do not run bindings on key releases */ - check_binding = 0; - - for (i = 0; i < 2; i++) - if (key == db->key[i]) - db->key_released[i] = 1; - - if (db->key_released[0] && db->key_released[1]) { - /* All key releases been swalled so end the grab */ - terminate = 1; - } else if (key != db->key[0] && key != db->key[1]) { - /* Should not swallow release of other keys */ - send = 1; - } - } else if (key == db->key[0] && !db->key_released[0]) { - /* Do not check bindings for the first press of the binding - * key. This allows it to be used as a debug shortcut. - * We still need to swallow this event. */ - check_binding = 0; - } else if (db->key[1]) { - /* If we already ran a binding don't process another one since - * we can't keep track of all the binding keys that were - * pressed in order to swallow the release events. */ - send = 1; - check_binding = 0; - } - - if (check_binding) { - if (weston_compositor_run_debug_binding(ec, db->seat, time, - key, state)) { - /* We ran a binding so swallow the press and keep the - * grab to swallow the released too. */ - send = 0; - terminate = 0; - db->key[1] = key; - } else { - /* Terminate the grab since the key pressed is not a - * debug binding key. */ - send = 1; - terminate = 1; - } - } - - if (send) { - serial = wl_display_next_serial(display); - resource_list = &grab->keyboard->focus_resource_list; - wl_resource_for_each(resource, resource_list) { - wl_keyboard_send_key(resource, serial, time, key, state); - } - } - - if (terminate) { - weston_keyboard_end_grab(grab->keyboard); - if (grab->keyboard->input_method_resource) - grab->keyboard->grab = &grab->keyboard->input_method_grab; - free(db); - } -} - -static void -debug_binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, - uint32_t mods_depressed, uint32_t mods_latched, - uint32_t mods_locked, uint32_t group) -{ - struct wl_resource *resource; - struct wl_list *resource_list; - - resource_list = &grab->keyboard->focus_resource_list; - - wl_resource_for_each(resource, resource_list) { - wl_keyboard_send_modifiers(resource, serial, mods_depressed, - mods_latched, mods_locked, group); - } -} - -static void -debug_binding_cancel(struct weston_keyboard_grab *grab) -{ - struct debug_binding_grab *db = (struct debug_binding_grab *) grab; - - weston_keyboard_end_grab(grab->keyboard); - free(db); -} - -struct weston_keyboard_grab_interface debug_binding_keyboard_grab = { - debug_binding_key, - debug_binding_modifiers, - debug_binding_cancel, -}; - -static void -debug_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data) -{ - struct debug_binding_grab *grab; - - grab = calloc(1, sizeof *grab); - if (!grab) - return; - - grab->seat = (struct weston_seat *) seat; - grab->key[0] = key; - grab->grab.interface = &debug_binding_keyboard_grab; - weston_keyboard_start_grab(seat->keyboard, &grab->grab); -} - -static void -force_kill_binding(struct weston_seat *seat, uint32_t time, uint32_t key, - void *data) -{ - struct weston_surface *focus_surface; - struct wl_client *client; - struct desktop_shell *shell = data; - struct weston_compositor *compositor = shell->compositor; - pid_t pid; - - focus_surface = seat->keyboard->focus; - if (!focus_surface) - return; - - wl_signal_emit(&compositor->kill_signal, focus_surface); - - client = wl_resource_get_client(focus_surface->resource); - wl_client_get_credentials(client, &pid, NULL, NULL); - - /* Skip clients that we launched ourselves (the credentials of - * the socketpair is ours) */ - if (pid == getpid()) - return; - - kill(pid, SIGKILL); -} - -static void -workspace_up_binding(struct weston_seat *seat, uint32_t time, - uint32_t key, void *data) -{ - struct desktop_shell *shell = data; - unsigned int new_index = shell->workspaces.current; - - if (shell->locked) - return; - if (new_index != 0) - new_index--; - - change_workspace(shell, new_index); -} - -static void -workspace_down_binding(struct weston_seat *seat, uint32_t time, - uint32_t key, void *data) -{ - struct desktop_shell *shell = data; - unsigned int new_index = shell->workspaces.current; - - if (shell->locked) - return; - if (new_index < shell->workspaces.num - 1) - new_index++; - - change_workspace(shell, new_index); -} - -static void -workspace_f_binding(struct weston_seat *seat, uint32_t time, - uint32_t key, void *data) -{ - struct desktop_shell *shell = data; - unsigned int new_index; - - if (shell->locked) - return; - new_index = key - KEY_F1; - if (new_index >= shell->workspaces.num) - new_index = shell->workspaces.num - 1; - - change_workspace(shell, new_index); -} - -static void -workspace_move_surface_up_binding(struct weston_seat *seat, uint32_t time, - uint32_t key, void *data) -{ - struct desktop_shell *shell = data; - unsigned int new_index = shell->workspaces.current; - - if (shell->locked) - return; - - if (new_index != 0) - new_index--; - - take_surface_to_workspace_by_seat(shell, seat, new_index); -} - -static void -workspace_move_surface_down_binding(struct weston_seat *seat, uint32_t time, - uint32_t key, void *data) -{ - struct desktop_shell *shell = data; - unsigned int new_index = shell->workspaces.current; - - if (shell->locked) - return; - - if (new_index < shell->workspaces.num - 1) - new_index++; - - take_surface_to_workspace_by_seat(shell, seat, new_index); -} - -static void -handle_output_destroy(struct wl_listener *listener, void *data) -{ - struct shell_output *output_listener = - container_of(listener, struct shell_output, destroy_listener); - - wl_list_remove(&output_listener->destroy_listener.link); - wl_list_remove(&output_listener->link); - free(output_listener); -} - -static void -create_shell_output(struct desktop_shell *shell, - struct weston_output *output) -{ - struct shell_output *shell_output; - - shell_output = zalloc(sizeof *shell_output); - if (shell_output == NULL) - return; - - shell_output->output = output; - shell_output->shell = shell; - shell_output->destroy_listener.notify = handle_output_destroy; - wl_signal_add(&output->destroy_signal, - &shell_output->destroy_listener); - wl_list_insert(shell->output_list.prev, &shell_output->link); -} - -static void -handle_output_create(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, output_create_listener); - struct weston_output *output = (struct weston_output *)data; - - create_shell_output(shell, output); -} - -static void -setup_output_destroy_handler(struct weston_compositor *ec, - struct desktop_shell *shell) -{ - struct weston_output *output; - - wl_list_init(&shell->output_list); - wl_list_for_each(output, &ec->output_list, link) - create_shell_output(shell, output); - - shell->output_create_listener.notify = handle_output_create; - wl_signal_add(&ec->output_created_signal, - &shell->output_create_listener); -} - -static void -shell_destroy(struct wl_listener *listener, void *data) -{ - struct desktop_shell *shell = - container_of(listener, struct desktop_shell, destroy_listener); - struct workspace **ws; - struct shell_output *shell_output, *tmp; - - /* Force state to unlocked so we don't try to fade */ - shell->locked = false; - if (shell->child.client) - wl_client_destroy(shell->child.client); - - wl_list_remove(&shell->idle_listener.link); - wl_list_remove(&shell->wake_listener.link); - - input_panel_destroy(shell); - - wl_list_for_each_safe(shell_output, tmp, &shell->output_list, link) { - wl_list_remove(&shell_output->destroy_listener.link); - wl_list_remove(&shell_output->link); - free(shell_output); - } - - wl_list_remove(&shell->output_create_listener.link); - - wl_array_for_each(ws, &shell->workspaces.array) - workspace_destroy(*ws); - wl_array_release(&shell->workspaces.array); - - free(shell->screensaver.path); - free(shell->client); - free(shell); -} - -static void -shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) -{ - uint32_t mod; - int i, num_workspace_bindings; - - /* fixed bindings */ - weston_compositor_add_key_binding(ec, KEY_BACKSPACE, - MODIFIER_CTRL | MODIFIER_ALT, - terminate_binding, ec); - weston_compositor_add_button_binding(ec, BTN_LEFT, 0, - click_to_activate_binding, - shell); - weston_compositor_add_touch_binding(ec, 0, - touch_to_activate_binding, - shell); - weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL, - MODIFIER_SUPER | MODIFIER_ALT, - surface_opacity_binding, NULL); - weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL, - MODIFIER_SUPER, zoom_axis_binding, - NULL); - - /* configurable bindings */ - mod = shell->binding_modifier; - weston_compositor_add_key_binding(ec, KEY_PAGEUP, mod, - zoom_key_binding, NULL); - weston_compositor_add_key_binding(ec, KEY_PAGEDOWN, mod, - zoom_key_binding, NULL); - weston_compositor_add_key_binding(ec, KEY_M, mod | MODIFIER_SHIFT, - maximize_binding, NULL); - weston_compositor_add_key_binding(ec, KEY_F, mod | MODIFIER_SHIFT, - fullscreen_binding, NULL); - weston_compositor_add_button_binding(ec, BTN_LEFT, mod, move_binding, - shell); - weston_compositor_add_touch_binding(ec, mod, touch_move_binding, shell); - weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod, - resize_binding, shell); - weston_compositor_add_button_binding(ec, BTN_LEFT, - mod | MODIFIER_SHIFT, - resize_binding, shell); - - if (ec->capabilities & WESTON_CAP_ROTATION_ANY) - weston_compositor_add_button_binding(ec, BTN_RIGHT, mod, - rotate_binding, NULL); - - weston_compositor_add_key_binding(ec, KEY_TAB, mod, switcher_binding, - shell); - weston_compositor_add_key_binding(ec, KEY_F9, mod, backlight_binding, - ec); - weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSDOWN, 0, - backlight_binding, ec); - weston_compositor_add_key_binding(ec, KEY_F10, mod, backlight_binding, - ec); - weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSUP, 0, - backlight_binding, ec); - weston_compositor_add_key_binding(ec, KEY_K, mod, - force_kill_binding, shell); - weston_compositor_add_key_binding(ec, KEY_UP, mod, - workspace_up_binding, shell); - weston_compositor_add_key_binding(ec, KEY_DOWN, mod, - workspace_down_binding, shell); - weston_compositor_add_key_binding(ec, KEY_UP, mod | MODIFIER_SHIFT, - workspace_move_surface_up_binding, - shell); - weston_compositor_add_key_binding(ec, KEY_DOWN, mod | MODIFIER_SHIFT, - workspace_move_surface_down_binding, - shell); - - if (shell->exposay_modifier) - weston_compositor_add_modifier_binding(ec, shell->exposay_modifier, - exposay_binding, shell); - - /* Add bindings for mod+F[1-6] for workspace 1 to 6. */ - if (shell->workspaces.num > 1) { - num_workspace_bindings = shell->workspaces.num; - if (num_workspace_bindings > 6) - num_workspace_bindings = 6; - for (i = 0; i < num_workspace_bindings; i++) - weston_compositor_add_key_binding(ec, KEY_F1 + i, mod, - workspace_f_binding, - shell); - } - - /* Debug bindings */ - weston_compositor_add_key_binding(ec, KEY_SPACE, mod | MODIFIER_SHIFT, - debug_binding, shell); -} - -WL_EXPORT int -module_init(struct weston_compositor *ec, - int *argc, char *argv[]) -{ - struct weston_seat *seat; - struct desktop_shell *shell; - struct workspace **pws; - unsigned int i; - struct wl_event_loop *loop; - - shell = zalloc(sizeof *shell); - if (shell == NULL) - return -1; - - /* save shell management table for other plugin */ - _ico_ivi_shell = shell; - - shell->compositor = ec; - - shell->destroy_listener.notify = shell_destroy; - wl_signal_add(&ec->destroy_signal, &shell->destroy_listener); - shell->idle_listener.notify = idle_handler; - wl_signal_add(&ec->idle_signal, &shell->idle_listener); - shell->wake_listener.notify = wake_handler; - wl_signal_add(&ec->wake_signal, &shell->wake_listener); - - ec->ping_handler = ping_handler; - ec->shell_interface.shell = shell; - ec->shell_interface.create_shell_surface = create_shell_surface; - ec->shell_interface.get_primary_view = get_primary_view; - ec->shell_interface.set_toplevel = set_toplevel; - ec->shell_interface.set_transient = set_transient; - ec->shell_interface.set_fullscreen = set_fullscreen; - ec->shell_interface.set_xwayland = set_xwayland; - ec->shell_interface.move = surface_move; - ec->shell_interface.resize = surface_resize; - ec->shell_interface.set_title = set_title; - - weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link); - weston_layer_init(&shell->panel_layer, &shell->fullscreen_layer.link); - weston_layer_init(&shell->background_layer, &shell->panel_layer.link); - weston_layer_init(&shell->lock_layer, NULL); - weston_layer_init(&shell->input_panel_layer, NULL); - - wl_array_init(&shell->workspaces.array); - wl_list_init(&shell->workspaces.client_list); - - if (input_panel_setup(shell) < 0) - return -1; - - shell_configuration(shell); - - shell->exposay.state_cur = EXPOSAY_LAYOUT_INACTIVE; - shell->exposay.state_target = EXPOSAY_TARGET_CANCEL; - - for (i = 0; i < shell->workspaces.num; i++) { - pws = wl_array_add(&shell->workspaces.array, sizeof *pws); - if (pws == NULL) - return -1; - - *pws = workspace_create(); - if (*pws == NULL) - return -1; - } - activate_workspace(shell, 0); - - wl_list_init(&shell->workspaces.anim_sticky_list); - wl_list_init(&shell->workspaces.animation.link); - shell->workspaces.animation.frame = animate_workspace_change_frame; - - if (wl_global_create(ec->wl_display, &wl_shell_interface, 1, - shell, bind_shell) == NULL) - return -1; - - if (wl_global_create(ec->wl_display, &xdg_shell_interface, 1, - shell, bind_xdg_shell) == NULL) - return -1; - - if (wl_global_create(ec->wl_display, - &desktop_shell_interface, 2, - shell, bind_desktop_shell) == NULL) - return -1; - - if (wl_global_create(ec->wl_display, &screensaver_interface, 1, - shell, bind_screensaver) == NULL) - return -1; - - if (wl_global_create(ec->wl_display, &workspace_manager_interface, 1, - shell, bind_workspace_manager) == NULL) - return -1; - - shell->child.deathstamp = weston_compositor_get_time(); - - setup_output_destroy_handler(ec, shell); - - loop = wl_display_get_event_loop(ec->wl_display); - wl_event_loop_add_idle(loop, launch_desktop_shell_process, shell); - - shell->screensaver.timer = - wl_event_loop_add_timer(loop, screensaver_timeout, shell); - - wl_list_for_each(seat, &ec->seat_list, link) - create_pointer_focus_listener(seat); - - shell_add_bindings(ec, shell); - - shell_fade_init(shell); - - return 0; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_weston_layer: get weston layer - * - * @param none - * @return current weston layer - * @retval !=NULL success(current weston layer) - * @retval ==NULL error(no layer) - */ -/*--------------------------------------------------------------------------*/ -/* API for other plugin */ -WL_EXPORT struct weston_layer * -ico_ivi_shell_weston_layer(void) -{ - return(&_ico_ivi_shell->panel_layer); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_set_toplevel: set surface to TopLevel - * - * @param[in] shsurf shell surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_set_toplevel(struct shell_surface *shsurf) -{ - set_toplevel(shsurf); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_get_surfacetype: get surface type - * - * @param[in] shsurf shell surface - * @return surface type - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT int -ico_ivi_shell_get_surfacetype(struct shell_surface *shsurf) -{ - return (shsurf ? (int)shsurf->type : -1); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_set_surface_type: set surface type - * - * @param[in] shsurf shell surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_set_surface_type(struct shell_surface *shsurf) -{ - set_surface_type(shsurf); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_send_configure: send configure event to client application - * - * @param[in] surface weston surface - * @param[in] edges surface resize position - * @param[in] width surface width - * @param[in] height surface height - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_send_configure(struct weston_surface *surface, - const uint32_t edges, const int width, const int height) -{ - send_configure(surface, edges, width, height); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_startup: start shell surface fade - * - * @param[in] shell shell table address - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_startup(void *shell) -{ - shell_fade_startup((struct desktop_shell *)shell); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_layertype: get layer type - * - * @param[in] surface weston surface - * @return layer type - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT int -ico_ivi_shell_layertype(struct weston_surface *surface) -{ - if (surface->configure == shell_surface_configure) { - return ((struct shell_surface *)surface->configure_private)->layertype; - } - return LAYER_TYPE_UNKNOWN; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ivi_shell_set_default_display: set default display - * - * @param[in] inputpanel default display of input panel surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ivi_shell_set_default_display(struct weston_output *inputpanel) -{ - default_inputpanel = inputpanel; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_bind: regist hook function for shell bind - * - * @param[in] hook_bind hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_bind(void (*hook_bind)(struct wl_client *client, void *shell)) -{ - shell_hook_bind = hook_bind; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_unbind: regist hook function for shell unbind - * - * @param[in] hook_unbind hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_unbind(void (*hook_unbind)(struct wl_client *client)) -{ - shell_hook_unbind = hook_unbind; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_create: regist hook function for create shell surface - * - * @param[in] hook_create hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_create(void (*hook_create)(int layertype, - struct weston_surface *surface, - struct wl_client *client, - struct shell_surface *shsurf)) -{ - shell_hook_create = hook_create; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_destroy: regist hook function for destroy shell surface - * - * @param[in] hook_destroy hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_destroy(void (*hook_destroy)(struct weston_surface *surface)) -{ - shell_hook_destroy = hook_destroy; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_map: regist hook function for map shell surface - * - * @param[in] hook_map hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_map(void (*hook_map)(struct weston_surface *surface, - int32_t *width, int32_t *height, - int32_t *sx, int32_t *sy)) -{ - shell_hook_map = hook_map; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_configure: regist hook function for configure shell surface - * - * @param[in] hook_configure hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_configure(void (*hook_configure)(struct weston_surface *surface)) -{ - shell_hook_configure = hook_configure; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_select: regist hook function for select(active) shell surface - * - * @param[in] hook_select hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_select(void (*hook_select)(struct weston_surface *surface)) -{ - shell_hook_select = hook_select; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_title: regist hook function for select(active) shell surface - * - * @param[in] hook_title hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_title(char *(*hook_title)(struct weston_surface *surface, - const char *title)) -{ - shell_hook_title = hook_title; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_move: regist hook function for move grab - * - * @param[in] hook_move hook function(if NULL, reset hook function) - * @param[in/out] dx new X coordinate - * @param[in/out] dy new Y coordinate - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_move(void (*hook_move)(struct weston_surface *surface, int *dx, int *dy)) -{ - shell_hook_move = hook_move; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_show_layer: layer visible control - * - * @param[in] hook_show hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_show_layer(void (*hook_show)(int layertype, int show, void *data)) -{ - shell_hook_show_layer = hook_show; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_ivi_shell_hook_fullscreen: fullscreen surface control - * - * @param[in] hook_fullscreen hook function(if NULL, reset hook function) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_ivi_shell_hook_fullscreen(int (*hook_fullscreen) - (int event, struct weston_surface *surface)) -{ - shell_hook_fullscreen = hook_fullscreen; -} diff --git a/src/ico_ivi_shell.h b/src/ico_ivi_shell.h deleted file mode 100644 index fe437b8..0000000 --- a/src/ico_ivi_shell.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright © 2010-2012 Intel Corporation - * Copyright © 2011-2012 Collabora, Ltd. - * Copyright © 2013 Raspberry Pi Foundation - * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION. - * - * 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. - */ - -#include - -#include - -enum animation_type { - ANIMATION_NONE, - - ANIMATION_ZOOM, - ANIMATION_FADE, - ANIMATION_DIM_LAYER, -}; - -enum fade_type { - FADE_IN, - FADE_OUT -}; - -enum exposay_target_state { - EXPOSAY_TARGET_OVERVIEW, /* show all windows */ - EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */ - EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */ -}; - -enum exposay_layout_state { - EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */ - EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */ - EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */ - EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */ -}; - -struct focus_surface { - struct weston_surface *surface; - struct weston_view *view; - struct weston_transform workspace_transform; -}; - -struct workspace { - struct weston_layer layer; - - struct wl_list focus_list; - struct wl_listener seat_destroyed_listener; - - struct focus_surface *fsurf_front; - struct focus_surface *fsurf_back; - struct weston_view_animation *focus_animation; -}; - -struct desktop_shell { - struct weston_compositor *compositor; - - struct wl_listener idle_listener; - struct wl_listener wake_listener; - struct wl_listener destroy_listener; - struct wl_listener show_input_panel_listener; - struct wl_listener hide_input_panel_listener; - struct wl_listener update_input_panel_listener; - - struct weston_layer fullscreen_layer; - struct weston_layer panel_layer; - struct weston_layer background_layer; - struct weston_layer lock_layer; - struct weston_layer input_panel_layer; - - struct wl_listener pointer_focus_listener; - struct weston_surface *grab_surface; - - struct { - struct weston_process process; - struct wl_client *client; - struct wl_resource *desktop_shell; - struct wl_listener client_destroy_listener; - - unsigned deathcount; - uint32_t deathstamp; - } child; - - bool locked; - bool showing_input_panels; - bool prepare_event_sent; - - struct { - struct weston_surface *surface; - pixman_box32_t cursor_rectangle; - } text_input; - - struct weston_surface *lock_surface; - struct wl_listener lock_surface_listener; - - struct { - struct wl_array array; - unsigned int current; - unsigned int num; - - struct wl_list client_list; - - struct weston_animation animation; - struct wl_list anim_sticky_list; - int anim_dir; - uint32_t anim_timestamp; - double anim_current; - struct workspace *anim_from; - struct workspace *anim_to; - } workspaces; - - struct { - char *path; - int duration; - struct wl_resource *binding; - struct weston_process process; - struct wl_event_source *timer; - } screensaver; - - struct { - struct wl_resource *binding; - struct wl_list surfaces; - } input_panel; - - struct { - struct weston_view *view; - struct weston_view_animation *animation; - enum fade_type type; - struct wl_event_source *startup_timer; - } fade; - - struct exposay { - /* XXX: Make these exposay_surfaces. */ - struct weston_view *focus_prev; - struct weston_view *focus_current; - struct weston_view *clicked; - struct workspace *workspace; - struct weston_seat *seat; - struct wl_list surface_list; - - struct weston_keyboard_grab grab_kbd; - struct weston_pointer_grab grab_ptr; - - enum exposay_target_state state_target; - enum exposay_layout_state state_cur; - int in_flight; /* number of animations still running */ - - int num_surfaces; - int grid_size; - int surface_size; - - int hpadding_outer; - int vpadding_outer; - int padding_inner; - - int row_current; - int column_current; - - bool mod_pressed; - bool mod_invalid; - } exposay; - - uint32_t binding_modifier; - uint32_t exposay_modifier; - enum animation_type win_animation_type; - enum animation_type startup_animation_type; - enum animation_type focus_animation_type; - - struct wl_listener output_create_listener; - struct wl_list output_list; - - char *client; -}; - -void -set_alpha_if_fullscreen(struct shell_surface *shsurf); - -struct weston_output * -get_default_output(struct weston_compositor *compositor); - -struct weston_view * -get_default_view(struct weston_surface *surface); - -struct shell_surface * -get_shell_surface(struct weston_surface *surface); - -struct workspace * -get_current_workspace(struct desktop_shell *shell); - -void -lower_fullscreen_layer(struct desktop_shell *shell); - -void -activate(struct desktop_shell *shell, struct weston_surface *es, - struct weston_seat *seat); - -void -exposay_binding(struct weston_seat *seat, - enum weston_keyboard_modifier modifier, - void *data); -int -input_panel_setup(struct desktop_shell *shell); -void -input_panel_destroy(struct desktop_shell *shell); diff --git a/src/ico_ivi_shell_private.h b/src/ico_ivi_shell_private.h deleted file mode 100644 index c2d4729..0000000 --- a/src/ico_ivi_shell_private.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright © 2010-2011 Intel Corporation - * Copyright © 2008-2011 Kristian Høgsberg - * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION. - * - * 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. - */ -/** - * @brief Public functions in ico_ivi_shell Weston plugin - * - * @date Jan-30-2014 - */ - -#ifndef _ICO_IVI_SHELL_PRIVATE_H_ -#define _ICO_IVI_SHELL_PRIVATE_H_ - -#include "ico_window_mgr-server-protocol.h" - -struct shell_surface; - -/* surface type */ -enum shell_surface_type { - SHELL_SURFACE_NONE, - SHELL_SURFACE_TOPLEVEL, - SHELL_SURFACE_POPUP, - SHELL_SURFACE_XWAYLAND -}; - -/* weston layer type */ -#define LAYER_TYPE_UNKNOWN 0 -#define LAYER_TYPE_BACKGROUND (ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND >> 12) -#define LAYER_TYPE_PANEL (ICO_WINDOW_MGR_LAYERTYPE_NORMAL >> 12) -#define LAYER_TYPE_FULLSCREEN (ICO_WINDOW_MGR_LAYERTYPE_FULLSCREEN >> 12) -#define LAYER_TYPE_INPUTPANEL (ICO_WINDOW_MGR_LAYERTYPE_INPUTPANEL >> 12) -#define LAYER_TYPE_TOUCH (ICO_WINDOW_MGR_LAYERTYPE_TOUCH >> 12) -#define LAYER_TYPE_CURSOR (ICO_WINDOW_MGR_LAYERTYPE_CURSOR >> 12) -#define LAYER_TYPE_LOCK 0xe -#define LAYER_TYPE_FADE 0xf - -/* fullscreen surface control */ -enum shell_fullscreen_control { - SHELL_FULLSCREEN_ISTOP, - SHELL_FULLSCREEN_SET, - SHELL_FULLSCREEN_UNSET, - SHELL_FULLSCREEN_CONF, - SHELL_FULLSCREEN_HIDEALL -}; - -/* Prototype for get/set function */ -struct weston_layer *ico_ivi_shell_weston_layer(void); -void ico_ivi_shell_set_toplevel(struct shell_surface *shsurf); -int ico_ivi_shell_get_surfacetype(struct shell_surface *shsurf); -void ico_ivi_shell_set_surface_type(struct shell_surface *shsurf); -void ico_ivi_shell_send_configure(struct weston_surface *surface, - const uint32_t edges, const int width, const int height); -void ico_ivi_shell_startup(void *shell); -int ico_ivi_shell_layertype(struct weston_surface *surface); -void ivi_shell_set_default_display(struct weston_output *inputpanel); - -/* Prototypr for hook routine */ -void ico_ivi_shell_hook_bind(void (*hook_bind)(struct wl_client *client, void *shell)); -void ico_ivi_shell_hook_unbind(void (*hook_unbind)(struct wl_client *client)); -void ico_ivi_shell_hook_create(void (*hook_create)(int layertype, - struct weston_surface *surface, - struct wl_client *client, struct shell_surface *shsurf)); -void ico_ivi_shell_hook_destroy(void (*hook_destroy)(struct weston_surface *surface)); -void ico_ivi_shell_hook_map(void (*hook_map)(struct weston_surface *surface, - int32_t *width, int32_t *height, int32_t *sx, int32_t *sy)); -void ico_ivi_shell_hook_configure(void (*hook_configure)(struct weston_surface *surface)); -void ico_ivi_shell_hook_select(void (*hook_select)(struct weston_surface *surface)); -void ico_ivi_shell_hook_title(char *(*hook_title)(struct weston_surface *surface, - const char *title)); -void ico_ivi_shell_hook_move(void (*hook_move)(struct weston_surface *surface, - int *dx, int *dy)); -void ico_ivi_shell_hook_show_layer(void (*hook_show)(int layertype, int show, void *data)); -void ico_ivi_shell_hook_fullscreen(int (*hook_fullscreen) - (int event, struct weston_surface *surface)); -struct weston_view *ico_input_panel_get_view(void *ipsurf); - -/* hook functions */ -extern void (*shell_hook_bind)(struct wl_client *client, void *shell); -extern void (*shell_hook_unbind)(struct wl_client *client); -extern void (*shell_hook_create)(int layertype, struct weston_surface *surface, - struct wl_client *client, - struct shell_surface *shsurf); -extern void (*shell_hook_destroy)(struct weston_surface *surface); -extern void (*shell_hook_map)(struct weston_surface *surface, int32_t *width, - int32_t *height, int32_t *sx, int32_t *sy); -extern void (*shell_hook_configure)(struct weston_surface *surface); -extern void (*shell_hook_select)(struct weston_surface *surface); -extern char *(*shell_hook_title)(struct weston_surface *surface, const char *title); -extern void (*shell_hook_move)(struct weston_surface *surface, int *dx, int *dy); -extern void (*shell_hook_show_layer)(int layertype, int show, void *data); -extern int (*shell_hook_fullscreen)(int event, struct weston_surface *surface); - -#endif /*_ICO_IVI_SHELL_PRIVATE_H_*/ diff --git a/src/ico_plugin_loader.c b/src/ico_plugin_loader.c index ce081cd..90fffae 100644 --- a/src/ico_plugin_loader.c +++ b/src/ico_plugin_loader.c @@ -26,7 +26,7 @@ * @brief Load the Weston plugins, because plugin loader of main body of Weston * @brief cannot use other plugin functions by a other plugin. * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #define _GNU_SOURCE diff --git a/src/ico_plugin_version.h b/src/ico_plugin_version.h index 9236f0f..d33e6f5 100644 --- a/src/ico_plugin_version.h +++ b/src/ico_plugin_version.h @@ -1 +1 @@ -#define ICO_PLUIGN_VERSION "0.9.14 (Feb-13-2014)" +#define ICO_PLUIGN_VERSION "0.9.21 (Feb-24-2014)" diff --git a/src/ico_window_animation.c b/src/ico_window_animation.c index 5a4658f..e78baab 100644 --- a/src/ico_window_animation.c +++ b/src/ico_window_animation.c @@ -24,7 +24,7 @@ /** * @brief Window Animation (Weston(Wayland) PlugIn) * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #include @@ -40,8 +40,9 @@ #include #include +#include +#include #include "ico_ivi_common_private.h" -#include "ico_ivi_shell_private.h" #include "ico_window_mgr_private.h" /* Animation type */ @@ -454,16 +455,20 @@ animation_end(struct uifw_win_surface *usurf, const int disp) usurf->restrain_configure = 0; if ((usurf->animation.visible == ANIMA_HIDE_AT_END) && (usurf->visible != 0)) { - ico_window_mgr_set_visible(usurf, 0); + usurf->visible = 0; + weston_layout_surfaceSetVisibility(usurf->ivisurf, 0); + weston_layout_commitChanges(); weston_surface_damage(usurf->surface); + weston_view_geometry_dirty(ev); } if ((usurf->animation.visible == ANIMA_SHOW_AT_END) && (usurf->visible == 0)) { - ico_window_mgr_set_visible(usurf, 1); + usurf->visible = 1; + weston_layout_surfaceSetVisibility(usurf->ivisurf, 1); + weston_layout_commitChanges(); weston_surface_damage(usurf->surface); + weston_view_geometry_dirty(ev); } - weston_view_geometry_dirty(ev); - ico_window_mgr_restack_layer(usurf); } usurf->animation.visible = ANIMA_NOCONTROL_AT_END; if (usurf->animation.next_anima != ICO_WINDOW_MGR_ANIMATION_NONE) { @@ -493,9 +498,6 @@ animation_end(struct uifw_win_surface *usurf, const int disp) free_data = animadata; } usurf->animation.type = ICO_WINDOW_MGR_ANIMATION_OPNONE; - if (! disp) { - ico_window_mgr_restack_layer(usurf); - } #if PERFORMANCE_EVALUATIONS > 0 uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d", usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima); @@ -965,9 +967,6 @@ animation_fade(struct weston_animation *animation, ev->alpha = 0.0; ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, usurf->width, usurf->height); - ico_window_mgr_change_surface(usurf, - usurf->animation.no_configure ? -1 : 0, 1); - ico_window_mgr_restack_layer(usurf); } } else { @@ -1095,8 +1094,6 @@ animation_zoom(struct weston_animation *animation, /* zoom move/resize */ ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, usurf->width, usurf->height); - ico_window_mgr_change_surface(usurf, usurf->animation.no_configure ? -1 : 0, 1); - fu = (float)usurf->width; fa = (float)usurf->animation.pos_width; fp = (100.0f - (float)par) / 100.0f; diff --git a/src/ico_window_mgr.c b/src/ico_window_mgr.c index fec092b..a5d14da 100644 --- a/src/ico_window_mgr.c +++ b/src/ico_window_mgr.c @@ -24,7 +24,7 @@ /** * @brief Multi Window Manager (Weston(Wayland) PlugIn) * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #define _GNU_SOURCE @@ -52,85 +52,18 @@ #include #include -#include -#include #include -#include /* detail debug log */ #define UIFW_DETAIL_OUT 0 /* 1=detail debug log/0=no detail log */ +#include #include "ico_ivi_common_private.h" -#include "ico_ivi_shell_private.h" #include "ico_window_mgr_private.h" -#include "ico_window_mgr.h" -#include "desktop-shell-server-protocol.h" #include "ico_window_mgr-server-protocol.h" -/* SurfaceID */ -#define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */ -#define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */ -#define SURCAFE_ID_MASK 0x0ffff /* SurfaceId bit mask pattern */ -#define UIFW_HASH 64 /* Hash value (2's compliment) */ - -/* Internal fixed value */ -#define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */ - /* show/hide animation with position */ -#define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000 - -/* GPU type code */ -#define ICO_GPUTYPE_NOACCELERATION 0 /* Do not use GPU-dependent acceleration*/ -#define ICO_GPUTYPE_INTEL_SANDYBRIDGE 1 /* Intel Sandybridge Mobile */ - -/* Code for Intel Sandybridge Mobile GPU dependent acceleration */ - -/* wl_drm_buffer (inport from mesa-9.1.3 & mesa-9.2.1/ */ -/* src/egl/wayland/wayland-drm/wayland-drm.h) */ -struct uifw_drm_buffer { - struct wl_resource *resource; - void *drm; /* struct wl_drm */ - int32_t width, height; - uint32_t format; - const void *driver_format; - int32_t offset[3]; - int32_t stride[3]; - void *driver_buffer; -}; - -/* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h */ -/* mesa-9.2.1/src/mesa/drivers/dri/i915/intel_regions.h */ -/* mesa-9.2.1/src/mesa/drivers/dri/i965/intel_regions.h) */ -struct uifw_intel_region { /* struct intel_region for mesa 9.2.1 */ - void *bo; /**< buffer manager's buffer */ - uint32_t refcount; /**< Reference count for region */ - uint32_t cpp; /**< bytes per pixel */ - uint32_t width; /**< in pixels */ - uint32_t height; /**< in pixels */ - uint32_t pitch; /**< in bytes */ - uint32_t tiling; /**< Which tiling mode the region is in */ - uint32_t name; /**< Global name for the bo */ -}; - -struct uifw_dri_image { /* struct __DRIimageRec */ - struct uifw_intel_region *region; - int internal_format; - uint32_t dri_format; - uint32_t format; - uint32_t offset; - uint32_t strides[3]; - uint32_t offsets[3]; - void *planar_format; /* intel_image_format */ - uint32_t width; - uint32_t height; - uint32_t tile_x; - uint32_t tile_y; - bool has_depthstencil; /* i965 only */ - void *data; -}; - -/* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c, */ -/* weston-1.3.1/src/gl-renderer.c */ +/* gl_surface_state (inport from weston-1.4.0/src/gl-renderer.c */ enum buffer_type { BUFFER_TYPE_NULL, BUFFER_TYPE_SHM, @@ -156,24 +89,23 @@ struct uifw_gl_surface_state { /* struct gl_surface_state */ int y_inverted; /* add weston 1.3.x */ }; -/* API access control configuration */ -struct ico_api_permit { - struct ico_api_permit *next; /* access control configuration list */ - struct ico_uifw_api_permit permit; /* permission */ -}; +/* SurfaceID */ +#define UIFW_HASH 64 /* Hash value (2's compliment) */ +#define SURCAFE_ID_MASK 0x0ffff /* SurfaceId hash mask pattern */ + +/* Internal fixed value */ +#define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */ + /* show/hide animation with position */ +#define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000 /* Multi Windiw Manager */ struct ico_win_mgr { struct weston_compositor *compositor; /* Weston compositor */ - void *shell; /* shell(ico_ivi_shell) table address */ + void *shell; /* shell table address */ int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */ struct wl_list client_list; /* Clients */ struct wl_list manager_list; /* Manager(ex.HomeScreen) list */ - int num_manager; /* Number of managers */ - - struct wl_list ivi_layer_list; /* Layer management table list */ - struct uifw_win_layer *touch_layer; /* layer table for touch panel layer */ struct wl_list map_list; /* surface map list */ struct uifw_surface_map *free_maptable; /* free maped surface table list */ @@ -181,54 +113,13 @@ struct ico_win_mgr { /* animation for map check */ struct wl_event_source *wait_mapevent; /* map event send wait timer */ - struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */ - struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */ - struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */ struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */ - uint32_t surfaceid_count; /* Number of surface id */ - uint32_t surfaceid_max; /* Maximum number of surface id */ - uint16_t *surfaceid_map; /* SurfaceId assign bit map */ - - struct ico_api_permit *access_config; /* access control configuration list */ - uint32_t default_access; /* default permit APIs */ - char shell_init; /* shell initialize flag */ char res[3]; /* (unused) */ }; -/* access control api table */ -static const struct { - char name[24]; /* API name */ - uint32_t api; /* API flag */ -} access_api_table[] = { - { "declare_manager", ICO_UIFW_WINDOW_MGR_DECLARE_MANAGER }, - { "set_window_layer", ICO_UIFW_WINDOW_MGR_SET_WINDOW_LAYER }, - { "set_positionsize", ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE }, - { "set_visible", ICO_UIFW_WINDOW_MGR_SET_VISIBLE }, - { "set_animation", ICO_UIFW_WINDOW_MGR_SET_ANIMATION }, - { "set_attributes", ICO_UIFW_WINDOW_MGR_SET_ATTRIBUTES }, - { "visible_animation", ICO_UIFW_WINDOW_MGR_VISIBLE_ANIMATION }, - { "set_active", ICO_UIFW_WINDOW_MGR_SET_ACTIVE }, - { "set_layer_visible", ICO_UIFW_WINDOW_MGR_SET_LAYER_VISIBLE }, - { "get_surfaces", ICO_UIFW_WINDOW_MGR_GET_SURFACES }, - { "set_map_buffer", ICO_UIFW_WINDOW_MGR_SET_MAP_BUFFER }, - { "map_surface", ICO_UIFW_WINDOW_MGR_MAP_SURFACE }, - { "unmap_surface", ICO_UIFW_WINDOW_MGR_UNMAP_SURFACE }, - - { "add_input_app", ICO_UIFW_INPUT_MGR_CONTROL_ADD_INPUT_APP }, - { "del_input_app", ICO_UIFW_INPUT_MGR_CONTROL_DEL_INPUT_APP }, - { "send_input_event", ICO_UIFW_INPUT_MGR_CONTROL_SEND_INPUT_EVENT }, - { "set_input_region", ICO_UIFW_EXINPUT_SET_INPUT_REGION }, - { "unset_input_region", ICO_UIFW_EXINPUT_UNSET_INPUT_REGION }, - { "confiure_input", ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_INPUT }, - { "confiure_code", ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_CODE }, - { "input_event", ICO_UIFW_INPUT_MGR_DEVICE_INPUT_EVENT }, - - { "\0", 0 } -}; - /* Internal macros */ /* UIFW SurfaceID */ #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1)) @@ -239,12 +130,10 @@ static const struct { /* get surface table from weston surface*/ static struct uifw_win_surface *find_uifw_win_surface_by_ws( struct weston_surface *wsurf); - /* assign new surface id */ -static uint32_t generate_id(void); /* bind shell client */ static void win_mgr_bind_client(struct wl_client *client, void *shell); - /* unind shell client */ -static void win_mgr_unbind_client(struct wl_client *client); + /* destroy client */ +static void win_mgr_destroy_client(struct wl_listener *listener, void *data); #if 0 /* work around: Walk through child processes until app ID is found */ /* get parent pid */ static pid_t win_mgr_get_ppid(pid_t pid); @@ -252,82 +141,18 @@ static pid_t win_mgr_get_ppid(pid_t pid); /* get appid from pid */ static void win_mgr_get_client_appid(struct uifw_client *uclient); /* create new surface */ -static void win_mgr_register_surface(int layertype, struct weston_surface *surface, +static void win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface, struct wl_client *client, - struct shell_surface *shsurf); + struct weston_layout_surface *ivisurf); /* surface destroy */ static void win_mgr_destroy_surface(struct weston_surface *surface); - /* map new surface */ -static void win_mgr_surface_map(struct weston_surface *surface, int32_t *width, - int32_t *height, int32_t *sx, int32_t *sy); - /* send surface change event to manager */ -static void win_mgr_change_surface(struct weston_surface *surface, - const int to, const int manager); /* window manager surface configure */ static void win_mgr_surface_configure(struct uifw_win_surface *usurf, int x, int y, int width, int height); - /* shell surface configure */ -static void win_mgr_shell_configure(struct weston_surface *surface); - /* surface select */ -static void win_mgr_select_surface(struct weston_surface *surface); - /* surface set title */ -static char *win_mgr_set_title(struct weston_surface *surface, const char *title); - /* surface move request from shell */ -static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy); - /* shell layer visible control */ -static void win_mgr_show_layer(int layertype, int show, void *data); - /* shell full screen surface control */ -static int win_mgr_fullscreen(int event, struct weston_surface *surface); - /* set raise */ -static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise); - /* surface change from manager */ -static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x, - const int y, const int width, const int height); - /* reset surface focus */ -static void win_mgr_reset_focus(struct uifw_win_surface *usurf); - /* create new layer */ -static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf, - const uint32_t layer, const int layertype); - /* set surface layer */ -static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer); - /* set active surface */ -static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target); - - /* declare manager */ -static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, - int manager); - /* set window layer */ -static void uifw_set_window_layer(struct wl_client *client, - struct wl_resource *resource, - uint32_t surfaceid, uint32_t layer); - /* set surface size and position */ -static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, uint32_t node, int32_t x, int32_t y, - int32_t width, int32_t height, int32_t flags); - /* show/hide and raise/lower surface */ -static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t visible, int32_t raise, - int32_t flag); /* set surface animation */ static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource, uint32_t surfaceid, int32_t type, const char *animation, int32_t time); - /* set surface attributes */ -static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, uint32_t attributes); - /* surface visibility control with animation*/ -static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t visible, - int32_t x, int32_t y, int32_t width, int32_t height); - /* set active surface (form HomeScreen) */ -static void uifw_set_active(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t active); - /* layer visibility control */ -static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource, - uint32_t layer, int32_t visible); - /* get application surfaces */ -static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, - const char *appid, int32_t pid); /* check and change all mapped surface */ static void win_mgr_check_mapsurface(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); @@ -336,12 +161,9 @@ static int win_mgr_timer_mapsurface(void *data); /* check and change mapped surface */ static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime); - /* set map buffer */ -static void uifw_set_map_buffer(struct wl_client *client, struct wl_resource *resource, - const char *shmname, uint32_t bufsize, uint32_t bufnum); /* map surface to system application */ static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t framerate); + uint32_t surfaceid, int32_t framerate, const char *filepath); /* unmap surface */ static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, uint32_t surfaceid); @@ -350,17 +172,29 @@ static void bind_ico_win_mgr(struct wl_client *client, void *data, uint32_t version, uint32_t id); /* unbind manager */ static void unbind_ico_win_mgr(struct wl_resource *resource); - /* send event to manager */ -static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, - const int param1, const int param2, const int param3, - const int param4, const int param5); - /* set surface transform */ -static int win_mgr_set_scale(struct uifw_win_surface *usurf); /* convert animation name to Id value */ static int ico_get_animation_name(const char *animation); - /* read surface pixels */ -static int ico_read_surface_pixels(struct weston_surface *es, pixman_format_code_t format, - void *pixels, int x, int y, int width, int height); + /* touch/click select surface */ +static void win_mgr_select_surface(struct weston_seat *seat, + struct weston_surface *focus, int target); +static void win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time, + uint32_t button, void *data); +static void win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time, + void *data); + /* hook for create surface of ivi-shell */ +static void ico_ivi_surfaceCreateNotification(struct weston_layout_surface *ivisurf, + void *userdata); + /* hook for remove surface of ivi-shell */ +static void ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf, + void *userdata); + /* hook for configure surface of ivi-shell*/ +static void ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf, + void *userdata); + /* hook for property change of ivi-shell*/ +static void ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, + struct weston_layout_SurfaceProperties *prop, + enum weston_layout_notification_mask mask, + void *userdata); /* hook for animation */ static int (*win_mgr_hook_animation)(const int op, void *data) = NULL; /* hook for input region */ @@ -376,54 +210,18 @@ static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf, /* static tables */ /* Multi Window Manager interface */ static const struct ico_window_mgr_interface ico_window_mgr_implementation = { - uifw_declare_manager, - uifw_set_window_layer, - uifw_set_positionsize, - uifw_set_visible, uifw_set_animation, - uifw_set_attributes, - uifw_visible_animation, - uifw_set_active, - uifw_set_layer_visible, - uifw_get_surfaces, - uifw_set_map_buffer, uifw_map_surface, uifw_unmap_surface }; -/* GPU driver name */ -static const struct _ico_gputype_table { - int gpu_type; /* GPU type code */ - char *gpu_name; /* GPU driver name */ -} ico_window_mgr_gpu_type[] = { - { ICO_GPUTYPE_INTEL_SANDYBRIDGE, "Mesa DRI Intel(R) Sandybridge Mobile" }, - { 0, "\0" } -}; - /* plugin common value(without ico_plugin_loader) */ static int _ico_ivi_option_flag = 0; /* option flags */ static int _ico_ivi_debug_level = 3; /* debug Level */ static char *_ico_ivi_animation_name = NULL; /* default animation name */ static int _ico_ivi_animation_time = 500; /* default animation time */ static int _ico_ivi_animation_fps = 30; /* animation frame rate */ -static char *_ico_ivi_inputpanel_animation = NULL; /* default animation name for input panel*/ -static int _ico_ivi_inputpanel_anima_time = 0; /* default animation time for input panel*/ - -static int _ico_ivi_inputpanel_display = 0; /* input panel display number */ -static int _ico_ivi_inputdeco_mag = 100; /* input panel magnification rate(%)*/ -static int _ico_ivi_inputdeco_diff = 0; /* input panel difference from the bottom*/ - -static int _ico_ivi_background_layer = 0; /* background layer */ -static int _ico_ivi_default_layer = 1; /* deafult layer id at surface create*/ -static int _ico_ivi_touch_layer = 101; /* touch panel layer id */ -static int _ico_ivi_cursor_layer = 102; /* cursor layer id */ -static int _ico_ivi_startup_layer = 109; /* deafult layer id at system startup*/ - -static int _ico_ivi_gpu_type = 0; /* GPU type for get EGL buffer */ -static int _ico_ivi_map_framerate_gpu = 30; /* framerate of map surface for GPU*/ -static int _ico_ivi_map_framerate_shm = 2; /* framerate of map surface for shm buffer*/ -static int _ico_ivi_map_framerate_pixel = 5; /* framerate of map surface for ReadPixels*/ /* static management table */ static struct ico_win_mgr *_ico_win_mgr = NULL; @@ -656,22 +454,25 @@ ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height) WL_EXPORT struct weston_view * ico_ivi_get_primary_view(struct uifw_win_surface *usurf) { - struct weston_view *ev; + struct weston_view *ev = NULL; + struct shell_surface *shsurf; - if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { - ev = ico_input_panel_get_view((void *)(usurf->shsurf)); + if (_ico_win_mgr->compositor->shell_interface.get_primary_view) { + shsurf = usurf->surface->configure_private; + if (shsurf) { + ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view)(NULL, shsurf); + } } - else { - ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view) - (NULL, usurf->shsurf); + if (! ev) { + ev = weston_layout_get_weston_view(usurf->ivisurf); } if (! ev) { uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view", (int)usurf, usurf->surfaceid, (int)usurf->surface); } else { - uifw_debug("ico_ivi_get_primary_view: %08x[%d] view=%08x view->surf=%08x", - usurf->surfaceid, usurf->layertype, (int)ev, (int)ev->surface); + uifw_debug("ico_ivi_get_primary_view: %08x view=%08x view->surf=%08x", + usurf->surfaceid, (int)ev, (int)ev->surface); } return ev; } @@ -696,7 +497,7 @@ ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, struct weston_view *ev; int buf_width, buf_height; - if ((es == NULL) || (usurf->shsurf == NULL)) { + if ((es == NULL) || (usurf->ivisurf == NULL)) { uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface", (int)usurf); return; @@ -734,34 +535,11 @@ ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, win_mgr_surface_configure(usurf, x, y, width, height); } weston_surface_damage(es); - weston_compositor_schedule_repaint(_ico_win_mgr->compositor); } } /*--------------------------------------------------------------------------*/ /** - * @brief ico_window_mgr_set_weston_surface: set weston surface - * - * @param[in] usurf UIFW surface - * @param[in] x X coordinate on screen - * @param[in] y Y coordinate on screen - * @param[in] width width - * @param[in] height height - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_window_mgr_change_surface(struct uifw_win_surface *usurf, - const int to, const int manager) -{ - uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)", - usurf->surfaceid, to, manager); - win_mgr_change_surface(usurf->surface, to, manager); - uifw_trace("ico_window_mgr_change_surface: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id * * @param[in] surfaceid UIFW surface id @@ -802,26 +580,8 @@ WL_EXPORT struct uifw_win_surface * ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client) { struct uifw_win_surface *usurf; - struct uifw_client *uclient; - if (surfaceid == ICO_WINDOW_MGR_V_MAINSURFACE) { - uclient = ico_window_mgr_find_uclient(client); - if (uclient) { - if (&uclient->surface_link != uclient->surface_link.next) { - usurf = container_of (uclient->surface_link.next, - struct uifw_win_surface, client_link); - } - else { - usurf = NULL; - } - } - else { - usurf = NULL; - } - } - else { - usurf = ico_window_mgr_get_usurf(surfaceid); - } + usurf = ico_window_mgr_get_usurf(surfaceid); return usurf; } @@ -921,83 +681,10 @@ ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y) /*--------------------------------------------------------------------------*/ /** - * @brief generate_id: generate uniq id for UIFW surface id - * - * @param none - * @return uniq id for UIFW surface id - */ -/*--------------------------------------------------------------------------*/ -static uint32_t -generate_id(void) -{ - int rep; - int i; - int map; - uint16_t *new_map; - uint32_t surfaceId; - - /* next assign id */ - _ico_win_mgr->surfaceid_count ++; - - /* serach free id from bitmap */ - for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) { - if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) { - _ico_win_mgr->surfaceid_count = 0; - } - if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) { - /* find free id from bitmap */ - map = 1 << (_ico_win_mgr->surfaceid_count % 16); - for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) { - if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map) - == 0) { - _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map; - _ico_win_mgr->surfaceid_count - = (_ico_win_mgr->surfaceid_count/16)*16 + i; - - surfaceId = (_ico_win_mgr->surfaceid_count + 1) - | _ico_win_mgr->surface_head; - uifw_trace("generate_id: SurfaceId=%08x", surfaceId); - return(surfaceId); - } - map = map << 1; - } - } - _ico_win_mgr->surfaceid_count += 16; - } - - /* no free id in bitmap, extend bitmap */ - if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) { - /* too many surfaces, system error */ - uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort", - _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK); - fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n", - _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK); - abort(); - } - - new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8); - memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8); - memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8); - _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max; - new_map[_ico_win_mgr->surfaceid_count/16] |= 1; - _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS; - free(_ico_win_mgr->surfaceid_map); - _ico_win_mgr->surfaceid_map = new_map; - - uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)", - _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max); - surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head; - - uifw_trace("generate_id: SurfaceId=%08x", surfaceId); - return(surfaceId); -} - -/*--------------------------------------------------------------------------*/ -/** * @brief win_mgr_bind_client: desktop_shell from client * * @param[in] client Wayland client - * @param[in] shell shell(ico_ivi_shell) table address + * @param[in] shell shell table address * @return none */ /*--------------------------------------------------------------------------*/ @@ -1009,10 +696,6 @@ win_mgr_bind_client(struct wl_client *client, void *shell) pid_t pid; uid_t uid; gid_t gid; - struct ico_api_permit *accp; - char subject[ICO_UIFW_MAX_SUBJECT_NAME]; - int fd; - int i; uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)", (int)client, (int)shell); @@ -1034,9 +717,10 @@ win_mgr_bind_client(struct wl_client *client, void *shell) } memset(uclient, 0, sizeof(struct uifw_client)); uclient->client = client; - uclient->api_access_control = _ico_win_mgr->default_access; wl_list_init(&uclient->surface_link); newclient = 1; + uclient->destroy_listener.notify = win_mgr_destroy_client; + wl_client_add_destroy_listener(client, &uclient->destroy_listener); } else { newclient = 0; @@ -1049,46 +733,6 @@ win_mgr_bind_client(struct wl_client *client, void *shell) /* get applicationId from AppCore(AUL) */ win_mgr_get_client_appid(uclient); - /* get SMACK subject label */ - if (! _ico_win_mgr->access_config) { - /* no access control, permit all APIs */ - uclient->api_access_control = 0xffffffff; - } - else { - sprintf(subject, "/proc/%d/attr/current", (int)pid); - fd = open(subject, O_RDONLY); - if (fd < 0) { - uifw_warn("win_mgr_bind_client: pid=%d(%s) not exist current", - pid, uclient->appid); - } - else { - i = read(fd, subject, sizeof(subject)-1); - if (i > 0) { - subject[i] = 0; - accp = _ico_win_mgr->access_config; - while (accp) { - if (strcmp(subject, accp->permit.subject) == 0) { - uclient->api_access_control |= accp->permit.api_permit; - break; - } - accp = accp->next; - } - } - else { - i = errno; - uifw_trace("win_mgr_bind_client: pid=%d(%s) current read error<%d>", - pid, uclient->appid, i); - if (i == EINVAL) { - /* SMACK not active */ - uclient->api_access_control = 0xffffffff; - } - } - close(fd); - } - } - uifw_trace("win_mgr_bind_client: pid=%d(%s) access_control=%08x", - pid, uclient->appid, uclient->api_access_control); - if (newclient > 0) { wl_list_insert(&_ico_win_mgr->client_list, &uclient->link); } @@ -1101,26 +745,28 @@ win_mgr_bind_client(struct wl_client *client, void *shell) /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_unbind_client: unbind desktop_shell from client + * @brief win_mgr_destroy_client: destroy client * - * @param[in] client Wayland client + * @param[in] listener listener + * @param[in] data listener * @return none */ /*--------------------------------------------------------------------------*/ static void -win_mgr_unbind_client(struct wl_client *client) +win_mgr_destroy_client(struct wl_listener *listener, void *data) { struct uifw_client *uclient; - uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client); + uclient = container_of(listener, struct uifw_client, destroy_listener); + + uifw_trace("win_mgr_destroy_client: Enter(uclient=%08x)", (int)uclient); - uclient = ico_window_mgr_find_uclient(client); if (uclient) { /* Client exist, Destory client management table */ wl_list_remove(&uclient->link); free(uclient); } - uifw_trace("win_mgr_unbind_client: Leave"); + uifw_trace("win_mgr_destroy_client: Leave"); } #if 0 /* work around: Walk through child processes until app ID is found */ @@ -1356,90 +1002,337 @@ ico_get_animation_name(const char *animation) /*--------------------------------------------------------------------------*/ /** - * @brief ico_read_surface_pixels: read surface pixel image - * this function inport from weston 1.3.1(by Tizen) + * @brief win_mgr_select_surface: select surface by mouse click * - * @param[in] es weston surface - * @param[in] format pixel format - * @param[out] pixels pixel read buffer - * @param[in] x X coordinate - * @param[in] y Y coordinate - * @param[in] width width - * @param[in] height height - * @return success(=0) or error(-1) + * @param[in] seat weston seat + * @param[in] focus selected surface + * @param[in] select selected device + * @return none */ /*--------------------------------------------------------------------------*/ -static int -ico_read_surface_pixels(struct weston_surface *es, pixman_format_code_t format, - void *pixels, int x, int y, int width, int height) +static void +win_mgr_select_surface(struct weston_seat *seat, struct weston_surface *focus, int select) { - struct weston_buffer *buffer = es->buffer_ref.buffer; - struct uifw_gl_surface_state *gs = es->renderer_state; - GLenum gl_format; - int size; - struct wl_shm_buffer *shm_buffer = NULL; - GLuint fbo; - - switch (format) { - case PIXMAN_a8r8g8b8: - gl_format = GL_BGRA_EXT; - break; - case PIXMAN_a8b8g8r8: - gl_format = GL_RGBA; - break; - default: - return -1; + struct weston_surface *surface; + struct uifw_win_surface *usurf; + struct uifw_manager *mgr; + + surface = weston_surface_get_main_surface(focus); + + uifw_trace("win_mgr_select_surface: Enter(%08x,%d)", (int)surface, select); + + if (! surface) { + uifw_trace("win_mgr_select_surface: Leave(no surface)"); + return; + } + /* find surface */ + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_select_surface: Leave(usurf not exist)"); + return; + } + /* surface active */ + weston_surface_activate(surface, seat); + + /* send active event to manager */ + wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { + uifw_trace("win_mgr_select_surface: Send Manager ACTIVE(surf=%08x)", + usurf->surfaceid); + ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid, + select); + } + uifw_trace("win_mgr_select_surface: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_click_to_activate: select surface by mouse click + * + * @param[in] seat weston seat + * @param[in] time click time(current time) + * @param[in] button click button + * @param[in] data user data(unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time, + uint32_t button, void *data) +{ + if (seat->pointer->grab != &seat->pointer->default_grab) + return; + if (seat->pointer->focus == NULL) + return; + + win_mgr_select_surface(seat, seat->pointer->focus->surface, + ICO_WINDOW_MGR_SELECT_POINTER); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_touch_to_activate: select surface by touch touch-panel + * + * @param[in] seat weston seat + * @param[in] time click time(current time) + * @param[in] data user data(unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time, void *data) +{ + if (seat->touch->grab != &seat->touch->default_grab) + return; + if (seat->touch->focus == NULL) + return; + + win_mgr_select_surface(seat, seat->touch->focus->surface, ICO_WINDOW_MGR_SELECT_TOUCH); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_surfaceCreateNotification: create ivi-surface + * + * @param[in] ivisurf ivi surface + * @param[in] userdata User Data(Unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +ico_ivi_surfaceCreateNotification(struct weston_layout_surface *ivisurf, void *userdata) +{ + uint32_t id_surface; + struct weston_view *ev; + struct weston_surface *es; + struct wl_client *client; + + id_surface = weston_layout_getIdOfSurface(ivisurf); + uifw_trace("ico_ivi_surfaceCreateNotification: Create %x", id_surface); + + /* set property notification */ + if (weston_layout_surfaceAddNotification(ivisurf, ico_ivi_surfacePropertyNotification, NULL) != 0) { + uifw_error("ico_ivi_surfaceCreateNotification: weston_layout_surfaceAddNotification Error"); + } + ev = weston_layout_get_weston_view(ivisurf); + if (! ev) { + uifw_error("ico_ivi_surfaceCreateNotification: weston_layout_get_weston_view Error"); + } + else { + es = ev->surface; + if (! es) { + uifw_error("ico_ivi_surfaceCreateNotification: no weston_surface"); + } + else { + client = wl_resource_get_client(es->resource); + if (! client) { + uifw_error("ico_ivi_surfaceCreateNotification: no wl_client"); + } + else { + win_mgr_register_surface(id_surface, es, client, ivisurf); + } + } } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_surfaceRemoveNotification: remove ivi-surface + * + * @param[in] ivisurf ivi surface + * @param[in] userdata User Data(Unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf, void *userdata) +{ + uint32_t id_surface; + struct weston_view *ev; + struct weston_surface *es; - if (buffer) { - shm_buffer = wl_shm_buffer_get(buffer->resource); + id_surface = weston_layout_getIdOfSurface(ivisurf); + uifw_trace("ico_ivi_surfaceRemoveNotification: Remove %x", id_surface); + + ev = weston_layout_get_weston_view(ivisurf); + if (! ev) { + uifw_error("ico_ivi_surfaceRemoveNotification: weston_layout_get_weston_view Error"); + } + else { + es = ev->surface; + if (! es) { + uifw_error("ico_ivi_surfaceRemoveNotification: no weston_surface"); + } + else { + win_mgr_destroy_surface(es); + } } - if (shm_buffer) { - size = buffer->width * 4 * buffer->height; - memcpy(pixels, wl_shm_buffer_get_data(shm_buffer), size); - } else if (gs != NULL) { - glGenFramebuffers(1, &fbo); - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, - gs->textures[0], 0); - - glReadPixels(x, y, width, height, - gl_format, GL_UNSIGNED_BYTE, pixels); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glDeleteFramebuffers(1, &fbo); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_surfaceConfigureNotification: configure ivi-surface + * + * @param[in] ivisurf ivi surface + * @param[in] userdata User Data(Unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf, void *userdata) +{ + struct weston_view *view; + struct weston_surface *surface; + uint32_t id_surface; +#if 1 /* for check genivi */ + struct weston_layout_SurfaceProperties prop; +#endif + + id_surface = weston_layout_getIdOfSurface(ivisurf); + view = weston_layout_get_weston_view(ivisurf); + if (! view) { + uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no view", + id_surface); } else { - return -1; + surface = view->surface; + if (! surface) { + uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no surface", + id_surface); + } + else { +#if 1 /* for check genivi */ + if (weston_layout_getPropertiesOfSurface(ivisurf, &prop) != 0) { + uifw_trace("ico_ivi_surfaceConfigureNotification: Properties get Error"); + uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x " + "x/y=%d/%d w/h=%d/%d", + id_surface, (int)view->geometry.x, (int)view->geometry.y, + surface->width, surface->height); + } + else { + uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x " + "x/y=%d/%d->%d/%d w/h=%d/%d(%d/%d)->%d/%d", + id_surface, prop.destX, prop.destY, + (int)view->geometry.x, (int)view->geometry.y, + prop.sourceWidth, prop.sourceHeight, + prop.origSourceWidth, prop.origSourceHeight, + surface->width, surface->height); + } +#else + uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x " + "x/y=%d/%d w/h=%d/%d", + id_surface, (int)view->geometry.x, (int)view->geometry.y, + surface->width, surface->height); +#endif + weston_layout_surfaceSetSourceRectangle(ivisurf, + 0, 0, surface->width, surface->height); + weston_layout_surfaceSetDestinationRectangle(ivisurf, + (uint32_t)view->geometry.x, (uint32_t)view->geometry.y, + surface->width, surface->height); + weston_layout_commitChanges(); + } + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_surfacePropertyNotification: property change ivi-surface + * + * @param[in] ivisurf ivi surface + * @param[in] userdata User Data(Unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf, + struct weston_layout_SurfaceProperties *prop, + enum weston_layout_notification_mask mask, + void *userdata) +{ + uint32_t id_surface; + int retanima; + struct uifw_win_surface *usurf; + + id_surface = weston_layout_getIdOfSurface(ivisurf); + if (mask != 0) { + usurf = ico_window_mgr_get_usurf(id_surface); + uifw_trace("ico_ivi_surfacePropertyNotification: Property %x(%08x) usurf=%08x", + id_surface, mask, (int)usurf); + if ((mask & IVI_NOTIFICATION_VISIBILITY) && (usurf != NULL)) { + if ((usurf->visible == 0) && (prop->visibility)) { + uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1", + id_surface); + usurf->visible = 1; + if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && + (win_mgr_hook_animation != NULL)) { + /* show with animation */ + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + retanima = + (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW, + (void *)usurf); + uifw_trace("ico_ivi_surfacePropertyNotification: ret call anima = %d", + retanima); + } + } + else if ((usurf->visible != 0) && (! prop->visibility)) { + uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0", + id_surface); + if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && + (win_mgr_hook_animation != NULL)) { + /* hide with animation */ + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + retanima = + (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE, + (void *)usurf); + } + else { + retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA; + } + if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) { + usurf->visible = 0; + uifw_trace("ico_ivi_surfacePropertyNotification: Change to UnVisible"); + } + else { + usurf->visible = 1; + uifw_trace("ico_ivi_surfacePropertyNotification: Change to Visible"); + weston_layout_surfaceSetVisibility(ivisurf, 1); + weston_layout_commitChanges(); + } + } + else { + uifw_trace("ico_ivi_surfacePropertyNotification: visible no change"); + } + } } - return 0; } /*--------------------------------------------------------------------------*/ /** * @brief win_mgr_register_surface: create UIFW surface * - * @param[in] layertype surface layer type + * @param[in] id_surface surface id (by ivi-shell) * @param[in] surface Weston surface * @param[in] client Wayland client - * @param[in] shsurf shell surface + * @param[in] ivisurf weston layout surface * @return none */ /*--------------------------------------------------------------------------*/ static void -win_mgr_register_surface(int layertype, struct weston_surface *surface, - struct wl_client *client, struct shell_surface *shsurf) +win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface, + struct wl_client *client, struct weston_layout_surface *ivisurf) { struct uifw_win_surface *usurf; struct uifw_win_surface *phash; struct uifw_win_surface *bhash; - int layer; uint32_t hash; - uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,type=%x,shsurf=%08x)", - (int)surface, (int)client, layertype, (int)shsurf); + uifw_trace("win_mgr_register_surface: Enter(surf=%x[%08x],client=%08x,ivisurf=%08x)", + id_surface, (int)surface, (int)client, (int)ivisurf); /* check new surface */ if (find_uifw_win_surface_by_ws(surface)) { @@ -1450,7 +1343,6 @@ win_mgr_register_surface(int layertype, struct weston_surface *surface, /* set default color and shader */ weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0); - /* create UIFW surface management table */ usurf = malloc(sizeof(struct uifw_win_surface)); if (! usurf) { @@ -1460,12 +1352,10 @@ win_mgr_register_surface(int layertype, struct weston_surface *surface, memset(usurf, 0, sizeof(struct uifw_win_surface)); - usurf->surfaceid = generate_id(); + usurf->surfaceid = id_surface; usurf->surface = surface; - usurf->shsurf = shsurf; - usurf->layertype = layertype; + usurf->ivisurf = ivisurf; usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */ - wl_list_init(&usurf->ivi_layer); wl_list_init(&usurf->client_link); wl_list_init(&usurf->animation.animation.link); wl_list_init(&usurf->surf_map); @@ -1478,23 +1368,7 @@ win_mgr_register_surface(int layertype, struct weston_surface *surface, usurf->animation.move_time = usurf->animation.hide_time; usurf->animation.resize_anima = usurf->animation.hide_anima; usurf->animation.resize_time = usurf->animation.hide_time; - if (layertype == LAYER_TYPE_INPUTPANEL) { - usurf->attributes = ICO_WINDOW_MGR_ATTR_FIXED_ASPECT; - usurf->animation.hide_anima = ico_get_animation_name(_ico_ivi_inputpanel_animation); - usurf->animation.hide_time = _ico_ivi_inputpanel_anima_time; - usurf->animation.show_anima = usurf->animation.hide_anima; - usurf->animation.show_time = usurf->animation.hide_time; - } - if ((layertype != LAYER_TYPE_INPUTPANEL) && - ((_ico_win_mgr->num_manager <= 0) || - (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE))) { - uifw_trace("win_mgr_register_surface: No Manager, Force visible"); - usurf->visible = 1; - } - else { - uifw_trace("win_mgr_register_surface: Manager exist, Not visible"); - usurf->visible = 0; - } + usurf->visible = 0; /* set client */ usurf->uclient = ico_window_mgr_find_uclient(client); @@ -1539,3417 +1413,675 @@ win_mgr_register_surface(int layertype, struct weston_surface *surface, else { _ico_win_mgr->wshash[hash] = usurf; } - - /* set default layer id */ - switch (layertype) { - case LAYER_TYPE_BACKGROUND: - layer = _ico_ivi_background_layer; - break; - case LAYER_TYPE_TOUCH: - layer = _ico_ivi_touch_layer; - break; - case LAYER_TYPE_CURSOR: - layer = _ico_ivi_cursor_layer; - break; - default: - if ((_ico_win_mgr->num_manager > 0) || - (layertype == LAYER_TYPE_INPUTPANEL)) { - layer = _ico_ivi_default_layer; - } - else { - layer = _ico_ivi_startup_layer; - } - break; - } - win_mgr_set_layer(usurf, layer); - uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid); } /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_surface_map: map surface to display + * @brief uifw_set_animation: set animation of surface visible/unvisible * - * @param[in] surface Weston surface - * @param[in] width surface width - * @param[in] height surface height - * @param[in] sx X coordinate on screen - * @param[in] sy Y coordinate on screen + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] type how to change surface + * @param[in] anmation animation name + * @param[in] time animation time(ms), if 0, default time * @return none */ /*--------------------------------------------------------------------------*/ static void -win_mgr_surface_map(struct weston_surface *surface, int32_t *width, int32_t *height, - int32_t *sx, int32_t *sy) +uifw_set_animation(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t type, const char *animation, int32_t time) { - struct uifw_win_surface *usurf; - - uifw_trace("win_mgr_surface_map: Enter(%08x, x/y=%d/%d w/h=%d/%d)", - (int)surface, *sx, *sy, *width, *height); + int animaid; + struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - usurf = find_uifw_win_surface_by_ws(surface); + uifw_trace("uifw_set_transition: surf=%08x,type=%x,anim=%s,time=%d", + surfaceid, type, animation, time); - if ((usurf != NULL) && (usurf->mapped == 0)) { - uifw_trace("win_mgr_surface_map: surf=%08x w/h=%d/%d vis=%d", - usurf->surfaceid, usurf->width, usurf->height, usurf->visible); - if ((usurf->width > 0) && (usurf->height > 0)) { - uifw_trace("win_mgr_surface_map: HomeScreen registed, PositionSize" - "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d", - usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height, - usurf->visible); - *width = usurf->width; - *height = usurf->height; - win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x, - usurf->node_tbl->disp_y + usurf->y, - usurf->width, usurf->height); - } - else { - uifw_trace("win_mgr_surface_map: HomeScreen not regist Surface, " - "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)", - usurf->surfaceid, *sx, *sy, *width, *height); - usurf->width = *width; - usurf->height = *height; - usurf->x = *sx; - usurf->y = *sy; - if (usurf->x < 0) usurf->x = 0; - if (usurf->y < 0) usurf->y = 0; - if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { - /* set position */ - usurf->node_tbl = &_ico_node_table[_ico_ivi_inputpanel_display]; - - usurf->width = (float)usurf->surface->width - * (float)_ico_ivi_inputdeco_mag / 100.0f; - usurf->height = (float)usurf->surface->height - * (float)_ico_ivi_inputdeco_mag / 100.0f; - - if ((usurf->width > (usurf->node_tbl->disp_width - 16)) || - (usurf->height > (usurf->node_tbl->disp_height - 16))) { - usurf->x = (usurf->node_tbl->disp_width - - usurf->surface->width) / 2; - usurf->y = usurf->node_tbl->disp_height - - usurf->surface->height - 16 - - _ico_ivi_inputdeco_diff; - if (usurf->x < 0) usurf->x = 0; - if (usurf->y < 0) usurf->y = 0; + if (usurf) { + if ((*animation != 0) && (*animation != ' ')) { + animaid = ico_get_animation_name(animation); + uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid); + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) { + if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) || + (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) { + usurf->animation.next_anima = animaid; } else { - win_mgr_set_scale(usurf); - - usurf->x = (usurf->node_tbl->disp_width - - usurf->width) / 2; - usurf->y = usurf->node_tbl->disp_height - - usurf->height - 16 - _ico_ivi_inputdeco_diff; - if (usurf->x < 0) usurf->x = 0; - if (usurf->y < 0) usurf->y = 0; + usurf->animation.hide_anima = animaid; } - uifw_trace("win_mgr_surface_map: set position %08x %d.%d/%d", - usurf->surfaceid, usurf->node_tbl->node, usurf->x, usurf->y); } - if (((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE) == 0) && - (_ico_win_mgr->num_manager > 0)) { - /* HomeScreen exist, coodinate set by HomeScreen */ - if (usurf->visible) { - win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x, - usurf->node_tbl->disp_y + usurf->y, - usurf->width, usurf->height); + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) { + if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) || + (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) { + usurf->animation.next_anima = animaid; } else { - win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1, - ICO_IVI_MAX_COORDINATE+1, - usurf->width, usurf->height); + usurf->animation.show_anima = animaid; } - uifw_trace("win_mgr_surface_map: Change size/position x/y=%d/%d w/h=%d/%d", - usurf->x, usurf->y, surface->width, surface->height); } - else if (usurf->layertype != LAYER_TYPE_INPUTPANEL) { - uifw_trace("win_mgr_surface_map: No HomeScreen, chaneg to Visible"); - ico_window_mgr_set_visible(usurf, 1); + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) { + if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) { + usurf->animation.next_anima = animaid; + } + else { + usurf->animation.move_anima = animaid; + } } - else { - if (usurf->visible) { - win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x, - usurf->node_tbl->disp_y + usurf->y, - usurf->width, usurf->height); + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) { + if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) { + usurf->animation.next_anima = animaid; } else { - win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1, - ICO_IVI_MAX_COORDINATE+1, - usurf->width, usurf->height); + usurf->animation.resize_anima = animaid; } } } - usurf->mapped = 1; - if (usurf->visible) { - ico_window_mgr_restack_layer(NULL); + if ((time > 0) && (time < 10000)) { + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) { + usurf->animation.hide_time = time; + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) { + usurf->animation.show_time = time; + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) { + usurf->animation.move_time = time; + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) { + usurf->animation.resize_time = time; + } } - uifw_trace("win_mgr_surface_map: Leave"); } else { - uifw_trace("win_mgr_surface_map: Leave(No UIFW Surface or mapped)"); + uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid); } } /*--------------------------------------------------------------------------*/ /** - * @brief ico_window_mgr_restack_layer: restack surface list + * @brief win_mgr_check_mapsurface: check and change all surface * - * @param[in] usurf UIFW surface (if NULL, no surface) + * @param[in] animation weston animation table(unused) + * @param[in] outout weston output table(unused) + * @param[in] mseces current time(unused) * @return none */ /*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_window_mgr_restack_layer(struct uifw_win_surface *usurf) +static void +win_mgr_check_mapsurface(struct weston_animation *animation, + struct weston_output *output, uint32_t msecs) { - struct uifw_win_surface *eu; - struct uifw_win_layer *el; - int32_t buf_width, buf_height; - float new_x, new_y; - struct weston_layer *wlayer; - struct weston_view *view, *viewtmp; - int num_visible = 0; - int layertype; - - /* make compositor surface list */ - wlayer = ico_ivi_shell_weston_layer(); - - uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x) layer=%08x", - (int)usurf, (int)wlayer); - - /* remove all surfaces in panel_layer */ - wl_list_for_each_safe (view, viewtmp, &wlayer->view_list, layer_link) { - wl_list_remove(&view->layer_link); - wl_list_init(&view->layer_link); - } - wl_list_init(&wlayer->view_list); - - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - wl_list_for_each (eu, &el->surface_list, ivi_layer) { - if (eu->surface == NULL) continue; - - /* target only panel or unknown layer */ - layertype = ico_ivi_shell_layertype(eu->surface); - if ((layertype != LAYER_TYPE_PANEL) && (layertype != LAYER_TYPE_INPUTPANEL) && - (layertype != LAYER_TYPE_FULLSCREEN) && (layertype != LAYER_TYPE_CURSOR) && - (layertype != LAYER_TYPE_UNKNOWN)) { - continue; - } + struct uifw_surface_map *sm, *sm_tmp; + uint32_t curtime; + int wait = 99999999; - if (eu->mapped != 0) { - if ((el->visible == FALSE) || (eu->visible == FALSE)) { - new_x = (float)(ICO_IVI_MAX_COORDINATE+1); - new_y = (float)(ICO_IVI_MAX_COORDINATE+1); - } - else if (eu->surface->buffer_ref.buffer) { - ico_ivi_surface_buffer_size(eu->surface, &buf_width, &buf_height); - if ((eu->width > buf_width) && (eu->scalex <= 1.0f)) { - new_x = (float)(eu->x + - (eu->width - eu->surface->width)/2); - } - else { - new_x = (float)eu->x; - } - if ((eu->height > buf_height) && (eu->scaley <= 1.0f)) { - new_y = (float) (eu->y + - (eu->height - eu->surface->height)/2); - } - else { - new_y = (float)eu->y; - } - new_x += eu->node_tbl->disp_x + eu->xadd; - new_y += eu->node_tbl->disp_y + eu->yadd; - num_visible ++; - } - else { - new_x = (float)(eu->x + eu->node_tbl->disp_x + eu->xadd); - new_y = (float)(eu->y + eu->node_tbl->disp_y + eu->yadd); - } - wl_list_for_each (view, &eu->surface->views, surface_link) { - wl_list_remove(&view->layer_link); - wl_list_init(&view->layer_link); - wl_list_insert(wlayer->view_list.prev, &view->layer_link); - if ((eu->restrain_configure == 0) && - ((new_x != view->geometry.x) || - (new_y != view->geometry.y))) { - weston_view_damage_below(view); - weston_view_set_position(view, (float)new_x, (float)new_y); - weston_surface_damage(eu->surface); - } - uifw_debug("ico_window_mgr_restack_layer:%3d(%d).%08x(%08x:%d) " - "x/y=%d/%d w/h=%d/%d[%x]", - el->layer, el->visible, eu->surfaceid, (int)eu->surface, - eu->visible, (int)view->geometry.x, - (int)view->geometry.y, eu->surface->width, - eu->surface->height, eu->layertype); - } - } + /* check touch down counter */ + if ((touch_check_seat) && + (touch_check_seat->touch)) { + if (touch_check_seat->touch->num_tp > 10) { + uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset", + (int)touch_check_seat->touch->num_tp); + touch_check_seat->touch->num_tp = 0; } } - /* damage(redraw) target surfacem if target exist */ - if (usurf) { - weston_surface_damage(usurf->surface); - } - - /* composit and draw screen(plane) */ - weston_compositor_schedule_repaint(_ico_win_mgr->compositor); - - if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) && - (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) { - /* start shell fade */ - _ico_win_mgr->shell_init = 1; - ico_ivi_shell_startup(_ico_win_mgr->shell); + /* check all mapped surfaces */ + curtime = weston_compositor_get_time(); + wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) { + uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x", + (int)sm, sm->usurf->surfaceid); + win_mgr_change_mapsurface(sm, 0, curtime); + if (sm->eventque) { + if (sm->interval < wait) { + wait = sm->interval; + } + } } - uifw_trace("ico_window_mgr_restack_layer: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_window_mgr_touch_layer: touch panel layer control - * - * @param[in] omit omit touch layer flag (TRUE=omit/FALSE=not omit) - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_window_mgr_touch_layer(int omit) -{ - struct uifw_win_surface *eu; - struct weston_view *ev; - /* check current touch layer mode */ - if ((_ico_win_mgr->touch_layer == NULL) || - ((omit != FALSE) && (_ico_win_mgr->touch_layer->visible == FALSE))) { - uifw_trace("ico_window_mgr_touch_layer: touch layer not exist or hide"); - return; + /* check frame interval */ + if (wait < 2000) { + wait = wait / 2; } - - wl_list_for_each (eu, &_ico_win_mgr->touch_layer->surface_list, ivi_layer) { - if ((eu->surface == NULL) || (eu->mapped == 0)) continue; - ev = ico_ivi_get_primary_view(eu); - if (omit != FALSE) { - eu->animation.pos_x = (int)ev->geometry.x; - eu->animation.pos_y = (int)ev->geometry.y; - ev->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1); - ev->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1); - } - else { - ev->geometry.x = (float)eu->animation.pos_x; - ev->geometry.y = (float)eu->animation.pos_y; - } + else { + wait = 1000; } + wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait); } /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_create_layer: create new layer + * @brief win_mgr_timer_mapsurface: mapped surface check timer * - * @param[in] usurf UIFW surface, (if need) - * @param[in] layer layer id - * @param[in] layertype layer type if need - * @return new layer - * @retval != NULL success(layer management table) - * @retval == NULL error(No Memory) + * @param[in] data user data(unused) + * @return fixed 1 */ /*--------------------------------------------------------------------------*/ -static struct uifw_win_layer * -win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer, - const int layertype) +static int +win_mgr_timer_mapsurface(void *data) { - struct uifw_win_layer *el; - struct uifw_win_layer *new_el; - - new_el = malloc(sizeof(struct uifw_win_layer)); - if (! new_el) { - uifw_trace("win_mgr_create_layer: Leave(No Memory)"); - return NULL; - } - - memset(new_el, 0, sizeof(struct uifw_win_layer)); - new_el->layer = layer; - if ((int)layer == _ico_ivi_background_layer ) { - new_el->layertype = LAYER_TYPE_BACKGROUND; - } - else if ((int)layer == _ico_ivi_touch_layer ) { - new_el->layertype = LAYER_TYPE_TOUCH; - _ico_win_mgr->touch_layer = new_el; - } - else if ((int)layer == _ico_ivi_cursor_layer ) { - new_el->layertype = LAYER_TYPE_CURSOR; - } - else { - new_el->layertype = LAYER_TYPE_PANEL; - } - new_el->visible = TRUE; - wl_list_init(&new_el->surface_list); - wl_list_init(&new_el->link); - - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - if (layer >= el->layer) break; - } - if (&el->link == &_ico_win_mgr->ivi_layer_list) { - wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link); - } - else { - wl_list_insert(el->link.prev, &new_el->link); - } - - if (usurf) { - wl_list_remove(&usurf->ivi_layer); - wl_list_insert(&new_el->surface_list, &usurf->ivi_layer); - usurf->win_layer = new_el; - if (new_el->layertype == LAYER_TYPE_CURSOR) { - usurf->layertype = LAYER_TYPE_CURSOR; - } - } - return new_el; + win_mgr_check_mapsurface(NULL, NULL, 0); + return 1; } /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_set_layer: set(or change) surface layer + * @brief win_mgr_change_mapsurface: check and change mapped surface * - * @param[in] usurf UIFW surface - * @param[in] layer layer id + * @param[in] sm map surface table + * @param[in] event send event (if 0, send if changed) + * @param[in] curtime current time(ms) * @return none */ /*--------------------------------------------------------------------------*/ static void -win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer) +win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime) { - struct uifw_win_layer *el; - struct uifw_win_layer *new_el; - uint32_t oldlayer; - - uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)", - usurf->surfaceid, (int)usurf->surface, layer); - - /* check if same layer */ - if (usurf->win_layer != NULL) { - oldlayer = usurf->win_layer->layer ; - if (oldlayer == layer) { - uifw_trace("win_mgr_set_layer: Leave(Same Layer)"); - return; - } - } - else { - oldlayer = 0; - } - - /* search existing layer */ - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - if (el->layer == layer) break; - } - - if (&el->link == &_ico_win_mgr->ivi_layer_list) { - /* layer not exist, create new layer */ - uifw_trace("win_mgr_set_layer: New Layer %d(%d)", layer, usurf->layertype); - new_el = win_mgr_create_layer(usurf, layer, usurf->layertype); - if (! new_el) { - uifw_trace("win_mgr_set_layer: Leave(No Memory)"); - return; - } - } - else { - uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer); - usurf->win_layer = el; - win_mgr_set_raise(usurf, 3); - } - - /* set input region */ - if (layer == (uint32_t)_ico_ivi_cursor_layer) { - uifw_trace("win_mgr_set_layer: %08x cursor Change to cursor layer (%d,%d)-(%d,%d)", - usurf->surfaceid, - usurf->surface->input.extents.x1, usurf->surface->input.extents.y1, - usurf->surface->input.extents.x2, usurf->surface->input.extents.y2); - pixman_region32_fini(&usurf->surface->pending.input); - pixman_region32_init_rect(&usurf->surface->pending.input, - ICO_IVI_MAX_COORDINATE + 1, ICO_IVI_MAX_COORDINATE + 1, - 1, 1); - } - else if (oldlayer == (uint32_t)_ico_ivi_cursor_layer) { - uifw_trace("win_mgr_set_layer: %08x cursor Change to normal layer (%d,%d)-(%d,%d)", - usurf->surfaceid, - usurf->surface->input.extents.x1, usurf->surface->input.extents.y1, - usurf->surface->input.extents.x2, usurf->surface->input.extents.y2); - pixman_region32_fini(&usurf->surface->pending.input); - pixman_region32_init_rect(&usurf->surface->pending.input, - INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); - } + struct weston_surface *es; + struct wl_shm_buffer *shm_buffer; + int width; + int height; + uint32_t format; + uint32_t dtime; - /* rebild compositor surface list */ - if (usurf->visible) { - ico_window_mgr_restack_layer(usurf); + uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event); + if (event == 0) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; } - uifw_trace("win_mgr_set_layer: Leave"); -} -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_set_active: set(or change) active surface - * - * @param[in] usurf UIFW surface (if NULL, change to inactive) - * @param[in] target target device - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_set_active(struct uifw_win_surface *usurf, const int target) -{ - struct weston_seat *seat; - struct weston_surface *surface; - int object = target; -#if 0 /* pointer grab can not release */ - int savetp, i; -#endif /* pointer grab can not release */ - - uifw_trace("win_mgr_set_active: Enter(%08x,%x)", usurf ? usurf->surfaceid : 0, target); - - if ((usurf) && (usurf->shsurf) && (usurf->surface)) { - surface = usurf->surface; - if ((object & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) { - surface = NULL; - if (_ico_win_mgr->active_pointer_usurf == usurf) { - object |= ICO_WINDOW_MGR_ACTIVE_POINTER; - } - if (_ico_win_mgr->active_keyboard_usurf == usurf) { - object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD; - } + /* check if buffered */ + es = sm->usurf->surface; + if ((es == NULL) || + ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) && + ((es->buffer_ref.buffer == NULL) || + (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) { + /* surface has no buffer */ + uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x", + sm->usurf->surfaceid, (int)es, + es ? (int)es->buffer_ref.buffer : 0); + if (sm->initflag) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; } else { - if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) { - _ico_win_mgr->active_pointer_usurf = usurf; - } - if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) { - _ico_win_mgr->active_keyboard_usurf = usurf; + event = 0; + } + } + else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) { + if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) { + if ((void *)wl_resource_get_user_data( + (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer) + == NULL) { + /* surface has no buffer */ + uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer", + sm->usurf->surfaceid); + if (sm->initflag) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; + } + else { + event = 0; + } } } } else { - surface = NULL; - if (object == 0) { - object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD; - } - if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) { - _ico_win_mgr->active_pointer_usurf = NULL; - } - if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) { - _ico_win_mgr->active_keyboard_usurf = NULL; + if (es->buffer_ref.buffer != NULL) { + shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource); + if (shm_buffer) { + format = wl_shm_buffer_get_format(shm_buffer); + if (format != WL_SHM_FORMAT_ARGB8888) { + uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x", + sm->usurf->surfaceid, format); + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; + } + } } } - wl_list_for_each (seat, &_ico_win_mgr->compositor->seat_list, link) { -#if 0 /* pointer grab can not release */ - if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) { - if (surface) { - if ((seat->pointer != NULL) && (seat->pointer->focus != surface)) { - uifw_trace("win_mgr_set_active: pointer reset focus(%08x)", - (int)seat->pointer->focus); - if (seat->pointer->button_count > 0) { - /* emulate button release */ - notify_button(seat, weston_compositor_get_time(), - seat->pointer->grab_button, - WL_POINTER_BUTTON_STATE_RELEASED); - /* count up button, because real mouse botan release */ - seat->pointer->button_count ++; - } - weston_pointer_set_focus(seat->pointer, NULL, - wl_fixed_from_int(0), wl_fixed_from_int(0)); + if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) { + + if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) { + format = EGL_TEXTURE_RGBA; /* currently only support RGBA */ + width = es->buffer_ref.buffer->width; + height = es->buffer_ref.buffer->height; + if ((sm->initflag == 0) && (width > 0) && (height > 0)) { + sm->initflag = 1; + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; + } + else if ((width <= 0) || (height <= 0)) { + event = 0; + } + else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { + if ((sm->width != width) || (sm->height != height) || + (format != sm->format)) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; } else { - uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)", - (int)surface); - } - if ((seat->touch != NULL) && (seat->touch->focus != surface)) { - uifw_trace("win_mgr_set_active: touch reset surface(%08x)", - (int)seat->touch->focus); - if (seat->num_tp > 10) { - seat->num_tp = 0; /* safty gard */ - } - else if (seat->num_tp > 0) { - /* emulate touch up */ - savetp = seat->num_tp; - for (i = 0; i < savetp; i++) { - notify_touch(seat, weston_compositor_get_time(), i+1, - seat->touch->grab_x, seat->touch->grab_y, - WL_TOUCH_UP); + if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) { +#if PERFORMANCE_EVALUATIONS > 0 + uifw_perf("SWAP_BUFFER appid=%s surface=%08x", + sm->usurf->uclient->appid, sm->usurf->surfaceid); +#endif /*PERFORMANCE_EVALUATIONS*/ + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + sm->eventque = 1; + event = 0; } - /* touch count up, becase real touch release */ - seat->num_tp = savetp; - } - weston_touch_set_focus(seat, NULL); - } - else { - uifw_trace("win_mgr_set_active: touch nochange surface(%08x)", - (int)surface); - } - } - else { - uifw_trace("win_mgr_set_active: pointer reset surface(%08x)", - (int)seat->pointer->focus); - if ((seat->pointer != NULL) && (seat->pointer->focus != NULL)) { - if (seat->pointer->button_count > 0) { - /* emulate button release */ - notify_button(seat, weston_compositor_get_time(), - seat->pointer->grab_button, - WL_POINTER_BUTTON_STATE_RELEASED); - seat->pointer->button_count ++; } - weston_pointer_set_focus(seat->pointer, NULL, - wl_fixed_from_int(0), wl_fixed_from_int(0)); - } - if ((seat->touch != NULL) && (seat->touch->focus != NULL)) { - if (seat->num_tp > 10) { - seat->num_tp = 0; /* safty gard */ - } - else if (seat->num_tp > 0) { - /* emulate touch up */ - savetp = seat->num_tp; - for (i = 0; i < savetp; i++) { - notify_touch(seat, weston_compositor_get_time(), i+1, - seat->touch->grab_x, seat->touch->grab_y, - WL_TOUCH_UP); + else if (sm->eventque) { + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + event = 0; } - /* touch count up, becase real touch release */ - seat->num_tp = savetp; } - weston_touch_set_focus(seat, NULL); + else { + event =0; + } } } + sm->width = width; + sm->height = height; + sm->stride = width * 4; + sm->format = format; + sm->curbuf = es->buffer_ref.buffer->legacy_buffer; } -#endif /* pointer grab can not release */ - if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) { - if (surface) { -#if 0 /* pointer grab can not release */ - if (seat->keyboard->focus != surface) { -#endif /* pointer grab can not release */ - weston_keyboard_set_focus(seat->keyboard, surface); - uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)", - (int)seat->keyboard->focus, (int)surface); -#if 0 /* pointer grab can not release */ + else { + if ((sm->eventque != 0) || + (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) { + sm->curbuf = es->buffer_ref.buffer; + if (es->buffer_ref.buffer != NULL) { + width = es->buffer_ref.buffer->width; + height = es->buffer_ref.buffer->height; + } + else { + width = es->width; + height = es->height; + } + if ((sm->initflag == 0) && (width > 0) && (height > 0)) { + sm->initflag = 1; + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; + uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x", + sm->usurf->surfaceid); } else { - uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)", - (int)surface); + if ((width <= 0) || (height <= 0)) { + event = 0; + sm->curbuf = NULL; + uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0", + sm->usurf->surfaceid); + } + else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { +#if PERFORMANCE_EVALUATIONS > 0 + if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) { + uifw_perf("SWAP_BUFFER appid=%s surface=%08x", + sm->usurf->uclient->appid, sm->usurf->surfaceid); + } +#endif /*PERFORMANCE_EVALUATIONS*/ + if ((sm->width != width) || (sm->height != height)) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; + } + else { + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + sm->eventque = 1; + event = 0; + uifw_detail("win_mgr_change_mapsurface: PIX %08x new queue", + sm->usurf->surfaceid); + } + else if (sm->eventque) { + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + event = 0; + uifw_detail("win_mgr_change_mapsurface: PIX %08x queued", + sm->usurf->surfaceid); + } + } + } + } } -#endif /* pointer grab can not release */ + sm->width = width; + sm->height = height; + sm->stride = width * 4; + sm->format = EGL_TEXTURE_RGBA; } else { - uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)", - (int)seat->keyboard); - weston_keyboard_set_focus(seat->keyboard, NULL); + event = 0; } } } - uifw_trace("win_mgr_set_active: Leave"); -} -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_window_mgr_ismykeyboard: check active keyboard - * - * @param[in] usurf UIFW surface - * @return check result - * @retval =1 usurf is active keyboard surface - * @retval =0 usurf is not active - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT int -ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf) -{ - return (_ico_win_mgr->active_keyboard_usurf == usurf) ? 1 : 0; + if (event != 0) { + uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d " + "w/h/s=%d/%d/%d format=%x", + event, sm->usurf->surfaceid, sm->type, + sm->width, sm->height, sm->stride, sm->format); + sm->lasttime = curtime; + sm->eventque = 0; + if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) && + (sm->filepath != NULL)) { + if (weston_layout_takeSurfaceScreenshot(sm->filepath, + sm->usurf->ivisurf) != 0) { + uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error", + sm->usurf->surfaceid, sm->filepath); + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; + } + } + ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event, + sm->usurf->surfaceid, sm->type, + sm->width, sm->height, sm->stride, sm->format); + if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) { + /* free map table if error */ + wl_list_remove(&sm->surf_link); + wl_list_remove(&sm->map_link); + sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; + _ico_win_mgr->free_maptable = sm; + } + } } /*--------------------------------------------------------------------------*/ /** - * @brief uifw_declare_manager: declare manager(ex.SystemController) client + * @brief uifw_map_surface: mapped surface buffer to system application * * @param[in] client Weyland client * @param[in] resource resource of request - * @param[in] manager manager(1=manager, 0=not manager) + * @param[in] surfaceid surface id + * @param[in] framerate frame rate of surface update(frame/sec) + * @param[in] filepath surface image file path(if NULL, not create file) * @return none */ /*--------------------------------------------------------------------------*/ static void -uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager) +uifw_map_surface(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t framerate, const char *filepath) { - struct uifw_manager* mgr; - struct uifw_win_surface *usurf; - struct uifw_client *uclient; - struct uifw_win_layer *el; + struct uifw_win_surface *usurf; + struct weston_surface *es; + struct uifw_surface_map *sm; + struct weston_buffer *buffer; + struct wl_shm_buffer *shm_buffer; + struct uifw_client *uclient; + struct uifw_gl_surface_state *gl_state; + int maptype; + int format; - uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d", - (int)client, manager); + uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d,file=%s)", + surfaceid, framerate, filepath ? filepath : "(null)"); - /* check for access control */ uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_declare_manager: unknown client"); - uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client); + usurf = ico_window_mgr_get_usurf(surfaceid); + if (! usurf) { + /* surface dose not exist, error */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 1, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid); return; } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_DECLARE_MANAGER) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_declare_manager: not permitted"); - uifw_trace("uifw_declare_manager: Leave(%s not permitted)", uclient->appid); + + /* check if buffered */ + es = usurf->surface; + if (es == NULL) { + /* surface has no buffer, error */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 2, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid); return; } + buffer = es->buffer_ref.buffer; - uclient->manager = manager; - - /* client set to manager */ - _ico_win_mgr->num_manager = 0; - wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { - if (mgr->resource == resource) { - if (mgr->manager != manager) { - uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d", - (int)client, mgr->manager, manager); - mgr->manager = manager; - - if (manager) { - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - wl_list_for_each (usurf, &el->surface_list, ivi_layer) { - /* send window create event to manager */ - if (usurf->created != 0) { - uifw_trace("uifw_declare_manager: Send manager(%08x) " - "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)", - (int)resource, usurf->surfaceid, - usurf->uclient->pid, usurf->uclient->appid); - ico_window_mgr_send_window_created(resource, - usurf->surfaceid, - usurf->winname, - usurf->uclient->pid, - usurf->uclient->appid, - usurf->layertype << 12); - } - } + /* check buffer type */ + gl_state = (struct uifw_gl_surface_state *)es->renderer_state; + if (gl_state == NULL) { + ico_window_mgr_send_map_surface(resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 3, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface(%08x) has no gl_state)", surfaceid); + return; + } + else if (gl_state->buffer_type == BUFFER_TYPE_SHM) { + maptype = -1; + format = 0xff; + if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) { + if (buffer != NULL) { + shm_buffer = wl_shm_buffer_get(buffer->resource); + if (shm_buffer) { + format = wl_shm_buffer_get_format(shm_buffer); + uifw_detail("uifw_map_surface: %08x shm_buffer type %x", + surfaceid, format); + if (format == WL_SHM_FORMAT_ARGB8888) { + maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM; } } } + else { + maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM; + } } - if (mgr->manager) { - _ico_win_mgr->num_manager++; + if (maptype < 0) { + ico_window_mgr_send_map_surface(resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 4, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))", + surfaceid, format); + return; } } - uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_window_layer: set layer id to surface - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid UIFW surface id - * @param[in] layer layer id - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, uint32_t layer) -{ - struct uifw_client *uclient; - struct uifw_win_surface *usurf; - - if (layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) { - layer = _ico_ivi_background_layer; - } - else if (layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) { - layer = _ico_ivi_touch_layer; - } - else if (layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) { - layer = _ico_ivi_cursor_layer; - } - else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) { - layer = _ico_ivi_startup_layer; + else { + maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL; } - uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d", - (int)resource, surfaceid, layer); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_window_layer: unknown client"); - uifw_trace("uifw_set_window_layer: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_WINDOW_LAYER) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_window_layer: not permitted"); - uifw_trace("uifw_set_window_layer: Leave(%s not permitted)", uclient->appid); - return; - } + /* maximum framerate */ + if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) { + if ((framerate <= 0) || (framerate > 15)) + framerate = 15; } - usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - - if (! usurf) { - uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid); - return; + else { + if ((framerate <= 0) || (framerate > 5)) + framerate = 5; } - if (usurf->win_layer->layer != layer) { - win_mgr_set_layer(usurf, layer); - win_mgr_change_surface(usurf->surface, -1, 1); + /* check same surface */ + wl_list_for_each(sm, &usurf->surf_map, surf_link) { + if ((sm->usurf == usurf) && (sm->uclient == uclient)) { + break; + } } - uifw_trace("uifw_set_window_layer: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_positionsize: set surface position and size - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid UIFW surface id - * @param[in] node surface node id - * @param[in] x X coordinate on screen(if bigger than 16383, no change) - * @param[in] y Y coordinate on screen(if bigger than 16383, no change) - * @param[in] width surface width(if bigger than 16383, no change) - * @param[in] height surface height(if bigger than 16383, no change) - * @param[in] flags with/without animation and client configure flag - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, uint32_t node, int32_t x, int32_t y, - int32_t width, int32_t height, int32_t flags) -{ - struct uifw_client *uclient; - struct uifw_win_surface *usurf; - struct weston_surface *es; - struct weston_view *ev; - int op; - int retanima; - int oldx, oldy; - struct uifw_node_table *oldnode; - uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x", - surfaceid, node, x, y, width, height, flags); - - /* check for access control */ - uclient = ico_window_mgr_find_uclient(client); - if (resource != NULL) { - /* resource is NULL, internal use */ - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_positionsize: unknown client"); - uifw_trace("uifw_set_positionsize: Leave(unknown client=%08x)", (int)client); - return; + if (&sm->surf_link == &usurf->surf_map) { + /* create map table */ + sm = _ico_win_mgr->free_maptable; + if (sm) { + _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf; } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_positionsize: not permitted"); - uifw_trace("uifw_set_positionsize: Leave(%s not permitted)", uclient->appid); - return; + else { + sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map)); + if (! sm) { + ico_window_mgr_send_map_surface(resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 5, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(malloc error)"); + return; + } } + memset(sm, 0, sizeof(struct uifw_surface_map)); + + wl_list_init(&sm->map_link); + wl_list_init(&sm->surf_link); + sm->usurf = usurf; + sm->uclient = uclient; + sm->type = maptype; + sm->framerate = framerate; + sm->interval = (1000 / sm->framerate) - 1; + wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link); + wl_list_insert(usurf->surf_map.prev, &sm->surf_link); } - usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - if (! usurf) { - uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid); - return; - } - oldx = usurf->x; - oldy = usurf->y; - oldnode = usurf->node_tbl; - - usurf->disable = 0; - if (((int)node) >= _ico_num_nodes) { - uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)", - node, _ico_num_nodes); - if ((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_NODISP) == 0) { - if (usurf->visible) { - /* no display, change to hide */ - uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE, - ICO_WINDOW_MGR_V_NOCHANGE, 0); - } - usurf->disable = 1; + else { + /* change frame rate */ + uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d", + sm->framerate, framerate); + if (sm->framerate != framerate) { + sm->framerate = framerate; + sm->interval = (1000 / sm->framerate) - 1; + win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time()); } - node = 0; + return; } - usurf->node_tbl = &_ico_node_table[node]; - es = usurf->surface; - if (es) { - /* weston surface exist */ - es = usurf->surface; - retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA; - - /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */ - if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x; - if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y; - if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width; - if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height; - - /* check animation */ - if ((usurf->animation.restrain_configure != 0) && - (x == usurf->x) && (y == usurf->y) && - (width == usurf->width) && (height == usurf->height)) { - uifw_trace("uifw_set_positionsize: Leave(same position size at animation)"); - return; - } + memset(sm->filepath, 0, ICO_IVI_FILEPATH_LENGTH); + if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) { + strncpy(sm->filepath, filepath, ICO_IVI_FILEPATH_LENGTH-1); + } - if (uclient) { - if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) && - (uclient->manager == 0) && (uclient->privilege == 0)) uclient = NULL; - } - ev = ico_ivi_get_primary_view(usurf); - if (! uclient) { - if ((usurf->width > 0) && (usurf->height > 0)) { - win_mgr_surface_change_mgr(es, x, y, width, height); - uifw_trace("uifw_set_positionsize: Leave(Request from App)"); - return; + if (buffer != NULL) { + sm->width = buffer->width; + sm->height = buffer->height; + if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) { + sm->stride = sm->width * 4; + sm->format = EGL_TEXTURE_RGBA; + if ((sm->width > 0) && (sm->height > 0)) { + sm->initflag = 1; } - - uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d", - usurf->visible); - /* Initiale position is (0,0) */ - weston_view_set_position(ev, (float)(usurf->node_tbl->disp_x), - (float)(usurf->node_tbl->disp_y)); - } - - uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d", - (int)ev->geometry.x, (int)ev->geometry.y, - (int)es->width, (int)es->height); - - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0; - - usurf->x = x; - usurf->y = y; - usurf->width = width; - usurf->height = height; - if (_ico_win_mgr->num_manager <= 0) { - /* no manager(HomeScreen), set geometory */ - weston_view_set_position(ev, (float)(usurf->node_tbl->disp_x + x), - (float)(usurf->node_tbl->disp_y + y)); + uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d", + maptype, surfaceid, framerate, buffer->width, buffer->height); } - if ((es->output) && (es->buffer_ref.buffer) && - (es->width > 0) && (es->height > 0)) { - uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)", - usurf->visible); - if (usurf->visible) { - if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) && - (win_mgr_hook_animation != NULL)) { - /* with animation */ - if ((x != (ev->geometry.x - usurf->node_tbl->disp_x)) || - (y != (ev->geometry.y - usurf->node_tbl->disp_y))) { - op = ICO_WINDOW_MGR_ANIMATION_OPMOVE; - } - else if ((width != usurf->surface->width) || - (height != usurf->surface->height)) { - op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE; - } - else { - op = ICO_WINDOW_MGR_ANIMATION_OPNONE; - } - if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) && - (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) || - ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) && - (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) { - retanima = (*win_mgr_hook_animation)(op, (void *)usurf); - uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima); - } - } - if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) || - (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) { - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); + else { + if (wl_resource_get_user_data((struct wl_resource *)buffer->legacy_buffer) + != NULL) { + sm->format = EGL_TEXTURE_RGBA; + if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) && + (gl_state != NULL)) { + sm->initflag = 1; } + uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d", + surfaceid, framerate, buffer->width, buffer->height); + } + else { + uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d", + surfaceid, framerate); } } - if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) || - (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) { - win_mgr_change_surface(es, - (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1); - } - uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output); - } - else { - usurf->x = x; - usurf->y = y; - usurf->width = width; - usurf->height = height; - uifw_trace("uifw_set_positionsize: Leave(OK, but no buffer)"); } - - /* if position change, call hook for input region */ - if (win_mgr_hook_change != NULL) { - if ((oldx != usurf->x) || (oldy != usurf->y) || (oldnode != usurf->node_tbl)) { - (*win_mgr_hook_change)(usurf); - } - } -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_visible: surface visible/raise control - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid UIFW surface id - * @param[in] visible visible(1=show/0=hide/other=no change) - * @param[in] raise raise(1=raise/0=lower/other=no change) - * @param[in] flags with/without animation - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_visible(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags) -{ - struct uifw_win_surface *usurf; - struct uifw_client *uclient; - struct weston_view *ev; - int restack; - int retanima; - int oldvisible; - - uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)", - surfaceid, visible, raise, flags); - - /* check for access control */ - uclient = ico_window_mgr_find_uclient(client); - if (resource != NULL) { - /* resource is NULL, internal use */ - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_visible: unknown client"); - uifw_trace("uifw_set_visible: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_visible: not permitted"); - uifw_trace("uifw_set_visible: Leave(%s not permitted)", uclient->appid); - return; - } - } - usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - if ((! usurf) || (! usurf->surface)) { - uifw_trace("uifw_set_visible: Leave(Surface Not Exist)"); - return; - } - oldvisible = ico_window_mgr_is_visible(usurf); - - if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) && - (uclient->manager == 0) && (uclient->privilege == 0)) { - uifw_trace("uifw_set_visible: Request from App(%s), not Manager", - uclient ? uclient->appid : ""); - uclient = NULL; - } - else { - uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid); - } - - restack = 0; - - if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) { - -#if PERFORMANCE_EVALUATIONS > 0 - if (! usurf->visible) { - uifw_perf("SWAP_BUFFER Show appid=%s surface=%08x", - usurf->uclient->appid, usurf->surfaceid); - } -#endif /*PERFORMANCE_EVALUATIONS*/ - if ((! usurf->visible) || - (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { - usurf->visible = 1; - uifw_trace("uifw_set_visible: Change to Visible"); - - if (usurf->layertype != LAYER_TYPE_INPUTPANEL) { - ico_ivi_shell_set_toplevel(usurf->shsurf); - } - - /* Weston surface configure */ - uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d", - (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y, - usurf->width, usurf->height); - ico_ivi_shell_set_surface_type(usurf->shsurf); - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); - - restack = 1; /* need damage */ - - if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) && - (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && - (win_mgr_hook_animation != NULL)) { - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - usurf->animation.no_configure = 0; - retanima = (*win_mgr_hook_animation)( - (flags & ICO_WINDOW_MGR_ANIMATION_POS) ? - ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS : - ICO_WINDOW_MGR_ANIMATION_OPSHOW, - (void *)usurf); - uifw_trace("uifw_set_visible: ret call anima = %d", retanima); - } - } - else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) && - (raise != ICO_WINDOW_MGR_RAISE_RAISE)) { - uifw_trace("uifw_set_visible: Leave(No Change)"); - return; - } - } - else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) { - -#if PERFORMANCE_EVALUATIONS > 0 - if (usurf->visible) { - uifw_perf("SWAP_BUFFER Hide appid=%s surface=%08x", - usurf->uclient->appid, usurf->surfaceid); - } -#endif /*PERFORMANCE_EVALUATIONS*/ - if ((usurf->visible) || - (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { - - /* Reset focus */ - win_mgr_reset_focus(usurf); - - /* Weston surface configure */ - ev = ico_ivi_get_primary_view(usurf); - weston_view_damage_below(ev); - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); - - retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA; - if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) && - (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && - (win_mgr_hook_animation != NULL)) { - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - usurf->animation.no_configure = 0; - retanima = (*win_mgr_hook_animation)( - (flags & ICO_WINDOW_MGR_ANIMATION_POS) ? - ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS : - ICO_WINDOW_MGR_ANIMATION_OPHIDE, - (void *)usurf); - } - if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) { - usurf->visible = 0; - uifw_trace("uifw_set_visible: Change to UnVisible"); - /* change visible to unvisible, restack surface list */ - restack = 1; - /* Weston surface configure */ - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); - } - else { - uifw_trace("uifw_set_visible: UnVisible but animation"); - } - } - else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) && - (raise != ICO_WINDOW_MGR_RAISE_RAISE)) { - uifw_trace("uifw_set_visible: Leave(No Change)"); - return; - } - } - else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) && - (raise != ICO_WINDOW_MGR_RAISE_RAISE)) { - uifw_trace("uifw_set_visible: Leave(No Change)"); - return; - } - - /* raise/lower */ - if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) { - win_mgr_set_raise(usurf, raise); - if (usurf->visible == 0) { - restack |= 2; - } - } - else { - raise = ICO_WINDOW_MGR_V_NOCHANGE; - } - - if (restack) { - ico_window_mgr_restack_layer(usurf); - } - - /* send event(VISIBLE) to manager */ - if (restack) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, - usurf, - (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 : - ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 : - ICO_WINDOW_MGR_V_NOCHANGE), - raise, uclient ? 0 : 1, 0,0); - } - - /* if visible change, call hook for input region */ - if (win_mgr_hook_change != NULL) { - if (oldvisible != ico_window_mgr_is_visible(usurf)) { - (*win_mgr_hook_change)(usurf); - } - } - uifw_trace("uifw_set_visible: Leave(OK)"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_animation: set animation of surface visible/unvisible - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid UIFW surface id - * @param[in] type how to change surface - * @param[in] anmation animation name - * @param[in] time animation time(ms), if 0, default time - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_animation(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t type, const char *animation, int32_t time) -{ - struct uifw_client *uclient; - int animaid; - struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - - uifw_trace("uifw_set_transition: surf=%08x,type=%x,anim=%s,time=%d", - surfaceid, type, animation, time); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_animation: unknown client"); - uifw_trace("uifw_set_animation: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_ANIMATION) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_animation: not permitted"); - uifw_trace("uifw_set_animation: Leave(%s not permitted)", uclient->appid); - return; - } - } - if (usurf) { - if ((*animation != 0) && (*animation != ' ')) { - animaid = ico_get_animation_name(animation); - uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid); - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) { - if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) || - (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) { - usurf->animation.next_anima = animaid; - } - else { - usurf->animation.hide_anima = animaid; - } - } - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) { - if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) || - (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) { - usurf->animation.next_anima = animaid; - } - else { - usurf->animation.show_anima = animaid; - } - } - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) { - if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) { - usurf->animation.next_anima = animaid; - } - else { - usurf->animation.move_anima = animaid; - } - } - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) { - if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) { - usurf->animation.next_anima = animaid; - } - else { - usurf->animation.resize_anima = animaid; - } - } - } - if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) { - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) { - usurf->animation.hide_time = time; - } - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) { - usurf->animation.show_time = time; - } - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) { - usurf->animation.move_time = time; - } - if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) { - usurf->animation.resize_time = time; - } - } - } - else { - uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid); - } -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_attributes: set surface attributes - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid UIFW surface id - * @param[in] attributes surface attributes - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_attributes(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, uint32_t attributes) -{ - struct uifw_client *uclient; - struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - - uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_attributes: unknown client"); - uifw_trace("uifw_set_attributes: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_ATTRIBUTES) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_attributes: not permitted"); - uifw_trace("uifw_set_attributes: Leave(%s not permitted)", uclient->appid); - return; - } - } - if (usurf) { - usurf->attributes = attributes; - if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) == - (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) { - usurf->attributes &= - ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT); - } - if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) == - (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) { - usurf->attributes &= - ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM); - } - } - uifw_trace("uifw_set_attributes: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_visible_animation: surface visibility control with animation - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid surface id - * @param[in] visible visible(1=show/0=hide) - * @param[in] x X coordinate on screen(if bigger than 16383, no change) - * @param[in] y Y coordinate on screen(if bigger than 16383, no change) - * @param[in] width surface width(if bigger than 16383, no change) - * @param[in] height surface height(if bigger than 16383, no change) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_visible_animation(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t visible, - int32_t x, int32_t y, int32_t width, int32_t height) -{ - struct uifw_client *uclient; - struct uifw_win_surface *usurf; - - uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)", - surfaceid, visible, x, y, width, height); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_visible_animation: unknown client"); - uifw_trace("uifw_visible_animation: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_VISIBLE_ANIMATION) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_visible_animation: not permitted"); - uifw_trace("uifw_visible_animation: Leave(%s not permitted)", uclient->appid); - return; - } - } - usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - - if ((! usurf) || (! usurf->surface)) { - uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)"); - return; - } - - usurf->animation.pos_x = x; - usurf->animation.pos_y = y; - if (width > 0) usurf->animation.pos_width = width; - else usurf->animation.pos_width = 1; - if (height > 0) usurf->animation.pos_height = height; - else usurf->animation.pos_height = 1; - usurf->animation.no_configure = 0; - - uifw_set_visible(client, resource, surfaceid, visible, - ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS); - - uifw_trace("uifw_visible_animation: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_active: set active surface - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid UIFW surface id - * @param[in] active target device - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_active(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t active) -{ - struct uifw_client *uclient; - struct uifw_win_surface *usurf; - - uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_active: unknown client"); - uifw_trace("uifw_set_active: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_ACTIVE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_active: not permitted"); - uifw_trace("uifw_set_active: Leave(%s not permitted)", uclient->appid); - return; - } - } - if ((surfaceid > 0) && - ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) { - usurf = ico_window_mgr_get_usurf_client(surfaceid, client); - } - else { - usurf = NULL; - } - if (usurf) { - switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) { - case ICO_WINDOW_MGR_ACTIVE_POINTER: - if (usurf != _ico_win_mgr->active_pointer_usurf) { - uifw_trace("uifw_set_active: pointer active change %08x->%08x", - _ico_win_mgr->active_pointer_usurf ? - _ico_win_mgr->active_pointer_usurf->surfaceid : 0, - usurf ? usurf->surfaceid : 0); - if (_ico_win_mgr->active_pointer_usurf) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - _ico_win_mgr->active_pointer_usurf, - (_ico_win_mgr->active_keyboard_usurf == - _ico_win_mgr->active_pointer_usurf) ? - ICO_WINDOW_MGR_ACTIVE_KEYBOARD : - ICO_WINDOW_MGR_ACTIVE_NONE, - 0,0,0,0); - } - _ico_win_mgr->active_pointer_usurf = usurf; - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - usurf, - ICO_WINDOW_MGR_ACTIVE_POINTER | - (_ico_win_mgr->active_keyboard_usurf == usurf) ? - ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0, - 0,0,0,0); - win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER); - } - break; - case ICO_WINDOW_MGR_ACTIVE_KEYBOARD: - if (usurf != _ico_win_mgr->active_keyboard_usurf) { - uifw_trace("uifw_set_active: keyboard active change %08x->%08x", - _ico_win_mgr->active_keyboard_usurf ? - _ico_win_mgr->active_keyboard_usurf->surfaceid : 0, - usurf ? usurf->surfaceid : 0); - if (_ico_win_mgr->active_keyboard_usurf) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - _ico_win_mgr->active_keyboard_usurf, - (_ico_win_mgr->active_keyboard_usurf == - _ico_win_mgr->active_pointer_usurf) ? - ICO_WINDOW_MGR_ACTIVE_POINTER : - ICO_WINDOW_MGR_ACTIVE_NONE, - 0,0,0,0); - } - _ico_win_mgr->active_keyboard_usurf = usurf; - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - usurf, - ICO_WINDOW_MGR_ACTIVE_KEYBOARD | - (_ico_win_mgr->active_pointer_usurf == usurf) ? - ICO_WINDOW_MGR_ACTIVE_POINTER : 0, - 0,0,0,0); - win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD); - } - break; - default: - if ((usurf != _ico_win_mgr->active_pointer_usurf) || - (usurf != _ico_win_mgr->active_keyboard_usurf)) { - uifw_trace("uifw_set_active: active change %08x/%08x->%08x", - _ico_win_mgr->active_pointer_usurf ? - _ico_win_mgr->active_pointer_usurf->surfaceid : 0, - _ico_win_mgr->active_keyboard_usurf ? - _ico_win_mgr->active_keyboard_usurf->surfaceid : 0, - usurf ? usurf->surfaceid : 0); - if (_ico_win_mgr->active_pointer_usurf) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - _ico_win_mgr->active_pointer_usurf, - ICO_WINDOW_MGR_ACTIVE_NONE, - 0,0,0,0); - if (_ico_win_mgr->active_keyboard_usurf == - _ico_win_mgr->active_pointer_usurf) { - _ico_win_mgr->active_keyboard_usurf = NULL; - } - } - if (_ico_win_mgr->active_keyboard_usurf) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - _ico_win_mgr->active_keyboard_usurf, - ICO_WINDOW_MGR_ACTIVE_NONE, - 0,0,0,0); - } - _ico_win_mgr->active_pointer_usurf = usurf; - _ico_win_mgr->active_keyboard_usurf = usurf; - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - usurf, - ICO_WINDOW_MGR_ACTIVE_POINTER | - ICO_WINDOW_MGR_ACTIVE_KEYBOARD, - 0,0,0,0); - win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER | - ICO_WINDOW_MGR_ACTIVE_KEYBOARD); - } - break; - } - uifw_trace("uifw_set_active: Leave(Change Active)"); - } - else { - win_mgr_set_active(NULL, active); - uifw_trace("uifw_set_active: Leave(Reset active surface)"); - } -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_layer_visible: layer visible control - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] layer layer id - * @param[in] visible visible(1=show/0=hide) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource, - uint32_t layer, int32_t visible) -{ - struct uifw_client *uclient; - struct uifw_win_layer *el; - struct uifw_win_layer *new_el; - struct uifw_win_surface *usurf; - struct weston_view *ev; - int layertype = 0; - - if ((layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) || - (layer == (uint32_t)_ico_ivi_background_layer)) { - layer = _ico_ivi_background_layer; - layertype = LAYER_TYPE_BACKGROUND; - } - else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) || - (layer == (uint32_t)_ico_ivi_touch_layer)) { - layer = _ico_ivi_touch_layer; - layertype = LAYER_TYPE_TOUCH; - } - else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) || - (layer == (uint32_t)_ico_ivi_cursor_layer)) { - layer = _ico_ivi_cursor_layer; - layertype = LAYER_TYPE_CURSOR; - } - else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) { - layer = _ico_ivi_startup_layer; - } - uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_layer_visible: unknown client"); - uifw_trace("uifw_set_layer_visible: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_LAYER_VISIBLE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_layer_visible: not permitted"); - uifw_trace("uifw_set_layer_visible: Leave(%s not permitted)", uclient->appid); - return; - } - } - /* Search Layer */ - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - if (el->layer == layer) break; - } - - if (&el->link == &_ico_win_mgr->ivi_layer_list) { - /* layer not exist, create new layer */ - uifw_trace("uifw_set_layer_visible: New Layer %d", layer); - new_el = win_mgr_create_layer(NULL, layer, layertype); - if (! new_el) { - uifw_trace("uifw_set_layer_visible: Leave(No Memory)"); - return; - } - new_el->visible = (visible != 0) ? TRUE : FALSE; - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL, - layer, new_el->visible, 0,0,0); - uifw_trace("uifw_set_layer_visible: Leave(new layer)"); - return; - } - - /* control all surface in layer */ - if ((el->visible != FALSE) && (visible == 0)) { - /* layer change to NOT visible */ - uifw_trace("uifw_set_layer_visible: change to not visible"); - el->visible = FALSE; - } - else if ((el->visible == FALSE) && (visible != 0)) { - /* layer change to visible */ - uifw_trace("uifw_set_layer_visible: change to visible"); - el->visible = TRUE; - } - else { - /* no change */ - uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)", - el->visible, visible); - return; - } - - /* set damege area */ - wl_list_for_each (usurf, &el->surface_list, ivi_layer) { - if ((usurf->visible != FALSE) && (usurf->surface != NULL) && - (usurf->surface->output != NULL)) { - /* Reset focus if hide */ - if (visible == 0) { - win_mgr_reset_focus(usurf); - } - /* Damage(redraw) target surface */ - ev = ico_ivi_get_primary_view(usurf); - weston_view_damage_below(ev); - } - } - - /* rebild compositor surface list */ - ico_window_mgr_restack_layer(NULL); - - /* send layer visible event to manager */ - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL, - layer, el->visible, 0,0,0); - - uifw_trace("uifw_set_layer_visible: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_get_surfaces: get application surfaces - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] appid application id - * @param[in] pid process id - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, - const char *appid, int32_t pid) -{ - struct uifw_client *uclient; - struct uifw_win_layer *el; - struct uifw_win_surface *usurf; - struct wl_array reply; - uint32_t *up; - - uifw_trace("uifw_get_surfaces: Enter(appid=%s, pid=%d)", appid ? appid : " ", pid); - - /* check for access control */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_get_surfaces: unknown client"); - uifw_trace("uifw_get_surfaces: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_GET_SURFACES) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_get_surfaces: not permitted"); - uifw_trace("uifw_get_surfaces: Leave(%s not permitted)", uclient->appid); - return; - } - - wl_array_init(&reply); - - wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) { - if ((appid != NULL) && (*appid != ' ')) { - if (strcmp(uclient->appid, appid) == 0) break; - } - if (pid != 0) { - if (uclient->pid == pid) break; - } - } - if (&uclient->link == &_ico_win_mgr->client_list) { - uifw_trace("uifw_get_surfaces: appid=%s pid=%d dose not exist", - appid ? appid : " ", pid); - } - else { - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - wl_list_for_each (usurf, &el->surface_list, ivi_layer) { - if (usurf->uclient == uclient) { - uifw_trace("uifw_get_surfaces: %s(%d) surf=%08x", - uclient->appid, uclient->pid, usurf->surfaceid); - up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t)); - if (up) { - *up = usurf->surfaceid; - } - } - } - } - } - ico_window_mgr_send_app_surfaces(resource, uclient->appid, uclient->pid, &reply); - - wl_array_release(&reply); - uifw_trace("uifw_get_surfaces: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_check_mapsurface: check and change all surface - * - * @param[in] animation weston animation table(unused) - * @param[in] outout weston output table(unused) - * @param[in] mseces current time(unused) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_check_mapsurface(struct weston_animation *animation, - struct weston_output *output, uint32_t msecs) -{ - struct uifw_surface_map *sm, *sm_tmp; - uint32_t curtime; - int wait = 99999999; - - /* check touch down counter */ - if ((touch_check_seat) && - (touch_check_seat->touch)) { - if (touch_check_seat->touch->num_tp > 10) { - uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset", - (int)touch_check_seat->touch->num_tp); - touch_check_seat->touch->num_tp = 0; - } - } - - /* check all mapped surfaces */ - curtime = weston_compositor_get_time(); - wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) { - uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x", - (int)sm, sm->usurf->surfaceid); - win_mgr_change_mapsurface(sm, 0, curtime); - if (sm->eventque) { - if (sm->interval < wait) { - wait = sm->interval; - } - } - } - - /* check frame interval */ - if (wait < 2000) { - wait = wait / 2; - } - else { - wait = 1000; - } - wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_timer_mapsurface: mapped surface check timer - * - * @param[in] data user data(unused) - * @return fixed 1 - */ -/*--------------------------------------------------------------------------*/ -static int -win_mgr_timer_mapsurface(void *data) -{ - win_mgr_check_mapsurface(NULL, NULL, 0); - return 1; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_change_mapsurface: check and change mapped surface - * - * @param[in] sm map surface table - * @param[in] event send event (if 0, send if changed) - * @param[in] curtime current time(ms) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime) -{ - struct uifw_drm_buffer *drm_buffer; - struct uifw_dri_image *dri_image; - struct uifw_intel_region *dri_region; - struct uifw_gl_surface_state *gl_state; - struct weston_surface *es; - struct weston_view *ev; - struct wl_shm_buffer *shm_buffer; - uint32_t eglname; - int width; - int height; - int stride; - uint32_t format; - uint32_t dtime; - int idx, idx2; - int delta, settime2; - struct ico_uifw_image_buffer *p; - - uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event); - if (event == 0) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; - } - - /* check if buffered */ - drm_buffer = NULL; - es = sm->usurf->surface; - if ((es == NULL) || - ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) && - ((es->buffer_ref.buffer == NULL) || - (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) { - /* surface has no buffer */ - uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x", - sm->usurf->surfaceid, (int)es, - es ? (int)es->buffer_ref.buffer : 0); - if (sm->initflag) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; - } - else { - event = 0; - } - } - else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) { - if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) { - drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data( - (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer); - if ((drm_buffer != NULL) && (drm_buffer->driver_buffer == NULL)) { - drm_buffer = NULL; - } - } - if (drm_buffer == NULL) { - /* surface has no buffer */ - uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer", - sm->usurf->surfaceid); - if (sm->initflag) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; - } - else { - event = 0; - } - } - } - else if (sm->uclient->shmbuf == NULL) { - /* no GPU acceleration but no buffer */ - uifw_debug("win_mgr_change_mapsurface: client has no shared memory buffer"); - if (sm->initflag) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; - } - else { - event = 0; - } - } - else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_SHM) { - if (es->buffer_ref.buffer != NULL) { - shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource); - if (shm_buffer) { - format = wl_shm_buffer_get_format(shm_buffer); - if (format != WL_SHM_FORMAT_ARGB8888) { - uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x", - sm->usurf->surfaceid, format); - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; - } - } - } - } - - if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) { - - if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) { - gl_state = (struct uifw_gl_surface_state *)es->renderer_state; - if (gl_state->buffer_type == BUFFER_TYPE_SHM) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; - } - else if (gl_state->buffer_type != BUFFER_TYPE_EGL) { - event = 0; - } - else { - dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer; - dri_region = dri_image->region; - width = es->buffer_ref.buffer->width; - height = es->buffer_ref.buffer->height; - stride = drm_buffer->stride[0]; - if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { - format = EGL_TEXTURE_RGB; - } - else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { - format = EGL_TEXTURE_RGBA; - } - else { - /* unknown format, error */ - format = EGL_NO_TEXTURE; - } - eglname = dri_region->name; - if (eglname == 0) { - if (drm_intel_bo_flink((drm_intel_bo *)dri_region->bo, &eglname)) { - uifw_warn("win_mgr_change_mapsurface: drm_intel_bo_flink() Error"); - eglname = 0; - } - } - if ((sm->initflag == 0) && (eglname != 0) && - (width > 0) && (height > 0) && (stride > 0)) { - sm->initflag = 1; - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; - } - else { - if ((eglname == 0) || (width <= 0) || (height <= 0) || (stride <= 0)) { - event = 0; - } - else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { - if ((sm->width != width) || (sm->height != height) || - (sm->stride != stride) || (format != sm->format)) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; - } - else if (eglname != sm->eglname) { -#if PERFORMANCE_EVALUATIONS > 0 - uifw_perf("SWAP_BUFFER appid=%s surface=%08x name=%d", - sm->usurf->uclient->appid, sm->usurf->surfaceid, - sm->eglname); -#endif /*PERFORMANCE_EVALUATIONS*/ - dtime = curtime - sm->lasttime; - if ((sm->interval > 0) && (dtime < sm->interval)) { - sm->eventque = 1; - event = 0; - } - } - else if (sm->eventque) { - dtime = curtime - sm->lasttime; - if ((sm->interval > 0) && (dtime < sm->interval)) { - event = 0; - } - } - else { - event =0; - } - } - } - sm->width = width; - sm->height = height; - sm->stride = stride; - sm->eglname = eglname; - sm->format = format; - } - } - else { - if ((sm->type != ICO_WINDOW_MGR_MAP_TYPE_PIXEL) || (sm->eventque != 0) || - (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) { - sm->curbuf = es->buffer_ref.buffer; - if (es->buffer_ref.buffer != NULL) { - width = es->buffer_ref.buffer->width; - height = es->buffer_ref.buffer->height; - } - else { - width = sm->usurf->client_width; - height = sm->usurf->client_height; - } - /* get shared memory buffer area */ - idx2 = sm->uclient->bufnum; - settime2 = 0x7fffffff; - for (idx = 0; idx < sm->uclient->bufnum; idx++) { - p = (struct ico_uifw_image_buffer *) - (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize); - if (p->settime == p->reftime) break; - delta = curtime - p->settime; - if (delta < 0) { - delta = delta + 0x80000000; - } - if ((delta > 3000) && (delta < settime2)) { - idx2 = idx; - settime2 = p->settime; - } - } - uifw_detail("win_mgr_change_mapsurface: PIX %08x idx=%d idx2=%d w/h=%d/%d", - sm->usurf->surfaceid, idx, idx2, width, height); - if (idx >= sm->uclient->bufnum) { - idx = idx2; - } - if (idx >= sm->uclient->bufnum) { - uifw_debug("win_mgr_change_mapsurface: shared buffer full"); - event = 0; - sm->curbuf = NULL; - sm->eventque = 1; - } - else if ((sm->initflag == 0) && (width > 0) && (height > 0)) { - sm->initflag = 1; - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; - uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x", - sm->usurf->surfaceid); - } - else { - if ((width <= 0) || (height <= 0)) { - event = 0; - sm->curbuf = NULL; - uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0", - sm->usurf->surfaceid); - } - else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { -#if PERFORMANCE_EVALUATIONS > 0 - if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) { - uifw_perf("SWAP_BUFFER appid=%s surface=%08x", - sm->usurf->uclient->appid, sm->usurf->surfaceid); - } -#endif /*PERFORMANCE_EVALUATIONS*/ - if ((sm->width != width) || (sm->height != height)) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; - } - else { - dtime = curtime - sm->lasttime; - if ((sm->interval > 0) && (dtime < sm->interval)) { - sm->eventque = 1; - event = 0; - uifw_detail("win_mgr_change_mapsurface: PIX %08x new queue", - sm->usurf->surfaceid); - } - else if (sm->eventque) { - dtime = curtime - sm->lasttime; - if ((sm->interval > 0) && (dtime < sm->interval)) { - event = 0; - uifw_detail("win_mgr_change_mapsurface: PIX %08x queued", - sm->usurf->surfaceid); - } - } - } - } - } - sm->width = width; - sm->height = height; - sm->stride = width * 4; - sm->format = EGL_TEXTURE_RGBA; - if (event != 0) { - /* read pixel */ - p = (struct ico_uifw_image_buffer *) - (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize); - height = (sm->uclient->bufsize - sizeof(struct ico_uifw_image_buffer)) - / (width * 4); - uifw_detail("win_mgr_change_mapsurface: PIX read buf=%08x height=%d(%d)", - (int)p, height, sm->height); - if ((height < sm->height) && - (sm->type == ICO_WINDOW_MGR_MAP_TYPE_SHM)) { - uifw_warn("win_mgr_change_mapsurface: Buffer SHM, " - "but buffer overflow(%d>%d)", sm->height, height); - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; - sm->eventque = 0; - } - else { - ev = ico_ivi_get_primary_view(sm->usurf); - if ((ev == NULL) || (ev->output == NULL)) { - uifw_debug("win_mgr_change_mapsurface: surface %08x has no view", - sm->usurf->surfaceid); - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; - } - else { - if (height > sm->height) { - height = sm->height; - } - if (ico_read_surface_pixels(es, PIXMAN_a8r8g8b8, p->image, - 0, 0, sm->width, height) != 0) { - uifw_debug("win_mgr_change_mapsurface: Error read pixel %s.%08x", - sm->usurf->uclient->appid, sm->usurf->surfaceid); - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; - sm->eventque = 0; - } - else { - uifw_detail("win_mgr_change_mapsurface: PIX read pixels(%d)", - idx+1); - p->surfaceid = sm->usurf->surfaceid; - p->settime = curtime; - p->width = sm->width; - p->height = height; - sm->eglname = idx + 1; - } - } - } - } - } - else { - event = 0; - } - } - } - - if (event != 0) { - uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d " - "name=%d w/h/s=%d/%d/%d format=%x", - event, sm->usurf->surfaceid, sm->type, sm->eglname, - sm->width, sm->height, sm->stride, sm->format); - sm->lasttime = curtime; - sm->eventque = 0; - ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event, - sm->usurf->surfaceid, sm->type, sm->eglname, - sm->width, sm->height, sm->stride, sm->format); - if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) { - /* free map table if error */ - wl_list_remove(&sm->surf_link); - wl_list_remove(&sm->map_link); - sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; - _ico_win_mgr->free_maptable = sm; - } - } -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_set_map_buffer: set map surface image buffer - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] shmname shared memory name(POSIX I/F) - * @param[in] bufsize buffer size in byte - * @param[in] bufnum number of buffers - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_set_map_buffer(struct wl_client *client, struct wl_resource *resource, - const char *shmname, uint32_t bufsize, uint32_t bufnum) -{ - struct uifw_client *uclient; - struct ico_uifw_image_buffer *p; - char *shmbuf; - int shmfd; - int i; - - uifw_trace("uifw_set_map_buffer: Enter(%s,%d,%d)", - shmname ? shmname : "(null)", bufsize, bufnum); - - /* check for access control */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_map_buffer: unknown client"); - uifw_trace("uifw_set_map_buffer: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_MAP_BUFFER) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_set_map_buffer: not permitted"); - uifw_trace("uifw_set_map_buffer: Leave(%s not permitted)", uclient->appid); - return; - } - - if ((shmname == NULL) || (*shmname == 0) || (*shmname == ' ') || - (bufsize == 0) || (bufnum == 0)) { - /* delete shared memory buffer */ - if (uclient->shmbuf) { - munmap(uclient->shmbuf, uclient->bufsize * uclient->bufnum); - uclient->shmbuf = NULL; - } - uifw_trace("uifw_set_map_buffer: Leave(delete shared memory buffer)"); - return; - } - - shmfd = shm_open(shmname, O_RDWR, 0600); - if (shmfd == -1) { - /* shared memory dose not exist */ - uifw_trace("uifw_set_map_buffer: Leave(shared memory(%s) dose not exist)", shmname); - return; - } - - shmbuf = (char *)mmap(NULL, bufsize * bufnum, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0); - close(shmfd); - - if (shmbuf == NULL) { - /* can not map shared memory */ - uifw_trace("uifw_set_map_buffer: Leave(can not map shared memory(%s))", shmname); - return; - } - if (uclient->shmbuf) { - munmap(uclient->shmbuf, uclient->bufsize * uclient->bufnum); - } - - uclient->shmbuf = shmbuf; - uclient->bufsize = bufsize; - uclient->bufnum = bufnum; - for (i = 0; i < (int)bufnum; i++) { - p = (struct ico_uifw_image_buffer *)(((char *)shmbuf) + bufsize * i); - memset((char *)p, 0, sizeof(struct ico_uifw_image_buffer)); - memcpy((char *)&p->magich, ICO_UIFW_IMAGE_BUFFER_MAGICH, 4); - memcpy((char *)&p->magict, ICO_UIFW_IMAGE_BUFFER_MAGICT, 4); - } - uifw_trace("uifw_set_map_buffer: Leave(shm addr=%08x)", (int)uclient->shmbuf); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_map_surface: mapped surface buffer to system application - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid surface id - * @param[in] framerate frame rate of surface update(frame/sec) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_map_surface(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid, int32_t framerate) -{ - struct uifw_win_surface *usurf; - struct weston_surface *es; - struct uifw_surface_map *sm; - struct weston_buffer *buffer; - struct wl_shm_buffer *shm_buffer; - struct uifw_client *uclient; - struct uifw_drm_buffer *drm_buffer; - struct uifw_gl_surface_state *gl_state; - int maptype; - int format; - - uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate); - - /* check for access control */ - uclient = ico_window_mgr_find_uclient(client); - if (resource != NULL) { - /* resource is NULL, internal use */ - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_map_surface: unknown client"); - uifw_trace("uifw_map_surface: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_MAP_SURFACE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_map_surface: not permitted"); - uifw_trace("uifw_map_surface: Leave(%s not permitted)", uclient->appid); - return; - } - } - if (! uclient) { - uifw_trace("uifw_map_surface: Leave(unknown client=%08x)", (int)client); - return; - } - - usurf = ico_window_mgr_get_usurf(surfaceid); - if (! usurf) { - /* surface dose not exist, error */ - ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 1, 0, 0, 0, 0, 0); - uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid); - return; - } - if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { - /* input panel surface dose not suport, error */ - ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 1, 0, 0, 0, 0, 0); - uifw_trace("uifw_map_surface: Leave(surface=%08x is input panel)", surfaceid); - return; - } - - /* check if buffered */ - es = usurf->surface; - if (es == NULL) { - /* surface has no buffer, error */ - ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 3, 0, 0, 0, 0, 0); - uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid); - return; - } - buffer = es->buffer_ref.buffer; - - /* check buffer type */ - gl_state = (struct uifw_gl_surface_state *)es->renderer_state; - if ((_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) || - (gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) { - /* No Acceleration or wl_shm_buffer support ReadPixels */ - if ((gl_state != NULL) && (gl_state->buffer_type == BUFFER_TYPE_SHM)) { - maptype = -1; - format = 0xff; - if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) { - if (buffer != NULL) { - shm_buffer = wl_shm_buffer_get(buffer->resource); - if (shm_buffer) { - format = wl_shm_buffer_get_format(shm_buffer); - uifw_detail("uifw_map_surface: %08x shm_buffer type %x", - surfaceid, format); - if (format == WL_SHM_FORMAT_ARGB8888) { - maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM; - } - } - } - else { - maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM; - } - } - if (maptype < 0) { - ico_window_mgr_send_map_surface(resource, - ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 5, 0, 0, 0, 0, 0); - uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))", - surfaceid, format); - return; - } - } - else { - maptype = ICO_WINDOW_MGR_MAP_TYPE_PIXEL; - } - } - else { - /* H/W(GPU) driver EGL buffer (Intel only) */ - maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL; - } - - /* maximum framerate */ - if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) { - if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_gpu)) - framerate = _ico_ivi_map_framerate_gpu; - } - else if (maptype == ICO_WINDOW_MGR_MAP_TYPE_SHM) { - if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_shm)) - framerate = _ico_ivi_map_framerate_shm; - } - else { - if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_pixel)) - framerate = _ico_ivi_map_framerate_pixel; - } - - /* check same surface */ - wl_list_for_each(sm, &usurf->surf_map, surf_link) { - if ((sm->usurf == usurf) && (sm->uclient == uclient)) { - break; - } - } - - if (&sm->surf_link == &usurf->surf_map) { - /* create map table */ - sm = _ico_win_mgr->free_maptable; - if (sm) { - _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf; - } - else { - sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map)); - if (! sm) { - ico_window_mgr_send_map_surface(resource, - ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 6, 0, 0, 0, 0, 0); - uifw_trace("uifw_map_surface: Leave(malloc error)"); - return; - } - } - memset(sm, 0, sizeof(struct uifw_surface_map)); - - wl_list_init(&sm->map_link); - wl_list_init(&sm->surf_link); - sm->usurf = usurf; - sm->uclient = uclient; - sm->type = maptype; - sm->framerate = framerate; - sm->interval = (1000 / sm->framerate) - 1; - wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link); - wl_list_insert(usurf->surf_map.prev, &sm->surf_link); - } - else { - /* change frame rate */ - uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d", - sm->framerate, framerate); - if (sm->framerate != framerate) { - sm->framerate = framerate; - sm->interval = (1000 / sm->framerate) - 1; - win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time()); - } - return; - } - - if (buffer != NULL) { - sm->width = buffer->width; - sm->height = buffer->height; - if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) { - sm->stride = sm->width * 4; - sm->format = EGL_TEXTURE_RGBA; - if ((sm->width > 0) && (sm->height > 0)) { - sm->initflag = 1; - } - uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d", - maptype, surfaceid, framerate, buffer->width, buffer->height); - } - else { - drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data( - (struct wl_resource *)buffer->legacy_buffer); - if (drm_buffer != NULL) { - sm->stride = drm_buffer->stride[0]; - if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { - sm->format = EGL_TEXTURE_RGB; - } - else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { - sm->format = EGL_TEXTURE_RGBA; - } - else { - /* unknown format, error */ - sm->format = EGL_NO_TEXTURE; - } - if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) && - (gl_state != NULL)) { - sm->initflag = 1; - } - uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d", - surfaceid, framerate, buffer->width, buffer->height); - } - else { - uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d", - surfaceid, framerate); - } - } - } - else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) { - sm->width = usurf->client_width; - sm->height = usurf->client_height; - sm->stride = sm->width * 4; - sm->format = EGL_TEXTURE_RGBA; - if ((sm->width > 0) && (sm->height > 0)) { - sm->initflag = 1; - } - uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d", - maptype, surfaceid, framerate, sm->width, sm->height); - } - else { - uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d", - surfaceid, framerate); - } - - /* send map event */ - if (sm->initflag) { - win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP, - weston_compositor_get_time()); - } - uifw_trace("uifw_map_surface: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief uifw_unmap_surface: unmap surface buffer - * - * @param[in] client Weyland client - * @param[in] resource resource of request - * @param[in] surfaceid surface id - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, - uint32_t surfaceid) -{ - struct uifw_win_surface *usurf; - struct uifw_surface_map *sm, *sm_tmp; - struct uifw_client *uclient; - struct ico_uifw_image_buffer *p; - int idx; - - uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid); - - /* check for access control */ - if (resource != NULL) { - /* resource is NULL, internal use */ - uclient = ico_window_mgr_find_uclient(client); - if (! uclient) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_unmap_surface: unknown client"); - uifw_trace("uifw_unmap_surface: Leave(unknown client=%08x)", (int)client); - return; - } - if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_UNMAP_SURFACE) == 0) { - wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "ico_window_mgr_unmap_surface: not permitted"); - uifw_trace("uifw_unmap_surface: Leave(%s not permitted)", uclient->appid); - return; - } - } - usurf = ico_window_mgr_get_usurf(surfaceid); - if (! usurf) { - /* surface dose not exist, error */ - uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid); - return; - } - if (client) { - uclient = ico_window_mgr_find_uclient(client); - if ((! uclient) || (! uclient->mgr)) { - /* client dose not exist, error */ - uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client); - return; - } - } - else { - uclient = NULL; - wl_list_for_each (sm, &usurf->surf_map, surf_link) { - if (sm->uclient->mgr != NULL) { - uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x " - "w/h/s=%d/%d/%d format=%x", - ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid, - sm->eglname, sm->width, sm->height, sm->stride, sm->format); - ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, - ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, - surfaceid, sm->type, sm->eglname, sm->width, - sm->height, sm->stride, sm->format); - } - } - } - - wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) { - if (((uclient != NULL) && (sm->uclient != uclient))) continue; - - if ((sm->type != ICO_WINDOW_MGR_MAP_TYPE_EGL) && - (sm->uclient->shmbuf != NULL)) { - /* reset shared memory buffer */ - for (idx = 0; idx < sm->uclient->bufnum; idx++) { - p = (struct ico_uifw_image_buffer *) - (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize); - if (p->surfaceid == surfaceid) { - p->surfaceid = 0; - p->settime = 0; - p->reftime = 0; - } - } - } - wl_list_remove(&sm->surf_link); - wl_list_remove(&sm->map_link); - sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; - _ico_win_mgr->free_maptable = sm; - } - uifw_trace("uifw_unmap_surface: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen) - * - * @param[in] surface Weston surface - * @param[in] x X coordinate on screen - * @param[in] y Y coordinate on screen - * @param[in] width surface width - * @param[in] height surface height - * @return number of managers - * @retval > 0 number of managers - * @retval 0 manager not exist - */ -/*--------------------------------------------------------------------------*/ -static int -win_mgr_surface_change_mgr(struct weston_surface *surface, - const int x, const int y, const int width, const int height) -{ - int num_mgr; - struct uifw_win_surface *usurf; - - uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)", - (int)surface, x, y, width, height); - - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)"); - return 0; - } - - num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, - usurf, x, y, width, height, 1); - - uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr); - return num_mgr; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_change_surface: surface change - * - * @param[in] surface Weston surface - * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager) - * @param[in] manager request from manager(0=Client,1=Manager) - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager) -{ - struct uifw_win_surface *usurf; - struct weston_surface *es; - struct weston_view *ev; - int x; - int y; - int repaint = 0; - - uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager); - - /* Find surface */ - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_change_surface: Leave(Not Exist)"); - return; - } - es = usurf->surface; - if (! es) { - uifw_trace("win_mgr_change_surface: Leave(No weston surface)"); - return; - } - - /* set surface size */ - ev = ico_ivi_get_primary_view(usurf); - uifw_debug("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d", - (int)ev->geometry.x, (int)ev->geometry.y, usurf->x, usurf->y, - es->width, es->height, usurf->width, usurf->height); - if ((usurf->width <= 0) || (usurf->height <= 0)) { - usurf->width = es->width; - usurf->height = es->height; - } - win_mgr_set_scale(usurf); - if (usurf->visible) { - weston_view_set_position(ev, (float)(usurf->node_tbl->disp_x + - usurf->x + usurf->xadd), - (float)(usurf->node_tbl->disp_y + - usurf->y + usurf->yadd)); - ico_window_mgr_restack_layer(usurf); - } - else { - weston_view_set_position(ev, (float)(ICO_IVI_MAX_COORDINATE+1), - (float)(ICO_IVI_MAX_COORDINATE+1)); - } - - /* send wayland event to client */ - if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) && - (usurf->width > 0) && (usurf->height > 0)) { - if ((usurf->width != usurf->conf_width) || - (usurf->height != usurf->conf_height)) { - usurf->conf_width = usurf->width; - usurf->conf_height = usurf->height; - uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ", - usurf->surfaceid, (int)es, usurf->width, usurf->height); - ico_ivi_shell_send_configure(es, - WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, - usurf->width, usurf->height); - } - } - - if (usurf->visible) { - x = usurf->node_tbl->disp_x + usurf->x; - y = usurf->node_tbl->disp_y + usurf->y; - } - else { - x = ICO_IVI_MAX_COORDINATE+1; - y = ICO_IVI_MAX_COORDINATE+1; - } - /* change geometry if request from manager */ - if (manager) { - if ((usurf->width != es->width) || - (usurf->height != es->height) || - ((int)ev->geometry.x != x) || ((int)ev->geometry.y != y)) { - win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height); - repaint ++; - } - } - - /* send manager event to HomeScreen */ - if (to <= 0) { - if (manager) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, - usurf, usurf->x, usurf->y, - usurf->width, usurf->height, 0); - } - else { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, - usurf, (int)ev->geometry.x, (int)ev->geometry.y, - es->width, es->height, 1); - } - } - - /* change geometry if request from client */ - if (! manager) { - if ((usurf->width != es->width) || (usurf->height != es->height) || - ((int)ev->geometry.x != x) || ((int)ev->geometry.y != y)) { - win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height); - repaint ++; - } - } - - if (repaint) { - uifw_trace("win_mgr_change_surface: repaint"); - weston_compositor_schedule_repaint(_ico_win_mgr->compositor); - } - uifw_trace("win_mgr_change_surface: Leave(OK)"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_surface_configure: UIFW surface configure - * - * @param[in] usurf UIFW surface - * @param[in] x X coordinate on screen - * @param[in] y Y coordinate on screen - * @param[in] width surface width - * @param[in] height surface height - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_surface_configure(struct uifw_win_surface *usurf, - int x, int y, int width, int height) -{ - struct weston_surface *es; - struct weston_view *ev; - - es = usurf->surface; - if ((es != NULL) && (es->buffer_ref.buffer)) { - if (usurf->client_width == 0) { - usurf->client_width = es->width; - if (usurf->client_width == 0) - usurf->client_width = ico_ivi_surface_buffer_width(es); - } - if (usurf->client_height == 0) { - usurf->client_height = es->height; - if (usurf->client_height == 0) - usurf->client_height = ico_ivi_surface_buffer_height(es); - } - - /* not set geometry width/height */ - win_mgr_set_scale(usurf); - ev = ico_ivi_get_primary_view(usurf); - weston_view_set_position(ev, x + usurf->xadd, y + usurf->yadd); - } -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_shell_configure: shell surface configure - * - * @param[in] surface Weston surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_shell_configure(struct weston_surface *surface) -{ - struct uifw_win_surface *usurf; - int buf_width; - int buf_height; - - uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface); - - /* Find UIFW surface */ - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_shell_configure: Leave(Not Exist)"); - return; - } - - usurf->client_width = surface->width; - usurf->client_height = surface->height; - ico_ivi_surface_buffer_size(surface, &buf_width, &buf_height); - uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d", - usurf->surfaceid, - usurf->client_width, usurf->client_height, buf_width, buf_height); - if (usurf->client_width > buf_width) usurf->client_width = buf_width; - if (usurf->client_height > buf_height) usurf->client_height = buf_height; - - /* send event to manager */ - win_mgr_change_surface(surface, -1, 0); - - uifw_trace("win_mgr_shell_configure: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_select_surface: select surface by Bottun/Touch - * - * @param[in] surface Weston surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_select_surface(struct weston_surface *surface) -{ - struct uifw_win_surface *usurf; - - uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface); - - /* find surface */ - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_select_surface: Leave(Not Exist)"); - return; - } - if (usurf != _ico_win_mgr->active_pointer_usurf) { - - /* send active event to manager */ - if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) { - uifw_trace("win_mgr_select_surface: not found manager, set active"); - win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER | - ICO_WINDOW_MGR_ACTIVE_KEYBOARD); - } - } - uifw_trace("win_mgr_select_surface: Leave(OK)"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_set_title: set tile name to surface - * - * @param[in] surface weston surface - * @param[in] title title name - * @return title string - * @retval != NULL title string - * @retval NULL no title string - */ -/*--------------------------------------------------------------------------*/ -static char * -win_mgr_set_title(struct weston_surface *surface, const char *title) -{ - struct uifw_win_surface *usurf; - char *optpoint, *ppoint, *bpoint, *cpoint; - int layer, visible, raise, node, x, y, width, height, attribute; - int rx, ry, rw, rh; - char wktitle[ICO_IVI_WINNAME_LENGTH + 256]; - - uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title); - - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_set_title: Leave(Not Exist)"); - return (char *)title; - } - - layer = -1; - visible = -1; - raise = -1; - node = -1; - x = -1; - y = -1; - width = -1; - height = -1; - attribute = -1; - - strncpy(wktitle, title, ICO_IVI_WINNAME_LENGTH+256-1); - wktitle[ICO_IVI_WINNAME_LENGTH+256-1] = 0; - - /* get option parameters */ - optpoint = strstr(wktitle, "@@"); - - if (optpoint != NULL) { - *optpoint = 0; - - usurf->uclient->privilege = 1; /* privilege application */ - ppoint = optpoint + 2; - while (1) { - bpoint = strtok(ppoint, "=;"); - ppoint = NULL; - if (! bpoint) break; - if (strcasecmp(bpoint, "layer") == 0) { - /* layer name or number */ - bpoint = strtok(ppoint, "=;"); - if (bpoint) { - if (strcasecmp(bpoint, "background") == 0) { - layer = _ico_ivi_background_layer; - } - else if (strcasecmp(bpoint, "default") == 0) { - layer = _ico_ivi_default_layer; - } - else if (strcasecmp(bpoint, "touch") == 0) { - layer = _ico_ivi_touch_layer; - } - else if (strcasecmp(bpoint, "cursor") == 0) { - layer = _ico_ivi_cursor_layer; - } - else if (strcasecmp(bpoint, "startup") == 0) { - layer = _ico_ivi_startup_layer; - } - else { - layer = strtol(bpoint, (char **)0, 0); - } - } - } - else if (strcasecmp(bpoint, "show") == 0) { - /* show */ - visible = 1; - } - else if (strcasecmp(bpoint, "hide") == 0) { - /* hide */ - visible = 0; - } - else if (strcasecmp(bpoint, "raise") == 0) { - /* raiee */ - raise = 1; - } - else if (strcasecmp(bpoint, "lower") == 0) { - /* lower */ - raise = 0; - } - else if (strcasecmp(bpoint, "node") == 0) { - /* node */ - bpoint = strtok(ppoint, ","); - if (bpoint) { - node = strtol(bpoint, (char **)0, 0); - } - } - else if (strcasecmp(bpoint, "position") == 0) { - /* position */ - bpoint = strtok(ppoint, ","); - if (bpoint) { - cpoint = strtok(ppoint, ";"); - if (cpoint) { - x = strtol(bpoint, (char **)0, 0); - y = strtol(cpoint, (char **)0, 0); - } - } - } - else if (strcasecmp(bpoint, "size") == 0) { - /* size */ - bpoint = strtok(ppoint, ","); - if (bpoint) { - cpoint = strtok(ppoint, ";"); - if (cpoint) { - width = strtol(bpoint, (char **)0, 0); - height = strtol(cpoint, (char **)0, 0); - } - } - } - else if (strcasecmp(bpoint, "attribute") == 0) { - /* attribute flags */ - bpoint = strtok(ppoint, ","); - if (bpoint) { - attribute = strtol(bpoint, (char **)0, 0); - } - } - else if (strcasecmp(bpoint, "region") == 0) { - /* set input region */ - bpoint = strtok(ppoint, ","); - if (bpoint) { - ry = 0; - rw = 100; - rh = 50; - rx = strtol(bpoint, (char **)0, 0); - bpoint = strtok(ppoint, ","); - if (bpoint) { - ry = strtol(bpoint, (char **)0, 0); - } - bpoint = strtok(ppoint, ","); - if (bpoint) { - rw = strtol(bpoint, (char **)0, 0); - } - bpoint = strtok(ppoint, ";"); - if (bpoint) { - rh = strtol(bpoint, (char **)0, 0); - } - if (win_mgr_hook_inputregion) { - (*win_mgr_hook_inputregion)(1, usurf, rx, ry, rw, rh, 0, 0, - 0, 0, 0, 0, 0); - } - } - } - else if (strcasecmp(bpoint, "unregion") == 0) { - /* unset input region */ - bpoint = strtok(ppoint, ","); - if (bpoint) { - ry = 0; - rw = 100; - rh = 50; - rx = strtol(bpoint, (char **)0, 0); - bpoint = strtok(ppoint, ","); - if (bpoint) { - ry = strtol(bpoint, (char **)0, 0); - } - bpoint = strtok(ppoint, ","); - if (bpoint) { - rw = strtol(bpoint, (char **)0, 0); - } - bpoint = strtok(ppoint, ";"); - if (bpoint) { - rh = strtol(bpoint, (char **)0, 0); - } - if (win_mgr_hook_inputregion) { - (*win_mgr_hook_inputregion)(0, usurf, rx, ry, rw, rh, 0, 0, - 0, 0, 0, 0, 0); - } - } - } - } - } - - if ((optpoint == NULL) || (wktitle[0] != 0)) { - if (((usurf->width > 0) && (usurf->height > 0)) && - ((usurf->created == 0) || - (strncmp(wktitle, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) { - strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1); - usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; - if (usurf->created == 0) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0); - usurf->created = 1; - } - else { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0); - } - } - else { - strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1); - usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; - } - } - - if (optpoint) { - if (layer >= 0) { - uifw_set_window_layer(usurf->uclient->client, NULL, usurf->surfaceid, layer); - } - if (attribute >= 0) { - uifw_set_attributes(usurf->uclient->client, NULL, usurf->surfaceid, attribute); - } - if ((node >= 0) || (x >=0) || (y >= 0) || (width >=0) || (height >= 0)) { - if (node < 0) node = usurf->node_tbl->node; - if (x < 0) x = ICO_IVI_MAX_COORDINATE + 1; - if (y < 0) y = ICO_IVI_MAX_COORDINATE + 1; - if (width < 0) width = ICO_IVI_MAX_COORDINATE + 1; - if (height < 0) height = ICO_IVI_MAX_COORDINATE + 1; - uifw_set_positionsize(usurf->uclient->client, NULL, usurf->surfaceid, - node, x, y, width, height, 0); - } - if ((visible >= 0) || (raise >= 0)) { - if (visible < 0) visible = ICO_WINDOW_MGR_V_NOCHANGE; - if (raise < 0) raise = ICO_WINDOW_MGR_V_NOCHANGE; - uifw_set_visible(usurf->uclient->client, NULL, usurf->surfaceid, - visible, raise, 0); + else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) { + sm->width = es->width; + sm->height = es->height; + sm->stride = sm->width * 4; + sm->format = EGL_TEXTURE_RGBA; + if ((sm->width > 0) && (sm->height > 0)) { + sm->initflag = 1; } - } - uifw_trace("win_mgr_set_title: Leave"); - - return usurf->winname; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_surface_move: set tile name to surface - * - * @param[in] surface weston surface - * @param[in] title title name - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy) -{ - struct uifw_win_surface *usurf; - - uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy); - - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_surface_move: Leave(Not Exist)"); - return; - } - if (usurf->visible) { - *dx = usurf->node_tbl->disp_x + usurf->x; - *dy = usurf->node_tbl->disp_y + usurf->y; + uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d", + maptype, surfaceid, framerate, sm->width, sm->height); } else { - *dx = ICO_IVI_MAX_COORDINATE+1; - *dy = ICO_IVI_MAX_COORDINATE+1; - } - uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_show_layer: shell layer visible control - * - * @param[in] layertype shell layer type - * @param[in] show show(1)/hide(0) - * @param[in] data requested weston surface in show - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_show_layer(int layertype, int show, void *data) -{ - struct uifw_win_layer *el; - struct uifw_win_surface *usurf; - struct uifw_win_surface *inusurf = NULL; - - uifw_trace("win_mgr_show_layer: Enter(type=%d, show=%d, data=%08x)", - layertype, show, (int)data); - - if (layertype != LAYER_TYPE_INPUTPANEL) { - uifw_trace("win_mgr_show_layer: Leave(layertype npt InputPanel)"); - return; - } - if (show) { - if (data == NULL) { - uifw_trace("win_mgr_show_layer: Leave(show but input surface not exist)"); - return; - } - inusurf = find_uifw_win_surface_by_ws((struct weston_surface *)data); - if (! inusurf) { - uifw_trace("win_mgr_show_layer: Leave(show but unknown input surface)"); - return; - } - } - - /* all input panel surface show/hide */ - wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - if ((el->layertype == LAYER_TYPE_CURSOR) || - (el->layertype == LAYER_TYPE_TOUCH)) continue; - wl_list_for_each (usurf, &el->surface_list, ivi_layer) { - if ((usurf->layertype == LAYER_TYPE_INPUTPANEL) && - (usurf->surface != NULL) && (usurf->mapped != 0) && - (usurf->surface->buffer_ref.buffer != NULL)) { - - if ((inusurf != NULL) && (usurf->win_layer != inusurf->win_layer)) { - win_mgr_set_layer(usurf, usurf->win_layer->layer); - usurf->raise = 1; - win_mgr_change_surface(usurf->surface, -1, 1); - } - if ((show == 0) || (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_INPUTLAYER)) { - /* show input panel automatically */ - ico_window_mgr_set_visible(usurf, show | 2); - } - else { - /* send hint event to HomeScreen */ - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, - usurf, show, ICO_WINDOW_MGR_RAISE_RAISE, 1, 0,0); - } - } - } - } - uifw_trace("win_mgr_show_layer: Leave"); -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_fullscreen: shell full screen surface control - * - * @param[in] event control event - * @param[in] surface target weston surface - * @return result - */ -/*--------------------------------------------------------------------------*/ -static int -win_mgr_fullscreen(int event, struct weston_surface *surface) -{ - struct uifw_win_surface *usurf; - struct uifw_win_surface *tmpusurf; - struct uifw_win_layer *ulayer; - int width, height; - int sx, sy; - - uifw_trace("win_mgr_fullscreen: Enter(event=%d, surface=%08x)", event, (int)surface); - - if (event == SHELL_FULLSCREEN_HIDEALL) { - /* hide all fullscreen srface */ - uifw_trace("win_mgr_fullscreen: SHELL_FULLSCREEN_HIDEALL"); - - wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) { - if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue; - wl_list_for_each_safe (usurf, tmpusurf, &ulayer->surface_list, ivi_layer) { - if (usurf->layertype == LAYER_TYPE_FULLSCREEN) { - ico_window_mgr_set_visible(usurf, 2); - usurf->layertype = usurf->old_layertype; - win_mgr_set_layer(usurf, usurf->old_layer->layer); - win_mgr_change_surface(usurf->surface, -1, 1); - /* send event to HomeScreen */ - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, - usurf, usurf->x, usurf->y, - usurf->width, usurf->height, 0); - } - } - } - uifw_trace("win_mgr_fullscreen: Leave"); - return 0; - } - - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("win_mgr_fullscreen: Leave(surface dose not exist)"); - return -1; - } - - switch(event) { - case SHELL_FULLSCREEN_ISTOP: /* check if top surface */ - if (usurf->layertype == LAYER_TYPE_FULLSCREEN) { - wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) { - if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue; - wl_list_for_each(tmpusurf, &ulayer->surface_list, ivi_layer) { - if (usurf == tmpusurf) { - uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP" - "(fullscreen surface)", usurf->surfaceid); - return 1; - } - if (tmpusurf->layertype == LAYER_TYPE_FULLSCREEN) { - uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP" - "(fullscreen surface but not top)", usurf->surfaceid); - return 0; - } - } - } - } - uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP" - "(not fullscreen surface)", usurf->surfaceid); - return 0; - case SHELL_FULLSCREEN_SET: /* change surface to full screen */ - uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_SET", usurf->surfaceid); - if (usurf->layertype != LAYER_TYPE_FULLSCREEN) { - usurf->old_layertype = usurf->layertype; - usurf->layertype = LAYER_TYPE_FULLSCREEN; - usurf->old_layer = usurf->win_layer; - /* send hint event to HomeScreen */ - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, - usurf, usurf->x, usurf->y, - usurf->width, usurf->height, 1); - } - break; - case SHELL_FULLSCREEN_UNSET: /* change surface to normal screen */ - uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_UNSET", usurf->surfaceid); - if (usurf->layertype == LAYER_TYPE_FULLSCREEN) { - ico_window_mgr_set_visible(usurf, 2); - usurf->layertype = usurf->old_layertype; - win_mgr_set_layer(usurf, usurf->old_layer->layer); - win_mgr_change_surface(usurf->surface, -1, 1); - /* send event to HomeScreen */ - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, - usurf, usurf->x, usurf->y, - usurf->width, usurf->height, 0); - } - break; - case SHELL_FULLSCREEN_CONF: /* configure full screen surface */ - uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_CONF", usurf->surfaceid); - if (usurf->mapped == 0) { - width = usurf->node_tbl->disp_width; - height = usurf->node_tbl->disp_height; - sx = 0; - sy = 0; - win_mgr_surface_map(usurf->surface, &width, &height, &sx, &sy); - } - break; - default: - uifw_trace("win_mgr_fullscreen: Leave(unknown event %d)", event); - return -1; + uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d", + surfaceid, framerate); } - uifw_trace("win_mgr_fullscreen: Leave"); - return 0; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_reset_focus: reset surface focus - * - * @param[in] usurf UIFW surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -static void -win_mgr_reset_focus(struct uifw_win_surface *usurf) -{ - struct weston_seat *seat; - struct weston_surface *surface; - - uifw_trace("win_mgr_reset_focus: Enter(%08x)", usurf->surfaceid); - seat = container_of (_ico_win_mgr->compositor->seat_list.next, struct weston_seat, link); - surface = usurf->surface; - if ((seat != NULL) && (surface != NULL)) { -#if 0 /* pointer grab can not release */ - /* reset pointer focus */ - if ((seat->pointer != NULL) && (seat->pointer->focus == surface)) { - weston_pointer_set_focus(seat->pointer, NULL, - wl_fixed_from_int(0), wl_fixed_from_int(0)); - } - /* reset touch focus */ - if ((seat->touch != NULL) && (seat->touch->focus == surface)) { - weston_touch_set_focus(seat, NULL); - } -#endif /* pointer grab can not release */ - /* reset keyboard focus */ - if ((seat->keyboard != NULL) && (seat->keyboard->focus == surface)) { - weston_keyboard_set_focus(seat->keyboard, NULL); - } + /* send map event */ + if (sm->initflag) { + win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP, + weston_compositor_get_time()); } - uifw_trace("win_mgr_reset_focus: Leave"); + uifw_trace("uifw_map_surface: Leave"); } /*--------------------------------------------------------------------------*/ /** - * @brief ico_window_mgr_set_visible: change surface visibility + * @brief uifw_unmap_surface: unmap surface buffer * - * @param[in] usurf UIFW surface - * @param[in] visible bit 0: visible(=1)/unvisible(=0) - * bit 1: width anima(=1)/without anima(=0) + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid surface id * @return none */ /*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible) +static void +uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid) { - int retanima; - - if (visible & 1) { - if ((usurf->visible == 0) || - (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { - uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x) x/y=%d/%d", - usurf->surfaceid, usurf->x, usurf->y); - usurf->visible = 1; - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); - if ((visible & 2) && (win_mgr_hook_animation != NULL)) { - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - usurf->animation.no_configure = 0; - retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW, - (void *)usurf); - uifw_trace("ico_window_mgr_set_visible: show animation = %d", retanima); - } - /* change unvisible to visible, restack surface list */ - ico_window_mgr_restack_layer(usurf); + struct uifw_win_surface *usurf; + struct uifw_surface_map *sm, *sm_tmp; + struct uifw_client *uclient; + + uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid); + + usurf = ico_window_mgr_get_usurf(surfaceid); + if (! usurf) { + /* surface dose not exist, error */ + uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid); + return; + } + if (client) { + uclient = ico_window_mgr_find_uclient(client); + if ((! uclient) || (! uclient->mgr)) { + /* client dose not exist, error */ + uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client); + return; } } else { - if ((usurf->visible != 0) || - (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { - - uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)", - usurf->surfaceid); - - /* Reset focus */ - win_mgr_reset_focus(usurf); - - retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA; - if ((visible & 2) && (win_mgr_hook_animation != NULL)) { - usurf->animation.pos_x = usurf->x; - usurf->animation.pos_y = usurf->y; - usurf->animation.pos_width = usurf->width; - usurf->animation.pos_height = usurf->height; - usurf->animation.no_configure = 0; - retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE, - (void *)usurf); - uifw_trace("ico_window_mgr_set_visible: hide animation = %d", retanima); - if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) { - usurf->visible = 0; - /* Weston surface configure */ - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); - } - } - else { - usurf->visible = 0; - /* Weston surface configure */ - ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, - usurf->width, usurf->height); + uclient = NULL; + wl_list_for_each (sm, &usurf->surf_map, surf_link) { + if (sm->uclient->mgr != NULL) { + uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x " + "w/h/s=%d/%d/%d format=%x", + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid, + sm->width, sm->height, sm->stride, sm->format); + ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, + surfaceid, sm->type, sm->width, + sm->height, sm->stride, sm->format); } - ico_window_mgr_restack_layer(usurf); } } - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, - usurf, usurf->visible, usurf->raise, 0, 0, 0); + wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) { + if (((uclient != NULL) && (sm->uclient != uclient))) continue; + wl_list_remove(&sm->surf_link); + wl_list_remove(&sm->map_link); + if (sm->filepath[0]) { + unlink(sm->filepath); + } + sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; + _ico_win_mgr->free_maptable = sm; + } + uifw_trace("uifw_unmap_surface: Leave"); } /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_set_raise: change surface raise/lower + * @brief win_mgr_surface_configure: UIFW surface configure * * @param[in] usurf UIFW surface - * @param[in] raise raise(=1)/lower(0) + * @param[in] x X coordinate on screen + * @param[in] y Y coordinate on screen + * @param[in] width surface width + * @param[in] height surface height * @return none */ /*--------------------------------------------------------------------------*/ static void -win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise) +win_mgr_surface_configure(struct uifw_win_surface *usurf, + int x, int y, int width, int height) { - struct uifw_win_surface *eu; - - uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%d type=%x", - (int)usurf, raise, (int)usurf->win_layer->layer, usurf->layertype); - - wl_list_remove(&usurf->ivi_layer); - if (raise & 1) { - /* raise ... surface stack to top of layer */ - if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { - /* if input panel, top of surface list */ - uifw_trace("win_mgr_set_raise: Raise Link to Top(InputPanel)"); - wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer); - } - else { - /* if not input panel, search not input panel */ - wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) { - if (eu->layertype != LAYER_TYPE_INPUTPANEL) break; - } - uifw_trace("win_mgr_set_raise: Raise Link to Top(Normal)"); - wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer); - } - usurf->raise = 1; - } - else { - /* Lower ... surface stack to bottom of layer */ - if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { - /* if input panel, search not input panel */ - uifw_trace("win_mgr_set_raise: Lower Link to Bottom(InputPanel)"); - wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) { - if (eu->layertype != LAYER_TYPE_INPUTPANEL) break; - } - wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer); + struct weston_surface *es; + struct weston_view *ev; + + es = usurf->surface; + if ((es != NULL) && (es->buffer_ref.buffer)) { + if (usurf->client_width == 0) { + usurf->client_width = es->width; + if (usurf->client_width == 0) + usurf->client_width = ico_ivi_surface_buffer_width(es); } - else { - /* if not input panel, bottom of surface list */ - uifw_trace("win_mgr_set_raise: Lower Link to Bottom(Normal)"); - wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer); + if (usurf->client_height == 0) { + usurf->client_height = es->height; + if (usurf->client_height == 0) + usurf->client_height = ico_ivi_surface_buffer_height(es); } - usurf->raise = 0; - } - /* rebild compositor surface list */ - if ((raise & 2) == 0) { - if (usurf->visible) { - ico_window_mgr_restack_layer(usurf); - } - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, - usurf, usurf->visible, usurf->raise, 0, 0,0); + /* not set geometry width/height */ + ev = ico_ivi_get_primary_view(usurf); + weston_view_set_position(ev, x + usurf->xadd, y + usurf->yadd); } - uifw_trace("win_mgr_set_raise: Leave"); } /*--------------------------------------------------------------------------*/ @@ -4975,9 +2107,6 @@ win_mgr_destroy_surface(struct weston_surface *surface) } uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid); - /* Reset focus */ - win_mgr_reset_focus(usurf); - /* destory input region */ if (win_mgr_hook_destory) { (*win_mgr_hook_destory)(usurf); @@ -4988,23 +2117,11 @@ win_mgr_destroy_surface(struct weston_surface *surface) uifw_unmap_surface(NULL, NULL, usurf->surfaceid); } - /* destroy active surface */ - if (usurf == _ico_win_mgr->active_pointer_usurf) { - _ico_win_mgr->active_pointer_usurf = NULL; - } - if (usurf == _ico_win_mgr->active_keyboard_usurf) { - _ico_win_mgr->active_keyboard_usurf = NULL; - } - /* destroy animation extenson */ if (win_mgr_hook_animation) { (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf); } - /* delete from layer list */ - wl_list_remove(&usurf->ivi_layer); - ico_window_mgr_restack_layer(NULL); - /* delete from cleint list */ wl_list_remove(&usurf->client_link); @@ -5037,12 +2154,6 @@ win_mgr_destroy_surface(struct weston_surface *surface) _ico_win_mgr->wshash[hash] = usurf->next_wshash; } - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED, - usurf, 0,0,0,0,0); - - hash = usurf->surfaceid & SURCAFE_ID_MASK; - _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16)); - free(usurf); uifw_trace("win_mgr_destroy_surface: Leave(OK)"); } @@ -5113,233 +2224,17 @@ unbind_ico_win_mgr(struct wl_resource *resource) uifw_trace("unbind_ico_win_mgr: Enter"); /* Remove manager from manager list */ - _ico_win_mgr->num_manager = 0; wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) { if (mgr->resource == resource) { wl_list_remove(&mgr->link); free(mgr); } - else { - if (mgr->manager) { - _ico_win_mgr->num_manager++; - } - } } uifw_trace("unbind_ico_win_mgr: Leave"); } /*--------------------------------------------------------------------------*/ /** - * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen) - * - * @param[in] event event code(if -1, not send event) - * @param[in] usurf UIFW surface table - * @param[in] param1 parameter 1 - * @param[in] : : - * @param[in] param5 parameter 5 - * @return number of managers - * @retval > 0 number of managers - * @retval 0 manager not exist - */ -/*--------------------------------------------------------------------------*/ -static int -ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, - const int param1, const int param2, const int param3, - const int param4, const int param5) -{ - int num_mgr = 0; - struct uifw_manager* mgr; - - /* if DESTROY and no send CREATE, Nop */ - if ((event == ICO_WINDOW_MGR_WINDOW_DESTROYED) && - (usurf != NULL) && (usurf->created == 0)) { - return 0; - } - - /* if appid not fix, check and fix appid */ - if ((usurf != NULL) && - (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) { - win_mgr_get_client_appid(usurf->uclient); - } - - /* send created if not send created event */ - if ((usurf != NULL) && (usurf->created == 0) && - (((usurf->width > 0) && (usurf->height > 0)) || - ((event != ICO_WINDOW_MGR_WINDOW_CREATED) && - (event != ICO_WINDOW_MGR_WINDOW_NAME)))) { - wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { - if (mgr->manager) { - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED" - "(surf=%08x,name=%s,pid=%d,appid=%s,type=%x)", (int)mgr->resource, - usurf->surfaceid, usurf->winname, usurf->uclient->pid, - usurf->uclient->appid, usurf->layertype); - ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid, - usurf->winname, usurf->uclient->pid, - usurf->uclient->appid, - usurf->layertype << 12); - } - } - usurf->created = 1; - } - - wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { - if (mgr->manager) { - num_mgr ++; - - switch(event) { - case ICO_WINDOW_MGR_WINDOW_CREATED: - /* Do nothing anymore because sended window create event */ - break; - - case ICO_WINDOW_MGR_WINDOW_NAME: - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME" - "(surf=%08x,name=%s)", (int)mgr->resource, - usurf->surfaceid, usurf->winname); - ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid, - usurf->winname); - break; - - case ICO_WINDOW_MGR_WINDOW_DESTROYED: - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED" - "(surf=%08x)", (int)mgr->resource, usurf->surfaceid); - ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid); - break; - - case ICO_WINDOW_MGR_WINDOW_VISIBLE: - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE" - "(surf=%08x,vis=%d,raise=%d,hint=%d)", - (int)mgr->resource, usurf->surfaceid, param1, param2, param3); - ico_window_mgr_send_window_visible(mgr->resource, - usurf->surfaceid, param1, param2, param3); - break; - - case ICO_WINDOW_MGR_WINDOW_CONFIGURE: - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE" - "(surf=%08x,app=%s,node=%x,type=%x,layer=%d," - "x/y=%d/%d,w/h=%d/%d,hint=%d)", - (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid, - usurf->node_tbl->node, usurf->layertype, - usurf->win_layer->layer, param1, param2, param3, param4, param5); - ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid, - usurf->node_tbl->node, - usurf->layertype << 12, - usurf->win_layer->layer, - param1, param2, param3, param4, param5); - break; - - case ICO_WINDOW_MGR_WINDOW_ACTIVE: - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE" - "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid, - param1); - ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid, - (uint32_t)param1); - break; - - case ICO_WINDOW_MGR_LAYER_VISIBLE: - uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE" - "(layer=%d,visivle=%d)", (int)mgr->resource, param1, param2); - ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2); - break; - - default: - uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event); - break; - } - } - } - return num_mgr; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief win_mgr_set_scale: set surface transform scale - * - * @param[in] usurf UIFW surface - * @return chagne display - * @retval =1 change display - * @retval =0 no change - */ -/*--------------------------------------------------------------------------*/ -static int -win_mgr_set_scale(struct uifw_win_surface *usurf) -{ - struct weston_surface *es; - struct weston_view *ev; - float scalex; - float scaley; - int ret = 0; - - es = usurf->surface; - if ((es != NULL) && (es->buffer_ref.buffer)) { - if (usurf->client_width == 0) usurf->client_width = es->width; - if (usurf->client_height == 0) usurf->client_height = es->height; - if ((usurf->client_width > 0) && (usurf->client_height > 0)) { - scalex = (float)usurf->width / (float)usurf->client_width; - scaley = (float)usurf->height / (float)usurf->client_height; - } - else { - scalex = 1.0f; - scaley = 1.0f; - } - uifw_debug("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)", - usurf->surfaceid, scalex, usurf->width, usurf->client_width, - scaley, usurf->height, usurf->client_height); - usurf->xadd = 0; - usurf->yadd = 0; - if ((ico_ivi_optionflag() & ICO_IVI_OPTION_FIXED_ASPECT) || - (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT)) { - if (scalex > scaley) { - scalex = scaley; - if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) { - usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex); - if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) { - usurf->xadd /= 2; - } - } - } - else if (scalex < scaley) { - scaley = scalex; - if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) { - usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley); - if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) { - usurf->yadd /= 2; - } - } - } - uifw_debug("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d", - usurf->surfaceid, usurf->xadd, usurf->yadd); - } - if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) { - usurf->scalex = scalex; - usurf->scaley = scaley; - ev = ico_ivi_get_primary_view(usurf); - if ((scalex != 1.0f) || (scaley != 1.0f)) { - weston_matrix_init(&usurf->transform.matrix); - weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f); - uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform); - if (usurf->set_transform == 0) { - usurf->set_transform = 1; - wl_list_init(&usurf->transform.link); - wl_list_insert(&ev->geometry.transformation_list, &usurf->transform.link); - } - } - else if (usurf->set_transform != 0) { - uifw_trace("win_mgr_set_scale: reset transform"); - usurf->set_transform = 0; - wl_list_remove(&usurf->transform.link); - } - weston_view_geometry_dirty(ev); - weston_view_update_transform(ev); - weston_view_damage_below(ev); - weston_surface_damage(es); - ret = 1; - } - } - return ret; -} - -/*--------------------------------------------------------------------------*/ -/** * @brief ico_window_mgr_get_uclient: get UIFW client table * * @param[in] appid application Id @@ -5425,65 +2320,6 @@ ico_window_mgr_get_client_usurf(const char *target) /*--------------------------------------------------------------------------*/ /** - * @brief ico_window_mgr_is_visible: check surface visible - * - * @param[in] usurf UIFW surface - * @return visibility - * @retval =1 visible - * @retval =0 not visible - * @retval =-1 surface visible but layer not vlsible - * @retval =-2 surface visible but lower(currently not support) - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT int -ico_window_mgr_is_visible(struct uifw_win_surface *usurf) -{ - if ((usurf->visible == 0) || (usurf->surface == NULL) || (usurf->mapped == 0)) { - return 0; - } - if (usurf->win_layer->visible == 0) { - return -1; - } - return 1; -} - -/*--------------------------------------------------------------------------*/ -/** - * @brief ico_window_mgr_active_surface: set active surface - * - * @param[in] surface Weston surface - * @return none - */ -/*--------------------------------------------------------------------------*/ -WL_EXPORT void -ico_window_mgr_active_surface(struct weston_surface *surface) -{ - struct uifw_win_surface *usurf; - - /* find surface */ - usurf = find_uifw_win_surface_by_ws(surface); - if (! usurf) { - uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", (int)surface); - uifw_trace("ico_window_mgr_active_surface: Leave(Not Exist)"); - return; - } - uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", usurf->surfaceid); - - if ((usurf != _ico_win_mgr->active_pointer_usurf) || - (usurf != _ico_win_mgr->active_keyboard_usurf)) { - - /* set weston active surface */ - win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER | - ICO_WINDOW_MGR_ACTIVE_KEYBOARD); - /* send active event to manager */ - (void) ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, - usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0); - } - uifw_trace("ico_window_mgr_active_surface: Leave(OK)"); -} - -/*--------------------------------------------------------------------------*/ -/** * @brief ico_window_mgr_set_hook_animation: set animation hook routine * * @param[in] hook_animation hook routine @@ -5565,12 +2401,7 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) struct weston_output *output; struct weston_config_section *section; char *displayno = NULL; - char *p, *pp; - char *wrkstrp; - char wkbuf[ICO_UIFW_MAX_SUBJECT_NAME]; - struct ico_api_permit *accp; - struct ico_api_permit *accp_next; - int same_accp; + char *p; struct wl_event_loop *loop; uifw_info("ico_window_mgr: Enter(module_init)"); @@ -5586,92 +2417,19 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL); if (section) { weston_config_section_get_string(section, "displayno", &displayno, NULL); - weston_config_section_get_int(section, "inputpanel", - &_ico_ivi_inputpanel_display, 0); } - /* get layer id */ - section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL); - if (section) { - weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1); - weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0); - weston_config_section_get_int(section, "touch", &_ico_ivi_touch_layer, 101); - weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102); - weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 103); - weston_config_section_get_string(section, "inputpaneldeco", &wrkstrp, NULL); - if (wrkstrp) { - p = strtok(wrkstrp, ";,"); - if (p) { - _ico_ivi_inputdeco_mag = strtol(p, (char **)0, 0); - p = strtok(NULL, ";,"); - if (p) { - _ico_ivi_inputdeco_diff = strtol(p, (char **)0, 0); - } - } - free(wrkstrp); - } - } - if (_ico_ivi_inputdeco_mag < 20) _ico_ivi_inputdeco_mag = 100; - /* get animation default */ section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL); if (section) { weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL); - weston_config_section_get_string(section, "inputpanel", - &_ico_ivi_inputpanel_animation, NULL); weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500); weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30); - if (_ico_ivi_animation_name) { - p = strtok(_ico_ivi_animation_name, ";,"); - if (p) { - p = strtok(NULL, ";."); - if (p) { - _ico_ivi_animation_time = strtol(p, (char **)0, 0); - p = strtok(NULL, ";."); - if (p) { - _ico_ivi_animation_fps = strtol(p, (char **)0, 0); - } - } - } - } - if (_ico_ivi_inputpanel_animation) { - p = strtok(_ico_ivi_inputpanel_animation, ";,"); - if (p) { - p = strtok(NULL, ",;"); - if (p) { - _ico_ivi_inputpanel_anima_time = strtol(p, (char **)0, 0); - } - } - } } if (_ico_ivi_animation_name == NULL) _ico_ivi_animation_name = (char *)"fade"; - if (_ico_ivi_inputpanel_animation == NULL) - _ico_ivi_inputpanel_animation = (char *)"fade"; if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500; if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30; - if (_ico_ivi_inputpanel_anima_time < 100) - _ico_ivi_inputpanel_anima_time = _ico_ivi_animation_time; - - /* get thumbnail maximum frame rate */ - section = weston_config_get_section(ec->config, "ivi-thumbnail", NULL, NULL); - if (section) { - weston_config_section_get_int(section, "gpu_accel_fps", - &_ico_ivi_map_framerate_gpu, 30); - if ((_ico_ivi_map_framerate_gpu <= 0) || (_ico_ivi_map_framerate_gpu > 60)) { - _ico_ivi_map_framerate_gpu = 30; - } - weston_config_section_get_int(section, "shm_buffer_fps", - &_ico_ivi_map_framerate_shm, 5); - if ((_ico_ivi_map_framerate_shm <= 0) || (_ico_ivi_map_framerate_shm > 10)) { - _ico_ivi_map_framerate_shm = 5; - } - weston_config_section_get_int(section, "no_accel_fps", - &_ico_ivi_map_framerate_pixel, 10); - if ((_ico_ivi_map_framerate_pixel <= 0) || (_ico_ivi_map_framerate_pixel > 20)) { - _ico_ivi_map_framerate_pixel = 10; - } - } /* create ico_window_mgr management table */ _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr)); @@ -5682,102 +2440,8 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr)); - /* get access control configuration */ - section = weston_config_get_section(ec->config, "ivi-access-control", NULL, NULL); - accp_next = NULL; - if (section) { - for (idx = 0; ; idx++) { - sprintf(wkbuf, "access_api.%d", idx); - weston_config_section_get_string(section, wkbuf, &wrkstrp, NULL); - if (wrkstrp == NULL) { - if (idx <= 0) continue; - break; - } - p = wrkstrp; - for (i = 0; i < (ICO_UIFW_MAX_SUBJECT_NAME-1); i++, p++) { - if ((*p == 0) || (*p == ';')) break; - wkbuf[i] = *p; - } - if ((i <= 0) || (*p == 0)) { - uifw_error("ico_window_mgr: illegal config format[%s]", wrkstrp); - free(wrkstrp); - continue; - } - wkbuf[i] = 0; - accp = _ico_win_mgr->access_config; - while (accp) { - if (strcmp(wkbuf, accp->permit.subject) == 0) break; - accp = accp->next; - } - if (! accp) { - accp = (struct ico_api_permit *) malloc(sizeof(struct ico_api_permit)); - if (! accp) { - uifw_error("ico_window_mgr: malloc failed"); - continue; - } - same_accp = 0; - memset(accp, 0, sizeof(struct ico_api_permit)); - strcpy(accp->permit.subject, wkbuf); - } - else { - same_accp = 1; - } - - while (1) { - pp = p + 1; - for (p++; (*p != 0) && (*p != ','); p++) ; - if ((strcasecmp(pp, "all") == 0) || (strcmp(pp, "*") == 0)) { - accp->permit.api_permit = 0xffffffff; - break; - } - if (strncasecmp(pp, "ico_", 4) == 0) pp += 4; - if (strncasecmp(pp, "window_mgr_", 11) == 0) pp += 11; - if (strncasecmp(pp, "input_mgr_", 10) == 0) pp += 10; - if (strncasecmp(pp, "exinput_", 8) == 0) pp += 8; - for (i = 0; access_api_table[i].name[0]; i++) { - if (strncasecmp(pp, access_api_table[i].name, p - pp) == 0) { - accp->permit.api_permit |= access_api_table[i].api; - break; - } - } - if (*p == 0) break; - } - free(wrkstrp); - if (same_accp == 0) { - if (accp_next) { - accp_next->next = accp; - } - else { - _ico_win_mgr->access_config = accp; - } - accp_next = accp; - } - if (strcmp(accp->permit.subject, "*") == 0) { - _ico_win_mgr->default_access |= accp->permit.api_permit; - } - } - accp = _ico_win_mgr->access_config; - while (accp) { - accp->permit.api_permit |= _ico_win_mgr->default_access; - accp = accp->next; - } - } - else { - uifw_trace("ico_window_mgr: no access control in weston.ini"); - } - - _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8); - if (! _ico_win_mgr->surfaceid_map) { - uifw_error("ico_window_mgr: malloc failed"); - return -1; - } - memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8); - _ico_win_mgr->compositor = ec; - _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS; - _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS; - uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)"); if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1, _ico_win_mgr, bind_ico_win_mgr) == NULL) { @@ -5787,9 +2451,7 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) wl_list_init(&_ico_win_mgr->client_list); wl_list_init(&_ico_win_mgr->manager_list); - wl_list_init(&_ico_win_mgr->ivi_layer_list); wl_list_init(&_ico_win_mgr->map_list); - _ico_win_mgr->free_maptable = NULL; /* create display list */ @@ -5852,14 +2514,6 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) } if (displayno) free(displayno); - if (_ico_ivi_inputpanel_display >= _ico_num_nodes) { - _ico_ivi_inputpanel_display = 0; - } - uifw_info("ico_window_mgr: inputpanel_display=%d", _ico_ivi_inputpanel_display); - - /* set default display to ico_ivi_shell */ - ivi_shell_set_default_display(_ico_node_table[_ico_ivi_inputpanel_display].output); - /* my node Id ... this version fixed 0 */ nodeId = ico_ivi_get_mynode(); @@ -5874,66 +2528,25 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL); wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000); - /* Hook to IVI-Shell */ - ico_ivi_shell_hook_bind(win_mgr_bind_client); - ico_ivi_shell_hook_unbind(win_mgr_unbind_client); - ico_ivi_shell_hook_create(win_mgr_register_surface); - ico_ivi_shell_hook_destroy(win_mgr_destroy_surface); - ico_ivi_shell_hook_map(win_mgr_surface_map); - ico_ivi_shell_hook_configure(win_mgr_shell_configure); - ico_ivi_shell_hook_select(win_mgr_select_surface); - ico_ivi_shell_hook_title(win_mgr_set_title); - ico_ivi_shell_hook_move(win_mgr_surface_move); - ico_ivi_shell_hook_show_layer(win_mgr_show_layer); - ico_ivi_shell_hook_fullscreen(win_mgr_fullscreen); - - uifw_info("ico_window_mgr: animation name=%s/%s time=%d/%d fps=%d", - _ico_ivi_animation_name, _ico_ivi_inputpanel_animation, - _ico_ivi_animation_time, _ico_ivi_inputpanel_anima_time, - _ico_ivi_animation_fps); - uifw_info("ico_window_mgr: input panel mag=%d%% diff=%d", - _ico_ivi_inputdeco_mag,_ico_ivi_inputdeco_diff); - uifw_info("ico_window_mgr: layer default=%d background=%d", - _ico_ivi_default_layer, _ico_ivi_background_layer); - uifw_info("ico_window_mgr: layer touch=%d cursor=%d startup=%d", - _ico_ivi_touch_layer, _ico_ivi_cursor_layer, _ico_ivi_startup_layer); - uifw_info("ico_window_mgr: thumbnail framerate gpu_accel=%d shm_buff=%d no_accel=%d", - _ico_ivi_map_framerate_gpu, _ico_ivi_map_framerate_shm, - _ico_ivi_map_framerate_pixel); + uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d", + _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps); uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x", _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff, (_ico_ivi_debug_level >> 16) & 0x0ffff); - accp = _ico_win_mgr->access_config; - while (accp) { - uifw_info("ico_window_mgr: access_control %s=%08x", - accp->permit.subject, accp->permit.api_permit); - accp = accp->next; - } - /* get GPU type for H/W support of the thumbnail acquisition */ - if ((ico_ivi_optionflag() & ICO_IVI_OPTION_GPU_DEPEND) == 0) { - /* can not use GPU H/W dependent acceleration */ - _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION; - uifw_info("ico_window_mgr: GPU type=No Acceleration by option flag"); - } - else { - _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION; + /* touch/click binding for select surface */ + weston_compositor_add_button_binding(ec, BTN_LEFT, 0, win_mgr_click_to_activate, NULL); + weston_compositor_add_touch_binding(ec, 0, win_mgr_touch_to_activate, NULL); - p = (char *)glGetString(GL_RENDERER); - if (p) { - uifw_info("ico_window_mgr: Renderer=<%s>", p); - for (i = 0; ico_window_mgr_gpu_type[i].gpu_type; i++) { - if (strncmp(p, ico_window_mgr_gpu_type[i].gpu_name, - strlen(ico_window_mgr_gpu_type[i].gpu_name)) == 0) { - _ico_ivi_gpu_type = ico_window_mgr_gpu_type[i].gpu_type; - uifw_info("ico_window_mgr: GPU type=Acceleration %d", _ico_ivi_gpu_type); - break; - } - } - } - if (_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) { - uifw_info("ico_window_mgr: GPU type=No Acceleration(can not find GPU)"); - } + /* set Notification function for GENIVI ivi-shell */ + if (weston_layout_setNotificationCreateSurface(ico_ivi_surfaceCreateNotification, NULL) != 0) { + uifw_error("ico_window_mgr: weston_layout_setNotificationCreateSurface Error"); + } + if (weston_layout_setNotificationRemoveSurface(ico_ivi_surfaceRemoveNotification, NULL) != 0) { + uifw_error("ico_window_mgr: weston_layout_setNotificationRemoveSurface Error"); + } + if (weston_layout_setNotificationConfigureSurface(ico_ivi_surfaceConfigureNotification, NULL) != 0) { + uifw_error("ico_window_mgr: weston_layout_setNotificationConfigureSurface Error"); } uifw_info("ico_window_mgr: Leave(module_init)"); diff --git a/src/ico_window_mgr.h b/src/ico_window_mgr.h deleted file mode 100644 index 96b7e57..0000000 --- a/src/ico_window_mgr.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2010-2011 Intel Corporation - * Copyright © 2008-2011 Kristian Høgsberg - * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION. - * - * 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. - */ -/** - * @brief Public functions in ico_window_mgr Weston plugin - * - * @date Jul-26-2013 - */ - -#ifndef _ICO_WINDOW_MGR_H_ -#define _ICO_WINDOW_MGR_H_ - -/* API flag */ -#define ICO_UIFW_WINDOW_MGR_DECLARE_MANAGER (1 << 0) -#define ICO_UIFW_WINDOW_MGR_SET_WINDOW_LAYER (1 << 1) -#define ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE (1 << 2) -#define ICO_UIFW_WINDOW_MGR_SET_VISIBLE (1 << 3) -#define ICO_UIFW_WINDOW_MGR_SET_ANIMATION (1 << 4) -#define ICO_UIFW_WINDOW_MGR_SET_ATTRIBUTES (1 << 5) -#define ICO_UIFW_WINDOW_MGR_VISIBLE_ANIMATION (1 << 6) -#define ICO_UIFW_WINDOW_MGR_SET_ACTIVE (1 << 7) -#define ICO_UIFW_WINDOW_MGR_SET_LAYER_VISIBLE (1 << 8) -#define ICO_UIFW_WINDOW_MGR_GET_SURFACES (1 << 9) -#define ICO_UIFW_WINDOW_MGR_SET_MAP_BUFFER (1 << 10) -#define ICO_UIFW_WINDOW_MGR_MAP_SURFACE (1 << 11) -#define ICO_UIFW_WINDOW_MGR_UNMAP_SURFACE (1 << 12) - -#define ICO_UIFW_INPUT_MGR_CONTROL_ADD_INPUT_APP (1 << 16) -#define ICO_UIFW_INPUT_MGR_CONTROL_DEL_INPUT_APP (1 << 17) -#define ICO_UIFW_INPUT_MGR_CONTROL_SEND_INPUT_EVENT (1 << 18) -#define ICO_UIFW_EXINPUT_SET_INPUT_REGION (1 << 19) -#define ICO_UIFW_EXINPUT_UNSET_INPUT_REGION (1 << 20) -#define ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_INPUT (1 << 21) -#define ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_CODE (1 << 22) -#define ICO_UIFW_INPUT_MGR_DEVICE_INPUT_EVENT (1 << 23) - -/* surface image buffer in wl_shm_pool */ -struct ico_uifw_image_buffer { - uint32_t magich; /* Magic number, fixed "UIFH"(no NULL terminate)*/ - uint32_t surfaceid; /* surface id */ - uint32_t settime; /* buffer set time(set by weston) */ - uint32_t width; /* width */ - uint32_t height; /* height */ - uint32_t reftime; /* buffer refer time(set by app) */ - uint32_t res; /* (unused) */ - uint32_t magict; /* Magic number, fixed "UIFT"(no NULL terminate)*/ - unsigned char image[4]; /* surface image(variable length) */ -}; -#define ICO_UIFW_IMAGE_HEADER_SIZE ((int)sizeof(struct ico_uifw_image_buffer) - 4) - -#define ICO_UIFW_IMAGE_BUFFER_MAGICH "UIFH" -#define ICO_UIFW_IMAGE_BUFFER_MAGICT "UIFT" - -#endif /*_ICO_WINDOW_MGR_H_*/ diff --git a/src/ico_window_mgr_private.h b/src/ico_window_mgr_private.h index f390bcb..e5b994e 100644 --- a/src/ico_window_mgr_private.h +++ b/src/ico_window_mgr_private.h @@ -24,7 +24,7 @@ /** * @brief Public functions in ico_window_mgr Weston plugin * - * @date Jul-26-2013 + * @date Feb-21-2014 */ #ifndef _ICO_WINDOW_MGR_PRIVATE_H_ @@ -33,7 +33,6 @@ /* Manager management table */ struct uifw_manager { struct wl_resource *resource; /* Manager resource */ - int manager; /* Manager(=event send flag) */ struct wl_list link; /* link to next manager */ }; @@ -50,9 +49,9 @@ struct uifw_client { char *shmbuf; /* shared memory for surface image */ int bufsize; /* shared memory buffer size */ int bufnum; /* number of shared memory buffer */ + struct wl_listener destroy_listener; /* client destroy listener */ struct wl_list surface_link; /* surface list of same client */ struct wl_list link; /* client list */ - uint32_t api_access_control; /* api permission flags */ }; /* Node information */ @@ -66,23 +65,14 @@ struct uifw_node_table { int disp_height; /* display height */ }; -/* Layer management table */ -struct uifw_win_layer { - uint32_t layer; /* Layer Id */ - char visible; /* visibility */ - char layertype; /* layer type */ - char res[2]; /* (unused) */ - struct wl_list surface_list; /* Surface list */ - struct wl_list link; /* Link pointer for layer list */ -}; - /* Surface map table */ struct uifw_win_surface; struct uifw_surface_map { struct uifw_win_surface *usurf; /* UIFW surface */ struct uifw_client *uclient; /* UIFW client */ struct weston_buffer *curbuf; /* current buffer */ - uint32_t eglname; /* EGL buffer name */ + char filepath[ICO_IVI_FILEPATH_LENGTH]; + /* surface image file path */ uint32_t format; /* format */ uint16_t type; /* buffer type(currently only EGL buffer)*/ uint16_t width; /* width */ @@ -100,13 +90,12 @@ struct uifw_surface_map { /* UIFW surface */ struct shell_surface; +struct weston_layout_surface; struct uifw_win_surface { uint32_t surfaceid; /* UIFW SurfaceId */ struct uifw_node_table *node_tbl; /* Node manager of ico_window_mgr */ - struct uifw_win_layer *win_layer; /* surface layer */ - struct uifw_win_layer *old_layer; /* saved surface layer for change full screen*/ struct weston_surface *surface; /* Weston surface */ - struct shell_surface *shsurf; /* Shell(IVI-Shell) surface */ + struct weston_layout_surface *ivisurf; /* Weston layout surface */ struct uifw_client *uclient; /* Client */ struct weston_transform transform; /* transform matrix */ float scalex; /* surface transform scale of X */ @@ -130,9 +119,7 @@ struct uifw_win_surface { char mapped; /* end of map */ char restrain_configure; /* restrant configure event */ char set_transform; /* surface transform flag */ - char layertype; /* surface layer type */ - char old_layertype; /* surface old layer type */ - char res[3]; /* (unused) */ + char res[1]; /* (unused) */ struct _uifw_win_surface_animation { /* wndow animation */ struct weston_animation animation; /* weston animation control */ uint16_t type; /* current animation type */ @@ -161,7 +148,6 @@ struct uifw_win_surface { uint32_t starttime; /* start time(ms) */ void *animadata; /* animation data */ } animation; - struct wl_list ivi_layer; /* surface list of same layer */ struct wl_list client_link; /* surface list of same client */ struct wl_list surf_map; /* surface map list */ struct wl_list input_region; /* surface input region list */ @@ -169,13 +155,6 @@ struct uifw_win_surface { struct uifw_win_surface *next_wshash; /* Weston SurfaceId hash list */ }; -/* access control */ -#define ICO_UIFW_MAX_SUBJECT_NAME 64 -struct ico_uifw_api_permit { - char subject[ICO_UIFW_MAX_SUBJECT_NAME]; /* subject smack label */ - uint32_t api_permit; /* api permission flags */ -}; - /* animation operation */ /* default animation */ #define ICO_WINDOW_MGR_ANIMATION_NONE 0 /* no animation */ @@ -207,20 +186,21 @@ struct ico_uifw_api_permit { /* Prototype for function */ /* find uifw_client table */ struct uifw_client *ico_window_mgr_find_uclient(struct wl_client *client); - /* surface visible control */ -void ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible); /* get client applicationId */ char *ico_window_mgr_get_appid(struct wl_client* client); /* get display coordinate */ void ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y); + /* get buffer width */ +int ico_ivi_surface_buffer_width(struct weston_surface *es); + /* get buffer height */ +int ico_ivi_surface_buffer_height(struct weston_surface *es); + /* get buffer size */ +void ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height); + /* get surface primary view */ +struct weston_view *ico_ivi_get_primary_view(struct uifw_win_surface *usurf); /* change weston surface */ void ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, int x, int y, int width, int height); - /* surface change */ -void ico_window_mgr_change_surface(struct uifw_win_surface *usurf, - const int to, const int manager); - /* check active keyboard surface */ -int ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf); /* get UIFW client table */ struct uifw_client *ico_window_mgr_get_uclient(const char *appid); /* get UIFW surface table */ @@ -230,22 +210,6 @@ struct uifw_win_surface *ico_window_mgr_get_usurf_client(const uint32_t surfacei struct wl_client *client); /* get application surface */ struct uifw_win_surface *ico_window_mgr_get_client_usurf(const char *target); - /* rebuild surface layer list */ -void ico_window_mgr_restack_layer(struct uifw_win_surface *usurf); - /* touch layer control for input manager*/ -void ico_window_mgr_touch_layer(int omit); - /* chek surface visibility */ -int ico_window_mgr_is_visible(struct uifw_win_surface *usurf); - /* set active surface */ -void ico_window_mgr_active_surface(struct weston_surface *surface); - /* get buffer width */ -int ico_ivi_surface_buffer_width(struct weston_surface *es); - /* get buffer height */ -int ico_ivi_surface_buffer_height(struct weston_surface *es); - /* get buffer size */ -void ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height); - /* get surface primary view */ -struct weston_view *ico_ivi_get_primary_view(struct uifw_win_surface *usurf); /* set window animation hook */ void ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data)); /* set surface attribute change hook */ diff --git a/tests/Makefile.am b/tests/Makefile.am index a86332c..1a31595 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,6 +3,9 @@ TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/weston-plugin-test export abs_builddir EFL_INCLUDE = `pkg-config --cflags ecore-evas ecore evas ecore-wayland elementary` +GENIVI_INCLUDE = -I/usr/include/ilm -I/usr/include/layermanager +GENIVI_LIBS = -lilmCommon -lilmControl -lilmClient + AM_CFLAGS = $(GCC_CFLAGS) $(EFL_INCLUDE) AM_CPPFLAGS = -I$(top_srcdir)/src -DUNIT_TEST $(COMPOSITOR_CFLAGS) @@ -26,8 +29,8 @@ test_send_event_SOURCES = test-send_event.c $(test_common_src) test_send_event_LDADD = $(SIMPLE_CLIENT_LIBS) $(test_wayland_client) test_homescreen_SOURCES = test-homescreen.c $(test_common_src) test-thumbnail.c -test_homescreen_CFLAGS = $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) -test_homescreen_LDADD = $(SIMPLE_CLIENT_LIBS) $(test_protocol_lib) $(test_wayland_client) $(PLUGIN_LIBS) +test_homescreen_CFLAGS = $(GENIVI_INCLUDE) $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) +test_homescreen_LDADD = $(GENIVI_LIBS) $(SIMPLE_CLIENT_LIBS) $(test_protocol_lib) $(test_wayland_client) $(PLUGIN_LIBS) test_client_SOURCES = test-client.c $(test_common_src) test_client_LDADD = $(SIMPLE_CLIENT_LIBS) $(test_protocol_lib) $(test_wayland_client) diff --git a/tests/test-client.c b/tests/test-client.c index 6a383f8..5592be6 100644 --- a/tests/test-client.c +++ b/tests/test-client.c @@ -427,15 +427,19 @@ handle_global(void *data, struct wl_registry *registry, uint32_t id, display->shell = wl_registry_bind(display->registry, id, &wl_shell_interface, 1); } else if (strcmp(interface, "ico_window_mgr") == 0) { +#if 0 display->ico_window_mgr = wl_registry_bind(display->registry, id, &ico_window_mgr_interface, 1); print_log("CLIENT: created window_mgr global %p", display->ico_window_mgr); +#endif } else if (strcmp(interface, "ico_exinput") == 0) { +#if 0 display->ico_exinput = wl_registry_bind(display->registry, id, &ico_exinput_interface, 1); ico_exinput_add_listener(display->ico_exinput, &exinput_listener, display); print_log("CLIENT: created exinput global %p", display->ico_exinput); +#endif } } @@ -708,7 +712,10 @@ int main(int argc, char *argv[]) else { display->display = wl_display_connect(NULL); } - assert(display->display); + if (! display->display) { + fprintf(stderr, "CLIENT: can not connect to weston\n"); + exit(2); + } display->registry = wl_display_get_registry(display->display); wl_registry_add_listener(display->registry, diff --git a/tests/test-homescreen.c b/tests/test-homescreen.c index 458a5b9..b62f127 100644 --- a/tests/test-homescreen.c +++ b/tests/test-homescreen.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "ico_window_mgr-client-protocol.h" #include "ico_input_mgr-client-protocol.h" #include "ico_input_mgr.h" @@ -454,9 +455,9 @@ output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, display->init_height = height; if (display->bgsurface_name) { - ico_window_mgr_set_positionsize(display->ico_window_mgr, +/* ico_window_mgr_set_positionsize(display->ico_window_mgr, display->bgsurface_name->surfaceid, - 0, 0, 0, 0, width, height); + 0, 0, 0, 0, width, height); */ } else if (display->bg_created == 0) { display->bg_created = 9; @@ -484,13 +485,7 @@ search_surface(struct display *display, const char *surfname) if (p) { return p->surfaceid; } - else { - if ((strcasecmp(surfname, "all") == 0) || - (strcasecmp(surfname, "main") == 0)) { - return ICO_WINDOW_MGR_V_MAINSURFACE; - } - return -1; - } + return -1; } static struct surface_name * @@ -509,6 +504,7 @@ search_surfacename(struct display *display, const char *surfname) return p; } +#if 0 static struct surface_name * search_surfaceid(struct display *display, const int surfaceid) { @@ -523,7 +519,9 @@ search_surfaceid(struct display *display, const int surfaceid) } return NULL; } +#endif +#if 0 static void window_created(void *data, struct ico_window_mgr *ico_window_mgr, uint32_t surfaceid, const char *winname, int32_t pid, @@ -568,8 +566,8 @@ window_created(void *data, struct ico_window_mgr *ico_window_mgr, /* Set default size and show */ if (p->width > 0) { - ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, - 0, p->x, p->y, p->width, p->height, 0); +/* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, + 0, p->x, p->y, p->width, p->height, 0); */ } print_log("HOMESCREEN: Created window[%08x] (app=%s)", (int)surfaceid, appid); @@ -578,11 +576,11 @@ window_created(void *data, struct ico_window_mgr *ico_window_mgr, display->bgsurface_name = p; if (display->bg_created == 1) { display->bg_created = 9; - ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, +/* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, 0, 0, 0, - display->init_width, display->init_height, 0); + display->init_width, display->init_height, 0);*/ } - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, 1, 0, 0); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, 1, 0, 0); */ print_log("HOMESCREEN: Created window[%08x] (app=%s) Visible", (int)surfaceid, appid); p->visible = 1; @@ -645,8 +643,8 @@ window_visible(void *data, struct ico_window_mgr *ico_window_mgr, "visible=%d raise=%d hint=%d", (int)surfaceid, visible, raise, hint); p->visible = visible; if (hint == 1) { - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, - visible, ICO_WINDOW_MGR_V_NOCHANGE, 0); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, + visible, ICO_WINDOW_MGR_V_NOCHANGE, 0); */ } } } @@ -688,8 +686,8 @@ window_active(void *data, struct ico_window_mgr *ico_window_mgr, print_log("HOMESCREEN: Event[window_active] surface=%08x acive=%d", (int)surfaceid, (int)active); if ((surfaceid & 0x0000ffff) == 0x0001) { - ico_window_mgr_set_visible(ico_window_mgr, surfaceid, - ICO_WINDOW_MGR_V_NOCHANGE, 0, 0); +/* ico_window_mgr_set_visible(ico_window_mgr, surfaceid, + ICO_WINDOW_MGR_V_NOCHANGE, 0, 0); */ } } @@ -708,7 +706,7 @@ window_map(void *data, struct ico_window_mgr *ico_window_mgr, struct display *display = data; char sevt[16]; - switch (event) { +/* switch (event) { case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS: strcpy(sevt, "Contents"); break; case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE: @@ -721,18 +719,20 @@ window_map(void *data, struct ico_window_mgr *ico_window_mgr, sprintf(sevt, "Error %d", type); break; default: sprintf(sevt, "??%d??", event); break; - } + } */ print_log("HOMESCREEN: Event[map_surface] ev=%s(%d) surf=%08x type=%d target=%x " "w/h/s/f=%d/%d/%d/%x", sevt, event, (int)surfaceid, type, target, width, height, stride, format); - if ((event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP) || - (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS)) { +/* if ((event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP) || + (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS)) { */ opengl_thumbnail(display->display, surfaceid, display->surface->dpy, display->surface->conf, display->surface->egl_surface, display->surface->ctx, target, width, height, stride, format); - } +/* } */ } +#endif +/** static const struct ico_window_mgr_listener window_mgr_listener = { window_created, window_name, @@ -744,6 +744,7 @@ static const struct ico_window_mgr_listener window_mgr_listener = { window_surfaces, window_map }; +**/ static void cb_input_capabilities(void *data, struct ico_exinput *ico_exinput, @@ -870,10 +871,10 @@ handle_global(void *data, struct wl_registry *registry, uint32_t id, else if (strcmp(interface, "ico_window_mgr") == 0) { display->ico_window_mgr = wl_registry_bind(display->registry, id, &ico_window_mgr_interface, 1); - ico_window_mgr_add_listener(display->ico_window_mgr, &window_mgr_listener, display); +/* ico_window_mgr_add_listener(display->ico_window_mgr, &window_mgr_listener, display); */ print_log("HOMESCREEN: created window_mgr global %p", display->ico_window_mgr); - ico_window_mgr_declare_manager(display->ico_window_mgr, 1); +/* ico_window_mgr_declare_manager(display->ico_window_mgr, 1); */ } else if (strcmp(interface, "ico_input_mgr_control") == 0) { display->ico_input_mgr = wl_registry_bind(display->registry, id, @@ -893,7 +894,7 @@ handle_global(void *data, struct wl_registry *registry, uint32_t id, ico_exinput_add_listener(display->ico_exinput, &exinput_listener, display); print_log("HOMESCREEN: created exinput global %p", display->ico_exinput); - ico_window_mgr_declare_manager(display->ico_window_mgr, 1); +/* ico_window_mgr_declare_manager(display->ico_window_mgr, 1); */ display->bg_created = 1; create_surface(display, "HomeScreen-BG"); @@ -987,7 +988,7 @@ layer_surface(struct display *display, char *buf) if ((surfaceid >= 0) && (layerid >= 0)) { print_log("HOMESCREEN: set_window_layer(%s,%08x)", args[0], surfaceid, layerid); - ico_window_mgr_set_window_layer(display->ico_window_mgr, surfaceid, layerid); +/* ico_window_mgr_set_window_layer(display->ico_window_mgr, surfaceid, layerid); */ } else { print_log("HOMESCREEN: Unknown surface(%s) at layer command", args[0]); @@ -1006,7 +1007,7 @@ positionsize_surface(struct display *display, char *buf) int narg; int surfaceid; int x, y, width, height; - int anima = 0; +/* int anima = 0; */ int node = 0; narg = pars_command(buf, args, 10); @@ -1027,13 +1028,13 @@ positionsize_surface(struct display *display, char *buf) node = p->node; } if (narg >= 7) { - anima = strtol(args[6], (char **)0, 0); +/* anima = strtol(args[6], (char **)0, 0); */ } if ((surfaceid >= 0) && (x >= 0) && (y >=0) && (width >= 0) && (height >=0)) { print_log("HOMESCREEN: set_positionsize(%s,%08x,%d,%d,%d,%d,%d)", args[0], surfaceid, node, x, y, width, height); - ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, - node, x, y, width, height, anima); +/* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, + node, x, y, width, height, anima); */ } else { print_log("HOMESCREEN: Unknown surface(%s) at positionsize command", args[0]); @@ -1080,10 +1081,10 @@ move_surface(struct display *display, char *buf) if ((surfaceid >= 0) && (x >= 0) && (y >=0)) { print_log("HOMESCREEN: move(%s,%08x,%d.%d,%d anima=%d)", args[0], surfaceid, node, x, y, anima); - ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, +/* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, node, x, y, ICO_WINDOW_MGR_V_NOCHANGE, - ICO_WINDOW_MGR_V_NOCHANGE, anima); + ICO_WINDOW_MGR_V_NOCHANGE, anima); */ } else { print_log("HOMESCREEN: Unknown surface(%s) at move command", args[0]); @@ -1121,9 +1122,9 @@ resize_surface(struct display *display, char *buf) if ((surfaceid >= 0) && (width >= 0) && (height >=0)) { print_log("HOMESCREEN: resize(%s,%08x,%d.%d,%d,anima=%d)", args[0], surfaceid, node, width, height, anima); - ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, +/* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid, node, ICO_WINDOW_MGR_V_NOCHANGE, - ICO_WINDOW_MGR_V_NOCHANGE, width, height, anima); + ICO_WINDOW_MGR_V_NOCHANGE, width, height, anima); */ } else { print_log("HOMESCREEN: Unknown surface(%s) at resize command", args[0]); @@ -1156,8 +1157,8 @@ visible_surface(struct display *display, char *buf) if ((surfaceid >= 0) && (visible >= 0) && (raise >=0)) { print_log("HOMESCREEN: visible(%s,%08x,%d,%d,%d)", args[0], surfaceid, visible, raise, anima); - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, - visible, raise, anima); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, + visible, raise, anima); */ } else { print_log("HOMESCREEN: Unknown surface(%s) at visible command", args[0]); @@ -1202,28 +1203,28 @@ show_surface(struct display *display, char *buf, const int show) if (anima >= 2) { print_log("HOMESCREEN: show anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)", args[0], surfaceid, ax, ay, awidth, aheight); - ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid, - 1, ax, ay, awidth, aheight); +/* ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid, + 1, ax, ay, awidth, aheight); */ } else { print_log("HOMESCREEN: show(%s,%08x,anima=%d)", args[0], surfaceid, anima); - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, - 1, ICO_WINDOW_MGR_V_NOCHANGE, anima); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, + 1, ICO_WINDOW_MGR_V_NOCHANGE, anima); */ } } else { if (anima >= 2) { print_log("HOMESCREEN: hide anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)", args[0], surfaceid, ax, ay, awidth, aheight); - ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid, - 0, ax, ay, awidth, aheight); +/* ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid, + 0, ax, ay, awidth, aheight); */ } else { print_log("HOMESCREEN: hide(%s,%08x,anima=%d)", args[0], surfaceid, anima); - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, - 0, ICO_WINDOW_MGR_V_NOCHANGE, anima); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, + 0, ICO_WINDOW_MGR_V_NOCHANGE, anima); */ } } } @@ -1254,13 +1255,13 @@ raise_surface(struct display *display, char *buf, const int raise) if (surfaceid >= 0) { if (raise) { print_log("HOMESCREEN: raise(%s,%08x,anima=%d)", args[0], surfaceid, anima); - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, - ICO_WINDOW_MGR_V_NOCHANGE, 1, anima); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, + ICO_WINDOW_MGR_V_NOCHANGE, 1, anima); */ } else { print_log("HOMESCREEN: lower(%s,%08x,anima=%d)", args[0], surfaceid, anima); - ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, - ICO_WINDOW_MGR_V_NOCHANGE, 0, anima); +/* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, + ICO_WINDOW_MGR_V_NOCHANGE, 0, anima); */ } } else { @@ -1287,11 +1288,11 @@ active_window(struct display *display, char *buf) target = strtol(args[1], (char **)0, 0); } else { - target = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD; + target = 0; } if (surfaceid >= 0) { print_log("HOMESCREEN: active(%s,%08x,target=%x)", args[0], surfaceid, target); - ico_window_mgr_set_active(display->ico_window_mgr, surfaceid, target); +/* ico_window_mgr_set_active(display->ico_window_mgr, surfaceid, target); */ } else { print_log("HOMESCREEN: Unknown surface(%s) at active command", args[0]); @@ -1357,11 +1358,11 @@ map_surface(struct display *display, char *buf, int map) if (map) { print_log("HOMESCREEN: map surface(%s,%08x,%d)", args[0], surfaceid, fps); - ico_window_mgr_map_surface(display->ico_window_mgr, surfaceid, fps); +/* ico_window_mgr_map_surface(display->ico_window_mgr, surfaceid, fps); */ } else { print_log("HOMESCREEN: unmap surface(%s,%08x)", args[0], surfaceid); - ico_window_mgr_unmap_surface(display->ico_window_mgr, surfaceid); +/* ico_window_mgr_unmap_surface(display->ico_window_mgr, surfaceid); */ } } else { @@ -1386,14 +1387,14 @@ visible_layer(struct display *display, char *buf) { char *args[10]; int narg; - int layer; - int visible; +/* int layer; */ +/* int visible; */ narg = pars_command(buf, args, 10); if (narg >= 2) { - layer = strtol(args[0], (char **)0, 0); - visible = strtol(args[1], (char **)0, 0); - ico_window_mgr_set_layer_visible(display->ico_window_mgr, layer, visible); +/* layer = strtol(args[0], (char **)0, 0); */ +/* visible = strtol(args[1], (char **)0, 0); */ +/* ico_window_mgr_set_layer_visible(display->ico_window_mgr, layer, visible); */ } else { print_log("HOMESCREEN: layer_visible command" @@ -1464,98 +1465,6 @@ input_del(struct display *display, char *buf) } static void -input_send(struct display *display, char *buf) -{ - char *args[10]; - int narg; - int surfaceid; - int type; - int no; - int code; - int value; - char appid[64]; - - narg = pars_command(buf, args, 10); - if (narg >= 5) { - memset(appid, 0, sizeof(appid)); - if (args[0][0] == '@') { - strncpy(appid, &args[0][1], sizeof(appid)-1); - surfaceid = 0; - } - else { - surfaceid = search_surface(display, args[0]); - } - if (strcasecmp(args[1], "POINTER") == 0) { - type = ICO_INPUT_MGR_DEVICE_TYPE_POINTER; - } - else if (strcasecmp(args[1], "KEYBOARD") == 0) { - type = ICO_INPUT_MGR_DEVICE_TYPE_KEYBOARD; - } - else if (strcasecmp(args[1], "TOUCH") == 0) { - type = ICO_INPUT_MGR_DEVICE_TYPE_TOUCH; - } - else if (strcasecmp(args[1], "SWITCH") == 0) { - type = ICO_INPUT_MGR_DEVICE_TYPE_SWITCH; - } - else if (strcasecmp(args[1], "HAPTIC") == 0) { - type = ICO_INPUT_MGR_DEVICE_TYPE_HAPTIC; - } - else { - type = strtol(args[1], (char **)0, 0); - } - no = strtol(args[2], (char **)0, 0); - if (strcasecmp(args[3], "ABS_X") == 0) { - code = ABS_X; - } - else if (strcasecmp(args[3], "ABS_Y") == 0) { - code = ABS_Y; - } - else if (strcasecmp(args[3], "ABS_Z") == 0) { - code = ABS_Z; - } - else if (strcasecmp(args[3], "REL_X") == 0) { - code = REL_X | (EV_REL << 16); - } - else if (strcasecmp(args[3], "REL_Y") == 0) { - code = REL_Y | (EV_REL << 16); - } - else if (strcasecmp(args[3], "REL_Z") == 0) { - code = REL_Z | (EV_REL << 16); - } - else if (strcasecmp(args[3], "BTN_TOUCH") == 0) { - code = BTN_TOUCH; - } - else if (strcasecmp(args[3], "BTN_LEFT") == 0) { - code = BTN_LEFT; - } - else if (strcasecmp(args[3], "BTN_RIGHT") == 0) { - code = BTN_RIGHT; - } - else if (strcasecmp(args[3], "BTN_MIDDLE") == 0) { - code = BTN_MIDDLE; - } - else if (strcasecmp(args[3], "BTN_RIGHT") == 0) { - code = BTN_RIGHT; - } - else { - code = strtol(args[3], (char **)0, 0); - } - value = strtol(args[4], (char **)0, 0); - if (narg >= 6) { - value = (value << 16) + strtol(args[5], (char **)0, 0); - } - print_log("HOMESCREEN: input_send(%s.%x,%d,%d,%x,%d)", - appid, surfaceid, type, no, code, value); - ico_input_mgr_control_send_input_event(display->ico_input_mgr, - appid, surfaceid, type, no, 0, code, value); - } - else { - print_log("HOMESCREEN: input_send command[input_send {@app/serface} type no code " - "value [value2]] has no argument"); - } -} - -static void input_conf(struct display *display, char *buf) { char *args[10]; @@ -1821,6 +1730,11 @@ int main(int argc, char *argv[]) long flags; #endif /* use mkostemp */ + if (ilm_init() != ILM_SUCCESS) { + fprintf(stderr, "HOMESCREEN: GENIVI-ILM(ilm_init) Error\n"); + exit(1); + } + display = malloc(sizeof *display); assert(display); memset((char *)display, 0, sizeof *display); @@ -1849,7 +1763,10 @@ int main(int argc, char *argv[]) else { display->display = wl_display_connect(NULL); } - assert(display->display); + if (! display->display) { + fprintf(stderr, "HOMESCREEN: can not connect to weston\n"); + exit(2); + } display->registry = wl_display_get_registry(display->display); wl_registry_add_listener(display->registry, ®istry_listener, display); @@ -1948,10 +1865,6 @@ int main(int argc, char *argv[]) /* Reset input switch to application*/ input_del(display, &buf[9]); } - else if (strncasecmp(buf, "input_send", 10) == 0) { - /* Input event send to application*/ - input_send(display, &buf[10]); - } else if (strncasecmp(buf, "input_conf", 10) == 0) { /* input switch configuration */ input_conf(display, &buf[10]); @@ -2000,6 +1913,7 @@ int main(int argc, char *argv[]) return -1; } } + (void) ilm_destroy(); print_log("HOMESCREEN: end"); diff --git a/tests/testdata/hs_sendinput.dat b/tests/testdata/hs_sendinput.dat deleted file mode 100644 index 6662065..0000000 --- a/tests/testdata/hs_sendinput.dat +++ /dev/null @@ -1,228 +0,0 @@ -# Test for Weston IVI Plugin for HomeScreen(SystemController) -# send input event Test -# -# 1. trigger clients -# -launch ../tests/test-client < ../tests/testdata/cl_surface4.dat 2> ../tests/testlog/test-client.log 1>&2 -waitcreate 2 -move test-client 100 200 -show test-client -sleep 1 -# -launch ../tests/test-eflapp @1 -color=0xe02040ff 2> ../tests/testlog/test-eflapp.log 1>&2 -waitcreate 2 -move test-eflapp@1 650 80 -show test-eflapp@1 -# -# 11. send pointer event to general pointer motion(general event) -# -sleep 1 -input_send @ pointer 0 ABS_Z 80 160 -sleep 0.1 -input_send @ pointer 0 ABS_X 270 -input_send @ pointer 0 ABS_Y 440 -sleep 0.1 -input_send @ pointer 0 BTN_LEFT 1 -sleep 0.2 -input_send @ pointer 0 BTN_LEFT 0 -sleep 0.5 -input_send @ pointer 0 ABS_X 272 -input_send @ pointer 0 ABS_Y 438 -sleep 0.1 -input_send @ pointer 0 BTN_LEFT 1 -sleep 0.1 -input_send @ pointer 0 ABS_X 271 -input_send @ pointer 0 ABS_Y 439 -sleep 0.1 -input_send @ pointer 0 BTN_LEFT 0 -sleep 1 -# -# 12. send keyboard event(general event) -# -active test-client -input_send @ keyboard 0 1 1 -input_send @ keyboard 0 1 0 -sleep 0.2 -active test-eflapp@1 -input_send @ keyboard 0 2 1 -sleep 0.1 -input_send @ keyboard 0 2 0 -sleep 1 -# -# 13. send touch event(general event) -# -active test-client -input_send @ touch 0 ABS_Z 250 450 -input_send @ touch 0 BTN_TOUCH 1 -sleep 0.1 -input_send @ touch 0 ABS_Z 255 455 -sleep 0.2 -input_send @ touch 0 BTN_TOUCH 0 -sleep 1 -# -# 14. switch event(general event) -# -active test-client -input_send @ switch 0 11 1 -input_send @ switch 0 11 0 -sleep 0.1 -active test-eflapp@1 -input_send @ switch 0 12 1 -sleep 0.1 -input_send @ switch 0 12 0 -sleep 1 -# -# 15. haptic event(general event) -# -active test-client -input_send @ haptic 0 ABS_Z 260 460 -sleep 0.1 -input_send @ haptic 0 ABS_Z 262 462 -sleep 0.1 -input_send @ haptic 0 BTN_LEFT 1 -sleep 0.1 -input_send @ haptic 0 BTN_LEFT 0 -sleep 1 -# -# 21. send pointer event to general pointer motion(appid) -# -sleep 1 -active test-eflapp@1 -input_send @test-client pointer 0 ABS_Z 80 160 -sleep 0.1 -input_send @test-client pointer 0 ABS_X 270 -input_send @test-client pointer 0 ABS_Y 440 -sleep 0.1 -input_send @test-client pointer 0 BTN_LEFT 1 -sleep 0.2 -input_send @test-client pointer 0 BTN_LEFT 0 -sleep 0.5 -input_send @test-client pointer 0 ABS_X 272 -input_send @test-client pointer 0 ABS_Y 438 -sleep 0.1 -input_send @test-client pointer 0 BTN_LEFT 1 -sleep 0.1 -input_send @test-client pointer 0 ABS_X 271 -input_send @test-client pointer 0 ABS_Y 439 -sleep 0.1 -input_send @test-client pointer 0 BTN_LEFT 0 -sleep 1 -# -# 22. send keyboard event(appid) -# -active test-eflapp@1 -input_send @test-client keyboard 0 1 1 -input_send @test-client keyboard 0 1 0 -sleep 0.2 -active test-client -input_send @test-client keyboard 0 2 1 -sleep 0.1 -input_send @test-client@test-client keyboard 0 2 0 -sleep 1 -# -# 23. send touch event(appid) -# -input_send @test-client touch 0 ABS_Z 250 450 -input_send @test-client touch 0 BTN_TOUCH 1 -sleep 0.1 -input_send @test-client touch 0 ABS_Z 255 455 -sleep 0.2 -input_send @test-client touch 0 BTN_TOUCH 0 -sleep 1 -# -# 24. switch event(appid) -# -input_send @test-client switch 0 11 1 -input_send @test-client switch 0 11 0 -sleep 0.1 -input_send @test-client switch 0 12 1 -sleep 0.1 -input_send @test-client switch 0 12 0 -sleep 1 -# -# 25. haptic event(appid) -# -input_send @test-client haptic 0 ABS_Z 260 460 -sleep 0.1 -input_send @test-client haptic 0 ABS_Z 262 462 -sleep 0.1 -input_send @test-client haptic 0 BTN_LEFT 1 -sleep 0.1 -input_send @test-client haptic 0 BTN_LEFT 0 -sleep 1 -# -# 31. send pointer event to general pointer motion(surface id) -# -sleep 1 -input_send test-client pointer 0 ABS_Z 80 160 -sleep 0.1 -input_send test-client pointer 0 ABS_X 270 -input_send test-client pointer 0 ABS_Y 440 -sleep 0.1 -input_send test-client pointer 0 BTN_LEFT 1 -sleep 0.2 -input_send test-client pointer 0 BTN_LEFT 0 -sleep 0.5 -input_send test-client pointer 0 ABS_X 272 -input_send test-client pointer 0 ABS_Y 438 -sleep 0.1 -input_send test-client pointer 0 BTN_LEFT 1 -sleep 0.1 -input_send test-client pointer 0 ABS_X 271 -input_send test-client pointer 0 ABS_Y 439 -sleep 0.1 -input_send test-client pointer 0 BTN_LEFT 0 -sleep 1 -# -# 32. send keyboard event(surface id) -# -active test-client -input_send test-client keyboard 0 1 1 -input_send test-client keyboard 0 1 0 -sleep 0.2 -active test-eflapp@1 -input_send test-client keyboard 0 2 1 -sleep 0.1 -input_send test-client keyboard 0 2 0 -sleep 1 -# -# 33. send touch event(surface id) -# -input_send test-client touch 0 ABS_Z 250 450 -input_send test-client touch 0 BTN_TOUCH 1 -sleep 0.1 -input_send test-client touch 0 ABS_Z 255 455 -sleep 0.2 -input_send test-client touch 0 BTN_TOUCH 0 -sleep 1 -# -# 34. switch event(surface id) -# -input_send test-client switch 0 11 1 -input_send test-client switch 0 11 0 -sleep 0.1 -input_send test-client switch 0 12 1 -sleep 0.1 -input_send test-client switch 0 12 0 -sleep 1 -# -# 35. haptic event(surface id) -# -input_send test-client haptic 0 ABS_Z 260 460 -sleep 0.1 -input_send test-client haptic 0 ABS_Z 262 462 -sleep 0.1 -input_send test-client haptic 0 BTN_LEFT 1 -sleep 0.1 -input_send test-client haptic 0 BTN_LEFT 0 -sleep 1 -# -sleep 20 -# -kill test-client -kill test-eflapp@1 -sleep 1 -# -# 99. End of Test -bye - diff --git a/tests/weston-homescreen-only b/tests/weston-homescreen-only new file mode 100755 index 0000000..fa9e2ab --- /dev/null +++ b/tests/weston-homescreen-only @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Weston IVI Plugin Test +# +# Remark: This examination premises that Weston does not run. + +# 1 Delete log file +mkdir ../tests/testlog 2> /dev/null +rm -fr ../tests/testlog/* 2> /dev/null + +# 2 Set Environment for Test +export WESTON_IVI_PLUGIN_DIR="../src/.libs" + +# 4 Start Weston +export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" +MOD_DIR="$PWD/../src/.libs" +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +sleep 1 + +# 5 Set library path +export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH + +# 6 Start test-homescreen +../tests/test-homescreen 2> ../tests/testlog/test-homescreen.log 1>&2 + diff --git a/tests/weston-only b/tests/weston-only new file mode 100755 index 0000000..f3df11c --- /dev/null +++ b/tests/weston-only @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Weston IVI Plugin Test +# +# Remark: This examination premises that Weston does not run. + +# 1 Delete log file +mkdir ../tests/testlog 2> /dev/null +rm -fr ../tests/testlog/* 2> /dev/null + +# 2 Set Environment for Test +export WESTON_IVI_PLUGIN_DIR="../src/.libs" + +# 3 Start Weston +export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" +MOD_DIR="$PWD/../src/.libs" +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +sleep 1 + diff --git a/tests/weston.ini b/tests/weston.ini index 4eb81ba..9efba02 100644 --- a/tests/weston.ini +++ b/tests/weston.ini @@ -5,7 +5,7 @@ modules=error_but_no_problem_for_test.so [shell] num-workspaces=1 -client= +shell-exe= locking=false animation=zoom startup-animation=fade @@ -31,47 +31,23 @@ path= #transform=90 [ivi-plugin] -modules=ico_ivi_shell.so,ico_window_mgr.so,ico_window_animation.so,ico_input_mgr.so +modules=/usr/lib/weston/ivi-shell.so,ico_window_mgr.so,ico_window_animation.so,ico_input_mgr.so [ivi-display] # logical display number list displayno=1,0 -# default input panel display -inputpanel=0 - -[ivi-layer] -# background layer id -background=0 -# default(panel) layer id -default=1 -# touch panel layer id -touch=101 -# cursor layer id -cursor=102 -# layer id at the time of the system startup -startup=103 -# input panel layer decoration (magnification rate(%);difference from the bottom) -inputpaneldeco=120;132 [ivi-animation] -# default animation name;time;rate(frame/sec) -default=fade;500;30 -# input panel surface animation(name;time) -inputpanel=fade;200 - -[ivi-thumbnail] -gpu_accel_fps=10 -shm_buffer_fps=2 -no_accel_fps=5 +# default animation name +default=fade +# default animation time(ms) +time=500 +# default animation frame rate(frame/sec) +fps=15 [ivi-option] -# option flags -# 0x0001 1=show surface at screen create if HomeScreen exist/0=not show surface at create -# 0x0002 1=1=show if display not exist/0=not show if display not exist -# 0x0004 1=show input panel automatically/0=not show automaticaly -# 0x0080 1=surface fixed aspect rate/0=not fixed aspect rate -# 0x8000 1=Acceleration depending on GPU(intel GPU only) -flag=0x0004 +# option flags (but not used) +flag=0x0000 # debug log output level and debug flag # lower 16 bit: log level(0=no/1=err/2=warn/3=info/4=trace/5=debug)