From b199e7ac7ddfc55c80bbffc174a813419d6e4210 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Wed, 2 Sep 2015 09:01:04 -0700 Subject: [PATCH] Rename to window.notify (should have a more robust notification system in the future) --- legacy/project/src/ExternalInterface.cpp | 28 +++++++++------ lime/_backend/flash/FlashWindow.hx | 13 ++++--- lime/_backend/html5/HTML5Window.hx | 13 ++++--- lime/_backend/native/NativeWindow.hx | 25 +++++++------- lime/ui/Window.hx | 15 +++++---- project/include/ui/Window.h | 2 +- project/src/ExternalInterface.cpp | 19 ++++++----- project/src/backend/sdl/SDLWindow.cpp | 43 ++++++++++++++---------- project/src/backend/sdl/SDLWindow.h | 4 +-- 9 files changed, 94 insertions(+), 68 deletions(-) diff --git a/legacy/project/src/ExternalInterface.cpp b/legacy/project/src/ExternalInterface.cpp index 49674fbe5..6c9472fc8 100644 --- a/legacy/project/src/ExternalInterface.cpp +++ b/legacy/project/src/ExternalInterface.cpp @@ -1,4 +1,5 @@ #include + #ifdef HX_WINDOWS #include #include @@ -566,20 +567,27 @@ 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) { + + value lime_window_notify () { #ifdef HX_WINDOWS + + int count = 0; + int speed = 0; + bool stopOnForeground = true; + SDL_SysWMinfo info; SDL_VERSION (&info.version); - SDL_GetWindowWMInfo(SDL_GL_GetCurrentWindow(), &info); - + SDL_GetWindowWMInfo (SDL_GL_GetCurrentWindow (), &info); + FLASHWINFO fi; - fi.cbSize = sizeof(FLASHWINFO); + 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); + fi.dwFlags = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER; + fi.uCount = count; + fi.dwTimeout = speed; + FlashWindowEx (&fi); + #endif return alloc_null (); @@ -587,7 +595,7 @@ namespace nme { } - DEFINE_PRIM (lime_window_alert, 3); + DEFINE_PRIM (lime_window_notify, 0); } @@ -599,4 +607,4 @@ extern "C" int lime_legacy_register_prims() { nme_register_prims(); return 0; -} +} \ No newline at end of file diff --git a/lime/_backend/flash/FlashWindow.hx b/lime/_backend/flash/FlashWindow.hx index 7774ef0c7..950a2bb14 100644 --- a/lime/_backend/flash/FlashWindow.hx +++ b/lime/_backend/flash/FlashWindow.hx @@ -70,6 +70,13 @@ class FlashWindow { + } + + + public function notify ():Void { + + + } @@ -114,9 +121,5 @@ class FlashWindow { } - public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { - - } - -} +} \ No newline at end of file diff --git a/lime/_backend/html5/HTML5Window.hx b/lime/_backend/html5/HTML5Window.hx index 1f08e63d0..aa3c6dc9d 100644 --- a/lime/_backend/html5/HTML5Window.hx +++ b/lime/_backend/html5/HTML5Window.hx @@ -520,6 +520,13 @@ class HTML5Window { + } + + + public function notify ():Void { + + + } @@ -626,9 +633,5 @@ class HTML5Window { } - public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { - - } - -} +} \ No newline at end of file diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index c2d9bc80f..1d6dfbe3b 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -154,6 +154,17 @@ class NativeWindow { } + public function notify ():Void { + + if (handle != null) { + + lime_window_notify (handle); + + } + + } + + public function resize (width:Int, height:Int):Void { if (handle != null) { @@ -233,16 +244,6 @@ 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; @@ -254,13 +255,13 @@ class NativeWindow { @:cffi private static function lime_window_get_x (handle:Float):Int; @:cffi private static function lime_window_get_y (handle:Float):Int; @:cffi private static function lime_window_move (handle:Float, x:Int, y:Int):Void; + @:cffi private static function lime_window_notify (handle:Float):Void; @:cffi private static function lime_window_resize (handle:Float, width:Int, height:Int):Void; @:cffi private static function lime_window_set_enable_text_events (handle:Float, enabled:Bool):Void; @:cffi private static function lime_window_set_fullscreen (handle:Float, fullscreen:Bool):Bool; @: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; } @@ -280,4 +281,4 @@ class NativeWindow { var WINDOW_FLAG_DEPTH_BUFFER = 0x00000200; var WINDOW_FLAG_STENCIL_BUFFER = 0x00000400; -} +} \ No newline at end of file diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index 9c877de42..b23be4a19 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -247,6 +247,13 @@ class Window { } + public function notify ():Void { + + backend.notify (); + + } + + public function resize (width:Int, height:Int):Void { backend.resize (width, height); @@ -269,12 +276,6 @@ class Window { } - public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void { - - backend.alert (count, speed, stopOnForeground); - - } - public function toString ():String { @@ -422,4 +423,4 @@ class Window { @:noCompletion private typedef WindowBackend = lime._backend.html5.HTML5Window; #else @:noCompletion private typedef WindowBackend = lime._backend.native.NativeWindow; -#end +#end \ No newline at end of file diff --git a/project/include/ui/Window.h b/project/include/ui/Window.h index 4abf98ead..efb1d5e5a 100644 --- a/project/include/ui/Window.h +++ b/project/include/ui/Window.h @@ -28,13 +28,13 @@ namespace lime { virtual int GetX () = 0; virtual int GetY () = 0; virtual void Move (int x, int y) = 0; + virtual void Notify () = 0; virtual void Resize (int width, int height) = 0; virtual void SetEnableTextEvents (bool enable) = 0; virtual bool SetFullscreen (bool fullscreen) = 0; 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; diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 1164a270e..d833de010 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1163,6 +1163,14 @@ namespace lime { } + void lime_window_notify (double window) { + + Window* targetWindow = (Window*)(intptr_t)window; + targetWindow->Notify (); + + } + + void lime_window_resize (double window, int width, int height) { Window* targetWindow = (Window*)(intptr_t)window; @@ -1211,13 +1219,6 @@ 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); @@ -1314,13 +1315,13 @@ namespace lime { DEFINE_PRIME1 (lime_window_get_x); DEFINE_PRIME1 (lime_window_get_y); DEFINE_PRIME3v (lime_window_move); + DEFINE_PRIME1v (lime_window_notify); DEFINE_PRIME3v (lime_window_resize); DEFINE_PRIME2v (lime_window_set_enable_text_events); DEFINE_PRIME2 (lime_window_set_fullscreen); DEFINE_PRIME2v (lime_window_set_icon); DEFINE_PRIME2 (lime_window_set_minimized); DEFINE_PRIME2 (lime_window_set_title); - DEFINE_PRIME4 (lime_window_alert); } @@ -1330,4 +1331,4 @@ extern "C" int lime_register_prims () { return 0; -} +} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index 511a0570b..769e2de9e 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -192,6 +192,31 @@ namespace lime { } + void SDLWindow::Notify () { + + #ifdef HX_WINDOWS + + int count = 0; + int speed = 0; + bool stopOnForeground = true; + + 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 = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER; + fi.uCount = count; + fi.dwTimeout = speed; + FlashWindowEx (&fi); + + #endif + + } + + void SDLWindow::Resize (int width, int height) { SDL_SetWindowSize (sdlWindow, width, height); @@ -270,22 +295,6 @@ 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) { @@ -294,4 +303,4 @@ namespace lime { } -} +} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLWindow.h b/project/src/backend/sdl/SDLWindow.h index f4c47c2b0..24d1e6e06 100644 --- a/project/src/backend/sdl/SDLWindow.h +++ b/project/src/backend/sdl/SDLWindow.h @@ -26,13 +26,13 @@ namespace lime { virtual int GetX (); virtual int GetY (); virtual void Move (int x, int y); + virtual void Notify (); virtual void Resize (int width, int height); virtual void SetEnableTextEvents (bool enabled); virtual bool SetFullscreen (bool fullscreen); 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; @@ -42,4 +42,4 @@ namespace lime { } -#endif +#endif \ No newline at end of file