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
=== modified file 'debian/compiz-plugins.install'
--- debian/compiz-plugins.install 2013-02-26 16:48:27 +0000
+++ debian/compiz-plugins.install 2013-05-12 17:13:30 +0000
@@ -32,6 +32,7 @@
32debian/tmp/usr/*/compiz/*rotate.*32debian/tmp/usr/*/compiz/*rotate.*
33debian/tmp/usr/*/compiz/*scaleaddon.*33debian/tmp/usr/*/compiz/*scaleaddon.*
34debian/tmp/usr/*/compiz/*scalefilter.*34debian/tmp/usr/*/compiz/*scalefilter.*
35debian/tmp/usr/*/compiz/*screensaver.*
35debian/tmp/usr/*/compiz/*screenshot.*36debian/tmp/usr/*/compiz/*screenshot.*
36debian/tmp/usr/*/compiz/*shelf.*37debian/tmp/usr/*/compiz/*shelf.*
37debian/tmp/usr/*/compiz/*shift.*38debian/tmp/usr/*/compiz/*shift.*
3839
=== modified file 'plugins/CMakeLists.txt'
--- plugins/CMakeLists.txt 2013-03-08 18:42:22 +0000
+++ plugins/CMakeLists.txt 2013-05-12 17:13:30 +0000
@@ -31,6 +31,7 @@
31 set (COMPIZ_DISABLE_PLUGIN_BENCH ON)31 set (COMPIZ_DISABLE_PLUGIN_BENCH ON)
32 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)32 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)
33 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)33 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)
34 set (COMPIZ_DISABLE_PLUGIN_SCREENSAVER ON)
34 set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)35 set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)
35 set (COMPIZ_DISABLE_PLUGIN_WIZARD ON)36 set (COMPIZ_DISABLE_PLUGIN_WIZARD ON)
3637
3738
=== added directory 'plugins/screensaver'
=== added file 'plugins/screensaver/CMakeLists.txt'
--- plugins/screensaver/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/CMakeLists.txt 2013-05-12 17:13:30 +0000
@@ -0,0 +1,5 @@
1find_package (Compiz REQUIRED)
2
3include (CompizPlugin)
4
5compiz_plugin (screensaver PLUGINDEPS composite opengl cube PKGDEPS xscrnsaver)
06
=== added file 'plugins/screensaver/screensaver.xml.in'
--- plugins/screensaver/screensaver.xml.in 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/screensaver.xml.in 2013-05-12 17:13:30 +0000
@@ -0,0 +1,132 @@
1<?xml version="1.0"?>
2<compiz>
3 <plugin name="screensaver" useBcop="true">
4 <_short>Screen Saver</_short>
5 <_long>Let windows take flight or the cube rotate</_long>
6 <deps>
7 <requirement>
8 <plugin>opengl</plugin>
9 <plugin>cube</plugin>
10 </requirement>
11 <relation type="after">
12 <plugin>opengl</plugin>
13 <plugin>cube</plugin>
14 </relation>
15 </deps>
16 <category>Extras</category>
17 <options>
18 <group>
19 <_short>Bindings</_short>
20 <option name="initiate_key" type="key">
21 <_short>Initiate Key</_short>
22 <_long>Key to manually start and stop the screensaver.</_long>
23 </option>
24 <option name="initiate_button" type="button">
25 <_short>Initiate Button</_short>
26 <_long>Mouse button to start and stop the screensaver.</_long>
27 </option>
28 <option name="initiate_edge" type="edge">
29 <_short>Initiate Corner / Edge</_short>
30 <_long>Start and stop the screensaver via screen corner or edge.</_long>
31 </option>
32 </group>
33 <option name="mode" type="int">
34 <_short>Screensaver Mode</_short>
35 <_long>Choose between flying windows or rotating cube as screensaver.</_long>
36 <default>0</default>
37 <min>0</min>
38 <max>1</max>
39 <desc>
40 <value>0</value>
41 <name>Flying Windows</name>
42 </desc>
43 <desc>
44 <value>1</value>
45 <name>Rotating Cube</name>
46 </desc>
47 </option>
48 <option name="start_automatically" type="bool">
49 <_short>Start Automatically</_short>
50 <_long>Start the chosen screensaver after a specified time period.</_long>
51 <default>true</default>
52 </option>
53 <option name="after" type="float">
54 <_short>After (min)</_short>
55 <_long>Amount of time before the screensaver starts automatically (in minutes).</_long>
56 <default>5.0</default>
57 <min>0.1</min>
58 <max>1000.0</max>
59 <precision>0.01</precision>
60 </option>
61 <option name="fade_in_duration" type="float">
62 <_short>Fade In Duration (sec)</_short>
63 <_long>Length of the fade in (in seconds).</_long>
64 <default>3.0</default>
65 <min>0.0</min>
66 <max>10.0</max>
67 <precision>0.01</precision>
68 </option>
69 <option name="fade_out_duration" type="float">
70 <_short>Fade Out Duration (sec)</_short>
71 <_long>Length of the fade out (in seconds).</_long>
72 <default>1.0</default>
73 <min>0.0</min>
74 <max>10.0</max>
75 <precision>0.01</precision>
76 </option>
77 <group>
78 <_short>Flying Windows</_short>
79 <option name="window_match" type="match">
80 <_short>Screen Saver Windows</_short>
81 <_long>The window types which should fly.</_long>
82 <default>type=Normal | Dialog | ModalDialog | Utility | Unknown</default>
83 </option>
84 <option name="mipmaps" type="bool">
85 <_short>Mipmaps</_short>
86 <_long>Generate mipmaps for higher quality scaling.</_long>
87 <default>false</default>
88 </option>
89 <option name="attraction_depth" type="float">
90 <_short>Attraction Depth</_short>
91 <_long>Attraction depth of the windows.</_long>
92 <default>1.5</default>
93 <min>0.0</min>
94 <max>10.0</max>
95 <precision>0.01</precision>
96 </option>
97 <option name="attraction_repulsion_ratio" type="float">
98 <_short>Attraction / Repulsion Ratio</_short>
99 <_long>Attraction/Repulsion ratio of the windows.</_long>
100 <default>50.0</default>
101 <min>0.0</min>
102 <max>100.0</max>
103 <precision>0.01</precision>
104 </option>
105 <option name="bounce" type="bool">
106 <_short>Bounce</_short>
107 <_long>Make windows bounce on the floor, still buggy, but essential with cube reflexion.</_long>
108 <default>true</default>
109 </option>
110 </group>
111 <group>
112 <_short>Rotating Cube</_short>
113 <option name="cube_rotation_speed" type="float">
114 <_short>Cube Rotation Speed</_short>
115 <_long>The speed of the cube's rotation.</_long>
116 <default>1.0</default>
117 <min>-10.0</min>
118 <max>10.0</max>
119 <precision>0.01</precision>
120 </option>
121 <option name="cube_zoom" type="float">
122 <_short>Zoom</_short>
123 <_long>The zoom applied.</_long>
124 <default>0.5</default>
125 <min>0.0</min>
126 <max>2.0</max>
127 <precision>0.1</precision>
128 </option>
129 </group>
130 </options>
131 </plugin>
132</compiz>
0133
=== added directory 'plugins/screensaver/src'
=== added file 'plugins/screensaver/src/effect.cpp'
--- plugins/screensaver/src/effect.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/effect.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,63 @@
1#include "screensaver.h"
2#include <cmath>
3
4#define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5))))
5#define sigmoidProgress(x) ((sigmoid(x) - sigmoid(0)) / (sigmoid(1) - sigmoid(0)))
6
7void
8ScreenEffect::handleEvent (XEvent *event)
9{
10 ScreenWrapper::handleEvent (event);
11}
12
13void
14ScreenEffect::cubeGetRotation (float &x, float &v, float &progress)
15{
16 ScreenWrapper::cubeGetRotation (x, v, progress);
17}
18
19bool ScreenEffect::enable ()
20{
21 progress = 0.0;
22 return true;
23}
24
25void ScreenEffect::preparePaint (int msSinceLastPaint)
26{
27 if (ss->mState.running)
28 {
29 if (ss->mState.fadingIn)
30 {
31 float fadeDuration = ss->optionGetFadeInDuration () * 1000.0;
32 progress = sigmoidProgress (((float)ss->mTime) / fadeDuration);
33 ss->mTime += msSinceLastPaint;
34
35 if (ss->mTime >= fadeDuration)
36 {
37 if (ss->optionGetStartAutomatically ())
38 XActivateScreenSaver(screen->dpy ());
39
40 ss->mState.fadingIn = FALSE;
41 ss->mTime = 0;
42 }
43 }
44 else if (ss->mState.fadingOut)
45 {
46 float fadeDuration = ss->optionGetFadeOutDuration () * 1000.0;
47 progress = sigmoidProgress (((float)ss->mTime) / fadeDuration);
48 ss->mTime += msSinceLastPaint;
49
50 if (ss->mTime >= fadeDuration)
51 {
52 clean ();
53 ss->mEffect->cleanEffect = true;
54 ss->mState.running = FALSE;
55 ss->cScreen->damageScreen ();
56 }
57 }
58 else
59 progress = 1.0;
60 }
61
62 ScreenWrapper::preparePaint (msSinceLastPaint);
63}
064
=== added file 'plugins/screensaver/src/effect.h'
--- plugins/screensaver/src/effect.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/effect.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,6 @@
1#ifndef EFFECT_H
2#define EFFECT_H
3
4#include "screensaver_internal.h"
5
6#endif
07
=== added file 'plugins/screensaver/src/flyingwindows.cpp'
--- plugins/screensaver/src/flyingwindows.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/flyingwindows.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,393 @@
1#include "flyingwindows.h"
2
3#define NE 0
4#define NO 1
5#define SE 2
6#define SO 3
7#define C 4
8
9void ScreenFlyingWindows::handleEvent (XEvent *event)
10{
11 ScreenEffect::handleEvent (event);
12
13 if (event->type == MapNotify)
14 {
15 CompWindow* w = screen->findWindow (event->xmap.window);
16
17 if (w)
18 WindowFlyingWindows::getInstance(w).initWindow();
19 }
20}
21
22bool ScreenFlyingWindows::enable ()
23{
24 ss->mAngleCam = 0.0;
25 ss->mScreenCenter = Vector (0.0, ss->optionGetBounce () ? 0.2 : 0.0,
26 -ss->optionGetAttractionDepth ());
27 ss->mCamera = Matrix::identity;
28 ss->mDesktopOpacity = OPAQUE;
29
30 foreach (CompWindow *w, screen->windows ())
31 {
32 WindowFlyingWindows::getInstance(w).initWindow ();
33 }
34
35 return ScreenEffect::enable ();
36}
37
38void ScreenFlyingWindows::disable ()
39{
40 foreach (CompWindow *w, screen->windows ())
41 {
42 WindowFlyingWindows& sw = WindowFlyingWindows::getInstance (w);
43
44 if (sw.active)
45 sw.transformFadeOut = ss->mCameraMat * sw.transform;
46
47 else sw.opacityFadeOut = sw.opacity;
48 }
49
50 ss->mCameraMat = Matrix::identity;
51 ScreenEffect::disable ();
52}
53
54void ScreenFlyingWindows::addForce (const Point& p1, const Point& p2, const Point& center, Vector& resultante, Vector& couple, float w, bool attract)
55{
56 Vector u = p2 - p1;
57 float d = u.norm ();
58 u.normalize ();
59
60 if (d < 1e-5)
61 d = 1e-5;
62
63 Vector force = attract ? w * u * d * d : -w * u / (d * d);
64 resultante += force;
65
66 couple += (center - p1) ^ force;
67}
68
69void ScreenFlyingWindows::preparePaint (int msSinceLastPaint)
70{
71 ScreenEffect::preparePaint (msSinceLastPaint);
72
73 float ratio = ss->optionGetAttractionRepulsionRatio() / 100.0;
74 float wAt = ratio;
75 float wRt = 1-ratio;
76
77 if (ss->mState.fadingIn)
78 {
79 wAt *= getProgress();
80 wRt *= getProgress();
81
82 ss->mDesktopOpacity = (GLushort)(OPAQUE * (1.0 - getProgress ()));
83 }
84
85 if (ss->mState.fadingOut)
86 ss->mDesktopOpacity = (GLushort)(OPAQUE * getProgress ());
87
88 if (!ss->mState.fadingOut)
89 {
90 ss->mAngleCam += ((float)msSinceLastPaint) / 100000.0;
91
92 if (ss->mAngleCam > 0.03)
93 ss->mAngleCam = 0.03;
94
95 ss->mCamera.rotate (ss->mAngleCam*msSinceLastPaint, 0.0, 1.0, 0.0);
96
97 Matrix centerTrans = Matrix::identity;
98 Matrix centerTransInv = Matrix::identity;
99
100 Vector screenCenterTranslated = ss->mScreenCenter.toCoordsSpace ();
101 screenCenterTranslated[z] *= screen->width ();
102
103 centerTrans.scale (1.0, 1.0, 1.0 / screen->width ());
104 centerTrans.translate (screenCenterTranslated);
105 centerTransInv.translate (-screenCenterTranslated);
106 centerTransInv.scale (1.0, 1.0, 1.0 * screen->width ());
107
108 ss->mCameraMat = centerTrans * ss->mCamera * centerTransInv;
109 }
110
111 foreach (CompWindow *w, screen->windows ())
112 {
113 WindowFlyingWindows& sw = WindowFlyingWindows::getInstance(w);
114
115 if (sw.active)
116 {
117 if (ss->mState.fadingOut)
118 sw.transform = interpolate (sw.transformFadeOut, Matrix::identity, getProgress ());
119 else
120 {
121 int collisionVertex = -1;
122 int collisionIteration = 1;
123 Vector a, p, o, omega;
124
125 do
126 {
127 Vector resultante, couple, resultanteA, coupleA;
128 resultante = couple = resultanteA = coupleA = Vector::null;
129 Vector windowcenter = sw.vertex[C];
130 float mass = sqrt (((float)(WIN_W(w) * WIN_H(w))) / (screen->width () * screen->height ()));
131
132 float wR = 1e-8 / mass * wRt;
133 float wA = 1e-8 / mass * wAt;
134
135 int numPoint = 0;
136
137 for (int i = 0; i < 5; ++i)
138 {
139 foreach (CompWindow *w2, screen->windows ())
140 {
141 WindowFlyingWindows& sw2 = WindowFlyingWindows::getInstance (w2);
142
143 if (w2 != w && sw2.active)
144 {
145 ++numPoint;
146
147 for (int j = 0; j < 5; ++j)
148 addForce (sw.vertex[i], sw2.vertex[j], windowcenter, resultante, couple, wR, FALSE);
149 }
150 }
151
152 addForce (sw.vertex[i], ss->mScreenCenter, windowcenter, resultanteA, coupleA, wA, TRUE);
153 }
154
155 if (numPoint < 1)
156 numPoint = 1;
157
158 resultante += resultanteA*numPoint;
159 couple += coupleA*numPoint;
160
161 if (collisionVertex != -1)
162 {
163 float wb = sw.vertex[collisionVertex][y] / msSinceLastPaint * 5e-4;
164 resultante[y] = -wb;
165 float tmp = couple[z];
166 couple = (sw.vertex[collisionVertex] - windowcenter) ^ Vector (0.0, -wb, 0.0);
167 couple[z] = tmp;
168 sw.speed[y] = 0;
169 }
170
171 a = resultante - 5e-4 * mass * sw.speed;
172 omega = couple * 1000 - 5e-3 * mass * sw.speedrot;
173
174 p = msSinceLastPaint * msSinceLastPaint * a + msSinceLastPaint * sw.speed;
175 sw.speed += msSinceLastPaint * a;
176
177 o = msSinceLastPaint * msSinceLastPaint * omega + msSinceLastPaint * sw.speedrot;
178 sw.speedrot += msSinceLastPaint * omega;
179
180 sw.transformTrans.translate (p[x]*screen->width (), -p[y]*screen->height (), p[z]);
181 sw.transformRot.rotate (o.norm(), o);
182
183 sw.transform = sw.transformTrans * sw.centerTrans * sw.transformRot * sw.centerTransInv;
184
185 sw.recalcVertices ();
186
187 if (ss->optionGetBounce ())
188 for (int i = 0; i < 4; ++i)
189 {
190 if (sw.vertex[i][y] < -0.5)
191 collisionVertex = i;
192 }
193
194 } while (collisionVertex != -1 && --collisionIteration);
195 }
196 }
197 else
198 {
199 if (ss->mState.fadingOut)
200 sw.opacity = (GLushort)(sw.opacityOld * getProgress() +
201 sw.opacityFadeOut * (1 - getProgress()));
202 else
203 sw.steps = (int)((msSinceLastPaint * OPAQUE) /
204 (ss->optionGetFadeInDuration() * 1000.0));
205 }
206 }
207}
208
209void ScreenFlyingWindows::donePaint ()
210{
211 ss->cScreen->damageScreen ();
212 ScreenEffect::donePaint ();
213}
214
215void ScreenFlyingWindows::paint (CompOutput::ptrList &outputs,
216 unsigned int mask)
217{
218 CompOutput::ptrList newOutputs;
219 newOutputs.push_back (&screen->fullscreenOutput ());
220
221 ScreenEffect::paint (newOutputs, mask);
222}
223
224bool
225ScreenFlyingWindows::glPaintOutput(const GLScreenPaintAttrib &attrib,
226 const GLMatrix &transform,
227 const CompRegion &region,
228 CompOutput *output,
229 unsigned int mask)
230{
231 ss->gScreen->clearTargetOutput (GL_COLOR_BUFFER_BIT);
232 return ScreenEffect::glPaintOutput (attrib, transform, region, output, mask | PAINT_SCREEN_TRANSFORMED_MASK);
233}
234
235void
236ScreenFlyingWindows::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
237 const GLMatrix &transform,
238 const CompRegion &region,
239 CompOutput *output,
240 unsigned int mask)
241{
242 bool wasCulled = glIsEnabled (GL_CULL_FACE);
243
244 if (wasCulled)
245 glDisable (GL_CULL_FACE);
246
247 GLenum oldFilter = ss->gScreen->textureFilter ();
248
249 if (ss->optionGetMipmaps ())
250 ss->gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
251
252 mask &= ~PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
253
254 GLboolean bTwoSite;
255 glGetBooleanv (GL_LIGHT_MODEL_TWO_SIDE, &bTwoSite);
256 glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, ss->gScreen->lighting ());
257
258 ScreenEffect::glPaintTransformedOutput (attrib, transform, region, output, mask);
259
260 glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, bTwoSite);
261
262 ss->gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
263 ss->gScreen->setTextureFilter (oldFilter);
264
265 if (wasCulled)
266 glEnable (GL_CULL_FACE);
267}
268
269WindowFlyingWindows::WindowFlyingWindows (CompWindow* w) :
270 WindowEffect(w),
271 active (FALSE),
272 opacity (GLWindow::get (w)->paintAttrib ().opacity),
273 opacityFadeOut (0),
274 opacityOld (0),
275 steps (0)
276{
277}
278
279// Returns true if w is a flying window
280bool WindowFlyingWindows::isActiveWin()
281{
282 return !w->overrideRedirect () && \
283 w->mapNum () && \
284 w->isViewable () && \
285 !(w->wmType () & ( CompWindowTypeDockMask | CompWindowTypeDesktopMask)) && \
286 /* !( w->state & ( CompWindowStateSkipPagerMask | CompWindowStateShadedMask )) && \*/
287 ScreenSaverScreen::get (screen)->optionGetWindowMatch ().evaluate (w);
288}
289
290// Initialize window transformation matrices and vertices
291void WindowFlyingWindows::initWindow ()
292{
293 active = isActiveWin ();
294
295 if (active)
296 {
297 float x = WIN_X (this->w);
298 float y = WIN_Y (this->w);
299 float w = WIN_W (this->w);
300 float h = WIN_H (this->w);
301
302 transform = transformRot = transformTrans = Matrix::identity;
303 centerTrans = centerTransInv = Matrix::identity;
304
305 centerTrans.scale (1.0, 1.0, 1.0 / screen->width ());
306 centerTrans.translate (x + w/2.0, y + h/2.0, 0.0);
307 centerTransInv.translate (-(x + w / 2.0), -(y + h / 2.0), 0.0);
308 centerTransInv.scale (1.0f, 1.0f, 1.0f * screen->width ());
309
310 recalcVertices ();
311 speed = speedrot = Vector::null;
312 }
313 else
314 opacityOld = opacity;
315}
316
317// Update window vertices
318void WindowFlyingWindows::recalcVertices ()
319{
320 float x = WIN_X (this->w);
321 float y = WIN_Y (this->w);
322 float w = WIN_W (this->w);
323 float h = WIN_H (this->w);
324
325 vertex[NO] = Point (x, y, 0.0);
326 vertex[NE] = Point (x + w, y, 0.0);
327 vertex[SO] = Point (x, y + h, 0.0);
328 vertex[SE] = Point (x + w, y + h, 0.0);
329 vertex[C] = Point (x + w/2.0, y + h/2.0, 0.0);
330
331 // Apply the window transformation and normalize
332 for (int i = 0; i < 5; ++i)
333 vertex[i] = (transform * vertex[i]).toScreenSpace ();
334}
335
336bool WindowFlyingWindows::glPaint (const GLWindowPaintAttrib &attrib,
337 const GLMatrix &transform,
338 const CompRegion &region,
339 unsigned int mask)
340{
341 GLWindowPaintAttrib sAttrib (attrib);
342 Matrix wTransform;
343
344 if (!active)
345 {
346 SCREENSAVER_SCREEN (screen);
347
348 if (opacity && steps && !ss->mState.fadingOut)
349 {
350 if (opacity < steps)
351 opacity = 0;
352 else
353 opacity -= steps;
354 steps = 0;
355 }
356
357 sAttrib.opacity = opacity;
358 wTransform = transform;
359 }
360 else
361 {
362 SCREENSAVER_SCREEN (screen);
363 wTransform = transform * ss->mCameraMat * this->transform;
364 mask |= PAINT_WINDOW_TRANSFORMED_MASK;
365
366 if (w->state () & CompWindowStateSkipPagerMask)
367 return WindowEffect::glPaint (sAttrib, wTransform.m, region, mask);
368 }
369
370 if (w->alpha () || sAttrib.opacity != OPAQUE)
371 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
372
373 // from paint.cpp
374 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
375 {
376 if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
377 mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK ||
378 mask & PAINT_WINDOW_TRANSLUCENT_MASK ||
379 w->shaded ())
380 return false;
381
382 return true;
383 }
384
385 GLWindowPaintAttrib fragment (sAttrib);
386
387 glPushMatrix ();
388 glLoadMatrixf (wTransform.m);
389 bool status = sw->gWindow->glDraw (wTransform.m, fragment, region, mask);
390 glPopMatrix ();
391
392 return status;
393}
0394
=== added file 'plugins/screensaver/src/flyingwindows.h'
--- plugins/screensaver/src/flyingwindows.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/flyingwindows.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,94 @@
1#ifndef FLYINGWINDOWS_H
2#define FLYINGWINDOWS_H
3
4#include "screensaver.h"
5
6class ScreenFlyingWindows : public ScreenEffect
7{
8 public:
9
10 ScreenFlyingWindows () : ScreenEffect () {}
11 virtual ~ScreenFlyingWindows () {}
12
13 virtual void handleEvent (XEvent *event);
14 virtual bool enable ();
15 virtual void disable ();
16 virtual void preparePaint (int);
17 virtual void donePaint ();
18 virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &,
19 const GLMatrix &,
20 const CompRegion &,
21 CompOutput *,
22 unsigned int );
23 virtual bool glPaintOutput (const GLScreenPaintAttrib &,
24 const GLMatrix &,
25 const CompRegion &,
26 CompOutput *,
27 unsigned int );
28 virtual void paint (CompOutput::ptrList &,
29 unsigned int );
30 private:
31 void initWindow (CompWindow* _w);
32 void recalcVertices (CompWindow* _w);
33 void addForce (const Point& p1,
34 const Point& p2,
35 const Point& center,
36 Vector& resultante,
37 Vector& couple,
38 float w,
39 bool attract);
40};
41
42class WindowFlyingWindows : public WindowEffect
43{
44 friend class ScreenFlyingWindows;
45
46 public:
47
48 WindowFlyingWindows (CompWindow* w);
49 virtual ~WindowFlyingWindows () {}
50 void initWindow ();
51 virtual bool glPaint (const GLWindowPaintAttrib &,
52 const GLMatrix &,
53 const CompRegion &,
54 unsigned int );
55 void recalcVertices ();
56
57 static WindowFlyingWindows& getInstance (CompWindow* w) { return (WindowFlyingWindows&)*ScreenSaverWindow::get (w)->mEffect; }
58
59 private:
60
61 bool isActiveWin ();
62
63 // isScreenSaverWin()
64 bool active;
65
66 // used for non-active window like the desktop
67 GLushort opacity;
68 GLushort opacityFadeOut;
69 GLushort opacityOld;
70 int steps;
71
72 // used for active window
73 // translate matrix
74 Matrix transformTrans;
75
76 // rotation matrix
77 Matrix centerTrans;
78 Matrix transformRot;
79 Matrix centerTransInv;
80
81 // precomputed transform matrix
82 Matrix transform;
83
84 Matrix transformFadeOut;
85
86 // 5 normalized vertices are stored, the four corners and the center
87 Point vertex[5];
88
89 // normalized speed vectors
90 Vector speed;
91 Vector speedrot;
92};
93
94#endif
095
=== added file 'plugins/screensaver/src/matrix.cpp'
--- plugins/screensaver/src/matrix.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/matrix.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,60 @@
1#include "screensaver.h"
2
3static const float _identity[16] =
4{
5 1.0, 0.0, 0.0, 0.0,
6 0.0, 1.0, 0.0, 0.0,
7 0.0, 0.0, 1.0, 0.0,
8 0.0, 0.0, 0.0, 1.0
9};
10
11const Matrix Matrix::identity = _identity;
12
13Matrix operator* (const Matrix& lhs, const Matrix& rhs)
14{
15 Matrix res;
16 res[0] = lhs[0] * rhs[0] + lhs[4] * rhs[1] + lhs[8] * rhs[2] + lhs[12] * rhs[3];
17 res[1] = lhs[1] * rhs[0] + lhs[5] * rhs[1] + lhs[9] * rhs[2] + lhs[13] * rhs[3];
18 res[2] = lhs[2] * rhs[0] + lhs[6] * rhs[1] + lhs[10] * rhs[2] + lhs[14] * rhs[3];
19 res[3] = lhs[3] * rhs[0] + lhs[7] * rhs[1] + lhs[11] * rhs[2] + lhs[15] * rhs[3];
20 res[4] = lhs[0] * rhs[4] + lhs[4] * rhs[5] + lhs[8] * rhs[6] + lhs[12] * rhs[7];
21 res[5] = lhs[1] * rhs[4] + lhs[5] * rhs[5] + lhs[9] * rhs[6] + lhs[13] * rhs[7];
22 res[6] = lhs[2] * rhs[4] + lhs[6] * rhs[5] + lhs[10] * rhs[6] + lhs[14] * rhs[7];
23 res[7] = lhs[3] * rhs[4] + lhs[7] * rhs[5] + lhs[11] * rhs[6] + lhs[15] * rhs[7];
24 res[8] = lhs[0] * rhs[8] + lhs[4] * rhs[9] + lhs[8] * rhs[10] + lhs[12] * rhs[11];
25 res[9] = lhs[1] * rhs[8] + lhs[5] * rhs[9] + lhs[9] * rhs[10] + lhs[13] * rhs[11];
26 res[10] = lhs[2] * rhs[8] + lhs[6] * rhs[9] + lhs[10] * rhs[10] + lhs[14] * rhs[11];
27 res[11] = lhs[3] * rhs[8] + lhs[7] * rhs[9] + lhs[11] * rhs[10] + lhs[15] * rhs[11];
28 res[12] = lhs[0] * rhs[12] + lhs[4] * rhs[13] + lhs[8] * rhs[14] + lhs[12] * rhs[15];
29 res[13] = lhs[1] * rhs[12] + lhs[5] * rhs[13] + lhs[9] * rhs[14] + lhs[13] * rhs[15];
30 res[14] = lhs[2] * rhs[12] + lhs[6] * rhs[13] + lhs[10] * rhs[14] + lhs[14] * rhs[15];
31 res[15] = lhs[3] * rhs[12] + lhs[7] * rhs[13] + lhs[11] * rhs[14] + lhs[15] * rhs[15];
32
33 return res;
34}
35
36Vector operator* (const Matrix& mat, const Vector& vect)
37{
38 Vector res;
39
40 res[0] = mat[0] * vect[0] + mat[4] * vect[1] + mat[8] * vect[2] + mat[12];
41 res[1] = mat[1] * vect[0] + mat[5] * vect[1] + mat[9] * vect[2] + mat[13];
42 res[2] = mat[2] * vect[0] + mat[6] * vect[1] + mat[10] * vect[2] + mat[14];
43 float w = mat[3] * vect[0] + mat[7] * vect[1] + mat[11] * vect[2] + mat[15];
44
45 res[0] /= w;
46 res[1] /= w;
47 res[2] /= w;
48
49 return res;
50}
51
52Matrix interpolate (const Matrix& from, const Matrix& to, float position)
53{
54 Matrix res;
55
56 for (int i = 0; i < 16; ++i)
57 res[i] = from[i] * (1 - position) + to[i] * position;
58
59 return res;
60}
061
=== added file 'plugins/screensaver/src/matrix.h'
--- plugins/screensaver/src/matrix.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/matrix.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,69 @@
1#ifndef MATRIX_H
2#define MATRIX_H
3
4#include <core/core.h>
5#include <opengl/opengl.h>
6#include <cmath>
7#include "vector.h"
8
9class Matrix
10{
11 public:
12
13 static const Matrix identity;
14
15 Matrix()
16 {
17 for (int i = 0; i < 16; ++i)
18 {
19 m[i] = 0;
20 }
21 }
22
23 Matrix (const GLMatrix &mat) { memcpy (m, mat.getMatrix (), sizeof(m)); }
24 Matrix (const Matrix& mat) { memcpy (m, mat.m, sizeof(m)); }
25 Matrix (const float* mat) { memcpy (m, mat, sizeof(m)); }
26
27 const float& operator[] (int i) const { return m[i]; }
28 float& operator[] (int i) { return m[i]; }
29
30 Matrix& operator*= (const Matrix& rhs) { Matrix res; *this = *this * rhs; return *this; }
31 friend Matrix operator* (const Matrix& lhs, const Matrix& rhs);
32 friend Vector operator* (const Matrix& mat, const Vector& vect);
33
34 friend Matrix interpolate (const Matrix& from, const Matrix& to, float position);
35
36 Matrix& rotate (float angle, float x, float y, float z)
37 {
38 GLMatrix t (m);
39 t.rotate (angle, x, y, z);
40 memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16);
41 return *this;
42 }
43
44 Matrix& rotate (float angle, const Vector& vect) { return rotate (angle, vect[x], vect[y], vect[z]); }
45
46 Matrix& scale (float x, float y, float z)
47 {
48 GLMatrix t (m);
49 t.scale (x, y, z);
50 memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16);
51 return *this;
52 }
53
54 Matrix& scale (const Vector& vect) { return scale (vect[x], vect[y], vect[z]); }
55
56 Matrix& translate (float x, float y, float z)
57 {
58 GLMatrix t (m);
59 t.translate (x, y, z);
60 memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16);
61 return *this;
62 }
63
64 Matrix& translate (const Vector& vect) { return translate (vect[x], vect[y], vect[z]); }
65
66 float m[16];
67};
68
69#endif
070
=== added file 'plugins/screensaver/src/rotatingcube.cpp'
--- plugins/screensaver/src/rotatingcube.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/rotatingcube.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,104 @@
1#include "rotatingcube.h"
2
3bool ScreenRotatingCube::loadCubePlugin()
4{
5 if (!CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI))
6 return false;
7
8 return true;
9}
10
11bool ScreenRotatingCube::enable ()
12{
13 if (!loadCubePlugin ())
14 return false;
15
16 CubeScreen *cs = ss->cubeScreen;
17
18 ss->mZCamera = 0.0;
19 ss->mCubeRotX = 0.0;
20 ss->mCubeRotV = 0.0;
21 cs->rotationState (CubeScreen::RotationManual);
22
23 ss->cubeScreen->cubeGetRotationSetEnabled (ss, true);
24
25 return ScreenEffect::enable ();
26}
27
28void ScreenRotatingCube::disable ()
29{
30 ss->mZCameraFadeOut = ss->mZCamera;
31 ss->mCubeRotXFadeOut = ss->mCubeRotX;
32 ss->mCubeRotVFadeOut = ss->mCubeRotV;
33
34 ScreenEffect::disable ();
35}
36
37void ScreenRotatingCube::clean ()
38{
39 ss->cubeScreen->rotationState (CubeScreen::RotationNone);
40}
41
42void ScreenRotatingCube::cubeGetRotation (float& x, float& v, float &progress)
43{
44 ScreenEffect::cubeGetRotation (x, v, progress);
45
46 x += ss->mCubeRotX;
47 v += ss->mCubeRotV;
48 progress = MAX (progress, ss->mCubeProgress);
49}
50
51void ScreenRotatingCube::preparePaint (int msSinceLastPaint)
52{
53 ScreenEffect::preparePaint (msSinceLastPaint);
54
55 float rotX = ss->optionGetCubeRotationSpeed () / 100.0;
56
57 if (ss->mState.fadingIn)
58 {
59 rotX *= getProgress();
60 ss->mZCamera = -ss->optionGetCubeZoom() * getProgress();
61 ss->mCubeProgress = getProgress();
62 }
63 else if (ss->mState.fadingOut)
64 {
65 ss->mZCamera = ss->mZCameraFadeOut * (1 - getProgress());
66 ss->mCubeRotX = ss->mCubeRotXFadeOut * (1 - getProgress());
67 ss->mCubeRotV = ss->mCubeRotVFadeOut * (1 - getProgress());
68 ss->mCubeProgress = 1 - getProgress();
69 }
70
71 if (!ss->mState.fadingOut)
72 {
73 float rotV = 0.0;
74 ss->mCubeRotX += rotX * msSinceLastPaint;
75 ss->mCubeRotV += rotV * msSinceLastPaint;
76 }
77
78 if (ss->mCubeRotX > 180.0)
79 ss->mCubeRotX -= 360.0;
80
81 if (ss->mCubeRotX < -180.0)
82 ss->mCubeRotX += 360.0;
83}
84
85void ScreenRotatingCube::donePaint()
86{
87 ss->cScreen->damageScreen();
88 ScreenEffect::donePaint();
89}
90
91bool ScreenRotatingCube::glPaintOutput (const GLScreenPaintAttrib &attrib,
92 const GLMatrix &transform,
93 const CompRegion &region,
94 CompOutput *output,
95 unsigned int mask)
96{
97 GLScreenPaintAttrib sA (attrib);
98 sA.zCamera += ss->mZCamera;
99
100 mask &= ~PAINT_SCREEN_REGION_MASK;
101 mask |= PAINT_SCREEN_TRANSFORMED_MASK;
102
103 return ScreenEffect::glPaintOutput (sA, transform, region, output, mask);
104}
0105
=== added file 'plugins/screensaver/src/rotatingcube.h'
--- plugins/screensaver/src/rotatingcube.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/rotatingcube.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,34 @@
1#ifndef ROTATINGCUBE_H
2#define ROTATINGCUBE_H
3
4#include "screensaver.h"
5
6class ScreenRotatingCube : public ScreenEffect
7{
8 public:
9
10 ScreenRotatingCube () : ScreenEffect () {}
11 virtual ~ScreenRotatingCube () {}
12
13 virtual bool enable ();
14 virtual void disable ();
15 virtual void cubeGetRotation (float &x,
16 float &v,
17 float &progress);
18 virtual void preparePaint (int msSinceLastPaint);
19 virtual void donePaint ();
20 virtual bool glPaintOutput (const GLScreenPaintAttrib &,
21 const GLMatrix &,
22 const CompRegion &,
23 CompOutput *,
24 unsigned int );
25 protected:
26
27 virtual void clean ();
28
29 private:
30
31 bool loadCubePlugin ();
32};
33
34#endif
035
=== added file 'plugins/screensaver/src/screensaver.cpp'
--- plugins/screensaver/src/screensaver.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/screensaver.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,312 @@
1/**
2 *
3 * Compiz screensaver plugin
4 *
5 * screensaver.cpp
6 *
7 * Copyright (c) 2007 Nicolas Viennot <nicolas@viennot.biz>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 **/
20
21#include <stdlib.h>
22#include <string.h>
23#include <math.h>
24
25#include "screensaver.h"
26#include "rotatingcube.h"
27#include "flyingwindows.h"
28
29COMPIZ_PLUGIN_20090315 (screensaver, ScreenSaverPluginVTable);
30
31template <typename _ScreenEffect, typename _WindowEffect>
32static void screenSaverEffectInstance ()
33{
34 SCREENSAVER_SCREEN (screen);
35 delete ss->mEffect;
36 ss->mEffect = new _ScreenEffect ();
37
38 foreach (CompWindow *w, screen->windows ())
39 {
40 SCREENSAVER_WINDOW (w);
41 delete sw->mEffect;
42 sw->mEffect = new _WindowEffect (w);
43 }
44}
45
46void
47ScreenSaverScreen::enableEffect ()
48{
49 enum ScreensaverOptions::Mode mode = (enum ScreensaverOptions::Mode) optionGetMode ();
50
51 if (mode == ModeFlyingWindows)
52 screenSaverEffectInstance <ScreenFlyingWindows, WindowFlyingWindows> ();
53
54 if (mode == ScreensaverOptions::ModeRotatingCube)
55 screenSaverEffectInstance <ScreenRotatingCube, WindowEffect> ();
56
57 mTime = 0;
58
59 if (!mEffect->enable ())
60 {
61 fprintf (stderr, "Fail\n");
62 screenSaverEffectInstance <ScreenEffect, WindowEffect> ();
63 return;
64 }
65
66 mState.fadingOut = false;
67 mState.fadingIn = true;
68 mState.running = true;
69}
70
71void
72ScreenSaverScreen::disableEffect ()
73{
74 mEffect->disable ();
75 mTime = 0;
76
77 mState.fadingOut = true;
78 mState.fadingIn = false;
79}
80
81void
82ScreenSaverScreen::cleanEffect ()
83{
84 screenSaverEffectInstance <ScreenEffect, WindowEffect> ();
85}
86
87void
88ScreenSaverScreen::setState (bool enable)
89{
90 if (!mState.running && enable)
91 mEffect->loadEffect = true;
92
93 if (mState.running && !enable && !mState.fadingOut)
94 disableEffect ();
95}
96
97bool
98ScreenSaverScreen::initiate (CompAction *action,
99 CompAction::State state,
100 CompOption::Vector options)
101{
102 setState (!mState.running);
103 return true;
104}
105
106void
107ScreenSaverScreen::cubeGetRotation (float &x, float &v, float &progress)
108{
109 mEffect->cubeGetRotation (x, v, progress);
110}
111
112bool
113ScreenSaverWindow::glPaint (const GLWindowPaintAttrib &attrib,
114 const GLMatrix &transform,
115 const CompRegion &region,
116 unsigned int mask)
117{
118 return mEffect->glPaint (attrib, transform, region, mask);
119}
120
121bool
122ScreenSaverScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
123 const GLMatrix &transform,
124 const CompRegion &region,
125 CompOutput *output,
126 unsigned int mask)
127{
128 return mEffect->glPaintOutput (attrib, transform, region, output, mask);
129}
130
131void
132ScreenSaverScreen::preparePaint (int ms)
133{
134 mEffect->preparePaint (ms);
135}
136
137void
138ScreenSaverScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
139 const GLMatrix &transform,
140 const CompRegion &region,
141 CompOutput *output,
142 unsigned int mask)
143{
144 mEffect->glPaintTransformedOutput (attrib, transform, region, output, mask);
145}
146
147void
148ScreenSaverScreen::donePaint ()
149{
150 mEffect->donePaint ();
151}
152
153void
154ScreenSaverScreen::handleEvent (XEvent *event)
155{
156 XScreenSaverNotifyEvent *xssEvent;
157
158 mEffect->handleEvent (event);
159
160 switch ((event->type & 0x7F) - mXSSContext.first_event)
161 {
162 case ScreenSaverNotify:
163 xssEvent = (XScreenSaverNotifyEvent *) event;
164 setState (xssEvent->state);
165 break;
166
167 default:
168 break;
169 }
170
171 if (mEffect->loadEffect)
172 {
173 mEffect->loadEffect = false;
174 enableEffect ();
175 }
176 else if (mEffect->cleanEffect)
177 {
178 mEffect->cleanEffect = false;
179 cleanEffect ();
180 }
181}
182
183void
184ScreenSaverScreen::paint (CompOutput::ptrList &outputs,
185 unsigned int mask)
186{
187 mEffect->paint (outputs, mask);
188}
189
190void
191ScreenSaverScreen::setXScreenSaver (bool enabled)
192{
193 Window root = screen->root ();
194
195 if (enabled && !mXSSContext.init)
196 {
197 int dummy;
198 long unsigned int mask = 0;
199 XSetWindowAttributes attr;
200
201 if (!XScreenSaverQueryExtension (screen->dpy (), &mXSSContext.first_event, &dummy))
202 {
203 compLogMessage ("screensaver", CompLogLevelWarn,
204 "XScreenSaver Extension not available, cannot integrate with "\
205 "desktop settings!");
206 return;
207 }
208
209 mXSSContext.init = true;
210
211 XGetScreenSaver (screen->dpy (), &mXSSContext.timeout, &mXSSContext.interval,
212 &mXSSContext.prefer_blanking, &mXSSContext.allow_exposures);
213 XSetScreenSaver (screen->dpy (), (int) (optionGetAfter () * 60.0), mXSSContext.interval, 0, AllowExposures);
214
215 XScreenSaverSetAttributes (screen->dpy (), root, -100, -100, 1, 1, 0,
216 CopyFromParent, CopyFromParent,
217 DefaultVisual (screen->dpy (), screen->screenNum ()), mask, &attr);
218
219 XScreenSaverSelectInput (screen->dpy (), root, ScreenSaverNotifyMask);
220
221 }
222 if (!enabled && mXSSContext.init)
223 {
224 mXSSContext.init = false;
225
226 XSetScreenSaver (screen->dpy (), mXSSContext.timeout, mXSSContext.interval,
227 mXSSContext.prefer_blanking, mXSSContext.allow_exposures);
228
229 XScreenSaverSelectInput (screen->dpy (), root, 0);
230 XScreenSaverUnsetAttributes (screen->dpy (), root);
231 }
232}
233
234void
235ScreenSaverScreen::optionChanged (CompOption *opt,
236 ScreensaverOptions::Options num)
237{
238 setXScreenSaver (false);
239 setXScreenSaver (optionGetStartAutomatically ());
240}
241
242ScreenSaverWindow::ScreenSaverWindow (CompWindow *w) :
243 PluginClassHandler <ScreenSaverWindow, CompWindow> (w),
244 mEffect (NULL),
245 window (w),
246 cWindow (CompositeWindow::get (w)),
247 gWindow (GLWindow::get (w))
248{
249 ScreenSaverScreen *ss = ScreenSaverScreen::get (screen);
250
251 if(ss->mState.running &&
252 (enum ScreensaverOptions::Mode) ss->optionGetMode() == ScreensaverOptions::ModeFlyingWindows)
253 mEffect = new WindowFlyingWindows (w);
254 else
255 mEffect = new WindowEffect (w);
256
257 GLWindowInterface::setHandler (gWindow);
258}
259
260ScreenSaverWindow::~ScreenSaverWindow ()
261{
262 delete mEffect;
263}
264
265ScreenSaverScreen::ScreenSaverScreen (CompScreen *s) :
266 PluginClassHandler <ScreenSaverScreen, CompScreen> (s),
267 cScreen (CompositeScreen::get (screen)),
268 gScreen (GLScreen::get (screen)),
269 cubeScreen (CubeScreen::get (screen)),
270 mEffect (new ScreenEffect ()),
271 mDesktopOpacity (OPAQUE)
272{
273 ScreenInterface::setHandler (screen);
274 GLScreenInterface::setHandler (gScreen);
275 CompositeScreenInterface::setHandler (cScreen);
276 CubeScreenInterface::setHandler (cubeScreen);
277
278 mState.running = false;
279 mState.fadingOut = false;
280 mState.fadingIn = false;
281
282 optionSetInitiateKeyInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3));
283 optionSetInitiateButtonInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3));
284 optionSetInitiateEdgeInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3));
285
286 optionSetStartAutomaticallyNotify (boost::bind (&ScreenSaverScreen::optionChanged, this, _1, _2));
287 optionSetAfterNotify (boost::bind (&ScreenSaverScreen::optionChanged, this, _1, _2));
288
289 mXSSContext.init = false;
290
291 mEffect->loadEffect = false;
292 mEffect->cleanEffect = false;
293
294 setXScreenSaver (optionGetStartAutomatically ());
295}
296
297ScreenSaverScreen::~ScreenSaverScreen ()
298{
299 delete mEffect;
300}
301
302bool
303ScreenSaverPluginVTable::init ()
304{
305 if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) &&
306 CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) &&
307 CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) &&
308 CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI))
309 return true;
310
311 return false;
312}
0313
=== added file 'plugins/screensaver/src/screensaver.h'
--- plugins/screensaver/src/screensaver.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/screensaver.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,258 @@
1#ifndef SCREENSAVER_INTERNAL_H
2#define SCREENSAVER_INTERNAL_H
3
4#include <core/core.h>
5#include <composite/composite.h>
6#include <opengl/opengl.h>
7#include <cube/cube.h>
8
9/* libxss-dev is needed, on Ubuntu: sudo apt-get install libxss-dev */
10#include <X11/extensions/scrnsaver.h>
11
12#include "screensaver_options.h"
13#include "matrix.h"
14#include "vector.h"
15
16#define WIN_X(w) ((w)->x () - (w)->input ().left)
17#define WIN_Y(w) ((w)->y () - (w)->input ().top)
18#define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right)
19#define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom)
20
21extern int displayPrivateIndex;
22
23class ScreenSaverScreen;
24class ScreenSaverWindow;
25
26class ScreenWrapper
27{
28 public:
29
30 ScreenWrapper ();
31 ~ScreenWrapper () {}
32
33 virtual void cubeGetRotation (float& x, float& v, float &progress);
34 virtual void handleEvent (XEvent *);
35 virtual void preparePaint (int);
36 virtual void donePaint ();
37 virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &,
38 const GLMatrix &,
39 const CompRegion &,
40 CompOutput *,
41 unsigned int );
42 virtual bool glPaintOutput (const GLScreenPaintAttrib &,
43 const GLMatrix &,
44 const CompRegion &,
45 CompOutput *,
46 unsigned int );
47 virtual void paint (CompOutput::ptrList &,
48 unsigned int );
49
50 protected:
51
52 CompScreen* s;
53 ScreenSaverScreen* ss;
54};
55
56class WindowWrapper
57{
58 public:
59
60 WindowWrapper (CompWindow* w);
61 virtual ~WindowWrapper () {}
62 virtual bool glPaint (const GLWindowPaintAttrib &,
63 const GLMatrix &,
64 const CompRegion &,
65 unsigned int );
66 protected:
67
68 CompWindow* w;
69 ScreenSaverWindow* sw;
70};
71
72class ScreenEffect : public ScreenWrapper
73{
74 public:
75
76 ScreenEffect() : ScreenWrapper(), progress (0) {}
77 virtual ~ScreenEffect() {}
78 float getProgress() { return progress; }
79 virtual void handleEvent (XEvent *event);
80
81 virtual bool enable ();
82 virtual void disable () {}
83 virtual void preparePaint (int msSinceLastPaint);
84 virtual void cubeGetRotation (float &, float &, float &); // TODO: get rid of this!
85
86 bool cleanEffect;
87 bool loadEffect;
88
89 protected:
90
91 virtual void clean () {}
92
93 private:
94
95 float progress;
96};
97
98class WindowEffect : public WindowWrapper
99{
100 public:
101
102 WindowEffect (CompWindow* w) : WindowWrapper (w) {}
103 virtual ~WindowEffect () {}
104};
105
106class ScreenSaver
107{
108 public:
109
110 class State
111 {
112 public:
113 // when the screensaver is enabled, running and fadingIn are set to true
114 // then, after fadingInDuration, fadingIn is set to false
115 // when the screensaver is requested to stop, fadingOut is set to true
116 // after fadingOutDuration, running is set to false
117 bool running;
118 bool fadingOut;
119 bool fadingIn;
120 };
121
122 class XSSContext
123 {
124 public:
125
126 int timeout;
127 int interval;
128 int prefer_blanking;
129 int allow_exposures;
130 int first_event;
131 bool init;
132 };
133};
134
135class ScreenSaverScreen :
136 public PluginClassHandler <ScreenSaverScreen, CompScreen>,
137 public ScreenInterface,
138 public CompositeScreenInterface,
139 public GLScreenInterface,
140 public CubeScreenInterface,
141 public ScreensaverOptions
142{
143 public:
144
145 ScreenSaverScreen (CompScreen *s);
146 ~ScreenSaverScreen ();
147
148 public:
149
150 CompositeScreen *cScreen;
151 GLScreen *gScreen;
152 CubeScreen *cubeScreen;
153
154 ScreenSaver::State mState;
155 ScreenSaver::XSSContext mXSSContext;
156
157 ScreenEffect *mEffect;
158
159 void
160 cubeGetRotation (float &x,
161 float &v,
162 float &progress);
163
164 void
165 handleEvent (XEvent *);
166
167 void
168 preparePaint (int);
169
170 void
171 donePaint ();
172
173 void
174 glPaintTransformedOutput (const GLScreenPaintAttrib &,
175 const GLMatrix &,
176 const CompRegion &,
177 CompOutput *,
178 unsigned int );
179
180 bool glPaintOutput (const GLScreenPaintAttrib &,
181 const GLMatrix &,
182 const CompRegion &,
183 CompOutput *,
184 unsigned int );
185
186 void
187 paint (CompOutput::ptrList &outputs,
188 unsigned int mask);
189
190 void enableEffect ();
191
192 void disableEffect ();
193
194 void cleanEffect ();
195
196 void setState (bool);
197
198 bool initiate (CompAction *, CompAction::State, CompOption::Vector);
199
200 void setXScreenSaver (bool);
201 void optionChanged (CompOption *, ScreensaverOptions::Options);
202
203 int mTime;
204 float mCubeRotX;
205 float mCubeRotV;
206 float mCubeProgress;
207 float mZCamera;
208
209 float mCubeRotXFadeOut;
210 float mCubeRotVFadeOut;
211 float mZCameraFadeOut;
212
213 Point mScreenCenter;
214 Matrix mCamera;
215 Matrix mCameraMat;
216
217 float mAngleCam;
218 GLushort mDesktopOpacity;
219};
220
221class ScreenSaverWindow :
222 public PluginClassHandler <ScreenSaverWindow, CompWindow>,
223 public GLWindowInterface
224{
225 public:
226
227 ScreenSaverWindow (CompWindow *w);
228 ~ScreenSaverWindow ();
229
230 WindowEffect *mEffect;
231
232 bool
233 glPaint (const GLWindowPaintAttrib &,
234 const GLMatrix &,
235 const CompRegion &,
236 unsigned int );
237
238 CompWindow *window;
239 CompositeWindow *cWindow;
240 GLWindow *gWindow;
241
242};
243
244#define SCREENSAVER_SCREEN(s) \
245 ScreenSaverScreen *ss = ScreenSaverScreen::get (s);
246
247#define SCREENSAVER_WINDOW(w) \
248 ScreenSaverWindow *sw = ScreenSaverWindow::get (w);
249
250class ScreenSaverPluginVTable :
251 public CompPlugin::VTableForScreenAndWindow <ScreenSaverScreen, ScreenSaverWindow>
252{
253 public:
254
255 bool init ();
256};
257
258#endif
0259
=== added file 'plugins/screensaver/src/vector.cpp'
--- plugins/screensaver/src/vector.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/vector.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,14 @@
1#include "vector.h"
2
3const Vector Vector::null (0.0, 0.0, 0.0);
4
5Vector operator^ (const Vector& lhs, const Vector& rhs)
6{
7 Vector res;
8
9 res[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1];
10 res[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2];
11 res[2] = lhs[0] * rhs[1] - lhs[1] * rhs[0];
12
13 return res;
14}
015
=== added file 'plugins/screensaver/src/vector.h'
--- plugins/screensaver/src/vector.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/vector.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,164 @@
1#ifndef VECTOR_H
2#define VECTOR_H
3
4#include <core/core.h>
5#include <opengl/opengl.h>
6#include <cmath>
7
8typedef enum
9{
10 x,
11 y,
12 z
13} VectorCoordsEnum;
14
15class Vector
16{
17 public:
18 static const Vector null;
19
20 Vector ()
21 {
22 for (int i = 0; i < 3; ++i)
23 v[i] = 0;
24 }
25
26 Vector (float x, float y, float z) { v[0] = x; v[1] = y; v[2] = z; }
27 Vector (const float* vect) { v[0] = vect[0]; v[1] = vect[1]; v[2] = vect[2]; }
28 Vector (const Vector& vect) { v[0] = vect[0]; v[1] = vect[1]; v[2] = vect[2]; }
29
30 float norm () { return sqrt ((*this) * (*this)); }
31
32 Vector& normalize ()
33 {
34 float n = norm ();
35
36 if (n == 0.0)
37 v[x] = v[y] = v[z] = 1.0;
38 else
39 *this /= n;
40
41 return *this;
42 }
43
44 Vector toScreenSpace () const
45 {
46 Vector res;
47 res[0] = v[0] / screen->width () - 0.5;
48 res[1] = 0.5 - v[1] / screen->height ();
49 res[2] = v[2];
50 return res;
51 }
52
53 Vector toCoordsSpace () const
54 {
55 Vector res;
56 res[0] = (v[0] + 0.5) * screen->width ();
57 res[1] = (0.5 - v[1]) * screen->height ();
58 res[2] = v[2];
59 return res;
60 }
61
62 float& operator[] (int i) { return v[i]; }
63 const float& operator[] (int i) const { return v[i]; }
64 float& operator[] (VectorCoordsEnum c) { return v[(int)c]; }
65 const float& operator[] (VectorCoordsEnum c) const { return v[(int)c]; }
66
67 Vector& operator+= (const Vector& rhs)
68 {
69 v[0] += rhs[0];
70 v[1] += rhs[1];
71 v[2] += rhs[2];
72 return *this;
73 }
74
75 friend Vector operator+ (const Vector& lhs, const Vector& rhs)
76 {
77 Vector res;
78 res[0] = lhs[0] + rhs[0];
79 res[1] = lhs[1] + rhs[1];
80 res[2] = lhs[2] + rhs[2];
81 return res;
82 }
83
84 Vector& operator-= (const Vector& rhs)
85 {
86 v[0] -= rhs[0];
87 v[1] -= rhs[1];
88 v[2] -= rhs[2];
89 return *this;
90 }
91
92 friend Vector operator- (const Vector& lhs, const Vector& rhs)
93 {
94 Vector res;
95 res[0] = lhs[0] - rhs[0];
96 res[1] = lhs[1] - rhs[1];
97 res[2] = lhs[2] - rhs[2];
98 return res;
99 }
100
101 friend Vector operator- (const Vector& vect)
102 {
103 Vector res;
104 res[0] = -vect[0];
105 res[1] = -vect[1];
106 res[2] = -vect[2];
107 return res;
108 }
109
110 Vector& operator*= (const float k)
111 {
112 v[0] *= k;
113 v[1] *= k;
114 v[2] *= k;
115 return *this;
116 }
117
118 friend float operator* (const Vector& lhs, const Vector& rhs)
119 {
120 return lhs[0] * rhs[0] + lhs[1] * rhs[1] + lhs[2] * rhs[2];
121 }
122
123 friend Vector operator* (const float k, const Vector& vect)
124 {
125 Vector res;
126 res[0] = k * vect[0];
127 res[1] = k * vect[1];
128 res[2] = k * vect[2];
129 return res;
130 }
131
132 friend Vector operator* (const Vector& v, const float k) { return k*v; }
133
134 Vector& operator/= (const float k)
135 {
136 v[0] /= k;
137 v[1] /= k;
138 v[2] /= k;
139 return *this;
140 }
141
142 friend Vector operator/ (const Vector& vect, const float k)
143 {
144 Vector res;
145 res[0] = vect[0] / k;
146 res[1] = vect[1] / k;
147 res[2] = vect[2] / k;
148 return res;
149 }
150
151 Vector& operator^= (const Vector& vect)
152 {
153 *this = *this ^ vect;
154 return *this;
155 }
156
157 friend Vector operator^ (const Vector& lhs, const Vector& rhs);
158
159 float v[3];
160};
161
162typedef Vector Point;
163
164#endif
0165
=== added file 'plugins/screensaver/src/wrapper.cpp'
--- plugins/screensaver/src/wrapper.cpp 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/wrapper.cpp 2013-05-12 17:13:30 +0000
@@ -0,0 +1,67 @@
1#include "screensaver.h"
2
3void ScreenWrapper::handleEvent (XEvent *event)
4{
5 screen->handleEvent (event);
6}
7
8ScreenWrapper::ScreenWrapper ()
9{
10 SCREENSAVER_SCREEN (screen);
11 this->s = screen;
12 this->ss = ss;
13}
14
15void ScreenWrapper::cubeGetRotation (float& x, float& v, float &progress)
16{
17 ss->cubeScreen->cubeGetRotation (x, v, progress);
18}
19
20void ScreenWrapper::preparePaint (int msSinceLastPaint )
21{
22 ss->cScreen->preparePaint (msSinceLastPaint);
23}
24
25void ScreenWrapper::donePaint ()
26{
27 ss->cScreen->donePaint ();
28}
29
30void ScreenWrapper::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
31 const GLMatrix &transform,
32 const CompRegion &region,
33 CompOutput *output,
34 unsigned int mask)
35{
36 ss->gScreen->glPaintTransformedOutput (attrib, transform, region, output, mask);
37}
38
39bool ScreenWrapper::glPaintOutput (const GLScreenPaintAttrib &attrib,
40 const GLMatrix &transform,
41 const CompRegion &region,
42 CompOutput *output,
43 unsigned int mask)
44{
45 return ss->gScreen->glPaintOutput (attrib, transform, region, output, mask);
46}
47
48void ScreenWrapper::paint (CompOutput::ptrList &outputs,
49 unsigned int mask)
50{
51 ss->cScreen->paint (outputs, mask);
52}
53
54WindowWrapper::WindowWrapper (CompWindow* w)
55{
56 SCREENSAVER_WINDOW (w);
57 this->w = w;
58 this->sw = sw;
59}
60
61bool WindowWrapper::glPaint (const GLWindowPaintAttrib &attrib,
62 const GLMatrix &transform,
63 const CompRegion &region,
64 unsigned int mask)
65{
66 return sw->gWindow->glPaint (attrib, transform, region, mask);
67}
068
=== added file 'plugins/screensaver/src/wrapper.h'
--- plugins/screensaver/src/wrapper.h 1970-01-01 00:00:00 +0000
+++ plugins/screensaver/src/wrapper.h 2013-05-12 17:13:30 +0000
@@ -0,0 +1,4 @@
1#ifndef WRAPPER_H
2#define WRAPPER_H
3
4#endif

Subscribers

People subscribed via source and target branches

to all changes: