Merge lp:~hikiko/compiz/compiz.move-additions into lp:compiz

Proposed by Eleni Maria Stea on 2016-09-06
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2017-01-09
Approved revision: 4096
Merged at revision: 4104
Proposed branch: lp:~hikiko/compiz/compiz.move-additions
Merge into: lp:compiz
Diff against target: 445 lines (+318/-3)
4 files modified
debian/unity-lowgfx.ini (+4/-0)
plugins/move/move.xml.in (+48/-0)
plugins/move/src/move.cpp (+254/-2)
plugins/move/src/move.h (+12/-1)
To merge this branch: bzr merge lp:~hikiko/compiz/compiz.move-additions
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2016-09-06 Approve on 2016-12-08
Review via email: mp+305008@code.launchpad.net

Commit Message

Move: add options for showing only the window shape (filled or not)

- the user can move the window (normal mode)
- a filled rectangle (rectangle mode) or
- a non-filled rectangle (outline mode)
also the user can enable and disable blend.

Non-blended outline mode can improve the performance in software rendering, thus using it in lowgfx profile.

Description of the Change

New options in Move plugin:
- the user can move the window (normal mode)
- a filled rectangle (rectangle mode) or
- a non-filled rectangle (outline mode)
also the user can enable and disable blend.

Non-blended outline mode can improve the performance in software rendering.

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

Looks good, but please see comments for some improvements

Marco Trevisan (Treviño) (3v1n0) wrote :

Better thanks.

Just one line change. See diff comment.

4096. By Eleni Maria Stea on 2016-12-08

damage the rectangle when getMovingRectangle returns true

Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/unity-lowgfx.ini'
2--- debian/unity-lowgfx.ini 2016-09-08 09:37:01 +0000
3+++ debian/unity-lowgfx.ini 2016-12-08 13:50:39 +0000
4@@ -46,3 +46,7 @@
5
6 [showdesktop]
7 s0_skip_animation = true
8+
9+[move]
10+s0_mode = 1
11+s0_blend = false
12
13=== modified file 'plugins/move/move.xml.in'
14--- plugins/move/move.xml.in 2013-04-14 11:46:28 +0000
15+++ plugins/move/move.xml.in 2016-12-08 13:50:39 +0000
16@@ -70,6 +70,54 @@
17 <_long>Do not update the server-side position of windows until finished moving.</_long>
18 <default>false</default>
19 </option>
20+
21+ <group>
22+ <_short>Appearance</_short>
23+ <option name="mode" type="int">
24+ <_short>Default Moving Window Mode</_short>
25+ <_long>Default mode used for window moving.</_long>
26+ <default>0</default>
27+ <min>0</min>
28+ <max>2</max>
29+ <desc>
30+ <value>0</value>
31+ <_name>Normal</_name>
32+ </desc>
33+ <desc>
34+ <value>1</value>
35+ <_name>Outline</_name>
36+ </desc>
37+ <desc>
38+ <value>2</value>
39+ <_name>Rectangle</_name>
40+ </desc>
41+ </option>
42+ <option name="border_color" type="color">
43+ <_short>Border Color</_short>
44+ <_long>Border color used for outline and rectangle moving modes</_long>
45+ <default>
46+ <red>0xfbfb</red>
47+ <green>0x8b8b</green>
48+ <blue>0x0</blue>
49+ <alpha>0x9f9f</alpha>
50+ </default>
51+ </option>
52+ <option name="fill_color" type="color">
53+ <_short>Fill Color</_short>
54+ <_long>Fill color used for rectangle moving mode</_long>
55+ <default>
56+ <red>0xfbfb</red>
57+ <green>0x8b8b</green>
58+ <blue>0x0</blue>
59+ <alpha>0x1919</alpha>
60+ </default>
61+ </option>
62+ <option name="blend" type="bool">
63+ <_short>Enable Transparency</_short>
64+ <_long>Enable or disable blending.</_long>
65+ <default>true</default>
66+ </option>
67+ </group>
68 </options>
69 </plugin>
70 </compiz>
71
72=== modified file 'plugins/move/src/move.cpp'
73--- plugins/move/src/move.cpp 2015-10-20 15:11:54 +0000
74+++ plugins/move/src/move.cpp 2016-12-08 13:50:39 +0000
75@@ -34,6 +34,9 @@
76
77 COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)
78
79+static float pos_x, pos_y;
80+static bool paint_rectangle;
81+
82 static bool
83 moveInitiate (CompAction *action,
84 CompAction::State state,
85@@ -43,6 +46,18 @@
86
87 MOVE_SCREEN (screen);
88
89+ if (ms->optionGetMode () != MoveOptions::ModeNormal)
90+ {
91+ ms->gScreen->glPaintOutputSetEnabled (ms, true);
92+ paint_rectangle = true;
93+ pos_x = pos_y = 0;
94+ }
95+ else
96+ {
97+ ms->gScreen->glPaintOutputSetEnabled (ms, false);
98+ paint_rectangle = false;
99+ }
100+
101 Window xid = CompOption::getIntOptionNamed (options, "window");
102
103 w = screen->findWindow (xid);
104@@ -173,13 +188,33 @@
105 {
106 MOVE_SCREEN (screen);
107
108+ if (ms->optionGetMode () != MoveOptions::ModeNormal)
109+ {
110+ ms->gScreen->glPaintOutputSetEnabled (ms, true);
111+ paint_rectangle = true;
112+ }
113+ else
114+ {
115+ ms->gScreen->glPaintOutputSetEnabled (ms, false);
116+ paint_rectangle = false;
117+ }
118+
119 if (ms->w)
120 {
121 MOVE_WINDOW (ms->w);
122
123+ if (ms->optionGetMode () != MoveOptions::ModeNormal) {
124+ ms->gScreen->glPaintOutputSetEnabled (ms, false);
125+ paint_rectangle = false;
126+
127+ mw->window->move (pos_x, pos_y, true);
128+ }
129+
130 if (state & CompAction::StateCancel)
131+ {
132 ms->w->move (ms->savedX - ms->w->geometry ().x (),
133 ms->savedY - ms->w->geometry ().y (), false);
134+ }
135
136 /* update window attributes as window constraints may have
137 changed - needed e.g. if a maximized window was moved
138@@ -318,6 +353,7 @@
139
140 int wX = w->geometry ().x ();
141 int wY = w->geometry ().y ();
142+
143 int wWidth = w->geometry ().widthIncBorders ();
144 int wHeight = w->geometry ().heightIncBorders ();
145
146@@ -522,8 +558,15 @@
147
148 if (dx || dy)
149 {
150- w->move (wX + dx - w->geometry ().x (),
151- wY + dy - w->geometry ().y (), false);
152+ if (ms->optionGetMode () == MoveOptions::ModeNormal)
153+ {
154+ w->move (wX + dx - w->geometry ().x (), wY + dy - w->geometry ().y (), false);
155+ }
156+ else
157+ {
158+ pos_x += wX + dx - w->geometry ().x ();
159+ pos_y += wY + dy - w->geometry ().y ();
160+ }
161
162 ms->x -= dx;
163 ms->y -= dy;
164@@ -534,6 +577,10 @@
165 void
166 MoveScreen::handleEvent (XEvent *event)
167 {
168+ Box box;
169+ if (getMovingRectangle (&box))
170+ damageMovingRectangle (&box);
171+
172 switch (event->type)
173 {
174 case ButtonPress:
175@@ -704,6 +751,7 @@
176 MoveScreen::MoveScreen (CompScreen *screen) :
177 PluginClassHandler<MoveScreen,CompScreen> (screen),
178 cScreen (CompositeScreen::get (screen)),
179+ gScreen (GLScreen::get (screen)),
180 w (0),
181 region (NULL),
182 status (RectangleOut),
183@@ -734,6 +782,18 @@
184 optionSetInitiateKeyTerminate (moveTerminate);
185
186 ScreenInterface::setHandler (screen);
187+ GLScreenInterface::setHandler (gScreen);
188+
189+ if (optionGetMode () != MoveOptions::ModeNormal)
190+ {
191+ paint_rectangle = true;
192+ gScreen->glPaintOutputSetEnabled (this, true);
193+ }
194+ else
195+ {
196+ paint_rectangle = false;
197+ gScreen->glPaintOutputSetEnabled (this, false);
198+ }
199 }
200
201 MoveScreen::~MoveScreen ()
202@@ -743,6 +803,198 @@
203 }
204
205 bool
206+MoveScreen::getMovingRectangle (BoxPtr pBox)
207+{
208+ if (optionGetMode () == MoveOptions::ModeNormal)
209+ return false;
210+
211+ MOVE_SCREEN (screen);
212+ if (!ms)
213+ return false;
214+
215+ CompWindow *w = ms->w;
216+ if (!w)
217+ return false;
218+
219+ int wX = w->geometry ().x () - w->border ().left;
220+ int wY = w->geometry ().y () - w->border ().top;
221+ int wWidth = w->geometry ().widthIncBorders ();
222+ int wHeight = w->geometry ().heightIncBorders ();
223+
224+ pBox->x1 = wX + pos_x;
225+ pBox->y1 = wY + pos_y;
226+
227+ pBox->x2 = pBox->x1 + wWidth;
228+ pBox->y2 = pBox->y1 + wHeight;
229+
230+ return true;
231+}
232+
233+bool MoveScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
234+ const GLMatrix &transform,
235+ const CompRegion &region,
236+ CompOutput *output,
237+ unsigned int mask)
238+{
239+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
240+
241+ if (status && paint_rectangle)
242+ {
243+ unsigned short *borderColor = optionGetBorderColor ();
244+ unsigned short *fillColor = optionGetFillColor ();
245+
246+ return glPaintMovingRectangle (transform, output, borderColor, (optionGetMode() == MoveOptions::ModeRectangle) ? fillColor : NULL);
247+ }
248+ return status;
249+}
250+
251+void
252+MoveScreen::damageMovingRectangle (BoxPtr pBox)
253+{
254+ int x1, x2, y1, y2;
255+
256+ x1 = pBox->x1 - 1;
257+ y1 = pBox->y1 - 1;
258+ x2 = pBox->x2 + 1;
259+ y2 = pBox->y2 + 1;
260+
261+ if (cScreen)
262+ cScreen->damageRegion (CompRect (x1, y1, x2 - x1, y2 - y1));
263+}
264+
265+bool
266+MoveScreen::glPaintMovingRectangle (const GLMatrix &transform,
267+ CompOutput *output,
268+ unsigned short *borderColor,
269+ unsigned short *fillColor)
270+{
271+ BoxRec box;
272+ if (!getMovingRectangle(&box))
273+ return false;
274+
275+ GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
276+ GLMatrix sTransform (transform);
277+
278+ GLfloat vertexData[12];
279+ GLfloat vertexData2[24];
280+ GLushort fc[4], bc[4];
281+ GLint origSrc, origDst;
282+
283+ bool blend = optionGetBlend ();
284+ if (blend)
285+ {
286+#ifdef USE_GLES
287+ GLint origSrcAlpha, origDstAlpha;
288+ glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
289+ glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
290+ glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
291+ glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
292+#else
293+ glGetIntegerv (GL_BLEND_SRC, &origSrc);
294+ glGetIntegerv (GL_BLEND_DST, &origDst);
295+#endif
296+ }
297+
298+ bc[3] = (float) borderColor[3] / (float) 65535.0f;
299+ bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
300+ bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
301+ bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
302+ if (!blend)
303+ bc[3] = 1;
304+
305+ vertexData[0] = box.x1;
306+ vertexData[1] = box.y1;
307+ vertexData[2] = 0.0f;
308+ vertexData[3] = box.x1;
309+ vertexData[4] = box.y2;
310+ vertexData[5] = 0.0f;
311+ vertexData[6] = box.x2;
312+ vertexData[7] = box.y1;
313+ vertexData[8] = 0.0f;
314+ vertexData[9] = box.x2;
315+ vertexData[10] = box.y2;
316+ vertexData[11] = 0.0f;
317+
318+ vertexData2[0] = box.x1;
319+ vertexData2[1] = box.y1;
320+ vertexData2[2] = 0.0f;
321+ vertexData2[3] = box.x1;
322+ vertexData2[4] = box.y2;
323+ vertexData2[5] = 0.0f;
324+ vertexData2[6] = box.x1;
325+ vertexData2[7] = box.y2;
326+ vertexData2[8] = 0.0f;
327+ vertexData2[9] = box.x2;
328+ vertexData2[10] = box.y2;
329+ vertexData2[11] = 0.0f;
330+ vertexData2[12] = box.x2;
331+ vertexData2[13] = box.y2;
332+ vertexData2[14] = 0.0f;
333+ vertexData2[15] = box.x2;
334+ vertexData2[16] = box.y1;
335+ vertexData2[17] = 0.0f;
336+ vertexData2[18] = box.x2;
337+ vertexData2[19] = box.y1;
338+ vertexData2[20] = 0.0f;
339+ vertexData2[21] = box.x1;
340+ vertexData2[22] = box.y1;
341+ vertexData2[23] = 0.0f;
342+
343+ sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
344+
345+ if (blend)
346+ {
347+ glEnable (GL_BLEND);
348+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
349+ }
350+
351+ /* fill rectangle */
352+ if (fillColor)
353+ {
354+ fc[3] = fillColor[3];
355+ fc[0] = fillColor[0] * (unsigned long) fc[3] / 65535;
356+ fc[1] = fillColor[1] * (unsigned long) fc[3] / 65535;
357+ fc[2] = fillColor[2] * (unsigned long) fc[3] / 65535;
358+ if (!blend)
359+ fc[3] = 1;
360+
361+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
362+ streamingBuffer->addColors (1, fc);
363+ streamingBuffer->addVertices (4, &vertexData[0]);
364+ streamingBuffer->end ();
365+ streamingBuffer->render (sTransform);
366+ }
367+
368+ /* draw outline */
369+ static const int borderWidth = 2;
370+
371+ glLineWidth (borderWidth);
372+ streamingBuffer->begin (GL_LINES);
373+ streamingBuffer->addColors (1, borderColor);
374+ streamingBuffer->addVertices (8, &vertexData2[0]);
375+ streamingBuffer->end ();
376+ streamingBuffer->render (sTransform);
377+
378+ if (blend)
379+ {
380+ glEnable (GL_BLEND);
381+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
382+ }
383+
384+ CompositeScreen *cScreen = CompositeScreen::get (screen);
385+ if (cScreen)
386+ {
387+ CompRect damage (box.x1 - borderWidth,
388+ box.y1 - borderWidth,
389+ box.x2 - box.x1 + 2,
390+ box.y2 - box.y1 + 2);
391+ cScreen->damageRegion (damage);
392+ }
393+
394+ return true;
395+}
396+
397+bool
398 MovePluginVTable::init ()
399 {
400 if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
401
402=== modified file 'plugins/move/src/move.h'
403--- plugins/move/src/move.h 2015-10-20 15:11:54 +0000
404+++ plugins/move/src/move.h 2016-12-08 13:50:39 +0000
405@@ -32,7 +32,6 @@
406 #include <composite/composite.h>
407 #include <opengl/opengl.h>
408
409-
410 #define NUM_KEYS (sizeof (mKeys) / sizeof (mKeys[0]))
411
412 struct _MoveKeys
413@@ -49,6 +48,7 @@
414 };
415
416 class MoveScreen :
417+ public GLScreenInterface,
418 public ScreenInterface,
419 public CompositeScreenInterface,
420 public PluginClassHandler<MoveScreen,CompScreen>,
421@@ -59,6 +59,7 @@
422 ~MoveScreen ();
423
424 CompositeScreen *cScreen;
425+ GLScreen *gScreen;
426
427 void updateOpacity ();
428
429@@ -67,6 +68,16 @@
430 bool registerPaintHandler (compiz::composite::PaintHandler *pHnd);
431 void unregisterPaintHandler ();
432
433+ bool glPaintOutput (const GLScreenPaintAttrib &,
434+ const GLMatrix &,
435+ const CompRegion &,
436+ CompOutput *,
437+ unsigned int);
438+
439+ bool getMovingRectangle (BoxPtr pbox);
440+ void damageMovingRectangle (BoxPtr pbox);
441+ bool glPaintMovingRectangle (const GLMatrix &transform, CompOutput *output, unsigned short *borderColor, unsigned short *fillColor);
442+
443 CompWindow *w;
444 int savedX;
445 int savedY;

Subscribers

People subscribed via source and target branches