4
* Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
6
* Requires the Qt widget libraries, available at no cost at
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
#include <config-X11.h>
34
#include <ktoolinvocation.h>
35
#include <klauncher_iface.h>
39
# include <X11/Xcursor/Xcursor.h>
44
KDE_EXPORT void kcminit_mouse()
46
KConfig *config = new KConfig("kcminputrc", KConfig::NoGlobals );
47
MouseSettings settings;
48
settings.load(config);
49
settings.apply(true); // force
52
KConfigGroup group = config->group("Mouse");
53
QString theme = group.readEntry("cursorTheme", QString());
54
QString size = group.readEntry("cursorSize", QString());
56
// Note: If you update this code, update kapplymousetheme as well.
58
// use a default value for theme only if it's not configured at all, not even in X resources
60
&& QByteArray( XGetDefault( QX11Info::display(), "Xcursor", "theme" )).isEmpty()
61
&& QByteArray( XcursorGetTheme( QX11Info::display())).isEmpty())
66
// Apply the KDE cursor theme to ourselves
68
XcursorSetTheme(QX11Info::display(), QFile::encodeName(theme));
71
XcursorSetDefaultSize(QX11Info::display(), size.toUInt());
73
// Load the default cursor from the theme and apply it to the root window.
74
Cursor handle = XcursorLibraryLoadCursor(QX11Info::display(), "left_ptr");
75
XDefineCursor(QX11Info::display(), QX11Info::appRootWindow(), handle);
76
XFreeCursor(QX11Info::display(), handle); // Don't leak the cursor
78
// Tell klauncher to set the XCURSOR_THEME and XCURSOR_SIZE environment
79
// variables when launching applications.
81
KToolInvocation::klauncher()->setLaunchEnv("XCURSOR_THEME", theme);
83
KToolInvocation::klauncher()->setLaunchEnv("XCURSOR_SIZE", size);