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
=== modified file 'VERSION'
--- VERSION 2015-08-19 15:50:54 +0000
+++ VERSION 2017-11-16 22:42:49 +0000
@@ -1,1 +1,1 @@
10.9.12.210.9.12.3
22
=== modified file 'debian/changelog'
--- debian/changelog 2016-08-23 16:06:02 +0000
+++ debian/changelog 2017-11-16 22:42:49 +0000
@@ -1,3 +1,31 @@
1compiz (1:0.9.12.3) UNRELEASED; urgency=medium
2
3 [ Eleni Maria Stea ]
4 * Added option to disable blend in grid plugin (LP: #1700859)
5 * Move: add options for showing only the window shape (filled or not)
6 (LP: #1700859)
7
8 [ Alberts Muktupāvels ]
9 * Ensure that surfaces used by metacity theme have device scale set to
10 1 . (LP: #1530277) (LP: #1530277)
11 * Use AnyPropertyType when getting _MOTIF_WM_HINTS property. (LP:
12 #1702297)
13
14 [ Martin Wimpress ]
15 * mate: Avoid artefacts of Windows Thumbnail Previews (LP: #1606369)
16
17 [ Marco Trevisan (Treviño) ]
18 * move: damage all the border area in outline mode and ignore
19 transparent colors (LP: #1700859)
20 * grid: ignore alpha in colors when not blending, and fix animations
21 (LP: #1700859)
22 * resize: add support for disabling transparency and avoid over-
23 damaging in outline mode (LP: #1700859)
24 * Screen: add averageColor to get the current desktop average color
25 * unity-lowgfx.ini: remove unsupported unity option
26
27 -- Marco Trevisan <marco@ubuntu.com> Tue, 27 Jun 2017 18:49:59 +0200
28
1compiz (1:0.9.12.2+16.04.20160823-0ubuntu1) xenial; urgency=medium29compiz (1:0.9.12.2+16.04.20160823-0ubuntu1) xenial; urgency=medium
230
3 [ Andrea Azzarone ]31 [ Andrea Azzarone ]
432
=== modified file 'debian/mate.ini'
--- debian/mate.ini 2016-04-07 11:50:19 +0000
+++ debian/mate.ini 2017-11-16 22:42:49 +0000
@@ -50,17 +50,17 @@
50s0_active_shadow_radius = 13.00000050s0_active_shadow_radius = 13.000000
51s0_active_shadow_opacity = 0.22500051s0_active_shadow_opacity = 0.225000
52s0_active_shadow_color = #0000008052s0_active_shadow_color = #00000080
53s0_active_shadow_x_offset = 653s0_active_shadow_x_offset = 2
54s0_active_shadow_y_offset = 654s0_active_shadow_y_offset = 2
55s0_inactive_shadow_radius = 13.00000055s0_inactive_shadow_radius = 13.000000
56s0_inactive_shadow_opacity = 0.22500056s0_inactive_shadow_opacity = 0.225000
57s0_inactive_shadow_color = #000000ff57s0_inactive_shadow_color = #000000ff
58s0_inactive_shadow_x_offset = 658s0_inactive_shadow_x_offset = 2
59s0_inactive_shadow_y_offset = 659s0_inactive_shadow_y_offset = 2
60s0_mipmap = true60s0_mipmap = false
6161
62[expo]62[expo]
63s0_expo_key = <Super>a63s0_expo_key = <Super>s
64s0_selected_color = #34422eff64s0_selected_color = #34422eff
65s0_reflection = true65s0_reflection = true
66s0_ground_color1 = #343631cc66s0_ground_color1 = #343631cc
@@ -162,12 +162,12 @@
162s0_manual_only = false162s0_manual_only = false
163163
164[thumbnail]164[thumbnail]
165s0_thumb_size = 280165s0_thumb_size = 256
166s0_fade_speed = 0.000000166s0_fade_speed = 0.000000
167s0_border = 12167s0_border = 15
168s0_thumb_color = #34363130168s0_thumb_color = #34363130
169s0_window_like = false169s0_window_like = false
170s0_mipmap = true170s0_mipmap = false
171s0_current_viewport = false171s0_current_viewport = false
172s0_title_enabled = false172s0_title_enabled = false
173s0_font_bold = false173s0_font_bold = false
174174
=== added file 'debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade'
--- debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade 1970-01-01 00:00:00 +0000
+++ debian/profile_upgrades/com.canonical.unity.unity-lowgfx.01.upgrade 2017-11-16 22:42:49 +0000
@@ -0,0 +1,12 @@
1[grid]
2+s0_animation_duration = 0
3+s0_draw_stretched_window = false
4
5[move]
6+s0_mode = 2
7+s0_increase_border_contrast = true
8+s0_lazy_positioning = true
9
10[resize]
11+s0_mode = 2
12+s0_increase_border_contrast = true
013
=== modified file 'debian/unity-lowgfx.ini'
--- debian/unity-lowgfx.ini 2016-07-14 15:51:05 +0000
+++ debian/unity-lowgfx.ini 2017-11-16 22:42:49 +0000
@@ -12,10 +12,17 @@
12s0_fade_time = 112s0_fade_time = 1
1313
14[grid]14[grid]
15s0_animation_duration = 115s0_animation_duration = 0
16s0_draw_stretched_window = false
17
18[move]
19s0_mode = 2
20s0_lazy_positioning = true
21s0_increase_border_contrast = true
1622
17[resize]23[resize]
18s0_mode = 224s0_mode = 2
25s0_increase_border_contrast = true
1926
20[opengl]27[opengl]
21s0_texture_filter = 028s0_texture_filter = 0
@@ -24,7 +31,6 @@
24s0_skip_animation = true31s0_skip_animation = true
2532
26[unityshell]33[unityshell]
27s0_low_graphics_mode = true
28s0_dash_blur_experimental = 034s0_dash_blur_experimental = 0
2935
30s0_override_decoration_theme = true36s0_override_decoration_theme = true
3137
=== modified file 'debian/unity.ini'
--- debian/unity.ini 2014-03-10 15:21:11 +0000
+++ debian/unity.ini 2017-11-16 22:42:49 +0000
@@ -1,3 +1,2 @@
1[core]1[core]
2s0_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;unityshell2s0_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
3
43
=== modified file 'gtk/window-decorator/decorator.c'
--- gtk/window-decorator/decorator.c 2016-02-29 13:41:59 +0000
+++ gtk/window-decorator/decorator.c 2017-11-16 22:42:49 +0000
@@ -603,6 +603,8 @@
603 else603 else
604 buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgba);604 buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgba);
605605
606 // FIXME: this should match the current monitor scaling!
607 cairo_surface_set_device_scale (buffer_surface, 1, 1);
606 gdk_flush ();608 gdk_flush ();
607609
608 /* Handle failure */610 /* Handle failure */
609611
=== modified file 'gtk/window-decorator/metacity.c'
--- gtk/window-decorator/metacity.c 2016-03-17 17:47:36 +0000
+++ gtk/window-decorator/metacity.c 2017-11-16 22:42:49 +0000
@@ -697,6 +697,8 @@
697 else697 else
698 surface = create_surface (fgeom.width, fgeom.height, d->frame->style_window_rgba);698 surface = create_surface (fgeom.width, fgeom.height, d->frame->style_window_rgba);
699699
700 // FIXME: this should match the current monitor scaling!
701 cairo_surface_set_device_scale (surface, 1, 1);
700 cr = cairo_create (surface);702 cr = cairo_create (surface);
701 gdk_cairo_set_source_rgba (cr, &bg_rgba);703 gdk_cairo_set_source_rgba (cr, &bg_rgba);
702 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);704 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
703705
=== modified file 'gtk/window-decorator/util.c'
--- gtk/window-decorator/util.c 2016-03-17 17:47:36 +0000
+++ gtk/window-decorator/util.c 2017-11-16 22:42:49 +0000
@@ -75,7 +75,7 @@
75 gdk_error_trap_push ();75 gdk_error_trap_push ();
7676
77 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,77 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,
78 0L, 20L, FALSE, mwm_hints_atom,78 0L, 20L, FALSE, AnyPropertyType,
79 &actual, &format, &n, &left, &data);79 &actual, &format, &n, &left, &data);
8080
81 err = gdk_error_trap_pop ();81 err = gdk_error_trap_pop ();
8282
=== modified file 'include/core/abiversion.h'
--- include/core/abiversion.h 2015-10-13 11:33:31 +0000
+++ include/core/abiversion.h 2017-11-16 22:42:49 +0000
@@ -5,6 +5,6 @@
5# error Conflicting definitions of CORE_ABIVERSION5# error Conflicting definitions of CORE_ABIVERSION
6#endif6#endif
77
8#define CORE_ABIVERSION 201510108#define CORE_ABIVERSION 20170630
99
10#endif // COMPIZ_ABIVERSION_H10#endif // COMPIZ_ABIVERSION_H
1111
=== modified file 'include/core/atoms.h'
--- include/core/atoms.h 2015-02-17 14:54:10 +0000
+++ include/core/atoms.h 2017-11-16 22:42:49 +0000
@@ -158,6 +158,8 @@
158158
159 extern Atom startupId;159 extern Atom startupId;
160160
161 extern Atom gnomeRepresentativeColors;
162
161 void init (Display *dpy);163 void init (Display *dpy);
162};164};
163165
164166
=== modified file 'include/core/screen.h'
--- include/core/screen.h 2016-05-17 02:52:07 +0000
+++ include/core/screen.h 2017-11-16 22:42:49 +0000
@@ -156,6 +156,8 @@
156 virtual void addSupportedAtoms (std::vector<Atom>& atoms);156 virtual void addSupportedAtoms (std::vector<Atom>& atoms);
157157
158 virtual void cursorChangeNotify (const CompString& theme, int size);158 virtual void cursorChangeNotify (const CompString& theme, int size);
159
160 virtual void averageColorChangeNotify (const unsigned short *color);
159};161};
160162
161namespace compiz { namespace private_screen {163namespace compiz { namespace private_screen {
@@ -221,7 +223,7 @@
221}223}
222224
223class CompScreen :225class CompScreen :
224 public WrapableHandler<ScreenInterface, 19>,226 public WrapableHandler<ScreenInterface, 20>,
225 public PluginClassStorage, // TODO should be an interface here227 public PluginClassStorage, // TODO should be an interface here
226 public CompSize,228 public CompSize,
227 public virtual ::compiz::DesktopWindowCount,229 public virtual ::compiz::DesktopWindowCount,
@@ -273,6 +275,8 @@
273 std::vector<Atom>& atoms);275 std::vector<Atom>& atoms);
274 WRAPABLE_HND (18, ScreenInterface, void, cursorChangeNotify,276 WRAPABLE_HND (18, ScreenInterface, void, cursorChangeNotify,
275 const CompString&, int);277 const CompString&, int);
278 WRAPABLE_HND (19, ScreenInterface, void, averageColorChangeNotify,
279 const unsigned short *);
276280
277 unsigned int allocPluginClassIndex ();281 unsigned int allocPluginClassIndex ();
278 void freePluginClassIndex (unsigned int index);282 void freePluginClassIndex (unsigned int index);
@@ -418,6 +422,7 @@
418 virtual CompWindow * getTopServerWindow() const = 0;422 virtual CompWindow * getTopServerWindow() const = 0;
419 virtual CoreOptions& getCoreOptions() = 0;423 virtual CoreOptions& getCoreOptions() = 0;
420 virtual Colormap colormap() const = 0;424 virtual Colormap colormap() const = 0;
425 virtual const unsigned short * averageColor() const = 0;
421 virtual void setCurrentDesktop (unsigned int desktop) = 0;426 virtual void setCurrentDesktop (unsigned int desktop) = 0;
422 virtual Window activeWindow() const = 0;427 virtual Window activeWindow() const = 0;
423 virtual void updatePassiveButtonGrabs(Window serverFrame) = 0;428 virtual void updatePassiveButtonGrabs(Window serverFrame) = 0;
@@ -453,6 +458,7 @@
453 virtual void _matchPropertyChanged(CompWindow *) = 0;458 virtual void _matchPropertyChanged(CompWindow *) = 0;
454 virtual void _outputChangeNotify() = 0;459 virtual void _outputChangeNotify() = 0;
455 virtual void _cursorChangeNotify(const CompString&, int) = 0;460 virtual void _cursorChangeNotify(const CompString&, int) = 0;
461 virtual void _averageColorChangeNotify(const unsigned short*) = 0;
456};462};
457463
458#endif464#endif
459465
=== modified file 'include/core/string.h'
--- include/core/string.h 2011-10-31 13:51:00 +0000
+++ include/core/string.h 2017-11-16 22:42:49 +0000
@@ -28,12 +28,15 @@
2828
29#include <string>29#include <string>
30#include <list>30#include <list>
31#include <vector>
31#include <cstdarg>32#include <cstdarg>
3233
33typedef std::string CompString;34typedef std::string CompString;
34typedef std::list<CompString> CompStringList;35typedef std::list<CompString> CompStringList;
36typedef std::vector<CompString> CompStringVector;
3537
36CompString compPrintf (const char *format, ...);38CompString compPrintf (const char *format, ...);
37CompString compPrintf (const char *format, va_list ap);39CompString compPrintf (const char *format, va_list ap);
40CompStringVector compGetRegexMatches (const CompString& regexStr, const CompString& string);
3841
39#endif42#endif
4043
=== modified file 'plugins/grid/grid.xml.in'
--- plugins/grid/grid.xml.in 2015-10-26 17:15:43 +0000
+++ plugins/grid/grid.xml.in 2017-11-16 22:42:49 +0000
@@ -569,6 +569,11 @@
569 <default>350</default>569 <default>350</default>
570 <min>0</min>570 <min>0</min>
571 </option>571 </option>
572 <option name="use_desktop_average_color" type="bool">
573 <_short>Use Desktop average color</_short>
574 <_long>Try to use the desktop average color if defined by your DE.</_long>
575 <default>true</default>
576 </option>
572 <option name="outline_color" type="color">577 <option name="outline_color" type="color">
573 <_short>Preview Outline Color</_short>578 <_short>Preview Outline Color</_short>
574 <_long>Color and opacity of the resize indicator preview outline.</_long>579 <_long>Color and opacity of the resize indicator preview outline.</_long>
@@ -589,6 +594,11 @@
589 <alpha>0x4f4f</alpha>594 <alpha>0x4f4f</alpha>
590 </default>595 </default>
591 </option>596 </option>
597 <option name="disable_blend" type="bool">
598 <_short>Disable Transparency</_short>
599 <_long>Disable blending.</_long>
600 <default>false</default>
601 </option>
592 </group>602 </group>
593 </options>603 </options>
594 </plugin>604 </plugin>
595605
=== modified file 'plugins/grid/src/grid.cpp'
--- plugins/grid/src/grid.cpp 2015-04-06 13:14:51 +0000
+++ plugins/grid/src/grid.cpp 2017-11-16 22:42:49 +0000
@@ -488,8 +488,10 @@
488 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();488 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
489 GLfloat vertexData[12];489 GLfloat vertexData[12];
490 GLushort colorData[4];490 GLushort colorData[4];
491 GLushort *color;491 unsigned short *color, *fillColor, *outlineColor;
492 unsigned short averageFillColor[4], averageOutlineColor[4];
492 GLboolean isBlendingEnabled;493 GLboolean isBlendingEnabled;
494 bool blend = !optionGetDisableBlend ();
493495
494 const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();496 const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();
495497
@@ -500,16 +502,51 @@
500502
501 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);503 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
502504
503 glGetBooleanv (GL_BLEND, &isBlendingEnabled);505 if (blend)
504 glEnable (GL_BLEND);506 {
507 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
508 glEnable (GL_BLEND);
509 }
510
511 fillColor = optionGetFillColor ();
512 outlineColor = optionGetOutlineColor ();
513
514 if (optionGetUseDesktopAverageColor ())
515 {
516 const unsigned short *averageColor = screen->averageColor ();
517
518 if (averageColor)
519 {
520 memcpy (averageFillColor, averageColor, 4 * sizeof (unsigned short));
521 averageFillColor[3] = MaxUShortFloat * 0.6;
522 fillColor = averageFillColor;
523
524 // Generate a lighter color based on border to create more contrast
525 unsigned int averageColorLevel = (averageColor[0] + averageColor[1] + averageColor[2]) / 3;
526 unsigned short *oc = averageOutlineColor;
527
528 float colorMultiplier;
529 if (averageColorLevel > MaxUShortFloat * 0.3)
530 colorMultiplier = 0.7; // make it darker
531 else
532 colorMultiplier = 2.0; // make it lighter
533
534 oc[3] = averageColor[3];
535 oc[0] = MIN(MaxUShortFloat, ((float) averageColor[0]) * colorMultiplier) * oc[3] / MaxUShortFloat;
536 oc[1] = MIN(MaxUShortFloat, ((float) averageColor[1]) * colorMultiplier) * oc[3] / MaxUShortFloat;
537 oc[2] = MIN(MaxUShortFloat, ((float) averageColor[2]) * colorMultiplier) * oc[3] / MaxUShortFloat;
538
539 outlineColor = averageOutlineColor;
540 }
541 }
505542
506 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)543 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)
507 {544 {
508 Animation& anim = *iter;545 Animation& anim = *iter;
509546
510 float curve = powf (CURVE_ANIMATION, -anim.progress);547 float curve = powf (CURVE_ANIMATION, -anim.progress);
511 float alpha = (optionGetFillColorAlpha () / MaxUShortFloat) * anim.opacity;548 float alpha = blend ? (fillColor[3] / MaxUShortFloat) * anim.opacity : 0.85;
512 color = optionGetFillColor ();549 color = fillColor;
513550
514 colorData[0] = alpha * color[0];551 colorData[0] = alpha * color[0];
515 colorData[1] = alpha * color[1];552 colorData[1] = alpha * color[1];
@@ -546,8 +583,8 @@
546 anim.currentRect.height () - 2);583 anim.currentRect.height () - 2);
547584
548 /* draw outline */585 /* draw outline */
549 alpha = (optionGetOutlineColorAlpha () / MaxUShortFloat) * anim.opacity;586 alpha = blend ? (outlineColor[3] / MaxUShortFloat) * anim.opacity : 1;
550 color = optionGetOutlineColor ();587 color = outlineColor;
551588
552 colorData[0] = alpha * color[0];589 colorData[0] = alpha * color[0];
553 colorData[1] = alpha * color[1];590 colorData[1] = alpha * color[1];
@@ -579,8 +616,8 @@
579 if (!animating)616 if (!animating)
580 {617 {
581 /* draw filled rectangle */618 /* draw filled rectangle */
582 float alpha = optionGetFillColorAlpha () / MaxUShortFloat;619 float alpha = blend ? fillColor[3] / MaxUShortFloat : 0.85;
583 color = optionGetFillColor ();620 color = fillColor;
584621
585 colorData[0] = alpha * color[0];622 colorData[0] = alpha * color[0];
586 colorData[1] = alpha * color[1];623 colorData[1] = alpha * color[1];
@@ -614,8 +651,8 @@
614 rect.height () - 2);651 rect.height () - 2);
615652
616 /* draw outline */653 /* draw outline */
617 alpha = optionGetOutlineColorAlpha () / MaxUShortFloat;654 alpha = outlineColor[3] / MaxUShortFloat;
618 color = optionGetOutlineColor ();655 color = outlineColor;
619656
620 colorData[0] = alpha * color[0];657 colorData[0] = alpha * color[0];
621 colorData[1] = alpha * color[1];658 colorData[1] = alpha * color[1];
@@ -641,8 +678,11 @@
641 streamingBuffer->render (sTransform);678 streamingBuffer->render (sTransform);
642 }679 }
643680
644 if (!isBlendingEnabled)681 if (blend)
645 glDisable (GL_BLEND);682 {
683 if (!isBlendingEnabled)
684 glDisable (GL_BLEND);
685 }
646}686}
647687
648bool688bool
@@ -858,7 +898,7 @@
858 animations.at (current).fromRect = w->serverBorderRect ();898 animations.at (current).fromRect = w->serverBorderRect ();
859 animations.at (current).currentRect = w->serverBorderRect ();899 animations.at (current).currentRect = w->serverBorderRect ();
860 animations.at (current).duration = optionGetAnimationDuration ();900 animations.at (current).duration = optionGetAnimationDuration ();
861 animations.at (current).timer = animations.at (current).duration;901 animations.at (current).progress = 0.0f;
862 animations.at (current).targetRect = desiredSlot;902 animations.at (current).targetRect = desiredSlot;
863 animations.at (current).window = w->id();903 animations.at (current).window = w->id();
864904
@@ -1172,18 +1212,24 @@
1172 for (iter = animations.begin (); iter != animations.end (); ++iter)1212 for (iter = animations.begin (); iter != animations.end (); ++iter)
1173 {1213 {
1174 Animation& anim = *iter;1214 Animation& anim = *iter;
1175 anim.timer -= msSinceLastPaint;1215 GLfloat msSinceLastPaintFloat = static_cast<GLfloat>(msSinceLastPaint);
1216 GLfloat animDurationFloat = static_cast<GLfloat>(anim.duration);
1217 GLfloat progress_delta = 1.0f;
11761218
1177 if (anim.timer < 0)1219 if (animDurationFloat > 0.0f)
1178 anim.timer = 0;1220 progress_delta = msSinceLastPaintFloat / animDurationFloat;
11791221
1180 if (anim.fadingOut)1222 if (anim.fadingOut)
1181 anim.opacity -= msSinceLastPaint * 0.002;1223 {
1224 anim.opacity -= progress_delta;
1225 }
1182 else1226 else
1227 {
1183 if (anim.opacity < 1.0f)1228 if (anim.opacity < 1.0f)
1184 anim.opacity = anim.progress * anim.progress;1229 anim.opacity = anim.progress * anim.progress;
1185 else1230 else
1186 anim.opacity = 1.0f;1231 anim.opacity = 1.0f;
1232 }
11871233
1188 if (anim.opacity < 0)1234 if (anim.opacity < 0)
1189 {1235 {
@@ -1192,10 +1238,10 @@
1192 anim.complete = true;1238 anim.complete = true;
1193 }1239 }
11941240
1195 anim.progress = (anim.duration - anim.timer) / anim.duration;1241 anim.progress = std::min<GLfloat>(anim.progress + progress_delta, 1.0);
1196 }1242 }
11971243
1198 if (optionGetDrawStretchedWindow ())1244 if (optionGetDrawStretchedWindow () && !optionGetDisableBlend ())
1199 {1245 {
1200 CompWindow *cw = screen->findWindow (CompOption::getIntOptionNamed (o, "window"));1246 CompWindow *cw = screen->findWindow (CompOption::getIntOptionNamed (o, "window"));
12011247
@@ -1265,7 +1311,6 @@
1265 targetRect = CompRect (0, 0, 0, 0);1311 targetRect = CompRect (0, 0, 0, 0);
1266 currentRect = CompRect (0, 0, 0, 0);1312 currentRect = CompRect (0, 0, 0, 0);
1267 opacity = 0.0f;1313 opacity = 0.0f;
1268 timer = 0.0f;
1269 duration = 0;1314 duration = 0;
1270 complete = false;1315 complete = false;
1271 fadingOut = false;1316 fadingOut = false;
@@ -1373,7 +1418,7 @@
1373 {1418 {
1374 Animation& anim = *iter;1419 Animation& anim = *iter;
13751420
1376 if (anim.timer > 0.0f && anim.window == window->id())1421 if (anim.progress < 1.0f && anim.window == window->id())
1377 {1422 {
1378 GLWindowPaintAttrib wAttrib(attrib);1423 GLWindowPaintAttrib wAttrib(attrib);
1379 GLMatrix wTransform (matrix);1424 GLMatrix wTransform (matrix);
13801425
=== modified file 'plugins/grid/src/grid.h'
--- plugins/grid/src/grid.h 2013-04-30 00:18:41 +0000
+++ plugins/grid/src/grid.h 2017-11-16 22:42:49 +0000
@@ -96,7 +96,6 @@
96 CompRect targetRect;96 CompRect targetRect;
97 CompRect currentRect;97 CompRect currentRect;
98 GLfloat opacity;98 GLfloat opacity;
99 GLfloat timer;
100 Window window;99 Window window;
101 int duration;100 int duration;
102 bool complete;101 bool complete;
103102
=== modified file 'plugins/move/move.xml.in'
--- plugins/move/move.xml.in 2013-04-14 11:46:28 +0000
+++ plugins/move/move.xml.in 2017-11-16 22:42:49 +0000
@@ -70,6 +70,64 @@
70 <_long>Do not update the server-side position of windows until finished moving.</_long>70 <_long>Do not update the server-side position of windows until finished moving.</_long>
71 <default>false</default>71 <default>false</default>
72 </option>72 </option>
73
74 <group>
75 <_short>Appearance</_short>
76 <option name="mode" type="int">
77 <_short>Default Moving Window Mode</_short>
78 <_long>Default mode used for window moving.</_long>
79 <default>0</default>
80 <min>0</min>
81 <max>2</max>
82 <desc>
83 <value>0</value>
84 <_name>Normal</_name>
85 </desc>
86 <desc>
87 <value>1</value>
88 <_name>Outline</_name>
89 </desc>
90 <desc>
91 <value>2</value>
92 <_name>Rectangle</_name>
93 </desc>
94 </option>
95 <option name="increase_border_contrast" type="bool">
96 <_short>Use a double-border in 'Rectangle' and 'Outline' modes</_short>
97 <_long>Increase the contrast of the border using a lighter color.</_long>
98 <default>true</default>
99 </option>
100 <option name="use_desktop_average_color" type="bool">
101 <_short>Use Desktop average colors</_short>
102 <_long>Try to use the desktop average color if defined by your DE (overrides custom colors).</_long>
103 <default>true</default>
104 </option>
105 <option name="border_color" type="color">
106 <_short>Border Color</_short>
107 <_long>Border color used for outline and rectangle moving modes</_long>
108 <default>
109 <red>0xfbfb</red>
110 <green>0x8b8b</green>
111 <blue>0x0</blue>
112 <alpha>0x9f9f</alpha>
113 </default>
114 </option>
115 <option name="fill_color" type="color">
116 <_short>Fill Color</_short>
117 <_long>Fill color used for rectangle moving mode</_long>
118 <default>
119 <red>0xfbfb</red>
120 <green>0x8b8b</green>
121 <blue>0x0</blue>
122 <alpha>0x1919</alpha>
123 </default>
124 </option>
125 <option name="blend" type="bool">
126 <_short>Enable Transparency</_short>
127 <_long>Enable or disable blending.</_long>
128 <default>true</default>
129 </option>
130 </group>
73 </options>131 </options>
74 </plugin>132 </plugin>
75</compiz>133</compiz>
76134
=== modified file 'plugins/move/src/move.cpp'
--- plugins/move/src/move.cpp 2015-10-20 15:11:54 +0000
+++ plugins/move/src/move.cpp 2017-11-16 22:42:49 +0000
@@ -34,6 +34,9 @@
3434
35COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)35COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)
3636
37static const int defaultBorderWidth = 2;
38static const int biggerBorderWidthMultiplier = 2;
39
37static bool40static bool
38moveInitiate (CompAction *action,41moveInitiate (CompAction *action,
39 CompAction::State state,42 CompAction::State state,
@@ -142,6 +145,19 @@
142 s->warpPointer (xRoot - pointerX, yRoot - pointerY);145 s->warpPointer (xRoot - pointerX, yRoot - pointerY);
143 }146 }
144147
148 if (ms->optionGetMode () != MoveOptions::ModeNormal)
149 {
150 Box box;
151
152 ms->gScreen->glPaintOutputSetEnabled (ms, true);
153 ms->paintRect = true;
154 ms->rectX = 0;
155 ms->rectY = 0;
156
157 if (ms->getMovingRectangle (&box))
158 ms->damageMovingRectangle (&box);
159 }
160
145 if (ms->moveOpacity != OPAQUE)161 if (ms->moveOpacity != OPAQUE)
146 {162 {
147 MOVE_WINDOW (w);163 MOVE_WINDOW (w);
@@ -177,9 +193,18 @@
177 {193 {
178 MOVE_WINDOW (ms->w);194 MOVE_WINDOW (ms->w);
179195
196 if (ms->paintRect)
197 {
198 ms->paintRect = false;
199 ms->gScreen->glPaintOutputSetEnabled (ms, false);
200 mw->window->move (ms->rectX, ms->rectY, true);
201 }
202
180 if (state & CompAction::StateCancel)203 if (state & CompAction::StateCancel)
204 {
181 ms->w->move (ms->savedX - ms->w->geometry ().x (),205 ms->w->move (ms->savedX - ms->w->geometry ().x (),
182 ms->savedY - ms->w->geometry ().y (), false);206 ms->savedY - ms->w->geometry ().y (), false);
207 }
183208
184 /* update window attributes as window constraints may have209 /* update window attributes as window constraints may have
185 changed - needed e.g. if a maximized window was moved210 changed - needed e.g. if a maximized window was moved
@@ -318,6 +343,7 @@
318343
319 int wX = w->geometry ().x ();344 int wX = w->geometry ().x ();
320 int wY = w->geometry ().y ();345 int wY = w->geometry ().y ();
346
321 int wWidth = w->geometry ().widthIncBorders ();347 int wWidth = w->geometry ().widthIncBorders ();
322 int wHeight = w->geometry ().heightIncBorders ();348 int wHeight = w->geometry ().heightIncBorders ();
323349
@@ -522,8 +548,15 @@
522548
523 if (dx || dy)549 if (dx || dy)
524 {550 {
525 w->move (wX + dx - w->geometry ().x (),551 if (ms->optionGetMode () == MoveOptions::ModeNormal)
526 wY + dy - w->geometry ().y (), false);552 {
553 w->move (wX + dx - w->geometry ().x (), wY + dy - w->geometry ().y (), false);
554 }
555 else
556 {
557 ms->rectX += wX + dx - w->geometry ().x ();
558 ms->rectY += wY + dy - w->geometry ().y ();
559 }
527560
528 ms->x -= dx;561 ms->x -= dx;
529 ms->y -= dy;562 ms->y -= dy;
@@ -704,11 +737,15 @@
704MoveScreen::MoveScreen (CompScreen *screen) :737MoveScreen::MoveScreen (CompScreen *screen) :
705 PluginClassHandler<MoveScreen,CompScreen> (screen),738 PluginClassHandler<MoveScreen,CompScreen> (screen),
706 cScreen (CompositeScreen::get (screen)),739 cScreen (CompositeScreen::get (screen)),
740 gScreen (GLScreen::get (screen)),
707 w (0),741 w (0),
708 region (NULL),742 region (NULL),
709 status (RectangleOut),743 status (RectangleOut),
710 releaseButton (0),744 releaseButton (0),
711 grab (NULL),745 grab (NULL),
746 paintRect(false),
747 rectX(0),
748 rectY(0),
712 hasCompositing (false),749 hasCompositing (false),
713 yConstrained (false)750 yConstrained (false)
714{751{
@@ -734,6 +771,9 @@
734 optionSetInitiateKeyTerminate (moveTerminate);771 optionSetInitiateKeyTerminate (moveTerminate);
735772
736 ScreenInterface::setHandler (screen);773 ScreenInterface::setHandler (screen);
774 GLScreenInterface::setHandler (gScreen);
775
776 gScreen->glPaintOutputSetEnabled (this, false);
737}777}
738778
739MoveScreen::~MoveScreen ()779MoveScreen::~MoveScreen ()
@@ -743,6 +783,290 @@
743}783}
744784
745bool785bool
786MoveScreen::getMovingRectangle (BoxPtr pBox)
787{
788 MOVE_SCREEN (screen);
789
790 CompWindow *w = ms->w;
791 if (!w)
792 return false;
793
794 int wX = w->geometry ().x () - w->border ().left;
795 int wY = w->geometry ().y () - w->border ().top;
796 int wWidth = w->geometry ().widthIncBorders () + w->border ().left + w->border ().right;
797 int wHeight = w->geometry ().heightIncBorders () + w->border ().top + w->border ().bottom;
798
799 pBox->x1 = wX + ms->rectX;
800 pBox->y1 = wY + ms->rectY;
801
802 pBox->x2 = pBox->x1 + wWidth;
803 pBox->y2 = pBox->y1 + wHeight;
804
805 return true;
806}
807
808bool
809MoveScreen::damageMovingRectangle (BoxPtr pBox)
810{
811 CompRegion damageRegion;
812 int borderWidth;
813
814 if (!cScreen || !pBox)
815 return false;
816
817 borderWidth = defaultBorderWidth;
818
819 if (optionGetIncreaseBorderContrast ())
820 borderWidth *= biggerBorderWidthMultiplier;
821
822 if (optionGetMode () == MoveOptions::ModeRectangle)
823 {
824 CompRect damage (pBox->x1 - borderWidth,
825 pBox->y1 - borderWidth,
826 pBox->x2 - pBox->x1 + borderWidth * 2,
827 pBox->y2 - pBox->y1 + borderWidth * 2);
828 damageRegion += damage;
829 }
830 else if (optionGetMode () == MoveOptions::ModeOutline)
831 {
832 // Top
833 damageRegion += CompRect (pBox->x1 - borderWidth,
834 pBox->y1 - borderWidth,
835 pBox->x2 - pBox->x1 + borderWidth * 2,
836 borderWidth * 2);
837 // Right
838 damageRegion += CompRect (pBox->x2 - borderWidth,
839 pBox->y1 - borderWidth,
840 borderWidth + borderWidth / 2,
841 pBox->y2 - pBox->y1 + borderWidth * 2);
842 // Bottom
843 damageRegion += CompRect (pBox->x1 - borderWidth,
844 pBox->y2 - borderWidth,
845 pBox->x2 - pBox->x1 + borderWidth * 2,
846 borderWidth * 2);
847 // Left
848 damageRegion += CompRect (pBox->x1 - borderWidth,
849 pBox->y1 - borderWidth,
850 borderWidth + borderWidth / 2,
851 pBox->y2 - pBox->y1 + borderWidth * 2);
852 }
853
854 if (!damageRegion.isEmpty ())
855 {
856 cScreen->damageRegion (damageRegion);
857 return true;
858 }
859
860 return false;
861}
862
863bool MoveScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
864 const GLMatrix &transform,
865 const CompRegion &region,
866 CompOutput *output,
867 unsigned int mask)
868{
869 bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
870
871 if (status && paintRect)
872 {
873 unsigned short *borderColor = optionGetBorderColor ();
874 unsigned short *fillColor = NULL;
875
876 if (optionGetMode() == MoveOptions::ModeRectangle)
877 fillColor = optionGetFillColor ();
878
879 return glPaintMovingRectangle (transform, output, borderColor, fillColor);
880 }
881
882 return status;
883}
884
885bool
886MoveScreen::glPaintMovingRectangle (const GLMatrix &transform,
887 CompOutput *output,
888 unsigned short *borderColor,
889 unsigned short *fillColor)
890{
891 BoxRec box;
892 if (!getMovingRectangle(&box))
893 return false;
894
895 const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
896 const float MaxUShortFloat = MaxUShort;
897 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
898 GLMatrix sTransform (transform);
899 bool usingAverageColors = false;
900
901 GLfloat vertexData[12];
902 GLfloat vertexData2[24];
903 GLushort fc[4], bc[4], averageFillColor[4];
904 GLint origSrc, origDst;
905#ifdef USE_GLES
906 GLint origSrcAlpha, origDstAlpha;
907#endif
908
909 if (optionGetUseDesktopAverageColor ())
910 {
911 const unsigned short *averageColor = screen->averageColor ();
912
913 if (averageColor)
914 {
915 usingAverageColors = true;
916 borderColor = const_cast<unsigned short *>(averageColor);
917 memcpy (averageFillColor, averageColor, 4 * sizeof (unsigned short));
918 averageFillColor[3] = MaxUShort * 0.6;
919
920 if (fillColor)
921 fillColor = averageFillColor;
922 }
923 }
924
925 bool blend = optionGetBlend ();
926
927 if (blend && borderColor[3] == MaxUShort)
928 {
929 if (optionGetMode () == MoveOptions::ModeOutline || fillColor[3] == MaxUShort)
930 blend = false;
931 }
932
933 if (blend)
934 {
935#ifdef USE_GLES
936 glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
937 glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
938 glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
939 glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
940#else
941 glGetIntegerv (GL_BLEND_SRC, &origSrc);
942 glGetIntegerv (GL_BLEND_DST, &origDst);
943#endif
944 }
945
946 vertexData[0] = box.x1;
947 vertexData[1] = box.y1;
948 vertexData[2] = 0.0f;
949 vertexData[3] = box.x1;
950 vertexData[4] = box.y2;
951 vertexData[5] = 0.0f;
952 vertexData[6] = box.x2;
953 vertexData[7] = box.y1;
954 vertexData[8] = 0.0f;
955 vertexData[9] = box.x2;
956 vertexData[10] = box.y2;
957 vertexData[11] = 0.0f;
958
959 vertexData2[0] = box.x1;
960 vertexData2[1] = box.y1;
961 vertexData2[2] = 0.0f;
962 vertexData2[3] = box.x1;
963 vertexData2[4] = box.y2;
964 vertexData2[5] = 0.0f;
965 vertexData2[6] = box.x1;
966 vertexData2[7] = box.y2;
967 vertexData2[8] = 0.0f;
968 vertexData2[9] = box.x2;
969 vertexData2[10] = box.y2;
970 vertexData2[11] = 0.0f;
971 vertexData2[12] = box.x2;
972 vertexData2[13] = box.y2;
973 vertexData2[14] = 0.0f;
974 vertexData2[15] = box.x2;
975 vertexData2[16] = box.y1;
976 vertexData2[17] = 0.0f;
977 vertexData2[18] = box.x2;
978 vertexData2[19] = box.y1;
979 vertexData2[20] = 0.0f;
980 vertexData2[21] = box.x1;
981 vertexData2[22] = box.y1;
982 vertexData2[23] = 0.0f;
983
984 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
985
986 if (blend)
987 {
988 glEnable (GL_BLEND);
989 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
990 }
991
992 /* fill rectangle */
993 if (fillColor)
994 {
995 fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
996 fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
997 fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
998 fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
999
1000 streamingBuffer->begin (GL_TRIANGLE_STRIP);
1001 streamingBuffer->addColors (1, fc);
1002 streamingBuffer->addVertices (4, &vertexData[0]);
1003 streamingBuffer->end ();
1004 streamingBuffer->render (sTransform);
1005 }
1006
1007 /* draw outline */
1008 int borderWidth = defaultBorderWidth;
1009
1010 if (optionGetIncreaseBorderContrast() || usingAverageColors)
1011 {
1012 // Generate a lighter color based on border to create more contrast
1013 unsigned int averageColorLevel = (borderColor[0] + borderColor[1] + borderColor[2]) / 3;
1014
1015 float colorMultiplier;
1016 if (averageColorLevel > MaxUShort * 0.3)
1017 colorMultiplier = 0.7; // make it darker
1018 else
1019 colorMultiplier = 2.0; // make it lighter
1020
1021 bc[3] = borderColor[3];
1022 bc[0] = MIN(MaxUShortFloat, ((float) borderColor[0]) * colorMultiplier) * bc[3] / MaxUShortFloat;
1023 bc[1] = MIN(MaxUShortFloat, ((float) borderColor[1]) * colorMultiplier) * bc[3] / MaxUShortFloat;
1024 bc[2] = MIN(MaxUShortFloat, ((float) borderColor[2]) * colorMultiplier) * bc[3] / MaxUShortFloat;
1025
1026 if (optionGetIncreaseBorderContrast ())
1027 {
1028 borderWidth *= biggerBorderWidthMultiplier;
1029
1030 glLineWidth (borderWidth);
1031 streamingBuffer->begin (GL_LINES);
1032 streamingBuffer->addVertices (8, &vertexData2[0]);
1033 streamingBuffer->addColors (1, bc);
1034 streamingBuffer->end ();
1035 streamingBuffer->render (sTransform);
1036 } else if (usingAverageColors) {
1037 borderColor = bc;
1038 }
1039 }
1040
1041 bc[3] = blend ? borderColor[3] : MaxUShortFloat;
1042 bc[0] = borderColor[0] * bc[3] / MaxUShortFloat;
1043 bc[1] = borderColor[1] * bc[3] / MaxUShortFloat;
1044 bc[2] = borderColor[2] * bc[3] / MaxUShortFloat;
1045
1046 glLineWidth (defaultBorderWidth);
1047 streamingBuffer->begin (GL_LINES);
1048 streamingBuffer->addColors (1, bc);
1049 streamingBuffer->addVertices (8, &vertexData2[0]);
1050 streamingBuffer->end ();
1051 streamingBuffer->render (sTransform);
1052
1053 if (blend)
1054 {
1055 glDisable (GL_BLEND);
1056#ifdef USE_GLES
1057 glBlendFuncSeparate (origSrc, origDst,
1058 origSrcAlpha, origDstAlpha);
1059#else
1060 glBlendFunc (origSrc, origDst);
1061#endif
1062 }
1063
1064 damageMovingRectangle (&box);
1065
1066 return true;
1067}
1068
1069bool
746MovePluginVTable::init ()1070MovePluginVTable::init ()
747{1071{
748 if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))1072 if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
7491073
=== modified file 'plugins/move/src/move.h'
--- plugins/move/src/move.h 2015-10-20 15:11:54 +0000
+++ plugins/move/src/move.h 2017-11-16 22:42:49 +0000
@@ -32,7 +32,6 @@
32#include <composite/composite.h>32#include <composite/composite.h>
33#include <opengl/opengl.h>33#include <opengl/opengl.h>
3434
35
36#define NUM_KEYS (sizeof (mKeys) / sizeof (mKeys[0]))35#define NUM_KEYS (sizeof (mKeys) / sizeof (mKeys[0]))
3736
38struct _MoveKeys37struct _MoveKeys
@@ -49,6 +48,7 @@
49};48};
5049
51class MoveScreen :50class MoveScreen :
51 public GLScreenInterface,
52 public ScreenInterface,52 public ScreenInterface,
53 public CompositeScreenInterface,53 public CompositeScreenInterface,
54 public PluginClassHandler<MoveScreen,CompScreen>,54 public PluginClassHandler<MoveScreen,CompScreen>,
@@ -59,6 +59,7 @@
59 ~MoveScreen ();59 ~MoveScreen ();
6060
61 CompositeScreen *cScreen;61 CompositeScreen *cScreen;
62 GLScreen *gScreen;
6263
63 void updateOpacity ();64 void updateOpacity ();
6465
@@ -67,6 +68,16 @@
67 bool registerPaintHandler (compiz::composite::PaintHandler *pHnd);68 bool registerPaintHandler (compiz::composite::PaintHandler *pHnd);
68 void unregisterPaintHandler ();69 void unregisterPaintHandler ();
6970
71 bool glPaintOutput (const GLScreenPaintAttrib &,
72 const GLMatrix &,
73 const CompRegion &,
74 CompOutput *,
75 unsigned int);
76
77 bool getMovingRectangle (BoxPtr pbox);
78 bool damageMovingRectangle (BoxPtr pbox);
79 bool glPaintMovingRectangle (const GLMatrix &transform, CompOutput *output, unsigned short *borderColor, unsigned short *fillColor);
80
70 CompWindow *w;81 CompWindow *w;
71 int savedX;82 int savedX;
72 int savedY;83 int savedY;
@@ -84,6 +95,10 @@
8495
85 unsigned int origState;96 unsigned int origState;
8697
98 bool paintRect;
99 int rectX;
100 int rectY;
101
87 int snapOffX;102 int snapOffX;
88 int snapBackX;103 int snapBackX;
89104
90105
=== modified file 'plugins/neg/neg.xml.in'
--- plugins/neg/neg.xml.in 2012-10-15 10:31:51 +0000
+++ plugins/neg/neg.xml.in 2017-11-16 22:42:49 +0000
@@ -21,6 +21,11 @@
21 <_long>Toggle active window negative</_long>21 <_long>Toggle active window negative</_long>
22 <default>&lt;Super&gt;n</default>22 <default>&lt;Super&gt;n</default>
23 </option>23 </option>
24 <option name="activate_at_startup" type="bool">
25 <_short>plugin should be active at startup</_short>
26 <_long>if active, the plugin will start active, with windows inverted</_long>
27 <default>false</default>
28 </option>
24 <option name="screen_toggle_key" type="key">29 <option name="screen_toggle_key" type="key">
25 <_short>Toggle Screen Negative</_short>30 <_short>Toggle Screen Negative</_short>
26 <_long>Toggle screen negative</_long>31 <_long>Toggle screen negative</_long>
2732
=== modified file 'plugins/neg/src/neg.cpp'
--- plugins/neg/src/neg.cpp 2013-05-09 13:43:07 +0000
+++ plugins/neg/src/neg.cpp 2017-11-16 22:42:49 +0000
@@ -437,7 +437,7 @@
437 NegOptions (),437 NegOptions (),
438 negFunction (0),438 negFunction (0),
439 negAlphaFunction (0),439 negAlphaFunction (0),
440 isNeg (false),440 isNeg (optionGetActivateAtStartup()),
441 gScreen (GLScreen::get (screen))441 gScreen (GLScreen::get (screen))
442{442{
443 optionSetWindowToggleKeyInitiate (boost::bind (&NegScreen::toggle, this,443 optionSetWindowToggleKeyInitiate (boost::bind (&NegScreen::toggle, this,
444444
=== modified file 'plugins/resize/resize.xml.in'
--- plugins/resize/resize.xml.in 2015-10-26 17:15:43 +0000
+++ plugins/resize/resize.xml.in 2017-11-16 22:42:49 +0000
@@ -58,6 +58,16 @@
58 <long>Maximizes the window vertically if the top or bottom screen edge is hit while resizing</long>58 <long>Maximizes the window vertically if the top or bottom screen edge is hit while resizing</long>
59 <default>true</default>59 <default>true</default>
60 </option>60 </option>
61 <option name="increase_border_contrast" type="bool">
62 <_short>Use a double-border in 'Rectangle' and 'Outline' modes</_short>
63 <_long>Increase the contrast of the border using a lighter color.</_long>
64 <default>true</default>
65 </option>
66 <option name="use_desktop_average_color" type="bool">
67 <_short>Use Desktop average colors</_short>
68 <_long>Try to use the desktop average color if defined by your DE (overrides custom colors).</_long>
69 <default>true</default>
70 </option>
61 <option name="border_color" type="color">71 <option name="border_color" type="color">
62 <_short>Border Color</_short>72 <_short>Border Color</_short>
63 <_long>Border color used for outline and rectangle resize modes</_long>73 <_long>Border color used for outline and rectangle resize modes</_long>
@@ -78,6 +88,11 @@
78 <alpha>0x1919</alpha>88 <alpha>0x1919</alpha>
79 </default>89 </default>
80 </option>90 </option>
91 <option name="disable_blend" type="bool">
92 <_short>Disable Transparency</_short>
93 <_long>Disable blending.</_long>
94 <default>false</default>
95 </option>
81 <subgroup>96 <subgroup>
82 <_short>Specific Window Matches</_short>97 <_short>Specific Window Matches</_short>
83 <option name="normal_match" type="match">98 <option name="normal_match" type="match">
8499
=== modified file 'plugins/resize/src/logic/src/resize-logic.cpp'
--- plugins/resize/src/logic/src/resize-logic.cpp 2016-03-03 14:22:25 +0000
+++ plugins/resize/src/logic/src/resize-logic.cpp 2017-11-16 22:42:49 +0000
@@ -487,13 +487,13 @@
487 che = he;487 che = he;
488488
489 if (w->constrainNewWindowSize (wi, he, &cwi, &che) &&489 if (w->constrainNewWindowSize (wi, he, &cwi, &che) &&
490 mode != ResizeOptions::ModeNormal)490 mode != ResizeOptions::ModeNormal &&
491 mode != ResizeOptions::ModeOutline)
491 {492 {
492 Box box;493 Box box;
493494
494 /* Also, damage relevant paint rectangles */495 /* Also, damage relevant paint rectangles */
495 if (mode == ResizeOptions::ModeRectangle ||496 if (mode == ResizeOptions::ModeRectangle)
496 mode == ResizeOptions::ModeOutline)
497 getPaintRectangle (&box);497 getPaintRectangle (&box);
498 else if (mode == ResizeOptions::ModeStretch)498 else if (mode == ResizeOptions::ModeStretch)
499 getStretchRectangle (&box);499 getStretchRectangle (&box);
@@ -518,7 +518,8 @@
518 xRoot, yRoot,518 xRoot, yRoot,
519 wX, wY, wWidth, wHeight); /*in*/519 wX, wY, wWidth, wHeight); /*in*/
520520
521 if (mode != ResizeOptions::ModeNormal)521 if (mode != ResizeOptions::ModeNormal &&
522 mode != ResizeOptions::ModeOutline)
522 {523 {
523 if (mode == ResizeOptions::ModeStretch)524 if (mode == ResizeOptions::ModeStretch)
524 getStretchRectangle (&box);525 getStretchRectangle (&box);
@@ -532,7 +533,8 @@
532533
533 computeGeometry (wi, he);534 computeGeometry (wi, he);
534535
535 if (mode != ResizeOptions::ModeNormal)536 if (mode != ResizeOptions::ModeNormal &&
537 mode != ResizeOptions::ModeOutline)
536 {538 {
537 if (mode == ResizeOptions::ModeStretch)539 if (mode == ResizeOptions::ModeStretch)
538 getStretchRectangle (&box);540 getStretchRectangle (&box);
@@ -541,7 +543,7 @@
541543
542 damageRectangle (&box);544 damageRectangle (&box);
543 }545 }
544 else546 else if (mode == ResizeOptions::ModeNormal)
545 {547 {
546 updateWindowSize ();548 updateWindowSize ();
547 }549 }
548550
=== modified file 'plugins/resize/src/resize.cpp'
--- plugins/resize/src/resize.cpp 2015-10-20 15:01:58 +0000
+++ plugins/resize/src/resize.cpp 2017-11-16 22:42:49 +0000
@@ -70,8 +70,8 @@
7070
71static bool71static bool
72resizeTerminate (CompAction *action,72resizeTerminate (CompAction *action,
73 CompAction::State state,73 CompAction::State state,
74 CompOption::Vector &options)74 CompOption::Vector &options)
75{75{
76 RESIZE_SCREEN (screen);76 RESIZE_SCREEN (screen);
77 return rs->logic.terminateResize(action, state, options);77 return rs->logic.terminateResize(action, state, options);
@@ -85,30 +85,57 @@
85 unsigned short *fillColor)85 unsigned short *fillColor)
86{86{
87 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();87 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
88 const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
89 const float MaxUShortFloat = MaxUShort;
90 bool usingAverageColors = false;
8891
89 BoxRec box;92 BoxRec box;
93 CompRegion damageRegion;
90 GLMatrix sTransform (transform);94 GLMatrix sTransform (transform);
91 GLfloat vertexData [12];95 GLfloat vertexData [12];
92 GLfloat vertexData2[24];96 GLfloat vertexData2[24];
93 GLint origSrc, origDst;97 GLint origSrc, origDst;
94 GLushort fc[4], bc[4];98#ifdef USE_GLES
9599 GLint origSrcAlpha, origDstAlpha;
96#ifdef USE_GLES100#endif
97 GLint origSrcAlpha, origDstAlpha;101 GLushort fc[4], bc[4], averageFillColor[4];
98 glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);102
99 glGetIntegerv (GL_BLEND_DST_RGB, &origDst);103 if (optionGetUseDesktopAverageColor ())
100 glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);104 {
101 glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);105 const unsigned short *averageColor = screen->averageColor ();
106
107 if (averageColor)
108 {
109 usingAverageColors = true;
110 borderColor = const_cast<unsigned short *>(averageColor);
111 memcpy (averageFillColor, averageColor, 4 * sizeof (unsigned short));
112 averageFillColor[3] = MaxUShort * 0.6;
113
114 if (fillColor)
115 fillColor = averageFillColor;
116 }
117 }
118
119 bool blend = !optionGetDisableBlend ();
120
121 if (blend && borderColor[3] == MaxUShort)
122 {
123 if (optionGetMode () == ResizeOptions::ModeOutline || fillColor[3] == MaxUShort)
124 blend = false;
125 }
126
127 if (blend)
128 {
129#ifdef USE_GLES
130 glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
131 glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
132 glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
133 glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
102#else134#else
103 glGetIntegerv (GL_BLEND_SRC, &origSrc);135 glGetIntegerv (GL_BLEND_SRC, &origSrc);
104 glGetIntegerv (GL_BLEND_DST, &origDst);136 glGetIntegerv (GL_BLEND_DST, &origDst);
105#endif137#endif
106138 }
107 /* Premultiply the alpha values */
108 bc[3] = (float) borderColor[3] / (float) 65535.0f;
109 bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
110 bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
111 bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
112139
113 logic.getPaintRectangle (&box);140 logic.getPaintRectangle (&box);
114141
@@ -159,16 +186,19 @@
159186
160 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);187 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
161188
162 glEnable (GL_BLEND);189 if (blend)
163 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);190 {
191 glEnable (GL_BLEND);
192 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
193 }
164194
165 /* fill rectangle */195 /* fill rectangle */
166 if (fillColor)196 if (fillColor)
167 {197 {
168 fc[3] = fillColor[3];198 fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
169 fc[0] = fillColor[0] * (unsigned long)fc[3] / 65535;199 fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
170 fc[1] = fillColor[1] * (unsigned long)fc[3] / 65535;200 fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
171 fc[2] = fillColor[2] * (unsigned long)fc[3] / 65535;201 fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
172202
173 streamingBuffer->begin (GL_TRIANGLE_STRIP);203 streamingBuffer->begin (GL_TRIANGLE_STRIP);
174 streamingBuffer->addColors (1, fc);204 streamingBuffer->addColors (1, fc);
@@ -178,28 +208,98 @@
178 }208 }
179209
180 /* draw outline */210 /* draw outline */
181 static const int borderWidth = 2;211 static const int defaultBorderWidth = 2;
182 glLineWidth (borderWidth);212 int borderWidth = defaultBorderWidth;
213
214 if (optionGetIncreaseBorderContrast() || usingAverageColors)
215 {
216 // Generate a lighter color based on border to create more contrast
217 unsigned int averageColorLevel = (borderColor[0] + borderColor[1] + borderColor[2]) / 3;
218
219 float colorMultiplier;
220 if (averageColorLevel > MaxUShort * 0.3)
221 colorMultiplier = 0.7; // make it darker
222 else
223 colorMultiplier = 2.0; // make it lighter
224
225 bc[3] = borderColor[3];
226 bc[0] = MIN(MaxUShortFloat, ((float) borderColor[0]) * colorMultiplier) * bc[3] / MaxUShortFloat;
227 bc[1] = MIN(MaxUShortFloat, ((float) borderColor[1]) * colorMultiplier) * bc[3] / MaxUShortFloat;
228 bc[2] = MIN(MaxUShortFloat, ((float) borderColor[2]) * colorMultiplier) * bc[3] / MaxUShortFloat;
229
230 if (optionGetIncreaseBorderContrast ())
231 {
232 borderWidth *= 2;
233
234 glLineWidth (borderWidth);
235 streamingBuffer->begin (GL_LINES);
236 streamingBuffer->addVertices (8, &vertexData2[0]);
237 streamingBuffer->addColors (1, bc);
238 streamingBuffer->end ();
239 streamingBuffer->render (sTransform);
240 } else if (usingAverageColors) {
241 borderColor = bc;
242 }
243 }
244
245 bc[3] = blend ? borderColor[3] : MaxUShortFloat;
246 bc[0] = borderColor[0] * bc[3] / MaxUShortFloat;
247 bc[1] = borderColor[1] * bc[3] / MaxUShortFloat;
248 bc[2] = borderColor[2] * bc[3] / MaxUShortFloat;
249
250 glLineWidth (defaultBorderWidth);
183 streamingBuffer->begin (GL_LINES);251 streamingBuffer->begin (GL_LINES);
184 streamingBuffer->addColors (1, borderColor);252 streamingBuffer->addColors (1, bc);
185 streamingBuffer->addVertices (8, &vertexData2[0]);253 streamingBuffer->addVertices (8, &vertexData2[0]);
186 streamingBuffer->end ();254 streamingBuffer->end ();
187 streamingBuffer->render (sTransform);255 streamingBuffer->render (sTransform);
188256
189 glDisable (GL_BLEND);257 if (blend)
258 {
259 glDisable (GL_BLEND);
190#ifdef USE_GLES260#ifdef USE_GLES
191 glBlendFuncSeparate (origSrc, origDst,261 glBlendFuncSeparate (origSrc, origDst,
192 origSrcAlpha, origDstAlpha);262 origSrcAlpha, origDstAlpha);
193#else263#else
194 glBlendFunc (origSrc, origDst);264 glBlendFunc (origSrc, origDst);
195#endif265#endif
266 }
196267
197 CompositeScreen *cScreen = CompositeScreen::get (screen);268 CompositeScreen *cScreen = CompositeScreen::get (screen);
198 CompRect damage (box.x1 - borderWidth,269
199 box.y1 - borderWidth,270 if (optionGetMode () == ResizeOptions::ModeOutline)
200 box.x2 - box.x1 + 2 * borderWidth,271 {
201 box.y2 - box.y1 + 2 * borderWidth);272 // Top
202 cScreen->damageRegion (damage);273 damageRegion += CompRect (box.x1 - borderWidth,
274 box.y1 - borderWidth,
275 box.x2 - box.x1 + borderWidth * 2,
276 borderWidth * 2);
277 // Right
278 damageRegion += CompRect (box.x2 - borderWidth,
279 box.y1 - borderWidth,
280 borderWidth + borderWidth / 2,
281 box.y2 - box.y1 + borderWidth * 2);
282 // Bottom
283 damageRegion += CompRect (box.x1 - borderWidth,
284 box.y2 - borderWidth,
285 box.x2 - box.x1 + borderWidth * 2,
286 borderWidth * 2);
287 // Left
288 damageRegion += CompRect (box.x1 - borderWidth,
289 box.y1 - borderWidth,
290 borderWidth + borderWidth / 2,
291 box.y2 - box.y1 + borderWidth * 2);
292 }
293 else
294 {
295 CompRect damage (box.x1 - borderWidth,
296 box.y1 - borderWidth,
297 box.x2 - box.x1 + borderWidth * 2,
298 box.y2 - box.y1 + borderWidth * 2);
299 damageRegion += damage;
300 }
301
302 cScreen->damageRegion (damageRegion);
203}303}
204304
205bool305bool
206306
=== modified file 'src/atoms.cpp'
--- src/atoms.cpp 2015-02-17 14:54:10 +0000
+++ src/atoms.cpp 2017-11-16 22:42:49 +0000
@@ -155,6 +155,8 @@
155155
156 Atom startupId;156 Atom startupId;
157157
158 Atom gnomeRepresentativeColors;
159
158 void init (Display *dpy)160 void init (Display *dpy)
159 {161 {
160 supported = XInternAtom (dpy, "_NET_SUPPORTED", 0);162 supported = XInternAtom (dpy, "_NET_SUPPORTED", 0);
@@ -325,5 +327,7 @@
325 atomPair = XInternAtom (dpy, "ATOM_PAIR", 0);327 atomPair = XInternAtom (dpy, "ATOM_PAIR", 0);
326328
327 startupId = XInternAtom (dpy, "_NET_STARTUP_ID", 0);329 startupId = XInternAtom (dpy, "_NET_STARTUP_ID", 0);
330
331 gnomeRepresentativeColors = XInternAtom (dpy, "_GNOME_BACKGROUND_REPRESENTATIVE_COLORS", 0);
328 }332 }
329};333};
330334
=== modified file 'src/event.cpp'
--- src/event.cpp 2016-05-17 02:52:07 +0000
+++ src/event.cpp 2017-11-16 22:42:49 +0000
@@ -1821,6 +1821,11 @@
1821 if (w)1821 if (w)
1822 w->priv->updateStartupId ();1822 w->priv->updateStartupId ();
1823 }1823 }
1824 else if (event->xproperty.atom == Atoms::gnomeRepresentativeColors)
1825 {
1826 if (event->xproperty.window == privateScreen.rootWindow())
1827 privateScreen.updateAverageColor (event->xproperty.atom);
1828 }
1824 else if (event->xproperty.atom == XA_WM_CLASS)1829 else if (event->xproperty.atom == XA_WM_CLASS)
1825 {1830 {
1826 w = findWindow (event->xproperty.window);1831 w = findWindow (event->xproperty.window);
18271832
=== modified file 'src/privatescreen.h'
--- src/privatescreen.h 2016-05-17 02:52:07 +0000
+++ src/privatescreen.h 2017-11-16 22:42:49 +0000
@@ -692,6 +692,8 @@
692692
693 void updateResources ();693 void updateResources ();
694694
695 void updateAverageColor (Atom atom);
696
695 Window getActiveWindow (Window root);697 Window getActiveWindow (Window root);
696698
697 void setWindowState (unsigned int state, Window id);699 void setWindowState (unsigned int state, Window id);
@@ -777,6 +779,8 @@
777 unsigned int nDesktop;779 unsigned int nDesktop;
778 unsigned int currentDesktop;780 unsigned int currentDesktop;
779781
782 std::vector<unsigned short> averageColor;
783
780 CompOutput fullscreenOutput;784 CompOutput fullscreenOutput;
781 CompScreenEdge screenEdge[SCREEN_EDGE_NUM];785 CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
782786
@@ -1092,6 +1096,7 @@
1092 virtual CompWindow * getTopServerWindow() const;1096 virtual CompWindow * getTopServerWindow() const;
1093 virtual CoreOptions& getCoreOptions();1097 virtual CoreOptions& getCoreOptions();
1094 virtual Colormap colormap() const;1098 virtual Colormap colormap() const;
1099 virtual const unsigned short * averageColor() const;
1095 virtual void setCurrentDesktop (unsigned int desktop);1100 virtual void setCurrentDesktop (unsigned int desktop);
1096 virtual Window activeWindow() const;1101 virtual Window activeWindow() const;
1097 virtual bool grabWindowIsNot(Window w) const;1102 virtual bool grabWindowIsNot(Window w) const;
@@ -1187,6 +1192,7 @@
1187 virtual void _matchPropertyChanged(CompWindow *);1192 virtual void _matchPropertyChanged(CompWindow *);
1188 virtual void _outputChangeNotify();1193 virtual void _outputChangeNotify();
1189 virtual void _cursorChangeNotify(const CompString&, int);1194 virtual void _cursorChangeNotify(const CompString&, int);
1195 virtual void _averageColorChangeNotify(const unsigned short*);
11901196
1191 void grabServer ();1197 void grabServer ();
1192 void ungrabServer ();1198 void ungrabServer ();
11931199
=== modified file 'src/privatescreen/tests/test-privatescreen.cpp'
--- src/privatescreen/tests/test-privatescreen.cpp 2016-05-17 02:52:07 +0000
+++ src/privatescreen/tests/test-privatescreen.cpp 2017-11-16 22:42:49 +0000
@@ -82,6 +82,7 @@
82 MOCK_METHOD1(_matchPropertyChanged, void (CompWindow *));82 MOCK_METHOD1(_matchPropertyChanged, void (CompWindow *));
83 MOCK_METHOD0(_outputChangeNotify, void ());83 MOCK_METHOD0(_outputChangeNotify, void ());
84 MOCK_METHOD2(_cursorChangeNotify, void (const CompString&, int));84 MOCK_METHOD2(_cursorChangeNotify, void (const CompString&, int));
85 MOCK_METHOD1(_averageColorChangeNotify, void (const unsigned short*));
8586
86 MOCK_METHOD0(outputDevs, CompOutput::vector & ());87 MOCK_METHOD0(outputDevs, CompOutput::vector & ());
87 MOCK_METHOD2(setWindowState, void (unsigned int state, Window id));88 MOCK_METHOD2(setWindowState, void (unsigned int state, Window id));
@@ -199,6 +200,7 @@
199 MOCK_CONST_METHOD0(getTopServerWindow, CompWindow * ());200 MOCK_CONST_METHOD0(getTopServerWindow, CompWindow * ());
200 MOCK_METHOD0(getCoreOptions, CoreOptions& ());201 MOCK_METHOD0(getCoreOptions, CoreOptions& ());
201 MOCK_CONST_METHOD0(colormap, Colormap ());202 MOCK_CONST_METHOD0(colormap, Colormap ());
203 MOCK_CONST_METHOD0(averageColor, const unsigned short * ());
202 MOCK_METHOD1(setCurrentDesktop, void (unsigned int desktop));204 MOCK_METHOD1(setCurrentDesktop, void (unsigned int desktop));
203 MOCK_CONST_METHOD0(activeWindow, Window ());205 MOCK_CONST_METHOD0(activeWindow, Window ());
204 MOCK_CONST_METHOD1(grabWindowIsNot, bool (Window w));206 MOCK_CONST_METHOD1(grabWindowIsNot, bool (Window w));
205207
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2016-08-01 13:25:02 +0000
+++ src/screen.cpp 2017-11-16 22:42:49 +0000
@@ -1427,6 +1427,113 @@
1427 screen->cursorChangeNotify (cursorTheme, cursorSize);1427 screen->cursorChangeNotify (cursorTheme, cursorSize);
1428}1428}
14291429
1430void
1431PrivateScreen::updateAverageColor (Atom atom)
1432{
1433 Atom actual_type;
1434 int result, format;
1435 unsigned long n, left;
1436 unsigned char *data;
1437
1438 auto previousAverageColor = averageColor;
1439 averageColor.clear ();
1440
1441 result = XGetWindowProperty (dpy, root,
1442 atom, 0L, 65536, False,
1443 XA_STRING, &actual_type, &format,
1444 &n, &left, &data);
1445
1446 if (result != Success || !data || actual_type != XA_STRING)
1447 {
1448 if (previousAverageColor != averageColor)
1449 screen->averageColorChangeNotify (averageColor.data ());
1450
1451 XFree (data);
1452 return;
1453 }
1454
1455 CompString colors (reinterpret_cast<char *> (data));
1456 bool found_valid;
1457 double r, g, b, a;
1458 found_valid = false;
1459 r = g = b = 0.0;
1460 a = 1.0;
1461 const CompString rgba_regex = R"((rgba?))"
1462 R"(\s*\(\s*([0-9]{1,3})\s*,)"
1463 R"(\s*([0-9]{1,3})\s*,)"
1464 R"(\s*([0-9]{1,3})\s*)"
1465 R"((,\s*((0*(\.[0-9]+)|1(\.0*)?)?)\s*)?\))";
1466
1467 std::vector<CompString> matches = compGetRegexMatches (rgba_regex, colors);
1468
1469 if (matches.size () > 4)
1470 {
1471 try
1472 {
1473 found_valid = true;
1474 r = std::stoi (matches[2]) / 255.0;
1475 g = std::stoi (matches[3]) / 255.0;
1476 b = std::stoi (matches[4]) / 255.0;
1477
1478 if (matches[1] == "rgba")
1479 {
1480 if (matches.size () > 6 && !matches[6].empty ())
1481 a = std::stod (matches[6][0] == '.' ? '0'+matches[6] : matches[6]);
1482 else
1483 found_valid = false;
1484 }
1485 } catch (std::exception const& except) {
1486 found_valid = false;
1487 compLogMessage ("core", CompLogLevelWarn, "%s: failed to parse '%s' color string",
1488 except.what (), colors.c_str ());
1489 }
1490 } else {
1491 size_t color_len = (colors.length () - 1) / 3;
1492
1493 if (color_len > 0 && color_len <= 4)
1494 {
1495 CompString hex_regex = "#([[:xdigit:]]{" + std::to_string(color_len) + "})" +
1496 "([[:xdigit:]]{" + std::to_string(color_len) + "})" +
1497 "([[:xdigit:]]{" + std::to_string(color_len) + "})" +
1498 "([[:xdigit:]]{" + std::to_string(color_len) + "})?$";
1499 std::vector<CompString> matches = compGetRegexMatches (hex_regex, colors);
1500 if (matches.size () == 5)
1501 {
1502 try
1503 {
1504 double max_value = static_cast<float> ((1 << (4 * color_len)) - 1);
1505 found_valid = true;
1506 r = std::stoi (matches[1], 0, 16) / max_value;
1507 g = std::stoi (matches[2], 0, 16) / max_value;
1508 b = std::stoi (matches[3], 0, 16) / max_value;
1509
1510 if (!matches[4].empty ())
1511 a = std::stoi (matches[4], 0, 16) / max_value;
1512 } catch (std::exception const& except) {
1513 found_valid = false;
1514 compLogMessage ("core", CompLogLevelWarn, "%s: failed to parse '%s' color string",
1515 except.what (), colors.c_str ());
1516 }
1517 }
1518 }
1519 }
1520
1521 if (found_valid)
1522 {
1523 const double MaxUShort = std::numeric_limits<unsigned short>::max ();
1524 averageColor.resize (4);
1525 averageColor[0] = MAX (0, MIN (r * MaxUShort, MaxUShort));
1526 averageColor[1] = MAX (0, MIN (g * MaxUShort, MaxUShort));
1527 averageColor[2] = MAX (0, MIN (b * MaxUShort, MaxUShort));
1528 averageColor[3] = MAX (0, MIN (a * MaxUShort, MaxUShort));
1529 }
1530
1531 XFree (data);
1532
1533 if (previousAverageColor != averageColor)
1534 screen->averageColorChangeNotify (averageColor.data ());
1535}
1536
1430bool1537bool
1431CompScreen::fileToImage (CompString &name,1538CompScreen::fileToImage (CompString &name,
1432 CompSize &size,1539 CompSize &size,
@@ -1732,7 +1839,7 @@
17321839
1733 result = XGetWindowProperty (dpy, id,1840 result = XGetWindowProperty (dpy, id,
1734 Atoms::mwmHints,1841 Atoms::mwmHints,
1735 0L, 20L, false, Atoms::mwmHints,1842 0L, 20L, false, AnyPropertyType,
1736 &actual, &format, &n, &left, &data);1843 &actual, &format, &n, &left, &data);
17371844
1738 if (result == Success && data)1845 if (result == Success && data)
@@ -3153,7 +3260,7 @@
3153 }3260 }
31543261
3155 if ((type & cps::GrabType::KEYBOARD) &&3262 if ((type & cps::GrabType::KEYBOARD) &&
3156 !eventManager.topGrab (cps::GrabType::KEYBOARD))3263 !eventManager.topGrab (cps::GrabType::KEYBOARD))
3157 {3264 {
3158 status = XGrabKeyboard (dpy,3265 status = XGrabKeyboard (dpy,
3159 eventManager.getGrabWindow (), true,3266 eventManager.getGrabWindow (), true,
@@ -3171,7 +3278,7 @@
3171 }3278 }
3172 else3279 else
3173 {3280 {
3174 XUngrabPointer (dpy, CurrentTime);3281 XUngrabPointer (dpy, CurrentTime);
3175 }3282 }
3176 }3283 }
31773284
@@ -3242,7 +3349,7 @@
3242 }3349 }
3243 else3350 else
3244 {3351 {
3245 XUngrabPointer (privateScreen.dpy, CurrentTime);3352 XUngrabPointer (privateScreen.dpy, CurrentTime);
3246 }3353 }
3247 }3354 }
32483355
@@ -4226,10 +4333,10 @@
4226PrivateScreen::updateCursors (const CompString& theme, int size)4333PrivateScreen::updateCursors (const CompString& theme, int size)
4227{4334{
4228 if (size > 0)4335 if (size > 0)
4229 XcursorSetDefaultSize (dpy, size);4336 XcursorSetDefaultSize (dpy, size);
42304337
4231 if (!theme.empty())4338 if (!theme.empty())
4232 XcursorSetTheme (dpy, theme.c_str());4339 XcursorSetTheme (dpy, theme.c_str());
42334340
4234 for (auto it = begin (cursors); it != end (cursors); ++it)4341 for (auto it = begin (cursors); it != end (cursors); ++it)
4235 {4342 {
@@ -4250,6 +4357,18 @@
4250 privateScreen.updateCursors (theme, size);4357 privateScreen.updateCursors (theme, size);
4251}4358}
42524359
4360void
4361CompScreen::averageColorChangeNotify (const unsigned short* color)
4362{
4363 WRAPABLE_HND_FUNCTN (averageColorChangeNotify, color);
4364 _averageColorChangeNotify (color);
4365}
4366
4367void
4368CompScreenImpl::_averageColorChangeNotify (const unsigned short* color)
4369{
4370}
4371
4253/* Returns default viewport for some window geometry. If the window spans4372/* Returns default viewport for some window geometry. If the window spans
4254 * more than one viewport the most appropriate viewport is returned. How the4373 * more than one viewport the most appropriate viewport is returned. How the
4255 * most appropriate viewport is computed can be made optional if necessary. It4374 * most appropriate viewport is computed can be made optional if necessary. It
@@ -4396,6 +4515,10 @@
4396ScreenInterface::cursorChangeNotify (const CompString& theme, int size)4515ScreenInterface::cursorChangeNotify (const CompString& theme, int size)
4397 WRAPABLE_DEF (cursorChangeNotify, theme, size)4516 WRAPABLE_DEF (cursorChangeNotify, theme, size)
43984517
4518void
4519ScreenInterface::averageColorChangeNotify (const unsigned short *color)
4520 WRAPABLE_DEF (averageColorChangeNotify, color)
4521
4399Window4522Window
4400CompScreenImpl::root ()4523CompScreenImpl::root ()
4401{4524{
@@ -4841,6 +4964,12 @@
4841 return privateScreen.colormap;4964 return privateScreen.colormap;
4842}4965}
48434966
4967const unsigned short *
4968CompScreenImpl::averageColor() const
4969{
4970 return privateScreen.averageColor.data ();
4971}
4972
4844void4973void
4845CompScreenImpl::setCurrentDesktop (unsigned int desktop)4974CompScreenImpl::setCurrentDesktop (unsigned int desktop)
4846{4975{
@@ -5270,6 +5399,8 @@
5270 XIGetClientPointer (dpy, None, &clientPointerDeviceId);5399 XIGetClientPointer (dpy, None, &clientPointerDeviceId);
5271 updateResources ();5400 updateResources ();
52725401
5402 updateAverageColor (Atoms::gnomeRepresentativeColors);
5403
5273 /* Attempt to gain SubstructureRedirectMask */5404 /* Attempt to gain SubstructureRedirectMask */
5274 CompScreenImpl::checkForError (dpy);5405 CompScreenImpl::checkForError (dpy);
52755406
52765407
=== modified file 'src/string/src/string.cpp'
--- src/string/src/string.cpp 2012-03-23 03:37:26 +0000
+++ src/string/src/string.cpp 2017-11-16 22:42:49 +0000
@@ -1,5 +1,6 @@
1/*1/*
2 * Copyright © 2008 Dennis Kasprzyk2 * Copyright © 2008 Dennis Kasprzyk
3 * Copyright © 2017 Canonical Ltd.
3 *4 *
4 * Permission to use, copy, modify, distribute, and sell this software5 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without6 * and its documentation for any purpose is hereby granted without
@@ -21,12 +22,20 @@
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.22 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *23 *
23 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>24 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25 * Marco Trevisan <marco.trevisan@canonical.com>
24 */26 */
2527
26#include <cstring>28#include <cstring>
27#include <cstdarg>29#include <cstdarg>
28#include <cstdio>30#include <cstdio>
2931
32#if defined(__GNUC__) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9)))
33#include <regex.h>
34#else
35#include <regex>
36#define HAVE_CPP_REGEX
37#endif
38
30#include <core/string.h>39#include <core/string.h>
3140
32CompString compPrintf (const char *format, ...)41CompString compPrintf (const char *format, ...)
@@ -86,3 +95,55 @@
86 delete [] str;95 delete [] str;
87 return rv;96 return rv;
88}97}
98
99CompStringVector
100compGetRegexMatches(const CompString& regexStr,
101 const CompString& string)
102{
103
104 CompStringVector matches;
105
106#ifdef HAVE_CPP_REGEX
107
108 std::smatch subMatches;
109 std::regex regex(regexStr);
110
111 if (std::regex_match(string, subMatches, regex))
112 {
113 for (const auto& subMatch : subMatches)
114 matches.push_back (subMatch.str ());
115 }
116
117#else
118
119 regex_t regex;
120 int ret;
121 ret = regcomp (&regex, regexStr.c_str (), REG_EXTENDED);
122
123 if (ret != 0)
124 return matches;
125
126 std::vector<regmatch_t> subMatches (regex.re_nsub + 1);
127 ret = regexec (&regex, string.c_str (), subMatches.size (), subMatches.data (), 0);
128
129 if (ret == REG_NOMATCH)
130 return matches;
131
132 for (const auto& sub_match : subMatches)
133 {
134 if (sub_match.rm_so >= 0)
135 {
136 size_t sub_len = sub_match.rm_eo - sub_match.rm_so;
137 matches.push_back (string.substr (sub_match.rm_so, sub_len));
138 } else {
139 /* We keep this empty so the clients might access to all the subs */
140 matches.push_back (CompString ());
141 }
142 }
143
144 regfree (&regex);
145
146#endif
147
148 return matches;
149}
89150
=== modified file 'src/window.cpp'
--- src/window.cpp 2016-05-17 02:52:25 +0000
+++ src/window.cpp 2017-11-16 22:42:49 +0000
@@ -6921,8 +6921,8 @@
6921 /* Gravity here is assumed to be SouthEast, clients can update6921 /* Gravity here is assumed to be SouthEast, clients can update
6922 * that if need be */6922 * that if need be */
69236923
6924 serverFrameGeometry.set (serverInput.left - border.left,6924 serverFrameGeometry.set (wa.x + (serverInput.left - border.left),
6925 serverInput.top - border.top,6925 wa.y + (serverInput.top - border.top),
6926 wa.width + (serverInput.left +6926 wa.width + (serverInput.left +
6927 serverInput.right),6927 serverInput.right),
6928 wa.height + (serverInput.top +6928 wa.height + (serverInput.top +

Subscribers

People subscribed via source and target branches

to all changes: