Merge lp:~unity-team/compiz/x-sru5 into lp:compiz/xenial

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 4036
Merged at revision: 4019
Proposed branch: lp:~unity-team/compiz/x-sru5
Merge into: lp:compiz/xenial
Diff against target: 1777 lines (+936/-94)
31 files modified
VERSION (+1/-1)
debian/changelog (+28/-0)
debian/mate.ini (+9/-9)
debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade (+12/-0)
debian/unity-lowgfx.ini (+8/-2)
debian/unity.ini (+0/-1)
gtk/window-decorator/decorator.c (+2/-0)
gtk/window-decorator/metacity.c (+2/-0)
gtk/window-decorator/util.c (+1/-1)
include/core/abiversion.h (+1/-1)
include/core/atoms.h (+2/-0)
include/core/screen.h (+7/-1)
include/core/string.h (+3/-0)
plugins/grid/grid.xml.in (+10/-0)
plugins/grid/src/grid.cpp (+67/-22)
plugins/grid/src/grid.h (+0/-1)
plugins/move/move.xml.in (+58/-0)
plugins/move/src/move.cpp (+326/-2)
plugins/move/src/move.h (+16/-1)
plugins/neg/neg.xml.in (+5/-0)
plugins/neg/src/neg.cpp (+1/-1)
plugins/resize/resize.xml.in (+15/-0)
plugins/resize/src/logic/src/resize-logic.cpp (+8/-6)
plugins/resize/src/resize.cpp (+137/-37)
src/atoms.cpp (+4/-0)
src/event.cpp (+5/-0)
src/privatescreen.h (+6/-0)
src/privatescreen/tests/test-privatescreen.cpp (+2/-0)
src/screen.cpp (+137/-6)
src/string/src/string.cpp (+61/-0)
src/window.cpp (+2/-2)
To merge this branch: bzr merge lp:~unity-team/compiz/x-sru5
Reviewer Review Type Date Requested Status
Andrea Azzarone Approve
Review via email: mp+326396@code.launchpad.net

Commit message

Releasing SRU5 for Ubuntu 16.04

To post a comment you must log in.
lp:~unity-team/compiz/x-sru5 updated
4027. By Marco Trevisan (Treviño)

unity-lowgfx: use better effect for grid

4028. By Marco Trevisan (Treviño)

debian/changelog: add missing bug references

4029. By Alberts Muktupāvels

Use AnyPropertyType when getting _MOTIF_WM_HINTS property.

4030. By Marco Trevisan (Treviño)

move: damage all the border area in outline mode and ignore transparent colors

Also we don't really need to damage at every X event. It's just about doing it
right the firs time, by including the exceeding space.
Also optimize damanging in outline-mode, by only touching such regions

Plus add some optimizations when not blending, as we don't care about the alpha channel

4031. By Marco Trevisan (Treviño)

grid: ignore alpha in colors when not blending, and fix animations

The fade-out animation was still happening when the duration was set to 1,
while it was broken when it was 0. Fixed both.

In unity-lowgfx.ini set the animation duration to 0 in grid and d not
draw stretched windows. Enable blending again as it's really not
expensive in this case, while not having it, really makes the user
experience a lot poorer.

4032. By Marco Trevisan (Treviño)

resize: add support for disabling transparency and avoid over-damaging in outline mode

4033. By Marco Trevisan (Treviño)

Screen: add averageColor to get the current desktop average color

We get the value from the root window and we parse it using regex.
Also use this in 'move', 'resize' and 'grid' plugins by default, doing the
appropriate lightening / darkening to make this working properly
on the desktop surface

4034. By Marco Trevisan (Treviño)

Bumping micro version

4035. By Marco Trevisan (Treviño)

debian: go back setting COMPIZ_CONFIG_PROFILE in X11 scripts

4036. By Marco Trevisan (Treviño)

debian: tune unity-lowgfx profile and add upgrades

Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve
Revision history for this message
Amr Ibrahim (amribrahim1987) wrote :

Ping!
SRU into Xenial.

lp:~unity-team/compiz/x-sru5 updated
4037. By Marco Trevisan (Treviño)

unity-lowgfx.ini: remove unsupported unity option

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VERSION'
2--- VERSION 2015-08-19 15:50:54 +0000
3+++ VERSION 2017-11-16 22:42:49 +0000
4@@ -1,1 +1,1 @@
5-0.9.12.2
6+0.9.12.3
7
8=== modified file 'debian/changelog'
9--- debian/changelog 2016-08-23 16:06:02 +0000
10+++ debian/changelog 2017-11-16 22:42:49 +0000
11@@ -1,3 +1,31 @@
12+compiz (1:0.9.12.3) UNRELEASED; urgency=medium
13+
14+ [ Eleni Maria Stea ]
15+ * Added option to disable blend in grid plugin (LP: #1700859)
16+ * Move: add options for showing only the window shape (filled or not)
17+ (LP: #1700859)
18+
19+ [ Alberts Muktupāvels ]
20+ * Ensure that surfaces used by metacity theme have device scale set to
21+ 1 . (LP: #1530277) (LP: #1530277)
22+ * Use AnyPropertyType when getting _MOTIF_WM_HINTS property. (LP:
23+ #1702297)
24+
25+ [ Martin Wimpress ]
26+ * mate: Avoid artefacts of Windows Thumbnail Previews (LP: #1606369)
27+
28+ [ Marco Trevisan (Treviño) ]
29+ * move: damage all the border area in outline mode and ignore
30+ transparent colors (LP: #1700859)
31+ * grid: ignore alpha in colors when not blending, and fix animations
32+ (LP: #1700859)
33+ * resize: add support for disabling transparency and avoid over-
34+ damaging in outline mode (LP: #1700859)
35+ * Screen: add averageColor to get the current desktop average color
36+ * unity-lowgfx.ini: remove unsupported unity option
37+
38+ -- Marco Trevisan <marco@ubuntu.com> Tue, 27 Jun 2017 18:49:59 +0200
39+
40 compiz (1:0.9.12.2+16.04.20160823-0ubuntu1) xenial; urgency=medium
41
42 [ Andrea Azzarone ]
43
44=== modified file 'debian/mate.ini'
45--- debian/mate.ini 2016-04-07 11:50:19 +0000
46+++ debian/mate.ini 2017-11-16 22:42:49 +0000
47@@ -50,17 +50,17 @@
48 s0_active_shadow_radius = 13.000000
49 s0_active_shadow_opacity = 0.225000
50 s0_active_shadow_color = #00000080
51-s0_active_shadow_x_offset = 6
52-s0_active_shadow_y_offset = 6
53+s0_active_shadow_x_offset = 2
54+s0_active_shadow_y_offset = 2
55 s0_inactive_shadow_radius = 13.000000
56 s0_inactive_shadow_opacity = 0.225000
57 s0_inactive_shadow_color = #000000ff
58-s0_inactive_shadow_x_offset = 6
59-s0_inactive_shadow_y_offset = 6
60-s0_mipmap = true
61+s0_inactive_shadow_x_offset = 2
62+s0_inactive_shadow_y_offset = 2
63+s0_mipmap = false
64
65 [expo]
66-s0_expo_key = <Super>a
67+s0_expo_key = <Super>s
68 s0_selected_color = #34422eff
69 s0_reflection = true
70 s0_ground_color1 = #343631cc
71@@ -162,12 +162,12 @@
72 s0_manual_only = false
73
74 [thumbnail]
75-s0_thumb_size = 280
76+s0_thumb_size = 256
77 s0_fade_speed = 0.000000
78-s0_border = 12
79+s0_border = 15
80 s0_thumb_color = #34363130
81 s0_window_like = false
82-s0_mipmap = true
83+s0_mipmap = false
84 s0_current_viewport = false
85 s0_title_enabled = false
86 s0_font_bold = false
87
88=== added file 'debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade'
89--- debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade 1970-01-01 00:00:00 +0000
90+++ debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade 2017-11-16 22:42:49 +0000
91@@ -0,0 +1,12 @@
92+[grid]
93++s0_animation_duration = 0
94++s0_draw_stretched_window = false
95+
96+[move]
97++s0_mode = 2
98++s0_increase_border_contrast = true
99++s0_lazy_positioning = true
100+
101+[resize]
102++s0_mode = 2
103++s0_increase_border_contrast = true
104
105=== modified file 'debian/unity-lowgfx.ini'
106--- debian/unity-lowgfx.ini 2016-07-14 15:51:05 +0000
107+++ debian/unity-lowgfx.ini 2017-11-16 22:42:49 +0000
108@@ -12,10 +12,17 @@
109 s0_fade_time = 1
110
111 [grid]
112-s0_animation_duration = 1
113+s0_animation_duration = 0
114+s0_draw_stretched_window = false
115+
116+[move]
117+s0_mode = 2
118+s0_lazy_positioning = true
119+s0_increase_border_contrast = true
120
121 [resize]
122 s0_mode = 2
123+s0_increase_border_contrast = true
124
125 [opengl]
126 s0_texture_filter = 0
127@@ -24,7 +31,6 @@
128 s0_skip_animation = true
129
130 [unityshell]
131-s0_low_graphics_mode = true
132 s0_dash_blur_experimental = 0
133
134 s0_override_decoration_theme = true
135
136=== modified file 'debian/unity.ini'
137--- debian/unity.ini 2014-03-10 15:21:11 +0000
138+++ debian/unity.ini 2017-11-16 22:42:49 +0000
139@@ -1,3 +1,2 @@
140 [core]
141 s0_active_plugins = core;composite;opengl;copytex;compiztoolbox;vpswitch;snap;mousepoll;resize;place;move;wall;grid;regex;imgpng;session;animation;fade;unitymtgrabhandles;workarounds;scale;expo;ezoom;commands;unityshell
142-
143
144=== modified file 'gtk/window-decorator/decorator.c'
145--- gtk/window-decorator/decorator.c 2016-02-29 13:41:59 +0000
146+++ gtk/window-decorator/decorator.c 2017-11-16 22:42:49 +0000
147@@ -603,6 +603,8 @@
148 else
149 buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgba);
150
151+ // FIXME: this should match the current monitor scaling!
152+ cairo_surface_set_device_scale (buffer_surface, 1, 1);
153 gdk_flush ();
154
155 /* Handle failure */
156
157=== modified file 'gtk/window-decorator/metacity.c'
158--- gtk/window-decorator/metacity.c 2016-03-17 17:47:36 +0000
159+++ gtk/window-decorator/metacity.c 2017-11-16 22:42:49 +0000
160@@ -697,6 +697,8 @@
161 else
162 surface = create_surface (fgeom.width, fgeom.height, d->frame->style_window_rgba);
163
164+ // FIXME: this should match the current monitor scaling!
165+ cairo_surface_set_device_scale (surface, 1, 1);
166 cr = cairo_create (surface);
167 gdk_cairo_set_source_rgba (cr, &bg_rgba);
168 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
169
170=== modified file 'gtk/window-decorator/util.c'
171--- gtk/window-decorator/util.c 2016-03-17 17:47:36 +0000
172+++ gtk/window-decorator/util.c 2017-11-16 22:42:49 +0000
173@@ -75,7 +75,7 @@
174 gdk_error_trap_push ();
175
176 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,
177- 0L, 20L, FALSE, mwm_hints_atom,
178+ 0L, 20L, FALSE, AnyPropertyType,
179 &actual, &format, &n, &left, &data);
180
181 err = gdk_error_trap_pop ();
182
183=== modified file 'include/core/abiversion.h'
184--- include/core/abiversion.h 2015-10-13 11:33:31 +0000
185+++ include/core/abiversion.h 2017-11-16 22:42:49 +0000
186@@ -5,6 +5,6 @@
187 # error Conflicting definitions of CORE_ABIVERSION
188 #endif
189
190-#define CORE_ABIVERSION 20151010
191+#define CORE_ABIVERSION 20170630
192
193 #endif // COMPIZ_ABIVERSION_H
194
195=== modified file 'include/core/atoms.h'
196--- include/core/atoms.h 2015-02-17 14:54:10 +0000
197+++ include/core/atoms.h 2017-11-16 22:42:49 +0000
198@@ -158,6 +158,8 @@
199
200 extern Atom startupId;
201
202+ extern Atom gnomeRepresentativeColors;
203+
204 void init (Display *dpy);
205 };
206
207
208=== modified file 'include/core/screen.h'
209--- include/core/screen.h 2016-05-17 02:52:07 +0000
210+++ include/core/screen.h 2017-11-16 22:42:49 +0000
211@@ -156,6 +156,8 @@
212 virtual void addSupportedAtoms (std::vector<Atom>& atoms);
213
214 virtual void cursorChangeNotify (const CompString& theme, int size);
215+
216+ virtual void averageColorChangeNotify (const unsigned short *color);
217 };
218
219 namespace compiz { namespace private_screen {
220@@ -221,7 +223,7 @@
221 }
222
223 class CompScreen :
224- public WrapableHandler<ScreenInterface, 19>,
225+ public WrapableHandler<ScreenInterface, 20>,
226 public PluginClassStorage, // TODO should be an interface here
227 public CompSize,
228 public virtual ::compiz::DesktopWindowCount,
229@@ -273,6 +275,8 @@
230 std::vector<Atom>& atoms);
231 WRAPABLE_HND (18, ScreenInterface, void, cursorChangeNotify,
232 const CompString&, int);
233+ WRAPABLE_HND (19, ScreenInterface, void, averageColorChangeNotify,
234+ const unsigned short *);
235
236 unsigned int allocPluginClassIndex ();
237 void freePluginClassIndex (unsigned int index);
238@@ -418,6 +422,7 @@
239 virtual CompWindow * getTopServerWindow() const = 0;
240 virtual CoreOptions& getCoreOptions() = 0;
241 virtual Colormap colormap() const = 0;
242+ virtual const unsigned short * averageColor() const = 0;
243 virtual void setCurrentDesktop (unsigned int desktop) = 0;
244 virtual Window activeWindow() const = 0;
245 virtual void updatePassiveButtonGrabs(Window serverFrame) = 0;
246@@ -453,6 +458,7 @@
247 virtual void _matchPropertyChanged(CompWindow *) = 0;
248 virtual void _outputChangeNotify() = 0;
249 virtual void _cursorChangeNotify(const CompString&, int) = 0;
250+ virtual void _averageColorChangeNotify(const unsigned short*) = 0;
251 };
252
253 #endif
254
255=== modified file 'include/core/string.h'
256--- include/core/string.h 2011-10-31 13:51:00 +0000
257+++ include/core/string.h 2017-11-16 22:42:49 +0000
258@@ -28,12 +28,15 @@
259
260 #include <string>
261 #include <list>
262+#include <vector>
263 #include <cstdarg>
264
265 typedef std::string CompString;
266 typedef std::list<CompString> CompStringList;
267+typedef std::vector<CompString> CompStringVector;
268
269 CompString compPrintf (const char *format, ...);
270 CompString compPrintf (const char *format, va_list ap);
271+CompStringVector compGetRegexMatches (const CompString& regexStr, const CompString& string);
272
273 #endif
274
275=== modified file 'plugins/grid/grid.xml.in'
276--- plugins/grid/grid.xml.in 2015-10-26 17:15:43 +0000
277+++ plugins/grid/grid.xml.in 2017-11-16 22:42:49 +0000
278@@ -569,6 +569,11 @@
279 <default>350</default>
280 <min>0</min>
281 </option>
282+ <option name="use_desktop_average_color" type="bool">
283+ <_short>Use Desktop average color</_short>
284+ <_long>Try to use the desktop average color if defined by your DE.</_long>
285+ <default>true</default>
286+ </option>
287 <option name="outline_color" type="color">
288 <_short>Preview Outline Color</_short>
289 <_long>Color and opacity of the resize indicator preview outline.</_long>
290@@ -589,6 +594,11 @@
291 <alpha>0x4f4f</alpha>
292 </default>
293 </option>
294+ <option name="disable_blend" type="bool">
295+ <_short>Disable Transparency</_short>
296+ <_long>Disable blending.</_long>
297+ <default>false</default>
298+ </option>
299 </group>
300 </options>
301 </plugin>
302
303=== modified file 'plugins/grid/src/grid.cpp'
304--- plugins/grid/src/grid.cpp 2015-04-06 13:14:51 +0000
305+++ plugins/grid/src/grid.cpp 2017-11-16 22:42:49 +0000
306@@ -488,8 +488,10 @@
307 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
308 GLfloat vertexData[12];
309 GLushort colorData[4];
310- GLushort *color;
311+ unsigned short *color, *fillColor, *outlineColor;
312+ unsigned short averageFillColor[4], averageOutlineColor[4];
313 GLboolean isBlendingEnabled;
314+ bool blend = !optionGetDisableBlend ();
315
316 const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();
317
318@@ -500,16 +502,51 @@
319
320 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
321
322- glGetBooleanv (GL_BLEND, &isBlendingEnabled);
323- glEnable (GL_BLEND);
324+ if (blend)
325+ {
326+ glGetBooleanv (GL_BLEND, &isBlendingEnabled);
327+ glEnable (GL_BLEND);
328+ }
329+
330+ fillColor = optionGetFillColor ();
331+ outlineColor = optionGetOutlineColor ();
332+
333+ if (optionGetUseDesktopAverageColor ())
334+ {
335+ const unsigned short *averageColor = screen->averageColor ();
336+
337+ if (averageColor)
338+ {
339+ memcpy (averageFillColor, averageColor, 4 * sizeof (unsigned short));
340+ averageFillColor[3] = MaxUShortFloat * 0.6;
341+ fillColor = averageFillColor;
342+
343+ // Generate a lighter color based on border to create more contrast
344+ unsigned int averageColorLevel = (averageColor[0] + averageColor[1] + averageColor[2]) / 3;
345+ unsigned short *oc = averageOutlineColor;
346+
347+ float colorMultiplier;
348+ if (averageColorLevel > MaxUShortFloat * 0.3)
349+ colorMultiplier = 0.7; // make it darker
350+ else
351+ colorMultiplier = 2.0; // make it lighter
352+
353+ oc[3] = averageColor[3];
354+ oc[0] = MIN(MaxUShortFloat, ((float) averageColor[0]) * colorMultiplier) * oc[3] / MaxUShortFloat;
355+ oc[1] = MIN(MaxUShortFloat, ((float) averageColor[1]) * colorMultiplier) * oc[3] / MaxUShortFloat;
356+ oc[2] = MIN(MaxUShortFloat, ((float) averageColor[2]) * colorMultiplier) * oc[3] / MaxUShortFloat;
357+
358+ outlineColor = averageOutlineColor;
359+ }
360+ }
361
362 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)
363 {
364 Animation& anim = *iter;
365
366 float curve = powf (CURVE_ANIMATION, -anim.progress);
367- float alpha = (optionGetFillColorAlpha () / MaxUShortFloat) * anim.opacity;
368- color = optionGetFillColor ();
369+ float alpha = blend ? (fillColor[3] / MaxUShortFloat) * anim.opacity : 0.85;
370+ color = fillColor;
371
372 colorData[0] = alpha * color[0];
373 colorData[1] = alpha * color[1];
374@@ -546,8 +583,8 @@
375 anim.currentRect.height () - 2);
376
377 /* draw outline */
378- alpha = (optionGetOutlineColorAlpha () / MaxUShortFloat) * anim.opacity;
379- color = optionGetOutlineColor ();
380+ alpha = blend ? (outlineColor[3] / MaxUShortFloat) * anim.opacity : 1;
381+ color = outlineColor;
382
383 colorData[0] = alpha * color[0];
384 colorData[1] = alpha * color[1];
385@@ -579,8 +616,8 @@
386 if (!animating)
387 {
388 /* draw filled rectangle */
389- float alpha = optionGetFillColorAlpha () / MaxUShortFloat;
390- color = optionGetFillColor ();
391+ float alpha = blend ? fillColor[3] / MaxUShortFloat : 0.85;
392+ color = fillColor;
393
394 colorData[0] = alpha * color[0];
395 colorData[1] = alpha * color[1];
396@@ -614,8 +651,8 @@
397 rect.height () - 2);
398
399 /* draw outline */
400- alpha = optionGetOutlineColorAlpha () / MaxUShortFloat;
401- color = optionGetOutlineColor ();
402+ alpha = outlineColor[3] / MaxUShortFloat;
403+ color = outlineColor;
404
405 colorData[0] = alpha * color[0];
406 colorData[1] = alpha * color[1];
407@@ -641,8 +678,11 @@
408 streamingBuffer->render (sTransform);
409 }
410
411- if (!isBlendingEnabled)
412- glDisable (GL_BLEND);
413+ if (blend)
414+ {
415+ if (!isBlendingEnabled)
416+ glDisable (GL_BLEND);
417+ }
418 }
419
420 bool
421@@ -858,7 +898,7 @@
422 animations.at (current).fromRect = w->serverBorderRect ();
423 animations.at (current).currentRect = w->serverBorderRect ();
424 animations.at (current).duration = optionGetAnimationDuration ();
425- animations.at (current).timer = animations.at (current).duration;
426+ animations.at (current).progress = 0.0f;
427 animations.at (current).targetRect = desiredSlot;
428 animations.at (current).window = w->id();
429
430@@ -1172,18 +1212,24 @@
431 for (iter = animations.begin (); iter != animations.end (); ++iter)
432 {
433 Animation& anim = *iter;
434- anim.timer -= msSinceLastPaint;
435+ GLfloat msSinceLastPaintFloat = static_cast<GLfloat>(msSinceLastPaint);
436+ GLfloat animDurationFloat = static_cast<GLfloat>(anim.duration);
437+ GLfloat progress_delta = 1.0f;
438
439- if (anim.timer < 0)
440- anim.timer = 0;
441+ if (animDurationFloat > 0.0f)
442+ progress_delta = msSinceLastPaintFloat / animDurationFloat;
443
444 if (anim.fadingOut)
445- anim.opacity -= msSinceLastPaint * 0.002;
446+ {
447+ anim.opacity -= progress_delta;
448+ }
449 else
450+ {
451 if (anim.opacity < 1.0f)
452 anim.opacity = anim.progress * anim.progress;
453 else
454 anim.opacity = 1.0f;
455+ }
456
457 if (anim.opacity < 0)
458 {
459@@ -1192,10 +1238,10 @@
460 anim.complete = true;
461 }
462
463- anim.progress = (anim.duration - anim.timer) / anim.duration;
464+ anim.progress = std::min<GLfloat>(anim.progress + progress_delta, 1.0);
465 }
466
467- if (optionGetDrawStretchedWindow ())
468+ if (optionGetDrawStretchedWindow () && !optionGetDisableBlend ())
469 {
470 CompWindow *cw = screen->findWindow (CompOption::getIntOptionNamed (o, "window"));
471
472@@ -1265,7 +1311,6 @@
473 targetRect = CompRect (0, 0, 0, 0);
474 currentRect = CompRect (0, 0, 0, 0);
475 opacity = 0.0f;
476- timer = 0.0f;
477 duration = 0;
478 complete = false;
479 fadingOut = false;
480@@ -1373,7 +1418,7 @@
481 {
482 Animation& anim = *iter;
483
484- if (anim.timer > 0.0f && anim.window == window->id())
485+ if (anim.progress < 1.0f && anim.window == window->id())
486 {
487 GLWindowPaintAttrib wAttrib(attrib);
488 GLMatrix wTransform (matrix);
489
490=== modified file 'plugins/grid/src/grid.h'
491--- plugins/grid/src/grid.h 2013-04-30 00:18:41 +0000
492+++ plugins/grid/src/grid.h 2017-11-16 22:42:49 +0000
493@@ -96,7 +96,6 @@
494 CompRect targetRect;
495 CompRect currentRect;
496 GLfloat opacity;
497- GLfloat timer;
498 Window window;
499 int duration;
500 bool complete;
501
502=== modified file 'plugins/move/move.xml.in'
503--- plugins/move/move.xml.in 2013-04-14 11:46:28 +0000
504+++ plugins/move/move.xml.in 2017-11-16 22:42:49 +0000
505@@ -70,6 +70,64 @@
506 <_long>Do not update the server-side position of windows until finished moving.</_long>
507 <default>false</default>
508 </option>
509+
510+ <group>
511+ <_short>Appearance</_short>
512+ <option name="mode" type="int">
513+ <_short>Default Moving Window Mode</_short>
514+ <_long>Default mode used for window moving.</_long>
515+ <default>0</default>
516+ <min>0</min>
517+ <max>2</max>
518+ <desc>
519+ <value>0</value>
520+ <_name>Normal</_name>
521+ </desc>
522+ <desc>
523+ <value>1</value>
524+ <_name>Outline</_name>
525+ </desc>
526+ <desc>
527+ <value>2</value>
528+ <_name>Rectangle</_name>
529+ </desc>
530+ </option>
531+ <option name="increase_border_contrast" type="bool">
532+ <_short>Use a double-border in 'Rectangle' and 'Outline' modes</_short>
533+ <_long>Increase the contrast of the border using a lighter color.</_long>
534+ <default>true</default>
535+ </option>
536+ <option name="use_desktop_average_color" type="bool">
537+ <_short>Use Desktop average colors</_short>
538+ <_long>Try to use the desktop average color if defined by your DE (overrides custom colors).</_long>
539+ <default>true</default>
540+ </option>
541+ <option name="border_color" type="color">
542+ <_short>Border Color</_short>
543+ <_long>Border color used for outline and rectangle moving modes</_long>
544+ <default>
545+ <red>0xfbfb</red>
546+ <green>0x8b8b</green>
547+ <blue>0x0</blue>
548+ <alpha>0x9f9f</alpha>
549+ </default>
550+ </option>
551+ <option name="fill_color" type="color">
552+ <_short>Fill Color</_short>
553+ <_long>Fill color used for rectangle moving mode</_long>
554+ <default>
555+ <red>0xfbfb</red>
556+ <green>0x8b8b</green>
557+ <blue>0x0</blue>
558+ <alpha>0x1919</alpha>
559+ </default>
560+ </option>
561+ <option name="blend" type="bool">
562+ <_short>Enable Transparency</_short>
563+ <_long>Enable or disable blending.</_long>
564+ <default>true</default>
565+ </option>
566+ </group>
567 </options>
568 </plugin>
569 </compiz>
570
571=== modified file 'plugins/move/src/move.cpp'
572--- plugins/move/src/move.cpp 2015-10-20 15:11:54 +0000
573+++ plugins/move/src/move.cpp 2017-11-16 22:42:49 +0000
574@@ -34,6 +34,9 @@
575
576 COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)
577
578+static const int defaultBorderWidth = 2;
579+static const int biggerBorderWidthMultiplier = 2;
580+
581 static bool
582 moveInitiate (CompAction *action,
583 CompAction::State state,
584@@ -142,6 +145,19 @@
585 s->warpPointer (xRoot - pointerX, yRoot - pointerY);
586 }
587
588+ if (ms->optionGetMode () != MoveOptions::ModeNormal)
589+ {
590+ Box box;
591+
592+ ms->gScreen->glPaintOutputSetEnabled (ms, true);
593+ ms->paintRect = true;
594+ ms->rectX = 0;
595+ ms->rectY = 0;
596+
597+ if (ms->getMovingRectangle (&box))
598+ ms->damageMovingRectangle (&box);
599+ }
600+
601 if (ms->moveOpacity != OPAQUE)
602 {
603 MOVE_WINDOW (w);
604@@ -177,9 +193,18 @@
605 {
606 MOVE_WINDOW (ms->w);
607
608+ if (ms->paintRect)
609+ {
610+ ms->paintRect = false;
611+ ms->gScreen->glPaintOutputSetEnabled (ms, false);
612+ mw->window->move (ms->rectX, ms->rectY, true);
613+ }
614+
615 if (state & CompAction::StateCancel)
616+ {
617 ms->w->move (ms->savedX - ms->w->geometry ().x (),
618 ms->savedY - ms->w->geometry ().y (), false);
619+ }
620
621 /* update window attributes as window constraints may have
622 changed - needed e.g. if a maximized window was moved
623@@ -318,6 +343,7 @@
624
625 int wX = w->geometry ().x ();
626 int wY = w->geometry ().y ();
627+
628 int wWidth = w->geometry ().widthIncBorders ();
629 int wHeight = w->geometry ().heightIncBorders ();
630
631@@ -522,8 +548,15 @@
632
633 if (dx || dy)
634 {
635- w->move (wX + dx - w->geometry ().x (),
636- wY + dy - w->geometry ().y (), false);
637+ if (ms->optionGetMode () == MoveOptions::ModeNormal)
638+ {
639+ w->move (wX + dx - w->geometry ().x (), wY + dy - w->geometry ().y (), false);
640+ }
641+ else
642+ {
643+ ms->rectX += wX + dx - w->geometry ().x ();
644+ ms->rectY += wY + dy - w->geometry ().y ();
645+ }
646
647 ms->x -= dx;
648 ms->y -= dy;
649@@ -704,11 +737,15 @@
650 MoveScreen::MoveScreen (CompScreen *screen) :
651 PluginClassHandler<MoveScreen,CompScreen> (screen),
652 cScreen (CompositeScreen::get (screen)),
653+ gScreen (GLScreen::get (screen)),
654 w (0),
655 region (NULL),
656 status (RectangleOut),
657 releaseButton (0),
658 grab (NULL),
659+ paintRect(false),
660+ rectX(0),
661+ rectY(0),
662 hasCompositing (false),
663 yConstrained (false)
664 {
665@@ -734,6 +771,9 @@
666 optionSetInitiateKeyTerminate (moveTerminate);
667
668 ScreenInterface::setHandler (screen);
669+ GLScreenInterface::setHandler (gScreen);
670+
671+ gScreen->glPaintOutputSetEnabled (this, false);
672 }
673
674 MoveScreen::~MoveScreen ()
675@@ -743,6 +783,290 @@
676 }
677
678 bool
679+MoveScreen::getMovingRectangle (BoxPtr pBox)
680+{
681+ MOVE_SCREEN (screen);
682+
683+ CompWindow *w = ms->w;
684+ if (!w)
685+ return false;
686+
687+ int wX = w->geometry ().x () - w->border ().left;
688+ int wY = w->geometry ().y () - w->border ().top;
689+ int wWidth = w->geometry ().widthIncBorders () + w->border ().left + w->border ().right;
690+ int wHeight = w->geometry ().heightIncBorders () + w->border ().top + w->border ().bottom;
691+
692+ pBox->x1 = wX + ms->rectX;
693+ pBox->y1 = wY + ms->rectY;
694+
695+ pBox->x2 = pBox->x1 + wWidth;
696+ pBox->y2 = pBox->y1 + wHeight;
697+
698+ return true;
699+}
700+
701+bool
702+MoveScreen::damageMovingRectangle (BoxPtr pBox)
703+{
704+ CompRegion damageRegion;
705+ int borderWidth;
706+
707+ if (!cScreen || !pBox)
708+ return false;
709+
710+ borderWidth = defaultBorderWidth;
711+
712+ if (optionGetIncreaseBorderContrast ())
713+ borderWidth *= biggerBorderWidthMultiplier;
714+
715+ if (optionGetMode () == MoveOptions::ModeRectangle)
716+ {
717+ CompRect damage (pBox->x1 - borderWidth,
718+ pBox->y1 - borderWidth,
719+ pBox->x2 - pBox->x1 + borderWidth * 2,
720+ pBox->y2 - pBox->y1 + borderWidth * 2);
721+ damageRegion += damage;
722+ }
723+ else if (optionGetMode () == MoveOptions::ModeOutline)
724+ {
725+ // Top
726+ damageRegion += CompRect (pBox->x1 - borderWidth,
727+ pBox->y1 - borderWidth,
728+ pBox->x2 - pBox->x1 + borderWidth * 2,
729+ borderWidth * 2);
730+ // Right
731+ damageRegion += CompRect (pBox->x2 - borderWidth,
732+ pBox->y1 - borderWidth,
733+ borderWidth + borderWidth / 2,
734+ pBox->y2 - pBox->y1 + borderWidth * 2);
735+ // Bottom
736+ damageRegion += CompRect (pBox->x1 - borderWidth,
737+ pBox->y2 - borderWidth,
738+ pBox->x2 - pBox->x1 + borderWidth * 2,
739+ borderWidth * 2);
740+ // Left
741+ damageRegion += CompRect (pBox->x1 - borderWidth,
742+ pBox->y1 - borderWidth,
743+ borderWidth + borderWidth / 2,
744+ pBox->y2 - pBox->y1 + borderWidth * 2);
745+ }
746+
747+ if (!damageRegion.isEmpty ())
748+ {
749+ cScreen->damageRegion (damageRegion);
750+ return true;
751+ }
752+
753+ return false;
754+}
755+
756+bool MoveScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
757+ const GLMatrix &transform,
758+ const CompRegion &region,
759+ CompOutput *output,
760+ unsigned int mask)
761+{
762+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
763+
764+ if (status && paintRect)
765+ {
766+ unsigned short *borderColor = optionGetBorderColor ();
767+ unsigned short *fillColor = NULL;
768+
769+ if (optionGetMode() == MoveOptions::ModeRectangle)
770+ fillColor = optionGetFillColor ();
771+
772+ return glPaintMovingRectangle (transform, output, borderColor, fillColor);
773+ }
774+
775+ return status;
776+}
777+
778+bool
779+MoveScreen::glPaintMovingRectangle (const GLMatrix &transform,
780+ CompOutput *output,
781+ unsigned short *borderColor,
782+ unsigned short *fillColor)
783+{
784+ BoxRec box;
785+ if (!getMovingRectangle(&box))
786+ return false;
787+
788+ const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
789+ const float MaxUShortFloat = MaxUShort;
790+ GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
791+ GLMatrix sTransform (transform);
792+ bool usingAverageColors = false;
793+
794+ GLfloat vertexData[12];
795+ GLfloat vertexData2[24];
796+ GLushort fc[4], bc[4], averageFillColor[4];
797+ GLint origSrc, origDst;
798+#ifdef USE_GLES
799+ GLint origSrcAlpha, origDstAlpha;
800+#endif
801+
802+ if (optionGetUseDesktopAverageColor ())
803+ {
804+ const unsigned short *averageColor = screen->averageColor ();
805+
806+ if (averageColor)
807+ {
808+ usingAverageColors = true;
809+ borderColor = const_cast<unsigned short *>(averageColor);
810+ memcpy (averageFillColor, averageColor, 4 * sizeof (unsigned short));
811+ averageFillColor[3] = MaxUShort * 0.6;
812+
813+ if (fillColor)
814+ fillColor = averageFillColor;
815+ }
816+ }
817+
818+ bool blend = optionGetBlend ();
819+
820+ if (blend && borderColor[3] == MaxUShort)
821+ {
822+ if (optionGetMode () == MoveOptions::ModeOutline || fillColor[3] == MaxUShort)
823+ blend = false;
824+ }
825+
826+ if (blend)
827+ {
828+#ifdef USE_GLES
829+ glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
830+ glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
831+ glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
832+ glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
833+#else
834+ glGetIntegerv (GL_BLEND_SRC, &origSrc);
835+ glGetIntegerv (GL_BLEND_DST, &origDst);
836+#endif
837+ }
838+
839+ vertexData[0] = box.x1;
840+ vertexData[1] = box.y1;
841+ vertexData[2] = 0.0f;
842+ vertexData[3] = box.x1;
843+ vertexData[4] = box.y2;
844+ vertexData[5] = 0.0f;
845+ vertexData[6] = box.x2;
846+ vertexData[7] = box.y1;
847+ vertexData[8] = 0.0f;
848+ vertexData[9] = box.x2;
849+ vertexData[10] = box.y2;
850+ vertexData[11] = 0.0f;
851+
852+ vertexData2[0] = box.x1;
853+ vertexData2[1] = box.y1;
854+ vertexData2[2] = 0.0f;
855+ vertexData2[3] = box.x1;
856+ vertexData2[4] = box.y2;
857+ vertexData2[5] = 0.0f;
858+ vertexData2[6] = box.x1;
859+ vertexData2[7] = box.y2;
860+ vertexData2[8] = 0.0f;
861+ vertexData2[9] = box.x2;
862+ vertexData2[10] = box.y2;
863+ vertexData2[11] = 0.0f;
864+ vertexData2[12] = box.x2;
865+ vertexData2[13] = box.y2;
866+ vertexData2[14] = 0.0f;
867+ vertexData2[15] = box.x2;
868+ vertexData2[16] = box.y1;
869+ vertexData2[17] = 0.0f;
870+ vertexData2[18] = box.x2;
871+ vertexData2[19] = box.y1;
872+ vertexData2[20] = 0.0f;
873+ vertexData2[21] = box.x1;
874+ vertexData2[22] = box.y1;
875+ vertexData2[23] = 0.0f;
876+
877+ sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
878+
879+ if (blend)
880+ {
881+ glEnable (GL_BLEND);
882+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
883+ }
884+
885+ /* fill rectangle */
886+ if (fillColor)
887+ {
888+ fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
889+ fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
890+ fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
891+ fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
892+
893+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
894+ streamingBuffer->addColors (1, fc);
895+ streamingBuffer->addVertices (4, &vertexData[0]);
896+ streamingBuffer->end ();
897+ streamingBuffer->render (sTransform);
898+ }
899+
900+ /* draw outline */
901+ int borderWidth = defaultBorderWidth;
902+
903+ if (optionGetIncreaseBorderContrast() || usingAverageColors)
904+ {
905+ // Generate a lighter color based on border to create more contrast
906+ unsigned int averageColorLevel = (borderColor[0] + borderColor[1] + borderColor[2]) / 3;
907+
908+ float colorMultiplier;
909+ if (averageColorLevel > MaxUShort * 0.3)
910+ colorMultiplier = 0.7; // make it darker
911+ else
912+ colorMultiplier = 2.0; // make it lighter
913+
914+ bc[3] = borderColor[3];
915+ bc[0] = MIN(MaxUShortFloat, ((float) borderColor[0]) * colorMultiplier) * bc[3] / MaxUShortFloat;
916+ bc[1] = MIN(MaxUShortFloat, ((float) borderColor[1]) * colorMultiplier) * bc[3] / MaxUShortFloat;
917+ bc[2] = MIN(MaxUShortFloat, ((float) borderColor[2]) * colorMultiplier) * bc[3] / MaxUShortFloat;
918+
919+ if (optionGetIncreaseBorderContrast ())
920+ {
921+ borderWidth *= biggerBorderWidthMultiplier;
922+
923+ glLineWidth (borderWidth);
924+ streamingBuffer->begin (GL_LINES);
925+ streamingBuffer->addVertices (8, &vertexData2[0]);
926+ streamingBuffer->addColors (1, bc);
927+ streamingBuffer->end ();
928+ streamingBuffer->render (sTransform);
929+ } else if (usingAverageColors) {
930+ borderColor = bc;
931+ }
932+ }
933+
934+ bc[3] = blend ? borderColor[3] : MaxUShortFloat;
935+ bc[0] = borderColor[0] * bc[3] / MaxUShortFloat;
936+ bc[1] = borderColor[1] * bc[3] / MaxUShortFloat;
937+ bc[2] = borderColor[2] * bc[3] / MaxUShortFloat;
938+
939+ glLineWidth (defaultBorderWidth);
940+ streamingBuffer->begin (GL_LINES);
941+ streamingBuffer->addColors (1, bc);
942+ streamingBuffer->addVertices (8, &vertexData2[0]);
943+ streamingBuffer->end ();
944+ streamingBuffer->render (sTransform);
945+
946+ if (blend)
947+ {
948+ glDisable (GL_BLEND);
949+#ifdef USE_GLES
950+ glBlendFuncSeparate (origSrc, origDst,
951+ origSrcAlpha, origDstAlpha);
952+#else
953+ glBlendFunc (origSrc, origDst);
954+#endif
955+ }
956+
957+ damageMovingRectangle (&box);
958+
959+ return true;
960+}
961+
962+bool
963 MovePluginVTable::init ()
964 {
965 if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
966
967=== modified file 'plugins/move/src/move.h'
968--- plugins/move/src/move.h 2015-10-20 15:11:54 +0000
969+++ plugins/move/src/move.h 2017-11-16 22:42:49 +0000
970@@ -32,7 +32,6 @@
971 #include <composite/composite.h>
972 #include <opengl/opengl.h>
973
974-
975 #define NUM_KEYS (sizeof (mKeys) / sizeof (mKeys[0]))
976
977 struct _MoveKeys
978@@ -49,6 +48,7 @@
979 };
980
981 class MoveScreen :
982+ public GLScreenInterface,
983 public ScreenInterface,
984 public CompositeScreenInterface,
985 public PluginClassHandler<MoveScreen,CompScreen>,
986@@ -59,6 +59,7 @@
987 ~MoveScreen ();
988
989 CompositeScreen *cScreen;
990+ GLScreen *gScreen;
991
992 void updateOpacity ();
993
994@@ -67,6 +68,16 @@
995 bool registerPaintHandler (compiz::composite::PaintHandler *pHnd);
996 void unregisterPaintHandler ();
997
998+ bool glPaintOutput (const GLScreenPaintAttrib &,
999+ const GLMatrix &,
1000+ const CompRegion &,
1001+ CompOutput *,
1002+ unsigned int);
1003+
1004+ bool getMovingRectangle (BoxPtr pbox);
1005+ bool damageMovingRectangle (BoxPtr pbox);
1006+ bool glPaintMovingRectangle (const GLMatrix &transform, CompOutput *output, unsigned short *borderColor, unsigned short *fillColor);
1007+
1008 CompWindow *w;
1009 int savedX;
1010 int savedY;
1011@@ -84,6 +95,10 @@
1012
1013 unsigned int origState;
1014
1015+ bool paintRect;
1016+ int rectX;
1017+ int rectY;
1018+
1019 int snapOffX;
1020 int snapBackX;
1021
1022
1023=== modified file 'plugins/neg/neg.xml.in'
1024--- plugins/neg/neg.xml.in 2012-10-15 10:31:51 +0000
1025+++ plugins/neg/neg.xml.in 2017-11-16 22:42:49 +0000
1026@@ -21,6 +21,11 @@
1027 <_long>Toggle active window negative</_long>
1028 <default>&lt;Super&gt;n</default>
1029 </option>
1030+ <option name="activate_at_startup" type="bool">
1031+ <_short>plugin should be active at startup</_short>
1032+ <_long>if active, the plugin will start active, with windows inverted</_long>
1033+ <default>false</default>
1034+ </option>
1035 <option name="screen_toggle_key" type="key">
1036 <_short>Toggle Screen Negative</_short>
1037 <_long>Toggle screen negative</_long>
1038
1039=== modified file 'plugins/neg/src/neg.cpp'
1040--- plugins/neg/src/neg.cpp 2013-05-09 13:43:07 +0000
1041+++ plugins/neg/src/neg.cpp 2017-11-16 22:42:49 +0000
1042@@ -437,7 +437,7 @@
1043 NegOptions (),
1044 negFunction (0),
1045 negAlphaFunction (0),
1046- isNeg (false),
1047+ isNeg (optionGetActivateAtStartup()),
1048 gScreen (GLScreen::get (screen))
1049 {
1050 optionSetWindowToggleKeyInitiate (boost::bind (&NegScreen::toggle, this,
1051
1052=== modified file 'plugins/resize/resize.xml.in'
1053--- plugins/resize/resize.xml.in 2015-10-26 17:15:43 +0000
1054+++ plugins/resize/resize.xml.in 2017-11-16 22:42:49 +0000
1055@@ -58,6 +58,16 @@
1056 <long>Maximizes the window vertically if the top or bottom screen edge is hit while resizing</long>
1057 <default>true</default>
1058 </option>
1059+ <option name="increase_border_contrast" type="bool">
1060+ <_short>Use a double-border in 'Rectangle' and 'Outline' modes</_short>
1061+ <_long>Increase the contrast of the border using a lighter color.</_long>
1062+ <default>true</default>
1063+ </option>
1064+ <option name="use_desktop_average_color" type="bool">
1065+ <_short>Use Desktop average colors</_short>
1066+ <_long>Try to use the desktop average color if defined by your DE (overrides custom colors).</_long>
1067+ <default>true</default>
1068+ </option>
1069 <option name="border_color" type="color">
1070 <_short>Border Color</_short>
1071 <_long>Border color used for outline and rectangle resize modes</_long>
1072@@ -78,6 +88,11 @@
1073 <alpha>0x1919</alpha>
1074 </default>
1075 </option>
1076+ <option name="disable_blend" type="bool">
1077+ <_short>Disable Transparency</_short>
1078+ <_long>Disable blending.</_long>
1079+ <default>false</default>
1080+ </option>
1081 <subgroup>
1082 <_short>Specific Window Matches</_short>
1083 <option name="normal_match" type="match">
1084
1085=== modified file 'plugins/resize/src/logic/src/resize-logic.cpp'
1086--- plugins/resize/src/logic/src/resize-logic.cpp 2016-03-03 14:22:25 +0000
1087+++ plugins/resize/src/logic/src/resize-logic.cpp 2017-11-16 22:42:49 +0000
1088@@ -487,13 +487,13 @@
1089 che = he;
1090
1091 if (w->constrainNewWindowSize (wi, he, &cwi, &che) &&
1092- mode != ResizeOptions::ModeNormal)
1093+ mode != ResizeOptions::ModeNormal &&
1094+ mode != ResizeOptions::ModeOutline)
1095 {
1096 Box box;
1097
1098 /* Also, damage relevant paint rectangles */
1099- if (mode == ResizeOptions::ModeRectangle ||
1100- mode == ResizeOptions::ModeOutline)
1101+ if (mode == ResizeOptions::ModeRectangle)
1102 getPaintRectangle (&box);
1103 else if (mode == ResizeOptions::ModeStretch)
1104 getStretchRectangle (&box);
1105@@ -518,7 +518,8 @@
1106 xRoot, yRoot,
1107 wX, wY, wWidth, wHeight); /*in*/
1108
1109- if (mode != ResizeOptions::ModeNormal)
1110+ if (mode != ResizeOptions::ModeNormal &&
1111+ mode != ResizeOptions::ModeOutline)
1112 {
1113 if (mode == ResizeOptions::ModeStretch)
1114 getStretchRectangle (&box);
1115@@ -532,7 +533,8 @@
1116
1117 computeGeometry (wi, he);
1118
1119- if (mode != ResizeOptions::ModeNormal)
1120+ if (mode != ResizeOptions::ModeNormal &&
1121+ mode != ResizeOptions::ModeOutline)
1122 {
1123 if (mode == ResizeOptions::ModeStretch)
1124 getStretchRectangle (&box);
1125@@ -541,7 +543,7 @@
1126
1127 damageRectangle (&box);
1128 }
1129- else
1130+ else if (mode == ResizeOptions::ModeNormal)
1131 {
1132 updateWindowSize ();
1133 }
1134
1135=== modified file 'plugins/resize/src/resize.cpp'
1136--- plugins/resize/src/resize.cpp 2015-10-20 15:01:58 +0000
1137+++ plugins/resize/src/resize.cpp 2017-11-16 22:42:49 +0000
1138@@ -70,8 +70,8 @@
1139
1140 static bool
1141 resizeTerminate (CompAction *action,
1142- CompAction::State state,
1143- CompOption::Vector &options)
1144+ CompAction::State state,
1145+ CompOption::Vector &options)
1146 {
1147 RESIZE_SCREEN (screen);
1148 return rs->logic.terminateResize(action, state, options);
1149@@ -85,30 +85,57 @@
1150 unsigned short *fillColor)
1151 {
1152 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
1153+ const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
1154+ const float MaxUShortFloat = MaxUShort;
1155+ bool usingAverageColors = false;
1156
1157 BoxRec box;
1158+ CompRegion damageRegion;
1159 GLMatrix sTransform (transform);
1160 GLfloat vertexData [12];
1161 GLfloat vertexData2[24];
1162- GLint origSrc, origDst;
1163- GLushort fc[4], bc[4];
1164-
1165-#ifdef USE_GLES
1166- GLint origSrcAlpha, origDstAlpha;
1167- glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
1168- glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
1169- glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
1170- glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
1171+ GLint origSrc, origDst;
1172+#ifdef USE_GLES
1173+ GLint origSrcAlpha, origDstAlpha;
1174+#endif
1175+ GLushort fc[4], bc[4], averageFillColor[4];
1176+
1177+ if (optionGetUseDesktopAverageColor ())
1178+ {
1179+ const unsigned short *averageColor = screen->averageColor ();
1180+
1181+ if (averageColor)
1182+ {
1183+ usingAverageColors = true;
1184+ borderColor = const_cast<unsigned short *>(averageColor);
1185+ memcpy (averageFillColor, averageColor, 4 * sizeof (unsigned short));
1186+ averageFillColor[3] = MaxUShort * 0.6;
1187+
1188+ if (fillColor)
1189+ fillColor = averageFillColor;
1190+ }
1191+ }
1192+
1193+ bool blend = !optionGetDisableBlend ();
1194+
1195+ if (blend && borderColor[3] == MaxUShort)
1196+ {
1197+ if (optionGetMode () == ResizeOptions::ModeOutline || fillColor[3] == MaxUShort)
1198+ blend = false;
1199+ }
1200+
1201+ if (blend)
1202+ {
1203+#ifdef USE_GLES
1204+ glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
1205+ glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
1206+ glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
1207+ glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
1208 #else
1209- glGetIntegerv (GL_BLEND_SRC, &origSrc);
1210- glGetIntegerv (GL_BLEND_DST, &origDst);
1211+ glGetIntegerv (GL_BLEND_SRC, &origSrc);
1212+ glGetIntegerv (GL_BLEND_DST, &origDst);
1213 #endif
1214-
1215- /* Premultiply the alpha values */
1216- bc[3] = (float) borderColor[3] / (float) 65535.0f;
1217- bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
1218- bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
1219- bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
1220+ }
1221
1222 logic.getPaintRectangle (&box);
1223
1224@@ -159,16 +186,19 @@
1225
1226 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
1227
1228- glEnable (GL_BLEND);
1229- glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1230+ if (blend)
1231+ {
1232+ glEnable (GL_BLEND);
1233+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1234+ }
1235
1236 /* fill rectangle */
1237 if (fillColor)
1238 {
1239- fc[3] = fillColor[3];
1240- fc[0] = fillColor[0] * (unsigned long)fc[3] / 65535;
1241- fc[1] = fillColor[1] * (unsigned long)fc[3] / 65535;
1242- fc[2] = fillColor[2] * (unsigned long)fc[3] / 65535;
1243+ fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
1244+ fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
1245+ fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
1246+ fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
1247
1248 streamingBuffer->begin (GL_TRIANGLE_STRIP);
1249 streamingBuffer->addColors (1, fc);
1250@@ -178,28 +208,98 @@
1251 }
1252
1253 /* draw outline */
1254- static const int borderWidth = 2;
1255- glLineWidth (borderWidth);
1256+ static const int defaultBorderWidth = 2;
1257+ int borderWidth = defaultBorderWidth;
1258+
1259+ if (optionGetIncreaseBorderContrast() || usingAverageColors)
1260+ {
1261+ // Generate a lighter color based on border to create more contrast
1262+ unsigned int averageColorLevel = (borderColor[0] + borderColor[1] + borderColor[2]) / 3;
1263+
1264+ float colorMultiplier;
1265+ if (averageColorLevel > MaxUShort * 0.3)
1266+ colorMultiplier = 0.7; // make it darker
1267+ else
1268+ colorMultiplier = 2.0; // make it lighter
1269+
1270+ bc[3] = borderColor[3];
1271+ bc[0] = MIN(MaxUShortFloat, ((float) borderColor[0]) * colorMultiplier) * bc[3] / MaxUShortFloat;
1272+ bc[1] = MIN(MaxUShortFloat, ((float) borderColor[1]) * colorMultiplier) * bc[3] / MaxUShortFloat;
1273+ bc[2] = MIN(MaxUShortFloat, ((float) borderColor[2]) * colorMultiplier) * bc[3] / MaxUShortFloat;
1274+
1275+ if (optionGetIncreaseBorderContrast ())
1276+ {
1277+ borderWidth *= 2;
1278+
1279+ glLineWidth (borderWidth);
1280+ streamingBuffer->begin (GL_LINES);
1281+ streamingBuffer->addVertices (8, &vertexData2[0]);
1282+ streamingBuffer->addColors (1, bc);
1283+ streamingBuffer->end ();
1284+ streamingBuffer->render (sTransform);
1285+ } else if (usingAverageColors) {
1286+ borderColor = bc;
1287+ }
1288+ }
1289+
1290+ bc[3] = blend ? borderColor[3] : MaxUShortFloat;
1291+ bc[0] = borderColor[0] * bc[3] / MaxUShortFloat;
1292+ bc[1] = borderColor[1] * bc[3] / MaxUShortFloat;
1293+ bc[2] = borderColor[2] * bc[3] / MaxUShortFloat;
1294+
1295+ glLineWidth (defaultBorderWidth);
1296 streamingBuffer->begin (GL_LINES);
1297- streamingBuffer->addColors (1, borderColor);
1298+ streamingBuffer->addColors (1, bc);
1299 streamingBuffer->addVertices (8, &vertexData2[0]);
1300 streamingBuffer->end ();
1301 streamingBuffer->render (sTransform);
1302
1303- glDisable (GL_BLEND);
1304+ if (blend)
1305+ {
1306+ glDisable (GL_BLEND);
1307 #ifdef USE_GLES
1308- glBlendFuncSeparate (origSrc, origDst,
1309- origSrcAlpha, origDstAlpha);
1310+ glBlendFuncSeparate (origSrc, origDst,
1311+ origSrcAlpha, origDstAlpha);
1312 #else
1313- glBlendFunc (origSrc, origDst);
1314+ glBlendFunc (origSrc, origDst);
1315 #endif
1316+ }
1317
1318 CompositeScreen *cScreen = CompositeScreen::get (screen);
1319- CompRect damage (box.x1 - borderWidth,
1320- box.y1 - borderWidth,
1321- box.x2 - box.x1 + 2 * borderWidth,
1322- box.y2 - box.y1 + 2 * borderWidth);
1323- cScreen->damageRegion (damage);
1324+
1325+ if (optionGetMode () == ResizeOptions::ModeOutline)
1326+ {
1327+ // Top
1328+ damageRegion += CompRect (box.x1 - borderWidth,
1329+ box.y1 - borderWidth,
1330+ box.x2 - box.x1 + borderWidth * 2,
1331+ borderWidth * 2);
1332+ // Right
1333+ damageRegion += CompRect (box.x2 - borderWidth,
1334+ box.y1 - borderWidth,
1335+ borderWidth + borderWidth / 2,
1336+ box.y2 - box.y1 + borderWidth * 2);
1337+ // Bottom
1338+ damageRegion += CompRect (box.x1 - borderWidth,
1339+ box.y2 - borderWidth,
1340+ box.x2 - box.x1 + borderWidth * 2,
1341+ borderWidth * 2);
1342+ // Left
1343+ damageRegion += CompRect (box.x1 - borderWidth,
1344+ box.y1 - borderWidth,
1345+ borderWidth + borderWidth / 2,
1346+ box.y2 - box.y1 + borderWidth * 2);
1347+ }
1348+ else
1349+ {
1350+ CompRect damage (box.x1 - borderWidth,
1351+ box.y1 - borderWidth,
1352+ box.x2 - box.x1 + borderWidth * 2,
1353+ box.y2 - box.y1 + borderWidth * 2);
1354+ damageRegion += damage;
1355+ }
1356+
1357+ cScreen->damageRegion (damageRegion);
1358 }
1359
1360 bool
1361
1362=== modified file 'src/atoms.cpp'
1363--- src/atoms.cpp 2015-02-17 14:54:10 +0000
1364+++ src/atoms.cpp 2017-11-16 22:42:49 +0000
1365@@ -155,6 +155,8 @@
1366
1367 Atom startupId;
1368
1369+ Atom gnomeRepresentativeColors;
1370+
1371 void init (Display *dpy)
1372 {
1373 supported = XInternAtom (dpy, "_NET_SUPPORTED", 0);
1374@@ -325,5 +327,7 @@
1375 atomPair = XInternAtom (dpy, "ATOM_PAIR", 0);
1376
1377 startupId = XInternAtom (dpy, "_NET_STARTUP_ID", 0);
1378+
1379+ gnomeRepresentativeColors = XInternAtom (dpy, "_GNOME_BACKGROUND_REPRESENTATIVE_COLORS", 0);
1380 }
1381 };
1382
1383=== modified file 'src/event.cpp'
1384--- src/event.cpp 2016-05-17 02:52:07 +0000
1385+++ src/event.cpp 2017-11-16 22:42:49 +0000
1386@@ -1821,6 +1821,11 @@
1387 if (w)
1388 w->priv->updateStartupId ();
1389 }
1390+ else if (event->xproperty.atom == Atoms::gnomeRepresentativeColors)
1391+ {
1392+ if (event->xproperty.window == privateScreen.rootWindow())
1393+ privateScreen.updateAverageColor (event->xproperty.atom);
1394+ }
1395 else if (event->xproperty.atom == XA_WM_CLASS)
1396 {
1397 w = findWindow (event->xproperty.window);
1398
1399=== modified file 'src/privatescreen.h'
1400--- src/privatescreen.h 2016-05-17 02:52:07 +0000
1401+++ src/privatescreen.h 2017-11-16 22:42:49 +0000
1402@@ -692,6 +692,8 @@
1403
1404 void updateResources ();
1405
1406+ void updateAverageColor (Atom atom);
1407+
1408 Window getActiveWindow (Window root);
1409
1410 void setWindowState (unsigned int state, Window id);
1411@@ -777,6 +779,8 @@
1412 unsigned int nDesktop;
1413 unsigned int currentDesktop;
1414
1415+ std::vector<unsigned short> averageColor;
1416+
1417 CompOutput fullscreenOutput;
1418 CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
1419
1420@@ -1092,6 +1096,7 @@
1421 virtual CompWindow * getTopServerWindow() const;
1422 virtual CoreOptions& getCoreOptions();
1423 virtual Colormap colormap() const;
1424+ virtual const unsigned short * averageColor() const;
1425 virtual void setCurrentDesktop (unsigned int desktop);
1426 virtual Window activeWindow() const;
1427 virtual bool grabWindowIsNot(Window w) const;
1428@@ -1187,6 +1192,7 @@
1429 virtual void _matchPropertyChanged(CompWindow *);
1430 virtual void _outputChangeNotify();
1431 virtual void _cursorChangeNotify(const CompString&, int);
1432+ virtual void _averageColorChangeNotify(const unsigned short*);
1433
1434 void grabServer ();
1435 void ungrabServer ();
1436
1437=== modified file 'src/privatescreen/tests/test-privatescreen.cpp'
1438--- src/privatescreen/tests/test-privatescreen.cpp 2016-05-17 02:52:07 +0000
1439+++ src/privatescreen/tests/test-privatescreen.cpp 2017-11-16 22:42:49 +0000
1440@@ -82,6 +82,7 @@
1441 MOCK_METHOD1(_matchPropertyChanged, void (CompWindow *));
1442 MOCK_METHOD0(_outputChangeNotify, void ());
1443 MOCK_METHOD2(_cursorChangeNotify, void (const CompString&, int));
1444+ MOCK_METHOD1(_averageColorChangeNotify, void (const unsigned short*));
1445
1446 MOCK_METHOD0(outputDevs, CompOutput::vector & ());
1447 MOCK_METHOD2(setWindowState, void (unsigned int state, Window id));
1448@@ -199,6 +200,7 @@
1449 MOCK_CONST_METHOD0(getTopServerWindow, CompWindow * ());
1450 MOCK_METHOD0(getCoreOptions, CoreOptions& ());
1451 MOCK_CONST_METHOD0(colormap, Colormap ());
1452+ MOCK_CONST_METHOD0(averageColor, const unsigned short * ());
1453 MOCK_METHOD1(setCurrentDesktop, void (unsigned int desktop));
1454 MOCK_CONST_METHOD0(activeWindow, Window ());
1455 MOCK_CONST_METHOD1(grabWindowIsNot, bool (Window w));
1456
1457=== modified file 'src/screen.cpp'
1458--- src/screen.cpp 2016-08-01 13:25:02 +0000
1459+++ src/screen.cpp 2017-11-16 22:42:49 +0000
1460@@ -1427,6 +1427,113 @@
1461 screen->cursorChangeNotify (cursorTheme, cursorSize);
1462 }
1463
1464+void
1465+PrivateScreen::updateAverageColor (Atom atom)
1466+{
1467+ Atom actual_type;
1468+ int result, format;
1469+ unsigned long n, left;
1470+ unsigned char *data;
1471+
1472+ auto previousAverageColor = averageColor;
1473+ averageColor.clear ();
1474+
1475+ result = XGetWindowProperty (dpy, root,
1476+ atom, 0L, 65536, False,
1477+ XA_STRING, &actual_type, &format,
1478+ &n, &left, &data);
1479+
1480+ if (result != Success || !data || actual_type != XA_STRING)
1481+ {
1482+ if (previousAverageColor != averageColor)
1483+ screen->averageColorChangeNotify (averageColor.data ());
1484+
1485+ XFree (data);
1486+ return;
1487+ }
1488+
1489+ CompString colors (reinterpret_cast<char *> (data));
1490+ bool found_valid;
1491+ double r, g, b, a;
1492+ found_valid = false;
1493+ r = g = b = 0.0;
1494+ a = 1.0;
1495+ const CompString rgba_regex = R"((rgba?))"
1496+ R"(\s*\(\s*([0-9]{1,3})\s*,)"
1497+ R"(\s*([0-9]{1,3})\s*,)"
1498+ R"(\s*([0-9]{1,3})\s*)"
1499+ R"((,\s*((0*(\.[0-9]+)|1(\.0*)?)?)\s*)?\))";
1500+
1501+ std::vector<CompString> matches = compGetRegexMatches (rgba_regex, colors);
1502+
1503+ if (matches.size () > 4)
1504+ {
1505+ try
1506+ {
1507+ found_valid = true;
1508+ r = std::stoi (matches[2]) / 255.0;
1509+ g = std::stoi (matches[3]) / 255.0;
1510+ b = std::stoi (matches[4]) / 255.0;
1511+
1512+ if (matches[1] == "rgba")
1513+ {
1514+ if (matches.size () > 6 && !matches[6].empty ())
1515+ a = std::stod (matches[6][0] == '.' ? '0'+matches[6] : matches[6]);
1516+ else
1517+ found_valid = false;
1518+ }
1519+ } catch (std::exception const& except) {
1520+ found_valid = false;
1521+ compLogMessage ("core", CompLogLevelWarn, "%s: failed to parse '%s' color string",
1522+ except.what (), colors.c_str ());
1523+ }
1524+ } else {
1525+ size_t color_len = (colors.length () - 1) / 3;
1526+
1527+ if (color_len > 0 && color_len <= 4)
1528+ {
1529+ CompString hex_regex = "#([[:xdigit:]]{" + std::to_string(color_len) + "})" +
1530+ "([[:xdigit:]]{" + std::to_string(color_len) + "})" +
1531+ "([[:xdigit:]]{" + std::to_string(color_len) + "})" +
1532+ "([[:xdigit:]]{" + std::to_string(color_len) + "})?$";
1533+ std::vector<CompString> matches = compGetRegexMatches (hex_regex, colors);
1534+ if (matches.size () == 5)
1535+ {
1536+ try
1537+ {
1538+ double max_value = static_cast<float> ((1 << (4 * color_len)) - 1);
1539+ found_valid = true;
1540+ r = std::stoi (matches[1], 0, 16) / max_value;
1541+ g = std::stoi (matches[2], 0, 16) / max_value;
1542+ b = std::stoi (matches[3], 0, 16) / max_value;
1543+
1544+ if (!matches[4].empty ())
1545+ a = std::stoi (matches[4], 0, 16) / max_value;
1546+ } catch (std::exception const& except) {
1547+ found_valid = false;
1548+ compLogMessage ("core", CompLogLevelWarn, "%s: failed to parse '%s' color string",
1549+ except.what (), colors.c_str ());
1550+ }
1551+ }
1552+ }
1553+ }
1554+
1555+ if (found_valid)
1556+ {
1557+ const double MaxUShort = std::numeric_limits<unsigned short>::max ();
1558+ averageColor.resize (4);
1559+ averageColor[0] = MAX (0, MIN (r * MaxUShort, MaxUShort));
1560+ averageColor[1] = MAX (0, MIN (g * MaxUShort, MaxUShort));
1561+ averageColor[2] = MAX (0, MIN (b * MaxUShort, MaxUShort));
1562+ averageColor[3] = MAX (0, MIN (a * MaxUShort, MaxUShort));
1563+ }
1564+
1565+ XFree (data);
1566+
1567+ if (previousAverageColor != averageColor)
1568+ screen->averageColorChangeNotify (averageColor.data ());
1569+}
1570+
1571 bool
1572 CompScreen::fileToImage (CompString &name,
1573 CompSize &size,
1574@@ -1732,7 +1839,7 @@
1575
1576 result = XGetWindowProperty (dpy, id,
1577 Atoms::mwmHints,
1578- 0L, 20L, false, Atoms::mwmHints,
1579+ 0L, 20L, false, AnyPropertyType,
1580 &actual, &format, &n, &left, &data);
1581
1582 if (result == Success && data)
1583@@ -3153,7 +3260,7 @@
1584 }
1585
1586 if ((type & cps::GrabType::KEYBOARD) &&
1587- !eventManager.topGrab (cps::GrabType::KEYBOARD))
1588+ !eventManager.topGrab (cps::GrabType::KEYBOARD))
1589 {
1590 status = XGrabKeyboard (dpy,
1591 eventManager.getGrabWindow (), true,
1592@@ -3171,7 +3278,7 @@
1593 }
1594 else
1595 {
1596- XUngrabPointer (dpy, CurrentTime);
1597+ XUngrabPointer (dpy, CurrentTime);
1598 }
1599 }
1600
1601@@ -3242,7 +3349,7 @@
1602 }
1603 else
1604 {
1605- XUngrabPointer (privateScreen.dpy, CurrentTime);
1606+ XUngrabPointer (privateScreen.dpy, CurrentTime);
1607 }
1608 }
1609
1610@@ -4226,10 +4333,10 @@
1611 PrivateScreen::updateCursors (const CompString& theme, int size)
1612 {
1613 if (size > 0)
1614- XcursorSetDefaultSize (dpy, size);
1615+ XcursorSetDefaultSize (dpy, size);
1616
1617 if (!theme.empty())
1618- XcursorSetTheme (dpy, theme.c_str());
1619+ XcursorSetTheme (dpy, theme.c_str());
1620
1621 for (auto it = begin (cursors); it != end (cursors); ++it)
1622 {
1623@@ -4250,6 +4357,18 @@
1624 privateScreen.updateCursors (theme, size);
1625 }
1626
1627+void
1628+CompScreen::averageColorChangeNotify (const unsigned short* color)
1629+{
1630+ WRAPABLE_HND_FUNCTN (averageColorChangeNotify, color);
1631+ _averageColorChangeNotify (color);
1632+}
1633+
1634+void
1635+CompScreenImpl::_averageColorChangeNotify (const unsigned short* color)
1636+{
1637+}
1638+
1639 /* Returns default viewport for some window geometry. If the window spans
1640 * more than one viewport the most appropriate viewport is returned. How the
1641 * most appropriate viewport is computed can be made optional if necessary. It
1642@@ -4396,6 +4515,10 @@
1643 ScreenInterface::cursorChangeNotify (const CompString& theme, int size)
1644 WRAPABLE_DEF (cursorChangeNotify, theme, size)
1645
1646+void
1647+ScreenInterface::averageColorChangeNotify (const unsigned short *color)
1648+ WRAPABLE_DEF (averageColorChangeNotify, color)
1649+
1650 Window
1651 CompScreenImpl::root ()
1652 {
1653@@ -4841,6 +4964,12 @@
1654 return privateScreen.colormap;
1655 }
1656
1657+const unsigned short *
1658+CompScreenImpl::averageColor() const
1659+{
1660+ return privateScreen.averageColor.data ();
1661+}
1662+
1663 void
1664 CompScreenImpl::setCurrentDesktop (unsigned int desktop)
1665 {
1666@@ -5270,6 +5399,8 @@
1667 XIGetClientPointer (dpy, None, &clientPointerDeviceId);
1668 updateResources ();
1669
1670+ updateAverageColor (Atoms::gnomeRepresentativeColors);
1671+
1672 /* Attempt to gain SubstructureRedirectMask */
1673 CompScreenImpl::checkForError (dpy);
1674
1675
1676=== modified file 'src/string/src/string.cpp'
1677--- src/string/src/string.cpp 2012-03-23 03:37:26 +0000
1678+++ src/string/src/string.cpp 2017-11-16 22:42:49 +0000
1679@@ -1,5 +1,6 @@
1680 /*
1681 * Copyright © 2008 Dennis Kasprzyk
1682+ * Copyright © 2017 Canonical Ltd.
1683 *
1684 * Permission to use, copy, modify, distribute, and sell this software
1685 * and its documentation for any purpose is hereby granted without
1686@@ -21,12 +22,20 @@
1687 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1688 *
1689 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1690+ * Marco Trevisan <marco.trevisan@canonical.com>
1691 */
1692
1693 #include <cstring>
1694 #include <cstdarg>
1695 #include <cstdio>
1696
1697+#if defined(__GNUC__) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9)))
1698+#include <regex.h>
1699+#else
1700+#include <regex>
1701+#define HAVE_CPP_REGEX
1702+#endif
1703+
1704 #include <core/string.h>
1705
1706 CompString compPrintf (const char *format, ...)
1707@@ -86,3 +95,55 @@
1708 delete [] str;
1709 return rv;
1710 }
1711+
1712+CompStringVector
1713+compGetRegexMatches(const CompString& regexStr,
1714+ const CompString& string)
1715+{
1716+
1717+ CompStringVector matches;
1718+
1719+#ifdef HAVE_CPP_REGEX
1720+
1721+ std::smatch subMatches;
1722+ std::regex regex(regexStr);
1723+
1724+ if (std::regex_match(string, subMatches, regex))
1725+ {
1726+ for (const auto& subMatch : subMatches)
1727+ matches.push_back (subMatch.str ());
1728+ }
1729+
1730+#else
1731+
1732+ regex_t regex;
1733+ int ret;
1734+ ret = regcomp (&regex, regexStr.c_str (), REG_EXTENDED);
1735+
1736+ if (ret != 0)
1737+ return matches;
1738+
1739+ std::vector<regmatch_t> subMatches (regex.re_nsub + 1);
1740+ ret = regexec (&regex, string.c_str (), subMatches.size (), subMatches.data (), 0);
1741+
1742+ if (ret == REG_NOMATCH)
1743+ return matches;
1744+
1745+ for (const auto& sub_match : subMatches)
1746+ {
1747+ if (sub_match.rm_so >= 0)
1748+ {
1749+ size_t sub_len = sub_match.rm_eo - sub_match.rm_so;
1750+ matches.push_back (string.substr (sub_match.rm_so, sub_len));
1751+ } else {
1752+ /* We keep this empty so the clients might access to all the subs */
1753+ matches.push_back (CompString ());
1754+ }
1755+ }
1756+
1757+ regfree (&regex);
1758+
1759+#endif
1760+
1761+ return matches;
1762+}
1763
1764=== modified file 'src/window.cpp'
1765--- src/window.cpp 2016-05-17 02:52:25 +0000
1766+++ src/window.cpp 2017-11-16 22:42:49 +0000
1767@@ -6921,8 +6921,8 @@
1768 /* Gravity here is assumed to be SouthEast, clients can update
1769 * that if need be */
1770
1771- serverFrameGeometry.set (serverInput.left - border.left,
1772- serverInput.top - border.top,
1773+ serverFrameGeometry.set (wa.x + (serverInput.left - border.left),
1774+ wa.y + (serverInput.top - border.top),
1775 wa.width + (serverInput.left +
1776 serverInput.right),
1777 wa.height + (serverInput.top +

Subscribers

People subscribed via source and target branches

to all changes: