Merge lp:~ksamak/compiz/switcher_add_size_multiplier into lp:compiz/0.9.13

Proposed by ksamak
Status: Superseded
Proposed branch: lp:~ksamak/compiz/switcher_add_size_multiplier
Merge into: lp:compiz/0.9.13
Diff against target: 372 lines (+121/-71)
3 files modified
plugins/switcher/src/switcher.cpp (+99/-68)
plugins/switcher/src/switcher.h (+14/-3)
plugins/switcher/switcher.xml.in (+8/-0)
To merge this branch: bzr merge lp:~ksamak/compiz/switcher_add_size_multiplier
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Pending
Review via email: mp+299071@code.launchpad.net

This proposal has been superseded by a proposal from 2016-07-09.

Commit message

switcher: adds a size multiplier for A11Y purposes (sight impaired people)

Description of the change

this patch adds a size modifier to the base switcher, for sight impaired people.
It allows to set a variable in ccsm that will make the switchWindow bigger

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

I see some indentation issues, but a part from that it looks ok

Revision history for this message
ksamak (ksamak) wrote :

On Tue, Jul 05, 2016 at 10:38:13AM -0000, Marco Trevisan (Treviño) wrote:
> I see some indentation issues, but a part from that it looks ok

You want me to have a look, and try to straighten that?
i guess should re-request a merge then.
--
Ksamak
hypra.fr Team

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

No need to re-request a merge. Just update this branch; MP will update automatically.

Just comment here once you've done.

4065. By ksamak <ksamak@ksalaptop>

indentation modifs

4066. By ksamak <ksamak@ksalaptop>

indentation modifs

Revision history for this message
ksamak (ksamak) wrote :

indents modifs done.
I just remember i need to set noexpandtab in my vim. differences didn't appear in my buffer.
don't know if you can squash commits with bzr too (like in git) to get rid of parasite revisions.

4067. By ksamak <ksamak@ksalaptop>

switcher: fixed coding style, minor refactoring

4068. By ksamak <ksamak@ksalaptop>

switcher: fixed coding style

4069. By ksamak <ksamak@ksalaptop>

switcher: fixed indentation

4070. By ksamak <ksamak@ksalaptop>

switcher: fixed typo

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/switcher/src/switcher.cpp'
2--- plugins/switcher/src/switcher.cpp 2015-08-22 21:46:01 +0000
3+++ plugins/switcher/src/switcher.cpp 2016-07-05 14:10:56 +0000
4@@ -20,7 +20,9 @@
5 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
6 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
7 *
8- * Author: David Reveman <davidr@novell.com>
9+ * Author(s):
10+ * - David Reveman <davidr@novell.com>
11+ * - Auboyneau Vincent <ksamak@riseup.net> (size multiplier for A11Y)
12 */
13
14 #include "switcher.h"
15@@ -35,36 +37,6 @@
16
17 #define XWINDOWCHANGES_INIT {0, 0, 0, 0, 0, None, 0}
18
19-static float _boxVertices[] =
20-{
21- -(WIDTH >> 1), BOX_WIDTH, 0.0f,
22- (WIDTH >> 1), BOX_WIDTH, 0.0f,
23- -(WIDTH >> 1), 0.0f, 0.0f,
24- -(WIDTH >> 1), 0.0f, 0.0f,
25- (WIDTH >> 1), BOX_WIDTH, 0.0f,
26- (WIDTH >> 1), 0.0f, 0.0f,
27-
28- -(WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
29- -(WIDTH >> 1) + BOX_WIDTH, HEIGHT - BOX_WIDTH, 0.0f,
30- -(WIDTH >> 1), BOX_WIDTH, 0.0f,
31- -(WIDTH >> 1), BOX_WIDTH, 0.0f,
32- -(WIDTH >> 1) + BOX_WIDTH, HEIGHT - BOX_WIDTH, 0.0f,
33- -(WIDTH >> 1) + BOX_WIDTH, BOX_WIDTH, 0.0f,
34-
35- (WIDTH >> 1) - BOX_WIDTH, HEIGHT - BOX_WIDTH, 0.0f,
36- (WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
37- (WIDTH >> 1) - BOX_WIDTH, BOX_WIDTH, 0.0f,
38- (WIDTH >> 1) - BOX_WIDTH, BOX_WIDTH, 0.0f,
39- (WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
40- (WIDTH >> 1), BOX_WIDTH, 0.0f,
41-
42- -(WIDTH >> 1), HEIGHT, 0.0f,
43- (WIDTH >> 1), HEIGHT, 0.0f,
44- -(WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
45- -(WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
46- (WIDTH >> 1), HEIGHT, 0.0f,
47- (WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
48-};
49
50 void
51 SwitchScreen::updateWindowList (int count)
52@@ -78,7 +50,7 @@
53 count = 3;
54 }
55
56- pos = ((count >> 1) - (int)windows.size ()) * WIDTH;
57+ pos = ((count >> 1) - (int)windows.size ()) * static_cast<int>(WIDTH * sm);
58 move = 0;
59
60 selectedWindow = windows.front ();
61@@ -184,9 +156,9 @@
62 SwitchScreen::handleSelectionChange (bool toNext, int nextIdx)
63 {
64 if (toNext)
65- move -= WIDTH;
66+ move -= static_cast<int>(WIDTH * sm);
67 else
68- move += WIDTH;
69+ move += static_cast<int>(WIDTH * sm);
70
71 moreAdjust = true;
72 }
73@@ -532,7 +504,7 @@
74
75 updateWindowList (count);
76
77- allWindowsWidth = windows.size () * WIDTH;
78+ allWindowsWidth = windows.size () * static_cast<int>(WIDTH * sm);
79
80 foreach (CompWindow *win, windows)
81 {
82@@ -541,7 +513,7 @@
83 if (selectedWindow == selected)
84 break;
85
86- pos -= WIDTH;
87+ pos -= static_cast<int>(WIDTH * sm);
88 if (pos < -allWindowsWidth)
89 pos += allWindowsWidth;
90 }
91@@ -650,7 +622,7 @@
92 float amount, chunk;
93 int allWindowsWidth;
94
95- allWindowsWidth = windows.size () * WIDTH;
96+ allWindowsWidth = windows.size () * static_cast<int>(WIDTH * sm);
97
98 amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
99 steps = amount / (0.5f * optionGetTimestep ());
100@@ -878,10 +850,10 @@
101 mask,
102 x,
103 y,
104- WIDTH - (SPACE << 1),
105- HEIGHT - (SPACE << 1),
106- WIDTH - (WIDTH >> 2),
107- HEIGHT - (HEIGHT >> 2));
108+ static_cast<int>(WIDTH * sm) - (SPACE << 1),
109+ static_cast<int>(HEIGHT * sm) - (SPACE << 1),
110+ static_cast<int>(WIDTH * sm) - (static_cast<int>(WIDTH * sm) >> 2),
111+ static_cast<int>(HEIGHT * sm) - (static_cast<int>(HEIGHT * sm) >> 2));
112 }
113
114 void
115@@ -901,8 +873,8 @@
116 else
117 sAttrib.xScale = sAttrib.yScale;
118
119- wx = x + WIDTH - icon->width () * sAttrib.xScale - SPACE;
120- wy = y + HEIGHT - icon->height () * sAttrib.yScale - SPACE;
121+ wx = x + static_cast<int>(WIDTH * sm) - icon->width () * sAttrib.xScale - SPACE;
122+ wy = y + static_cast<int>(HEIGHT * sm) - icon->height () * sAttrib.yScale - SPACE;
123 }
124
125 void
126@@ -931,8 +903,8 @@
127 width = icon->width () * sAttrib.xScale;
128 height = icon->height () * sAttrib.yScale;
129
130- wx = x + SPACE + ((WIDTH - (SPACE << 1)) - width) / 2;
131- wy = y + SPACE + ((HEIGHT - (SPACE << 1)) - height) / 2;
132+ wx = x + SPACE + ((static_cast<int>(WIDTH * sm) - (SPACE << 1)) - width) / 2;
133+ wy = y + SPACE + ((static_cast<int>(HEIGHT * sm) - (SPACE << 1)) - height) / 2;
134 }
135
136 void
137@@ -943,8 +915,8 @@
138 float width,
139 float height)
140 {
141- wx = x + SPACE + ((WIDTH - (SPACE << 1)) - width) / 2;
142- wy = y + SPACE + ((HEIGHT - (SPACE << 1)) - height) / 2;
143+ wx = x + SPACE + ((static_cast<int>(WIDTH * sm) - (SPACE << 1)) - width) / 2;
144+ wy = y + SPACE + ((static_cast<int>(HEIGHT * sm) - (SPACE << 1)) - height) / 2;
145 }
146
147
148@@ -971,6 +943,7 @@
149 int x, y, x1, x2, cx;
150 unsigned short color[4];
151
152+ sm = sScreen->sm;
153 const CompWindow::Geometry &g = window->geometry ();
154
155 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK ||
156@@ -991,23 +964,25 @@
157 glEnable (GL_SCISSOR_TEST);
158 glScissor (x1, 0, x2 - x1, screen->height ());
159
160- foreach (CompWindow *w, sScreen->windows)
161- {
162- if (x + WIDTH > x1)
163- SwitchWindow::get (w)->paintThumb (gWindow->lastPaintAttrib (),
164- transform, mask, x, y);
165- x += WIDTH;
166- }
167-
168- foreach (CompWindow *w, sScreen->windows)
169- {
170- if (x > x2)
171- break;
172-
173- SwitchWindow::get (w)->paintThumb (gWindow->lastPaintAttrib (),
174- transform, mask, x, y);
175- x += WIDTH;
176- }
177+ foreach (CompWindow *w, sScreen->windows)
178+ {
179+ if (x + static_cast<int>(WIDTH * sm) > x1) {
180+ auto switchWin = SwitchWindow::get(w);
181+ switchWin->sm = sm;
182+ switchWin->paintThumb (gWindow->lastPaintAttrib (), transform, mask, x, y);
183+ }
184+ x += static_cast<int>(WIDTH * sm);
185+ }
186+
187+ foreach (CompWindow *w, sScreen->windows)
188+ {
189+ if (x > x2) { break; }
190+
191+ auto switchWin = SwitchWindow::get(w);
192+ switchWin->sm = sm;
193+ switchWin->paintThumb (gWindow->lastPaintAttrib (), transform, mask, x, y);
194+ x += static_cast<int>(WIDTH * sm);
195+ }
196
197 glDisable (GL_SCISSOR_TEST);
198
199@@ -1025,7 +1000,7 @@
200 streamingBuffer->begin (GL_TRIANGLES);
201
202 streamingBuffer->addColors (1, color);
203- streamingBuffer->addVertices (24, _boxVertices);
204+ streamingBuffer->addVertices (24, sScreen->_boxVertices);
205
206 streamingBuffer->end ();
207 streamingBuffer->render (wTransform, attrib);
208@@ -1102,6 +1077,58 @@
209
210 }
211
212+void SwitchScreen::setSizeMultiplier() {
213+ sm = optionGetSizeMultiplier();
214+ float width = (WIDTH >> 1) * sm;
215+ float height = HEIGHT * sm;
216+ float box_width = BOX_WIDTH * sm;
217+ float boxVertices[72] =
218+ {
219+ -width, box_width, 0.0f,
220+ width, box_width, 0.0f,
221+ -width, 0.0f, 0.0f,
222+ -width, 0.0f, 0.0f,
223+ width, box_width, 0.0f,
224+ width, 0.0f, 0.0f,
225+
226+ -width, height - box_width, 0.0f,
227+ -width + box_width, height - box_width, 0.0f,
228+ -width, box_width, 0.0f,
229+ -width, box_width, 0.0f,
230+ -width + box_width, height - box_width, 0.0f,
231+ -width + box_width, box_width, 0.0f,
232+
233+ width - box_width, height - box_width, 0.0f,
234+ width, height - box_width, 0.0f,
235+ width - box_width, box_width, 0.0f,
236+ width - box_width, box_width, 0.0f,
237+ width, height - box_width, 0.0f,
238+ width, box_width, 0.0f,
239+
240+ -width, height, 0.0f,
241+ width, height, 0.0f,
242+ -width, height - box_width, 0.0f,
243+ -width, height - box_width, 0.0f,
244+ width, height, 0.0f,
245+ width, height - box_width, 0.0f,
246+ };
247+ std::copy(boxVertices, boxVertices + 72, _boxVertices);
248+
249+ foreach (CompWindow *w, windows)
250+ {
251+ auto switchWin = SwitchWindow::get(w);
252+ switchWin->resetGraphics();
253+ }
254+}
255+
256+void SwitchWindow::resetGraphics() {
257+ sm = sScreen->optionGetSizeMultiplier();
258+ if (sScreen->popupWindow && sScreen->popupWindow == window->id ()) {
259+ gWindow->glPaintSetEnabled (this, false);
260+ gWindow->glPaintSetEnabled (this, true);
261+ }
262+}
263+
264 SwitchScreen::SwitchScreen (CompScreen *screen) :
265 BaseSwitchScreen (screen),
266 PluginClassHandler<SwitchScreen,CompScreen> (screen),
267@@ -1115,14 +1142,16 @@
268 pos (0),
269 move (0),
270 translate (0.0),
271- sTranslate (0.0)
272+ sTranslate (0.0),
273+ sm(1)
274 {
275 zoom = optionGetZoom () / 30.0f;
276-
277 zooming = (optionGetZoom () > 0.05f);
278-
279 optionSetZoomNotify (boost::bind (&SwitchScreen::setZoom, this));
280
281+ setSizeMultiplier();
282+ optionSetSizeMultiplierNotify(boost::bind(&SwitchScreen::setSizeMultiplier, this));
283+
284 auto bgUpdater = [=] (...){ this->updateBackground (this->optionGetUseBackgroundColor (), this->optionGetBackgroundColor ());};
285 optionSetUseBackgroundColorNotify (bgUpdater);
286 optionSetBackgroundColorNotify (bgUpdater);
287@@ -1182,8 +1211,10 @@
288 BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *>
289 (SwitchScreen::get (screen)), window),
290 PluginClassHandler<SwitchWindow,CompWindow> (window),
291+ sm(1),
292 sScreen (SwitchScreen::get (screen))
293 {
294+ sm = sScreen->optionGetSizeMultiplier();
295 GLWindowInterface::setHandler (gWindow, false);
296 CompositeWindowInterface::setHandler (cWindow, false);
297
298
299=== modified file 'plugins/switcher/src/switcher.h'
300--- plugins/switcher/src/switcher.h 2015-08-22 21:46:01 +0000
301+++ plugins/switcher/src/switcher.h 2016-07-05 14:10:56 +0000
302@@ -20,7 +20,9 @@
303 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
304 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
305 *
306- * Author: David Reveman <davidr@novell.com>
307+ * Author(s):
308+ * - David Reveman <davidr@novell.com>
309+ * - Auboyneau Vincent <ksamak@riseup.net> (size multiplier for A11Y)
310 */
311
312 #include <stdio.h>
313@@ -96,6 +98,11 @@
314
315 float translate;
316 float sTranslate;
317+
318+ void setSizeMultiplier();
319+ float sm;
320+ float _boxVertices[72];
321+
322 };
323
324 class SwitchWindow :
325@@ -115,6 +122,8 @@
326 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
327 const CompRegion &, unsigned int);
328
329+ void resetGraphics();
330+
331 void paintThumb (const GLWindowPaintAttrib &attrib,
332 const GLMatrix &transform,
333 unsigned int mask,
334@@ -143,6 +152,8 @@
335
336 IconMode getIconMode ();
337
338+ float sm; // sizeMultiplier
339+
340 SwitchScreen *sScreen;
341 };
342
343@@ -160,8 +171,8 @@
344
345 extern const unsigned short BOX_WIDTH;
346
347-#define WINDOW_WIDTH(count) (WIDTH * (count) + (SPACE << 1))
348-#define WINDOW_HEIGHT (HEIGHT + (SPACE << 1))
349+#define WINDOW_WIDTH(count) (static_cast<int>(WIDTH * optionGetSizeMultiplier()) * (count) + (SPACE << 1))
350+#define WINDOW_HEIGHT (static_cast<int>(HEIGHT * optionGetSizeMultiplier()) + (SPACE << 1))
351
352 #define SWITCH_SCREEN(s) \
353 SwitchScreen *ss = SwitchScreen::get (s)
354
355=== modified file 'plugins/switcher/switcher.xml.in'
356--- plugins/switcher/switcher.xml.in 2015-08-22 21:46:01 +0000
357+++ plugins/switcher/switcher.xml.in 2016-07-05 14:10:56 +0000
358@@ -98,6 +98,14 @@
359 <max>50</max>
360 <precision>0.1</precision>
361 </option>
362+ <option name="size_multiplier" type="float">
363+ <_short>Size multiplier</_short>
364+ <_long>adjusts the size of the switch windows</_long>
365+ <default>1</default>
366+ <min>0.1</min>
367+ <max>10</max>
368+ <precision>0.1</precision>
369+ </option>
370 <option name="window_match" type="match">
371 <_short>Switcher windows</_short>
372 <_long>Windows that should be shown in switcher</_long>

Subscribers

People subscribed via source and target branches

to all changes: