diff --git a/src/Tizen.WindowSystem/Tizen.WindowSystem.csproj b/src/Tizen.WindowSystem/Tizen.WindowSystem.csproj new file mode 100644 index 00000000000..b5599cfed92 --- /dev/null +++ b/src/Tizen.WindowSystem/Tizen.WindowSystem.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + false + + + + + + + + diff --git a/src/Tizen.WindowSystem/src/Enums/DropTarget.cs b/src/Tizen.WindowSystem/src/Enums/DropTarget.cs new file mode 100644 index 00000000000..e00e192fd27 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/DropTarget.cs @@ -0,0 +1,20 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Drop target type of PerformDrop request of KVM Service. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum DropTarget + { + /// + /// Drop to KVM Service window self. + /// + KVMServiceWin = 0, + /// + /// Drop to the window that under pointer. + /// + UnderPointer = 1, + }; +} diff --git a/src/Tizen.WindowSystem/src/Enums/GestureEdge.cs b/src/Tizen.WindowSystem/src/Enums/GestureEdge.cs new file mode 100644 index 00000000000..9d830dadb49 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/GestureEdge.cs @@ -0,0 +1,32 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of gesture edges. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureEdge + { + /// + /// edge top. + /// + Top, + + /// + /// edge right. + /// + Right, + + /// + /// edge bottom. + /// + Bottom, + + /// + /// edge left. + /// + Left, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/GestureEdgeSize.cs b/src/Tizen.WindowSystem/src/Enums/GestureEdgeSize.cs new file mode 100644 index 00000000000..e51daf5ca2f --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/GestureEdgeSize.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of gesture edge sizes. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureEdgeSize + { + /// + /// edge size full. + /// + Full, + + /// + /// edge size partial. + /// + Partial, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/GestureGrabMode.cs b/src/Tizen.WindowSystem/src/Enums/GestureGrabMode.cs new file mode 100644 index 00000000000..4dbb83ceafe --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/GestureGrabMode.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of gesture grab modes. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureGrabMode + { + /// + /// mode exclusive. + /// + Exclusive, + + /// + /// mode shared. + /// + Shared, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/GestureState.cs b/src/Tizen.WindowSystem/src/Enums/GestureState.cs new file mode 100644 index 00000000000..94867f9c84e --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/GestureState.cs @@ -0,0 +1,32 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of gesture states. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureState + { + /// + /// Begin. + /// + Begin, + + /// + /// Update. + /// + Update, + + /// + /// End. + /// + End, + + /// + /// Done. + /// + Done, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/InputGeneratorDevices.cs b/src/Tizen.WindowSystem/src/Enums/InputGeneratorDevices.cs new file mode 100644 index 00000000000..dedf2d5eea2 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/InputGeneratorDevices.cs @@ -0,0 +1,33 @@ +using System; +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of input device types. + /// + [Flags] + [EditorBrowsable(EditorBrowsableState.Never)] + public enum InputGeneratorDevices + { + /// + /// Touchscreen device. + /// + Touchscreen = (1 << 0), + + /// + /// Keyboard device. + /// + Keyboard = (1 << 1), + + /// + /// Pointer device. + /// + Pointer = (1 << 2), + + /// + /// All devices. + /// + All = Touchscreen | Keyboard | Pointer + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/PointerAction.cs b/src/Tizen.WindowSystem/src/Enums/PointerAction.cs new file mode 100644 index 00000000000..2da8fc4c479 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/PointerAction.cs @@ -0,0 +1,26 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of pointer event types. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum PointerAction + { + /// + /// Pointer down. + /// + Down, + + /// + /// Pointer up. + /// + Up, + + /// + /// Pointer move. + /// + Move, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/QuickPanelCategory.cs b/src/Tizen.WindowSystem/src/Enums/QuickPanelCategory.cs new file mode 100644 index 00000000000..cc9ac87461a --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/QuickPanelCategory.cs @@ -0,0 +1,29 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Enumeration for type of quickpanel service window. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public enum QuickPanelCategory + { + /// + /// Unknown type. There is no quickpanel service. + /// + Unknown = 0x0, + /// + /// System default type. + /// + SystemDefault = 0x1, + /// + /// Context menu type. + /// + ContextMenu = 0x2, + /// + /// Apps menu type. + /// + AppsMenu = 0x3, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/QuickPanelEffect.cs b/src/Tizen.WindowSystem/src/Enums/QuickPanelEffect.cs new file mode 100644 index 00000000000..ff40892f89c --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/QuickPanelEffect.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Effect type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum QuickPanelEffect + { + /// + /// Swipe effect + /// + Swipe = 0, + /// + /// Move effect + /// + Move = 1, + /// + /// App control effect + /// + Custom = 2, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/QuickPanelScrollMode.cs b/src/Tizen.WindowSystem/src/Enums/QuickPanelScrollMode.cs new file mode 100644 index 00000000000..b162235ab39 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/QuickPanelScrollMode.cs @@ -0,0 +1,33 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Enumeration for scroll mode of quickpanel service window. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public enum QuickPanelScrollMode + { + /// + /// Unknown state. There is no quickpanel service. + /// + /// 8 + Unknown = 0x0, + /// + /// Scrollable state. + /// + /// 8 + Scrollable = 0x1, + /// + /// Not scrollable state. + /// + /// 8 + NotScrollable = 0x2, + /// + /// Retain scroll mode. + /// + /// 8 + Retain = 0x3, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/QuickPanelVisibility.cs b/src/Tizen.WindowSystem/src/Enums/QuickPanelVisibility.cs new file mode 100644 index 00000000000..3a39e903222 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/QuickPanelVisibility.cs @@ -0,0 +1,28 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Enumeration for visible state of quickpanel service window. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public enum QuickPanelVisibility + { + /// + /// Unknown state. There is no quickpanel service. + /// + /// 8 + Unknown = 0x0, + /// + /// Shown state. + /// + /// 8 + Shown = 0x1, + /// + /// Hidden state. + /// + /// 8 + Hidden = 0x2, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/TaskbarPosition.cs b/src/Tizen.WindowSystem/src/Enums/TaskbarPosition.cs new file mode 100644 index 00000000000..09ce2f5e205 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/TaskbarPosition.cs @@ -0,0 +1,28 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Enumeration for placed type of taskbar service window. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum TaskbarPosition + { + /// + /// 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, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/TouchAction.cs b/src/Tizen.WindowSystem/src/Enums/TouchAction.cs new file mode 100644 index 00000000000..ed54545fcc1 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/TouchAction.cs @@ -0,0 +1,26 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of touch event types. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum TouchAction + { + /// + /// Touch begin. + /// + Begin, + + /// + /// Touch move. + /// + Update, + + /// + /// Touch end. + /// + End, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/WheelDirection.cs b/src/Tizen.WindowSystem/src/Enums/WheelDirection.cs new file mode 100644 index 00000000000..4df7236f20b --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/WheelDirection.cs @@ -0,0 +1,21 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of pointer wheel event types. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum WheelDirection + { + /// + /// Vertical wheel. + /// + Vertical, + + /// + /// Horizontal wheel. + /// + Horizontal, + } +} diff --git a/src/Tizen.WindowSystem/src/Enums/WindowOrientation.cs b/src/Tizen.WindowSystem/src/Enums/WindowOrientation.cs new file mode 100644 index 00000000000..80339c64f79 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Enums/WindowOrientation.cs @@ -0,0 +1,28 @@ +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Orientation of the window. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum WindowOrientation + { + /// + /// Portrait orientation. + /// + Portrait = 0, + /// + /// Landscape orientation. + /// + Landscape = 90, + /// + /// Inverse portrait orientation. + /// + PortraitInverse = 180, + /// + /// Inverse landscape orientation. + /// + LandscapeInverse = 270, + } +} diff --git a/src/Tizen.WindowSystem/src/ErrorUtils.cs b/src/Tizen.WindowSystem/src/ErrorUtils.cs new file mode 100644 index 00000000000..efa0443850d --- /dev/null +++ b/src/Tizen.WindowSystem/src/ErrorUtils.cs @@ -0,0 +1,67 @@ +/* + * Copyright(c) 2020 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 Tizen.Applications.Exceptions; + +namespace Tizen.WindowSystem +{ + internal static class ErrorUtils + { + private const int ErrorTzsh = -0x02860000; + private const int NoServiceError = ErrorTzsh | 0x01; + + internal static void ThrowIfError(int error, string message = null) + { + if (error == (int)Tizen.Internals.Errors.ErrorCode.None) + { + return; + } + + string msg = message ?? "Unknown Error"; + + if (error == (int)Tizen.Internals.Errors.ErrorCode.OutOfMemory) + { + throw new Tizen.Applications.Exceptions.OutOfMemoryException("Out of Memory"); + } + else if (error == (int)Tizen.Internals.Errors.ErrorCode.InvalidParameter) + { + throw new ArgumentException("Invalid Parameter"); + } + else if (error == (int)Tizen.Internals.Errors.ErrorCode.PermissionDenied) + { + throw new PermissionDeniedException("Permission denied"); + } + else if (error == (int)Tizen.Internals.Errors.ErrorCode.NotSupported) + { + throw new NotSupportedException("Not Supported"); + } + else if (error == (int)Tizen.Internals.Errors.ErrorCode.InvalidOperation) + { + throw new InvalidOperationException("Invalid Operation"); + } + else if (error == NoServiceError) + { + throw new InvalidOperationException("No Service"); + } + else + { + throw new InvalidOperationException(msg); + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/Events/EdgeGestureEventArgs.cs b/src/Tizen.WindowSystem/src/Events/EdgeGestureEventArgs.cs new file mode 100644 index 00000000000..9c2d4df8ec0 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Events/EdgeGestureEventArgs.cs @@ -0,0 +1,59 @@ +/* + * Copyright(c) 2024 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.WindowSystem +{ + /// + /// This class contains the data related to edge gesture events (EdgeSwipe and EdgeDrag). + /// For EdgeSwipe, X/Y represent the start position. For EdgeDrag, X/Y represent the current position. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class EdgeGestureEventArgs : EventArgs + { + internal EdgeGestureEventArgs(GestureState state, int fingers, int x, int y, GestureEdge edge) + { + State = state; + Fingers = fingers; + X = x; + Y = y; + Edge = edge; + } + /// + /// State of the gesture. + /// + public GestureState State { get; internal set; } + /// + /// Number of fingers. + /// + public int Fingers { get; internal set; } + /// + /// X coordinate. Start position for EdgeSwipe, current position for EdgeDrag. + /// + public int X { get; internal set; } + /// + /// Y coordinate. Start position for EdgeSwipe, current position for EdgeDrag. + /// + public int Y { get; internal set; } + /// + /// Edge position. + /// + public GestureEdge Edge { get; internal set; } + } +} diff --git a/src/Tizen.WindowSystem/src/Events/PalmCoverEventArgs.cs b/src/Tizen.WindowSystem/src/Events/PalmCoverEventArgs.cs new file mode 100644 index 00000000000..746911bf46e --- /dev/null +++ b/src/Tizen.WindowSystem/src/Events/PalmCoverEventArgs.cs @@ -0,0 +1,63 @@ +/* + * Copyright(c) 2024 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.WindowSystem +{ + /// + /// This class contains the data related to the PalmCover event. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class PalmCoverEventArgs : EventArgs + { + internal PalmCoverEventArgs(GestureState state, int duration, int centerX, int centerY, int size, double pressure) + { + State = state; + Duration = duration; + CenterX = centerX; + CenterY = centerY; + Size = size; + Pressure = pressure; + } + /// + /// State + /// + public GestureState State { get; internal set; } + /// + /// Duration + /// + public int Duration{ get; internal set;} + /// + /// Center X + /// + public int CenterX{ get; internal set;} + /// + /// Center Y + /// + public int CenterY{ get; internal set;} + /// + /// Size + /// + public double Size{ get; internal set;} + /// + /// Pressure + /// + public double Pressure{ get; internal set;} + } +} diff --git a/src/Tizen.WindowSystem/src/Events/SoftkeyServiceEventArgs.cs b/src/Tizen.WindowSystem/src/Events/SoftkeyServiceEventArgs.cs new file mode 100644 index 00000000000..ba81a8c4a73 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Events/SoftkeyServiceEventArgs.cs @@ -0,0 +1,56 @@ +using System; +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Provides data for the event. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyVisibleChangedEventArgs : EventArgs + { + internal SoftkeyVisibleChangedEventArgs(bool isVisible) + { + IsVisible = isVisible; + } + + /// + /// Gets whether the softkey is visible. + /// + public bool IsVisible { get; } + } + + /// + /// Provides data for the event. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyExpandChangedEventArgs : EventArgs + { + internal SoftkeyExpandChangedEventArgs(bool isExpandable) + { + IsExpandable = isExpandable; + } + + /// + /// Gets whether the softkey is expandable. + /// + public bool IsExpandable { get; } + } + + /// + /// Provides data for the event. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyOpacityChangedEventArgs : EventArgs + { + internal SoftkeyOpacityChangedEventArgs(bool isOpaque) + { + IsOpaque = isOpaque; + } + + /// + /// Gets whether the softkey is opaque. + /// + public bool IsOpaque { get; } + } +} diff --git a/src/Tizen.WindowSystem/src/Events/TapEventArgs.cs b/src/Tizen.WindowSystem/src/Events/TapEventArgs.cs new file mode 100644 index 00000000000..cbcdfbbcf5d --- /dev/null +++ b/src/Tizen.WindowSystem/src/Events/TapEventArgs.cs @@ -0,0 +1,48 @@ +/* + * Copyright(c) 2024 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.WindowSystem +{ + /// + /// This class contains the data related to the Tap event. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class TapEventArgs : EventArgs + { + internal TapEventArgs(GestureState state, int fingers, int repeats) + { + State = state; + Fingers = fingers; + Repeats = repeats; + } + /// + /// State + /// + public GestureState State { get; internal set; } + /// + /// Fingers + /// + public int Fingers{ get; internal set;} + /// + /// Repeats + /// + public int Repeats{ get; internal set;} + } +} diff --git a/src/Tizen.WindowSystem/src/InputGenerator.cs b/src/Tizen.WindowSystem/src/InputGenerator.cs new file mode 100644 index 00000000000..0164093551f --- /dev/null +++ b/src/Tizen.WindowSystem/src/InputGenerator.cs @@ -0,0 +1,157 @@ +/* + * 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.WindowSystem +{ + /// + /// Class for the Tizen Input Generator. + /// + /// + /// http://tizen.org/privilege/inputgenerator + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class InputGenerator : IDisposable + { + private SafeHandles.InputGeneratorHandle _inputGeneratorHandle; + private bool disposed = false; + + /// + /// Creates a new InputGenerator. + /// + /// The name of the new input generator. + /// + /// + public InputGenerator(string name = null, bool sync = false) + { + if (sync) + { + _inputGeneratorHandle = Interop.InputGenerator.SyncInit(InputGeneratorDevices.All, name); + } + else + { + if (name == null) + _inputGeneratorHandle = Interop.InputGenerator.Init(InputGeneratorDevices.All); + else + _inputGeneratorHandle = Interop.InputGenerator.InitWithName(InputGeneratorDevices.All, name); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _inputGeneratorHandle?.Dispose(); + } + disposed = true; + } + } + + /// + /// Send given key. + /// + /// The key name to generate. + /// Set the key is pressed or released. + public void SendKey(string keyName, bool isPressed) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateKey(_inputGeneratorHandle, keyName, isPressed); + ErrorUtils.ThrowIfError((int)res, "Unknown Error"); + } + + /// + /// Send given pointer. + /// + /// The pointer button or touch index to generate. + /// The pointer action to generate. + /// X coordinate of the pointer. + /// Y coordinate of the pointer. + /// The device type to generate. + public void SendPointer(int index, PointerAction action, int x, int y, InputGeneratorDevices device = InputGeneratorDevices.Pointer) + { + if (device == InputGeneratorDevices.Touchscreen) + { + int touchAction = 0; // None + switch (action) + { + case PointerAction.Down: touchAction = 1; break; // Begin + case PointerAction.Up: touchAction = 3; break; // End + case PointerAction.Move: touchAction = 2; break; // Update + } + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateTouch(_inputGeneratorHandle, index, touchAction, x, y); + ErrorUtils.ThrowIfError((int)res, "Unknown Error"); + } + else + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GeneratePointer(_inputGeneratorHandle, index, (int)action, x, y); + ErrorUtils.ThrowIfError((int)res, "Unknown Error"); + } + } + + /// + /// Send given wheel. + /// + /// The wheel type to generate. + /// The offset value of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise). + public void SendWheel(WheelDirection wheelType, int value) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateWheel(_inputGeneratorHandle, wheelType, value); + ErrorUtils.ThrowIfError((int)res, "Unknown Error"); + } + + /// + /// Send given touch with axis. + /// + /// The touch index to generate. + /// The touch action to generate. + /// X coordinate of the touch. + /// Y coordinate of the touch. + /// radius_x of the touch. + /// radius_y of the touch. + /// pressure of the touch. + /// angle of the touch. + /// palm of the touch. + + public void SendPointer(int index, PointerAction action, int x, int y, double radiusX, double radiusY, double pressure, double angle, double palm) + { + int touchAction = 0; // None + switch (action) + { + case PointerAction.Down: touchAction = 1; break; // Begin + case PointerAction.Up: touchAction = 3; break; // End + case PointerAction.Move: touchAction = 2; break; // Update + } + + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateTouchAxis(_inputGeneratorHandle, index, touchAction, x, y, radiusX, radiusY, pressure, angle, palm); + ErrorUtils.ThrowIfError((int)res, "Unknown Error"); + } + } +} diff --git a/src/Tizen.WindowSystem/src/InputGesture.cs b/src/Tizen.WindowSystem/src/InputGesture.cs new file mode 100644 index 00000000000..e4d369c1280 --- /dev/null +++ b/src/Tizen.WindowSystem/src/InputGesture.cs @@ -0,0 +1,459 @@ +/* + * Copyright(c) 2024 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; +using System.Collections.Generic; +using static Tizen.WindowSystem.Interop.InputGesture; + +namespace Tizen.WindowSystem +{ + /// + /// Class for the Tizen Input Gesture. + /// Provides gesture detection through standard .NET events. + /// Register which gestures to detect, then subscribe to events to receive notifications. + /// Registration and event subscription are order-independent. + /// + /// + /// http://tizen.org/privilege/gesturegrab + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class InputGesture : IDisposable + { + SafeHandles.InputGestureHandle _handler; + bool disposed = false; + + // Native handles keyed by gesture parameters + private readonly Dictionary<(int fingers, GestureEdge edge), IntPtr> _edgeSwipeHandles = new Dictionary<(int, GestureEdge), IntPtr>(); + private readonly Dictionary<(int fingers, GestureEdge edge), IntPtr> _edgeDragHandles = new Dictionary<(int, GestureEdge), IntPtr>(); + private readonly Dictionary<(int fingers, int repeats), IntPtr> _tapHandles = new Dictionary<(int, int), IntPtr>(); + private IntPtr _palmCoverHandle = IntPtr.Zero; + + // Native delegate instances (prevent GC) + EdgeSwipeCb _edgeSwipeDelegate; + EdgeDragCb _edgeDragDelegate; + TapCb _tapDelegate; + PalmCoverCb _palmCoverDelegate; + + // .NET events + event EventHandler _edgeSwipeDetected; + event EventHandler _edgeDragDetected; + event EventHandler _tapDetected; + event EventHandler _palmCoverDetected; + + /// + /// Creates a new InputGesture. + /// + /// This module operates in a NUI application and requires instantiation and disposal on the main thread. + /// Thrown when the memory is not enough to allocate. + /// Thrown when the feature is not supported. + /// Thrown when the permission is denied. + public InputGesture() + { + _handler = Interop.InputGesture.Initialize(); + if (_handler.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err, "Failed to initialize InputGesture"); + } + + SetupNativeCallbacks(); + Log.Debug(LogTag, "InputGesture Created"); + } + + /// + /// Sets up native callbacks once during construction. + /// These persist for the lifetime of the InputGesture instance. + /// + void SetupNativeCallbacks() + { + _edgeSwipeDelegate = (IntPtr userData, GestureState mode, int fingers, int sx, int sy, GestureEdge edge) => + { + var args = new EdgeGestureEventArgs(mode, fingers, sx, sy, edge); + Log.Debug(LogTag, "EdgeSwipe Event received. mode: " + mode + ", fingers: " + fingers); + _edgeSwipeDetected?.Invoke(this, args); + }; + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetEdgeSwipeCb(_handler, _edgeSwipeDelegate, IntPtr.Zero); + ErrorUtils.ThrowIfError((int)res, "Failed to set edge swipe callback"); + + _edgeDragDelegate = (IntPtr userData, GestureState mode, int fingers, int cx, int cy, GestureEdge edge) => + { + var args = new EdgeGestureEventArgs(mode, fingers, cx, cy, edge); + Log.Debug(LogTag, "EdgeDrag Event received. mode: " + mode + ", fingers: " + fingers); + _edgeDragDetected?.Invoke(this, args); + }; + res = Interop.InputGesture.SetEdgeDragCb(_handler, _edgeDragDelegate, IntPtr.Zero); + ErrorUtils.ThrowIfError((int)res, "Failed to set edge drag callback"); + + _tapDelegate = (IntPtr userData, GestureState mode, int fingers, int repeats) => + { + var args = new TapEventArgs(mode, fingers, repeats); + Log.Debug(LogTag, "Tap Event received. mode: " + mode + ", fingers: " + fingers + ", repeats: " + repeats); + _tapDetected?.Invoke(this, args); + }; + res = Interop.InputGesture.SetTapCb(_handler, _tapDelegate, IntPtr.Zero); + ErrorUtils.ThrowIfError((int)res, "Failed to set tap callback"); + + _palmCoverDelegate = (IntPtr userData, GestureState mode, int duration, int cx, int cy, int size, double pressure) => + { + var args = new PalmCoverEventArgs(mode, duration, cx, cy, size, pressure); + Log.Debug(LogTag, "PalmCover Event received. mode: " + mode + ", duration: " + duration); + _palmCoverDetected?.Invoke(this, args); + }; + res = Interop.InputGesture.SetPalmCoverCb(_handler, _palmCoverDelegate, IntPtr.Zero); + ErrorUtils.ThrowIfError((int)res, "Failed to set palm cover callback"); + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (disposed) return; + + // Free all native gesture handles + foreach (var kvp in _edgeSwipeHandles) + Interop.InputGesture.EdgeSwipeFree(_handler, kvp.Value); + _edgeSwipeHandles.Clear(); + + foreach (var kvp in _edgeDragHandles) + Interop.InputGesture.EdgeDragFree(_handler, kvp.Value); + _edgeDragHandles.Clear(); + + foreach (var kvp in _tapHandles) + Interop.InputGesture.TapFree(_handler, kvp.Value); + _tapHandles.Clear(); + + if (_palmCoverHandle != IntPtr.Zero) + { + Interop.InputGesture.PalmCoverFree(_handler, _palmCoverHandle); + _palmCoverHandle = IntPtr.Zero; + } + + if (disposing) + { + _handler?.Dispose(); + } + + disposed = true; + } + + /// + /// Occurs when an edge swipe gesture is detected. + /// Subscribe to this event and call to specify which gestures to detect. + /// Subscription and registration are order-independent. + /// + public event EventHandler EdgeSwipeDetected + { + add => _edgeSwipeDetected += value; + remove => _edgeSwipeDetected -= value; + } + + /// + /// Occurs when an edge drag gesture is detected. + /// Subscribe to this event and call to specify which gestures to detect. + /// Subscription and registration are order-independent. + /// + public event EventHandler EdgeDragDetected + { + add => _edgeDragDetected += value; + remove => _edgeDragDetected -= value; + } + + /// + /// Occurs when a tap gesture is detected. + /// Subscribe to this event and call to specify which gestures to detect. + /// Subscription and registration are order-independent. + /// + public event EventHandler TapDetected + { + add => _tapDetected += value; + remove => _tapDetected -= value; + } + + /// + /// Occurs when a palm cover gesture is detected. + /// Subscribe to this event and call to specify which gestures to detect. + /// Subscription and registration are order-independent. + /// + public event EventHandler PalmCoverDetected + { + add => _palmCoverDetected += value; + remove => _palmCoverDetected -= value; + } + + /// + /// Registers an edge swipe gesture to detect. + /// + /// The number of fingers. + /// The position of edge. + /// Optional edge size. + /// The start point of edge area. + /// The end point of edge area. + /// Optional grab mode. + /// Thrown when the gesture is already registered or argument is invalid. + /// Thrown when the memory is not enough to allocate. + public void RegisterEdgeSwipe(int fingers, GestureEdge edge, GestureEdgeSize? edgeSize = null, int startPoint = 0, int endPoint = 0, GestureGrabMode? grabMode = null) + { + var key = (fingers, edge); + if (_edgeSwipeHandles.ContainsKey(key)) + throw new ArgumentException("Edge swipe gesture already registered for this (fingers, edge) combination."); + + IntPtr handle = Interop.InputGesture.EdgeSwipeNew(_handler, fingers, edge); + if (handle == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err, "Failed to create edge swipe gesture"); + } + + if (edgeSize.HasValue) + { + var res = Interop.InputGesture.EdgeSwipeSizeSet(handle, edgeSize.Value, startPoint, endPoint); + if (res != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.EdgeSwipeFree(_handler, handle); + ErrorUtils.ThrowIfError((int)res, "Failed to set edge swipe size"); + } + } + + if (grabMode.HasValue) + { + var res = Interop.InputGesture.SetGestureGrabMode(_handler, handle, grabMode.Value); + if (res != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.EdgeSwipeFree(_handler, handle); + ErrorUtils.ThrowIfError((int)res, "Failed to set grab mode"); + } + } + + var grabRes = Interop.InputGesture.GestureGrab(_handler, handle); + if (grabRes != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.EdgeSwipeFree(_handler, handle); + ErrorUtils.ThrowIfError((int)grabRes, "Failed to grab edge swipe gesture"); + } + + _edgeSwipeHandles[key] = handle; + Log.Debug(LogTag, $"RegisterEdgeSwipe fingers: {fingers}, edge: {edge}"); + } + + /// + /// Unregisters an edge swipe gesture. + /// + /// The number of fingers. + /// The position of edge. + public void UnregisterEdgeSwipe(int fingers, GestureEdge edge) + { + var key = (fingers, edge); + if (_edgeSwipeHandles.TryGetValue(key, out IntPtr handle)) + { + Interop.InputGesture.GestureUngrab(_handler, handle); + Interop.InputGesture.EdgeSwipeFree(_handler, handle); + _edgeSwipeHandles.Remove(key); + } + } + + /// + /// Registers an edge drag gesture to detect. + /// + /// The number of fingers. + /// The position of edge. + /// Optional edge size. + /// The start point of edge area. + /// The end point of edge area. + /// Optional grab mode. + /// Thrown when the gesture is already registered or argument is invalid. + /// Thrown when the memory is not enough to allocate. + public void RegisterEdgeDrag(int fingers, GestureEdge edge, GestureEdgeSize? edgeSize = null, int startPoint = 0, int endPoint = 0, GestureGrabMode? grabMode = null) + { + var key = (fingers, edge); + if (_edgeDragHandles.ContainsKey(key)) + throw new ArgumentException("Edge drag gesture already registered for this (fingers, edge) combination."); + + IntPtr handle = Interop.InputGesture.EdgeDragNew(_handler, fingers, edge); + if (handle == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err, "Failed to create edge drag gesture"); + } + + if (edgeSize.HasValue) + { + var res = Interop.InputGesture.EdgeDragSizeSet(handle, edgeSize.Value, startPoint, endPoint); + if (res != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.EdgeDragFree(_handler, handle); + ErrorUtils.ThrowIfError((int)res, "Failed to set edge drag size"); + } + } + + if (grabMode.HasValue) + { + var res = Interop.InputGesture.SetGestureGrabMode(_handler, handle, grabMode.Value); + if (res != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.EdgeDragFree(_handler, handle); + ErrorUtils.ThrowIfError((int)res, "Failed to set grab mode"); + } + } + + var grabRes = Interop.InputGesture.GestureGrab(_handler, handle); + if (grabRes != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.EdgeDragFree(_handler, handle); + ErrorUtils.ThrowIfError((int)grabRes, "Failed to grab edge drag gesture"); + } + + _edgeDragHandles[key] = handle; + Log.Debug(LogTag, $"RegisterEdgeDrag fingers: {fingers}, edge: {edge}"); + } + + /// + /// Unregisters an edge drag gesture. + /// + /// The number of fingers. + /// The position of edge. + public void UnregisterEdgeDrag(int fingers, GestureEdge edge) + { + var key = (fingers, edge); + if (_edgeDragHandles.TryGetValue(key, out IntPtr handle)) + { + Interop.InputGesture.GestureUngrab(_handler, handle); + Interop.InputGesture.EdgeDragFree(_handler, handle); + _edgeDragHandles.Remove(key); + } + } + + /// + /// Registers a tap gesture to detect. + /// + /// The number of fingers. + /// The number of repeats. + /// Optional grab mode. + /// Thrown when the gesture is already registered or argument is invalid. + /// Thrown when the memory is not enough to allocate. + public void RegisterTap(int fingers, int repeats, GestureGrabMode? grabMode = null) + { + var key = (fingers, repeats); + if (_tapHandles.ContainsKey(key)) + throw new ArgumentException("Tap gesture already registered for this (fingers, repeats) combination."); + + IntPtr handle = Interop.InputGesture.TapNew(_handler, fingers, repeats); + if (handle == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err, "Failed to create tap gesture"); + } + + if (grabMode.HasValue) + { + var res = Interop.InputGesture.SetGestureGrabMode(_handler, handle, grabMode.Value); + if (res != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.TapFree(_handler, handle); + ErrorUtils.ThrowIfError((int)res, "Failed to set grab mode"); + } + } + + var grabRes = Interop.InputGesture.GestureGrab(_handler, handle); + if (grabRes != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.TapFree(_handler, handle); + ErrorUtils.ThrowIfError((int)grabRes, "Failed to grab tap gesture"); + } + + _tapHandles[key] = handle; + Log.Debug(LogTag, $"RegisterTap fingers: {fingers}, repeats: {repeats}"); + } + + /// + /// Unregisters a tap gesture. + /// + /// The number of fingers. + /// The number of repeats. + public void UnregisterTap(int fingers, int repeats) + { + var key = (fingers, repeats); + if (_tapHandles.TryGetValue(key, out IntPtr handle)) + { + Interop.InputGesture.GestureUngrab(_handler, handle); + Interop.InputGesture.TapFree(_handler, handle); + _tapHandles.Remove(key); + } + } + + /// + /// Registers a palm cover gesture to detect. + /// + /// Optional grab mode. + /// Thrown when the gesture is already registered. + /// Thrown when the memory is not enough to allocate. + public void RegisterPalmCover(GestureGrabMode? grabMode = null) + { + if (_palmCoverHandle != IntPtr.Zero) + throw new ArgumentException("Palm cover gesture already registered."); + + IntPtr handle = Interop.InputGesture.PalmCoverNew(_handler); + if (handle == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err, "Failed to create palm cover gesture"); + } + + if (grabMode.HasValue) + { + var res = Interop.InputGesture.SetGestureGrabMode(_handler, handle, grabMode.Value); + if (res != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.PalmCoverFree(_handler, handle); + ErrorUtils.ThrowIfError((int)res, "Failed to set grab mode"); + } + } + + var grabRes = Interop.InputGesture.GestureGrab(_handler, handle); + if (grabRes != Interop.InputGesture.ErrorCode.None) + { + Interop.InputGesture.PalmCoverFree(_handler, handle); + ErrorUtils.ThrowIfError((int)grabRes, "Failed to grab palm cover gesture"); + } + + _palmCoverHandle = handle; + Log.Debug(LogTag, "RegisterPalmCover"); + } + + /// + /// Unregisters a palm cover gesture. + /// + public void UnregisterPalmCover() + { + if (_palmCoverHandle != IntPtr.Zero) + { + Interop.InputGesture.GestureUngrab(_handler, _palmCoverHandle); + Interop.InputGesture.PalmCoverFree(_handler, _palmCoverHandle); + _palmCoverHandle = IntPtr.Zero; + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.EcoreWl2.cs b/src/Tizen.WindowSystem/src/Interop/Interop.EcoreWl2.cs new file mode 100644 index 00000000000..7b95d46d858 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.EcoreWl2.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem +{ + internal static partial class Interop + { + internal static partial class EcoreWl2 + { + const string lib = "libecore_wl2.so.1"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "ecore_wl2_window_id_get")] + internal static extern int GetWindowId(IntPtr win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "ecore_wl2_window_display_get")] + internal static extern IntPtr GetDisplay(IntPtr win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "ecore_wl2_display_screen_size_get")] + internal static extern void GetScreenSize(IntPtr display, out int w, out int h); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.InputGenerator.cs b/src/Tizen.WindowSystem/src/Interop/Interop.InputGenerator.cs new file mode 100644 index 00000000000..02c9bf0f8ec --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.InputGenerator.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem +{ + internal static partial class Interop + { + internal static partial class InputGenerator + { + const string lib = "libcapi-ui-efl-util.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator")] + internal static extern SafeHandles.InputGeneratorHandle Init(InputGeneratorDevices devType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator_with_name")] + internal static extern SafeHandles.InputGeneratorHandle InitWithName(InputGeneratorDevices devType, string devName); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator_with_sync")] + internal static extern SafeHandles.InputGeneratorHandle SyncInit(InputGeneratorDevices devType, string devName); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_deinitialize_generator")] + internal static extern ErrorCode Deinit(IntPtr inputGenHandler); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_key")] + internal static extern ErrorCode GenerateKey(SafeHandles.InputGeneratorHandle inputGenHandler, string keyName, bool isPressed); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_pointer")] + internal static extern ErrorCode GeneratePointer(SafeHandles.InputGeneratorHandle inputGenHandler, int buttons, int pointerType, int x, int y); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_wheel")] + internal static extern ErrorCode GenerateWheel(SafeHandles.InputGeneratorHandle inputGenHandler, WheelDirection wheelType, int value); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_touch")] + internal static extern ErrorCode GenerateTouch(SafeHandles.InputGeneratorHandle inputGenHandler, int idx, int touchType, int x, int y); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_touch_axis")] + internal static extern ErrorCode GenerateTouchAxis(SafeHandles.InputGeneratorHandle inputGenHandler, int idx, int touchType, int x, int y, double radius_x, double radius_y, double pressure, double angle, double palm); + + private const int ErrorTzsh = -0x02860000; + + internal enum ErrorCode + { + None = Tizen.Internals.Errors.ErrorCode.None, // Successful + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, // Out of memory + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, // Invalid parameter + InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, // Invalid operation + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, // Permission denied + NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, // NOT supported + NoService = ErrorTzsh | 0x01, // Service does not exist + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.InputGesture.cs b/src/Tizen.WindowSystem/src/Interop/Interop.InputGesture.cs new file mode 100644 index 00000000000..4ccc746e63f --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.InputGesture.cs @@ -0,0 +1,96 @@ +using System; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem +{ + internal static partial class Interop + { + internal static class InputGesture + { + const string lib = "libcapi-ui-efl-util.so.0"; + + internal static string LogTag = "Tizen.NUI.WindowSystem"; + + [DllImport(lib, EntryPoint = "efl_util_gesture_initialize")] + internal static extern SafeHandles.InputGestureHandle Initialize(); + + [DllImport(lib, EntryPoint = "efl_util_gesture_deinitialize")] + internal static extern ErrorCode Deinitialize(IntPtr gestureHandler); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_new")] + internal static extern IntPtr EdgeSwipeNew(SafeHandles.InputGestureHandle gestureHandler, int fingers, GestureEdge edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_free")] + internal static extern ErrorCode EdgeSwipeFree(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_size_set")] + internal static extern ErrorCode EdgeSwipeSizeSet(IntPtr gestureData, GestureEdgeSize edgeSize, int startPoint, int endPoint); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_new")] + internal static extern IntPtr EdgeDragNew(SafeHandles.InputGestureHandle gestureHandler, int fingers, GestureEdge edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_free")] + internal static extern ErrorCode EdgeDragFree(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_size_set")] + internal static extern ErrorCode EdgeDragSizeSet(IntPtr gestureData, GestureEdgeSize edgeSize, int startPoint, int endPoint); + + [DllImport(lib, EntryPoint = "efl_util_gesture_tap_new")] + internal static extern IntPtr TapNew(SafeHandles.InputGestureHandle gestureHandler, int fingers, int repeats); + + [DllImport(lib, EntryPoint = "efl_util_gesture_tap_free")] + internal static extern ErrorCode TapFree(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_palm_cover_new")] + internal static extern IntPtr PalmCoverNew(SafeHandles.InputGestureHandle gestureHandler); + + [DllImport(lib, EntryPoint = "efl_util_gesture_palm_cover_free")] + internal static extern ErrorCode PalmCoverFree(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_grab")] + internal static extern ErrorCode GestureGrab(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_grab_mode_set")] + internal static extern ErrorCode SetGestureGrabMode(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData, GestureGrabMode mode); + + [DllImport(lib, EntryPoint = "efl_util_gesture_ungrab")] + internal static extern ErrorCode GestureUngrab(SafeHandles.InputGestureHandle gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_cb_set")] + internal static extern ErrorCode SetEdgeSwipeCb(SafeHandles.InputGestureHandle gestureHandler, EdgeSwipeCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void EdgeSwipeCb(IntPtr usergestureData, GestureState mode, int fingers, int sx, int sy, GestureEdge edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_cb_set")] + internal static extern ErrorCode SetEdgeDragCb(SafeHandles.InputGestureHandle gestureHandler, EdgeDragCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void EdgeDragCb(IntPtr usergestureData, GestureState mode, int fingers, int cx, int cy, GestureEdge edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_tap_cb_set")] + internal static extern ErrorCode SetTapCb(SafeHandles.InputGestureHandle gestureHandler, TapCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void TapCb(IntPtr usergestureData, GestureState mode, int fingers, int repeats); + + [DllImport(lib, EntryPoint = "efl_util_gesture_palm_cover_cb_set")] + internal static extern ErrorCode SetPalmCoverCb(SafeHandles.InputGestureHandle gestureHandler, PalmCoverCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void PalmCoverCb(IntPtr usergestureData, GestureState mode, int duration, int cx, int cy, int size, double pressure); + + internal enum ErrorCode + { + None = Tizen.Internals.Errors.ErrorCode.None, // Successful + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, // Out of memory + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, // Invalid parameter + InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, // Invalid operation + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, // Permission denied + NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, // NOT supported + }; + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.KVMService.cs b/src/Tizen.WindowSystem/src/Interop/Interop.KVMService.cs new file mode 100644 index 00000000000..c15bd4cadfd --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.KVMService.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class KVMService + { + const string lib = "libtzsh_kvm_service.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_create")] + internal static extern SafeHandles.KVMServiceHandle Create(SafeHandles.TizenShellHandle tzsh, uint win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_destroy")] + internal static extern int Destroy(IntPtr kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop")] + internal static extern int PerformDrop(SafeHandles.KVMServiceHandle kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_cancel_drag")] + internal static extern int CancelDrag(SafeHandles.KVMServiceHandle kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_receive_drag_data")] + internal static extern int ReceiveDragData(SafeHandles.KVMServiceHandle kvmService, string mimeType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_get_source_mimetypes")] + internal static extern int GetSourceMimetypes( + SafeHandles.KVMServiceHandle kvmService, + out IntPtr mimeTypes, + out int count); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_set")] + internal static extern int SetSecondarySelection(SafeHandles.KVMServiceHandle kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_unset")] + internal static extern int UnsetSecondarySelection(SafeHandles.KVMServiceHandle kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop_target")] + internal static extern int PerformDropTarget(SafeHandles.KVMServiceHandle kvmService, uint drop_target); + + internal delegate void KVMDragStartEventCallback(IntPtr data, IntPtr kvmService); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_drag_start_cb_set")] + internal static extern int SetDragStartEventHandler(SafeHandles.KVMServiceHandle kvmService, KVMDragStartEventCallback func, IntPtr data); + + internal delegate void KVMDragEndEventCallback(IntPtr data, IntPtr kvmService); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_drag_end_cb_set")] + internal static extern int SetDragEndEventHandler(SafeHandles.KVMServiceHandle kvmService, KVMDragEndEventCallback func, IntPtr data); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.QuickPanelClient.cs b/src/Tizen.WindowSystem/src/Interop/Interop.QuickPanelClient.cs new file mode 100644 index 00000000000..0cfa8b50760 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.QuickPanelClient.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class QuickPanelClient + { + const string lib = "libtzsh_quickpanel.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_create_with_type")] + internal static extern SafeHandles.QuickPanelClientHandle CreateWithType(SafeHandles.TizenShellHandle tzsh, uint win, QuickPanelCategory type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_destroy")] + internal static extern int Destroy(IntPtr qpClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_visible_get")] + internal static extern int GetVisible(SafeHandles.QuickPanelClientHandle qpClient, out int vis); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_scrollable_state_get")] + internal static extern int GetScrollableState(SafeHandles.QuickPanelClientHandle qpClient, out int scroll); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_scrollable_state_set")] + internal static extern int SetScrollableState(SafeHandles.QuickPanelClientHandle qpClient, QuickPanelScrollMode scroll); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_orientation_get")] + internal static extern int GetOrientation(SafeHandles.QuickPanelClientHandle qpClient, out int orientation); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_show")] + internal static extern int Show(SafeHandles.QuickPanelClientHandle qpClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_hide")] + internal static extern int Hide(SafeHandles.QuickPanelClientHandle qpClient); + + internal delegate void QuickPanelEventCallback(int type, IntPtr ev_info, IntPtr data); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_event_handler_add")] + internal static extern IntPtr AddEventHandler(SafeHandles.QuickPanelClientHandle qpClient, int type, QuickPanelEventCallback func, IntPtr data); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_event_handler_del")] + internal static extern int DelEventHandler(SafeHandles.QuickPanelClientHandle qpClient, IntPtr eventHandler); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_event_visible_get")] + internal static extern int GetEventVisible(IntPtr ev_info, out int state); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_event_orientation_get")] + internal static extern int GetEventOrientation(IntPtr ev_info, out int state); + + internal const string EventStringVisible = "tzsh_quickpanel_event_visible"; + internal const string EventStringOrientation = "tzsh_quickpanel_event_orientation"; + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.QuickPanelService.cs b/src/Tizen.WindowSystem/src/Interop/Interop.QuickPanelService.cs new file mode 100644 index 00000000000..b29960aafda --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.QuickPanelService.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class QuickPanelService + { + const string lib = "libtzsh_quickpanel_service.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_create_with_type")] + internal static extern SafeHandles.QuickPanelServiceHandle CreateWithType(SafeHandles.TizenShellHandle tzsh, uint win, QuickPanelCategory type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_destroy")] + internal static extern int Destroy(IntPtr service); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_type_get")] + internal static extern int GetType(SafeHandles.QuickPanelServiceHandle service, out int type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_show")] + internal static extern int Show(SafeHandles.QuickPanelServiceHandle service); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_hide")] + internal static extern int Hide(SafeHandles.QuickPanelServiceHandle service); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_content_region_set")] + internal static extern int SetContentRegion(SafeHandles.QuickPanelServiceHandle service, uint angle, SafeHandles.ShellRegionHandle region); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_handler_region_set")] + internal static extern int SetHandlerRegion(SafeHandles.QuickPanelServiceHandle service, uint angle, SafeHandles.ShellRegionHandle region); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_effect_type_set")] + internal static extern int SetEffectType(SafeHandles.QuickPanelServiceHandle service, QuickPanelEffect type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_scroll_lock")] + internal static extern int LockScroll(SafeHandles.QuickPanelServiceHandle service, bool locked); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.ScreensaverService.cs b/src/Tizen.WindowSystem/src/Interop/Interop.ScreensaverService.cs new file mode 100644 index 00000000000..6873396d190 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.ScreensaverService.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class ScreensaverService + { + const string lib = "libtzsh_screensaver_service.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_screensaver_service_create")] + internal static extern SafeHandles.ScreensaverServiceHandle Create(SafeHandles.TizenShellHandle tzsh, uint win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_screensaver_service_destroy")] + internal static extern int Destroy(IntPtr ScreensaverService); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.SoftkeyClient.cs b/src/Tizen.WindowSystem/src/Interop/Interop.SoftkeyClient.cs new file mode 100644 index 00000000000..d88ed43fca8 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.SoftkeyClient.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class SoftkeyClient + { + const string lib = "libtzsh_softkey.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_create")] + internal static extern SafeHandles.SoftkeyClientHandle Create(SafeHandles.TizenShellHandle tzsh, uint win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_destroy")] + internal static extern int Destroy(IntPtr softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_show")] + internal static extern int Show(SafeHandles.SoftkeyClientHandle softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_hide")] + internal static extern int Hide(SafeHandles.SoftkeyClientHandle softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_visible_state_get")] + internal static extern int GetVisibleState(SafeHandles.SoftkeyClientHandle softkeyClient, out int visible); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_expand_state_set")] + internal static extern int SetExpandState(SafeHandles.SoftkeyClientHandle softkeyClient, int expand); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_expand_state_get")] + internal static extern int GetExpandState(SafeHandles.SoftkeyClientHandle softkeyClient, out int expand); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_opacity_state_set")] + internal static extern int SetOpacityState(SafeHandles.SoftkeyClientHandle softkeyClient, int opacity); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_opacity_state_get")] + internal static extern int GetOpacityState(SafeHandles.SoftkeyClientHandle softkeyClient, out int opacity); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.SoftkeyService.cs b/src/Tizen.WindowSystem/src/Interop/Interop.SoftkeyService.cs new file mode 100644 index 00000000000..92a86d86c04 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.SoftkeyService.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class SoftkeyService + { + const string lib = "libtzsh_softkey_service.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_create")] + internal static extern SafeHandles.SoftkeyServiceHandle Create(SafeHandles.TizenShellHandle tzsh, uint win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_destroy")] + internal static extern int Destroy(IntPtr softkeyService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_show")] + internal static extern int Show(SafeHandles.SoftkeyServiceHandle softkeyService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_hide")] + internal static extern int Hide(SafeHandles.SoftkeyServiceHandle softkeyService); + + internal delegate void SoftkeyVisibleEventCallback(IntPtr data, IntPtr softkeyService, int visible); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_visible_request_cb_set")] + internal static extern int SetVisibleEventHandler(SafeHandles.SoftkeyServiceHandle softkeyService, SoftkeyVisibleEventCallback func, IntPtr data); + + internal delegate void SoftkeyExpandEventCallback(IntPtr data, IntPtr softkeyService, int expand); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_expand_request_cb_set")] + internal static extern int SetExpandEventHandler(SafeHandles.SoftkeyServiceHandle softkeyService, SoftkeyExpandEventCallback func, IntPtr data); + + internal delegate void SoftkeyOpacityEventCallback(IntPtr data, IntPtr softkeyService, int opacity); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_opacity_request_cb_set")] + internal static extern int SetOpacityEventHandler(SafeHandles.SoftkeyServiceHandle softkeyService, SoftkeyOpacityEventCallback func, IntPtr data); + + internal enum VisibleState + { + Hide = 0x0, + Show = 0x1, + } + + internal enum ExpandState + { + Off = 0x0, + On = 0x1, + } + + internal enum OpacityState + { + Opaque = 0x0, + Transparent = 0x1, + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.TaskbarService.cs b/src/Tizen.WindowSystem/src/Interop/Interop.TaskbarService.cs new file mode 100755 index 00000000000..0ff7fbe9b0d --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.TaskbarService.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.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 SafeHandles.TaskbarServiceHandle Create(SafeHandles.TizenShellHandle tzsh, uint 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(SafeHandles.TaskbarServiceHandle taskbarService, TaskbarPosition placeType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_size_set")] + internal static extern int SetSize(SafeHandles.TaskbarServiceHandle taskbarService, int width, int height); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.TizenRegion.cs b/src/Tizen.WindowSystem/src/Interop/Interop.TizenRegion.cs new file mode 100644 index 00000000000..869999ed17c --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.TizenRegion.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class TizenShellRegion + { + const string lib = "libtzsh_common.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_region_create")] + internal static extern SafeHandles.ShellRegionHandle Create(SafeHandles.TizenShellHandle tzsh); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_region_destroy")] + internal static extern int Destroy(IntPtr region); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_region_add")] + internal static extern int Add(SafeHandles.ShellRegionHandle region, int x, int y, int w, int h); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_region_subtract")] + internal static extern int Subtract(SafeHandles.ShellRegionHandle region, int x, int y, int w, int h); + } + } +} diff --git a/src/Tizen.WindowSystem/src/Interop/Interop.TizenShell.cs b/src/Tizen.WindowSystem/src/Interop/Interop.TizenShell.cs new file mode 100644 index 00000000000..f2687126d32 --- /dev/null +++ b/src/Tizen.WindowSystem/src/Interop/Interop.TizenShell.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + internal static partial class Interop + { + internal static partial class TizenShell + { + const string lib = "libtzsh_common.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_create")] + internal static extern SafeHandles.TizenShellHandle Create(int type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_destroy")] + internal static extern int Destroy(IntPtr tzsh); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_event_type_new")] + internal static extern int NewEventType(SafeHandles.TizenShellHandle tzsh, string name); + + internal enum ToolKitType + { + Unknown = 0, + Efl = 1, + } + + private const int ErrorTzsh = -0x02860000; + + internal enum ErrorCode + { + None = Tizen.Internals.Errors.ErrorCode.None, /* Successful */ + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /* Out of memory */ + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /* Invalid parameter */ + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /* Permission denied */ + NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /* NOT supported */ + NoService = ErrorTzsh | 0x01, /* Service does not exist */ + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/KVMService.cs b/src/Tizen.WindowSystem/src/KVMService.cs new file mode 100644 index 00000000000..f0c0550b0dd --- /dev/null +++ b/src/Tizen.WindowSystem/src/KVMService.cs @@ -0,0 +1,249 @@ +/* + * 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; +using System.Collections.Generic; +using Tizen.Common; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Class for the Tizen KVM service. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class KVMService : IDisposable + { + TizenShell _tzsh; + SafeHandles.KVMServiceHandle _kvmService; + int _tzshWin; + bool disposed = false; + + Interop.KVMService.KVMDragStartEventCallback _onDragStarted; + Interop.KVMService.KVMDragEndEventCallback _onDragEnded; + + event EventHandler _dragStarted; + event EventHandler _dragEnded; + + /// + /// Creates a new KVM Service handle. + /// + /// The TizenShell instance. + /// The window provider for the quickpanel service. + /// Thrown when failed of invalid argument. + /// Thrown when an argument is null. + /// 12 + public KVMService(TizenShell tzShell, IWindowProvider win) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _kvmService = Interop.KVMService.Create(_tzsh.SafeHandle, (uint)_tzshWin); + if (_kvmService.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _kvmService?.Dispose(); + } + disposed = true; + } + } + + /// + /// Emits the event when the drag started from any window. + /// + /// Thrown when failed of invalid argument. + public event EventHandler DragStarted + { + add + { + if (_dragStarted == null) + { + _onDragStarted = OnDragStarted; + int res = Interop.KVMService.SetDragStartEventHandler(_kvmService, _onDragStarted, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + _dragStarted += value; + } + remove + { + _dragStarted -= value; + if (_dragStarted == null) + { + int res = Interop.KVMService.SetDragStartEventHandler(_kvmService, null, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + } + } + + /// + /// Emits the event when the drag ended on any window except KVM window. + /// + /// Thrown when failed of invalid argument. + public event EventHandler DragEnded + { + add + { + if (_dragEnded == null) + { + _onDragEnded = OnDragEnded; + int res = Interop.KVMService.SetDragEndEventHandler(_kvmService, _onDragEnded, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + _dragEnded += value; + } + remove + { + _dragEnded -= value; + if (_dragEnded == null) + { + int res = Interop.KVMService.SetDragEndEventHandler(_kvmService, null, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + } + } + + void OnDragStarted(IntPtr data, IntPtr softkeyService) + { + _dragStarted?.Invoke(this, EventArgs.Empty); + } + + void OnDragEnded(IntPtr data, IntPtr softkeyService) + { + _dragEnded?.Invoke(this, EventArgs.Empty); + } + + /// + /// Requests to perform drop to KVM window. + /// + /// Thrown when failed of invalid argument. + public void PerformDrop() + { + int res = Interop.KVMService.PerformDrop(_kvmService); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to perform drop to given target. + /// + /// Thrown when failed of invalid argument. + public void PerformDrop(DropTarget target) + { + int res = Interop.KVMService.PerformDropTarget(_kvmService, (uint)target); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to cancel current drag. + /// + /// Thrown when failed of invalid argument. + public void CancelDrag() + { + int res = Interop.KVMService.CancelDrag(_kvmService); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to receive the current drag data. + /// the drag data will be received by the DragEvent of the window. + /// + /// Thrown when failed of invalid argument. + public void ReceiveDragData(string mimeType) + { + int res = Interop.KVMService.ReceiveDragData(_kvmService, mimeType); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to receive the mimetype collection of drag source. + /// + /// + /// The collection of mimetype. + /// If there are no mimetype, returns null. + /// + /// Thrown when failed of invalid argument. + public IEnumerable GetSourceMimetypes() + { + int res = Interop.KVMService.GetSourceMimetypes(_kvmService, out IntPtr mimeTypesPtr, out int mimeTypeCount); + ErrorUtils.ThrowIfError(res); + + if (mimeTypesPtr == IntPtr.Zero || mimeTypeCount == 0) + { + return null; + } + List mimetypes = new List(); + for (int i = 0; i < mimeTypeCount; i++) + { + IntPtr strPtr = global::System.Runtime.InteropServices.Marshal.ReadIntPtr(mimeTypesPtr, i * IntPtr.Size); + mimetypes.Add(global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strPtr)); + } + return mimetypes; + } + + /// + /// Requests to set KVM window as secondary selection window. + /// + /// Thrown when failed of invalid argument. + public void SetSecondarySelection() + { + int res = Interop.KVMService.SetSecondarySelection(_kvmService); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to unset secondary selection window of KVM window. + /// + /// Thrown when failed of invalid argument. + public void UnsetSecondarySelection() + { + int res = Interop.KVMService.UnsetSecondarySelection(_kvmService); + ErrorUtils.ThrowIfError(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/QuickPanelClient.cs b/src/Tizen.WindowSystem/src/QuickPanelClient.cs new file mode 100644 index 00000000000..31f1ea00ee4 --- /dev/null +++ b/src/Tizen.WindowSystem/src/QuickPanelClient.cs @@ -0,0 +1,472 @@ +/* + * Copyright(c) 2020 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 Tizen.Common; +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Class for the Tizen quickpanel client. + /// + /// + /// TizenShell.QuickPanelClient is a specialized class designed for handling interactions with the Quickpanel service that Tizen system GUI Application. + /// Through this class, we can conveniently retrieve various states of the Quickpanel service and make changes to specific states when necessary. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public class QuickPanelClient : IDisposable + { + TizenShell _tzsh; + SafeHandles.QuickPanelClientHandle _tzshQpClient; + int _tzshWin; + bool disposed = false; + WindowOrientation _screenOrientation = WindowOrientation.Portrait; + + int _visibleEventType; + IntPtr _visibleEventHandler; + Interop.QuickPanelClient.QuickPanelEventCallback _onVisibleChanged; + event EventHandler _visibleChanged; + + /// + /// The constructor of QuickPanelClient class. + /// + /// + /// This constructor creates a new Quickpanel Client handle. with this handle, we can interact with the quickpanel service. + /// This handle needs the TizenShell handle first. + /// + /// The TizenShell instance. + /// The window provider for the quickpanel service. + /// The type of quickpanel service. + /// Thrown when there is not enough memory (to allocate). + /// Thrown when failed of invalid argument. + /// Thrown when an argument is null. + /// 12 + public QuickPanelClient(TizenShell tzShell, IWindowProvider win, QuickPanelCategory type) + { + int width = 0, height = 0; + if (tzShell == null) + { + throw new ArgumentNullException("tzShell"); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException("win"); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _tzshQpClient = Interop.QuickPanelClient.CreateWithType(_tzsh.SafeHandle, (uint)_tzshWin, type); + if (_tzshQpClient.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + + IntPtr display = WindowSystem.Interop.EcoreWl2.GetDisplay(win.WindowHandle); + if (display != IntPtr.Zero) + { + WindowSystem.Interop.EcoreWl2.GetScreenSize(display, out width, out height); + } + if (width > height) _screenOrientation = (WindowOrientation)(90); + } + + /// + /// Disposes the resources of the QuickPanelClient class. + /// + /// Thrown when private memeber is a corrupted. + /// 8 + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _tzshQpClient?.Dispose(); + } + disposed = true; + } + } + + /// + /// Emits the event when the visible state of the quickpanel service window is changed. + /// + /// Thrown when failed of invalid argument. + /// 8 + public event EventHandler VisibleChanged + { + add + { + if (_visibleChanged == null) + { + if (_visibleEventType == 0) + { + _visibleEventType = Interop.TizenShell.NewEventType(_tzsh.SafeHandle, Interop.QuickPanelClient.EventStringVisible); + } + _onVisibleChanged = OnVisibleChanged; + _visibleEventHandler = Interop.QuickPanelClient.AddEventHandler(_tzshQpClient, _visibleEventType, _onVisibleChanged, IntPtr.Zero); + if (_visibleEventHandler == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + _visibleChanged += value; + } + remove + { + int _res; + _visibleChanged -= value; + if (_visibleChanged == null) + { + _res = Interop.QuickPanelClient.DelEventHandler(_tzshQpClient, _visibleEventHandler); + ErrorUtils.ThrowIfError(_res); + } + } + } + + int _orientationEventType; + IntPtr _orientationEventHandler; + Interop.QuickPanelClient.QuickPanelEventCallback _onOrientationChanged; + event EventHandler _orientationChanged; + + /// + /// Emits the event when the orientation of the quickpanel service window is changed. + /// + /// Thrown when failed of invalid argument. + /// 8 + public event EventHandler OrientationChanged + { + add + { + if (_orientationChanged == null) + { + if (_orientationEventType == 0) + { + _orientationEventType = Interop.TizenShell.NewEventType(_tzsh.SafeHandle, Interop.QuickPanelClient.EventStringOrientation); + } + _onOrientationChanged = OnOrientationChanged; + _orientationEventHandler = Interop.QuickPanelClient.AddEventHandler(_tzshQpClient, _orientationEventType, _onOrientationChanged, IntPtr.Zero); + if (_orientationEventHandler == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + _orientationChanged += value; + } + remove + { + int _res; + _orientationChanged -= value; + if (_orientationChanged == null) + { + _res = Interop.QuickPanelClient.DelEventHandler(_tzshQpClient, _orientationEventHandler); + ErrorUtils.ThrowIfError(_res); + } + } + } + + event EventHandler _rotationChanged; + + /// + /// Emits the event when the rotation(orientation) of the quickpanel service window is changed. + /// + /// + /// The value of the event argument represents the rotation angle in degrees. + /// + /// Thrown when failed of invalid argument. + /// 12 + public event EventHandler RotationChanged + { + add + { + if(_rotationChanged == null) + { + OrientationChanged += OnRotationChanged; + } + _rotationChanged += value; + } + remove + { + _rotationChanged -= value; + if(_rotationChanged == null) + { + OrientationChanged -= OnRotationChanged; + } + } + } + + void OnRotationChanged(object sender, WindowOrientation e) + { + _rotationChanged?.Invoke(sender, (int)e); + } + + /// + /// Enumeration for orientation state of quickpanel service window. + /// + /// 8 + enum OrientationState + { + /// + /// Unknown state. There is no quickpanel service. + /// + Unknown = 0x0, + /// + /// Radius 0 + /// + Angle_0 = 0x1, + /// + /// 90 + /// + Angle_90 = 0x2, + /// + /// 180 + /// + Angle_180 = 0x3, + /// + /// 270 + /// + Angle_270 = 0x4, + } + + WindowOrientation ConvertOrientation(OrientationState state) + { + if (_screenOrientation == WindowOrientation.Portrait) + { + if (state == OrientationState.Angle_90) + { + return WindowOrientation.Landscape; + } + else if (state == OrientationState.Angle_180) + { + return WindowOrientation.PortraitInverse; + } + else if (state == OrientationState.Angle_270) + { + return WindowOrientation.LandscapeInverse; + } + else + { + return WindowOrientation.Portrait; + } + } + else + { + if (state == OrientationState.Angle_90) + { + return WindowOrientation.Portrait; + } + else if (state == OrientationState.Angle_180) + { + return WindowOrientation.LandscapeInverse; + } + else if (state == OrientationState.Angle_270) + { + return WindowOrientation.PortraitInverse; + } + else + { + return WindowOrientation.Landscape; + } + } + } + + /// Thrown when failed of invalid argument. + void OnVisibleChanged(int type, IntPtr ev_info, IntPtr data) + { + int res; + int state; + + res = Interop.QuickPanelClient.GetEventVisible(ev_info, out state); + ErrorUtils.ThrowIfError(res); + + _visibleChanged?.Invoke(this, (QuickPanelVisibility)state); + } + + /// Thrown when failed of invalid argument. + void OnOrientationChanged(int type, IntPtr ev_info, IntPtr data) + { + int res; + int state; + WindowOrientation orientation; + + res = Interop.QuickPanelClient.GetEventOrientation(ev_info, out state); + ErrorUtils.ThrowIfError(res); + + orientation = ConvertOrientation((OrientationState)state); + + _orientationChanged?.Invoke(this, orientation); + } + + /// + /// Gets the visible state of the quickpanel. + /// + /// + /// Retrieves the visible state of the Quickpanel Service. + /// This visible state indicates whether or not the Quickpanel Service window is displayed at the time of invocation. + /// + /// The visible state of the quickpanel service window. + /// Thrown when failed of invalid argument. + /// Thrown when failed because of an invalid operation or no service. + /// 8 + public QuickPanelVisibility Visibility + { + get + { + return GetVisibility(); + } + } + + QuickPanelVisibility GetVisibility() + { + int res; + int vis; + + res = Interop.QuickPanelClient.GetVisible(_tzshQpClient, out vis); + + ErrorUtils.ThrowIfError(res); + + return (QuickPanelVisibility)vis; + } + + /// + /// Gets or sets the window's scrollable state of the quickpanel service window. + /// + /// + /// Retrieves or Changes the scrollable state of the Quickpanel Service window. + /// The scrollableState determines whether the Quickpanel Service window is scrollable or not. + /// And the scrollableState can be affect the visibility of the Quickpanel Service window. + /// + /// The scrollable state of the quickpanel service window. + /// Thrown when failed of invalid argument. + /// Thrown when failed because of an invalid operation or no service. + /// 8 + public QuickPanelScrollMode ScrollMode + { + get + { + return GetScrollable(); + } + set + { + SetScrollable(value); + } + } + + QuickPanelScrollMode GetScrollable() + { + int res; + int scroll; + + res = Interop.QuickPanelClient.GetScrollableState(_tzshQpClient, out scroll); + + ErrorUtils.ThrowIfError(res); + + return (QuickPanelScrollMode)scroll; + } + + void SetScrollable(QuickPanelScrollMode scroll) + { + int res; + + res = Interop.QuickPanelClient.SetScrollableState(_tzshQpClient, scroll); + + ErrorUtils.ThrowIfError(res); + } + + /// + /// Gets the current orientation of the quickpanel service window. + /// + /// + /// Retrieves the orientation of the Quickpanel Service. + /// This orientation value indicates the current angle of the Quickpanel Service window. + /// + /// The orientation of the quickpanel service window. + /// Thrown when failed of invalid argument. + /// Thrown when failed because of an invalid operation or no service. + /// 8 + public WindowOrientation Orientation + { + get + { + return GetOrientation(); + } + } + + WindowOrientation GetOrientation() + { + int res; + int state; + WindowOrientation orientation; + + res = Interop.QuickPanelClient.GetOrientation(_tzshQpClient, out state); + + ErrorUtils.ThrowIfError(res); + orientation = ConvertOrientation((OrientationState)state); + + return orientation; + } + + /// + /// Shows the quickpanel service window if it is currently scrollable. + /// + /// + /// Change the visible state of the quickpanel service window to shown if it is currently scrollable. + /// If the quickpanel is not scrollable, nothing will happen. + /// + /// Thrown when failed of invalid argument. + /// Thrown when failed because of an invalid operation or no service. + /// 8 + public void Show() + { + int res; + + res = Interop.QuickPanelClient.Show(_tzshQpClient); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Hides the quickpanel service window. + /// + /// + /// Change the visible state of the quickpanel service window to hidden. + /// + /// Thrown when failed of invalid argument. + /// Thrown when failed because of an invalid operation or no service. + /// 8 + public void Hide() + { + int res; + + res = Interop.QuickPanelClient.Hide(_tzshQpClient); + ErrorUtils.ThrowIfError(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/QuickPanelService.cs b/src/Tizen.WindowSystem/src/QuickPanelService.cs new file mode 100644 index 00000000000..73e5bcedfaf --- /dev/null +++ b/src/Tizen.WindowSystem/src/QuickPanelService.cs @@ -0,0 +1,255 @@ +/* + * Copyright(c) 2020 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; +using Tizen.Common; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Class for the Tizen quickpanel service. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class QuickPanelService : IDisposable + { + TizenShell _tzsh; + SafeHandles.QuickPanelServiceHandle _tzshQpService; + int _tzshWin; + bool disposed = false; + QuickPanelEffect _currentEffect; + bool _isLocked; + + /// + /// Creates a new Quickpanel Service handle. + /// + /// The TzShell instance. + /// The window provider for the quickpanel service. + /// The type of quickpanel service. + /// Thrown when the memory is not enough to allocate. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + /// 12 + public QuickPanelService(TizenShell tzShell, IWindowProvider win, QuickPanelCategory type) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _tzshQpService = Interop.QuickPanelService.CreateWithType(_tzsh.SafeHandle, (uint)_tzshWin, type); + if (_tzshQpService.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + + /// + /// Dispose. + /// + /// Thrown when private memeber is a corrupted. + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _tzshQpService?.Dispose(); + } + disposed = true; + } + } + + /// + /// Gets or sets the effect type of the quickpanel service. + /// + /// Thrown when failed of invalid argument. + public QuickPanelEffect Effect + { + get + { + return _currentEffect; + } + set + { + int res = Interop.QuickPanelService.SetEffectType(_tzshQpService, value); + ErrorUtils.ThrowIfError(res); + _currentEffect = value; + } + } + + /// + /// Gets or sets whether scrolling is locked for the quickpanel service window. + /// + /// Thrown when failed of invalid argument. + public bool IsLocked + { + get + { + return _isLocked; + } + set + { + int res = Interop.QuickPanelService.LockScroll(_tzshQpService, value); + ErrorUtils.ThrowIfError(res); + _isLocked = value; + } + } + + /// + /// Gets the type of the quickpanel service handle. + /// + /// The type of the quickpanel service handle + /// Thrown when failed of invalid argument. + public QuickPanelCategory ServiceType + { + get + { + return GetServiceType(); + } + } + + QuickPanelCategory GetServiceType() + { + int res; + int type; + + res = Interop.QuickPanelService.GetType(_tzshQpService, out type); + + ErrorUtils.ThrowIfError(res); + + return (QuickPanelCategory)type; + } + + /// + /// Requests to show the quickpanel service window. + /// + /// Thrown when failed of invalid argument. + public void Show() + { + int res; + + res = Interop.QuickPanelService.Show(_tzshQpService); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to hide the quickpanel service window. + /// + /// Thrown when failed of invalid argument. + public void Hide() + { + int res; + + res = Interop.QuickPanelService.Hide(_tzshQpService); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Sets the content region of the quickpanel service. + /// + /// The angle setting the region + /// The regions of the content + /// Thrown when failed of invalid argument. + /// Thrown when an argument is null. + public void SetContentRegion(uint angle, params (int x, int y, int width, int height)[] regions) + { + if (regions == null) + { + throw new ArgumentNullException(nameof(regions)); + } + + var regionHandle = Interop.TizenShellRegion.Create(_tzsh.SafeHandle); + if (regionHandle.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + Tizen.WindowSystem.ErrorUtils.ThrowIfError(err); + } + + try + { + foreach (var rect in regions) + { + int resAdd = Interop.TizenShellRegion.Add(regionHandle, rect.x, rect.y, rect.width, rect.height); + Tizen.WindowSystem.ErrorUtils.ThrowIfError(resAdd); + } + int res = Interop.QuickPanelService.SetContentRegion(_tzshQpService, angle, regionHandle); + Tizen.WindowSystem.ErrorUtils.ThrowIfError(res); + } + finally + { + regionHandle.Dispose(); + } + } + + /// + /// Sets the handler region of the quickpanel service. + /// + /// The angle setting the region + /// The regions of the handler + /// Thrown when failed of invalid argument. + /// Thrown when an argument is null. + public void SetHandlerRegion(uint angle, params (int x, int y, int width, int height)[] regions) + { + if (regions == null) + { + throw new ArgumentNullException(nameof(regions)); + } + + var regionHandle = Interop.TizenShellRegion.Create(_tzsh.SafeHandle); + if (regionHandle.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + Tizen.WindowSystem.ErrorUtils.ThrowIfError(err); + } + + try + { + foreach (var rect in regions) + { + int resAdd = Interop.TizenShellRegion.Add(regionHandle, rect.x, rect.y, rect.width, rect.height); + Tizen.WindowSystem.ErrorUtils.ThrowIfError(resAdd); + } + int res = Interop.QuickPanelService.SetHandlerRegion(_tzshQpService, angle, regionHandle); + Tizen.WindowSystem.ErrorUtils.ThrowIfError(res); + } + finally + { + regionHandle.Dispose(); + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/InputGeneratorHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/InputGeneratorHandle.cs new file mode 100644 index 00000000000..88d1e42667e --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/InputGeneratorHandle.cs @@ -0,0 +1,28 @@ +using System; +using System.Runtime.InteropServices; +using Tizen.WindowSystem; + + + +namespace Tizen.WindowSystem.SafeHandles +{ + internal class InputGeneratorHandle : SafeHandle + { + public InputGeneratorHandle() : base(IntPtr.Zero, true) + { + } + + public InputGeneratorHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Tizen.WindowSystem.Interop.InputGenerator.Deinit(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/InputGestureHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/InputGestureHandle.cs new file mode 100644 index 00000000000..7c184dc4b0a --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/InputGestureHandle.cs @@ -0,0 +1,28 @@ +using System; +using System.Runtime.InteropServices; +using Tizen.WindowSystem; + + + +namespace Tizen.WindowSystem.SafeHandles +{ + internal class InputGestureHandle : SafeHandle + { + public InputGestureHandle() : base(IntPtr.Zero, true) + { + } + + public InputGestureHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Tizen.WindowSystem.Interop.InputGesture.Deinitialize(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/KVMServiceHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/KVMServiceHandle.cs new file mode 100644 index 00000000000..f794919e1be --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/KVMServiceHandle.cs @@ -0,0 +1,26 @@ +using System; +using System.Runtime.InteropServices; + + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class KVMServiceHandle : SafeHandle + { + public KVMServiceHandle() : base(IntPtr.Zero, true) + { + } + + public KVMServiceHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.KVMService.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/QuickPanelClientHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/QuickPanelClientHandle.cs new file mode 100644 index 00000000000..8d09c2bd07f --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/QuickPanelClientHandle.cs @@ -0,0 +1,26 @@ +using System; +using System.Runtime.InteropServices; + + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class QuickPanelClientHandle : SafeHandle + { + public QuickPanelClientHandle() : base(IntPtr.Zero, true) + { + } + + public QuickPanelClientHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.QuickPanelClient.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/QuickPanelServiceHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/QuickPanelServiceHandle.cs new file mode 100644 index 00000000000..6e0bb16f757 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/QuickPanelServiceHandle.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class QuickPanelServiceHandle : SafeHandle + { + public QuickPanelServiceHandle() : base(IntPtr.Zero, true) + { + } + + public QuickPanelServiceHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.QuickPanelService.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/ScreensaverServiceHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/ScreensaverServiceHandle.cs new file mode 100644 index 00000000000..c98929bf8f5 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/ScreensaverServiceHandle.cs @@ -0,0 +1,26 @@ +using System; +using System.Runtime.InteropServices; + + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class ScreensaverServiceHandle : SafeHandle + { + public ScreensaverServiceHandle() : base(IntPtr.Zero, true) + { + } + + public ScreensaverServiceHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.ScreensaverService.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/ShellRegionHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/ShellRegionHandle.cs new file mode 100644 index 00000000000..beece158ab3 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/ShellRegionHandle.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class ShellRegionHandle : SafeHandle + { + public ShellRegionHandle() : base(IntPtr.Zero, true) + { + } + + public ShellRegionHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.TizenShellRegion.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/SoftkeyClientHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/SoftkeyClientHandle.cs new file mode 100644 index 00000000000..122f2652086 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/SoftkeyClientHandle.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class SoftkeyClientHandle : SafeHandle + { + public SoftkeyClientHandle() : base(IntPtr.Zero, true) + { + } + + public SoftkeyClientHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.SoftkeyClient.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/SoftkeyServiceHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/SoftkeyServiceHandle.cs new file mode 100644 index 00000000000..d57a91bcd99 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/SoftkeyServiceHandle.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class SoftkeyServiceHandle : SafeHandle + { + public SoftkeyServiceHandle() : base(IntPtr.Zero, true) + { + } + + public SoftkeyServiceHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.SoftkeyService.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/TaskbarServiceHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/TaskbarServiceHandle.cs new file mode 100644 index 00000000000..304f3453928 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/TaskbarServiceHandle.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class TaskbarServiceHandle : SafeHandle + { + public TaskbarServiceHandle() : base(IntPtr.Zero, true) + { + } + + public TaskbarServiceHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.TaskbarService.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/SafeHandles/TizenShellHandle.cs b/src/Tizen.WindowSystem/src/SafeHandles/TizenShellHandle.cs new file mode 100644 index 00000000000..5648fb7f6f7 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SafeHandles/TizenShellHandle.cs @@ -0,0 +1,26 @@ +using System; +using System.Runtime.InteropServices; + + +namespace Tizen.WindowSystem.Shell.SafeHandles +{ + internal class TizenShellHandle : SafeHandle + { + public TizenShellHandle() : base(IntPtr.Zero, true) + { + } + + public TizenShellHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(handle); + } + + public override bool IsInvalid => handle == IntPtr.Zero; + + protected override bool ReleaseHandle() + { + Interop.TizenShell.Destroy(handle); + return true; + } + } +} diff --git a/src/Tizen.WindowSystem/src/ScreensaverService.cs b/src/Tizen.WindowSystem/src/ScreensaverService.cs new file mode 100644 index 00000000000..9b8d65999ea --- /dev/null +++ b/src/Tizen.WindowSystem/src/ScreensaverService.cs @@ -0,0 +1,90 @@ +/* + * 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; +using Tizen.Common; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Class for the Tizen screensaver service. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class ScreensaverService : IDisposable + { + TizenShell _tzsh; + SafeHandles.ScreensaverServiceHandle _screensaverService; + int _tzshWin; + bool disposed = false; + + /// + /// Creates a new Screensaver Service handle. + /// + /// The TizenShell instance. + /// The window provider for the screensaver service. + /// Thrown when failed of invalid argument. + /// Thrown when an argument is null. + public ScreensaverService(TizenShell tzShell, IWindowProvider win) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _screensaverService = Interop.ScreensaverService.Create(_tzsh.SafeHandle, (uint)_tzshWin); + if (_screensaverService.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _screensaverService?.Dispose(); + } + disposed = true; + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/SoftkeyClient.cs b/src/Tizen.WindowSystem/src/SoftkeyClient.cs new file mode 100644 index 00000000000..fe3e604a349 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SoftkeyClient.cs @@ -0,0 +1,179 @@ +/* + * Copyright(c) 2020 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; +using Tizen.Common; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Class for the Tizen softkey client. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyClient : IDisposable + { + TizenShell _tzsh; + SafeHandles.SoftkeyClientHandle _softkeyClient; + int _tzshWin; + bool disposed = false; + + /// + /// Creates a new Softkey Client handle. + /// + /// The TizenShell instance. + /// The window provider for the quickpanel service. + /// http://tizen.org/privilege/windowsystem.admin + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + /// Thrown when failed because of an invalid operation or no service. + /// Thrown when the caller does not have privilege to use this method. + /// Thrown when the feature is not supported. + /// 12 + public SoftkeyClient(TizenShell tzShell, IWindowProvider win) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _softkeyClient = Interop.SoftkeyClient.Create(_tzsh.SafeHandle, (uint)_tzshWin); + if (_softkeyClient.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _softkeyClient?.Dispose(); + } + disposed = true; + } + } + + /// + /// Gets the visible state of a softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public bool IsVisible + { + get + { + int res = Interop.SoftkeyClient.GetVisibleState(_softkeyClient, out int vis); + ErrorUtils.ThrowIfError(res); + return vis != 1; + } + } + + /// + /// Gets or sets the expand state of a softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public bool IsExpandable + { + get + { + int res = Interop.SoftkeyClient.GetExpandState(_softkeyClient, out int expand); + ErrorUtils.ThrowIfError(res); + return expand != 1; + } + set + { + int res = Interop.SoftkeyClient.SetExpandState(_softkeyClient, value ? 1 : 0); + ErrorUtils.ThrowIfError(res); + } + } + + /// + /// Gets or sets the opacity state of a softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public bool IsOpaque + { + get + { + int res = Interop.SoftkeyClient.GetOpacityState(_softkeyClient, out int opacity); + ErrorUtils.ThrowIfError(res); + return opacity != 1; + } + set + { + int res = Interop.SoftkeyClient.SetOpacityState(_softkeyClient, value ? 1 : 0); + ErrorUtils.ThrowIfError(res); + } + } + + /// + /// Requests to show the softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public void Show() + { + int res = Interop.SoftkeyClient.Show(_softkeyClient); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to hide the softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public void Hide() + { + int res = Interop.SoftkeyClient.Hide(_softkeyClient); + ErrorUtils.ThrowIfError(res); + } + + + } +} diff --git a/src/Tizen.WindowSystem/src/SoftkeyService.cs b/src/Tizen.WindowSystem/src/SoftkeyService.cs new file mode 100644 index 00000000000..7c1f265d329 --- /dev/null +++ b/src/Tizen.WindowSystem/src/SoftkeyService.cs @@ -0,0 +1,217 @@ +/* + * Copyright(c) 2020 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; +using Tizen.Common; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Class for the Tizen softkey service. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyService : IDisposable + { + TizenShell _tzsh; + SafeHandles.SoftkeyServiceHandle _softkeyService; + int _tzshWin; + bool disposed = false; + + Interop.SoftkeyService.SoftkeyVisibleEventCallback _onVisibleChanged; + Interop.SoftkeyService.SoftkeyExpandEventCallback _onExpandChanged; + Interop.SoftkeyService.SoftkeyOpacityEventCallback _onOpacityChanged; + + event EventHandler _visibleChanged; + event EventHandler _expandChanged; + event EventHandler _opacityChanged; + + /// + /// Creates a new Softkey Service handle. + /// + /// The TizenShell instance. + /// The window provider for the quickpanel service. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public SoftkeyService(TizenShell tzShell, IWindowProvider win) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _softkeyService = Interop.SoftkeyService.Create(_tzsh.SafeHandle, (uint)_tzshWin); + if (_softkeyService.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _softkeyService?.Dispose(); + } + disposed = true; + } + } + + /// + /// Emits the event when the visible state of the softkey service window is changed. + /// + /// Thrown when failed of invalid argument. + public event EventHandler VisibleChanged + { + add + { + if (_visibleChanged == null) + { + _onVisibleChanged = OnVisibleChanged; + int res = Interop.SoftkeyService.SetVisibleEventHandler(_softkeyService, _onVisibleChanged, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + _visibleChanged += value; + } + remove + { + _visibleChanged -= value; + if (_visibleChanged == null) + { + int res = Interop.SoftkeyService.SetVisibleEventHandler(_softkeyService, null, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + } + } + + /// + /// Emits the event when the expand state of the softkey service window is changed. + /// + /// Thrown when failed of invalid argument. + public event EventHandler ExpandChanged + { + add + { + if (_expandChanged == null) + { + _onExpandChanged = OnExpandChanged; + int res = Interop.SoftkeyService.SetExpandEventHandler(_softkeyService, _onExpandChanged, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + _expandChanged += value; + } + remove + { + _expandChanged -= value; + if (_expandChanged == null) + { + int res = Interop.SoftkeyService.SetExpandEventHandler(_softkeyService, null, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + } + } + + /// + /// Emits the event when the opacity state of the softkey service window is changed. + /// + /// Thrown when failed of invalid argument. + public event EventHandler OpacityChanged + { + add + { + if (_opacityChanged == null) + { + _onOpacityChanged = OnOpacityChanged; + int res = Interop.SoftkeyService.SetOpacityEventHandler(_softkeyService, _onOpacityChanged, IntPtr.Zero); + ErrorUtils.ThrowIfError(res, "Unknown Error"); + } + _opacityChanged += value; + } + remove + { + _opacityChanged -= value; + if (_opacityChanged == null) + { + int res = Interop.SoftkeyService.SetOpacityEventHandler(_softkeyService, null, IntPtr.Zero); + ErrorUtils.ThrowIfError(res); + } + } + } + + void OnVisibleChanged(IntPtr data, IntPtr softkeyService, int visible) + { + bool isVisible = (Interop.SoftkeyService.VisibleState)visible == Interop.SoftkeyService.VisibleState.Show; + _visibleChanged?.Invoke(this, new SoftkeyVisibleChangedEventArgs(isVisible)); + } + + void OnExpandChanged(IntPtr data, IntPtr softkeyService, int expand) + { + bool isExpandable = (Interop.SoftkeyService.ExpandState)expand == Interop.SoftkeyService.ExpandState.On; + _expandChanged?.Invoke(this, new SoftkeyExpandChangedEventArgs(isExpandable)); + } + + void OnOpacityChanged(IntPtr data, IntPtr softkeyService, int opacity) + { + bool isOpaque = (Interop.SoftkeyService.OpacityState)opacity == Interop.SoftkeyService.OpacityState.Opaque; + _opacityChanged?.Invoke(this, new SoftkeyOpacityChangedEventArgs(isOpaque)); + } + + /// + /// Requests to show the softkey service window. + /// + /// Thrown when failed of invalid argument. + public void Show() + { + int res = Interop.SoftkeyService.Show(_softkeyService); + ErrorUtils.ThrowIfError(res); + } + + /// + /// Requests to hide the softkey service window. + /// + /// Thrown when failed of invalid argument. + public void Hide() + { + int res = Interop.SoftkeyService.Hide(_softkeyService); + ErrorUtils.ThrowIfError(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/TaskbarService.cs b/src/Tizen.WindowSystem/src/TaskbarService.cs new file mode 100755 index 00000000000..4ac9ce61846 --- /dev/null +++ b/src/Tizen.WindowSystem/src/TaskbarService.cs @@ -0,0 +1,129 @@ +/* + * 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; +using Tizen.Common; + +namespace Tizen.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 + { + TizenShell _tzsh; + SafeHandles.TaskbarServiceHandle _taskbarService; + TaskbarPosition _taskbarPosition; + int _tzshWin; + bool disposed = false; + + /// + /// Creates a new Taskbar Service handle. + /// + /// The TizenShell instance. + /// The window provider for the taskbar service. + /// The selected, predefined location on the screen the Taskbar should be placed on the screen. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public TaskbarService(TizenShell tzShell, IWindowProvider win, TaskbarPosition position = TaskbarPosition.Bottom) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.SafeHandle == null || tzShell.SafeHandle.IsInvalid) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _taskbarService = Interop.TaskbarService.Create(_tzsh.SafeHandle, (uint)_tzshWin); + if (_taskbarService.IsInvalid) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(err); + } + + Position = position; + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _taskbarService?.Dispose(); + } + disposed = true; + } + } + + /// + /// Gets or sets the current place type. + /// The window manager can use this to determine the geometry of another applications. + /// + /// Thrown when failed of invalid argument. + public TaskbarPosition Position + { + get => _taskbarPosition; + set + { + if (_taskbarPosition != value) + { + int res = Interop.TaskbarService.SetPlaceType(_taskbarService, value); + ErrorUtils.ThrowIfError(res); + _taskbarPosition = value; + } + } + } + + /// + /// 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(int width, int height) + { + int res; + + res = Interop.TaskbarService.SetSize(_taskbarService, width, height); + ErrorUtils.ThrowIfError(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/TizenShell.cs b/src/Tizen.WindowSystem/src/TizenShell.cs new file mode 100644 index 00000000000..edc9530d7b7 --- /dev/null +++ b/src/Tizen.WindowSystem/src/TizenShell.cs @@ -0,0 +1,83 @@ +/* + * Copyright(c) 2020 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; +using Tizen.Applications.Exceptions; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Basic handle of Tizen Window System Shell. + /// + /// + /// This class is a basic handle class for other class in Tizen Window System Shell. + /// TizenShell serves as the entry point for interacting with the other subclass of Tizen Window System Shell. + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public class TizenShell : IDisposable + { + SafeHandles.TizenShellHandle _tizenShell; + bool disposed = false; + + /// + /// The constructor of TizenShell class. + /// + /// Thrown when the memory is not enough to allocate. + /// Thrown when failed of invalid argument. + /// 8 + public TizenShell() + { + _tizenShell = Interop.TizenShell.Create((int)Interop.TizenShell.ToolKitType.Efl); + if (_tizenShell.IsInvalid) + { + int error = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorUtils.ThrowIfError(error, "Unknown Error"); + } + } + + /// + /// Dispose the TizenShell instance explicitly. + /// + /// Thrown when private memeber is a corrupted. + /// 8 + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + _tizenShell?.Dispose(); + } + disposed = true; + } + } + + internal SafeHandles.TizenShellHandle SafeHandle + { + get { return _tizenShell; } + } + } +} diff --git a/test/Tizen.NUI.WindowSystem.InputGesture/tizen-manifest.xml b/test/Tizen.NUI.WindowSystem.InputGesture/tizen-manifest.xml index 5c85e42c178..9e11914f47c 100644 --- a/test/Tizen.NUI.WindowSystem.InputGesture/tizen-manifest.xml +++ b/test/Tizen.NUI.WindowSystem.InputGesture/tizen-manifest.xml @@ -13,4 +13,8 @@ Tizen.NUI.WindowSystem.InputGesture.png + + http://tizen.org/privilege/gesturegrab + http://tizen.org/privilege/inputgenerator + diff --git a/test/Tizen.NUI.WindowSystem.InputGesture/tizen_dotnet_project.yaml b/test/Tizen.NUI.WindowSystem.InputGesture/tizen_dotnet_project.yaml index cb53adc6fce..3cde76a32f2 100644 --- a/test/Tizen.NUI.WindowSystem.InputGesture/tizen_dotnet_project.yaml +++ b/test/Tizen.NUI.WindowSystem.InputGesture/tizen_dotnet_project.yaml @@ -6,4 +6,4 @@ files: - Tizen.NUI.WindowSystem.InputGesture.csproj - Tizen.NUI.WindowSystem.InputGesture.cs - tizen-manifest.xml - - shared/res/Tizen.NUI.WindowSystem.InputGesture.png \ No newline at end of file + - shared/res/Tizen.NUI.WindowSystem.InputGesture.png diff --git a/test/Tizen.WindowSystem.InputGenerator/Tizen.WindowSystem.InputGenerator.cs b/test/Tizen.WindowSystem.InputGenerator/Tizen.WindowSystem.InputGenerator.cs new file mode 100644 index 00000000000..ac1eee22a43 --- /dev/null +++ b/test/Tizen.WindowSystem.InputGenerator/Tizen.WindowSystem.InputGenerator.cs @@ -0,0 +1,141 @@ +/* + * Copyright(c) 2024 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 Tizen; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.WindowSystem; + +namespace Tizen.WindowSystem.InputGeneratorTest +{ + class Program : NUIApplication + { + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + void Initialize() + { + Window win = Window.Default; + inputGen = new InputGenerator(); + + win.WindowSize = new Size2D(500, 500); + win.KeyEvent += OnKeyEvent; + win.BackgroundColor = Color.White; + + // Root layout + View rootView = new View(); + rootView.Size2D = new Size2D(500, 500); + rootView.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }; + win.Add(rootView); + + // Upper area: touch to generate SendKey + View touchView = new View(); + touchView.SizeWidth = 500; + touchView.Weight = 1.0f; + touchView.SizeHeight = 400; + touchView.BackgroundColor = Color.White; + touchView.TouchEvent += OnTouchView; + rootView.Add(touchView); + + centerLabel = new TextLabel("Touch upper area: SendKey test\nTouch counter: 0 / Key counter: 0"); + centerLabel.HorizontalAlignment = HorizontalAlignment.Center; + centerLabel.VerticalAlignment = VerticalAlignment.Center; + centerLabel.TextColor = Color.Black; + centerLabel.PointSize = 12.0f; + centerLabel.MultiLine = true; + centerLabel.HeightResizePolicy = ResizePolicyType.FillToParent; + centerLabel.WidthResizePolicy = ResizePolicyType.FillToParent; + touchView.Add(centerLabel); + + // Lower area: button to generate SendPointer + var sendPointerBtn = new Tizen.NUI.Components.Button() + { + Text = "SendPointer (generate touch at upper area)", + SizeWidth = 500, + SizeHeight = 80, + PointSize = 10.0f, + PositionY = 300f + }; + sendPointerBtn.Clicked += OnSendPointerClicked; + rootView.Add(sendPointerBtn); + } + + private void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + if (e.Key.State == Key.StateType.Down && e.Key.KeyPressedName == "Return") + { + keyCounter++; + UpdateLabel(); + } + } + + /// + /// Touch on upper area → SendKey("Return") test + /// + private bool OnTouchView(object sender, View.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Down) + { + touchCounter++; + UpdateLabel(); + + inputGen.SendKey("Return", true); + inputGen.SendKey("Return", false); + + return true; + } + return false; + } + + /// + /// Button click → SendPointer() generates a touch at (250, 150) which lands on the upper touchView. + /// This triggers OnTouchView, proving SendPointer works. + /// + private void OnSendPointerClicked(object sender, Tizen.NUI.Components.ClickedEventArgs e) + { + inputGen.SendPointer(0, PointerAction.Down, 250, 150, InputGeneratorDevices.Touchscreen); + inputGen.SendPointer(0, PointerAction.Up, 250, 150, InputGeneratorDevices.Touchscreen); + } + + private void UpdateLabel() + { + centerLabel.Text = $"Touch counter: {touchCounter} / Key counter: {keyCounter}"; + } + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + + private InputGenerator inputGen; + private TextLabel centerLabel; + int touchCounter = 0; + int keyCounter = 0; + } +} diff --git a/test/Tizen.WindowSystem.InputGenerator/Tizen.WindowSystem.InputGenerator.csproj b/test/Tizen.WindowSystem.InputGenerator/Tizen.WindowSystem.InputGenerator.csproj new file mode 100644 index 00000000000..e6fc9ec8d85 --- /dev/null +++ b/test/Tizen.WindowSystem.InputGenerator/Tizen.WindowSystem.InputGenerator.csproj @@ -0,0 +1,26 @@ + + + + Exe + net8.0-tizen10.0 + + + + portable + + + None + + + + + + + + + + + True + + + diff --git a/test/Tizen.WindowSystem.InputGenerator/shared/res/Tizen.WindowSystem.InputGenerator.png b/test/Tizen.WindowSystem.InputGenerator/shared/res/Tizen.WindowSystem.InputGenerator.png new file mode 100644 index 00000000000..9f3cb986081 Binary files /dev/null and b/test/Tizen.WindowSystem.InputGenerator/shared/res/Tizen.WindowSystem.InputGenerator.png differ diff --git a/test/Tizen.WindowSystem.InputGenerator/tizen-manifest.xml b/test/Tizen.WindowSystem.InputGenerator/tizen-manifest.xml new file mode 100644 index 00000000000..02297c1dc9d --- /dev/null +++ b/test/Tizen.WindowSystem.InputGenerator/tizen-manifest.xml @@ -0,0 +1,18 @@ + + + + + + Tizen.WindowSystem.InputGenerator.png + + + + http://tizen.org/privilege/inputgenerator + + diff --git a/test/Tizen.WindowSystem.InputGenerator/tizen_dotnet_project.yaml b/test/Tizen.WindowSystem.InputGenerator/tizen_dotnet_project.yaml new file mode 100644 index 00000000000..fe47193dc7f --- /dev/null +++ b/test/Tizen.WindowSystem.InputGenerator/tizen_dotnet_project.yaml @@ -0,0 +1,9 @@ +# csproj file path +csproj_file: Tizen.WindowSystem.InputGenerator.csproj + +# files monitored for dirty/modified status +files: + - Tizen.WindowSystem.InputGenerator.csproj + - Tizen.WindowSystem.InputGenerator.cs + - tizen-manifest.xml + - shared/res/Tizen.WindowSystem.InputGenerator.png diff --git a/test/Tizen.WindowSystem.InputGesture/Tizen.WindowSystem.InputGesture.cs b/test/Tizen.WindowSystem.InputGesture/Tizen.WindowSystem.InputGesture.cs new file mode 100644 index 00000000000..833e42a8566 --- /dev/null +++ b/test/Tizen.WindowSystem.InputGesture/Tizen.WindowSystem.InputGesture.cs @@ -0,0 +1,203 @@ +/* + * Copyright(c) 2024 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 Tizen; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.WindowSystem; + +namespace Tizen.WindowSystem.InputGestureTest +{ + class Program : NUIApplication + { + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + void Initialize() + { + Window win = Window.Default; + inputGesture = new InputGesture(); + + win.WindowSize = new Size2D(500, 500); + win.KeyEvent += OnKeyEvent; + win.BackgroundColor = Color.White; + + View windowView = new View(); + windowView.Size2D = new Size2D(500, 500); + windowView.BackgroundColor = Color.White; + windowView.TouchEvent += OnTouchEvent; + win.Add(windowView); + + centerLabel = new TextLabel("InputGesture Sample\n[S] EdgeSwipe [D] EdgeDrag\n[T] Tap [P] PalmCover\n[G] EdgeSwipe(Shared)"); + centerLabel.HorizontalAlignment = HorizontalAlignment.Center; + centerLabel.VerticalAlignment = VerticalAlignment.Center; + centerLabel.TextColor = Color.Black; + centerLabel.PointSize = 12.0f; + centerLabel.HeightResizePolicy = ResizePolicyType.FillToParent; + centerLabel.WidthResizePolicy = ResizePolicyType.FillToParent; + centerLabel.MultiLine = true; + windowView.Add(centerLabel); + } + + private void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + + // [S] EdgeSwipe: 2 fingers, Left edge + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "S" || e.Key.KeyPressedName == "s")) + { + if (!edgeSwipeRegistered) + { + inputGesture.RegisterEdgeSwipe(2, GestureEdge.Left); + inputGesture.EdgeSwipeDetected += OnEdgeSwipeDetected; + centerLabel.Text = "'S' Key Pressed. EdgeSwipe Registered"; + edgeSwipeRegistered = true; + } + else + { + inputGesture.EdgeSwipeDetected -= OnEdgeSwipeDetected; + inputGesture.UnregisterEdgeSwipe(2, GestureEdge.Left); + centerLabel.Text = "'S' Key Pressed. EdgeSwipe Unregistered"; + edgeSwipeRegistered = false; + } + } + + // [D] EdgeDrag: 2 fingers, Right edge + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "D" || e.Key.KeyPressedName == "d")) + { + if (!edgeDragRegistered) + { + inputGesture.RegisterEdgeDrag(2, GestureEdge.Right); + inputGesture.EdgeDragDetected += OnEdgeDragDetected; + centerLabel.Text = "'D' Key Pressed. EdgeDrag Registered"; + edgeDragRegistered = true; + } + else + { + inputGesture.EdgeDragDetected -= OnEdgeDragDetected; + inputGesture.UnregisterEdgeDrag(2, GestureEdge.Right); + centerLabel.Text = "'D' Key Pressed. EdgeDrag Unregistered"; + edgeDragRegistered = false; + } + } + + // [T] Tap: 3 fingers, 2 repeats + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "T" || e.Key.KeyPressedName == "t")) + { + if (!tapRegistered) + { + inputGesture.RegisterTap(3, 2); + inputGesture.TapDetected += OnTapDetected; + centerLabel.Text = "'T' Key Pressed. Tap Registered"; + tapRegistered = true; + } + else + { + inputGesture.TapDetected -= OnTapDetected; + inputGesture.UnregisterTap(3, 2); + centerLabel.Text = "'T' Key Pressed. Tap Unregistered"; + tapRegistered = false; + } + } + + // [P] PalmCover + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "P" || e.Key.KeyPressedName == "p")) + { + if (!palmCoverRegistered) + { + inputGesture.RegisterPalmCover(); + inputGesture.PalmCoverDetected += OnPalmCoverDetected; + centerLabel.Text = "'P' Key Pressed. PalmCover Registered"; + palmCoverRegistered = true; + } + else + { + inputGesture.PalmCoverDetected -= OnPalmCoverDetected; + inputGesture.UnregisterPalmCover(); + centerLabel.Text = "'P' Key Pressed. PalmCover Unregistered"; + palmCoverRegistered = false; + } + } + + // [G] EdgeSwipe with Shared grab mode: 1 finger, Left edge + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "G" || e.Key.KeyPressedName == "g")) + { + if (!edgeSwipeSharedRegistered) + { + inputGesture.RegisterEdgeSwipe(1, GestureEdge.Left, grabMode: GestureGrabMode.Shared); + inputGesture.EdgeSwipeDetected += OnEdgeSwipeDetected; + centerLabel.Text = "'G' Key Pressed. EdgeSwipe Shared Registered"; + edgeSwipeSharedRegistered = true; + } + else + { + inputGesture.EdgeSwipeDetected -= OnEdgeSwipeDetected; + inputGesture.UnregisterEdgeSwipe(1, GestureEdge.Left); + centerLabel.Text = "'G' Key Pressed. EdgeSwipe Shared Unregistered"; + edgeSwipeSharedRegistered = false; + } + } + } + + private bool OnTouchEvent(object sender, View.TouchEventArgs e) + { + return true; + } + + private void OnEdgeSwipeDetected(object sender, EdgeGestureEventArgs e) + { + Log.Debug("GestureSample", "EdgeSwipe - State: " + e.State + ", Fingers: " + e.Fingers + ", X: " + e.X + ", Y: " + e.Y + ", Edge: " + e.Edge); + } + + private void OnEdgeDragDetected(object sender, EdgeGestureEventArgs e) + { + Log.Debug("GestureSample", "EdgeDrag - State: " + e.State + ", Fingers: " + e.Fingers + ", X: " + e.X + ", Y: " + e.Y + ", Edge: " + e.Edge); + } + + private void OnTapDetected(object sender, TapEventArgs e) + { + Log.Debug("GestureSample", "Tap - State: " + e.State + ", Fingers: " + e.Fingers + ", Repeats: " + e.Repeats); + } + + private void OnPalmCoverDetected(object sender, PalmCoverEventArgs e) + { + Log.Debug("GestureSample", "PalmCover - State: " + e.State + ", Duration: " + e.Duration + ", CenterX: " + e.CenterX + ", CenterY: " + e.CenterY + ", Size: " + e.Size + ", Pressure: " + e.Pressure); + } + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + + private InputGesture inputGesture; + private TextLabel centerLabel; + + bool edgeSwipeRegistered; + bool edgeDragRegistered; + bool tapRegistered; + bool palmCoverRegistered; + bool edgeSwipeSharedRegistered; + } +} diff --git a/test/Tizen.WindowSystem.InputGesture/Tizen.WindowSystem.InputGesture.csproj b/test/Tizen.WindowSystem.InputGesture/Tizen.WindowSystem.InputGesture.csproj new file mode 100644 index 00000000000..e6fc9ec8d85 --- /dev/null +++ b/test/Tizen.WindowSystem.InputGesture/Tizen.WindowSystem.InputGesture.csproj @@ -0,0 +1,26 @@ + + + + Exe + net8.0-tizen10.0 + + + + portable + + + None + + + + + + + + + + + True + + + diff --git a/test/Tizen.WindowSystem.InputGesture/shared/res/Tizen.WindowSystem.InputGesture.png b/test/Tizen.WindowSystem.InputGesture/shared/res/Tizen.WindowSystem.InputGesture.png new file mode 100644 index 00000000000..9f3cb986081 Binary files /dev/null and b/test/Tizen.WindowSystem.InputGesture/shared/res/Tizen.WindowSystem.InputGesture.png differ diff --git a/test/Tizen.WindowSystem.InputGesture/tizen-manifest.xml b/test/Tizen.WindowSystem.InputGesture/tizen-manifest.xml new file mode 100644 index 00000000000..e737153fe3a --- /dev/null +++ b/test/Tizen.WindowSystem.InputGesture/tizen-manifest.xml @@ -0,0 +1,17 @@ + + + + + + Tizen.WindowSystem.InputGesture.png + + + + + + http://tizen.org/privilege/gesturegrab + http://tizen.org/privilege/inputgenerator + + + + diff --git a/test/Tizen.WindowSystem.InputGesture/tizen_dotnet_project.yaml b/test/Tizen.WindowSystem.InputGesture/tizen_dotnet_project.yaml new file mode 100644 index 00000000000..afdf085df02 --- /dev/null +++ b/test/Tizen.WindowSystem.InputGesture/tizen_dotnet_project.yaml @@ -0,0 +1,9 @@ +# csproj file path +csproj_file: Tizen.WindowSystem.InputGesture.csproj + +# files monitored for dirty/modified status +files: + - Tizen.WindowSystem.InputGesture.csproj + - Tizen.WindowSystem.InputGesture.cs + - tizen-manifest.xml + - shared/res/Tizen.WindowSystem.InputGesture.png diff --git a/test/Tizen.WindowSystem.Samples/Tizen.WindowSystem.Samples.cs b/test/Tizen.WindowSystem.Samples/Tizen.WindowSystem.Samples.cs new file mode 100644 index 00000000000..b98f78db736 --- /dev/null +++ b/test/Tizen.WindowSystem.Samples/Tizen.WindowSystem.Samples.cs @@ -0,0 +1,708 @@ +using System; +using System.Threading.Tasks; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using Tizen.WindowSystem.Shell; +using Tizen.Common; +using Color = Tizen.NUI.Color; + +namespace Tizen.WindowSystem.Samples +{ + class Program : NUIApplication + { + TizenShell tzShell; + QuickPanelClient qpClient; + Button BtnClient; + TextLabel textClientVisible; + TextLabel textClientScrollable; + TextLabel textClientOrientation; + + QuickPanelService qpService; + Button BtnService; + Timer _timer; + + SoftkeyClient softkeyClient; + Button BtnSoftkeyClient; + TextLabel textSoftkeyClientVisible; + TextLabel textSoftkeyClientExpand; + TextLabel textSoftkeyClientOpacity; + + SoftkeyService softkeyService; + Button BtnSoftkeyService; + TextLabel textSoftkeyServiceVisible; + TextLabel textSoftkeyServiceExpand; + TextLabel textSoftkeyServiceOpacity; + + ScreensaverService screensaverService; + Button BtnScreensaverService; + TextLabel textScreensaverServiceTitle; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + void Initialize() + { + Window window = NUIApplication.GetDefaultWindow(); + window.KeyEvent += OnKeyEvent; + window.BackgroundColor = Color.White; + + BtnClient = new Button() + { + Text = "QuickPanelClient", + Size = new Size(400, 100), + Position = new Position(100, 200), + Margin = 10, + }; + + BtnService = new Button() + { + Text = "QuickPanelService", + Size = new Size(400, 100), + Position = new Position(100, 340), + Margin = 10, + }; + + BtnSoftkeyClient = new Button() + { + Text = "SoftkeyClient", + Size = new Size(400, 100), + Position = new Position(100, 480), + Margin = 10, + }; + + BtnSoftkeyService = new Button() + { + Text = "SoftkeyService", + Size = new Size(400, 100), + Position = new Position(100, 620), + Margin = 10, + }; + + BtnScreensaverService = new Button() + { + Text = "ScreensaverService", + Size = new Size(400, 100), + Position = new Position(100, 760), + Margin = 10, + }; + + window.Add(BtnClient); + window.Add(BtnService); + window.Add(BtnSoftkeyClient); + window.Add(BtnSoftkeyService); + window.Add(BtnScreensaverService); + + BtnClient.Clicked += BtnClient_ClickEvent; + BtnService.Clicked += BtnService_ClickEvent; + BtnSoftkeyClient.Clicked += BtnSoftkeyClient_ClickEvent; + BtnSoftkeyService.Clicked += BtnSoftkeyService_ClickEvent; + BtnScreensaverService.Clicked += BtnScreensaverService_ClickEvent; + + tzShell = new TizenShell(); + + window.AddAvailableOrientation(Window.WindowOrientation.Portrait); + window.AddAvailableOrientation(Window.WindowOrientation.Landscape); + window.AddAvailableOrientation(Window.WindowOrientation.PortraitInverse); + window.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse); + } + + public void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + } + + // ===================================================================== + // QuickPanelClient + // ===================================================================== + + public void OnVisibleEvent(object sender, QuickPanelVisibility state) + { + textClientVisible.Text = $"Visible: {qpClient.Visibility}"; + } + + public void OnOrientationEvent(object sender, WindowOrientation state) + { + textClientOrientation.Text = $"Orientation: {qpClient.Orientation}"; + } + + private void BtnClient_ClickEvent(object sender, ClickedEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + RemoveMenuButtons(window); + + qpClient = new QuickPanelClient(tzShell, (IWindowProvider)window, QuickPanelCategory.SystemDefault); + + qpClient.VisibleChanged += OnVisibleEvent; + qpClient.OrientationChanged += OnOrientationEvent; + + textClientVisible = new TextLabel($"Visible: {qpClient.Visibility}"); + textClientVisible.Position = new Position(0, -100); + textClientVisible.HorizontalAlignment = HorizontalAlignment.Center; + textClientVisible.VerticalAlignment = VerticalAlignment.Center; + textClientVisible.TextColor = Color.Blue; + textClientVisible.PointSize = 12.0f; + textClientVisible.HeightResizePolicy = ResizePolicyType.FillToParent; + textClientVisible.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textClientVisible); + + textClientScrollable = new TextLabel($"Scrollable: {qpClient.ScrollMode}"); + textClientScrollable.HorizontalAlignment = HorizontalAlignment.Center; + textClientScrollable.VerticalAlignment = VerticalAlignment.Center; + textClientScrollable.TextColor = Color.Blue; + textClientScrollable.PointSize = 12.0f; + textClientScrollable.HeightResizePolicy = ResizePolicyType.FillToParent; + textClientScrollable.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textClientScrollable); + + textClientOrientation = new TextLabel($"Orientation: {qpClient.Orientation}"); + textClientOrientation.Position = new Position(0, 100); + textClientOrientation.HorizontalAlignment = HorizontalAlignment.Center; + textClientOrientation.VerticalAlignment = VerticalAlignment.Center; + textClientOrientation.TextColor = Color.Blue; + textClientOrientation.PointSize = 12.0f; + textClientOrientation.HeightResizePolicy = ResizePolicyType.FillToParent; + textClientOrientation.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textClientOrientation); + + Button BtnScrollableSet = new Button() + { + Text = "Scrollable Set", + Size = new Size(400, 100), + Position = new Position(50, 800), + Margin = 10, + }; + Button BtnScrollableUnset = new Button() + { + Text = "Scrollable Unset", + Size = new Size(400, 100), + Position = new Position(50, 920), + Margin = 10, + }; + Button BtnScrollableRetain = new Button() + { + Text = "Scrollable Retain", + Size = new Size(400, 100), + Position = new Position(50, 1040), + Margin = 10, + }; + Button BtnShow = new Button() + { + Text = "Show", + Size = new Size(200, 100), + Position = new Position(470, 850), + Margin = 10, + }; + Button BtnHide = new Button() + { + Text = "Hide", + Size = new Size(200, 100), + Position = new Position(470, 990), + Margin = 10, + }; + + BtnScrollableSet.Clicked += BtnScrollableSet_ClickEvent; + BtnScrollableUnset.Clicked += BtnScrollableUnset_ClickEvent; + BtnScrollableRetain.Clicked += BtnScrollableRetain_ClickEvent; + BtnShow.Clicked += BtnClientShow_ClickEvent; + BtnHide.Clicked += BtnClientHide_ClickEvent; + + window.Add(BtnScrollableSet); + window.Add(BtnScrollableUnset); + window.Add(BtnScrollableRetain); + window.Add(BtnShow); + window.Add(BtnHide); + } + + private void BtnScrollableSet_ClickEvent(object sender, ClickedEventArgs e) + { + qpClient.ScrollMode = QuickPanelScrollMode.Scrollable; + textClientScrollable.Text = $"Scrollable: {qpClient.ScrollMode}"; + } + private void BtnScrollableUnset_ClickEvent(object sender, ClickedEventArgs e) + { + qpClient.ScrollMode = QuickPanelScrollMode.NotScrollable; + textClientScrollable.Text = $"Scrollable: {qpClient.ScrollMode}"; + } + private void BtnScrollableRetain_ClickEvent(object sender, ClickedEventArgs e) + { + qpClient.ScrollMode = QuickPanelScrollMode.Retain; + textClientScrollable.Text = $"Scrollable: {qpClient.ScrollMode}"; + } + private void BtnClientShow_ClickEvent(object sender, ClickedEventArgs e) + { + qpClient.Show(); + } + private void BtnClientHide_ClickEvent(object sender, ClickedEventArgs e) + { + qpClient.Hide(); + } + + // ===================================================================== + // QuickPanelService + // ===================================================================== + + private void BtnService_ClickEvent(object sender, ClickedEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + QuickPanelCategory type = QuickPanelCategory.AppsMenu; + + RemoveMenuButtons(window); + + qpService = new QuickPanelService(tzShell, (IWindowProvider)window, type); + + TextLabel textServiceType = new TextLabel($"Type: {qpService.ServiceType}"); + textServiceType.Position = new Position(0, -300); + textServiceType.HorizontalAlignment = HorizontalAlignment.Center; + textServiceType.VerticalAlignment = VerticalAlignment.Center; + textServiceType.TextColor = Color.Blue; + textServiceType.PointSize = 12.0f; + textServiceType.HeightResizePolicy = ResizePolicyType.FillToParent; + textServiceType.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textServiceType); + + Button BtnShow = new Button() + { + Text = "Show", + Size = new Size(200, 100), + Position = new Position(50, 500), + Margin = 10, + }; + Button BtnHide = new Button() + { + Text = "Hide", + Size = new Size(200, 100), + Position = new Position(410, 500), + Margin = 10, + }; + + Button BtnEffectSwipe = new Button() + { + Text = "EffectSwipe", + Size = new Size(400, 80), + Position = new Position(50, 700), + Margin = 10, + }; + Button BtnEffectMove = new Button() + { + Text = "EffectMove", + Size = new Size(400, 80), + Position = new Position(50, 800), + Margin = 10, + }; + Button BtnEffectAppCustom = new Button() + { + Text = "EffectAppCustom", + Size = new Size(400, 80), + Position = new Position(50, 900), + Margin = 10, + }; + + Button BtnLockTrue = new Button() + { + Text = "LockTrue", + Size = new Size(300, 80), + Position = new Position(50, 1000), + Margin = 10, + }; + Button BtnLockFalse = new Button() + { + Text = "LockFalse", + Size = new Size(300, 80), + Position = new Position(400, 1000), + Margin = 10, + }; + Button BtnTimerStop = new Button() + { + Text = "TimerStop", + Size = new Size(300, 80), + Position = new Position(50, 50), + Margin = 10, + }; + + BtnShow.Clicked += BtnServiceShow_ClickEvent; + BtnHide.Clicked += BtnServiceHide_ClickEvent; + + BtnEffectSwipe.Clicked += BtnEffectSwipe_ClickEvent; + BtnEffectMove.Clicked += BtnEffectMove_ClickEvent; + BtnEffectAppCustom.Clicked += BtnEffectAppCustom_ClickEvent; + + BtnLockTrue.Clicked += BtnLockTrue_ClickEvent; + BtnLockFalse.Clicked += BtnLockFalse_ClickEvent; + + BtnTimerStop.Clicked += BtnTimerStop_ClickEvent; + + window.Add(BtnShow); + window.Add(BtnHide); + + window.Add(BtnEffectSwipe); + window.Add(BtnEffectMove); + window.Add(BtnEffectAppCustom); + + window.Add(BtnLockTrue); + window.Add(BtnLockFalse); + + window.Add(BtnTimerStop); + + // SetContentRegion / SetHandlerRegion now use params tuples instead of TizenRegion + int winX = window.WindowPosition.X; + int winY = window.WindowPosition.Y; + int winW = window.WindowSize.Width; + int winH = window.WindowSize.Height; + + qpService.SetContentRegion(0, (winX, winY, winW, winH - 50)); + qpService.SetHandlerRegion(0, (winX, winY + winH - 50, winW, 50)); + + _timer = new Timer(2000); + _timer.Tick += Timer_Tick; + _timer.Start(); + } + + bool _cnt = true; + + private bool Timer_Tick(object source, Timer.TickEventArgs e) + { + if (_cnt) + { + qpService.Show(); + } + else + { + qpService.Hide(); + } + _cnt = !_cnt; + return true; + } + + private void BtnServiceShow_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.Show(); + } + private void BtnServiceHide_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.Hide(); + } + + private void BtnEffectSwipe_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.Effect = QuickPanelEffect.Swipe; + } + private void BtnEffectMove_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.Effect = QuickPanelEffect.Move; + } + private void BtnEffectAppCustom_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.Effect = QuickPanelEffect.Custom; + } + private void BtnLockTrue_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.IsLocked = true; + } + private void BtnLockFalse_ClickEvent(object sender, ClickedEventArgs e) + { + qpService.IsLocked = false; + } + private void BtnTimerStop_ClickEvent(object sender, ClickedEventArgs e) + { + _timer.Stop(); + } + + // ===================================================================== + // SoftkeyClient + // ===================================================================== + + private void BtnSoftkeyClient_ClickEvent(object sender, ClickedEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + RemoveMenuButtons(window); + + softkeyClient = new SoftkeyClient(tzShell, (IWindowProvider)window); + + textSoftkeyClientVisible = new TextLabel($"Visible: {softkeyClient.IsVisible}"); + textSoftkeyClientVisible.Position = new Position(0, -100); + textSoftkeyClientVisible.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyClientVisible.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyClientVisible.TextColor = Color.Blue; + textSoftkeyClientVisible.PointSize = 12.0f; + textSoftkeyClientVisible.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyClientVisible.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyClientVisible); + + textSoftkeyClientExpand = new TextLabel($"Expandable: {softkeyClient.IsExpandable}"); + textSoftkeyClientExpand.Position = new Position(0, 0); + textSoftkeyClientExpand.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyClientExpand.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyClientExpand.TextColor = Color.Blue; + textSoftkeyClientExpand.PointSize = 12.0f; + textSoftkeyClientExpand.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyClientExpand.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyClientExpand); + + textSoftkeyClientOpacity = new TextLabel($"Opaque: {softkeyClient.IsOpaque}"); + textSoftkeyClientOpacity.Position = new Position(0, 100); + textSoftkeyClientOpacity.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyClientOpacity.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyClientOpacity.TextColor = Color.Blue; + textSoftkeyClientOpacity.PointSize = 12.0f; + textSoftkeyClientOpacity.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyClientOpacity.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyClientOpacity); + + Button BtnExpandSetOn = new Button() + { + Text = "Expand On", + Size = new Size(300, 100), + Position = new Position(50, 800), + Margin = 10, + }; + Button BtnExpandSetOff = new Button() + { + Text = "Expand Off", + Size = new Size(300, 100), + Position = new Position(400, 800), + Margin = 10, + }; + Button BtnOpacitySetOpaque = new Button() + { + Text = "Opacity Opaque", + Size = new Size(300, 100), + Position = new Position(50, 1000), + Margin = 10, + }; + Button BtnOpacitySetTransparent = new Button() + { + Text = "Opacity Transparent", + Size = new Size(300, 100), + Position = new Position(400, 1000), + Margin = 10, + }; + Button BtnShow = new Button() + { + Text = "Show", + Size = new Size(200, 100), + Position = new Position(50, 1100), + Margin = 10, + }; + Button BtnHide = new Button() + { + Text = "Hide", + Size = new Size(200, 100), + Position = new Position(410, 1100), + Margin = 10, + }; + + BtnExpandSetOn.Clicked += BtnExpandSetOn_ClickEvent; + BtnExpandSetOff.Clicked += BtnExpandSetOff_ClickEvent; + BtnOpacitySetOpaque.Clicked += BtnOpacitySetOpaque_ClickEvent; + BtnOpacitySetTransparent.Clicked += BtnOpacitySetTransparent_ClickEvent; + BtnShow.Clicked += BtnSoftkeyClientShow_ClickEvent; + BtnHide.Clicked += BtnSoftkeyClientHide_ClickEvent; + + window.Add(BtnExpandSetOn); + window.Add(BtnExpandSetOff); + window.Add(BtnOpacitySetOpaque); + window.Add(BtnOpacitySetTransparent); + window.Add(BtnShow); + window.Add(BtnHide); + } + + private void BtnExpandSetOn_ClickEvent(object sender, ClickedEventArgs e) + { + softkeyClient.IsExpandable = true; + textSoftkeyClientExpand.Text = $"Expandable: {softkeyClient.IsExpandable}"; + } + + private void BtnExpandSetOff_ClickEvent(object sender, ClickedEventArgs e) + { + softkeyClient.IsExpandable = false; + textSoftkeyClientExpand.Text = $"Expandable: {softkeyClient.IsExpandable}"; + } + + private void BtnOpacitySetOpaque_ClickEvent(object sender, ClickedEventArgs e) + { + softkeyClient.IsOpaque = true; + textSoftkeyClientOpacity.Text = $"Opaque: {softkeyClient.IsOpaque}"; + } + + private void BtnOpacitySetTransparent_ClickEvent(object sender, ClickedEventArgs e) + { + softkeyClient.IsOpaque = false; + textSoftkeyClientOpacity.Text = $"Opaque: {softkeyClient.IsOpaque}"; + } + + private async Task ControlSoftKeyVisible(bool visible) + { + if (visible) + softkeyClient.Show(); + else + softkeyClient.Hide(); + await Task.Delay(50); + textSoftkeyClientVisible.Text = $"Visible: {softkeyClient.IsVisible}"; + } + + private void BtnSoftkeyClientShow_ClickEvent(object sender, ClickedEventArgs e) + { + _ = ControlSoftKeyVisible(true); + } + + private void BtnSoftkeyClientHide_ClickEvent(object sender, ClickedEventArgs e) + { + _ = ControlSoftKeyVisible(false); + } + + // ===================================================================== + // SoftkeyService + // ===================================================================== + + private void BtnSoftkeyService_ClickEvent(object sender, ClickedEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + window.WindowSize = new Size(500, 500); + window.WindowPosition = new Position(0, 700); + + RemoveMenuButtons(window); + + softkeyService = new SoftkeyService(tzShell, (IWindowProvider)window); + + textSoftkeyServiceVisible = new TextLabel($"Visible: None"); + textSoftkeyServiceVisible.Position = new Position(0, -100); + textSoftkeyServiceVisible.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyServiceVisible.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyServiceVisible.TextColor = Color.Blue; + textSoftkeyServiceVisible.PointSize = 12.0f; + textSoftkeyServiceVisible.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyServiceVisible.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyServiceVisible); + + textSoftkeyServiceExpand = new TextLabel($"Expand: None"); + textSoftkeyServiceExpand.Position = new Position(0, 0); + textSoftkeyServiceExpand.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyServiceExpand.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyServiceExpand.TextColor = Color.Blue; + textSoftkeyServiceExpand.PointSize = 12.0f; + textSoftkeyServiceExpand.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyServiceExpand.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyServiceExpand); + + textSoftkeyServiceOpacity = new TextLabel($"Opacity: None"); + textSoftkeyServiceOpacity.Position = new Position(0, 100); + textSoftkeyServiceOpacity.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyServiceOpacity.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyServiceOpacity.TextColor = Color.Blue; + textSoftkeyServiceOpacity.PointSize = 12.0f; + textSoftkeyServiceOpacity.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyServiceOpacity.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyServiceOpacity); + + Button BtnShow = new Button() + { + Text = "Show", + Size = new Size(200, 100), + Position = new Position(50, 800), + Margin = 10, + }; + Button BtnHide = new Button() + { + Text = "Hide", + Size = new Size(200, 100), + Position = new Position(410, 800), + Margin = 10, + }; + + window.Add(BtnShow); + window.Add(BtnHide); + + BtnShow.Clicked += BtnSoftkeyServiceShow_ClickEvent; + BtnHide.Clicked += BtnSoftkeyServiceHide_ClickEvent; + + softkeyService.VisibleChanged += OnSoftkeyServiceVisibleEvent; + softkeyService.ExpandChanged += OnSoftkeyServiceExpandEvent; + softkeyService.OpacityChanged += OnSoftkeyServiceOpacityEvent; + } + + public void OnSoftkeyServiceVisibleEvent(object sender, SoftkeyVisibleChangedEventArgs e) + { + SoftkeyService obj = (SoftkeyService)sender; + textSoftkeyServiceVisible.Text = $"Visible: {e.IsVisible}"; + if (e.IsVisible) + { + obj.Show(); + } + else + { + obj.Hide(); + } + } + + public void OnSoftkeyServiceExpandEvent(object sender, SoftkeyExpandChangedEventArgs e) + { + textSoftkeyServiceExpand.Text = $"Expand: {e.IsExpandable}"; + } + + public void OnSoftkeyServiceOpacityEvent(object sender, SoftkeyOpacityChangedEventArgs e) + { + textSoftkeyServiceOpacity.Text = $"Opacity: {e.IsOpaque}"; + } + + private void BtnSoftkeyServiceShow_ClickEvent(object sender, ClickedEventArgs e) + { + softkeyService.Show(); + } + + private void BtnSoftkeyServiceHide_ClickEvent(object sender, ClickedEventArgs e) + { + softkeyService.Hide(); + } + + // ===================================================================== + // ScreensaverService + // ===================================================================== + + private void BtnScreensaverService_ClickEvent(object sender, ClickedEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + window.WindowSize = new Size(1920, 1080); + window.WindowPosition = new Position(0, 0); + + RemoveMenuButtons(window); + + screensaverService = new ScreensaverService(tzShell, (IWindowProvider)window); + + textScreensaverServiceTitle = new TextLabel($"Screen Saver"); + textScreensaverServiceTitle.Position = new Position(0, 0); + textScreensaverServiceTitle.HorizontalAlignment = HorizontalAlignment.Center; + textScreensaverServiceTitle.VerticalAlignment = VerticalAlignment.Center; + textScreensaverServiceTitle.TextColor = Color.Blue; + textScreensaverServiceTitle.PointSize = 12.0f; + textScreensaverServiceTitle.HeightResizePolicy = ResizePolicyType.FillToParent; + textScreensaverServiceTitle.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textScreensaverServiceTitle); + } + + // ===================================================================== + // Helper + // ===================================================================== + + private void RemoveMenuButtons(Window window) + { + window.Remove(BtnService); + window.Remove(BtnClient); + window.Remove(BtnScreensaverService); + window.Remove(BtnSoftkeyService); + window.Remove(BtnSoftkeyClient); + } + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/test/Tizen.WindowSystem.Samples/Tizen.WindowSystem.Samples.csproj b/test/Tizen.WindowSystem.Samples/Tizen.WindowSystem.Samples.csproj new file mode 100644 index 00000000000..734fc2a8091 --- /dev/null +++ b/test/Tizen.WindowSystem.Samples/Tizen.WindowSystem.Samples.csproj @@ -0,0 +1,25 @@ + + + + Exe + net8.0-tizen10.0 + + + + portable + + + None + + + + + + + + + + + + + diff --git a/test/Tizen.WindowSystem.Samples/shared/res/Tizen.WindowSystem.Samples.png b/test/Tizen.WindowSystem.Samples/shared/res/Tizen.WindowSystem.Samples.png new file mode 100644 index 00000000000..a2839141439 Binary files /dev/null and b/test/Tizen.WindowSystem.Samples/shared/res/Tizen.WindowSystem.Samples.png differ diff --git a/test/Tizen.WindowSystem.Samples/tizen-manifest.xml b/test/Tizen.WindowSystem.Samples/tizen-manifest.xml new file mode 100644 index 00000000000..706562f6615 --- /dev/null +++ b/test/Tizen.WindowSystem.Samples/tizen-manifest.xml @@ -0,0 +1,18 @@ + + + + + + Tizen.WindowSystem.Samples.png + + + + + + http://tizen.org/privilege/windowsystem.admin + http://tizen.org/privilege/gesturegrab + http://tizen.org/privilege/inputgenerator + + + +