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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
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
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.
Revision history for this message
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
=== modified file 'plugins/showmouse/showmouse.xml.in'
--- plugins/showmouse/showmouse.xml.in 2013-01-22 21:05:49 +0000
+++ plugins/showmouse/showmouse.xml.in 2016-05-31 17:33:30 +0000
@@ -34,6 +34,32 @@
34 <_long>Toggle the mouse pointer trail.</_long>34 <_long>Toggle the mouse pointer trail.</_long>
35 <default/>35 <default/>
36 </option>36 </option>
37 <option name="guide_thickness" type="int">
38 <_short>Guide thickness</_short>
39 <_long>How thick mouse guides should be, in pixels.</_long>
40 <default>0</default>
41 <min>0</min>
42 <max>20</max><!-- search for "XML" in showmouse.cpp -->
43 <precision>1</precision>
44 </option>
45 <option name="guide_empty_radius" type="int">
46 <_short>Guide empty radius</_short>
47 <_long>Radius of the disk around the cursor which doesn't contain guides.</_long>
48 <default>20</default>
49 <min>0</min>
50 <max>100</max>
51 <precision>1</precision>
52 </option>
53 <option name="guide_color" type="color">
54 <_short>Guide Color</_short>
55 <_long>Guide color.</_long>
56 <default>
57 <red>0xffff</red>
58 <green>0x0</green>
59 <blue>0x0</blue>
60 <alpha>0x9999</alpha>
61 </default>
62 </option>
37 <option name="rotation_speed" type="float">63 <option name="rotation_speed" type="float">
38 <_short>Rotation speed</_short>64 <_short>Rotation speed</_short>
39 <_long>Rotation speed.</_long>65 <_long>Rotation speed.</_long>
@@ -51,9 +77,9 @@
51 </option>77 </option>
52 <option name="emitters" type="int">78 <option name="emitters" type="int">
53 <_short>Emitters</_short>79 <_short>Emitters</_short>
54 <_long>Number of particle emitters.</_long>80 <_long>Number of particle emitters (0 to disable).</_long>
55 <default>3</default>81 <default>3</default>
56 <min>1</min>82 <min>0</min>
57 <max>10</max>83 <max>10</max>
58 </option>84 </option>
59 </group>85 </group>
6086
=== modified file 'plugins/showmouse/src/showmouse.cpp'
--- plugins/showmouse/src/showmouse.cpp 2013-05-09 13:43:07 +0000
+++ plugins/showmouse/src/showmouse.cpp 2016-05-31 17:33:30 +0000
@@ -11,6 +11,9 @@
11 * Copyright : (C) 2009 by Sam Spilsbury11 * Copyright : (C) 2009 by Sam Spilsbury
12 * E-mail : smpillaz@gmail.com12 * E-mail : smpillaz@gmail.com
13 *13 *
14 * Copyright (C) 2016 by Hypra
15 * E-mail contact@hypra.fr
16 * Added mouse guides.
14 *17 *
15 * This program is free software; you can redistribute it and/or18 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License19 * modify it under the terms of the GNU General Public License
@@ -350,6 +353,12 @@
350void353void
351ShowmouseScreen::genNewParticles (int f_time)354ShowmouseScreen::genNewParticles (int f_time)
352{355{
356 unsigned int nE = optionGetEmitters ();
357 if (nE == 0)
358 {
359 ps.active = true; // Don't stop drawing: we may have guides.
360 return;
361 }
353 bool rColor = optionGetRandom ();362 bool rColor = optionGetRandom ();
354 float life = optionGetLife ();363 float life = optionGetLife ();
355 float lifeNeg = 1 - life;364 float lifeNeg = 1 - life;
@@ -373,7 +382,6 @@
373 unsigned int i, j;382 unsigned int i, j;
374383
375 float pos[10][2];384 float pos[10][2];
376 unsigned int nE = optionGetEmitters ();
377 float rA = (2 * M_PI) / nE;385 float rA = (2 * M_PI) / nE;
378 int radius = optionGetRadius ();386 int radius = optionGetRadius ();
379387
@@ -562,11 +570,65 @@
562570
563 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);571 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
564572
565 ps.drawParticles (sTransform);573 drawGuides (sTransform);
574
575 if (optionGetEmitters () > 0)
576 ps.drawParticles (sTransform);
566577
567 return status;578 return status;
568}579}
569580
581void
582ShowmouseScreen::drawLine (const GLMatrix &transform,
583 double x1, double y1, double x2, double y2,
584 unsigned short *color)
585{
586 GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
587 GLfloat vertices[6] =
588 {GLfloat(x1), GLfloat(y1), GLfloat(0), GLfloat(x2), GLfloat(y2), GLfloat(0)};
589
590 stream->begin (GL_LINES);
591 stream->addColors (1, color);
592 stream->addVertices (2, vertices);
593 if (stream->end ())
594 stream->render (transform);
595}
596
597void
598ShowmouseScreen::drawGuides (const GLMatrix &transform)
599{
600 unsigned short *color = optionGetGuideColor ();
601 float x = mousePos.x ();
602 float y = mousePos.y ();
603 float thickness = optionGetGuideThickness ();
604 float r = optionGetGuideEmptyRadius ();
605
606 // If the thickness is zero we don't have to draw, but we should
607 // still mark the region where the guides should be as damaged --
608 // this is useful when thickness has just been changed.
609
610 if (thickness > 0)
611 {
612 glLineWidth (thickness);
613 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
614 glEnable (GL_BLEND);
615 drawLine (transform, x, 0, x, y - r, color);
616 drawLine (transform, x, y + r, x, screen->height (), color);
617 drawLine (transform, 0, y, x - r, y, color);
618 drawLine (transform, x + r, y, screen->width (), y, color);
619 glDisable (GL_BLEND);
620 }
621
622 // This has to be manually synchronized with the maximum value in
623 // showmouse.xml.in. The code generated from the XML file keeps
624 // the value private.
625 thickness = 20;
626 cScreen->damageRegion (CompRegion(0, y - thickness / 2 - 1,
627 screen->width (), thickness + 1));
628 cScreen->damageRegion (CompRegion(x - thickness / 2 - 1, 0,
629 thickness + 1, screen->height ()));
630}
631
570bool632bool
571ShowmouseScreen::terminate (CompAction *action,633ShowmouseScreen::terminate (CompAction *action,
572 CompAction::State state,634 CompAction::State state,
573635
=== modified file 'plugins/showmouse/src/showmouse.h'
--- plugins/showmouse/src/showmouse.h 2013-04-21 23:32:04 +0000
+++ plugins/showmouse/src/showmouse.h 2016-05-31 17:33:30 +0000
@@ -7,6 +7,7 @@
7 * Copyright : (C) 2008 by Dennis Kasprzyk7 * Copyright : (C) 2008 by Dennis Kasprzyk
8 * E-mail : onestone@opencompositing.org8 * E-mail : onestone@opencompositing.org
9 *9 *
10 * Updated in 2016 by Hypra (contact@hypra.fr): mouse guides support.
10 *11 *
11 * This program is free software; you can redistribute it and/or12 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License13 * modify it under the terms of the GNU General Public License
@@ -110,6 +111,16 @@
110 public CompositeScreenInterface,111 public CompositeScreenInterface,
111 public GLScreenInterface112 public GLScreenInterface
112{113{
114 private:
115
116 void
117 drawGuides (const GLMatrix &transform);
118
119 void
120 drawLine (const GLMatrix &transform,
121 double x1, double y1, double x2, double y2,
122 unsigned short *color);
123
113 public:124 public:
114125
115 ShowmouseScreen (CompScreen *);126 ShowmouseScreen (CompScreen *);

Subscribers

People subscribed via source and target branches