summaryrefslogtreecommitdiffstats
path: root/redhat/tdebase/tdebase-14.0.0-kcm_xcursor_applytheme.patch
blob: b5adadbc9d02e1bbb4cb52bd21d8b3ad745e93ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
--- 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
 )