137 lines
4.4 KiB
137 lines
4.4 KiB
12 years ago
|
--- tdebase/kcontrol/input/xcursor/themepage.cpp.ORI 2013-07-22 19:33:45.153674930 +0200
|
||
|
+++ tdebase/kcontrol/input/xcursor/themepage.cpp 2013-07-23 15:24:01.664497762 +0200
|
||
|
@@ -33,6 +33,8 @@
|
||
|
#include <tdeio/netaccess.h>
|
||
|
#include <ktar.h>
|
||
|
|
||
|
+#include "../../krdb/krdb.h"
|
||
|
+
|
||
|
#include <tqlayout.h>
|
||
|
#include <tqdir.h>
|
||
|
#include <tqpixmap.h>
|
||
|
@@ -42,6 +44,7 @@
|
||
|
#include <tqpainter.h>
|
||
|
#include <tqfileinfo.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
+#include <dcopref.h>
|
||
|
|
||
|
#include <cstdlib> // for getenv()
|
||
|
|
||
|
@@ -53,6 +56,10 @@
|
||
|
#include <X11/Xlib.h>
|
||
|
#include <X11/Xcursor/Xcursor.h>
|
||
|
|
||
|
+#ifdef HAVE_XFIXES
|
||
|
+# include <X11/extensions/Xfixes.h>
|
||
|
+#endif
|
||
|
+
|
||
|
// Check for older version
|
||
|
#if !defined(XCURSOR_LIB_MAJOR) && defined(XCURSOR_MAJOR)
|
||
|
# define XCURSOR_LIB_MAJOR XCURSOR_MAJOR
|
||
|
@@ -133,6 +140,65 @@
|
||
|
{
|
||
|
}
|
||
|
|
||
|
+bool ThemePage::applyTheme(TQString theme, TQString size)
|
||
|
+{
|
||
|
+#ifdef HAVE_XCURSOR
|
||
|
+ if (theme.isEmpty()) {
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ // Apply the TDE cursor theme to ourselves
|
||
|
+ XcursorSetTheme(tqt_xdisplay(), theme.latin1());
|
||
|
+
|
||
|
+ // Tell tdelauncher to set the XCURSOR_THEME and XCURSOR_SIZE environment
|
||
|
+ // variables when launching applications.
|
||
|
+ DCOPRef tdelauncher("tdelauncher");
|
||
|
+ tdelauncher.send("setLaunchEnv", TQCString("XCURSOR_THEME"), TQFile::encodeName(theme));
|
||
|
+ if( !size.isEmpty()) {
|
||
|
+ tdelauncher.send("setLaunchEnv", TQCString("XCURSOR_SIZE"), size);
|
||
|
+ }
|
||
|
+
|
||
|
+ // Update the Xcursor X resources
|
||
|
+ runRdb(0);
|
||
|
+
|
||
|
+ // Apply the TDE cursor size to ourselves
|
||
|
+ if (!size.isEmpty()) {
|
||
|
+ XcursorSetDefaultSize(tqt_xdisplay(), size.toUInt());
|
||
|
+ }
|
||
|
+
|
||
|
+ // Reload the standard cursors
|
||
|
+ TQStringList names;
|
||
|
+
|
||
|
+ // Qt cursors
|
||
|
+ names << "left_ptr" << "up_arrow" << "cross" << "wait"
|
||
|
+ << "left_ptr_watch" << "ibeam" << "size_ver" << "size_hor"
|
||
|
+ << "size_bdiag" << "size_fdiag" << "size_all" << "split_v"
|
||
|
+ << "split_h" << "pointing_hand" << "openhand"
|
||
|
+ << "closedhand" << "forbidden" << "whats_this" << "copy" << "move" << "link";
|
||
|
+
|
||
|
+ // X core cursors
|
||
|
+ names << "X_cursor" << "right_ptr" << "hand1"
|
||
|
+ << "hand2" << "watch" << "xterm"
|
||
|
+ << "crosshair" << "left_ptr_watch" << "center_ptr"
|
||
|
+ << "sb_h_double_arrow" << "sb_v_double_arrow" << "fleur"
|
||
|
+ << "top_left_corner" << "top_side" << "top_right_corner"
|
||
|
+ << "right_side" << "bottom_right_corner" << "bottom_side"
|
||
|
+ << "bottom_left_corner" << "left_side" << "question_arrow"
|
||
|
+ << "pirate";
|
||
|
+
|
||
|
+ for (int i = 0; i < names.size(); ++i)
|
||
|
+ {
|
||
|
+ const char* name = (*(names.at(i))).ascii();
|
||
|
+ Cursor handle = XcursorLibraryLoadCursor(tqt_xdisplay(), name);
|
||
|
+ XFixesChangeCursorByName(tqt_xdisplay(), handle, TQFile::encodeName(name));
|
||
|
+ XFreeCursor(tqt_xdisplay(), handle); // Don't leak the cursor
|
||
|
+ }
|
||
|
+
|
||
|
+ return true;
|
||
|
+#else // HAVE_XCURSOR
|
||
|
+ return false;
|
||
|
+#endif
|
||
|
+}
|
||
|
|
||
|
void ThemePage::save()
|
||
|
{
|
||
|
@@ -145,10 +209,17 @@
|
||
|
c.setGroup( "Mouse" );
|
||
|
c.writeEntry( "cursorTheme", selectedTheme != "system" ? selectedTheme : TQString::null );
|
||
|
|
||
|
- KMessageBox::information( this, i18n("You have to restart TDE for these "
|
||
|
+ // The Kcontrol panel does not allow to set cursor size for now.
|
||
|
+ // So we keep the same size as written in config file.
|
||
|
+ TQCString size = c.readEntry("cursorSize", TQString()).local8Bit();
|
||
|
+
|
||
|
+ if (!applyTheme(selectedTheme, size))
|
||
|
+ {
|
||
|
+ KMessageBox::information( this, i18n("You have to restart TDE for these "
|
||
|
"changes to take effect."), i18n("Cursor Settings Changed"),
|
||
|
"CursorSettingsChanged" );
|
||
|
-
|
||
|
+ }
|
||
|
+
|
||
|
currentTheme = selectedTheme;
|
||
|
}
|
||
|
|
||
|
--- tdebase/kcontrol/input/xcursor/themepage.h.ORI 2013-07-22 19:49:33.467191658 +0200
|
||
|
+++ tdebase/kcontrol/input/xcursor/themepage.h 2013-07-22 19:56:03.990484896 +0200
|
||
|
@@ -45,6 +45,7 @@
|
||
|
void load();
|
||
|
void load( bool useDefaults );
|
||
|
void defaults();
|
||
|
+ bool applyTheme(TQString theme, TQString size);
|
||
|
|
||
|
signals:
|
||
|
void changed( bool );
|
||
|
--- tdebase/kcontrol/input/xcursor/CMakeLists.txt.ORI 2013-07-23 15:24:41.178064068 +0200
|
||
|
+++ tdebase/kcontrol/input/xcursor/CMakeLists.txt 2013-07-23 15:27:31.694851294 +0200
|
||
|
@@ -21,5 +21,6 @@
|
||
|
|
||
|
tde_add_library( themepage STATIC_PIC AUTOMOC
|
||
|
SOURCES
|
||
|
- themepage.cpp previewwidget.cpp
|
||
|
+ themepage.cpp previewwidget.cpp ../../krdb/krdb.cpp
|
||
|
+ LINK Xfixes
|
||
|
)
|