diff --git a/src/zen/common/ZenCommonUtils.mjs b/src/zen/common/ZenCommonUtils.mjs index 42cfd9804..d11b27558 100644 --- a/src/zen/common/ZenCommonUtils.mjs +++ b/src/zen/common/ZenCommonUtils.mjs @@ -82,13 +82,15 @@ var gZenCommonActions = { Services.io.newURI(currentUrl), '', '', - buttonRect.left - buttonRect.width / 2, - buttonRect.top + buttonRect.height + buttonRect.left, + window.innerHeight - buttonRect.bottom, + buttonRect.width, + buttonRect.height ); }, }; } - gZenUIManager.showToast('zen-copy-current-url-confirmation', { button }); + gZenUIManager.showToast('zen-copy-current-url-confirmation', { button, timeout: 3000 }); } }, copyCurrentURLAsMarkdownToClipboard() { diff --git a/src/zen/toolkit/common/ZenCommonUtils.cpp b/src/zen/toolkit/common/ZenCommonUtils.cpp index 5d257b556..e4fa84e0d 100644 --- a/src/zen/toolkit/common/ZenCommonUtils.cpp +++ b/src/zen/toolkit/common/ZenCommonUtils.cpp @@ -73,8 +73,8 @@ ZenCommonUtils::CanShare(bool* canShare) { } NS_IMETHODIMP -ZenCommonUtils::Share(nsIURI* url, const nsACString& title, - const nsACString& text, uint32_t aX, uint32_t aY) { +ZenCommonUtils::Share(nsIURI* url, const nsACString& title, const nsACString& text, + uint32_t aX, uint32_t aY, uint32_t aWidth, uint32_t aHeight) { auto aWindow = GetMostRecentWindow(); if (!aWindow) { return NS_ERROR_NOT_AVAILABLE; @@ -82,15 +82,19 @@ ZenCommonUtils::Share(nsIURI* url, const nsACString& title, if (!IsSharingSupported()) { return NS_OK; // We don't want to throw an error here } - return ShareInternal(aWindow, url, title, text, aX, aY); + return ShareInternal(aWindow, url, title, text, aX, aY, aWidth, aHeight); } nsresult ZenCommonUtils::ShareInternal(nsCOMPtr& aWindow, nsIURI* url, - const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY) { + const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY, + uint32_t aWidth, uint32_t aHeight) { // We shoud've had done pointer checks before, so we can assume // aWindow is valid. #ifdef NS_ZEN_CAN_SHARE_NATIVE - return ::nsZenNativeShareInternal::ShowNativeDialog(aWindow, url, title, text, aX, aY); + return ::nsZenNativeShareInternal::ShowNativeDialog( + aWindow, url, title, text, + aX, aY, aWidth, aHeight + ); #else return NS_ERROR_NOT_IMPLEMENTED; #endif diff --git a/src/zen/toolkit/common/ZenCommonUtils.h b/src/zen/toolkit/common/ZenCommonUtils.h index 43161d8ed..3f58702e7 100644 --- a/src/zen/toolkit/common/ZenCommonUtils.h +++ b/src/zen/toolkit/common/ZenCommonUtils.h @@ -40,7 +40,8 @@ class ZenCommonUtils final : public nsIZenCommonUtils { * @returns A promise that resolves when the share is complete. */ static auto ShareInternal(nsCOMPtr& aWindow, nsIURI* url, - const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY) + const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY, + uint32_t aWidth, uint32_t aHeight) -> nsresult; }; diff --git a/src/zen/toolkit/common/ZenShareInternal.h b/src/zen/toolkit/common/ZenShareInternal.h index 2fcc9c5f0..fd0bee5cf 100644 --- a/src/zen/toolkit/common/ZenShareInternal.h +++ b/src/zen/toolkit/common/ZenShareInternal.h @@ -29,7 +29,8 @@ class nsZenNativeShareInternal final { * @returns void */ static auto ShowNativeDialog(nsCOMPtr& aWindow, nsIURI* aUrl, - const nsACString& aTitle, const nsACString& aText, uint32_t aX = 0, uint32_t aY = 0) + const nsACString& aTitle, const nsACString& aText, uint32_t aX = 0, uint32_t aY = 0, + uint32_t aWidth = 0, uint32_t aHeight = 0) -> nsresult; nsZenNativeShareInternal() = default; diff --git a/src/zen/toolkit/common/cocoa/ZenShareInternal.mm b/src/zen/toolkit/common/cocoa/ZenShareInternal.mm index 84970d877..eb47cb62d 100644 --- a/src/zen/toolkit/common/cocoa/ZenShareInternal.mm +++ b/src/zen/toolkit/common/cocoa/ZenShareInternal.mm @@ -41,7 +41,8 @@ static nsresult GetNativeWindowPointerFromDOMWindow(mozIDOMWindowProxy* a_window } auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr& aWindow, - nsIURI* aUrl, const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY) + nsIURI* aUrl, const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY, + uint32_t aWidth, uint32_t aHeight) -> nsresult { // Just use the URL since apple doesn't support sharing text // and title in the share dialog @@ -69,9 +70,9 @@ auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr& aW return NS_ERROR_FAILURE; } // Create a rect for the sharing picker - NSRect rect = NSMakeRect(aX, aY, 0, 0); + NSRect rect = NSMakeRect(aX, aY, aWidth, aHeight); [sharingPicker showRelativeToRect:rect ofView:cocoaMru.contentView - preferredEdge:NSMinYEdge]; + preferredEdge:NSMaxYEdge]; return NS_OK; } diff --git a/src/zen/toolkit/common/nsIZenCommonUtils.idl b/src/zen/toolkit/common/nsIZenCommonUtils.idl index 86a77c209..06eb62ea8 100644 --- a/src/zen/toolkit/common/nsIZenCommonUtils.idl +++ b/src/zen/toolkit/common/nsIZenCommonUtils.idl @@ -21,7 +21,7 @@ interface nsIZenCommonUtils : nsISupports { * @returns A promise that resolves when the share is complete. */ void share(in nsIURI url, in ACString title, in ACString text, - in uint32_t x, in uint32_t y); + in uint32_t x, in uint32_t y, in uint32_t width, in uint32_t height); /* * @brief Check if the current context can share data. * @param window The window to check. diff --git a/src/zen/toolkit/common/windows/ZenShareInternal.cpp b/src/zen/toolkit/common/windows/ZenShareInternal.cpp index 55ca10aef..15b721585 100644 --- a/src/zen/toolkit/common/windows/ZenShareInternal.cpp +++ b/src/zen/toolkit/common/windows/ZenShareInternal.cpp @@ -19,8 +19,9 @@ inline NS_ConvertUTF8toUTF16 NS_ConvertUTF8toUTF16_MaybeVoid( } } // namespace: zen -auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr& aWindow, nsIURI* aUrl, - const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY) +auto nsZenNativeShareInternal::ShowNativeDialog( + nsCOMPtr& aWindow, nsIURI* aUrl, const nsACString& aTitle, + const nsACString& aText, uint32_t aX, uint32_t aY, uint32_t aWidth, uint32_t aHeight) -> nsresult { nsAutoCString urlString; if (aUrl) {