Merge lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz-core/compiz-core.fix_883102
Merge into: lp:compiz-core/0.9.5
Diff against target: 2311 lines (+1078/-508)
60 files modified
CMakeLists.txt (+0/-14)
cmake/CompizCommon.cmake (+374/-0)
cmake/CompizPlugin.cmake (+39/-49)
include/CMakeLists.txt (+0/-1)
include/compiz-common.h.in (+0/-5)
include/compiz.h (+0/-103)
include/core/CMakeLists.txt (+0/-5)
include/core/core.h (+23/-0)
include/core/match.h (+1/-0)
include/core/option.h (+1/-2)
include/core/plugin.h (+1/-1)
include/core/session.h (+1/-0)
include/core/string.h (+39/-0)
metadata/CMakeLists.txt (+2/-2)
plugins/composite/src/screen.cpp (+4/-2)
plugins/opengl/src/matrix.cpp (+0/-1)
plugins/opengl/src/texture.cpp (+0/-2)
po/POTFILES.in (+0/-4)
src/CMakeLists.txt (+38/-6)
src/action.cpp (+0/-2)
src/logmessage/include/core/logmessage.h (+51/-0)
src/logmessage/src/logmessage.cpp (+2/-1)
src/main.cpp (+0/-2)
src/pluginclasshandler/include/core/pluginclasshandler.h (+1/-1)
src/pluginclasshandler/include/core/valueholder.h (+3/-2)
src/pluginclasshandler/tests/CMakeLists.txt (+1/-1)
src/pluginclasshandler/tests/construct/CMakeLists.txt (+1/-25)
src/pluginclasshandler/tests/construct/src/test-pch-construct.cpp (+6/-0)
src/pluginclasshandler/tests/get/CMakeLists.txt (+1/-25)
src/pluginclasshandler/tests/get/src/test-pch-get.cpp (+6/-0)
src/pluginclasshandler/tests/indexes/CMakeLists.txt (+1/-24)
src/pluginclasshandler/tests/indexes/src/test-pch-indexes.cpp (+6/-0)
src/pluginclasshandler/tests/test-pluginclasshandler.cpp (+1/-1)
src/pluginclasshandler/tests/test-pluginclasshandler.h (+3/-0)
src/pluginclasshandler/tests/typenames/CMakeLists.txt (+1/-25)
src/pluginclasshandler/tests/typenames/src/test-pch-typenames.cpp (+6/-0)
src/privatescreen.h (+14/-0)
src/screen.cpp (+2/-2)
src/session.cpp (+0/-2)
src/string/src/string.cpp (+2/-2)
src/string/tests/CMakeLists.txt (+3/-0)
src/string/tests/printf/CMakeLists.txt (+1/-0)
src/string/tests/printf/src/test-string-printf.cpp (+193/-0)
src/string/tests/test-string.cpp (+47/-0)
src/string/tests/test-string.h (+52/-0)
src/timer/include/core/timer.h (+18/-0)
src/timer/tests/CMakeLists.txt (+17/-15)
src/timer/tests/callbacks/CMakeLists.txt (+1/-23)
src/timer/tests/callbacks/src/test-timer-callbacks.cpp (+6/-0)
src/timer/tests/diffs/CMakeLists.txt (+1/-23)
src/timer/tests/diffs/src/test-timer-diffs.cpp (+88/-0)
src/timer/tests/set-values/CMakeLists.txt (+1/-23)
src/timer/tests/set-values/src/test-timer-set-values.cpp (+6/-0)
src/timer/tests/test-timer.cpp (+1/-1)
src/timer/tests/test-timer.h (+3/-0)
src/timer/tests/while-calling/CMakeLists.txt (+1/-23)
src/timer/tests/while-calling/src/test-timer-set-times-while-calling.cpp (+6/-0)
src/window.cpp (+2/-4)
tests/CMakeLists.txt (+0/-2)
tests/timer/diffs/test-timer-diffs.cpp (+0/-82)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_883102
Reviewer Review Type Date Requested Status
Thomas Voß Needs Fixing
Tim Penhey (community) Abstain
Compiz Maintainers Pending
Review via email: mp+80803@code.launchpad.net

This proposal has been superseded by a proposal from 2011-12-20.

Description of the change

Fix bug 883102

    Move to a test-driven-development type buildsystem which allows for
    modules to be build interternally and statically linked to plugins and to
    testcases.

    Use compiz_module to add a new module, with the following directory structure:

    module/
     src/
     include/
     tests/
     CMakeLists.txt

    Use compiz_test_base to add a library for all tests for that module to
    link to, and add each test in a separate subdirectory in tests/

    Use compiz_test to add a new test in a name subdirectory for a module and
    prefix.

    prefix: plugin / core
    module: module of functionality
    test: test name

    Removed compiz.h and compiz-common.h . Use core/string.h core/timer.h
    core/logmessage.h core/screen.h for timeval diff functionality, CompString,
    compLogMessage and wraparound modulus.

    Added workaround for core xml file race condition

To post a comment you must log in.
2892. By Sam Spilsbury

Removed useless file

2893. By Sam Spilsbury

Added compPrintf test

Revision history for this message
Tim Penhey (thumper) wrote :

I find the string test remarkably hard to follow. Have you considered using google-test and google-mock for the testing framework?

The CMake stuff is way over my understanding, and I can't comfortably review the code.

A +1 for removing compiz.h, but is this used in unity at all?

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Wed, Nov 9, 2011 at 6:55 AM, Tim Penhey <email address hidden> wrote:
> I find the string test remarkably hard to follow.  Have you considered using google-test and google-mock for the testing framework?

Yeah, the string test could probably be reworked slightly. I am not
sure about using google-mock or google-test as I am not sure how
available they are on other distributions.

>
> The CMake stuff is way over my understanding, and I can't comfortably review the code.
>
> A +1 for removing compiz.h, but is this used in unity at all?

It is used by some compiz code, but was mostly just a random
assortment of #defines and typedefs that needed to die.

> --
> https://code.launchpad.net/~compiz-team/compiz-core/compiz-core.fix_883102/+merge/80803
> Your team Compiz Maintainers is requested to review the proposed merge of lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core.
>

--
Sam Spilsbury

Revision history for this message
Tim Penhey (thumper) wrote :

I don't feel confident about reviewing the CMake changes. We should get someone who knows cmake to look at it.

review: Abstain
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

The CMake functions seem to be duplicating a lot of stuff that CMake already does. For example there is a lot of code to build compiler flag prefixes which you really should not need to do. As an example is this line:

list (APPEND ${_prefix}_LIBRARY_LDFLAGS -l${_library})

It seems (not having read all of the build system code thoroughly) that these are then added to a target with set_target_properties. You really should not need to do this. Simply do target_link_libraries(foo library_of_bar). It's the same, but portable and consistency checked by CMake.

In the same vein, why are linker flags set with set_target_properties and not target_link_libraries? The arguments to the latter can be linker flags and they are handled appropriately by CMake. The same applies for include paths and other properties. Why have a function for include expansion (that basically just adds a "-I" to a list of strings) when all you would need to do is include_directories(${foobar})? These definitions do not propagate to parent directories so you can just set them in a test subdirectory and they remain isolated.

On this line the word "library" is misspelt:

list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> The CMake functions seem to be duplicating a lot of stuff that CMake already
> does. For example there is a lot of code to build compiler flag prefixes which
> you really should not need to do. As an example is this line:
>
> list (APPEND ${_prefix}_LIBRARY_LDFLAGS -l${_library})
>
> It seems (not having read all of the build system code thoroughly) that these
> are then added to a target with set_target_properties. You really should not
> need to do this. Simply do target_link_libraries(foo library_of_bar). It's the
> same, but portable and consistency checked by CMake.
>
> In the same vein, why are linker flags set with set_target_properties and not
> target_link_libraries? The arguments to the latter can be linker flags and
> they are handled appropriately by CMake. The same applies for include paths
> and other properties. Why have a function for include expansion (that
> basically just adds a "-I" to a list of strings) when all you would need to do
> is include_directories(${foobar})? These definitions do not propagate to
> parent directories so you can just set them in a test subdirectory and they
> remain isolated.

Yes, that is ugly.

The reason I did it that way was because CMake seems to have a preference for storing the include dirs and link libraries on a per-directory basis rather than a per-target basis. Or at least, I was hitting problems where I would end up with absurdly long linker lines because it was pulling in all the stuff from the directories before it.

I'll need to have another look at whether or not I was just hacking around some problem that I may have fixed later on.

>
> On this line the word "library" is misspelt:
>
> list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})

ack.

Revision history for this message
Thomas Voß (thomas-voss) wrote :

+1 for Jussi's remarks.

Regarding Google Test: It is recommended in [*] that Google Test is distributed together with the respective project. It provides a simple CMake setup that allows for adding it in by means of add_subdirectory in compiz' CMake setup.

[*] http://code.google.com/p/googletest/wiki/V1_6_Primer#Setting_up_a_New_Test_Project

review: Needs Fixing
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

There's nothing wrong with keeping target definitions to a minimum. But you should still set them with the default commands.

You can control which settings propagate to subdirectories quite easily. If you have something like this:

add_definitions(-DTHING1)
add_subdirectory(foo)
add_definitions(-DTHING2)

add_executable(thing thing.c)

then only THING1 is defined in subdirectory foo and both THING1 and THING2 are defined for "thing" executable. Include directories and others work the same way.

And further, if you have multiple targets in one subdirectory that have massively different (and possibly conflicting) build requirements, it's a pretty strong indication that they should be moved further away from each other.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Mon, Nov 21, 2011 at 6:18 PM, Thomas Voß <email address hidden>wrote:

>
> Regarding Google Test: It is recommended in [*] that Google Test is
> distributed together with the respective project. It provides a simple
> CMake setup that allows for adding it in by means of add_subdirectory in
> compiz' CMake setup.
>
> [*]
> http://code.google.com/p/googletest/wiki/V1_6_Primer#Setting_up_a_New_Test_Project
>
>
Hmmmm, this seems all kinds of wrong, it shouldn't be necessary to
statically link it in.

> --
>
> https://code.launchpad.net/~compiz-team/compiz-core/compiz-core.fix_883102/+merge/80803<https://code.launchpad.net/%7Ecompiz-team/compiz-core/compiz-core.fix_883102/+merge/80803>
> Your team Compiz Maintainers is requested to review the proposed merge of
> lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core.
>

--
Sam Spilsbury

Revision history for this message
Thomas Voß (thomas-voss) wrote :

> On Mon, Nov 21, 2011 at 6:18 PM, Thomas Voß <email address hidden>wrote:
>
> >
> > Regarding Google Test: It is recommended in [*] that Google Test is
> > distributed together with the respective project. It provides a simple
> > CMake setup that allows for adding it in by means of add_subdirectory in
> > compiz' CMake setup.
> >
> > [*]
> > http://code.google.com/p/googletest/wiki/V1_6_Primer#Setting_up_a_New_Test_P
> roject
> >
> >
> Hmmmm, this seems all kinds of wrong, it shouldn't be necessary to
> statically link it in.
>
>

Wouldn't do it by default. How about introducing a cmake option then?

  Thomas

> > --
> >
> > https://code.launchpad.net/~compiz-team/compiz-core/compiz-
> core.fix_883102/+merge/80803<https://code.launchpad.net/%7Ecompiz-team/compiz-
> core/compiz-core.fix_883102/+merge/80803>
> > Your team Compiz Maintainers is requested to review the proposed merge of
> > lp:~compiz-team/compiz-core/compiz-core.fix_883102 into lp:compiz-core.
> >
>
>
>
> --
> Sam Spilsbury

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-09-09 09:54:02 +0000
3+++ CMakeLists.txt 2011-11-01 23:21:23 +0000
4@@ -82,16 +82,6 @@
5 compiz_configure_file (${compiz_SOURCE_DIR}/config.h.core.in ${compiz_BINARY_DIR}/generated/config.h)
6
7 compiz_configure_file (
8- ${CMAKE_SOURCE_DIR}/include/compiz-common.h.in
9- ${CMAKE_BINARY_DIR}/generated/compiz-common.h
10-)
11-
12-install (
13- FILES ${CMAKE_BINARY_DIR}/generated/compiz-common.h
14- DESTINATION ${COMPIZ_DESTDIR}${includedir}/compiz
15-)
16-
17-compiz_configure_file (
18 ${CMAKE_SOURCE_DIR}/compiz.pc.in
19 ${CMAKE_BINARY_DIR}/compiz.pc
20 COMPIZ_REQUIRES
21@@ -115,10 +105,6 @@
22 add_subdirectory (xslt)
23 add_subdirectory (plugins)
24
25-if (BUILD_TESTING)
26- add_subdirectory (tests)
27-endif (BUILD_TESTING)
28-
29 compiz_ensure_linkage ()
30 compiz_package_generation ("Compiz")
31 compiz_add_uninstall ()
32
33=== modified file 'cmake/CompizCommon.cmake'
34--- cmake/CompizCommon.cmake 2011-09-19 13:00:51 +0000
35+++ cmake/CompizCommon.cmake 2011-11-01 23:21:23 +0000
36@@ -489,6 +489,380 @@
37 endif ()
38 endfunction ()
39
40+#### modules / tests
41+macro (_get_parameters _prefix)
42+ set (_current_var _foo)
43+ set (_supported_var PKGDEPS PLUGINDEPS MODULES LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS DEFSADD)
44+ foreach (_val ${_supported_var})
45+ set (${_prefix}_${_val})
46+ endforeach (_val)
47+ foreach (_val ${ARGN})
48+ set (_found FALSE)
49+ foreach (_find ${_supported_var})
50+ if ("${_find}" STREQUAL "${_val}")
51+ set (_found TRUE)
52+ endif ("${_find}" STREQUAL "${_val}")
53+ endforeach (_find)
54+
55+ if (_found)
56+ set (_current_var ${_prefix}_${_val})
57+ else (_found)
58+ list (APPEND ${_current_var} ${_val})
59+ endif (_found)
60+ endforeach (_val)
61+endmacro (_get_parameters)
62+
63+macro (_check_pkg_deps _prefix)
64+ set (${_prefix}_HAS_PKG_DEPS TRUE)
65+ foreach (_val ${ARGN})
66+ string (REGEX REPLACE "[<>=\\.]" "_" _name ${_val})
67+ string (TOUPPER ${_name} _name)
68+
69+ compiz_pkg_check_modules (_${_name} ${_val})
70+
71+ if (_${_name}_FOUND)
72+ list (APPEND ${_prefix}_PKG_LIBDIRS "${_${_name}_LIBRARY_DIRS}")
73+ list (APPEND ${_prefix}_PKG_LIBRARIES "${_${_name}_LIBRARIES}")
74+ list (APPEND ${_prefix}_PKG_INCDIRS "${_${_name}_INCLUDE_DIRS}")
75+ else (_${_name}_FOUND)
76+ set (${_prefix}_HAS_PKG_DEPS FALSE)
77+ compiz_set (${_prefix}_MISSING_DEPS "${${_prefix}_MISSING_DEPS} ${_val}")
78+ set(__pkg_config_checked__${_name} 0 CACHE INTERNAL "" FORCE)
79+ endif (_${_name}_FOUND)
80+ endforeach ()
81+endmacro (_check_pkg_deps)
82+
83+macro (_build_include_flags _prefix)
84+ foreach (_include ${ARGN})
85+ if (NOT ${_prefix}_INCLUDE_CFLAGS)
86+ compiz_set (${_prefix}_INCLUDE_CFLAGS "" PARENT_SCOPE)
87+ endif (NOT ${_prefix}_INCLUDE_CFLAGS)
88+ list (APPEND ${_prefix}_INCLUDE_CFLAGS -I${_include})
89+ endforeach (_include)
90+endmacro (_build_include_flags)
91+
92+macro (_build_definitions_flags _prefix)
93+ foreach (_def ${ARGN})
94+ if (NOT ${_prefix}_DEFINITIONS_CFLAGS)
95+ compiz_set (${_prefix}_DEFINITIONS_CFLAGS "")
96+ endif (NOT ${_prefix}_DEFINITIONS_CFLAGS)
97+ list (APPEND ${_prefix}_DEFINITIONS_CFLAGS -D${_def})
98+ endforeach (_def)
99+endmacro (_build_definitions_flags)
100+
101+macro (_build_link_dir_flags _prefix)
102+ foreach (_link_dir ${ARGN})
103+ if (NOT ${_prefix}_LINK_DIR_LDFLAGS)
104+ compiz_set (${_prefix}_LINK_DIR_LDFLAGS "")
105+ endif (NOT ${_prefix}_LINK_DIR_LDFLAGS)
106+ list (APPEND ${_prefix}_LINK_DIR_LDFLAGS -L${_link_dir})
107+ endforeach (_link_dir)
108+endmacro (_build_link_dir_flags)
109+
110+macro (_build_library_flags _prefix)
111+ foreach (_library ${ARGN})
112+ if (NOT ${_prefix}_LIBRARY_LDFLAGS)
113+ compiz_set (${_prefix}_LIBRARY_LDFLAGS "")
114+ endif (NOT ${_prefix}_LIBRARY_LDFLAGS)
115+ list (APPEND ${_prefix}_LIBRARY_LDFLAGS -l${_library})
116+ endforeach (_library)
117+endmacro (_build_library_flags)
118+
119+function (_build_compiz_module _prefix _name _full_prefix)
120+
121+ if (${_full_prefix}_INCLUDE_DIRS)
122+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIRS})
123+ endif (${_full_prefix}_INCLUDE_DIRS)
124+ _build_include_flags (${_full_prefix} ${${_full_prefix}_SOURCE_DIR})
125+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIR})
126+
127+ if (${_full_prefix}_DEFSADD)
128+ _build_definitions_flags (${_full_prefix} ${${_full_prefix}_DEFSADD})
129+ endif (${_full_prefix}_DEFSADD)
130+
131+ if (${_full_prefix}_LIBRARY_DIRS)
132+ _build_link_dir_flags (${_full_prefix} ${${_full_prefix}_LIBRARY_DIRS})
133+ endif (${_full_prefix}_LIBRARY_DIRS)
134+
135+ if (${_full_prefix}_LIBRARIES)
136+ _build_library_flags (${_full_prefix} ${${_full_prefix}_LIBRARIES})
137+ endif (${_full_prefix}_LIBRARIES)
138+
139+ file (GLOB _cpp_files "${${_full_prefix}_SOURCE_DIR}/*.cpp")
140+
141+ add_library (${_prefix}_${_name}_internal STATIC ${_cpp_files})
142+
143+ target_link_libraries (${_prefix}_${_name}_internal
144+ ${${_full_prefix}_LIBRARIES} m pthread dl)
145+
146+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_INCLUDE_CFLAGS})
147+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_DEFINITIONS_CFLAGS})
148+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_CFLAGSADD})
149+
150+ set (${_full_prefix}_COMPILE_FLAGS_STR " ")
151+ foreach (_flag ${${_full_prefix}_COMPILE_FLAGS})
152+ set (${_full_prefix}_COMPILE_FLAGS_STR "${_flag} ${${_full_prefix}_COMPILE_FLAGS_STR}")
153+ endforeach (_flag)
154+
155+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LINK_LDFLAGS})
156+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LDFLAGSADD})
157+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})
158+
159+ set (${_full_prefix}_LINK_FLAGS_STR " ")
160+ foreach (_flag ${${_full_prefix}_LINK_FLAGS})
161+ set (${_full_prefix}_LINK_FLAGS_STR "${_flag} ${${_full_prefix}_LINK_FLAGS_STR}")
162+ endforeach (_flag)
163+
164+ set_target_properties (${_prefix}_${_name}_internal PROPERTIES
165+ COMPILE_FLAGS ${${_full_prefix}_COMPILE_FLAGS_STR}
166+ LINK_FLAGS ${${_full_prefix}_LINK_FLAGS_STR})
167+
168+ file (GLOB _h_files "${_full_prefix}_INCLUDE_DIR/*.h")
169+
170+ foreach (_file ${_h_files})
171+
172+ install (
173+ FILES ${_file}
174+ DESTINATION ${COMPIZ_DESTDIR}${includedir}/compiz/${_prefix}
175+ )
176+
177+ endforeach (_file)
178+
179+endfunction (_build_compiz_module)
180+
181+macro (compiz_module _prefix _name)
182+
183+ string (TOUPPER ${_prefix} _PREFIX)
184+ string (TOUPPER ${_name} _NAME)
185+ set (_FULL_PREFIX ${_PREFIX}_${_NAME})
186+
187+ _get_parameters (${_FULL_PREFIX} ${ARGN})
188+ _check_pkg_deps (${_FULL_PREFIX} ${${_FULL_PREFIX}_PKGDEPS})
189+
190+ if (${_FULL_PREFIX}_HAS_PKG_DEPS)
191+
192+ list (APPEND ${_FULL_PREFIX}_LIBRARIES ${${_FULL_PREFIX}_PKG_LIBRARIES})
193+ list (APPEND ${_FULL_PREFIX}_INCLUDE_DIRS ${${_FULL_PREFIX}_INCDIRS})
194+ list (APPEND ${_FULL_PREFIX}_INCLUDE_DIRS ${${_FULL_PREFIX}_PKG_INCDIRS})
195+ list (APPEND ${_FULL_PREFIX}_LIBRARY_DIRS ${${_FULL_PREFIX}_LIBDIRS})
196+ list (APPEND ${_FULL_PREFIX}_LIBRARY_DIRS ${${_FULL_PREFIX}_PKG_LIBDIRS})
197+
198+ # also add modules
199+ foreach (_module ${${_FULL_PREFIX}_MODULES})
200+ string (TOUPPER ${_module} _MODULE)
201+ list (APPEND ${_FULL_PREFIX}_INCLUDE_DIRS ${${_MODULE}_INCLUDE_DIR})
202+ list (APPEND ${_FULL_PREFIX}_LIBRARY_DIRS ${${_MODULE}_BINARY_DIR})
203+ list (APPEND ${_FULL_PREFIX}_LIBRARIES ${_module}_internal)
204+ endforeach (_module)
205+
206+ compiz_set (${_FULL_PREFIX}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${_name})
207+ compiz_set (${_FULL_PREFIX}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_name}/src)
208+ compiz_set (${_FULL_PREFIX}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_name}/include)
209+ compiz_set (${_FULL_PREFIX}_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_name}tests)
210+
211+ # Need to abuse set_property here since set () with CACHE INTERNAL will save the
212+ # value to the cache which we will just read right back (but we need to regenerate that)
213+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_LIBRARY_DIRS ${${_FULL_PREFIX}_BINARY_DIR})
214+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_INCLUDE_DIRS ${${_FULL_PREFIX}_INCLUDE_DIR})
215+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_INCLUDE_DIRS ${${_FULL_PREFIX}_SOURCE_DIR})
216+ set_property (GLOBAL APPEND PROPERTY ${_PREFIX}_MOD_LIBRARIES ${_prefix}_${_name}_internal)
217+
218+ _build_compiz_module (${_prefix} ${_name} ${_FULL_PREFIX})
219+
220+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/${_name}/tests)
221+
222+ else (${_FULL_PREFIX}_HAS_PKG_DEPS)
223+ message (STATUS "[WARNING] One or more dependencies for module ${_name} for ${_prefix} not found. Skipping module.")
224+ message (STATUS "Missing dependencies :${${_FULL_PREFIX}_MISSING_DEPS}")
225+ compiz_set (${_FULL_PREFIX}_BUILD FALSE)
226+ endif (${_FULL_PREFIX}_HAS_PKG_DEPS)
227+
228+
229+endmacro (compiz_module)
230+
231+function (_build_compiz_test_base _prefix _module _full_prefix)
232+
233+ file (GLOB _cpp_files "${${_FULL_TEST_BASE_PREFIX}_SOURCE_DIR}/*.cpp")
234+
235+ if (${_full_prefix}_INCLUDE_DIRS)
236+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIRS})
237+ endif (${_full_prefix}_INCLUDE_DIRS)
238+ _build_include_flags (${_full_prefix} ${${_full_prefix}_SOURCE_DIR})
239+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIR})
240+
241+ if (${_full_prefix}_DEFSADD)
242+ _build_definitions_flags (${_full_prefix} ${${_full_prefix}_DEFSADD})
243+ endif (${_full_prefix}_DEFSADD)
244+
245+ if (${_full_prefix}_LIBRARY_DIRS)
246+ _build_link_dir_flags (${_full_prefix} ${${_full_prefix}_LIBRARY_DIRS})
247+ endif (${_full_prefix}_LIBRARY_DIRS)
248+
249+ if (${_full_prefix}_LIBRARIES)
250+ _build_library_flags (${_full_prefix} ${${_full_prefix}_LIBRARIES})
251+ endif (${_full_prefix}_LIBRARIES)
252+
253+ add_library (${_prefix}_${_module}_test_internal STATIC
254+ ${_cpp_files})
255+
256+ target_link_libraries (${_prefix}_${_module}_test_internal
257+ ${${_full_prefix}_LIBRARIES}
258+ ${_prefix}_${_module}_internal)
259+
260+
261+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_INCLUDE_CFLAGS})
262+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_DEFINITIONS_CFLAGS})
263+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_CFLAGSADD})
264+
265+ set (${_full_prefix}_COMPILE_FLAGS_STR " ")
266+ foreach (_flag ${${_full_prefix}_COMPILE_FLAGS})
267+ set (${_full_prefix}_COMPILE_FLAGS_STR "${_flag} ${${_full_prefix}_COMPILE_FLAGS_STR}")
268+ endforeach (_flag)
269+
270+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LINK_LDFLAGS})
271+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LDFLAGSADD})
272+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})
273+
274+ set (${_full_prefix}_LINK_FLAGS_STR " ")
275+ foreach (_flag ${${_full_prefix}_LINK_FLAGS})
276+ set (${_full_prefix}_LINK_FLAGS_STR "${_flag} ${${_full_prefix}_LINK_FLAGS_STR}")
277+ endforeach (_flag)
278+
279+ set_target_properties (${_prefix}_${_module}_test_internal PROPERTIES
280+ COMPILE_FLAGS "${${_full_prefix}_COMPILE_FLAGS_STR}"
281+ LINK_FLAGS "${${_full_prefix}_LINK_FLAGS_STR}")
282+endfunction (_build_compiz_test_base)
283+
284+macro (compiz_test_base _prefix _module)
285+
286+ string (TOUPPER ${_prefix} _PREFIX)
287+ string (TOUPPER ${_module} _MODULE)
288+
289+ set (_FULL_MODULE_PREFIX ${_PREFIX}_${_NAME})
290+ set (_FULL_TEST_BASE_PREFIX ${_FULL_MODULE_PREFIX}_TEST_BASE)
291+
292+ _get_parameters (${_FULL_TEST_BASE_PREFIX} ${ARGN})
293+ _check_pkg_deps (${_FULL_TEST_BASE_PREFIX} ${${_FULL_TEST_BASE_PREFIX}_PKGDEPS})
294+
295+ if (${_FULL_TEST_BASE_PREFIX}_HAS_PKG_DEPS)
296+
297+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARIES ${${_FULL_TEST_BASE_PREFIX}_PKG_LIBDIRS})
298+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_INCDIRS})
299+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_PKG_INCDIRS})
300+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_LIBDIRS})
301+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_PKG_LIBDIRS})
302+
303+ compiz_set (${_FULL_TEST_BASE_PREFIX}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
304+ compiz_set (${_FULL_TEST_BASE_PREFIX}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
305+ compiz_set (${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
306+
307+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_MODULE_PREFIX}_INCLUDE_DIRS})
308+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_MODULE_PREFIX}_INCLUDE_DIR})
309+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS ${${_FULL_MODULE_PREFIX}_SOURCE_DIR})
310+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_MODULE_PREFIX}_LIBRARY_DIRS})
311+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS ${${_FULL_MODULE_PREFIX}_BINARY_DIR})
312+ list (APPEND ${_FULL_TEST_BASE_PREFIX}_LIBRARIES ${${_FULL_MODULE_PREFIX}_LIBRARIES})
313+
314+ _build_compiz_test_base (${_prefix} ${_module} ${_FULL_TEST_BASE_PREFIX})
315+ else (${_FULL_TEST_BASE_PREFIX}_HAS_PKG_DEPS)
316+ message (STATUS "[WARNING] One or more dependencies for test base on module ${_module} for ${_prefix} not found. Skipping test base.")
317+ message (STATUS "Missing dependencies :${${_FULL_TEST_BASE_PREFIX}_MISSING_DEPS}")
318+ compiz_set (${_FULL_TEST_BASE_PREFIX}_BUILD FALSE)
319+ endif (${_FULL_TEST_BASE_PREFIX}_HAS_PKG_DEPS)
320+endmacro (compiz_test_base)
321+
322+function (_build_compiz_test _prefix _module _test _full_prefix)
323+ file (GLOB _cpp_files "${${_FULL_TEST_PREFIX}_SOURCE_DIR}/*.cpp")
324+
325+ if (${_full_prefix}_INCLUDE_DIRS)
326+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIRS})
327+ endif (${_full_prefix}_INCLUDE_DIRS)
328+ _build_include_flags (${_full_prefix} ${${_full_prefix}_SOURCE_DIR})
329+ _build_include_flags (${_full_prefix} ${${_full_prefix}_INCLUDE_DIR})
330+
331+ if (${_full_prefix}_DEFSADD)
332+ _build_definitions_flags (${_full_prefix} ${${_full_prefix}_DEFSADD})
333+ endif (${_full_prefix}_DEFSADD)
334+
335+ if (${_full_prefix}_LIBRARY_DIRS)
336+ _build_link_dir_flags (${_full_prefix} ${${_full_prefix}_LIBRARY_DIRS})
337+ endif (${_full_prefix}_LIBRARY_DIRS)
338+
339+ if (${_full_prefix}_LIBRARIES)
340+ _build_library_flags (${_full_prefix} ${${_full_prefix}_LIBRARIES})
341+ endif (${_full_prefix}_LIBRARIES)
342+
343+ add_executable (${_prefix}_${_module}_${_test}_test
344+ ${_cpp_files})
345+
346+ target_link_libraries (${_prefix}_${_module}_${_test}_test
347+ ${${_full_prefix}_LIBRARIES}
348+ ${_prefix}_${_module}_internal
349+ ${_prefix}_${_module}_test_internal)
350+
351+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_INCLUDE_CFLAGS})
352+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_DEFINITIONS_CFLAGS})
353+ list (APPEND ${_full_prefix}_COMPILE_FLAGS ${${_full_prefix}_CFLAGSADD})
354+
355+ set (${_full_prefix}_COMPILE_FLAGS_STR " ")
356+ foreach (_flag ${${_full_prefix}_COMPILE_FLAGS})
357+ set (${_full_prefix}_COMPILE_FLAGS_STR "${_flag} ${${_full_prefix}_COMPILE_FLAGS_STR}")
358+ endforeach (_flag)
359+
360+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LINK_LDFLAGS})
361+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LDFLAGSADD})
362+ list (APPEND ${_full_prefix}_LINK_FLAGS ${${_full_prefix}_LIBARY_FLAGS})
363+
364+ set (${_full_prefix}_LINK_FLAGS_STR " ")
365+ foreach (_flag ${${_full_prefix}_LINK_FLAGS})
366+ set (${_full_prefix}_LINK_FLAGS_STR "${_flag} ${${_full_prefix}_LINK_FLAGS_STR}")
367+ endforeach (_flag)
368+
369+ set_target_properties (${_prefix}_${_module}_${_test}_test PROPERTIES
370+ COMPILE_FLAGS "${${_full_prefix}_COMPILE_FLAGS_STR}"
371+ LINK_FLAGS "${${_full_prefix}_LINK_FLAGS_STR}")
372+
373+ add_test (test-${_prefix}-${_module}-${_test}
374+ ${CMAKE_CURRENT_BINARY_DIR}/${_prefix}_${_module}_${_test}_test)
375+endfunction (_build_compiz_test)
376+
377+macro (compiz_test _prefix _module _test)
378+
379+ set (_supported_var PKGDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS DEFSADD)
380+
381+ set (_FULL_TEST_PREFIX ${_FULL_MODULE_PREFIX}_TEST)
382+
383+ _get_parameters (${_FULL_TEST_PREFIX} ${ARGN})
384+ _check_pkg_deps (${_FULL_TEST_PREFIX} ${${_FULL_TEST_PREFIX}_PKGDEPS})
385+
386+ if (${_FULL_TEST_PREFIX}_HAS_PKG_DEPS)
387+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARIES ${${_FULL_TEST_PREFIX}_PKG_LIBDIRS})
388+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_PREFIX}_INCDIRS})
389+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_PREFIX}_PKG_INCDIRS})
390+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_PREFIX}_LIBDIRS})
391+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_PREFIX}_PKG_LIBDIRS})
392+
393+ compiz_set (${_FULL_TEST_PREFIX}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
394+ compiz_set (${_FULL_TEST_PREFIX}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
395+ compiz_set (${_FULL_TEST_PREFIX}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
396+
397+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIRS})
398+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_INCLUDE_DIR})
399+ list (APPEND ${_FULL_TEST_PREFIX}_INCLUDE_DIRS ${${_FULL_TEST_BASE_PREFIX}_SOURCE_DIR})
400+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_LIBRARY_DIRS})
401+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARY_DIRS ${${_FULL_TEST_BASE_PREFIX}_BINARY_DIR})
402+ list (APPEND ${_FULL_TEST_PREFIX}_LIBRARIES ${${_FULL_TEST_BASE_PREFIX}_LIBRARIES})
403+
404+ _build_compiz_test (${_prefix} ${_module} ${_test} ${_FULL_TEST_PREFIX})
405+
406+ else (${_FULL_TEST_PREFIX}_HAS_PKG_DEPS)
407+ message (STATUS "[WARNING] One or more dependencies for test ${_test} on module ${_name} for ${_prefix} not found. Skipping test.")
408+ message (STATUS "Missing dependencies :${${_FULL_TEST_PREFIX}_MISSING_DEPS}")
409+ compiz_set (${_FULL_TEST_PREFIX}_BUILD FALSE)
410+ endif (${_FULL_TEST_PREFIX}_HAS_PKG_DEPS)
411+
412+endmacro (compiz_test)
413+
414 #### optional file install
415
416 function (compiz_opt_install_file _src _dst)
417
418=== modified file 'cmake/CompizPlugin.cmake'
419--- cmake/CompizPlugin.cmake 2011-09-01 19:52:58 +0000
420+++ cmake/CompizPlugin.cmake 2011-11-01 23:21:23 +0000
421@@ -136,50 +136,6 @@
422 endif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package")
423 endmacro (_prepare_directories)
424
425-# parse plugin macro parameter
426-macro (_get_plugin_parameters _prefix)
427- set (_current_var _foo)
428- set (_supported_var PKGDEPS PLUGINDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS)
429- foreach (_val ${_supported_var})
430- set (${_prefix}_${_val})
431- endforeach (_val)
432- foreach (_val ${ARGN})
433- set (_found FALSE)
434- foreach (_find ${_supported_var})
435- if ("${_find}" STREQUAL "${_val}")
436- set (_found TRUE)
437- endif ("${_find}" STREQUAL "${_val}")
438- endforeach (_find)
439-
440- if (_found)
441- set (_current_var ${_prefix}_${_val})
442- else (_found)
443- list (APPEND ${_current_var} ${_val})
444- endif (_found)
445- endforeach (_val)
446-endmacro (_get_plugin_parameters)
447-
448-# check pkgconfig dependencies
449-macro (_check_plugin_pkg_deps _prefix)
450- set (${_prefix}_HAS_PKG_DEPS TRUE)
451- foreach (_val ${ARGN})
452- string (REGEX REPLACE "[<>=\\.]" "_" _name ${_val})
453- string (TOUPPER ${_name} _name)
454-
455- compiz_pkg_check_modules (_${_name} ${_val})
456-
457- if (_${_name}_FOUND)
458- list (APPEND ${_prefix}_PKG_LIBDIRS "${_${_name}_LIBRARY_DIRS}")
459- list (APPEND ${_prefix}_PKG_LIBRARIES "${_${_name}_LIBRARIES}")
460- list (APPEND ${_prefix}_PKG_INCDIRS "${_${_name}_INCLUDE_DIRS}")
461- else ()
462- set (${_prefix}_HAS_PKG_DEPS FALSE)
463- compiz_set (COMPIZ_${_prefix}_MISSING_DEPS "${COMPIZ_${_prefix}_MISSING_DEPS} ${_val}")
464- set(__pkg_config_checked__${_name} 0 CACHE INTERNAL "" FORCE)
465- endif ()
466- endforeach ()
467-endmacro ()
468-
469 # check plugin dependencies
470 macro (_check_plugin_plugin_deps _prefix)
471 set (${_prefix}_HAS_PLUGIN_DEPS TRUE)
472@@ -216,9 +172,6 @@
473 endforeach ()
474 endmacro ()
475
476-
477-
478-
479 # main function
480 function (_build_compiz_plugin plugin)
481 string (TOUPPER ${plugin} _PLUGIN)
482@@ -235,7 +188,7 @@
483 )
484 endif (COMPIZ_PLUGIN_INSTALL_TYPE)
485
486- _get_plugin_parameters (${_PLUGIN} ${ARGN})
487+ _get_parameters (${_PLUGIN} ${ARGN})
488 _prepare_directories ()
489
490 find_file (
491@@ -259,7 +212,7 @@
492 # check dependencies
493 compiz_unset (COMPIZ_${_PLUGIN}_MISSING_DEPS)
494 _check_plugin_plugin_deps (${_PLUGIN} ${${_PLUGIN}_PLUGINDEPS})
495- _check_plugin_pkg_deps (${_PLUGIN} ${${_PLUGIN}_PKGDEPS})
496+ _check_pkg_deps (${_PLUGIN} ${${_PLUGIN}_PKGDEPS})
497
498 if (${_PLUGIN}_HAS_PKG_DEPS AND ${_PLUGIN}_HAS_PLUGIN_DEPS)
499
500@@ -357,6 +310,30 @@
501 add_definitions (-DPREFIX='\"${PLUGIN_PREFIX}\"'
502 ${COMPIZ_DEFINITIONS_ADD})
503
504+ foreach (_def ${_PLUGIN}_DEFSADD)
505+ add_definitions (-D${_def})
506+ endforeach (_def)
507+
508+ # Need to know the include-dirs for the internal
509+ # modules to this plugin, core (if built with core)
510+ # and any other plugins that we depend on
511+
512+ get_property (${_PLUGIN}_MOD_INCLUDE_DIRS
513+ GLOBAL
514+ PROPERTY ${_PLUGIN}_MOD_INCLUDE_DIRS)
515+
516+ get_property (CORE_MOD_INCLUDE_DIRS
517+ GLOBAL
518+ PROPERTY CORE_MOD_INCLUDE_DIRS)
519+
520+ foreach (_plugindep ${${_PLUGIN}_PLUGINDEPS})
521+ string (TOUPPER ${_plugindep} _PLUGINDEP)
522+ get_property (${_PLUGINDEP}_MOD_INCLUDE_DIRS
523+ GLOBAL
524+ PROPERTY ${_PLUGINDEP}_MOD_INCLUDE_DIRS)
525+ list (APPEND ${_PLUGIN}_PLUGINDEP_MOD_INCLUDE_DIRS ${${_PLUGINDEP}_MOD_INCLUDE_DIRS})
526+ endforeach (_plugindep)
527+
528 include_directories (
529 ${CMAKE_CURRENT_SOURCE_DIR}/src
530 ${CMAKE_CURRENT_SOURCE_DIR}/include
531@@ -367,8 +344,15 @@
532 ${COMPIZ_INCLUDE_DIRS}
533 ${CMAKE_PREFIX_PATH}/include
534 ${CMAKE_INCLUDE_PATH}
535+ ${${_PLUGIN}_MOD_INCLUDE_DIRS}
536+ ${CORE_MOD_INCLUDE_DIRS}
537+ ${${_PLUGIN}_PLUGINDEP_MOD_INCLUDE_DIRS}
538 )
539
540+ get_property (${_PLUGIN}_MOD_LIBRARY_DIRS
541+ GLOBAL
542+ PROPERTY ${_PLUGIN}_MOD_LIBRARY_DIRS)
543+
544 link_directories (
545 ${COMPIZ_LINK_DIRS}
546 ${${_PLUGIN}_PKG_LIBDIRS}
547@@ -378,6 +362,7 @@
548 ${CMAKE_PREFIX_PATH}/lib
549 ${CMAKE_PREFIX_PATH}/lib32
550 ${CMAKE_PREFIX_PATH}/lib64
551+ ${${_PLUGIN}_MOD_LIBRARY_DIRS}
552 )
553
554 add_library (
555@@ -409,11 +394,16 @@
556 )
557 endif (COMPIZ_BUILD_WITH_RPATH)
558
559+ get_property (${_PLUGIN}_MOD_LIBRARIES
560+ GLOBAL
561+ PROPERTY ${_PLUGIN}_MOD_LIBRARIES)
562+
563 target_link_libraries (
564 ${plugin} ${COMPIZ_LIBRARIES}
565 ${${_PLUGIN}_LOCAL_LIBRARIES}
566 ${${_PLUGIN}_PKG_LIBRARIES}
567 ${${_PLUGIN}_LIBRARIES}
568+ ${${_PLUGIN}_MOD_LIBRARIES}
569 )
570
571 install (
572
573=== modified file 'include/CMakeLists.txt'
574--- include/CMakeLists.txt 2010-05-18 11:30:17 +0000
575+++ include/CMakeLists.txt 2011-11-01 23:21:23 +0000
576@@ -1,5 +1,4 @@
577 set (_headers
578- compiz.h
579 decoration.h
580 )
581
582
583=== removed file 'include/compiz-common.h.in'
584--- include/compiz-common.h.in 2011-07-06 22:55:10 +0000
585+++ include/compiz-common.h.in 1970-01-01 00:00:00 +0000
586@@ -1,5 +0,0 @@
587-#ifndef COMPIZ_COMMON_H
588-#define COMPIZ_COMMON_H
589-
590-#define COMPIZ_VERSION_STRING "@VERSION@"
591-#endif
592
593=== removed file 'include/compiz.h'
594--- include/compiz.h 2011-06-25 05:06:53 +0000
595+++ include/compiz.h 1970-01-01 00:00:00 +0000
596@@ -1,103 +0,0 @@
597-/*
598- * Copyright © 2007 Novell, Inc.
599- *
600- * Permission to use, copy, modify, distribute, and sell this software
601- * and its documentation for any purpose is hereby granted without
602- * fee, provided that the above copyright notice appear in all copies
603- * and that both that copyright notice and this permission notice
604- * appear in supporting documentation, and that the name of
605- * Novell, Inc. not be used in advertising or publicity pertaining to
606- * distribution of the software without specific, written prior permission.
607- * Novell, Inc. makes no representations about the suitability of this
608- * software for any purpose. It is provided "as is" without express or
609- * implied warranty.
610- *
611- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
612- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
613- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
614- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
615- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
616- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
617- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
618- *
619- * Author: David Reveman <davidr@novell.com>
620- */
621-
622-#ifndef _COMPIZ_H
623-#define _COMPIZ_H
624-
625-#include <compiz-common.h>
626-
627-#include <string>
628-#include <list>
629-#include <cstdarg>
630-
631-#define STRINGIFY(x) #x
632-#define TOSTRING(x) STRINGIFY (x)
633-
634-#define RESTRICT_VALUE(value, min, max) \
635- (((value) < (min)) ? (min): ((value) > (max)) ? (max) : (value))
636-
637-#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
638-
639-#define TIMEVALDIFF(tv1, tv2) \
640- ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
641- ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
642- ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \
643- ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
644- (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
645-
646-#define TIMESPECDIFF(ts1, ts2) \
647- ((ts1)->tv_sec == (ts2)->tv_sec || (ts1)->tv_nsec >= (ts2)->tv_nsec) ? \
648- ((((ts1)->tv_sec - (ts2)->tv_sec) * 1000000) + \
649- ((ts1)->tv_nsec - (ts2)->tv_nsec)) / 1000000 : \
650- ((((ts1)->tv_sec - 1 - (ts2)->tv_sec) * 1000000) + \
651- (1000000 + (ts1)->tv_nsec - (ts2)->tv_nsec)) / 1000000
652-
653-#define MULTIPLY_USHORT(us1, us2) \
654- (((GLuint) (us1) * (GLuint) (us2)) / 0xffff)
655-
656-#define DEG2RAD (M_PI / 180.0f)
657-
658-#if defined(HAVE_SCANDIR_POSIX)
659- // POSIX (2008) defines the comparison function like this:
660- #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const dirent **, const dirent **))(d));
661-#else
662- #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const void*,const void*))(d));
663-#endif
664-
665-typedef std::string CompString;
666-typedef std::list<CompString> CompStringList;
667-
668-CompString compPrintf (const char *format, ...);
669-CompString compPrintf (const char *format, va_list ap);
670-
671-extern bool debugOutput;
672-
673-typedef enum {
674- CompLogLevelFatal = 0,
675- CompLogLevelError,
676- CompLogLevelWarn,
677- CompLogLevelInfo,
678- CompLogLevelDebug
679-} CompLogLevel;
680-
681-void
682-logMessage (const char *componentName,
683- CompLogLevel level,
684- const char *message);
685-
686-void
687-compLogMessage (const char *componentName,
688- CompLogLevel level,
689- const char *format,
690- ...);
691-
692-const char *
693-logLevelToString (CompLogLevel level);
694-
695-extern char *programName;
696-extern char **programArgv;
697-extern int programArgc;
698-
699-#endif
700
701=== modified file 'include/core/CMakeLists.txt'
702--- include/core/CMakeLists.txt 2011-07-07 16:59:41 +0000
703+++ include/core/CMakeLists.txt 2011-11-01 23:21:23 +0000
704@@ -10,8 +10,6 @@
705 output.h
706 plugin.h
707 point.h
708- pluginclasshandler.h
709- pluginclasses.h
710 propertywriter.h
711 privateunion.h
712 rect.h
713@@ -20,9 +18,6 @@
714 serialization.h
715 session.h
716 size.h
717- timeouthandler.h
718- timer.h
719- valueholder.h
720 window.h
721 wrapsystem.h
722 )
723
724=== modified file 'include/core/core.h'
725--- include/core/core.h 2011-10-13 09:53:38 +0000
726+++ include/core/core.h 2011-11-01 23:21:23 +0000
727@@ -32,6 +32,10 @@
728 #include <stdio.h>
729 #include <assert.h>
730
731+#include <string>
732+#include <list>
733+#include <cstdarg>
734+
735 #include <X11/Xlib-xcb.h>
736 #include <X11/Xutil.h>
737 #include <X11/extensions/Xdamage.h>
738@@ -69,6 +73,23 @@
739 # define BITMAP_BIT_ORDER LSBFirst
740 #endif
741
742+#define STRINGIFY(x) #x
743+#define TOSTRING(x) STRINGIFY (x)
744+#define DEG2RAD (M_PI / 180.0f)
745+
746+#if defined(HAVE_SCANDIR_POSIX)
747+ // POSIX (2008) defines the comparison function like this:
748+ #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const dirent **, const dirent **))(d));
749+#else
750+ #define scandir(a,b,c,d) scandir((a), (b), (c), (int(*)(const void*,const void*))(d));
751+#endif
752+
753+extern bool debugOutput;
754+
755+extern char *programName;
756+extern char **programArgv;
757+extern int programArgc;
758+
759 #include <core/pluginclasses.h>
760 #include <core/screen.h>
761 #include <core/window.h>
762@@ -85,5 +106,7 @@
763 #include <core/region.h>
764 #include <core/countedlist.h>
765 #include <core/timeouthandler.h>
766+#include <core/logmessage.h>
767+#include <core/string.h>
768
769 #endif
770
771=== modified file 'include/core/match.h'
772--- include/core/match.h 2010-03-24 01:31:41 +0000
773+++ include/core/match.h 2011-11-01 23:21:23 +0000
774@@ -28,6 +28,7 @@
775 #ifndef _COMPMATCH_H
776 #define _COMPMATCH_H
777
778+#include <core/string.h>
779 #include <core/core.h>
780
781 class PrivateMatch;
782
783=== modified file 'include/core/option.h'
784--- include/core/option.h 2011-03-16 19:39:25 +0000
785+++ include/core/option.h 2011-11-01 23:21:23 +0000
786@@ -28,8 +28,7 @@
787 #ifndef _COMPOPTION_H
788 #define _COMPOPTION_H
789
790-#include <compiz.h>
791-
792+#include <core/string.h>
793 #include <vector>
794
795 class PrivateOption;
796
797=== modified file 'include/core/plugin.h'
798--- include/core/plugin.h 2011-06-25 02:31:02 +0000
799+++ include/core/plugin.h 2011-11-01 23:21:23 +0000
800@@ -26,7 +26,7 @@
801 #ifndef _COMPIZ_PLUGIN_H
802 #define _COMPIZ_PLUGIN_H
803
804-#include <compiz.h>
805+#include <core/string.h>
806 #include <core/option.h>
807 #include <core/privateunion.h>
808
809
810=== modified file 'include/core/session.h'
811--- include/core/session.h 2009-03-05 19:42:59 +0000
812+++ include/core/session.h 2011-11-01 23:21:23 +0000
813@@ -28,6 +28,7 @@
814
815 #define SN_API_NOT_YET_FROZEN
816 #include <libsn/sn.h>
817+#include <core/string.h>
818
819 namespace CompSession {
820
821
822=== added file 'include/core/string.h'
823--- include/core/string.h 1970-01-01 00:00:00 +0000
824+++ include/core/string.h 2011-11-01 23:21:23 +0000
825@@ -0,0 +1,39 @@
826+/*
827+ * Copyright © 2007 Novell, Inc.
828+ *
829+ * Permission to use, copy, modify, distribute, and sell this software
830+ * and its documentation for any purpose is hereby granted without
831+ * fee, provided that the above copyright notice appear in all copies
832+ * and that both that copyright notice and this permission notice
833+ * appear in supporting documentation, and that the name of
834+ * Novell, Inc. not be used in advertising or publicity pertaining to
835+ * distribution of the software without specific, written prior permission.
836+ * Novell, Inc. makes no representations about the suitability of this
837+ * software for any purpose. It is provided "as is" without express or
838+ * implied warranty.
839+ *
840+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
841+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
842+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
843+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
844+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
845+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
846+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
847+ *
848+ * Author: David Reveman <davidr@novell.com>
849+ */
850+
851+#ifndef _COMPIZ_STRING_H
852+#define _COMPIZ_STRING_H
853+
854+#include <string>
855+#include <list>
856+#include <cstdarg>
857+
858+typedef std::string CompString;
859+typedef std::list<CompString> CompStringList;
860+
861+CompString compPrintf (const char *format, ...);
862+CompString compPrintf (const char *format, va_list ap);
863+
864+#endif
865
866=== modified file 'metadata/CMakeLists.txt'
867--- metadata/CMakeLists.txt 2011-08-18 18:15:11 +0000
868+++ metadata/CMakeLists.txt 2011-11-01 23:21:23 +0000
869@@ -9,9 +9,9 @@
870 if (XSLTPROC_EXECUTABLE)
871
872 add_custom_command (
873- OUTPUT ${CMAKE_BINARY_DIR}/generated/core.xml.in
874+ OUTPUT ${compiz_BINARY_DIR}/generated/core.xml.in
875 COMMAND ${XSLTPROC_EXECUTABLE}
876- -o ${CMAKE_BINARY_DIR}/generated/core.xml.in
877+ -o ${compiz_BINARY_DIR}/generated/core.xml.in
878 --param default_plugins "\"'${COMPIZ_DEFAULT_PLUGINS}'\""
879 ${CMAKE_SOURCE_DIR}/xslt/default_plugins.xslt
880 ${CMAKE_CURRENT_SOURCE_DIR}/core.xml.in
881
882=== modified file 'plugins/composite/src/screen.cpp'
883--- plugins/composite/src/screen.cpp 2011-10-15 11:00:51 +0000
884+++ plugins/composite/src/screen.cpp 2011-11-01 23:21:23 +0000
885@@ -43,6 +43,8 @@
886 #include <X11/extensions/shape.h>
887 #include <X11/extensions/Xrandr.h>
888
889+#include <core/timer.h>
890+
891 CompWindow *lastDamagedWindow = 0;
892
893 void
894@@ -696,7 +698,7 @@
895 {
896 int diff;
897
898- diff = TIMEVALDIFF (tv, &lastRedraw);
899+ diff = compiz::core::timer::timeval_diff (tv, &lastRedraw);
900
901 /* handle clock rollback */
902 if (diff < 0)
903@@ -791,7 +793,7 @@
904 if (priv->pHnd)
905 priv->pHnd->prepareDrawing ();
906
907- timeDiff = TIMEVALDIFF (&tv, &priv->lastRedraw);
908+ timeDiff = compiz::core::timer::timeval_diff (&tv, &priv->lastRedraw);
909
910 /* handle clock rollback */
911 if (timeDiff < 0)
912
913=== modified file 'plugins/opengl/src/matrix.cpp'
914--- plugins/opengl/src/matrix.cpp 2010-10-24 14:42:07 +0000
915+++ plugins/opengl/src/matrix.cpp 2011-11-01 23:21:23 +0000
916@@ -46,7 +46,6 @@
917 * From Mesa 3-D graphics library.
918 */
919
920-#include <compiz.h>
921 #include <string.h>
922 #include <math.h>
923 #include <core/core.h>
924
925=== modified file 'plugins/opengl/src/texture.cpp'
926--- plugins/opengl/src/texture.cpp 2011-02-24 07:52:09 +0000
927+++ plugins/opengl/src/texture.cpp 2011-11-01 23:21:23 +0000
928@@ -27,8 +27,6 @@
929 # include <config.h>
930 #endif
931
932-#include <compiz.h>
933-
934 #include <stdio.h>
935 #include <stdlib.h>
936 #include <string.h>
937
938=== modified file 'po/POTFILES.in'
939--- po/POTFILES.in 2009-10-18 20:23:24 +0000
940+++ po/POTFILES.in 2011-11-01 23:21:23 +0000
941@@ -1,7 +1,3 @@
942-gtk/gnome/50-compiz-desktop-key.xml.in
943-gtk/gnome/50-compiz-key.xml.in
944-gtk/gnome/compiz.desktop.in
945-gtk/gnome/compiz-wm.desktop.in
946 gtk/window-decorator/gwd.schemas.in
947 gtk/window-decorator/gtk-window-decorator.c
948 metadata/core.xml.in
949
950=== modified file 'src/CMakeLists.txt'
951--- src/CMakeLists.txt 2011-09-19 12:54:22 +0000
952+++ src/CMakeLists.txt 2011-11-01 23:21:23 +0000
953@@ -1,11 +1,29 @@
954 include (CompizBcop)
955
956+compiz_module (core string LIBRARIES ${Boost_LIBRARIES}
957+ INCDIRS ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
958+
959+compiz_module (core logmessage LIBRARIES ${Boost_LIBRARIES}
960+ INCDIRS ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
961+
962+compiz_module (core timer PKGDEPS glibmm-2.4
963+ LIBRARIES ${Boost_LIBRARIES}
964+ INCDIRS ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
965+
966+compiz_module (core pluginclasshandler MODULES core_string core_logmessage
967+ LIBRARIES ${Boost_LIBRARIES}
968+ INCDIRS ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
969+
970 compiz_add_bcop_targets (
971 core
972 ${compiz_BINARY_DIR}/generated/core.xml.in
973 _bcop_sources
974 )
975
976+get_property (CORE_MOD_INCLUDE_DIRS
977+ GLOBAL
978+ PROPERTY CORE_MOD_INCLUDE_DIRS)
979+
980 include_directories (
981 ${compiz_SOURCE_DIR}/include
982 ${compiz_BINARY_DIR}
983@@ -14,6 +32,7 @@
984 ${COMPIZ_INCLUDE_DIRS}
985 ${CMAKE_PREFIX_PATH}/include
986 ${CMAKE_INCLUDE_PATH}
987+ ${CORE_MOD_INCLUDE_DIRS}
988 )
989
990 add_definitions (
991@@ -23,23 +42,25 @@
992 -DMETADATADIR=\\\"${compiz_metadatadir}\\\"
993 )
994
995+get_property (CORE_MOD_LIBRARY_DIRS
996+ GLOBAL
997+ PROPERTY CORE_MOD_LIBRARY_DIRS)
998+
999 link_directories (
1000 ${COMPIZ_LINK_DIRS}
1001+ ${CORE_MOD_LIBRARY_DIRS}
1002 )
1003
1004 add_executable (compiz
1005 region.cpp
1006 atoms.cpp
1007- timer.cpp
1008 main.cpp
1009 actions.cpp
1010 screen.cpp
1011 window.cpp
1012 action.cpp
1013 option.cpp
1014- string.cpp
1015 match.cpp
1016- pluginclasses.cpp
1017 event.cpp
1018 plugin.cpp
1019 session.cpp
1020@@ -52,17 +73,28 @@
1021 modifierhandler.cpp
1022 propertywriter.cpp
1023 eventsource.cpp
1024- timeouthandler.cpp
1025- valueholder.cpp
1026- logmessage.cpp
1027 stackdebugger.cpp
1028 ${_bcop_sources}
1029 )
1030
1031+# workaround for build race
1032+add_dependencies (compiz core-xml-file)
1033+
1034+get_property (CORE_MOD_LIBRARIES
1035+ GLOBAL
1036+ PROPERTY CORE_MOD_LIBRARIES)
1037+
1038 target_link_libraries (
1039 compiz ${COMPIZ_LIBRARIES} m pthread dl
1040+ ${CORE_MOD_LIBRARIES}
1041 )
1042
1043+foreach (_lib ${CORE_MOD_LIBRARIES})
1044+ target_link_libraries (
1045+ compiz ${_lib}
1046+ )
1047+endforeach (_lib)
1048+
1049 install (
1050 TARGETS compiz
1051 DESTINATION ${COMPIZ_DESTDIR}${exec_prefix}
1052
1053=== modified file 'src/action.cpp'
1054--- src/action.cpp 2010-11-09 14:13:19 +0000
1055+++ src/action.cpp 2011-11-01 23:21:23 +0000
1056@@ -27,8 +27,6 @@
1057 #include <stdlib.h>
1058 #include <string.h>
1059
1060-#include <compiz.h>
1061-
1062 #include <core/option.h>
1063 #include <core/action.h>
1064 #include <core/screen.h>
1065
1066=== added directory 'src/logmessage'
1067=== added directory 'src/logmessage/include'
1068=== added directory 'src/logmessage/include/core'
1069=== added file 'src/logmessage/include/core/logmessage.h'
1070--- src/logmessage/include/core/logmessage.h 1970-01-01 00:00:00 +0000
1071+++ src/logmessage/include/core/logmessage.h 2011-11-01 23:21:23 +0000
1072@@ -0,0 +1,51 @@
1073+/*
1074+ * Copyright © 2007 Novell, Inc.
1075+ *
1076+ * Permission to use, copy, modify, distribute, and sell this software
1077+ * and its documentation for any purpose is hereby granted without
1078+ * fee, provided that the above copyright notice appear in all copies
1079+ * and that both that copyright notice and this permission notice
1080+ * appear in supporting documentation, and that the name of
1081+ * Novell, Inc. not be used in advertising or publicity pertaining to
1082+ * distribution of the software without specific, written prior permission.
1083+ * Novell, Inc. makes no representations about the suitability of this
1084+ * software for any purpose. It is provided "as is" without express or
1085+ * implied warranty.
1086+ *
1087+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1088+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1089+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1090+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1091+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1092+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1093+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1094+ *
1095+ * Author: David Reveman <davidr@novell.com>
1096+ */
1097+
1098+#ifndef _COMPIZ_LOGMESSAGE_H
1099+#define _COMPIZ_LOGMESSAGE_H
1100+
1101+typedef enum {
1102+ CompLogLevelFatal = 0,
1103+ CompLogLevelError,
1104+ CompLogLevelWarn,
1105+ CompLogLevelInfo,
1106+ CompLogLevelDebug
1107+} CompLogLevel;
1108+
1109+void
1110+logMessage (const char *componentName,
1111+ CompLogLevel level,
1112+ const char *message);
1113+
1114+void
1115+compLogMessage (const char *componentName,
1116+ CompLogLevel level,
1117+ const char *format,
1118+ ...);
1119+
1120+const char *
1121+logLevelToString (CompLogLevel level);
1122+
1123+#endif
1124
1125=== added directory 'src/logmessage/src'
1126=== renamed file 'src/logmessage.cpp' => 'src/logmessage/src/logmessage.cpp'
1127--- src/logmessage.cpp 2011-07-05 19:49:12 +0000
1128+++ src/logmessage/src/logmessage.cpp 2011-11-01 23:21:23 +0000
1129@@ -23,7 +23,8 @@
1130 * Author: David Reveman <davidr@novell.com>
1131 */
1132
1133-#include <compiz.h>
1134+#include <core/logmessage.h>
1135+#include <core/core.h>
1136 #include <cstdio>
1137
1138 const char *
1139
1140=== added directory 'src/logmessage/tests'
1141=== added file 'src/logmessage/tests/CMakeLists.txt'
1142=== added file 'src/logmessage/tests/test-logmessage.cpp'
1143=== modified file 'src/main.cpp'
1144--- src/main.cpp 2011-10-13 14:46:33 +0000
1145+++ src/main.cpp 2011-11-01 23:21:23 +0000
1146@@ -27,8 +27,6 @@
1147 # include <config.h>
1148 #endif
1149
1150-#include <compiz.h>
1151-
1152 #include <stdio.h>
1153 #include <stdlib.h>
1154 #include <signal.h>
1155
1156=== renamed directory 'tests/pluginclasshandler' => 'src/pluginclasshandler'
1157=== added directory 'src/pluginclasshandler/include'
1158=== added directory 'src/pluginclasshandler/include/core'
1159=== renamed file 'include/core/pluginclasses.h' => 'src/pluginclasshandler/include/core/pluginclasses.h'
1160=== renamed file 'include/core/pluginclasshandler.h' => 'src/pluginclasshandler/include/core/pluginclasshandler.h'
1161--- include/core/pluginclasshandler.h 2011-09-16 00:51:33 +0000
1162+++ src/pluginclasshandler/include/core/pluginclasshandler.h 2011-11-01 23:21:23 +0000
1163@@ -29,7 +29,7 @@
1164 #include <typeinfo>
1165 #include <boost/preprocessor/cat.hpp>
1166
1167-#include <compiz.h>
1168+#include <core/string.h>
1169 #include <core/valueholder.h>
1170 #include <core/pluginclasses.h>
1171
1172
1173=== renamed file 'include/core/valueholder.h' => 'src/pluginclasshandler/include/core/valueholder.h'
1174--- include/core/valueholder.h 2011-06-25 02:31:02 +0000
1175+++ src/pluginclasshandler/include/core/valueholder.h 2011-11-01 23:21:23 +0000
1176@@ -26,7 +26,8 @@
1177 #ifndef _COMPIZ_VALUEHOLDER_H
1178 #define _COMPIZ_VALUEHOLDER_H
1179
1180-#include <compiz.h>
1181+#include <core/string.h>
1182+#include <core/logmessage.h>
1183 #include <core/privateunion.h>
1184
1185 class PrivateValueHolder;
1186@@ -50,4 +51,4 @@
1187 PrivateValueHolder *priv;
1188 };
1189
1190-#endif
1191\ No newline at end of file
1192+#endif
1193
1194=== added directory 'src/pluginclasshandler/src'
1195=== renamed file 'src/pluginclasses.cpp' => 'src/pluginclasshandler/src/pluginclasses.cpp'
1196=== renamed file 'src/valueholder.cpp' => 'src/pluginclasshandler/src/valueholder.cpp'
1197=== renamed file 'src/valueholder.h' => 'src/pluginclasshandler/src/valueholder.h'
1198=== added directory 'src/pluginclasshandler/tests'
1199=== renamed file 'tests/pluginclasshandler/CMakeLists.txt' => 'src/pluginclasshandler/tests/CMakeLists.txt'
1200--- tests/pluginclasshandler/CMakeLists.txt 2011-07-06 18:53:03 +0000
1201+++ src/pluginclasshandler/tests/CMakeLists.txt 2011-11-01 23:21:23 +0000
1202@@ -1,4 +1,4 @@
1203-set (COMPIZ_TEST_PCH_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1204+compiz_test_base (core pluginclasshandler)
1205
1206 add_subdirectory (construct)
1207 add_subdirectory (get)
1208
1209=== renamed directory 'tests/pluginclasshandler/construct' => 'src/pluginclasshandler/tests/construct'
1210=== modified file 'src/pluginclasshandler/tests/construct/CMakeLists.txt'
1211--- tests/pluginclasshandler/construct/CMakeLists.txt 2011-07-06 19:52:01 +0000
1212+++ src/pluginclasshandler/tests/construct/CMakeLists.txt 2011-11-01 23:21:23 +0000
1213@@ -1,25 +1,1 @@
1214-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
1215-
1216-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
1217- ${compiz_SOURCE_DIR}/include
1218- ${compiz_BINARY_DIR}
1219- ${compiz_BINARY_DIR}/generated
1220- ${compiz_SOURCE_DIR}/src
1221- ${COMPIZ_TEST_PCH_BASE_DIR})
1222-
1223-set (OBJECT CompizPCHTestConstruct)
1224-add_definitions (-DOBJECT=${OBJECT})
1225-
1226-add_executable (test-pch-construct
1227- test-pch-construct.cpp
1228- ../test-pluginclasshandler.cpp
1229- ${compiz_SOURCE_DIR}/src/valueholder.cpp
1230- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
1231- ${compiz_SOURCE_DIR}/src/string.cpp
1232- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
1233-
1234-target_link_libraries (test-pch-construct
1235- ${COMPIZ_TEST_PCH_LIBRARIES})
1236-
1237-add_test (test-pch-construct
1238- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-construct)
1239+compiz_test (core pluginclasshandler construct)
1240
1241=== added directory 'src/pluginclasshandler/tests/construct/src'
1242=== renamed file 'tests/pluginclasshandler/construct/test-pch-construct.cpp' => 'src/pluginclasshandler/tests/construct/src/test-pch-construct.cpp'
1243--- tests/pluginclasshandler/construct/test-pch-construct.cpp 2011-07-06 18:53:03 +0000
1244+++ src/pluginclasshandler/tests/construct/src/test-pch-construct.cpp 2011-11-01 23:21:23 +0000
1245@@ -62,3 +62,9 @@
1246
1247 std::cout << "PASS: Basic construction" << std::endl;
1248 }
1249+
1250+CompizPCHTest *
1251+get_object (Global *g)
1252+{
1253+ return new CompizPCHTestConstruct (g);
1254+}
1255
1256=== renamed directory 'tests/pluginclasshandler/get' => 'src/pluginclasshandler/tests/get'
1257=== modified file 'src/pluginclasshandler/tests/get/CMakeLists.txt'
1258--- tests/pluginclasshandler/get/CMakeLists.txt 2011-07-06 19:52:01 +0000
1259+++ src/pluginclasshandler/tests/get/CMakeLists.txt 2011-11-01 23:21:23 +0000
1260@@ -1,25 +1,1 @@
1261-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
1262-
1263-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
1264- ${compiz_SOURCE_DIR}/include
1265- ${compiz_BINARY_DIR}
1266- ${compiz_BINARY_DIR}/generated
1267- ${compiz_SOURCE_DIR}/src
1268- ${COMPIZ_TEST_PCH_BASE_DIR})
1269-
1270-set (OBJECT CompizPCHTestGet)
1271-add_definitions (-DOBJECT=${OBJECT})
1272-
1273-add_executable (test-pch-get
1274- test-pch-get.cpp
1275- ../test-pluginclasshandler.cpp
1276- ${compiz_SOURCE_DIR}/src/valueholder.cpp
1277- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
1278- ${compiz_SOURCE_DIR}/src/string.cpp
1279- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
1280-
1281-target_link_libraries (test-pch-get
1282- ${COMPIZ_TEST_PCH_LIBRARIES})
1283-
1284-add_test (test-pch-get
1285- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-get)
1286+compiz_test (core pluginclasshandler get)
1287
1288=== added directory 'src/pluginclasshandler/tests/get/src'
1289=== renamed file 'tests/pluginclasshandler/get/test-pch-get.cpp' => 'src/pluginclasshandler/tests/get/src/test-pch-get.cpp'
1290--- tests/pluginclasshandler/get/test-pch-get.cpp 2011-07-06 18:53:03 +0000
1291+++ src/pluginclasshandler/tests/get/src/test-pch-get.cpp 2011-11-01 23:21:23 +0000
1292@@ -62,3 +62,9 @@
1293
1294 std::cout << "PASS: Object Retreival" << std::endl;
1295 }
1296+
1297+CompizPCHTest *
1298+get_object (Global *g)
1299+{
1300+ return new CompizPCHTestGet (g);
1301+}
1302
1303=== renamed directory 'tests/pluginclasshandler/indexes' => 'src/pluginclasshandler/tests/indexes'
1304=== modified file 'src/pluginclasshandler/tests/indexes/CMakeLists.txt'
1305--- tests/pluginclasshandler/indexes/CMakeLists.txt 2011-07-06 19:52:01 +0000
1306+++ src/pluginclasshandler/tests/indexes/CMakeLists.txt 2011-11-01 23:21:23 +0000
1307@@ -1,28 +1,5 @@
1308-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
1309-
1310-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
1311- ${compiz_SOURCE_DIR}/include
1312- ${compiz_BINARY_DIR}
1313- ${compiz_BINARY_DIR}/generated
1314- ${compiz_SOURCE_DIR}/src
1315- ${COMPIZ_TEST_PCH_BASE_DIR})
1316-
1317-set (OBJECT CompizPCHTestIndexes)
1318-add_definitions (-DOBJECT=${OBJECT})
1319 # hack
1320 add_definitions (-Dprivate=public)
1321 add_definitions (-Dprotected=public)
1322
1323-add_executable (test-pch-indexes
1324- test-pch-indexes.cpp
1325- ../test-pluginclasshandler.cpp
1326- ${compiz_SOURCE_DIR}/src/valueholder.cpp
1327- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
1328- ${compiz_SOURCE_DIR}/src/string.cpp
1329- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
1330-
1331-target_link_libraries (test-pch-indexes
1332- ${COMPIZ_TEST_PCH_LIBRARIES})
1333-
1334-add_test (test-pch-indexes
1335- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-indexes)
1336+compiz_test (core pluginclasshandler indexes)
1337
1338=== added directory 'src/pluginclasshandler/tests/indexes/src'
1339=== renamed file 'tests/pluginclasshandler/indexes/test-pch-indexes.cpp' => 'src/pluginclasshandler/tests/indexes/src/test-pch-indexes.cpp'
1340--- tests/pluginclasshandler/indexes/test-pch-indexes.cpp 2011-07-06 18:53:03 +0000
1341+++ src/pluginclasshandler/tests/indexes/src/test-pch-indexes.cpp 2011-11-01 23:21:23 +0000
1342@@ -432,3 +432,9 @@
1343
1344 std::cout << "PASS: Index Sanity" << std::endl;
1345 }
1346+
1347+CompizPCHTest *
1348+get_object (Global *g)
1349+{
1350+ return new CompizPCHTestIndexes (g);
1351+}
1352
1353=== renamed file 'tests/pluginclasshandler/test-pluginclasshandler.cpp' => 'src/pluginclasshandler/tests/test-pluginclasshandler.cpp'
1354--- tests/pluginclasshandler/test-pluginclasshandler.cpp 2011-07-06 18:53:03 +0000
1355+++ src/pluginclasshandler/tests/test-pluginclasshandler.cpp 2011-11-01 23:21:23 +0000
1356@@ -76,7 +76,7 @@
1357 {
1358 programName = argv[0];
1359
1360- gTest = static_cast <CompizPCHTest *> (new OBJECT (new Global ()));
1361+ gTest = static_cast <CompizPCHTest *> (get_object (new Global ()));
1362 gTest->run ();
1363
1364 while (gTest->plugins.size ())
1365
1366=== renamed file 'tests/pluginclasshandler/test-pluginclasshandler.h' => 'src/pluginclasshandler/tests/test-pluginclasshandler.h'
1367--- tests/pluginclasshandler/test-pluginclasshandler.h 2011-07-06 18:53:03 +0000
1368+++ src/pluginclasshandler/tests/test-pluginclasshandler.h 2011-11-01 23:21:23 +0000
1369@@ -112,3 +112,6 @@
1370 unsigned int ePcIndex;
1371 bool eLoadFailed;
1372 };
1373+
1374+CompizPCHTest *
1375+get_object (Global *);
1376
1377=== renamed directory 'tests/pluginclasshandler/typenames' => 'src/pluginclasshandler/tests/typenames'
1378=== modified file 'src/pluginclasshandler/tests/typenames/CMakeLists.txt'
1379--- tests/pluginclasshandler/typenames/CMakeLists.txt 2011-07-06 19:52:01 +0000
1380+++ src/pluginclasshandler/tests/typenames/CMakeLists.txt 2011-11-01 23:21:23 +0000
1381@@ -1,25 +1,1 @@
1382-link_directories (${COMPIZ_TEST_PCH_LINK_DIRS})
1383-
1384-include_directories (${COMPIZ_TEST_PCH_INCLUDE_DIRS}
1385- ${compiz_SOURCE_DIR}/include
1386- ${compiz_BINARY_DIR}
1387- ${compiz_BINARY_DIR}/generated
1388- ${compiz_SOURCE_DIR}/src
1389- ${COMPIZ_TEST_PCH_BASE_DIR})
1390-
1391-set (OBJECT CompizPCHTestTypenames)
1392-add_definitions (-DOBJECT=${OBJECT})
1393-
1394-add_executable (test-pch-typenames
1395- test-pch-typenames.cpp
1396- ../test-pluginclasshandler.cpp
1397- ${compiz_SOURCE_DIR}/src/valueholder.cpp
1398- ${compiz_SOURCE_DIR}/src/pluginclasses.cpp
1399- ${compiz_SOURCE_DIR}/src/string.cpp
1400- ${compiz_SOURCE_DIR}/src/logmessage.cpp)
1401-
1402-target_link_libraries (test-pch-typenames
1403- ${COMPIZ_TEST_PCH_LIBRARIES})
1404-
1405-add_test (test-pch-typenames
1406- ${CMAKE_CURRENT_BINARY_DIR}/test-pch-typenames)
1407+compiz_test (core pluginclasshandler typenames)
1408
1409=== added directory 'src/pluginclasshandler/tests/typenames/src'
1410=== renamed file 'tests/pluginclasshandler/typenames/test-pch-typenames.cpp' => 'src/pluginclasshandler/tests/typenames/src/test-pch-typenames.cpp'
1411--- tests/pluginclasshandler/typenames/test-pch-typenames.cpp 2011-07-06 18:53:03 +0000
1412+++ src/pluginclasshandler/tests/typenames/src/test-pch-typenames.cpp 2011-11-01 23:21:23 +0000
1413@@ -81,3 +81,9 @@
1414
1415 std::cout << "PASS: Typenames" << std::endl;
1416 }
1417+
1418+CompizPCHTest *
1419+get_object (Global *g)
1420+{
1421+ return new CompizPCHTestTypenames (g);
1422+}
1423
1424=== modified file 'src/privatescreen.h'
1425--- src/privatescreen.h 2011-10-10 14:56:06 +0000
1426+++ src/privatescreen.h 2011-11-01 23:21:23 +0000
1427@@ -103,6 +103,20 @@
1428
1429 namespace compiz
1430 {
1431+namespace core
1432+{
1433+namespace screen
1434+{
1435+ inline int wraparound_mod (int a, int b)
1436+ {
1437+ if (a < 0)
1438+ return (b - ((-a - 1) % (b))) - 1;
1439+ else
1440+ return a % b;
1441+ };
1442+}
1443+}
1444+
1445 namespace X11
1446 {
1447 class PendingEvent {
1448
1449=== modified file 'src/screen.cpp'
1450--- src/screen.cpp 2011-10-13 14:28:30 +0000
1451+++ src/screen.cpp 2011-11-01 23:21:23 +0000
1452@@ -3502,11 +3502,11 @@
1453 CompPoint pnt;
1454
1455 tx = priv->vp.x () - tx;
1456- tx = MOD (tx, priv->vpSize.width ());
1457+ tx = compiz::core::screen::wraparound_mod (tx, priv->vpSize.width ());
1458 tx -= priv->vp.x ();
1459
1460 ty = priv->vp.y () - ty;
1461- ty = MOD (ty, priv->vpSize.height ());
1462+ ty = compiz::core::screen::wraparound_mod (ty, priv->vpSize.height ());
1463 ty -= priv->vp.y ();
1464
1465 if (!tx && !ty)
1466
1467=== modified file 'src/session.cpp'
1468--- src/session.cpp 2011-03-16 20:27:14 +0000
1469+++ src/session.cpp 2011-11-01 23:21:23 +0000
1470@@ -27,8 +27,6 @@
1471 # include <config.h>
1472 #endif
1473
1474-#include <compiz.h>
1475-
1476 #include <stdlib.h>
1477 #include <stdio.h>
1478 #include <poll.h>
1479
1480=== added directory 'src/string'
1481=== added directory 'src/string/include'
1482=== added directory 'src/string/src'
1483=== renamed file 'src/string.cpp' => 'src/string/src/string.cpp'
1484--- src/string.cpp 2009-08-08 05:52:48 +0000
1485+++ src/string/src/string.cpp 2011-11-01 23:21:23 +0000
1486@@ -23,12 +23,12 @@
1487 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1488 */
1489
1490-#include <compiz.h>
1491-
1492 #include <cstring>
1493 #include <cstdarg>
1494 #include <cstdio>
1495
1496+#include <core/string.h>
1497+
1498 CompString compPrintf (const char *format, ...)
1499 {
1500 va_list ap;
1501
1502=== added directory 'src/string/tests'
1503=== added file 'src/string/tests/CMakeLists.txt'
1504--- src/string/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
1505+++ src/string/tests/CMakeLists.txt 2011-11-01 23:21:23 +0000
1506@@ -0,0 +1,3 @@
1507+compiz_test_base (core string)
1508+
1509+add_subdirectory (printf)
1510
1511=== added directory 'src/string/tests/printf'
1512=== added file 'src/string/tests/printf/CMakeLists.txt'
1513--- src/string/tests/printf/CMakeLists.txt 1970-01-01 00:00:00 +0000
1514+++ src/string/tests/printf/CMakeLists.txt 2011-11-01 23:21:23 +0000
1515@@ -0,0 +1,1 @@
1516+compiz_test (core string printf LIBRARIES ${Boost_LIBRARIES} INCDIRS ${Boost_INCLUDE_DIRS})
1517
1518=== added directory 'src/string/tests/printf/src'
1519=== added file 'src/string/tests/printf/src/test-string-printf.cpp'
1520--- src/string/tests/printf/src/test-string-printf.cpp 1970-01-01 00:00:00 +0000
1521+++ src/string/tests/printf/src/test-string-printf.cpp 2011-11-01 23:21:23 +0000
1522@@ -0,0 +1,193 @@
1523+/*
1524+ * Copyright © 2011 Canonical Ltd.
1525+ *
1526+ * Permission to use, copy, modify, distribute, and sell this software
1527+ * and its documentation for any purpose is hereby granted without
1528+ * fee, provided that the above copyright notice appear in all copies
1529+ * and that both that copyright notice and this permission notice
1530+ * appear in supporting documentation, and that the name of
1531+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1532+ * distribution of the software without specific, written prior permission.
1533+ * Canonical Ltd. makes no representations about the suitability of this
1534+ * software for any purpose. It is provided "as is" without express or
1535+ * implied warranty.
1536+ *
1537+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1538+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1539+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1540+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1541+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1542+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1543+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1544+ *
1545+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
1546+ */
1547+
1548+#include "test-string.h"
1549+#include <string>
1550+#include <iostream>
1551+#include <map>
1552+#include <boost/shared_ptr.hpp>
1553+#include <boost/pointer_cast.hpp>
1554+#include <typeinfo>
1555+
1556+namespace compiz
1557+{
1558+namespace string
1559+{
1560+namespace printf_test
1561+{
1562+
1563+class Value
1564+{
1565+ public:
1566+ virtual ~Value ();
1567+
1568+ typedef boost::shared_ptr <Value> Ptr;
1569+
1570+ protected:
1571+
1572+ Value () {};
1573+
1574+ void *v;
1575+};
1576+
1577+template <typename T>
1578+class TValue :
1579+ public Value
1580+{
1581+ public:
1582+ TValue (const T &);
1583+ ~TValue ();
1584+
1585+ const T & value ();
1586+};
1587+
1588+template <typename T>
1589+TValue<T>::TValue (const T &av)
1590+{
1591+ v = new T (av);
1592+}
1593+
1594+template <typename T>
1595+TValue<T>::~TValue ()
1596+{
1597+ delete (reinterpret_cast <T *> (v));
1598+}
1599+
1600+template <typename T>
1601+const T &
1602+TValue<T>::value ()
1603+{
1604+ return *(reinterpret_cast <T *> (v));
1605+}
1606+
1607+Value::~Value ()
1608+{
1609+}
1610+
1611+CompString get_format (const CompString &fmt, Value::Ptr v)
1612+{
1613+ if (fmt == "%i" || fmt == "%d")
1614+ return compPrintf (fmt.c_str (), (boost::shared_static_cast <TValue<int> > (v))->value ());
1615+ if (fmt == "%f")
1616+ return compPrintf (fmt.c_str (), (boost::shared_static_cast <TValue<float> > (v))->value ());
1617+ if (fmt == "%s")
1618+ return compPrintf (fmt.c_str (), (boost::shared_static_cast <TValue<std::string> > (v))->value ().c_str ());
1619+ if (fmt == "%x")
1620+ return compPrintf (fmt.c_str (), (boost::shared_static_cast <TValue<int> > (v))->value ());
1621+
1622+ return "not_reached";
1623+}
1624+
1625+}
1626+}
1627+}
1628+
1629+bool
1630+CompStringTestPrintf::test ()
1631+{
1632+ CompString s1;
1633+ CompString s2;
1634+ std::map <CompString, compiz::string::printf_test::Value::Ptr> formatValues;
1635+ std::map <CompString, CompString> formatStrings;
1636+
1637+ std::cout << "-= TEST: compPrintf" << std::endl;
1638+
1639+ s1 = "foo";
1640+
1641+ const char *other_foo = "foo";
1642+ s2 = compPrintf ("%s", other_foo);
1643+
1644+ if (s1 == s2)
1645+ std::cout << "PASS: %s" << std::endl;
1646+ else
1647+ {
1648+ std::cout << "FAIL: %s" << std::endl;
1649+ return false;
1650+ }
1651+
1652+ s1 = "3";
1653+ s2 = compPrintf ("%i", 3, NULL);
1654+
1655+ if (s1 == s2)
1656+ std::cout << "PASS: %i" << std::endl;
1657+ else
1658+ {
1659+ std::cout << "FAIL: %%i" << std::endl;
1660+ return false;
1661+ }
1662+
1663+ s1 = "3.012600";
1664+ s2 = compPrintf ("%f", 3.0126, NULL);
1665+
1666+ if (s1 == s2)
1667+ std::cout << "PASS: %f" << std::endl;
1668+ else
1669+ {
1670+ std::cout << "FAIL: %f " << s2 << std::endl;
1671+ return false;
1672+ }
1673+
1674+ s1 = "0x4f567";
1675+ s2 = compPrintf ("0x%x", 0x4f567, NULL);
1676+
1677+ if (s1 == s2)
1678+ std::cout << "PASS: %x" << std::endl;
1679+ else
1680+ {
1681+ std::cout << "FAIL: %x" << std::endl;
1682+ return false;
1683+ }
1684+
1685+ formatValues["%i"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<int> (6)));
1686+ formatStrings["%i"] = CompString ("6");
1687+ formatValues["%f"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<float> (6.532)));
1688+ formatStrings["%f"] = CompString ("6.532000");
1689+ formatValues["%x"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<int> (0x34fe5aa)));
1690+ formatStrings["%x"] = CompString ("34fe5aa");
1691+ formatValues["%d"] = boost::shared_static_cast <compiz::string::printf_test::Value> (compiz::string::printf_test::Value::Ptr (new compiz::string::printf_test::TValue<int> (2)));
1692+ formatStrings["%d"] = CompString ("2");
1693+
1694+ for (std::map <CompString, CompString>::iterator it = formatStrings.begin ();
1695+ it != formatStrings.end (); it++)
1696+ {
1697+ CompString str = compiz::string::printf_test::get_format (it->first, formatValues[it->first]);
1698+ if (str != it->second)
1699+ {
1700+ std::cout << "FAIL: format " << it->first << " result " << str << " expected " << it->second << std::endl;
1701+ return false;
1702+ }
1703+ else
1704+ std::cout << "PASS: format " << it->first << std::endl;
1705+ }
1706+
1707+ return true;
1708+
1709+}
1710+
1711+CompStringTest *
1712+getTestObject ()
1713+{
1714+ return new CompStringTestPrintf ();
1715+}
1716
1717=== added file 'src/string/tests/test-string.cpp'
1718--- src/string/tests/test-string.cpp 1970-01-01 00:00:00 +0000
1719+++ src/string/tests/test-string.cpp 2011-11-01 23:21:23 +0000
1720@@ -0,0 +1,47 @@
1721+/*
1722+ * Copyright © 2011 Canonical Ltd.
1723+ *
1724+ * Permission to use, copy, modify, distribute, and sell this software
1725+ * and its documentation for any purpose is hereby granted without
1726+ * fee, provided that the above copyright notice appear in all copies
1727+ * and that both that copyright notice and this permission notice
1728+ * appear in supporting documentation, and that the name of
1729+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1730+ * distribution of the software without specific, written prior permission.
1731+ * Canonical Ltd. makes no representations about the suitability of this
1732+ * software for any purpose. It is provided "as is" without express or
1733+ * implied warranty.
1734+ *
1735+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1736+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1737+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1738+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1739+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1740+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1741+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1742+ *
1743+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
1744+ */
1745+
1746+#include "test-string.h"
1747+
1748+CompStringTest::CompStringTest ()
1749+{
1750+}
1751+
1752+CompStringTest::~CompStringTest ()
1753+{
1754+}
1755+
1756+int
1757+main (int argc, char **argv)
1758+{
1759+ CompStringTest *cst = static_cast <CompStringTest *> (getTestObject ());
1760+ bool ret = false;
1761+
1762+ ret = cst->test ();
1763+
1764+ delete cst;
1765+
1766+ return ret ? 0 : 1;
1767+}
1768
1769=== added file 'src/string/tests/test-string.h'
1770--- src/string/tests/test-string.h 1970-01-01 00:00:00 +0000
1771+++ src/string/tests/test-string.h 2011-11-01 23:21:23 +0000
1772@@ -0,0 +1,52 @@
1773+/*
1774+ * Copyright © 2011 Canonical Ltd.
1775+ *
1776+ * Permission to use, copy, modify, distribute, and sell this software
1777+ * and its documentation for any purpose is hereby granted without
1778+ * fee, provided that the above copyright notice appear in all copies
1779+ * and that both that copyright notice and this permission notice
1780+ * appear in supporting documentation, and that the name of
1781+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1782+ * distribution of the software without specific, written prior permission.
1783+ * Canonical Ltd. makes no representations about the suitability of this
1784+ * software for any purpose. It is provided "as is" without express or
1785+ * implied warranty.
1786+ *
1787+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1788+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1789+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1790+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1791+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1792+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1793+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1794+ *
1795+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
1796+ */
1797+
1798+#ifndef _COMPIZ_TEST_STRING_H
1799+#define _COMPIZ_TEST_STRING_H
1800+
1801+#include <core/string.h>
1802+
1803+class CompStringTest
1804+{
1805+public:
1806+
1807+ CompStringTest ();
1808+ virtual ~CompStringTest ();
1809+
1810+ virtual bool test () = 0;
1811+};
1812+
1813+class CompStringTestPrintf :
1814+ public CompStringTest
1815+{
1816+public:
1817+
1818+ bool test ();
1819+};
1820+
1821+CompStringTest *
1822+getTestObject ();
1823+
1824+#endif
1825
1826=== added directory 'src/timer'
1827=== added directory 'src/timer/include'
1828=== added directory 'src/timer/include/core'
1829=== renamed file 'include/core/timeouthandler.h' => 'src/timer/include/core/timeouthandler.h'
1830=== renamed file 'include/core/timer.h' => 'src/timer/include/core/timer.h'
1831--- include/core/timer.h 2011-07-04 18:17:44 +0000
1832+++ src/timer/include/core/timer.h 2011-11-01 23:21:23 +0000
1833@@ -32,6 +32,24 @@
1834
1835 class CompTimeoutSource;
1836 class PrivateTimer;
1837+
1838+namespace compiz {
1839+namespace core {
1840+namespace timer {
1841+
1842+ inline int timeval_diff (struct timeval *tv1, struct timeval *tv2)
1843+ {
1844+ if (tv1->tv_sec == tv2->tv_sec || tv1->tv_usec >= tv2->tv_usec)
1845+ return (((tv1->tv_sec - tv2->tv_sec) * 1000000) +
1846+ (tv1->tv_usec - tv2->tv_usec)) / 1000;
1847+ else
1848+ return (((tv1->tv_sec - 1 - tv2->tv_sec) * 1000000) +
1849+ (1000000 + tv1->tv_usec - tv2->tv_usec)) / 1000;
1850+ }
1851+}
1852+}
1853+}
1854+
1855 /**
1856 * A simple timer for use with invoking a CallBack during a timed duration.
1857 */
1858
1859=== added directory 'src/timer/src'
1860=== renamed file 'src/privatetimeouthandler.h' => 'src/timer/src/privatetimeouthandler.h'
1861=== renamed file 'src/privatetimeoutsource.h' => 'src/timer/src/privatetimeoutsource.h'
1862=== renamed file 'src/privatetimer.h' => 'src/timer/src/privatetimer.h'
1863=== renamed file 'src/timeouthandler.cpp' => 'src/timer/src/timeouthandler.cpp'
1864=== renamed file 'src/timer.cpp' => 'src/timer/src/timer.cpp'
1865=== added directory 'src/timer/tests'
1866=== renamed file 'tests/timer/CMakeLists.txt' => 'src/timer/tests/CMakeLists.txt'
1867--- tests/timer/CMakeLists.txt 2011-07-06 18:58:47 +0000
1868+++ src/timer/tests/CMakeLists.txt 2011-11-01 23:21:23 +0000
1869@@ -1,15 +1,17 @@
1870-include (CompizCommon)
1871-include (FindPkgConfig)
1872-
1873-pkg_check_modules (COMPIZ_TEST_TIMER glibmm-2.4)
1874-
1875-if (COMPIZ_TEST_TIMER_FOUND)
1876-
1877- set (COMPIZ_TIMER_TEST_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1878-
1879- add_subdirectory (callbacks)
1880- add_subdirectory (diffs)
1881- add_subdirectory (set-values)
1882- add_subdirectory (while-calling)
1883-
1884-endif (COMPIZ_TEST_TIMER_FOUND)
1885+#include (CompizCommon)
1886+#include (FindPkgConfig)
1887+
1888+#set (COMPIZ_TEST_TIMER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1889+#set (COMPIZ_TEST_TIMER_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1890+
1891+#include_directories (${COMPIZ_TIMER_SOURCE_DIR}
1892+# ${COMPIZ_TIMER_INCLUDE_DIR})
1893+
1894+#add_library (timer_test_internal STATIC
1895+# test-timer.cpp)
1896+
1897+compiz_test_base (core timer)
1898+add_subdirectory (callbacks)
1899+add_subdirectory (diffs)
1900+add_subdirectory (set-values)
1901+add_subdirectory (while-calling)
1902
1903=== renamed directory 'tests/timer/callbacks' => 'src/timer/tests/callbacks'
1904=== modified file 'src/timer/tests/callbacks/CMakeLists.txt'
1905--- tests/timer/callbacks/CMakeLists.txt 2011-07-06 18:58:47 +0000
1906+++ src/timer/tests/callbacks/CMakeLists.txt 2011-11-01 23:21:23 +0000
1907@@ -1,23 +1,1 @@
1908-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
1909-
1910-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
1911- ${compiz_SOURCE_DIR}/include
1912- ${compiz_BINARY_DIR}
1913- ${compiz_BINARY_DIR}/generated
1914- ${compiz_SOURCE_DIR}/src
1915- ${COMPIZ_TIMER_TEST_BASE_DIR})
1916-
1917-set (OBJECT CompTimerTestCallbacks)
1918-add_definitions (-DOBJECT=${OBJECT})
1919-
1920-add_executable (test-timer-callbacks
1921- test-timer-callbacks.cpp
1922- ../test-timer.cpp
1923- ${compiz_SOURCE_DIR}/src/timer.cpp
1924- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
1925-
1926-target_link_libraries (test-timer-callbacks
1927- ${COMPIZ_TEST_TIMER_LIBRARIES})
1928-
1929-add_test (test-timer-callbacks
1930- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-callbacks)
1931+compiz_test (core timer callbacks)
1932
1933=== added directory 'src/timer/tests/callbacks/src'
1934=== renamed file 'tests/timer/callbacks/test-timer-callbacks.cpp' => 'src/timer/tests/callbacks/src/test-timer-callbacks.cpp'
1935--- tests/timer/callbacks/test-timer-callbacks.cpp 2011-07-06 18:58:47 +0000
1936+++ src/timer/tests/callbacks/src/test-timer-callbacks.cpp 2011-11-01 23:21:23 +0000
1937@@ -104,3 +104,9 @@
1938 exit (1);
1939 }
1940 }
1941+
1942+CompTimerTest *
1943+getTestObject ()
1944+{
1945+ return new CompTimerTestCallbacks ();
1946+}
1947
1948=== renamed directory 'tests/timer/diffs' => 'src/timer/tests/diffs'
1949=== modified file 'src/timer/tests/diffs/CMakeLists.txt'
1950--- tests/timer/diffs/CMakeLists.txt 2011-07-06 18:58:47 +0000
1951+++ src/timer/tests/diffs/CMakeLists.txt 2011-11-01 23:21:23 +0000
1952@@ -1,23 +1,1 @@
1953-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
1954-
1955-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
1956- ${compiz_SOURCE_DIR}/include
1957- ${compiz_BINARY_DIR}
1958- ${compiz_BINARY_DIR}/generated
1959- ${compiz_SOURCE_DIR}/src
1960- ${COMPIZ_TIMER_TEST_BASE_DIR})
1961-
1962-set (OBJECT CompTimerTestDiffs)
1963-add_definitions (-DOBJECT=${OBJECT})
1964-
1965-add_executable (test-timer-diffs
1966- test-timer-diffs.cpp
1967- ../test-timer.cpp
1968- ${compiz_SOURCE_DIR}/src/timer.cpp
1969- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
1970-
1971-target_link_libraries (test-timer-diffs
1972- ${COMPIZ_TEST_TIMER_LIBRARIES})
1973-
1974-add_test (test-timer-diffs
1975- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-diffs)
1976+compiz_test (core timer diffs)
1977
1978=== added directory 'src/timer/tests/diffs/src'
1979=== added file 'src/timer/tests/diffs/src/test-timer-diffs.cpp'
1980--- src/timer/tests/diffs/src/test-timer-diffs.cpp 1970-01-01 00:00:00 +0000
1981+++ src/timer/tests/diffs/src/test-timer-diffs.cpp 2011-11-01 23:21:23 +0000
1982@@ -0,0 +1,88 @@
1983+/*
1984+ * Copyright © 2011 Canonical Ltd.
1985+ *
1986+ * Permission to use, copy, modify, distribute, and sell this software
1987+ * and its documentation for any purpose is hereby granted without
1988+ * fee, provided that the above copyright notice appear in all copies
1989+ * and that both that copyright notice and this permission notice
1990+ * appear in supporting documentation, and that the name of
1991+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1992+ * distribution of the software without specific, written prior permission.
1993+ * Canonical Ltd. makes no representations about the suitability of this
1994+ * software for any purpose. It is provided "as is" without express or
1995+ * implied warranty.
1996+ *
1997+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1998+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1999+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2000+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2001+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2002+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2003+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2004+ *
2005+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2006+ */
2007+
2008+#include "test-timer.h"
2009+
2010+bool
2011+CompTimerTestDiffs::cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3)
2012+{
2013+ if (timernum == 1 || timernum == 2 || timernum == 3)
2014+ {
2015+ std::cout << "INFO: executing timer " << timernum << std::endl;
2016+
2017+ std::cout << "INFO: t1->minLeft " << t1->minLeft () << std::endl << \
2018+ "INFO: t1->maxLeft " << t1->maxLeft () << std::endl << \
2019+ "INFO: t1->minTime " << t1->minTime () << std::endl << \
2020+ "INFO: t1->maxTime " << t1->maxTime () << std::endl;
2021+
2022+ std::cout << "INFO: t2->minLeft " << t2->minLeft () << std::endl << \
2023+ "INFO: t2->maxLeft " << t2->maxLeft () << std::endl << \
2024+ "INFO: t2->minTime " << t2->minTime () << std::endl << \
2025+ "INFO: t2->maxTime " << t2->maxTime () << std::endl;
2026+
2027+ std::cout << "INFO: t3->minLeft " << t3->minLeft () << std::endl << \
2028+ "INFO: t3->maxLeft " << t3->maxLeft () << std::endl << \
2029+ "INFO: t3->minTime " << t3->minTime () << std::endl << \
2030+ "INFO: t3->maxTime " << t3->maxTime () << std::endl;
2031+ }
2032+
2033+ if (timernum == 3)
2034+ ml->quit ();
2035+
2036+ std::cout << "return false" << std::endl;
2037+ return false;
2038+}
2039+
2040+void
2041+CompTimerTestDiffs::precallback ()
2042+{
2043+ CompTimer *t1, *t2, *t3;
2044+
2045+ std::cout << "-= TEST: checking timeout diff" << std::endl;
2046+
2047+ t1 = new CompTimer ();
2048+ t2 = new CompTimer ();
2049+ t3 = new CompTimer ();
2050+
2051+ timers.push_back (t1);
2052+ timers.push_back (t2);
2053+ timers.push_back (t3);
2054+
2055+ t1->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 1, t1, t2, t3));
2056+ t1->setTimes (1000, 1100);
2057+ t1->start ();
2058+ t2->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 2, t1, t2, t3));
2059+ t2->setTimes (2000, 2100);
2060+ t2->start ();
2061+ t3->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 3, t1, t2, t3));
2062+ t3->setTimes (3000, 3100);
2063+ t3->start ();
2064+}
2065+
2066+CompTimerTest *
2067+getTestObject ()
2068+{
2069+ return new CompTimerTestDiffs ();
2070+}
2071
2072=== renamed directory 'tests/timer/set-values' => 'src/timer/tests/set-values'
2073=== modified file 'src/timer/tests/set-values/CMakeLists.txt'
2074--- tests/timer/set-values/CMakeLists.txt 2011-07-06 18:58:47 +0000
2075+++ src/timer/tests/set-values/CMakeLists.txt 2011-11-01 23:21:23 +0000
2076@@ -1,23 +1,1 @@
2077-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
2078-
2079-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
2080- ${compiz_SOURCE_DIR}/include
2081- ${compiz_BINARY_DIR}
2082- ${compiz_BINARY_DIR}/generated
2083- ${compiz_SOURCE_DIR}/src
2084- ${COMPIZ_TIMER_TEST_BASE_DIR})
2085-
2086-set (OBJECT CompTimerTestSetValues)
2087-add_definitions (-DOBJECT=${OBJECT})
2088-
2089-add_executable (test-timer-set-values
2090- test-timer-set-values.cpp
2091- ../test-timer.cpp
2092- ${compiz_SOURCE_DIR}/src/timer.cpp
2093- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
2094-
2095-target_link_libraries (test-timer-set-values
2096- ${COMPIZ_TEST_TIMER_LIBRARIES})
2097-
2098-add_test (test-timer-set-values
2099- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-set-values)
2100+compiz_test (core timer set-values)
2101
2102=== added directory 'src/timer/tests/set-values/src'
2103=== renamed file 'tests/timer/set-values/test-timer-set-values.cpp' => 'src/timer/tests/set-values/src/test-timer-set-values.cpp'
2104--- tests/timer/set-values/test-timer-set-values.cpp 2011-07-06 18:58:47 +0000
2105+++ src/timer/tests/set-values/src/test-timer-set-values.cpp 2011-11-01 23:21:23 +0000
2106@@ -137,3 +137,9 @@
2107 timers.push_back (t2);
2108 timers.push_back (t3);
2109 }
2110+
2111+CompTimerTest *
2112+getTestObject ()
2113+{
2114+ return new CompTimerTestSetValues ();
2115+}
2116
2117=== renamed file 'tests/timer/test-timer.cpp' => 'src/timer/tests/test-timer.cpp'
2118--- tests/timer/test-timer.cpp 2011-07-06 18:58:47 +0000
2119+++ src/timer/tests/test-timer.cpp 2011-11-01 23:21:23 +0000
2120@@ -47,7 +47,7 @@
2121 int
2122 main (int argc, char **argv)
2123 {
2124- CompTimerTest *ctt = static_cast <CompTimerTest *> (new OBJECT ());
2125+ CompTimerTest *ctt = static_cast <CompTimerTest *> (getTestObject ());
2126 TimeoutHandler *th = new TimeoutHandler ();
2127 TimeoutHandler::SetDefault (th);
2128
2129
2130=== renamed file 'tests/timer/test-timer.h' => 'src/timer/tests/test-timer.h'
2131--- tests/timer/test-timer.h 2011-07-06 18:58:47 +0000
2132+++ src/timer/tests/test-timer.h 2011-11-01 23:21:23 +0000
2133@@ -86,4 +86,7 @@
2134 bool cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3);
2135 };
2136
2137+CompTimerTest *
2138+getTestObject ();
2139+
2140 #endif
2141
2142=== renamed directory 'tests/timer/while-calling' => 'src/timer/tests/while-calling'
2143=== modified file 'src/timer/tests/while-calling/CMakeLists.txt'
2144--- tests/timer/while-calling/CMakeLists.txt 2011-07-06 18:58:47 +0000
2145+++ src/timer/tests/while-calling/CMakeLists.txt 2011-11-01 23:21:23 +0000
2146@@ -1,23 +1,1 @@
2147-link_directories (${COMPIZ_TEST_TIMER_LINK_DIRS})
2148-
2149-include_directories (${COMPIZ_TEST_TIMER_INCLUDE_DIRS}
2150- ${compiz_SOURCE_DIR}/include
2151- ${compiz_BINARY_DIR}
2152- ${compiz_BINARY_DIR}/generated
2153- ${compiz_SOURCE_DIR}/src
2154- ${COMPIZ_TIMER_TEST_BASE_DIR})
2155-
2156-set (OBJECT CompTimerTestSetCalling)
2157-add_definitions (-DOBJECT=${OBJECT})
2158-
2159-add_executable (test-timer-set-times-while-calling
2160- test-timer-set-times-while-calling.cpp
2161- ../test-timer.cpp
2162- ${compiz_SOURCE_DIR}/src/timer.cpp
2163- ${compiz_SOURCE_DIR}/src/timeouthandler.cpp)
2164-
2165-target_link_libraries (test-timer-set-times-while-calling
2166- ${COMPIZ_TEST_TIMER_LIBRARIES})
2167-
2168-add_test (test-timer-set-times-while-calling
2169- ${CMAKE_CURRENT_BINARY_DIR}/test-timer-set-times-while-calling)
2170+compiz_test (core timer while-calling)
2171
2172=== added directory 'src/timer/tests/while-calling/src'
2173=== renamed file 'tests/timer/while-calling/test-timer-set-times-while-calling.cpp' => 'src/timer/tests/while-calling/src/test-timer-set-times-while-calling.cpp'
2174--- tests/timer/while-calling/test-timer-set-times-while-calling.cpp 2011-07-06 18:58:47 +0000
2175+++ src/timer/tests/while-calling/src/test-timer-set-times-while-calling.cpp 2011-11-01 23:21:23 +0000
2176@@ -122,3 +122,9 @@
2177 t3->setTimes (3000, 3100);
2178 t3->start ();
2179 }
2180+
2181+CompTimerTest *
2182+getTestObject ()
2183+{
2184+ return new CompTimerTestSetCalling ();
2185+}
2186
2187=== modified file 'src/window.cpp'
2188--- src/window.cpp 2011-10-26 23:18:47 +0000
2189+++ src/window.cpp 2011-11-01 23:21:23 +0000
2190@@ -23,8 +23,6 @@
2191 * Author: David Reveman <davidr@novell.com>
2192 */
2193
2194-#include <compiz.h>
2195-
2196 #include <X11/Xlib.h>
2197 #include <X11/Xatom.h>
2198 #include <X11/Xproto.h>
2199@@ -6141,14 +6139,14 @@
2200 if (screen->vpSize ().width () != 1)
2201 {
2202 x += screen->vp ().x () * screen->width ();
2203- x = MOD (x, vWidth);
2204+ x = compiz::core::screen::wraparound_mod (x, vWidth);
2205 x -= screen->vp ().x () * screen->width ();
2206 }
2207
2208 if (screen->vpSize ().height () != 1)
2209 {
2210 y += screen->vp ().y () * screen->height ();
2211- y = MOD (y, vHeight);
2212+ y = compiz::core::screen::wraparound_mod (y, vHeight);
2213 y -= screen->vp ().y () * screen->height ();
2214 }
2215
2216
2217=== removed directory 'tests'
2218=== removed file 'tests/CMakeLists.txt'
2219--- tests/CMakeLists.txt 2011-07-06 19:52:01 +0000
2220+++ tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
2221@@ -1,2 +0,0 @@
2222-add_subdirectory (pluginclasshandler)
2223-add_subdirectory (timer)
2224
2225=== removed directory 'tests/timer'
2226=== removed file 'tests/timer/diffs/test-timer-diffs.cpp'
2227--- tests/timer/diffs/test-timer-diffs.cpp 2011-07-06 18:58:47 +0000
2228+++ tests/timer/diffs/test-timer-diffs.cpp 1970-01-01 00:00:00 +0000
2229@@ -1,82 +0,0 @@
2230-/*
2231- * Copyright © 2011 Canonical Ltd.
2232- *
2233- * Permission to use, copy, modify, distribute, and sell this software
2234- * and its documentation for any purpose is hereby granted without
2235- * fee, provided that the above copyright notice appear in all copies
2236- * and that both that copyright notice and this permission notice
2237- * appear in supporting documentation, and that the name of
2238- * Canonical Ltd. not be used in advertising or publicity pertaining to
2239- * distribution of the software without specific, written prior permission.
2240- * Canonical Ltd. makes no representations about the suitability of this
2241- * software for any purpose. It is provided "as is" without express or
2242- * implied warranty.
2243- *
2244- * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2245- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2246- * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2247- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2248- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2249- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2250- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2251- *
2252- * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2253- */
2254-
2255-#include "test-timer.h"
2256-
2257-bool
2258-CompTimerTestDiffs::cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3)
2259-{
2260- if (timernum == 1 || timernum == 2 || timernum == 3)
2261- {
2262- std::cout << "INFO: executing timer " << timernum << std::endl;
2263-
2264- std::cout << "INFO: t1->minLeft " << t1->minLeft () << std::endl << \
2265- "INFO: t1->maxLeft " << t1->maxLeft () << std::endl << \
2266- "INFO: t1->minTime " << t1->minTime () << std::endl << \
2267- "INFO: t1->maxTime " << t1->maxTime () << std::endl;
2268-
2269- std::cout << "INFO: t2->minLeft " << t2->minLeft () << std::endl << \
2270- "INFO: t2->maxLeft " << t2->maxLeft () << std::endl << \
2271- "INFO: t2->minTime " << t2->minTime () << std::endl << \
2272- "INFO: t2->maxTime " << t2->maxTime () << std::endl;
2273-
2274- std::cout << "INFO: t3->minLeft " << t3->minLeft () << std::endl << \
2275- "INFO: t3->maxLeft " << t3->maxLeft () << std::endl << \
2276- "INFO: t3->minTime " << t3->minTime () << std::endl << \
2277- "INFO: t3->maxTime " << t3->maxTime () << std::endl;
2278- }
2279-
2280- if (timernum == 3)
2281- ml->quit ();
2282-
2283- std::cout << "return false" << std::endl;
2284- return false;
2285-}
2286-
2287-void
2288-CompTimerTestDiffs::precallback ()
2289-{
2290- CompTimer *t1, *t2, *t3;
2291-
2292- std::cout << "-= TEST: checking timeout diff" << std::endl;
2293-
2294- t1 = new CompTimer ();
2295- t2 = new CompTimer ();
2296- t3 = new CompTimer ();
2297-
2298- timers.push_back (t1);
2299- timers.push_back (t2);
2300- timers.push_back (t3);
2301-
2302- t1->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 1, t1, t2, t3));
2303- t1->setTimes (1000, 1100);
2304- t1->start ();
2305- t2->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 2, t1, t2, t3));
2306- t2->setTimes (2000, 2100);
2307- t2->start ();
2308- t3->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 3, t1, t2, t3));
2309- t3->setTimes (3000, 3100);
2310- t3->start ();
2311-}

Subscribers

People subscribed via source and target branches