Move get display index to C++

This commit is contained in:
Joshua Granick
2016-01-12 11:43:13 -08:00
parent bd7bb51000
commit b8646f1596
5 changed files with 23 additions and 8 deletions

View File

@@ -128,17 +128,13 @@ class NativeWindow {
public function getDisplay ():Display { public function getDisplay ():Display {
var center = new Vector2 (parent.__x + (parent.__width / 2), parent.__y + (parent.__height / 2)); if (handle != null) {
var numDisplays = System.numDisplays;
var display;
for (i in 0...numDisplays) { var index = lime_window_get_display (handle);
display = System.getDisplay (i); if (index > -1) {
if (display.bounds.containsPoint (center)) { return System.getDisplay (index);
return display;
} }
@@ -307,6 +303,7 @@ class NativeWindow {
@:cffi private static function lime_window_close (handle:Dynamic):Void; @: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_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_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_enable_text_events (handle:Dynamic):Bool;
@:cffi private static function lime_window_get_height (handle:Dynamic):Int; @:cffi private static function lime_window_get_height (handle:Dynamic):Int;
@:cffi private static function lime_window_get_id (handle:Dynamic):Int; @:cffi private static function lime_window_get_id (handle:Dynamic):Int;

View File

@@ -22,6 +22,7 @@ namespace lime {
virtual void Alert (const char* message, const char* title) = 0; virtual void Alert (const char* message, const char* title) = 0;
virtual void Close () = 0; virtual void Close () = 0;
virtual void Focus () = 0; virtual void Focus () = 0;
virtual int GetDisplay () = 0;
virtual bool GetEnableTextEvents () = 0; virtual bool GetEnableTextEvents () = 0;
virtual int GetHeight () = 0; virtual int GetHeight () = 0;
virtual uint32_t GetID () = 0; virtual uint32_t GetID () = 0;

View File

@@ -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) { bool lime_window_get_enable_text_events (value window) {
Window* targetWindow = (Window*)val_data (window); Window* targetWindow = (Window*)val_data (window);
@@ -1527,6 +1535,7 @@ namespace lime {
DEFINE_PRIME5 (lime_window_create); DEFINE_PRIME5 (lime_window_create);
DEFINE_PRIME2v (lime_window_event_manager_register); DEFINE_PRIME2v (lime_window_event_manager_register);
DEFINE_PRIME1v (lime_window_focus); DEFINE_PRIME1v (lime_window_focus);
DEFINE_PRIME1 (lime_window_get_display);
DEFINE_PRIME1 (lime_window_get_enable_text_events); DEFINE_PRIME1 (lime_window_get_enable_text_events);
DEFINE_PRIME1 (lime_window_get_height); DEFINE_PRIME1 (lime_window_get_height);
DEFINE_PRIME1 (lime_window_get_id); DEFINE_PRIME1 (lime_window_get_id);

View File

@@ -179,6 +179,13 @@ namespace lime {
} }
int SDLWindow::GetDisplay () {
return SDL_GetWindowDisplayIndex (sdlWindow);
}
bool SDLWindow::GetEnableTextEvents () { bool SDLWindow::GetEnableTextEvents () {
return SDL_IsTextInputActive (); return SDL_IsTextInputActive ();

View File

@@ -20,6 +20,7 @@ namespace lime {
virtual void Alert (const char* message, const char* title); virtual void Alert (const char* message, const char* title);
virtual void Close (); virtual void Close ();
virtual void Focus (); virtual void Focus ();
virtual int GetDisplay ();
virtual bool GetEnableTextEvents (); virtual bool GetEnableTextEvents ();
virtual int GetHeight (); virtual int GetHeight ();
virtual uint32_t GetID (); virtual uint32_t GetID ();