From 2a041ff47239a54fb4dcdebc3a1968e651680012 Mon Sep 17 00:00:00 2001 From: darkleem Date: Tue, 4 Apr 2017 14:33:37 +0900 Subject: [PATCH] Add internal api for winKeygrab and Iconified Change-Id: I80b9b5ac1d5263c539846a9e4e2d8a8732b9ca25 Signed-off-by: darkleem --- ElmSharp.Test/ElmSharp.Test.csproj | 7 ++- ElmSharp.Test/TC/WindowInternalTest.cs | 97 ++++++++++++++++++++++++++++++ ElmSharp.Test/TestRunner.cs | 2 +- ElmSharp/ElmSharp/Window.cs | 34 +++++++++++ ElmSharp/Interop/Interop.Elementary.Win.cs | 16 +++++ packaging/elm-sharp.spec | 2 +- 6 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 ElmSharp.Test/TC/WindowInternalTest.cs diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index 01e4434..0bdd667 100644 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -102,6 +102,7 @@ + @@ -191,11 +192,11 @@ - + - + - + \ No newline at end of file diff --git a/ElmSharp.Test/TC/WindowInternalTest.cs b/ElmSharp.Test/TC/WindowInternalTest.cs new file mode 100644 index 0000000..c238b74 --- /dev/null +++ b/ElmSharp.Test/TC/WindowInternalTest.cs @@ -0,0 +1,97 @@ +using Tizen.Applications; +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 ElmSharp; +using System.Diagnostics; + +namespace ElmSharp.Test +{ + class WindowInternalTest : TestCaseBase + { + public override string TestName => "WindowInternalTest"; + public override string TestDescription => "Window Test"; + + public override void Run(Window window) + { + var firstWindow = (Application.Current as TestRunner)?._firstPageWindow; + firstWindow.Hide(); + firstWindow.Unrealize(); + + Button button1 = new Button(window) { + Text = "Iconified", + }; + button1.Resize(window.ScreenSize.Width, 100); + button1.Move(0, 0); + button1.Show(); + + button1.Clicked += (e, o) => + { + window.Iconified = true; + }; + + Button button2 = new Button(window) + { + Text = "WinKeyGrab", + }; + button2.Resize(window.ScreenSize.Width, 100); + button2.Move(0, 100); + button2.Show(); + + button2.Clicked += (e, o) => + { + Debug.WriteLine("@@KeyGrab"); + window.KeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, true); + window.WinKeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, KeyGrabMode.Exclusive); + }; + + Button button3 = new Button(window) + { + Text = "WinUnKeyGrab", + }; + button3.Resize(window.ScreenSize.Width, 100); + button3.Move(0, 200); + button3.Show(); + + button3.Clicked += (e, o) => + { + Debug.WriteLine("@@UnKeyGrab"); + window.WinKeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName); + window.KeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName); + + }; + window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true); + EventHandler handler = (s, e) => + { + Debug.WriteLine("@@KeyDown start" + e.KeyName); + + if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName) + { + Application.Current.Exit(); + } + if (e.KeyName == EvasKeyEventArgs.PlatformHomeButtonName) + { + Debug.WriteLine("@@KeyDown OK : " + window.Iconified); + window.Iconified = !window.Iconified; + } + }; + + window.KeyUp += handler; + } + + } +} diff --git a/ElmSharp.Test/TestRunner.cs b/ElmSharp.Test/TestRunner.cs index c472650..ebdab32 100644 --- a/ElmSharp.Test/TestRunner.cs +++ b/ElmSharp.Test/TestRunner.cs @@ -26,7 +26,7 @@ namespace ElmSharp.Test { public class TestRunner : CoreUIApplication { - private Window _firstPageWindow; + internal Window _firstPageWindow; private static bool s_terminated; public static string ResourceDir { get; private set; } diff --git a/ElmSharp/ElmSharp/Window.cs b/ElmSharp/ElmSharp/Window.cs index 139270c..52391de 100755 --- a/ElmSharp/ElmSharp/Window.cs +++ b/ElmSharp/ElmSharp/Window.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; namespace ElmSharp { @@ -67,6 +68,15 @@ namespace ElmSharp Transparent = 3, } + [EditorBrowsable(EditorBrowsableState.Never)] + public enum KeyGrabMode + { + Shared = 256, + Topmost = 512, + Exclusive = 1024, + OverrideExclusive = 2048, + } + /// /// The Window is container that contain the graphical user interface of a program. /// @@ -273,6 +283,19 @@ namespace ElmSharp } } + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Iconified + { + get + { + return Interop.Elementary.elm_win_iconified_get(RealHandle); + } + set + { + Interop.Elementary.elm_win_iconified_set(RealHandle, value); + } + } + /// /// This function sends a request to the Windows Manager to activate the Window. /// If honored by the WM, the window receives the keyboard focus. @@ -303,6 +326,17 @@ namespace ElmSharp Interop.Elementary.elm_win_resize_object_add(Handle, obj); } + [EditorBrowsable(EditorBrowsableState.Never)] + public void WinKeyGrab(string keyname, KeyGrabMode mode) + { + Interop.Elementary.elm_win_keygrab_set(RealHandle, keyname, 0, 0, 0, mode); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void WinKeyUngrab(string keyname) + { + Interop.Elementary.elm_win_keygrab_unset(RealHandle, keyname, 0, 0); + } /// /// Set the keygrab of the window. diff --git a/ElmSharp/Interop/Interop.Elementary.Win.cs b/ElmSharp/Interop/Interop.Elementary.Win.cs index 959f867..30871f0 100644 --- a/ElmSharp/Interop/Interop.Elementary.Win.cs +++ b/ElmSharp/Interop/Interop.Elementary.Win.cs @@ -14,6 +14,7 @@ * limitations under the License. */ +using ElmSharp; using System; using System.Runtime.InteropServices; @@ -137,6 +138,21 @@ internal static partial class Interop [DllImport(Libraries.Elementary)] internal static extern void elm_win_screen_dpi_get(IntPtr obj, out int xdpi, out int ydpi); + [DllImport(Libraries.Elementary)] + internal static extern void elm_win_iconified_set(IntPtr obj, bool iconified); + + [DllImport(Libraries.Elementary)] + [return: MarshalAs(UnmanagedType.U1)] + internal static extern bool elm_win_iconified_get(IntPtr obj); + + [DllImport(Libraries.Elementary)] + [return: MarshalAs(UnmanagedType.U1)] + internal static extern bool elm_win_keygrab_set(IntPtr obj, string key, ulong modifiers, ulong notModifiers, int proirity, KeyGrabMode grabMode); + + [DllImport(Libraries.Elementary)] + [return: MarshalAs(UnmanagedType.U1)] + internal static extern bool elm_win_keygrab_unset(IntPtr obj, string key, ulong modifiers, ulong notModifiers); + [DllImport(Libraries.Eext)] internal static extern bool eext_win_keygrab_set(IntPtr obj, string key); diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 2f140ee..5a8658a 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,4 +1,4 @@ -%define DEV_VERSION beta-018 +%define DEV_VERSION beta-019 Name: elm-sharp Summary: C# Binding for Elementary -- 2.7.4