Skip to content

Commit

Permalink
[TCSACR-586][NUI] Add IWindowProvider to be used as a common window i…
Browse files Browse the repository at this point in the history
…nterface across different modules
  • Loading branch information
dongsug-song committed Aug 20, 2024
1 parent 9b36d30 commit d9b4f92
Show file tree
Hide file tree
Showing 20 changed files with 374 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/Tizen.Multimedia/Common/Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
using System;
using ElmSharp;
using Tizen.Common;

namespace Tizen.Multimedia
{
Expand Down Expand Up @@ -175,19 +176,19 @@ public Display(NUI.Window window, bool uiSync)
}

/// <summary>
/// Initializes a new instance of the <see cref="Display"/> class with an <see cref="IWindowProvider"/> interface.
/// Initializes a new instance of the <see cref="Display"/> class with an <see cref="Tizen.Common.IWindowProvider"/> interface.
/// </summary>
/// <param name="window">An <see cref="IWindowProvider"/> object that provides a handle to a window.</param>
/// <param name="window">An <see cref="Tizen.Common.IWindowProvider"/> object that provides a handle to a window.</param>
/// <since_tizen> 12 </since_tizen>
public Display(IWindowProvider window)
: this(window, false)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="Display"/> class with an <see cref="IWindowProvider"/> interface.
/// Initializes a new instance of the <see cref="Display"/> class with an <see cref="Tizen.Common.IWindowProvider"/> interface.
/// </summary>
/// <param name="window">An <see cref="IWindowProvider"/> object that provides a handle to a window.</param>
/// <param name="window">An <see cref="Tizen.Common.IWindowProvider"/> object that provides a handle to a window.</param>
/// <param name="uiSync">A value indicating whether video and UI are in sync or not.</param>
/// <remarks>
/// UI sync is only for <see cref="T:Tizen.Multimedia.Player"/> and
Expand All @@ -208,7 +209,6 @@ public Display(IWindowProvider window, bool uiSync)
UiSync = uiSync;
}


private EvasObject EvasObject { get; }

private DisplayType Type { get; }
Expand Down
25 changes: 25 additions & 0 deletions src/Tizen.NUI.WindowSystem/Tizen.NUI.WindowSystem.sln
Original file line number Diff line number Diff line change
@@ -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.NUI.WindowSystem", "Tizen.NUI.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tizen.NUI.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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, IntPtr win);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, IntPtr win, int 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, IntPtr win, int 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, IntPtr win);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, IntPtr win);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static partial class TaskbarService
const string lib = "libtzsh_taskbar_service.so.0";

[global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_taskbar_service_create")]
internal static extern IntPtr Create(IntPtr tzsh, IntPtr win);
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);
Expand Down
38 changes: 36 additions & 2 deletions src/Tizen.NUI.WindowSystem/src/public/KVMService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using Tizen.Common;

namespace Tizen.NUI.WindowSystem.Shell
{
Expand Down Expand Up @@ -62,7 +63,7 @@ public enum DropTarget
/// <param name="tzShell">The TizenShell instance.</param>
/// <param name="win">The window to provide service of the quickpanel.</param>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
/// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
/// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception>
public KVMService(TizenShell tzShell, Window win)
{
if (tzShell == null)
Expand All @@ -80,7 +81,40 @@ public KVMService(TizenShell tzShell, Window win)

_tzsh = tzShell;
_tzshWin = win.GetNativeId();
_kvmService = Interop.KVMService.Create(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin);
_kvmService = Interop.KVMService.Create(_tzsh.GetNativeHandle(), (uint)_tzshWin);
if (_kvmService == IntPtr.Zero)
{
int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
_tzsh.ErrorCodeThrow(err);
}
}

/// <summary>
/// Creates a new KVM Service handle.
/// </summary>
/// <param name="tzShell">The TizenShell instance.</param>
/// <param name="win">The window provider for the quickpanel service.</param>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
/// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception>
/// <since_tizen> 12 </since_tizen>
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();
Expand Down
78 changes: 76 additions & 2 deletions src/Tizen.NUI.WindowSystem/src/public/QuickPanelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Text;
using Tizen.Applications.Exceptions;
using Tizen.System;
using Tizen.Common;

namespace Tizen.NUI.WindowSystem.Shell
{
Expand Down Expand Up @@ -118,6 +119,39 @@ public event EventHandler<Window.WindowOrientation> OrientationChanged
}
}

private event EventHandler<int> _rotationChanged;

/// <summary>
/// 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.
/// </summary>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
/// <since_tizen> 12 </since_tizen>
public event EventHandler<int> RotationChanged
{
add
{
if(_rotationChanged == null)
{
OrientationChanged += OnRotationChanged;
}
_rotationChanged += value;
}
remove
{
_rotationChanged -= value;
if(_rotationChanged == null)
{
OrientationChanged -= OnRotationChanged;
}
}
}

private void OnRotationChanged(object sender, Window.WindowOrientation e)
{
_rotationChanged?.Invoke(sender, (int)e);
}

/// <summary>
/// Enumeration for type of quickpanel service window.
/// </summary>
Expand Down Expand Up @@ -228,7 +262,7 @@ private enum OrientationState
/// <param name="type">The type of quickpanel service.</param>
/// <exception cref="Tizen.Applications.Exceptions.OutOfMemoryException">Thrown when the memory is not enough to allocate.</exception>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
/// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
/// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception>
/// <since_tizen> 8 </since_tizen>
public QuickPanelClient(TizenShell tzShell, Window win, Types type)
{
Expand All @@ -248,7 +282,7 @@ public QuickPanelClient(TizenShell tzShell, Window win, Types type)

_tzsh = tzShell;
_tzshWin = win.GetNativeId();
_tzshQpClient = Interop.QuickPanelClient.CreateWithType(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin, (int)type);
_tzshQpClient = Interop.QuickPanelClient.CreateWithType(_tzsh.GetNativeHandle(), (uint)_tzshWin, (int)type);
if (_tzshQpClient == IntPtr.Zero)
{
int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
Expand All @@ -260,6 +294,46 @@ public QuickPanelClient(TizenShell tzShell, Window win, Types type)
if (width > height) _screenOrientation = Window.WindowOrientation.Landscape;
}

/// <summary>
/// Creates a new Quickpanel Client handle.
/// </summary>
/// <param name="tzShell">The TizenShell instance.</param>
/// <param name="win">The window provider for the quickpanel service.</param>
/// <param name="type">The type of quickpanel service.</param>
/// <exception cref="Tizen.Applications.Exceptions.OutOfMemoryException">Thrown when there is not enough memory (to allocate).</exception>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
/// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception>
/// <since_tizen> 12 </since_tizen>
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 = (Window.WindowOrientation)(90);
}

/// <summary>
/// Destructor.
/// </summary>
Expand Down
38 changes: 37 additions & 1 deletion src/Tizen.NUI.WindowSystem/src/public/QuickPanelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using Tizen.Common;

namespace Tizen.NUI.WindowSystem.Shell
{
Expand Down Expand Up @@ -103,7 +104,42 @@ public QuickPanelService(TizenShell tzShell, Window win, Types type)

_tzsh = tzShell;
_tzshWin = win.GetNativeId();
_tzshQpService = Interop.QuickPanelService.CreateWithType(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin, (int)type);
_tzshQpService = Interop.QuickPanelService.CreateWithType(_tzsh.GetNativeHandle(), (uint)_tzshWin, (int)type);
if (_tzshQpService == IntPtr.Zero)
{
int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
_tzsh.ErrorCodeThrow(err);
}
}

/// <summary>
/// Creates a new Quickpanel Service handle.
/// </summary>
/// <param name="tzShell">The TzShell instance.</param>
/// <param name="win">The window provider for the quickpanel service.</param>
/// <param name="type">The type of quickpanel service.</param>
/// <exception cref="Tizen.Applications.Exceptions.OutOfMemoryException">Thrown when the memory is not enough to allocate.</exception>
/// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
/// <exception cref="ArgumentNullException">Thrown when a argument is null.</exception>
/// <since_tizen> 12 </since_tizen>
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();
Expand Down
Loading

0 comments on commit d9b4f92

Please sign in to comment.