summaryrefslogtreecommitdiffstats
path: root/kcontrol/input/main.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/input/main.cpp
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/input/main.cpp')
-rw-r--r--kcontrol/input/main.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/kcontrol/input/main.cpp b/kcontrol/input/main.cpp
new file mode 100644
index 000000000..f0a464adc
--- /dev/null
+++ b/kcontrol/input/main.cpp
@@ -0,0 +1,96 @@
+/*
+ * main.cpp
+ *
+ * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <dcopref.h>
+#include <qfile.h>
+
+#include <X11/Xlib.h>
+
+#ifdef HAVE_XCURSOR
+# include <X11/Xcursor/Xcursor.h>
+#endif
+
+#include "mouse.h"
+
+extern "C"
+{
+ KDE_EXPORT KCModule *create_mouse(QWidget *parent, const char *)
+ {
+ return new MouseConfig(parent, "kcminput");
+ }
+
+ KDE_EXPORT void init_mouse()
+ {
+ KConfig *config = new KConfig("kcminputrc", true, false); // Read-only, no globals
+ MouseSettings settings;
+ settings.load(config);
+ settings.apply(true); // force
+
+#ifdef HAVE_XCURSOR
+ config->setGroup("Mouse");
+ QCString theme = QFile::encodeName(config->readEntry("cursorTheme", QString()));
+ QCString size = config->readEntry("cursorSize", QString()).local8Bit();
+
+ // Note: If you update this code, update kapplymousetheme as well.
+
+ // use a default value for theme only if it's not configured at all, not even in X resources
+ if( theme.isEmpty()
+ && QCString( XGetDefault( qt_xdisplay(), "Xcursor", "theme" )).isEmpty()
+ && QCString( XcursorGetTheme( qt_xdisplay())).isEmpty())
+ {
+ theme = "default";
+ }
+
+ // Apply the KDE cursor theme to ourselves
+ if( !theme.isEmpty())
+ XcursorSetTheme(qt_xdisplay(), theme.data());
+
+ if (!size.isEmpty())
+ XcursorSetDefaultSize(qt_xdisplay(), size.toUInt());
+
+ // Load the default cursor from the theme and apply it to the root window.
+ Cursor handle = XcursorLibraryLoadCursor(qt_xdisplay(), "left_ptr");
+ XDefineCursor(qt_xdisplay(), qt_xrootwin(), handle);
+ XFreeCursor(qt_xdisplay(), handle); // Don't leak the cursor
+
+ // Tell klauncher to set the XCURSOR_THEME and XCURSOR_SIZE environment
+ // variables when launching applications.
+ DCOPRef klauncher("klauncher");
+ if( !theme.isEmpty())
+ klauncher.send("setLaunchEnv", QCString("XCURSOR_THEME"), theme);
+ if( !size.isEmpty())
+ klauncher.send("setLaunchEnv", QCString("XCURSOR_SIZE"), size);
+#endif
+
+ delete config;
+ }
+}
+
+