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/Tizen.WindowSystem.sln b/src/Tizen.WindowSystem/Tizen.WindowSystem.sln new file mode 100644 index 00000000000..265963c6483 --- /dev/null +++ b/src/Tizen.WindowSystem/Tizen.WindowSystem.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.WindowSystem", "Tizen.WindowSystem.csproj", "{4736851E-294E-4EBA-9DF1-79D2D78176B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4736851E-294E-4EBA-9DF1-79D2D78176B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4736851E-294E-4EBA-9DF1-79D2D78176B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4736851E-294E-4EBA-9DF1-79D2D78176B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4736851E-294E-4EBA-9DF1-79D2D78176B9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0EBD4ED2-63CC-4DCC-A57A-68DBC451B9F2} + EndGlobalSection +EndGlobal diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.EcoreWl2.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.EcoreWl2.cs new file mode 100644 index 00000000000..1cba9e2e091 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/Interop/Interop.EcoreWl2.cs @@ -0,0 +1,17 @@ +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); + } + } +} diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.InputGenerator.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.InputGenerator.cs new file mode 100644 index 00000000000..afade995dc6 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/Interop/Interop.InputGenerator.cs @@ -0,0 +1,89 @@ +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 IntPtr Init(int devType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator_with_name")] + internal static extern IntPtr InitWithName(int devType, string devName); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator_with_sync")] + internal static extern IntPtr SyncInit(int 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(IntPtr inputGenHandler, string keyName, int pressed); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_pointer")] + internal static extern ErrorCode GeneratePointer(IntPtr 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(IntPtr inputGenHandler, int wheelType, int value); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_touch")] + internal static extern ErrorCode GenerateTouch(IntPtr 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(IntPtr inputGenHandler, int idx, int touchType, int x, int y, double radius_x, double radius_y, double pressure, double angle, double palm); + + // Enumeration of input device types. + // The device type may be used overlapped. + internal enum DeviceType + { + None = 0x0, + Touchscreen = (1 << 0), + Keyboard = (1 << 1), + Pointer = (1 << 2), + All = Touchscreen | Keyboard, // Keyboard and Touchscreen + } + + // Enumeration of touch event types + internal enum TouchType + { + None, + Begin, + Update, + End, + } + + // Enumeration of pointer event types + internal enum PointerType + { + Down, + Up, + Move, + } + + // Enumeration of pointer wheel event types + internal enum PointerWheelType + { + Vertical, + Horizontal, + } + + 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/internal/Interop/Interop.InputGesture.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.InputGesture.cs new file mode 100644 index 00000000000..5338f26ce8d --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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.WindowSystem"; + + [DllImport(lib, EntryPoint = "efl_util_gesture_initialize")] + internal static extern IntPtr 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(IntPtr gestureHandler, int fingers, int edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_free")] + internal static extern ErrorCode EdgeSwipeFree(IntPtr gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_size_set")] + internal static extern ErrorCode EdgeSwipeSizeSet(IntPtr gestureData, int edgeSize, int startPoint, int endPoint); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_new")] + internal static extern IntPtr EdgeDragNew(IntPtr gestureHandler, int fingers, int edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_free")] + internal static extern ErrorCode EdgeDragFree(IntPtr gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_size_set")] + internal static extern ErrorCode EdgeDragSizeSet(IntPtr gestureData, int edgeSize, int startPoint, int endPoint); + + [DllImport(lib, EntryPoint = "efl_util_gesture_tap_new")] + internal static extern IntPtr TapNew(IntPtr gestureHandler, int fingers, int repeats); + + [DllImport(lib, EntryPoint = "efl_util_gesture_tap_free")] + internal static extern ErrorCode TapFree(IntPtr gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_palm_cover_new")] + internal static extern IntPtr PalmCoverNew(IntPtr gestureHandler); + + [DllImport(lib, EntryPoint = "efl_util_gesture_palm_cover_free")] + internal static extern ErrorCode PalmCoverFree(IntPtr gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_grab")] + internal static extern ErrorCode GestureGrab(IntPtr gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_grab_mode_set")] + internal static extern ErrorCode SetGestureGrabMode(IntPtr gestureHandler, IntPtr gestureData, int mode); + + [DllImport(lib, EntryPoint = "efl_util_gesture_ungrab")] + internal static extern ErrorCode GestureUngrab(IntPtr gestureHandler, IntPtr gestureData); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_swipe_cb_set")] + internal static extern ErrorCode SetEdgeSwipeCb(IntPtr gestureHandler, EdgeSwipeCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void EdgeSwipeCb(IntPtr usergestureData, int mode, int fingers, int sx, int sy, int edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_edge_drag_cb_set")] + internal static extern ErrorCode SetEdgeDragCb(IntPtr gestureHandler, EdgeDragCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void EdgeDragCb(IntPtr usergestureData, int mode, int fingers, int cx, int cy, int edge); + + [DllImport(lib, EntryPoint = "efl_util_gesture_tap_cb_set")] + internal static extern ErrorCode SetTapCb(IntPtr gestureHandler, TapCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void TapCb(IntPtr usergestureData, int mode, int fingers, int repeats); + + [DllImport(lib, EntryPoint = "efl_util_gesture_palm_cover_cb_set")] + internal static extern ErrorCode SetPalmCoverCb(IntPtr gestureHandler, PalmCoverCb cbFunc, IntPtr usergestureData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void PalmCoverCb(IntPtr usergestureData, int 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/internal/Interop/Interop.KVMService.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.KVMService.cs new file mode 100644 index 00000000000..53b7b0f3b58 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr Create(IntPtr 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(IntPtr kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_cancel_drag")] + internal static extern int CancelDrag(IntPtr kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_receive_drag_data")] + internal static extern int ReceiveDragData(IntPtr kvmService, string mimeType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_get_source_mimetypes")] + internal static extern int GetSourceMimetypes( + IntPtr kvmService, + out string[] mimeTypes, + out int count); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_set")] + internal static extern int SetSecondarySelection(IntPtr kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_unset")] + internal static extern int UnsetSecondarySelection(IntPtr kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop_target")] + internal static extern int PerformDropTarget(IntPtr 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(IntPtr 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(IntPtr kvmService, KVMDragEndEventCallback func, IntPtr data); + } + } +} diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.QuickPanelClient.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.QuickPanelClient.cs new file mode 100644 index 00000000000..ad72455c58a --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr CreateWithType(IntPtr tzsh, uint win, int 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(IntPtr qpClient, out int vis); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_scrollable_state_get")] + internal static extern int GetScrollableState(IntPtr qpClient, out int scroll); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_scrollable_state_set")] + internal static extern int SetScrollableState(IntPtr qpClient, int scroll); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_orientation_get")] + internal static extern int GetOrientation(IntPtr qpClient, out int orientation); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_show")] + internal static extern int Show(IntPtr qpClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_hide")] + internal static extern int Hide(IntPtr 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(IntPtr qpClient, int type, QuickPanelEventCallback func, IntPtr data); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_event_handler_del")] + internal static extern int DelEventHandler(IntPtr 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/internal/Interop/Interop.QuickPanelService.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.QuickPanelService.cs new file mode 100644 index 00000000000..11b378dc181 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr CreateWithType(IntPtr tzsh, uint win, int 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(IntPtr service, out int type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_show")] + internal static extern int Show(IntPtr service); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_hide")] + internal static extern int Hide(IntPtr service); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_content_region_set")] + internal static extern int SetContentRegion(IntPtr service, uint angle, IntPtr region); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_handler_region_set")] + internal static extern int SetHandlerRegion(IntPtr service, uint angle, IntPtr region); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_effect_type_set")] + internal static extern int SetEffectType(IntPtr service, int type); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_quickpanel_service_scroll_lock")] + internal static extern int LockScroll(IntPtr service, bool locked); + } + } +} diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.ScreensaverService.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.ScreensaverService.cs new file mode 100644 index 00000000000..f1f0b33dd94 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr Create(IntPtr 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/internal/Interop/Interop.SoftkeyClient.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.SoftkeyClient.cs new file mode 100644 index 00000000000..125c09236d8 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/Interop/Interop.SoftkeyClient.cs @@ -0,0 +1,62 @@ +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 IntPtr Create(IntPtr 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(IntPtr softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_hide")] + internal static extern int Hide(IntPtr softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_visible_state_get")] + internal static extern int GetVisibleState(IntPtr softkeyClient, out int visible); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_expand_state_set")] + internal static extern int SetExpandState(IntPtr softkeyClient, int expand); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_expand_state_get")] + internal static extern int GetExpandState(IntPtr softkeyClient, out int expand); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_opacity_state_set")] + internal static extern int SetOpacityState(IntPtr softkeyClient, int opacity); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_opacity_state_get")] + internal static extern int GetOpacityState(IntPtr softkeyClient, out int opacity); + + internal enum VisibleState + { + Unknown = 0x0, + Shown = 0x1, + Hidden = 0x2, + } + + internal enum ExpandState + { + Unknown = 0x0, + On = 0x1, + Off = 0x2, + } + + internal enum OpacityState + { + Unknown = 0x0, + Opaque = 0x1, + Transparent = 0x2, + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.SoftkeyService.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.SoftkeyService.cs new file mode 100644 index 00000000000..626b8b8b401 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr Create(IntPtr 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(IntPtr softkeyService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_hide")] + internal static extern int Hide(IntPtr 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(IntPtr 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(IntPtr 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(IntPtr 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/internal/Interop/Interop.TaskbarService.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.TaskbarService.cs new file mode 100755 index 00000000000..bc1ea025c82 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr Create(IntPtr 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(IntPtr taskbarService, int placeType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_size_set")] + internal static extern int SetSize(IntPtr taskbarService, uint width, uint height); + } + } +} diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.TizenRegion.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.TizenRegion.cs new file mode 100644 index 00000000000..1db22c59ef0 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 TizenRegion + { + const string lib = "libtzsh_common.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_region_create")] + internal static extern IntPtr Create(IntPtr 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(IntPtr region, int x, int y, int w, int h); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_region_subtract")] + internal static extern int Subtract(IntPtr region, int x, int y, int w, int h); + } + } +} diff --git a/src/Tizen.WindowSystem/src/internal/Interop/Interop.TizenShell.cs b/src/Tizen.WindowSystem/src/internal/Interop/Interop.TizenShell.cs new file mode 100644 index 00000000000..b1f0022d335 --- /dev/null +++ b/src/Tizen.WindowSystem/src/internal/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 IntPtr 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(IntPtr 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/public/EdgeDragEventArgs.cs b/src/Tizen.WindowSystem/src/public/EdgeDragEventArgs.cs new file mode 100644 index 00000000000..0839fbcf675 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/EdgeDragEventArgs.cs @@ -0,0 +1,58 @@ +/* + * 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 EdgeDrag event. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class EdgeDragEventArgs : EventArgs + { + internal EdgeDragEventArgs(int mode, int fingers, int cx, int cy, int edge) + { + Mode = mode; + Fingers = fingers; + Cx = cx; + Cy = cy; + Edge = edge; + } + /// + /// Mode + /// + public int Mode{ get; internal set; } + /// + /// Fingers + /// + public int Fingers{ get; internal set;} + /// + /// Cx + /// + public int Cx{ get; internal set;} + /// + /// Cy + /// + public int Cy{ get; internal set;} + /// + /// Edge + /// + public int Edge{ get; internal set;} + } +} diff --git a/src/Tizen.WindowSystem/src/public/EdgeSwipeEventArgs.cs b/src/Tizen.WindowSystem/src/public/EdgeSwipeEventArgs.cs new file mode 100644 index 00000000000..554ae38b3ac --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/EdgeSwipeEventArgs.cs @@ -0,0 +1,58 @@ +/* + * 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 EdgeSwipe event. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class EdgeSwipeEventArgs : EventArgs + { + internal EdgeSwipeEventArgs(int mode, int fingers, int sx, int sy, int edge) + { + Mode = mode; + Fingers = fingers; + Sx = sx; + Sy = sy; + Edge = edge; + } + /// + /// Mode + /// + public int Mode{ get; internal set; } + /// + /// Fingers + /// + public int Fingers{ get; internal set;} + /// + /// Sx + /// + public int Sx{ get; internal set;} + /// + /// Sy + /// + public int Sy{ get; internal set;} + /// + /// Edge + /// + public int Edge{ get; internal set;} + } +} diff --git a/src/Tizen.WindowSystem/src/public/InputGenerator.cs b/src/Tizen.WindowSystem/src/public/InputGenerator.cs new file mode 100644 index 00000000000..870fa7f5ec9 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/InputGenerator.cs @@ -0,0 +1,269 @@ +/* + * 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 IntPtr _handler; + private bool disposed = false; + + /// + /// Enumeration of input device types. + /// + public enum DeviceType + { + /// + /// None. + /// + None = Interop.InputGenerator.DeviceType.None, + + /// + /// Touchscreen device. + /// + Touchscreen = Interop.InputGenerator.DeviceType.Touchscreen, + + /// + /// Keyboard device. + /// + Keyboard = Interop.InputGenerator.DeviceType.Keyboard, + + /// + /// Pointer device. + /// + Pointer = Interop.InputGenerator.DeviceType.Pointer, + + /// + /// Keyboard and Touchscreen device. + /// + All = Interop.InputGenerator.DeviceType.All, + } + + /// + /// Enumeration of touch event types. + /// + public enum TouchType + { + /// + /// None. + /// + None = Interop.InputGenerator.TouchType.None, + + /// + /// Touch begin. + /// + Begin = Interop.InputGenerator.TouchType.Begin, + + /// + /// Touch move. + /// + Update = Interop.InputGenerator.TouchType.Update, + + /// + /// Touch end. + /// + End = Interop.InputGenerator.TouchType.End, + } + + /// + /// Enumeration of pointer event types. + /// + public enum PointerType + { + /// + /// Pointer down. + /// + Down = Interop.InputGenerator.PointerType.Down, + + /// + /// Pointer up. + /// + Up = Interop.InputGenerator.PointerType.Up, + + /// + /// Pointer move. + /// + Move = Interop.InputGenerator.PointerType.Move, + } + + /// + /// Enumeration of pointer wheel event types. + /// + public enum PointerWheelType + { + /// + /// Vertical wheel. + /// + Vertical = Interop.InputGenerator.PointerWheelType.Vertical, + + /// + /// Horizontal wheel. + /// + Horizontal = Interop.InputGenerator.PointerWheelType.Horizontal, + } + + internal void ErrorCodeThrow(Interop.InputGenerator.ErrorCode error) + { + switch (error) + { + case Interop.InputGenerator.ErrorCode.None : + return; + case Interop.InputGenerator.ErrorCode.OutOfMemory : + throw new Tizen.Applications.Exceptions.OutOfMemoryException("Out of Memory"); + case Interop.InputGenerator.ErrorCode.InvalidParameter : + throw new ArgumentException("Invalid Parameter"); + case Interop.InputGenerator.ErrorCode.PermissionDenied : + throw new Tizen.Applications.Exceptions.PermissionDeniedException("Permission denied"); + case Interop.InputGenerator.ErrorCode.NotSupported : + throw new NotSupportedException("Not Supported"); + case Interop.InputGenerator.ErrorCode.NoService : + throw new InvalidOperationException("No Service"); + default : + throw new InvalidOperationException("Unknown Error"); + } + } + + /// + /// Creates a new InputGenerator. + /// + /// The Device type of the new input generator. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public InputGenerator(DeviceType devType) + { + if (devType == DeviceType.None) + { + throw new ArgumentException("Invalid device type"); + } + + _handler = Interop.InputGenerator.Init((int)devType); + } + + public InputGenerator(DeviceType devType, string name, bool sync = false) + { + if (devType == DeviceType.None) + { + throw new ArgumentException("Invalid device type"); + } + + if (sync) + _handler = Interop.InputGenerator.SyncInit((int)devType, name); + else + _handler = Interop.InputGenerator.InitWithName((int)devType, name); + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (_handler != IntPtr.Zero) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.Deinit(_handler); + ErrorCodeThrow(res); + _handler = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Generate given key. + /// + /// The key name to generate. + /// Set the key is pressed or released. + public void GenerateKey(string keyName, int pressed) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateKey(_handler, keyName, pressed); + ErrorCodeThrow(res); + } + + /// + /// Generate given pointer. + /// + /// The pointer button to generate. + /// The type of the pointer. + /// X coordinate of the pointer. + /// Y coordinate of the pointer. + public void GeneratePointer(int buttons, PointerType pointerType, int x, int y) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GeneratePointer(_handler, buttons, (int)pointerType, x, y); + ErrorCodeThrow(res); + } + + /// + /// Generate given wheel. + /// + /// The wheel type to generate. + /// The value of the wheel. + public void GenerateWheel(PointerWheelType wheelType, int value) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateWheel(_handler, (int)wheelType, value); + ErrorCodeThrow(res); + } + + /// + /// Generate given touch. + /// + /// The touch index to generate. + /// The touch type to generate. + /// X coordinate of the touch. + /// Y coordinate of the touch. + public void GenerateTouch(int idx, TouchType touchType, int x, int y) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateTouch(_handler, idx, (int) touchType, x, y); + ErrorCodeThrow(res); + } + + /// + /// Generate given touch with axis. + /// + /// The touch index to generate. + /// The touch type 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 GenerateTouchAxis(int idx, TouchType touchType, int x, int y, double radius_x, double radius_y, double pressure, double angle, double palm) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateTouchAxis(_handler, idx, (int) touchType, x, y, radius_x, radius_y, pressure, angle, palm); + ErrorCodeThrow(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/InputGesture.cs b/src/Tizen.WindowSystem/src/public/InputGesture.cs new file mode 100644 index 00000000000..ee8e0c381f4 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/InputGesture.cs @@ -0,0 +1,590 @@ +/* + * 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 static Tizen.WindowSystem.Interop.InputGesture; + +namespace Tizen.WindowSystem +{ + /// + /// Enumeration of gesture modes. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureMode + { + /// + /// None. + /// + None, + + /// + /// Begin. + /// + Begin, + + /// + /// Update. + /// + Update, + + /// + /// End. + /// + End, + + /// + /// Done. + /// + Done, + } + + /// + /// Enumeration of gesture edges. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureEdge + { + /// + /// edge none. + /// + None, + + /// + /// edge top. + /// + Top, + + /// + /// edge right. + /// + Right, + + /// + /// edge bottom. + /// + Bottom, + + /// + /// edge left. + /// + Left, + } + + /// + /// Enumeration of gesture edge sizes. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureEdgeSize + { + /// + /// edge size none. + /// + None, + + /// + /// edge size full. + /// + Full, + + /// + /// edge size partial. + /// + Partial, + } + + /// + /// Enumeration of gesture grab modes. + /// + /// This enum is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public enum GestureGrabMode + { + /// + /// mode none. + /// + None, + + /// + /// mode exclusive. + /// + Exclusive, + + /// + /// mode shared. + /// + Shared, + } + + /// + /// Class for the Tizen Input Gesture. + /// + /// + /// http://tizen.org/privilege/gesturegrab + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class InputGesture : IDisposable + { + private IntPtr _handler; + private bool disposed = false; + + private event EventHandler _edgeSwipeEventHandler; + private EdgeSwipeCb _edgeSwipeDelegate; + + private event EventHandler _edgeDragEventHandler; + private EdgeDragCb _edgeDragDelegate; + + private event EventHandler _tapEventHandler; + private TapCb _tapDelegate; + + private event EventHandler _palmCoverEventHandler; + private PalmCoverCb _palmCoverDelegate; + + internal void ErrorCodeThrow(Interop.InputGesture.ErrorCode error) + { + switch (error) + { + case Interop.InputGesture.ErrorCode.None : + return; + case Interop.InputGesture.ErrorCode.OutOfMemory : + throw new Tizen.Applications.Exceptions.OutOfMemoryException("Out of Memory"); + case Interop.InputGesture.ErrorCode.InvalidParameter : + throw new ArgumentException("Invalid Parameter"); + case Interop.InputGesture.ErrorCode.PermissionDenied : + throw new Tizen.Applications.Exceptions.PermissionDeniedException("Permission denied"); + case Interop.InputGesture.ErrorCode.NotSupported : + throw new NotSupportedException("Not Supported"); + default : + throw new InvalidOperationException("Unknown Error"); + } + } + + /// + /// 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 == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorCodeThrow((Interop.InputGesture.ErrorCode)err); + } + Log.Debug(LogTag, "InputGesture Created"); + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (disposed) + { + return; + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + if (_handler != global::System.IntPtr.Zero) + { + Interop.InputGesture.ErrorCode res = Interop.InputGesture.Deinitialize(_handler); + ErrorCodeThrow(res); + _handler = IntPtr.Zero; + } + + disposed = true; + } + + /// + /// Generates a edge swipe gesture's grab info handle + /// + /// The number of fingers + /// The position of edge + /// The edge swipe gesture data handle + /// Thrown when failed of invalid argument. + /// Thrown when the memory is not enough to allocate. + public IntPtr CreateEdgeSwipeData(int fingers, GestureEdge edge) + { + IntPtr edgeSwipeG = IntPtr.Zero; + edgeSwipeG = Interop.InputGesture.EdgeSwipeNew(_handler, fingers, (int)edge); + if (edgeSwipeG == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorCodeThrow((Interop.InputGesture.ErrorCode)err); + } + Log.Debug(LogTag, "CreateEdgeSwipeData" + "fingers: " + fingers, "edge: " + (int)edge); + return edgeSwipeG; + } + + /// + /// Frees a memory of edge swipe gesture's grab info handle + /// + /// The edge swipe gesture data handle + /// Thrown when failed of invalid argument. + public void ReleaseEdgeSwipeData(IntPtr data) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("EdgeSwipeData is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.EdgeSwipeFree(_handler, data); + ErrorCodeThrow(res); + Log.Debug(LogTag, "ReleaseEdgeSwipeData"); + } + + /// + /// Sets a specific size of edge for edge swipe gesture + /// + /// The edge swipe gesture data handle + /// The enum of gesture edge size + /// The start point of edge area + /// The end point of edge area + /// Thrown when failed of invalid argument. + public void SetEdgeSwipeSize(IntPtr data, GestureEdgeSize edgeSize, int startPoint, int endPoint) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("EdgeSwipeData is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.EdgeSwipeSizeSet(data, (int)edgeSize, startPoint, endPoint); + ErrorCodeThrow(res); + Log.Debug(LogTag, "SetEdgeSwipeSize" + "size: " + (int)edgeSize + "startPoint: " + startPoint + "endPoint: " + endPoint); + } + + /// + /// Generates a edge drag gesture's grab info handle + /// + /// The number of fingers + /// The position of edge + /// The edge drag gesture data handle + /// Thrown when failed of invalid argument. + /// Thrown when the memory is not enough to allocate. + public IntPtr CreateEdgeDragData(int fingers, GestureEdge edge) + { + IntPtr edgeDragG = IntPtr.Zero; + edgeDragG = Interop.InputGesture.EdgeDragNew(_handler, fingers, (int)edge); + if (edgeDragG == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorCodeThrow((Interop.InputGesture.ErrorCode)err); + } + Log.Debug(LogTag, "CreateEdgeDragData" + "fingers: " + fingers, "edge: " + (int)edge); + return edgeDragG; + } + + /// + /// Frees a memory of edge drag gesture's grab info handle + /// + /// The edge drag gesture data handle + /// Thrown when failed of invalid argument. + public void ReleaseEdgeDrageData(IntPtr data) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("EdgeDragData is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.EdgeDragFree(_handler, data); + ErrorCodeThrow(res); + Log.Debug(LogTag, "ReleaseEdgeDrageData"); + } + + /// + /// Sets a specific size of edge for edge drag gesture + /// + /// The edge drag gesture data handle + /// The enum of gesture edge size + /// The start point of edge area + /// The end point of edge area + /// Thrown when failed of invalid argument. + public void SetEdgeDragSize(IntPtr data, GestureEdgeSize edgeSize, int startPoint, int endPoint) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("EdgeDragData is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.EdgeDragSizeSet(data, (int)edgeSize, startPoint, endPoint); + ErrorCodeThrow(res); + Log.Debug(LogTag, "SetEdgeDragSize" + "size: " + (int)edgeSize + "startPoint: " + startPoint + "endPoint: " + endPoint); + } + + /// + /// Generates a tap gesture's grab info handle + /// + /// The number of fingers + /// The number of repeats + /// The tap gesture data handle + /// Thrown when failed of invalid argument. + /// Thrown when the memory is not enough to allocate. + public IntPtr CreateTapData(int fingers, int repeats) + { + IntPtr tapG = IntPtr.Zero; + tapG = Interop.InputGesture.TapNew(_handler, fingers, repeats); + if (tapG == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorCodeThrow((Interop.InputGesture.ErrorCode)err); + } + Log.Debug(LogTag, "CreateTapData" + "fingers: " + fingers, "repeats: " + repeats); + return tapG; + } + + /// + /// Frees a memory of tap gesture's grab info handle + /// + /// The tap gesture data handle + /// Thrown when failed of invalid argument. + public void ReleaseTapData(IntPtr data) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("tapData is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.TapFree(_handler, data); + ErrorCodeThrow(res); + Log.Debug(LogTag, "ReleaseTapData"); + } + + /// + /// Generates a palm cover gesture's grab info handle + /// + /// The palm cover gesture data handle + /// Thrown when failed of invalid argument. + /// Thrown when the memory is not enough to allocate. + public IntPtr CreatePalmCoverData() + { + IntPtr palmCoverG = IntPtr.Zero; + palmCoverG = Interop.InputGesture.PalmCoverNew(_handler); + if (palmCoverG == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorCodeThrow((Interop.InputGesture.ErrorCode)err); + } + Log.Debug(LogTag, "CreatePalmCoverData"); + return palmCoverG; + } + + /// + /// Frees a memory of palm cover gesture's grab info handle + /// + /// The palm cover gesture data handle + /// Thrown when failed of invalid argument. + public void ReleasePalmCoverData(IntPtr data) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("palmCoverData is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.PalmCoverFree(_handler, data); + ErrorCodeThrow(res); + Log.Debug(LogTag, "ReleasePalmCoverData"); + } + + /// + /// Grabs a global gesture + /// + /// gesture data to grab + /// Thrown when failed of invalid argument. + public void GrabGesture(IntPtr data) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("gesture data is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.GestureGrab(_handler, data); + ErrorCodeThrow(res); + Log.Debug(LogTag, "GrabGesture"); + } + + /// + /// Sets grab mode of global gesture + /// + /// gesture data to grab + /// The mode of gesture grab + /// Thrown when failed of invalid argument. + public void SetGestureGrabMode(IntPtr data, GestureGrabMode mode) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("gesture data is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetGestureGrabMode(_handler, data, (int)mode); + ErrorCodeThrow(res); + Log.Debug(LogTag, "SetGestureGrabMode"); + } + + /// + /// Ungrabs a global gesture. + /// + /// gesture data to ungrab + /// Thrown when failed of invalid argument. + public void UngrabGesture(IntPtr data) + { + if (data == IntPtr.Zero) + { + throw new ArgumentException("gesture data is not valid."); + } + Interop.InputGesture.ErrorCode res = Interop.InputGesture.GestureUngrab(_handler, data); + ErrorCodeThrow(res); + Log.Debug(LogTag, "UngrabGesture"); + } + + /// + /// Emits the event when the edge swipe event comes + /// + /// Thrown when failed of invalid argument. + public event EventHandler EdgeSwipeEventHandler + { + add + { + if (_edgeSwipeEventHandler == null) + { + _edgeSwipeDelegate = (IntPtr userData, int mode, int fingers, int sx, int sy, int edge) => + { + EdgeSwipeEventArgs args = new EdgeSwipeEventArgs(mode, fingers, sx, sy, edge); + Log.Debug(LogTag, "EdgeSwipe Event received. mode: " + mode + ", fingers: " + fingers); + _edgeSwipeEventHandler?.Invoke(null, args); + }; + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetEdgeSwipeCb(_handler, _edgeSwipeDelegate, IntPtr.Zero); + ErrorCodeThrow(res); + } + + _edgeSwipeEventHandler += value; + } + remove + { + _edgeSwipeEventHandler -= value; + if (_edgeSwipeEventHandler == null) + { + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetEdgeSwipeCb(_handler, null, IntPtr.Zero); + ErrorCodeThrow(res); + } + } + } + + /// + /// Emits the event when the edge drag event comes + /// + /// Thrown when failed of invalid argument. + public event EventHandler EdgeDragEventHandler + { + add + { + if (_edgeDragEventHandler == null) + { + _edgeDragDelegate = (IntPtr userData, int mode, int fingers, int cx, int cy, int edge) => + { + EdgeDragEventArgs args = new EdgeDragEventArgs(mode, fingers, cx, cy, edge); + Log.Debug(LogTag, "EdgeDrag Event received. mode: " + mode + ", fingers: " + fingers); + _edgeDragEventHandler?.Invoke(null, args); + }; + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetEdgeDragCb(_handler, _edgeDragDelegate, IntPtr.Zero); + ErrorCodeThrow(res); + } + + _edgeDragEventHandler += value; + } + remove + { + _edgeDragEventHandler -= value; + if (_edgeDragEventHandler == null) + { + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetEdgeDragCb(_handler, null, IntPtr.Zero); + ErrorCodeThrow(res); + } + } + } + + /// + /// Emits the event when the tap event comes + /// + /// Thrown when failed of invalid argument. + public event EventHandler TapEventHandler + { + add + { + if (_tapEventHandler == null) + { + _tapDelegate = (IntPtr userData, int mode, int fingers, int repeats) => + { + TapEventArgs args = new TapEventArgs(mode, fingers, repeats); + Log.Debug(LogTag, "Tap Event received. mode: " + mode + ", fingers: " + fingers + ", repeats: " + repeats); + _tapEventHandler?.Invoke(null, args); + }; + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetTapCb(_handler, _tapDelegate, IntPtr.Zero); + ErrorCodeThrow(res); + } + + _tapEventHandler += value; + } + remove + { + _tapEventHandler -= value; + if (_tapEventHandler == null) + { + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetTapCb(_handler, null, IntPtr.Zero); + ErrorCodeThrow(res); + } + } + } + /// + /// Emits the event when the palm cover event comes + /// + /// Thrown when failed of invalid argument. + public event EventHandler PalmCoverEventHandler + { + add + { + if (_palmCoverEventHandler == null) + { + _palmCoverDelegate = (IntPtr userData, int mode, int duration, int cx, int cy, int size, double pressure) => + { + PalmCoverEventArgs args = new PalmCoverEventArgs(mode, duration, cx, cy, size, pressure); + Log.Debug(LogTag, "PalmCover Event received. mode: " + mode + ", duration: " + duration); + _palmCoverEventHandler?.Invoke(null, args); + }; + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetPalmCoverCb(_handler, _palmCoverDelegate, IntPtr.Zero); + ErrorCodeThrow(res); + } + _palmCoverEventHandler += value; + } + remove + { + _palmCoverEventHandler -= value; + if (_palmCoverEventHandler == null) + { + Interop.InputGesture.ErrorCode res = Interop.InputGesture.SetPalmCoverCb(_handler, null, IntPtr.Zero); + ErrorCodeThrow(res); + } + } + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/KVMService.cs b/src/Tizen.WindowSystem/src/public/KVMService.cs new file mode 100644 index 00000000000..7176ff3258b --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/KVMService.cs @@ -0,0 +1,278 @@ +/* + * 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 + { + private TizenShell _tzsh; + private IntPtr _kvmService; + private int _tzshWin; + private bool disposed = false; + + private Interop.KVMService.KVMDragStartEventCallback _onDragStarted; + private Interop.KVMService.KVMDragEndEventCallback _onDragEnded; + + private event EventHandler _dragStarted; + private event EventHandler _dragEnded; + + + /// + /// Drop target type of PerformDrop request of KVM Service. + /// + public enum DropTarget + { + /// + /// Drop to KVM Service window self. + /// + KVMServiceWin = 0, + /// + /// Drop to the window that under pointer. + /// + UnderPointer = 1, + }; + + /// + /// 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.GetNativeHandle() == IntPtr.Zero) + { + 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.GetNativeHandle(), (uint)_tzshWin); + if (_kvmService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (_kvmService != IntPtr.Zero) + { + int res = Interop.KVMService.Destroy(_kvmService); + _kvmService = IntPtr.Zero; + } + 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); + _tzsh.ErrorCodeThrow(res); + } + _dragStarted += value; + } + remove + { + _dragStarted -= value; + if (_dragStarted == null) + { + int res = Interop.KVMService.SetDragStartEventHandler(_kvmService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + _dragEnded += value; + } + remove + { + _dragEnded -= value; + if (_dragEnded == null) + { + int res = Interop.KVMService.SetDragEndEventHandler(_kvmService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + } + } + + private void OnDragStarted(IntPtr data, IntPtr softkeyService) + { + _dragStarted?.Invoke(this, EventArgs.Empty); + } + + private 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); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to cancel current drag. + /// + /// Thrown when failed of invalid argument. + public void CancelDrag() + { + int res = Interop.KVMService.CancelDrag(_kvmService); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to receive the mimetype list of drag source. + /// + /// + /// The list of mimetype. + /// If there are no mimetype, returns null. + /// + /// Thrown when failed of invalid argument. + public List GetSourceMimetypes() + { + int res = Interop.KVMService.GetSourceMimetypes(_kvmService, out string[] mimetypes, out int mimeTypeCount); + _tzsh.ErrorCodeThrow(res); + + if (mimetypes == null) return null; + return new List(mimetypes); + } + + /// + /// Requests to set KVM window as secondary selection window. + /// The request name has typo and will remove soon. + /// Please use SetSecondarySelection. + /// + /// Thrown when failed of invalid argument. + public void SetSecondarySelction() + { + SetSecondarySelection(); + } + + /// + /// Requests to unset secondary selection window of KVM window. + /// The request name has typo and will remove soon. + /// Please use UnsetSecondarySelection. + /// + /// Thrown when failed of invalid argument. + public void UnsetSecondarySelction() + { + UnsetSecondarySelection(); + } + + /// + /// Requests to set KVM window as secondary selection window. + /// + /// Thrown when failed of invalid argument. + public void SetSecondarySelection() + { + int res = Interop.KVMService.SetSecondarySelection(_kvmService); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/PalmCoverEventArgs.cs b/src/Tizen.WindowSystem/src/public/PalmCoverEventArgs.cs new file mode 100644 index 00000000000..1fcf2f13f85 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/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(int mode, int duration, int cx, int cy, int size, double pressure) + { + Mode = mode; + Duration = duration; + Cx = cx; + Cy = cy; + Size = size; + Pressure = pressure; + } + /// + /// Mode + /// + public int Mode{ get; internal set; } + /// + /// Duration + /// + public int Duration{ get; internal set;} + /// + /// Cx + /// + public int Cx{ get; internal set;} + /// + /// Cy + /// + public int Cy{ get; internal set;} + /// + /// Size + /// + public double Size{ get; internal set;} + /// + /// Pressure + /// + public double Pressure{ get; internal set;} + } +} diff --git a/src/Tizen.WindowSystem/src/public/QuickPanelClient.cs b/src/Tizen.WindowSystem/src/public/QuickPanelClient.cs new file mode 100644 index 00000000000..9817cb0c5f6 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/QuickPanelClient.cs @@ -0,0 +1,554 @@ +/* + * 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.Collections.Generic; +using System.Text; +using Tizen.Applications.Exceptions; +using Tizen.System; +using Tizen.Common; + +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 + public class QuickPanelClient : IDisposable + { + private TizenShell _tzsh; + private IntPtr _tzshQpClient; + private int _tzshWin; + private bool disposed = false; + + private WindowOrientation _screenOrientation = WindowOrientation.Portrait; + + private int _visibleEventType; + private IntPtr _visibleEventHandler; + private Interop.QuickPanelClient.QuickPanelEventCallback _onVisibleChanged; + private event EventHandler _visibleChanged; + /// + /// 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.GetNativeHandle(), 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(); + _tzsh.ErrorCodeThrow(err); + } + } + _visibleChanged += value; + } + remove + { + int _res; + _visibleChanged -= value; + if (_visibleChanged == null) + { + _res = Interop.QuickPanelClient.DelEventHandler(_tzshQpClient, _visibleEventHandler); + _tzsh.ErrorCodeThrow(_res); + } + } + } + + private int _orientationEventType; + private IntPtr _orientationEventHandler; + private Interop.QuickPanelClient.QuickPanelEventCallback _onOrientationChanged; + private 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.GetNativeHandle(), 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(); + _tzsh.ErrorCodeThrow(err); + } + } + _orientationChanged += value; + } + remove + { + int _res; + _orientationChanged -= value; + if (_orientationChanged == null) + { + _res = Interop.QuickPanelClient.DelEventHandler(_tzshQpClient, _orientationEventHandler); + _tzsh.ErrorCodeThrow(_res); + } + } + } + + private 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; + } + } + } + + private void OnRotationChanged(object sender, WindowOrientation e) + { + _rotationChanged?.Invoke(sender, (int)e); + } + + /// + /// Enumeration for type of quickpanel service window. + /// + /// 8 + public enum Types + { + /// + /// Unknown type. There is no quickpanel service. + /// + Unknown = 0x0, + /// + /// System default type. + /// + SystemDefault = 0x1, + /// + /// Context menu type. + /// + ContextMenu = 0x2, + /// + /// Apps menu type. + /// + AppsMenu = 0x3, + } + + /// + /// Enumeration for visible state of quickpanel service window. + /// + /// 8 + public enum VisibleState + { + /// + /// Unknown state. There is no quickpanel service. + /// + /// 8 + Unknown = 0x0, + /// + /// Shown state. + /// + /// 8 + Shown = 0x1, + /// + /// Hidden state. + /// + /// 8 + Hidden = 0x2, + } + + /// + /// Enumeration for scrollable state of quickpanel service window. + /// + /// 8 + public enum ScrollableState + { + /// + /// Unknown state. There is no quickpanel service. + /// + /// 8 + Unknown = 0x0, + /// + /// Scrollable state. + /// + /// 8 + Set = 0x1, + /// + /// Not scrollable state. + /// + /// 8 + Unset = 0x2, + /// + /// Retain scrollable state. + /// + /// 8 + Retain = 0x3, + } + + /// + /// Enumeration for orientation state of quickpanel service window. + /// + /// 8 + private 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, + } + + /// + /// The constructor of QuickPanelClass 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, Types type) + { + int width = 0, height = 0; + if (tzShell == null) + { + throw new ArgumentNullException((string)"tzShell"); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException((string)"win"); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _tzshQpClient = Interop.QuickPanelClient.CreateWithType(_tzsh.GetNativeHandle(), (uint)_tzshWin, (int)type); + if (_tzshQpClient == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + + Information.TryGetValue("http://tizen.org/feature/screen.width", out width); + Information.TryGetValue("http://tizen.org/feature/screen.height", 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); + } + + /// + protected virtual void Dispose(bool disposing) + { + int res; + if (!disposed) + { + if (_tzshQpClient != IntPtr.Zero) + { + res = Interop.QuickPanelClient.Destroy(_tzshQpClient); + try + { + _tzsh.ErrorCodeThrow(res); + } + catch (ArgumentException) + { + throw new MemberAccessException("QuickPanelClient is a corrupted"); + } + _tzshQpClient = IntPtr.Zero; + } + disposed = true; + } + } + + private 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. + private void OnVisibleChanged(int type, IntPtr ev_info, IntPtr data) + { + int res; + int state; + + res = Interop.QuickPanelClient.GetEventVisible(ev_info, out state); + _tzsh.ErrorCodeThrow(res); + + _visibleChanged?.Invoke(this, (VisibleState)state); + } + + /// Thrown when failed of invalid argument. + private void OnOrientationChanged(int type, IntPtr ev_info, IntPtr data) + { + int res; + int state; + WindowOrientation orientation; + + res = Interop.QuickPanelClient.GetEventOrientation(ev_info, out state); + _tzsh.ErrorCodeThrow(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 VisibleState Visible + { + get + { + return GetVisible(); + } + } + + private VisibleState GetVisible() + { + int res; + int vis; + + res = Interop.QuickPanelClient.GetVisible(_tzshQpClient, out vis); + + _tzsh.ErrorCodeThrow(res); + + return (VisibleState)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 ScrollableState Scrollable + { + get + { + return GetScrollable(); + } + set + { + SetScrollable(value); + } + } + + private ScrollableState GetScrollable() + { + int res; + int scroll; + + res = Interop.QuickPanelClient.GetScrollableState(_tzshQpClient, out scroll); + + _tzsh.ErrorCodeThrow(res); + + return (ScrollableState)scroll; + } + + private void SetScrollable(ScrollableState scroll) + { + int res; + + res = Interop.QuickPanelClient.SetScrollableState(_tzshQpClient, (int)scroll); + + _tzsh.ErrorCodeThrow(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(); + } + } + + private WindowOrientation GetOrientation() + { + int res; + int state; + WindowOrientation orientation; + + res = Interop.QuickPanelClient.GetOrientation(_tzshQpClient, out state); + + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/QuickPanelService.cs b/src/Tizen.WindowSystem/src/public/QuickPanelService.cs new file mode 100644 index 00000000000..0e3234d58bc --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/QuickPanelService.cs @@ -0,0 +1,300 @@ +/* + * 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.Collections.Generic; +using System.ComponentModel; +using System.Text; +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 + { + private TizenShell _tzsh; + private IntPtr _tzshQpService; + private int _tzshWin; + private bool disposed = false; + + /// + /// QuickPanel Type. + /// + public enum Types + { + /// + /// Unknown type. There is no quickpanel service. + /// + Unknown = 0x0, + /// + /// System default type. + /// + SystemDefault = 0x1, + /// + /// Context menu type. + /// + ContextMenu = 0x2, + /// + /// Apps menu type. + /// + AppsMenu = 0x3, + } + + /// + /// Effect type. + /// + public enum EffectType + { + /// + /// Swipe effect + /// + Swipe = 0, + /// + /// Move effect + /// + Move = 1, + /// + /// App control effect + /// + Custom = 2, + } + + /// + /// Creates a new Quickpanel Service handle. + /// + /// The TzShell instance. + /// The window to provide service of the quickpanel. + /// 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. + public QuickPanelService(TizenShell tzShell, int win, Types type) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win < 0) + { + throw new ArgumentException("Invalid window ID"); + } + + _tzsh = tzShell; + _tzshWin = win; + _tzshQpService = Interop.QuickPanelService.CreateWithType(_tzsh.GetNativeHandle(), (uint)_tzshWin, (int)type); + if (_tzshQpService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// 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, Types type) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _tzshQpService = Interop.QuickPanelService.CreateWithType(_tzsh.GetNativeHandle(), (uint)_tzshWin, (int)type); + if (_tzshQpService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Destructor. + /// + /// Thrown when failed of invalid argument. + + + /// + /// Dispose. + /// + /// Thrown when private memeber is a corrupted. + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + int res; + if (!disposed) + { + if (_tzshQpService != IntPtr.Zero) + { + res = Interop.QuickPanelService.Destroy(_tzshQpService); + try + { + _tzsh.ErrorCodeThrow(res); + } + catch (ArgumentException) + { + throw new MemberAccessException("QuickPanelService is a corrupted"); + } + _tzshQpService = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Gets the type of the quickpanel service handle. + /// + /// The type of the quickpanel service handle + /// Thrown when failed of invalid argument. + public Types ServiceType + { + get + { + return GetType(); + } + } + + private new Types GetType() + { + int res; + int type; + + res = Interop.QuickPanelService.GetType(_tzshQpService, out type); + + _tzsh.ErrorCodeThrow(res); + + return (Types)type; + } + + /// + /// Requests to show the quickpanel service window. + /// + /// Thrown when failed of invalid argument. + public void Show() + { + int res; + + res = Interop.QuickPanelService.Show(_tzshQpService); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to hide the quickpanel service window. + /// + /// Thrown when failed of invalid argument. + public void Hide() + { + int res; + + res = Interop.QuickPanelService.Hide(_tzshQpService); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Sets the content region of the quickpanel service handle. + /// + /// The angle setting the region + /// The region of the content + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public void SetContentRegion(uint angle, TizenRegion region) + { + int res; + + if (region == null) + { + throw new ArgumentNullException(nameof(region)); + } + res = Interop.QuickPanelService.SetContentRegion(_tzshQpService, angle, region.GetNativeHandle()); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Sets the handler region of the quickpanel service handle. + /// + /// The angle setting the region + /// The region of the content + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public void SetHandlerRegion(uint angle, TizenRegion region) + { + int res; + + if (region == null) + { + throw new ArgumentNullException(nameof(region)); + } + res = Interop.QuickPanelService.SetHandlerRegion(_tzshQpService, angle, region.GetNativeHandle()); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to change the effect of animation. + /// + /// The type of effect, enumeration for effect type. + /// Thrown when failed of invalid argument. + public void SetEffectType(EffectType type) + { + int res; + + res = Interop.QuickPanelService.SetEffectType(_tzshQpService, (int)type); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to lock/unlock scrolling the quickpanel service window. + /// + /// The scroll lock state + /// Thrown when failed of invalid argument. + public void LockScroll(bool locked) + { + int res; + + res = Interop.QuickPanelService.LockScroll(_tzshQpService, locked); + _tzsh.ErrorCodeThrow(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/ScreensaverService.cs b/src/Tizen.WindowSystem/src/public/ScreensaverService.cs new file mode 100644 index 00000000000..b147f118f95 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/ScreensaverService.cs @@ -0,0 +1,104 @@ +/* + * 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; +using Tizen.Applications; + +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 + { + private TizenShell _tzsh; + private IntPtr _screensaverService; + private int _tzshWin; + private 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.GetNativeHandle() == IntPtr.Zero) + { + 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.GetNativeHandle(), (uint)_tzshWin); + if (_screensaverService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Destructor. + /// + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + ReleaseHandle(_screensaverService); + } + else + { + var handle = _screensaverService; + CoreApplication.Post(() => ReleaseHandle(handle)); + } + disposed = true; + } + } + + private void ReleaseHandle(IntPtr handle) + { + Interop.ScreensaverService.Destroy(handle); + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/ShellEnums.cs b/src/Tizen.WindowSystem/src/public/ShellEnums.cs new file mode 100644 index 00000000000..924857f400d --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/ShellEnums.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Enumeration for the window orientation. + /// + /// 8 + public enum WindowOrientation + { + /// + /// Portrait. + /// + Portrait = 0, + + /// + /// Landscape. + /// + Landscape = 90, + + /// + /// Portrait inverse. + /// + PortraitInverse = 180, + + /// + /// Landscape inverse. + /// + LandscapeInverse = 270, + } + + /// + /// Visible state of softkey. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum SoftkeyVisibleState + { + /// + /// Unknown state. There is no softkey service. + /// + Unknown = 0x0, + /// + /// Shown state. + /// + Shown = 0x1, + /// + /// Hidden state. + /// + Hidden = 0x2, + } + + /// + /// Expand state of softkey. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum SoftkeyExpandState + { + /// + /// Unknown state. There is no softkey service. + /// + Unknown = 0x0, + /// + /// Expandable state. + /// + On = 0x1, + /// + /// Not Expandable state. + /// + Off = 0x2, + } + + /// + /// Opacity state of softkey. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum SoftkeyOpacityState + { + /// + /// Unknown state. There is no softkey service. + /// + Unknown = 0x0, + /// + /// Opaque state. + /// + Opaque = 0x1, + /// + /// Transparent state. + /// + Transparent = 0x2, + } +} diff --git a/src/Tizen.WindowSystem/src/public/SoftkeyClient.cs b/src/Tizen.WindowSystem/src/public/SoftkeyClient.cs new file mode 100644 index 00000000000..ebf13b02b80 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/SoftkeyClient.cs @@ -0,0 +1,273 @@ +/* + * 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 + { + private TizenShell _tzsh; + private IntPtr _softkeyClient; + private int _tzshWin; + private 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.GetNativeHandle() == IntPtr.Zero) + { + 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.GetNativeHandle(), (uint)_tzshWin); + if (_softkeyClient == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (_softkeyClient != IntPtr.Zero) + { + int res = Interop.SoftkeyClient.Destroy(_softkeyClient); + _softkeyClient = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Gets the visible state of a softkey service window. + /// + /// The visible state of 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 SoftkeyVisibleState Visible + { + get + { + return GetVisible(); + } + } + + /// + /// Gets the expand state of a softkey service window. + /// + /// The expand state of 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 SoftkeyExpandState Expand + { + get + { + return GetExpand(); + } + set + { + SetExpand(value); + } + } + + /// + /// Gets the opacity state of a softkey service window. + /// + /// The opacity state of 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 SoftkeyOpacityState Opacity + { + get + { + return GetOpacity(); + } + set + { + SetOpacity(value); + } + } + + /// + /// 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); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyVisibleState GetVisible() + { + int res = Interop.SoftkeyClient.GetVisibleState(_softkeyClient, out int vis); + + _tzsh.ErrorCodeThrow(res); + + return ChangeVisibleStateToPublic((Interop.SoftkeyClient.VisibleState)vis); + } + + private SoftkeyExpandState GetExpand() + { + int res = Interop.SoftkeyClient.GetExpandState(_softkeyClient, out int expand); + + _tzsh.ErrorCodeThrow(res); + + return ChangeExpandStateToPublic((Interop.SoftkeyClient.ExpandState)expand); + } + + private void SetExpand(SoftkeyExpandState expand) + { + int res = Interop.SoftkeyClient.SetExpandState(_softkeyClient, (int)(ChangeExpandStateToInternal(expand))); + + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyOpacityState GetOpacity() + { + int res = Interop.SoftkeyClient.GetOpacityState(_softkeyClient, out int opacity); + + _tzsh.ErrorCodeThrow(res); + + return ChangeOpacityStateToPublic((Interop.SoftkeyClient.OpacityState)opacity); + } + + private void SetOpacity(SoftkeyOpacityState opacity) + { + int res = Interop.SoftkeyClient.SetOpacityState(_softkeyClient, (int)(ChangeOpacityStateToInternal(opacity))); + + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyVisibleState ChangeVisibleStateToPublic(Interop.SoftkeyClient.VisibleState state) + { + if (state == Interop.SoftkeyClient.VisibleState.Shown) + return SoftkeyVisibleState.Shown; + else if (state == Interop.SoftkeyClient.VisibleState.Hidden) + return SoftkeyVisibleState.Hidden; + else + return SoftkeyVisibleState.Unknown; + } + + private Interop.SoftkeyClient.VisibleState ChangeVisibleStateToInternal(SoftkeyVisibleState state) + { + if (state == SoftkeyVisibleState.Shown) + return Interop.SoftkeyClient.VisibleState.Shown; + else if (state == SoftkeyVisibleState.Hidden) + return Interop.SoftkeyClient.VisibleState.Hidden; + else + return Interop.SoftkeyClient.VisibleState.Unknown; + } + + private SoftkeyExpandState ChangeExpandStateToPublic(Interop.SoftkeyClient.ExpandState state) + { + if (state == Interop.SoftkeyClient.ExpandState.On) + return SoftkeyExpandState.On; + else if (state == Interop.SoftkeyClient.ExpandState.Off) + return SoftkeyExpandState.Off; + else + return SoftkeyExpandState.Unknown; + } + + private Interop.SoftkeyClient.ExpandState ChangeExpandStateToInternal(SoftkeyExpandState state) + { + if (state == SoftkeyExpandState.On) + return Interop.SoftkeyClient.ExpandState.On; + else if (state == SoftkeyExpandState.Off) + return Interop.SoftkeyClient.ExpandState.Off; + else + return Interop.SoftkeyClient.ExpandState.Unknown; + } + + private SoftkeyOpacityState ChangeOpacityStateToPublic(Interop.SoftkeyClient.OpacityState state) + { + if (state == Interop.SoftkeyClient.OpacityState.Opaque) + return SoftkeyOpacityState.Opaque; + else if (state == Interop.SoftkeyClient.OpacityState.Transparent) + return SoftkeyOpacityState.Transparent; + else + return SoftkeyOpacityState.Unknown; + } + + private Interop.SoftkeyClient.OpacityState ChangeOpacityStateToInternal(SoftkeyOpacityState state) + { + if (state == SoftkeyOpacityState.Opaque) + return Interop.SoftkeyClient.OpacityState.Opaque; + else if (state == SoftkeyOpacityState.Transparent) + return Interop.SoftkeyClient.OpacityState.Transparent; + else + return Interop.SoftkeyClient.OpacityState.Unknown; + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/SoftkeyService.cs b/src/Tizen.WindowSystem/src/public/SoftkeyService.cs new file mode 100644 index 00000000000..9d7f83ff26c --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/SoftkeyService.cs @@ -0,0 +1,262 @@ +/* + * 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 + { + private TizenShell _tzsh; + private IntPtr _softkeyService; + private int _tzshWin; + private bool disposed = false; + + private Interop.SoftkeyService.SoftkeyVisibleEventCallback _onVisibleChanged; + private Interop.SoftkeyService.SoftkeyExpandEventCallback _onExpandChanged; + private Interop.SoftkeyService.SoftkeyOpacityEventCallback _onOpacityChanged; + + private event EventHandler _visibleChanged; + private event EventHandler _expandChanged; + private 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.GetNativeHandle() == IntPtr.Zero) + { + 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.GetNativeHandle(), (uint)_tzshWin); + if (_softkeyService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (_softkeyService != IntPtr.Zero) + { + int res = Interop.SoftkeyService.Destroy(_softkeyService); + _softkeyService = IntPtr.Zero; + } + 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); + _tzsh.ErrorCodeThrow(res); + } + _visibleChanged += value; + } + remove + { + _visibleChanged -= value; + if (_visibleChanged == null) + { + int res = Interop.SoftkeyService.SetVisibleEventHandler(_softkeyService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + _expandChanged += value; + } + remove + { + _expandChanged -= value; + if (_expandChanged == null) + { + int res = Interop.SoftkeyService.SetExpandEventHandler(_softkeyService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(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); + _tzsh.ErrorCodeThrow(res); + } + _opacityChanged += value; + } + remove + { + _opacityChanged -= value; + if (_opacityChanged == null) + { + int res = Interop.SoftkeyService.SetOpacityEventHandler(_softkeyService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + } + } + + private void OnVisibleChanged(IntPtr data, IntPtr softkeyService, int visible) + { + _visibleChanged?.Invoke(this, ChangeVisibleStateToPublic((Interop.SoftkeyService.VisibleState)visible)); + } + + private void OnExpandChanged(IntPtr data, IntPtr softkeyService, int expand) + { + _expandChanged?.Invoke(this, ChangeExpandStateToPublic((Interop.SoftkeyService.ExpandState)expand)); + } + + private void OnOpacityChanged(IntPtr data, IntPtr softkeyService, int opacity) + { + _opacityChanged?.Invoke(this, ChangeOpacityStateToPublic((Interop.SoftkeyService.OpacityState)opacity)); + } + + /// + /// Requests to show the softkey service window. + /// + /// Thrown when failed of invalid argument. + public void Show() + { + int res = Interop.SoftkeyService.Show(_softkeyService); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to hide the softkey service window. + /// + /// Thrown when failed of invalid argument. + public void Hide() + { + int res = Interop.SoftkeyService.Hide(_softkeyService); + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyVisibleState ChangeVisibleStateToPublic(Interop.SoftkeyService.VisibleState state) + { + if (state == Interop.SoftkeyService.VisibleState.Show) + return SoftkeyVisibleState.Shown; + else + return SoftkeyVisibleState.Hidden; + } + + private Interop.SoftkeyService.VisibleState ChangeVisibleStateToInternal(SoftkeyVisibleState state) + { + if (state == SoftkeyVisibleState.Shown) + return Interop.SoftkeyService.VisibleState.Show; + else + return Interop.SoftkeyService.VisibleState.Hide; + } + + private SoftkeyExpandState ChangeExpandStateToPublic(Interop.SoftkeyService.ExpandState state) + { + if (state == Interop.SoftkeyService.ExpandState.On) + return SoftkeyExpandState.On; + else + return SoftkeyExpandState.Off; + } + + private Interop.SoftkeyService.ExpandState ChangeExpandStateToInternal(SoftkeyExpandState state) + { + if (state == SoftkeyExpandState.On) + return Interop.SoftkeyService.ExpandState.On; + else + return Interop.SoftkeyService.ExpandState.Off; + } + + private SoftkeyOpacityState ChangeOpacityStateToPublic(Interop.SoftkeyService.OpacityState state) + { + if (state == Interop.SoftkeyService.OpacityState.Opaque) + return SoftkeyOpacityState.Opaque; + else + return SoftkeyOpacityState.Transparent; + } + + private Interop.SoftkeyService.OpacityState ChangeOpacityStateToInternal(SoftkeyOpacityState state) + { + if (state == SoftkeyOpacityState.Opaque) + return Interop.SoftkeyService.OpacityState.Opaque; + else + return Interop.SoftkeyService.OpacityState.Transparent; + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/TapEventArgs.cs b/src/Tizen.WindowSystem/src/public/TapEventArgs.cs new file mode 100644 index 00000000000..dd24c71a34e --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/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(int mode, int fingers, int repeats) + { + Mode = mode; + Fingers = fingers; + Repeats = repeats; + } + /// + /// Mode + /// + public int Mode{ get; internal set; } + /// + /// Fingers + /// + public int Fingers{ get; internal set;} + /// + /// Repeats + /// + public int Repeats{ get; internal set;} + } +} diff --git a/src/Tizen.WindowSystem/src/public/TaskbarService.cs b/src/Tizen.WindowSystem/src/public/TaskbarService.cs new file mode 100755 index 00000000000..82b54460cec --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/TaskbarService.cs @@ -0,0 +1,147 @@ +/* + * 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 + { + private TizenShell _tzsh; + private IntPtr _taskbarService; + private int _tzshWin; + private bool disposed = false; + + /// + /// Enumeration for placed type of taskbar service window. + /// + public enum PlaceType + { + /// + /// Place to Bottom of Screen. Default type. + /// + Bottom = 0x0, + /// + /// Place to Top of Screen. + /// + Top = 0x1, + /// + /// Place to Left Side of Screen. + /// + Left = 0x2, + /// + /// Place to Right Side of Screen. + /// + Right = 0x3, + } + + /// + /// Creates a new Taskbar Service handle. + /// + /// The TizenShell instance. + /// The window 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, PlaceType type = PlaceType.Bottom) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = WindowSystem.Interop.EcoreWl2.GetWindowId(win.WindowHandle); + _taskbarService = Interop.TaskbarService.Create(_tzsh.GetNativeHandle(), (uint)_tzshWin); + if (_taskbarService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + + Interop.TaskbarService.SetPlaceType(_taskbarService, (int)type); + } + + + /// + /// Dispose. + /// + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (_taskbarService != IntPtr.Zero) + { + int res = Interop.TaskbarService.Destroy(_taskbarService); + _taskbarService = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Set the current place type. + /// The window manager can use this to determine the geometry of another applications. + /// + /// The type of placement, enumeration for the place type. + /// Thrown when failed of invalid argument. + public void SetPlaceType(PlaceType type) + { + int res; + + res = Interop.TaskbarService.SetPlaceType(_taskbarService, (int)type); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Set the size of the taskbar. + /// This may be different from the actual size. The window manager can use this to + /// determine the geometry of another applications. + /// + /// The width of the taskbar area. + /// The height of the taskbar area. + /// Thrown when failed of invalid argument. + public void SetSize(uint width, uint height) + { + int res; + + res = Interop.TaskbarService.SetSize(_taskbarService, width, height); + _tzsh.ErrorCodeThrow(res); + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/TizenRegion.cs b/src/Tizen.WindowSystem/src/public/TizenRegion.cs new file mode 100644 index 00000000000..9085ae0e7f6 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/TizenRegion.cs @@ -0,0 +1,133 @@ +/* + * 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.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace Tizen.WindowSystem.Shell +{ + /// + /// Tizen Window System Shell. + /// This is a basic handle class for others in WsShell. + /// Others class in WsShell using this basic class to use TIzen Window System Shell. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class TizenRegion : IDisposable + { + private TizenShell _tzsh; + private IntPtr _region; + private bool disposed = false; + + /// + /// Creates a new Tizen region object. + /// + /// The TzShell instance. + /// Thrown when the memory is not enough to allocate. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public TizenRegion(TizenShell tzShell) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + + _tzsh = tzShell; + _region = Interop.TizenRegion.Create(_tzsh.GetNativeHandle()); + if (_region == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Dispose. + /// + /// Thrown when private memeber is a corrupted. + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + int res; + if (!disposed) + { + if (_region != IntPtr.Zero) + { + res = Interop.TizenRegion.Destroy(_region); + try + { + _tzsh.ErrorCodeThrow(res); + } + catch (ArgumentException) + { + throw new MemberAccessException("TizenRegion is a corrupted"); + } + _region = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Adds the rectangle to the region. + /// + /// The x coordinate + /// The y coordinate + /// The width + /// The height + /// Thrown when failed of invalid argument. + public void Add(int x, int y, int w, int h) + { + int res; + + res = Interop.TizenRegion.Add(_region, x, y, w, h); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Substracts the rectangle to the tizen region. + /// + /// The x coordinate + /// The y coordinate + /// The width + /// The height + /// Thrown when failed of invalid argument. + public void Subtract(int x, int y, int w, int h) + { + int res; + + res = Interop.TizenRegion.Subtract(_region, x, y, w, h); + _tzsh.ErrorCodeThrow(res); + } + + internal IntPtr GetNativeHandle() + { + return _region; + } + } +} diff --git a/src/Tizen.WindowSystem/src/public/TizenShell.cs b/src/Tizen.WindowSystem/src/public/TizenShell.cs new file mode 100644 index 00000000000..42f4de430f2 --- /dev/null +++ b/src/Tizen.WindowSystem/src/public/TizenShell.cs @@ -0,0 +1,126 @@ +/* + * 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.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +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 + public class TizenShell : IDisposable + { + private IntPtr _tzsh; + private bool disposed = false; + + internal void ErrorCodeThrow(int error) + { + if (error == (int)Interop.TizenShell.ErrorCode.None) + { + return; + } + else if (error == (int)Interop.TizenShell.ErrorCode.OutOfMemory) + { + throw new Tizen.Applications.Exceptions.OutOfMemoryException("Out of Memory"); + } + else if (error == (int)Interop.TizenShell.ErrorCode.InvalidParameter) + { + throw new ArgumentException("Invalid Parameter"); + } + else if (error == (int)Interop.TizenShell.ErrorCode.PermissionDenied) + { + throw new PermissionDeniedException("Permission denied"); + } + else if (error == (int)Interop.TizenShell.ErrorCode.NotSupported) + { + throw new NotSupportedException("Not Supported"); + } + else if (error == (int)Interop.TizenShell.ErrorCode.NoService) + { + throw new InvalidOperationException("No Service"); + } + else + { + throw new InvalidOperationException("Unknown Error"); + } + } + + /// + /// The constructor of TizenShell class. + /// + /// Thrown when the memory is not enough to allocate. + /// Thrown when failed of invalid argument. + /// 8 + public TizenShell() + { + _tzsh = Interop.TizenShell.Create((int)Interop.TizenShell.ToolKitType.Efl); + if (_tzsh == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + ErrorCodeThrow(err); + } + } + + /// + /// Dispose the TizenShell instance explicitly. + /// + /// Thrown when private memeber is a corrupted. + /// 8 + public void Dispose() + { + Dispose(true); + } + + /// + protected virtual void Dispose(bool disposing) + { + int res; + + if (!disposed) + { + if (_tzsh != IntPtr.Zero) + { + res = Interop.TizenShell.Destroy(_tzsh); + try + { + ErrorCodeThrow(res); + } + catch (ArgumentException) + { + throw new MemberAccessException("TizehShell is a corrupted"); + } + _tzsh = IntPtr.Zero; + } + disposed = true; + } + } + + internal IntPtr GetNativeHandle() + { + return _tzsh; + } + } +}