Hello. [Resending the message from a subscribed address] I'm Luca Saiu. I'm part of a small but very motivated team in France, working on accessibility; you might have already exchanged some messages with my colleagues Jean-Philippe Mengual, Ksamak and Raphaƫl Poitevin.
We are developing a customized version of debian using Compiz with Emerald and MATE. I've developed a relatively simple addition to the "Show mouse" plugin to (optionally) draw what we call "mouse guides": horizontal and vertical lines crossing near the mouse pointer to make its position more visible to visually impaired users. The user can configure the guide thickness, color (including transparency) and distance from the mouse, using CCSM. A patch is attached. Please feel free to tell me about any problems, including about the repo we should be using; we have based our work on the debian repository on alioth. It was not completely clear to us what repo is considered "official" for compiz, as several look abandoned. I'm also slightly concerned about CPU use. Shall I separate the guides functionality into a new plugin? A random questions: we are having problems seeing any effect of the Compiz configuration in gsettings after installation, even if configured with -DUSE_GSETTINGS=ON; as far as I can see compiz stores its configuration in gconf. However some code supporting gsettings is obviously there. Is the functionality not completely implemented, or are we doing something wrong? Another patch containing a new plugin for mouse cursor themes is forthcoming. Thanks, commit d23ca3dba5882ffaab222f68ff50704caf842e97 Author: Luca Saiu <ls...@hypra.fr> Date: Sun Mar 15 22:48:07 2015 +0000 add mouse guides to the "Show Mouse" plugin Add functionality to the "Show mouse" plugin for drawing guide lines to highlight the mouse pointer. The user can choose the guide thickness, color and transparency. Change the minimum number of emitters from 1 to 0, for the case where we have guides only. CPU use is high (at least on my VirtualBox machines). I don't think the particle engine gets used by mistake. The code is easy enough, but unfortunately we have to manually synchronize a constant in plugins/showmouse/showmouse.xml.in and in plugins/showmouse/src/showmouse.cpp to have the same value. The code generated from the XML file seems to keep the datum private, so I can't easily query it. * plugins/showmouse/showmouse.xml.in: Configuration interface. * plugins/showmouse/src/showmouse.cpp, plugins/showmouse/src/showmouse.h: Here. -- Luca Saiu Hypra team (Accessible website in construction)
diff --git a/plugins/showmouse/showmouse.xml.in b/plugins/showmouse/showmouse.xml.in index 0dfa896..07e60f2 100644 --- a/plugins/showmouse/showmouse.xml.in +++ b/plugins/showmouse/showmouse.xml.in @@ -34,6 +34,32 @@ <_long>Toggle the mouse pointer trail.</_long> <default/> </option> + <option name="guide_thickness" type="int"> + <_short>Guide thickness</_short> + <_long>How thick mouse guides should be, in pixels.</_long> + <default>0</default> + <min>0</min> + <max>20</max><!-- search for "XML" in showmouse.cpp --> + <precision>1</precision> + </option> + <option name="guide_empty_radius" type="int"> + <_short>Guide empty radius</_short> + <_long>Radius of the disk around the cursor which doesn't contain guides.</_long> + <default>20</default> + <min>0</min> + <max>100</max> + <precision>1</precision> + </option> + <option name="guide_color" type="color"> + <_short>Guide Color</_short> + <_long>Guide color.</_long> + <default> + <red>0xffff</red> + <green>0x0</green> + <blue>0x0</blue> + <alpha>0x9999</alpha> + </default> + </option> <option name="rotation_speed" type="float"> <_short>Rotation speed</_short> <_long>Rotation speed.</_long> @@ -51,9 +77,9 @@ </option> <option name="emitters" type="int"> <_short>Emitters</_short> - <_long>Number of particle emitters.</_long> + <_long>Number of particle emitters (0 to disable).</_long> <default>3</default> - <min>1</min> + <min>0</min> <max>10</max> </option> </group> diff --git a/plugins/showmouse/src/showmouse.cpp b/plugins/showmouse/src/showmouse.cpp index 01712d2..073718e 100644 --- a/plugins/showmouse/src/showmouse.cpp +++ b/plugins/showmouse/src/showmouse.cpp @@ -11,6 +11,9 @@ * Copyright : (C) 2009 by Sam Spilsbury * E-mail : smpil...@gmail.com * + * Copyright (C) 2015 Hypra + * http://www.hypra.fr + * Added guides. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -350,6 +353,12 @@ toggleFunctions (bool enabled) void ShowmouseScreen::genNewParticles (int f_time) { + unsigned int nE = optionGetEmitters (); + if (nE == 0) + { + ps.active = true; // Don't stop drawing: we may have guides. + return; + } bool rColor = optionGetRandom (); float life = optionGetLife (); float lifeNeg = 1 - life; @@ -373,7 +382,6 @@ ShowmouseScreen::genNewParticles (int f_time) unsigned int i, j; float pos[10][2]; - unsigned int nE = optionGetEmitters (); float rA = (2 * M_PI) / nE; int radius = optionGetRadius (); @@ -562,11 +570,65 @@ ShowmouseScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); - ps.drawParticles (sTransform); + drawGuides (sTransform); + + if (optionGetEmitters () > 0) + ps.drawParticles (sTransform); return status; } +void +ShowmouseScreen::drawLine (const GLMatrix &transform, + double x1, double y1, double x2, double y2, + unsigned short *color) +{ + GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer (); + GLfloat vertices[6] = + {GLfloat(x1), GLfloat(y1), GLfloat(0), GLfloat(x2), GLfloat(y2), GLfloat(0)}; + + stream->begin (GL_LINES); + stream->addColors (1, color); + stream->addVertices (2, vertices); + if (stream->end ()) + stream->render (transform); +} + +void +ShowmouseScreen::drawGuides (const GLMatrix &transform) +{ + unsigned short *color = optionGetGuideColor (); + float x = mousePos.x (); + float y = mousePos.y (); + float thickness = optionGetGuideThickness (); + float r = optionGetGuideEmptyRadius (); + + // If the thickness is zero we don't have to draw, but we should + // still mark the region where the guides should be as damaged -- + // this is useful when thickness has just been changed. + + if (thickness > 0) + { + glLineWidth (thickness); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_BLEND); + drawLine (transform, x, 0, x, y - r, color); + drawLine (transform, x, y + r, x, screen->height (), color); + drawLine (transform, 0, y, x - r, y, color); + drawLine (transform, x + r, y, screen->width (), y, color); + glDisable (GL_BLEND); + } + + // This has to be manually synchronized with the maximum value in + // showmouse.xml.in. The code generated from the XML file keeps + // the value private. + thickness = 20; + cScreen->damageRegion (CompRegion(0, y - thickness / 2 - 1, + screen->width (), thickness + 1)); + cScreen->damageRegion (CompRegion(x - thickness / 2 - 1, 0, + thickness + 1, screen->height ())); +} + bool ShowmouseScreen::terminate (CompAction *action, CompAction::State state, diff --git a/plugins/showmouse/src/showmouse.h b/plugins/showmouse/src/showmouse.h index 68e3996..bf12124 100644 --- a/plugins/showmouse/src/showmouse.h +++ b/plugins/showmouse/src/showmouse.h @@ -7,6 +7,7 @@ * Copyright : (C) 2008 by Dennis Kasprzyk * E-mail : onest...@opencompositing.org * + * Updated in 2015 by Hypra (http://www.hypra.fr): guide support. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -110,6 +111,16 @@ class ShowmouseScreen : public CompositeScreenInterface, public GLScreenInterface { + private: + + void + drawGuides (const GLMatrix &transform); + + void + drawLine (const GLMatrix &transform, + double x1, double y1, double x2, double y2, + unsigned short *color); + public: ShowmouseScreen (CompScreen *);
_______________________________________________ compiz mailing list compiz@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/compiz