diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be762d9a..306b4da79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -8.0.0 (??/??/2022) +8.0.0 (08/30/2022) ------------------ * Updated HashLink to version 1.12 diff --git a/project/include/ui/MouseEvent.h b/project/include/ui/MouseEvent.h index 72da59a18..c3f86aa9a 100644 --- a/project/include/ui/MouseEvent.h +++ b/project/include/ui/MouseEvent.h @@ -30,6 +30,7 @@ namespace lime { int windowID; double x; double y; + int clickCount; static ValuePointer* callback; static ValuePointer* eventObject; diff --git a/project/src/backend/sdl/SDLApplication.cpp b/project/src/backend/sdl/SDLApplication.cpp index 07b7e81fd..7948d769d 100644 --- a/project/src/backend/sdl/SDLApplication.cpp +++ b/project/src/backend/sdl/SDLApplication.cpp @@ -622,6 +622,7 @@ namespace lime { mouseEvent.button = event->button.button - 1; mouseEvent.x = event->button.x; mouseEvent.y = event->button.y; + mouseEvent.clickCount = event->button.clicks; break; case SDL_MOUSEBUTTONUP: @@ -632,6 +633,7 @@ namespace lime { mouseEvent.button = event->button.button - 1; mouseEvent.x = event->button.x; mouseEvent.y = event->button.y; + mouseEvent.clickCount = event->button.clicks; break; case SDL_MOUSEWHEEL: diff --git a/project/src/ui/MouseEvent.cpp b/project/src/ui/MouseEvent.cpp index 4bb5cbf67..e28100d61 100644 --- a/project/src/ui/MouseEvent.cpp +++ b/project/src/ui/MouseEvent.cpp @@ -15,6 +15,7 @@ namespace lime { static int id_windowID; static int id_x; static int id_y; + static int id_clickCount; static bool init = false; @@ -27,6 +28,7 @@ namespace lime { y = 0.0; movementX = 0.0; movementY = 0.0; + clickCount = 0; } @@ -46,6 +48,7 @@ namespace lime { id_windowID = val_id ("windowID"); id_x = val_id ("x"); id_y = val_id ("y"); + id_clickCount = val_id ("clickCount"); init = true; } @@ -55,7 +58,11 @@ namespace lime { if (event->type != MOUSE_WHEEL) { alloc_field (object, id_button, alloc_int (event->button)); + } + if (event->type != MOUSE_WHEEL && event->type != MOUSE_MOVE) { + + alloc_field (object, id_clickCount, alloc_int (event->clickCount)); } alloc_field (object, id_movementX, alloc_float (event->movementX)); @@ -70,6 +77,7 @@ namespace lime { MouseEvent* eventObject = (MouseEvent*)MouseEvent::eventObject->Get (); eventObject->button = event->button; + eventObject->clickCount = event->clickCount; eventObject->movementX = event->movementX; eventObject->movementY = event->movementY; eventObject->type = event->type; diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index c938bd193..a5a636025 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -76,6 +76,8 @@ class HTML5Window private var textInputRect:Rectangle; private var unusedTouchesPool = new List(); + private var __focusPending:Bool; + public function new(parent:Window) { this.parent = parent; @@ -340,6 +342,19 @@ class HTML5Window public function focus():Void {} + private function focusTextInput():Void + { + // Avoid changing focus multiple times per frame. + if (__focusPending) return; + __focusPending = true; + + Timer.delay(function() + { + __focusPending = false; + if (textInputEnabled) textInput.focus(); + }, 20); + } + public function getCursor():MouseCursor { return cursor; @@ -462,10 +477,7 @@ class HTML5Window { if (event.relatedTarget == null || isDescendent(cast event.relatedTarget)) { - Timer.delay(function() - { - if (textInputEnabled) textInput.focus(); - }, 20); + focusTextInput(); } } } @@ -930,6 +942,10 @@ class HTML5Window { Browser.document.execCommand("copy"); } + if (textInputEnabled) + { + focusTextInput(); + } } public function setCursor(value:MouseCursor):MouseCursor diff --git a/src/lime/_internal/backend/native/NativeApplication.hx b/src/lime/_internal/backend/native/NativeApplication.hx index af2f38d29..55bbc602a 100644 --- a/src/lime/_internal/backend/native/NativeApplication.hx +++ b/src/lime/_internal/backend/native/NativeApplication.hx @@ -1,5 +1,6 @@ package lime._internal.backend.native; +import haxe.Int64; import haxe.Timer; import lime._internal.backend.native.NativeCFFI; import lime.app.Application; @@ -335,10 +336,10 @@ class NativeApplication switch (mouseEventInfo.type) { case MOUSE_DOWN: - window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button); + window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button, mouseEventInfo.clickCount); case MOUSE_UP: - window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button); + window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button, mouseEventInfo.clickCount); case MOUSE_MOVE: window.onMouseMove.dispatch(mouseEventInfo.x, mouseEventInfo.y); @@ -779,6 +780,7 @@ class NativeApplication @:keep /*private*/ class MouseEventInfo { public var button:Int; + public var clickCount:Int; public var movementX:Float; public var movementY:Float; public var type:MouseEventType; @@ -786,7 +788,7 @@ class NativeApplication public var x:Float; public var y:Float; - public function new(type:MouseEventType = null, windowID:Int = 0, x:Float = 0, y:Float = 0, button:Int = 0, movementX:Float = 0, movementY:Float = 0) + public function new(type:MouseEventType = null, windowID:Int = 0, x:Float = 0, y:Float = 0, button:Int = 0, movementX:Float = 0, movementY:Float = 0, clickCount:Int = 0) { this.type = type; this.windowID = 0; @@ -795,6 +797,7 @@ class NativeApplication this.button = button; this.movementX = movementX; this.movementY = movementY; + this.clickCount = clickCount; } public function clone():MouseEventInfo diff --git a/src/lime/_internal/backend/native/NativeAudioSource.hx b/src/lime/_internal/backend/native/NativeAudioSource.hx index ee3cc8031..d44f6a26a 100644 --- a/src/lime/_internal/backend/native/NativeAudioSource.hx +++ b/src/lime/_internal/backend/native/NativeAudioSource.hx @@ -187,8 +187,6 @@ class NativeAudioSource { var time = completed ? 0 : getCurrentTime(); - AL.sourcePlay(handle); - setCurrentTime(time); } } @@ -417,7 +415,7 @@ class NativeAudioSource else if (parent.buffer != null) { AL.sourceRewind(handle); - if (playing) AL.sourcePlay(handle); + // AL.sourcef (handle, AL.SEC_OFFSET, (value + parent.offset) / 1000); var secondOffset = (value + parent.offset) / 1000; @@ -430,6 +428,7 @@ class NativeAudioSource var totalOffset = Std.int(dataLength * ratio); AL.sourcei(handle, AL.BYTE_OFFSET, totalOffset); + if (playing) AL.sourcePlay(handle); } } diff --git a/src/lime/_internal/backend/native/NativeHTTPRequest.hx b/src/lime/_internal/backend/native/NativeHTTPRequest.hx index f5e3934c9..9f7c65186 100644 --- a/src/lime/_internal/backend/native/NativeHTTPRequest.hx +++ b/src/lime/_internal/backend/native/NativeHTTPRequest.hx @@ -393,8 +393,9 @@ class NativeHTTPRequest } private function curl_onWrite(curl:CURL, output:Bytes):Int - { - buffer.add(output); + { + buffer.addBytes(output, 0, output.length); + return output.length; } diff --git a/src/lime/app/Application.hx b/src/lime/app/Application.hx index 0cdf4d3e7..6905d380b 100644 --- a/src/lime/app/Application.hx +++ b/src/lime/app/Application.hx @@ -260,7 +260,7 @@ class Application extends Module @param y The current y coordinate of the mouse @param button The ID of the mouse button that was pressed **/ - public function onMouseDown(x:Float, y:Float, button:MouseButton):Void {} + public function onMouseDown(x:Float, y:Float, button:MouseButton, clickCount:Int):Void {} /** Called when a mouse move event is fired on the primary window @@ -282,7 +282,7 @@ class Application extends Module @param y The current y coordinate of the mouse @param button The ID of the button that was released **/ - public function onMouseUp(x:Float, y:Float, button:MouseButton):Void {} + public function onMouseUp(x:Float, y:Float, button:MouseButton, clickCount:Int):Void {} /** Called when a mouse wheel event is fired on the primary window diff --git a/src/lime/system/Clipboard.hx b/src/lime/system/Clipboard.hx index cb66fc2ee..6e7f71557 100644 --- a/src/lime/system/Clipboard.hx +++ b/src/lime/system/Clipboard.hx @@ -52,10 +52,22 @@ class Clipboard // Get & Set Methods private static function get_text():String { - // Native clipboard calls __update when clipboard changes + // Native clipboard (except Xorg) calls __update when clipboard changes. #if (flash || js || html5) __update(); + #elseif linux + // Xorg won't call __update until we call set_text at least once. + // Details: SDL_x11clipboard.c calls X11_XSetSelectionOwner, + // registering this app to receive clipboard events. + if (_text == null) + { + __update(); + + // Call set_text while changing as little as possible. (Rich text + // formatting will unavoidably be lost.) + set_text(_text); + } #end return _text; diff --git a/src/lime/system/JNI.hx b/src/lime/system/JNI.hx index ad2577f71..fea483491 100644 --- a/src/lime/system/JNI.hx +++ b/src/lime/system/JNI.hx @@ -367,7 +367,7 @@ class JNIMethod ``` **/ // Haxe 3 can't parse "target.threaded" inside parentheses. -#if !lime_doc_gen +#if !doc_gen #if target.threaded @:autoBuild(lime.system.JNI.JNISafetyTools.build()) #elseif (cpp || neko) @@ -376,7 +376,7 @@ class JNIMethod #end interface JNISafety {} -#if !lime_doc_gen +#if !doc_gen class JNISafetyTools { #if target.threaded diff --git a/src/lime/tools/IconHelper.hx b/src/lime/tools/IconHelper.hx index 1b862dd67..7db1dfdb1 100644 --- a/src/lime/tools/IconHelper.hx +++ b/src/lime/tools/IconHelper.hx @@ -298,9 +298,11 @@ class IconHelper for (icon in icons) { var iconDifference = icon.width - width + icon.height - height; - if (Path.extension(icon.path) == "svg") + + // If size is unspecified, accept it as an almost-perfect match + if (icon.width == 0 && icon.height == 0) { - iconDifference = 0; + iconDifference = 1; } if (iconDifference < 0 && !acceptSmaller) diff --git a/src/lime/ui/Window.hx b/src/lime/ui/Window.hx index 1cdc8dd73..c430a30f6 100644 --- a/src/lime/ui/Window.hx +++ b/src/lime/ui/Window.hx @@ -67,10 +67,10 @@ class Window public var onLeave(default, null) = new EventVoid>(); public var onMaximize(default, null) = new EventVoid>(); public var onMinimize(default, null) = new EventVoid>(); - public var onMouseDown(default, null) = new EventFloat->MouseButton->Void>(); + public var onMouseDown(default, null) = new EventFloat->MouseButton->Int->Void>(); public var onMouseMove(default, null) = new EventFloat->Void>(); public var onMouseMoveRelative(default, null) = new EventFloat->Void>(); - public var onMouseUp(default, null) = new EventFloat->Int->Void>(); + public var onMouseUp(default, null) = new EventFloat->Int->Int->Void>(); public var onMouseWheel(default, null) = new EventFloat->MouseWheelMode->Void>(); public var onMove(default, null) = new EventFloat->Void>(); public var onRender(default, null) = new EventVoid>(); diff --git a/src/lime/utils/AssetLibrary.hx b/src/lime/utils/AssetLibrary.hx index 263081c45..673b0d476 100644 --- a/src/lime/utils/AssetLibrary.hx +++ b/src/lime/utils/AssetLibrary.hx @@ -334,10 +334,12 @@ class AssetLibrary return true; } - var requestedType = type != null ? cast(type, AssetType) : null; - - return switch (requestedType) + return switch (cast(type, AssetType)) { + case null: + cachedBytes.exists(id) || cachedText.exists(id) || cachedImages.exists(id) + || cachedAudioBuffers.exists(id) || cachedFonts.exists(id); + case IMAGE: cachedImages.exists(id); @@ -347,7 +349,8 @@ class AssetLibrary case FONT: cachedFonts.exists(id); - default: cachedBytes.exists(id) || cachedText.exists(id); + default: + cachedBytes.exists(id) || cachedText.exists(id); } #end } diff --git a/src/lime/utils/PackedAssetLibrary.hx b/src/lime/utils/PackedAssetLibrary.hx index 4015d1f29..dd976c22e 100644 --- a/src/lime/utils/PackedAssetLibrary.hx +++ b/src/lime/utils/PackedAssetLibrary.hx @@ -241,11 +241,10 @@ import flash.media.Sound; } else { - var basePath = rootPath; - if (basePath == null) basePath = ""; - if (basePath != "" && !StringTools.endsWith(basePath, "/")) basePath += "/"; + var basePath = rootPath == null || rootPath == "" ? "" : Path.addTrailingSlash(rootPath); + var libPath = paths.exists(id) ? paths.get(id) : id; - var path = basePath + (paths.exists(id) ? paths.get(id) : id); + var path = Path.join([basePath, libPath]); path = __cacheBreak(path); Bytes.loadFromFile(path).onError(promise.error).onComplete(packedData_onComplete); diff --git a/templates/cpp/static/Main.cpp b/templates/cpp/static/Main.cpp index dc71655b3..290d63baa 100644 --- a/templates/cpp/static/Main.cpp +++ b/templates/cpp/static/Main.cpp @@ -1,6 +1,6 @@ #include -#ifdef HX_WINDOWS +#if defined(HX_WINDOWS) && !defined(HXCPP_DEBUG) #include #endif @@ -14,7 +14,7 @@ extern "C" int lime_openal_register_prims (); extern "C" int ::nameSafe::_register_prims ();::end::::end:: -#ifdef HX_WINDOWS +#if defined(HX_WINDOWS) && !defined(HXCPP_DEBUG) int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #else extern "C" int main(int argc, char *argv[]) { @@ -40,4 +40,4 @@ extern "C" int main(int argc, char *argv[]) { return 0; -} \ No newline at end of file +} diff --git a/templates/haxe/ManifestResources.hx b/templates/haxe/ManifestResources.hx index d8565bcde..b1d526120 100644 --- a/templates/haxe/ManifestResources.hx +++ b/templates/haxe/ManifestResources.hx @@ -44,6 +44,12 @@ import sys.FileSystem; rootPath = Reflect.field (config, "rootPath"); + if(!StringTools.endsWith (rootPath, "/")) { + + rootPath += "/"; + + } + } if (rootPath == null) { @@ -84,9 +90,9 @@ import sys.FileSystem; Assets.registerLibrary ("::library::", library); ::else::Assets.libraryPaths["::library::"] = rootPath + "::resourceName::"; ::end::::end::::if (type == "bundle")::::if (embed):: - bundle = AssetBundle.fromBytes(#if flash Bytes.ofData(new __ASSET__::flatName::() #else new __ASSET__::flatName::() #end)); - library = AssetLibrary.fromBundle(bundle); - Assets.registerLibrary("::library::", library); + bundle = AssetBundle.fromBytes (#if flash Bytes.ofData (new __ASSET__::flatName:: () #else new __ASSET__::flatName:: () #end)); + library = AssetLibrary.fromBundle (bundle); + Assets.registerLibrary ("::library::", library); ::else::Assets.bundlePaths["::library::"] = rootPath + "::resourceName::"; ::end::::end::::end::::end::