diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index f6ba24f8f..5df5df748 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -128,17 +128,13 @@ class NativeWindow { public function getDisplay ():Display { - var center = new Vector2 (parent.__x + (parent.__width / 2), parent.__y + (parent.__height / 2)); - var numDisplays = System.numDisplays; - var display; - - for (i in 0...numDisplays) { + if (handle != null) { - display = System.getDisplay (i); + var index = lime_window_get_display (handle); - if (display.bounds.containsPoint (center)) { + if (index > -1) { - return display; + return System.getDisplay (index); } @@ -307,6 +303,7 @@ class NativeWindow { @:cffi private static function lime_window_close (handle:Dynamic):Void; @:cffi private static function lime_window_create (application:Dynamic, width:Int, height:Int, flags:Int, title:String):Dynamic; @:cffi private static function lime_window_focus (handle:Dynamic):Void; + @:cffi private static function lime_window_get_display (handle:Dynamic):Int; @:cffi private static function lime_window_get_enable_text_events (handle:Dynamic):Bool; @:cffi private static function lime_window_get_height (handle:Dynamic):Int; @:cffi private static function lime_window_get_id (handle:Dynamic):Int; diff --git a/project/include/ui/Window.h b/project/include/ui/Window.h index 453cbffde..b09d10d59 100644 --- a/project/include/ui/Window.h +++ b/project/include/ui/Window.h @@ -22,6 +22,7 @@ namespace lime { virtual void Alert (const char* message, const char* title) = 0; virtual void Close () = 0; virtual void Focus () = 0; + virtual int GetDisplay () = 0; virtual bool GetEnableTextEvents () = 0; virtual int GetHeight () = 0; virtual uint32_t GetID () = 0; diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index a4c8c3317..91fe125e9 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1300,6 +1300,14 @@ namespace lime { } + int lime_window_get_display (value window) { + + Window* targetWindow = (Window*)val_data (window); + return targetWindow->GetDisplay (); + + } + + bool lime_window_get_enable_text_events (value window) { Window* targetWindow = (Window*)val_data (window); @@ -1527,6 +1535,7 @@ namespace lime { DEFINE_PRIME5 (lime_window_create); DEFINE_PRIME2v (lime_window_event_manager_register); DEFINE_PRIME1v (lime_window_focus); + DEFINE_PRIME1 (lime_window_get_display); DEFINE_PRIME1 (lime_window_get_enable_text_events); DEFINE_PRIME1 (lime_window_get_height); DEFINE_PRIME1 (lime_window_get_id); diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index d1693e500..fa47de57b 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -179,6 +179,13 @@ namespace lime { } + int SDLWindow::GetDisplay () { + + return SDL_GetWindowDisplayIndex (sdlWindow); + + } + + bool SDLWindow::GetEnableTextEvents () { return SDL_IsTextInputActive (); diff --git a/project/src/backend/sdl/SDLWindow.h b/project/src/backend/sdl/SDLWindow.h index 6de21a22b..4a66f8224 100644 --- a/project/src/backend/sdl/SDLWindow.h +++ b/project/src/backend/sdl/SDLWindow.h @@ -20,6 +20,7 @@ namespace lime { virtual void Alert (const char* message, const char* title); virtual void Close (); virtual void Focus (); + virtual int GetDisplay (); virtual bool GetEnableTextEvents (); virtual int GetHeight (); virtual uint32_t GetID ();