Merge lp:~unity-team/compiz/showmouse-guides into lp:compiz/0.9.12

Proposed by Marco Trevisan (Treviño) on 2016-05-31
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2016-05-31
Approved revision: 4045
Merged at revision: 4049
Proposed branch: lp:~unity-team/compiz/showmouse-guides
Merge into: lp:compiz/0.9.12
Diff against target: 179 lines (+103/-4)
3 files modified
plugins/showmouse/showmouse.xml.in (+28/-2)
plugins/showmouse/src/showmouse.cpp (+64/-2)
plugins/showmouse/src/showmouse.h (+11/-0)
To merge this branch: bzr merge lp:~unity-team/compiz/showmouse-guides
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve on 2016-05-31
Review via email: mp+296125@code.launchpad.net

Commit message

showmouse: add mouse vertical and horizontal guides

Added vertical and horizontal mouse guides to the showmouse plugin.
With this, the user can set the number of circular emiters to zero, and
add thickness to the bars. When activated (mod4-k), compiz can draw
the circular emmiters, the guides, or both.

Description of the change

Hi all compiz people.

We at hypra are preparing a desktop, based on debian/mate, aimed at providing maximum accessibility for impaired people.
We use compiz, for visual features related to visual impairement.

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, thanks for the contribution.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/showmouse/showmouse.xml.in'
2--- plugins/showmouse/showmouse.xml.in 2013-01-22 21:05:49 +0000
3+++ plugins/showmouse/showmouse.xml.in 2016-05-31 17:33:30 +0000
4@@ -34,6 +34,32 @@
5 <_long>Toggle the mouse pointer trail.</_long>
6 <default/>
7 </option>
8+ <option name="guide_thickness" type="int">
9+ <_short>Guide thickness</_short>
10+ <_long>How thick mouse guides should be, in pixels.</_long>
11+ <default>0</default>
12+ <min>0</min>
13+ <max>20</max><!-- search for "XML" in showmouse.cpp -->
14+ <precision>1</precision>
15+ </option>
16+ <option name="guide_empty_radius" type="int">
17+ <_short>Guide empty radius</_short>
18+ <_long>Radius of the disk around the cursor which doesn't contain guides.</_long>
19+ <default>20</default>
20+ <min>0</min>
21+ <max>100</max>
22+ <precision>1</precision>
23+ </option>
24+ <option name="guide_color" type="color">
25+ <_short>Guide Color</_short>
26+ <_long>Guide color.</_long>
27+ <default>
28+ <red>0xffff</red>
29+ <green>0x0</green>
30+ <blue>0x0</blue>
31+ <alpha>0x9999</alpha>
32+ </default>
33+ </option>
34 <option name="rotation_speed" type="float">
35 <_short>Rotation speed</_short>
36 <_long>Rotation speed.</_long>
37@@ -51,9 +77,9 @@
38 </option>
39 <option name="emitters" type="int">
40 <_short>Emitters</_short>
41- <_long>Number of particle emitters.</_long>
42+ <_long>Number of particle emitters (0 to disable).</_long>
43 <default>3</default>
44- <min>1</min>
45+ <min>0</min>
46 <max>10</max>
47 </option>
48 </group>
49
50=== modified file 'plugins/showmouse/src/showmouse.cpp'
51--- plugins/showmouse/src/showmouse.cpp 2013-05-09 13:43:07 +0000
52+++ plugins/showmouse/src/showmouse.cpp 2016-05-31 17:33:30 +0000
53@@ -11,6 +11,9 @@
54 * Copyright : (C) 2009 by Sam Spilsbury
55 * E-mail : smpillaz@gmail.com
56 *
57+ * Copyright (C) 2016 by Hypra
58+ * E-mail contact@hypra.fr
59+ * Added mouse guides.
60 *
61 * This program is free software; you can redistribute it and/or
62 * modify it under the terms of the GNU General Public License
63@@ -350,6 +353,12 @@
64 void
65 ShowmouseScreen::genNewParticles (int f_time)
66 {
67+ unsigned int nE = optionGetEmitters ();
68+ if (nE == 0)
69+ {
70+ ps.active = true; // Don't stop drawing: we may have guides.
71+ return;
72+ }
73 bool rColor = optionGetRandom ();
74 float life = optionGetLife ();
75 float lifeNeg = 1 - life;
76@@ -373,7 +382,6 @@
77 unsigned int i, j;
78
79 float pos[10][2];
80- unsigned int nE = optionGetEmitters ();
81 float rA = (2 * M_PI) / nE;
82 int radius = optionGetRadius ();
83
84@@ -562,11 +570,65 @@
85
86 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
87
88- ps.drawParticles (sTransform);
89+ drawGuides (sTransform);
90+
91+ if (optionGetEmitters () > 0)
92+ ps.drawParticles (sTransform);
93
94 return status;
95 }
96
97+void
98+ShowmouseScreen::drawLine (const GLMatrix &transform,
99+ double x1, double y1, double x2, double y2,
100+ unsigned short *color)
101+{
102+ GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
103+ GLfloat vertices[6] =
104+ {GLfloat(x1), GLfloat(y1), GLfloat(0), GLfloat(x2), GLfloat(y2), GLfloat(0)};
105+
106+ stream->begin (GL_LINES);
107+ stream->addColors (1, color);
108+ stream->addVertices (2, vertices);
109+ if (stream->end ())
110+ stream->render (transform);
111+}
112+
113+void
114+ShowmouseScreen::drawGuides (const GLMatrix &transform)
115+{
116+ unsigned short *color = optionGetGuideColor ();
117+ float x = mousePos.x ();
118+ float y = mousePos.y ();
119+ float thickness = optionGetGuideThickness ();
120+ float r = optionGetGuideEmptyRadius ();
121+
122+ // If the thickness is zero we don't have to draw, but we should
123+ // still mark the region where the guides should be as damaged --
124+ // this is useful when thickness has just been changed.
125+
126+ if (thickness > 0)
127+ {
128+ glLineWidth (thickness);
129+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
130+ glEnable (GL_BLEND);
131+ drawLine (transform, x, 0, x, y - r, color);
132+ drawLine (transform, x, y + r, x, screen->height (), color);
133+ drawLine (transform, 0, y, x - r, y, color);
134+ drawLine (transform, x + r, y, screen->width (), y, color);
135+ glDisable (GL_BLEND);
136+ }
137+
138+ // This has to be manually synchronized with the maximum value in
139+ // showmouse.xml.in. The code generated from the XML file keeps
140+ // the value private.
141+ thickness = 20;
142+ cScreen->damageRegion (CompRegion(0, y - thickness / 2 - 1,
143+ screen->width (), thickness + 1));
144+ cScreen->damageRegion (CompRegion(x - thickness / 2 - 1, 0,
145+ thickness + 1, screen->height ()));
146+}
147+
148 bool
149 ShowmouseScreen::terminate (CompAction *action,
150 CompAction::State state,
151
152=== modified file 'plugins/showmouse/src/showmouse.h'
153--- plugins/showmouse/src/showmouse.h 2013-04-21 23:32:04 +0000
154+++ plugins/showmouse/src/showmouse.h 2016-05-31 17:33:30 +0000
155@@ -7,6 +7,7 @@
156 * Copyright : (C) 2008 by Dennis Kasprzyk
157 * E-mail : onestone@opencompositing.org
158 *
159+ * Updated in 2016 by Hypra (contact@hypra.fr): mouse guides support.
160 *
161 * This program is free software; you can redistribute it and/or
162 * modify it under the terms of the GNU General Public License
163@@ -110,6 +111,16 @@
164 public CompositeScreenInterface,
165 public GLScreenInterface
166 {
167+ private:
168+
169+ void
170+ drawGuides (const GLMatrix &transform);
171+
172+ void
173+ drawLine (const GLMatrix &transform,
174+ double x1, double y1, double x2, double y2,
175+ unsigned short *color);
176+
177 public:
178
179 ShowmouseScreen (CompScreen *);

Subscribers

People subscribed via source and target branches