Commit 5e204f5fbc6889107c4d68fd39445fedf1e2c495

Authored by Marco Trevisan (Treviño)
1 parent 0fc2f097

Screen: use XCursor to set size and theme based on settings, and update cursors on settings change

CMakeLists.txt
... ... @@ -101,6 +101,7 @@ set (COMPIZ_REQUIRES
101 101 xext
102 102 xdamage
103 103 xcomposite
  104 + xcursor
104 105 x11-xcb
105 106 xrandr
106 107 xinerama
... ...
src/privatescreen.h
... ... @@ -710,6 +710,8 @@ class PrivateScreen :
710 710  
711 711 void setDefaultWindowAttributes (XWindowAttributes *);
712 712  
  713 + void updateCursors (const CompString& theme, int size);
  714 +
713 715 static void compScreenSnEvent (SnMonitorEvent *event,
714 716 void *userData);
715 717  
... ...
src/screen.cpp
... ... @@ -54,6 +54,7 @@
54 54 #include <X11/extensions/shape.h>
55 55 #include <X11/cursorfont.h>
56 56 #include <X11/extensions/XInput2.h>
  57 +#include <X11/Xcursor/Xcursor.h>
57 58  
58 59 #include <core/global.h>
59 60 #include <core/screen.h>
... ... @@ -4153,8 +4154,26 @@ CompScreen::cursorChangeNotify (const CompString&amp; theme, int size)
4153 4154 _cursorChangeNotify (theme, size);
4154 4155 }
4155 4156  
4156   -void CompScreenImpl::_cursorChangeNotify (const CompString&, int)
  4157 +void
  4158 +PrivateScreen::updateCursors (const CompString& theme, int size)
  4159 +{
  4160 + XFreeCursor (dpy, normalCursor);
  4161 + XFreeCursor (dpy, busyCursor);
  4162 +
  4163 + XcursorSetDefaultSize (dpy, size);
  4164 + XcursorSetTheme (dpy, theme.c_str());
  4165 +
  4166 + normalCursor = XCreateFontCursor (dpy, XC_left_ptr);
  4167 + busyCursor = XCreateFontCursor (dpy, XC_watch);
  4168 +
  4169 + XIDefineCursor (dpy, clientPointerDeviceId, root, normalCursor);
  4170 + startupSequence.updateStartupFeedback ();
  4171 +}
  4172 +
  4173 +void
  4174 +CompScreenImpl::_cursorChangeNotify (const CompString& theme, int size)
4157 4175 {
  4176 + privateScreen.updateCursors (theme, size);
4158 4177 }
4159 4178  
4160 4179 /* Returns default viewport for some window geometry. If the window spans
... ... @@ -5154,14 +5173,10 @@ PrivateScreen::initDisplay (const char *name, cps::History&amp; history, unsigned in
5154 5173 eventManager.setSupportingWmCheck (dpy, rootWindow());
5155 5174 screen->updateSupportedWmHints ();
5156 5175  
5157   - updateResources ();
5158 5176  
5159 5177 XIGetClientPointer (dpy, None, &clientPointerDeviceId);
5160   -
5161   - normalCursor = XCreateFontCursor (dpy, XC_left_ptr);
5162   - busyCursor = XCreateFontCursor (dpy, XC_watch);
5163   -
5164   - XIDefineCursor (dpy, clientPointerDeviceId, rootWindow(), normalCursor);
  5178 + updateCursors (XcursorGetTheme (dpy), XcursorGetDefaultSize (dpy));
  5179 + updateResources ();
5165 5180  
5166 5181 /* Attempt to gain SubstructureRedirectMask */
5167 5182 CompScreenImpl::checkForError (dpy);
... ...