From d7951bf2244b7f96ceaa331794532739122957e5 Mon Sep 17 00:00:00 2001 From: Andrey Bondrov Date: Tue, 18 Feb 2014 20:02:32 +1100 Subject: [PATCH] LOG Add patch to fix setting wallpaper in KDE4 --- firefox.spec | 6 +- mozilla-kde-background.patch | 139 +++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 mozilla-kde-background.patch diff --git a/firefox.spec b/firefox.spec index 1b625d1..0791359 100644 --- a/firefox.spec +++ b/firefox.spec @@ -24,15 +24,13 @@ %define _use_syshunspell 0 -%define release 1 - %define update_channel release Summary: Next generation web browser Name: firefox Version: %{major} Epoch: %{ff_epoch} -Release: %{release} +Release: 2 License: MPLv1+ Group: Networking/WWW Url: http://www.mozilla.com/firefox/ @@ -57,6 +55,7 @@ Patch10: firefox-3.5.3-default-mail-handler.patch # Patches for kde integration of FF Patch11: firefox-27-kde.patch Patch12: mozilla-27-kde.patch +Patch13: mozilla-kde-background.patch Patch34: xulrunner_nojit.patch # Upstream patches @@ -171,6 +170,7 @@ Files and macros mainly for building Firefox extensions. # Disable kde integration , need refactoring %patch11 -p1 -b .kdepatch %patch12 -p1 -b .kdemoz +%patch13 -p1 -b .kdebackground %ifarch %arm %if "%{_target_cpu}" != "armv7l" diff --git a/mozilla-kde-background.patch b/mozilla-kde-background.patch new file mode 100644 index 0000000..7ee40a8 --- /dev/null +++ b/mozilla-kde-background.patch @@ -0,0 +1,139 @@ +diff -urN mozilla-orig/browser/components/shell/src/nsKDEShellService.cpp mozilla-patched/browser/components/shell/src/nsKDEShellService.cpp +--- mozilla-orig/browser/components/shell/src/nsKDEShellService.cpp 2014-02-16 11:27:48.238244349 +1100 ++++ mozilla-patched/browser/components/shell/src/nsKDEShellService.cpp 2014-02-18 19:57:45.740168755 +1100 +@@ -15,6 +15,21 @@ + #include "nsIMutableArray.h" + #include "nsISupportsPrimitives.h" + #include "nsArrayUtils.h" ++#include "nsIImageLoadingContent.h" ++#include "imgIRequest.h" ++#include "nsIStringBundle.h" ++#include "nsIDOMHTMLImageElement.h" ++#include "prenv.h" ++ ++#include ++#include ++#include ++#include ++#if defined(MOZ_WIDGET_GTK) ++#include "nsIImageToPixbuf.h" ++#endif ++#include ++#include + + nsresult + nsKDEShellService::Init() +@@ -115,23 +130,109 @@ + return NS_OK; + } + ++static nsresult ++WriteImage(const nsCString& aPath, imgIContainer* aImage) ++{ ++#if !defined(MOZ_WIDGET_GTK) ++ return NS_ERROR_NOT_AVAILABLE; ++#else ++ nsCOMPtr imgToPixbuf = ++ do_GetService("@mozilla.org/widget/image-to-gdk-pixbuf;1"); ++ if (!imgToPixbuf) ++ return NS_ERROR_NOT_AVAILABLE; ++ ++ GdkPixbuf* pixbuf = imgToPixbuf->ConvertImageToPixbuf(aImage); ++ if (!pixbuf) ++ return NS_ERROR_NOT_AVAILABLE; ++ ++ gboolean res = gdk_pixbuf_save(pixbuf, aPath.get(), "png", nullptr, nullptr); ++ ++ g_object_unref(pixbuf); ++ return res ? NS_OK : NS_ERROR_FAILURE; ++#endif ++} ++ + NS_IMETHODIMP + nsKDEShellService::SetDesktopBackground(nsIDOMElement* aElement, + PRInt32 aPosition) +- { +- return NS_ERROR_NOT_IMPLEMENTED; ++{ ++ nsresult rv; ++ nsCOMPtr imageContent = do_QueryInterface(aElement, &rv); ++ if (!imageContent) return rv; ++ ++ // get the image container ++ nsCOMPtr request; ++ rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, ++ getter_AddRefs(request)); ++ if (!request) return rv; ++ nsCOMPtr container; ++ rv = request->GetImage(getter_AddRefs(container)); ++ if (!container) return rv; ++ ++ // Set desktop wallpaper filling style ++ nsAutoCString options; ++ if (aPosition == BACKGROUND_TILE) ++ options.Assign("TiledResize"); ++ else if (aPosition == BACKGROUND_STRETCH) ++ options.Assign("ScaledResize"); ++ else if (aPosition == BACKGROUND_FILL) ++ options.Assign("ScaledAndCroppedResize"); ++ else if (aPosition == BACKGROUND_FIT) ++ options.Assign("MaxpectResize"); ++ else ++ options.Assign("CenteredResize"); ++ ++ // Write the background file to the home directory. ++ nsAutoCString filePath(PR_GetEnv("HOME")); ++ ++ // get the product brand name from localized strings ++ nsString brandName; ++ nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID; ++ nsCOMPtr bundleService(do_GetService(bundleCID)); ++ if (bundleService) { ++ nsCOMPtr brandBundle; ++ rv = bundleService->CreateBundle(BRAND_PROPERTIES, ++ getter_AddRefs(brandBundle)); ++ if (NS_SUCCEEDED(rv) && brandBundle) { ++ rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), ++ getter_Copies(brandName)); ++ NS_ENSURE_SUCCESS(rv, rv); + } ++ } + ++ // build the file name ++ filePath.Append('/'); ++ filePath.Append(NS_ConvertUTF16toUTF8(brandName)); ++ filePath.Append("_wallpaper.png"); ++ ++ // write the image to a file in the home dir ++ rv = WriteImage(filePath, container); ++ NS_ENSURE_SUCCESS(rv, rv); ++ ++ nsCOMPtr command = do_CreateInstance( NS_ARRAY_CONTRACTID ); ++ nsCOMPtr cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID ); ++ nsCOMPtr imgstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID ); ++ nsCOMPtr modestr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID ); ++ cmdstr->SetData( NS_LITERAL_CSTRING( "SETWALLPAPER" )); ++ command->AppendElement( cmdstr, false ); ++ imgstr->SetData( filePath ); ++ command->AppendElement( imgstr, false ); ++ modestr->SetData( options ); ++ command->AppendElement( modestr, false ); ++ return nsKDEUtils::command( command ) ? rv : NS_ERROR_FAILURE; ++} ++ + NS_IMETHODIMP + nsKDEShellService::GetDesktopBackgroundColor(PRUint32 *aColor) + { +- return NS_ERROR_NOT_IMPLEMENTED; ++ aColor = 0; ++ return NS_OK; + } + + NS_IMETHODIMP + nsKDEShellService::SetDesktopBackgroundColor(PRUint32 aColor) + { +- return NS_ERROR_NOT_IMPLEMENTED; ++ return NS_OK; + } + + NS_IMETHODIMP