Merge lp:~linaro-graphics-wg/compiz-core/linaro-gles2 into lp:compiz-core/0.9.5
- linaro-gles2
- Merge into 0.9.5
Status: | Superseded | ||||||||
---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~linaro-graphics-wg/compiz-core/linaro-gles2 | ||||||||
Merge into: | lp:compiz-core/0.9.5 | ||||||||
Diff against target: |
41667 lines (+29201/-5352) (has conflicts) 161 files modified
CMakeLists.txt (+26/-0) VERSION (+4/-0) cmake/CMakeLists.txt (+2/-0) cmake/CompizCommon.cmake (+67/-0) cmake/CompizGSettings.cmake (+76/-0) cmake/CompizPlugin.cmake (+14/-10) cmake/FindOpenGLES2.cmake (+51/-0) cmake/base.cmake (+3/-1) cmake/plugin_extensions/CompizGenGSettings.cmake (+0/-104) cmake/plugin_extensions/CompizOpenGLFixups.cmake (+22/-0) gtk/CMakeLists.txt (+1/-1) gtk/config.h.gtk.in (+0/-25) gtk/gnome/CMakeLists.txt (+74/-0) gtk/gnome/compiz.desktop.in (+1/-1) gtk/window-decorator/actionmenu.c (+0/-133) gtk/window-decorator/blurprops.c (+0/-89) gtk/window-decorator/cairo.c (+915/-0) gtk/window-decorator/decorator.c (+1301/-0) gtk/window-decorator/decorprops.c (+161/-0) gtk/window-decorator/events.c (+1177/-0) gtk/window-decorator/forcequit.c (+0/-201) gtk/window-decorator/frames.c (+316/-0) gtk/window-decorator/gdk.c (+0/-106) gtk/window-decorator/gtk-window-decorator.c (+453/-0) gtk/window-decorator/gtk-window-decorator.h (+1140/-0) gtk/window-decorator/gwd.schemas.in (+81/-0) gtk/window-decorator/metacity.c (+1634/-0) gtk/window-decorator/settings.c (+546/-0) gtk/window-decorator/style.c (+0/-66) gtk/window-decorator/switcher.c (+512/-0) gtk/window-decorator/util.c (+0/-299) gtk/window-decorator/wnck.c (+709/-0) include/core/core.h (+4/-0) include/core/rect.h.OTHER (+229/-0) include/core/screen.h (+3/-1) include/core/window.h (+28/-1) include/decoration.h (+50/-59) kde/window-decorator-kde4/decorator.cpp (+6/-17) kde/window-decorator-kde4/decorator.h (+2/-19) kde/window-decorator-kde4/switcher.cpp (+5/-10) kde/window-decorator-kde4/utils.cpp (+2/-0) kde/window-decorator-kde4/window.cpp (+14/-110) kde/window-decorator-kde4/window.h (+1/-1) libdecoration/decoration.c (+88/-112) metadata/core.xml.in (+3/-3) plugins/annotate/src/annotate.cpp (+160/-86) plugins/bailer/CMakeLists.txt (+5/-0) plugins/bailer/bailer.xml.in (+82/-0) plugins/bailer/src/bailer.cpp (+277/-0) plugins/bailer/src/bailer.h (+86/-0) plugins/blur/CMakeLists.txt (+12/-12) plugins/clone/src/clone.cpp (+4/-9) plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h (+1/-1) plugins/compiztoolbox/src/compiztoolbox.cpp (+14/-28) plugins/composite/include/composite/composite.h (+26/-13) plugins/composite/src/privates.h (+12/-0) plugins/composite/src/screen.cpp (+77/-0) plugins/copytex/src/copytex.cpp (+9/-0) plugins/cube/CMakeLists.txt (+1/-1) plugins/cube/cube.xml.in (+7/-6) plugins/cube/src/cube.cpp (+40/-39) plugins/debugspew/CMakeLists.txt (+5/-0) plugins/debugspew/debugspew.xml.in (+24/-0) plugins/debugspew/src/debugspew.cpp (+622/-0) plugins/debugspew/src/debugspew.h (+55/-0) plugins/decor/decor.xml.in (+38/-0) plugins/decor/src/decor.cpp (+338/-885) plugins/decor/src/decor.h (+14/-36) plugins/detection/CMakeLists.txt (+5/-0) plugins/detection/detection.xml.in (+28/-0) plugins/detection/src/detection.cpp (+74/-0) plugins/detection/src/detection.h (+52/-0) plugins/fade/fade.xml.in (+2/-1) plugins/imgsvg/src/imgsvg.cpp (+12/-9) plugins/imgsvg/src/imgsvg.h (+2/-1) plugins/kde/src/dispatcher.cpp (+18/-18) plugins/kde/src/dispatcher.h (+8/-8) plugins/kde/src/socket.cpp (+1/-1) plugins/kde/src/timer.cpp (+1/-1) plugins/move/src/move.cpp (+41/-0) plugins/move/src/move.h (+7/-1) plugins/obs/src/obs.cpp (+10/-9) plugins/obs/src/obs.h (+1/-1) plugins/opengl/CMakeLists.txt (+9/-4) plugins/opengl/compiz-opengl.pc.in (+2/-2) plugins/opengl/include/opengl/framebufferobject.h (+107/-0) plugins/opengl/include/opengl/matrix.h (+2/-0) plugins/opengl/include/opengl/opengl.h (+275/-65) plugins/opengl/include/opengl/program.h (+75/-0) plugins/opengl/include/opengl/programcache.h (+51/-0) plugins/opengl/include/opengl/texture.h (+9/-0) plugins/opengl/include/opengl/vector.h (+1/-1) plugins/opengl/include/opengl/vertexbuffer.h (+100/-0) plugins/opengl/opengl.xml.in (+1/-1) plugins/opengl/src/framebufferobject.cpp (+191/-0) plugins/opengl/src/matrix.cpp (+54/-0) plugins/opengl/src/paint.cpp (+446/-360) plugins/opengl/src/privatefragment.h (+0/-54) plugins/opengl/src/privates.h (+41/-9) plugins/opengl/src/privatetexture.h (+37/-0) plugins/opengl/src/privatevertexbuffer.h (+136/-0) plugins/opengl/src/program.cpp (+262/-0) plugins/opengl/src/programcache.cpp (+175/-0) plugins/opengl/src/screen.cpp (+813/-69) plugins/opengl/src/shaders.h (+136/-0) plugins/opengl/src/texture.cpp (+137/-12) plugins/opengl/src/vertexbuffer.cpp (+530/-0) plugins/opengl/src/window.cpp (+44/-84) plugins/place/place.xml.in (+5/-0) plugins/place/src/place.h (+15/-2) plugins/resize/resize.xml.in (+8/-8) plugins/resize/src/resize.cpp (+95/-40) plugins/rotate/CMakeLists.txt (+1/-1) plugins/rotate/src/rotate.cpp (+21/-21) plugins/scale/scale.xml.in (+8/-10) plugins/scale/src/privates.h (+4/-0) plugins/scale/src/scale.cpp (+39/-24) plugins/screenshot/src/screenshot.cpp (+52/-25) plugins/switcher/src/switcher.cpp (+49/-48) plugins/water/CMakeLists.txt (+1/-1) plugins/water/src/shaders.h (+201/-0) plugins/water/src/water.cpp (+265/-803) plugins/water/src/water.h (+37/-67) plugins/water/water.xml.in (+24/-0) plugins/wobbly/CMakeLists.txt (+1/-1) plugins/zoom/src/zoom.cpp.OTHER (+764/-0) src/CMakeLists.txt (+36/-0) src/event.cpp (+62/-0) src/main.cpp (+67/-1) src/plugin.cpp (+1/-3) src/privatescreen.h (+83/-1) src/screen.cpp (+212/-64) src/stackdebugger.cpp (+985/-491) src/window.cpp (+873/-104) unity/unity_window_decorator/AUTHORS (+29/-0) unity/unity_window_decorator/CMakeLists.txt (+38/-0) unity/unity_window_decorator/COPYING (+6/-0) unity/unity_window_decorator/COPYING.GPL (+340/-0) unity/unity_window_decorator/INSTALL (+14/-0) unity/unity_window_decorator/README (+8/-0) unity/unity_window_decorator/src/CMakeLists.txt (+161/-0) unity/unity_window_decorator/src/TODO (+6/-0) unity/unity_window_decorator/src/actionmenu.c (+109/-0) unity/unity_window_decorator/src/blurprops.c (+68/-0) unity/unity_window_decorator/src/cairo.c (+1001/-0) unity/unity_window_decorator/src/config.h.gtk.in (+25/-0) unity/unity_window_decorator/src/decorator.c (+874/-0) unity/unity_window_decorator/src/decorprops.c (+150/-0) unity/unity_window_decorator/src/events.c (+1146/-0) unity/unity_window_decorator/src/forcequit.c (+176/-0) unity/unity_window_decorator/src/gdk.c (+87/-0) unity/unity_window_decorator/src/gtk-window-decorator.c (+442/-0) unity/unity_window_decorator/src/gtk-window-decorator.h (+1009/-0) unity/unity_window_decorator/src/gwd.schemas.in (+81/-0) unity/unity_window_decorator/src/metacity.c (+1943/-0) unity/unity_window_decorator/src/settings.c (+567/-0) unity/unity_window_decorator/src/style.c (+42/-0) unity/unity_window_decorator/src/switcher.c (+452/-0) unity/unity_window_decorator/src/util.c (+278/-0) unity/unity_window_decorator/src/wnck.c (+714/-0) xslt/compiz_gsettings_schemas.xslt.in (+0/-441) Text conflict in CMakeLists.txt Text conflict in VERSION Text conflict in cmake/CompizCommon.cmake Contents conflict in cmake/CompizGSettings.cmake Text conflict in gtk/gnome/CMakeLists.txt Contents conflict in gtk/window-decorator/cairo.c Contents conflict in gtk/window-decorator/decorator.c Contents conflict in gtk/window-decorator/decorprops.c Contents conflict in gtk/window-decorator/events.c Contents conflict in gtk/window-decorator/frames.c Contents conflict in gtk/window-decorator/gtk-window-decorator.c Contents conflict in gtk/window-decorator/gtk-window-decorator.h Contents conflict in gtk/window-decorator/gwd.schemas.in Contents conflict in gtk/window-decorator/metacity.c Contents conflict in gtk/window-decorator/settings.c Contents conflict in gtk/window-decorator/switcher.c Contents conflict in gtk/window-decorator/wnck.c Text conflict in include/core/core.h Contents conflict in include/core/rect.h Text conflict in include/core/window.h Text conflict in libdecoration/decoration.c Text conflict in plugins/composite/include/composite/composite.h Text conflict in plugins/composite/src/privates.h Text conflict in plugins/composite/src/screen.cpp Text conflict in plugins/cube/src/cube.cpp Text conflict in plugins/decor/decor.xml.in Text conflict in plugins/decor/src/decor.cpp Text conflict in plugins/decor/src/decor.h Text conflict in plugins/move/src/move.cpp Contents conflict in plugins/opengl/include/opengl/fragment.h Text conflict in plugins/opengl/include/opengl/opengl.h Text conflict in plugins/opengl/include/opengl/texture.h Contents conflict in plugins/opengl/src/fragment.cpp Text conflict in plugins/opengl/src/paint.cpp Text conflict in plugins/opengl/src/privates.h Text conflict in plugins/opengl/src/privatetexture.h Text conflict in plugins/opengl/src/screen.cpp Text conflict in plugins/place/place.xml.in Text conflict in plugins/place/src/place.h Text conflict in plugins/scale/src/privates.h Text conflict in plugins/scale/src/scale.cpp Conflict adding files to plugins/zoom. Created directory. Conflict because plugins/zoom is not versioned, but has versioned children. Versioned directory. Conflict adding files to plugins/zoom/src. Created directory. Conflict because plugins/zoom/src is not versioned, but has versioned children. Versioned directory. Contents conflict in plugins/zoom/src/zoom.cpp Text conflict in src/CMakeLists.txt Text conflict in src/event.cpp Text conflict in src/main.cpp Text conflict in src/privatescreen.h Text conflict in src/screen.cpp Text conflict in src/stackdebugger.cpp Text conflict in src/window.cpp |
||||||||
To merge this branch: | bzr merge lp:~linaro-graphics-wg/compiz-core/linaro-gles2 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Spilsbury | Pending | ||
Review via email: mp+89765@code.launchpad.net |
This proposal supersedes a proposal from 2011-08-10.
This proposal has been superseded by a proposal from 2012-02-21.
Commit message
Description of the change
This branch contains the code to make compiz work on GLES. This includes several changes to the compiz API.
* GLVertexBuffer class added for managing vertices, normals, texture coordinates, and colors
* GLProgram class added for managing GLSL programs
* GLProgramCache class added for managing per-plugin GLSL programs efficiently, uses an LRU cache
to avoid recompiling recently used GLSL programs all the time
* GLFragment class removed as fragment programs are no longer used (replaced with GLSL programs)
* GL_BLEND now always enabled when rendering as almost everything was enabling it anyway
* EGL context setup added
* EglTexture class added to use EGL_image extension instead of GLX_EXT_
Things left to do for a complete port:
* properly check for GLSL support on desktop, currently assumes if you have VBO support you
have GLSL support
* port blur, wobbly, rotate, cube, and water plugins
* wobbly, cube, and rotate should be fairly straightforward, water and blur need updated to
use GLSL instead of fragment programs
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Is there a reason nothing has happened here since Aug/Sep 2011?
Sam Spilsbury (smspillaz) wrote : | # |
All these conflicts seem to be here due to the fact that bzr seems to think we've deleted and re-added every file in the tree *sigh*
Daniel van Vugt (vanvugt) wrote : | # |
No problem. Just make a new branch and copy these files into it and propose the new one. Then bzr should be happier.
Frederic Plourde (fredinfinite23) : | # |
- 2901. By Frederic Plourde
-
Fix compiz decorator's shadow blending
- 2902. By Frederic Plourde
-
Workaround GL_LINE_LOOP usage in resize plugin
- 2903. By Frederic Plourde
-
Fix blending in the resize plugin
- 2904. By Frederic Plourde
-
Draw resize plugin in fullscreen mode to workaround rendering instabilities
- 2905. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2906. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2907. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2908. By Alexandros Frantzis
-
Use new WRAPABLE_HND_* macros.
- 2909. By Alexandros Frantzis
-
Correct count of wrapable functions in GLScreen.
- 2910. By Alexandros Frantzis
-
Sync with lp:compiz-core
- 2911. By Frederic Plourde
-
Fix decoration mapping instabilities and texturing artefacts.
- 2912. By Alexandros Frantzis
-
Work around compile issue on ARM.
When compiling with -O2 on ARM, the original code leads to an array index out
of bounds compilation error. In that case, the compiler doesn't infer that
sizeof(a)/sizeof(T) is a constant, and tries to compile cases in the switch
statement that use array indices that are invalid for the particular template
instantiation.To fix this we use the 'C' template variable, which is constant for each
template instantiation, directly in the switch statement. - 2913. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2914. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2915. By Alexandros Frantzis
-
opengl: Ensure blending is enabled, when needed, when drawing window contents.
- 2916. By Alexandros Frantzis
-
opengl: Refactor shader infrastructure to use small, performant programs.
This commit replaces the single complicated shader with minimal,
performant shaders, tailored to specific use cases. The new GLShaderCache
object is used for creating and caching the shader data for specific uses
cases (GLShaderParameters). This commit also adds automatic creation of suitable GL programs in
GLVertexBuffers (see ::setAutoProgram) that don't have a program
explicitly set. - 2917. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2918. By Alexandros Frantzis
-
opengl: Disable blending by default when drawing the screen.
Each operation/plugin should enable it (and reset it) as needed
(as most operations are currently doing). - 2919. By Alexandros Frantzis
-
Fix compilation with desktop GL.
- 2920. By Alexandros Frantzis
-
opengl: For OpenGL ES 2.0 ensure that format equals internalFormat when uploading texture data.
In OpenGL ES 2.0 no format conversion is allowed, i.e., format must equal internalFormat.
- 2921. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2922. By Alexandros Frantzis
-
Sync with lp:compiz-core.
Unmerged revisions
- 2922. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2921. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2920. By Alexandros Frantzis
-
opengl: For OpenGL ES 2.0 ensure that format equals internalFormat when uploading texture data.
In OpenGL ES 2.0 no format conversion is allowed, i.e., format must equal internalFormat.
- 2919. By Alexandros Frantzis
-
Fix compilation with desktop GL.
- 2918. By Alexandros Frantzis
-
opengl: Disable blending by default when drawing the screen.
Each operation/plugin should enable it (and reset it) as needed
(as most operations are currently doing). - 2917. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2916. By Alexandros Frantzis
-
opengl: Refactor shader infrastructure to use small, performant programs.
This commit replaces the single complicated shader with minimal,
performant shaders, tailored to specific use cases. The new GLShaderCache
object is used for creating and caching the shader data for specific uses
cases (GLShaderParameters). This commit also adds automatic creation of suitable GL programs in
GLVertexBuffers (see ::setAutoProgram) that don't have a program
explicitly set. - 2915. By Alexandros Frantzis
-
opengl: Ensure blending is enabled, when needed, when drawing window contents.
- 2914. By Alexandros Frantzis
-
Sync with lp:compiz-core.
- 2913. By Alexandros Frantzis
-
Sync with lp:compiz-core.
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2012-01-24 10:43:23 +0000 | |||
3 | +++ CMakeLists.txt 2012-02-08 18:50:27 +0000 | |||
4 | @@ -86,6 +86,7 @@ | |||
5 | 86 | libxml-2.0 | 86 | libxml-2.0 |
6 | 87 | libxslt | 87 | libxslt |
7 | 88 | glib-2.0 | 88 | glib-2.0 |
8 | 89 | gtk+-3.0 | ||
9 | 89 | gio-2.0 | 90 | gio-2.0 |
10 | 90 | glibmm-2.4 | 91 | glibmm-2.4 |
11 | 91 | "libstartup-notification-1.0 >= 0.7" | 92 | "libstartup-notification-1.0 >= 0.7" |
12 | @@ -119,6 +120,7 @@ | |||
13 | 119 | DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig | 120 | DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig |
14 | 120 | ) | 121 | ) |
15 | 121 | 122 | ||
16 | 123 | <<<<<<< TREE | ||
17 | 122 | # Build Google Test and make its headers known | 124 | # Build Google Test and make its headers known |
18 | 123 | find_package (GTest) | 125 | find_package (GTest) |
19 | 124 | find_library (GMOCK_LIBRARY gmock) | 126 | find_library (GMOCK_LIBRARY gmock) |
20 | @@ -134,6 +136,14 @@ | |||
21 | 134 | find_package (Threads REQUIRED) | 136 | find_package (Threads REQUIRED) |
22 | 135 | 137 | ||
23 | 136 | # Add the rest of compiz | 138 | # Add the rest of compiz |
24 | 139 | ======= | ||
25 | 140 | # temporarily disable plugins that aren't ported yed | ||
26 | 141 | set (COMPIZ_DISABLE_PLUGIN_BLUR ON) | ||
27 | 142 | set (COMPIZ_DISABLE_PLUGIN_CUBE ON) | ||
28 | 143 | set (COMPIZ_DISABLE_PLUGIN_ROTATE ON) | ||
29 | 144 | set (COMPIZ_DISABLE_PLUGIN_WOBBLY ON) | ||
30 | 145 | |||
31 | 146 | >>>>>>> MERGE-SOURCE | ||
32 | 137 | add_subdirectory (cmake) | 147 | add_subdirectory (cmake) |
33 | 138 | add_subdirectory (include) | 148 | add_subdirectory (include) |
34 | 139 | add_subdirectory (images) | 149 | add_subdirectory (images) |
35 | @@ -145,7 +155,14 @@ | |||
36 | 145 | add_subdirectory (src) | 155 | add_subdirectory (src) |
37 | 146 | add_subdirectory (xslt) | 156 | add_subdirectory (xslt) |
38 | 147 | add_subdirectory (plugins) | 157 | add_subdirectory (plugins) |
39 | 158 | <<<<<<< TREE | ||
40 | 148 | add_subdirectory (tests) | 159 | add_subdirectory (tests) |
41 | 160 | ======= | ||
42 | 161 | add_subdirectory (unity/unity_window_decorator) | ||
43 | 162 | if (BUILD_TESTING) | ||
44 | 163 | add_subdirectory (tests) | ||
45 | 164 | endif (BUILD_TESTING) | ||
46 | 165 | >>>>>>> MERGE-SOURCE | ||
47 | 149 | 166 | ||
48 | 150 | compiz_ensure_linkage () | 167 | compiz_ensure_linkage () |
49 | 151 | compiz_package_generation ("Compiz") | 168 | compiz_package_generation ("Compiz") |
50 | @@ -159,7 +176,16 @@ | |||
51 | 159 | 176 | ||
52 | 160 | _check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG}) | 177 | _check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG}) |
53 | 161 | 178 | ||
54 | 179 | <<<<<<< TREE | ||
55 | 162 | # Enable coverage reporting for compiz | 180 | # Enable coverage reporting for compiz |
56 | 163 | enable_coverage_report() | 181 | enable_coverage_report() |
57 | 164 | 182 | ||
58 | 165 | 183 | ||
59 | 184 | ======= | ||
60 | 185 | # temporarily disable plugins that aren't ported yed | ||
61 | 186 | SET(COMPIZ_DISABLE_PLUGIN_BLUR "ON") | ||
62 | 187 | SET(COMPIZ_DISABLE_PLUGIN_CUBE "ON") | ||
63 | 188 | SET(COMPIZ_DISABLE_PLUGIN_ROTATE "ON") | ||
64 | 189 | SET(COMPIZ_DISABLE_PLUGIN_WATER "ON") | ||
65 | 190 | SET(COMPIZ_DISABLE_PLUGIN_WOBBLY "ON") | ||
66 | 191 | >>>>>>> MERGE-SOURCE | ||
67 | 166 | 192 | ||
68 | === modified file 'NEWS' | |||
69 | === modified file 'VERSION' | |||
70 | --- VERSION 2012-01-24 09:11:41 +0000 | |||
71 | +++ VERSION 2012-02-08 18:50:27 +0000 | |||
72 | @@ -1,1 +1,5 @@ | |||
73 | 1 | <<<<<<< TREE | ||
74 | 1 | 0.9.7.0 | 2 | 0.9.7.0 |
75 | 3 | ======= | ||
76 | 4 | 0.9.6 | ||
77 | 5 | >>>>>>> MERGE-SOURCE | ||
78 | 2 | 6 | ||
79 | === modified file 'cmake/CMakeLists.txt' | |||
80 | --- cmake/CMakeLists.txt 2011-07-27 16:13:28 +0000 | |||
81 | +++ cmake/CMakeLists.txt 2012-02-08 18:50:27 +0000 | |||
82 | @@ -15,6 +15,8 @@ | |||
83 | 15 | plugin_extensions/CompizGenInstallData.cmake) | 15 | plugin_extensions/CompizGenInstallData.cmake) |
84 | 16 | list (APPEND _PluginExtensionFiles | 16 | list (APPEND _PluginExtensionFiles |
85 | 17 | plugin_extensions/CompizGenInstallImages.cmake) | 17 | plugin_extensions/CompizGenInstallImages.cmake) |
86 | 18 | list (APPEND _PluginExtensionFiles | ||
87 | 19 | plugin_extensions/CompizOpenGLFixups.cmake) | ||
88 | 18 | 20 | ||
89 | 19 | if (USE_GCONF) | 21 | if (USE_GCONF) |
90 | 20 | list (APPEND _files CompizGconf.cmake) | 22 | list (APPEND _files CompizGconf.cmake) |
91 | 21 | 23 | ||
92 | === modified file 'cmake/CompizCommon.cmake' | |||
93 | --- cmake/CompizCommon.cmake 2012-01-27 07:01:47 +0000 | |||
94 | +++ cmake/CompizCommon.cmake 2012-02-08 18:50:27 +0000 | |||
95 | @@ -18,6 +18,7 @@ | |||
96 | 18 | 18 | ||
97 | 19 | set (CMAKE_SKIP_RPATH FALSE) | 19 | set (CMAKE_SKIP_RPATH FALSE) |
98 | 20 | 20 | ||
99 | 21 | option (BUILD_GLES "Build against GLESv2 instead of GL" OFF) | ||
100 | 21 | option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON) | 22 | option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON) |
101 | 22 | option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install") | 23 | option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install") |
102 | 23 | option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF) | 24 | option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF) |
103 | @@ -75,6 +76,17 @@ | |||
104 | 75 | set(IS_BZR_REPO 0) | 76 | set(IS_BZR_REPO 0) |
105 | 76 | endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr) | 77 | endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr) |
106 | 77 | 78 | ||
107 | 79 | set (USE_GLES ${BUILD_GLES}) | ||
108 | 80 | |||
109 | 81 | if (USE_GLES) | ||
110 | 82 | find_package(OpenGLES2) | ||
111 | 83 | |||
112 | 84 | if (NOT OPENGLES2_FOUND) | ||
113 | 85 | set (USE_GLES 0) | ||
114 | 86 | message (SEND_ERROR "OpenGLESv2 not found") | ||
115 | 87 | endif (NOT OPENGLES2_FOUND) | ||
116 | 88 | endif (USE_GLES) | ||
117 | 89 | |||
118 | 78 | function (compiz_ensure_linkage) | 90 | function (compiz_ensure_linkage) |
119 | 79 | find_program (LDCONFIG_EXECUTABLE ldconfig) | 91 | find_program (LDCONFIG_EXECUTABLE ldconfig) |
120 | 80 | mark_as_advanced (FORCE LDCONFIG_EXECUTABLE) | 92 | mark_as_advanced (FORCE LDCONFIG_EXECUTABLE) |
121 | @@ -124,8 +136,13 @@ | |||
122 | 124 | add_custom_target (release-signoff) | 136 | add_custom_target (release-signoff) |
123 | 125 | 137 | ||
124 | 126 | add_custom_target (release-update-working-tree | 138 | add_custom_target (release-update-working-tree |
125 | 139 | <<<<<<< TREE | ||
126 | 127 | COMMAND cp NEWS ${CMAKE_SOURCE_DIR} && bzr add ${CMAKE_SOURCE_DIR}/NEWS && | 140 | COMMAND cp NEWS ${CMAKE_SOURCE_DIR} && bzr add ${CMAKE_SOURCE_DIR}/NEWS && |
127 | 128 | cp AUTHORS ${CMAKE_SOURCE_DIR} && bzr add ${CMAKE_SOURCE_DIR}/AUTHORS | 141 | cp AUTHORS ${CMAKE_SOURCE_DIR} && bzr add ${CMAKE_SOURCE_DIR}/AUTHORS |
128 | 142 | ======= | ||
129 | 143 | COMMAND cp NEWS ${CMAKE_SOURCE_DIR} && git add ${CMAKE_SOURCE_DIR}/NEWS && | ||
130 | 144 | cp AUTHORS ${CMAKE_SOURCE_DIR} && git add ${CMAKE_SOURCE_DIR}/AUTHORS | ||
131 | 145 | >>>>>>> MERGE-SOURCE | ||
132 | 129 | COMMENT "Updating working tree" | 146 | COMMENT "Updating working tree" |
133 | 130 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | 147 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) |
134 | 131 | 148 | ||
135 | @@ -190,6 +207,7 @@ | |||
136 | 190 | message ("-- Using auto news update: " ${AUTO_NEWS_UPDATE}) | 207 | message ("-- Using auto news update: " ${AUTO_NEWS_UPDATE}) |
137 | 191 | endif (AUTO_NEWS_UPDATE) | 208 | endif (AUTO_NEWS_UPDATE) |
138 | 192 | 209 | ||
139 | 210 | <<<<<<< TREE | ||
140 | 193 | if (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed) | 211 | if (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed) |
141 | 194 | file (WRITE ${CMAKE_SOURCE_DIR}/.AUTHORS.sed "") | 212 | file (WRITE ${CMAKE_SOURCE_DIR}/.AUTHORS.sed "") |
142 | 195 | endif (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed) | 213 | endif (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed) |
143 | @@ -210,6 +228,55 @@ | |||
144 | 210 | COMMENT "Generating NEWS Header" | 228 | COMMENT "Generating NEWS Header" |
145 | 211 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | 229 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |
146 | 212 | endif (AUTO_NEWS_UPDATE) | 230 | endif (AUTO_NEWS_UPDATE) |
147 | 231 | ======= | ||
148 | 232 | if (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed) | ||
149 | 233 | file (WRITE ${CMAKE_SOURCE_DIR}/.AUTHORS.sed "") | ||
150 | 234 | endif (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed) | ||
151 | 235 | |||
152 | 236 | if (${IS_GIT_REPO}) | ||
153 | 237 | find_program (GEN_GIT_LOG gen-git-log.sh) | ||
154 | 238 | add_custom_target (authors | ||
155 | 239 | COMMAND git shortlog -se | cut -c8- | sed -r -f ${CMAKE_SOURCE_DIR}/.AUTHORS.sed | sort -u > AUTHORS | ||
156 | 240 | COMMENT "Generating AUTHORS" | ||
157 | 241 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
158 | 242 | |||
159 | 243 | if (AUTO_NEWS_UPDATE) | ||
160 | 244 | add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update | ||
161 | 245 | COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`git config user.name`' <'`git config user.email`'>)' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo '${AUTO_NEWS_UPDATE}' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update | ||
162 | 246 | COMMENT "Generating NEWS Header" | ||
163 | 247 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
164 | 248 | else (AUTO_NEWS_UPDATE) | ||
165 | 249 | add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update | ||
166 | 250 | COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`git config user.name`' <'`git config user.email`'>)' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && $ENV{EDITOR} ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update | ||
167 | 251 | COMMENT "Generating NEWS Header" | ||
168 | 252 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
169 | 253 | endif (AUTO_NEWS_UPDATE) | ||
170 | 254 | |||
171 | 255 | else (${IS_GIT_REPO}) | ||
172 | 256 | if (${IS_BZR_REPO}) | ||
173 | 257 | add_custom_target (authors | ||
174 | 258 | COMMAND bzr log --long --levels=0 | grep -e "^\\s*author:" -e "^\\s*committer:" | cut -d ":" -f 2 | sed -r -f ${CMAKE_SOURCE_DIR}/.AUTHORS.sed | sort -u > AUTHORS | ||
175 | 259 | COMMENT "Generating AUTHORS") | ||
176 | 260 | |||
177 | 261 | if (AUTO_NEWS_UPDATE) | ||
178 | 262 | |||
179 | 263 | add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update | ||
180 | 264 | COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`bzr config email`')' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo '${AUTO_NEWS_UPDATE}' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update | ||
181 | 265 | COMMENT "Generating NEWS Header" | ||
182 | 266 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
183 | 267 | else (AUTO_NEWS_UPDATE) | ||
184 | 268 | add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update | ||
185 | 269 | COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`bzr config email`')' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && $ENV{EDITOR} ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update | ||
186 | 270 | COMMENT "Generating NEWS Header" | ||
187 | 271 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
188 | 272 | endif (AUTO_NEWS_UPDATE) | ||
189 | 273 | |||
190 | 274 | else (${IS_BZR_REPO}) | ||
191 | 275 | add_custom_target (authors) | ||
192 | 276 | add_custom_target (news-header) | ||
193 | 277 | endif (${IS_BZR_REPO}) | ||
194 | 278 | endif (${IS_GIT_REPO}) | ||
195 | 279 | >>>>>>> MERGE-SOURCE | ||
196 | 213 | 280 | ||
197 | 214 | add_custom_target (news | 281 | add_custom_target (news |
198 | 215 | COMMAND cat ${CMAKE_SOURCE_DIR}/NEWS > NEWS.old && | 282 | COMMAND cat ${CMAKE_SOURCE_DIR}/NEWS > NEWS.old && |
199 | 216 | 283 | ||
200 | === added file 'cmake/CompizGSettings.cmake' | |||
201 | --- cmake/CompizGSettings.cmake 1970-01-01 00:00:00 +0000 | |||
202 | +++ cmake/CompizGSettings.cmake 2012-02-08 18:50:27 +0000 | |||
203 | @@ -0,0 +1,76 @@ | |||
204 | 1 | option ( | ||
205 | 2 | USE_GSETTINGS | ||
206 | 3 | "Generate GSettings schemas" | ||
207 | 4 | ON | ||
208 | 5 | ) | ||
209 | 6 | |||
210 | 7 | option ( | ||
211 | 8 | COMPIZ_DISABLE_GS_SCHEMAS_INSTALL | ||
212 | 9 | "Disables gsettings schema installation" | ||
213 | 10 | OFF | ||
214 | 11 | ) | ||
215 | 12 | |||
216 | 13 | set ( | ||
217 | 14 | COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR ${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR} CACHE PATH | ||
218 | 15 | "Installation path of the gsettings schema file" | ||
219 | 16 | ) | ||
220 | 17 | |||
221 | 18 | function (compiz_install_gsettings_schema _src _dst) | ||
222 | 19 | find_program (PKG_CONFIG_TOOL pkg-config) | ||
223 | 20 | find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) | ||
224 | 21 | mark_as_advanced (FORCE PKG_CONFIG_TOOL) | ||
225 | 22 | |||
226 | 23 | # find out where schemas need to go if we are installing them systemwide | ||
227 | 24 | execute_process (COMMAND ${PKG_CONFIG_TOOL} glib-2.0 --variable prefix OUTPUT_VARIABLE GSETTINGS_GLIB_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
228 | 25 | SET (GSETTINGS_GLOBAL_INSTALL_DIR "${GSETTINGS_GLIB_PREFIX}/share/glib-2.0/schemas/") | ||
229 | 26 | |||
230 | 27 | if (PKG_CONFIG_TOOL AND | ||
231 | 28 | GLIB_COMPILE_SCHEMAS AND NOT | ||
232 | 29 | COMPIZ_DISABLE_SCHEMAS_INSTALL AND | ||
233 | 30 | USE_GSETTINGS) | ||
234 | 31 | install (CODE " | ||
235 | 32 | message (\"$ENV{USER} is the username in use right now\") | ||
236 | 33 | if (\"$ENV{USER}\"\ STREQUAL \"root\") | ||
237 | 34 | message (\"-- Installing GSettings schemas ${GSETTINGS_GLOBAL_INSTALL_DIR}\"\) | ||
238 | 35 | file (INSTALL DESTINATION \"${GSETTINGS_GLOBAL_INSTALL_DIR}\" | ||
239 | 36 | TYPE FILE | ||
240 | 37 | FILES \"${_src}\") | ||
241 | 38 | message (\"-- Recompiling GSettings schemas in ${GSETTINGS_GLOBAL_INSTALL_DIR}\"\) | ||
242 | 39 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${GSETTINGS_GLOBAL_INSTALL_DIR}) | ||
243 | 40 | |||
244 | 41 | else (\"$ENV{USER}\"\ STREQUAL \"root\"\) | ||
245 | 42 | # It seems like this is only available in CMake > 2.8.5 | ||
246 | 43 | # but hardly anybody has that, so comment out this warning for now | ||
247 | 44 | # string (FIND $ENV{XDG_DATA_DIRS} \"${COMPIZ_DESTDIR}${_dst}\" XDG_INSTALL_PATH) | ||
248 | 45 | # if (NOT XDG_INSTALL_PATH) | ||
249 | 46 | # message (\"[WARNING]: Installing GSettings schemas to directory that is not in XDG_DATA_DIRS, you need to add ${COMPIZ_DESTDIR}${_dst} to your XDG_DATA_DIRS in order for GSettings schemas to be found!\"\) | ||
250 | 47 | # endif (NOT XDG_INSTALL_PATH) | ||
251 | 48 | message (\"-- Installing GSettings schemas to ${COMPIZ_DESTDIR}${_dst}\"\) | ||
252 | 49 | file (INSTALL DESTINATION \"${COMPIZ_DESTDIR}${_dst}\" | ||
253 | 50 | TYPE FILE | ||
254 | 51 | FILES \"${_src}\") | ||
255 | 52 | message (\"-- Recompiling GSettings schemas in ${COMPIZ_DESTDIR}${_dst}\"\) | ||
256 | 53 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${COMPIZ_DESTDIR}${_dst}) | ||
257 | 54 | endif (\"$ENV{USER}\" STREQUAL \"root\"\) | ||
258 | 55 | ") | ||
259 | 56 | endif () | ||
260 | 57 | endfunction () | ||
261 | 58 | |||
262 | 59 | # generate gconf schema | ||
263 | 60 | function (compiz_gsettings_schema _src _dst _inst) | ||
264 | 61 | find_program (XSLTPROC_EXECUTABLE xsltproc) | ||
265 | 62 | mark_as_advanced (FORCE XSLTPROC_EXECUTABLE) | ||
266 | 63 | |||
267 | 64 | if (XSLTPROC_EXECUTABLE AND USE_GSETTINGS) | ||
268 | 65 | message ("generating gsettings schema for core") | ||
269 | 66 | add_custom_command ( | ||
270 | 67 | OUTPUT ${_dst} | ||
271 | 68 | COMMAND ${XSLTPROC_EXECUTABLE} | ||
272 | 69 | -o ${_dst} | ||
273 | 70 | ${COMPIZ_GSETTINGS_SCHEMAS_XSLT} | ||
274 | 71 | ${_src} | ||
275 | 72 | DEPENDS ${_src} | ||
276 | 73 | ) | ||
277 | 74 | compiz_install_gsettings_schema (${_dst} ${_inst}) | ||
278 | 75 | endif () | ||
279 | 76 | endfunction () | ||
280 | 0 | 77 | ||
281 | === renamed file 'cmake/CompizGSettings.cmake' => 'cmake/CompizGSettings.cmake.THIS' | |||
282 | === modified file 'cmake/CompizPlugin.cmake' | |||
283 | --- cmake/CompizPlugin.cmake 2012-01-23 17:33:54 +0000 | |||
284 | +++ cmake/CompizPlugin.cmake 2012-02-08 18:50:27 +0000 | |||
285 | @@ -257,6 +257,16 @@ | |||
286 | 257 | NO_DEFAULT_PATH | 257 | NO_DEFAULT_PATH |
287 | 258 | ) | 258 | ) |
288 | 259 | 259 | ||
289 | 260 | set (COMPIZ_CURRENT_PLUGIN ${plugin}) | ||
290 | 261 | set (COMPIZ_CURRENT_XML_FILE ${_translated_xml}) | ||
291 | 262 | |||
292 | 263 | # find extension files | ||
293 | 264 | file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake") | ||
294 | 265 | |||
295 | 266 | foreach (_file ${_extension_files}) | ||
296 | 267 | include (${_file}) | ||
297 | 268 | endforeach () | ||
298 | 269 | |||
299 | 260 | # generate pkgconfig file and install it and the plugin header file | 270 | # generate pkgconfig file and install it and the plugin header file |
300 | 261 | if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}) | 271 | if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}) |
301 | 262 | if ("${PLUGIN_BUILDTYPE}" STREQUAL "local") | 272 | if ("${PLUGIN_BUILDTYPE}" STREQUAL "local") |
302 | @@ -269,11 +279,15 @@ | |||
303 | 269 | set (VERSION 0.0.1-git) | 279 | set (VERSION 0.0.1-git) |
304 | 270 | endif (NOT VERSION) | 280 | endif (NOT VERSION) |
305 | 271 | 281 | ||
306 | 282 | #add CFLAGSADD so pkg-config file has correct flags | ||
307 | 283 | set (COMPIZ_CFLAGS ${COMPIZ_CFLAGS} ${${_PLUGIN}_CFLAGSADD}) | ||
308 | 284 | |||
309 | 272 | compiz_configure_file ( | 285 | compiz_configure_file ( |
310 | 273 | ${_${plugin}_pkg} | 286 | ${_${plugin}_pkg} |
311 | 274 | ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc | 287 | ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc |
312 | 275 | COMPIZ_REQUIRES | 288 | COMPIZ_REQUIRES |
313 | 276 | COMPIZ_CFLAGS | 289 | COMPIZ_CFLAGS |
314 | 290 | PKGCONFIG_LIBS | ||
315 | 277 | ) | 291 | ) |
316 | 278 | 292 | ||
317 | 279 | install ( | 293 | install ( |
318 | @@ -287,16 +301,6 @@ | |||
319 | 287 | endif () | 301 | endif () |
320 | 288 | endif () | 302 | endif () |
321 | 289 | 303 | ||
322 | 290 | set (COMPIZ_CURRENT_PLUGIN ${plugin}) | ||
323 | 291 | set (COMPIZ_CURRENT_XML_FILE ${_translated_xml}) | ||
324 | 292 | |||
325 | 293 | # find extension files | ||
326 | 294 | file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake") | ||
327 | 295 | |||
328 | 296 | foreach (_file ${_extension_files}) | ||
329 | 297 | include (${_file}) | ||
330 | 298 | endforeach () | ||
331 | 299 | |||
332 | 300 | # find files for build | 304 | # find files for build |
333 | 301 | file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") | 305 | file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") |
334 | 302 | file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h") | 306 | file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h") |
335 | 303 | 307 | ||
336 | === added file 'cmake/FindOpenGLES2.cmake' | |||
337 | --- cmake/FindOpenGLES2.cmake 1970-01-01 00:00:00 +0000 | |||
338 | +++ cmake/FindOpenGLES2.cmake 2012-02-08 18:50:27 +0000 | |||
339 | @@ -0,0 +1,51 @@ | |||
340 | 1 | # - Try to find OpenGLES | ||
341 | 2 | # Once done this will define | ||
342 | 3 | # | ||
343 | 4 | # OPENGLES2_FOUND - system has OpenGLES | ||
344 | 5 | # OPENGLES2_INCLUDE_DIR - the GLES include directory | ||
345 | 6 | # OPENGLES2_LIBRARY - the GLES library | ||
346 | 7 | # OPENGLES2_LIBRARIES - Link this to use OpenGLES | ||
347 | 8 | # | ||
348 | 9 | |||
349 | 10 | FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h | ||
350 | 11 | /usr/openwin/share/include | ||
351 | 12 | /opt/graphics/OpenGL/include /usr/X11R6/include | ||
352 | 13 | /usr/include | ||
353 | 14 | ) | ||
354 | 15 | |||
355 | 16 | FIND_LIBRARY(OPENGLES2_LIBRARY | ||
356 | 17 | NAMES GLESv2 | ||
357 | 18 | PATHS /opt/graphics/OpenGL/lib | ||
358 | 19 | /usr/openwin/lib | ||
359 | 20 | /usr/shlib /usr/X11R6/lib | ||
360 | 21 | /usr/lib | ||
361 | 22 | ) | ||
362 | 23 | |||
363 | 24 | FIND_LIBRARY(OPENGLES2_EGL_LIBRARY | ||
364 | 25 | NAMES EGL | ||
365 | 26 | PATHS /usr/shlib /usr/X11R6/lib | ||
366 | 27 | /usr/lib | ||
367 | 28 | ) | ||
368 | 29 | |||
369 | 30 | # On Unix OpenGL most certainly always requires X11. | ||
370 | 31 | # Feel free to tighten up these conditions if you don't | ||
371 | 32 | # think this is always true. | ||
372 | 33 | # It's not true on OSX. | ||
373 | 34 | |||
374 | 35 | IF (OPENGLES2_LIBRARY) | ||
375 | 36 | IF(NOT X11_FOUND) | ||
376 | 37 | INCLUDE(FindX11) | ||
377 | 38 | ENDIF(NOT X11_FOUND) | ||
378 | 39 | IF (X11_FOUND) | ||
379 | 40 | IF (NOT APPLE) | ||
380 | 41 | SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES}) | ||
381 | 42 | ENDIF (NOT APPLE) | ||
382 | 43 | ENDIF (X11_FOUND) | ||
383 | 44 | ENDIF(OPENGLES2_LIBRARY) | ||
384 | 45 | |||
385 | 46 | SET( OPENGLES2_FOUND "NO" ) | ||
386 | 47 | IF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY) | ||
387 | 48 | SET( OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${OPENGLES2_EGL_LIBRARY} ${OPENGLES2_LIBRARIES}) | ||
388 | 49 | SET( OPENGLES2_FOUND "YES" ) | ||
389 | 50 | ENDIF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY) | ||
390 | 51 | |||
391 | 0 | 52 | ||
392 | === modified file 'cmake/base.cmake' | |||
393 | --- cmake/base.cmake 2011-07-27 16:13:28 +0000 | |||
394 | +++ cmake/base.cmake 2012-02-08 18:50:27 +0000 | |||
395 | @@ -24,6 +24,7 @@ | |||
396 | 24 | compiz_print_configure_header ("Compiz") | 24 | compiz_print_configure_header ("Compiz") |
397 | 25 | compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n") | 25 | compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n") |
398 | 26 | 26 | ||
399 | 27 | compiz_print_result_message ("GLESv2" USE_GLES) | ||
400 | 27 | compiz_print_result_message ("gtk window decorator" USE_GTK) | 28 | compiz_print_result_message ("gtk window decorator" USE_GTK) |
401 | 28 | compiz_print_result_message ("metacity theme support" USE_METACITY) | 29 | compiz_print_result_message ("metacity theme support" USE_METACITY) |
402 | 29 | compiz_print_result_message ("gconf schemas" USE_GCONF) | 30 | compiz_print_result_message ("gconf schemas" USE_GCONF) |
403 | @@ -46,7 +47,8 @@ | |||
404 | 46 | endif () | 47 | endif () |
405 | 47 | add_custom_target (findcompiz_install | 48 | add_custom_target (findcompiz_install |
406 | 48 | ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules && | 49 | ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules && |
408 | 49 | ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules | 50 | ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules && |
409 | 51 | ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindOpenGLES2.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules | ||
410 | 50 | ) | 52 | ) |
411 | 51 | endfunction () | 53 | endfunction () |
412 | 52 | 54 | ||
413 | 53 | 55 | ||
414 | === added file 'cmake/plugin_extensions/CompizGenGSettings.cmake' | |||
415 | --- cmake/plugin_extensions/CompizGenGSettings.cmake 1970-01-01 00:00:00 +0000 | |||
416 | +++ cmake/plugin_extensions/CompizGenGSettings.cmake 2012-02-08 18:50:27 +0000 | |||
417 | @@ -0,0 +1,104 @@ | |||
418 | 1 | option ( | ||
419 | 2 | COMPIZ_DISABLE_SCHEMAS_INSTALL | ||
420 | 3 | "Disables gsettings schema installation" | ||
421 | 4 | OFF | ||
422 | 5 | ) | ||
423 | 6 | |||
424 | 7 | option ( | ||
425 | 8 | USE_GSETTINGS | ||
426 | 9 | "Generate GSettings schemas" | ||
427 | 10 | ON | ||
428 | 11 | ) | ||
429 | 12 | |||
430 | 13 | set ( | ||
431 | 14 | COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR ${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR} CACHE PATH | ||
432 | 15 | "Installation path of the gsettings schema file" | ||
433 | 16 | ) | ||
434 | 17 | |||
435 | 18 | macro (compiz_gsettings_prepare_install_dirs) | ||
436 | 19 | # package | ||
437 | 20 | if ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package") | ||
438 | 21 | if (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
439 | 22 | set (PLUGIN_SCHEMADIR "${datadir}/glib-2.0/schemas/") | ||
440 | 23 | else (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
441 | 24 | set (PLUGIN_SCHEMADIR "${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR}") | ||
442 | 25 | endif (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
443 | 26 | # compiz | ||
444 | 27 | elseif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "compiz" OR | ||
445 | 28 | "$ENV{BUILD_GLOBAL}" STREQUAL "true") | ||
446 | 29 | if (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
447 | 30 | set (PLUGIN_SCHEMADIR "${COMPIZ_PREFIX}/share/glib-2.0/schemas/") | ||
448 | 31 | else (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
449 | 32 | set (PLUGIN_SCHEMADIR "${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR}") | ||
450 | 33 | endif (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
451 | 34 | # local | ||
452 | 35 | else ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "compiz" OR | ||
453 | 36 | "$ENV{BUILD_GLOBAL}" STREQUAL "true") | ||
454 | 37 | |||
455 | 38 | if (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
456 | 39 | set (PLUGIN_SCHEMADIR "$ENV{HOME}/.config/compiz-1/gsettings/schemas") | ||
457 | 40 | else (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
458 | 41 | set (PLUGIN_SCHEMADIR "${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR}") | ||
459 | 42 | endif (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
460 | 43 | |||
461 | 44 | endif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package") | ||
462 | 45 | endmacro (compiz_gsettings_prepare_install_dirs) | ||
463 | 46 | |||
464 | 47 | function (compiz_install_gsettings_schema _src _dst) | ||
465 | 48 | find_program (PKG_CONFIG_TOOL pkg-config) | ||
466 | 49 | find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) | ||
467 | 50 | mark_as_advanced (FORCE PKG_CONFIG_TOOL) | ||
468 | 51 | |||
469 | 52 | # find out where schemas need to go if we are installing them systemwide | ||
470 | 53 | execute_process (COMMAND ${PKG_CONFIG_TOOL} glib-2.0 --variable prefix OUTPUT_VARIABLE GSETTINGS_GLIB_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
471 | 54 | SET (GSETTINGS_GLOBAL_INSTALL_DIR "${GSETTINGS_GLIB_PREFIX}/share/glib-2.0/schemas/") | ||
472 | 55 | |||
473 | 56 | if (USE_GSETTINGS AND | ||
474 | 57 | PKG_CONFIG_TOOL AND | ||
475 | 58 | GLIB_COMPILE_SCHEMAS AND NOT | ||
476 | 59 | COMPIZ_DISABLE_SCHEMAS_INSTALL) | ||
477 | 60 | install (CODE " | ||
478 | 61 | if (\"$ENV{USER}\"\ STREQUAL \"root\") | ||
479 | 62 | message (\"-- Installing GSettings schemas ${GSETTINGS_GLOBAL_INSTALL_DIR}\"\) | ||
480 | 63 | file (INSTALL DESTINATION \"${GSETTINGS_GLOBAL_INSTALL_DIR}\" | ||
481 | 64 | TYPE FILE | ||
482 | 65 | FILES \"${_src}\") | ||
483 | 66 | message (\"-- Recompiling GSettings schemas in ${GSETTINGS_GLOBAL_INSTALL_DIR}\"\) | ||
484 | 67 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${GSETTINGS_GLOBAL_INSTALL_DIR}) | ||
485 | 68 | |||
486 | 69 | else (\"$ENV{USER}\"\ STREQUAL \"root\"\) | ||
487 | 70 | # It seems like this is only available in CMake > 2.8.5 | ||
488 | 71 | # but hardly anybody has that, so comment out this warning for now | ||
489 | 72 | # string (FIND $ENV{XDG_DATA_DIRS} \"${COMPIZ_DESTDIR}${_dst}\" XDG_INSTALL_PATH) | ||
490 | 73 | # if (NOT XDG_INSTALL_PATH) | ||
491 | 74 | message (\"[WARNING]: Installing GSettings schemas to a custom location that might not be in XDG_DATA_DIRS, you need to add ${COMPIZ_DESTDIR}${_dst} to your XDG_DATA_DIRS in order for GSettings schemas to be found!\"\) | ||
492 | 75 | # endif (NOT XDG_INSTALL_PATH) | ||
493 | 76 | message (\"-- Installing GSettings schemas to ${COMPIZ_DESTDIR}${_dst}\"\) | ||
494 | 77 | file (INSTALL DESTINATION \"${COMPIZ_DESTDIR}${_dst}\" | ||
495 | 78 | TYPE FILE | ||
496 | 79 | FILES \"${_src}\") | ||
497 | 80 | message (\"-- Recompiling GSettings schemas in ${COMPIZ_DESTDIR}${_dst}\"\) | ||
498 | 81 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${COMPIZ_DESTDIR}${_dst}) | ||
499 | 82 | endif (\"$ENV{USER}\" STREQUAL \"root\"\) | ||
500 | 83 | ") | ||
501 | 84 | endif () | ||
502 | 85 | endfunction () | ||
503 | 86 | |||
504 | 87 | # generate gsettings schema | ||
505 | 88 | find_program (XSLTPROC_EXECUTABLE xsltproc) | ||
506 | 89 | mark_as_advanced (FORCE XSLTPROC_EXECUTABLE) | ||
507 | 90 | |||
508 | 91 | if (XSLTPROC_EXECUTABLE AND USE_GSETTINGS) | ||
509 | 92 | compiz_gsettings_prepare_install_dirs () | ||
510 | 93 | |||
511 | 94 | add_custom_command ( | ||
512 | 95 | OUTPUT "${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml" | ||
513 | 96 | COMMAND ${XSLTPROC_EXECUTABLE} | ||
514 | 97 | -o "${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml" | ||
515 | 98 | ${COMPIZ_GSETTINGS_SCHEMAS_XSLT} | ||
516 | 99 | ${COMPIZ_CURRENT_XML_FILE} | ||
517 | 100 | DEPENDS ${COMPIZ_CURRENT_XML_FILE} | ||
518 | 101 | ) | ||
519 | 102 | compiz_install_gsettings_schema ("${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml" ${PLUGIN_SCHEMADIR}) | ||
520 | 103 | list (APPEND COMPIZ_CURRENT_SOURCES_ADDS ${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml) | ||
521 | 104 | endif () | ||
522 | 0 | 105 | ||
523 | === removed file 'cmake/plugin_extensions/CompizGenGSettings.cmake' | |||
524 | --- cmake/plugin_extensions/CompizGenGSettings.cmake 2011-09-29 03:29:41 +0000 | |||
525 | +++ cmake/plugin_extensions/CompizGenGSettings.cmake 1970-01-01 00:00:00 +0000 | |||
526 | @@ -1,104 +0,0 @@ | |||
527 | 1 | option ( | ||
528 | 2 | COMPIZ_DISABLE_SCHEMAS_INSTALL | ||
529 | 3 | "Disables gsettings schema installation" | ||
530 | 4 | OFF | ||
531 | 5 | ) | ||
532 | 6 | |||
533 | 7 | option ( | ||
534 | 8 | USE_GSETTINGS | ||
535 | 9 | "Generate GSettings schemas" | ||
536 | 10 | ON | ||
537 | 11 | ) | ||
538 | 12 | |||
539 | 13 | set ( | ||
540 | 14 | COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR ${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR} CACHE PATH | ||
541 | 15 | "Installation path of the gsettings schema file" | ||
542 | 16 | ) | ||
543 | 17 | |||
544 | 18 | macro (compiz_gsettings_prepare_install_dirs) | ||
545 | 19 | # package | ||
546 | 20 | if ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package") | ||
547 | 21 | if (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
548 | 22 | set (PLUGIN_SCHEMADIR "${datadir}/glib-2.0/schemas/") | ||
549 | 23 | else (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
550 | 24 | set (PLUGIN_SCHEMADIR "${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR}") | ||
551 | 25 | endif (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
552 | 26 | # compiz | ||
553 | 27 | elseif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "compiz" OR | ||
554 | 28 | "$ENV{BUILD_GLOBAL}" STREQUAL "true") | ||
555 | 29 | if (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
556 | 30 | set (PLUGIN_SCHEMADIR "${COMPIZ_PREFIX}/share/glib-2.0/schemas/") | ||
557 | 31 | else (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
558 | 32 | set (PLUGIN_SCHEMADIR "${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR}") | ||
559 | 33 | endif (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
560 | 34 | # local | ||
561 | 35 | else ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "compiz" OR | ||
562 | 36 | "$ENV{BUILD_GLOBAL}" STREQUAL "true") | ||
563 | 37 | |||
564 | 38 | if (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
565 | 39 | set (PLUGIN_SCHEMADIR "$ENV{HOME}/.config/compiz-1/gsettings/schemas") | ||
566 | 40 | else (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
567 | 41 | set (PLUGIN_SCHEMADIR "${COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR}") | ||
568 | 42 | endif (NOT COMPIZ_INSTALL_GSETTINGS_SCHEMA_DIR) | ||
569 | 43 | |||
570 | 44 | endif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package") | ||
571 | 45 | endmacro (compiz_gsettings_prepare_install_dirs) | ||
572 | 46 | |||
573 | 47 | function (compiz_install_gsettings_schema _src _dst) | ||
574 | 48 | find_program (PKG_CONFIG_TOOL pkg-config) | ||
575 | 49 | find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) | ||
576 | 50 | mark_as_advanced (FORCE PKG_CONFIG_TOOL) | ||
577 | 51 | |||
578 | 52 | # find out where schemas need to go if we are installing them systemwide | ||
579 | 53 | execute_process (COMMAND ${PKG_CONFIG_TOOL} glib-2.0 --variable prefix OUTPUT_VARIABLE GSETTINGS_GLIB_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
580 | 54 | SET (GSETTINGS_GLOBAL_INSTALL_DIR "${GSETTINGS_GLIB_PREFIX}/share/glib-2.0/schemas/") | ||
581 | 55 | |||
582 | 56 | if (USE_GSETTINGS AND | ||
583 | 57 | PKG_CONFIG_TOOL AND | ||
584 | 58 | GLIB_COMPILE_SCHEMAS AND NOT | ||
585 | 59 | COMPIZ_DISABLE_SCHEMAS_INSTALL) | ||
586 | 60 | install (CODE " | ||
587 | 61 | if (\"$ENV{USER}\"\ STREQUAL \"root\") | ||
588 | 62 | message (\"-- Installing GSettings schemas ${GSETTINGS_GLOBAL_INSTALL_DIR}\"\) | ||
589 | 63 | file (INSTALL DESTINATION \"${GSETTINGS_GLOBAL_INSTALL_DIR}\" | ||
590 | 64 | TYPE FILE | ||
591 | 65 | FILES \"${_src}\") | ||
592 | 66 | message (\"-- Recompiling GSettings schemas in ${GSETTINGS_GLOBAL_INSTALL_DIR}\"\) | ||
593 | 67 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${GSETTINGS_GLOBAL_INSTALL_DIR}) | ||
594 | 68 | |||
595 | 69 | else (\"$ENV{USER}\"\ STREQUAL \"root\"\) | ||
596 | 70 | # It seems like this is only available in CMake > 2.8.5 | ||
597 | 71 | # but hardly anybody has that, so comment out this warning for now | ||
598 | 72 | # string (FIND $ENV{XDG_DATA_DIRS} \"${COMPIZ_DESTDIR}${_dst}\" XDG_INSTALL_PATH) | ||
599 | 73 | # if (NOT XDG_INSTALL_PATH) | ||
600 | 74 | message (\"[WARNING]: Installing GSettings schemas to a custom location that might not be in XDG_DATA_DIRS, you need to add ${COMPIZ_DESTDIR}${_dst} to your XDG_DATA_DIRS in order for GSettings schemas to be found!\"\) | ||
601 | 75 | # endif (NOT XDG_INSTALL_PATH) | ||
602 | 76 | message (\"-- Installing GSettings schemas to ${COMPIZ_DESTDIR}${_dst}\"\) | ||
603 | 77 | file (INSTALL DESTINATION \"${COMPIZ_DESTDIR}${_dst}\" | ||
604 | 78 | TYPE FILE | ||
605 | 79 | FILES \"${_src}\") | ||
606 | 80 | message (\"-- Recompiling GSettings schemas in ${COMPIZ_DESTDIR}${_dst}\"\) | ||
607 | 81 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${COMPIZ_DESTDIR}${_dst}) | ||
608 | 82 | endif (\"$ENV{USER}\" STREQUAL \"root\"\) | ||
609 | 83 | ") | ||
610 | 84 | endif () | ||
611 | 85 | endfunction () | ||
612 | 86 | |||
613 | 87 | # generate gsettings schema | ||
614 | 88 | find_program (XSLTPROC_EXECUTABLE xsltproc) | ||
615 | 89 | mark_as_advanced (FORCE XSLTPROC_EXECUTABLE) | ||
616 | 90 | |||
617 | 91 | if (XSLTPROC_EXECUTABLE AND USE_GSETTINGS) | ||
618 | 92 | compiz_gsettings_prepare_install_dirs () | ||
619 | 93 | |||
620 | 94 | add_custom_command ( | ||
621 | 95 | OUTPUT "${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml" | ||
622 | 96 | COMMAND ${XSLTPROC_EXECUTABLE} | ||
623 | 97 | -o "${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml" | ||
624 | 98 | ${COMPIZ_GSETTINGS_SCHEMAS_XSLT} | ||
625 | 99 | ${COMPIZ_CURRENT_XML_FILE} | ||
626 | 100 | DEPENDS ${COMPIZ_CURRENT_XML_FILE} | ||
627 | 101 | ) | ||
628 | 102 | compiz_install_gsettings_schema ("${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml" ${PLUGIN_SCHEMADIR}) | ||
629 | 103 | list (APPEND COMPIZ_CURRENT_SOURCES_ADDS ${CMAKE_BINARY_DIR}/generated/org.freedesktop.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml) | ||
630 | 104 | endif () | ||
631 | 105 | 0 | ||
632 | === added file 'cmake/plugin_extensions/CompizOpenGLFixups.cmake' | |||
633 | --- cmake/plugin_extensions/CompizOpenGLFixups.cmake 1970-01-01 00:00:00 +0000 | |||
634 | +++ cmake/plugin_extensions/CompizOpenGLFixups.cmake 2012-02-08 18:50:27 +0000 | |||
635 | @@ -0,0 +1,22 @@ | |||
636 | 1 | |||
637 | 2 | # modify pkg-config libs for opengl based on if we found GLES or not | ||
638 | 3 | if (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl") | ||
639 | 4 | if (USE_GLES) | ||
640 | 5 | set (PKGCONFIG_LIBS "-lGLESv2 -lEGL") | ||
641 | 6 | else (USE_GLES) | ||
642 | 7 | set (PKGCONFIG_LIBS "-lGL") | ||
643 | 8 | endif (USE_GLES) | ||
644 | 9 | endif (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl") | ||
645 | 10 | |||
646 | 11 | # if plugin is using opengl plugin check for GLES library and set correct define | ||
647 | 12 | if (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "") | ||
648 | 13 | string (REGEX MATCH "opengl" opengl_found ${${_PLUGIN}_PLUGINDEPS}) | ||
649 | 14 | |||
650 | 15 | if (opengl_found STREQUAL "opengl") | ||
651 | 16 | if (USE_GLES) | ||
652 | 17 | set (${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD} " -DUSE_GLES") | ||
653 | 18 | string (REPLACE ";" " " ${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD}) | ||
654 | 19 | endif (USE_GLES) | ||
655 | 20 | endif (opengl_found STREQUAL "opengl") | ||
656 | 21 | endif (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "") | ||
657 | 22 | |||
658 | 0 | 23 | ||
659 | === modified file 'gtk/CMakeLists.txt' | |||
660 | --- gtk/CMakeLists.txt 2011-10-13 14:06:05 +0000 | |||
661 | +++ gtk/CMakeLists.txt 2012-02-08 18:50:27 +0000 | |||
662 | @@ -82,7 +82,7 @@ | |||
663 | 82 | 82 | ||
664 | 83 | configure_file ( | 83 | configure_file ( |
665 | 84 | ${CMAKE_CURRENT_SOURCE_DIR}/config.h.gtk.in | 84 | ${CMAKE_CURRENT_SOURCE_DIR}/config.h.gtk.in |
667 | 85 | ${CMAKE_CURRENT_BINARY_DIR}/config.h | 85 | ${CMAKE_CURRENT_BINARY_DIR}/config.h |
668 | 86 | ) | 86 | ) |
669 | 87 | 87 | ||
670 | 88 | add_subdirectory (window-decorator) | 88 | add_subdirectory (window-decorator) |
671 | 89 | 89 | ||
672 | === added file 'gtk/config.h.gtk.in' | |||
673 | --- gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000 | |||
674 | +++ gtk/config.h.gtk.in 2012-02-08 18:50:27 +0000 | |||
675 | @@ -0,0 +1,25 @@ | |||
676 | 1 | /* Define to 1 if Metacity support is enabled */ | ||
677 | 2 | #cmakedefine USE_METACITY 1 | ||
678 | 3 | |||
679 | 4 | /* Define to 1 if Gconf support is enabled */ | ||
680 | 5 | #cmakedefine USE_GCONF 1 | ||
681 | 6 | |||
682 | 7 | /* Define to 1 if you have the `wnck_window_has_name' function. */ | ||
683 | 8 | #cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1 | ||
684 | 9 | |||
685 | 10 | /* Define to 1 if libwnck version >= 2_18_1 */ | ||
686 | 11 | #cmakedefine HAVE_LIBWNCK_2_18_1 1 | ||
687 | 12 | |||
688 | 13 | /* Define to 1 if libwnck version >= 2_19_4 */ | ||
689 | 14 | #cmakedefine HAVE_LIBWNCK_2_19_4 1 | ||
690 | 15 | |||
691 | 16 | /* Define to 1 if metacity version >= 2.15.21 */ | ||
692 | 17 | #cmakedefine HAVE_METACITY_2_15_21 1 | ||
693 | 18 | |||
694 | 19 | /* Define to 1 if metacity version >= 2.17.0 */ | ||
695 | 20 | #cmakedefine HAVE_METACITY_2_17_0 1 | ||
696 | 21 | |||
697 | 22 | /* Define to 1 if metacity version >= 2.23.2 */ | ||
698 | 23 | #cmakedefine HAVE_METACITY_2_23_2 1 | ||
699 | 24 | |||
700 | 25 | #define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}" | ||
701 | 0 | 26 | ||
702 | === removed file 'gtk/config.h.gtk.in' | |||
703 | --- gtk/config.h.gtk.in 2008-10-14 10:27:55 +0000 | |||
704 | +++ gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000 | |||
705 | @@ -1,25 +0,0 @@ | |||
706 | 1 | /* Define to 1 if Metacity support is enabled */ | ||
707 | 2 | #cmakedefine USE_METACITY 1 | ||
708 | 3 | |||
709 | 4 | /* Define to 1 if Gconf support is enabled */ | ||
710 | 5 | #cmakedefine USE_GCONF 1 | ||
711 | 6 | |||
712 | 7 | /* Define to 1 if you have the `wnck_window_has_name' function. */ | ||
713 | 8 | #cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1 | ||
714 | 9 | |||
715 | 10 | /* Define to 1 if libwnck version >= 2_18_1 */ | ||
716 | 11 | #cmakedefine HAVE_LIBWNCK_2_18_1 1 | ||
717 | 12 | |||
718 | 13 | /* Define to 1 if libwnck version >= 2_19_4 */ | ||
719 | 14 | #cmakedefine HAVE_LIBWNCK_2_19_4 1 | ||
720 | 15 | |||
721 | 16 | /* Define to 1 if metacity version >= 2.15.21 */ | ||
722 | 17 | #cmakedefine HAVE_METACITY_2_15_21 1 | ||
723 | 18 | |||
724 | 19 | /* Define to 1 if metacity version >= 2.17.0 */ | ||
725 | 20 | #cmakedefine HAVE_METACITY_2_17_0 1 | ||
726 | 21 | |||
727 | 22 | /* Define to 1 if metacity version >= 2.23.2 */ | ||
728 | 23 | #cmakedefine HAVE_METACITY_2_23_2 1 | ||
729 | 24 | |||
730 | 25 | #define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}" | ||
731 | 26 | 0 | ||
732 | === modified file 'gtk/gnome/CMakeLists.txt' | |||
733 | --- gtk/gnome/CMakeLists.txt 2011-10-13 14:06:05 +0000 | |||
734 | +++ gtk/gnome/CMakeLists.txt 2012-02-08 18:50:27 +0000 | |||
735 | @@ -9,5 +9,79 @@ | |||
736 | 9 | DESTINATION ${COMPIZ_DESTDIR}${datadir}/applications | 9 | DESTINATION ${COMPIZ_DESTDIR}${datadir}/applications |
737 | 10 | ) | 10 | ) |
738 | 11 | 11 | ||
739 | 12 | <<<<<<< TREE | ||
740 | 12 | add_custom_target (compiz.desktop ALL SOURCES ${desktop_file}) | 13 | add_custom_target (compiz.desktop ALL SOURCES ${desktop_file}) |
741 | 13 | endif (BUILD_GNOME) | 14 | endif (BUILD_GNOME) |
742 | 15 | ======= | ||
743 | 16 | set (wmproperties_file ${CMAKE_CURRENT_BINARY_DIR}/compiz-wm.desktop) | ||
744 | 17 | compiz_translate_desktop_file ( | ||
745 | 18 | ${CMAKE_CURRENT_SOURCE_DIR}/compiz-wm.desktop.in | ||
746 | 19 | ${wmproperties_file} | ||
747 | 20 | ) | ||
748 | 21 | compiz_opt_install_file ( | ||
749 | 22 | ${wmproperties_file} | ||
750 | 23 | ${windowsettingsdatadir}/gnome/wm-properties/compiz-wm.desktop | ||
751 | 24 | ) | ||
752 | 25 | |||
753 | 26 | |||
754 | 27 | if (USE_GNOME_KEYBINDINGS) | ||
755 | 28 | compiz_translate_xml ( | ||
756 | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/50-compiz-desktop-key.xml.in | ||
757 | 30 | ${CMAKE_CURRENT_BINARY_DIR}/50-compiz-desktop-key.xml | ||
758 | 31 | ) | ||
759 | 32 | compiz_translate_xml ( | ||
760 | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/50-compiz-key.xml.in | ||
761 | 34 | ${CMAKE_CURRENT_BINARY_DIR}/50-compiz-key.xml | ||
762 | 35 | ) | ||
763 | 36 | set (key_xml | ||
764 | 37 | ${CMAKE_CURRENT_BINARY_DIR}/50-compiz-desktop-key.xml | ||
765 | 38 | ${CMAKE_CURRENT_BINARY_DIR}/50-compiz-key.xml | ||
766 | 39 | ) | ||
767 | 40 | compiz_opt_install_file ( | ||
768 | 41 | ${CMAKE_CURRENT_BINARY_DIR}/50-compiz-desktop-key.xml | ||
769 | 42 | ${keybindingsdir}/50-compiz-desktop-key.xml | ||
770 | 43 | ) | ||
771 | 44 | compiz_opt_install_file ( | ||
772 | 45 | ${CMAKE_CURRENT_BINARY_DIR}/50-compiz-key.xml | ||
773 | 46 | ${keybindingsdir}/50-compiz-key.xml | ||
774 | 47 | ) | ||
775 | 48 | endif (USE_GNOME_KEYBINDINGS) | ||
776 | 49 | |||
777 | 50 | add_library (gnome-compiz MODULE | ||
778 | 51 | compiz-window-manager.c | ||
779 | 52 | compiz-window-manager.h | ||
780 | 53 | ${key_xml} | ||
781 | 54 | ${desktop_file} | ||
782 | 55 | ${wmproperties_file} | ||
783 | 56 | ) | ||
784 | 57 | |||
785 | 58 | |||
786 | 59 | set_target_properties (gnome-compiz | ||
787 | 60 | PROPERTIES OUTPUT_NAME compiz | ||
788 | 61 | SKIP_BUILD_RPATH 1 | ||
789 | 62 | ) | ||
790 | 63 | |||
791 | 64 | target_link_libraries ( | ||
792 | 65 | gnome-compiz ${GNOME_WINDOW_SETTINGS_LIBRARIES} | ||
793 | 66 | ) | ||
794 | 67 | |||
795 | 68 | compiz_opt_install_file ( | ||
796 | 69 | ${CMAKE_CURRENT_BINARY_DIR}/libcompiz.so | ||
797 | 70 | ${windowsettingslibdir}/window-manager-settings/libcompiz.so | ||
798 | 71 | ) | ||
799 | 72 | else (USE_GNOME) | ||
800 | 73 | |||
801 | 74 | set (desktop_file ${CMAKE_CURRENT_BINARY_DIR}/compiz.desktop) | ||
802 | 75 | compiz_translate_desktop_file ( | ||
803 | 76 | ${CMAKE_CURRENT_SOURCE_DIR}/compiz.desktop.in | ||
804 | 77 | ${desktop_file} | ||
805 | 78 | ) | ||
806 | 79 | |||
807 | 80 | install ( | ||
808 | 81 | FILES ${desktop_file} | ||
809 | 82 | DESTINATION ${COMPIZ_DESTDIR}${datadir}/applications | ||
810 | 83 | ) | ||
811 | 84 | |||
812 | 85 | add_custom_target (gnome-compiz ALL | ||
813 | 86 | DEPENDS ${desktop_file}) | ||
814 | 87 | endif (USE_GNOME)>>>>>>> MERGE-SOURCE | ||
815 | 14 | 88 | ||
816 | === modified file 'gtk/gnome/compiz.desktop.in' | |||
817 | --- gtk/gnome/compiz.desktop.in 2009-03-08 12:21:32 +0000 | |||
818 | +++ gtk/gnome/compiz.desktop.in 2012-02-08 18:50:27 +0000 | |||
819 | @@ -5,7 +5,7 @@ | |||
820 | 5 | Exec=compiz | 5 | Exec=compiz |
821 | 6 | NoDisplay=true | 6 | NoDisplay=true |
822 | 7 | # name of loadable control center module | 7 | # name of loadable control center module |
824 | 8 | X-GNOME-WMSettingsModule=compiz | 8 | X-GNOME-WMSettingsModule=metacity |
825 | 9 | # autostart phase | 9 | # autostart phase |
826 | 10 | X-GNOME-Autostart-Phase=WindowManager | 10 | X-GNOME-Autostart-Phase=WindowManager |
827 | 11 | X-GNOME-Provides=windowmanager | 11 | X-GNOME-Provides=windowmanager |
828 | 12 | 12 | ||
829 | === added file 'gtk/window-decorator/actionmenu.c' | |||
830 | --- gtk/window-decorator/actionmenu.c 1970-01-01 00:00:00 +0000 | |||
831 | +++ gtk/window-decorator/actionmenu.c 2012-02-08 18:50:27 +0000 | |||
832 | @@ -0,0 +1,134 @@ | |||
833 | 1 | /* | ||
834 | 2 | * Copyright © 2006 Novell, Inc. | ||
835 | 3 | * | ||
836 | 4 | * This library is free software; you can redistribute it and/or | ||
837 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
838 | 6 | * License as published by the Free Software Foundation; either | ||
839 | 7 | * version 2 of the License, or (at your option) any later version. | ||
840 | 8 | * | ||
841 | 9 | * This library is distributed in the hope that it will be useful, | ||
842 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
843 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
844 | 12 | * Lesser General Public License for more details. | ||
845 | 13 | * | ||
846 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
847 | 15 | * License along with this library; if not, write to the | ||
848 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
849 | 17 | * Boston, MA 02111-1307, USA. | ||
850 | 18 | * | ||
851 | 19 | * Author: David Reveman <davidr@novell.com> | ||
852 | 20 | */ | ||
853 | 21 | |||
854 | 22 | #include "gtk-window-decorator.h" | ||
855 | 23 | |||
856 | 24 | static void | ||
857 | 25 | action_menu_unmap (GObject *object) | ||
858 | 26 | { | ||
859 | 27 | action_menu_mapped = FALSE; | ||
860 | 28 | } | ||
861 | 29 | |||
862 | 30 | static void | ||
863 | 31 | position_action_menu (GtkMenu *menu, | ||
864 | 32 | gint *x, | ||
865 | 33 | gint *y, | ||
866 | 34 | gboolean *push_in, | ||
867 | 35 | gpointer user_data) | ||
868 | 36 | { | ||
869 | 37 | WnckWindow *win = (WnckWindow *) user_data; | ||
870 | 38 | WnckWindowType win_type = wnck_window_get_window_type (win); | ||
871 | 39 | decor_frame_t *frame = gwd_get_decor_frame (win); | ||
872 | 40 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
873 | 41 | gint bx, by, width, height; | ||
874 | 42 | |||
875 | 43 | wnck_window_get_client_window_geometry (win, x, y, &width, &height); | ||
876 | 44 | |||
877 | 45 | if ((*theme_get_button_position) (d, BUTTON_MENU, width, height, | ||
878 | 46 | &bx, &by, &width, &height)) | ||
879 | 47 | *x = *x - frame->win_extents.left + bx; | ||
880 | 48 | |||
881 | 49 | gwd_decor_frame_unref (frame); | ||
882 | 50 | |||
883 | 51 | if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) | ||
884 | 52 | { | ||
885 | 53 | GtkRequisition req; | ||
886 | 54 | |||
887 | 55 | gtk_widget_size_request (GTK_WIDGET (menu), &req); | ||
888 | 56 | *x = MAX (0, *x - req.width + width); | ||
889 | 57 | } | ||
890 | 58 | |||
891 | 59 | *push_in = TRUE; | ||
892 | 60 | } | ||
893 | 61 | |||
894 | 62 | void | ||
895 | 63 | action_menu_map (WnckWindow *win, | ||
896 | 64 | long button, | ||
897 | 65 | Time time) | ||
898 | 66 | { | ||
899 | 67 | GdkDisplay *gdkdisplay; | ||
900 | 68 | GdkScreen *screen; | ||
901 | 69 | |||
902 | 70 | gdkdisplay = gdk_display_get_default (); | ||
903 | 71 | screen = gdk_display_get_default_screen (gdkdisplay); | ||
904 | 72 | |||
905 | 73 | if (action_menu) | ||
906 | 74 | { | ||
907 | 75 | if (action_menu_mapped) | ||
908 | 76 | { | ||
909 | 77 | gtk_widget_destroy (action_menu); | ||
910 | 78 | action_menu_mapped = FALSE; | ||
911 | 79 | action_menu = NULL; | ||
912 | 80 | return; | ||
913 | 81 | } | ||
914 | 82 | else | ||
915 | 83 | gtk_widget_destroy (action_menu); | ||
916 | 84 | } | ||
917 | 85 | |||
918 | 86 | switch (wnck_window_get_window_type (win)) { | ||
919 | 87 | case WNCK_WINDOW_DESKTOP: | ||
920 | 88 | case WNCK_WINDOW_DOCK: | ||
921 | 89 | /* don't allow window action */ | ||
922 | 90 | return; | ||
923 | 91 | case WNCK_WINDOW_NORMAL: | ||
924 | 92 | case WNCK_WINDOW_DIALOG: | ||
925 | 93 | |||
926 | 94 | #ifndef HAVE_LIBWNCK_2_19_4 | ||
927 | 95 | case WNCK_WINDOW_MODAL_DIALOG: | ||
928 | 96 | #endif | ||
929 | 97 | |||
930 | 98 | case WNCK_WINDOW_TOOLBAR: | ||
931 | 99 | case WNCK_WINDOW_MENU: | ||
932 | 100 | case WNCK_WINDOW_UTILITY: | ||
933 | 101 | case WNCK_WINDOW_SPLASHSCREEN: | ||
934 | 102 | /* allow window action menu */ | ||
935 | 103 | break; | ||
936 | 104 | } | ||
937 | 105 | |||
938 | 106 | action_menu = wnck_create_window_action_menu (win); | ||
939 | 107 | |||
940 | 108 | gtk_menu_set_screen (GTK_MENU (action_menu), screen); | ||
941 | 109 | |||
942 | 110 | g_signal_connect_object (G_OBJECT (action_menu), "unmap", | ||
943 | 111 | G_CALLBACK (action_menu_unmap), | ||
944 | 112 | 0, 0); | ||
945 | 113 | |||
946 | 114 | gtk_widget_show (action_menu); | ||
947 | 115 | |||
948 | 116 | if (!button || button == 1) | ||
949 | 117 | { | ||
950 | 118 | gtk_menu_popup (GTK_MENU (action_menu), | ||
951 | 119 | NULL, NULL, | ||
952 | 120 | position_action_menu, (gpointer) win, | ||
953 | 121 | button, | ||
954 | 122 | time); | ||
955 | 123 | } | ||
956 | 124 | else | ||
957 | 125 | { | ||
958 | 126 | gtk_menu_popup (GTK_MENU (action_menu), | ||
959 | 127 | NULL, NULL, | ||
960 | 128 | NULL, NULL, | ||
961 | 129 | button, | ||
962 | 130 | time); | ||
963 | 131 | } | ||
964 | 132 | |||
965 | 133 | action_menu_mapped = TRUE; | ||
966 | 134 | } | ||
967 | 0 | 135 | ||
968 | === removed file 'gtk/window-decorator/actionmenu.c' | |||
969 | --- gtk/window-decorator/actionmenu.c 2011-05-07 08:58:10 +0000 | |||
970 | +++ gtk/window-decorator/actionmenu.c 1970-01-01 00:00:00 +0000 | |||
971 | @@ -1,133 +0,0 @@ | |||
972 | 1 | /* | ||
973 | 2 | * Copyright © 2006 Novell, Inc. | ||
974 | 3 | * | ||
975 | 4 | * This library is free software; you can redistribute it and/or | ||
976 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
977 | 6 | * License as published by the Free Software Foundation; either | ||
978 | 7 | * version 2 of the License, or (at your option) any later version. | ||
979 | 8 | * | ||
980 | 9 | * This library is distributed in the hope that it will be useful, | ||
981 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
982 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
983 | 12 | * Lesser General Public License for more details. | ||
984 | 13 | * | ||
985 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
986 | 15 | * License along with this library; if not, write to the | ||
987 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
988 | 17 | * Boston, MA 02111-1307, USA. | ||
989 | 18 | * | ||
990 | 19 | * Author: David Reveman <davidr@novell.com> | ||
991 | 20 | */ | ||
992 | 21 | |||
993 | 22 | #include "gtk-window-decorator.h" | ||
994 | 23 | |||
995 | 24 | static void | ||
996 | 25 | action_menu_unmap (GObject *object) | ||
997 | 26 | { | ||
998 | 27 | action_menu_mapped = FALSE; | ||
999 | 28 | } | ||
1000 | 29 | |||
1001 | 30 | static void | ||
1002 | 31 | position_action_menu (GtkMenu *menu, | ||
1003 | 32 | gint *x, | ||
1004 | 33 | gint *y, | ||
1005 | 34 | gboolean *push_in, | ||
1006 | 35 | gpointer user_data) | ||
1007 | 36 | { | ||
1008 | 37 | WnckWindow *win = (WnckWindow *) user_data; | ||
1009 | 38 | decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win)); | ||
1010 | 39 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
1011 | 40 | gint bx, by, width, height; | ||
1012 | 41 | |||
1013 | 42 | wnck_window_get_client_window_geometry (win, x, y, &width, &height); | ||
1014 | 43 | |||
1015 | 44 | if ((*theme_get_button_position) (d, BUTTON_MENU, width, height, | ||
1016 | 45 | &bx, &by, &width, &height)) | ||
1017 | 46 | *x = *x - frame->win_extents.left + bx; | ||
1018 | 47 | |||
1019 | 48 | gwd_decor_frame_unref (frame); | ||
1020 | 49 | |||
1021 | 50 | if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) | ||
1022 | 51 | { | ||
1023 | 52 | GtkRequisition req; | ||
1024 | 53 | |||
1025 | 54 | gtk_widget_size_request (GTK_WIDGET (menu), &req); | ||
1026 | 55 | *x = MAX (0, *x - req.width + width); | ||
1027 | 56 | } | ||
1028 | 57 | |||
1029 | 58 | *push_in = TRUE; | ||
1030 | 59 | } | ||
1031 | 60 | |||
1032 | 61 | void | ||
1033 | 62 | action_menu_map (WnckWindow *win, | ||
1034 | 63 | long button, | ||
1035 | 64 | Time time) | ||
1036 | 65 | { | ||
1037 | 66 | GdkDisplay *gdkdisplay; | ||
1038 | 67 | GdkScreen *screen; | ||
1039 | 68 | |||
1040 | 69 | gdkdisplay = gdk_display_get_default (); | ||
1041 | 70 | screen = gdk_display_get_default_screen (gdkdisplay); | ||
1042 | 71 | |||
1043 | 72 | if (action_menu) | ||
1044 | 73 | { | ||
1045 | 74 | if (action_menu_mapped) | ||
1046 | 75 | { | ||
1047 | 76 | gtk_widget_destroy (action_menu); | ||
1048 | 77 | action_menu_mapped = FALSE; | ||
1049 | 78 | action_menu = NULL; | ||
1050 | 79 | return; | ||
1051 | 80 | } | ||
1052 | 81 | else | ||
1053 | 82 | gtk_widget_destroy (action_menu); | ||
1054 | 83 | } | ||
1055 | 84 | |||
1056 | 85 | switch (wnck_window_get_window_type (win)) { | ||
1057 | 86 | case WNCK_WINDOW_DESKTOP: | ||
1058 | 87 | case WNCK_WINDOW_DOCK: | ||
1059 | 88 | /* don't allow window action */ | ||
1060 | 89 | return; | ||
1061 | 90 | case WNCK_WINDOW_NORMAL: | ||
1062 | 91 | case WNCK_WINDOW_DIALOG: | ||
1063 | 92 | |||
1064 | 93 | #ifndef HAVE_LIBWNCK_2_19_4 | ||
1065 | 94 | case WNCK_WINDOW_MODAL_DIALOG: | ||
1066 | 95 | #endif | ||
1067 | 96 | |||
1068 | 97 | case WNCK_WINDOW_TOOLBAR: | ||
1069 | 98 | case WNCK_WINDOW_MENU: | ||
1070 | 99 | case WNCK_WINDOW_UTILITY: | ||
1071 | 100 | case WNCK_WINDOW_SPLASHSCREEN: | ||
1072 | 101 | /* allow window action menu */ | ||
1073 | 102 | break; | ||
1074 | 103 | } | ||
1075 | 104 | |||
1076 | 105 | action_menu = wnck_create_window_action_menu (win); | ||
1077 | 106 | |||
1078 | 107 | gtk_menu_set_screen (GTK_MENU (action_menu), screen); | ||
1079 | 108 | |||
1080 | 109 | g_signal_connect_object (G_OBJECT (action_menu), "unmap", | ||
1081 | 110 | G_CALLBACK (action_menu_unmap), | ||
1082 | 111 | 0, 0); | ||
1083 | 112 | |||
1084 | 113 | gtk_widget_show (action_menu); | ||
1085 | 114 | |||
1086 | 115 | if (!button || button == 1) | ||
1087 | 116 | { | ||
1088 | 117 | gtk_menu_popup (GTK_MENU (action_menu), | ||
1089 | 118 | NULL, NULL, | ||
1090 | 119 | position_action_menu, (gpointer) win, | ||
1091 | 120 | button, | ||
1092 | 121 | time); | ||
1093 | 122 | } | ||
1094 | 123 | else | ||
1095 | 124 | { | ||
1096 | 125 | gtk_menu_popup (GTK_MENU (action_menu), | ||
1097 | 126 | NULL, NULL, | ||
1098 | 127 | NULL, NULL, | ||
1099 | 128 | button, | ||
1100 | 129 | time); | ||
1101 | 130 | } | ||
1102 | 131 | |||
1103 | 132 | action_menu_mapped = TRUE; | ||
1104 | 133 | } | ||
1105 | 134 | 0 | ||
1106 | === added file 'gtk/window-decorator/blurprops.c' | |||
1107 | --- gtk/window-decorator/blurprops.c 1970-01-01 00:00:00 +0000 | |||
1108 | +++ gtk/window-decorator/blurprops.c 2012-02-08 18:50:27 +0000 | |||
1109 | @@ -0,0 +1,89 @@ | |||
1110 | 1 | /* | ||
1111 | 2 | * Copyright © 2006 Novell, Inc. | ||
1112 | 3 | * | ||
1113 | 4 | * This library is free software; you can redistribute it and/or | ||
1114 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
1115 | 6 | * License as published by the Free Software Foundation; either | ||
1116 | 7 | * version 2 of the License, or (at your option) any later version. | ||
1117 | 8 | * | ||
1118 | 9 | * This library is distributed in the hope that it will be useful, | ||
1119 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1120 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1121 | 12 | * Lesser General Public License for more details. | ||
1122 | 13 | * | ||
1123 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
1124 | 15 | * License along with this library; if not, write to the | ||
1125 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1126 | 17 | * Boston, MA 02111-1307, USA. | ||
1127 | 18 | * | ||
1128 | 19 | * Author: David Reveman <davidr@novell.com> | ||
1129 | 20 | */ | ||
1130 | 21 | |||
1131 | 22 | #include "gtk-window-decorator.h" | ||
1132 | 23 | |||
1133 | 24 | void | ||
1134 | 25 | decor_update_blur_property (decor_t *d, | ||
1135 | 26 | int width, | ||
1136 | 27 | int height, | ||
1137 | 28 | Region top_region, | ||
1138 | 29 | int top_offset, | ||
1139 | 30 | Region bottom_region, | ||
1140 | 31 | int bottom_offset, | ||
1141 | 32 | Region left_region, | ||
1142 | 33 | int left_offset, | ||
1143 | 34 | Region right_region, | ||
1144 | 35 | int right_offset) | ||
1145 | 36 | { | ||
1146 | 37 | Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
1147 | 38 | long *data = NULL; | ||
1148 | 39 | int size = 0; | ||
1149 | 40 | |||
1150 | 41 | if (settings->blur_type != BLUR_TYPE_ALL) | ||
1151 | 42 | { | ||
1152 | 43 | bottom_region = NULL; | ||
1153 | 44 | left_region = NULL; | ||
1154 | 45 | right_region = NULL; | ||
1155 | 46 | |||
1156 | 47 | if (settings->blur_type != BLUR_TYPE_TITLEBAR) | ||
1157 | 48 | top_region = NULL; | ||
1158 | 49 | } | ||
1159 | 50 | |||
1160 | 51 | if (top_region) | ||
1161 | 52 | size += top_region->numRects; | ||
1162 | 53 | if (bottom_region) | ||
1163 | 54 | size += bottom_region->numRects; | ||
1164 | 55 | if (left_region) | ||
1165 | 56 | size += left_region->numRects; | ||
1166 | 57 | if (right_region) | ||
1167 | 58 | size += right_region->numRects; | ||
1168 | 59 | |||
1169 | 60 | if (size) | ||
1170 | 61 | data = (long *) malloc (sizeof (long) * (2 + size * 6)); | ||
1171 | 62 | |||
1172 | 63 | if (data) | ||
1173 | 64 | { | ||
1174 | 65 | decor_region_to_blur_property (data, 4, 0, width, height, | ||
1175 | 66 | top_region, top_offset, | ||
1176 | 67 | bottom_region, bottom_offset, | ||
1177 | 68 | left_region, left_offset, | ||
1178 | 69 | right_region, right_offset); | ||
1179 | 70 | |||
1180 | 71 | gdk_error_trap_push (); | ||
1181 | 72 | XChangeProperty (xdisplay, d->prop_xid, | ||
1182 | 73 | win_blur_decor_atom, | ||
1183 | 74 | XA_INTEGER, | ||
1184 | 75 | 32, PropModeReplace, (guchar *) data, | ||
1185 | 76 | 2 + size * 6); | ||
1186 | 77 | gdk_display_sync (gdk_display_get_default ()); | ||
1187 | 78 | gdk_error_trap_pop (); | ||
1188 | 79 | |||
1189 | 80 | free (data); | ||
1190 | 81 | } | ||
1191 | 82 | else | ||
1192 | 83 | { | ||
1193 | 84 | gdk_error_trap_push (); | ||
1194 | 85 | XDeleteProperty (xdisplay, d->prop_xid, win_blur_decor_atom); | ||
1195 | 86 | gdk_display_sync (gdk_display_get_default ()); | ||
1196 | 87 | gdk_error_trap_pop (); | ||
1197 | 88 | } | ||
1198 | 89 | } | ||
1199 | 0 | 90 | ||
1200 | === removed file 'gtk/window-decorator/blurprops.c' | |||
1201 | --- gtk/window-decorator/blurprops.c 2011-02-21 09:53:08 +0000 | |||
1202 | +++ gtk/window-decorator/blurprops.c 1970-01-01 00:00:00 +0000 | |||
1203 | @@ -1,89 +0,0 @@ | |||
1204 | 1 | /* | ||
1205 | 2 | * Copyright © 2006 Novell, Inc. | ||
1206 | 3 | * | ||
1207 | 4 | * This library is free software; you can redistribute it and/or | ||
1208 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
1209 | 6 | * License as published by the Free Software Foundation; either | ||
1210 | 7 | * version 2 of the License, or (at your option) any later version. | ||
1211 | 8 | * | ||
1212 | 9 | * This library is distributed in the hope that it will be useful, | ||
1213 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1214 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1215 | 12 | * Lesser General Public License for more details. | ||
1216 | 13 | * | ||
1217 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
1218 | 15 | * License along with this library; if not, write to the | ||
1219 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1220 | 17 | * Boston, MA 02111-1307, USA. | ||
1221 | 18 | * | ||
1222 | 19 | * Author: David Reveman <davidr@novell.com> | ||
1223 | 20 | */ | ||
1224 | 21 | |||
1225 | 22 | #include "gtk-window-decorator.h" | ||
1226 | 23 | |||
1227 | 24 | void | ||
1228 | 25 | decor_update_blur_property (decor_t *d, | ||
1229 | 26 | int width, | ||
1230 | 27 | int height, | ||
1231 | 28 | Region top_region, | ||
1232 | 29 | int top_offset, | ||
1233 | 30 | Region bottom_region, | ||
1234 | 31 | int bottom_offset, | ||
1235 | 32 | Region left_region, | ||
1236 | 33 | int left_offset, | ||
1237 | 34 | Region right_region, | ||
1238 | 35 | int right_offset) | ||
1239 | 36 | { | ||
1240 | 37 | Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
1241 | 38 | long *data = NULL; | ||
1242 | 39 | int size = 0; | ||
1243 | 40 | |||
1244 | 41 | if (settings->blur_type != BLUR_TYPE_ALL) | ||
1245 | 42 | { | ||
1246 | 43 | bottom_region = NULL; | ||
1247 | 44 | left_region = NULL; | ||
1248 | 45 | right_region = NULL; | ||
1249 | 46 | |||
1250 | 47 | if (settings->blur_type != BLUR_TYPE_TITLEBAR) | ||
1251 | 48 | top_region = NULL; | ||
1252 | 49 | } | ||
1253 | 50 | |||
1254 | 51 | if (top_region) | ||
1255 | 52 | size += top_region->numRects; | ||
1256 | 53 | if (bottom_region) | ||
1257 | 54 | size += bottom_region->numRects; | ||
1258 | 55 | if (left_region) | ||
1259 | 56 | size += left_region->numRects; | ||
1260 | 57 | if (right_region) | ||
1261 | 58 | size += right_region->numRects; | ||
1262 | 59 | |||
1263 | 60 | if (size) | ||
1264 | 61 | data = (long *) malloc (sizeof (long) * (2 + size * 6)); | ||
1265 | 62 | |||
1266 | 63 | if (data) | ||
1267 | 64 | { | ||
1268 | 65 | decor_region_to_blur_property (data, 4, 0, width, height, | ||
1269 | 66 | top_region, top_offset, | ||
1270 | 67 | bottom_region, bottom_offset, | ||
1271 | 68 | left_region, left_offset, | ||
1272 | 69 | right_region, right_offset); | ||
1273 | 70 | |||
1274 | 71 | gdk_error_trap_push (); | ||
1275 | 72 | XChangeProperty (xdisplay, d->prop_xid, | ||
1276 | 73 | win_blur_decor_atom, | ||
1277 | 74 | XA_INTEGER, | ||
1278 | 75 | 32, PropModeReplace, (guchar *) data, | ||
1279 | 76 | 2 + size * 6); | ||
1280 | 77 | gdk_display_sync (gdk_display_get_default ()); | ||
1281 | 78 | gdk_error_trap_pop (); | ||
1282 | 79 | |||
1283 | 80 | free (data); | ||
1284 | 81 | } | ||
1285 | 82 | else | ||
1286 | 83 | { | ||
1287 | 84 | gdk_error_trap_push (); | ||
1288 | 85 | XDeleteProperty (xdisplay, d->prop_xid, win_blur_decor_atom); | ||
1289 | 86 | gdk_display_sync (gdk_display_get_default ()); | ||
1290 | 87 | gdk_error_trap_pop (); | ||
1291 | 88 | } | ||
1292 | 89 | } | ||
1293 | 90 | 0 | ||
1294 | === added file 'gtk/window-decorator/cairo.c' | |||
1295 | --- gtk/window-decorator/cairo.c 1970-01-01 00:00:00 +0000 | |||
1296 | +++ gtk/window-decorator/cairo.c 2012-02-08 18:50:27 +0000 | |||
1297 | @@ -0,0 +1,915 @@ | |||
1298 | 1 | /* | ||
1299 | 2 | * Copyright © 2006 Novell, Inc. | ||
1300 | 3 | * | ||
1301 | 4 | * This library is free software; you can redistribute it and/or | ||
1302 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
1303 | 6 | * License as published by the Free Software Foundation; either | ||
1304 | 7 | * version 2 of the License, or (at your option) any later version. | ||
1305 | 8 | * | ||
1306 | 9 | * This library is distributed in the hope that it will be useful, | ||
1307 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1308 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1309 | 12 | * Lesser General Public License for more details. | ||
1310 | 13 | * | ||
1311 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
1312 | 15 | * License along with this library; if not, write to the | ||
1313 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1314 | 17 | * Boston, MA 02111-1307, USA. | ||
1315 | 18 | * | ||
1316 | 19 | * Author: David Reveman <davidr@novell.com> | ||
1317 | 20 | * | ||
1318 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
1319 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
1320 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1321 | 24 | */ | ||
1322 | 25 | |||
1323 | 26 | #include "gtk-window-decorator.h" | ||
1324 | 27 | |||
1325 | 28 | void | ||
1326 | 29 | rounded_rectangle (cairo_t *cr, | ||
1327 | 30 | double x, | ||
1328 | 31 | double y, | ||
1329 | 32 | double w, | ||
1330 | 33 | double h, | ||
1331 | 34 | double radius, | ||
1332 | 35 | int corner) | ||
1333 | 36 | { | ||
1334 | 37 | if (corner & CORNER_TOPLEFT) | ||
1335 | 38 | cairo_move_to (cr, x + radius, y); | ||
1336 | 39 | else | ||
1337 | 40 | cairo_move_to (cr, x, y); | ||
1338 | 41 | |||
1339 | 42 | if (corner & CORNER_TOPRIGHT) | ||
1340 | 43 | cairo_arc (cr, x + w - radius, y + radius, radius, | ||
1341 | 44 | M_PI * 1.5, M_PI * 2.0); | ||
1342 | 45 | else | ||
1343 | 46 | cairo_line_to (cr, x + w, y); | ||
1344 | 47 | |||
1345 | 48 | if (corner & CORNER_BOTTOMRIGHT) | ||
1346 | 49 | cairo_arc (cr, x + w - radius, y + h - radius, radius, | ||
1347 | 50 | 0.0, M_PI * 0.5); | ||
1348 | 51 | else | ||
1349 | 52 | cairo_line_to (cr, x + w, y + h); | ||
1350 | 53 | |||
1351 | 54 | if (corner & CORNER_BOTTOMLEFT) | ||
1352 | 55 | cairo_arc (cr, x + radius, y + h - radius, radius, | ||
1353 | 56 | M_PI * 0.5, M_PI); | ||
1354 | 57 | else | ||
1355 | 58 | cairo_line_to (cr, x, y + h); | ||
1356 | 59 | |||
1357 | 60 | if (corner & CORNER_TOPLEFT) | ||
1358 | 61 | cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5); | ||
1359 | 62 | else | ||
1360 | 63 | cairo_line_to (cr, x, y); | ||
1361 | 64 | } | ||
1362 | 65 | |||
1363 | 66 | void | ||
1364 | 67 | fill_rounded_rectangle (cairo_t *cr, | ||
1365 | 68 | double x, | ||
1366 | 69 | double y, | ||
1367 | 70 | double w, | ||
1368 | 71 | double h, | ||
1369 | 72 | double radius, | ||
1370 | 73 | int corner, | ||
1371 | 74 | decor_color_t *c0, | ||
1372 | 75 | double alpha0, | ||
1373 | 76 | decor_color_t *c1, | ||
1374 | 77 | double alpha1, | ||
1375 | 78 | int gravity) | ||
1376 | 79 | { | ||
1377 | 80 | cairo_pattern_t *pattern; | ||
1378 | 81 | |||
1379 | 82 | rounded_rectangle (cr, x, y, w, h, radius, corner); | ||
1380 | 83 | |||
1381 | 84 | if (gravity & SHADE_RIGHT) | ||
1382 | 85 | { | ||
1383 | 86 | x = x + w; | ||
1384 | 87 | w = -w; | ||
1385 | 88 | } | ||
1386 | 89 | else if (!(gravity & SHADE_LEFT)) | ||
1387 | 90 | { | ||
1388 | 91 | x = w = 0; | ||
1389 | 92 | } | ||
1390 | 93 | |||
1391 | 94 | if (gravity & SHADE_BOTTOM) | ||
1392 | 95 | { | ||
1393 | 96 | y = y + h; | ||
1394 | 97 | h = -h; | ||
1395 | 98 | } | ||
1396 | 99 | else if (!(gravity & SHADE_TOP)) | ||
1397 | 100 | { | ||
1398 | 101 | y = h = 0; | ||
1399 | 102 | } | ||
1400 | 103 | |||
1401 | 104 | if (w && h) | ||
1402 | 105 | { | ||
1403 | 106 | cairo_matrix_t matrix; | ||
1404 | 107 | |||
1405 | 108 | pattern = cairo_pattern_create_radial (0.0, 0.0, 0.0, 0.0, 0.0, w); | ||
1406 | 109 | |||
1407 | 110 | cairo_matrix_init_scale (&matrix, 1.0, w / h); | ||
1408 | 111 | cairo_matrix_translate (&matrix, -(x + w), -(y + h)); | ||
1409 | 112 | |||
1410 | 113 | cairo_pattern_set_matrix (pattern, &matrix); | ||
1411 | 114 | } | ||
1412 | 115 | else | ||
1413 | 116 | { | ||
1414 | 117 | pattern = cairo_pattern_create_linear (x + w, y + h, x, y); | ||
1415 | 118 | } | ||
1416 | 119 | |||
1417 | 120 | cairo_pattern_add_color_stop_rgba (pattern, 0.0, c0->r, c0->g, c0->b, | ||
1418 | 121 | alpha0); | ||
1419 | 122 | |||
1420 | 123 | cairo_pattern_add_color_stop_rgba (pattern, 1.0, c1->r, c1->g, c1->b, | ||
1421 | 124 | alpha1); | ||
1422 | 125 | |||
1423 | 126 | cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); | ||
1424 | 127 | |||
1425 | 128 | cairo_set_source (cr, pattern); | ||
1426 | 129 | cairo_fill (cr); | ||
1427 | 130 | cairo_pattern_destroy (pattern); | ||
1428 | 131 | } | ||
1429 | 132 | |||
1430 | 133 | void | ||
1431 | 134 | draw_shadow_background (decor_t *d, | ||
1432 | 135 | cairo_t *cr, | ||
1433 | 136 | decor_shadow_t *s, | ||
1434 | 137 | decor_context_t *c) | ||
1435 | 138 | { | ||
1436 | 139 | Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
1437 | 140 | |||
1438 | 141 | if (!s || !s->picture ||!d->picture) | ||
1439 | 142 | { | ||
1440 | 143 | cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0); | ||
1441 | 144 | cairo_paint (cr); | ||
1442 | 145 | } | ||
1443 | 146 | else | ||
1444 | 147 | { | ||
1445 | 148 | decor_fill_picture_extents_with_shadow (xdisplay, | ||
1446 | 149 | s, c, | ||
1447 | 150 | d->picture, | ||
1448 | 151 | &d->border_layout); | ||
1449 | 152 | } | ||
1450 | 153 | } | ||
1451 | 154 | |||
1452 | 155 | static void | ||
1453 | 156 | draw_close_button (decor_t *d, | ||
1454 | 157 | cairo_t *cr, | ||
1455 | 158 | double s) | ||
1456 | 159 | { | ||
1457 | 160 | cairo_rel_move_to (cr, 0.0, s); | ||
1458 | 161 | |||
1459 | 162 | cairo_rel_line_to (cr, s, -s); | ||
1460 | 163 | cairo_rel_line_to (cr, s, s); | ||
1461 | 164 | cairo_rel_line_to (cr, s, -s); | ||
1462 | 165 | cairo_rel_line_to (cr, s, s); | ||
1463 | 166 | |||
1464 | 167 | cairo_rel_line_to (cr, -s, s); | ||
1465 | 168 | cairo_rel_line_to (cr, s, s); | ||
1466 | 169 | cairo_rel_line_to (cr, -s, s); | ||
1467 | 170 | cairo_rel_line_to (cr, -s, -s); | ||
1468 | 171 | |||
1469 | 172 | cairo_rel_line_to (cr, -s, s); | ||
1470 | 173 | cairo_rel_line_to (cr, -s, -s); | ||
1471 | 174 | cairo_rel_line_to (cr, s, -s); | ||
1472 | 175 | |||
1473 | 176 | cairo_close_path (cr); | ||
1474 | 177 | } | ||
1475 | 178 | |||
1476 | 179 | static void | ||
1477 | 180 | draw_max_button (decor_t *d, | ||
1478 | 181 | cairo_t *cr, | ||
1479 | 182 | double s) | ||
1480 | 183 | { | ||
1481 | 184 | cairo_rel_line_to (cr, 12.0, 0.0); | ||
1482 | 185 | cairo_rel_line_to (cr, 0.0, 12.0); | ||
1483 | 186 | cairo_rel_line_to (cr, -12.0, 0.0); | ||
1484 | 187 | |||
1485 | 188 | cairo_close_path (cr); | ||
1486 | 189 | |||
1487 | 190 | cairo_rel_move_to (cr, 2.0, s); | ||
1488 | 191 | |||
1489 | 192 | cairo_rel_line_to (cr, 12.0 - 4.0, 0.0); | ||
1490 | 193 | cairo_rel_line_to (cr, 0.0, 12.0 - s - 2.0); | ||
1491 | 194 | cairo_rel_line_to (cr, -(12.0 - 4.0), 0.0); | ||
1492 | 195 | |||
1493 | 196 | cairo_close_path (cr); | ||
1494 | 197 | } | ||
1495 | 198 | |||
1496 | 199 | static void | ||
1497 | 200 | draw_unmax_button (decor_t *d, | ||
1498 | 201 | cairo_t *cr, | ||
1499 | 202 | double s) | ||
1500 | 203 | { | ||
1501 | 204 | cairo_rel_move_to (cr, 1.0, 1.0); | ||
1502 | 205 | |||
1503 | 206 | cairo_rel_line_to (cr, 10.0, 0.0); | ||
1504 | 207 | cairo_rel_line_to (cr, 0.0, 10.0); | ||
1505 | 208 | cairo_rel_line_to (cr, -10.0, 0.0); | ||
1506 | 209 | |||
1507 | 210 | cairo_close_path (cr); | ||
1508 | 211 | |||
1509 | 212 | cairo_rel_move_to (cr, 2.0, s); | ||
1510 | 213 | |||
1511 | 214 | cairo_rel_line_to (cr, 10.0 - 4.0, 0.0); | ||
1512 | 215 | cairo_rel_line_to (cr, 0.0, 10.0 - s - 2.0); | ||
1513 | 216 | cairo_rel_line_to (cr, -(10.0 - 4.0), 0.0); | ||
1514 | 217 | |||
1515 | 218 | cairo_close_path (cr); | ||
1516 | 219 | } | ||
1517 | 220 | |||
1518 | 221 | static void | ||
1519 | 222 | draw_min_button (decor_t *d, | ||
1520 | 223 | cairo_t *cr, | ||
1521 | 224 | double s) | ||
1522 | 225 | { | ||
1523 | 226 | cairo_rel_move_to (cr, 0.0, 8.0); | ||
1524 | 227 | |||
1525 | 228 | cairo_rel_line_to (cr, 12.0, 0.0); | ||
1526 | 229 | cairo_rel_line_to (cr, 0.0, s); | ||
1527 | 230 | cairo_rel_line_to (cr, -12.0, 0.0); | ||
1528 | 231 | |||
1529 | 232 | cairo_close_path (cr); | ||
1530 | 233 | } | ||
1531 | 234 | |||
1532 | 235 | typedef void (*draw_proc) (cairo_t *cr); | ||
1533 | 236 | |||
1534 | 237 | static void | ||
1535 | 238 | button_state_offsets (gdouble x, | ||
1536 | 239 | gdouble y, | ||
1537 | 240 | guint state, | ||
1538 | 241 | gdouble *return_x, | ||
1539 | 242 | gdouble *return_y) | ||
1540 | 243 | { | ||
1541 | 244 | static double off[] = { 0.0, 0.0, 0.0, 0.5 }; | ||
1542 | 245 | |||
1543 | 246 | *return_x = x + off[state]; | ||
1544 | 247 | *return_y = y + off[state]; | ||
1545 | 248 | } | ||
1546 | 249 | |||
1547 | 250 | static void | ||
1548 | 251 | button_state_paint (cairo_t *cr, | ||
1549 | 252 | GtkStyle *style, | ||
1550 | 253 | decor_color_t *color, | ||
1551 | 254 | guint state) | ||
1552 | 255 | { | ||
1553 | 256 | |||
1554 | 257 | #define IN_STATE (PRESSED_EVENT_WINDOW | IN_EVENT_WINDOW) | ||
1555 | 258 | |||
1556 | 259 | if ((state & IN_STATE) == IN_STATE) | ||
1557 | 260 | { | ||
1558 | 261 | if (state & IN_EVENT_WINDOW) | ||
1559 | 262 | cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); | ||
1560 | 263 | else | ||
1561 | 264 | cairo_set_source_rgba (cr, color->r, color->g, color->b, 0.95); | ||
1562 | 265 | |||
1563 | 266 | cairo_fill_preserve (cr); | ||
1564 | 267 | |||
1565 | 268 | gdk_cairo_set_source_color_alpha (cr, | ||
1566 | 269 | &style->fg[GTK_STATE_NORMAL], | ||
1567 | 270 | STROKE_ALPHA); | ||
1568 | 271 | |||
1569 | 272 | cairo_set_line_width (cr, 1.0); | ||
1570 | 273 | cairo_stroke (cr); | ||
1571 | 274 | cairo_set_line_width (cr, 2.0); | ||
1572 | 275 | } | ||
1573 | 276 | else | ||
1574 | 277 | { | ||
1575 | 278 | gdk_cairo_set_source_color_alpha (cr, | ||
1576 | 279 | &style->fg[GTK_STATE_NORMAL], | ||
1577 | 280 | STROKE_ALPHA); | ||
1578 | 281 | cairo_stroke_preserve (cr); | ||
1579 | 282 | |||
1580 | 283 | if (state & IN_EVENT_WINDOW) | ||
1581 | 284 | cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); | ||
1582 | 285 | else | ||
1583 | 286 | cairo_set_source_rgba (cr, color->r, color->g, color->b, 0.95); | ||
1584 | 287 | |||
1585 | 288 | cairo_fill (cr); | ||
1586 | 289 | } | ||
1587 | 290 | } | ||
1588 | 291 | |||
1589 | 292 | void | ||
1590 | 293 | draw_window_decoration (decor_t *d) | ||
1591 | 294 | { | ||
1592 | 295 | cairo_t *cr; | ||
1593 | 296 | GtkStyle *style; | ||
1594 | 297 | GdkDrawable *drawable; | ||
1595 | 298 | decor_color_t color; | ||
1596 | 299 | double alpha; | ||
1597 | 300 | double x1, y1, x2, y2, x, y, h; | ||
1598 | 301 | int corners = SHADE_LEFT | SHADE_RIGHT | SHADE_TOP | SHADE_BOTTOM; | ||
1599 | 302 | int top; | ||
1600 | 303 | int button_x; | ||
1601 | 304 | |||
1602 | 305 | if (!d->pixmap) | ||
1603 | 306 | return; | ||
1604 | 307 | |||
1605 | 308 | |||
1606 | 309 | style = gtk_widget_get_style (d->frame->style_window_rgba); | ||
1607 | 310 | |||
1608 | 311 | if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | | ||
1609 | 312 | WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) | ||
1610 | 313 | corners = 0; | ||
1611 | 314 | |||
1612 | 315 | color.r = style->bg[GTK_STATE_NORMAL].red / 65535.0; | ||
1613 | 316 | color.g = style->bg[GTK_STATE_NORMAL].green / 65535.0; | ||
1614 | 317 | color.b = style->bg[GTK_STATE_NORMAL].blue / 65535.0; | ||
1615 | 318 | |||
1616 | 319 | if (d->frame_window) | ||
1617 | 320 | { | ||
1618 | 321 | GdkColormap *cmap; | ||
1619 | 322 | |||
1620 | 323 | cmap = get_colormap_for_drawable (GDK_DRAWABLE (d->pixmap)); | ||
1621 | 324 | gdk_drawable_set_colormap (GDK_DRAWABLE (d->pixmap), cmap); | ||
1622 | 325 | gdk_drawable_set_colormap (GDK_DRAWABLE (d->buffer_pixmap), cmap); | ||
1623 | 326 | drawable = GDK_DRAWABLE (d->buffer_pixmap); | ||
1624 | 327 | } | ||
1625 | 328 | else if (d->buffer_pixmap) | ||
1626 | 329 | drawable = GDK_DRAWABLE (d->buffer_pixmap); | ||
1627 | 330 | else | ||
1628 | 331 | drawable = GDK_DRAWABLE (d->pixmap); | ||
1629 | 332 | |||
1630 | 333 | cr = gdk_cairo_create (GDK_DRAWABLE (drawable)); | ||
1631 | 334 | if (!cr) | ||
1632 | 335 | return; | ||
1633 | 336 | |||
1634 | 337 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); | ||
1635 | 338 | |||
1636 | 339 | top = d->frame->win_extents.top + d->frame->titlebar_height; | ||
1637 | 340 | |||
1638 | 341 | x1 = d->context->left_space - d->frame->win_extents.left; | ||
1639 | 342 | y1 = d->context->top_space - d->frame->win_extents.top - d->frame->titlebar_height; | ||
1640 | 343 | x2 = d->width - d->context->right_space + d->frame->win_extents.right; | ||
1641 | 344 | y2 = d->height - d->context->bottom_space + d->frame->win_extents.bottom; | ||
1642 | 345 | |||
1643 | 346 | h = d->height - d->context->top_space - d->context->bottom_space; | ||
1644 | 347 | |||
1645 | 348 | cairo_set_line_width (cr, 1.0); | ||
1646 | 349 | |||
1647 | 350 | if (!d->frame_window) | ||
1648 | 351 | draw_shadow_background (d, cr, d->shadow, d->context); | ||
1649 | 352 | |||
1650 | 353 | if (d->active) | ||
1651 | 354 | { | ||
1652 | 355 | decor_color_t *title_color = _title_color; | ||
1653 | 356 | |||
1654 | 357 | alpha = settings->decoration_alpha + 0.3; | ||
1655 | 358 | |||
1656 | 359 | fill_rounded_rectangle (cr, | ||
1657 | 360 | x1 + 0.5, | ||
1658 | 361 | y1 + 0.5, | ||
1659 | 362 | d->frame->win_extents.left - 0.5, | ||
1660 | 363 | top - 0.5, | ||
1661 | 364 | 5.0, CORNER_TOPLEFT & corners, | ||
1662 | 365 | &title_color[0], 1.0, &title_color[1], alpha, | ||
1663 | 366 | SHADE_TOP | SHADE_LEFT); | ||
1664 | 367 | |||
1665 | 368 | fill_rounded_rectangle (cr, | ||
1666 | 369 | x1 + d->frame->win_extents.left, | ||
1667 | 370 | y1 + 0.5, | ||
1668 | 371 | x2 - x1 - d->frame->win_extents.left - | ||
1669 | 372 | d->frame->win_extents.right, | ||
1670 | 373 | top - 0.5, | ||
1671 | 374 | 5.0, 0, | ||
1672 | 375 | &title_color[0], 1.0, &title_color[1], alpha, | ||
1673 | 376 | SHADE_TOP); | ||
1674 | 377 | |||
1675 | 378 | fill_rounded_rectangle (cr, | ||
1676 | 379 | x2 - d->frame->win_extents.right, | ||
1677 | 380 | y1 + 0.5, | ||
1678 | 381 | d->frame->win_extents.right - 0.5, | ||
1679 | 382 | top - 0.5, | ||
1680 | 383 | 5.0, CORNER_TOPRIGHT & corners, | ||
1681 | 384 | &title_color[0], 1.0, &title_color[1], alpha, | ||
1682 | 385 | SHADE_TOP | SHADE_RIGHT); | ||
1683 | 386 | } | ||
1684 | 387 | else | ||
1685 | 388 | { | ||
1686 | 389 | alpha = settings->decoration_alpha; | ||
1687 | 390 | |||
1688 | 391 | fill_rounded_rectangle (cr, | ||
1689 | 392 | x1 + 0.5, | ||
1690 | 393 | y1 + 0.5, | ||
1691 | 394 | d->frame->win_extents.left - 0.5, | ||
1692 | 395 | top - 0.5, | ||
1693 | 396 | 5.0, CORNER_TOPLEFT & corners, | ||
1694 | 397 | &color, 1.0, &color, alpha, | ||
1695 | 398 | SHADE_TOP | SHADE_LEFT); | ||
1696 | 399 | |||
1697 | 400 | fill_rounded_rectangle (cr, | ||
1698 | 401 | x1 + d->frame->win_extents.left, | ||
1699 | 402 | y1 + 0.5, | ||
1700 | 403 | x2 - x1 - d->frame->win_extents.left - | ||
1701 | 404 | d->frame->win_extents.right, | ||
1702 | 405 | top - 0.5, | ||
1703 | 406 | 5.0, 0, | ||
1704 | 407 | &color, 1.0, &color, alpha, | ||
1705 | 408 | SHADE_TOP); | ||
1706 | 409 | |||
1707 | 410 | fill_rounded_rectangle (cr, | ||
1708 | 411 | x2 - d->frame->win_extents.right, | ||
1709 | 412 | y1 + 0.5, | ||
1710 | 413 | d->frame->win_extents.right - 0.5, | ||
1711 | 414 | top - 0.5, | ||
1712 | 415 | 5.0, CORNER_TOPRIGHT & corners, | ||
1713 | 416 | &color, 1.0, &color, alpha, | ||
1714 | 417 | SHADE_TOP | SHADE_RIGHT); | ||
1715 | 418 | } | ||
1716 | 419 | |||
1717 | 420 | fill_rounded_rectangle (cr, | ||
1718 | 421 | x1 + 0.5, | ||
1719 | 422 | y1 + top, | ||
1720 | 423 | d->frame->win_extents.left - 0.5, | ||
1721 | 424 | h, | ||
1722 | 425 | 5.0, 0, | ||
1723 | 426 | &color, 1.0, &color, alpha, | ||
1724 | 427 | SHADE_LEFT); | ||
1725 | 428 | |||
1726 | 429 | fill_rounded_rectangle (cr, | ||
1727 | 430 | x2 - d->frame->win_extents.right, | ||
1728 | 431 | y1 + top, | ||
1729 | 432 | d->frame->win_extents.right - 0.5, | ||
1730 | 433 | h, | ||
1731 | 434 | 5.0, 0, | ||
1732 | 435 | &color, 1.0, &color, alpha, | ||
1733 | 436 | SHADE_RIGHT); | ||
1734 | 437 | |||
1735 | 438 | |||
1736 | 439 | fill_rounded_rectangle (cr, | ||
1737 | 440 | x1 + 0.5, | ||
1738 | 441 | y2 - d->frame->win_extents.bottom, | ||
1739 | 442 | d->frame->win_extents.left - 0.5, | ||
1740 | 443 | d->frame->win_extents.bottom - 0.5, | ||
1741 | 444 | 5.0, CORNER_BOTTOMLEFT & corners, | ||
1742 | 445 | &color, 1.0, &color, alpha, | ||
1743 | 446 | SHADE_BOTTOM | SHADE_LEFT); | ||
1744 | 447 | |||
1745 | 448 | fill_rounded_rectangle (cr, | ||
1746 | 449 | x1 + d->frame->win_extents.left, | ||
1747 | 450 | y2 - d->frame->win_extents.bottom, | ||
1748 | 451 | x2 - x1 - d->frame->win_extents.left - | ||
1749 | 452 | d->frame->win_extents.right, | ||
1750 | 453 | d->frame->win_extents.bottom - 0.5, | ||
1751 | 454 | 5.0, 0, | ||
1752 | 455 | &color, 1.0, &color, alpha, | ||
1753 | 456 | SHADE_BOTTOM); | ||
1754 | 457 | |||
1755 | 458 | fill_rounded_rectangle (cr, | ||
1756 | 459 | x2 - d->frame->win_extents.right, | ||
1757 | 460 | y2 - d->frame->win_extents.bottom, | ||
1758 | 461 | d->frame->win_extents.right - 0.5, | ||
1759 | 462 | d->frame->win_extents.bottom - 0.5, | ||
1760 | 463 | 5.0, CORNER_BOTTOMRIGHT & corners, | ||
1761 | 464 | &color, 1.0, &color, alpha, | ||
1762 | 465 | SHADE_BOTTOM | SHADE_RIGHT); | ||
1763 | 466 | |||
1764 | 467 | cairo_rectangle (cr, | ||
1765 | 468 | d->context->left_space, | ||
1766 | 469 | d->context->top_space, | ||
1767 | 470 | d->width - d->context->left_space - | ||
1768 | 471 | d->context->right_space, | ||
1769 | 472 | h); | ||
1770 | 473 | gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]); | ||
1771 | 474 | cairo_fill (cr); | ||
1772 | 475 | |||
1773 | 476 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); | ||
1774 | 477 | |||
1775 | 478 | if (d->active) | ||
1776 | 479 | { | ||
1777 | 480 | gdk_cairo_set_source_color_alpha (cr, | ||
1778 | 481 | &style->fg[GTK_STATE_NORMAL], | ||
1779 | 482 | 0.7); | ||
1780 | 483 | |||
1781 | 484 | cairo_move_to (cr, x1 + 0.5, y1 + top - 0.5); | ||
1782 | 485 | cairo_rel_line_to (cr, x2 - x1 - 1.0, 0.0); | ||
1783 | 486 | |||
1784 | 487 | cairo_stroke (cr); | ||
1785 | 488 | } | ||
1786 | 489 | |||
1787 | 490 | rounded_rectangle (cr, | ||
1788 | 491 | x1 + 0.5, y1 + 0.5, | ||
1789 | 492 | x2 - x1 - 1.0, y2 - y1 - 1.0, | ||
1790 | 493 | 5.0, | ||
1791 | 494 | (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | | ||
1792 | 495 | CORNER_BOTTOMRIGHT) & corners); | ||
1793 | 496 | |||
1794 | 497 | cairo_clip (cr); | ||
1795 | 498 | |||
1796 | 499 | cairo_translate (cr, 1.0, 1.0); | ||
1797 | 500 | |||
1798 | 501 | rounded_rectangle (cr, | ||
1799 | 502 | x1 + 0.5, y1 + 0.5, | ||
1800 | 503 | x2 - x1 - 1.0, y2 - y1 - 1.0, | ||
1801 | 504 | 5.0, | ||
1802 | 505 | (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | | ||
1803 | 506 | CORNER_BOTTOMRIGHT) & corners); | ||
1804 | 507 | |||
1805 | 508 | cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.4); | ||
1806 | 509 | |||
1807 | 510 | cairo_stroke (cr); | ||
1808 | 511 | |||
1809 | 512 | cairo_translate (cr, -2.0, -2.0); | ||
1810 | 513 | |||
1811 | 514 | rounded_rectangle (cr, | ||
1812 | 515 | x1 + 0.5, y1 + 0.5, | ||
1813 | 516 | x2 - x1 - 1.0, y2 - y1 - 1.0, | ||
1814 | 517 | 5.0, | ||
1815 | 518 | (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | | ||
1816 | 519 | CORNER_BOTTOMRIGHT) & corners); | ||
1817 | 520 | |||
1818 | 521 | cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.1); | ||
1819 | 522 | |||
1820 | 523 | cairo_stroke (cr); | ||
1821 | 524 | |||
1822 | 525 | cairo_translate (cr, 1.0, 1.0); | ||
1823 | 526 | |||
1824 | 527 | cairo_reset_clip (cr); | ||
1825 | 528 | |||
1826 | 529 | rounded_rectangle (cr, | ||
1827 | 530 | x1 + 0.5, y1 + 0.5, | ||
1828 | 531 | x2 - x1 - 1.0, y2 - y1 - 1.0, | ||
1829 | 532 | 5.0, | ||
1830 | 533 | (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | | ||
1831 | 534 | CORNER_BOTTOMRIGHT) & corners); | ||
1832 | 535 | |||
1833 | 536 | gdk_cairo_set_source_color_alpha (cr, | ||
1834 | 537 | &style->fg[GTK_STATE_NORMAL], | ||
1835 | 538 | alpha); | ||
1836 | 539 | |||
1837 | 540 | cairo_stroke (cr); | ||
1838 | 541 | |||
1839 | 542 | cairo_set_line_width (cr, 2.0); | ||
1840 | 543 | |||
1841 | 544 | button_x = d->width - d->context->right_space - 13; | ||
1842 | 545 | |||
1843 | 546 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) | ||
1844 | 547 | { | ||
1845 | 548 | button_state_offsets (button_x, | ||
1846 | 549 | y1 - 3.0 + d->frame->titlebar_height / 2, | ||
1847 | 550 | d->button_states[BUTTON_CLOSE], &x, &y); | ||
1848 | 551 | |||
1849 | 552 | button_x -= 17; | ||
1850 | 553 | |||
1851 | 554 | if (d->active) | ||
1852 | 555 | { | ||
1853 | 556 | cairo_move_to (cr, x, y); | ||
1854 | 557 | draw_close_button (d, cr, 3.0); | ||
1855 | 558 | button_state_paint (cr, style, &color, | ||
1856 | 559 | d->button_states[BUTTON_CLOSE]); | ||
1857 | 560 | } | ||
1858 | 561 | else | ||
1859 | 562 | { | ||
1860 | 563 | gdk_cairo_set_source_color_alpha (cr, | ||
1861 | 564 | &style->fg[GTK_STATE_NORMAL], | ||
1862 | 565 | alpha * 0.75); | ||
1863 | 566 | |||
1864 | 567 | cairo_move_to (cr, x, y); | ||
1865 | 568 | draw_close_button (d, cr, 3.0); | ||
1866 | 569 | cairo_fill (cr); | ||
1867 | 570 | } | ||
1868 | 571 | } | ||
1869 | 572 | |||
1870 | 573 | if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) | ||
1871 | 574 | { | ||
1872 | 575 | button_state_offsets (button_x, | ||
1873 | 576 | y1 - 3.0 + d->frame->titlebar_height / 2, | ||
1874 | 577 | d->button_states[BUTTON_MAX], &x, &y); | ||
1875 | 578 | |||
1876 | 579 | button_x -= 17; | ||
1877 | 580 | |||
1878 | 581 | cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); | ||
1879 | 582 | |||
1880 | 583 | if (d->active) | ||
1881 | 584 | { | ||
1882 | 585 | gdk_cairo_set_source_color_alpha (cr, | ||
1883 | 586 | &style->fg[GTK_STATE_NORMAL], | ||
1884 | 587 | STROKE_ALPHA); | ||
1885 | 588 | |||
1886 | 589 | cairo_move_to (cr, x, y); | ||
1887 | 590 | |||
1888 | 591 | if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | | ||
1889 | 592 | WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) | ||
1890 | 593 | draw_unmax_button (d, cr, 4.0); | ||
1891 | 594 | else | ||
1892 | 595 | draw_max_button (d, cr, 4.0); | ||
1893 | 596 | |||
1894 | 597 | button_state_paint (cr, style, &color, | ||
1895 | 598 | d->button_states[BUTTON_MAX]); | ||
1896 | 599 | } | ||
1897 | 600 | else | ||
1898 | 601 | { | ||
1899 | 602 | gdk_cairo_set_source_color_alpha (cr, | ||
1900 | 603 | &style->fg[GTK_STATE_NORMAL], | ||
1901 | 604 | alpha * 0.75); | ||
1902 | 605 | |||
1903 | 606 | cairo_move_to (cr, x, y); | ||
1904 | 607 | |||
1905 | 608 | if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | | ||
1906 | 609 | WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) | ||
1907 | 610 | draw_unmax_button (d, cr, 4.0); | ||
1908 | 611 | else | ||
1909 | 612 | draw_max_button (d, cr, 4.0); | ||
1910 | 613 | |||
1911 | 614 | cairo_fill (cr); | ||
1912 | 615 | } | ||
1913 | 616 | } | ||
1914 | 617 | |||
1915 | 618 | if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) | ||
1916 | 619 | { | ||
1917 | 620 | button_state_offsets (button_x, | ||
1918 | 621 | y1 - 3.0 + d->frame->titlebar_height / 2, | ||
1919 | 622 | d->button_states[BUTTON_MIN], &x, &y); | ||
1920 | 623 | |||
1921 | 624 | button_x -= 17; | ||
1922 | 625 | |||
1923 | 626 | if (d->active) | ||
1924 | 627 | { | ||
1925 | 628 | gdk_cairo_set_source_color_alpha (cr, | ||
1926 | 629 | &style->fg[GTK_STATE_NORMAL], | ||
1927 | 630 | STROKE_ALPHA); | ||
1928 | 631 | |||
1929 | 632 | |||
1930 | 633 | cairo_move_to (cr, x, y); | ||
1931 | 634 | draw_min_button (d, cr, 4.0); | ||
1932 | 635 | button_state_paint (cr, style, &color, | ||
1933 | 636 | d->button_states[BUTTON_MIN]); | ||
1934 | 637 | } | ||
1935 | 638 | else | ||
1936 | 639 | { | ||
1937 | 640 | gdk_cairo_set_source_color_alpha (cr, | ||
1938 | 641 | &style->fg[GTK_STATE_NORMAL], | ||
1939 | 642 | alpha * 0.75); | ||
1940 | 643 | |||
1941 | 644 | cairo_move_to (cr, x, y); | ||
1942 | 645 | draw_min_button (d, cr, 4.0); | ||
1943 | 646 | cairo_fill (cr); | ||
1944 | 647 | } | ||
1945 | 648 | } | ||
1946 | 649 | |||
1947 | 650 | if (d->layout) | ||
1948 | 651 | { | ||
1949 | 652 | if (d->active) | ||
1950 | 653 | { | ||
1951 | 654 | cairo_move_to (cr, | ||
1952 | 655 | d->context->left_space + 21.0, | ||
1953 | 656 | y1 + 2.0 + (d->frame->titlebar_height - d->frame->text_height) / 2.0); | ||
1954 | 657 | |||
1955 | 658 | gdk_cairo_set_source_color_alpha (cr, | ||
1956 | 659 | &style->fg[GTK_STATE_NORMAL], | ||
1957 | 660 | STROKE_ALPHA); | ||
1958 | 661 | |||
1959 | 662 | pango_cairo_layout_path (cr, d->layout); | ||
1960 | 663 | cairo_stroke (cr); | ||
1961 | 664 | |||
1962 | 665 | cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); | ||
1963 | 666 | } | ||
1964 | 667 | else | ||
1965 | 668 | { | ||
1966 | 669 | gdk_cairo_set_source_color_alpha (cr, | ||
1967 | 670 | &style->fg[GTK_STATE_NORMAL], | ||
1968 | 671 | alpha); | ||
1969 | 672 | } | ||
1970 | 673 | |||
1971 | 674 | cairo_move_to (cr, | ||
1972 | 675 | d->context->left_space + 21.0, | ||
1973 | 676 | y1 + 2.0 + (d->frame->titlebar_height - d->frame->text_height) / 2.0); | ||
1974 | 677 | |||
1975 | 678 | pango_cairo_show_layout (cr, d->layout); | ||
1976 | 679 | } | ||
1977 | 680 | |||
1978 | 681 | if (d->icon) | ||
1979 | 682 | { | ||
1980 | 683 | cairo_translate (cr, d->context->left_space + 1, | ||
1981 | 684 | y1 - 5.0 + d->frame->titlebar_height / 2); | ||
1982 | 685 | cairo_set_source (cr, d->icon); | ||
1983 | 686 | cairo_rectangle (cr, 0.0, 0.0, 16.0, 16.0); | ||
1984 | 687 | cairo_clip (cr); | ||
1985 | 688 | |||
1986 | 689 | if (d->active) | ||
1987 | 690 | cairo_paint (cr); | ||
1988 | 691 | else | ||
1989 | 692 | cairo_paint_with_alpha (cr, alpha); | ||
1990 | 693 | } | ||
1991 | 694 | |||
1992 | 695 | cairo_destroy (cr); | ||
1993 | 696 | |||
1994 | 697 | copy_to_front_buffer (d); | ||
1995 | 698 | |||
1996 | 699 | if (d->frame_window) | ||
1997 | 700 | { | ||
1998 | 701 | GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window); | ||
1999 | 702 | |||
2000 | 703 | gtk_image_set_from_pixmap (GTK_IMAGE (d->decor_image), d->pixmap, NULL); | ||
2001 | 704 | gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height); | ||
2002 | 705 | gdk_window_move (gdk_frame_window, 0, 0); | ||
2003 | 706 | gdk_window_lower (gdk_frame_window); | ||
2004 | 707 | } | ||
2005 | 708 | |||
2006 | 709 | if (d->prop_xid) | ||
2007 | 710 | { | ||
2008 | 711 | decor_update_window_property (d); | ||
2009 | 712 | d->prop_xid = 0; | ||
2010 | 713 | } | ||
2011 | 714 | } | ||
2012 | 715 | |||
2013 | 716 | static void | ||
2014 | 717 | calc_button_size (decor_t *d) | ||
2015 | 718 | { | ||
2016 | 719 | gint button_width; | ||
2017 | 720 | |||
2018 | 721 | button_width = 0; | ||
2019 | 722 | |||
2020 | 723 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) | ||
2021 | 724 | button_width += 17; | ||
2022 | 725 | |||
2023 | 726 | if (d->actions & (WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY | | ||
2024 | 727 | WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY | | ||
2025 | 728 | WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY | | ||
2026 | 729 | WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY)) | ||
2027 | 730 | button_width += 17; | ||
2028 | 731 | |||
2029 | 732 | if (d->actions & (WNCK_WINDOW_ACTION_MINIMIZE | | ||
2030 | 733 | WNCK_WINDOW_ACTION_MINIMIZE)) | ||
2031 | 734 | button_width += 17; | ||
2032 | 735 | |||
2033 | 736 | if (button_width) | ||
2034 | 737 | button_width++; | ||
2035 | 738 | |||
2036 | 739 | d->button_width = button_width; | ||
2037 | 740 | } | ||
2038 | 741 | |||
2039 | 742 | gboolean | ||
2040 | 743 | calc_decoration_size (decor_t *d, | ||
2041 | 744 | gint w, | ||
2042 | 745 | gint h, | ||
2043 | 746 | gint name_width, | ||
2044 | 747 | gint *width, | ||
2045 | 748 | gint *height) | ||
2046 | 749 | { | ||
2047 | 750 | decor_layout_t layout; | ||
2048 | 751 | int top_width; | ||
2049 | 752 | |||
2050 | 753 | /* To avoid wasting texture memory, we only calculate the minimal | ||
2051 | 754 | * required decoration size then clip and stretch the texture where | ||
2052 | 755 | * appropriate | ||
2053 | 756 | */ | ||
2054 | 757 | |||
2055 | 758 | if (!d->frame_window) | ||
2056 | 759 | { | ||
2057 | 760 | calc_button_size (d); | ||
2058 | 761 | |||
2059 | 762 | if (w < ICON_SPACE + d->button_width) | ||
2060 | 763 | return FALSE; | ||
2061 | 764 | |||
2062 | 765 | top_width = name_width + d->button_width + ICON_SPACE; | ||
2063 | 766 | if (w < top_width) | ||
2064 | 767 | top_width = MAX (ICON_SPACE + d->button_width, w); | ||
2065 | 768 | |||
2066 | 769 | decor_get_default_layout (&d->frame->window_context, top_width, 1, &layout); | ||
2067 | 770 | |||
2068 | 771 | if (!d->context || memcmp (&layout, &d->border_layout, sizeof (layout))) | ||
2069 | 772 | { | ||
2070 | 773 | *width = layout.width; | ||
2071 | 774 | *height = layout.height; | ||
2072 | 775 | |||
2073 | 776 | d->border_layout = layout; | ||
2074 | 777 | d->context = &d->frame->window_context; | ||
2075 | 778 | d->shadow = d->frame->border_shadow; | ||
2076 | 779 | |||
2077 | 780 | return TRUE; | ||
2078 | 781 | } | ||
2079 | 782 | } | ||
2080 | 783 | else | ||
2081 | 784 | { | ||
2082 | 785 | calc_button_size (d); | ||
2083 | 786 | |||
2084 | 787 | /* _default_win_extents + top height */ | ||
2085 | 788 | |||
2086 | 789 | top_width = name_width + d->button_width + ICON_SPACE; | ||
2087 | 790 | if (w < top_width) | ||
2088 | 791 | top_width = MAX (ICON_SPACE + d->button_width, w); | ||
2089 | 792 | |||
2090 | 793 | decor_get_default_layout (&d->frame->window_context_no_shadow, | ||
2091 | 794 | d->client_width, d->client_height, &layout); | ||
2092 | 795 | |||
2093 | 796 | *width = layout.width; | ||
2094 | 797 | *height = layout.height; | ||
2095 | 798 | |||
2096 | 799 | d->border_layout = layout; | ||
2097 | 800 | d->context = &d->frame->window_context_no_shadow; | ||
2098 | 801 | d->shadow = d->frame->border_no_shadow; | ||
2099 | 802 | |||
2100 | 803 | return TRUE; | ||
2101 | 804 | } | ||
2102 | 805 | |||
2103 | 806 | return FALSE; | ||
2104 | 807 | } | ||
2105 | 808 | |||
2106 | 809 | gboolean | ||
2107 | 810 | get_button_position (decor_t *d, | ||
2108 | 811 | gint i, | ||
2109 | 812 | gint width, | ||
2110 | 813 | gint height, | ||
2111 | 814 | gint *x, | ||
2112 | 815 | gint *y, | ||
2113 | 816 | gint *w, | ||
2114 | 817 | gint *h) | ||
2115 | 818 | { | ||
2116 | 819 | if (i > BUTTON_MENU) | ||
2117 | 820 | return FALSE; | ||
2118 | 821 | |||
2119 | 822 | if (d->frame_window) | ||
2120 | 823 | { | ||
2121 | 824 | *x = bpos[i].x + bpos[i].xw * width + d->frame->win_extents.left + 4; | ||
2122 | 825 | *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * | ||
2123 | 826 | (d->frame->titlebar_height - 17) + d->frame->win_extents.top + 2; | ||
2124 | 827 | } | ||
2125 | 828 | else | ||
2126 | 829 | { | ||
2127 | 830 | *x = bpos[i].x + bpos[i].xw * width; | ||
2128 | 831 | *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * | ||
2129 | 832 | (d->frame->titlebar_height - 17); | ||
2130 | 833 | } | ||
2131 | 834 | |||
2132 | 835 | *w = bpos[i].w + bpos[i].ww * width; | ||
2133 | 836 | *h = bpos[i].h + bpos[i].hh * height + bpos[i].hth + | ||
2134 | 837 | (d->frame->titlebar_height - 17); | ||
2135 | 838 | |||
2136 | 839 | /* hack to position multiple buttons on the right */ | ||
2137 | 840 | if (i != BUTTON_MENU) | ||
2138 | 841 | *x -= 10 + 16 * i; | ||
2139 | 842 | |||
2140 | 843 | return TRUE; | ||
2141 | 844 | } | ||
2142 | 845 | |||
2143 | 846 | void | ||
2144 | 847 | get_event_window_position (decor_t *d, | ||
2145 | 848 | gint i, | ||
2146 | 849 | gint j, | ||
2147 | 850 | gint width, | ||
2148 | 851 | gint height, | ||
2149 | 852 | gint *x, | ||
2150 | 853 | gint *y, | ||
2151 | 854 | gint *w, | ||
2152 | 855 | gint *h) | ||
2153 | 856 | { | ||
2154 | 857 | if (d->frame_window) | ||
2155 | 858 | { | ||
2156 | 859 | *x = pos[i][j].x + pos[i][j].xw * width + d->frame->win_extents.left; | ||
2157 | 860 | *y = pos[i][j].y + d->frame->win_extents.top + | ||
2158 | 861 | pos[i][j].yh * height + pos[i][j].yth * (d->frame->titlebar_height - 17); | ||
2159 | 862 | |||
2160 | 863 | if (i == 0 && (j == 0 || j == 2)) | ||
2161 | 864 | *y -= d->frame->titlebar_height; | ||
2162 | 865 | } | ||
2163 | 866 | else | ||
2164 | 867 | { | ||
2165 | 868 | *x = pos[i][j].x + pos[i][j].xw * width; | ||
2166 | 869 | *y = pos[i][j].y + | ||
2167 | 870 | pos[i][j].yh * height + pos[i][j].yth * (d->frame->titlebar_height - 17); | ||
2168 | 871 | } | ||
2169 | 872 | |||
2170 | 873 | if ((d->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY) && | ||
2171 | 874 | (j == 0 || j == 2)) | ||
2172 | 875 | { | ||
2173 | 876 | *w = 0; | ||
2174 | 877 | } | ||
2175 | 878 | else | ||
2176 | 879 | { | ||
2177 | 880 | *w = pos[i][j].w + pos[i][j].ww * width; | ||
2178 | 881 | } | ||
2179 | 882 | |||
2180 | 883 | if ((d->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY) && | ||
2181 | 884 | (i == 0 || i == 2)) | ||
2182 | 885 | { | ||
2183 | 886 | *h = 0; | ||
2184 | 887 | } | ||
2185 | 888 | else | ||
2186 | 889 | { | ||
2187 | 890 | *h = pos[i][j].h + | ||
2188 | 891 | pos[i][j].hh * height + pos[i][j].hth * (d->frame->titlebar_height - 17); | ||
2189 | 892 | } | ||
2190 | 893 | } | ||
2191 | 894 | |||
2192 | 895 | gfloat | ||
2193 | 896 | get_title_scale (decor_frame_t *frame) | ||
2194 | 897 | { | ||
2195 | 898 | return 1.0f; | ||
2196 | 899 | } | ||
2197 | 900 | |||
2198 | 901 | void | ||
2199 | 902 | update_border_extents (decor_frame_t *frame) | ||
2200 | 903 | { | ||
2201 | 904 | decor_frame_t *default_frame = gwd_get_decor_frame ("default"); | ||
2202 | 905 | |||
2203 | 906 | frame = gwd_decor_frame_ref (frame); | ||
2204 | 907 | |||
2205 | 908 | frame->win_extents = default_frame->win_extents; | ||
2206 | 909 | frame->max_win_extents = default_frame->win_extents; | ||
2207 | 910 | frame->titlebar_height = frame->max_titlebar_height = | ||
2208 | 911 | (frame->text_height < 17) ? 17 : frame->text_height; | ||
2209 | 912 | |||
2210 | 913 | gwd_decor_frame_unref (frame); | ||
2211 | 914 | gwd_decor_frame_unref (default_frame); | ||
2212 | 915 | } | ||
2213 | 0 | 916 | ||
2214 | === renamed file 'gtk/window-decorator/cairo.c' => 'gtk/window-decorator/cairo.c.THIS' | |||
2215 | === added file 'gtk/window-decorator/decorator.c' | |||
2216 | --- gtk/window-decorator/decorator.c 1970-01-01 00:00:00 +0000 | |||
2217 | +++ gtk/window-decorator/decorator.c 2012-02-08 18:50:27 +0000 | |||
2218 | @@ -0,0 +1,1301 @@ | |||
2219 | 1 | /* | ||
2220 | 2 | * Copyright © 2006 Novell, Inc. | ||
2221 | 3 | * | ||
2222 | 4 | * This library is free software; you can redistribute it and/or | ||
2223 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
2224 | 6 | * License as published by the Free Software Foundation; either | ||
2225 | 7 | * version 2 of the License, or (at your option) any later version. | ||
2226 | 8 | * | ||
2227 | 9 | * This library is distributed in the hope that it will be useful, | ||
2228 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2229 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2230 | 12 | * Lesser General Public License for more details. | ||
2231 | 13 | * | ||
2232 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
2233 | 15 | * License along with this library; if not, write to the | ||
2234 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
2235 | 17 | * Boston, MA 02111-1307, USA. | ||
2236 | 18 | * | ||
2237 | 19 | * Author: David Reveman <davidr@novell.com> | ||
2238 | 20 | * | ||
2239 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
2240 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
2241 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2242 | 24 | */ | ||
2243 | 25 | |||
2244 | 26 | #include "gtk-window-decorator.h" | ||
2245 | 27 | |||
2246 | 28 | decor_frame_t * | ||
2247 | 29 | create_normal_frame (const gchar *type) | ||
2248 | 30 | { | ||
2249 | 31 | decor_frame_t *frame = decor_frame_new (type); | ||
2250 | 32 | |||
2251 | 33 | decor_context_t _window_context = { | ||
2252 | 34 | { 0, 0, 0, 0 }, | ||
2253 | 35 | 6, 6, 4, 6, | ||
2254 | 36 | 0, 0, 0, 0 | ||
2255 | 37 | }; | ||
2256 | 38 | |||
2257 | 39 | decor_context_t _max_window_context = { | ||
2258 | 40 | { 0, 0, 0, 0 }, | ||
2259 | 41 | 6, 6, 4, 6, | ||
2260 | 42 | 0, 0, 0, 0 | ||
2261 | 43 | }; | ||
2262 | 44 | |||
2263 | 45 | decor_context_t _window_context_no_shadow = { | ||
2264 | 46 | { 0, 0, 0, 0 }, | ||
2265 | 47 | 6, 6, 4, 6, | ||
2266 | 48 | 0, 0, 0, 0 | ||
2267 | 49 | }; | ||
2268 | 50 | |||
2269 | 51 | decor_context_t _max_window_context_no_shadow = { | ||
2270 | 52 | { 0, 0, 0, 0 }, | ||
2271 | 53 | 6, 6, 4, 6, | ||
2272 | 54 | 0, 0, 0, 0 | ||
2273 | 55 | }; | ||
2274 | 56 | |||
2275 | 57 | decor_extents_t _win_extents = { 6, 6, 6, 6 }; | ||
2276 | 58 | decor_extents_t _max_win_extents = { 6, 6, 4, 6 }; | ||
2277 | 59 | |||
2278 | 60 | frame->win_extents = _win_extents; | ||
2279 | 61 | frame->max_win_extents = _max_win_extents; | ||
2280 | 62 | frame->update_shadow = decor_frame_update_shadow; | ||
2281 | 63 | frame->window_context = _window_context; | ||
2282 | 64 | frame->window_context_no_shadow = _window_context_no_shadow; | ||
2283 | 65 | frame->max_window_context = _max_window_context; | ||
2284 | 66 | frame->max_window_context_no_shadow = _max_window_context_no_shadow; | ||
2285 | 67 | |||
2286 | 68 | return frame; | ||
2287 | 69 | } | ||
2288 | 70 | |||
2289 | 71 | void | ||
2290 | 72 | destroy_normal_frame (decor_frame_t *frame) | ||
2291 | 73 | { | ||
2292 | 74 | decor_frame_destroy (frame); | ||
2293 | 75 | } | ||
2294 | 76 | |||
2295 | 77 | decor_frame_t * | ||
2296 | 78 | create_bare_frame (const gchar *type) | ||
2297 | 79 | { | ||
2298 | 80 | decor_frame_t *frame = decor_frame_new (type); | ||
2299 | 81 | decor_context_t _shadow_context = { | ||
2300 | 82 | { 0, 0, 0, 0 }, | ||
2301 | 83 | 0, 0, 0, 0, | ||
2302 | 84 | 0, 0, 0, 0, | ||
2303 | 85 | }; | ||
2304 | 86 | |||
2305 | 87 | decor_extents_t _shadow_extents = { 0, 0, 0, 0 }; | ||
2306 | 88 | |||
2307 | 89 | frame->win_extents = _shadow_extents; | ||
2308 | 90 | frame->max_win_extents = _shadow_extents; | ||
2309 | 91 | frame->win_extents = _shadow_extents; | ||
2310 | 92 | frame->window_context = _shadow_context; | ||
2311 | 93 | frame->window_context_no_shadow = _shadow_context; | ||
2312 | 94 | frame->max_window_context = _shadow_context; | ||
2313 | 95 | frame->max_window_context_no_shadow = _shadow_context; | ||
2314 | 96 | frame->update_shadow = bare_frame_update_shadow; | ||
2315 | 97 | |||
2316 | 98 | return frame; | ||
2317 | 99 | } | ||
2318 | 100 | |||
2319 | 101 | void | ||
2320 | 102 | destroy_bare_frame (decor_frame_t *frame) | ||
2321 | 103 | { | ||
2322 | 104 | decor_frame_destroy (frame); | ||
2323 | 105 | } | ||
2324 | 106 | |||
2325 | 107 | |||
2326 | 108 | /* | ||
2327 | 109 | * get_titlebar_font | ||
2328 | 110 | * | ||
2329 | 111 | * Returns: PangoFontDescription * or NULL if using system font | ||
2330 | 112 | * Description: Helper function to get the font for the titlebar | ||
2331 | 113 | */ | ||
2332 | 114 | static const PangoFontDescription * | ||
2333 | 115 | get_titlebar_font (decor_frame_t *frame) | ||
2334 | 116 | { | ||
2335 | 117 | if (settings->use_system_font) | ||
2336 | 118 | return NULL; | ||
2337 | 119 | else | ||
2338 | 120 | return frame->titlebar_font; | ||
2339 | 121 | } | ||
2340 | 122 | |||
2341 | 123 | /* | ||
2342 | 124 | * frame_update_titlebar_font | ||
2343 | 125 | * | ||
2344 | 126 | * Returns: void | ||
2345 | 127 | * Description: updates the titlebar font from the pango context, should | ||
2346 | 128 | * be called whenever the gtk style or font has changed | ||
2347 | 129 | */ | ||
2348 | 130 | void | ||
2349 | 131 | frame_update_titlebar_font (decor_frame_t *frame) | ||
2350 | 132 | { | ||
2351 | 133 | const PangoFontDescription *font_desc; | ||
2352 | 134 | PangoFontMetrics *metrics; | ||
2353 | 135 | PangoLanguage *lang; | ||
2354 | 136 | |||
2355 | 137 | frame = gwd_decor_frame_ref (frame); | ||
2356 | 138 | |||
2357 | 139 | font_desc = get_titlebar_font (frame); | ||
2358 | 140 | if (!font_desc) | ||
2359 | 141 | { | ||
2360 | 142 | GtkStyle *default_style; | ||
2361 | 143 | |||
2362 | 144 | default_style = gtk_widget_get_default_style (); | ||
2363 | 145 | font_desc = default_style->font_desc; | ||
2364 | 146 | } | ||
2365 | 147 | |||
2366 | 148 | pango_context_set_font_description (frame->pango_context, font_desc); | ||
2367 | 149 | |||
2368 | 150 | lang = pango_context_get_language (frame->pango_context); | ||
2369 | 151 | metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang); | ||
2370 | 152 | |||
2371 | 153 | frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + | ||
2372 | 154 | pango_font_metrics_get_descent (metrics)); | ||
2373 | 155 | |||
2374 | 156 | gwd_decor_frame_unref (frame); | ||
2375 | 157 | |||
2376 | 158 | pango_font_metrics_unref (metrics); | ||
2377 | 159 | } | ||
2378 | 160 | |||
2379 | 161 | void | ||
2380 | 162 | update_frames_titlebar_fonts (gpointer key, | ||
2381 | 163 | gpointer value, | ||
2382 | 164 | gpointer user_data) | ||
2383 | 165 | { | ||
2384 | 166 | frame_update_titlebar_font ((decor_frame_t *) value); | ||
2385 | 167 | } | ||
2386 | 168 | |||
2387 | 169 | void | ||
2388 | 170 | update_titlebar_font () | ||
2389 | 171 | { | ||
2390 | 172 | gwd_frames_foreach (update_frames_titlebar_fonts, NULL); | ||
2391 | 173 | } | ||
2392 | 174 | |||
2393 | 175 | |||
2394 | 176 | /* | ||
2395 | 177 | * update_event_windows | ||
2396 | 178 | * | ||
2397 | 179 | * Returns: void | ||
2398 | 180 | * Description: creates small "event windows" for the buttons specified to be | ||
2399 | 181 | * on the titlebar by wnck. Note here that for the pixmap mode we create actual | ||
2400 | 182 | * X windows but in the reparenting mode this is not possible so we create event | ||
2401 | 183 | * capture boxes on the window instead. The geometry of the decoration is retrieved | ||
2402 | 184 | * with wnck_window_get_client_window_geometry and adjusted for shade. Also we | ||
2403 | 185 | * need to query the theme for what window positions are appropriate here. | ||
2404 | 186 | * | ||
2405 | 187 | * This function works on the buttons and also the small event regions that we need | ||
2406 | 188 | * in order to toggle certain actions on the window decoration (eg resize, move) | ||
2407 | 189 | * | ||
2408 | 190 | * So your window decoration might look something like this (not to scale): | ||
2409 | 191 | * | ||
2410 | 192 | * ----------------------------------------------------------- | ||
2411 | 193 | * | rtl | rt | rtr | | ||
2412 | 194 | * | --- |---------------------------------------------| --- | | ||
2413 | 195 | * | | [i][s][m] mv [_][M][X] | | | ||
2414 | 196 | * | |---------------------------------------------| | | ||
2415 | 197 | * | | | | | ||
2416 | 198 | * | rl | window contents | rr | | ||
2417 | 199 | * | | | | | ||
2418 | 200 | * | | | | | ||
2419 | 201 | * | --- |---------------------------------------------| --- | | ||
2420 | 202 | * | rbl | rb | rbr | | ||
2421 | 203 | * ----------------------------------------------------------- | ||
2422 | 204 | * | ||
2423 | 205 | * Where: | ||
2424 | 206 | * - rtl = resize top left | ||
2425 | 207 | * - rtr = resize top right | ||
2426 | 208 | * - rbl = resize bottom left | ||
2427 | 209 | * - rbr = resize bottom right | ||
2428 | 210 | * - rt = resize top | ||
2429 | 211 | * - rb = resize bottom | ||
2430 | 212 | * - rl = resize left | ||
2431 | 213 | * - rr = resize right | ||
2432 | 214 | * - mv = "grab move" area (eg titlebar) | ||
2433 | 215 | * - i = icon | ||
2434 | 216 | * - s = shade | ||
2435 | 217 | * - m = menu | ||
2436 | 218 | * - _ = minimize | ||
2437 | 219 | * - M = maximize | ||
2438 | 220 | * - X = close | ||
2439 | 221 | * | ||
2440 | 222 | * For the reparenting mode we use button_windows[i].pos and for the pixmap mode | ||
2441 | 223 | * we use buttons_windows[i].window | ||
2442 | 224 | * | ||
2443 | 225 | */ | ||
2444 | 226 | void | ||
2445 | 227 | update_event_windows (WnckWindow *win) | ||
2446 | 228 | { | ||
2447 | 229 | Display *xdisplay; | ||
2448 | 230 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
2449 | 231 | gint x0, y0, width, height, x, y, w, h; | ||
2450 | 232 | gint i, j, k, l; | ||
2451 | 233 | gint actions = d->actions; | ||
2452 | 234 | |||
2453 | 235 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
2454 | 236 | |||
2455 | 237 | /* Get the geometry of the client */ | ||
2456 | 238 | wnck_window_get_client_window_geometry (win, &x0, &y0, &width, &height); | ||
2457 | 239 | |||
2458 | 240 | /* Shaded windows have no height - also skip some event windows */ | ||
2459 | 241 | if (d->state & WNCK_WINDOW_STATE_SHADED) | ||
2460 | 242 | { | ||
2461 | 243 | height = 0; | ||
2462 | 244 | k = l = 1; | ||
2463 | 245 | } | ||
2464 | 246 | else | ||
2465 | 247 | { | ||
2466 | 248 | k = 0; | ||
2467 | 249 | l = 2; | ||
2468 | 250 | } | ||
2469 | 251 | |||
2470 | 252 | gdk_error_trap_push (); | ||
2471 | 253 | |||
2472 | 254 | /* [rtl, ru, rtr], [rl, mv, rr], [rbl, rb, rbr] */ | ||
2473 | 255 | for (i = 0; i < 3; i++) | ||
2474 | 256 | { | ||
2475 | 257 | static guint event_window_actions[3][3] = { | ||
2476 | 258 | { | ||
2477 | 259 | WNCK_WINDOW_ACTION_RESIZE, | ||
2478 | 260 | WNCK_WINDOW_ACTION_RESIZE, | ||
2479 | 261 | WNCK_WINDOW_ACTION_RESIZE | ||
2480 | 262 | }, { | ||
2481 | 263 | WNCK_WINDOW_ACTION_RESIZE, | ||
2482 | 264 | WNCK_WINDOW_ACTION_MOVE, | ||
2483 | 265 | WNCK_WINDOW_ACTION_RESIZE | ||
2484 | 266 | }, { | ||
2485 | 267 | WNCK_WINDOW_ACTION_RESIZE, | ||
2486 | 268 | WNCK_WINDOW_ACTION_RESIZE, | ||
2487 | 269 | WNCK_WINDOW_ACTION_RESIZE | ||
2488 | 270 | } | ||
2489 | 271 | }; | ||
2490 | 272 | |||
2491 | 273 | for (j = 0; j < 3; j++) | ||
2492 | 274 | { | ||
2493 | 275 | w = 0; | ||
2494 | 276 | h = 0; | ||
2495 | 277 | |||
2496 | 278 | if (actions & event_window_actions[i][j] && i >= k && i <= l) | ||
2497 | 279 | (*theme_get_event_window_position) (d, i, j, width, height, | ||
2498 | 280 | &x, &y, &w, &h); | ||
2499 | 281 | |||
2500 | 282 | /* Reparenting mode - create boxes which we monitor motionnotify on */ | ||
2501 | 283 | if (d->frame_window) | ||
2502 | 284 | { | ||
2503 | 285 | BoxPtr box = &d->event_windows[i][j].pos; | ||
2504 | 286 | box->x1 = x; | ||
2505 | 287 | box->x2 = x + w; | ||
2506 | 288 | box->y1 = y; | ||
2507 | 289 | box->y2 = y + h; | ||
2508 | 290 | } | ||
2509 | 291 | /* Pixmap mode with window geometry - create small event windows */ | ||
2510 | 292 | else if (!d->frame_window && w != 0 && h != 0) | ||
2511 | 293 | { | ||
2512 | 294 | XMapWindow (xdisplay, d->event_windows[i][j].window); | ||
2513 | 295 | XMoveResizeWindow (xdisplay, d->event_windows[i][j].window, | ||
2514 | 296 | x, y, w, h); | ||
2515 | 297 | } | ||
2516 | 298 | /* No parent and no geometry - unmap all event windows */ | ||
2517 | 299 | else if (!d->frame_window) | ||
2518 | 300 | { | ||
2519 | 301 | XUnmapWindow (xdisplay, d->event_windows[i][j].window); | ||
2520 | 302 | } | ||
2521 | 303 | } | ||
2522 | 304 | } | ||
2523 | 305 | |||
2524 | 306 | /* no button event windows if width is less than minimum width */ | ||
2525 | 307 | if (width < ICON_SPACE + d->button_width) | ||
2526 | 308 | actions = 0; | ||
2527 | 309 | |||
2528 | 310 | /* Above, stick, unshade and unstick are only available in wnck => 2.18.1 */ | ||
2529 | 311 | for (i = 0; i < BUTTON_NUM; i++) | ||
2530 | 312 | { | ||
2531 | 313 | static guint button_actions[BUTTON_NUM] = { | ||
2532 | 314 | WNCK_WINDOW_ACTION_CLOSE, | ||
2533 | 315 | WNCK_WINDOW_ACTION_MAXIMIZE, | ||
2534 | 316 | WNCK_WINDOW_ACTION_MINIMIZE, | ||
2535 | 317 | 0, | ||
2536 | 318 | WNCK_WINDOW_ACTION_SHADE, | ||
2537 | 319 | |||
2538 | 320 | #ifdef HAVE_LIBWNCK_2_18_1 | ||
2539 | 321 | WNCK_WINDOW_ACTION_ABOVE, | ||
2540 | 322 | WNCK_WINDOW_ACTION_STICK, | ||
2541 | 323 | WNCK_WINDOW_ACTION_UNSHADE, | ||
2542 | 324 | WNCK_WINDOW_ACTION_ABOVE, | ||
2543 | 325 | WNCK_WINDOW_ACTION_UNSTICK | ||
2544 | 326 | #else | ||
2545 | 327 | 0, | ||
2546 | 328 | 0, | ||
2547 | 329 | 0, | ||
2548 | 330 | 0, | ||
2549 | 331 | 0 | ||
2550 | 332 | #endif | ||
2551 | 333 | |||
2552 | 334 | }; | ||
2553 | 335 | |||
2554 | 336 | /* Reparenting mode - if a box was set and we no longer need it reset its geometry */ | ||
2555 | 337 | if (d->frame_window && | ||
2556 | 338 | button_actions[i] && !(actions & button_actions[i])) | ||
2557 | 339 | { | ||
2558 | 340 | memset (&d->button_windows[i].pos, 0, sizeof (Box)); | ||
2559 | 341 | } | ||
2560 | 342 | /* Pixmap mode - if a box was set and we no longer need it unmap its window */ | ||
2561 | 343 | else if (!d->frame_window && | ||
2562 | 344 | button_actions[i] && !(actions & button_actions[i])) | ||
2563 | 345 | { | ||
2564 | 346 | XUnmapWindow (xdisplay, d->button_windows[i].window); | ||
2565 | 347 | continue; | ||
2566 | 348 | } | ||
2567 | 349 | |||
2568 | 350 | /* Reparenting mode - if there is a button position for this | ||
2569 | 351 | * button then set the geometry */ | ||
2570 | 352 | if (d->frame_window && | ||
2571 | 353 | (*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h)) | ||
2572 | 354 | { | ||
2573 | 355 | BoxPtr box = &d->button_windows[i].pos; | ||
2574 | 356 | box->x1 = x; | ||
2575 | 357 | box->y1 = y; | ||
2576 | 358 | box->x2 = x + w; | ||
2577 | 359 | box->y2 = y + h; | ||
2578 | 360 | } | ||
2579 | 361 | /* Pixmap mode - if there is a button position for this button then map the window | ||
2580 | 362 | * and resize it to this position */ | ||
2581 | 363 | else if (!d->frame_window && | ||
2582 | 364 | (*theme_get_button_position) (d, i, width, height, | ||
2583 | 365 | &x, &y, &w, &h)) | ||
2584 | 366 | { | ||
2585 | 367 | Window win = d->button_windows[i].window; | ||
2586 | 368 | XMapWindow (xdisplay, win); | ||
2587 | 369 | XMoveResizeWindow (xdisplay, win, x, y, w, h); | ||
2588 | 370 | } | ||
2589 | 371 | else if (!d->frame_window) | ||
2590 | 372 | { | ||
2591 | 373 | XUnmapWindow (xdisplay, d->button_windows[i].window); | ||
2592 | 374 | } | ||
2593 | 375 | } | ||
2594 | 376 | |||
2595 | 377 | gdk_display_sync (gdk_display_get_default ()); | ||
2596 | 378 | gdk_error_trap_pop (); | ||
2597 | 379 | } | ||
2598 | 380 | |||
2599 | 381 | /* | ||
2600 | 382 | * wnck_window_get_real_name | ||
2601 | 383 | * | ||
2602 | 384 | * Returns: const char * or NULL | ||
2603 | 385 | * Description: Wrapper function to either get the name of the window or | ||
2604 | 386 | * return NULL | ||
2605 | 387 | */ | ||
2606 | 388 | |||
2607 | 389 | #ifdef HAVE_WNCK_WINDOW_HAS_NAME | ||
2608 | 390 | static const char * | ||
2609 | 391 | wnck_window_get_real_name (WnckWindow *win) | ||
2610 | 392 | { | ||
2611 | 393 | return wnck_window_has_name (win) ? wnck_window_get_name (win) : NULL; | ||
2612 | 394 | } | ||
2613 | 395 | #define wnck_window_get_name wnck_window_get_real_name | ||
2614 | 396 | #endif | ||
2615 | 397 | |||
2616 | 398 | /* | ||
2617 | 399 | * max_window_name_width | ||
2618 | 400 | * | ||
2619 | 401 | * Returns: gint | ||
2620 | 402 | * Description: Calculate the width of the decoration required to display | ||
2621 | 403 | * the window name using pango (with 6px padding) | ||
2622 | 404 | * Returns zero if window has no name. | ||
2623 | 405 | */ | ||
2624 | 406 | gint | ||
2625 | 407 | max_window_name_width (WnckWindow *win) | ||
2626 | 408 | { | ||
2627 | 409 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
2628 | 410 | const gchar *name; | ||
2629 | 411 | gint w; | ||
2630 | 412 | |||
2631 | 413 | /* Ensure that a layout is created */ | ||
2632 | 414 | if (!d->layout) | ||
2633 | 415 | { | ||
2634 | 416 | d->layout = pango_layout_new (d->frame->pango_context); | ||
2635 | 417 | if (!d->layout) | ||
2636 | 418 | return 0; | ||
2637 | 419 | |||
2638 | 420 | pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR); | ||
2639 | 421 | } | ||
2640 | 422 | |||
2641 | 423 | /* Return zero if window has no name */ | ||
2642 | 424 | name = wnck_window_get_name (win); | ||
2643 | 425 | if (!name) | ||
2644 | 426 | return 0; | ||
2645 | 427 | |||
2646 | 428 | /* Reset the width, set hte text and get the size required */ | ||
2647 | 429 | pango_layout_set_auto_dir (d->layout, FALSE); | ||
2648 | 430 | pango_layout_set_width (d->layout, -1); | ||
2649 | 431 | pango_layout_set_text (d->layout, name, strlen (name)); | ||
2650 | 432 | pango_layout_get_pixel_size (d->layout, &w, NULL); | ||
2651 | 433 | |||
2652 | 434 | if (d->name) | ||
2653 | 435 | pango_layout_set_text (d->layout, d->name, strlen (d->name)); | ||
2654 | 436 | |||
2655 | 437 | return w + 6; | ||
2656 | 438 | } | ||
2657 | 439 | |||
2658 | 440 | /* | ||
2659 | 441 | * update_window_decoration_name | ||
2660 | 442 | * | ||
2661 | 443 | * Returns: void | ||
2662 | 444 | * Description: frees the last window name and gets the new one from | ||
2663 | 445 | * wnck. Also checks to see if the name has a length (slight optimization) | ||
2664 | 446 | * and re-creates the pango context to re-render the name | ||
2665 | 447 | */ | ||
2666 | 448 | void | ||
2667 | 449 | update_window_decoration_name (WnckWindow *win) | ||
2668 | 450 | { | ||
2669 | 451 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
2670 | 452 | const gchar *name; | ||
2671 | 453 | glong name_length; | ||
2672 | 454 | PangoLayoutLine *line; | ||
2673 | 455 | |||
2674 | 456 | if (d->name) | ||
2675 | 457 | { | ||
2676 | 458 | g_free (d->name); | ||
2677 | 459 | d->name = NULL; | ||
2678 | 460 | } | ||
2679 | 461 | |||
2680 | 462 | /* Only operate if the window name has a length */ | ||
2681 | 463 | name = wnck_window_get_name (win); | ||
2682 | 464 | if (name && (name_length = strlen (name))) | ||
2683 | 465 | { | ||
2684 | 466 | gint w; | ||
2685 | 467 | |||
2686 | 468 | /* Cairo mode: w = SHRT_MAX */ | ||
2687 | 469 | if (theme_draw_window_decoration != draw_window_decoration) | ||
2688 | 470 | { | ||
2689 | 471 | w = SHRT_MAX; | ||
2690 | 472 | } | ||
2691 | 473 | /* Need to get a minimum width for the name */ | ||
2692 | 474 | else | ||
2693 | 475 | { | ||
2694 | 476 | gint width; | ||
2695 | 477 | |||
2696 | 478 | wnck_window_get_client_window_geometry (win, NULL, NULL, | ||
2697 | 479 | &width, NULL); | ||
2698 | 480 | |||
2699 | 481 | w = width - ICON_SPACE - 2 - d->button_width; | ||
2700 | 482 | if (w < 1) | ||
2701 | 483 | w = 1; | ||
2702 | 484 | } | ||
2703 | 485 | |||
2704 | 486 | /* Set the maximum width for the layout (in case | ||
2705 | 487 | * decoration size < text width) since we | ||
2706 | 488 | * still need to show the buttons and the window name */ | ||
2707 | 489 | pango_layout_set_auto_dir (d->layout, FALSE); | ||
2708 | 490 | pango_layout_set_width (d->layout, w * PANGO_SCALE); | ||
2709 | 491 | pango_layout_set_text (d->layout, name, name_length); | ||
2710 | 492 | |||
2711 | 493 | line = pango_layout_get_line (d->layout, 0); | ||
2712 | 494 | |||
2713 | 495 | name_length = line->length; | ||
2714 | 496 | if (pango_layout_get_line_count (d->layout) > 1) | ||
2715 | 497 | { | ||
2716 | 498 | if (name_length < 4) | ||
2717 | 499 | { | ||
2718 | 500 | pango_layout_set_text (d->layout, NULL, 0); | ||
2719 | 501 | return; | ||
2720 | 502 | } | ||
2721 | 503 | |||
2722 | 504 | d->name = g_strndup (name, name_length); | ||
2723 | 505 | strcpy (d->name + name_length - 3, "..."); | ||
2724 | 506 | } | ||
2725 | 507 | else | ||
2726 | 508 | d->name = g_strndup (name, name_length); | ||
2727 | 509 | |||
2728 | 510 | /* Truncate the text */ | ||
2729 | 511 | pango_layout_set_text (d->layout, d->name, name_length); | ||
2730 | 512 | } | ||
2731 | 513 | } | ||
2732 | 514 | |||
2733 | 515 | /* | ||
2734 | 516 | * update_window_decoration_icon | ||
2735 | 517 | * | ||
2736 | 518 | * Updates the window icon (destroys the existing cairo pattern | ||
2737 | 519 | * and creates a new one for the pixmap) | ||
2738 | 520 | */ | ||
2739 | 521 | void | ||
2740 | 522 | update_window_decoration_icon (WnckWindow *win) | ||
2741 | 523 | { | ||
2742 | 524 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
2743 | 525 | |||
2744 | 526 | /* Destroy old stuff */ | ||
2745 | 527 | if (d->icon) | ||
2746 | 528 | { | ||
2747 | 529 | cairo_pattern_destroy (d->icon); | ||
2748 | 530 | d->icon = NULL; | ||
2749 | 531 | } | ||
2750 | 532 | |||
2751 | 533 | if (d->icon_pixmap) | ||
2752 | 534 | { | ||
2753 | 535 | g_object_unref (G_OBJECT (d->icon_pixmap)); | ||
2754 | 536 | d->icon_pixmap = NULL; | ||
2755 | 537 | } | ||
2756 | 538 | |||
2757 | 539 | if (d->icon_pixbuf) | ||
2758 | 540 | g_object_unref (G_OBJECT (d->icon_pixbuf)); | ||
2759 | 541 | |||
2760 | 542 | /* Get the mini icon pixbuf from libwnck */ | ||
2761 | 543 | d->icon_pixbuf = wnck_window_get_mini_icon (win); | ||
2762 | 544 | if (d->icon_pixbuf) | ||
2763 | 545 | { | ||
2764 | 546 | cairo_t *cr; | ||
2765 | 547 | |||
2766 | 548 | g_object_ref (G_OBJECT (d->icon_pixbuf)); | ||
2767 | 549 | |||
2768 | 550 | /* 32 bit pixmap on pixmap mode, 24 for reparenting */ | ||
2769 | 551 | if (d->frame_window) | ||
2770 | 552 | d->icon_pixmap = pixmap_new_from_pixbuf (d->icon_pixbuf, | ||
2771 | 553 | d->frame->style_window_rgba); | ||
2772 | 554 | else | ||
2773 | 555 | d->icon_pixmap = pixmap_new_from_pixbuf (d->icon_pixbuf, | ||
2774 | 556 | d->frame->style_window_rgb); | ||
2775 | 557 | cr = gdk_cairo_create (GDK_DRAWABLE (d->icon_pixmap)); | ||
2776 | 558 | d->icon = cairo_pattern_create_for_surface (cairo_get_target (cr)); | ||
2777 | 559 | cairo_destroy (cr); | ||
2778 | 560 | } | ||
2779 | 561 | } | ||
2780 | 562 | |||
2781 | 563 | |||
2782 | 564 | /* | ||
2783 | 565 | * update_window_decoration_size | ||
2784 | 566 | * Returns: FALSE for failure, TRUE for success | ||
2785 | 567 | * Description: Calculates the minimum size of the decoration that we need | ||
2786 | 568 | * to render. This is mostly done by the theme but there is some work that | ||
2787 | 569 | * we need to do here first, such as getting the client geometry, setting | ||
2788 | 570 | * drawable depths, creating pixmaps, creating XRenderPictures and | ||
2789 | 571 | * updating the window decoration name | ||
2790 | 572 | */ | ||
2791 | 573 | |||
2792 | 574 | gboolean | ||
2793 | 575 | update_window_decoration_size (WnckWindow *win) | ||
2794 | 576 | { | ||
2795 | 577 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
2796 | 578 | GdkPixmap *pixmap, *buffer_pixmap = NULL; | ||
2797 | 579 | Picture picture; | ||
2798 | 580 | gint width, height; | ||
2799 | 581 | gint x, y, w, h, name_width; | ||
2800 | 582 | Display *xdisplay; | ||
2801 | 583 | XRenderPictFormat *format; | ||
2802 | 584 | |||
2803 | 585 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
2804 | 586 | |||
2805 | 587 | /* Get the geometry of the window, we'll need it later */ | ||
2806 | 588 | wnck_window_get_client_window_geometry (win, &x, &y, &w, &h); | ||
2807 | 589 | |||
2808 | 590 | /* Get the width of the name */ | ||
2809 | 591 | name_width = max_window_name_width (win); | ||
2810 | 592 | |||
2811 | 593 | /* Ask the theme to tell us how much space it needs. If this is not successful | ||
2812 | 594 | * update the decoration name and return false */ | ||
2813 | 595 | if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height)) | ||
2814 | 596 | { | ||
2815 | 597 | update_window_decoration_name (win); | ||
2816 | 598 | return FALSE; | ||
2817 | 599 | } | ||
2818 | 600 | |||
2819 | 601 | gdk_error_trap_push (); | ||
2820 | 602 | |||
2821 | 603 | /* Get the correct depth for the frame window in reparenting mode, otherwise | ||
2822 | 604 | * enforce 32 */ | ||
2823 | 605 | if (d->frame_window) | ||
2824 | 606 | pixmap = create_pixmap (width, height, d->frame->style_window_rgb); | ||
2825 | 607 | else | ||
2826 | 608 | pixmap = create_pixmap (width, height, d->frame->style_window_rgba); | ||
2827 | 609 | |||
2828 | 610 | gdk_flush (); | ||
2829 | 611 | |||
2830 | 612 | /* Handle failure */ | ||
2831 | 613 | if (!pixmap || gdk_error_trap_pop ()) | ||
2832 | 614 | { | ||
2833 | 615 | memset (pixmap, 0, sizeof (pixmap)); | ||
2834 | 616 | return FALSE; | ||
2835 | 617 | } | ||
2836 | 618 | |||
2837 | 619 | gdk_error_trap_push (); | ||
2838 | 620 | |||
2839 | 621 | if (d->frame_window) | ||
2840 | 622 | buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgb); | ||
2841 | 623 | else | ||
2842 | 624 | buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgba); | ||
2843 | 625 | |||
2844 | 626 | gdk_flush (); | ||
2845 | 627 | |||
2846 | 628 | /* Handle failure */ | ||
2847 | 629 | if (!buffer_pixmap || gdk_error_trap_pop ()) | ||
2848 | 630 | { | ||
2849 | 631 | memset (buffer_pixmap, 0, sizeof (buffer_pixmap)); | ||
2850 | 632 | g_object_unref (G_OBJECT (pixmap)); | ||
2851 | 633 | return FALSE; | ||
2852 | 634 | } | ||
2853 | 635 | |||
2854 | 636 | /* Create XRender context */ | ||
2855 | 637 | format = get_format_for_drawable (d, GDK_DRAWABLE (buffer_pixmap)); | ||
2856 | 638 | picture = XRenderCreatePicture (xdisplay, GDK_PIXMAP_XID (buffer_pixmap), | ||
2857 | 639 | format, 0, NULL); | ||
2858 | 640 | |||
2859 | 641 | /* Destroy the old pixmaps and pictures */ | ||
2860 | 642 | if (d->pixmap) | ||
2861 | 643 | g_object_unref (G_OBJECT (d->pixmap)); | ||
2862 | 644 | |||
2863 | 645 | if (d->buffer_pixmap) | ||
2864 | 646 | g_object_unref (G_OBJECT (d->buffer_pixmap)); | ||
2865 | 647 | |||
2866 | 648 | if (d->picture) | ||
2867 | 649 | XRenderFreePicture (xdisplay, d->picture); | ||
2868 | 650 | |||
2869 | 651 | if (d->cr) | ||
2870 | 652 | cairo_destroy (d->cr); | ||
2871 | 653 | |||
2872 | 654 | /* Assign new pixmaps and pictures */ | ||
2873 | 655 | d->pixmap = pixmap; | ||
2874 | 656 | d->buffer_pixmap = buffer_pixmap; | ||
2875 | 657 | d->cr = gdk_cairo_create (pixmap); | ||
2876 | 658 | |||
2877 | 659 | d->picture = picture; | ||
2878 | 660 | |||
2879 | 661 | d->width = width; | ||
2880 | 662 | d->height = height; | ||
2881 | 663 | |||
2882 | 664 | d->prop_xid = wnck_window_get_xid (win); | ||
2883 | 665 | |||
2884 | 666 | update_window_decoration_name (win); | ||
2885 | 667 | |||
2886 | 668 | /* Redraw decoration on idle */ | ||
2887 | 669 | queue_decor_draw (d); | ||
2888 | 670 | |||
2889 | 671 | return TRUE; | ||
2890 | 672 | } | ||
2891 | 673 | |||
2892 | 674 | /* to save some memory, value is specific to current decorations */ | ||
2893 | 675 | #define TRANSLUCENT_CORNER_SIZE 3 | ||
2894 | 676 | |||
2895 | 677 | /* | ||
2896 | 678 | * draw_border_shape | ||
2897 | 679 | * Returns: void | ||
2898 | 680 | * Description: Draws a slight border around the decoration | ||
2899 | 681 | */ | ||
2900 | 682 | static void | ||
2901 | 683 | draw_border_shape (Display *xdisplay, | ||
2902 | 684 | Pixmap pixmap, | ||
2903 | 685 | Picture picture, | ||
2904 | 686 | int width, | ||
2905 | 687 | int height, | ||
2906 | 688 | decor_context_t *c, | ||
2907 | 689 | void *closure) | ||
2908 | 690 | { | ||
2909 | 691 | static XRenderColor white = { 0xffff, 0xffff, 0xffff, 0xffff }; | ||
2910 | 692 | GdkColormap *colormap; | ||
2911 | 693 | decor_t d; | ||
2912 | 694 | decor_shadow_info_t *info = (decor_shadow_info_t *) closure; | ||
2913 | 695 | double save_decoration_alpha; | ||
2914 | 696 | |||
2915 | 697 | memset (&d, 0, sizeof (d)); | ||
2916 | 698 | |||
2917 | 699 | if (info) | ||
2918 | 700 | d.frame = info->frame; | ||
2919 | 701 | else | ||
2920 | 702 | d.frame = gwd_get_decor_frame ("default"); | ||
2921 | 703 | |||
2922 | 704 | d.pixmap = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (), | ||
2923 | 705 | pixmap); | ||
2924 | 706 | d.width = width; | ||
2925 | 707 | d.height = height; | ||
2926 | 708 | d.active = TRUE; | ||
2927 | 709 | d.draw = theme_draw_window_decoration; | ||
2928 | 710 | d.picture = picture; | ||
2929 | 711 | d.context = c; | ||
2930 | 712 | |||
2931 | 713 | /* we use closure argument if maximized */ | ||
2932 | 714 | if (info) | ||
2933 | 715 | d.state = info->state; | ||
2934 | 716 | else | ||
2935 | 717 | d.state = 0; | ||
2936 | 718 | |||
2937 | 719 | decor_get_default_layout (c, 1, 1, &d.border_layout); | ||
2938 | 720 | |||
2939 | 721 | colormap = get_colormap_for_drawable (GDK_DRAWABLE (d.pixmap)); | ||
2940 | 722 | gdk_drawable_set_colormap (d.pixmap, colormap); | ||
2941 | 723 | |||
2942 | 724 | /* create shadow from opaque decoration | ||
2943 | 725 | * FIXME: Should not modify settings value | ||
2944 | 726 | * like this */ | ||
2945 | 727 | save_decoration_alpha = settings->decoration_alpha; | ||
2946 | 728 | settings->decoration_alpha = 1.0; | ||
2947 | 729 | |||
2948 | 730 | (*d.draw) (&d); | ||
2949 | 731 | |||
2950 | 732 | settings->decoration_alpha = save_decoration_alpha; | ||
2951 | 733 | |||
2952 | 734 | XRenderFillRectangle (xdisplay, PictOpSrc, picture, &white, | ||
2953 | 735 | c->left_space, | ||
2954 | 736 | c->top_space, | ||
2955 | 737 | width - c->left_space - c->right_space, | ||
2956 | 738 | height - c->top_space - c->bottom_space); | ||
2957 | 739 | |||
2958 | 740 | if (!info) | ||
2959 | 741 | gwd_decor_frame_unref (d.frame); | ||
2960 | 742 | |||
2961 | 743 | g_object_unref (G_OBJECT (d.pixmap)); | ||
2962 | 744 | } | ||
2963 | 745 | |||
2964 | 746 | |||
2965 | 747 | /* | ||
2966 | 748 | * update_shadow | ||
2967 | 749 | * Returns: 1 for success, 0 for failure | ||
2968 | 750 | * Description: creates a libdecoration shadow context and updates | ||
2969 | 751 | * the decoration context for the shadow for the properties that we | ||
2970 | 752 | * have already read from the root window. | ||
2971 | 753 | * | ||
2972 | 754 | * For the pixmap mode we have opt_shadow which is passed to | ||
2973 | 755 | * decor_shadow_create (which contains the shadow settings from | ||
2974 | 756 | * the root window) | ||
2975 | 757 | * | ||
2976 | 758 | * For the reparenting mode we always enforce a zero-shadow in | ||
2977 | 759 | * the opt_no_shadow passed to decor_shadow_create. | ||
2978 | 760 | * | ||
2979 | 761 | * We do something similar for the maximimzed mode as well | ||
2980 | 762 | */ | ||
2981 | 763 | void | ||
2982 | 764 | bare_frame_update_shadow (Display *xdisplay, | ||
2983 | 765 | Screen *screen, | ||
2984 | 766 | decor_frame_t *frame, | ||
2985 | 767 | decor_shadow_info_t *info, | ||
2986 | 768 | decor_shadow_options_t *opt_shadow, | ||
2987 | 769 | decor_shadow_options_t *opt_no_shadow) | ||
2988 | 770 | { | ||
2989 | 771 | if (frame->border_shadow) | ||
2990 | 772 | { | ||
2991 | 773 | decor_shadow_destroy (xdisplay, frame->border_shadow); | ||
2992 | 774 | frame->border_shadow = NULL; | ||
2993 | 775 | } | ||
2994 | 776 | |||
2995 | 777 | frame->border_shadow = decor_shadow_create (xdisplay, | ||
2996 | 778 | screen, | ||
2997 | 779 | 1, 1, | ||
2998 | 780 | 0, | ||
2999 | 781 | 0, | ||
3000 | 782 | 0, | ||
3001 | 783 | 0, | ||
3002 | 784 | 0, 0, 0, 0, | ||
3003 | 785 | opt_shadow, | ||
3004 | 786 | &frame->window_context, | ||
3005 | 787 | decor_draw_simple, | ||
3006 | 788 | NULL); | ||
3007 | 789 | } | ||
3008 | 790 | |||
3009 | 791 | void | ||
3010 | 792 | switcher_frame_update_shadow (Display *xdisplay, | ||
3011 | 793 | Screen *screen, | ||
3012 | 794 | decor_frame_t *frame, | ||
3013 | 795 | decor_shadow_info_t *info, | ||
3014 | 796 | decor_shadow_options_t *opt_shadow, | ||
3015 | 797 | decor_shadow_options_t *opt_no_shadow) | ||
3016 | 798 | { | ||
3017 | 799 | if (frame->border_shadow) | ||
3018 | 800 | { | ||
3019 | 801 | decor_shadow_destroy (xdisplay, frame->border_shadow); | ||
3020 | 802 | frame->border_shadow = NULL; | ||
3021 | 803 | } | ||
3022 | 804 | |||
3023 | 805 | frame->border_shadow = decor_shadow_create (xdisplay, | ||
3024 | 806 | screen, | ||
3025 | 807 | 1, 1, | ||
3026 | 808 | frame->win_extents.left, | ||
3027 | 809 | frame->win_extents.right, | ||
3028 | 810 | frame->win_extents.top, | ||
3029 | 811 | frame->win_extents.bottom, | ||
3030 | 812 | frame->win_extents.left - | ||
3031 | 813 | TRANSLUCENT_CORNER_SIZE, | ||
3032 | 814 | frame->win_extents.right - | ||
3033 | 815 | TRANSLUCENT_CORNER_SIZE, | ||
3034 | 816 | frame->win_extents.top - | ||
3035 | 817 | TRANSLUCENT_CORNER_SIZE, | ||
3036 | 818 | frame->win_extents.bottom - | ||
3037 | 819 | TRANSLUCENT_CORNER_SIZE, | ||
3038 | 820 | opt_shadow, | ||
3039 | 821 | &frame->window_context, | ||
3040 | 822 | decor_draw_simple, | ||
3041 | 823 | NULL); | ||
3042 | 824 | } | ||
3043 | 825 | |||
3044 | 826 | void | ||
3045 | 827 | decor_frame_update_shadow (Display *xdisplay, | ||
3046 | 828 | Screen *screen, | ||
3047 | 829 | decor_frame_t *frame, | ||
3048 | 830 | decor_shadow_info_t *info, | ||
3049 | 831 | decor_shadow_options_t *opt_shadow, | ||
3050 | 832 | decor_shadow_options_t *opt_no_shadow) | ||
3051 | 833 | { | ||
3052 | 834 | if (frame->border_shadow) | ||
3053 | 835 | { | ||
3054 | 836 | decor_shadow_destroy (xdisplay, frame->border_shadow); | ||
3055 | 837 | frame->border_shadow = NULL; | ||
3056 | 838 | } | ||
3057 | 839 | |||
3058 | 840 | frame->border_shadow = decor_shadow_create (xdisplay, | ||
3059 | 841 | screen, | ||
3060 | 842 | 1, 1, | ||
3061 | 843 | frame->win_extents.left, | ||
3062 | 844 | frame->win_extents.right, | ||
3063 | 845 | frame->win_extents.top + frame->titlebar_height, | ||
3064 | 846 | frame->win_extents.bottom, | ||
3065 | 847 | frame->win_extents.left - | ||
3066 | 848 | TRANSLUCENT_CORNER_SIZE, | ||
3067 | 849 | frame->win_extents.right - | ||
3068 | 850 | TRANSLUCENT_CORNER_SIZE, | ||
3069 | 851 | frame->win_extents.top + frame->titlebar_height - | ||
3070 | 852 | TRANSLUCENT_CORNER_SIZE, | ||
3071 | 853 | frame->win_extents.bottom - | ||
3072 | 854 | TRANSLUCENT_CORNER_SIZE, | ||
3073 | 855 | opt_shadow, | ||
3074 | 856 | &frame->window_context, | ||
3075 | 857 | draw_border_shape, | ||
3076 | 858 | (void *) info); | ||
3077 | 859 | if (frame->border_no_shadow) | ||
3078 | 860 | { | ||
3079 | 861 | decor_shadow_destroy (xdisplay, frame->border_no_shadow); | ||
3080 | 862 | frame->border_no_shadow = NULL; | ||
3081 | 863 | } | ||
3082 | 864 | |||
3083 | 865 | frame->border_no_shadow = decor_shadow_create (xdisplay, | ||
3084 | 866 | screen, | ||
3085 | 867 | 1, 1, | ||
3086 | 868 | frame->win_extents.left, | ||
3087 | 869 | frame->win_extents.right, | ||
3088 | 870 | frame->win_extents.top + frame->titlebar_height, | ||
3089 | 871 | frame->win_extents.bottom, | ||
3090 | 872 | frame->win_extents.left - | ||
3091 | 873 | TRANSLUCENT_CORNER_SIZE, | ||
3092 | 874 | frame->win_extents.right - | ||
3093 | 875 | TRANSLUCENT_CORNER_SIZE, | ||
3094 | 876 | frame->win_extents.top + frame->titlebar_height - | ||
3095 | 877 | TRANSLUCENT_CORNER_SIZE, | ||
3096 | 878 | frame->win_extents.bottom - | ||
3097 | 879 | TRANSLUCENT_CORNER_SIZE, | ||
3098 | 880 | opt_no_shadow, | ||
3099 | 881 | &frame->window_context_no_shadow, | ||
3100 | 882 | draw_border_shape, | ||
3101 | 883 | 0); | ||
3102 | 884 | |||
3103 | 885 | /* Maximized border shadow pixmap mode */ | ||
3104 | 886 | if (frame->max_border_shadow) | ||
3105 | 887 | { | ||
3106 | 888 | decor_shadow_destroy (xdisplay, frame->max_border_shadow); | ||
3107 | 889 | frame->max_border_shadow = NULL; | ||
3108 | 890 | } | ||
3109 | 891 | |||
3110 | 892 | info->state = (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | | ||
3111 | 893 | WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY); | ||
3112 | 894 | |||
3113 | 895 | frame->max_border_shadow = | ||
3114 | 896 | decor_shadow_create (xdisplay, | ||
3115 | 897 | screen, | ||
3116 | 898 | 1, 1, | ||
3117 | 899 | frame->max_win_extents.left, | ||
3118 | 900 | frame->max_win_extents.right, | ||
3119 | 901 | frame->max_win_extents.top + frame->max_titlebar_height, | ||
3120 | 902 | frame->max_win_extents.bottom, | ||
3121 | 903 | frame->max_win_extents.left - TRANSLUCENT_CORNER_SIZE, | ||
3122 | 904 | frame->max_win_extents.right - TRANSLUCENT_CORNER_SIZE, | ||
3123 | 905 | frame->max_win_extents.top + frame->max_titlebar_height - | ||
3124 | 906 | TRANSLUCENT_CORNER_SIZE, | ||
3125 | 907 | frame->max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE, | ||
3126 | 908 | opt_shadow, | ||
3127 | 909 | &frame->max_window_context, | ||
3128 | 910 | draw_border_shape, | ||
3129 | 911 | (void *) info); | ||
3130 | 912 | |||
3131 | 913 | /* Enforced maximize zero shadow reparenting mode */ | ||
3132 | 914 | if (frame->max_border_no_shadow) | ||
3133 | 915 | { | ||
3134 | 916 | decor_shadow_destroy (xdisplay, frame->max_border_shadow); | ||
3135 | 917 | frame->max_border_shadow = NULL; | ||
3136 | 918 | } | ||
3137 | 919 | |||
3138 | 920 | frame->max_border_no_shadow = | ||
3139 | 921 | decor_shadow_create (xdisplay, | ||
3140 | 922 | screen, | ||
3141 | 923 | 1, 1, | ||
3142 | 924 | frame->max_win_extents.left, | ||
3143 | 925 | frame->max_win_extents.right, | ||
3144 | 926 | frame->max_win_extents.top + frame->max_titlebar_height, | ||
3145 | 927 | frame->max_win_extents.bottom, | ||
3146 | 928 | frame->max_win_extents.left - TRANSLUCENT_CORNER_SIZE, | ||
3147 | 929 | frame->max_win_extents.right - TRANSLUCENT_CORNER_SIZE, | ||
3148 | 930 | frame->max_win_extents.top + frame->max_titlebar_height - | ||
3149 | 931 | TRANSLUCENT_CORNER_SIZE, | ||
3150 | 932 | frame->max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE, | ||
3151 | 933 | opt_no_shadow, | ||
3152 | 934 | &frame->max_window_context_no_shadow, | ||
3153 | 935 | draw_border_shape, | ||
3154 | 936 | (void *) info); | ||
3155 | 937 | } | ||
3156 | 938 | |||
3157 | 939 | |||
3158 | 940 | typedef struct _tdtd_shadow_options | ||
3159 | 941 | { | ||
3160 | 942 | decor_shadow_options_t *shadow; | ||
3161 | 943 | decor_shadow_options_t *no_shadow; | ||
3162 | 944 | } tdtd_shadow_options_t; | ||
3163 | 945 | |||
3164 | 946 | void | ||
3165 | 947 | frame_update_shadow (decor_frame_t *frame, | ||
3166 | 948 | decor_shadow_info_t *info, | ||
3167 | 949 | decor_shadow_options_t *opt_shadow, | ||
3168 | 950 | decor_shadow_options_t *opt_no_shadow) | ||
3169 | 951 | { | ||
3170 | 952 | gwd_decor_frame_ref (frame); | ||
3171 | 953 | |||
3172 | 954 | (*frame->update_shadow) (gdk_x11_get_default_xdisplay (), | ||
3173 | 955 | gdk_x11_screen_get_xscreen (gdk_screen_get_default ()), | ||
3174 | 956 | frame, info, opt_shadow, opt_no_shadow); | ||
3175 | 957 | |||
3176 | 958 | gwd_decor_frame_unref (frame); | ||
3177 | 959 | } | ||
3178 | 960 | |||
3179 | 961 | void | ||
3180 | 962 | update_frames_shadows (gpointer key, | ||
3181 | 963 | gpointer value, | ||
3182 | 964 | gpointer user_data) | ||
3183 | 965 | { | ||
3184 | 966 | decor_frame_t *frame = (decor_frame_t *) value; | ||
3185 | 967 | tdtd_shadow_options_t *opts = (tdtd_shadow_options_t *) user_data; | ||
3186 | 968 | |||
3187 | 969 | gwd_decor_frame_ref (frame); | ||
3188 | 970 | |||
3189 | 971 | decor_shadow_info_t *info = malloc (sizeof (decor_shadow_info_t)); | ||
3190 | 972 | |||
3191 | 973 | if (!info) | ||
3192 | 974 | return; | ||
3193 | 975 | |||
3194 | 976 | info->frame = frame; | ||
3195 | 977 | info->state = 0; | ||
3196 | 978 | |||
3197 | 979 | frame_update_shadow (frame, info, opts->shadow, opts->no_shadow); | ||
3198 | 980 | |||
3199 | 981 | gwd_decor_frame_unref (frame); | ||
3200 | 982 | |||
3201 | 983 | free (info); | ||
3202 | 984 | info = NULL; | ||
3203 | 985 | |||
3204 | 986 | } | ||
3205 | 987 | |||
3206 | 988 | int | ||
3207 | 989 | update_shadow (void) | ||
3208 | 990 | { | ||
3209 | 991 | decor_shadow_options_t opt_shadow; | ||
3210 | 992 | decor_shadow_options_t opt_no_shadow; | ||
3211 | 993 | tdtd_shadow_options_t *opts; | ||
3212 | 994 | |||
3213 | 995 | opts = malloc (sizeof (tdtd_shadow_options_t)); | ||
3214 | 996 | |||
3215 | 997 | if (!opts) | ||
3216 | 998 | return 0; | ||
3217 | 999 | |||
3218 | 1000 | opt_shadow.shadow_radius = settings->shadow_radius; | ||
3219 | 1001 | opt_shadow.shadow_opacity = settings->shadow_opacity; | ||
3220 | 1002 | |||
3221 | 1003 | memcpy (opt_shadow.shadow_color, settings->shadow_color, sizeof (settings->shadow_color)); | ||
3222 | 1004 | |||
3223 | 1005 | opt_shadow.shadow_offset_x = settings->shadow_offset_x; | ||
3224 | 1006 | opt_shadow.shadow_offset_y = settings->shadow_offset_y; | ||
3225 | 1007 | |||
3226 | 1008 | opt_no_shadow.shadow_radius = 0; | ||
3227 | 1009 | opt_no_shadow.shadow_opacity = 0; | ||
3228 | 1010 | |||
3229 | 1011 | opt_no_shadow.shadow_offset_x = 0; | ||
3230 | 1012 | opt_no_shadow.shadow_offset_y = 0; | ||
3231 | 1013 | |||
3232 | 1014 | opts->shadow = &opt_shadow; | ||
3233 | 1015 | opts->no_shadow = &opt_no_shadow; | ||
3234 | 1016 | |||
3235 | 1017 | gwd_frames_foreach (update_frames_shadows, (gpointer ) opts); | ||
3236 | 1018 | |||
3237 | 1019 | if (opts) | ||
3238 | 1020 | free (opts); | ||
3239 | 1021 | |||
3240 | 1022 | return 1; | ||
3241 | 1023 | } | ||
3242 | 1024 | |||
3243 | 1025 | /* | ||
3244 | 1026 | * update_window_decoration | ||
3245 | 1027 | * | ||
3246 | 1028 | * Returns: void | ||
3247 | 1029 | * Description: The master function to update the window decoration | ||
3248 | 1030 | * if the pixmap needs to be redrawn | ||
3249 | 1031 | */ | ||
3250 | 1032 | void | ||
3251 | 1033 | update_window_decoration (WnckWindow *win) | ||
3252 | 1034 | { | ||
3253 | 1035 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3254 | 1036 | |||
3255 | 1037 | if (d->decorated) | ||
3256 | 1038 | { | ||
3257 | 1039 | /* force size update */ | ||
3258 | 1040 | d->context = NULL; | ||
3259 | 1041 | d->width = d->height = 0; | ||
3260 | 1042 | |||
3261 | 1043 | update_window_decoration_size (win); | ||
3262 | 1044 | update_event_windows (win); | ||
3263 | 1045 | } | ||
3264 | 1046 | } | ||
3265 | 1047 | |||
3266 | 1048 | /* | ||
3267 | 1049 | * update_window_decoration_state | ||
3268 | 1050 | * | ||
3269 | 1051 | * Returns: void | ||
3270 | 1052 | * Description: helper function to update the state of the decor_t | ||
3271 | 1053 | */ | ||
3272 | 1054 | void | ||
3273 | 1055 | update_window_decoration_state (WnckWindow *win) | ||
3274 | 1056 | { | ||
3275 | 1057 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3276 | 1058 | |||
3277 | 1059 | d->state = wnck_window_get_state (win); | ||
3278 | 1060 | } | ||
3279 | 1061 | |||
3280 | 1062 | /* | ||
3281 | 1063 | * update_window_decoration_actions | ||
3282 | 1064 | * | ||
3283 | 1065 | * Returns: void | ||
3284 | 1066 | * Description: helper function to update the actions of the decor_t | ||
3285 | 1067 | */ | ||
3286 | 1068 | void | ||
3287 | 1069 | update_window_decoration_actions (WnckWindow *win) | ||
3288 | 1070 | { | ||
3289 | 1071 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3290 | 1072 | |||
3291 | 1073 | d->actions = wnck_window_get_actions (win); | ||
3292 | 1074 | } | ||
3293 | 1075 | |||
3294 | 1076 | |||
3295 | 1077 | /* | ||
3296 | 1078 | * draw_decor_list | ||
3297 | 1079 | * | ||
3298 | 1080 | * Returns: bool | ||
3299 | 1081 | * Description: function to be called on g_idle_add to draw window | ||
3300 | 1082 | * decorations when we are not doing anything | ||
3301 | 1083 | */ | ||
3302 | 1084 | static gboolean | ||
3303 | 1085 | draw_decor_list (void *data) | ||
3304 | 1086 | { | ||
3305 | 1087 | GSList *list; | ||
3306 | 1088 | decor_t *d; | ||
3307 | 1089 | |||
3308 | 1090 | draw_idle_id = 0; | ||
3309 | 1091 | |||
3310 | 1092 | for (list = draw_list; list; list = list->next) | ||
3311 | 1093 | { | ||
3312 | 1094 | d = (decor_t *) list->data; | ||
3313 | 1095 | (*d->draw) (d); | ||
3314 | 1096 | } | ||
3315 | 1097 | |||
3316 | 1098 | g_slist_free (draw_list); | ||
3317 | 1099 | draw_list = NULL; | ||
3318 | 1100 | |||
3319 | 1101 | return FALSE; | ||
3320 | 1102 | } | ||
3321 | 1103 | |||
3322 | 1104 | /* | ||
3323 | 1105 | * queue_decor_draw | ||
3324 | 1106 | * | ||
3325 | 1107 | * Description :queue a redraw request for this decoration. Since this function | ||
3326 | 1108 | * only gets called on idle, don't redraw window decorations multiple | ||
3327 | 1109 | * times if they are already waiting to be drawn (since the drawn copy | ||
3328 | 1110 | * will always be the most updated one) | ||
3329 | 1111 | */ | ||
3330 | 1112 | void | ||
3331 | 1113 | queue_decor_draw (decor_t *d) | ||
3332 | 1114 | { | ||
3333 | 1115 | if (g_slist_find (draw_list, d)) | ||
3334 | 1116 | return; | ||
3335 | 1117 | |||
3336 | 1118 | draw_list = g_slist_append (draw_list, d); | ||
3337 | 1119 | |||
3338 | 1120 | if (!draw_idle_id) | ||
3339 | 1121 | draw_idle_id = g_idle_add (draw_decor_list, NULL); | ||
3340 | 1122 | } | ||
3341 | 1123 | |||
3342 | 1124 | /* | ||
3343 | 1125 | * update_default_decorations | ||
3344 | 1126 | * | ||
3345 | 1127 | * Description: update the default decorations | ||
3346 | 1128 | */ | ||
3347 | 1129 | void | ||
3348 | 1130 | update_default_decorations (GdkScreen *screen) | ||
3349 | 1131 | { | ||
3350 | 1132 | long data[256]; | ||
3351 | 1133 | Window xroot; | ||
3352 | 1134 | GdkDisplay *gdkdisplay = gdk_display_get_default (); | ||
3353 | 1135 | Display *xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay); | ||
3354 | 1136 | Atom bareAtom, normalAtom, activeAtom; | ||
3355 | 1137 | decor_t d; | ||
3356 | 1138 | gint nQuad; | ||
3357 | 1139 | decor_quad_t quads[N_QUADS_MAX]; | ||
3358 | 1140 | decor_frame_t *frame; | ||
3359 | 1141 | decor_frame_t *bare_frame = gwd_get_decor_frame ("bare"); | ||
3360 | 1142 | decor_extents_t extents; | ||
3361 | 1143 | |||
3362 | 1144 | xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); | ||
3363 | 1145 | |||
3364 | 1146 | bareAtom = XInternAtom (xdisplay, DECOR_BARE_ATOM_NAME, FALSE); | ||
3365 | 1147 | normalAtom = XInternAtom (xdisplay, DECOR_NORMAL_ATOM_NAME, FALSE); | ||
3366 | 1148 | activeAtom = XInternAtom (xdisplay, DECOR_ACTIVE_ATOM_NAME, FALSE); | ||
3367 | 1149 | |||
3368 | 1150 | if (bare_frame->border_shadow) | ||
3369 | 1151 | { | ||
3370 | 1152 | decor_layout_t layout; | ||
3371 | 1153 | |||
3372 | 1154 | decor_get_default_layout (&bare_frame->window_context, 1, 1, &layout); | ||
3373 | 1155 | |||
3374 | 1156 | nQuad = decor_set_lSrStSbS_window_quads (quads, &bare_frame->window_context, | ||
3375 | 1157 | &layout); | ||
3376 | 1158 | |||
3377 | 1159 | decor_quads_to_property (data, bare_frame->border_shadow->pixmap, | ||
3378 | 1160 | &bare_frame->win_extents, &bare_frame->win_extents, | ||
3379 | 1161 | &bare_frame->win_extents, &bare_frame->win_extents, | ||
3380 | 1162 | 0, 0, quads, nQuad); | ||
3381 | 1163 | |||
3382 | 1164 | XChangeProperty (xdisplay, xroot, | ||
3383 | 1165 | bareAtom, | ||
3384 | 1166 | XA_INTEGER, | ||
3385 | 1167 | 32, PropModeReplace, (guchar *) data, | ||
3386 | 1168 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3387 | 1169 | |||
3388 | 1170 | if (minimal) | ||
3389 | 1171 | { | ||
3390 | 1172 | XChangeProperty (xdisplay, xroot, | ||
3391 | 1173 | normalAtom, | ||
3392 | 1174 | XA_INTEGER, | ||
3393 | 1175 | 32, PropModeReplace, (guchar *) data, | ||
3394 | 1176 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3395 | 1177 | XChangeProperty (xdisplay, xroot, | ||
3396 | 1178 | activeAtom, | ||
3397 | 1179 | XA_INTEGER, | ||
3398 | 1180 | 32, PropModeReplace, (guchar *) data, | ||
3399 | 1181 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3400 | 1182 | } | ||
3401 | 1183 | } | ||
3402 | 1184 | else | ||
3403 | 1185 | { | ||
3404 | 1186 | XDeleteProperty (xdisplay, xroot, bareAtom); | ||
3405 | 1187 | |||
3406 | 1188 | if (minimal) | ||
3407 | 1189 | { | ||
3408 | 1190 | XDeleteProperty (xdisplay, xroot, normalAtom); | ||
3409 | 1191 | XDeleteProperty (xdisplay, xroot, activeAtom); | ||
3410 | 1192 | } | ||
3411 | 1193 | } | ||
3412 | 1194 | |||
3413 | 1195 | if (minimal) | ||
3414 | 1196 | { | ||
3415 | 1197 | gwd_decor_frame_unref (bare_frame); | ||
3416 | 1198 | return; | ||
3417 | 1199 | } | ||
3418 | 1200 | |||
3419 | 1201 | memset (&d, 0, sizeof (d)); | ||
3420 | 1202 | |||
3421 | 1203 | frame = gwd_get_decor_frame ("default"); | ||
3422 | 1204 | extents = frame->win_extents; | ||
3423 | 1205 | |||
3424 | 1206 | d.context = &frame->window_context; | ||
3425 | 1207 | d.shadow = frame->border_shadow; | ||
3426 | 1208 | d.layout = pango_layout_new (frame->pango_context); | ||
3427 | 1209 | |||
3428 | 1210 | decor_get_default_layout (d.context, 1, 1, &d.border_layout); | ||
3429 | 1211 | |||
3430 | 1212 | d.width = d.border_layout.width; | ||
3431 | 1213 | d.height = d.border_layout.height; | ||
3432 | 1214 | |||
3433 | 1215 | d.frame = frame; | ||
3434 | 1216 | |||
3435 | 1217 | extents.top += frame->titlebar_height; | ||
3436 | 1218 | |||
3437 | 1219 | d.draw = theme_draw_window_decoration; | ||
3438 | 1220 | |||
3439 | 1221 | if (decor_normal_pixmap) | ||
3440 | 1222 | g_object_unref (G_OBJECT (decor_normal_pixmap)); | ||
3441 | 1223 | |||
3442 | 1224 | nQuad = decor_set_lSrStSbS_window_quads (quads, d.context, | ||
3443 | 1225 | &d.border_layout); | ||
3444 | 1226 | |||
3445 | 1227 | decor_normal_pixmap = create_pixmap (d.width, d.height, frame->style_window_rgba); | ||
3446 | 1228 | |||
3447 | 1229 | if (decor_normal_pixmap) | ||
3448 | 1230 | { | ||
3449 | 1231 | d.pixmap = decor_normal_pixmap; | ||
3450 | 1232 | d.active = FALSE; | ||
3451 | 1233 | d.picture = XRenderCreatePicture (xdisplay, | ||
3452 | 1234 | GDK_PIXMAP_XID (d.pixmap), | ||
3453 | 1235 | xformat_rgba, 0, NULL); | ||
3454 | 1236 | |||
3455 | 1237 | (*d.draw) (&d); | ||
3456 | 1238 | |||
3457 | 1239 | XRenderFreePicture (xdisplay, d.picture); | ||
3458 | 1240 | |||
3459 | 1241 | decor_quads_to_property (data, GDK_PIXMAP_XID (d.pixmap), | ||
3460 | 1242 | &extents, &extents, | ||
3461 | 1243 | &extents, &extents, 0, 0, quads, nQuad); | ||
3462 | 1244 | |||
3463 | 1245 | XChangeProperty (xdisplay, xroot, | ||
3464 | 1246 | normalAtom, | ||
3465 | 1247 | XA_INTEGER, | ||
3466 | 1248 | 32, PropModeReplace, (guchar *) data, | ||
3467 | 1249 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3468 | 1250 | } | ||
3469 | 1251 | |||
3470 | 1252 | if (decor_active_pixmap) | ||
3471 | 1253 | g_object_unref (G_OBJECT (decor_active_pixmap)); | ||
3472 | 1254 | |||
3473 | 1255 | decor_active_pixmap = create_pixmap (d.width, d.height, frame->style_window_rgba); | ||
3474 | 1256 | |||
3475 | 1257 | if (decor_active_pixmap) | ||
3476 | 1258 | { | ||
3477 | 1259 | d.pixmap = decor_active_pixmap; | ||
3478 | 1260 | d.active = TRUE; | ||
3479 | 1261 | d.picture = XRenderCreatePicture (xdisplay, | ||
3480 | 1262 | GDK_PIXMAP_XID (d.pixmap), | ||
3481 | 1263 | xformat_rgba, 0, NULL); | ||
3482 | 1264 | |||
3483 | 1265 | (*d.draw) (&d); | ||
3484 | 1266 | |||
3485 | 1267 | XRenderFreePicture (xdisplay, d.picture); | ||
3486 | 1268 | |||
3487 | 1269 | decor_quads_to_property (data, GDK_PIXMAP_XID (d.pixmap), | ||
3488 | 1270 | &extents, &extents, | ||
3489 | 1271 | &extents, &extents, 0, 0, quads, nQuad); | ||
3490 | 1272 | |||
3491 | 1273 | XChangeProperty (xdisplay, xroot, | ||
3492 | 1274 | activeAtom, | ||
3493 | 1275 | XA_INTEGER, | ||
3494 | 1276 | 32, PropModeReplace, (guchar *) data, | ||
3495 | 1277 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3496 | 1278 | } | ||
3497 | 1279 | |||
3498 | 1280 | gwd_decor_frame_unref (frame); | ||
3499 | 1281 | gwd_decor_frame_unref (bare_frame); | ||
3500 | 1282 | |||
3501 | 1283 | if (d.layout) | ||
3502 | 1284 | g_object_unref (G_OBJECT (d.layout)); | ||
3503 | 1285 | } | ||
3504 | 1286 | |||
3505 | 1287 | /* | ||
3506 | 1288 | * copy_to_front_buffer | ||
3507 | 1289 | * | ||
3508 | 1290 | * Description: Helper function to copy the buffer pixmap to a front buffer | ||
3509 | 1291 | */ | ||
3510 | 1292 | void | ||
3511 | 1293 | copy_to_front_buffer (decor_t *d) | ||
3512 | 1294 | { | ||
3513 | 1295 | if (!d->buffer_pixmap) | ||
3514 | 1296 | return; | ||
3515 | 1297 | |||
3516 | 1298 | cairo_set_operator (d->cr, CAIRO_OPERATOR_SOURCE); | ||
3517 | 1299 | gdk_cairo_set_source_pixmap (d->cr, d->buffer_pixmap, 0, 0); | ||
3518 | 1300 | cairo_paint (d->cr); | ||
3519 | 1301 | } | ||
3520 | 0 | 1302 | ||
3521 | === renamed file 'gtk/window-decorator/decorator.c' => 'gtk/window-decorator/decorator.c.THIS' | |||
3522 | === added file 'gtk/window-decorator/decorprops.c' | |||
3523 | --- gtk/window-decorator/decorprops.c 1970-01-01 00:00:00 +0000 | |||
3524 | +++ gtk/window-decorator/decorprops.c 2012-02-08 18:50:27 +0000 | |||
3525 | @@ -0,0 +1,161 @@ | |||
3526 | 1 | /* | ||
3527 | 2 | * Copyright © 2006 Novell, Inc. | ||
3528 | 3 | * | ||
3529 | 4 | * This library is free software; you can redistribute it and/or | ||
3530 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
3531 | 6 | * License as published by the Free Software Foundation; either | ||
3532 | 7 | * version 2 of the License, or (at your option) any later version. | ||
3533 | 8 | * | ||
3534 | 9 | * This library is distributed in the hope that it will be useful, | ||
3535 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3536 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
3537 | 12 | * Lesser General Public License for more details. | ||
3538 | 13 | * | ||
3539 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
3540 | 15 | * License along with this library; if not, write to the | ||
3541 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
3542 | 17 | * Boston, MA 02111-1307, USA. | ||
3543 | 18 | * | ||
3544 | 19 | * Author: David Reveman <davidr@novell.com> | ||
3545 | 20 | * | ||
3546 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
3547 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
3548 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
3549 | 24 | */ | ||
3550 | 25 | |||
3551 | 26 | #include "gtk-window-decorator.h" | ||
3552 | 27 | |||
3553 | 28 | void | ||
3554 | 29 | decor_update_window_property (decor_t *d) | ||
3555 | 30 | { | ||
3556 | 31 | long data[256]; | ||
3557 | 32 | Display *xdisplay = | ||
3558 | 33 | GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
3559 | 34 | decor_extents_t extents = d->frame->win_extents; | ||
3560 | 35 | gint nQuad; | ||
3561 | 36 | decor_quad_t quads[N_QUADS_MAX]; | ||
3562 | 37 | int w, h; | ||
3563 | 38 | gint stretch_offset; | ||
3564 | 39 | REGION top, bottom, left, right; | ||
3565 | 40 | |||
3566 | 41 | w = d->border_layout.top.x2 - d->border_layout.top.x1 - | ||
3567 | 42 | d->context->left_space - d->context->right_space; | ||
3568 | 43 | |||
3569 | 44 | if (d->border_layout.rotation) | ||
3570 | 45 | h = d->border_layout.left.x2 - d->border_layout.left.x1; | ||
3571 | 46 | else | ||
3572 | 47 | h = d->border_layout.left.y2 - d->border_layout.left.y1; | ||
3573 | 48 | |||
3574 | 49 | stretch_offset = w - d->button_width - 1; | ||
3575 | 50 | |||
3576 | 51 | nQuad = decor_set_lSrStXbS_window_quads (quads, d->context, | ||
3577 | 52 | &d->border_layout, | ||
3578 | 53 | stretch_offset); | ||
3579 | 54 | |||
3580 | 55 | extents.top += d->frame->titlebar_height; | ||
3581 | 56 | |||
3582 | 57 | if (d->frame_window) | ||
3583 | 58 | { | ||
3584 | 59 | decor_gen_window_property (data, &extents, &extents, 20, 20); | ||
3585 | 60 | } | ||
3586 | 61 | else | ||
3587 | 62 | { | ||
3588 | 63 | decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap), | ||
3589 | 64 | &extents, &extents, | ||
3590 | 65 | &extents, &extents, | ||
3591 | 66 | ICON_SPACE + d->button_width, | ||
3592 | 67 | 0, | ||
3593 | 68 | quads, nQuad); | ||
3594 | 69 | } | ||
3595 | 70 | |||
3596 | 71 | gdk_error_trap_push (); | ||
3597 | 72 | XChangeProperty (xdisplay, d->prop_xid, | ||
3598 | 73 | win_decor_atom, | ||
3599 | 74 | XA_INTEGER, | ||
3600 | 75 | 32, PropModeReplace, (guchar *) data, | ||
3601 | 76 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3602 | 77 | gdk_display_sync (gdk_display_get_default ()); | ||
3603 | 78 | gdk_error_trap_pop (); | ||
3604 | 79 | |||
3605 | 80 | top.rects = &top.extents; | ||
3606 | 81 | top.numRects = top.size = 1; | ||
3607 | 82 | |||
3608 | 83 | top.extents.x1 = -extents.left; | ||
3609 | 84 | top.extents.y1 = -extents.top; | ||
3610 | 85 | top.extents.x2 = w + extents.right; | ||
3611 | 86 | top.extents.y2 = 0; | ||
3612 | 87 | |||
3613 | 88 | bottom.rects = &bottom.extents; | ||
3614 | 89 | bottom.numRects = bottom.size = 1; | ||
3615 | 90 | |||
3616 | 91 | bottom.extents.x1 = -extents.left; | ||
3617 | 92 | bottom.extents.y1 = 0; | ||
3618 | 93 | bottom.extents.x2 = w + extents.right; | ||
3619 | 94 | bottom.extents.y2 = extents.bottom; | ||
3620 | 95 | |||
3621 | 96 | left.rects = &left.extents; | ||
3622 | 97 | left.numRects = left.size = 1; | ||
3623 | 98 | |||
3624 | 99 | left.extents.x1 = -extents.left; | ||
3625 | 100 | left.extents.y1 = 0; | ||
3626 | 101 | left.extents.x2 = 0; | ||
3627 | 102 | left.extents.y2 = h; | ||
3628 | 103 | |||
3629 | 104 | right.rects = &right.extents; | ||
3630 | 105 | right.numRects = right.size = 1; | ||
3631 | 106 | |||
3632 | 107 | right.extents.x1 = 0; | ||
3633 | 108 | right.extents.y1 = 0; | ||
3634 | 109 | right.extents.x2 = extents.right; | ||
3635 | 110 | right.extents.y2 = h; | ||
3636 | 111 | |||
3637 | 112 | decor_update_blur_property (d, | ||
3638 | 113 | w, h, | ||
3639 | 114 | &top, stretch_offset, | ||
3640 | 115 | &bottom, w / 2, | ||
3641 | 116 | &left, h / 2, | ||
3642 | 117 | &right, h / 2); | ||
3643 | 118 | } | ||
3644 | 119 | |||
3645 | 120 | void | ||
3646 | 121 | decor_update_switcher_property (decor_t *d) | ||
3647 | 122 | { | ||
3648 | 123 | long data[256]; | ||
3649 | 124 | Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | ||
3650 | 125 | gint nQuad; | ||
3651 | 126 | decor_quad_t quads[N_QUADS_MAX]; | ||
3652 | 127 | GtkStyle *style; | ||
3653 | 128 | long fgColor[4]; | ||
3654 | 129 | |||
3655 | 130 | nQuad = decor_set_lSrStSbX_window_quads (quads, &d->frame->window_context, | ||
3656 | 131 | &d->border_layout, | ||
3657 | 132 | d->border_layout.top.x2 - | ||
3658 | 133 | d->border_layout.top.x1 - | ||
3659 | 134 | d->frame->window_context.extents.left - | ||
3660 | 135 | d->frame->window_context.extents.right - | ||
3661 | 136 | 32); | ||
3662 | 137 | |||
3663 | 138 | decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap), | ||
3664 | 139 | &d->frame->win_extents, &d->frame->win_extents, | ||
3665 | 140 | &d->frame->win_extents, &d->frame->win_extents, | ||
3666 | 141 | 0, 0, quads, nQuad); | ||
3667 | 142 | |||
3668 | 143 | style = gtk_widget_get_style (d->frame->style_window_rgba); | ||
3669 | 144 | |||
3670 | 145 | fgColor[0] = style->fg[GTK_STATE_NORMAL].red; | ||
3671 | 146 | fgColor[1] = style->fg[GTK_STATE_NORMAL].green; | ||
3672 | 147 | fgColor[2] = style->fg[GTK_STATE_NORMAL].blue; | ||
3673 | 148 | fgColor[3] = SWITCHER_ALPHA; | ||
3674 | 149 | |||
3675 | 150 | gdk_error_trap_push (); | ||
3676 | 151 | XChangeProperty (xdisplay, d->prop_xid, | ||
3677 | 152 | win_decor_atom, | ||
3678 | 153 | XA_INTEGER, | ||
3679 | 154 | 32, PropModeReplace, (guchar *) data, | ||
3680 | 155 | BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad); | ||
3681 | 156 | XChangeProperty (xdisplay, d->prop_xid, switcher_fg_atom, | ||
3682 | 157 | XA_INTEGER, 32, PropModeReplace, (guchar *) fgColor, 4); | ||
3683 | 158 | gdk_display_sync (gdk_display_get_default ()); | ||
3684 | 159 | gdk_error_trap_pop (); | ||
3685 | 160 | |||
3686 | 161 | } | ||
3687 | 0 | 162 | ||
3688 | === renamed file 'gtk/window-decorator/decorprops.c' => 'gtk/window-decorator/decorprops.c.THIS' | |||
3689 | === added file 'gtk/window-decorator/events.c' | |||
3690 | --- gtk/window-decorator/events.c 1970-01-01 00:00:00 +0000 | |||
3691 | +++ gtk/window-decorator/events.c 2012-02-08 18:50:27 +0000 | |||
3692 | @@ -0,0 +1,1177 @@ | |||
3693 | 1 | /* | ||
3694 | 2 | * Copyright © 2006 Novell, Inc. | ||
3695 | 3 | * | ||
3696 | 4 | * This library is free software; you can redistribute it and/or | ||
3697 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
3698 | 6 | * License as published by the Free Software Foundation; either | ||
3699 | 7 | * version 2 of the License, or (at your option) any later version. | ||
3700 | 8 | * | ||
3701 | 9 | * This library is distributed in the hope that it will be useful, | ||
3702 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3703 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
3704 | 12 | * Lesser General Public License for more details. | ||
3705 | 13 | * | ||
3706 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
3707 | 15 | * License along with this library; if not, write to the | ||
3708 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
3709 | 17 | * Boston, MA 02111-1307, USA. | ||
3710 | 18 | * | ||
3711 | 19 | * Author: David Reveman <davidr@novell.com> | ||
3712 | 20 | * | ||
3713 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
3714 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
3715 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
3716 | 24 | */ | ||
3717 | 25 | |||
3718 | 26 | #include "gtk-window-decorator.h" | ||
3719 | 27 | |||
3720 | 28 | void | ||
3721 | 29 | move_resize_window (WnckWindow *win, | ||
3722 | 30 | int direction, | ||
3723 | 31 | decor_event *gtkwd_event) | ||
3724 | 32 | { | ||
3725 | 33 | Display *xdisplay; | ||
3726 | 34 | GdkDisplay *gdkdisplay; | ||
3727 | 35 | GdkScreen *screen; | ||
3728 | 36 | Window xroot; | ||
3729 | 37 | XEvent ev; | ||
3730 | 38 | |||
3731 | 39 | gdkdisplay = gdk_display_get_default (); | ||
3732 | 40 | xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay); | ||
3733 | 41 | screen = gdk_display_get_default_screen (gdkdisplay); | ||
3734 | 42 | xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); | ||
3735 | 43 | |||
3736 | 44 | if (action_menu_mapped) | ||
3737 | 45 | { | ||
3738 | 46 | gtk_object_destroy (GTK_OBJECT (action_menu)); | ||
3739 | 47 | action_menu_mapped = FALSE; | ||
3740 | 48 | action_menu = NULL; | ||
3741 | 49 | return; | ||
3742 | 50 | } | ||
3743 | 51 | |||
3744 | 52 | ev.xclient.type = ClientMessage; | ||
3745 | 53 | ev.xclient.display = xdisplay; | ||
3746 | 54 | |||
3747 | 55 | ev.xclient.serial = 0; | ||
3748 | 56 | ev.xclient.send_event = TRUE; | ||
3749 | 57 | |||
3750 | 58 | ev.xclient.window = wnck_window_get_xid (win); | ||
3751 | 59 | ev.xclient.message_type = wm_move_resize_atom; | ||
3752 | 60 | ev.xclient.format = 32; | ||
3753 | 61 | |||
3754 | 62 | ev.xclient.data.l[0] = gtkwd_event->x_root; | ||
3755 | 63 | ev.xclient.data.l[1] = gtkwd_event->y_root; | ||
3756 | 64 | ev.xclient.data.l[2] = direction; | ||
3757 | 65 | ev.xclient.data.l[3] = gtkwd_event->button; | ||
3758 | 66 | ev.xclient.data.l[4] = 1; | ||
3759 | 67 | |||
3760 | 68 | XUngrabPointer (xdisplay, gtkwd_event->time); | ||
3761 | 69 | XUngrabKeyboard (xdisplay, gtkwd_event->time); | ||
3762 | 70 | |||
3763 | 71 | XSendEvent (xdisplay, xroot, FALSE, | ||
3764 | 72 | SubstructureRedirectMask | SubstructureNotifyMask, | ||
3765 | 73 | &ev); | ||
3766 | 74 | |||
3767 | 75 | XSync (xdisplay, FALSE); | ||
3768 | 76 | } | ||
3769 | 77 | |||
3770 | 78 | void | ||
3771 | 79 | common_button_event (WnckWindow *win, | ||
3772 | 80 | decor_event *gtkwd_event, | ||
3773 | 81 | decor_event_type gtkwd_type, | ||
3774 | 82 | int button, | ||
3775 | 83 | int max, | ||
3776 | 84 | char *tooltip) | ||
3777 | 85 | { | ||
3778 | 86 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3779 | 87 | guint state = d->button_states[button]; | ||
3780 | 88 | |||
3781 | 89 | handle_tooltip_event (win, gtkwd_event, gtkwd_type, state, tooltip); | ||
3782 | 90 | |||
3783 | 91 | if (d->frame_window && gtkwd_type == GEnterNotify) | ||
3784 | 92 | { | ||
3785 | 93 | GdkCursor* cursor; | ||
3786 | 94 | cursor = gdk_cursor_new (GDK_LEFT_PTR); | ||
3787 | 95 | gdk_window_set_cursor (d->frame_window, cursor); | ||
3788 | 96 | gdk_cursor_unref (cursor); | ||
3789 | 97 | } | ||
3790 | 98 | |||
3791 | 99 | switch (gtkwd_type) { | ||
3792 | 100 | case GButtonPress: | ||
3793 | 101 | if (gtkwd_event->button <= max) | ||
3794 | 102 | d->button_states[button] |= PRESSED_EVENT_WINDOW; | ||
3795 | 103 | break; | ||
3796 | 104 | case GButtonRelease: | ||
3797 | 105 | if (gtkwd_event->button <= max) | ||
3798 | 106 | d->button_states[button] &= ~PRESSED_EVENT_WINDOW; | ||
3799 | 107 | break; | ||
3800 | 108 | case GEnterNotify: | ||
3801 | 109 | d->button_states[button] |= IN_EVENT_WINDOW; | ||
3802 | 110 | break; | ||
3803 | 111 | case GLeaveNotify: | ||
3804 | 112 | d->button_states[button] &= ~IN_EVENT_WINDOW; | ||
3805 | 113 | break; | ||
3806 | 114 | default: | ||
3807 | 115 | break; | ||
3808 | 116 | } | ||
3809 | 117 | |||
3810 | 118 | if (state != d->button_states[button]) | ||
3811 | 119 | queue_decor_draw (d); | ||
3812 | 120 | } | ||
3813 | 121 | |||
3814 | 122 | #define BUTTON_EVENT_ACTION_STATE (PRESSED_EVENT_WINDOW | IN_EVENT_WINDOW) | ||
3815 | 123 | |||
3816 | 124 | void | ||
3817 | 125 | close_button_event (WnckWindow *win, | ||
3818 | 126 | decor_event *gtkwd_event, | ||
3819 | 127 | decor_event_type gtkwd_type) | ||
3820 | 128 | { | ||
3821 | 129 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3822 | 130 | guint state = d->button_states[BUTTON_CLOSE]; | ||
3823 | 131 | |||
3824 | 132 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
3825 | 133 | BUTTON_CLOSE, 1, _("Close Window")); | ||
3826 | 134 | |||
3827 | 135 | switch (gtkwd_type) { | ||
3828 | 136 | case GButtonRelease: | ||
3829 | 137 | if (gtkwd_event->button == 1) | ||
3830 | 138 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
3831 | 139 | wnck_window_close (win, gtkwd_event->time); | ||
3832 | 140 | break; | ||
3833 | 141 | default: | ||
3834 | 142 | break; | ||
3835 | 143 | } | ||
3836 | 144 | } | ||
3837 | 145 | |||
3838 | 146 | void | ||
3839 | 147 | max_button_event (WnckWindow *win, | ||
3840 | 148 | decor_event *gtkwd_event, | ||
3841 | 149 | decor_event_type gtkwd_type) | ||
3842 | 150 | { | ||
3843 | 151 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3844 | 152 | guint state = d->button_states[BUTTON_MAX]; | ||
3845 | 153 | |||
3846 | 154 | if (wnck_window_is_maximized (win)) | ||
3847 | 155 | common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX, | ||
3848 | 156 | 3, _("Unmaximize Window")); | ||
3849 | 157 | else | ||
3850 | 158 | common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX, | ||
3851 | 159 | 3, _("Maximize Window")); | ||
3852 | 160 | |||
3853 | 161 | switch (gtkwd_type) { | ||
3854 | 162 | case GButtonRelease: | ||
3855 | 163 | if (gtkwd_event->button <= 3) | ||
3856 | 164 | { | ||
3857 | 165 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
3858 | 166 | { | ||
3859 | 167 | if (gtkwd_event->button == 2) | ||
3860 | 168 | { | ||
3861 | 169 | if (wnck_window_is_maximized_vertically (win)) | ||
3862 | 170 | wnck_window_unmaximize_vertically (win); | ||
3863 | 171 | else | ||
3864 | 172 | wnck_window_maximize_vertically (win); | ||
3865 | 173 | } | ||
3866 | 174 | else if (gtkwd_event->button == 3) | ||
3867 | 175 | { | ||
3868 | 176 | if (wnck_window_is_maximized_horizontally (win)) | ||
3869 | 177 | wnck_window_unmaximize_horizontally (win); | ||
3870 | 178 | else | ||
3871 | 179 | wnck_window_maximize_horizontally (win); | ||
3872 | 180 | } | ||
3873 | 181 | else | ||
3874 | 182 | { | ||
3875 | 183 | if (wnck_window_is_maximized (win)) | ||
3876 | 184 | wnck_window_unmaximize (win); | ||
3877 | 185 | else | ||
3878 | 186 | wnck_window_maximize (win); | ||
3879 | 187 | } | ||
3880 | 188 | } | ||
3881 | 189 | } | ||
3882 | 190 | break; | ||
3883 | 191 | default: | ||
3884 | 192 | break; | ||
3885 | 193 | } | ||
3886 | 194 | } | ||
3887 | 195 | |||
3888 | 196 | void | ||
3889 | 197 | min_button_event (WnckWindow *win, | ||
3890 | 198 | decor_event *gtkwd_event, | ||
3891 | 199 | decor_event_type gtkwd_type) | ||
3892 | 200 | { | ||
3893 | 201 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3894 | 202 | guint state = d->button_states[BUTTON_MIN]; | ||
3895 | 203 | |||
3896 | 204 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
3897 | 205 | BUTTON_MIN, 1, _("Minimize Window")); | ||
3898 | 206 | |||
3899 | 207 | switch (gtkwd_type) { | ||
3900 | 208 | case GButtonRelease: | ||
3901 | 209 | if (gtkwd_event->button == 1) | ||
3902 | 210 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
3903 | 211 | wnck_window_minimize (win); | ||
3904 | 212 | break; | ||
3905 | 213 | default: | ||
3906 | 214 | break; | ||
3907 | 215 | } | ||
3908 | 216 | } | ||
3909 | 217 | |||
3910 | 218 | void | ||
3911 | 219 | menu_button_event (WnckWindow *win, | ||
3912 | 220 | decor_event *gtkwd_event, | ||
3913 | 221 | decor_event_type gtkwd_type) | ||
3914 | 222 | { | ||
3915 | 223 | |||
3916 | 224 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
3917 | 225 | BUTTON_MENU, 1, _("Window Menu")); | ||
3918 | 226 | |||
3919 | 227 | switch (gtkwd_type) { | ||
3920 | 228 | case GButtonPress: | ||
3921 | 229 | if (gtkwd_event->button == 1) | ||
3922 | 230 | action_menu_map (win, | ||
3923 | 231 | gtkwd_event->button, | ||
3924 | 232 | gtkwd_event->time); | ||
3925 | 233 | break; | ||
3926 | 234 | default: | ||
3927 | 235 | break; | ||
3928 | 236 | } | ||
3929 | 237 | } | ||
3930 | 238 | |||
3931 | 239 | void | ||
3932 | 240 | shade_button_event (WnckWindow *win, | ||
3933 | 241 | decor_event *gtkwd_event, | ||
3934 | 242 | decor_event_type gtkwd_type) | ||
3935 | 243 | { | ||
3936 | 244 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3937 | 245 | guint state = d->button_states[BUTTON_SHADE]; | ||
3938 | 246 | |||
3939 | 247 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
3940 | 248 | BUTTON_SHADE, 1, _("Shade")); | ||
3941 | 249 | |||
3942 | 250 | switch (gtkwd_type) { | ||
3943 | 251 | case GButtonRelease: | ||
3944 | 252 | if (gtkwd_event->button == 1) | ||
3945 | 253 | { | ||
3946 | 254 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
3947 | 255 | wnck_window_shade (win); | ||
3948 | 256 | } | ||
3949 | 257 | break; | ||
3950 | 258 | default: | ||
3951 | 259 | break; | ||
3952 | 260 | } | ||
3953 | 261 | } | ||
3954 | 262 | |||
3955 | 263 | void | ||
3956 | 264 | above_button_event (WnckWindow *win, | ||
3957 | 265 | decor_event *gtkwd_event, | ||
3958 | 266 | decor_event_type gtkwd_type) | ||
3959 | 267 | { | ||
3960 | 268 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3961 | 269 | guint state = d->button_states[BUTTON_ABOVE]; | ||
3962 | 270 | |||
3963 | 271 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
3964 | 272 | BUTTON_ABOVE, 1, _("Make Above")); | ||
3965 | 273 | |||
3966 | 274 | switch (gtkwd_type) { | ||
3967 | 275 | case GButtonRelease: | ||
3968 | 276 | if (gtkwd_event->button == 1) | ||
3969 | 277 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
3970 | 278 | #ifdef HAVE_LIBWNCK_2_18_1 | ||
3971 | 279 | wnck_window_make_above (win); | ||
3972 | 280 | #endif | ||
3973 | 281 | break; | ||
3974 | 282 | default: | ||
3975 | 283 | break; | ||
3976 | 284 | } | ||
3977 | 285 | } | ||
3978 | 286 | |||
3979 | 287 | void | ||
3980 | 288 | stick_button_event (WnckWindow *win, | ||
3981 | 289 | decor_event *gtkwd_event, | ||
3982 | 290 | decor_event_type gtkwd_type) | ||
3983 | 291 | { | ||
3984 | 292 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
3985 | 293 | guint state = d->button_states[BUTTON_STICK]; | ||
3986 | 294 | |||
3987 | 295 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
3988 | 296 | BUTTON_STICK, 1, _("Stick")); | ||
3989 | 297 | |||
3990 | 298 | switch (gtkwd_type) { | ||
3991 | 299 | case GButtonRelease: | ||
3992 | 300 | if (gtkwd_event->button == 1) | ||
3993 | 301 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
3994 | 302 | wnck_window_stick (win); | ||
3995 | 303 | break; | ||
3996 | 304 | default: | ||
3997 | 305 | break; | ||
3998 | 306 | } | ||
3999 | 307 | } | ||
4000 | 308 | |||
4001 | 309 | void | ||
4002 | 310 | unshade_button_event (WnckWindow *win, | ||
4003 | 311 | decor_event *gtkwd_event, | ||
4004 | 312 | decor_event_type gtkwd_type) | ||
4005 | 313 | { | ||
4006 | 314 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4007 | 315 | guint state = d->button_states[BUTTON_UNSHADE]; | ||
4008 | 316 | |||
4009 | 317 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
4010 | 318 | BUTTON_UNSHADE, 1, _("Unshade")); | ||
4011 | 319 | |||
4012 | 320 | switch (gtkwd_type) { | ||
4013 | 321 | case GButtonRelease: | ||
4014 | 322 | if (gtkwd_event->button == 1) | ||
4015 | 323 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
4016 | 324 | wnck_window_unshade (win); | ||
4017 | 325 | break; | ||
4018 | 326 | default: | ||
4019 | 327 | break; | ||
4020 | 328 | } | ||
4021 | 329 | } | ||
4022 | 330 | |||
4023 | 331 | void | ||
4024 | 332 | unabove_button_event (WnckWindow *win, | ||
4025 | 333 | decor_event *gtkwd_event, | ||
4026 | 334 | decor_event_type gtkwd_type) | ||
4027 | 335 | { | ||
4028 | 336 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4029 | 337 | guint state = d->button_states[BUTTON_UNABOVE]; | ||
4030 | 338 | |||
4031 | 339 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
4032 | 340 | BUTTON_UNABOVE, 1, _("Unmake Above")); | ||
4033 | 341 | |||
4034 | 342 | switch (gtkwd_type) { | ||
4035 | 343 | case GButtonRelease: | ||
4036 | 344 | if (gtkwd_event->button == 1) | ||
4037 | 345 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
4038 | 346 | #ifdef HAVE_LIBWNCK_2_18_1 | ||
4039 | 347 | wnck_window_unmake_above (win); | ||
4040 | 348 | #endif | ||
4041 | 349 | break; | ||
4042 | 350 | default: | ||
4043 | 351 | break; | ||
4044 | 352 | } | ||
4045 | 353 | } | ||
4046 | 354 | |||
4047 | 355 | void | ||
4048 | 356 | unstick_button_event (WnckWindow *win, | ||
4049 | 357 | decor_event *gtkwd_event, | ||
4050 | 358 | decor_event_type gtkwd_type) | ||
4051 | 359 | { | ||
4052 | 360 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4053 | 361 | guint state = d->button_states[BUTTON_UNSTICK]; | ||
4054 | 362 | |||
4055 | 363 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
4056 | 364 | BUTTON_UNSTICK, 1, _("Unstick")); | ||
4057 | 365 | |||
4058 | 366 | switch (gtkwd_type) { | ||
4059 | 367 | case GButtonRelease: | ||
4060 | 368 | if (gtkwd_event->button == 1) | ||
4061 | 369 | if (state == BUTTON_EVENT_ACTION_STATE) | ||
4062 | 370 | wnck_window_unstick (win); | ||
4063 | 371 | break; | ||
4064 | 372 | default: | ||
4065 | 373 | break; | ||
4066 | 374 | } | ||
4067 | 375 | } | ||
4068 | 376 | |||
4069 | 377 | void | ||
4070 | 378 | handle_title_button_event (WnckWindow *win, | ||
4071 | 379 | int action, | ||
4072 | 380 | decor_event *gtkwd_event) | ||
4073 | 381 | { | ||
4074 | 382 | switch (action) { | ||
4075 | 383 | case CLICK_ACTION_SHADE: | ||
4076 | 384 | if (wnck_window_is_shaded (win)) | ||
4077 | 385 | wnck_window_unshade (win); | ||
4078 | 386 | else | ||
4079 | 387 | wnck_window_shade (win); | ||
4080 | 388 | break; | ||
4081 | 389 | case CLICK_ACTION_MAXIMIZE: | ||
4082 | 390 | if (wnck_window_is_maximized (win)) | ||
4083 | 391 | wnck_window_unmaximize (win); | ||
4084 | 392 | else | ||
4085 | 393 | wnck_window_maximize (win); | ||
4086 | 394 | break; | ||
4087 | 395 | case CLICK_ACTION_MINIMIZE: | ||
4088 | 396 | if (!wnck_window_is_minimized (win)) | ||
4089 | 397 | wnck_window_minimize (win); | ||
4090 | 398 | break; | ||
4091 | 399 | case CLICK_ACTION_RAISE: | ||
4092 | 400 | restack_window (win, Above); | ||
4093 | 401 | break; | ||
4094 | 402 | case CLICK_ACTION_LOWER: | ||
4095 | 403 | restack_window (win, Below); | ||
4096 | 404 | break; | ||
4097 | 405 | case CLICK_ACTION_MENU: | ||
4098 | 406 | action_menu_map (win, gtkwd_event->button, gtkwd_event->time); | ||
4099 | 407 | break; | ||
4100 | 408 | } | ||
4101 | 409 | } | ||
4102 | 410 | |||
4103 | 411 | void | ||
4104 | 412 | handle_mouse_wheel_title_event (WnckWindow *win, | ||
4105 | 413 | unsigned int button) | ||
4106 | 414 | { | ||
4107 | 415 | switch (settings->wheel_action) { | ||
4108 | 416 | case WHEEL_ACTION_SHADE: | ||
4109 | 417 | if (button == 4) | ||
4110 | 418 | { | ||
4111 | 419 | if (!wnck_window_is_shaded (win)) | ||
4112 | 420 | wnck_window_shade (win); | ||
4113 | 421 | } | ||
4114 | 422 | else if (button == 5) | ||
4115 | 423 | { | ||
4116 | 424 | if (wnck_window_is_shaded (win)) | ||
4117 | 425 | wnck_window_unshade (win); | ||
4118 | 426 | } | ||
4119 | 427 | break; | ||
4120 | 428 | default: | ||
4121 | 429 | break; | ||
4122 | 430 | } | ||
4123 | 431 | } | ||
4124 | 432 | |||
4125 | 433 | void | ||
4126 | 434 | title_event (WnckWindow *win, | ||
4127 | 435 | decor_event *gtkwd_event, | ||
4128 | 436 | decor_event_type gtkwd_type) | ||
4129 | 437 | { | ||
4130 | 438 | static int last_button_num = 0; | ||
4131 | 439 | static Window last_button_xwindow = None; | ||
4132 | 440 | static Time last_button_time = 0; | ||
4133 | 441 | static int last_button_x = 0; | ||
4134 | 442 | static int last_button_y = 0; | ||
4135 | 443 | |||
4136 | 444 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4137 | 445 | |||
4138 | 446 | if (d->frame_window && gtkwd_type == GEnterNotify) | ||
4139 | 447 | { | ||
4140 | 448 | GdkCursor* cursor = gdk_cursor_new (GDK_LEFT_PTR); | ||
4141 | 449 | gdk_window_set_cursor (d->frame_window, cursor); | ||
4142 | 450 | gdk_cursor_unref (cursor); | ||
4143 | 451 | } | ||
4144 | 452 | |||
4145 | 453 | if (gtkwd_type != GButtonPress) | ||
4146 | 454 | return; | ||
4147 | 455 | |||
4148 | 456 | if (gtkwd_event->button == 1) | ||
4149 | 457 | { | ||
4150 | 458 | if (gtkwd_event->button == last_button_num && | ||
4151 | 459 | gtkwd_event->window == last_button_xwindow && | ||
4152 | 460 | gtkwd_event->time < last_button_time + double_click_timeout && | ||
4153 | 461 | dist (gtkwd_event->x, gtkwd_event->y, | ||
4154 | 462 | last_button_x, last_button_y) < DOUBLE_CLICK_DISTANCE) | ||
4155 | 463 | { | ||
4156 | 464 | handle_title_button_event (win, settings->double_click_action, | ||
4157 | 465 | gtkwd_event); | ||
4158 | 466 | |||
4159 | 467 | last_button_num = 0; | ||
4160 | 468 | last_button_xwindow = None; | ||
4161 | 469 | last_button_time = 0; | ||
4162 | 470 | last_button_x = 0; | ||
4163 | 471 | last_button_y = 0; | ||
4164 | 472 | } | ||
4165 | 473 | else | ||
4166 | 474 | { | ||
4167 | 475 | last_button_num = gtkwd_event->button; | ||
4168 | 476 | last_button_xwindow = gtkwd_event->window; | ||
4169 | 477 | last_button_time = gtkwd_event->time; | ||
4170 | 478 | last_button_x = gtkwd_event->x; | ||
4171 | 479 | last_button_y = gtkwd_event->y; | ||
4172 | 480 | |||
4173 | 481 | restack_window (win, Above); | ||
4174 | 482 | |||
4175 | 483 | move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event); | ||
4176 | 484 | } | ||
4177 | 485 | } | ||
4178 | 486 | else if (gtkwd_event->button == 2) | ||
4179 | 487 | { | ||
4180 | 488 | handle_title_button_event (win, settings->middle_click_action, | ||
4181 | 489 | gtkwd_event); | ||
4182 | 490 | } | ||
4183 | 491 | else if (gtkwd_event->button == 3) | ||
4184 | 492 | { | ||
4185 | 493 | handle_title_button_event (win, settings->right_click_action, | ||
4186 | 494 | gtkwd_event); | ||
4187 | 495 | } | ||
4188 | 496 | else if (gtkwd_event->button == 4 || | ||
4189 | 497 | gtkwd_event->button == 5) | ||
4190 | 498 | { | ||
4191 | 499 | handle_mouse_wheel_title_event (win, gtkwd_event->button); | ||
4192 | 500 | } | ||
4193 | 501 | } | ||
4194 | 502 | |||
4195 | 503 | void | ||
4196 | 504 | frame_common_event (WnckWindow *win, | ||
4197 | 505 | int direction, | ||
4198 | 506 | decor_event *gtkwd_event, | ||
4199 | 507 | decor_event_type gtkwd_type) | ||
4200 | 508 | { | ||
4201 | 509 | |||
4202 | 510 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4203 | 511 | |||
4204 | 512 | if (d->frame_window && gtkwd_type == GEnterNotify) | ||
4205 | 513 | { | ||
4206 | 514 | GdkCursor *cursor = NULL; | ||
4207 | 515 | |||
4208 | 516 | switch (direction) | ||
4209 | 517 | { | ||
4210 | 518 | case WM_MOVERESIZE_SIZE_TOPLEFT: | ||
4211 | 519 | cursor = gdk_cursor_new (GDK_TOP_LEFT_CORNER); | ||
4212 | 520 | break; | ||
4213 | 521 | case WM_MOVERESIZE_SIZE_LEFT: | ||
4214 | 522 | cursor = gdk_cursor_new (GDK_LEFT_SIDE); | ||
4215 | 523 | break; | ||
4216 | 524 | case WM_MOVERESIZE_SIZE_BOTTOMLEFT: | ||
4217 | 525 | cursor = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER); | ||
4218 | 526 | break; | ||
4219 | 527 | case WM_MOVERESIZE_SIZE_BOTTOM: | ||
4220 | 528 | cursor = gdk_cursor_new (GDK_BOTTOM_SIDE); | ||
4221 | 529 | break; | ||
4222 | 530 | case WM_MOVERESIZE_SIZE_BOTTOMRIGHT: | ||
4223 | 531 | cursor = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER); | ||
4224 | 532 | break; | ||
4225 | 533 | case WM_MOVERESIZE_SIZE_RIGHT: | ||
4226 | 534 | cursor = gdk_cursor_new (GDK_RIGHT_SIDE); | ||
4227 | 535 | break; | ||
4228 | 536 | case WM_MOVERESIZE_SIZE_TOPRIGHT: | ||
4229 | 537 | cursor = gdk_cursor_new (GDK_TOP_RIGHT_CORNER); | ||
4230 | 538 | break; | ||
4231 | 539 | case WM_MOVERESIZE_SIZE_TOP: | ||
4232 | 540 | cursor = gdk_cursor_new (GDK_TOP_SIDE); | ||
4233 | 541 | break; | ||
4234 | 542 | default: | ||
4235 | 543 | break; | ||
4236 | 544 | } | ||
4237 | 545 | |||
4238 | 546 | if (cursor) | ||
4239 | 547 | { | ||
4240 | 548 | gdk_window_set_cursor (d->frame_window, cursor); | ||
4241 | 549 | gdk_cursor_unref (cursor); | ||
4242 | 550 | } | ||
4243 | 551 | } | ||
4244 | 552 | |||
4245 | 553 | if (gtkwd_type != GButtonPress) | ||
4246 | 554 | return; | ||
4247 | 555 | |||
4248 | 556 | switch (gtkwd_event->button) { | ||
4249 | 557 | case 1: | ||
4250 | 558 | move_resize_window (win, direction, gtkwd_event); | ||
4251 | 559 | restack_window (win, Above); | ||
4252 | 560 | break; | ||
4253 | 561 | case 2: | ||
4254 | 562 | handle_title_button_event (win, settings->middle_click_action, | ||
4255 | 563 | gtkwd_event); | ||
4256 | 564 | break; | ||
4257 | 565 | case 3: | ||
4258 | 566 | handle_title_button_event (win, settings->right_click_action, | ||
4259 | 567 | gtkwd_event); | ||
4260 | 568 | break; | ||
4261 | 569 | } | ||
4262 | 570 | } | ||
4263 | 571 | |||
4264 | 572 | void | ||
4265 | 573 | top_left_event (WnckWindow *win, | ||
4266 | 574 | decor_event *gtkwd_event, | ||
4267 | 575 | decor_event_type gtkwd_type) | ||
4268 | 576 | { | ||
4269 | 577 | frame_common_event (win, WM_MOVERESIZE_SIZE_TOPLEFT, | ||
4270 | 578 | gtkwd_event, gtkwd_type); | ||
4271 | 579 | } | ||
4272 | 580 | |||
4273 | 581 | void | ||
4274 | 582 | top_event (WnckWindow *win, | ||
4275 | 583 | decor_event *gtkwd_event, | ||
4276 | 584 | decor_event_type gtkwd_type) | ||
4277 | 585 | { | ||
4278 | 586 | frame_common_event (win, WM_MOVERESIZE_SIZE_TOP, | ||
4279 | 587 | gtkwd_event, gtkwd_type); | ||
4280 | 588 | } | ||
4281 | 589 | |||
4282 | 590 | void | ||
4283 | 591 | top_right_event (WnckWindow *win, | ||
4284 | 592 | decor_event *gtkwd_event, | ||
4285 | 593 | decor_event_type gtkwd_type) | ||
4286 | 594 | { | ||
4287 | 595 | frame_common_event (win, WM_MOVERESIZE_SIZE_TOPRIGHT, | ||
4288 | 596 | gtkwd_event, gtkwd_type); | ||
4289 | 597 | } | ||
4290 | 598 | |||
4291 | 599 | void | ||
4292 | 600 | left_event (WnckWindow *win, | ||
4293 | 601 | decor_event *gtkwd_event, | ||
4294 | 602 | decor_event_type gtkwd_type) | ||
4295 | 603 | { | ||
4296 | 604 | frame_common_event (win, WM_MOVERESIZE_SIZE_LEFT, | ||
4297 | 605 | gtkwd_event, gtkwd_type); | ||
4298 | 606 | } | ||
4299 | 607 | |||
4300 | 608 | void | ||
4301 | 609 | right_event (WnckWindow *win, | ||
4302 | 610 | decor_event *gtkwd_event, | ||
4303 | 611 | decor_event_type gtkwd_type) | ||
4304 | 612 | { | ||
4305 | 613 | frame_common_event (win, WM_MOVERESIZE_SIZE_RIGHT, | ||
4306 | 614 | gtkwd_event, gtkwd_type); | ||
4307 | 615 | } | ||
4308 | 616 | |||
4309 | 617 | void | ||
4310 | 618 | bottom_left_event (WnckWindow *win, | ||
4311 | 619 | decor_event *gtkwd_event, | ||
4312 | 620 | decor_event_type gtkwd_type) | ||
4313 | 621 | { | ||
4314 | 622 | frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMLEFT, | ||
4315 | 623 | gtkwd_event, gtkwd_type); | ||
4316 | 624 | } | ||
4317 | 625 | |||
4318 | 626 | void | ||
4319 | 627 | bottom_event (WnckWindow *win, | ||
4320 | 628 | decor_event *gtkwd_event, | ||
4321 | 629 | decor_event_type gtkwd_type) | ||
4322 | 630 | { | ||
4323 | 631 | frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOM, | ||
4324 | 632 | gtkwd_event, gtkwd_type); | ||
4325 | 633 | } | ||
4326 | 634 | |||
4327 | 635 | void | ||
4328 | 636 | bottom_right_event (WnckWindow *win, | ||
4329 | 637 | decor_event *gtkwd_event, | ||
4330 | 638 | decor_event_type gtkwd_type) | ||
4331 | 639 | { | ||
4332 | 640 | frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMRIGHT, | ||
4333 | 641 | gtkwd_event, gtkwd_type); | ||
4334 | 642 | } | ||
4335 | 643 | |||
4336 | 644 | void | ||
4337 | 645 | frame_window_realized (GtkWidget *widget, | ||
4338 | 646 | gpointer data) | ||
4339 | 647 | { | ||
4340 | 648 | decor_t *d = (decor_t *) data; | ||
4341 | 649 | |||
4342 | 650 | if (d) | ||
4343 | 651 | { | ||
4344 | 652 | GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window); | ||
4345 | 653 | gdk_window_reparent (gdk_frame_window, d->frame_window, 0, 0); | ||
4346 | 654 | gdk_window_lower (gdk_frame_window); | ||
4347 | 655 | |||
4348 | 656 | } | ||
4349 | 657 | } | ||
4350 | 658 | |||
4351 | 659 | event_callback | ||
4352 | 660 | find_event_callback_for_point (decor_t *d, | ||
4353 | 661 | int x, | ||
4354 | 662 | int y, | ||
4355 | 663 | Bool *enter, | ||
4356 | 664 | Bool *leave, | ||
4357 | 665 | BoxPtr *entered_box) | ||
4358 | 666 | { | ||
4359 | 667 | int i, j; | ||
4360 | 668 | BoxPtr box; | ||
4361 | 669 | |||
4362 | 670 | for (i = 0; i < BUTTON_NUM; i++) | ||
4363 | 671 | { | ||
4364 | 672 | box = &d->button_windows[i].pos; | ||
4365 | 673 | if (x >= box->x1 && x <= box->x2 && | ||
4366 | 674 | y >= box->y1 && y <= box->y2) | ||
4367 | 675 | { | ||
4368 | 676 | if (d->last_pos_entered != box) | ||
4369 | 677 | { | ||
4370 | 678 | if (enter) | ||
4371 | 679 | *enter = TRUE; | ||
4372 | 680 | if (leave && d->last_pos_entered) | ||
4373 | 681 | *leave = TRUE; | ||
4374 | 682 | if (entered_box) | ||
4375 | 683 | *entered_box = box; | ||
4376 | 684 | } | ||
4377 | 685 | return d->button_windows[i].callback; | ||
4378 | 686 | } | ||
4379 | 687 | } | ||
4380 | 688 | |||
4381 | 689 | for (i = 0; i < 3; i++) | ||
4382 | 690 | { | ||
4383 | 691 | for (j = 0; j < 3; j++) | ||
4384 | 692 | { | ||
4385 | 693 | box = &d->event_windows[i][j].pos; | ||
4386 | 694 | if (x >= box->x1 && x <= box->x2 && | ||
4387 | 695 | y >= box->y1 && y <= box->y2) | ||
4388 | 696 | { | ||
4389 | 697 | if (d->last_pos_entered != box) | ||
4390 | 698 | { | ||
4391 | 699 | if (enter) | ||
4392 | 700 | *enter = TRUE; | ||
4393 | 701 | if (leave && d->last_pos_entered) | ||
4394 | 702 | *leave = TRUE; | ||
4395 | 703 | if (entered_box) | ||
4396 | 704 | *entered_box = box; | ||
4397 | 705 | } | ||
4398 | 706 | return d->event_windows[i][j].callback; | ||
4399 | 707 | } | ||
4400 | 708 | } | ||
4401 | 709 | } | ||
4402 | 710 | |||
4403 | 711 | return NULL; | ||
4404 | 712 | } | ||
4405 | 713 | |||
4406 | 714 | event_callback | ||
4407 | 715 | find_leave_event_callback (decor_t *d) | ||
4408 | 716 | { | ||
4409 | 717 | int i, j; | ||
4410 | 718 | |||
4411 | 719 | for (i = 0; i < BUTTON_NUM; i++) | ||
4412 | 720 | { | ||
4413 | 721 | if (d->last_pos_entered == &d->button_windows[i].pos) | ||
4414 | 722 | return d->button_windows[i].callback; | ||
4415 | 723 | } | ||
4416 | 724 | |||
4417 | 725 | for (i = 0; i < 3; i++) | ||
4418 | 726 | { | ||
4419 | 727 | for (j = 0; j < 3; j++) | ||
4420 | 728 | { | ||
4421 | 729 | if (d->last_pos_entered == &d->event_windows[i][j].pos) | ||
4422 | 730 | return d->event_windows[i][j].callback; | ||
4423 | 731 | } | ||
4424 | 732 | } | ||
4425 | 733 | |||
4426 | 734 | return NULL; | ||
4427 | 735 | } | ||
4428 | 736 | |||
4429 | 737 | void | ||
4430 | 738 | frame_handle_button_press (GtkWidget *widget, | ||
4431 | 739 | GdkEventButton *event, | ||
4432 | 740 | gpointer user_data) | ||
4433 | 741 | { | ||
4434 | 742 | decor_t *d = (decor_t *) user_data; | ||
4435 | 743 | |||
4436 | 744 | if (d) | ||
4437 | 745 | { | ||
4438 | 746 | /* Check to see where the event happened and fill out an appropriate | ||
4439 | 747 | * struct | ||
4440 | 748 | */ | ||
4441 | 749 | event_callback cb; | ||
4442 | 750 | |||
4443 | 751 | cb = find_event_callback_for_point (d, event->x, event->y, | ||
4444 | 752 | NULL, NULL, NULL); | ||
4445 | 753 | |||
4446 | 754 | if (cb && d->decorated) | ||
4447 | 755 | { | ||
4448 | 756 | decor_event gtkwd_event; | ||
4449 | 757 | |||
4450 | 758 | gtkwd_event.window = GDK_WINDOW_XID (d->frame_window); | ||
4451 | 759 | gtkwd_event.button = event->button; | ||
4452 | 760 | gtkwd_event.x = event->x; | ||
4453 | 761 | gtkwd_event.y = event->y; | ||
4454 | 762 | gtkwd_event.x_root = event->x_root; | ||
4455 | 763 | gtkwd_event.y_root = event->y_root; | ||
4456 | 764 | gtkwd_event.time = event->time; | ||
4457 | 765 | |||
4458 | 766 | (*cb) (d->win, >kwd_event, GButtonPress); | ||
4459 | 767 | } | ||
4460 | 768 | } | ||
4461 | 769 | } | ||
4462 | 770 | |||
4463 | 771 | void | ||
4464 | 772 | frame_handle_button_release (GtkWidget *widget, | ||
4465 | 773 | GdkEventButton *event, | ||
4466 | 774 | gpointer user_data) | ||
4467 | 775 | { | ||
4468 | 776 | decor_t *d = (decor_t *) user_data; | ||
4469 | 777 | |||
4470 | 778 | if (d) | ||
4471 | 779 | { | ||
4472 | 780 | event_callback cb; | ||
4473 | 781 | |||
4474 | 782 | cb = find_event_callback_for_point (d, event->x, event->y, | ||
4475 | 783 | NULL, NULL, NULL); | ||
4476 | 784 | |||
4477 | 785 | if (cb && d->decorated) | ||
4478 | 786 | { | ||
4479 | 787 | decor_event gtkwd_event; | ||
4480 | 788 | |||
4481 | 789 | gtkwd_event.window = GDK_WINDOW_XID (d->frame_window); | ||
4482 | 790 | gtkwd_event.button = event->button; | ||
4483 | 791 | gtkwd_event.x = event->x; | ||
4484 | 792 | gtkwd_event.y = event->y; | ||
4485 | 793 | gtkwd_event.x_root = event->x_root; | ||
4486 | 794 | gtkwd_event.y_root = event->y_root; | ||
4487 | 795 | gtkwd_event.time = event->time; | ||
4488 | 796 | |||
4489 | 797 | (*cb) (d->win, >kwd_event, GButtonRelease); | ||
4490 | 798 | } | ||
4491 | 799 | } | ||
4492 | 800 | } | ||
4493 | 801 | |||
4494 | 802 | void | ||
4495 | 803 | frame_handle_motion (GtkWidget *widget, | ||
4496 | 804 | GdkEventMotion *event, | ||
4497 | 805 | gpointer user_data) | ||
4498 | 806 | { | ||
4499 | 807 | decor_t *d = (decor_t *) user_data; | ||
4500 | 808 | |||
4501 | 809 | if (d) | ||
4502 | 810 | { | ||
4503 | 811 | event_callback cb = NULL; | ||
4504 | 812 | Bool send_enter = FALSE; | ||
4505 | 813 | Bool send_leave = FALSE; | ||
4506 | 814 | BoxPtr entered_box; | ||
4507 | 815 | |||
4508 | 816 | cb = find_event_callback_for_point (d, event->x, event->y, | ||
4509 | 817 | &send_enter, &send_leave, | ||
4510 | 818 | &entered_box); | ||
4511 | 819 | |||
4512 | 820 | if (cb && d->decorated) | ||
4513 | 821 | { | ||
4514 | 822 | decor_event gtkwd_event; | ||
4515 | 823 | |||
4516 | 824 | gtkwd_event.window = GDK_WINDOW_XID (d->frame_window); | ||
4517 | 825 | gtkwd_event.x = event->x; | ||
4518 | 826 | gtkwd_event.y = event->y; | ||
4519 | 827 | gtkwd_event.x_root = event->x_root; | ||
4520 | 828 | gtkwd_event.y_root = event->y_root; | ||
4521 | 829 | gtkwd_event.time = event->time; | ||
4522 | 830 | |||
4523 | 831 | if (send_enter) | ||
4524 | 832 | (*cb) (d->win, >kwd_event, GEnterNotify); | ||
4525 | 833 | |||
4526 | 834 | if (send_leave) | ||
4527 | 835 | { | ||
4528 | 836 | event_callback leave_cb; | ||
4529 | 837 | |||
4530 | 838 | leave_cb = find_leave_event_callback (d); | ||
4531 | 839 | |||
4532 | 840 | if (leave_cb) | ||
4533 | 841 | (*leave_cb) (d->win, >kwd_event, GLeaveNotify); | ||
4534 | 842 | |||
4535 | 843 | } | ||
4536 | 844 | |||
4537 | 845 | if (send_enter) | ||
4538 | 846 | d->last_pos_entered = entered_box; | ||
4539 | 847 | } | ||
4540 | 848 | else if (d->last_pos_entered && d->decorated) | ||
4541 | 849 | { | ||
4542 | 850 | /* We are not in an event / button window but last_pos_entered | ||
4543 | 851 | * is still set, so send a GLeaveNotify to last_pos_entered | ||
4544 | 852 | * and set it to NULL | ||
4545 | 853 | */ | ||
4546 | 854 | |||
4547 | 855 | event_callback leave_cb; | ||
4548 | 856 | |||
4549 | 857 | leave_cb = find_leave_event_callback (d); | ||
4550 | 858 | |||
4551 | 859 | if (leave_cb) | ||
4552 | 860 | { | ||
4553 | 861 | decor_event gtkwd_event; | ||
4554 | 862 | |||
4555 | 863 | gtkwd_event.window = GDK_WINDOW_XID (d->frame_window); | ||
4556 | 864 | gtkwd_event.x = event->x; | ||
4557 | 865 | gtkwd_event.y = event->y; | ||
4558 | 866 | gtkwd_event.x_root = event->x_root; | ||
4559 | 867 | gtkwd_event.y_root = event->y_root; | ||
4560 | 868 | gtkwd_event.time = event->time; | ||
4561 | 869 | |||
4562 | 870 | (*leave_cb) (d->win, >kwd_event, GLeaveNotify); | ||
4563 | 871 | } | ||
4564 | 872 | |||
4565 | 873 | d->last_pos_entered = NULL; | ||
4566 | 874 | } | ||
4567 | 875 | } | ||
4568 | 876 | } | ||
4569 | 877 | |||
4570 | 878 | GdkFilterReturn | ||
4571 | 879 | event_filter_func (GdkXEvent *gdkxevent, | ||
4572 | 880 | GdkEvent *event, | ||
4573 | 881 | gpointer data) | ||
4574 | 882 | { | ||
4575 | 883 | Display *xdisplay; | ||
4576 | 884 | GdkDisplay *gdkdisplay; | ||
4577 | 885 | XEvent *xevent = gdkxevent; | ||
4578 | 886 | gulong xid = 0; | ||
4579 | 887 | Window select = 0; | ||
4580 | 888 | |||
4581 | 889 | gdkdisplay = gdk_display_get_default (); | ||
4582 | 890 | xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay); | ||
4583 | 891 | |||
4584 | 892 | switch (xevent->type) { | ||
4585 | 893 | case CreateNotify: | ||
4586 | 894 | { | ||
4587 | 895 | if (!wnck_window_get (xevent->xcreatewindow.window)) | ||
4588 | 896 | { | ||
4589 | 897 | GdkWindow *toplevel = create_foreign_window (xevent->xcreatewindow.window); | ||
4590 | 898 | |||
4591 | 899 | if (toplevel) | ||
4592 | 900 | { | ||
4593 | 901 | gdk_window_set_events (toplevel, | ||
4594 | 902 | gdk_window_get_events (toplevel) | | ||
4595 | 903 | GDK_PROPERTY_CHANGE_MASK); | ||
4596 | 904 | |||
4597 | 905 | /* check if the window is a switcher and update accordingly */ | ||
4598 | 906 | |||
4599 | 907 | if (get_window_prop (xevent->xcreatewindow.window, select_window_atom, &select)) | ||
4600 | 908 | update_switcher_window (xevent->xcreatewindow.window, select); | ||
4601 | 909 | } | ||
4602 | 910 | } | ||
4603 | 911 | } | ||
4604 | 912 | break; | ||
4605 | 913 | case ButtonPress: | ||
4606 | 914 | case ButtonRelease: | ||
4607 | 915 | xid = (gulong) | ||
4608 | 916 | g_hash_table_lookup (frame_table, | ||
4609 | 917 | GINT_TO_POINTER (xevent->xbutton.window)); | ||
4610 | 918 | break; | ||
4611 | 919 | case EnterNotify: | ||
4612 | 920 | case LeaveNotify: | ||
4613 | 921 | xid = (gulong) | ||
4614 | 922 | g_hash_table_lookup (frame_table, | ||
4615 | 923 | GINT_TO_POINTER (xevent->xcrossing.window)); | ||
4616 | 924 | break; | ||
4617 | 925 | case MotionNotify: | ||
4618 | 926 | xid = (gulong) | ||
4619 | 927 | g_hash_table_lookup (frame_table, | ||
4620 | 928 | GINT_TO_POINTER (xevent->xmotion.window)); | ||
4621 | 929 | break; | ||
4622 | 930 | case PropertyNotify: | ||
4623 | 931 | if (xevent->xproperty.atom == frame_input_window_atom) | ||
4624 | 932 | { | ||
4625 | 933 | WnckWindow *win; | ||
4626 | 934 | |||
4627 | 935 | xid = xevent->xproperty.window; | ||
4628 | 936 | |||
4629 | 937 | win = wnck_window_get (xid); | ||
4630 | 938 | if (win) | ||
4631 | 939 | { | ||
4632 | 940 | Window frame; | ||
4633 | 941 | |||
4634 | 942 | if (!get_window_prop (xid, select_window_atom, &select)) | ||
4635 | 943 | { | ||
4636 | 944 | if (get_window_prop (xid, frame_input_window_atom, &frame)) | ||
4637 | 945 | add_frame_window (win, frame, FALSE); | ||
4638 | 946 | else | ||
4639 | 947 | remove_frame_window (win); | ||
4640 | 948 | } | ||
4641 | 949 | } | ||
4642 | 950 | } | ||
4643 | 951 | if (xevent->xproperty.atom == frame_output_window_atom) | ||
4644 | 952 | { | ||
4645 | 953 | WnckWindow *win; | ||
4646 | 954 | |||
4647 | 955 | xid = xevent->xproperty.window; | ||
4648 | 956 | |||
4649 | 957 | win = wnck_window_get (xid); | ||
4650 | 958 | if (win) | ||
4651 | 959 | { | ||
4652 | 960 | Window frame; | ||
4653 | 961 | |||
4654 | 962 | if (!get_window_prop (xid, select_window_atom, &select)) | ||
4655 | 963 | { | ||
4656 | 964 | if (get_window_prop (xid, frame_output_window_atom, &frame)) | ||
4657 | 965 | add_frame_window (win, frame, TRUE); | ||
4658 | 966 | else | ||
4659 | 967 | remove_frame_window (win); | ||
4660 | 968 | } | ||
4661 | 969 | } | ||
4662 | 970 | } | ||
4663 | 971 | else if (xevent->xproperty.atom == compiz_shadow_info_atom || | ||
4664 | 972 | xevent->xproperty.atom == compiz_shadow_color_atom) | ||
4665 | 973 | { | ||
4666 | 974 | GdkScreen *g_screen = gdk_display_get_default_screen (gdkdisplay); | ||
4667 | 975 | Window root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (g_screen)); | ||
4668 | 976 | WnckScreen *screen; | ||
4669 | 977 | |||
4670 | 978 | screen = wnck_screen_get_for_root (root); | ||
4671 | 979 | |||
4672 | 980 | if (screen) | ||
4673 | 981 | { | ||
4674 | 982 | if (shadow_property_changed (screen)) | ||
4675 | 983 | decorations_changed (screen); | ||
4676 | 984 | } | ||
4677 | 985 | } | ||
4678 | 986 | else if (xevent->xproperty.atom == mwm_hints_atom) | ||
4679 | 987 | { | ||
4680 | 988 | WnckWindow *win; | ||
4681 | 989 | |||
4682 | 990 | xid = xevent->xproperty.window; | ||
4683 | 991 | |||
4684 | 992 | win = wnck_window_get (xid); | ||
4685 | 993 | if (win) | ||
4686 | 994 | { | ||
4687 | 995 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4688 | 996 | gboolean decorated = FALSE; | ||
4689 | 997 | |||
4690 | 998 | if (get_mwm_prop (xid) & (MWM_DECOR_ALL | MWM_DECOR_TITLE)) | ||
4691 | 999 | decorated = TRUE; | ||
4692 | 1000 | |||
4693 | 1001 | if (decorated != d->decorated) | ||
4694 | 1002 | { | ||
4695 | 1003 | d->decorated = decorated; | ||
4696 | 1004 | if (decorated) | ||
4697 | 1005 | { | ||
4698 | 1006 | d->context = NULL; | ||
4699 | 1007 | d->width = d->height = 0; | ||
4700 | 1008 | |||
4701 | 1009 | d->frame = gwd_get_decor_frame (get_frame_type (win)); | ||
4702 | 1010 | |||
4703 | 1011 | update_window_decoration_size (win); | ||
4704 | 1012 | update_event_windows (win); | ||
4705 | 1013 | } | ||
4706 | 1014 | else | ||
4707 | 1015 | { | ||
4708 | 1016 | gwd_decor_frame_unref (d->frame); | ||
4709 | 1017 | d->frame = NULL; | ||
4710 | 1018 | |||
4711 | 1019 | gdk_error_trap_push (); | ||
4712 | 1020 | XDeleteProperty (xdisplay, xid, win_decor_atom); | ||
4713 | 1021 | gdk_display_sync (gdk_display_get_default ()); | ||
4714 | 1022 | gdk_error_trap_pop (); | ||
4715 | 1023 | } | ||
4716 | 1024 | } | ||
4717 | 1025 | } | ||
4718 | 1026 | } | ||
4719 | 1027 | else if (xevent->xproperty.atom == select_window_atom) | ||
4720 | 1028 | { | ||
4721 | 1029 | Window select; | ||
4722 | 1030 | |||
4723 | 1031 | if (get_window_prop (xevent->xproperty.window, select_window_atom, &select)) | ||
4724 | 1032 | update_switcher_window (xevent->xproperty.window, select); | ||
4725 | 1033 | } | ||
4726 | 1034 | break; | ||
4727 | 1035 | case DestroyNotify: | ||
4728 | 1036 | g_hash_table_remove (frame_table, | ||
4729 | 1037 | GINT_TO_POINTER (xevent->xproperty.window)); | ||
4730 | 1038 | break; | ||
4731 | 1039 | case ClientMessage: | ||
4732 | 1040 | if (xevent->xclient.message_type == toolkit_action_atom) | ||
4733 | 1041 | { | ||
4734 | 1042 | long action; | ||
4735 | 1043 | |||
4736 | 1044 | action = xevent->xclient.data.l[0]; | ||
4737 | 1045 | if (action == toolkit_action_window_menu_atom) | ||
4738 | 1046 | { | ||
4739 | 1047 | WnckWindow *win; | ||
4740 | 1048 | |||
4741 | 1049 | win = wnck_window_get (xevent->xclient.window); | ||
4742 | 1050 | if (win) | ||
4743 | 1051 | { | ||
4744 | 1052 | action_menu_map (win, | ||
4745 | 1053 | xevent->xclient.data.l[2], | ||
4746 | 1054 | xevent->xclient.data.l[1]); | ||
4747 | 1055 | } | ||
4748 | 1056 | } | ||
4749 | 1057 | else if (action == toolkit_action_force_quit_dialog_atom) | ||
4750 | 1058 | { | ||
4751 | 1059 | WnckWindow *win; | ||
4752 | 1060 | |||
4753 | 1061 | win = wnck_window_get (xevent->xclient.window); | ||
4754 | 1062 | if (win) | ||
4755 | 1063 | { | ||
4756 | 1064 | if (xevent->xclient.data.l[2]) | ||
4757 | 1065 | show_force_quit_dialog (win, | ||
4758 | 1066 | xevent->xclient.data.l[1]); | ||
4759 | 1067 | else | ||
4760 | 1068 | hide_force_quit_dialog (win); | ||
4761 | 1069 | } | ||
4762 | 1070 | } | ||
4763 | 1071 | } | ||
4764 | 1072 | default: | ||
4765 | 1073 | break; | ||
4766 | 1074 | } | ||
4767 | 1075 | |||
4768 | 1076 | if (xid) | ||
4769 | 1077 | { | ||
4770 | 1078 | WnckWindow *win; | ||
4771 | 1079 | |||
4772 | 1080 | win = wnck_window_get (xid); | ||
4773 | 1081 | if (win) | ||
4774 | 1082 | { | ||
4775 | 1083 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4776 | 1084 | |||
4777 | 1085 | if (d->decorated) | ||
4778 | 1086 | { | ||
4779 | 1087 | gint i, j; | ||
4780 | 1088 | event_callback cb = NULL; | ||
4781 | 1089 | Window w = xevent->xany.window; | ||
4782 | 1090 | |||
4783 | 1091 | for (i = 0; i < 3; i++) | ||
4784 | 1092 | for (j = 0; j < 3; j++) | ||
4785 | 1093 | if (d->event_windows[i][j].window == w) | ||
4786 | 1094 | cb = d->event_windows[i][j].callback; | ||
4787 | 1095 | |||
4788 | 1096 | if (!cb) | ||
4789 | 1097 | { | ||
4790 | 1098 | for (i = 0; i < BUTTON_NUM; i++) | ||
4791 | 1099 | if (d->button_windows[i].window == w) | ||
4792 | 1100 | cb = d->button_windows[i].callback; | ||
4793 | 1101 | } | ||
4794 | 1102 | |||
4795 | 1103 | if (cb) | ||
4796 | 1104 | { | ||
4797 | 1105 | decor_event gtkwd_event; | ||
4798 | 1106 | decor_event_type gtkwd_type; | ||
4799 | 1107 | |||
4800 | 1108 | gtkwd_event.window = w; | ||
4801 | 1109 | |||
4802 | 1110 | switch (xevent->type) | ||
4803 | 1111 | { | ||
4804 | 1112 | case ButtonPress: | ||
4805 | 1113 | case ButtonRelease: | ||
4806 | 1114 | if (xevent->type == ButtonPress) | ||
4807 | 1115 | gtkwd_type = GButtonPress; | ||
4808 | 1116 | else | ||
4809 | 1117 | gtkwd_type = GButtonRelease; | ||
4810 | 1118 | gtkwd_event.button = xevent->xbutton.button; | ||
4811 | 1119 | gtkwd_event.x = xevent->xbutton.x; | ||
4812 | 1120 | gtkwd_event.y = xevent->xbutton.y; | ||
4813 | 1121 | gtkwd_event.x_root = xevent->xbutton.x_root; | ||
4814 | 1122 | gtkwd_event.y_root = xevent->xbutton.y_root; | ||
4815 | 1123 | gtkwd_event.time = xevent->xbutton.time; | ||
4816 | 1124 | break; | ||
4817 | 1125 | case EnterNotify: | ||
4818 | 1126 | case LeaveNotify: | ||
4819 | 1127 | if (xevent->type == EnterNotify) | ||
4820 | 1128 | gtkwd_type = GEnterNotify; | ||
4821 | 1129 | else | ||
4822 | 1130 | gtkwd_type = GLeaveNotify; | ||
4823 | 1131 | gtkwd_event.x = xevent->xcrossing.x; | ||
4824 | 1132 | gtkwd_event.y = xevent->xcrossing.y; | ||
4825 | 1133 | gtkwd_event.x_root = xevent->xcrossing.x_root; | ||
4826 | 1134 | gtkwd_event.y_root = xevent->xcrossing.y_root; | ||
4827 | 1135 | gtkwd_event.time = xevent->xcrossing.time; | ||
4828 | 1136 | break; | ||
4829 | 1137 | default: | ||
4830 | 1138 | cb = NULL; | ||
4831 | 1139 | break; | ||
4832 | 1140 | } | ||
4833 | 1141 | if (cb) | ||
4834 | 1142 | (*cb) (win, >kwd_event, gtkwd_type); | ||
4835 | 1143 | } | ||
4836 | 1144 | } | ||
4837 | 1145 | } | ||
4838 | 1146 | } | ||
4839 | 1147 | |||
4840 | 1148 | return GDK_FILTER_CONTINUE; | ||
4841 | 1149 | } | ||
4842 | 1150 | |||
4843 | 1151 | GdkFilterReturn | ||
4844 | 1152 | selection_event_filter_func (GdkXEvent *gdkxevent, | ||
4845 | 1153 | GdkEvent *event, | ||
4846 | 1154 | gpointer data) | ||
4847 | 1155 | { | ||
4848 | 1156 | Display *xdisplay; | ||
4849 | 1157 | GdkDisplay *gdkdisplay; | ||
4850 | 1158 | XEvent *xevent = gdkxevent; | ||
4851 | 1159 | int status; | ||
4852 | 1160 | |||
4853 | 1161 | gdkdisplay = gdk_display_get_default (); | ||
4854 | 1162 | xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay); | ||
4855 | 1163 | |||
4856 | 1164 | switch (xevent->type) { | ||
4857 | 1165 | case SelectionRequest: | ||
4858 | 1166 | decor_handle_selection_request (xdisplay, xevent, dm_sn_timestamp); | ||
4859 | 1167 | break; | ||
4860 | 1168 | case SelectionClear: | ||
4861 | 1169 | status = decor_handle_selection_clear (xdisplay, xevent, 0); | ||
4862 | 1170 | if (status == DECOR_SELECTION_GIVE_UP) | ||
4863 | 1171 | gtk_main_quit (); | ||
4864 | 1172 | default: | ||
4865 | 1173 | break; | ||
4866 | 1174 | } | ||
4867 | 1175 | |||
4868 | 1176 | return GDK_FILTER_CONTINUE; | ||
4869 | 1177 | } | ||
4870 | 0 | 1178 | ||
4871 | === renamed file 'gtk/window-decorator/events.c' => 'gtk/window-decorator/events.c.THIS' | |||
4872 | === added file 'gtk/window-decorator/forcequit.c' | |||
4873 | --- gtk/window-decorator/forcequit.c 1970-01-01 00:00:00 +0000 | |||
4874 | +++ gtk/window-decorator/forcequit.c 2012-02-08 18:50:27 +0000 | |||
4875 | @@ -0,0 +1,201 @@ | |||
4876 | 1 | /* | ||
4877 | 2 | * Copyright © 2006 Novell, Inc. | ||
4878 | 3 | * | ||
4879 | 4 | * This library is free software; you can redistribute it and/or | ||
4880 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
4881 | 6 | * License as published by the Free Software Foundation; either | ||
4882 | 7 | * version 2 of the License, or (at your option) any later version. | ||
4883 | 8 | * | ||
4884 | 9 | * This library is distributed in the hope that it will be useful, | ||
4885 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4886 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4887 | 12 | * Lesser General Public License for more details. | ||
4888 | 13 | * | ||
4889 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
4890 | 15 | * License along with this library; if not, write to the | ||
4891 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
4892 | 17 | * Boston, MA 02111-1307, USA. | ||
4893 | 18 | * | ||
4894 | 19 | * Author: David Reveman <davidr@novell.com> | ||
4895 | 20 | * | ||
4896 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
4897 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
4898 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
4899 | 24 | */ | ||
4900 | 25 | |||
4901 | 26 | #include "gtk-window-decorator.h" | ||
4902 | 27 | |||
4903 | 28 | static char * | ||
4904 | 29 | get_client_machine (Window xwindow) | ||
4905 | 30 | { | ||
4906 | 31 | Atom atom, type; | ||
4907 | 32 | gulong nitems, bytes_after; | ||
4908 | 33 | guchar *str = NULL; | ||
4909 | 34 | int format, result; | ||
4910 | 35 | char *retval; | ||
4911 | 36 | |||
4912 | 37 | atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "WM_CLIENT_MACHINE", FALSE); | ||
4913 | 38 | |||
4914 | 39 | gdk_error_trap_push (); | ||
4915 | 40 | |||
4916 | 41 | result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), | ||
4917 | 42 | xwindow, atom, | ||
4918 | 43 | 0, G_MAXLONG, | ||
4919 | 44 | FALSE, XA_STRING, &type, &format, &nitems, | ||
4920 | 45 | &bytes_after, &str); | ||
4921 | 46 | |||
4922 | 47 | gdk_error_trap_pop (); | ||
4923 | 48 | |||
4924 | 49 | if (result != Success) | ||
4925 | 50 | return NULL; | ||
4926 | 51 | |||
4927 | 52 | if (type != XA_STRING) | ||
4928 | 53 | { | ||
4929 | 54 | XFree (str); | ||
4930 | 55 | return NULL; | ||
4931 | 56 | } | ||
4932 | 57 | |||
4933 | 58 | retval = g_strdup ((gchar *) str); | ||
4934 | 59 | |||
4935 | 60 | XFree (str); | ||
4936 | 61 | |||
4937 | 62 | return retval; | ||
4938 | 63 | } | ||
4939 | 64 | |||
4940 | 65 | static void | ||
4941 | 66 | kill_window (WnckWindow *win) | ||
4942 | 67 | { | ||
4943 | 68 | WnckApplication *app; | ||
4944 | 69 | |||
4945 | 70 | app = wnck_window_get_application (win); | ||
4946 | 71 | if (app) | ||
4947 | 72 | { | ||
4948 | 73 | gchar buf[257], *client_machine; | ||
4949 | 74 | int pid; | ||
4950 | 75 | |||
4951 | 76 | pid = wnck_application_get_pid (app); | ||
4952 | 77 | client_machine = get_client_machine (wnck_application_get_xid (app)); | ||
4953 | 78 | |||
4954 | 79 | if (client_machine && pid > 0) | ||
4955 | 80 | { | ||
4956 | 81 | if (gethostname (buf, sizeof (buf) - 1) == 0) | ||
4957 | 82 | { | ||
4958 | 83 | if (strcmp (buf, client_machine) == 0) | ||
4959 | 84 | kill (pid, 9); | ||
4960 | 85 | } | ||
4961 | 86 | } | ||
4962 | 87 | |||
4963 | 88 | if (client_machine) | ||
4964 | 89 | g_free (client_machine); | ||
4965 | 90 | } | ||
4966 | 91 | |||
4967 | 92 | gdk_error_trap_push (); | ||
4968 | 93 | XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win)); | ||
4969 | 94 | gdk_display_sync (gdk_display_get_default ()); | ||
4970 | 95 | gdk_error_trap_pop (); | ||
4971 | 96 | } | ||
4972 | 97 | |||
4973 | 98 | static void | ||
4974 | 99 | force_quit_dialog_realize (GtkWidget *dialog, | ||
4975 | 100 | void *data) | ||
4976 | 101 | { | ||
4977 | 102 | WnckWindow *win = data; | ||
4978 | 103 | |||
4979 | 104 | gdk_error_trap_push (); | ||
4980 | 105 | XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), | ||
4981 | 106 | GDK_WINDOW_XID (dialog->window), | ||
4982 | 107 | wnck_window_get_xid (win)); | ||
4983 | 108 | gdk_display_sync (gdk_display_get_default ()); | ||
4984 | 109 | gdk_error_trap_pop (); | ||
4985 | 110 | } | ||
4986 | 111 | |||
4987 | 112 | static void | ||
4988 | 113 | force_quit_dialog_response (GtkWidget *dialog, | ||
4989 | 114 | gint response, | ||
4990 | 115 | void *data) | ||
4991 | 116 | { | ||
4992 | 117 | WnckWindow *win = data; | ||
4993 | 118 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
4994 | 119 | |||
4995 | 120 | if (response == GTK_RESPONSE_ACCEPT) | ||
4996 | 121 | kill_window (win); | ||
4997 | 122 | |||
4998 | 123 | if (d->force_quit_dialog) | ||
4999 | 124 | { | ||
5000 | 125 | d->force_quit_dialog = NULL; |
1682 + int render (const GLMatrix &modelview,
1683 + const GLWindowPaintAttrib &attrib);
1684 +
1685 + int render (const GLMatrix &projection,
1686 + const GLMatrix &modelview,
1687 + const GLWindowPaintAttrib &attrib);
Probably for the sake of API confusion, it might be worth swapping the order of projection and modelview in this case, so you have
1685 + int render (const GLMatrix &modelview,
1686 + const GLMatrix &projection,
1687 + const GLWindowPaintAttrib &attrib);
--
1586 + GLProgram* operator () (std::list< GLShaderData* >);
Can that take a const std::list <GLShaderData *> & ?
1116 +#if !defined(GL_BGRA) GL_BGRA_ EXT)
1117 + #if !defined(
1118 + #error GL_BGRA support is required
1119 + #else
1120 + #define GL_BGRA GL_BGRA_EXT
1121 + #endif
1122 +#endif
This can probably be detected in CMake by using try_compile () [1]
1703 - <default> true</default> false</ default>
1704 + <default>
Does this need to be off by default?
1678 + void setProgram (GLProgram *program);
1679 +
1680 + int render (const GLMatrix &modelview);
1681 +
1682 + int render (const GLMatrix &modelview,
1683 + const GLWindowPaintAttrib &attrib);
1684 +
1685 + int render (const GLMatrix &projection,
1686 + const GLMatrix &modelview,
1687 + const GLWindowPaintAttrib &attrib);
The semantics of this are odd. Is GLVertexBuffer meant to be a stateful object which holds on to the state of what its rendering? In that case, it might be more appropriate to have a:
void setProjection ();
void setModelView ();
void setAttrib ();
However, on another though, perhaps all of these arguments are redundant. If glPushMatrix, glLoadMatrixf and glPopMatrix are all parts of the deprecated API, and PrivateGLVertex Buffer: :render is really doing this:
+ GLfloat params[4] = {0, 0, 0, 0};
+ GLfloat attribs[3] = {1, 1, 1};
+ GLint index = 0;
+
+ program->setUniform ("projection", projection);
+ program->setUniform ("modelview", modelview);
+ //convert paint attribs to 0-1 range >setUniform3f ("paintAttrib", attribs[0], attribs[1], attribs[2]);
+ attribs[0] = attrib.opacity / 65535.0f;
+ attribs[1] = attrib.brightness / 65535.0f;
+ attribs[2] = attrib.saturation / 65535.0f;
+ program-
+
Then it might make more sense to have helper objects in the OpenGL plugin to handle that so that you don't need to pass matrices or paint attributes to the GLVertexBuffer at render time and we don't need to continue to expand the ::render () function argument list should we add more things to the core profile.
The helper object might just server to build a GLProgram with that stuff built in so that it can be passed directly to GLVertexBuffer at render time. Just a thought.
+ #ifdef USE_GLES SCREEN_ DAMAGE_ ALL_MASK)
+ Display *xdpy = screen->dpy ();
+
+ glFlush ();
+ if (mask & COMPOSITE_
+ {
+ eglSwapBuffers (eglGetDisplay (xdpy), surface);
+ }
+ else
+ {
+ #warning use proper extension for this
+ eglSwapBuffers (eglGetDisplay (xdpy), surface);
+ }
+ eglW...