Merge lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz/0.9.10

Proposed by MC Return
Status: Work in progress
Proposed branch: lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver
Merge into: lp:compiz/0.9.10
Diff against target: 1884 lines (+1781/-0)
18 files modified
debian/compiz-plugins.install (+1/-0)
plugins/CMakeLists.txt (+1/-0)
plugins/screensaver/CMakeLists.txt (+5/-0)
plugins/screensaver/screensaver.xml.in (+132/-0)
plugins/screensaver/src/effect.cpp (+63/-0)
plugins/screensaver/src/effect.h (+6/-0)
plugins/screensaver/src/flyingwindows.cpp (+393/-0)
plugins/screensaver/src/flyingwindows.h (+94/-0)
plugins/screensaver/src/matrix.cpp (+60/-0)
plugins/screensaver/src/matrix.h (+69/-0)
plugins/screensaver/src/rotatingcube.cpp (+104/-0)
plugins/screensaver/src/rotatingcube.h (+34/-0)
plugins/screensaver/src/screensaver.cpp (+312/-0)
plugins/screensaver/src/screensaver.h (+258/-0)
plugins/screensaver/src/vector.cpp (+14/-0)
plugins/screensaver/src/vector.h (+164/-0)
plugins/screensaver/src/wrapper.cpp (+67/-0)
plugins/screensaver/src/wrapper.h (+4/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver
Reviewer Review Type Date Requested Status
MC Return Needs Resubmitting
Daniel van Vugt Pending
PS Jenkins bot continuous-integration Pending
Sam Spilsbury Pending
Review via email: mp+156680@code.launchpad.net

This proposal supersedes a proposal from 2012-12-31.

Commit message

Added the plug-in "Screensaver" converted from git to bzr (including full history) to lp:compiz.
Replaced GLFragment::Attrib with GLWindowPaintAttrib to fix compilation for Compiz post-r3320 (Thanks, Sam.).

Note: This plugin is currently disabled for GLES builds.

(LP: #1012197)

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I am okay with merging this as long as there is a maintainer for it. @MCR1 are you happy to maintain it across API changes?

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> I am okay with merging this as long as there is a maintainer for it. @MCR1 are
> you happy to maintain it across API changes?

I can only tell you that I can try, in the worst case we can disable it in the case I am not able to.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

As long as we do our best...

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Plugins like this don't affect Ubuntu/Unity. However we need to verify the code builds (or is skipped) not just with gcc, but also cland and gcc with BUILD_GLES=ON.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

@MCR1 can you check that?

Building a GLES build requires that you have a compatible libGLESv2
installed. That can be done with the radeon driver installed, not so
sure about fglrx. Pass -BUILD_GLES=ON to cmake.

Building with clang is relatively straightforward to. Install clang
and clang++ and pass -CMAKE_C_COMPILER=/usr/bin/clang
-CMAKE_CXX_COMPILER=/usr/bin/clang++

Though, I note that requiring reviewers and submitters to rebuild
everything three times is a bit time consuming and silly, especially
when this is a job that could be done by continuous integration. Can
we have a look into that?

(Also, why isn't the ps-jenkins-bot running on reviews that don't
originate from members who have commit access?)

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Note: There seems to be a bug in the raring versions of cmake that
cause it to get into an infinite configure-loop if you haven't removed
your entire build dir and then re-configure with those compiler
options.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

A few things need attention...

1. How do I build it? "package 'xscrnsaver' not found". Where do I get the cmake/pkgconfig package 'xscrnsaver'?

2. If you can build it, does it really build with BUILD_GLES=ON? If not, then please disable it for BUILD_GLES in plugins/CMakeLists.txt

3. Copyrights and license info is missing. We can't use someone else's code if we don't know the license conditions.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Fri, Jan 4, 2013 at 11:55 AM, Daniel van Vugt
<email address hidden> wrote:
> Review: Needs Fixing
>
> A few things need attention...
>
> 1. How do I build it? "package 'xscrnsaver' not found". Where do I get the cmake/pkgconfig package 'xscrnsaver'?
>

sudo apt-get install libxss-dev

Does the plugin automatically disable itself for building if that's
not found? If so, then it probably should.

> 2. If you can build it, does it really build with BUILD_GLES=ON? If not, then please disable it for BUILD_GLES in plugins/CMakeLists.txt
>
> 3. Copyrights and license info is missing. We can't use someone else's code if we don't know the license conditions.

The author is Nicholas Viennot and the licence is GPL v2 . That's only
from memory though, I'll see if I can find the actual licence file.

>
> --
> https://code.launchpad.net/~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver/+merge/141533
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz.

--
Sam Spilsbury

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

>
> The author is Nicholas Viennot and the licence is GPL v2 . That's only
> from memory though, I'll see if I can find the actual licence file.

There we go:

* Copyright (c) 2007 Nicolas Viennot <email address hidden>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.

from screensaver.cpp
>
>>
>> --
>> https://code.launchpad.net/~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver/+merge/141533
>> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz.
>
>
>
> --
> Sam Spilsbury

--
Sam Spilsbury

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

OK, all is fine except it fails to build with GLES. So please add an exclusion for BUILD_GLES in plugins/CMakeLists.txt

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

[ 95%] Building CXX object plugins/screensaver/CMakeFiles/screensaver.dir/src/effect.cpp.o
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp: In member function ‘virtual void ScreenFlyingWindows::glPaintTransformedOutput(const GLScreenPaintAttrib&, const GLMatrix&, const CompRegion&, CompOutput*, unsigned int)’:
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp:244:19: error: ‘GL_LIGHT_MODEL_TWO_SIDE’ was not declared in this scope
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp:245:69: error: ‘glLightModeli’ was not declared in this scope
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp: In member function ‘virtual bool WindowFlyingWindows::glPaint(const GLWindowPaintAttrib&, const GLMatrix&, const CompRegion&, unsigned int)’:
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp:376:18: error: ‘glPushMatrix’ was not declared in this scope
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp:377:33: error: ‘glLoadMatrixf’ was not declared in this scope
/home/dan/bzr/compiz/tmp.ss/plugins/screensaver/src/flyingwindows.cpp:379:17: error: ‘glPopMatrix’ was not declared in this scope
make[2]: *** [plugins/screensaver/CMakeFiles/screensaver.dir/src/flyingwindows.cpp.o] Error 1

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Aside from plugins/CMakeLists.txt needing an update, I suspect we may also need to touch:
debian/compiz-plugins.install

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> A few things need attention...
>
> 2. If you can build it, does it really build with BUILD_GLES=ON? If not, then
> please disable it for BUILD_GLES in plugins/CMakeLists.txt

Done in r3295.

> Aside from plugins/CMakeLists.txt needing an update, I suspect we may also
> need to touch:
> debian/compiz-plugins.install

Done in r3296.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> > A few things need attention...
> >
> > 1. How do I build it? "package 'xscrnsaver' not found". Where do I get the
> cmake/pkgconfig package 'xscrnsaver'?
> >
>
> sudo apt-get install libxss-dev
>
> Does the plugin automatically disable itself for building if that's
> not found? If so, then it probably should.
>
I agree. Can you give me a hint how I could accomplish that ?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Yes it is disabled if libxss-dev is missing. You can scroll up just after running cmake to see that.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Should I add a dependency on libxss-dev to compiz-plugins in debian/control ?

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

No, we don't want normal compiz builders to require libxss-dev. It's fine being optional.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> No, we don't want normal compiz builders to require libxss-dev. It's fine
> being optional.

Ok, should be fine now then...

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Seems to work well thanks.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Hi,

It seems like the screensaver plugin is not actually being installed

dh_install --fail-missing
dh_install: compiz-plugins missing files (debian/tmp/usr/*/compiz/*screensaver.*), aborting
make[1]: *** [override_dh_install] Error 2

Can you check that:

a) it does actually get installed
b) it gets installed to $PREFIX/lib/compiz/screenaver

It might get installed somewhere else - have a check to see.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Hi,
>
> It seems like the screensaver plugin is not actually being installed
>
> dh_install --fail-missing
> dh_install: compiz-plugins missing files
> (debian/tmp/usr/*/compiz/*screensaver.*), aborting
> make[1]: *** [override_dh_install] Error 2
>
> Can you check that:
>
> a) it does actually get installed
> b) it gets installed to $PREFIX/lib/compiz/screenaver
>
> It might get installed somewhere else - have a check to see.

I think the problem might be the missing xscrnsaver dependency
and it might probably be fixed by adding a dependency on libxss-dev
to compiz-plugins or compiz-dev package in debian/control.
The build logs above seem to be indicating that it fails to install
because screensaver was not compiled in the first place...

review: Needs Information
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Sat, Jan 5, 2013 at 5:46 PM, MC Return <email address hidden> wrote:
> Review: Needs Information
>
>> Hi,
>>
>> It seems like the screensaver plugin is not actually being installed
>>
>> dh_install --fail-missing
>> dh_install: compiz-plugins missing files
>> (debian/tmp/usr/*/compiz/*screensaver.*), aborting
>> make[1]: *** [override_dh_install] Error 2
>>
>> Can you check that:
>>
>> a) it does actually get installed
>> b) it gets installed to $PREFIX/lib/compiz/screenaver
>>
>> It might get installed somewhere else - have a check to see.
>
> I think the problem might be the missing xscrnsaver dependency
> and it might probably be fixed by adding a dependency on libxss-dev
> to compiz-plugins or compiz-dev package in debian/control.
> The build logs above seem to be indicating that it fails to install
> because screensaver was not compiled in the first place...

Hmm, that is a problem.

I don't know if we want to be adding dependencies on things in order
to build an unsupported plugin.

Maybe the next best thing to do would be to disable it for building in
the package? eg in debian/rules pass
-DCOMPIZ_DISABLE_PLUGIN_SCREENSAVER=ON

> --
> https://code.launchpad.net/~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver/+merge/141533
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Hmm, that is a problem.
>
> I don't know if we want to be adding dependencies on things in order
> to build an unsupported plugin.
>
> Maybe the next best thing to do would be to disable it for building in
> the package? eg in debian/rules pass
> -DCOMPIZ_DISABLE_PLUGIN_SCREENSAVER=ON
>
Hmm, that would mean almost noone would ever see this plugin, unless the
user compiles from source...
Maybe we could find yet another solution ?

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Sat, Jan 5, 2013 at 6:52 PM, MC Return <email address hidden> wrote:
>> Hmm, that is a problem.
>>
>> I don't know if we want to be adding dependencies on things in order
>> to build an unsupported plugin.
>>
>> Maybe the next best thing to do would be to disable it for building in
>> the package? eg in debian/rules pass
>> -DCOMPIZ_DISABLE_PLUGIN_SCREENSAVER=ON
>>
> Hmm, that would mean almost noone would ever see this plugin, unless the
> user compiles from source...
> Maybe we could find yet another solution ?

We could make the dependency conditional.

I know that the dependency on libxss-dev is only there for the
screensaver timeout logic. That can be conditionally compiled, so
users of the ubuntu package won't get the timeout-to-screensaver
functionality.

>
> --
> https://code.launchpad.net/~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver/+merge/141533
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz.

--
Sam Spilsbury

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

didrocks says:
the only way would be to create some kind of debian/compiz-plugins.install.in, which in debian/rules generates debian/compiz-plugins.install with or without the line you want just before calling dh_install

So either do that, or give up and say screensaver is not in the deb.

Either way, the change to compiz-plugins.install needs to be reverted.

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Sam, how should we continue this journey ?

I guess "PKGDEPS xscrnsaver" needs to be changed to "PKGDEPS libxss-dev" ?

Also I would still like to avoid excluding screensaver from the .deb package,
because most people would most probably never be able to use this great plugin...

I understand that we do not want to add a new dependency and you mentioned:

"We could make the dependency conditional.

I know that the dependency on libxss-dev is only there for the
screensaver timeout logic. That can be conditionally compiled, so
users of the ubuntu package won't get the timeout-to-screensaver
functionality."

I would like to help implementing that.
We could maybe use some internal Compiz timer to add that functionality
to the Compiz toolbox and not to have to depend on libxss-dev at all.

I am sure you have an idea on how to best achieve that, Sam ;)

review: Needs Information
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Sat, Mar 30, 2013 at 7:22 PM, MC Return <email address hidden> wrote:
> I understand that we do not want to add a new dependency and you mentioned:
>
> "We could make the dependency conditional.
>
> I know that the dependency on libxss-dev is only there for the
> screensaver timeout logic. That can be conditionally compiled, so
> users of the ubuntu package won't get the timeout-to-screensaver
> functionality."
>
> I would like to help implementing that.
> We could maybe use some internal Compiz timer to add that functionality
> to the Compiz toolbox and not to have to depend on libxss-dev at all.

As mentioned, you can do something like that with cmake in the
toplevel CMakeLists.txt and a config.h.in

config.h.in:

#cmakedefine USE_XSS

CMakeLists.txt

pkg_check_modules (LIBXSS xscrnsaver)

if (LIBXSS_FOUND)
    set (SCREENSAVER_ADDITIONAL_LIBRARIES ${LIBXSS_LIBRARIES})
    set (SCREENSAVER_ADDITIONAL_INCLUDES ${LIBXSS_INCLUDE_DIRS})
    set (USE_XSS ON)
endif (LIBXSS_FOUND)

configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
                     ${CMAKE_CURRENT_BINARY_DIR}/config.h.in)

include_directories (${CMAKE_CURRENT_BINARY_DIR}
                             ${SCREENSAVER_ADDITIONAL_INCLUDES})

compiz_plugin (screensaver PLUGINDEPS composite opengl LIBRARIES
${LIBXSS_LIBRARIES})

Then in the code, you can just conditionally compile the bits that
depend on libxss.

#ifdef USE_XSS
....
#else
....
#endif

>
> I am sure you have an idea on how to best achieve that, Sam ;)
> --
> https://code.launchpad.net/~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver/+merge/141533
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote :

I immediately tried the solution suggested, but it did not work unfortunately - probably my fault...

I need to ask for help with this at this stage I guess...

review: Needs Resubmitting
3307. By MC Return

More code cleanup

3308. By MC Return

Merged latest lp:compiz

3309. By MC Return

Minor .xml improvements

3310. By MC Return

Merged latest lp:compiz

3311. By MC Return

Optimized ABI check here as well

Unmerged revisions

3311. By MC Return

Optimized ABI check here as well

3310. By MC Return

Merged latest lp:compiz

3309. By MC Return

Minor .xml improvements

3308. By MC Return

Merged latest lp:compiz

3307. By MC Return

More code cleanup

3306. By MC Return

Fixed indentation and improved readability

3305. By MC Return

Improved readability
Fixed indentation
Removed redundant brackets

3304. By MC Return

Reenabled showmouse and splash plugins for GLES,
which were disabled by mistake

3303. By MC Return

Merged latest lp:compiz and fixed conflicts

3302. By MC Return

Merged latest lp:compiz and fixed conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/compiz-plugins.install'
2--- debian/compiz-plugins.install 2013-02-26 16:48:27 +0000
3+++ debian/compiz-plugins.install 2013-05-12 17:13:30 +0000
4@@ -32,6 +32,7 @@
5 debian/tmp/usr/*/compiz/*rotate.*
6 debian/tmp/usr/*/compiz/*scaleaddon.*
7 debian/tmp/usr/*/compiz/*scalefilter.*
8+debian/tmp/usr/*/compiz/*screensaver.*
9 debian/tmp/usr/*/compiz/*screenshot.*
10 debian/tmp/usr/*/compiz/*shelf.*
11 debian/tmp/usr/*/compiz/*shift.*
12
13=== modified file 'plugins/CMakeLists.txt'
14--- plugins/CMakeLists.txt 2013-03-08 18:42:22 +0000
15+++ plugins/CMakeLists.txt 2013-05-12 17:13:30 +0000
16@@ -31,6 +31,7 @@
17 set (COMPIZ_DISABLE_PLUGIN_BENCH ON)
18 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)
19 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)
20+ set (COMPIZ_DISABLE_PLUGIN_SCREENSAVER ON)
21 set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)
22 set (COMPIZ_DISABLE_PLUGIN_WIZARD ON)
23
24
25=== added directory 'plugins/screensaver'
26=== added file 'plugins/screensaver/CMakeLists.txt'
27--- plugins/screensaver/CMakeLists.txt 1970-01-01 00:00:00 +0000
28+++ plugins/screensaver/CMakeLists.txt 2013-05-12 17:13:30 +0000
29@@ -0,0 +1,5 @@
30+find_package (Compiz REQUIRED)
31+
32+include (CompizPlugin)
33+
34+compiz_plugin (screensaver PLUGINDEPS composite opengl cube PKGDEPS xscrnsaver)
35
36=== added file 'plugins/screensaver/screensaver.xml.in'
37--- plugins/screensaver/screensaver.xml.in 1970-01-01 00:00:00 +0000
38+++ plugins/screensaver/screensaver.xml.in 2013-05-12 17:13:30 +0000
39@@ -0,0 +1,132 @@
40+<?xml version="1.0"?>
41+<compiz>
42+ <plugin name="screensaver" useBcop="true">
43+ <_short>Screen Saver</_short>
44+ <_long>Let windows take flight or the cube rotate</_long>
45+ <deps>
46+ <requirement>
47+ <plugin>opengl</plugin>
48+ <plugin>cube</plugin>
49+ </requirement>
50+ <relation type="after">
51+ <plugin>opengl</plugin>
52+ <plugin>cube</plugin>
53+ </relation>
54+ </deps>
55+ <category>Extras</category>
56+ <options>
57+ <group>
58+ <_short>Bindings</_short>
59+ <option name="initiate_key" type="key">
60+ <_short>Initiate Key</_short>
61+ <_long>Key to manually start and stop the screensaver.</_long>
62+ </option>
63+ <option name="initiate_button" type="button">
64+ <_short>Initiate Button</_short>
65+ <_long>Mouse button to start and stop the screensaver.</_long>
66+ </option>
67+ <option name="initiate_edge" type="edge">
68+ <_short>Initiate Corner / Edge</_short>
69+ <_long>Start and stop the screensaver via screen corner or edge.</_long>
70+ </option>
71+ </group>
72+ <option name="mode" type="int">
73+ <_short>Screensaver Mode</_short>
74+ <_long>Choose between flying windows or rotating cube as screensaver.</_long>
75+ <default>0</default>
76+ <min>0</min>
77+ <max>1</max>
78+ <desc>
79+ <value>0</value>
80+ <name>Flying Windows</name>
81+ </desc>
82+ <desc>
83+ <value>1</value>
84+ <name>Rotating Cube</name>
85+ </desc>
86+ </option>
87+ <option name="start_automatically" type="bool">
88+ <_short>Start Automatically</_short>
89+ <_long>Start the chosen screensaver after a specified time period.</_long>
90+ <default>true</default>
91+ </option>
92+ <option name="after" type="float">
93+ <_short>After (min)</_short>
94+ <_long>Amount of time before the screensaver starts automatically (in minutes).</_long>
95+ <default>5.0</default>
96+ <min>0.1</min>
97+ <max>1000.0</max>
98+ <precision>0.01</precision>
99+ </option>
100+ <option name="fade_in_duration" type="float">
101+ <_short>Fade In Duration (sec)</_short>
102+ <_long>Length of the fade in (in seconds).</_long>
103+ <default>3.0</default>
104+ <min>0.0</min>
105+ <max>10.0</max>
106+ <precision>0.01</precision>
107+ </option>
108+ <option name="fade_out_duration" type="float">
109+ <_short>Fade Out Duration (sec)</_short>
110+ <_long>Length of the fade out (in seconds).</_long>
111+ <default>1.0</default>
112+ <min>0.0</min>
113+ <max>10.0</max>
114+ <precision>0.01</precision>
115+ </option>
116+ <group>
117+ <_short>Flying Windows</_short>
118+ <option name="window_match" type="match">
119+ <_short>Screen Saver Windows</_short>
120+ <_long>The window types which should fly.</_long>
121+ <default>type=Normal | Dialog | ModalDialog | Utility | Unknown</default>
122+ </option>
123+ <option name="mipmaps" type="bool">
124+ <_short>Mipmaps</_short>
125+ <_long>Generate mipmaps for higher quality scaling.</_long>
126+ <default>false</default>
127+ </option>
128+ <option name="attraction_depth" type="float">
129+ <_short>Attraction Depth</_short>
130+ <_long>Attraction depth of the windows.</_long>
131+ <default>1.5</default>
132+ <min>0.0</min>
133+ <max>10.0</max>
134+ <precision>0.01</precision>
135+ </option>
136+ <option name="attraction_repulsion_ratio" type="float">
137+ <_short>Attraction / Repulsion Ratio</_short>
138+ <_long>Attraction/Repulsion ratio of the windows.</_long>
139+ <default>50.0</default>
140+ <min>0.0</min>
141+ <max>100.0</max>
142+ <precision>0.01</precision>
143+ </option>
144+ <option name="bounce" type="bool">
145+ <_short>Bounce</_short>
146+ <_long>Make windows bounce on the floor, still buggy, but essential with cube reflexion.</_long>
147+ <default>true</default>
148+ </option>
149+ </group>
150+ <group>
151+ <_short>Rotating Cube</_short>
152+ <option name="cube_rotation_speed" type="float">
153+ <_short>Cube Rotation Speed</_short>
154+ <_long>The speed of the cube's rotation.</_long>
155+ <default>1.0</default>
156+ <min>-10.0</min>
157+ <max>10.0</max>
158+ <precision>0.01</precision>
159+ </option>
160+ <option name="cube_zoom" type="float">
161+ <_short>Zoom</_short>
162+ <_long>The zoom applied.</_long>
163+ <default>0.5</default>
164+ <min>0.0</min>
165+ <max>2.0</max>
166+ <precision>0.1</precision>
167+ </option>
168+ </group>
169+ </options>
170+ </plugin>
171+</compiz>
172
173=== added directory 'plugins/screensaver/src'
174=== added file 'plugins/screensaver/src/effect.cpp'
175--- plugins/screensaver/src/effect.cpp 1970-01-01 00:00:00 +0000
176+++ plugins/screensaver/src/effect.cpp 2013-05-12 17:13:30 +0000
177@@ -0,0 +1,63 @@
178+#include "screensaver.h"
179+#include <cmath>
180+
181+#define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5))))
182+#define sigmoidProgress(x) ((sigmoid(x) - sigmoid(0)) / (sigmoid(1) - sigmoid(0)))
183+
184+void
185+ScreenEffect::handleEvent (XEvent *event)
186+{
187+ ScreenWrapper::handleEvent (event);
188+}
189+
190+void
191+ScreenEffect::cubeGetRotation (float &x, float &v, float &progress)
192+{
193+ ScreenWrapper::cubeGetRotation (x, v, progress);
194+}
195+
196+bool ScreenEffect::enable ()
197+{
198+ progress = 0.0;
199+ return true;
200+}
201+
202+void ScreenEffect::preparePaint (int msSinceLastPaint)
203+{
204+ if (ss->mState.running)
205+ {
206+ if (ss->mState.fadingIn)
207+ {
208+ float fadeDuration = ss->optionGetFadeInDuration () * 1000.0;
209+ progress = sigmoidProgress (((float)ss->mTime) / fadeDuration);
210+ ss->mTime += msSinceLastPaint;
211+
212+ if (ss->mTime >= fadeDuration)
213+ {
214+ if (ss->optionGetStartAutomatically ())
215+ XActivateScreenSaver(screen->dpy ());
216+
217+ ss->mState.fadingIn = FALSE;
218+ ss->mTime = 0;
219+ }
220+ }
221+ else if (ss->mState.fadingOut)
222+ {
223+ float fadeDuration = ss->optionGetFadeOutDuration () * 1000.0;
224+ progress = sigmoidProgress (((float)ss->mTime) / fadeDuration);
225+ ss->mTime += msSinceLastPaint;
226+
227+ if (ss->mTime >= fadeDuration)
228+ {
229+ clean ();
230+ ss->mEffect->cleanEffect = true;
231+ ss->mState.running = FALSE;
232+ ss->cScreen->damageScreen ();
233+ }
234+ }
235+ else
236+ progress = 1.0;
237+ }
238+
239+ ScreenWrapper::preparePaint (msSinceLastPaint);
240+}
241
242=== added file 'plugins/screensaver/src/effect.h'
243--- plugins/screensaver/src/effect.h 1970-01-01 00:00:00 +0000
244+++ plugins/screensaver/src/effect.h 2013-05-12 17:13:30 +0000
245@@ -0,0 +1,6 @@
246+#ifndef EFFECT_H
247+#define EFFECT_H
248+
249+#include "screensaver_internal.h"
250+
251+#endif
252
253=== added file 'plugins/screensaver/src/flyingwindows.cpp'
254--- plugins/screensaver/src/flyingwindows.cpp 1970-01-01 00:00:00 +0000
255+++ plugins/screensaver/src/flyingwindows.cpp 2013-05-12 17:13:30 +0000
256@@ -0,0 +1,393 @@
257+#include "flyingwindows.h"
258+
259+#define NE 0
260+#define NO 1
261+#define SE 2
262+#define SO 3
263+#define C 4
264+
265+void ScreenFlyingWindows::handleEvent (XEvent *event)
266+{
267+ ScreenEffect::handleEvent (event);
268+
269+ if (event->type == MapNotify)
270+ {
271+ CompWindow* w = screen->findWindow (event->xmap.window);
272+
273+ if (w)
274+ WindowFlyingWindows::getInstance(w).initWindow();
275+ }
276+}
277+
278+bool ScreenFlyingWindows::enable ()
279+{
280+ ss->mAngleCam = 0.0;
281+ ss->mScreenCenter = Vector (0.0, ss->optionGetBounce () ? 0.2 : 0.0,
282+ -ss->optionGetAttractionDepth ());
283+ ss->mCamera = Matrix::identity;
284+ ss->mDesktopOpacity = OPAQUE;
285+
286+ foreach (CompWindow *w, screen->windows ())
287+ {
288+ WindowFlyingWindows::getInstance(w).initWindow ();
289+ }
290+
291+ return ScreenEffect::enable ();
292+}
293+
294+void ScreenFlyingWindows::disable ()
295+{
296+ foreach (CompWindow *w, screen->windows ())
297+ {
298+ WindowFlyingWindows& sw = WindowFlyingWindows::getInstance (w);
299+
300+ if (sw.active)
301+ sw.transformFadeOut = ss->mCameraMat * sw.transform;
302+
303+ else sw.opacityFadeOut = sw.opacity;
304+ }
305+
306+ ss->mCameraMat = Matrix::identity;
307+ ScreenEffect::disable ();
308+}
309+
310+void ScreenFlyingWindows::addForce (const Point& p1, const Point& p2, const Point& center, Vector& resultante, Vector& couple, float w, bool attract)
311+{
312+ Vector u = p2 - p1;
313+ float d = u.norm ();
314+ u.normalize ();
315+
316+ if (d < 1e-5)
317+ d = 1e-5;
318+
319+ Vector force = attract ? w * u * d * d : -w * u / (d * d);
320+ resultante += force;
321+
322+ couple += (center - p1) ^ force;
323+}
324+
325+void ScreenFlyingWindows::preparePaint (int msSinceLastPaint)
326+{
327+ ScreenEffect::preparePaint (msSinceLastPaint);
328+
329+ float ratio = ss->optionGetAttractionRepulsionRatio() / 100.0;
330+ float wAt = ratio;
331+ float wRt = 1-ratio;
332+
333+ if (ss->mState.fadingIn)
334+ {
335+ wAt *= getProgress();
336+ wRt *= getProgress();
337+
338+ ss->mDesktopOpacity = (GLushort)(OPAQUE * (1.0 - getProgress ()));
339+ }
340+
341+ if (ss->mState.fadingOut)
342+ ss->mDesktopOpacity = (GLushort)(OPAQUE * getProgress ());
343+
344+ if (!ss->mState.fadingOut)
345+ {
346+ ss->mAngleCam += ((float)msSinceLastPaint) / 100000.0;
347+
348+ if (ss->mAngleCam > 0.03)
349+ ss->mAngleCam = 0.03;
350+
351+ ss->mCamera.rotate (ss->mAngleCam*msSinceLastPaint, 0.0, 1.0, 0.0);
352+
353+ Matrix centerTrans = Matrix::identity;
354+ Matrix centerTransInv = Matrix::identity;
355+
356+ Vector screenCenterTranslated = ss->mScreenCenter.toCoordsSpace ();
357+ screenCenterTranslated[z] *= screen->width ();
358+
359+ centerTrans.scale (1.0, 1.0, 1.0 / screen->width ());
360+ centerTrans.translate (screenCenterTranslated);
361+ centerTransInv.translate (-screenCenterTranslated);
362+ centerTransInv.scale (1.0, 1.0, 1.0 * screen->width ());
363+
364+ ss->mCameraMat = centerTrans * ss->mCamera * centerTransInv;
365+ }
366+
367+ foreach (CompWindow *w, screen->windows ())
368+ {
369+ WindowFlyingWindows& sw = WindowFlyingWindows::getInstance(w);
370+
371+ if (sw.active)
372+ {
373+ if (ss->mState.fadingOut)
374+ sw.transform = interpolate (sw.transformFadeOut, Matrix::identity, getProgress ());
375+ else
376+ {
377+ int collisionVertex = -1;
378+ int collisionIteration = 1;
379+ Vector a, p, o, omega;
380+
381+ do
382+ {
383+ Vector resultante, couple, resultanteA, coupleA;
384+ resultante = couple = resultanteA = coupleA = Vector::null;
385+ Vector windowcenter = sw.vertex[C];
386+ float mass = sqrt (((float)(WIN_W(w) * WIN_H(w))) / (screen->width () * screen->height ()));
387+
388+ float wR = 1e-8 / mass * wRt;
389+ float wA = 1e-8 / mass * wAt;
390+
391+ int numPoint = 0;
392+
393+ for (int i = 0; i < 5; ++i)
394+ {
395+ foreach (CompWindow *w2, screen->windows ())
396+ {
397+ WindowFlyingWindows& sw2 = WindowFlyingWindows::getInstance (w2);
398+
399+ if (w2 != w && sw2.active)
400+ {
401+ ++numPoint;
402+
403+ for (int j = 0; j < 5; ++j)
404+ addForce (sw.vertex[i], sw2.vertex[j], windowcenter, resultante, couple, wR, FALSE);
405+ }
406+ }
407+
408+ addForce (sw.vertex[i], ss->mScreenCenter, windowcenter, resultanteA, coupleA, wA, TRUE);
409+ }
410+
411+ if (numPoint < 1)
412+ numPoint = 1;
413+
414+ resultante += resultanteA*numPoint;
415+ couple += coupleA*numPoint;
416+
417+ if (collisionVertex != -1)
418+ {
419+ float wb = sw.vertex[collisionVertex][y] / msSinceLastPaint * 5e-4;
420+ resultante[y] = -wb;
421+ float tmp = couple[z];
422+ couple = (sw.vertex[collisionVertex] - windowcenter) ^ Vector (0.0, -wb, 0.0);
423+ couple[z] = tmp;
424+ sw.speed[y] = 0;
425+ }
426+
427+ a = resultante - 5e-4 * mass * sw.speed;
428+ omega = couple * 1000 - 5e-3 * mass * sw.speedrot;
429+
430+ p = msSinceLastPaint * msSinceLastPaint * a + msSinceLastPaint * sw.speed;
431+ sw.speed += msSinceLastPaint * a;
432+
433+ o = msSinceLastPaint * msSinceLastPaint * omega + msSinceLastPaint * sw.speedrot;
434+ sw.speedrot += msSinceLastPaint * omega;
435+
436+ sw.transformTrans.translate (p[x]*screen->width (), -p[y]*screen->height (), p[z]);
437+ sw.transformRot.rotate (o.norm(), o);
438+
439+ sw.transform = sw.transformTrans * sw.centerTrans * sw.transformRot * sw.centerTransInv;
440+
441+ sw.recalcVertices ();
442+
443+ if (ss->optionGetBounce ())
444+ for (int i = 0; i < 4; ++i)
445+ {
446+ if (sw.vertex[i][y] < -0.5)
447+ collisionVertex = i;
448+ }
449+
450+ } while (collisionVertex != -1 && --collisionIteration);
451+ }
452+ }
453+ else
454+ {
455+ if (ss->mState.fadingOut)
456+ sw.opacity = (GLushort)(sw.opacityOld * getProgress() +
457+ sw.opacityFadeOut * (1 - getProgress()));
458+ else
459+ sw.steps = (int)((msSinceLastPaint * OPAQUE) /
460+ (ss->optionGetFadeInDuration() * 1000.0));
461+ }
462+ }
463+}
464+
465+void ScreenFlyingWindows::donePaint ()
466+{
467+ ss->cScreen->damageScreen ();
468+ ScreenEffect::donePaint ();
469+}
470+
471+void ScreenFlyingWindows::paint (CompOutput::ptrList &outputs,
472+ unsigned int mask)
473+{
474+ CompOutput::ptrList newOutputs;
475+ newOutputs.push_back (&screen->fullscreenOutput ());
476+
477+ ScreenEffect::paint (newOutputs, mask);
478+}
479+
480+bool
481+ScreenFlyingWindows::glPaintOutput(const GLScreenPaintAttrib &attrib,
482+ const GLMatrix &transform,
483+ const CompRegion &region,
484+ CompOutput *output,
485+ unsigned int mask)
486+{
487+ ss->gScreen->clearTargetOutput (GL_COLOR_BUFFER_BIT);
488+ return ScreenEffect::glPaintOutput (attrib, transform, region, output, mask | PAINT_SCREEN_TRANSFORMED_MASK);
489+}
490+
491+void
492+ScreenFlyingWindows::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
493+ const GLMatrix &transform,
494+ const CompRegion &region,
495+ CompOutput *output,
496+ unsigned int mask)
497+{
498+ bool wasCulled = glIsEnabled (GL_CULL_FACE);
499+
500+ if (wasCulled)
501+ glDisable (GL_CULL_FACE);
502+
503+ GLenum oldFilter = ss->gScreen->textureFilter ();
504+
505+ if (ss->optionGetMipmaps ())
506+ ss->gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
507+
508+ mask &= ~PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
509+
510+ GLboolean bTwoSite;
511+ glGetBooleanv (GL_LIGHT_MODEL_TWO_SIDE, &bTwoSite);
512+ glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, ss->gScreen->lighting ());
513+
514+ ScreenEffect::glPaintTransformedOutput (attrib, transform, region, output, mask);
515+
516+ glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, bTwoSite);
517+
518+ ss->gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
519+ ss->gScreen->setTextureFilter (oldFilter);
520+
521+ if (wasCulled)
522+ glEnable (GL_CULL_FACE);
523+}
524+
525+WindowFlyingWindows::WindowFlyingWindows (CompWindow* w) :
526+ WindowEffect(w),
527+ active (FALSE),
528+ opacity (GLWindow::get (w)->paintAttrib ().opacity),
529+ opacityFadeOut (0),
530+ opacityOld (0),
531+ steps (0)
532+{
533+}
534+
535+// Returns true if w is a flying window
536+bool WindowFlyingWindows::isActiveWin()
537+{
538+ return !w->overrideRedirect () && \
539+ w->mapNum () && \
540+ w->isViewable () && \
541+ !(w->wmType () & ( CompWindowTypeDockMask | CompWindowTypeDesktopMask)) && \
542+ /* !( w->state & ( CompWindowStateSkipPagerMask | CompWindowStateShadedMask )) && \*/
543+ ScreenSaverScreen::get (screen)->optionGetWindowMatch ().evaluate (w);
544+}
545+
546+// Initialize window transformation matrices and vertices
547+void WindowFlyingWindows::initWindow ()
548+{
549+ active = isActiveWin ();
550+
551+ if (active)
552+ {
553+ float x = WIN_X (this->w);
554+ float y = WIN_Y (this->w);
555+ float w = WIN_W (this->w);
556+ float h = WIN_H (this->w);
557+
558+ transform = transformRot = transformTrans = Matrix::identity;
559+ centerTrans = centerTransInv = Matrix::identity;
560+
561+ centerTrans.scale (1.0, 1.0, 1.0 / screen->width ());
562+ centerTrans.translate (x + w/2.0, y + h/2.0, 0.0);
563+ centerTransInv.translate (-(x + w / 2.0), -(y + h / 2.0), 0.0);
564+ centerTransInv.scale (1.0f, 1.0f, 1.0f * screen->width ());
565+
566+ recalcVertices ();
567+ speed = speedrot = Vector::null;
568+ }
569+ else
570+ opacityOld = opacity;
571+}
572+
573+// Update window vertices
574+void WindowFlyingWindows::recalcVertices ()
575+{
576+ float x = WIN_X (this->w);
577+ float y = WIN_Y (this->w);
578+ float w = WIN_W (this->w);
579+ float h = WIN_H (this->w);
580+
581+ vertex[NO] = Point (x, y, 0.0);
582+ vertex[NE] = Point (x + w, y, 0.0);
583+ vertex[SO] = Point (x, y + h, 0.0);
584+ vertex[SE] = Point (x + w, y + h, 0.0);
585+ vertex[C] = Point (x + w/2.0, y + h/2.0, 0.0);
586+
587+ // Apply the window transformation and normalize
588+ for (int i = 0; i < 5; ++i)
589+ vertex[i] = (transform * vertex[i]).toScreenSpace ();
590+}
591+
592+bool WindowFlyingWindows::glPaint (const GLWindowPaintAttrib &attrib,
593+ const GLMatrix &transform,
594+ const CompRegion &region,
595+ unsigned int mask)
596+{
597+ GLWindowPaintAttrib sAttrib (attrib);
598+ Matrix wTransform;
599+
600+ if (!active)
601+ {
602+ SCREENSAVER_SCREEN (screen);
603+
604+ if (opacity && steps && !ss->mState.fadingOut)
605+ {
606+ if (opacity < steps)
607+ opacity = 0;
608+ else
609+ opacity -= steps;
610+ steps = 0;
611+ }
612+
613+ sAttrib.opacity = opacity;
614+ wTransform = transform;
615+ }
616+ else
617+ {
618+ SCREENSAVER_SCREEN (screen);
619+ wTransform = transform * ss->mCameraMat * this->transform;
620+ mask |= PAINT_WINDOW_TRANSFORMED_MASK;
621+
622+ if (w->state () & CompWindowStateSkipPagerMask)
623+ return WindowEffect::glPaint (sAttrib, wTransform.m, region, mask);
624+ }
625+
626+ if (w->alpha () || sAttrib.opacity != OPAQUE)
627+ mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
628+
629+ // from paint.cpp
630+ if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
631+ {
632+ if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
633+ mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK ||
634+ mask & PAINT_WINDOW_TRANSLUCENT_MASK ||
635+ w->shaded ())
636+ return false;
637+
638+ return true;
639+ }
640+
641+ GLWindowPaintAttrib fragment (sAttrib);
642+
643+ glPushMatrix ();
644+ glLoadMatrixf (wTransform.m);
645+ bool status = sw->gWindow->glDraw (wTransform.m, fragment, region, mask);
646+ glPopMatrix ();
647+
648+ return status;
649+}
650
651=== added file 'plugins/screensaver/src/flyingwindows.h'
652--- plugins/screensaver/src/flyingwindows.h 1970-01-01 00:00:00 +0000
653+++ plugins/screensaver/src/flyingwindows.h 2013-05-12 17:13:30 +0000
654@@ -0,0 +1,94 @@
655+#ifndef FLYINGWINDOWS_H
656+#define FLYINGWINDOWS_H
657+
658+#include "screensaver.h"
659+
660+class ScreenFlyingWindows : public ScreenEffect
661+{
662+ public:
663+
664+ ScreenFlyingWindows () : ScreenEffect () {}
665+ virtual ~ScreenFlyingWindows () {}
666+
667+ virtual void handleEvent (XEvent *event);
668+ virtual bool enable ();
669+ virtual void disable ();
670+ virtual void preparePaint (int);
671+ virtual void donePaint ();
672+ virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &,
673+ const GLMatrix &,
674+ const CompRegion &,
675+ CompOutput *,
676+ unsigned int );
677+ virtual bool glPaintOutput (const GLScreenPaintAttrib &,
678+ const GLMatrix &,
679+ const CompRegion &,
680+ CompOutput *,
681+ unsigned int );
682+ virtual void paint (CompOutput::ptrList &,
683+ unsigned int );
684+ private:
685+ void initWindow (CompWindow* _w);
686+ void recalcVertices (CompWindow* _w);
687+ void addForce (const Point& p1,
688+ const Point& p2,
689+ const Point& center,
690+ Vector& resultante,
691+ Vector& couple,
692+ float w,
693+ bool attract);
694+};
695+
696+class WindowFlyingWindows : public WindowEffect
697+{
698+ friend class ScreenFlyingWindows;
699+
700+ public:
701+
702+ WindowFlyingWindows (CompWindow* w);
703+ virtual ~WindowFlyingWindows () {}
704+ void initWindow ();
705+ virtual bool glPaint (const GLWindowPaintAttrib &,
706+ const GLMatrix &,
707+ const CompRegion &,
708+ unsigned int );
709+ void recalcVertices ();
710+
711+ static WindowFlyingWindows& getInstance (CompWindow* w) { return (WindowFlyingWindows&)*ScreenSaverWindow::get (w)->mEffect; }
712+
713+ private:
714+
715+ bool isActiveWin ();
716+
717+ // isScreenSaverWin()
718+ bool active;
719+
720+ // used for non-active window like the desktop
721+ GLushort opacity;
722+ GLushort opacityFadeOut;
723+ GLushort opacityOld;
724+ int steps;
725+
726+ // used for active window
727+ // translate matrix
728+ Matrix transformTrans;
729+
730+ // rotation matrix
731+ Matrix centerTrans;
732+ Matrix transformRot;
733+ Matrix centerTransInv;
734+
735+ // precomputed transform matrix
736+ Matrix transform;
737+
738+ Matrix transformFadeOut;
739+
740+ // 5 normalized vertices are stored, the four corners and the center
741+ Point vertex[5];
742+
743+ // normalized speed vectors
744+ Vector speed;
745+ Vector speedrot;
746+};
747+
748+#endif
749
750=== added file 'plugins/screensaver/src/matrix.cpp'
751--- plugins/screensaver/src/matrix.cpp 1970-01-01 00:00:00 +0000
752+++ plugins/screensaver/src/matrix.cpp 2013-05-12 17:13:30 +0000
753@@ -0,0 +1,60 @@
754+#include "screensaver.h"
755+
756+static const float _identity[16] =
757+{
758+ 1.0, 0.0, 0.0, 0.0,
759+ 0.0, 1.0, 0.0, 0.0,
760+ 0.0, 0.0, 1.0, 0.0,
761+ 0.0, 0.0, 0.0, 1.0
762+};
763+
764+const Matrix Matrix::identity = _identity;
765+
766+Matrix operator* (const Matrix& lhs, const Matrix& rhs)
767+{
768+ Matrix res;
769+ res[0] = lhs[0] * rhs[0] + lhs[4] * rhs[1] + lhs[8] * rhs[2] + lhs[12] * rhs[3];
770+ res[1] = lhs[1] * rhs[0] + lhs[5] * rhs[1] + lhs[9] * rhs[2] + lhs[13] * rhs[3];
771+ res[2] = lhs[2] * rhs[0] + lhs[6] * rhs[1] + lhs[10] * rhs[2] + lhs[14] * rhs[3];
772+ res[3] = lhs[3] * rhs[0] + lhs[7] * rhs[1] + lhs[11] * rhs[2] + lhs[15] * rhs[3];
773+ res[4] = lhs[0] * rhs[4] + lhs[4] * rhs[5] + lhs[8] * rhs[6] + lhs[12] * rhs[7];
774+ res[5] = lhs[1] * rhs[4] + lhs[5] * rhs[5] + lhs[9] * rhs[6] + lhs[13] * rhs[7];
775+ res[6] = lhs[2] * rhs[4] + lhs[6] * rhs[5] + lhs[10] * rhs[6] + lhs[14] * rhs[7];
776+ res[7] = lhs[3] * rhs[4] + lhs[7] * rhs[5] + lhs[11] * rhs[6] + lhs[15] * rhs[7];
777+ res[8] = lhs[0] * rhs[8] + lhs[4] * rhs[9] + lhs[8] * rhs[10] + lhs[12] * rhs[11];
778+ res[9] = lhs[1] * rhs[8] + lhs[5] * rhs[9] + lhs[9] * rhs[10] + lhs[13] * rhs[11];
779+ res[10] = lhs[2] * rhs[8] + lhs[6] * rhs[9] + lhs[10] * rhs[10] + lhs[14] * rhs[11];
780+ res[11] = lhs[3] * rhs[8] + lhs[7] * rhs[9] + lhs[11] * rhs[10] + lhs[15] * rhs[11];
781+ res[12] = lhs[0] * rhs[12] + lhs[4] * rhs[13] + lhs[8] * rhs[14] + lhs[12] * rhs[15];
782+ res[13] = lhs[1] * rhs[12] + lhs[5] * rhs[13] + lhs[9] * rhs[14] + lhs[13] * rhs[15];
783+ res[14] = lhs[2] * rhs[12] + lhs[6] * rhs[13] + lhs[10] * rhs[14] + lhs[14] * rhs[15];
784+ res[15] = lhs[3] * rhs[12] + lhs[7] * rhs[13] + lhs[11] * rhs[14] + lhs[15] * rhs[15];
785+
786+ return res;
787+}
788+
789+Vector operator* (const Matrix& mat, const Vector& vect)
790+{
791+ Vector res;
792+
793+ res[0] = mat[0] * vect[0] + mat[4] * vect[1] + mat[8] * vect[2] + mat[12];
794+ res[1] = mat[1] * vect[0] + mat[5] * vect[1] + mat[9] * vect[2] + mat[13];
795+ res[2] = mat[2] * vect[0] + mat[6] * vect[1] + mat[10] * vect[2] + mat[14];
796+ float w = mat[3] * vect[0] + mat[7] * vect[1] + mat[11] * vect[2] + mat[15];
797+
798+ res[0] /= w;
799+ res[1] /= w;
800+ res[2] /= w;
801+
802+ return res;
803+}
804+
805+Matrix interpolate (const Matrix& from, const Matrix& to, float position)
806+{
807+ Matrix res;
808+
809+ for (int i = 0; i < 16; ++i)
810+ res[i] = from[i] * (1 - position) + to[i] * position;
811+
812+ return res;
813+}
814
815=== added file 'plugins/screensaver/src/matrix.h'
816--- plugins/screensaver/src/matrix.h 1970-01-01 00:00:00 +0000
817+++ plugins/screensaver/src/matrix.h 2013-05-12 17:13:30 +0000
818@@ -0,0 +1,69 @@
819+#ifndef MATRIX_H
820+#define MATRIX_H
821+
822+#include <core/core.h>
823+#include <opengl/opengl.h>
824+#include <cmath>
825+#include "vector.h"
826+
827+class Matrix
828+{
829+ public:
830+
831+ static const Matrix identity;
832+
833+ Matrix()
834+ {
835+ for (int i = 0; i < 16; ++i)
836+ {
837+ m[i] = 0;
838+ }
839+ }
840+
841+ Matrix (const GLMatrix &mat) { memcpy (m, mat.getMatrix (), sizeof(m)); }
842+ Matrix (const Matrix& mat) { memcpy (m, mat.m, sizeof(m)); }
843+ Matrix (const float* mat) { memcpy (m, mat, sizeof(m)); }
844+
845+ const float& operator[] (int i) const { return m[i]; }
846+ float& operator[] (int i) { return m[i]; }
847+
848+ Matrix& operator*= (const Matrix& rhs) { Matrix res; *this = *this * rhs; return *this; }
849+ friend Matrix operator* (const Matrix& lhs, const Matrix& rhs);
850+ friend Vector operator* (const Matrix& mat, const Vector& vect);
851+
852+ friend Matrix interpolate (const Matrix& from, const Matrix& to, float position);
853+
854+ Matrix& rotate (float angle, float x, float y, float z)
855+ {
856+ GLMatrix t (m);
857+ t.rotate (angle, x, y, z);
858+ memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16);
859+ return *this;
860+ }
861+
862+ Matrix& rotate (float angle, const Vector& vect) { return rotate (angle, vect[x], vect[y], vect[z]); }
863+
864+ Matrix& scale (float x, float y, float z)
865+ {
866+ GLMatrix t (m);
867+ t.scale (x, y, z);
868+ memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16);
869+ return *this;
870+ }
871+
872+ Matrix& scale (const Vector& vect) { return scale (vect[x], vect[y], vect[z]); }
873+
874+ Matrix& translate (float x, float y, float z)
875+ {
876+ GLMatrix t (m);
877+ t.translate (x, y, z);
878+ memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16);
879+ return *this;
880+ }
881+
882+ Matrix& translate (const Vector& vect) { return translate (vect[x], vect[y], vect[z]); }
883+
884+ float m[16];
885+};
886+
887+#endif
888
889=== added file 'plugins/screensaver/src/rotatingcube.cpp'
890--- plugins/screensaver/src/rotatingcube.cpp 1970-01-01 00:00:00 +0000
891+++ plugins/screensaver/src/rotatingcube.cpp 2013-05-12 17:13:30 +0000
892@@ -0,0 +1,104 @@
893+#include "rotatingcube.h"
894+
895+bool ScreenRotatingCube::loadCubePlugin()
896+{
897+ if (!CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI))
898+ return false;
899+
900+ return true;
901+}
902+
903+bool ScreenRotatingCube::enable ()
904+{
905+ if (!loadCubePlugin ())
906+ return false;
907+
908+ CubeScreen *cs = ss->cubeScreen;
909+
910+ ss->mZCamera = 0.0;
911+ ss->mCubeRotX = 0.0;
912+ ss->mCubeRotV = 0.0;
913+ cs->rotationState (CubeScreen::RotationManual);
914+
915+ ss->cubeScreen->cubeGetRotationSetEnabled (ss, true);
916+
917+ return ScreenEffect::enable ();
918+}
919+
920+void ScreenRotatingCube::disable ()
921+{
922+ ss->mZCameraFadeOut = ss->mZCamera;
923+ ss->mCubeRotXFadeOut = ss->mCubeRotX;
924+ ss->mCubeRotVFadeOut = ss->mCubeRotV;
925+
926+ ScreenEffect::disable ();
927+}
928+
929+void ScreenRotatingCube::clean ()
930+{
931+ ss->cubeScreen->rotationState (CubeScreen::RotationNone);
932+}
933+
934+void ScreenRotatingCube::cubeGetRotation (float& x, float& v, float &progress)
935+{
936+ ScreenEffect::cubeGetRotation (x, v, progress);
937+
938+ x += ss->mCubeRotX;
939+ v += ss->mCubeRotV;
940+ progress = MAX (progress, ss->mCubeProgress);
941+}
942+
943+void ScreenRotatingCube::preparePaint (int msSinceLastPaint)
944+{
945+ ScreenEffect::preparePaint (msSinceLastPaint);
946+
947+ float rotX = ss->optionGetCubeRotationSpeed () / 100.0;
948+
949+ if (ss->mState.fadingIn)
950+ {
951+ rotX *= getProgress();
952+ ss->mZCamera = -ss->optionGetCubeZoom() * getProgress();
953+ ss->mCubeProgress = getProgress();
954+ }
955+ else if (ss->mState.fadingOut)
956+ {
957+ ss->mZCamera = ss->mZCameraFadeOut * (1 - getProgress());
958+ ss->mCubeRotX = ss->mCubeRotXFadeOut * (1 - getProgress());
959+ ss->mCubeRotV = ss->mCubeRotVFadeOut * (1 - getProgress());
960+ ss->mCubeProgress = 1 - getProgress();
961+ }
962+
963+ if (!ss->mState.fadingOut)
964+ {
965+ float rotV = 0.0;
966+ ss->mCubeRotX += rotX * msSinceLastPaint;
967+ ss->mCubeRotV += rotV * msSinceLastPaint;
968+ }
969+
970+ if (ss->mCubeRotX > 180.0)
971+ ss->mCubeRotX -= 360.0;
972+
973+ if (ss->mCubeRotX < -180.0)
974+ ss->mCubeRotX += 360.0;
975+}
976+
977+void ScreenRotatingCube::donePaint()
978+{
979+ ss->cScreen->damageScreen();
980+ ScreenEffect::donePaint();
981+}
982+
983+bool ScreenRotatingCube::glPaintOutput (const GLScreenPaintAttrib &attrib,
984+ const GLMatrix &transform,
985+ const CompRegion &region,
986+ CompOutput *output,
987+ unsigned int mask)
988+{
989+ GLScreenPaintAttrib sA (attrib);
990+ sA.zCamera += ss->mZCamera;
991+
992+ mask &= ~PAINT_SCREEN_REGION_MASK;
993+ mask |= PAINT_SCREEN_TRANSFORMED_MASK;
994+
995+ return ScreenEffect::glPaintOutput (sA, transform, region, output, mask);
996+}
997
998=== added file 'plugins/screensaver/src/rotatingcube.h'
999--- plugins/screensaver/src/rotatingcube.h 1970-01-01 00:00:00 +0000
1000+++ plugins/screensaver/src/rotatingcube.h 2013-05-12 17:13:30 +0000
1001@@ -0,0 +1,34 @@
1002+#ifndef ROTATINGCUBE_H
1003+#define ROTATINGCUBE_H
1004+
1005+#include "screensaver.h"
1006+
1007+class ScreenRotatingCube : public ScreenEffect
1008+{
1009+ public:
1010+
1011+ ScreenRotatingCube () : ScreenEffect () {}
1012+ virtual ~ScreenRotatingCube () {}
1013+
1014+ virtual bool enable ();
1015+ virtual void disable ();
1016+ virtual void cubeGetRotation (float &x,
1017+ float &v,
1018+ float &progress);
1019+ virtual void preparePaint (int msSinceLastPaint);
1020+ virtual void donePaint ();
1021+ virtual bool glPaintOutput (const GLScreenPaintAttrib &,
1022+ const GLMatrix &,
1023+ const CompRegion &,
1024+ CompOutput *,
1025+ unsigned int );
1026+ protected:
1027+
1028+ virtual void clean ();
1029+
1030+ private:
1031+
1032+ bool loadCubePlugin ();
1033+};
1034+
1035+#endif
1036
1037=== added file 'plugins/screensaver/src/screensaver.cpp'
1038--- plugins/screensaver/src/screensaver.cpp 1970-01-01 00:00:00 +0000
1039+++ plugins/screensaver/src/screensaver.cpp 2013-05-12 17:13:30 +0000
1040@@ -0,0 +1,312 @@
1041+/**
1042+ *
1043+ * Compiz screensaver plugin
1044+ *
1045+ * screensaver.cpp
1046+ *
1047+ * Copyright (c) 2007 Nicolas Viennot <nicolas@viennot.biz>
1048+ *
1049+ * This program is free software; you can redistribute it and/or
1050+ * modify it under the terms of the GNU General Public License
1051+ * as published by the Free Software Foundation; either version 2
1052+ * of the License, or (at your option) any later version.
1053+ *
1054+ * This program is distributed in the hope that it will be useful,
1055+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1056+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1057+ * GNU General Public License for more details.
1058+ *
1059+ **/
1060+
1061+#include <stdlib.h>
1062+#include <string.h>
1063+#include <math.h>
1064+
1065+#include "screensaver.h"
1066+#include "rotatingcube.h"
1067+#include "flyingwindows.h"
1068+
1069+COMPIZ_PLUGIN_20090315 (screensaver, ScreenSaverPluginVTable);
1070+
1071+template <typename _ScreenEffect, typename _WindowEffect>
1072+static void screenSaverEffectInstance ()
1073+{
1074+ SCREENSAVER_SCREEN (screen);
1075+ delete ss->mEffect;
1076+ ss->mEffect = new _ScreenEffect ();
1077+
1078+ foreach (CompWindow *w, screen->windows ())
1079+ {
1080+ SCREENSAVER_WINDOW (w);
1081+ delete sw->mEffect;
1082+ sw->mEffect = new _WindowEffect (w);
1083+ }
1084+}
1085+
1086+void
1087+ScreenSaverScreen::enableEffect ()
1088+{
1089+ enum ScreensaverOptions::Mode mode = (enum ScreensaverOptions::Mode) optionGetMode ();
1090+
1091+ if (mode == ModeFlyingWindows)
1092+ screenSaverEffectInstance <ScreenFlyingWindows, WindowFlyingWindows> ();
1093+
1094+ if (mode == ScreensaverOptions::ModeRotatingCube)
1095+ screenSaverEffectInstance <ScreenRotatingCube, WindowEffect> ();
1096+
1097+ mTime = 0;
1098+
1099+ if (!mEffect->enable ())
1100+ {
1101+ fprintf (stderr, "Fail\n");
1102+ screenSaverEffectInstance <ScreenEffect, WindowEffect> ();
1103+ return;
1104+ }
1105+
1106+ mState.fadingOut = false;
1107+ mState.fadingIn = true;
1108+ mState.running = true;
1109+}
1110+
1111+void
1112+ScreenSaverScreen::disableEffect ()
1113+{
1114+ mEffect->disable ();
1115+ mTime = 0;
1116+
1117+ mState.fadingOut = true;
1118+ mState.fadingIn = false;
1119+}
1120+
1121+void
1122+ScreenSaverScreen::cleanEffect ()
1123+{
1124+ screenSaverEffectInstance <ScreenEffect, WindowEffect> ();
1125+}
1126+
1127+void
1128+ScreenSaverScreen::setState (bool enable)
1129+{
1130+ if (!mState.running && enable)
1131+ mEffect->loadEffect = true;
1132+
1133+ if (mState.running && !enable && !mState.fadingOut)
1134+ disableEffect ();
1135+}
1136+
1137+bool
1138+ScreenSaverScreen::initiate (CompAction *action,
1139+ CompAction::State state,
1140+ CompOption::Vector options)
1141+{
1142+ setState (!mState.running);
1143+ return true;
1144+}
1145+
1146+void
1147+ScreenSaverScreen::cubeGetRotation (float &x, float &v, float &progress)
1148+{
1149+ mEffect->cubeGetRotation (x, v, progress);
1150+}
1151+
1152+bool
1153+ScreenSaverWindow::glPaint (const GLWindowPaintAttrib &attrib,
1154+ const GLMatrix &transform,
1155+ const CompRegion &region,
1156+ unsigned int mask)
1157+{
1158+ return mEffect->glPaint (attrib, transform, region, mask);
1159+}
1160+
1161+bool
1162+ScreenSaverScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
1163+ const GLMatrix &transform,
1164+ const CompRegion &region,
1165+ CompOutput *output,
1166+ unsigned int mask)
1167+{
1168+ return mEffect->glPaintOutput (attrib, transform, region, output, mask);
1169+}
1170+
1171+void
1172+ScreenSaverScreen::preparePaint (int ms)
1173+{
1174+ mEffect->preparePaint (ms);
1175+}
1176+
1177+void
1178+ScreenSaverScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
1179+ const GLMatrix &transform,
1180+ const CompRegion &region,
1181+ CompOutput *output,
1182+ unsigned int mask)
1183+{
1184+ mEffect->glPaintTransformedOutput (attrib, transform, region, output, mask);
1185+}
1186+
1187+void
1188+ScreenSaverScreen::donePaint ()
1189+{
1190+ mEffect->donePaint ();
1191+}
1192+
1193+void
1194+ScreenSaverScreen::handleEvent (XEvent *event)
1195+{
1196+ XScreenSaverNotifyEvent *xssEvent;
1197+
1198+ mEffect->handleEvent (event);
1199+
1200+ switch ((event->type & 0x7F) - mXSSContext.first_event)
1201+ {
1202+ case ScreenSaverNotify:
1203+ xssEvent = (XScreenSaverNotifyEvent *) event;
1204+ setState (xssEvent->state);
1205+ break;
1206+
1207+ default:
1208+ break;
1209+ }
1210+
1211+ if (mEffect->loadEffect)
1212+ {
1213+ mEffect->loadEffect = false;
1214+ enableEffect ();
1215+ }
1216+ else if (mEffect->cleanEffect)
1217+ {
1218+ mEffect->cleanEffect = false;
1219+ cleanEffect ();
1220+ }
1221+}
1222+
1223+void
1224+ScreenSaverScreen::paint (CompOutput::ptrList &outputs,
1225+ unsigned int mask)
1226+{
1227+ mEffect->paint (outputs, mask);
1228+}
1229+
1230+void
1231+ScreenSaverScreen::setXScreenSaver (bool enabled)
1232+{
1233+ Window root = screen->root ();
1234+
1235+ if (enabled && !mXSSContext.init)
1236+ {
1237+ int dummy;
1238+ long unsigned int mask = 0;
1239+ XSetWindowAttributes attr;
1240+
1241+ if (!XScreenSaverQueryExtension (screen->dpy (), &mXSSContext.first_event, &dummy))
1242+ {
1243+ compLogMessage ("screensaver", CompLogLevelWarn,
1244+ "XScreenSaver Extension not available, cannot integrate with "\
1245+ "desktop settings!");
1246+ return;
1247+ }
1248+
1249+ mXSSContext.init = true;
1250+
1251+ XGetScreenSaver (screen->dpy (), &mXSSContext.timeout, &mXSSContext.interval,
1252+ &mXSSContext.prefer_blanking, &mXSSContext.allow_exposures);
1253+ XSetScreenSaver (screen->dpy (), (int) (optionGetAfter () * 60.0), mXSSContext.interval, 0, AllowExposures);
1254+
1255+ XScreenSaverSetAttributes (screen->dpy (), root, -100, -100, 1, 1, 0,
1256+ CopyFromParent, CopyFromParent,
1257+ DefaultVisual (screen->dpy (), screen->screenNum ()), mask, &attr);
1258+
1259+ XScreenSaverSelectInput (screen->dpy (), root, ScreenSaverNotifyMask);
1260+
1261+ }
1262+ if (!enabled && mXSSContext.init)
1263+ {
1264+ mXSSContext.init = false;
1265+
1266+ XSetScreenSaver (screen->dpy (), mXSSContext.timeout, mXSSContext.interval,
1267+ mXSSContext.prefer_blanking, mXSSContext.allow_exposures);
1268+
1269+ XScreenSaverSelectInput (screen->dpy (), root, 0);
1270+ XScreenSaverUnsetAttributes (screen->dpy (), root);
1271+ }
1272+}
1273+
1274+void
1275+ScreenSaverScreen::optionChanged (CompOption *opt,
1276+ ScreensaverOptions::Options num)
1277+{
1278+ setXScreenSaver (false);
1279+ setXScreenSaver (optionGetStartAutomatically ());
1280+}
1281+
1282+ScreenSaverWindow::ScreenSaverWindow (CompWindow *w) :
1283+ PluginClassHandler <ScreenSaverWindow, CompWindow> (w),
1284+ mEffect (NULL),
1285+ window (w),
1286+ cWindow (CompositeWindow::get (w)),
1287+ gWindow (GLWindow::get (w))
1288+{
1289+ ScreenSaverScreen *ss = ScreenSaverScreen::get (screen);
1290+
1291+ if(ss->mState.running &&
1292+ (enum ScreensaverOptions::Mode) ss->optionGetMode() == ScreensaverOptions::ModeFlyingWindows)
1293+ mEffect = new WindowFlyingWindows (w);
1294+ else
1295+ mEffect = new WindowEffect (w);
1296+
1297+ GLWindowInterface::setHandler (gWindow);
1298+}
1299+
1300+ScreenSaverWindow::~ScreenSaverWindow ()
1301+{
1302+ delete mEffect;
1303+}
1304+
1305+ScreenSaverScreen::ScreenSaverScreen (CompScreen *s) :
1306+ PluginClassHandler <ScreenSaverScreen, CompScreen> (s),
1307+ cScreen (CompositeScreen::get (screen)),
1308+ gScreen (GLScreen::get (screen)),
1309+ cubeScreen (CubeScreen::get (screen)),
1310+ mEffect (new ScreenEffect ()),
1311+ mDesktopOpacity (OPAQUE)
1312+{
1313+ ScreenInterface::setHandler (screen);
1314+ GLScreenInterface::setHandler (gScreen);
1315+ CompositeScreenInterface::setHandler (cScreen);
1316+ CubeScreenInterface::setHandler (cubeScreen);
1317+
1318+ mState.running = false;
1319+ mState.fadingOut = false;
1320+ mState.fadingIn = false;
1321+
1322+ optionSetInitiateKeyInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3));
1323+ optionSetInitiateButtonInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3));
1324+ optionSetInitiateEdgeInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3));
1325+
1326+ optionSetStartAutomaticallyNotify (boost::bind (&ScreenSaverScreen::optionChanged, this, _1, _2));
1327+ optionSetAfterNotify (boost::bind (&ScreenSaverScreen::optionChanged, this, _1, _2));
1328+
1329+ mXSSContext.init = false;
1330+
1331+ mEffect->loadEffect = false;
1332+ mEffect->cleanEffect = false;
1333+
1334+ setXScreenSaver (optionGetStartAutomatically ());
1335+}
1336+
1337+ScreenSaverScreen::~ScreenSaverScreen ()
1338+{
1339+ delete mEffect;
1340+}
1341+
1342+bool
1343+ScreenSaverPluginVTable::init ()
1344+{
1345+ if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) &&
1346+ CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) &&
1347+ CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) &&
1348+ CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI))
1349+ return true;
1350+
1351+ return false;
1352+}
1353
1354=== added file 'plugins/screensaver/src/screensaver.h'
1355--- plugins/screensaver/src/screensaver.h 1970-01-01 00:00:00 +0000
1356+++ plugins/screensaver/src/screensaver.h 2013-05-12 17:13:30 +0000
1357@@ -0,0 +1,258 @@
1358+#ifndef SCREENSAVER_INTERNAL_H
1359+#define SCREENSAVER_INTERNAL_H
1360+
1361+#include <core/core.h>
1362+#include <composite/composite.h>
1363+#include <opengl/opengl.h>
1364+#include <cube/cube.h>
1365+
1366+/* libxss-dev is needed, on Ubuntu: sudo apt-get install libxss-dev */
1367+#include <X11/extensions/scrnsaver.h>
1368+
1369+#include "screensaver_options.h"
1370+#include "matrix.h"
1371+#include "vector.h"
1372+
1373+#define WIN_X(w) ((w)->x () - (w)->input ().left)
1374+#define WIN_Y(w) ((w)->y () - (w)->input ().top)
1375+#define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right)
1376+#define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom)
1377+
1378+extern int displayPrivateIndex;
1379+
1380+class ScreenSaverScreen;
1381+class ScreenSaverWindow;
1382+
1383+class ScreenWrapper
1384+{
1385+ public:
1386+
1387+ ScreenWrapper ();
1388+ ~ScreenWrapper () {}
1389+
1390+ virtual void cubeGetRotation (float& x, float& v, float &progress);
1391+ virtual void handleEvent (XEvent *);
1392+ virtual void preparePaint (int);
1393+ virtual void donePaint ();
1394+ virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &,
1395+ const GLMatrix &,
1396+ const CompRegion &,
1397+ CompOutput *,
1398+ unsigned int );
1399+ virtual bool glPaintOutput (const GLScreenPaintAttrib &,
1400+ const GLMatrix &,
1401+ const CompRegion &,
1402+ CompOutput *,
1403+ unsigned int );
1404+ virtual void paint (CompOutput::ptrList &,
1405+ unsigned int );
1406+
1407+ protected:
1408+
1409+ CompScreen* s;
1410+ ScreenSaverScreen* ss;
1411+};
1412+
1413+class WindowWrapper
1414+{
1415+ public:
1416+
1417+ WindowWrapper (CompWindow* w);
1418+ virtual ~WindowWrapper () {}
1419+ virtual bool glPaint (const GLWindowPaintAttrib &,
1420+ const GLMatrix &,
1421+ const CompRegion &,
1422+ unsigned int );
1423+ protected:
1424+
1425+ CompWindow* w;
1426+ ScreenSaverWindow* sw;
1427+};
1428+
1429+class ScreenEffect : public ScreenWrapper
1430+{
1431+ public:
1432+
1433+ ScreenEffect() : ScreenWrapper(), progress (0) {}
1434+ virtual ~ScreenEffect() {}
1435+ float getProgress() { return progress; }
1436+ virtual void handleEvent (XEvent *event);
1437+
1438+ virtual bool enable ();
1439+ virtual void disable () {}
1440+ virtual void preparePaint (int msSinceLastPaint);
1441+ virtual void cubeGetRotation (float &, float &, float &); // TODO: get rid of this!
1442+
1443+ bool cleanEffect;
1444+ bool loadEffect;
1445+
1446+ protected:
1447+
1448+ virtual void clean () {}
1449+
1450+ private:
1451+
1452+ float progress;
1453+};
1454+
1455+class WindowEffect : public WindowWrapper
1456+{
1457+ public:
1458+
1459+ WindowEffect (CompWindow* w) : WindowWrapper (w) {}
1460+ virtual ~WindowEffect () {}
1461+};
1462+
1463+class ScreenSaver
1464+{
1465+ public:
1466+
1467+ class State
1468+ {
1469+ public:
1470+ // when the screensaver is enabled, running and fadingIn are set to true
1471+ // then, after fadingInDuration, fadingIn is set to false
1472+ // when the screensaver is requested to stop, fadingOut is set to true
1473+ // after fadingOutDuration, running is set to false
1474+ bool running;
1475+ bool fadingOut;
1476+ bool fadingIn;
1477+ };
1478+
1479+ class XSSContext
1480+ {
1481+ public:
1482+
1483+ int timeout;
1484+ int interval;
1485+ int prefer_blanking;
1486+ int allow_exposures;
1487+ int first_event;
1488+ bool init;
1489+ };
1490+};
1491+
1492+class ScreenSaverScreen :
1493+ public PluginClassHandler <ScreenSaverScreen, CompScreen>,
1494+ public ScreenInterface,
1495+ public CompositeScreenInterface,
1496+ public GLScreenInterface,
1497+ public CubeScreenInterface,
1498+ public ScreensaverOptions
1499+{
1500+ public:
1501+
1502+ ScreenSaverScreen (CompScreen *s);
1503+ ~ScreenSaverScreen ();
1504+
1505+ public:
1506+
1507+ CompositeScreen *cScreen;
1508+ GLScreen *gScreen;
1509+ CubeScreen *cubeScreen;
1510+
1511+ ScreenSaver::State mState;
1512+ ScreenSaver::XSSContext mXSSContext;
1513+
1514+ ScreenEffect *mEffect;
1515+
1516+ void
1517+ cubeGetRotation (float &x,
1518+ float &v,
1519+ float &progress);
1520+
1521+ void
1522+ handleEvent (XEvent *);
1523+
1524+ void
1525+ preparePaint (int);
1526+
1527+ void
1528+ donePaint ();
1529+
1530+ void
1531+ glPaintTransformedOutput (const GLScreenPaintAttrib &,
1532+ const GLMatrix &,
1533+ const CompRegion &,
1534+ CompOutput *,
1535+ unsigned int );
1536+
1537+ bool glPaintOutput (const GLScreenPaintAttrib &,
1538+ const GLMatrix &,
1539+ const CompRegion &,
1540+ CompOutput *,
1541+ unsigned int );
1542+
1543+ void
1544+ paint (CompOutput::ptrList &outputs,
1545+ unsigned int mask);
1546+
1547+ void enableEffect ();
1548+
1549+ void disableEffect ();
1550+
1551+ void cleanEffect ();
1552+
1553+ void setState (bool);
1554+
1555+ bool initiate (CompAction *, CompAction::State, CompOption::Vector);
1556+
1557+ void setXScreenSaver (bool);
1558+ void optionChanged (CompOption *, ScreensaverOptions::Options);
1559+
1560+ int mTime;
1561+ float mCubeRotX;
1562+ float mCubeRotV;
1563+ float mCubeProgress;
1564+ float mZCamera;
1565+
1566+ float mCubeRotXFadeOut;
1567+ float mCubeRotVFadeOut;
1568+ float mZCameraFadeOut;
1569+
1570+ Point mScreenCenter;
1571+ Matrix mCamera;
1572+ Matrix mCameraMat;
1573+
1574+ float mAngleCam;
1575+ GLushort mDesktopOpacity;
1576+};
1577+
1578+class ScreenSaverWindow :
1579+ public PluginClassHandler <ScreenSaverWindow, CompWindow>,
1580+ public GLWindowInterface
1581+{
1582+ public:
1583+
1584+ ScreenSaverWindow (CompWindow *w);
1585+ ~ScreenSaverWindow ();
1586+
1587+ WindowEffect *mEffect;
1588+
1589+ bool
1590+ glPaint (const GLWindowPaintAttrib &,
1591+ const GLMatrix &,
1592+ const CompRegion &,
1593+ unsigned int );
1594+
1595+ CompWindow *window;
1596+ CompositeWindow *cWindow;
1597+ GLWindow *gWindow;
1598+
1599+};
1600+
1601+#define SCREENSAVER_SCREEN(s) \
1602+ ScreenSaverScreen *ss = ScreenSaverScreen::get (s);
1603+
1604+#define SCREENSAVER_WINDOW(w) \
1605+ ScreenSaverWindow *sw = ScreenSaverWindow::get (w);
1606+
1607+class ScreenSaverPluginVTable :
1608+ public CompPlugin::VTableForScreenAndWindow <ScreenSaverScreen, ScreenSaverWindow>
1609+{
1610+ public:
1611+
1612+ bool init ();
1613+};
1614+
1615+#endif
1616
1617=== added file 'plugins/screensaver/src/vector.cpp'
1618--- plugins/screensaver/src/vector.cpp 1970-01-01 00:00:00 +0000
1619+++ plugins/screensaver/src/vector.cpp 2013-05-12 17:13:30 +0000
1620@@ -0,0 +1,14 @@
1621+#include "vector.h"
1622+
1623+const Vector Vector::null (0.0, 0.0, 0.0);
1624+
1625+Vector operator^ (const Vector& lhs, const Vector& rhs)
1626+{
1627+ Vector res;
1628+
1629+ res[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1];
1630+ res[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2];
1631+ res[2] = lhs[0] * rhs[1] - lhs[1] * rhs[0];
1632+
1633+ return res;
1634+}
1635
1636=== added file 'plugins/screensaver/src/vector.h'
1637--- plugins/screensaver/src/vector.h 1970-01-01 00:00:00 +0000
1638+++ plugins/screensaver/src/vector.h 2013-05-12 17:13:30 +0000
1639@@ -0,0 +1,164 @@
1640+#ifndef VECTOR_H
1641+#define VECTOR_H
1642+
1643+#include <core/core.h>
1644+#include <opengl/opengl.h>
1645+#include <cmath>
1646+
1647+typedef enum
1648+{
1649+ x,
1650+ y,
1651+ z
1652+} VectorCoordsEnum;
1653+
1654+class Vector
1655+{
1656+ public:
1657+ static const Vector null;
1658+
1659+ Vector ()
1660+ {
1661+ for (int i = 0; i < 3; ++i)
1662+ v[i] = 0;
1663+ }
1664+
1665+ Vector (float x, float y, float z) { v[0] = x; v[1] = y; v[2] = z; }
1666+ Vector (const float* vect) { v[0] = vect[0]; v[1] = vect[1]; v[2] = vect[2]; }
1667+ Vector (const Vector& vect) { v[0] = vect[0]; v[1] = vect[1]; v[2] = vect[2]; }
1668+
1669+ float norm () { return sqrt ((*this) * (*this)); }
1670+
1671+ Vector& normalize ()
1672+ {
1673+ float n = norm ();
1674+
1675+ if (n == 0.0)
1676+ v[x] = v[y] = v[z] = 1.0;
1677+ else
1678+ *this /= n;
1679+
1680+ return *this;
1681+ }
1682+
1683+ Vector toScreenSpace () const
1684+ {
1685+ Vector res;
1686+ res[0] = v[0] / screen->width () - 0.5;
1687+ res[1] = 0.5 - v[1] / screen->height ();
1688+ res[2] = v[2];
1689+ return res;
1690+ }
1691+
1692+ Vector toCoordsSpace () const
1693+ {
1694+ Vector res;
1695+ res[0] = (v[0] + 0.5) * screen->width ();
1696+ res[1] = (0.5 - v[1]) * screen->height ();
1697+ res[2] = v[2];
1698+ return res;
1699+ }
1700+
1701+ float& operator[] (int i) { return v[i]; }
1702+ const float& operator[] (int i) const { return v[i]; }
1703+ float& operator[] (VectorCoordsEnum c) { return v[(int)c]; }
1704+ const float& operator[] (VectorCoordsEnum c) const { return v[(int)c]; }
1705+
1706+ Vector& operator+= (const Vector& rhs)
1707+ {
1708+ v[0] += rhs[0];
1709+ v[1] += rhs[1];
1710+ v[2] += rhs[2];
1711+ return *this;
1712+ }
1713+
1714+ friend Vector operator+ (const Vector& lhs, const Vector& rhs)
1715+ {
1716+ Vector res;
1717+ res[0] = lhs[0] + rhs[0];
1718+ res[1] = lhs[1] + rhs[1];
1719+ res[2] = lhs[2] + rhs[2];
1720+ return res;
1721+ }
1722+
1723+ Vector& operator-= (const Vector& rhs)
1724+ {
1725+ v[0] -= rhs[0];
1726+ v[1] -= rhs[1];
1727+ v[2] -= rhs[2];
1728+ return *this;
1729+ }
1730+
1731+ friend Vector operator- (const Vector& lhs, const Vector& rhs)
1732+ {
1733+ Vector res;
1734+ res[0] = lhs[0] - rhs[0];
1735+ res[1] = lhs[1] - rhs[1];
1736+ res[2] = lhs[2] - rhs[2];
1737+ return res;
1738+ }
1739+
1740+ friend Vector operator- (const Vector& vect)
1741+ {
1742+ Vector res;
1743+ res[0] = -vect[0];
1744+ res[1] = -vect[1];
1745+ res[2] = -vect[2];
1746+ return res;
1747+ }
1748+
1749+ Vector& operator*= (const float k)
1750+ {
1751+ v[0] *= k;
1752+ v[1] *= k;
1753+ v[2] *= k;
1754+ return *this;
1755+ }
1756+
1757+ friend float operator* (const Vector& lhs, const Vector& rhs)
1758+ {
1759+ return lhs[0] * rhs[0] + lhs[1] * rhs[1] + lhs[2] * rhs[2];
1760+ }
1761+
1762+ friend Vector operator* (const float k, const Vector& vect)
1763+ {
1764+ Vector res;
1765+ res[0] = k * vect[0];
1766+ res[1] = k * vect[1];
1767+ res[2] = k * vect[2];
1768+ return res;
1769+ }
1770+
1771+ friend Vector operator* (const Vector& v, const float k) { return k*v; }
1772+
1773+ Vector& operator/= (const float k)
1774+ {
1775+ v[0] /= k;
1776+ v[1] /= k;
1777+ v[2] /= k;
1778+ return *this;
1779+ }
1780+
1781+ friend Vector operator/ (const Vector& vect, const float k)
1782+ {
1783+ Vector res;
1784+ res[0] = vect[0] / k;
1785+ res[1] = vect[1] / k;
1786+ res[2] = vect[2] / k;
1787+ return res;
1788+ }
1789+
1790+ Vector& operator^= (const Vector& vect)
1791+ {
1792+ *this = *this ^ vect;
1793+ return *this;
1794+ }
1795+
1796+ friend Vector operator^ (const Vector& lhs, const Vector& rhs);
1797+
1798+ float v[3];
1799+};
1800+
1801+typedef Vector Point;
1802+
1803+#endif
1804
1805=== added file 'plugins/screensaver/src/wrapper.cpp'
1806--- plugins/screensaver/src/wrapper.cpp 1970-01-01 00:00:00 +0000
1807+++ plugins/screensaver/src/wrapper.cpp 2013-05-12 17:13:30 +0000
1808@@ -0,0 +1,67 @@
1809+#include "screensaver.h"
1810+
1811+void ScreenWrapper::handleEvent (XEvent *event)
1812+{
1813+ screen->handleEvent (event);
1814+}
1815+
1816+ScreenWrapper::ScreenWrapper ()
1817+{
1818+ SCREENSAVER_SCREEN (screen);
1819+ this->s = screen;
1820+ this->ss = ss;
1821+}
1822+
1823+void ScreenWrapper::cubeGetRotation (float& x, float& v, float &progress)
1824+{
1825+ ss->cubeScreen->cubeGetRotation (x, v, progress);
1826+}
1827+
1828+void ScreenWrapper::preparePaint (int msSinceLastPaint )
1829+{
1830+ ss->cScreen->preparePaint (msSinceLastPaint);
1831+}
1832+
1833+void ScreenWrapper::donePaint ()
1834+{
1835+ ss->cScreen->donePaint ();
1836+}
1837+
1838+void ScreenWrapper::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
1839+ const GLMatrix &transform,
1840+ const CompRegion &region,
1841+ CompOutput *output,
1842+ unsigned int mask)
1843+{
1844+ ss->gScreen->glPaintTransformedOutput (attrib, transform, region, output, mask);
1845+}
1846+
1847+bool ScreenWrapper::glPaintOutput (const GLScreenPaintAttrib &attrib,
1848+ const GLMatrix &transform,
1849+ const CompRegion &region,
1850+ CompOutput *output,
1851+ unsigned int mask)
1852+{
1853+ return ss->gScreen->glPaintOutput (attrib, transform, region, output, mask);
1854+}
1855+
1856+void ScreenWrapper::paint (CompOutput::ptrList &outputs,
1857+ unsigned int mask)
1858+{
1859+ ss->cScreen->paint (outputs, mask);
1860+}
1861+
1862+WindowWrapper::WindowWrapper (CompWindow* w)
1863+{
1864+ SCREENSAVER_WINDOW (w);
1865+ this->w = w;
1866+ this->sw = sw;
1867+}
1868+
1869+bool WindowWrapper::glPaint (const GLWindowPaintAttrib &attrib,
1870+ const GLMatrix &transform,
1871+ const CompRegion &region,
1872+ unsigned int mask)
1873+{
1874+ return sw->gWindow->glPaint (attrib, transform, region, mask);
1875+}
1876
1877=== added file 'plugins/screensaver/src/wrapper.h'
1878--- plugins/screensaver/src/wrapper.h 1970-01-01 00:00:00 +0000
1879+++ plugins/screensaver/src/wrapper.h 2013-05-12 17:13:30 +0000
1880@@ -0,0 +1,4 @@
1881+#ifndef WRAPPER_H
1882+#define WRAPPER_H
1883+
1884+#endif

Subscribers

People subscribed via source and target branches

to all changes: