From 47fec8f53960c644dd06d71b2e44b384a25022c2 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Fri, 12 May 2023 10:42:58 +0900 Subject: [PATCH] [NUI.WindowSystem] introduce the taskbar service feature Signed-off-by: Doyoun Kang --- .../src/internal/Interop/Interop.TaskbarService.cs | 26 ++++ .../src/public/TaskbarService.cs | 166 +++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100755 src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.TaskbarService.cs create mode 100755 src/Tizen.NUI.WindowSystem/src/public/TaskbarService.cs diff --git a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.TaskbarService.cs b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.TaskbarService.cs new file mode 100755 index 0000000..139edbe --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.TaskbarService.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.NUI.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class TaskbarService + { + const string lib = "libtzsh_taskbar_service.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_create")] + internal static extern IntPtr Create(IntPtr tzsh, IntPtr win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_destroy")] + internal static extern int Destroy(IntPtr taskbarService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_place_type_set")] + internal static extern int SetPlaceType(IntPtr taskbarService, int placeType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_size_set")] + internal static extern int SetSize(IntPtr taskbarService, uint width, uint height); + } + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/public/TaskbarService.cs b/src/Tizen.NUI.WindowSystem/src/public/TaskbarService.cs new file mode 100755 index 0000000..50d0eef --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/public/TaskbarService.cs @@ -0,0 +1,166 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.WindowSystem.Shell +{ + /// + /// Class for the Tizen taskbar service. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class TaskbarService : IDisposable + { + private TizenShell _tzsh; + private IntPtr _taskbarService; + private int _tzshWin; + private bool disposed = false; + private bool isDisposeQueued = false; + + /// + /// Enumeration for placed type of taskbar service window. + /// + public enum PlaceType + { + /// + /// Place to Bottom of Screen. Default type. + /// + Bottom = 0x0, + /// + /// Place to Top of Screen. + /// + Top = 0x1, + /// + /// Place to Left Side of Screen. + /// + Left = 0x2, + /// + /// Place to Right Side of Screen. + /// + Right = 0x3, + } + + /// + /// Creates a new Taskbar Service handle. + /// + /// The TizenShell instance. + /// The window to provide service of the taskbar. + /// The type to be placed on the screen. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public TaskbarService(TizenShell tzShell, Window win, PlaceType type = PlaceType.Bottom) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = win.GetNativeId(); + _taskbarService = Interop.TaskbarService.Create(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin); + if (_taskbarService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + + Interop.TaskbarService.SetPlaceType(_taskbarService, (int)type); + } + + /// + /// Destructor. + /// + ~TaskbarService() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + if (isDisposeQueued) + { + Dispose(DisposeTypes.Implicit); + } + else + { + Dispose(DisposeTypes.Explicit); + GC.SuppressFinalize(this); + } + } + + /// + protected virtual void Dispose(DisposeTypes type) + { + if (!disposed) + { + if (_taskbarService != IntPtr.Zero) + { + int res = Interop.TaskbarService.Destroy(_taskbarService); + _taskbarService = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Set the current place type. + /// The window manager can use this to determine the geometry of another applications. + /// + /// The type of placement, enumeration for the place type. + /// Thrown when failed of invalid argument. + public void SetPlaceType(PlaceType type) + { + int res; + + res = Interop.TaskbarService.SetPlaceType(_taskbarService, (int)type); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Set the size of the taskbar. + /// This may be different from the actual size. The window manager can use this to + /// determine the geometry of another applications. + /// + /// The width of the taskbar area. + /// The height of the taskbar area. + /// Thrown when failed of invalid argument. + public void SetSize(uint width, uint height) + { + int res; + + res = Interop.TaskbarService.SetSize(_taskbarService, width, height); + _tzsh.ErrorCodeThrow(res); + } + } +} -- 2.7.4