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

Proposed by Alexandros Frantzis on 2012-04-20
Status: Superseded
Proposed branch: lp:~linaro-graphics-wg/compiz-core/linaro-gles2
Merge into: lp:compiz-core/0.9.8
Diff against target: 12066 lines (+4692/-4113) (has conflicts)
66 files modified
CMakeLists.txt (+12/-0)
cmake/CMakeLists.txt (+2/-0)
cmake/CompizCommon.cmake (+12/-0)
cmake/CompizPlugin.cmake (+14/-10)
cmake/FindOpenGLES2.cmake (+51/-0)
cmake/base.cmake (+3/-1)
cmake/plugin_extensions/CompizOpenGLFixups.cmake (+22/-0)
gtk/config.h.gtk.in (+0/-25)
gtk/window-decorator/actionmenu.c (+0/-133)
gtk/window-decorator/blurprops.c (+0/-89)
gtk/window-decorator/forcequit.c (+0/-201)
gtk/window-decorator/gdk.c (+0/-106)
gtk/window-decorator/style.c (+0/-66)
gtk/window-decorator/util.c (+0/-299)
plugins/annotate/src/annotate.cpp (+151/-77)
plugins/blur/CMakeLists.txt (+12/-12)
plugins/clone/src/clone.cpp (+0/-5)
plugins/compiztoolbox/src/compiztoolbox.cpp (+14/-28)
plugins/copytex/src/copytex.cpp (+9/-0)
plugins/cube/CMakeLists.txt (+1/-1)
plugins/cube/src/cube.cpp (+0/-4)
plugins/decor/src/decor.cpp (+35/-22)
plugins/decor/src/decor.h (+3/-3)
plugins/imgsvg/src/imgsvg.cpp (+12/-9)
plugins/imgsvg/src/imgsvg.h (+2/-1)
plugins/obs/src/obs.cpp (+9/-8)
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/fragment.h (+0/-125)
plugins/opengl/include/opengl/framebufferobject.h (+107/-0)
plugins/opengl/include/opengl/matrix.h (+2/-0)
plugins/opengl/include/opengl/opengl.h (+266/-72)
plugins/opengl/include/opengl/program.h (+75/-0)
plugins/opengl/include/opengl/programcache.h (+51/-0)
plugins/opengl/include/opengl/shadercache.h (+100/-0)
plugins/opengl/include/opengl/texture.h (+5/-0)
plugins/opengl/include/opengl/vector.h (+1/-1)
plugins/opengl/include/opengl/vertexbuffer.h (+109/-0)
plugins/opengl/opengl.xml.in (+1/-1)
plugins/opengl/src/fragment.cpp (+0/-1146)
plugins/opengl/src/framebufferobject.cpp (+191/-0)
plugins/opengl/src/matrix.cpp (+54/-0)
plugins/opengl/src/paint.cpp (+414/-422)
plugins/opengl/src/privatefragment.h (+0/-54)
plugins/opengl/src/privates.h (+36/-11)
plugins/opengl/src/privatetexture.h (+32/-0)
plugins/opengl/src/privatevertexbuffer.h (+138/-0)
plugins/opengl/src/program.cpp (+262/-0)
plugins/opengl/src/programcache.cpp (+175/-0)
plugins/opengl/src/screen.cpp (+558/-70)
plugins/opengl/src/shadercache.cpp (+246/-0)
plugins/opengl/src/texture.cpp (+136/-11)
plugins/opengl/src/vertexbuffer.cpp (+550/-0)
plugins/opengl/src/window.cpp (+69/-84)
plugins/resize/src/resize.cpp (+95/-39)
plugins/rotate/CMakeLists.txt (+1/-1)
plugins/scale/src/scale.cpp (+12/-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)
Text conflict in plugins/opengl/src/screen.cpp
To merge this branch: bzr merge lp:~linaro-graphics-wg/compiz-core/linaro-gles2
Reviewer Review Type Date Requested Status
Compiz Maintainers 2012-04-20 Pending
Review via email: mp+102823@code.launchpad.net

This proposal has been superseded by a proposal from 2012-05-14.

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
* GLShaderCache class added for managing dynamically created shader source code.
* GLFragment class removed as fragment programs are no longer used (replaced with GLSL programs)
* 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:

  * 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.
Alan Griffiths (alan-griffiths) wrote :

Apart from a few (mostly simple) merge conflicts this builds with trunk. Unsurprisingly the unit tests pass (they don't touch the affected codepath).

Apart from a lack of the usual plugins the result runs.

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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-03-27 15:28:35 +0000
+++ CMakeLists.txt 2012-04-20 09:45:47 +0000
@@ -119,6 +119,12 @@
119 DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig119 DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig
120)120)
121121
122# temporarily disable plugins that aren't ported yed
123set (COMPIZ_DISABLE_PLUGIN_BLUR ON)
124set (COMPIZ_DISABLE_PLUGIN_CUBE ON)
125set (COMPIZ_DISABLE_PLUGIN_ROTATE ON)
126set (COMPIZ_DISABLE_PLUGIN_WOBBLY ON)
127
122# Build Google Test and make its headers known128# Build Google Test and make its headers known
123find_package (GTest)129find_package (GTest)
124130
@@ -183,6 +189,12 @@
183189
184_check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG})190_check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG})
185191
192# temporarily disable plugins that aren't ported yed
193SET(COMPIZ_DISABLE_PLUGIN_BLUR "ON")
194SET(COMPIZ_DISABLE_PLUGIN_CUBE "ON")
195SET(COMPIZ_DISABLE_PLUGIN_ROTATE "ON")
196SET(COMPIZ_DISABLE_PLUGIN_WATER "ON")
197SET(COMPIZ_DISABLE_PLUGIN_WOBBLY "ON")
186# Enable coverage reporting for compiz198# Enable coverage reporting for compiz
187enable_coverage_report()199enable_coverage_report()
188200
189201
=== modified file 'cmake/CMakeLists.txt'
--- cmake/CMakeLists.txt 2011-07-27 16:13:28 +0000
+++ cmake/CMakeLists.txt 2012-04-20 09:45:47 +0000
@@ -15,6 +15,8 @@
15 plugin_extensions/CompizGenInstallData.cmake)15 plugin_extensions/CompizGenInstallData.cmake)
16list (APPEND _PluginExtensionFiles16list (APPEND _PluginExtensionFiles
17 plugin_extensions/CompizGenInstallImages.cmake)17 plugin_extensions/CompizGenInstallImages.cmake)
18list (APPEND _PluginExtensionFiles
19 plugin_extensions/CompizOpenGLFixups.cmake)
1820
19if (USE_GCONF)21if (USE_GCONF)
20 list (APPEND _files CompizGconf.cmake)22 list (APPEND _files CompizGconf.cmake)
2123
=== modified file 'cmake/CompizCommon.cmake'
--- cmake/CompizCommon.cmake 2012-01-27 07:01:47 +0000
+++ cmake/CompizCommon.cmake 2012-04-20 09:45:47 +0000
@@ -18,6 +18,7 @@
1818
19set (CMAKE_SKIP_RPATH FALSE)19set (CMAKE_SKIP_RPATH FALSE)
2020
21option (BUILD_GLES "Build against GLESv2 instead of GL" OFF)
21option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)22option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)
22option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")23option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")
23option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)24option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)
@@ -75,6 +76,17 @@
75 set(IS_BZR_REPO 0)76 set(IS_BZR_REPO 0)
76endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)77endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
7778
79set (USE_GLES ${BUILD_GLES})
80
81if (USE_GLES)
82 find_package(OpenGLES2)
83
84 if (NOT OPENGLES2_FOUND)
85 set (USE_GLES 0)
86 message (SEND_ERROR "OpenGLESv2 not found")
87 endif (NOT OPENGLES2_FOUND)
88endif (USE_GLES)
89
78function (compiz_ensure_linkage)90function (compiz_ensure_linkage)
79 find_program (LDCONFIG_EXECUTABLE ldconfig)91 find_program (LDCONFIG_EXECUTABLE ldconfig)
80 mark_as_advanced (FORCE LDCONFIG_EXECUTABLE)92 mark_as_advanced (FORCE LDCONFIG_EXECUTABLE)
8193
=== modified file 'cmake/CompizPlugin.cmake'
--- cmake/CompizPlugin.cmake 2012-02-07 06:39:28 +0000
+++ cmake/CompizPlugin.cmake 2012-04-20 09:45:47 +0000
@@ -257,6 +257,16 @@
257 NO_DEFAULT_PATH257 NO_DEFAULT_PATH
258 )258 )
259259
260 set (COMPIZ_CURRENT_PLUGIN ${plugin})
261 set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
262
263 # find extension files
264 file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
265
266 foreach (_file ${_extension_files})
267 include (${_file})
268 endforeach ()
269
260 # generate pkgconfig file and install it and the plugin header file270 # generate pkgconfig file and install it and the plugin header file
261 if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})271 if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})
262 if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")272 if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")
@@ -269,11 +279,15 @@
269 set (VERSION 0.0.1-git)279 set (VERSION 0.0.1-git)
270 endif (NOT VERSION)280 endif (NOT VERSION)
271281
282 #add CFLAGSADD so pkg-config file has correct flags
283 set (COMPIZ_CFLAGS ${COMPIZ_CFLAGS} ${${_PLUGIN}_CFLAGSADD})
284
272 compiz_configure_file (285 compiz_configure_file (
273 ${_${plugin}_pkg}286 ${_${plugin}_pkg}
274 ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc287 ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc
275 COMPIZ_REQUIRES288 COMPIZ_REQUIRES
276 COMPIZ_CFLAGS289 COMPIZ_CFLAGS
290 PKGCONFIG_LIBS
277 )291 )
278292
279 install (293 install (
@@ -287,16 +301,6 @@
287 endif ()301 endif ()
288 endif ()302 endif ()
289303
290 set (COMPIZ_CURRENT_PLUGIN ${plugin})
291 set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
292
293 # find extension files
294 file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
295
296 foreach (_file ${_extension_files})
297 include (${_file})
298 endforeach ()
299
300 # find files for build304 # find files for build
301 file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")305 file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
302 file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")306 file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")
303307
=== added file 'cmake/FindOpenGLES2.cmake'
--- cmake/FindOpenGLES2.cmake 1970-01-01 00:00:00 +0000
+++ cmake/FindOpenGLES2.cmake 2012-04-20 09:45:47 +0000
@@ -0,0 +1,51 @@
1# - Try to find OpenGLES
2# Once done this will define
3#
4# OPENGLES2_FOUND - system has OpenGLES
5# OPENGLES2_INCLUDE_DIR - the GLES include directory
6# OPENGLES2_LIBRARY - the GLES library
7# OPENGLES2_LIBRARIES - Link this to use OpenGLES
8#
9
10FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
11 /usr/openwin/share/include
12 /opt/graphics/OpenGL/include /usr/X11R6/include
13 /usr/include
14)
15
16FIND_LIBRARY(OPENGLES2_LIBRARY
17 NAMES GLESv2
18 PATHS /opt/graphics/OpenGL/lib
19 /usr/openwin/lib
20 /usr/shlib /usr/X11R6/lib
21 /usr/lib
22)
23
24FIND_LIBRARY(OPENGLES2_EGL_LIBRARY
25 NAMES EGL
26 PATHS /usr/shlib /usr/X11R6/lib
27 /usr/lib
28)
29
30# On Unix OpenGL most certainly always requires X11.
31# Feel free to tighten up these conditions if you don't
32# think this is always true.
33# It's not true on OSX.
34
35IF (OPENGLES2_LIBRARY)
36 IF(NOT X11_FOUND)
37 INCLUDE(FindX11)
38 ENDIF(NOT X11_FOUND)
39 IF (X11_FOUND)
40 IF (NOT APPLE)
41 SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
42 ENDIF (NOT APPLE)
43 ENDIF (X11_FOUND)
44ENDIF(OPENGLES2_LIBRARY)
45
46SET( OPENGLES2_FOUND "NO" )
47IF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
48 SET( OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${OPENGLES2_EGL_LIBRARY} ${OPENGLES2_LIBRARIES})
49 SET( OPENGLES2_FOUND "YES" )
50ENDIF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
51
052
=== modified file 'cmake/base.cmake'
--- cmake/base.cmake 2011-07-27 16:13:28 +0000
+++ cmake/base.cmake 2012-04-20 09:45:47 +0000
@@ -24,6 +24,7 @@
24 compiz_print_configure_header ("Compiz")24 compiz_print_configure_header ("Compiz")
25 compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")25 compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")
2626
27 compiz_print_result_message ("GLESv2" USE_GLES)
27 compiz_print_result_message ("gtk window decorator" USE_GTK)28 compiz_print_result_message ("gtk window decorator" USE_GTK)
28 compiz_print_result_message ("metacity theme support" USE_METACITY)29 compiz_print_result_message ("metacity theme support" USE_METACITY)
29 compiz_print_result_message ("gconf schemas" USE_GCONF)30 compiz_print_result_message ("gconf schemas" USE_GCONF)
@@ -46,7 +47,8 @@
46 endif ()47 endif ()
47 add_custom_target (findcompiz_install48 add_custom_target (findcompiz_install
48 ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&49 ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&
49 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules50 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&
51 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindOpenGLES2.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules
50 )52 )
51endfunction ()53endfunction ()
5254
5355
=== added file 'cmake/plugin_extensions/CompizOpenGLFixups.cmake'
--- cmake/plugin_extensions/CompizOpenGLFixups.cmake 1970-01-01 00:00:00 +0000
+++ cmake/plugin_extensions/CompizOpenGLFixups.cmake 2012-04-20 09:45:47 +0000
@@ -0,0 +1,22 @@
1
2# modify pkg-config libs for opengl based on if we found GLES or not
3if (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
4 if (USE_GLES)
5 set (PKGCONFIG_LIBS "-lGLESv2 -lEGL")
6 else (USE_GLES)
7 set (PKGCONFIG_LIBS "-lGL")
8 endif (USE_GLES)
9endif (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
10
11# if plugin is using opengl plugin check for GLES library and set correct define
12if (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
13 string (REGEX MATCH "opengl" opengl_found ${${_PLUGIN}_PLUGINDEPS})
14
15 if (opengl_found STREQUAL "opengl")
16 if (USE_GLES)
17 set (${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD} " -DUSE_GLES")
18 string (REPLACE ";" " " ${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD})
19 endif (USE_GLES)
20 endif (opengl_found STREQUAL "opengl")
21endif (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
22
023
=== added file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000
+++ gtk/config.h.gtk.in 2012-04-20 09:45:47 +0000
@@ -0,0 +1,25 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
026
=== removed file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 2008-10-14 10:27:55 +0000
+++ gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
260
=== added file 'gtk/window-decorator/actionmenu.c'
--- gtk/window-decorator/actionmenu.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/actionmenu.c 2012-04-20 09:45:47 +0000
@@ -0,0 +1,133 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24static void
25action_menu_unmap (GObject *object)
26{
27 action_menu_mapped = FALSE;
28}
29
30static void
31position_action_menu (GtkMenu *menu,
32 gint *x,
33 gint *y,
34 gboolean *push_in,
35 gpointer user_data)
36{
37 WnckWindow *win = (WnckWindow *) user_data;
38 decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win));
39 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
40 gint bx, by, width, height;
41
42 wnck_window_get_client_window_geometry (win, x, y, &width, &height);
43
44 if ((*theme_get_button_position) (d, BUTTON_MENU, width, height,
45 &bx, &by, &width, &height))
46 *x = *x - frame->win_extents.left + bx;
47
48 gwd_decor_frame_unref (frame);
49
50 if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
51 {
52 GtkRequisition req;
53
54 gtk_widget_size_request (GTK_WIDGET (menu), &req);
55 *x = MAX (0, *x - req.width + width);
56 }
57
58 *push_in = TRUE;
59}
60
61void
62action_menu_map (WnckWindow *win,
63 long button,
64 Time time)
65{
66 GdkDisplay *gdkdisplay;
67 GdkScreen *screen;
68
69 gdkdisplay = gdk_display_get_default ();
70 screen = gdk_display_get_default_screen (gdkdisplay);
71
72 if (action_menu)
73 {
74 if (action_menu_mapped)
75 {
76 gtk_widget_destroy (action_menu);
77 action_menu_mapped = FALSE;
78 action_menu = NULL;
79 return;
80 }
81 else
82 gtk_widget_destroy (action_menu);
83 }
84
85 switch (wnck_window_get_window_type (win)) {
86 case WNCK_WINDOW_DESKTOP:
87 case WNCK_WINDOW_DOCK:
88 /* don't allow window action */
89 return;
90 case WNCK_WINDOW_NORMAL:
91 case WNCK_WINDOW_DIALOG:
92
93#ifndef HAVE_LIBWNCK_2_19_4
94 case WNCK_WINDOW_MODAL_DIALOG:
95#endif
96
97 case WNCK_WINDOW_TOOLBAR:
98 case WNCK_WINDOW_MENU:
99 case WNCK_WINDOW_UTILITY:
100 case WNCK_WINDOW_SPLASHSCREEN:
101 /* allow window action menu */
102 break;
103 }
104
105 action_menu = wnck_create_window_action_menu (win);
106
107 gtk_menu_set_screen (GTK_MENU (action_menu), screen);
108
109 g_signal_connect_object (G_OBJECT (action_menu), "unmap",
110 G_CALLBACK (action_menu_unmap),
111 0, 0);
112
113 gtk_widget_show (action_menu);
114
115 if (!button || button == 1)
116 {
117 gtk_menu_popup (GTK_MENU (action_menu),
118 NULL, NULL,
119 position_action_menu, (gpointer) win,
120 button,
121 time);
122 }
123 else
124 {
125 gtk_menu_popup (GTK_MENU (action_menu),
126 NULL, NULL,
127 NULL, NULL,
128 button,
129 time);
130 }
131
132 action_menu_mapped = TRUE;
133}
0134
=== removed file 'gtk/window-decorator/actionmenu.c'
--- gtk/window-decorator/actionmenu.c 2011-05-07 08:58:10 +0000
+++ gtk/window-decorator/actionmenu.c 1970-01-01 00:00:00 +0000
@@ -1,133 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24static void
25action_menu_unmap (GObject *object)
26{
27 action_menu_mapped = FALSE;
28}
29
30static void
31position_action_menu (GtkMenu *menu,
32 gint *x,
33 gint *y,
34 gboolean *push_in,
35 gpointer user_data)
36{
37 WnckWindow *win = (WnckWindow *) user_data;
38 decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win));
39 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
40 gint bx, by, width, height;
41
42 wnck_window_get_client_window_geometry (win, x, y, &width, &height);
43
44 if ((*theme_get_button_position) (d, BUTTON_MENU, width, height,
45 &bx, &by, &width, &height))
46 *x = *x - frame->win_extents.left + bx;
47
48 gwd_decor_frame_unref (frame);
49
50 if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
51 {
52 GtkRequisition req;
53
54 gtk_widget_size_request (GTK_WIDGET (menu), &req);
55 *x = MAX (0, *x - req.width + width);
56 }
57
58 *push_in = TRUE;
59}
60
61void
62action_menu_map (WnckWindow *win,
63 long button,
64 Time time)
65{
66 GdkDisplay *gdkdisplay;
67 GdkScreen *screen;
68
69 gdkdisplay = gdk_display_get_default ();
70 screen = gdk_display_get_default_screen (gdkdisplay);
71
72 if (action_menu)
73 {
74 if (action_menu_mapped)
75 {
76 gtk_widget_destroy (action_menu);
77 action_menu_mapped = FALSE;
78 action_menu = NULL;
79 return;
80 }
81 else
82 gtk_widget_destroy (action_menu);
83 }
84
85 switch (wnck_window_get_window_type (win)) {
86 case WNCK_WINDOW_DESKTOP:
87 case WNCK_WINDOW_DOCK:
88 /* don't allow window action */
89 return;
90 case WNCK_WINDOW_NORMAL:
91 case WNCK_WINDOW_DIALOG:
92
93#ifndef HAVE_LIBWNCK_2_19_4
94 case WNCK_WINDOW_MODAL_DIALOG:
95#endif
96
97 case WNCK_WINDOW_TOOLBAR:
98 case WNCK_WINDOW_MENU:
99 case WNCK_WINDOW_UTILITY:
100 case WNCK_WINDOW_SPLASHSCREEN:
101 /* allow window action menu */
102 break;
103 }
104
105 action_menu = wnck_create_window_action_menu (win);
106
107 gtk_menu_set_screen (GTK_MENU (action_menu), screen);
108
109 g_signal_connect_object (G_OBJECT (action_menu), "unmap",
110 G_CALLBACK (action_menu_unmap),
111 0, 0);
112
113 gtk_widget_show (action_menu);
114
115 if (!button || button == 1)
116 {
117 gtk_menu_popup (GTK_MENU (action_menu),
118 NULL, NULL,
119 position_action_menu, (gpointer) win,
120 button,
121 time);
122 }
123 else
124 {
125 gtk_menu_popup (GTK_MENU (action_menu),
126 NULL, NULL,
127 NULL, NULL,
128 button,
129 time);
130 }
131
132 action_menu_mapped = TRUE;
133}
1340
=== added file 'gtk/window-decorator/blurprops.c'
--- gtk/window-decorator/blurprops.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/blurprops.c 2012-04-20 09:45:47 +0000
@@ -0,0 +1,89 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25decor_update_blur_property (decor_t *d,
26 int width,
27 int height,
28 Region top_region,
29 int top_offset,
30 Region bottom_region,
31 int bottom_offset,
32 Region left_region,
33 int left_offset,
34 Region right_region,
35 int right_offset)
36{
37 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
38 long *data = NULL;
39 int size = 0;
40
41 if (settings->blur_type != BLUR_TYPE_ALL)
42 {
43 bottom_region = NULL;
44 left_region = NULL;
45 right_region = NULL;
46
47 if (settings->blur_type != BLUR_TYPE_TITLEBAR)
48 top_region = NULL;
49 }
50
51 if (top_region)
52 size += top_region->numRects;
53 if (bottom_region)
54 size += bottom_region->numRects;
55 if (left_region)
56 size += left_region->numRects;
57 if (right_region)
58 size += right_region->numRects;
59
60 if (size)
61 data = (long *) malloc (sizeof (long) * (2 + size * 6));
62
63 if (data)
64 {
65 decor_region_to_blur_property (data, 4, 0, width, height,
66 top_region, top_offset,
67 bottom_region, bottom_offset,
68 left_region, left_offset,
69 right_region, right_offset);
70
71 gdk_error_trap_push ();
72 XChangeProperty (xdisplay, d->prop_xid,
73 win_blur_decor_atom,
74 XA_INTEGER,
75 32, PropModeReplace, (guchar *) data,
76 2 + size * 6);
77 gdk_display_sync (gdk_display_get_default ());
78 gdk_error_trap_pop ();
79
80 free (data);
81 }
82 else
83 {
84 gdk_error_trap_push ();
85 XDeleteProperty (xdisplay, d->prop_xid, win_blur_decor_atom);
86 gdk_display_sync (gdk_display_get_default ());
87 gdk_error_trap_pop ();
88 }
89}
090
=== removed file 'gtk/window-decorator/blurprops.c'
--- gtk/window-decorator/blurprops.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/blurprops.c 1970-01-01 00:00:00 +0000
@@ -1,89 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25decor_update_blur_property (decor_t *d,
26 int width,
27 int height,
28 Region top_region,
29 int top_offset,
30 Region bottom_region,
31 int bottom_offset,
32 Region left_region,
33 int left_offset,
34 Region right_region,
35 int right_offset)
36{
37 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
38 long *data = NULL;
39 int size = 0;
40
41 if (settings->blur_type != BLUR_TYPE_ALL)
42 {
43 bottom_region = NULL;
44 left_region = NULL;
45 right_region = NULL;
46
47 if (settings->blur_type != BLUR_TYPE_TITLEBAR)
48 top_region = NULL;
49 }
50
51 if (top_region)
52 size += top_region->numRects;
53 if (bottom_region)
54 size += bottom_region->numRects;
55 if (left_region)
56 size += left_region->numRects;
57 if (right_region)
58 size += right_region->numRects;
59
60 if (size)
61 data = (long *) malloc (sizeof (long) * (2 + size * 6));
62
63 if (data)
64 {
65 decor_region_to_blur_property (data, 4, 0, width, height,
66 top_region, top_offset,
67 bottom_region, bottom_offset,
68 left_region, left_offset,
69 right_region, right_offset);
70
71 gdk_error_trap_push ();
72 XChangeProperty (xdisplay, d->prop_xid,
73 win_blur_decor_atom,
74 XA_INTEGER,
75 32, PropModeReplace, (guchar *) data,
76 2 + size * 6);
77 gdk_display_sync (gdk_display_get_default ());
78 gdk_error_trap_pop ();
79
80 free (data);
81 }
82 else
83 {
84 gdk_error_trap_push ();
85 XDeleteProperty (xdisplay, d->prop_xid, win_blur_decor_atom);
86 gdk_display_sync (gdk_display_get_default ());
87 gdk_error_trap_pop ();
88 }
89}
900
=== added file 'gtk/window-decorator/forcequit.c'
--- gtk/window-decorator/forcequit.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/forcequit.c 2012-04-20 09:45:47 +0000
@@ -0,0 +1,201 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 *
21 * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com>
22 * Frames Management: Copright © 2011 Canonical Ltd.
23 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "gtk-window-decorator.h"
27
28static char *
29get_client_machine (Window xwindow)
30{
31 Atom atom, type;
32 gulong nitems, bytes_after;
33 guchar *str = NULL;
34 int format, result;
35 char *retval;
36
37 atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "WM_CLIENT_MACHINE", FALSE);
38
39 gdk_error_trap_push ();
40
41 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
42 xwindow, atom,
43 0, G_MAXLONG,
44 FALSE, XA_STRING, &type, &format, &nitems,
45 &bytes_after, &str);
46
47 gdk_error_trap_pop ();
48
49 if (result != Success)
50 return NULL;
51
52 if (type != XA_STRING)
53 {
54 XFree (str);
55 return NULL;
56 }
57
58 retval = g_strdup ((gchar *) str);
59
60 XFree (str);
61
62 return retval;
63}
64
65static void
66kill_window (WnckWindow *win)
67{
68 WnckApplication *app;
69
70 app = wnck_window_get_application (win);
71 if (app)
72 {
73 gchar buf[257], *client_machine;
74 int pid;
75
76 pid = wnck_application_get_pid (app);
77 client_machine = get_client_machine (wnck_application_get_xid (app));
78
79 if (client_machine && pid > 0)
80 {
81 if (gethostname (buf, sizeof (buf) - 1) == 0)
82 {
83 if (strcmp (buf, client_machine) == 0)
84 kill (pid, 9);
85 }
86 }
87
88 if (client_machine)
89 g_free (client_machine);
90 }
91
92 gdk_error_trap_push ();
93 XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win));
94 gdk_display_sync (gdk_display_get_default ());
95 gdk_error_trap_pop ();
96}
97
98static void
99force_quit_dialog_realize (GtkWidget *dialog,
100 void *data)
101{
102 WnckWindow *win = data;
103
104 gdk_error_trap_push ();
105 XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
106 GDK_WINDOW_XID (dialog->window),
107 wnck_window_get_xid (win));
108 gdk_display_sync (gdk_display_get_default ());
109 gdk_error_trap_pop ();
110}
111
112static void
113force_quit_dialog_response (GtkWidget *dialog,
114 gint response,
115 void *data)
116{
117 WnckWindow *win = data;
118 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
119
120 if (response == GTK_RESPONSE_ACCEPT)
121 kill_window (win);
122
123 if (d->force_quit_dialog)
124 {
125 d->force_quit_dialog = NULL;
126 gtk_widget_destroy (dialog);
127 }
128}
129
130void
131show_force_quit_dialog (WnckWindow *win,
132 Time timestamp)
133{
134 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
135 GtkWidget *dialog;
136 gchar *str, *tmp;
137
138 if (d->force_quit_dialog)
139 return;
140
141 tmp = g_markup_escape_text (wnck_window_get_name (win), -1);
142 str = g_strdup_printf (_("The window \"%s\" is not responding."), tmp);
143
144 g_free (tmp);
145
146 dialog = gtk_message_dialog_new (NULL, 0,
147 GTK_MESSAGE_WARNING,
148 GTK_BUTTONS_NONE,
149 "<b>%s</b>\n\n%s",
150 str,
151 _("Forcing this application to "
152 "quit will cause you to lose any "
153 "unsaved changes."));
154 g_free (str);
155
156 gtk_window_set_icon_name (GTK_WINDOW (dialog), "force-quit");
157
158 gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
159 TRUE);
160 gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
161 TRUE);
162
163 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
164 GTK_STOCK_CANCEL,
165 GTK_RESPONSE_REJECT,
166 _("_Force Quit"),
167 GTK_RESPONSE_ACCEPT,
168 NULL);
169
170 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
171
172 g_signal_connect (G_OBJECT (dialog), "realize",
173 G_CALLBACK (force_quit_dialog_realize),
174 win);
175
176 g_signal_connect (G_OBJECT (dialog), "response",
177 G_CALLBACK (force_quit_dialog_response),
178 win);
179
180 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
181
182 gtk_widget_realize (dialog);
183
184 gdk_x11_window_set_user_time (dialog->window, timestamp);
185
186 gtk_widget_show (dialog);
187
188 d->force_quit_dialog = dialog;
189}
190
191void
192hide_force_quit_dialog (WnckWindow *win)
193{
194 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
195
196 if (d->force_quit_dialog)
197 {
198 gtk_widget_destroy (d->force_quit_dialog);
199 d->force_quit_dialog = NULL;
200 }
201}
0202
=== removed file 'gtk/window-decorator/forcequit.c'
--- gtk/window-decorator/forcequit.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/forcequit.c 1970-01-01 00:00:00 +0000
@@ -1,201 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 *
21 * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com>
22 * Frames Management: Copright © 2011 Canonical Ltd.
23 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "gtk-window-decorator.h"
27
28static char *
29get_client_machine (Window xwindow)
30{
31 Atom atom, type;
32 gulong nitems, bytes_after;
33 guchar *str = NULL;
34 int format, result;
35 char *retval;
36
37 atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "WM_CLIENT_MACHINE", FALSE);
38
39 gdk_error_trap_push ();
40
41 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
42 xwindow, atom,
43 0, G_MAXLONG,
44 FALSE, XA_STRING, &type, &format, &nitems,
45 &bytes_after, &str);
46
47 gdk_error_trap_pop ();
48
49 if (result != Success)
50 return NULL;
51
52 if (type != XA_STRING)
53 {
54 XFree (str);
55 return NULL;
56 }
57
58 retval = g_strdup ((gchar *) str);
59
60 XFree (str);
61
62 return retval;
63}
64
65static void
66kill_window (WnckWindow *win)
67{
68 WnckApplication *app;
69
70 app = wnck_window_get_application (win);
71 if (app)
72 {
73 gchar buf[257], *client_machine;
74 int pid;
75
76 pid = wnck_application_get_pid (app);
77 client_machine = get_client_machine (wnck_application_get_xid (app));
78
79 if (client_machine && pid > 0)
80 {
81 if (gethostname (buf, sizeof (buf) - 1) == 0)
82 {
83 if (strcmp (buf, client_machine) == 0)
84 kill (pid, 9);
85 }
86 }
87
88 if (client_machine)
89 g_free (client_machine);
90 }
91
92 gdk_error_trap_push ();
93 XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win));
94 gdk_display_sync (gdk_display_get_default ());
95 gdk_error_trap_pop ();
96}
97
98static void
99force_quit_dialog_realize (GtkWidget *dialog,
100 void *data)
101{
102 WnckWindow *win = data;
103
104 gdk_error_trap_push ();
105 XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
106 GDK_WINDOW_XID (dialog->window),
107 wnck_window_get_xid (win));
108 gdk_display_sync (gdk_display_get_default ());
109 gdk_error_trap_pop ();
110}
111
112static void
113force_quit_dialog_response (GtkWidget *dialog,
114 gint response,
115 void *data)
116{
117 WnckWindow *win = data;
118 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
119
120 if (response == GTK_RESPONSE_ACCEPT)
121 kill_window (win);
122
123 if (d->force_quit_dialog)
124 {
125 d->force_quit_dialog = NULL;
126 gtk_widget_destroy (dialog);
127 }
128}
129
130void
131show_force_quit_dialog (WnckWindow *win,
132 Time timestamp)
133{
134 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
135 GtkWidget *dialog;
136 gchar *str, *tmp;
137
138 if (d->force_quit_dialog)
139 return;
140
141 tmp = g_markup_escape_text (wnck_window_get_name (win), -1);
142 str = g_strdup_printf (_("The window \"%s\" is not responding."), tmp);
143
144 g_free (tmp);
145
146 dialog = gtk_message_dialog_new (NULL, 0,
147 GTK_MESSAGE_WARNING,
148 GTK_BUTTONS_NONE,
149 "<b>%s</b>\n\n%s",
150 str,
151 _("Forcing this application to "
152 "quit will cause you to lose any "
153 "unsaved changes."));
154 g_free (str);
155
156 gtk_window_set_icon_name (GTK_WINDOW (dialog), "force-quit");
157
158 gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
159 TRUE);
160 gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
161 TRUE);
162
163 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
164 GTK_STOCK_CANCEL,
165 GTK_RESPONSE_REJECT,
166 _("_Force Quit"),
167 GTK_RESPONSE_ACCEPT,
168 NULL);
169
170 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
171
172 g_signal_connect (G_OBJECT (dialog), "realize",
173 G_CALLBACK (force_quit_dialog_realize),
174 win);
175
176 g_signal_connect (G_OBJECT (dialog), "response",
177 G_CALLBACK (force_quit_dialog_response),
178 win);
179
180 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
181
182 gtk_widget_realize (dialog);
183
184 gdk_x11_window_set_user_time (dialog->window, timestamp);
185
186 gtk_widget_show (dialog);
187
188 d->force_quit_dialog = dialog;
189}
190
191void
192hide_force_quit_dialog (WnckWindow *win)
193{
194 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
195
196 if (d->force_quit_dialog)
197 {
198 gtk_widget_destroy (d->force_quit_dialog);
199 d->force_quit_dialog = NULL;
200 }
201}
2020
=== added file 'gtk/window-decorator/gdk.c'
--- gtk/window-decorator/gdk.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/gdk.c 2012-04-20 09:45:47 +0000
@@ -0,0 +1,106 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24GdkPixmap *
25pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent)
26{
27 GdkPixmap *pixmap;
28 guint width, height;
29 cairo_t *cr;
30
31 width = gdk_pixbuf_get_width (pixbuf);
32 height = gdk_pixbuf_get_height (pixbuf);
33
34 pixmap = create_pixmap (width, height, parent);
35 if (!pixmap)
36 return NULL;
37
38 cr = (cairo_t *) gdk_cairo_create (GDK_DRAWABLE (pixmap));
39 gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
40 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
41 cairo_paint (cr);
42 cairo_destroy (cr);
43
44 return pixmap;
45}
46
47
48void
49gdk_cairo_set_source_color_alpha (cairo_t *cr,
50 GdkColor *color,
51 double alpha)
52{
53 cairo_set_source_rgba (cr,
54 color->red / 65535.0,
55 color->green / 65535.0,
56 color->blue / 65535.0,
57 alpha);
58}
59
60inline GdkWindow *
61create_gdk_window (Window xframe)
62{
63 GdkDisplay *display = gdk_display_get_default ();
64 GdkScreen *screen = gdk_display_get_default_screen (display);
65 GdkWindow *window = create_foreign_window (xframe);
66 GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen);
67
68 gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap);
69
70 return window;
71}
72
73GdkColormap *
74get_colormap_for_drawable (GdkDrawable *d)
75{
76 GdkDisplay *display = gdk_display_get_default ();
77 GdkScreen *screen = gdk_display_get_default_screen (display);
78
79 if (gdk_drawable_get_depth (d) == 32)
80 return gdk_screen_get_rgba_colormap (screen);
81
82 return gdk_screen_get_rgb_colormap (screen);
83}
84
85XRenderPictFormat *
86get_format_for_drawable (decor_t *d, GdkDrawable *drawable)
87{
88 if (!d->frame_window || gdk_drawable_get_depth (drawable) == 32)
89 return xformat_rgba;
90
91 return xformat_rgb;
92}
93
94GdkPixmap *
95create_pixmap (int w,
96 int h,
97 GtkWidget *parent_style_window)
98{
99 GdkWindow *window;
100
101 if (w == 0 || h == 0)
102 abort ();
103
104 window = gtk_widget_get_window (parent_style_window);
105 return gdk_pixmap_new (GDK_DRAWABLE (window), w, h, -1 /* CopyFromParent */);
106}
0107
=== removed file 'gtk/window-decorator/gdk.c'
--- gtk/window-decorator/gdk.c 2011-02-23 18:11:11 +0000
+++ gtk/window-decorator/gdk.c 1970-01-01 00:00:00 +0000
@@ -1,106 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24GdkPixmap *
25pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent)
26{
27 GdkPixmap *pixmap;
28 guint width, height;
29 cairo_t *cr;
30
31 width = gdk_pixbuf_get_width (pixbuf);
32 height = gdk_pixbuf_get_height (pixbuf);
33
34 pixmap = create_pixmap (width, height, parent);
35 if (!pixmap)
36 return NULL;
37
38 cr = (cairo_t *) gdk_cairo_create (GDK_DRAWABLE (pixmap));
39 gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
40 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
41 cairo_paint (cr);
42 cairo_destroy (cr);
43
44 return pixmap;
45}
46
47
48void
49gdk_cairo_set_source_color_alpha (cairo_t *cr,
50 GdkColor *color,
51 double alpha)
52{
53 cairo_set_source_rgba (cr,
54 color->red / 65535.0,
55 color->green / 65535.0,
56 color->blue / 65535.0,
57 alpha);
58}
59
60inline GdkWindow *
61create_gdk_window (Window xframe)
62{
63 GdkDisplay *display = gdk_display_get_default ();
64 GdkScreen *screen = gdk_display_get_default_screen (display);
65 GdkWindow *window = create_foreign_window (xframe);
66 GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen);
67
68 gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap);
69
70 return window;
71}
72
73GdkColormap *
74get_colormap_for_drawable (GdkDrawable *d)
75{
76 GdkDisplay *display = gdk_display_get_default ();
77 GdkScreen *screen = gdk_display_get_default_screen (display);
78
79 if (gdk_drawable_get_depth (d) == 32)
80 return gdk_screen_get_rgba_colormap (screen);
81
82 return gdk_screen_get_rgb_colormap (screen);
83}
84
85XRenderPictFormat *
86get_format_for_drawable (decor_t *d, GdkDrawable *drawable)
87{
88 if (!d->frame_window || gdk_drawable_get_depth (drawable) == 32)
89 return xformat_rgba;
90
91 return xformat_rgb;
92}
93
94GdkPixmap *
95create_pixmap (int w,
96 int h,
97 GtkWidget *parent_style_window)
98{
99 GdkWindow *window;
100
101 if (w == 0 || h == 0)
102 abort ();
103
104 window = gtk_widget_get_window (parent_style_window);
105 return gdk_pixmap_new (GDK_DRAWABLE (window), w, h, -1 /* CopyFromParent */);
106}
1070
=== added file 'gtk/window-decorator/style.c'
--- gtk/window-decorator/style.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/style.c 2012-04-20 09:45:47 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25update_style (GtkWidget *widget)
26{
27 GtkStyle *style;
28 decor_color_t spot_color;
29
30 style = gtk_widget_get_style (widget);
31 g_object_ref (G_OBJECT (style));
32
33 style = gtk_style_attach (style, widget->window);
34
35 spot_color.r = style->bg[GTK_STATE_SELECTED].red / 65535.0;
36 spot_color.g = style->bg[GTK_STATE_SELECTED].green / 65535.0;
37 spot_color.b = style->bg[GTK_STATE_SELECTED].blue / 65535.0;
38
39 g_object_unref (G_OBJECT (style));
40
41 shade (&spot_color, &_title_color[0], 1.05);
42 shade (&_title_color[0], &_title_color[1], 0.85);
43
44}
45
46void
47style_changed (GtkWidget *widget,
48 void *user_data)
49{
50 GdkDisplay *gdkdisplay;
51 GdkScreen *gdkscreen;
52 WnckScreen *screen;
53
54 PangoContext *context = (PangoContext *) user_data;
55
56 gdkdisplay = gdk_display_get_default ();
57 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
58 screen = wnck_screen_get_default ();
59
60 update_style (widget);
61
62 pango_cairo_context_set_resolution (context,
63 gdk_screen_get_resolution (gdkscreen));
64
65 decorations_changed (screen);
66}
067
=== removed file 'gtk/window-decorator/style.c'
--- gtk/window-decorator/style.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/style.c 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25update_style (GtkWidget *widget)
26{
27 GtkStyle *style;
28 decor_color_t spot_color;
29
30 style = gtk_widget_get_style (widget);
31 g_object_ref (G_OBJECT (style));
32
33 style = gtk_style_attach (style, widget->window);
34
35 spot_color.r = style->bg[GTK_STATE_SELECTED].red / 65535.0;
36 spot_color.g = style->bg[GTK_STATE_SELECTED].green / 65535.0;
37 spot_color.b = style->bg[GTK_STATE_SELECTED].blue / 65535.0;
38
39 g_object_unref (G_OBJECT (style));
40
41 shade (&spot_color, &_title_color[0], 1.05);
42 shade (&_title_color[0], &_title_color[1], 0.85);
43
44}
45
46void
47style_changed (GtkWidget *widget,
48 void *user_data)
49{
50 GdkDisplay *gdkdisplay;
51 GdkScreen *gdkscreen;
52 WnckScreen *screen;
53
54 PangoContext *context = (PangoContext *) user_data;
55
56 gdkdisplay = gdk_display_get_default ();
57 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
58 screen = wnck_screen_get_default ();
59
60 update_style (widget);
61
62 pango_cairo_context_set_resolution (context,
63 gdk_screen_get_resolution (gdkscreen));
64
65 decorations_changed (screen);
66}
670
=== added file 'gtk/window-decorator/util.c'
--- gtk/window-decorator/util.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/util.c 2012-04-20 09:45:47 +0000
@@ -0,0 +1,299 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24double
25square (double x)
26{
27 return x * x;
28}
29
30double
31dist (double x1, double y1,
32 double x2, double y2)
33{
34 return sqrt (square (x1 - x2) + square (y1 - y2));
35}
36
37gboolean
38get_window_prop (Window xwindow,
39 Atom atom,
40 Window *val)
41{
42 Atom type;
43 int format;
44 gulong nitems;
45 gulong bytes_after;
46 Window *w;
47 int err, result;
48
49 *val = 0;
50
51 gdk_error_trap_push ();
52
53 type = None;
54 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
55 xwindow,
56 atom,
57 0, G_MAXLONG,
58 False, XA_WINDOW, &type, &format, &nitems,
59 &bytes_after, (void*) &w);
60 err = gdk_error_trap_pop ();
61 if (err != Success || result != Success)
62 return FALSE;
63
64 if (type != XA_WINDOW)
65 {
66 XFree (w);
67 return FALSE;
68 }
69
70 *val = *w;
71 XFree (w);
72
73 return TRUE;
74}
75
76unsigned int
77get_mwm_prop (Window xwindow)
78{
79 Display *xdisplay;
80 Atom actual;
81 int err, result, format;
82 unsigned long n, left;
83 unsigned char *data;
84 unsigned int decor = MWM_DECOR_ALL;
85
86 xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
87
88 gdk_error_trap_push ();
89
90 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,
91 0L, 20L, FALSE, mwm_hints_atom,
92 &actual, &format, &n, &left, &data);
93
94 err = gdk_error_trap_pop ();
95 if (err != Success || result != Success)
96 return decor;
97
98 if (data)
99 {
100 MwmHints *mwm_hints = (MwmHints *) data;
101
102 if (n >= PROP_MOTIF_WM_HINT_ELEMENTS)
103 {
104 if (mwm_hints->flags & MWM_HINTS_DECORATIONS)
105 decor = mwm_hints->decorations;
106 }
107
108 XFree (data);
109 }
110
111 return decor;
112}
113
114/* from clearlooks theme */
115static void
116rgb_to_hls (gdouble *r,
117 gdouble *g,
118 gdouble *b)
119{
120 gdouble min;
121 gdouble max;
122 gdouble red;
123 gdouble green;
124 gdouble blue;
125 gdouble h, l, s;
126 gdouble delta;
127
128 red = *r;
129 green = *g;
130 blue = *b;
131
132 if (red > green)
133 {
134 if (red > blue)
135 max = red;
136 else
137 max = blue;
138
139 if (green < blue)
140 min = green;
141 else
142 min = blue;
143 }
144 else
145 {
146 if (green > blue)
147 max = green;
148 else
149 max = blue;
150
151 if (red < blue)
152 min = red;
153 else
154 min = blue;
155 }
156
157 l = (max + min) / 2;
158 s = 0;
159 h = 0;
160
161 if (max != min)
162 {
163 if (l <= 0.5)
164 s = (max - min) / (max + min);
165 else
166 s = (max - min) / (2 - max - min);
167
168 delta = max -min;
169 if (red == max)
170 h = (green - blue) / delta;
171 else if (green == max)
172 h = 2 + (blue - red) / delta;
173 else if (blue == max)
174 h = 4 + (red - green) / delta;
175
176 h *= 60;
177 if (h < 0.0)
178 h += 360;
179 }
180
181 *r = h;
182 *g = l;
183 *b = s;
184}
185
186static void
187hls_to_rgb (gdouble *h,
188 gdouble *l,
189 gdouble *s)
190{
191 gdouble hue;
192 gdouble lightness;
193 gdouble saturation;
194 gdouble m1, m2;
195 gdouble r, g, b;
196
197 lightness = *l;
198 saturation = *s;
199
200 if (lightness <= 0.5)
201 m2 = lightness * (1 + saturation);
202 else
203 m2 = lightness + saturation - lightness * saturation;
204
205 m1 = 2 * lightness - m2;
206
207 if (saturation == 0)
208 {
209 *h = lightness;
210 *l = lightness;
211 *s = lightness;
212 }
213 else
214 {
215 hue = *h + 120;
216 while (hue > 360)
217 hue -= 360;
218 while (hue < 0)
219 hue += 360;
220
221 if (hue < 60)
222 r = m1 + (m2 - m1) * hue / 60;
223 else if (hue < 180)
224 r = m2;
225 else if (hue < 240)
226 r = m1 + (m2 - m1) * (240 - hue) / 60;
227 else
228 r = m1;
229
230 hue = *h;
231 while (hue > 360)
232 hue -= 360;
233 while (hue < 0)
234 hue += 360;
235
236 if (hue < 60)
237 g = m1 + (m2 - m1) * hue / 60;
238 else if (hue < 180)
239 g = m2;
240 else if (hue < 240)
241 g = m1 + (m2 - m1) * (240 - hue) / 60;
242 else
243 g = m1;
244
245 hue = *h - 120;
246 while (hue > 360)
247 hue -= 360;
248 while (hue < 0)
249 hue += 360;
250
251 if (hue < 60)
252 b = m1 + (m2 - m1) * hue / 60;
253 else if (hue < 180)
254 b = m2;
255 else if (hue < 240)
256 b = m1 + (m2 - m1) * (240 - hue) / 60;
257 else
258 b = m1;
259
260 *h = r;
261 *l = g;
262 *s = b;
263 }
264}
265
266void
267shade (const decor_color_t *a,
268 decor_color_t *b,
269 float k)
270{
271 double red;
272 double green;
273 double blue;
274
275 red = a->r;
276 green = a->g;
277 blue = a->b;
278
279 rgb_to_hls (&red, &green, &blue);
280
281 green *= k;
282 if (green > 1.0)
283 green = 1.0;
284 else if (green < 0.0)
285 green = 0.0;
286
287 blue *= k;
288 if (blue > 1.0)
289 blue = 1.0;
290 else if (blue < 0.0)
291 blue = 0.0;
292
293 hls_to_rgb (&red, &green, &blue);
294
295 b->r = red;
296 b->g = green;
297 b->b = blue;
298}
299
0300
=== removed file 'gtk/window-decorator/util.c'
--- gtk/window-decorator/util.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/util.c 1970-01-01 00:00:00 +0000
@@ -1,299 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24double
25square (double x)
26{
27 return x * x;
28}
29
30double
31dist (double x1, double y1,
32 double x2, double y2)
33{
34 return sqrt (square (x1 - x2) + square (y1 - y2));
35}
36
37gboolean
38get_window_prop (Window xwindow,
39 Atom atom,
40 Window *val)
41{
42 Atom type;
43 int format;
44 gulong nitems;
45 gulong bytes_after;
46 Window *w;
47 int err, result;
48
49 *val = 0;
50
51 gdk_error_trap_push ();
52
53 type = None;
54 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
55 xwindow,
56 atom,
57 0, G_MAXLONG,
58 False, XA_WINDOW, &type, &format, &nitems,
59 &bytes_after, (void*) &w);
60 err = gdk_error_trap_pop ();
61 if (err != Success || result != Success)
62 return FALSE;
63
64 if (type != XA_WINDOW)
65 {
66 XFree (w);
67 return FALSE;
68 }
69
70 *val = *w;
71 XFree (w);
72
73 return TRUE;
74}
75
76unsigned int
77get_mwm_prop (Window xwindow)
78{
79 Display *xdisplay;
80 Atom actual;
81 int err, result, format;
82 unsigned long n, left;
83 unsigned char *data;
84 unsigned int decor = MWM_DECOR_ALL;
85
86 xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
87
88 gdk_error_trap_push ();
89
90 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,
91 0L, 20L, FALSE, mwm_hints_atom,
92 &actual, &format, &n, &left, &data);
93
94 err = gdk_error_trap_pop ();
95 if (err != Success || result != Success)
96 return decor;
97
98 if (data)
99 {
100 MwmHints *mwm_hints = (MwmHints *) data;
101
102 if (n >= PROP_MOTIF_WM_HINT_ELEMENTS)
103 {
104 if (mwm_hints->flags & MWM_HINTS_DECORATIONS)
105 decor = mwm_hints->decorations;
106 }
107
108 XFree (data);
109 }
110
111 return decor;
112}
113
114/* from clearlooks theme */
115static void
116rgb_to_hls (gdouble *r,
117 gdouble *g,
118 gdouble *b)
119{
120 gdouble min;
121 gdouble max;
122 gdouble red;
123 gdouble green;
124 gdouble blue;
125 gdouble h, l, s;
126 gdouble delta;
127
128 red = *r;
129 green = *g;
130 blue = *b;
131
132 if (red > green)
133 {
134 if (red > blue)
135 max = red;
136 else
137 max = blue;
138
139 if (green < blue)
140 min = green;
141 else
142 min = blue;
143 }
144 else
145 {
146 if (green > blue)
147 max = green;
148 else
149 max = blue;
150
151 if (red < blue)
152 min = red;
153 else
154 min = blue;
155 }
156
157 l = (max + min) / 2;
158 s = 0;
159 h = 0;
160
161 if (max != min)
162 {
163 if (l <= 0.5)
164 s = (max - min) / (max + min);
165 else
166 s = (max - min) / (2 - max - min);
167
168 delta = max -min;
169 if (red == max)
170 h = (green - blue) / delta;
171 else if (green == max)
172 h = 2 + (blue - red) / delta;
173 else if (blue == max)
174 h = 4 + (red - green) / delta;
175
176 h *= 60;
177 if (h < 0.0)
178 h += 360;
179 }
180
181 *r = h;
182 *g = l;
183 *b = s;
184}
185
186static void
187hls_to_rgb (gdouble *h,
188 gdouble *l,
189 gdouble *s)
190{
191 gdouble hue;
192 gdouble lightness;
193 gdouble saturation;
194 gdouble m1, m2;
195 gdouble r, g, b;
196
197 lightness = *l;
198 saturation = *s;
199
200 if (lightness <= 0.5)
201 m2 = lightness * (1 + saturation);
202 else
203 m2 = lightness + saturation - lightness * saturation;
204
205 m1 = 2 * lightness - m2;
206
207 if (saturation == 0)
208 {
209 *h = lightness;
210 *l = lightness;
211 *s = lightness;
212 }
213 else
214 {
215 hue = *h + 120;
216 while (hue > 360)
217 hue -= 360;
218 while (hue < 0)
219 hue += 360;
220
221 if (hue < 60)
222 r = m1 + (m2 - m1) * hue / 60;
223 else if (hue < 180)
224 r = m2;
225 else if (hue < 240)
226 r = m1 + (m2 - m1) * (240 - hue) / 60;
227 else
228 r = m1;
229
230 hue = *h;
231 while (hue > 360)
232 hue -= 360;
233 while (hue < 0)
234 hue += 360;
235
236 if (hue < 60)
237 g = m1 + (m2 - m1) * hue / 60;
238 else if (hue < 180)
239 g = m2;
240 else if (hue < 240)
241 g = m1 + (m2 - m1) * (240 - hue) / 60;
242 else
243 g = m1;
244
245 hue = *h - 120;
246 while (hue > 360)
247 hue -= 360;
248 while (hue < 0)
249 hue += 360;
250
251 if (hue < 60)
252 b = m1 + (m2 - m1) * hue / 60;
253 else if (hue < 180)
254 b = m2;
255 else if (hue < 240)
256 b = m1 + (m2 - m1) * (240 - hue) / 60;
257 else
258 b = m1;
259
260 *h = r;
261 *l = g;
262 *s = b;
263 }
264}
265
266void
267shade (const decor_color_t *a,
268 decor_color_t *b,
269 float k)
270{
271 double red;
272 double green;
273 double blue;
274
275 red = a->r;
276 green = a->g;
277 blue = a->b;
278
279 rgb_to_hls (&red, &green, &blue);
280
281 green *= k;
282 if (green > 1.0)
283 green = 1.0;
284 else if (green < 0.0)
285 green = 0.0;
286
287 blue *= k;
288 if (blue > 1.0)
289 blue = 1.0;
290 else if (blue < 0.0)
291 blue = 0.0;
292
293 hls_to_rgb (&red, &green, &blue);
294
295 b->r = red;
296 b->g = green;
297 b->b = blue;
298}
299
3000
=== modified file 'plugins/annotate/src/annotate.cpp'
--- plugins/annotate/src/annotate.cpp 2012-01-30 05:12:24 +0000
+++ plugins/annotate/src/annotate.cpp 2012-04-20 09:45:47 +0000
@@ -629,11 +629,14 @@
629629
630 if (status)630 if (status)
631 {631 {
632 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
633 GLfloat vertexData[18];
634 GLfloat textureData[12];
632 CompRect rect;635 CompRect rect;
633 GLMatrix sTransform = transform;636 GLMatrix sTransform = transform;
634 int numRect;637 int numRect;
635 int pos = 0;638 int pos = 0;
636 float vectorX, vectorY, offset;639 float offset;
637 int angle;640 int angle;
638641
639 offset = optionGetStrokeWidth () / 2;642 offset = optionGetStrokeWidth () / 2;
@@ -641,12 +644,6 @@
641 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */644 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */
642 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);645 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
643646
644 glPushMatrix ();
645 glLoadMatrixf (sTransform.getMatrix ());
646
647 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
648 glEnable (GL_BLEND);
649
650 if (content && !region.isEmpty ())647 if (content && !region.isEmpty ())
651 {648 {
652 foreach (GLTexture *tex, texture)649 foreach (GLTexture *tex, texture)
@@ -656,34 +653,66 @@
656653
657 tex->enable (GLTexture::Fast);654 tex->enable (GLTexture::Fast);
658655
659 glBegin (GL_QUADS);656 streamingBuffer->begin (GL_TRIANGLES);
660657
661 while (numRect--)658 while (numRect--)
662 {659 {
663 glTexCoord2f (660 GLfloat tx1 = COMP_TEX_COORD_X (tex->matrix (),
664 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),661 rect.at (pos).x1 ());
665 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));662 GLfloat tx2 = COMP_TEX_COORD_X (tex->matrix (),
666 glVertex2i (rect.at (pos).x1 (), rect.at (pos).y2 ());663 rect.at (pos).x2 ());
667664 GLfloat ty1 = COMP_TEX_COORD_Y (tex->matrix (),
668 glTexCoord2f (665 rect.at (pos).y1 ());
669 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),666 GLfloat ty2 = COMP_TEX_COORD_Y (tex->matrix (),
670 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));667 rect.at (pos).y2 ());
671 glVertex2i (rect.at (pos).x2 (), rect.at (pos).y2 ());668
672669 vertexData[0] = rect.at (pos).x1 ();
673 glTexCoord2f (670 vertexData[1] = rect.at (pos).y1 ();
674 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),671 vertexData[2] = 0.0f;
675 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));672 vertexData[3] = rect.at (pos).x1 ();
676 glVertex2i (rect.at (pos).x2 (), rect.at (pos).y1 ());673 vertexData[4] = rect.at (pos).y2 ();
677674 vertexData[5] = 0.0f;
678 glTexCoord2f (675 vertexData[6] = rect.at (pos).x2 ();
679 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),676 vertexData[7] = rect.at (pos).y1 ();
680 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));677 vertexData[8] = 0.0f;
681 glVertex2i (rect.at (pos).x1 (), rect.at (pos).y1 ());678 vertexData[9] = rect.at (pos).x1 ();
682679 vertexData[10] = rect.at (pos).y2 ();
680 vertexData[11] = 0.0f;
681
682 vertexData[12] = rect.at (pos).x2 ();
683 vertexData[13] = rect.at (pos).y2 ();
684 vertexData[14] = 0.0f;
685
686 vertexData[15] = rect.at (pos).x2 ();
687 vertexData[16] = rect.at (pos).y1 ();
688 vertexData[17] = 0.0f;
689
690 textureData[0] = tx1;
691 textureData[1] = ty1;
692
693 textureData[2] = tx1;
694 textureData[3] = ty2;
695
696 textureData[4] = tx2;
697 textureData[5] = ty1;
698
699 textureData[6] = tx1;
700 textureData[7] = ty2;
701
702 textureData[8] = tx2;
703 textureData[9] = ty2;
704
705 textureData[10] = tx2;
706 textureData[11] = ty1;
707
708 streamingBuffer->addVertices (6, vertexData);
709 streamingBuffer->addTexCoords (0, 6, textureData);
683 pos++;710 pos++;
684 }711 }
685712
686 glEnd ();713 streamingBuffer->end ();
714 streamingBuffer->render (sTransform);
715
687 tex->disable ();716 tex->disable ();
688 }717 }
689 }718 }
@@ -691,85 +720,130 @@
691 switch (drawMode)720 switch (drawMode)
692 {721 {
693 case LineMode:722 case LineMode:
694 glColor4usv (optionGetStrokeColor ());
695 glLineWidth (optionGetStrokeWidth ());723 glLineWidth (optionGetStrokeWidth ());
696 glBegin (GL_LINES);724
697 glVertex2i (initialPointerX, initialPointerY);725 streamingBuffer->begin (GL_LINES);
698 glVertex2i (lineVector.x (), lineVector.y ());726
699 glEnd ();727 streamingBuffer->addColors (1, optionGetStrokeColor ());
728
729 vertexData[0] = initialPointerX;
730 vertexData[1] = initialPointerY;
731 vertexData[2] = 0.0f;
732 vertexData[3] = lineVector.x ();
733 vertexData[4] = lineVector.y ();
734 vertexData[5] = 0.0f;
735 streamingBuffer->addVertices (2, vertexData);
736
737 streamingBuffer->end ();
738 streamingBuffer->render (sTransform);
700 break;739 break;
701740
702 case RectangleMode:741 case RectangleMode:
742 vertexData[0] = rectangle.x1 ();
743 vertexData[1] = rectangle.y1 ();
744 vertexData[2] = 0.0f;
745 vertexData[3] = rectangle.x1 ();
746 vertexData[4] = rectangle.y2 ();
747 vertexData[5] = 0.0f;
748 vertexData[6] = rectangle.x2 ();
749 vertexData[7] = rectangle.y1 ();
750 vertexData[8] = 0.0f;
751 vertexData[9] = rectangle.x2 ();
752 vertexData[10] = rectangle.y2 ();
753 vertexData[11] = 0.0f;
754
703 /* fill rectangle */755 /* fill rectangle */
704 glColor4usv (optionGetFillColor ());756 streamingBuffer->begin (GL_TRIANGLE_STRIP);
705 glRecti (rectangle.x1 (), rectangle.y2 (),757
706 rectangle.x2 (), rectangle.y1 ());758 streamingBuffer->addColors (1, optionGetFillColor ());
759 streamingBuffer->addVertices (4, vertexData);
760
761 streamingBuffer->end ();
762 streamingBuffer->render (sTransform);
707763
708 /* draw rectangle outline */764 /* draw rectangle outline */
709 glColor4usv (optionGetStrokeColor ());765/* streamingBuffer->begin ();
710 glRecti (rectangle.x1 () - offset, rectangle.y2 (),766
711 rectangle.x1 () + offset, rectangle.y1 ());767 streamingBuffer->addColors (1, optionGetStrokeColor ());
768
769 vertexData[0] = rectangle.x1 () - offset;
770 vertexData[3] = rectangle.x1 () - offset;
771 streamingBuffer->addVertices (4, vertexData);
772
712 glRecti (rectangle.x2 () - offset, rectangle.y2 (),773 glRecti (rectangle.x2 () - offset, rectangle.y2 (),
713 rectangle.x2 () + offset, rectangle.y1 ());774 rectangle.x2 () + offset, rectangle.y1 ());
714 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,775 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
715 rectangle.x2 () + offset, rectangle.y1 () - offset);776 rectangle.x2 () + offset, rectangle.y1 () - offset);
716 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,777 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
717 rectangle.x2 () + offset, rectangle.y2 () - offset);778 rectangle.x2 () + offset, rectangle.y2 () - offset);*/
718 break;779 break;
719780
720 case EllipseMode:781 case EllipseMode:
721 /* fill ellipse */782 /* fill ellipse */
722 glColor4usv (optionGetFillColor ());783 streamingBuffer->begin (GL_TRIANGLE_FAN);
723784
724 glBegin (GL_TRIANGLE_FAN);785 streamingBuffer->addColors (1, optionGetFillColor ());
725 glVertex2d (ellipse.center.x (), ellipse.center.y ());786
787 vertexData[0] = ellipse.center.x ();
788 vertexData[1] = ellipse.center.y ();
789 vertexData[2] = 0.0f;
790 streamingBuffer->addVertices (1, vertexData);
791
726 for (angle = 0; angle <= 360; angle += 1)792 for (angle = 0; angle <= 360; angle += 1)
727 {793 {
728 vectorX = ellipse.center.x () +794 vertexData[0] = ellipse.center.x () +
729 (ellipse.radiusX * sinf (angle * DEG2RAD));795 (ellipse.radiusX * sinf (angle * DEG2RAD));
730 vectorY = ellipse.center.y () +796 vertexData[1] = ellipse.center.y () +
731 (ellipse.radiusY * cosf (angle * DEG2RAD));797 (ellipse.radiusY * cosf (angle * DEG2RAD));
732 glVertex2d (vectorX, vectorY);798 streamingBuffer->addVertices (1, vertexData);
733 }799 }
734 glVertex2d (ellipse.center.x (), ellipse.center.y () +800
735 ellipse.radiusY);801 vertexData[0] = ellipse.center.x ();
736 glEnd();802 vertexData[1] = ellipse.center.y () + ellipse.radiusY;
803 streamingBuffer->addVertices (1, vertexData);
804
805 streamingBuffer->end ();
806 streamingBuffer->render (sTransform);
737807
738 /* draw ellipse outline */808 /* draw ellipse outline */
739 glColor4usv (optionGetStrokeColor ());
740 glLineWidth (optionGetStrokeWidth ());809 glLineWidth (optionGetStrokeWidth ());
741810
742 glBegin (GL_TRIANGLE_STRIP);811 streamingBuffer->begin (GL_TRIANGLE_STRIP);
743 glVertex2d (ellipse.center.x (), ellipse.center.y () +812
744 ellipse.radiusY - offset);813 streamingBuffer->addColors (1, optionGetStrokeColor ());
814
815
816 vertexData[0] = ellipse.center.x ();
817 vertexData[1] = ellipse.center.y () + ellipse.radiusY - offset;
818 vertexData[2] = 0.0f;
819 streamingBuffer->addVertices (1, vertexData);
820
745 for (angle = 360; angle >= 0; angle -= 1)821 for (angle = 360; angle >= 0; angle -= 1)
746 {822 {
747 vectorX = ellipse.center.x () + ((ellipse.radiusX -823 vertexData[0] = ellipse.center.x () + ((ellipse.radiusX -
748 offset) * sinf (angle * DEG2RAD));824 offset) * sinf (angle * DEG2RAD));
749 vectorY = ellipse.center.y () + ((ellipse.radiusY -825 vertexData[1] = ellipse.center.y () + ((ellipse.radiusY -
750 offset) * cosf (angle * DEG2RAD));826 offset) * cosf (angle * DEG2RAD));
751 glVertex2d (vectorX, vectorY);827 vertexData[2] = 0.0f;
752 vectorX = ellipse.center.x () + ((ellipse.radiusX +828 vertexData[3] = ellipse.center.x () + ((ellipse.radiusX +
753 offset) * sinf (angle * DEG2RAD));829 offset) * sinf (angle * DEG2RAD));
754 vectorY = ellipse.center.y () + ((ellipse.radiusY +830 vertexData[4] = ellipse.center.y () + ((ellipse.radiusY +
755 offset) * cosf (angle * DEG2RAD));831 offset) * cosf (angle * DEG2RAD));
756 glVertex2d (vectorX, vectorY);832 vertexData[5] = 0.0f;
833 streamingBuffer->addVertices (2, vertexData);
757 }834 }
758 glVertex2d (ellipse.center.x (), ellipse.center.y () +835
759 ellipse.radiusY + offset);836 vertexData[0] = ellipse.center.x ();
760 glEnd();837 vertexData[1] = ellipse.center.y () + ellipse.radiusY + offset;
838 streamingBuffer->addVertices (1, vertexData);
839
840 streamingBuffer->end ();
841 streamingBuffer->render (sTransform);
761 break;842 break;
762843
763 default:844 default:
764 break;845 break;
765 }846 }
766
767 /* clean up */
768 glColor4usv (defaultColor);
769 glDisable (GL_BLEND);
770 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
771
772 glPopMatrix ();
773 }847 }
774848
775 return status;849 return status;
776850
=== modified file 'plugins/blur/CMakeLists.txt'
--- plugins/blur/CMakeLists.txt 2011-01-24 06:28:52 +0000
+++ plugins/blur/CMakeLists.txt 2012-04-20 09:45:47 +0000
@@ -2,15 +2,15 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5find_package (OpenGL)5#find_package (OpenGL)
66
7if (OPENGL_GLU_FOUND)7#if (OPENGL_GLU_FOUND)
8 compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})8# compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
99
10 if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)10# if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
11 set_target_properties (11# set_target_properties (
12 blur PROPERTIES12# blur PROPERTIES
13 INSTALL_RPATH "${COMPIZ_LIBDIR}"13# INSTALL_RPATH "${COMPIZ_LIBDIR}"
14 )14# )
15 endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)15# endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
16endif ()16#endif ()
1717
=== modified file 'plugins/clone/src/clone.cpp'
--- plugins/clone/src/clone.cpp 2010-02-04 17:16:02 +0000
+++ plugins/clone/src/clone.cpp 2012-04-20 09:45:47 +0000
@@ -295,9 +295,6 @@
295 0.0f);295 0.0f);
296 sTransform.scale (zoomX, zoomY, 1.0f);296 sTransform.scale (zoomX, zoomY, 1.0f);
297297
298 glPushMatrix ();
299 glLoadMatrixf (sTransform.getMatrix ());
300
301 filter = gScreen->textureFilter ();298 filter = gScreen->textureFilter ();
302299
303 if (offset == 0.0f)300 if (offset == 0.0f)
@@ -325,8 +322,6 @@
325 }322 }
326323
327 gScreen->setTextureFilter (filter);324 gScreen->setTextureFilter (filter);
328
329 glPopMatrix ();
330 }325 }
331326
332 return status;327 return status;
333328
=== modified file 'plugins/compiztoolbox/src/compiztoolbox.cpp'
--- plugins/compiztoolbox/src/compiztoolbox.cpp 2012-01-18 16:26:45 +0000
+++ plugins/compiztoolbox/src/compiztoolbox.cpp 2012-04-20 09:45:47 +0000
@@ -465,9 +465,7 @@
465 sAttrib.yTranslate = wy - g.y () +465 sAttrib.yTranslate = wy - g.y () +
466 window->border ().top * sAttrib.yScale;466 window->border ().top * sAttrib.yScale;
467467
468 GLFragment::Attrib fragment (sAttrib);468 if (window->alpha () || sAttrib.opacity != OPAQUE)
469
470 if (window->alpha () || fragment.getOpacity () != OPAQUE)
471 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;469 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
472470
473 wTransform.translate (g.x (), g.y (), 0.0f);471 wTransform.translate (g.x (), g.y (), 0.0f);
@@ -476,9 +474,6 @@
476 sAttrib.yTranslate / sAttrib.yScale - g.y (),474 sAttrib.yTranslate / sAttrib.yScale - g.y (),
477 0.0f);475 0.0f);
478476
479 glPushMatrix ();
480 glLoadMatrixf (wTransform.getMatrix ());
481
482 filter = gScreen->textureFilter ();477 filter = gScreen->textureFilter ();
483478
484 if (baseScreen->getMipmap ())479 if (baseScreen->getMipmap ())
@@ -488,13 +483,11 @@
488 very ugly but necessary until the vertex stage has been made483 very ugly but necessary until the vertex stage has been made
489 fully pluggable. */484 fully pluggable. */
490 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);485 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
491 gWindow->glDraw (wTransform, fragment, infiniteRegion, mask);486 gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask);
492 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);487 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
493488
494 gScreen->setTextureFilter (filter);489 gScreen->setTextureFilter (filter);
495490
496 glPopMatrix ();
497
498 if (iconMode != HideIcon)491 if (iconMode != HideIcon)
499 {492 {
500 icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);493 icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);
@@ -535,30 +528,23 @@
535 sAttrib.xTranslate = wx - g.x ();528 sAttrib.xTranslate = wx - g.x ();
536 sAttrib.yTranslate = wy - g.y ();529 sAttrib.yTranslate = wy - g.y ();
537530
538 gWindow->geometry ().reset ();531 gWindow->vertexBuffer ()->begin ();
539532
540 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);533 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
541 gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);534 gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);
542 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);535 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
543536
544 if (gWindow->geometry ().vCount)537 gWindow->vertexBuffer ()->end ();
545 {538
546 GLFragment::Attrib fragment (sAttrib);539 GLMatrix wTransform (transform);
547 GLMatrix wTransform (transform);540
548541 wTransform.translate (g.x (), g.y (), 0.0f);
549 wTransform.translate (g.x (), g.y (), 0.0f);542 wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);
550 wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);543 wTransform.translate (sAttrib.xTranslate / sAttrib.xScale - g.x (),
551 wTransform.translate (sAttrib.xTranslate / sAttrib.xScale - g.x (),544 sAttrib.yTranslate / sAttrib.yScale - g.y (),
552 sAttrib.yTranslate / sAttrib.yScale - g.y (),545 0.0f);
553 0.0f);546
554547 gWindow->glDrawTexture (icon, wTransform, sAttrib, mask);
555 glPushMatrix ();
556 glLoadMatrixf (wTransform.getMatrix ());
557
558 gWindow->glDrawTexture (icon, fragment, mask);
559
560 glPopMatrix ();
561 }
562 }548 }
563}549}
564550
565551
=== modified file 'plugins/copytex/src/copytex.cpp'
--- plugins/copytex/src/copytex.cpp 2011-06-01 03:33:04 +0000
+++ plugins/copytex/src/copytex.cpp 2012-04-20 09:45:47 +0000
@@ -112,6 +112,14 @@
112 GLenum target;112 GLenum target;
113 GLTexture::Matrix matrix = _identity_matrix;113 GLTexture::Matrix matrix = _identity_matrix;
114114
115#ifdef USE_GLES
116 target = GL_TEXTURE_2D;
117 matrix.xx = 1.0f / dim.width ();
118 matrix.yy = 1.0f / dim.height ();
119 matrix.x0 = -dim.x () * matrix.xx;
120 matrix.y0 = -dim.y () * matrix.yy;
121#else
122
115 if (GL::textureNonPowerOfTwo ||123 if (GL::textureNonPowerOfTwo ||
116 (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))124 (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))
117 {125 {
@@ -129,6 +137,7 @@
129 matrix.x0 = -dim.x ();137 matrix.x0 = -dim.x ();
130 matrix.y0 = -dim.y ();138 matrix.y0 = -dim.y ();
131 }139 }
140#endif
132141
133 setData (target, matrix, false);142 setData (target, matrix, false);
134 setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());143 setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());
135144
=== modified file 'plugins/cube/CMakeLists.txt'
--- plugins/cube/CMakeLists.txt 2009-11-03 20:14:43 +0000
+++ plugins/cube/CMakeLists.txt 2012-04-20 09:45:47 +0000
@@ -2,4 +2,4 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5compiz_plugin(cube PLUGINDEPS composite opengl)
6\ No newline at end of file5\ No newline at end of file
6#compiz_plugin(cube PLUGINDEPS composite opengl)
77
=== modified file 'plugins/cube/src/cube.cpp'
--- plugins/cube/src/cube.cpp 2012-01-16 09:50:28 +0000
+++ plugins/cube/src/cube.cpp 2012-04-20 09:45:47 +0000
@@ -1123,7 +1123,6 @@
1123 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))1123 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
1124 {1124 {
1125 priv->gScreen->setTexEnvMode (GL_MODULATE);1125 priv->gScreen->setTexEnvMode (GL_MODULATE);
1126 glEnable (GL_BLEND);
1127 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1126 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1128 }1127 }
11291128
@@ -1149,7 +1148,6 @@
1149 glEnableClientState (GL_TEXTURE_COORD_ARRAY);1148 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
11501149
1151 priv->gScreen->setTexEnvMode (GL_REPLACE);1150 priv->gScreen->setTexEnvMode (GL_REPLACE);
1152 glDisable (GL_BLEND);
1153 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1151 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1154}1152}
11551153
@@ -1190,7 +1188,6 @@
1190 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))1188 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
1191 {1189 {
1192 priv->gScreen->setTexEnvMode (GL_MODULATE);1190 priv->gScreen->setTexEnvMode (GL_MODULATE);
1193 glEnable (GL_BLEND);
1194 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1191 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1195 }1192 }
11961193
@@ -1206,7 +1203,6 @@
1206 glEnableClientState (GL_TEXTURE_COORD_ARRAY);1203 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
12071204
1208 priv->gScreen->setTexEnvMode (GL_REPLACE);1205 priv->gScreen->setTexEnvMode (GL_REPLACE);
1209 glDisable (GL_BLEND);
1210 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1206 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1211}1207}
12121208
12131209
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2012-04-19 07:28:34 +0000
+++ plugins/decor/src/decor.cpp 2012-04-20 09:45:47 +0000
@@ -177,15 +177,13 @@
177 */177 */
178178
179bool179bool
180DecorWindow::glDraw (const GLMatrix &transform,180DecorWindow::glDraw (const GLMatrix &transform,
181 GLFragment::Attrib &attrib,181 const GLWindowPaintAttrib &attrib,
182 const CompRegion &region,182 const CompRegion &region,
183 unsigned int mask)183 unsigned int mask)
184{184{
185 bool status;185 bool status;
186186
187 status = gWindow->glDraw (transform, attrib, region, mask);
188
189 /* Don't render dock decorations (shadows) on just any old window */187 /* Don't render dock decorations (shadows) on just any old window */
190 if (!(window->type () & CompWindowTypeDockMask))188 if (!(window->type () & CompWindowTypeDockMask))
191 {189 {
@@ -205,15 +203,19 @@
205 }203 }
206 }204 }
207205
206 status = gWindow->glDraw (transform, attrib, region, mask);
207
208 return status;208 return status;
209}209}
210210
211void211void
212DecorWindow::glDecorate (const GLMatrix &transform,212DecorWindow::glDecorate (const GLMatrix &transform,
213 GLFragment::Attrib &attrib,213 const GLWindowPaintAttrib &attrib,
214 const CompRegion &region,214 const CompRegion &region,
215 unsigned int mask)215 unsigned int mask)
216{216{
217 GLboolean isBlendingEnabled;
218
217 if (wd &&219 if (wd &&
218 wd->decor->type == WINDOW_DECORATION_TYPE_PIXMAP)220 wd->decor->type == WINDOW_DECORATION_TYPE_PIXMAP)
219 {221 {
@@ -221,6 +223,7 @@
221 GLTexture::MatrixList ml (1);223 GLTexture::MatrixList ml (1);
222 mask |= PAINT_WINDOW_BLEND_MASK;224 mask |= PAINT_WINDOW_BLEND_MASK;
223225
226 gWindow->vertexBuffer ()->begin ();
224 const CompRegion *preg = NULL;227 const CompRegion *preg = NULL;
225228
226 if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |229 if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
@@ -245,8 +248,6 @@
245248
246 const CompRegion &reg (*preg);249 const CompRegion &reg (*preg);
247250
248 gWindow->geometry ().reset ();
249
250 for (int i = 0; i < wd->nQuad; i++)251 for (int i = 0; i < wd->nQuad; i++)
251 {252 {
252 box.setGeometry (wd->quad[i].box.x1,253 box.setGeometry (wd->quad[i].box.x1,
@@ -262,9 +263,14 @@
262 }263 }
263 }264 }
264265
265 if (gWindow->geometry ().vCount)266 gWindow->vertexBuffer ()->end ();
266 gWindow->glDrawTexture (wd->decor->texture->textures[0],267
267 attrib, mask);268 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
269 glEnable (GL_BLEND);
270 gWindow->glDrawTexture (wd->decor->texture->textures[0], transform,
271 attrib, mask);
272 if (!isBlendingEnabled)
273 glDisable (GL_BLEND);
268 }274 }
269 else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)275 else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
270 {276 {
@@ -275,14 +281,18 @@
275 if (gWindow->textures ().empty ())281 if (gWindow->textures ().empty ())
276 return;282 return;
277283
284 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
285 glEnable (GL_BLEND);
286
278 if (gWindow->textures ().size () == 1)287 if (gWindow->textures ().size () == 1)
279 {288 {
280 ml[0] = gWindow->matrices ()[0];289 ml[0] = gWindow->matrices ()[0];
281 gWindow->geometry ().reset ();290 gWindow->vertexBuffer ()->begin ();
282 gWindow->glAddGeometry (ml, window->frameRegion (), region);291 gWindow->glAddGeometry (ml, window->frameRegion (), region);
292 gWindow->vertexBuffer ()->end ();
283293
284 if (gWindow->geometry ().vCount)294 gWindow->glDrawTexture (gWindow->textures ()[0], transform,
285 gWindow->glDrawTexture (gWindow->textures ()[0], attrib, mask);295 attrib, mask);
286 }296 }
287 else297 else
288 {298 {
@@ -291,14 +301,17 @@
291 for (unsigned int i = 0; i < gWindow->textures ().size (); i++)301 for (unsigned int i = 0; i < gWindow->textures ().size (); i++)
292 {302 {
293 ml[0] = gWindow->matrices ()[i];303 ml[0] = gWindow->matrices ()[i];
294 gWindow->geometry ().reset ();304 gWindow->vertexBuffer ()->begin ();
295 gWindow->glAddGeometry (ml, regions[i], region);305 gWindow->glAddGeometry (ml, regions[i], region);
306 gWindow->vertexBuffer ()->end ();
296307
297 if (gWindow->geometry ().vCount)308 gWindow->glDrawTexture (gWindow->textures ()[i], transform,
298 gWindow->glDrawTexture (gWindow->textures ()[i], attrib,309 attrib, mask);
299 mask);
300 }310 }
301 }311 }
312
313 if (!isBlendingEnabled)
314 glDisable (GL_BLEND);
302 }315 }
303}316}
304317
305318
=== modified file 'plugins/decor/src/decor.h'
--- plugins/decor/src/decor.h 2012-04-18 12:48:53 +0000
+++ plugins/decor/src/decor.h 2012-04-20 09:45:47 +0000
@@ -254,10 +254,10 @@
254254
255 void computeShadowRegion ();255 void computeShadowRegion ();
256256
257 bool glDraw (const GLMatrix &, GLFragment::Attrib &,257 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
258 const CompRegion &, unsigned int);258 const CompRegion &, unsigned int);
259 void glDecorate (const GLMatrix &, GLFragment::Attrib &,259 void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
260 const CompRegion &, unsigned int);260 const CompRegion &, unsigned int);
261261
262 void windowNotify (CompWindowNotify n);262 void windowNotify (CompWindowNotify n);
263263
264264
=== modified file 'plugins/imgsvg/src/imgsvg.cpp'
--- plugins/imgsvg/src/imgsvg.cpp 2012-01-18 16:26:45 +0000
+++ plugins/imgsvg/src/imgsvg.cpp 2012-04-20 09:45:47 +0000
@@ -220,12 +220,12 @@
220}220}
221221
222bool222bool
223SvgWindow::glDraw (const GLMatrix &transform,223SvgWindow::glDraw (const GLMatrix &transform,
224 GLFragment::Attrib &fragment,224 const GLWindowPaintAttrib &attrib,
225 const CompRegion &region,225 const CompRegion &region,
226 unsigned int mask)226 unsigned int mask)
227{227{
228 bool status = gWindow->glDraw (transform, fragment, region, mask);228 bool status = gWindow->glDraw (transform, attrib, region, mask);
229229
230 if (!status)230 if (!status)
231 return status;231 return status;
@@ -251,13 +251,15 @@
251 {251 {
252 matrix[0] = context->texture[0].matrices[i];252 matrix[0] = context->texture[0].matrices[i];
253253
254 gWindow->geometry ().reset ();254 gWindow->vertexBuffer ()->begin ();
255 gWindow->glAddGeometry (matrix, context->box, reg);255 gWindow->glAddGeometry (matrix, context->box, reg);
256 gWindow->vertexBuffer ()->end ();
256257
257 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)258 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
258 mask |= PAINT_WINDOW_BLEND_MASK;259 mask |= PAINT_WINDOW_BLEND_MASK;
259260
260 gWindow->glDrawTexture (context->texture[0].textures[i], fragment, mask);261 gWindow->glDrawTexture (context->texture[0].textures[i], transform,
262 attrib, mask);
261263
262 if (rect.width () > 0 && rect.height () > 0)264 if (rect.width () > 0 && rect.height () > 0)
263 {265 {
@@ -321,11 +323,12 @@
321 saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);323 saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);
322 gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);324 gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
323325
324 gWindow->geometry ().reset ();326 gWindow->vertexBuffer ()->begin ();
325 gWindow->glAddGeometry (matrix, r, reg);327 gWindow->glAddGeometry (matrix, r, reg);
328 gWindow->vertexBuffer ()->end ();
326329
327 gWindow->glDrawTexture (context->texture[1].textures[j],330 gWindow->glDrawTexture (context->texture[1].textures[j],
328 fragment, mask);331 transform, attrib, mask);
329332
330 gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);333 gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);
331 }334 }
332335
=== modified file 'plugins/imgsvg/src/imgsvg.h'
--- plugins/imgsvg/src/imgsvg.h 2012-01-18 16:26:45 +0000
+++ plugins/imgsvg/src/imgsvg.h 2012-04-20 09:45:47 +0000
@@ -76,7 +76,8 @@
76 SvgWindow (CompWindow *window);76 SvgWindow (CompWindow *window);
77 ~SvgWindow ();77 ~SvgWindow ();
7878
79 bool glDraw (const GLMatrix &transform, GLFragment::Attrib &fragment,79 bool glDraw (const GLMatrix &transform,
80 const GLWindowPaintAttrib &attrib,
80 const CompRegion &region, unsigned int mask);81 const CompRegion &region, unsigned int mask);
81 void moveNotify (int dx, int dy, bool immediate);82 void moveNotify (int dx, int dy, bool immediate);
82 void resizeNotify (int dx, int dy, int dwidth, int dheight);83 void resizeNotify (int dx, int dy, int dwidth, int dheight);
8384
=== modified file 'plugins/obs/src/obs.cpp'
--- plugins/obs/src/obs.cpp 2010-07-02 02:49:24 +0000
+++ plugins/obs/src/obs.cpp 2012-04-20 09:45:47 +0000
@@ -151,29 +151,30 @@
151 we wrap into glDrawWindow here */151 we wrap into glDrawWindow here */
152152
153bool153bool
154ObsWindow::glDraw (const GLMatrix& transform,154ObsWindow::glDraw (const GLMatrix &transform,
155 GLFragment::Attrib& attrib,155 const GLWindowPaintAttrib &attrib,
156 const CompRegion& region,156 const CompRegion &region,
157 unsigned int mask)157 unsigned int mask)
158{158{
159 GLWindowPaintAttrib wAttrib (attrib);
159 int factor;160 int factor;
160161
161 factor = customFactor[MODIFIER_OPACITY];162 factor = customFactor[MODIFIER_OPACITY];
162 if (factor != 100)163 if (factor != 100)
163 {164 {
164 attrib.setOpacity (factor * attrib.getOpacity () / 100);165 wAttrib.opacity = factor * wAttrib.opacity / 100;
165 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;166 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
166 }167 }
167168
168 factor = customFactor[MODIFIER_BRIGHTNESS];169 factor = customFactor[MODIFIER_BRIGHTNESS];
169 if (factor != 100)170 if (factor != 100)
170 attrib.setBrightness (factor * attrib.getBrightness () / 100);171 wAttrib.brightness = factor * wAttrib.brightness / 100;
171172
172 factor = customFactor[MODIFIER_SATURATION];173 factor = customFactor[MODIFIER_SATURATION];
173 if (factor != 100)174 if (factor != 100)
174 attrib.setSaturation (factor * attrib.getSaturation () / 100);175 wAttrib.saturation = factor * wAttrib.saturation / 100;
175176
176 return gWindow->glDraw (transform, attrib, region, mask);177 return gWindow->glDraw (transform, wAttrib, region, mask);
177}178}
178179
179void180void
180181
=== modified file 'plugins/obs/src/obs.h'
--- plugins/obs/src/obs.h 2012-01-18 16:26:45 +0000
+++ plugins/obs/src/obs.h 2012-04-20 09:45:47 +0000
@@ -66,7 +66,7 @@
6666
67 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,67 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
68 const CompRegion &, unsigned int);68 const CompRegion &, unsigned int);
69 bool glDraw (const GLMatrix &, GLFragment::Attrib &,69 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
70 const CompRegion &, unsigned int);70 const CompRegion &, unsigned int);
7171
72 void changePaintModifier (unsigned int, int);72 void changePaintModifier (unsigned int, int);
7373
=== modified file 'plugins/opengl/CMakeLists.txt'
--- plugins/opengl/CMakeLists.txt 2009-03-15 05:09:18 +0000
+++ plugins/opengl/CMakeLists.txt 2012-04-20 09:45:47 +0000
@@ -2,7 +2,12 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5find_package (OpenGL)
6if (OPENGL_FOUND)
7 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
8endif ()
9\ No newline at end of file5\ No newline at end of file
6if (USE_GLES)
7 compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD "-DUSE_GLES -std=c++0x" LIBRARIES ${OPENGLES2_LIBRARIES} INCDIRS ${OPENGLES2_INCLUDE_DIR})
8else (USE_GLES)
9 find_package (OpenGL)
10 if (OPENGL_FOUND)
11 compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD -std=c++0x LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
12 endif (OPENGL_FOUND)
13endif (USE_GLES)
14
1015
=== modified file 'plugins/opengl/compiz-opengl.pc.in'
--- plugins/opengl/compiz-opengl.pc.in 2009-03-15 05:09:18 +0000
+++ plugins/opengl/compiz-opengl.pc.in 2012-04-20 09:45:47 +0000
@@ -8,5 +8,5 @@
8Version: @VERSION@8Version: @VERSION@
99
10Requires: compiz compiz-composite10Requires: compiz compiz-composite
11Libs: -lGL -L${libdir} -lopengl
12Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
13\ No newline at end of file11\ No newline at end of file
12Libs: @PKGCONFIG_LIBS@ -L${libdir} -lopengl
13Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
1414
=== removed file 'plugins/opengl/include/opengl/fragment.h'
--- plugins/opengl/include/opengl/fragment.h 2012-01-18 16:26:45 +0000
+++ plugins/opengl/include/opengl/fragment.h 1970-01-01 00:00:00 +0000
@@ -1,125 +0,0 @@
1/*
2 * Copyright © 2008 Dennis Kasprzyk
3 * Copyright © 2007 Novell, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior permission.
12 * Dennis Kasprzyk makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without express or
14 * implied warranty.
15 *
16 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 *
24 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25 * David Reveman <davidr@novell.com>
26 */
27
28#ifndef _GLFRAGMENT_H
29#define _GLFRAGMENT_H
30
31#define MAX_FRAGMENT_FUNCTIONS 16
32
33#define COMP_FETCH_TARGET_2D 0
34#define COMP_FETCH_TARGET_RECT 1
35#define COMP_FETCH_TARGET_NUM 2
36
37struct GLWindowPaintAttrib;
38class GLScreen;
39class GLTexture;
40
41/**
42 * Describes a texture modification fragment program
43 * for a texture
44 */
45namespace GLFragment {
46
47 class Storage;
48
49 typedef unsigned int FunctionId;
50
51 class PrivateFunctionData;
52 class PrivateAttrib;
53
54 class FunctionData {
55 public:
56 FunctionData ();
57 ~FunctionData ();
58
59 /**
60 * Returns the status of this fragment program
61 * (valid or invalid)
62 */
63 bool status ();
64
65 void addTempHeaderOp (const char *name);
66
67 void addParamHeaderOp (const char *name);
68
69 void addAttribHeaderOp (const char *name);
70
71
72 void addFetchOp (const char *dst, const char *offset, int target);
73
74 void addColorOp (const char *dst, const char *src);
75
76 void addDataOp (const char *str, ...);
77
78 void addBlendOp (const char *str, ...);
79
80 FunctionId createFragmentFunction (const char *name);
81
82 private:
83 PrivateFunctionData *priv;
84 };
85
86 class Attrib {
87 public:
88 Attrib (const GLWindowPaintAttrib &paint);
89 Attrib (const Attrib&);
90 ~Attrib ();
91
92 Attrib &operator= (const Attrib &rhs);
93
94 unsigned int allocTextureUnits (unsigned int nTexture);
95
96 unsigned int allocParameters (unsigned int nParam);
97
98 void addFunction (FunctionId function);
99
100 bool enable (bool *blending);
101 void disable ();
102
103 unsigned short getSaturation ();
104 unsigned short getBrightness ();
105 unsigned short getOpacity ();
106
107 void setSaturation (unsigned short);
108 void setBrightness (unsigned short);
109 void setOpacity (unsigned short);
110
111 bool hasFunctions ();
112
113 private:
114 PrivateAttrib *priv;
115 };
116
117 void destroyFragmentFunction (FunctionId id);
118
119 FunctionId getSaturateFragmentFunction (GLTexture *texture,
120 int param);
121};
122
123
124
125#endif
1260
=== added file 'plugins/opengl/include/opengl/framebufferobject.h'
--- plugins/opengl/include/opengl/framebufferobject.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/framebufferobject.h 2012-04-20 09:45:47 +0000
@@ -0,0 +1,107 @@
1/*
2 * Copyright (c) 2011 Collabora, Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Collabora Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Collabora Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL COLLABORA LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Pekka Paalanen <ppaalanen@gmail.com>
24 */
25
26#ifndef _COMPIZ_GLFRAMEBUFFEROBJECT_H
27#define _COMPIZ_GLFRAMEBUFFEROBJECT_H
28
29#include <opengl/opengl.h>
30
31struct PrivateGLFramebufferObject;
32
33/**
34 * Class representing a framebuffer object in GL, supporting only one
35 * color attachment as per GLES 2 spec. The color attachment is referred
36 * to as the texture (of the FBO).
37 *
38 * Usage:
39 * 1. create a GLFramebufferObject (requires a GL context)
40 * 2. call allocate (size), and check status ()
41 * 3. old = bind ()
42 * 4. do your rendering
43 * 5. rebind (old)
44 * 6. use the rendered texture via tex ()
45 * 7. go to 2 or 3, or delete to quit (requires a GL context)
46 *
47 * TODO: add depth/stencil attachments
48 * FIXME: written for OpenGL ES 2 only, desktop OpenGL might not work.
49 */
50class GLFramebufferObject
51{
52 public:
53 GLFramebufferObject ();
54 ~GLFramebufferObject ();
55
56 /**
57 * Ensure the texture is of the given size, recreating it if needed,
58 * and replace the FBO color attachment with it. The texture contents
59 * become undefined, unless specified in the 'image' argument.
60 * When specifying 'image', it's also possible to pass-in the
61 * desired image's 'format' and 'type'.
62 *
63 * Returns true on success, and false on texture allocation failure.
64 */
65 bool allocate (const CompSize &size,
66 const char *image = NULL,
67 GLenum format = GL_RGBA,
68 GLenum type = GL_UNSIGNED_BYTE);
69
70 /**
71 * Bind this as the current FBO, previous binding in GL context is
72 * undone. GL rendering is now targeted to this FBO.
73 * Returns a pointer to the previously bound FBO, or NULL if
74 * the previous binding was zero (the window system provided
75 * framebuffer).
76 *
77 * The previous FBO is no longer bound, so you can use its
78 * texture. To restore the previous FBO, call rebind (FBO) with
79 * the returned pointer as the argument.
80 */
81 GLFramebufferObject *bind ();
82
83 /**
84 * Bind the given FBO as the current FBO, without looking up the
85 * previous binding. The argument can be NULL, in which case the
86 * window system provided framebuffer gets bound (FBO is unbound).
87 */
88 static void rebind (GLFramebufferObject *fbo);
89
90 /**
91 * Check the FBO completeness. Returns true on complete.
92 * Otherwise returns false and reports the error to log.
93 */
94 bool checkStatus ();
95
96 /**
97 * Return a pointer to the texture that is the color attachment.
98 * This will return NULL, if allocate () has not been called, or
99 * the last allocate () call failed.
100 */
101 GLTexture *tex ();
102
103 private:
104 PrivateGLFramebufferObject *priv;
105};
106
107#endif // _COMPIZ_GLFRAMEBUFFEROBJECT_H
0108
=== modified file 'plugins/opengl/include/opengl/matrix.h'
--- plugins/opengl/include/opengl/matrix.h 2009-03-15 05:09:18 +0000
+++ plugins/opengl/include/opengl/matrix.h 2012-04-20 09:45:47 +0000
@@ -44,6 +44,8 @@
44 void reset ();44 void reset ();
45 void toScreenSpace (const CompOutput *output, float z);45 void toScreenSpace (const CompOutput *output, float z);
4646
47 bool invert ();
48
47 void rotate (const float angle, const float x,49 void rotate (const float angle, const float x,
48 const float y, const float z);50 const float y, const float z);
49 void rotate (const float angle, const GLVector& vector);51 void rotate (const float angle, const GLVector& vector);
5052
=== modified file 'plugins/opengl/include/opengl/opengl.h'
--- plugins/opengl/include/opengl/opengl.h 2012-01-20 09:05:56 +0000
+++ plugins/opengl/include/opengl/opengl.h 2012-04-20 09:45:47 +0000
@@ -28,16 +28,45 @@
28#ifndef _COMPIZ_OPENGL_H28#ifndef _COMPIZ_OPENGL_H
29#define _COMPIZ_OPENGL_H29#define _COMPIZ_OPENGL_H
3030
31#ifdef USE_GLES
32#define SUPPORT_X11
33#include <GLES2/gl2.h>
34#include <GLES2/gl2ext.h>
35#include <EGL/egl.h>
36#include <EGL/eglext.h>
37#else
31#include <GL/gl.h>38#include <GL/gl.h>
32#include <GL/glx.h>39#include <GL/glx.h>
40#endif
41
42#include <core/size.h>
43#include <core/pluginclasshandler.h>
3344
34#include <opengl/matrix.h>45#include <opengl/matrix.h>
35#include <opengl/texture.h>46#include <opengl/texture.h>
36#include <opengl/fragment.h>47#include <opengl/framebufferobject.h>
48#include <opengl/vertexbuffer.h>
49#include <opengl/program.h>
50#include <opengl/programcache.h>
51#include <opengl/shadercache.h>
3752
38#define COMPIZ_OPENGL_ABI 453#define COMPIZ_OPENGL_ABI 4
3954
40#include <core/pluginclasshandler.h>55#if !defined(GL_BGRA)
56 #if !defined(GL_BGRA_EXT)
57 #error GL_BGRA support is required
58 #else
59 #define GL_BGRA GL_BGRA_EXT
60 #endif
61#endif
62
63#if !defined(GL_BGRA)
64 #if !defined(GL_BGRA_EXT)
65 #error GL_BGRA support is required
66 #else
67 #define GL_BGRA GL_BGRA_EXT
68 #endif
69#endif
4170
42/**71/**
43 * camera distance from screen, 0.5 * tan (FOV)72 * camera distance from screen, 0.5 * tan (FOV)
@@ -75,8 +104,26 @@
75#endif104#endif
76105
77namespace GL {106namespace GL {
78107 #ifdef USE_GLES
108 typedef EGLImageKHR (*EGLCreateImageKHRProc) (EGLDisplay dpy,
109 EGLContext ctx,
110 EGLenum target,
111 EGLClientBuffer buffer,
112 const EGLint *attrib_list);
113 typedef EGLBoolean (*EGLDestroyImageKHRProc) (EGLDisplay dpy,
114 EGLImageKHR image);
115
116 typedef void (*GLEGLImageTargetTexture2DOESProc) (GLenum target,
117 GLeglImageOES image);
118
119 typedef EGLBoolean (*EGLPostSubBufferNVProc) (EGLDisplay dpy,
120 EGLSurface surface,
121 EGLint x, EGLint y,
122 EGLint width, EGLint height);
123
124 #else
79 typedef void (*FuncPtr) (void);125 typedef void (*FuncPtr) (void);
126
80 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);127 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
81128
82 typedef void (*GLXBindTexImageProc) (Display *display,129 typedef void (*GLXBindTexImageProc) (Display *display,
@@ -122,11 +169,6 @@
122 const int *attribList);169 const int *attribList);
123 typedef void (*GLXDestroyPixmapProc) (Display *display,170 typedef void (*GLXDestroyPixmapProc) (Display *display,
124 GLXPixmap pixmap);171 GLXPixmap pixmap);
125
126 typedef void (*GLActiveTextureProc) (GLenum texture);
127 typedef void (*GLClientActiveTextureProc) (GLenum texture);
128 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
129
130 typedef void (*GLGenProgramsProc) (GLsizei n,172 typedef void (*GLGenProgramsProc) (GLsizei n,
131 GLuint *programs);173 GLuint *programs);
132 typedef void (*GLDeleteProgramsProc) (GLsizei n,174 typedef void (*GLDeleteProgramsProc) (GLsizei n,
@@ -146,11 +188,16 @@
146 typedef void (*GLGetProgramivProc) (GLenum target,188 typedef void (*GLGetProgramivProc) (GLenum target,
147 GLenum pname,189 GLenum pname,
148 int *params);190 int *params);
191 #endif
192
193 typedef void (*GLActiveTextureProc) (GLenum texture);
194 typedef void (*GLClientActiveTextureProc) (GLenum texture);
195 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
149196
150 typedef void (*GLGenFramebuffersProc) (GLsizei n,197 typedef void (*GLGenFramebuffersProc) (GLsizei n,
151 GLuint *framebuffers);198 GLuint *framebuffers);
152 typedef void (*GLDeleteFramebuffersProc) (GLsizei n,199 typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
153 GLuint *framebuffers);200 const GLuint *framebuffers);
154 typedef void (*GLBindFramebufferProc) (GLenum target,201 typedef void (*GLBindFramebufferProc) (GLenum target,
155 GLuint framebuffer);202 GLuint framebuffer);
156 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);203 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
@@ -161,6 +208,96 @@
161 GLint level);208 GLint level);
162 typedef void (*GLGenerateMipmapProc) (GLenum target);209 typedef void (*GLGenerateMipmapProc) (GLenum target);
163210
211 typedef void (*GLBindBufferProc) (GLenum target,
212 GLuint buffer);
213 typedef void (*GLDeleteBuffersProc) (GLsizei n,
214 const GLuint *buffers);
215 typedef void (*GLGenBuffersProc) (GLsizei n,
216 GLuint *buffers);
217 typedef void (*GLBufferDataProc) (GLenum target,
218 GLsizeiptr size,
219 const GLvoid *data,
220 GLenum usage);
221 typedef void (*GLBufferSubDataProc) (GLenum target,
222 GLintptr offset,
223 GLsizeiptr size,
224 const GLvoid *data);
225
226 typedef void (*GLGetShaderivProc) (GLuint shader,
227 GLenum pname,
228 GLint *params);
229 typedef void (*GLGetShaderInfoLogProc) (GLuint shader,
230 GLsizei bufsize,
231 GLsizei *length,
232 GLchar *infoLog);
233 typedef void (*GLGetProgramivProc) (GLuint program,
234 GLenum pname,
235 GLint* params);
236 typedef void (*GLGetProgramInfoLogProc) (GLuint program,
237 GLsizei bufsize,
238 GLsizei *length,
239 GLchar *infoLog);
240 typedef GLuint (*GLCreateShaderProc) (GLenum type);
241 typedef void (*GLShaderSourceProc) (GLuint shader,
242 GLsizei count,
243 const GLchar **string,
244 const GLint* length);
245 typedef void (*GLCompileShaderProc) (GLuint shader);
246 typedef GLuint (*GLCreateProgramProc) ();
247 typedef void (*GLAttachShaderProc) (GLuint program,
248 GLuint shader);
249 typedef void (*GLLinkProgramProc) (GLuint program);
250 typedef void (*GLValidateProgramProc) (GLuint program);
251 typedef void (*GLDeleteShaderProc) (GLuint shader);
252 typedef void (*GLDeleteProgramProc) (GLuint program);
253 typedef void (*GLUseProgramProc) (GLuint program);
254 typedef int (*GLGetUniformLocationProc) (GLuint program,
255 const GLchar* name);
256 typedef void (*GLUniform1fProc) (GLint location, GLfloat x);
257 typedef void (*GLUniform1iProc) (GLint location, GLint x);
258 typedef void (*GLUniform2fProc) (GLint location, GLfloat x, GLfloat y);
259 typedef void (*GLUniform3fProc) (GLint location,
260 GLfloat x,
261 GLfloat y,
262 GLfloat z);
263 typedef void (*GLUniform4fProc) (GLint location,
264 GLfloat x,
265 GLfloat y,
266 GLfloat z,
267 GLfloat w);
268 typedef void (*GLUniform2iProc) (GLint location, GLint x, GLint y);
269 typedef void (*GLUniform3iProc) (GLint location,
270 GLint x,
271 GLint y,
272 GLint z);
273 typedef void (*GLUniform4iProc) (GLint location,
274 GLint x,
275 GLint y,
276 GLint z,
277 GLint w);
278 typedef void (*GLUniformMatrix4fvProc) (GLint location,
279 GLsizei count,
280 GLboolean transpose,
281 const GLfloat *value);
282 typedef int (*GLGetAttribLocationProc) (GLuint program,
283 const GLchar *name);
284
285 typedef void (*GLEnableVertexAttribArrayProc) (GLuint index);
286 typedef void (*GLDisableVertexAttribArrayProc) (GLuint index);
287 typedef void (*GLVertexAttribPointerProc) (GLuint index,
288 GLint size,
289 GLenum type,
290 GLboolean normalized,
291 GLsizei stride,
292 const GLvoid *ptr);
293
294 #ifdef USE_GLES
295 extern EGLCreateImageKHRProc createImage;
296 extern EGLDestroyImageKHRProc destroyImage;
297
298 extern GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
299
300 #else
164 extern GLXBindTexImageProc bindTexImage;301 extern GLXBindTexImageProc bindTexImage;
165 extern GLXReleaseTexImageProc releaseTexImage;302 extern GLXReleaseTexImageProc releaseTexImage;
166 extern GLXQueryDrawableProc queryDrawable;303 extern GLXQueryDrawableProc queryDrawable;
@@ -172,11 +309,6 @@
172 extern GLXGetFBConfigAttribProc getFBConfigAttrib;309 extern GLXGetFBConfigAttribProc getFBConfigAttrib;
173 extern GLXCreatePixmapProc createPixmap;310 extern GLXCreatePixmapProc createPixmap;
174 extern GLXDestroyPixmapProc destroyPixmap;311 extern GLXDestroyPixmapProc destroyPixmap;
175
176 extern GLActiveTextureProc activeTexture;
177 extern GLClientActiveTextureProc clientActiveTexture;
178 extern GLMultiTexCoord2fProc multiTexCoord2f;
179
180 extern GLGenProgramsProc genPrograms;312 extern GLGenProgramsProc genPrograms;
181 extern GLDeleteProgramsProc deletePrograms;313 extern GLDeleteProgramsProc deletePrograms;
182 extern GLBindProgramProc bindProgram;314 extern GLBindProgramProc bindProgram;
@@ -184,6 +316,11 @@
184 extern GLProgramParameter4fProc programEnvParameter4f;316 extern GLProgramParameter4fProc programEnvParameter4f;
185 extern GLProgramParameter4fProc programLocalParameter4f;317 extern GLProgramParameter4fProc programLocalParameter4f;
186 extern GLGetProgramivProc getProgramiv;318 extern GLGetProgramivProc getProgramiv;
319 #endif
320
321 extern GLActiveTextureProc activeTexture;
322 extern GLClientActiveTextureProc clientActiveTexture;
323 extern GLMultiTexCoord2fProc multiTexCoord2f;
187324
188 extern GLGenFramebuffersProc genFramebuffers;325 extern GLGenFramebuffersProc genFramebuffers;
189 extern GLDeleteFramebuffersProc deleteFramebuffers;326 extern GLDeleteFramebuffersProc deleteFramebuffers;
@@ -192,16 +329,56 @@
192 extern GLFramebufferTexture2DProc framebufferTexture2D;329 extern GLFramebufferTexture2DProc framebufferTexture2D;
193 extern GLGenerateMipmapProc generateMipmap;330 extern GLGenerateMipmapProc generateMipmap;
194331
332 extern GLBindBufferProc bindBuffer;
333 extern GLDeleteBuffersProc deleteBuffers;
334 extern GLGenBuffersProc genBuffers;
335 extern GLBufferDataProc bufferData;
336 extern GLBufferSubDataProc bufferSubData;
337
338
339 extern GLGetShaderivProc getShaderiv;
340 extern GLGetShaderInfoLogProc getShaderInfoLog;
341 extern GLGetProgramivProc getProgramiv;
342 extern GLGetProgramInfoLogProc getProgramInfoLog;
343 extern GLCreateShaderProc createShader;
344 extern GLShaderSourceProc shaderSource;
345 extern GLCompileShaderProc compileShader;
346 extern GLCreateProgramProc createProgram;
347 extern GLAttachShaderProc attachShader;
348 extern GLLinkProgramProc linkProgram;
349 extern GLValidateProgramProc validateProgram;
350 extern GLDeleteShaderProc deleteShader;
351 extern GLDeleteProgramProc deleteProgram;
352 extern GLUseProgramProc useProgram;
353 extern GLGetUniformLocationProc getUniformLocation;
354 extern GLUniform1fProc uniform1f;
355 extern GLUniform1iProc uniform1i;
356 extern GLUniform2fProc uniform2f;
357 extern GLUniform2iProc uniform2i;
358 extern GLUniform3fProc uniform3f;
359 extern GLUniform3iProc uniform3i;
360 extern GLUniform4fProc uniform4f;
361 extern GLUniform4iProc uniform4i;
362 extern GLUniformMatrix4fvProc uniformMatrix4fv;
363 extern GLGetAttribLocationProc getAttribLocation;
364
365 extern GLEnableVertexAttribArrayProc enableVertexAttribArray;
366 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;
367 extern GLVertexAttribPointerProc vertexAttribPointer;
368
369
195 extern bool textureFromPixmap;370 extern bool textureFromPixmap;
196 extern bool textureRectangle;371 extern bool textureRectangle;
197 extern bool textureNonPowerOfTwo;372 extern bool textureNonPowerOfTwo;
373 extern bool textureNonPowerOfTwoMipmap;
198 extern bool textureEnvCombine;374 extern bool textureEnvCombine;
199 extern bool textureEnvCrossbar;375 extern bool textureEnvCrossbar;
200 extern bool textureBorderClamp;376 extern bool textureBorderClamp;
201 extern bool textureCompression;377 extern bool textureCompression;
202 extern GLint maxTextureSize;378 extern GLint maxTextureSize;
203 extern bool fbo;379 extern bool fbo;
204 extern bool fragmentProgram;380 extern bool vbo;
381 extern bool shaders;
205 extern GLint maxTextureUnits;382 extern GLint maxTextureUnits;
206383
207 extern bool canDoSaturated;384 extern bool canDoSaturated;
@@ -220,6 +397,7 @@
220397
221#define MAX_DEPTH 32398#define MAX_DEPTH 32
222399
400#ifndef USE_GLES
223struct GLFBConfig {401struct GLFBConfig {
224 GLXFBConfig fbConfig;402 GLXFBConfig fbConfig;
225 int yInverted;403 int yInverted;
@@ -227,6 +405,7 @@
227 int textureFormat;405 int textureFormat;
228 int textureTargets;406 int textureTargets;
229};407};
408#endif
230409
231#define NOTHING_TRANS_FILTER 0410#define NOTHING_TRANS_FILTER 0
232#define SCREEN_TRANS_FILTER 1411#define SCREEN_TRANS_FILTER 1
@@ -236,6 +415,7 @@
236extern GLScreenPaintAttrib defaultScreenPaintAttrib;415extern GLScreenPaintAttrib defaultScreenPaintAttrib;
237416
238class GLScreen;417class GLScreen;
418class GLFramebufferObject;
239419
240class GLScreenInterface :420class GLScreenInterface :
241 public WrapableInterface<GLScreen, GLScreenInterface>421 public WrapableInterface<GLScreen, GLScreenInterface>
@@ -302,11 +482,24 @@
302 CompOutput *);482 CompOutput *);
303 virtual void glDisableOutputClipping ();483 virtual void glDisableOutputClipping ();
304484
485 virtual GLMatrix *projectionMatrix ();
486
487 /**
488 * Hookable function used by plugins to shade the final composited
489 * Output.
490 *
491 * @param tmpRegion Describes the final composited output region
492 * @param scratchFbo Describes the final composited FBO that is
493 * to be rendered.
494 */
495 virtual void glPaintCompositedOutput (const CompRegion &region,
496 GLFramebufferObject *fbo,
497 unsigned int mask);
305};498};
306499
307500
308class GLScreen :501class GLScreen :
309 public WrapableHandler<GLScreenInterface, 6>,502 public WrapableHandler<GLScreenInterface, 7>,
310 public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,503 public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,
311 public CompOption::Class504 public CompOption::Class
312{505{
@@ -332,7 +525,9 @@
332 /**525 /**
333 * Gets the libGL address of a particular openGL functor526 * Gets the libGL address of a particular openGL functor
334 */527 */
528 #ifndef USE_GLES
335 GL::FuncPtr getProcAddress (const char *name);529 GL::FuncPtr getProcAddress (const char *name);
530 #endif
336531
337 void updateBackground ();532 void updateBackground ();
338533
@@ -346,8 +541,6 @@
346 */541 */
347 void setFilter (int, GLTexture::Filter);542 void setFilter (int, GLTexture::Filter);
348543
349 GLFragment::Storage * fragmentStorage ();
350
351 /**544 /**
352 * Sets a new compiz-wid openGL texture environment mode545 * Sets a new compiz-wid openGL texture environment mode
353 */546 */
@@ -356,7 +549,6 @@
356 /**549 /**
357 * Turns lighting on and off550 * Turns lighting on and off
358 */551 */
359
360 void setLighting (bool lighting);552 void setLighting (bool lighting);
361553
362 /**554 /**
@@ -371,7 +563,28 @@
371 GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);563 GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);
372 void unregisterBindPixmap (GLTexture::BindPixmapHandle);564 void unregisterBindPixmap (GLTexture::BindPixmapHandle);
373565
566 #ifndef USE_GLES
374 GLFBConfig * glxPixmapFBConfig (unsigned int depth);567 GLFBConfig * glxPixmapFBConfig (unsigned int depth);
568 #endif
569
570 #ifdef USE_GLES
571 EGLContext getEGLContext ();
572 #endif
573
574 /**
575 * Returns a GLProgram from the cache or creates one and caches it
576 */
577 GLProgram *getProgram (std::list<const GLShaderData*>);
578
579 /**
580 * Returns a GLShaderData from the cache or creates one and caches it
581 */
582 const GLShaderData *getShaderData (GLShaderParameters &params);
583
584 /**
585 * Returns the FBO compiz is using for the screen
586 */
587 GLFramebufferObject *fbo ();
375588
376 /**589 /**
377 * Returns a default icon texture590 * Returns a default icon texture
@@ -380,12 +593,6 @@
380593
381 void resetRasterPos ();594 void resetRasterPos ();
382595
383 /**
384 * Returns a 4x4 const float array which
385 * represents the current projection matrix
386 */
387 const float * projectionMatrix ();
388
389 bool glInitContext (XVisualInfo *);596 bool glInitContext (XVisualInfo *);
390597
391 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,598 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,
@@ -402,7 +609,12 @@
402 const GLMatrix &, const CompRegion &, CompOutput *);609 const GLMatrix &, const CompRegion &, CompOutput *);
403 WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);610 WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);
404611
612 WRAPABLE_HND (5, GLScreenInterface, GLMatrix *, projectionMatrix);
613 WRAPABLE_HND (6, GLScreenInterface, void, glPaintCompositedOutput,
614 const CompRegion &, GLFramebufferObject *, unsigned int);
615
405 friend class GLTexture;616 friend class GLTexture;
617 friend class GLWindow;
406618
407 private:619 private:
408 PrivateGLScreen *priv;620 PrivateGLScreen *priv;
@@ -453,10 +665,10 @@
453 * @param region Describes which region will be drawn665 * @param region Describes which region will be drawn
454 * @param mask Bitmask which describes how this window is drawn666 * @param mask Bitmask which describes how this window is drawn
455 */667 */
456 virtual bool glDraw (const GLMatrix &matrix,668 virtual bool glDraw (const GLMatrix &matrix,
457 GLFragment::Attrib &attrib,669 const GLWindowPaintAttrib &attrib,
458 const CompRegion &region,670 const CompRegion &region,
459 unsigned int mask);671 unsigned int mask);
460672
461 /**673 /**
462 * Hookable function to add points to a window674 * Hookable function to add points to a window
@@ -479,51 +691,18 @@
479 const CompRegion &clipRegion,691 const CompRegion &clipRegion,
480 unsigned int min = MAXSHORT,692 unsigned int min = MAXSHORT,
481 unsigned int max = MAXSHORT);693 unsigned int max = MAXSHORT);
482 virtual void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,694 virtual void glDrawTexture (GLTexture *texture, const GLMatrix &,
483 unsigned int);695 const GLWindowPaintAttrib &, unsigned int);
484 virtual void glDrawGeometry ();
485};696};
486697
487class GLWindow :698class GLWindow :
488 public WrapableHandler<GLWindowInterface, 5>,699 public WrapableHandler<GLWindowInterface, 4>,
489 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>700 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
490{701{
491 public:702 public:
492703
493 /**
494 * Class which describes the texture geometry and transformation points
495 * of a window
496 */
497 class Geometry {
498 public:
499 Geometry ();
500 ~Geometry ();
501
502 void reset ();
503
504 /**
505 * Set the number of vertices in the texture geometry
506 */
507 bool moreVertices (int newSize);
508
509 /**
510 * Set the number of indices in the texture geometry
511 */
512 bool moreIndices (int newSize);
513
514 public:
515 GLfloat *vertices;
516 int vertexSize;
517 int vertexStride;
518 GLushort *indices;
519 int indexSize;
520 int vCount;
521 int texUnits;
522 int texCoordSize;
523 int indexCount;
524 };
525
526 static GLWindowPaintAttrib defaultPaintAttrib;704 static GLWindowPaintAttrib defaultPaintAttrib;
705
527 public:706 public:
528707
529 GLWindow (CompWindow *w);708 GLWindow (CompWindow *w);
@@ -566,9 +745,20 @@
566 void updatePaintAttribs ();745 void updatePaintAttribs ();
567746
568 /**747 /**
569 * Returns the window texture geometry748 * Returns the window vertex buffer object
570 */749 */
571 Geometry & geometry ();750 GLVertexBuffer * vertexBuffer ();
751
752 /**
753 * Add a vertex and/or fragment shader function to the pipeline.
754 *
755 * @param name Name of the plugin adding the functions
756 * @param vertex_shader Function to add to the vertex shader
757 * @param fragment_shader Function to add to the fragment shader
758 */
759 void addShaders (std::string name,
760 std::string vertex_shader,
761 std::string fragment_shader);
572762
573 GLTexture *getIcon (int width, int height);763 GLTexture *getIcon (int width, int height);
574764
@@ -576,20 +766,24 @@
576 const GLWindowPaintAttrib &, const GLMatrix &,766 const GLWindowPaintAttrib &, const GLMatrix &,
577 const CompRegion &, unsigned int);767 const CompRegion &, unsigned int);
578 WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,768 WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,
579 GLFragment::Attrib &, const CompRegion &, unsigned int);769 const GLWindowPaintAttrib &, const CompRegion &,
770 unsigned int);
580 WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,771 WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,
581 const GLTexture::MatrixList &, const CompRegion &,772 const GLTexture::MatrixList &, const CompRegion &,
582 const CompRegion &,773 const CompRegion &,
583 unsigned int = MAXSHORT, unsigned int = MAXSHORT);774 unsigned int = MAXSHORT, unsigned int = MAXSHORT);
584 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,775 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,
585 GLTexture *texture, GLFragment::Attrib &, unsigned int);776 GLTexture *texture, const GLMatrix &,
586 WRAPABLE_HND (4, GLWindowInterface, void, glDrawGeometry);777 const GLWindowPaintAttrib &, unsigned int);
587778
588 friend class GLScreen;779 friend class GLScreen;
589 friend class PrivateGLScreen;780 friend class PrivateGLScreen;
781 friend class SpewScreen;
782 friend class SpewWindow;
590783
591 private:784 private:
592 PrivateGLWindow *priv;785 PrivateGLWindow *priv;
593};786};
594787
595#endif788#endif
789
596790
=== added file 'plugins/opengl/include/opengl/program.h'
--- plugins/opengl/include/opengl/program.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/program.h 2012-04-20 09:45:47 +0000
@@ -0,0 +1,75 @@
1/*
2 * Copyright © 2011 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Travis Watkins <travis.watkins@linaro.org>
24 */
25
26#ifndef _COMPIZ_GLPROGRAM_H
27#define _COMPIZ_GLPROGRAM_H
28
29#ifdef USE_GLES
30#include <GLES2/gl2.h>
31#else
32#include <GL/gl.h>
33#endif
34
35#include <core/core.h>
36#include <opengl/matrix.h>
37
38class PrivateProgram;
39
40class GLProgram
41{
42 public:
43 GLProgram (CompString &vertexShader, CompString &fragmentShader);
44 ~GLProgram ();
45
46 bool valid ();
47 void bind ();
48 void unbind ();
49
50 bool setUniform (const char *name, GLfloat value);
51 bool setUniform (const char *name, GLint value);
52 bool setUniform (const char *name, const GLMatrix &value);
53 bool setUniform2f (const char *name, GLfloat x, GLfloat y);
54 bool setUniform3f (const char *name, GLfloat x, GLfloat y, GLfloat z);
55 bool setUniform4f (const char *name,
56 GLfloat x,
57 GLfloat y,
58 GLfloat z,
59 GLfloat w);
60 bool setUniform2i (const char *name, GLint x, GLint y);
61 bool setUniform3i (const char *name, GLint x, GLint y, GLint z);
62 bool setUniform4i (const char *name,
63 GLint x,
64 GLint y,
65 GLint z,
66 GLint w);
67
68 GLuint attributeLocation (const char *name);
69
70 private:
71 PrivateProgram *priv;
72};
73
74#endif // _COMPIZ_GLPROGRAM_H
75
076
=== added file 'plugins/opengl/include/opengl/programcache.h'
--- plugins/opengl/include/opengl/programcache.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/programcache.h 2012-04-20 09:45:47 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright © 2011 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Travis Watkins <travis.watkins@linaro.org>
24 */
25
26#ifndef _COMPIZ_GLPROGRAMCACHE_H
27#define _COMPIZ_GLPROGRAMCACHE_H
28
29#include <string>
30#include <list>
31#include <map>
32#include <boost/bind.hpp>
33#include <opengl/program.h>
34
35class PrivateProgramCache;
36struct GLShaderData;
37
38class GLProgramCache
39{
40 private:
41 PrivateProgramCache *priv;
42
43 public:
44 GLProgramCache (size_t);
45 ~GLProgramCache ();
46
47 GLProgram* operator () (std::list<const GLShaderData*>);
48};
49
50#endif // _COMPIZ_GLPROGRAMCACHE_H
51
052
=== added file 'plugins/opengl/include/opengl/shadercache.h'
--- plugins/opengl/include/opengl/shadercache.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/shadercache.h 2012-04-20 09:45:47 +0000
@@ -0,0 +1,100 @@
1/*
2 * Copyright © 2012 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Alexandros Frantzis <alexandros.frantzis@linaro.org>
24 */
25#ifndef GL_SHADER_CACHE_H_
26#define GL_SHADER_CACHE_H_
27
28#include <string>
29
30/**
31 * How to use a variable in a shader.
32 */
33enum GLShaderVariableType
34{
35 /** The variable is not used */
36 GLShaderVariableNone,
37 /** The variable value is held in a uniform */
38 GLShaderVariableUniform,
39 /** The variable value is held in a varying (from a vertex attribute) */
40 GLShaderVariableVarying,
41};
42
43/**
44 * Parameters that define a vertex-fragment shader pair.
45 */
46struct GLShaderParameters
47{
48 /** Whether this shader supports opacity */
49 bool opacity;
50 /** Whether this shader supports brightness */
51 bool brightness;
52 /** Whether this shader supports saturation */
53 bool saturation;
54 /** Whether this shader supports color and how */
55 GLShaderVariableType color;
56 /** Whether this shader supports normals and how */
57 GLShaderVariableType normal;