diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/input/kapplymousetheme.cpp | |
download | tdebase-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/kapplymousetheme.cpp')
-rw-r--r-- | kcontrol/input/kapplymousetheme.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/kcontrol/input/kapplymousetheme.cpp b/kcontrol/input/kapplymousetheme.cpp new file mode 100644 index 000000000..99d6d1077 --- /dev/null +++ b/kcontrol/input/kapplymousetheme.cpp @@ -0,0 +1,92 @@ +/* + * main.cpp + * + * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> + * Copyright (c) 2005 Lubos Lunak <l.lunak@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 <stdlib.h> +#include <ctype.h> +#include <X11/Xlib.h> + +#ifdef HAVE_XCURSOR +# include <X11/Xcursor/Xcursor.h> +#endif + +static Display* dpy; +static Display* qt_xdisplay() { return dpy; }\ +static Window qt_xrootwin() { return DefaultRootWindow( dpy ); } + +bool isEmpty( const char* str ) + { + if( str == NULL ) + return true; + while( isspace( *str )) + ++str; + return *str == '\0'; + } + +int main( int argc, char* argv[] ) + { + if( argc != 3 ) + return 1; + dpy = XOpenDisplay( NULL ); + if( dpy == NULL ) + return 2; + int ret = 0; +#ifdef HAVE_XCURSOR + const char* theme = argv[ 1 ]; + const char* size = argv[ 2 ]; + + // 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( isEmpty( theme ) + && isEmpty( XGetDefault( qt_xdisplay(), "Xcursor", "theme" )) + && isEmpty( XcursorGetTheme( qt_xdisplay()))) + { + theme = "default"; + ret = 10; // means to switch to default + } + + // Apply the KDE cursor theme to ourselves + if( !isEmpty( theme )) + XcursorSetTheme(qt_xdisplay(), theme ); + + if (!isEmpty( size )) + XcursorSetDefaultSize(qt_xdisplay(), atoi( size )); + + // 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 + +#else + ( void ) qt_xdisplay(); + ( void ) qt_xrootwin(); + ( void ) argv; +#endif + XCloseDisplay( dpy ); + return ret; + } |