From a8a7ff4dadd9294c316306fc6114c42628aa71a0 Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:10:48 -0400 Subject: [PATCH 1/9] Added Alert function --- project/include/ui/Window.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/include/ui/Window.h b/project/include/ui/Window.h index a8286c342..4abf98ead 100644 --- a/project/include/ui/Window.h +++ b/project/include/ui/Window.h @@ -34,6 +34,7 @@ namespace lime { virtual void SetIcon (ImageBuffer *imageBuffer) = 0; virtual bool SetMinimized (bool minimized) = 0; virtual const char* SetTitle (const char* title) = 0; + virtual void Alert (int count, int speed, bool stop_on_foreground) = 0; Application* currentApplication; int flags; @@ -64,4 +65,4 @@ namespace lime { } -#endif \ No newline at end of file +#endif From 62b2c765434a6243d2497b8368d01f81986700cf Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:12:03 -0400 Subject: [PATCH 2/9] Added Alert function --- project/src/backend/sdl/SDLWindow.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index b074c8f37..511a0570b 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -270,6 +270,22 @@ namespace lime { } + void SDLWindow::Alert (int count, int speed, bool stop_on_foreground) { + + SDL_SysWMinfo info; + SDL_VERSION (&info.version); + SDL_GetWindowWMInfo(sdlWindow, &info); + + FLASHWINFO fi; + fi.cbSize = sizeof(FLASHWINFO); + fi.hwnd = info.info.win.window; + fi.dwFlags = stop_on_foreground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER; + fi.uCount = count; + fi.dwTimeout = speed; + FlashWindowEx(&fi); + + } + Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) { @@ -278,4 +294,4 @@ namespace lime { } -} \ No newline at end of file +} From 77b9243ce8a3a88607bf77bc739c8f2d6e2b49d8 Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:12:41 -0400 Subject: [PATCH 3/9] Added Alert function --- project/src/backend/sdl/SDLWindow.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/src/backend/sdl/SDLWindow.h b/project/src/backend/sdl/SDLWindow.h index 37d0aff43..f4c47c2b0 100644 --- a/project/src/backend/sdl/SDLWindow.h +++ b/project/src/backend/sdl/SDLWindow.h @@ -32,6 +32,7 @@ namespace lime { virtual void SetIcon (ImageBuffer *imageBuffer); virtual bool SetMinimized (bool minimized); virtual const char* SetTitle (const char* title); + virtual void Alert (int count, int speed, bool stop_on_foreground); SDL_Window* sdlWindow; @@ -41,4 +42,4 @@ namespace lime { } -#endif \ No newline at end of file +#endif From 81acecfaeabf52e8b3aebaab3d185a7cec88ecb8 Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:16:12 -0400 Subject: [PATCH 4/9] Update ExternalInterface.cpp --- project/src/ExternalInterface.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 673199903..1164a270e 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1211,6 +1211,13 @@ namespace lime { } + void lime_window_alert (double window, int count, int speed, bool stop_on_forground) { + + Window* targetWindow = (Window*)(intptr_t)window; + targetWindow->Alert (count, speed, stop_on_forground); + + } + DEFINE_PRIME1 (lime_application_create); DEFINE_PRIME2v (lime_application_event_manager_register); @@ -1313,6 +1320,7 @@ namespace lime { DEFINE_PRIME2v (lime_window_set_icon); DEFINE_PRIME2 (lime_window_set_minimized); DEFINE_PRIME2 (lime_window_set_title); + DEFINE_PRIME4 (lime_window_alert); } @@ -1322,4 +1330,4 @@ extern "C" int lime_register_prims () { return 0; -} \ No newline at end of file +} From a04580895098ffd3e90af8d63f2d867b430a5924 Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:17:44 -0400 Subject: [PATCH 5/9] Added Alert function --- lime/ui/Window.hx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index f54fbadf1..9c877de42 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -269,6 +269,12 @@ class Window { } + public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { + + backend.alert (count, speed, stopOnForeground); + + } + public function toString ():String { @@ -416,4 +422,4 @@ class Window { @:noCompletion private typedef WindowBackend = lime._backend.html5.HTML5Window; #else @:noCompletion private typedef WindowBackend = lime._backend.native.NativeWindow; -#end \ No newline at end of file +#end From 98ed2c02458469e073ee8a527c172728ffa478ff Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:18:11 -0400 Subject: [PATCH 6/9] Added Alert function --- lime/_backend/flash/FlashWindow.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lime/_backend/flash/FlashWindow.hx b/lime/_backend/flash/FlashWindow.hx index 204d74542..7774ef0c7 100644 --- a/lime/_backend/flash/FlashWindow.hx +++ b/lime/_backend/flash/FlashWindow.hx @@ -114,5 +114,9 @@ class FlashWindow { } + public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { + + } -} \ No newline at end of file + +} From 3a2b94009cc25db8518300ae9d066e516c612459 Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:18:30 -0400 Subject: [PATCH 7/9] Added Alert function --- lime/_backend/html5/HTML5Window.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lime/_backend/html5/HTML5Window.hx b/lime/_backend/html5/HTML5Window.hx index 4da179f18..1f08e63d0 100644 --- a/lime/_backend/html5/HTML5Window.hx +++ b/lime/_backend/html5/HTML5Window.hx @@ -626,5 +626,9 @@ class HTML5Window { } + public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { + + } -} \ No newline at end of file + +} From c05e0825ac4dd35b8532d5384f6eceb234d67e8c Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:20:05 -0400 Subject: [PATCH 8/9] Added Alert function --- lime/_backend/native/NativeWindow.hx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index 3d06f60df..c2d9bc80f 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -233,6 +233,16 @@ class NativeWindow { } + public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { + + if (handle != null) { + + lime_window_alert (handle, count, speed, stopOnForeground); + + } + + } + @:cffi private static function lime_window_close (handle:Float):Void; @:cffi private static function lime_window_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float; @@ -250,6 +260,7 @@ class NativeWindow { @:cffi private static function lime_window_set_icon (handle:Float, buffer:Dynamic):Void; @:cffi private static function lime_window_set_minimized (handle:Float, minimized:Bool):Bool; @:cffi private static function lime_window_set_title (handle:Float, title:String):String; + @:cffi private static function lime_window_alert (handle:Float, count:Int, speed:Int, stopOnForeground:Bool):Void; } @@ -269,4 +280,4 @@ class NativeWindow { var WINDOW_FLAG_DEPTH_BUFFER = 0x00000200; var WINDOW_FLAG_STENCIL_BUFFER = 0x00000400; -} \ No newline at end of file +} From 04b30f501044f4f5d55716483a33d351147ce780 Mon Sep 17 00:00:00 2001 From: Tommy X Date: Tue, 1 Sep 2015 20:21:11 -0400 Subject: [PATCH 9/9] Added Alert function --- legacy/project/src/ExternalInterface.cpp | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/legacy/project/src/ExternalInterface.cpp b/legacy/project/src/ExternalInterface.cpp index 9e997b297..49674fbe5 100644 --- a/legacy/project/src/ExternalInterface.cpp +++ b/legacy/project/src/ExternalInterface.cpp @@ -1,4 +1,8 @@ #include +#ifdef HX_WINDOWS +#include +#include +#endif // Custom DEFINE_PRIM macro when calls are the same as NME @@ -562,6 +566,29 @@ namespace nme { DEFINE_LIME_LEGACY_PRIM_1(gl_s3d_set_focal_length); #endif + value lime_window_alert (value count, value speed, value stop_on_forground) { + + #ifdef HX_WINDOWS + SDL_SysWMinfo info; + SDL_VERSION (&info.version); + SDL_GetWindowWMInfo(SDL_GL_GetCurrentWindow(), &info); + + FLASHWINFO fi; + fi.cbSize = sizeof(FLASHWINFO); + fi.hwnd = info.info.win.window; + fi.dwFlags = val_bool (stop_on_forground) ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER; + fi.uCount = val_int (count); + fi.dwTimeout = val_int (speed); + FlashWindowEx(&fi); + #endif + + return alloc_null (); + + } + + + DEFINE_PRIM (lime_window_alert, 3); + } @@ -572,4 +599,4 @@ extern "C" int lime_legacy_register_prims() { nme_register_prims(); return 0; -} \ No newline at end of file +}