libreoffice/libreoffice-6.4.4.2-kde4-detection.patch
2020-06-03 17:40:51 +03:00

203 lines
8 KiB
Diff

diff -urN libreoffice-6.4.4.2/vcl/inc/unx/desktops.hxx libreoffice-6.4.4.2-patched/vcl/inc/unx/desktops.hxx
--- libreoffice-6.4.4.2/vcl/inc/unx/desktops.hxx 2020-05-13 14:19:20.000000000 +0300
+++ libreoffice-6.4.4.2-patched/vcl/inc/unx/desktops.hxx 2020-06-03 15:34:37.770413281 +0300
@@ -31,6 +31,7 @@
DESKTOP_UNITY,
DESKTOP_XFCE,
DESKTOP_MATE,
+ DESKTOP_KDE4,
DESKTOP_PLASMA5,
DESKTOP_LXQT
}; // keep in sync with desktop_strings[] in salplug.cxx
diff -urN libreoffice-6.4.4.2/vcl/source/app/IconThemeSelector.cxx libreoffice-6.4.4.2-patched/vcl/source/app/IconThemeSelector.cxx
--- libreoffice-6.4.4.2/vcl/source/app/IconThemeSelector.cxx 2020-05-13 14:19:20.000000000 +0300
+++ libreoffice-6.4.4.2-patched/vcl/source/app/IconThemeSelector.cxx 2020-06-03 15:36:36.153752538 +0300
@@ -60,7 +60,8 @@
return "colibre";
#else
OUString r;
- if ( desktopEnvironment.equalsIgnoreAsciiCase("plasma5") ||
+ if ( desktopEnvironment.equalsIgnoreAsciiCase("kde4") ||
+ desktopEnvironment.equalsIgnoreAsciiCase("plasma5") ||
desktopEnvironment.equalsIgnoreAsciiCase("lxqt") ) {
r = "breeze";
}
diff -urN libreoffice-6.4.4.2/vcl/source/app/salplug.cxx libreoffice-6.4.4.2-patched/vcl/source/app/salplug.cxx
--- libreoffice-6.4.4.2/vcl/source/app/salplug.cxx 2020-05-13 14:19:20.000000000 +0300
+++ libreoffice-6.4.4.2-patched/vcl/source/app/salplug.cxx 2020-06-03 15:34:37.783746616 +0300
@@ -95,6 +95,8 @@
* not access the 'gnome_accessibility_module_shutdown' anymore.
* So make sure libgtk+ & co are still mapped into memory when
* atk-bridge's atexit handler gets called.
+ * * #i109007# KDE3 seems to have the same problem.
+ * * And same applies for KDE4.
*/
if( aUsedModuleBase == "gtk3" || aUsedModuleBase == "gtk3_kde5" || aUsedModuleBase == "win" )
{
@@ -185,7 +187,9 @@
desktop == DESKTOP_XFCE ||
desktop == DESKTOP_MATE )
pList = pStandardFallbackList;
- else if (desktop == DESKTOP_PLASMA5 || desktop == DESKTOP_LXQT)
+ else if (desktop == DESKTOP_KDE4 ||
+ desktop == DESKTOP_PLASMA5 ||
+ desktop == DESKTOP_LXQT)
pList = pKDEFallbackList;
SalInstance* pInst = nullptr;
@@ -317,7 +321,7 @@
// Order to match desktops.hxx' DesktopType
static const char * const desktop_strings[] = {
"none", "unknown", "GNOME", "UNITY",
- "XFCE", "MATE", "PLASMA5", "LXQT" };
+ "XFCE", "MATE", "KDE4", "PLASMA5", "LXQT" };
static OUString aDesktopEnvironment;
if( aDesktopEnvironment.isEmpty())
{
diff -urN libreoffice-6.4.4.2/vcl/unx/generic/desktopdetect/desktopdetector.cxx libreoffice-6.4.4.2-patched/vcl/unx/generic/desktopdetect/desktopdetector.cxx
--- libreoffice-6.4.4.2/vcl/unx/generic/desktopdetect/desktopdetector.cxx 2020-05-13 14:19:20.000000000 +0300
+++ libreoffice-6.4.4.2-patched/vcl/unx/generic/desktopdetect/desktopdetector.cxx 2020-06-03 15:34:37.787079949 +0300
@@ -110,6 +110,80 @@
return ret;
}
+static bool bWasXError = false;
+
+static bool WasXError()
+{
+ bool bRet = bWasXError;
+ bWasXError = false;
+ return bRet;
+}
+
+extern "C"
+{
+ static int autodect_error_handler( Display*, XErrorEvent* )
+ {
+ bWasXError = true;
+ return 0;
+ }
+
+ typedef int(* XErrorHandler)(Display*,XErrorEvent*);
+}
+
+static int KDEVersion( Display* pDisplay )
+{
+ int nRet = 0;
+
+ Atom nFullSession = XInternAtom( pDisplay, "KDE_FULL_SESSION", True );
+ Atom nKDEVersion = XInternAtom( pDisplay, "KDE_SESSION_VERSION", True );
+
+ if( nFullSession )
+ {
+ if( !nKDEVersion )
+ return 3;
+
+ Atom aRealType = None;
+ int nFormat = 8;
+ unsigned long nItems = 0;
+ unsigned long nBytesLeft = 0;
+ unsigned char* pProperty = nullptr;
+ XGetWindowProperty( pDisplay,
+ DefaultRootWindow( pDisplay ),
+ nKDEVersion,
+ 0, 1,
+ False,
+ AnyPropertyType,
+ &aRealType,
+ &nFormat,
+ &nItems,
+ &nBytesLeft,
+ &pProperty );
+ if( !WasXError() && nItems != 0 && pProperty )
+ {
+ nRet = *reinterpret_cast< sal_Int32* >( pProperty );
+ }
+ if( pProperty )
+ {
+ XFree( pProperty );
+ pProperty = nullptr;
+ }
+ }
+ return nRet;
+}
+
+static bool is_kde4_desktop( Display* pDisplay )
+{
+ static const char * pFullVersion = getenv( "KDE_FULL_SESSION" );
+ static const char * pSessionVersion = getenv( "KDE_SESSION_VERSION" );
+ if ( pFullVersion && pSessionVersion && strcmp(pSessionVersion, "4") == 0 )
+ return true;
+
+ if ( KDEVersion( pDisplay ) == 4 )
+ return true;
+
+ return false;
+}
+
static bool is_plasma5_desktop()
{
static const char* pFullVersion = getenv("KDE_FULL_SESSION");
@@ -130,6 +204,8 @@
if ( aOver.equalsIgnoreAsciiCase( "lxqt" ) )
return DESKTOP_LXQT;
+ if ( aOver.equalsIgnoreAsciiCase( "kde4" ) )
+ return DESKTOP_KDE4;
if (aOver.equalsIgnoreAsciiCase("plasma5") || aOver.equalsIgnoreAsciiCase("plasma"))
return DESKTOP_PLASMA5;
if ( aOver.equalsIgnoreAsciiCase( "gnome" ) )
@@ -238,10 +314,16 @@
return DESKTOP_NONE;
DesktopType ret;
- if ( is_gnome_desktop( pDisplay ) )
- ret = DESKTOP_GNOME;
- else
- ret = DESKTOP_UNKNOWN;
+ XErrorHandler pOldHdl = XSetErrorHandler( autodect_error_handler );
+ if ( is_kde4_desktop( pDisplay ) )
+ ret = DESKTOP_KDE4;
+ else if ( is_gnome_desktop( pDisplay ) )
+ ret = DESKTOP_GNOME;
+ else
+ ret = DESKTOP_UNKNOWN;
+
+ // set the default handler again
+ XSetErrorHandler( pOldHdl );
XCloseDisplay( pDisplay );
diff -urN libreoffice-6.4.4.2/vcl/unx/gtk3_kde5/kde5_filepicker.cxx libreoffice-6.4.4.2-patched/vcl/unx/gtk3_kde5/kde5_filepicker.cxx
--- libreoffice-6.4.4.2/vcl/unx/gtk3_kde5/kde5_filepicker.cxx 2020-05-13 14:19:20.000000000 +0300
+++ libreoffice-6.4.4.2-patched/vcl/unx/gtk3_kde5/kde5_filepicker.cxx 2020-06-03 15:34:37.787079949 +0300
@@ -245,7 +245,7 @@
// dialog there in order not to lose the custom controls and insert the custom
// widget in the layout returned by QFileDialog::layout()
// (which returns nullptr for native file dialogs)
- if (Application::GetDesktopEnvironment() == "PLASMA5")
+ if (Application::GetDesktopEnvironment() == "PLASMA5" || Application::GetDesktopEnvironment() == "KDE4")
{
qApp->installEventFilter(this);
}
diff -urN libreoffice-6.4.4.2/vcl/unx/kf5/KF5SalInstance.cxx libreoffice-6.4.4.2-patched/vcl/unx/kf5/KF5SalInstance.cxx
--- libreoffice-6.4.4.2/vcl/unx/kf5/KF5SalInstance.cxx 2020-05-13 14:19:20.000000000 +0300
+++ libreoffice-6.4.4.2-patched/vcl/unx/kf5/KF5SalInstance.cxx 2020-06-03 15:34:37.790413282 +0300
@@ -52,7 +52,7 @@
bool KF5SalInstance::hasNativeFileSelection() const
{
- if (Application::GetDesktopEnvironment() == "PLASMA5")
+ if (Application::GetDesktopEnvironment() == "PLASMA5" || Application::GetDesktopEnvironment() == "KDE4")
return true;
return Qt5Instance::hasNativeFileSelection();
}
@@ -73,7 +73,7 @@
// In order to insert custom controls, KF5FilePicker currently relies on KFileWidget
// being used in the native file picker, which is only the case for KDE Plasma.
// Therefore, return the plain qt5 one in order to not lose custom controls.
- if (Application::GetDesktopEnvironment() == "PLASMA5")
+ if (Application::GetDesktopEnvironment() == "PLASMA5" || Application::GetDesktopEnvironment() == "KDE4")
return new KF5FilePicker(context, eMode);
return Qt5Instance::createPicker(context, eMode);
}