Merge lp:~linaro-graphics-wg/compiz-core/linaro-gles2 into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury on 2012-01-23
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
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.

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_texture_from_pixmap for GLES

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

To post a comment you must log in.
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (8.3 KiB)

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)
1117 + #if !defined(GL_BGRA_EXT)
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>
1704 + <default>false</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 PrivateGLVertexBuffer::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
+ attribs[0] = attrib.opacity / 65535.0f;
+ attribs[1] = attrib.brightness / 65535.0f;
+ attribs[2] = attrib.saturation / 65535.0f;
+ program->setUniform3f ("paintAttrib", attribs[0], attribs[1], attribs[2]);
+

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
+ Display *xdpy = screen->dpy ();
+
+ glFlush ();
+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ {
+ eglSwapBuffers (eglGetDisplay (xdpy), surface);
+ }
+ else
+ {
+ #warning use proper extension for this
+ eglSwapBuffers (eglGetDisplay (xdpy), surface);
+ }
+ eglW...

Read more...

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.

2901. By Frederic Plourde on 2012-01-25

Fix compiz decorator's shadow blending

2902. By Frederic Plourde on 2012-01-25

Workaround GL_LINE_LOOP usage in resize plugin

2903. By Frederic Plourde on 2012-01-25

Fix blending in the resize plugin

2904. By Frederic Plourde on 2012-01-25

Draw resize plugin in fullscreen mode to workaround rendering instabilities

2905. By Alexandros Frantzis on 2012-02-23

Sync with lp:compiz-core.

2906. By Alexandros Frantzis on 2012-02-23

Sync with lp:compiz-core.

2907. By Alexandros Frantzis on 2012-03-02

Sync with lp:compiz-core.

2908. By Alexandros Frantzis on 2012-03-05

Use new WRAPABLE_HND_* macros.

2909. By Alexandros Frantzis on 2012-03-05

Correct count of wrapable functions in GLScreen.

2910. By Alexandros Frantzis on 2012-03-05

Sync with lp:compiz-core

2911. By Frederic Plourde on 2012-03-09

Fix decoration mapping instabilities and texturing artefacts.

2912. By Alexandros Frantzis on 2012-03-13

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 on 2012-03-13

Sync with lp:compiz-core.

2914. By Alexandros Frantzis on 2012-03-21

Sync with lp:compiz-core.

2915. By Alexandros Frantzis on 2012-03-29

opengl: Ensure blending is enabled, when needed, when drawing window contents.

2916. By Alexandros Frantzis on 2012-04-02

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 on 2012-04-03

Sync with lp:compiz-core.

2918. By Alexandros Frantzis on 2012-04-04

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 on 2012-04-06

Fix compilation with desktop GL.

2920. By Alexandros Frantzis on 2012-04-06

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 on 2012-04-10

Sync with lp:compiz-core.

2922. By Alexandros Frantzis on 2012-04-19

Sync with lp:compiz-core.

Unmerged revisions

2922. By Alexandros Frantzis on 2012-04-19

Sync with lp:compiz-core.

2921. By Alexandros Frantzis on 2012-04-10

Sync with lp:compiz-core.

2920. By Alexandros Frantzis on 2012-04-06

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 on 2012-04-06

Fix compilation with desktop GL.

2918. By Alexandros Frantzis on 2012-04-04

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 on 2012-04-03

Sync with lp:compiz-core.

2916. By Alexandros Frantzis on 2012-04-02

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 on 2012-03-29

opengl: Ensure blending is enabled, when needed, when drawing window contents.

2914. By Alexandros Frantzis on 2012-03-21

Sync with lp:compiz-core.

2913. By Alexandros Frantzis on 2012-03-13

Sync with lp:compiz-core.

Preview Diff

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

Subscribers

People subscribed via source and target branches