--- /dev/null
+/*
+ * 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.NUI.WindowSystem.Shell
+{
+ /// <summary>
+ /// Class for the Tizen screensaver service.
+ /// </summary>
+ /// 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;
+ private bool isDisposeQueued = false;
+
+ /// <summary>
+ /// Creates a new Screensaver Service handle.
+ /// </summary>
+ /// <param name="tzShell">The TizenShell instance.</param>
+ /// <param name="win">The window to provide service of the screensaver.</param>
+ /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+ /// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception>
+ public ScreensaverService(TizenShell tzShell, Window 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 = win.GetNativeId();
+ _screensaverService = Interop.ScreensaverService.Create(_tzsh.GetNativeHandle(), (uint)_tzshWin);
+ if (_screensaverService == IntPtr.Zero)
+ {
+ int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult();
+ _tzsh.ErrorCodeThrow(err);
+ }
+ }
+
+ /// <summary>
+ /// Creates a new Screensaver Service handle.
+ /// </summary>
+ /// <param name="tzShell">The TizenShell instance.</param>
+ /// <param name="win">The window provider for the screensaver service.</param>
+ /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+ /// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception>
+ 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);
+ }
+ }
+
+ /// <summary>
+ /// Destructor.
+ /// </summary>
+ ~ScreensaverService()
+ {
+ Dispose(disposing: false);
+ }
+ /// <summary>
+ /// Dispose.
+ /// </summary>
+ public void Dispose()
+ {
+ if (disposed)
+ return;
+
+ Dispose(disposing: true);
+ GC.SuppressFinalize(this);
+ }
+ /// <inheritdoc/>
+ 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);
+ }
+ }
+}
TextLabel textSoftkeyServiceExpand;
TextLabel textSoftkeyServiceOpacity;
+ Shell.ScreensaverService screensaverService;
+ Button BtnScreensaverService;
+ TextLabel textScreensaverServiceTitle;
+
protected override void OnCreate()
{
base.OnCreate();
{
Text = "QuickPanelService",
Size = new Size(400, 100),
- Position = new Position(100, 400),
+ Position = new Position(100, 340),
Margin = 10,
};
{
Text = "SoftkeyClient",
Size = new Size(400, 100),
- Position = new Position(100, 600),
+ Position = new Position(100, 480),
Margin = 10,
};
{
Text = "SoftkeyService",
Size = new Size(400, 100),
- Position = new Position(100, 800),
+ Position = new Position(100, 620),
+ Margin = 10,
+ };
+
+ BtnScreensaverService = new Button()
+ {
+ Text = "ScreensaverService",
+ Size = new Size(400, 100),
+ Position = new Position(100, 760),
Margin = 10,
};
window.Add(BtnService);
window.Add(BtnSoftkeyClient);
window.Add(BtnSoftkeyService);
+ window.Add(BtnScreensaverService);
BtnClient.ClickEvent += BtnClient_ClickEvent;
BtnService.ClickEvent += BtnService_ClickEvent;
BtnSoftkeyClient.ClickEvent += BtnSoftkeyClient_ClickEvent;
BtnSoftkeyService.ClickEvent += BtnSoftkeyService_ClickEvent;
+ BtnScreensaverService.ClickEvent += BtnScreensaverService_ClickEvent;
tzShell = new Shell.TizenShell();
window.Remove(BtnService);
window.Remove(BtnClient);
+ window.Remove(BtnScreensaverService);
window.Remove(BtnSoftkeyService);
window.Remove(BtnSoftkeyClient);
qpClient = new Shell.QuickPanelClient(tzShell, (IWindowProvider)window, Shell.QuickPanelClient.Types.SystemDefault);
window.Remove(BtnService);
window.Remove(BtnClient);
+ window.Remove(BtnScreensaverService);
window.Remove(BtnSoftkeyService);
window.Remove(BtnSoftkeyClient);
qpService = new Shell.QuickPanelService(tzShell, (IWindowProvider)window, type);
window.Remove(BtnService);
window.Remove(BtnClient);
+ window.Remove(BtnScreensaverService);
window.Remove(BtnSoftkeyService);
window.Remove(BtnSoftkeyClient);
softkeyClient = new Shell.SoftkeyClient(tzShell, (IWindowProvider)window);
window.Remove(BtnService);
window.Remove(BtnClient);
+ window.Remove(BtnScreensaverService);
window.Remove(BtnSoftkeyService);
window.Remove(BtnSoftkeyClient);
softkeyService = new Shell.SoftkeyService(tzShell, (IWindowProvider)window);
softkeyService.Hide();
}
+ private void BtnScreensaverService_ClickEvent(object sender, Button.ClickEventArgs e)
+ {
+ Window window = NUIApplication.GetDefaultWindow();
+ window.WindowSize = new Size(1920, 1080);
+ window.WindowPosition = new Position(0, 0);
+
+ window.Remove(BtnService);
+ window.Remove(BtnClient);
+ window.Remove(BtnScreensaverService);
+ window.Remove(BtnSoftkeyService);
+ window.Remove(BtnSoftkeyClient);
+ screensaverService = new Shell.ScreensaverService(tzShell, (IWindowProvider)window);
+
+ textScreensaverServiceTitle = new TextLabel($"Screen Saver");
+ textScreensaverServiceTitle.Position = new Position(0, 0);
+ textScreensaverServiceTitle.HorizontalAlignment = HorizontalAlignment.Center;
+ textScreensaverServiceTitle.VerticalAlignment = VerticalAlignment.Center;
+ textScreensaverServiceTitle.TextColor = Color.Blue;
+ textScreensaverServiceTitle.PointSize = 12.0f;
+ textScreensaverServiceTitle.HeightResizePolicy = ResizePolicyType.FillToParent;
+ textScreensaverServiceTitle.WidthResizePolicy = ResizePolicyType.FillToParent;
+ window.Add(textScreensaverServiceTitle);
+ }
+
static void Main(string[] args)
{
var app = new Program();