diff -Nru compiz-0.9.12.2+16.04.20160415/cmake/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/cmake/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/cmake/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/cmake/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -19,11 +19,10 @@ plugin_extensions/CompizGenInstallImages.cmake) list (APPEND _PluginExtensionFiles plugin_extensions/CompizOpenGLFixups.cmake) - -if (USE_GSETTINGS) - list (APPEND _files CompizGSettings.cmake) - list (APPEND _PluginExtensionFiles plugin_extensions/CompizGenGSettings.cmake) -endif (USE_GSETTINGS) +list (APPEND _files + CompizGSettings.cmake) +list (APPEND _PluginExtensionFiles + plugin_extensions/CompizGenGSettings.cmake) install ( FILES ${_files} diff -Nru compiz-0.9.12.2+16.04.20160415/cmake/CompizGSettings.cmake compiz-0.9.12.2+16.10.20160517/cmake/CompizGSettings.cmake --- compiz-0.9.12.2+16.04.20160415/cmake/CompizGSettings.cmake 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/cmake/CompizGSettings.cmake 2016-05-17 02:52:30.000000000 +0000 @@ -1,10 +1,4 @@ option ( - USE_GSETTINGS - "Generate GSettings schemas" - ON -) - -option ( COMPIZ_DISABLE_GS_SCHEMAS_INSTALL "Disables gsettings schema installation" OFF @@ -74,8 +68,7 @@ if (PKG_CONFIG_TOOL AND GLIB_COMPILE_SCHEMAS AND NOT - COMPIZ_DISABLE_SCHEMAS_INSTALL AND - USE_GSETTINGS) + COMPIZ_DISABLE_SCHEMAS_INSTALL) # Install schema file install (CODE " @@ -111,8 +104,7 @@ endif (PKG_CONFIG_TOOL AND GLIB_COMPILE_SCHEMAS AND NOT - COMPIZ_DISABLE_SCHEMAS_INSTALL AND - USE_GSETTINGS) + COMPIZ_DISABLE_SCHEMAS_INSTALL) endfunction () function (add_gsettings_local_recompilation_rule _schemas) @@ -195,13 +187,13 @@ endfunction () -# generate gconf schema +# generate gsettings schema function (compiz_gsettings_schema _name _src _dst _inst) find_program (XSLTPROC_EXECUTABLE xsltproc) find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) mark_as_advanced (FORCE XSLTPROC_EXECUTABLE) - if (XSLTPROC_EXECUTABLE AND GLIB_COMPILE_SCHEMAS AND USE_GSETTINGS) + if (XSLTPROC_EXECUTABLE AND GLIB_COMPILE_SCHEMAS) add_custom_command ( OUTPUT ${_dst} COMMAND ${XSLTPROC_EXECUTABLE} diff -Nru compiz-0.9.12.2+16.04.20160415/cmake/plugin_extensions/CompizGenGSettings.cmake compiz-0.9.12.2+16.10.20160517/cmake/plugin_extensions/CompizGenGSettings.cmake --- compiz-0.9.12.2+16.04.20160415/cmake/plugin_extensions/CompizGenGSettings.cmake 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/cmake/plugin_extensions/CompizGenGSettings.cmake 2016-05-17 02:52:30.000000000 +0000 @@ -29,23 +29,20 @@ endif ("${COMPIZ_PLUGIN_INSTALL_TYPE}" STREQUAL "package") endmacro (compiz_gsettings_prepare_install_dirs) -if (USE_GSETTINGS) +compiz_gsettings_prepare_install_dirs () - compiz_gsettings_prepare_install_dirs () +set (PLUGIN_GSETTINGS_SCHEMA_DST + ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml) - set (PLUGIN_GSETTINGS_SCHEMA_DST - ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.${COMPIZ_CURRENT_PLUGIN}.gschema.xml) +set (_install_gsettings_schema ) +if (NOT _install_plugin_${COMPIZ_CURRENT_PLUGIN}) + set (_install_gsettings_schema NOINSTALL) +endif (NOT _install_plugin_${COMPIZ_CURRENT_PLUGIN}) + +compiz_gsettings_schema (${COMPIZ_CURRENT_PLUGIN} + ${COMPIZ_CURRENT_XML_FILE} + ${PLUGIN_GSETTINGS_SCHEMA_DST} + ${PLUGIN_SCHEMADIR} + ${_install_gsettings_schema}) - set (_install_gsettings_schema ) - if (NOT _install_plugin_${COMPIZ_CURRENT_PLUGIN}) - set (_install_gsettings_schema NOINSTALL) - endif (NOT _install_plugin_${COMPIZ_CURRENT_PLUGIN}) - - compiz_gsettings_schema (${COMPIZ_CURRENT_PLUGIN} - ${COMPIZ_CURRENT_XML_FILE} - ${PLUGIN_GSETTINGS_SCHEMA_DST} - ${PLUGIN_SCHEMADIR} - ${_install_gsettings_schema}) - list (APPEND COMPIZ_CURRENT_SOURCES_ADDS ${PLUGIN_GSETTINGS_SCHEMA_DST}) - -endif (USE_GSETTINGS) +list (APPEND COMPIZ_CURRENT_SOURCES_ADDS ${PLUGIN_GSETTINGS_SCHEMA_DST}) diff -Nru compiz-0.9.12.2+16.04.20160415/compizconfig/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/compizconfig/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/compizconfig/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/compizconfig/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -20,10 +20,7 @@ add_subdirectory (compizconfig-python) add_subdirectory (integration) add_subdirectory (ccsm) - -if (USE_GSETTINGS) - add_subdirectory (gsettings) -endif (USE_GSETTINGS) +add_subdirectory (gsettings) if (COMPIZ_BUILD_TESTING) add_subdirectory (mocks) diff -Nru compiz-0.9.12.2+16.04.20160415/compizconfig/integration/gnome/gsettings/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/compizconfig/integration/gnome/gsettings/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/compizconfig/integration/gnome/gsettings/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/compizconfig/integration/gnome/gsettings/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -1,7 +1,5 @@ include (FindPkgConfig) -if (USE_GSETTINGS) - set (_deps glib-2.0>=2.20.0 gio-2.0>=2.25.0) @@ -83,5 +81,3 @@ endif (COMPIZ_BUILD_TESTING) endif (COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_FOUND) - -endif (USE_GSETTINGS) diff -Nru compiz-0.9.12.2+16.04.20160415/compizconfig/integration/mate/gsettings/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/compizconfig/integration/mate/gsettings/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/compizconfig/integration/mate/gsettings/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/compizconfig/integration/mate/gsettings/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -1,7 +1,5 @@ include (FindPkgConfig) -if (USE_GSETTINGS) - set (_deps glib-2.0>=2.20.0 gio-2.0>=2.25.0) @@ -56,5 +54,3 @@ endif (COMPIZ_BUILD_TESTING) endif (COMPIZCONFIG_MATE_GSETTINGS_INTEGRATION_FOUND) - -endif (USE_GSETTINGS) diff -Nru compiz-0.9.12.2+16.04.20160415/debian/changelog compiz-0.9.12.2+16.10.20160517/debian/changelog --- compiz-0.9.12.2+16.04.20160415/debian/changelog 2016-05-24 12:06:18.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/debian/changelog 2016-05-24 12:06:18.000000000 +0000 @@ -1,3 +1,35 @@ +compiz (1:0.9.12.2+16.10.20160517-0ubuntu1) yakkety; urgency=medium + + [ Alberts Muktupāvels ] + * CMake: Remove USE_GSETTINGS option. + * Fix memory leaks in GWDSettingsStorage. + * OpenGL: use the number of Opaque windows around to decide whether + paint the bg or not (LP: #1574866) + * Remove GWDSettingsStorageInterface. + + [ Andrea Azzarone ] + * Add an option to notify that a key press is actually an "auto + repeat" one. (LP: #1572241) + + [ Eleni Maria Stea ] + * Expo, Scale: add support for bottom offsets (LP: #1573897, #1562346) + + [ Marco Trevisan (Treviño) ] + * Scale: allow to iterate through windows using Tab key + * Scale: use the selectedWindow as starting point when focusing a + window (LP: #1575168) + * Window: call stateChangeNotify when compiz state changed but before + changing the WM state (LP: #1521302) + + [ Sam Spilsbury smspillaz@gmail.com ] + * Blur: port the plugin to modern OpenGL + + [ handsome_feng ] + * Add a YBottomOffset value when stretch maximized windows。 (LP: + #1562348) + + -- Marco Trevisan (Treviño) Tue, 17 May 2016 02:53:09 +0000 + compiz (1:0.9.12.2+16.04.20160415-0ubuntu2) yakkety; urgency=medium * No-change rebuild for libpng soname change. diff -Nru compiz-0.9.12.2+16.04.20160415/debian/compiz-plugins.install compiz-0.9.12.2+16.10.20160517/debian/compiz-plugins.install --- compiz-0.9.12.2+16.04.20160415/debian/compiz-plugins.install 2016-05-24 12:06:18.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/debian/compiz-plugins.install 2016-05-24 12:06:18.000000000 +0000 @@ -4,6 +4,8 @@ usr/share/compiz/*annotate.* usr/lib/*/compiz/*bench.* usr/share/compiz/*bench.* +usr/lib/*/compiz/*blur.* +usr/share/compiz/*blur.* usr/lib/*/compiz/*clone.* usr/share/compiz/*clone.* usr/lib/*/compiz/*crashhandler.* diff -Nru compiz-0.9.12.2+16.04.20160415/debian/rules compiz-0.9.12.2+16.10.20160517/debian/rules --- compiz-0.9.12.2+16.04.20160415/debian/rules 2016-05-24 12:06:18.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/debian/rules 2016-05-24 12:06:18.000000000 +0000 @@ -20,9 +20,9 @@ override_dh_auto_configure: # right now, xorg-gtest won't compile on arm. ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(gles2_architectures))) - dh_auto_configure -- -DCOMPIZ_BUILD_WITH_RPATH=FALSE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCOMPIZ_PACKAGING_ENABLED=TRUE -DUSE_GSETTINGS=ON -DCOMPIZ_DISABLE_GS_SCHEMAS_INSTALL=OFF -DCOMPIZ_DISABLE_PLUGIN_KDE=ON -DCOMPIZ_BUILD_TESTING=OFF -DUSE_KDE4=OFF -DBUILD_GLES=ON -DBUILD_XORG_GTEST=OFF + dh_auto_configure -- -DCOMPIZ_BUILD_WITH_RPATH=FALSE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCOMPIZ_PACKAGING_ENABLED=TRUE -DCOMPIZ_DISABLE_GS_SCHEMAS_INSTALL=OFF -DCOMPIZ_DISABLE_PLUGIN_KDE=ON -DCOMPIZ_BUILD_TESTING=OFF -DUSE_KDE4=OFF -DBUILD_GLES=ON -DBUILD_XORG_GTEST=OFF else - dh_auto_configure -- -DCOMPIZ_BUILD_WITH_RPATH=FALSE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCOMPIZ_PACKAGING_ENABLED=TRUE -DUSE_GSETTINGS=ON -DCOMPIZ_DISABLE_GS_SCHEMAS_INSTALL=OFF -DCOMPIZ_DISABLE_PLUGIN_KDE=ON -DCOMPIZ_BUILD_TESTING=OFF -DUSE_KDE4=OFF + dh_auto_configure -- -DCOMPIZ_BUILD_WITH_RPATH=FALSE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCOMPIZ_PACKAGING_ENABLED=TRUE -DCOMPIZ_DISABLE_GS_SCHEMAS_INSTALL=OFF -DCOMPIZ_DISABLE_PLUGIN_KDE=ON -DCOMPIZ_BUILD_TESTING=OFF -DUSE_KDE4=OFF endif override_dh_install: diff -Nru compiz-0.9.12.2+16.04.20160415/.gitignore compiz-0.9.12.2+16.10.20160517/.gitignore --- compiz-0.9.12.2+16.04.20160415/.gitignore 2016-05-24 12:06:18.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -po/compiz.pot diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/CMakeLists.txt 2016-05-17 02:52:35.000000000 +0000 @@ -35,9 +35,6 @@ add_library (gtk_window_decorator_settings STATIC ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings.c) - add_library (gtk_window_decorator_settings_storage_interface STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-storage-interface.c) - add_library (gtk_window_decorator_settings_writable_interface STATIC ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-writable-interface.c) @@ -49,42 +46,38 @@ gtk_window_decorator_settings_interface gtk_window_decorator_settings_writable_interface gtk_window_decorator_settings - gtk_window_decorator_settings_storage_interface gtk_window_decorator_metacity_window_decoration_util gtk_window_decorator_cairo_window_decoration_util) - if (USE_GSETTINGS) - add_definitions (-DUSE_GSETTINGS) - add_library (gtk_window_decorator_settings_storage_gsettings STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-storage-gsettings.c) - - compiz_pkg_check_modules (GSETTINGS gio-2.0 glib-2.0) - - target_link_libraries (gtk_window_decorator_settings_storage_gsettings - ${GSETTINGS_LIBRARIES}) - - list (APPEND GTK_WINDOW_DECORATOR_ADDITIONAL_LIBRARIES - gtk_window_decorator_settings_storage_gsettings) - - set (_gwd_gschema_name org.compiz.gwd) - set (_gwd_gschema_filename ${_gwd_gschema_name}.gschema.xml) - set (_gwd_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_gwd_gschema_filename}) - set (_gwd_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_gwd_gschema_filename}) - set (_gwd_gschema_dest ${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/) - - add_custom_command (OUTPUT ${_gwd_gschema_generated_location} - COMMAND cp -r ${_gwd_gschema_filepath} ${_gwd_gschema_generated_location} - DEPENDS ${_gwd_gschema_filepath} - VERBATIM) - - add_custom_target (compiz_gwd_gsettings_org_compiz_gwd_schema ALL - DEPENDS ${_gwd_gschema_generated_location}) - - add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_compiz_gwd_schema) - - compiz_install_gsettings_schema (${_gwd_gschema_generated_location} - ${_gwd_gschema_dest}) - endif (USE_GSETTINGS) + add_library (gtk_window_decorator_settings_storage_gsettings STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-storage.c) + + compiz_pkg_check_modules (GSETTINGS gio-2.0 glib-2.0) + + target_link_libraries (gtk_window_decorator_settings_storage_gsettings + ${GSETTINGS_LIBRARIES}) + + list (APPEND GTK_WINDOW_DECORATOR_ADDITIONAL_LIBRARIES + gtk_window_decorator_settings_storage_gsettings) + + set (_gwd_gschema_name org.compiz.gwd) + set (_gwd_gschema_filename ${_gwd_gschema_name}.gschema.xml) + set (_gwd_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_gwd_gschema_filename}) + set (_gwd_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_gwd_gschema_filename}) + set (_gwd_gschema_dest ${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/) + + add_custom_command (OUTPUT ${_gwd_gschema_generated_location} + COMMAND cp -r ${_gwd_gschema_filepath} ${_gwd_gschema_generated_location} + DEPENDS ${_gwd_gschema_filepath} + VERBATIM) + + add_custom_target (compiz_gwd_gsettings_org_compiz_gwd_schema ALL + DEPENDS ${_gwd_gschema_generated_location}) + + add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_compiz_gwd_schema) + + compiz_install_gsettings_schema (${_gwd_gschema_generated_location} + ${_gwd_gschema_dest}) add_executable (gtk-window-decorator gtk-window-decorator.c diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage.c compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.c --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.c 2016-05-17 02:52:40.000000000 +0000 @@ -0,0 +1,506 @@ +/* + * Copyright © 2012 Canonical Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Authored By: Sam Spilsbury + */ +#include +#include + +#include + +#include + +#include "gwd-settings-writable-interface.h" +#include "gwd-settings-storage.h" + +const gchar * ORG_COMPIZ_GWD = "org.compiz.gwd"; +const gchar * ORG_GNOME_METACITY = "org.gnome.metacity"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES = "org.gnome.desktop.wm.preferences"; +const gchar * ORG_MATE_MARCO_GENERAL = "org.mate.Marco.general"; + +const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS = "use-tooltips"; +const gchar * ORG_COMPIZ_GWD_KEY_BLUR_TYPE = "blur-type"; +const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY = "metacity-theme-active-opacity"; +const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY = "metacity-theme-inactive-opacity"; +const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY = "metacity-theme-active-shade-opacity"; +const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY = "metacity-theme-inactive-shade-opacity"; +const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME = "use-metacity-theme"; +const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION = "mouse-wheel-action"; +const gchar * ORG_GNOME_METACITY_THEME = "theme"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR = "action-right-click-titlebar"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME = "theme"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT = "titlebar-uses-system-font"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT = "titlebar-font"; +const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT = "button-layout"; +const gchar * ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar"; +const gchar * ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar"; +const gchar * ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR = "action-right-click-titlebar"; +const gchar * ORG_MATE_MARCO_GENERAL_THEME = "theme"; +const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT = "titlebar-uses-system-font"; +const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT = "titlebar-font"; +const gchar * ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT = "button-layout"; + +struct _GWDSettingsStorage +{ + GObject parent; + + GWDSettingsWritable *writable; + gboolean connect; + + GSettings *gwd; + GSettings *desktop; + GSettings *metacity; + GSettings *marco; + + gboolean is_mate_desktop; +}; + +enum +{ + PROP_0, + + PROP_WRITABLE, + PROP_CONNECT, + + LAST_PROP +}; + +static GParamSpec *storage_properties[LAST_PROP] = { NULL }; + +G_DEFINE_TYPE (GWDSettingsStorage, gwd_settings_storage, G_TYPE_OBJECT) + +static inline GSettings * +get_settings_no_abort (const gchar *schema) +{ + GSettingsSchemaSource *source; + GSettings *settings; + + source = g_settings_schema_source_get_default (); + settings = NULL; + + if (g_settings_schema_source_lookup (source, schema, TRUE)) + settings = g_settings_new (schema); + + return settings; +} + +static void +translate_dashes_to_underscores (gchar *original) +{ + gint i = 0; + + for (i = 0; i < strlen (original); ++i) { + if (original[i] == '-') + original[i] = '_'; + } +} + +static void +org_compiz_gwd_settings_changed (GSettings *settings, + const gchar *key, + GWDSettingsStorage *storage) +{ + if (strcmp (key, ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION) == 0) + gwd_settings_storage_update_titlebar_actions (storage); + else if (strcmp (key, ORG_COMPIZ_GWD_KEY_BLUR_TYPE) == 0) + gwd_settings_storage_update_blur (storage); + else if (strcmp (key, ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME) == 0) + gwd_settings_storage_update_metacity_theme (storage); + else if (strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY) == 0 || + strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY) == 0 || + strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY) == 0 || + strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY) == 0) + gwd_settings_storage_update_opacity (storage); + else if (strcmp (key, ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS) == 0) + gwd_settings_storage_update_use_tooltips (storage); +} + +static void +org_gnome_desktop_wm_preferences_settings_changed (GSettings *settings, + const gchar *key, + GWDSettingsStorage *storage) +{ + if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT) == 0 || + strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT) == 0) + gwd_settings_storage_update_font (storage); + else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT) == 0) + gwd_settings_storage_update_font (storage); + else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR) == 0 || + strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR) == 0 || + strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR) == 0) + gwd_settings_storage_update_titlebar_actions (storage); + else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME) == 0) + gwd_settings_storage_update_metacity_theme (storage); + else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT) == 0) + gwd_settings_storage_update_button_layout (storage); +} + +static void +org_gnome_metacity_settings_changed (GSettings *settings, + const gchar *key, + GWDSettingsStorage *storage) +{ + if (strcmp (key, ORG_GNOME_METACITY_THEME) == 0) + gwd_settings_storage_update_metacity_theme (storage); +} + +static void +org_mate_marco_general_settings_changed (GSettings *settings, + const gchar *key, + GWDSettingsStorage *storage) +{ + if (strcmp (key, ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT) == 0 || + strcmp (key, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT) == 0) + gwd_settings_storage_update_font (storage); + else if (strcmp (key, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT) == 0) + gwd_settings_storage_update_font (storage); + else if (strcmp (key, ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR) == 0 || + strcmp (key, ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR) == 0 || + strcmp (key, ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR) == 0) + gwd_settings_storage_update_titlebar_actions (storage); + else if (strcmp (key, ORG_MATE_MARCO_GENERAL_THEME) == 0) + gwd_settings_storage_update_metacity_theme (storage); + else if (strcmp (key, ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT) == 0) + gwd_settings_storage_update_button_layout (storage); +} + +static void +gwd_settings_storage_constructed (GObject *object) +{ + GWDSettingsStorage *storage; + + storage = GWD_SETTINGS_STORAGE (object); + + G_OBJECT_CLASS (gwd_settings_storage_parent_class)->constructed (object); + + if (storage->gwd && storage->connect) { + g_signal_connect (storage->gwd, "changed", + G_CALLBACK (org_compiz_gwd_settings_changed), + storage); + } + + if (storage->desktop && storage->connect) { + g_signal_connect (storage->desktop, "changed", + G_CALLBACK (org_gnome_desktop_wm_preferences_settings_changed), + storage); + } + + if (storage->metacity && storage->connect) { + g_signal_connect (storage->metacity, "changed", + G_CALLBACK (org_gnome_metacity_settings_changed), + storage); + } + + if (storage->marco && storage->connect) { + g_signal_connect (storage->marco, "changed", + G_CALLBACK (org_mate_marco_general_settings_changed), + storage); + } +} + +static void +gwd_settings_storage_dispose (GObject *object) +{ + GWDSettingsStorage *storage; + + storage = GWD_SETTINGS_STORAGE (object); + + g_clear_object (&storage->writable); + + g_clear_object (&storage->gwd); + g_clear_object (&storage->desktop); + g_clear_object (&storage->metacity); + g_clear_object (&storage->marco); + + G_OBJECT_CLASS (gwd_settings_storage_parent_class)->dispose (object); +} + +static void +gwd_settings_storage_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GWDSettingsStorage *storage; + + storage = GWD_SETTINGS_STORAGE (object); + + switch (property_id) { + case PROP_WRITABLE: + storage->writable = g_value_dup_object (value); + break; + + case PROP_CONNECT: + storage->connect = g_value_get_boolean (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gwd_settings_storage_class_init (GWDSettingsStorageClass *storage_class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (storage_class); + + object_class->constructed = gwd_settings_storage_constructed; + object_class->dispose = gwd_settings_storage_dispose; + object_class->set_property = gwd_settings_storage_set_property; + + storage_properties[PROP_WRITABLE] = + g_param_spec_object ("writable", "GWDWritableSettings", + "A GWDWritableSettings object", + GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | + G_PARAM_STATIC_STRINGS); + + storage_properties[PROP_CONNECT] = + g_param_spec_boolean ("connect", "Connect", "Connect", + TRUE, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, LAST_PROP, + storage_properties); +} + +void +gwd_settings_storage_init (GWDSettingsStorage *storage) +{ + storage->gwd = get_settings_no_abort (ORG_COMPIZ_GWD); + storage->desktop = get_settings_no_abort (ORG_GNOME_DESKTOP_WM_PREFERENCES); + storage->metacity = get_settings_no_abort (ORG_GNOME_METACITY); + storage->marco = get_settings_no_abort (ORG_MATE_MARCO_GENERAL); + + if (storage->marco) { + const gchar *xdg_current_desktop; + + xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); + + if (xdg_current_desktop) { + gchar **desktops; + gint i; + + desktops = g_strsplit (xdg_current_desktop, ":", -1); + + for (i = 0; desktops[i] != NULL; i++) { + if (g_strcmp0 (desktops[i], "MATE") == 0) { + storage->is_mate_desktop = TRUE; + break; + } + } + + g_strfreev (desktops); + } + } +} + +GWDSettingsStorage * +gwd_settings_storage_new (GWDSettingsWritable *writable, + gboolean connect) +{ + return g_object_new (GWD_TYPE_SETTINGS_STORAGE, + "writable", writable, + "connect", connect, + NULL); +} + +gboolean +gwd_settings_storage_update_use_tooltips (GWDSettingsStorage *storage) +{ + gboolean use_tooltips; + + if (!storage->gwd) + return FALSE; + + use_tooltips = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS); + + return gwd_settings_writable_use_tooltips_changed (storage->writable, use_tooltips); +} + +gboolean +gwd_settings_storage_update_blur (GWDSettingsStorage *storage) +{ + gchar *blur_type; + gboolean retval; + + if (!storage->gwd) + return FALSE; + + blur_type = g_settings_get_string (storage->gwd, ORG_COMPIZ_GWD_KEY_BLUR_TYPE); + retval = gwd_settings_writable_blur_changed (storage->writable, blur_type); + g_free (blur_type); + + return retval; +} + +gboolean +gwd_settings_storage_update_metacity_theme (GWDSettingsStorage *storage) +{ + gboolean use_metacity_theme; + gchar *theme; + gboolean retval; + + if (!storage->gwd) + return FALSE; + + use_metacity_theme = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME); + + if (storage->is_mate_desktop) + theme = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_THEME); + else if (storage->metacity) + theme = g_settings_get_string (storage->metacity, ORG_GNOME_METACITY_THEME); + else + return FALSE; + + retval = gwd_settings_writable_metacity_theme_changed (storage->writable, use_metacity_theme, theme); + g_free (theme); + + return retval; +} + +gboolean +gwd_settings_storage_update_opacity (GWDSettingsStorage *storage) +{ + gdouble active; + gdouble inactive; + gboolean active_shade; + gboolean inactive_shade; + + if (!storage->gwd) + return FALSE; + + active = g_settings_get_double (storage->gwd, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY); + inactive = g_settings_get_double (storage->gwd, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY); + active_shade = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY); + inactive_shade = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY); + + return gwd_settings_writable_opacity_changed (storage->writable, active, inactive, + active_shade, inactive_shade); +} + +gboolean +gwd_settings_storage_update_button_layout (GWDSettingsStorage *storage) +{ + gchar *button_layout; + gboolean retval; + + if (storage->is_mate_desktop) + button_layout = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT); + else if (storage->desktop) + button_layout = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT); + else + return FALSE; + + retval = gwd_settings_writable_button_layout_changed (storage->writable, button_layout); + g_free (button_layout); + + return retval; +} + +gboolean +gwd_settings_storage_update_font (GWDSettingsStorage *storage) +{ + gchar *titlebar_font; + gboolean titlebar_system_font; + gboolean retval; + + if (storage->is_mate_desktop) { + titlebar_font = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT); + titlebar_system_font = g_settings_get_boolean (storage->marco, ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT); + } else if (storage->desktop) { + titlebar_font = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT); + titlebar_system_font = g_settings_get_boolean (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT); + } else + return FALSE; + + retval = gwd_settings_writable_font_changed (storage->writable, titlebar_system_font, titlebar_font); + g_free (titlebar_font); + + return retval; +} + +gboolean +gwd_settings_storage_update_titlebar_actions (GWDSettingsStorage *storage) +{ + gchar *double_click_action; + gchar *middle_click_action; + gchar *right_click_action; + gchar *mouse_wheel_action; + gboolean retval; + + if (!storage->gwd) + return FALSE; + + if (storage->is_mate_desktop) { + double_click_action = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR); + middle_click_action = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR); + right_click_action = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR); + } else if (storage->desktop) { + double_click_action = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR); + middle_click_action = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR); + right_click_action = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR); + } else + return FALSE; + + translate_dashes_to_underscores (double_click_action); + translate_dashes_to_underscores (middle_click_action); + translate_dashes_to_underscores (right_click_action); + + mouse_wheel_action = g_settings_get_string (storage->gwd, ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION); + + retval = gwd_settings_writable_titlebar_actions_changed (storage->writable, double_click_action, + middle_click_action, right_click_action, + mouse_wheel_action); + + g_free (double_click_action); + g_free (middle_click_action); + g_free (right_click_action); + g_free (mouse_wheel_action); + + return retval; +} + +GSettings * +gwd_get_org_compiz_gwd_settings (GWDSettingsStorage *storage) +{ + return storage->gwd; +} + +GSettings * +gwd_get_org_gnome_desktop_wm_preferences_settings (GWDSettingsStorage *storage) +{ + return storage->desktop; +} + +GSettings * +gwd_get_org_gnome_metacity_settings (GWDSettingsStorage *storage) +{ + return storage->metacity; +} + +GSettings * +gwd_get_org_mate_marco_general_settings (GWDSettingsStorage *storage) +{ + return storage->marco; +} diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-gsettings.c compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-gsettings.c --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-gsettings.c 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-gsettings.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,649 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include -#include - -#include - -#include - -#include "gwd-settings-writable-interface.h" -#include "gwd-settings-storage-interface.h" -#include "gwd-settings-storage-gsettings.h" - -const gchar * ORG_COMPIZ_GWD = "org.compiz.gwd"; -const gchar * ORG_GNOME_METACITY = "org.gnome.metacity"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES = "org.gnome.desktop.wm.preferences"; -const gchar * ORG_MATE_MARCO_GENERAL = "org.mate.Marco.general"; - -const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS = "use-tooltips"; -const gchar * ORG_COMPIZ_GWD_KEY_BLUR_TYPE = "blur-type"; -const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY = "metacity-theme-active-opacity"; -const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY = "metacity-theme-inactive-opacity"; -const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY = "metacity-theme-active-shade-opacity"; -const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY = "metacity-theme-inactive-shade-opacity"; -const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME = "use-metacity-theme"; -const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION = "mouse-wheel-action"; -const gchar * ORG_GNOME_METACITY_THEME = "theme"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR = "action-right-click-titlebar"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME = "theme"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT = "titlebar-uses-system-font"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT = "titlebar-font"; -const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT = "button-layout"; -const gchar * ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar"; -const gchar * ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar"; -const gchar * ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR = "action-right-click-titlebar"; -const gchar * ORG_MATE_MARCO_GENERAL_THEME = "theme"; -const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT = "titlebar-uses-system-font"; -const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT = "titlebar-font"; -const gchar * ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT = "button-layout"; - -#define GWD_SETTINGS_STORAGE_GSETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_SETTINGS_STORAGE_GSETTINGS, GWDSettingsStorageGSettings)); -#define GWD_SETTINGS_STORAGE_GSETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_SETTINGS_STORAGE_GSETTINGS, GWDSettingsStorageGSettingsClass)); -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_SETTINGS_STORAGE_GSETTINGS)); -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_SETTINGS_STORAGE_GSETTINGS)); -#define GWD_SETTINGS_STORAGE_GSETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_SETTINGS_STORAGE_GSETTINGS, GWDSettingsStorageGSettingsClass)); - -typedef struct _GWDSettingsStorageGSettings -{ - GObject parent; -} GWDSettingsStorageGSettings; - -typedef struct _GWDSettingsStorageGSettingsClass -{ - GObjectClass parent_class; -} GWDSettingsStorageGSettingsClass; - -static void gwd_settings_storage_gsettings_interface_init (GWDSettingsStorageInterface *interface); - -G_DEFINE_TYPE_WITH_CODE (GWDSettingsStorageGSettings, gwd_settings_storage_gsettings, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_STORAGE_INTERFACE, - gwd_settings_storage_gsettings_interface_init)) - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_SETTINGS_STORAGE_GSETTINGS, GWDSettingsStorageGSettingsPrivate)) - -enum -{ - GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_DESKTOP_GSETTINGS = 1, - GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_METACITY_GSETTINGS = 2, - GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_MARCO_GSETTINGS = 3, - GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_GWD_GSETTINGS = 4, - GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_WRITABLE_SETTINGS = 5 -}; - -typedef struct _GWDSettingsStorageGSettingsPrivate -{ - GSettings *desktop; - GSettings *metacity; - - GSettings *marco; - gboolean is_mate_desktop; - - GSettings *gwd; - GWDSettingsWritable *writable; -} GWDSettingsStorageGSettingsPrivate; - -static gboolean -gwd_settings_storage_gsettings_update_use_tooltips (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - - if (!priv->gwd) - return FALSE; - - return gwd_settings_writable_use_tooltips_changed (priv->writable, - g_settings_get_boolean (priv->gwd, - ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS)); -} - -static gboolean -gwd_settings_storage_gsettings_update_blur (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - - if (!priv->gwd) - return FALSE; - - return gwd_settings_writable_blur_changed (priv->writable, - g_settings_get_string (priv->gwd, - ORG_COMPIZ_GWD_KEY_BLUR_TYPE)); -} - -static gboolean -gwd_settings_storage_gsettings_update_metacity_theme (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage; - GWDSettingsStorageGSettingsPrivate *priv; - gboolean use_metacity_theme; - gchar *theme; - - storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - priv = GET_PRIVATE (storage); - - if (!priv->gwd) - return FALSE; - - use_metacity_theme = g_settings_get_boolean (priv->gwd, ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME); - - if (priv->is_mate_desktop) - theme = g_settings_get_string (priv->marco, ORG_MATE_MARCO_GENERAL_THEME); - else if (priv->metacity) - theme = g_settings_get_string (priv->metacity, ORG_GNOME_METACITY_THEME); - else - return FALSE; - - return gwd_settings_writable_metacity_theme_changed (priv->writable, - use_metacity_theme, - theme); -} - -static gboolean -gwd_settings_storage_gsettings_update_opacity (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - - if (!priv->gwd) - return FALSE; - - return gwd_settings_writable_opacity_changed (priv->writable, - g_settings_get_double (priv->gwd, - ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY), - g_settings_get_double (priv->gwd, - ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY), - g_settings_get_boolean (priv->gwd, - ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY), - g_settings_get_boolean (priv->gwd, - ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY)); -} - -static gboolean -gwd_settings_storage_gsettings_update_button_layout (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - gchar *button_layout; - - if (priv->is_mate_desktop) - button_layout = g_settings_get_string (priv->marco, ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT); - else if (priv->desktop) - button_layout = g_settings_get_string (priv->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT); - else - return FALSE; - - return gwd_settings_writable_button_layout_changed (priv->writable, - button_layout); -} - -static gboolean -gwd_settings_storage_gsettings_update_font (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - gchar *titlebar_font; - gboolean titlebar_system_font; - - if (priv->is_mate_desktop) { - titlebar_font = g_settings_get_string (priv->marco, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT); - titlebar_system_font = g_settings_get_boolean (priv->marco, ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT); - } else if (priv->desktop) { - titlebar_font = g_settings_get_string (priv->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT); - titlebar_system_font = g_settings_get_boolean (priv->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT); - } else - return FALSE; - - return gwd_settings_writable_font_changed (priv->writable, - titlebar_system_font, - titlebar_font); -} - -static inline gchar * -translate_dashes_to_underscores (const gchar *original) -{ - gint i = 0; - gchar *copy = g_strdup (original); - - if (!copy) - return NULL; - - for (; i < strlen (copy); ++i) - { - if (copy[i] == '-') - copy[i] = '_'; - } - - return copy; -} - -static gboolean -gwd_settings_storage_gsettings_update_titlebar_actions (GWDSettingsStorage *settings) -{ - GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - gchar *double_click_action, *middle_click_action, *right_click_action; - - if (!priv->gwd) - return FALSE; - - if (priv->is_mate_desktop) { - double_click_action = translate_dashes_to_underscores (g_settings_get_string (priv->marco, - ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR)); - middle_click_action = translate_dashes_to_underscores (g_settings_get_string (priv->marco, - ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR)); - right_click_action = translate_dashes_to_underscores (g_settings_get_string (priv->marco, - ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR)); - } else if (priv->desktop) { - double_click_action = translate_dashes_to_underscores (g_settings_get_string (priv->desktop, - ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR)); - middle_click_action = translate_dashes_to_underscores (g_settings_get_string (priv->desktop, - ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR)); - right_click_action = translate_dashes_to_underscores (g_settings_get_string (priv->desktop, - ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR)); - } else - return FALSE; - - return gwd_settings_writable_titlebar_actions_changed (priv->writable, - double_click_action, - middle_click_action, - right_click_action, - g_settings_get_string (priv->gwd, - ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION)); - - if (double_click_action) - g_free (double_click_action); - - if (middle_click_action) - g_free (middle_click_action); - - if (right_click_action) - g_free (right_click_action); -} - -static void -gwd_settings_storage_gsettings_interface_init (GWDSettingsStorageInterface *interface) -{ - interface->update_use_tooltips = gwd_settings_storage_gsettings_update_use_tooltips; - interface->update_blur = gwd_settings_storage_gsettings_update_blur; - interface->update_metacity_theme = gwd_settings_storage_gsettings_update_metacity_theme; - interface->update_opacity = gwd_settings_storage_gsettings_update_opacity; - interface->update_button_layout = gwd_settings_storage_gsettings_update_button_layout; - interface->update_font = gwd_settings_storage_gsettings_update_font; - interface->update_titlebar_actions = gwd_settings_storage_gsettings_update_titlebar_actions; -} - -static void -gwd_settings_storage_gsettings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_DESKTOP_GSETTINGS: - if (priv->desktop) - g_object_unref (priv->desktop); - - priv->desktop = g_value_dup_object (value); - break; - case GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_METACITY_GSETTINGS: - if (priv->metacity) - g_object_unref (priv->metacity); - - priv->metacity = g_value_dup_object (value); - break; - case GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_MARCO_GSETTINGS: - if (priv->marco) - g_object_unref (priv->marco); - - priv->marco = g_value_dup_object (value); - break; - case GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_GWD_GSETTINGS: - if (priv->gwd) - g_object_unref (priv->gwd); - - priv->gwd = g_value_dup_object (value); - break; - case GWD_SETTINGS_STORAGE_GSETTINGS_PROPERTY_WRITABLE_SETTINGS: - priv->writable = g_value_get_pointer (value); - break; - default: - g_assert_not_reached (); - } -} - -static void -gwd_settings_storage_gsettings_dispose (GObject *object) -{ - GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (object); - - G_OBJECT_CLASS (gwd_settings_storage_gsettings_parent_class)->dispose (object); - - if (priv->desktop) - g_object_unref (priv->desktop); - - if (priv->metacity) - g_object_unref (priv->metacity); - - if (priv->marco) - g_object_unref (priv->marco); - - if (priv->gwd) - g_object_unref (priv->gwd); -} - -static void -gwd_settings_storage_gsettings_finalize (GObject *object) -{ - G_OBJECT_CLASS (gwd_settings_storage_gsettings_parent_class)->finalize (object); -} - -static void -gwd_settings_storage_gsettings_class_init (GWDSettingsStorageGSettingsClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *properties[] = - { - NULL, - g_param_spec_object ("desktop-gsettings", - ORG_GNOME_DESKTOP_WM_PREFERENCES, - "GSettings Object for org.gnome.desktop.wm.preferences", - G_TYPE_SETTINGS, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY), - g_param_spec_object ("metacity-gsettings", - ORG_GNOME_METACITY, - "GSettings Object for org.gnome.metacity", - G_TYPE_SETTINGS, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY), - g_param_spec_object ("marco-gsettings", - ORG_MATE_MARCO_GENERAL, - "GSettings Object for org.mate.Marco.general", - G_TYPE_SETTINGS, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY), - g_param_spec_object ("gwd-gsettings", - ORG_COMPIZ_GWD, - "GSettings Object for org.compiz.gwd", - G_TYPE_SETTINGS, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY), - g_param_spec_pointer ("writable-settings", - "GWDWritableSettings", - "A GWDWritableSettings object", - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY) - }; - - g_type_class_add_private (klass, sizeof (GWDSettingsStorageGSettingsPrivate)); - - object_class->dispose = gwd_settings_storage_gsettings_dispose; - object_class->finalize = gwd_settings_storage_gsettings_finalize; - object_class->set_property = gwd_settings_storage_gsettings_set_property; - - g_object_class_install_properties (object_class, - sizeof (properties) / sizeof (properties[0]), - properties); -} - -void gwd_settings_storage_gsettings_init (GWDSettingsStorageGSettings *self) -{ -} - -GWDSettingsStorage * -gwd_settings_storage_gsettings_new (GSettings *desktop, - GSettings *metacity, - GSettings *marco, - GSettings *gwd, - GWDSettingsWritable *writable) -{ - static const guint gwd_settings_storage_gsettings_n_construction_params = 5; - GParameter param[gwd_settings_storage_gsettings_n_construction_params]; - - GValue desktop_value = G_VALUE_INIT; - GValue metacity_value = G_VALUE_INIT; - GValue marco_value = G_VALUE_INIT; - GValue gwd_value = G_VALUE_INIT; - GValue writable_value = G_VALUE_INIT; - - GWDSettingsStorage *storage = NULL; - GWDSettingsStorageGSettingsPrivate *priv; - - g_return_val_if_fail (writable != NULL, NULL); - - g_value_init (&desktop_value, G_TYPE_OBJECT); - g_value_init (&metacity_value, G_TYPE_OBJECT); - g_value_init (&marco_value, G_TYPE_OBJECT); - g_value_init (&gwd_value, G_TYPE_OBJECT); - g_value_init (&writable_value, G_TYPE_POINTER); - - g_value_take_object (&desktop_value, desktop); - g_value_take_object (&metacity_value, metacity); - g_value_take_object (&marco_value, marco); - g_value_take_object (&gwd_value, gwd); - g_value_set_pointer (&writable_value, writable); - - param[0].name = "desktop-gsettings"; - param[0].value = desktop_value; - param[1].name = "metacity-gsettings"; - param[1].value = metacity_value; - param[2].name = "marco-gsettings"; - param[2].value = marco_value; - param[3].name = "gwd-gsettings"; - param[3].value = gwd_value; - param[4].name = "writable-settings"; - param[4].value = writable_value; - - storage = GWD_SETTINGS_STORAGE_INTERFACE (g_object_newv (GWD_TYPE_SETTINGS_STORAGE_GSETTINGS, - gwd_settings_storage_gsettings_n_construction_params, - param)); - - g_value_unset (&desktop_value); - g_value_unset (&metacity_value); - g_value_unset (&marco_value); - g_value_unset (&gwd_value); - g_value_unset (&writable_value); - - priv = GET_PRIVATE (storage); - priv->is_mate_desktop = FALSE; - - if (marco) { - const gchar *xdg_current_desktop; - - xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); - if (xdg_current_desktop) { - gchar **desktops; - gint i; - - desktops = g_strsplit (xdg_current_desktop, ":", -1); - for (i = 0; desktops[i] != NULL; i++) { - if (g_strcmp0 (desktops[i], "MATE") == 0) { - priv->is_mate_desktop = TRUE; - break; - } - } - - g_strfreev (desktops); - } - } - - return storage; -} - -/* Factory methods */ - -static inline GSettings * -get_settings_no_abort (const gchar *schema) -{ - GSettings *settings = NULL; - - if (g_settings_schema_source_lookup (g_settings_schema_source_get_default(), schema, TRUE)) { - settings = g_settings_new (schema); - } - - return settings; -} - -static void -org_compiz_gwd_settings_changed (GSettings *settings, - const gchar *key, - gpointer user_data) -{ - GWDSettingsStorage *storage = GWD_SETTINGS_STORAGE_INTERFACE (user_data); - - if (strcmp (key, ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION) == 0) - gwd_settings_storage_update_titlebar_actions (storage); - else if (strcmp (key, ORG_COMPIZ_GWD_KEY_BLUR_TYPE) == 0) - gwd_settings_storage_update_blur (storage); - else if (strcmp (key, ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME) == 0) - gwd_settings_storage_update_metacity_theme (storage); - else if (strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY) == 0 || - strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY) == 0 || - strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY) == 0 || - strcmp (key, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY) == 0) - gwd_settings_storage_update_opacity (storage); - else if (strcmp (key, ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS) == 0) - gwd_settings_storage_update_use_tooltips (storage); -} - -void -gwd_connect_org_compiz_gwd_settings (GSettings *settings, - GWDSettingsStorage *storage) -{ - if (!settings) - return; - - g_signal_connect (settings, "changed", (GCallback) org_compiz_gwd_settings_changed, storage); -} - -GSettings * -gwd_get_org_compiz_gwd_settings () -{ - return get_settings_no_abort (ORG_COMPIZ_GWD); -} - -static void -org_gnome_metacity_settings_changed (GSettings *settings, - const gchar *key, - gpointer user_data) -{ - GWDSettingsStorage *storage; - - storage = GWD_SETTINGS_STORAGE_INTERFACE (user_data); - - if (strcmp (key, ORG_GNOME_METACITY_THEME) == 0) - gwd_settings_storage_update_metacity_theme (storage); -} - -void -gwd_connect_org_gnome_metacity_settings (GSettings *settings, - GWDSettingsStorage *storage) -{ - if (!settings) - return; - - g_signal_connect (settings, "changed", (GCallback) org_gnome_metacity_settings_changed, storage); -} - -GSettings * -gwd_get_org_gnome_metacity_settings () -{ - return get_settings_no_abort (ORG_GNOME_METACITY); -} - -static void -org_gnome_desktop_wm_keybindings_settings_changed (GSettings *settings, - const gchar *key, - gpointer user_data) -{ - GWDSettingsStorage *storage = GWD_SETTINGS_STORAGE_INTERFACE (user_data); - - if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT) == 0 || - strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT) == 0) - gwd_settings_storage_update_font (storage); - else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT) == 0) - gwd_settings_storage_update_font (storage); - else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR) == 0 || - strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR) == 0 || - strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR) == 0) - gwd_settings_storage_update_titlebar_actions (storage); - else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME) == 0) - gwd_settings_storage_update_metacity_theme (storage); - else if (strcmp (key, ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT) == 0) - gwd_settings_storage_update_button_layout (storage); -} - -void -gwd_connect_org_gnome_desktop_wm_preferences_settings (GSettings *settings, - GWDSettingsStorage *storage) -{ - if (!settings) - return; - - g_signal_connect (settings, "changed", - (GCallback) org_gnome_desktop_wm_keybindings_settings_changed, storage); -} - -GSettings * -gwd_get_org_gnome_desktop_wm_preferences_settings () -{ - return get_settings_no_abort (ORG_GNOME_DESKTOP_WM_PREFERENCES); -} - -static void -org_mate_marco_general_settings_changed (GSettings *settings, - const gchar *key, - gpointer user_data) -{ - GWDSettingsStorage *storage; - - storage = GWD_SETTINGS_STORAGE_INTERFACE (user_data); - - if (strcmp (key, ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT) == 0 || - strcmp (key, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT) == 0) - gwd_settings_storage_update_font (storage); - else if (strcmp (key, ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT) == 0) - gwd_settings_storage_update_font (storage); - else if (strcmp (key, ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR) == 0 || - strcmp (key, ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR) == 0 || - strcmp (key, ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR) == 0) - gwd_settings_storage_update_titlebar_actions (storage); - else if (strcmp (key, ORG_MATE_MARCO_GENERAL_THEME) == 0) - gwd_settings_storage_update_metacity_theme (storage); - else if (strcmp (key, ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT) == 0) - gwd_settings_storage_update_button_layout (storage); -} - -void -gwd_connect_org_mate_marco_general_settings (GSettings *settings, - GWDSettingsStorage *storage) -{ - if (!settings) - return; - - g_signal_connect (settings, "changed", (GCallback) org_mate_marco_general_settings_changed, storage); -} - -GSettings * -gwd_get_org_mate_marco_general_settings () -{ - return get_settings_no_abort (ORG_MATE_MARCO_GENERAL); -} diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-gsettings.h compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-gsettings.h --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-gsettings.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-gsettings.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_SETTINGS_STORAGE_GSETTINGS_H -#define _COMPIZ_GWD_SETTINGS_STORAGE_GSETTINGS_H - -#include -#include - -G_BEGIN_DECLS - -#define GWD_TYPE_SETTINGS_STORAGE_GSETTINGS (gwd_settings_storage_gsettings_get_type ()) -GType gwd_settings_storage_gsettings_get_type (); - -GWDSettingsStorage * -gwd_settings_storage_gsettings_new (GSettings *orgGNOMEDesktopSettings, - GSettings *metacitySettings, - GSettings *marcoSettings, - GSettings *gwdSettings, - GWDSettingsWritable *writableSettings); - -void -gwd_connect_org_compiz_gwd_settings (GSettings *settings, - GWDSettingsStorage *storage); - -GSettings * -gwd_get_org_compiz_gwd_settings (); - -void -gwd_connect_org_gnome_metacity_settings (GSettings *settings, - GWDSettingsStorage *storage); - -GSettings * -gwd_get_org_gnome_metacity_settings (); - -void -gwd_connect_org_gnome_desktop_wm_preferences_settings (GSettings *settings, - GWDSettingsStorage *storage); - -GSettings * -gwd_get_org_gnome_desktop_wm_preferences_settings (); - -void -gwd_connect_org_mate_marco_general_settings (GSettings *settings, - GWDSettingsStorage *storage); - -GSettings * -gwd_get_org_mate_marco_general_settings (); - -extern const gchar * ORG_COMPIZ_GWD; -extern const gchar * ORG_GNOME_METACITY; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES; -extern const gchar * ORG_MATE_MARCO_GENERAL; - -extern const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS; -extern const gchar * ORG_COMPIZ_GWD_KEY_BLUR_TYPE; -extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY; -extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY; -extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY; -extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY; -extern const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME; -extern const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION; -extern const gchar * ORG_GNOME_METACITY_THEME; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT; -extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT; -extern const gchar * ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR; -extern const gchar * ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR; -extern const gchar * ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR; -extern const gchar * ORG_MATE_MARCO_GENERAL_THEME; -extern const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT; -extern const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT; -extern const gchar * ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT; - -G_END_DECLS - -#endif diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage.h compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.h --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.h 2016-05-17 02:52:35.000000000 +0000 @@ -0,0 +1,101 @@ +/* + * Copyright © 2012 Canonical Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Authored By: Sam Spilsbury + */ + +#ifndef GWD_SETTINGS_STORAGE_H +#define GWD_SETTINGS_STORAGE_H + +#include +#include + +G_BEGIN_DECLS + +extern const gchar * ORG_COMPIZ_GWD; +extern const gchar * ORG_GNOME_METACITY; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES; +extern const gchar * ORG_MATE_MARCO_GENERAL; + +extern const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS; +extern const gchar * ORG_COMPIZ_GWD_KEY_BLUR_TYPE; +extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY; +extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY; +extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY; +extern const gchar * ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY; +extern const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME; +extern const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION; +extern const gchar * ORG_GNOME_METACITY_THEME; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT; +extern const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT; +extern const gchar * ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR; +extern const gchar * ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR; +extern const gchar * ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR; +extern const gchar * ORG_MATE_MARCO_GENERAL_THEME; +extern const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT; +extern const gchar * ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT; +extern const gchar * ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT; + +#define GWD_TYPE_SETTINGS_STORAGE gwd_settings_storage_get_type () +G_DECLARE_FINAL_TYPE (GWDSettingsStorage, gwd_settings_storage, + GWD, SETTINGS_STORAGE, GObject) + +GWDSettingsStorage * +gwd_settings_storage_new (GWDSettingsWritable *writable, + gboolean connect); + +gboolean +gwd_settings_storage_update_use_tooltips (GWDSettingsStorage *storage); + +gboolean +gwd_settings_storage_update_blur (GWDSettingsStorage *storage); + +gboolean +gwd_settings_storage_update_metacity_theme (GWDSettingsStorage *storage); + +gboolean +gwd_settings_storage_update_opacity (GWDSettingsStorage *storage); + +gboolean +gwd_settings_storage_update_button_layout (GWDSettingsStorage *storage); + +gboolean +gwd_settings_storage_update_font (GWDSettingsStorage *storage); + +gboolean +gwd_settings_storage_update_titlebar_actions (GWDSettingsStorage *storage); + +GSettings * +gwd_get_org_compiz_gwd_settings (GWDSettingsStorage *storage); + +GSettings * +gwd_get_org_gnome_desktop_wm_preferences_settings (GWDSettingsStorage *storage); + +GSettings * +gwd_get_org_gnome_metacity_settings (GWDSettingsStorage *storage); + +GSettings * +gwd_get_org_mate_marco_general_settings (GWDSettingsStorage *storage); + +G_END_DECLS + +#endif diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-interface.c compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-interface.c --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-interface.c 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-interface.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include "gwd-settings-storage-interface.h" - -static void gwd_settings_storage_interface_default_init (GWDSettingsStorageInterface *settings_interface); - -G_DEFINE_INTERFACE (GWDSettingsStorage, gwd_settings_storage_interface, G_TYPE_OBJECT); - -static void gwd_settings_storage_interface_default_init (GWDSettingsStorageInterface *settings_interface) -{ -} - -gboolean gwd_settings_storage_update_use_tooltips (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_use_tooltips) (settings); -} - -gboolean gwd_settings_storage_update_blur (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_blur) (settings); -} - -gboolean gwd_settings_storage_update_metacity_theme (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_metacity_theme) (settings); -} - -gboolean gwd_settings_storage_update_opacity (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_opacity) (settings); -} - -gboolean gwd_settings_storage_update_button_layout (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_button_layout) (settings); -} - -gboolean gwd_settings_storage_update_font (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_font) (settings); -} - -gboolean gwd_settings_storage_update_titlebar_actions (GWDSettingsStorage *settings) -{ - GWDSettingsStorageInterface *interface = GWD_SETTINGS_STORAGE_GET_INTERFACE (settings); - return (*interface->update_titlebar_actions) (settings); -} diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-interface.h compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-interface.h --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/gwd-settings-storage-interface.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage-interface.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_SETTINGS_STORAGE_INTERFACE_H -#define _COMPIZ_GWD_SETTINGS_STORAGE_INTERFACE_H - -#include -#include - -G_BEGIN_DECLS - -#define GWD_SETTINGS_STORAGE_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - GWD_TYPE_SETTINGS_STORAGE_INTERFACE, \ - GWDSettingsStorage)) -#define GWD_SETTINGS_STORAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE (obj, \ - GWD_TYPE_SETTINGS_STORAGE_INTERFACE, \ - GWDSettingsStorageInterface)) -#define GWD_TYPE_SETTINGS_STORAGE_INTERFACE (gwd_settings_storage_interface_get_type ()) - -typedef struct _GWDSettingsStorageInterface GWDSettingsStorageInterface; - -struct _GWDSettingsStorageInterface -{ - GTypeInterface parent; - - gboolean (*update_use_tooltips) (GWDSettingsStorage *settings); - gboolean (*update_blur) (GWDSettingsStorage *settings); - gboolean (*update_metacity_theme) (GWDSettingsStorage *settings); - gboolean (*update_opacity) (GWDSettingsStorage *settings); - gboolean (*update_button_layout) (GWDSettingsStorage *settings); - gboolean (*update_font) (GWDSettingsStorage *settings); - gboolean (*update_titlebar_actions) (GWDSettingsStorage *settings); -}; - -gboolean gwd_settings_storage_update_use_tooltips (GWDSettingsStorage *settings); -gboolean gwd_settings_storage_update_blur (GWDSettingsStorage *settings); -gboolean gwd_settings_storage_update_metacity_theme (GWDSettingsStorage *settings); -gboolean gwd_settings_storage_update_opacity (GWDSettingsStorage *settings); -gboolean gwd_settings_storage_update_button_layout (GWDSettingsStorage *settings); -gboolean gwd_settings_storage_update_font (GWDSettingsStorage *settings); -gboolean gwd_settings_storage_update_titlebar_actions (GWDSettingsStorage *settings); - -GType gwd_settings_storage_interface_get_type (void); - -G_END_DECLS - -#endif diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/settings.c compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/settings.c --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/settings.c 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/settings.c 2016-05-17 02:52:35.000000000 +0000 @@ -21,12 +21,7 @@ #include "gtk-window-decorator.h" #include "gwd-settings-writable-interface.h" -#include "gwd-settings-storage-interface.h" - -#ifdef USE_GSETTINGS -#include "gwd-settings-storage-gsettings.h" -#endif - +#include "gwd-settings-storage.h" #include "gwd-settings-xproperty-storage.h" GWDSettingsStorage *storage = NULL; @@ -34,26 +29,11 @@ gboolean init_settings (GWDSettingsWritable *writable, - WnckScreen *screen) + WnckScreen *screen) { -#ifdef USE_GSETTINGS -#define STORAGE_USED - GSettings *compiz = gwd_get_org_compiz_gwd_settings (); - GSettings *metacity = gwd_get_org_gnome_metacity_settings (); - GSettings *gnome = gwd_get_org_gnome_desktop_wm_preferences_settings (); - GSettings *marco = gwd_get_org_mate_marco_general_settings (); - - storage = gwd_settings_storage_gsettings_new (gnome, metacity, marco, compiz, writable); - - gwd_connect_org_compiz_gwd_settings (compiz, storage); - gwd_connect_org_gnome_metacity_settings (metacity, storage); - gwd_connect_org_gnome_desktop_wm_preferences_settings (gnome, storage); - gwd_connect_org_mate_marco_general_settings (marco, storage); -#endif - + storage = gwd_settings_storage_new (writable, TRUE); xprop_storage = gwd_settings_xproperty_storage_new (writable); -#ifdef STORAGE_USED gwd_settings_storage_update_metacity_theme (storage); gwd_settings_storage_update_opacity (storage); gwd_settings_storage_update_button_layout (storage); @@ -61,12 +41,8 @@ gwd_settings_storage_update_titlebar_actions (storage); gwd_settings_storage_update_blur (storage); gwd_settings_storage_update_use_tooltips (storage); - gwd_process_decor_shadow_property_update (); -#else - storage = NULL; -#endif -#undef STORAGE_USED + gwd_process_decor_shadow_property_update (); return TRUE; } diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/CMakeLists.txt 2016-05-17 02:52:35.000000000 +0000 @@ -18,12 +18,6 @@ link_directories (${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/..) - add_library (gtk_window_decorator_mock_settings_storage STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings_storage.cpp) - - target_link_libraries (gtk_window_decorator_mock_settings_storage - gtk_window_decorator_settings_storage_interface) - add_library (gtk_window_decorator_mock_settings STATIC ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings.cpp) @@ -49,71 +43,65 @@ gtk_window_decorator_settings gtk_window_decorator_mock_settings gtk_window_decorator_mock_settings_writable - gtk_window_decorator_mock_settings_storage gtk_window_decorator_mock_settings_notified) set (COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS gtk_window_decorator_settings gtk_window_decorator_settings_interface - gtk_window_decorator_settings_storage_interface gtk_window_decorator_settings_notified_interface) - if (USE_GSETTINGS) - add_definitions (-DUSE_GSETTINGS) - set (_desktop_gschema_name org.gnome.desktop.wm.preferences) - set (_desktop_gschema_filename ${_desktop_gschema_name}.gschema.xml) - set (_desktop_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_desktop_gschema_filename}) - set (_desktop_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_desktop_gschema_filename}) - - add_custom_command (OUTPUT ${_desktop_gschema_generated_location} - COMMAND cp -r ${_desktop_gschema_filepath} ${_desktop_gschema_generated_location} - DEPENDS ${_desktop_gschema_filepath} - VERBATIM) - - add_custom_target (compiz_gwd_gsettings_org_gnome_desktop_wm_preferences_schema ALL - DEPENDS ${_desktop_gschema_generated_location}) - - add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_gnome_desktop_wm_preferences_schema) - - set (_metacity_gschema_name org.gnome.metacity) - set (_metacity_gschema_filename ${_metacity_gschema_name}.gschema.xml) - set (_metacity_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_metacity_gschema_filename}) - set (_metacity_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_metacity_gschema_filename}) - - add_custom_command (OUTPUT ${_metacity_gschema_generated_location} - COMMAND cp -r ${_metacity_gschema_filepath} ${_metacity_gschema_generated_location} - DEPENDS ${_metacity_gschema_filepath} - VERBATIM) - - add_custom_target (compiz_gwd_gsettings_org_gnome_metacity_schema ALL - DEPENDS ${_metacity_gschema_generated_location}) - - add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_gnome_metacity_schema) - - set (_marco_gschema_name org.mate.marco) - set (_marco_gschema_filename ${_marco_gschema_name}.gschema.xml) - set (_marco_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_marco_gschema_filename}) - set (_marco_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_marco_gschema_filename}) - - add_custom_command (OUTPUT ${_marco_gschema_generated_location} - COMMAND cp -r ${_marco_gschema_filepath} ${_marco_gschema_generated_location} - DEPENDS ${_marco_gschema_filepath} - VERBATIM) - - add_custom_target (compiz_gwd_gsettings_org_mate_marco_schema ALL - DEPENDS ${_marco_gschema_generated_location}) - - add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_mate_marco_schema) - - set (COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES - ${COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES} - gtk_window_decorator_settings_storage_gsettings) - - set (COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS - ${COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS} - gtk_window_decorator_settings_storage_gsettings) - endif (USE_GSETTINGS) + set (_desktop_gschema_name org.gnome.desktop.wm.preferences) + set (_desktop_gschema_filename ${_desktop_gschema_name}.gschema.xml) + set (_desktop_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_desktop_gschema_filename}) + set (_desktop_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_desktop_gschema_filename}) + + add_custom_command (OUTPUT ${_desktop_gschema_generated_location} + COMMAND cp -r ${_desktop_gschema_filepath} ${_desktop_gschema_generated_location} + DEPENDS ${_desktop_gschema_filepath} + VERBATIM) + + add_custom_target (compiz_gwd_gsettings_org_gnome_desktop_wm_preferences_schema ALL + DEPENDS ${_desktop_gschema_generated_location}) + + add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_gnome_desktop_wm_preferences_schema) + + set (_metacity_gschema_name org.gnome.metacity) + set (_metacity_gschema_filename ${_metacity_gschema_name}.gschema.xml) + set (_metacity_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_metacity_gschema_filename}) + set (_metacity_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_metacity_gschema_filename}) + + add_custom_command (OUTPUT ${_metacity_gschema_generated_location} + COMMAND cp -r ${_metacity_gschema_filepath} ${_metacity_gschema_generated_location} + DEPENDS ${_metacity_gschema_filepath} + VERBATIM) + + add_custom_target (compiz_gwd_gsettings_org_gnome_metacity_schema ALL + DEPENDS ${_metacity_gschema_generated_location}) + + add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_gnome_metacity_schema) + + set (_marco_gschema_name org.mate.marco) + set (_marco_gschema_filename ${_marco_gschema_name}.gschema.xml) + set (_marco_gschema_filepath ${CMAKE_CURRENT_SOURCE_DIR}/${_marco_gschema_filename}) + set (_marco_gschema_generated_location ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/${_marco_gschema_filename}) + + add_custom_command (OUTPUT ${_marco_gschema_generated_location} + COMMAND cp -r ${_marco_gschema_filepath} ${_marco_gschema_generated_location} + DEPENDS ${_marco_gschema_filepath} + VERBATIM) + + add_custom_target (compiz_gwd_gsettings_org_mate_marco_schema ALL + DEPENDS ${_marco_gschema_generated_location}) + + add_gsettings_schema_to_recompilation_list (compiz_gwd_gsettings_org_mate_marco_schema) + set (COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES + ${COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES} + gtk_window_decorator_settings_storage_gsettings) + + set (COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS + ${COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS} + gtk_window_decorator_settings_storage_gsettings) target_link_libraries (compiz_test_gwd_settings ${COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES} diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.cpp compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.cpp --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,195 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include -#include - -#include - -#include "gwd-settings-storage-interface.h" -#include "compiz_gwd_mock_settings_storage.h" - -#define GWD_MOCK_SETTINGS_STORAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_MOCK_SETTINGS_STORAGE, GWDMockSettingsStorage)); -#define GWD_MOCK_SETTINGS_STORAGE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_MOCK_SETTINGS_STORAGE, GWDMockSettingsStorageClass)); -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS_STORAGE)); -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS_STORAGE)); -#define GWD_MOCK_SETTINGS_STORAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_MOCK_SETTINGS_STORAGE, GWDMockSettingsStorageClass)); - -typedef struct _GWDMockSettingsStorage -{ - GObject parent; -} GWDMockSettingsStorage; - -typedef struct _GWDMockSettingsStorageClass -{ - GObjectClass parent_class; -} GWDMockSettingsStorageClass; - -static void gwd_mock_settings_storage_interface_init (GWDSettingsStorageInterface *interface); - -G_DEFINE_TYPE_WITH_CODE (GWDMockSettingsStorage, gwd_mock_settings_storage, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_STORAGE_INTERFACE, - gwd_mock_settings_storage_interface_init)) - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_MOCK_SETTINGS_STORAGE, GWDMockSettingsStoragePrivate)) - -enum -{ - GWD_MOCK_SETTINGS_STORAGE_PROPERTY_GMOCK_INTERFACE = 1 -}; - -typedef struct _GWDMockSettingsStoragePrivate -{ - GWDMockSettingsStorageGMockInterface *mock; -} GWDMockSettingsStoragePrivate; - -gboolean gwd_mock_settings_storage_update_use_tooltips (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateUseTooltips (); -} - -gboolean gwd_mock_settings_storage_update_blur (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateBlur (); -} - -gboolean gwd_mock_settings_storage_update_metacity_theme (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateMetacityTheme (); -} - -gboolean gwd_mock_settings_storage_update_opacity (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateOpacity (); -} - -gboolean gwd_mock_settings_storage_update_button_layout (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateButtonLayout (); -} - -gboolean gwd_mock_settings_storage_update_font (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateFont (); -} - -gboolean gwd_mock_settings_storage_update_titlebar_actions (GWDSettingsStorage *settings) -{ - GWDMockSettingsStorage *settingsStorageMock = GWD_MOCK_SETTINGS_STORAGE (settings); - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (settingsStorageMock)->mock; - return settingsGMock->updateTitlebarActions (); -} - -static void gwd_mock_settings_storage_interface_init (GWDSettingsStorageInterface *interface) -{ - interface->update_use_tooltips = gwd_mock_settings_storage_update_use_tooltips; - interface->update_blur = gwd_mock_settings_storage_update_blur; - interface->update_metacity_theme = gwd_mock_settings_storage_update_metacity_theme; - interface->update_opacity = gwd_mock_settings_storage_update_opacity; - interface->update_button_layout = gwd_mock_settings_storage_update_button_layout; - interface->update_font = gwd_mock_settings_storage_update_font; - interface->update_titlebar_actions = gwd_mock_settings_storage_update_titlebar_actions; -} - -static void gwd_mock_settings_storage_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDMockSettingsStoragePrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_MOCK_SETTINGS_STORAGE_PROPERTY_GMOCK_INTERFACE: - if (!priv->mock) - priv->mock = reinterpret_cast (g_value_get_pointer (value)); - break; - default: - g_assert_not_reached (); - } -} - -static void gwd_mock_settings_storage_dispose (GObject *object) -{ - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_storage_parent_class)->dispose (object); - settingsGMock->dispose (); -} - -static void gwd_mock_settings_storage_finalize (GObject *object) -{ - GWDMockSettingsStorageGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_storage_parent_class)->finalize (object); - settingsGMock->finalize (); -} - -static void gwd_mock_settings_storage_class_init (GWDMockSettingsStorageClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (GWDMockSettingsStoragePrivate)); - - object_class->dispose = gwd_mock_settings_storage_dispose; - object_class->finalize = gwd_mock_settings_storage_finalize; - object_class->set_property = gwd_mock_settings_storage_set_property; - - g_object_class_install_property (object_class, - GWD_MOCK_SETTINGS_STORAGE_PROPERTY_GMOCK_INTERFACE, - g_param_spec_pointer ("gmock-interface", - "Google Mock Interface", - "Google Mock Interface", - static_cast (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); -} - -void gwd_mock_settings_storage_init (GWDMockSettingsStorage *self) -{ -} - -GWDSettingsStorage * -gwd_mock_settings_storage_new (GWDMockSettingsStorageGMockInterface *gmock) -{ - GValue gmock_interface_v = G_VALUE_INIT; - - g_value_init (&gmock_interface_v, G_TYPE_POINTER); - - g_value_set_pointer (&gmock_interface_v, reinterpret_cast (gmock)); - - GParameter param[1] = - { - { "gmock-interface", gmock_interface_v } - }; - - GWDSettingsStorage *storage = GWD_SETTINGS_STORAGE_INTERFACE (g_object_newv (GWD_TYPE_MOCK_SETTINGS_STORAGE, 1, param)); - - g_value_unset (&gmock_interface_v); - - return storage; -} diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.h compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.h --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_storage.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_MOCK_SETTINGS_STORAGE_H -#define _COMPIZ_GWD_MOCK_SETTINGS_STORAGE_H - -#include -#include - -#include - -typedef struct _GWDSettingsStorage GWDSettingsStorage; - -class GWDMockSettingsStorageGMockInterface; - -G_BEGIN_DECLS - -#define GWD_TYPE_MOCK_SETTINGS_STORAGE (gwd_mock_settings_storage_get_type ()) -GType gwd_mock_settings_storage_get_type (); - -GWDSettingsStorage * -gwd_mock_settings_storage_new (GWDMockSettingsStorageGMockInterface *); - -G_END_DECLS - -class GWDMockSettingsStorageGMockInterface -{ - public: - - virtual ~GWDMockSettingsStorageGMockInterface () {} - - virtual gboolean updateUseTooltips () = 0; - virtual gboolean updateDraggableBorderWidth () = 0; - virtual gboolean updateAttachModalDialogs () = 0; - virtual gboolean updateBlur () = 0; - virtual gboolean updateMetacityTheme () = 0; - virtual gboolean updateOpacity () = 0; - virtual gboolean updateButtonLayout () = 0; - virtual gboolean updateFont () = 0; - virtual gboolean updateTitlebarActions () = 0; - - virtual void dispose () = 0; - virtual void finalize () = 0; -}; - -class GWDMockSettingsStorageGMock : - public GWDMockSettingsStorageGMockInterface -{ - public: - - MOCK_METHOD0 (updateUseTooltips, gboolean ()); - MOCK_METHOD0 (updateDraggableBorderWidth, gboolean ()); - MOCK_METHOD0 (updateAttachModalDialogs, gboolean ()); - MOCK_METHOD0 (updateBlur, gboolean ()); - MOCK_METHOD0 (updateMetacityTheme, gboolean ()); - MOCK_METHOD0 (updateOpacity, gboolean ()); - MOCK_METHOD0 (updateButtonLayout, gboolean ()); - MOCK_METHOD0 (updateFont, gboolean ()); - MOCK_METHOD0 (updateTitlebarActions, gboolean ()); - MOCK_METHOD0 (dispose, void ()); - MOCK_METHOD0 (finalize, void ()); -}; - -#endif diff -Nru compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/test_gwd_settings.cpp compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/test_gwd_settings.cpp --- compiz-0.9.12.2+16.04.20160415/gtk/window-decorator/tests/test_gwd_settings.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/test_gwd_settings.cpp 2016-05-17 02:52:35.000000000 +0000 @@ -43,16 +43,14 @@ #include "gwd-settings-interface.h" #include "gwd-settings.h" -#include "gwd-settings-storage-gsettings.h" +#include "gwd-settings-storage.h" #include "gwd-settings-writable-interface.h" -#include "gwd-settings-storage-interface.h" #include "gwd-settings-notified-interface.h" #include "decoration.h" #include "compiz_gwd_mock_settings.h" #include "compiz_gwd_mock_settings_writable.h" -#include "compiz_gwd_mock_settings_storage.h" #include "compiz_gwd_mock_settings_notified.h" using ::testing::TestWithParam; @@ -1288,153 +1286,6 @@ gwd_settings_storage_update_titlebar_actions (storage); } -class GWDMockSettingsStorageFactoryWrapper : - public GWDSettingsStorageFactoryWrapperInterface -{ - public: - - virtual void SetUp (GWDSettingsWritable *writable) - { - mWritable = writable; - mStorageMock.reset (new GWDMockSettingsStorageGMock ()); - mStorage.reset (gwd_mock_settings_storage_new (mStorageMock.get ()), - boost::bind (gwd_settings_storage_unref, _1)); - } - - virtual GWDSettingsStorage * GetStorage () - { - return mStorage.get (); - } - - virtual void SetUseTooltips (gboolean useTooltips) - { - EXPECT_CALL (*mStorageMock, updateUseTooltips ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_use_tooltips_changed, mWritable, useTooltips))); - } - - virtual void SetBlur (const std::string &blurType) - { - EXPECT_CALL (*mStorageMock, updateBlur ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_blur_changed, mWritable, blurType.c_str ()))); - } - - virtual void SetOpacity (gdouble activeOpacity, - gdouble inactiveOpacity, - gboolean activeShadeOpacity, - gboolean inactiveShadeOpacity) - { - EXPECT_CALL (*mStorageMock, updateOpacity ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_opacity_changed, - mWritable, - activeOpacity, - inactiveOpacity, - activeShadeOpacity, - inactiveShadeOpacity))); - } - - virtual void SetMetacityTheme (gboolean useMetacityTheme, - const std::string &metacityTheme) - { - EXPECT_CALL (*mStorageMock, updateMetacityTheme ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_metacity_theme_changed, - mWritable, - useMetacityTheme, - metacityTheme.c_str ()))); - } - - virtual void SetButtonLayout (const std::string &buttonLayout) - { - EXPECT_CALL (*mStorageMock, updateButtonLayout ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_button_layout_changed, mWritable, buttonLayout.c_str ()))); - } - - virtual void SetFont (gboolean useSystemFont, const std::string &titlebarFont) - { - EXPECT_CALL (*mStorageMock, updateFont ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_font_changed, - mWritable, - useSystemFont, - titlebarFont.c_str ()))); - } - - virtual void SetTitlebarActions (const std::string &doubleClickAction, - const std::string &middleClickAction, - const std::string &rightClickAction, - const std::string &mouseWheelAction) - { - EXPECT_CALL (*mStorageMock, updateTitlebarActions ()) - .WillOnce ( - InvokeFunctor ( - boost::bind ( - gwd_settings_writable_titlebar_actions_changed, - mWritable, - doubleClickAction.c_str (), - middleClickAction.c_str (), - rightClickAction.c_str (), - mouseWheelAction.c_str ()))); - } - - virtual void TearDown () - { - if (mStorage) - { - EXPECT_CALL (*mStorageMock, dispose ()); - EXPECT_CALL (*mStorageMock, finalize ()); - } - - mStorage.reset (); - mStorageMock.reset (); - } - - private: - - GWDSettingsWritable *mWritable; - boost::shared_ptr mStorageMock; - boost::shared_ptr mStorage; -}; - -INSTANTIATE_TEST_CASE_P (MockStorageUpdates, GWDSettingsTestStorageUpdates, - ::testing::Values (boost::shared_ptr (new GWDMockSettingsStorageFactoryWrapper ()))); - -#ifdef USE_GSETTINGS -class GWDSettingsStorageGSettingsTest : - public GWDSettingsTestCommon -{ -}; - -TEST_F (GWDSettingsStorageGSettingsTest, TestNoDeathOnConnectingSignalToNULLObject) -{ - boost::shared_ptr mStorageMock (new GWDMockSettingsStorageGMock ()); - boost::shared_ptr mStorage (gwd_mock_settings_storage_new (mStorageMock.get ()), - boost::bind (gwd_settings_storage_unref, _1)); - - gwd_connect_org_compiz_gwd_settings (NULL, mStorage.get ()); - gwd_connect_org_gnome_metacity_settings (NULL, mStorage.get ()); - gwd_connect_org_gnome_desktop_wm_preferences_settings (NULL, mStorage.get ()); - gwd_connect_org_mate_marco_general_settings (NULL, mStorage.get ()); - - EXPECT_CALL (*mStorageMock, dispose ()); - EXPECT_CALL (*mStorageMock, finalize ()); -} - class GWDSettingsStorageGSettingsFactoryWrapper : public GWDSettingsStorageFactoryWrapperInterface { @@ -1445,18 +1296,14 @@ gsliceEnv.SetUpEnv (); gsettingsEnv.SetUpEnv (MOCK_PATH); - /* We do not need to keep a reference to these */ - mGWDSettings = gwd_get_org_compiz_gwd_settings (); - mMetacitySettings = gwd_get_org_gnome_metacity_settings (); - mDesktopSettings = gwd_get_org_gnome_desktop_wm_preferences_settings (); - mMarcoSettings = gwd_get_org_mate_marco_general_settings (); - - mStorage.reset (gwd_settings_storage_gsettings_new (mDesktopSettings, - mMetacitySettings, - mMarcoSettings, - mGWDSettings, - writable), + mStorage.reset (gwd_settings_storage_new (writable, FALSE), boost::bind (gwd_settings_storage_unref, _1)); + + /* We do not need to keep a reference to these */ + mGWDSettings = gwd_get_org_compiz_gwd_settings (GetStorage ()); + mMetacitySettings = gwd_get_org_gnome_metacity_settings (GetStorage ()); + mDesktopSettings = gwd_get_org_gnome_desktop_wm_preferences_settings (GetStorage ()); + mMarcoSettings = gwd_get_org_mate_marco_general_settings (GetStorage ()); } virtual GWDSettingsStorage * GetStorage () @@ -1579,5 +1426,3 @@ INSTANTIATE_TEST_CASE_P (GSettingsStorageUpdates, GWDSettingsTestStorageUpdates, ::testing::Values (boost::shared_ptr (new GWDSettingsStorageGSettingsFactoryWrapper ()))); - -#endif diff -Nru compiz-0.9.12.2+16.04.20160415/include/core/screen.h compiz-0.9.12.2+16.10.20160517/include/core/screen.h --- compiz-0.9.12.2+16.04.20160415/include/core/screen.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/include/core/screen.h 2016-05-17 02:52:06.000000000 +0000 @@ -169,8 +169,11 @@ { public: virtual void incrementDesktopWindowCount() = 0; + virtual void incrementOpaqueDesktopWindowCount() = 0; virtual void decrementDesktopWindowCount() = 0; + virtual void decrementOpaqueDesktopWindowCount() = 0; virtual int desktopWindowCount() = 0; + virtual int opaqueDesktopWindowCount() = 0; protected: ~DesktopWindowCount() {} }; diff -Nru compiz-0.9.12.2+16.04.20160415/metadata/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/metadata/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/metadata/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/metadata/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -40,16 +40,14 @@ DEPENDS ${_core_xml_file} ) -if (USE_GSETTINGS) - set (_core_gschema_path ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.core.gschema.xml) - compiz_gsettings_schema ( - compiz - ${_core_xml_file} - ${_core_gschema_path} - ${datadir}/glib-2.0/schemas - ) - add_custom_target (core-settings-schema ALL - DEPENDS ${_core_gschema_path} - core-xml-file - ) -endif () +set (_core_gschema_path ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.core.gschema.xml) +compiz_gsettings_schema ( + compiz + ${_core_xml_file} + ${_core_gschema_path} + ${datadir}/glib-2.0/schemas +) +add_custom_target (core-settings-schema ALL + DEPENDS ${_core_gschema_path} + core-xml-file +) diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/blur/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/plugins/blur/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/plugins/blur/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/blur/CMakeLists.txt 2016-05-17 02:52:47.000000000 +0000 @@ -2,15 +2,15 @@ include (CompizPlugin) -#find_package (OpenGL) +find_package (OpenGL) -#if (OPENGL_GLU_FOUND) -# compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR}) +if (OPENGL_GLU_FOUND) + compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR}) -# if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR) -# set_target_properties ( -# blur PROPERTIES -# INSTALL_RPATH "${COMPIZ_LIBDIR}" -# ) -# endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR) -#endif () + if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR) + set_target_properties ( + blur PROPERTIES + INSTALL_RPATH "${COMPIZ_LIBDIR}" + ) + endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR) +endif () diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/blur/src/blur.cpp compiz-0.9.12.2+16.10.20160517/plugins/blur/src/blur.cpp --- compiz-0.9.12.2+16.04.20160415/plugins/blur/src/blur.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/blur/src/blur.cpp 2016-05-17 02:52:47.000000000 +0000 @@ -22,19 +22,22 @@ * * Author: David Reveman */ - #include +#include +#include -COMPIZ_PLUGIN_20090315 (blur, BlurPluginVTable) - -const unsigned short BLUR_GAUSSIAN_RADIUS_MAX = 15; +/* Supporting independent texture fetch operations will require + * GLVertexBuffer to support per-plugin attributes as texture co-ordinates + * are two-component and not four-component + */ +#define INDEPENDENT_TEX_SUPPORTED 0 -const unsigned short BLUR_STATE_CLIENT = 0; -const unsigned short BLUR_STATE_DECOR = 1; -const unsigned short BLUR_STATE_NUM = 2; +COMPIZ_PLUGIN_20090315 (blur, BlurPluginVTable) /* pascal triangle based kernel generator */ -static int +namespace +{ +int blurCreateGaussianLinearKernel (int radius, float strength, float *amp, @@ -106,6 +109,7 @@ return radius; } +} void BlurScreen::updateFilterRadius () @@ -137,20 +141,11 @@ { updateFilterRadius (); - foreach (BlurFunction &bf, srcBlurFunctions) - GLFragment::destroyFragmentFunction (bf.id); srcBlurFunctions.clear (); - foreach (BlurFunction &bf, dstBlurFunctions) - GLFragment::destroyFragmentFunction (bf.id); dstBlurFunctions.clear (); - width = height = 0; - - if (program) - { - GL::deletePrograms (1, &program); - program = 0; - } + program.reset (); + texture.clear (); } static CompRegion @@ -249,7 +244,6 @@ int threshold, std::vector box) { - this->state[state].threshold = threshold; this->state[state].box = box; @@ -289,7 +283,7 @@ match = &bScreen->optionGetFocusBlurMatch (); - focus = GL::fragmentProgram && match->evaluate (window); + focus = GL::shaders && match->evaluate (window); if (focus != focusBlur) { focusBlur = focus; @@ -421,49 +415,75 @@ } cScreen->preparePaint (msSinceLastPaint); +} - if (cScreen->damageMask () & COMPOSITE_SCREEN_DAMAGE_REGION_MASK) +bool +BlurScreen::markAreaDirty (const CompRegion &r) +{ + return allowAreaDirtyOnOwnDamageBuffer; +} + +void +BlurScreen::damageCutoff () +{ + if (alphaBlur) { - /* walk from bottom to top and expand damage */ - if (alphaBlur) + this->output = &screen->fullscreenOutput (); + + /* We need to do a primary pass here with glPaint to check which + * regions of the backbuffer need to be updated. + * + * Because the backbuffer is effectively partially undefined, we are completely + * reliant on what core is telling us the repair regions of the + * backbuffer need to be - but obviously we can't completely rely + * on it because of a feedback effect, as we need to expand + * the repair region slightly so that the texture sampler + * doesn't go out of range of the damage region. If we were to + * simply expand the damage region, then that would feedback to us + * on the next frame, until the damage region eventually became infinite. + * + * As such, we have a tracker in core to track all damage except the effect + * of expanding the damage region that came back to us. We then use + * this tracker along with the frame age to determine what damage really + * needs to be expanded in order to determine the backbuffer update region, + * and then use the real damage in order to determine what blur regions + * should be updated + */ + backbufferUpdateRegionThisFrame &= emptyRegion; + CompRegion frameAgeDamage = damageQuery->damageForFrameAge (cScreen->getFrameAge ()); + foreach (CompWindow *w, screen->windows ()) { - int x1, y1, x2, y2; - int count = 0; - CompRegion damage (cScreen->currentDamage ()); + /* Skip windows that would not have glPaint called on them */ + if (w->destroyed ()) + continue; - foreach (CompWindow *w, screen->windows ()) - { - BLUR_WINDOW (w); + if (!w->shaded () && !w->isViewable ()) + continue; - if (!w->isViewable () || !CompositeWindow::get (w)->damaged ()) - continue; + BlurWindow *bw = BlurWindow::get (w); - if (!bw->region.isEmpty ()) - { - CompRect r = bw->region.boundingRect (); - CompRect d = damage.boundingRect (); - x1 = r.x1 () - filterRadius; - y1 = r.y1 () - filterRadius; - x2 = r.x2 () + filterRadius; - y2 = r.y2 () + filterRadius; - - if (x1 < d.x2 () && - y1 < d.y2 () && - x2 > d.x1 () && - y2 > d.y1 ()) - { - damage.shrink (-filterRadius, -filterRadius); - count++; - } - } - } + if (!bw->cWindow->redirected ()) + continue; - if (count) - cScreen->damageRegion (damage); + if (!bw->projectedBlurRegion.isEmpty ()) + bw->projectedBlurRegion &= emptyRegion; - this->count = count; + GLMatrix screenSpace; + screenSpace.toScreenSpace (this->output, -DEFAULT_Z_CAMERA); + + bw->gWindow->glPaint (bw->gWindow->paintAttrib (), screenSpace, + frameAgeDamage, + PAINT_WINDOW_NO_CORE_INSTANCE_MASK); + + backbufferUpdateRegionThisFrame += bw->projectedBlurRegion; } + + allowAreaDirtyOnOwnDamageBuffer = false; + cScreen->damageRegion (backbufferUpdateRegionThisFrame); + allowAreaDirtyOnOwnDamageBuffer = true; } + + cScreen->damageCutoff (); } bool @@ -471,23 +491,10 @@ const GLMatrix &transform, const CompRegion ®ion, CompOutput *output, unsigned int mask) { - bool status; - if (alphaBlur) { stencilBox = region.boundingRect (); this->region = region; - - if (mask & PAINT_SCREEN_REGION_MASK) - { - /* we need to redraw more than the screen region being updated */ - if (count) - { - this->region.shrink (-filterRadius * 2, -filterRadius * 2); - - this->region &= screen->region (); - } - } } if (!blurOcclusion) @@ -500,12 +507,7 @@ this->output = output; - if (alphaBlur) - status = gScreen->glPaintOutput (sAttrib, transform, this->region, output, mask); - else - status = gScreen->glPaintOutput (sAttrib, transform, region, output, mask); - - return status; + return gScreen->glPaintOutput (sAttrib, transform, region, output, mask); } void @@ -542,12 +544,42 @@ cScreen->donePaint (); } +void +BlurWindow::glTransformationComplete (const GLMatrix &matrix, + const CompRegion ®ion, + unsigned int mask) +{ + gWindow->glTransformationComplete (matrix, region, mask); + + int clientThreshold; + const CompRegion *reg = NULL; + + /* only care about client window blurring when it's translucent */ + if (mask & PAINT_WINDOW_TRANSLUCENT_MASK) + clientThreshold = state[BLUR_STATE_CLIENT].threshold; + else + clientThreshold = 0; + + if (mask & PAINT_WINDOW_TRANSFORMED_MASK) + reg = &infiniteRegion; + else + reg = ®ion; + + bScreen->tmpRegion = this->region.intersected (*reg); + + if (state[BLUR_STATE_DECOR].threshold || clientThreshold) + { + determineBlurRegion (bScreen->optionGetFilter (), + matrix, + clientThreshold); + } +} + bool BlurWindow::glPaint (const GLWindowPaintAttrib &attrib, const GLMatrix &transform, const CompRegion ®ion, unsigned int mask) { - bool status = gWindow->glPaint (attrib, transform, region, mask); if (!bScreen->blurOcclusion && @@ -564,307 +596,359 @@ return status; } -GLFragment::FunctionId -BlurScreen::getSrcBlurFragmentFunction (GLTexture *texture, - int param) +namespace { - GLFragment::FunctionData data; - BlurFunction function; - int target; - - if (texture->target () == GL_TEXTURE_2D) - target = COMP_FETCH_TARGET_2D; - else - target = COMP_FETCH_TARGET_RECT; +struct SamplerInfo +{ + GLint target; + CompString func; +}; - foreach (BlurFunction &bf, srcBlurFunctions) - if (bf.param == param && bf.target == target) - return bf.id; +SamplerInfo +getSamplerInfoForSize (const CompSize &size) +{ + SamplerInfo info; - if (data.status ()) +#ifdef USE_GLES + info.target = GL_TEXTURE_2D; + info.func = "texture2D"; +#else + if (GL::textureNonPowerOfTwo || + (POWER_OF_TWO (size.width ()) && POWER_OF_TWO (size.height ()))) + { + info.target = GL_TEXTURE_2D; + info.func = "texture2D"; + } + else { - static const char *temp[] = { "offset0", "offset1", "sum" }; - unsigned int i; + info.target = GL_TEXTURE_RECTANGLE_NV; + info.func = "textureRECT"; + } +#endif - for (i = 0; i < sizeof (temp) / sizeof (temp[0]); i++) - data.addTempHeaderOp (temp[i]); + return info; +} +} - data.addDataOp ( - "MUL offset0, program.env[%d].xyzw, { 1.0, 1.0, 0.0, 0.0 };" - "MUL offset1, program.env[%d].zwww, { 1.0, 1.0, 0.0, 0.0 };", - param, param); +/* XXX: param is redundant */ +const CompString & +BlurScreen::getSrcBlurFragmentFunction (GLTexture *texture) +{ + BlurFunction function; + std::stringstream data (std::stringstream::out); + SamplerInfo info (getSamplerInfoForSize (CompSize (texture->width (), + texture->height ()))); - switch (optionGetFilter ()) { - case BlurOptions::Filter4xbilinear: - default: - data.addFetchOp ("output", "offset0", target); - data.addDataOp ("MUL sum, output, 0.25;"); - data.addFetchOp ("output", "-offset0", target); - data.addDataOp ("MAD sum, output, 0.25, sum;"); - data.addFetchOp ("output", "offset1", target); - data.addDataOp ("MAD sum, output, 0.25, sum;"); - data.addFetchOp ("output", "-offset1", target); - data.addDataOp ("MAD output, output, 0.25, sum;"); - break; - } + foreach (const BlurFunction &bf, srcBlurFunctions) + if (bf.target == info.target) + return bf.shader; - if (!data.status ()) - return 0; + data << "uniform vec4 focusblur_input_offset;\n"\ + "\n"\ + "void focusblur_fragment ()\n"\ + "{\n"; - function.id = data.createFragmentFunction ("blur"); - function.target = target; - function.param = param; - function.unit = 0; + if (optionGetFilter () == BlurOptions::Filter4xbilinear) + data << " float blur_offset0, blur_offset1;\n"\ + " vec4 blur_sum;\n"\ + " vec4 offset0 = focusblur_input_offset.xyzw * vec4 (1.0, 1.0, 0.0, 0.0);\n"\ + " vec4 offset1 = focusblur_input_offset.zwww * vec4 (1.0, 1.0, 0.0, 0.0);\n" + " vec4 output = texture2D (texture0, vTexCoord0 + offset0);\n"\ + " blur_sum = output * 0.25;\n"\ + " output = " << info.func << " (texture0, vTexCoord0 - offset0);\n"\ + " blur_sum += output * 0.25;\n"\ + " output = " << info.func << " (texture0, vTexCoord0 + offset1);\n"\ + " blur_sum += output * 0.25;\n"\ + " output = " << info.func << " (texture0, vTexCoord0 - offset1);\n"\ + " output = output * 0.25 + blur_sum;\n"\ + " gl_FragColor = output;\n"; - srcBlurFunctions.push_back (function); + data << "}\n"; - return function.id; - } + function.shader = data.str (); + function.target = info.target; + + srcBlurFunctions.push_back (function); - return 0; + return srcBlurFunctions.back ().shader; } -GLFragment::FunctionId +/* This seems incomplete to me */ + +const CompString & BlurScreen::getDstBlurFragmentFunction (GLTexture *texture, - int param, - int unit, + int unit, int numITC, int startTC) { - BlurFunction function; - GLFragment::FunctionData data; - int target; - char *targetString; + BlurFunction function; + std::stringstream data (std::stringstream::out); + int saturation = optionGetSaturation (); - if (texture->target () == GL_TEXTURE_2D) - { - target = COMP_FETCH_TARGET_2D; - targetString = (char *) "2D"; - } - else - { - target = COMP_FETCH_TARGET_RECT; - targetString = (char *) "RECT"; - } + SamplerInfo info (getSamplerInfoForSize (CompSize (texture->width (), + texture->height ()))); foreach (BlurFunction &function, dstBlurFunctions) - if (function.param == param && - function.target == target && - function.unit == unit && + if (function.target == info.target && function.numITC == numITC && - function.startTC == startTC) - return function.id; + function.startTC == startTC && + function.saturation == saturation) + return function.shader; + + data << "uniform vec4 blur_translation;\n"\ + "uniform vec4 blur_threshold;\n"; + + int i, j; + /* These are always initialized if running a gaussian shader */ + int numIndirect = 0; + int numIndirectOp = 0; + int base, end, ITCbase; - if (data.status ()) + /* Set per-shader uniforms */ + switch (optionGetFilter ()) { - static const char *temp[] = { "fCoord", "mask", "sum", "dst" }; - int i, j; - char str[1024]; - int saturation = optionGetSaturation (); - int numIndirect; - int numIndirectOp; - int base, end, ITCbase; - - for (i = 0; (unsigned int) i < sizeof (temp) / sizeof (temp[0]); i++) - data.addTempHeaderOp (temp[i]); - - if (saturation < 100) - data.addTempHeaderOp ("sat"); - - switch (optionGetFilter ()) { - case BlurOptions::Filter4xbilinear: { - static const char *filterTemp[] = { - "t0", "t1", "t2", "t3", - "s0", "s1", "s2", "s3" - }; - - for (i = 0; - (unsigned int) i < sizeof (filterTemp) / sizeof (filterTemp[0]); - i++) - data.addTempHeaderOp (filterTemp[i]); - - data.addFetchOp ("output", NULL, target); - data.addColorOp ("output", "output"); - - data.addDataOp ( - "MUL fCoord, fragment.position, program.env[%d];", - param); - - - data.addDataOp ( - "ADD t0, fCoord, program.env[%d];" - "TEX s0, t0, texture[%d], %s;" - - "SUB t1, fCoord, program.env[%d];" - "TEX s1, t1, texture[%d], %s;" - - "MAD t2, program.env[%d], { -1.0, 1.0, 0.0, 0.0 }, fCoord;" - "TEX s2, t2, texture[%d], %s;" - - "MAD t3, program.env[%d], { 1.0, -1.0, 0.0, 0.0 }, fCoord;" - "TEX s3, t3, texture[%d], %s;" - - "MUL_SAT mask, output.a, program.env[%d];" - - "MUL sum, s0, 0.25;" - "MAD sum, s1, 0.25, sum;" - "MAD sum, s2, 0.25, sum;" - "MAD sum, s3, 0.25, sum;", - - param + 2, unit, targetString, - param + 2, unit, targetString, - param + 2, unit, targetString, - param + 2, unit, targetString, - param + 1); - - } break; - case BlurOptions::FilterGaussian: { - - /* try to use only half of the available temporaries to keep - other plugins working */ - if ((maxTemp / 2) - 4 > - (numTexop + (numTexop - numITC)) * 2) - { - numIndirect = 1; - numIndirectOp = numTexop; - } - else - { - i = MAX (((maxTemp / 2) - 4) / 4, 1); - numIndirect = ceil ((float)numTexop / (float)i); - numIndirectOp = ceil ((float)numTexop / (float)numIndirect); - } - - /* we need to define all coordinate temporaries if we have - multiple indirection steps */ - j = (numIndirect > 1) ? 0 : numITC; - - for (i = 0; i < numIndirectOp * 2; i++) - { - snprintf (str, 1024, "pix_%d", i); - data.addTempHeaderOp (str); - } - - for (i = j * 2; i < numIndirectOp * 2; i++) - { - snprintf (str, 1024, "coord_%d", i); - data.addTempHeaderOp (str); - } - - data.addFetchOp ("output", NULL, target); - data.addColorOp ("output", "output"); + case BlurOptions::Filter4xbilinear: + data << "uniform vec4 blur_dxdy;\n"; + break; + default: + break; + } - data.addDataOp ( - "MUL fCoord, fragment.position, program.env[%d];", - param); + data << "\n"\ + "void blur_fragment ()\n"\ + "{\n"\ + " vec4 blur_sum, blur_dst, blur_output;\n"\ + " vec2 blur_fCoord;\n"\ + " vec4 blur_mask;\n"; + if (saturation < 100) + data << " float blur_sat;\n"; - data.addDataOp ("TEX sum, fCoord, texture[%d], %s;", - unit + 1, targetString); + /* Define per-filter temporaries */ + switch (optionGetFilter ()) + { + case BlurOptions::Filter4xbilinear: + { + static const char *filterTemp[] = { + "blur_t0", "blur_t1", "blur_t2", "blur_t3", + }; + + static const char *filterSampleTemp[] = { + "blur_s0", "blur_s1", "blur_s2", "blur_s3" + }; + + for (i = 0; + (unsigned int) i < sizeof (filterTemp) / sizeof (filterTemp[0]); + ++i) + data << " vec2 " << filterTemp[i] << ";\n"; + + for (i = 0; + (unsigned int) i < sizeof (filterSampleTemp) / sizeof (filterSampleTemp[0]); + ++i) + data << " vec4 " << filterSampleTemp[i] << ";\n"; + } + break; + case BlurOptions::FilterGaussian: + { + /* try to use only half of the available temporaries to keep + other plugins working */ + if ((maxTemp / 2) - 4 > + (numTexop + (numTexop - numITC)) * 2) + { + numIndirect = 1; + numIndirectOp = numTexop; + } + else + { + i = MAX (((maxTemp / 2) - 4) / 4, 1); + numIndirect = ceil ((float)numTexop / (float)i); + numIndirectOp = ceil ((float)numTexop / (float)numIndirect); + } + /* we need to define all coordinate temporaries if we have + multiple indirection steps */ + j = (numIndirect > 1) ? 0 : numITC; - data.addDataOp ("MUL_SAT mask, output.a, program.env[%d];" - "MUL sum, sum, %f;", - param + 1, amp[numTexop]); + for (i = 0; i < numIndirectOp * 2; i++) + data << " vec4 blur_pix_" << i << ";\n"; - for (j = 0; j < numIndirect; j++) - { - base = j * numIndirectOp; - end = MIN ((j + 1) * numIndirectOp, numTexop) - base; + for (i = j * 2; i < numIndirectOp * 2; i++) + data << " vec2 blur_coord_" << i << ";\n"; + } + break; + case BlurOptions::FilterMipmap: + { + data << " float lod_bias;\n"; + } + default: + break; + } - ITCbase = MAX (numITC - base, 0); + /* + * blur_output: copy the original gl_FragColor determined by sampling + * the window texture in the core shader + * blur_fCoord: take the fragment co-ordinate in window co-ordinates + * and normalize it (eg, blur_translation). Once normalized we can + * sample texUnitN + 1 (for the copy of the backbuffer we wish to blur) + * and texUnitN + 2 (scratch fbo for gaussian blurs) + * blur_mask: take blur_output pixel alpha value, multiply by threshold value + * and clamp between 0 - 1. We will use this later to mix the blur fragments + * with the window fragments. + */ + data << "\n"\ + " blur_output = gl_FragColor;\n"\ + " blur_fCoord = gl_FragCoord.st * blur_translation.st;\n"\ + " blur_mask = clamp (blur_output.a * blur_threshold, vec4 (0.0, 0.0, 0.0, 0.), vec4 (1.0, 1.0, 1.0, 1.0));\n"\ + "\n"; - for (i = ITCbase; i < end; i++) - { - data.addDataOp ( - "ADD coord_%d, fCoord, {0.0, %g, 0.0, 0.0};" - "SUB coord_%d, fCoord, {0.0, %g, 0.0, 0.0};", - i * 2, pos[base + i] * ty, - (i * 2) + 1, pos[base + i] * ty); - } + /* Define filter program */ + switch (optionGetFilter ()) + { + case BlurOptions::Filter4xbilinear: + { + data << " blur_t0 = blur_fCoord + blur_dxdy.st;\n"\ + " blur_s0 = " << info.func << " (texture1, blur_t0);\n"\ + " blur_t1 = blur_fCoord - blur_dxdy.st;\n"\ + " blur_s1 = " << info.func << " (texture1, blur_t1);\n"\ + " blur_t2 = blur_fCoord + vec2 (-1.0, 1.0) * blur_dxdy.st;\n"\ + " blur_s2 = " << info.func << " (texture1, blur_t2);\n"\ + " blur_t3 = blur_fCoord + vec2 (1.0, -1.0) * blur_dxdy.st;\n"\ + " blur_s3 = " << info.func << " (texture1, blur_t3);\n"\ + " blur_sum = blur_s0 * 0.25;\n"\ + " blur_sum += blur_s1 * 0.25;\n"\ + " blur_sum += blur_s2 * 0.25;\n"\ + " blur_sum += blur_s3 * 0.25;\n"; + } break; + case BlurOptions::FilterGaussian: + { + /* Invert y */ + data << " blur_fCoord.y = 1.0 - blur_fCoord.y;\n"\ + " blur_sum = " << info.func << " (texture2, blur_fCoord);\n"\ + " blur_sum *= " << amp[numTexop] << ";\n"; - for (i = 0; i < ITCbase; i++) - { - data.addDataOp ( - "TXP pix_%d, fragment.texcoord[%d], texture[%d], %s;" - "TXP pix_%d, fragment.texcoord[%d], texture[%d], %s;", - i * 2, startTC + ((i + base) * 2), - unit + 1, targetString, - (i * 2) + 1, startTC + 1 + ((i + base) * 2), - unit + 1, targetString); - } + for (j = 0; j < numIndirect; j++) + { + base = j * numIndirectOp; + end = MIN ((j + 1) * numIndirectOp, numTexop) - base; - for (i = ITCbase; i < end; i++) - { - data.addDataOp ( - "TEX pix_%d, coord_%d, texture[%d], %s;" - "TEX pix_%d, coord_%d, texture[%d], %s;", - i * 2, i * 2, - unit + 1, targetString, - (i * 2) + 1, (i * 2) + 1, - unit + 1, targetString); - } + ITCbase = MAX (numITC - base, 0); - for (i = 0; i < end * 2; i++) - { - data.addDataOp ( - "MAD sum, pix_%d, %f, sum;", - i, amp[base + (i / 2)]); - } + for (i = ITCbase; i < end; i++) + { + data << " blur_coord_" << i * 2 << " = blur_fCoord + vec2 (0.0, " << pos[base + i] * ty << ");\n"\ + " blur_coord_" << (i * 2) + 1 << " = blur_fCoord - vec2 (0.0, " << pos[base + i] * ty << ");\n"; + } +#if INDEPENDENT_TEX_SUPPORTED + for (i = 0; i < ITCbase; i++) + { + data << " blur_pix_" + i * 2 + " vTexCoord" + data.addDataOp ( + "TXP pix_%d, fragment.texcoord[%d], texture[%d], %s;" + "TXP pix_%d, fragment.texcoord[%d], texture[%d], %s;", + i * 2, startTC + ((i + base) * 2), + unit + 1, targetString, + (i * 2) + 1, startTC + 1 + ((i + base) * 2), + unit + 1, targetString); + } +#endif + for (i = ITCbase; i < end; i++) + { + data << " blur_pix_" << i * 2 << " = " << info.func << " (texture2, blur_coord_" << i * 2 << ");\n"\ + " blur_pix_" << (i * 2) + 1 << " = " << info.func << " (texture2, blur_coord_" << (i * 2) + 1 << ");\n"; } - } break; - case BlurOptions::FilterMipmap: - data.addFetchOp ("output", NULL, target); - data.addColorOp ("output", "output"); - - data.addDataOp ( - "MUL fCoord, fragment.position, program.env[%d].xyzz;" - "MOV fCoord.w, program.env[%d].w;" - "TXB sum, fCoord, texture[%d], %s;" - "MUL_SAT mask, output.a, program.env[%d];", - param, param, unit, targetString, - param + 1); - - break; - } + for (i = 0; i < end * 2; i++) + data << " blur_sum += blur_pix_" << i << " * " << amp[base + (i / 2)] << ";\n"; + } - if (saturation < 100) - { - data.addDataOp ( - "MUL sat, sum, { 1.0, 1.0, 1.0, 0.0 };" - "DP3 sat, sat, { %f, %f, %f, %f };" - "LRP sum.xyz, %f, sum, sat;", - RED_SATURATION_WEIGHT, GREEN_SATURATION_WEIGHT, - BLUE_SATURATION_WEIGHT, 0.0f, saturation / 100.0f); - } + } break; + case BlurOptions::FilterMipmap: + data << " lod_bias = blur_translation.w;\n"\ + " blur_sum = " << info.func << " (texture1, blur_fCoord, lod_bias);\n"; - data.addDataOp ( - "MAD dst, mask, -output.a, mask;" - "MAD output.rgb, sum, dst.a, output;" - "ADD output.a, output.a, dst.a;"); + break; + } - if (!data.status ()) - { - return 0; - } + if (saturation < 100) + { + data << " blur_sat = blur_sum * vec4 (1.0, 1.0, 1.0, 0.0);\n"\ + " blur_sat = dot (blur_sat, vec4 (" << + RED_SATURATION_WEIGHT << ", " << GREEN_SATURATION_WEIGHT << ", " << + BLUE_SATURATION_WEIGHT << ", 0.0f);\n"\ + " blur_sum.xyz = mix (" << saturation / 100.f << ", blur_sat);\n"; + } + data << " blur_dst = (blur_mask * -blur_output.a) + blur_mask;\n"\ + " blur_output.rgb = blur_sum.rgb * blur_dst.a + blur_output.rgb;\n"\ + " blur_output.a += blur_dst.a;\n"\ + " gl_FragColor = blur_output;\n"\ + "}"; + function.shader = data.str (); + function.target = texture->target (); + function.numITC = numITC; + function.startTC = startTC; + function.saturation = saturation; - function.id = data.createFragmentFunction ("blur"); - function.target = target; - function.param = param; - function.unit = unit; - function.numITC = numITC; - function.startTC = startTC; + dstBlurFunctions.push_back (function); - dstBlurFunctions.push_back (function); + return dstBlurFunctions.back ().shader; +} - return function.id; +namespace +{ +bool +project (float objx, float objy, float objz, + const float modelview[16], const float projection[16], + const GLint viewport[4], + float *winx, float *winy, float *winz) +{ + unsigned int i; + float in[4]; + float out[4]; + + in[0] = objx; + in[1] = objy; + in[2] = objz; + in[3] = 1.0; + + for (i = 0; i < 4; i++) { + out[i] = + in[0] * modelview[i] + + in[1] * modelview[4 + i] + + in[2] * modelview[8 + i] + + in[3] * modelview[12 + i]; + } + + for (i = 0; i < 4; i++) { + in[i] = + out[0] * projection[i] + + out[1] * projection[4 + i] + + out[2] * projection[8 + i] + + out[3] * projection[12 + i]; } - return 0; + if (in[3] == 0.0) + return false; + + in[0] /= in[3]; + in[1] /= in[3]; + in[2] /= in[3]; + /* Map x, y and z to range 0-1 */ + in[0] = in[0] * 0.5 + 0.5; + in[1] = in[1] * 0.5 + 0.5; + in[2] = in[2] * 0.5 + 0.5; + + /* Map x,y to viewport */ + in[0] = in[0] * viewport[2] + viewport[0]; + in[1] = in[1] * viewport[3] + viewport[1]; + + *winx = in[0]; + *winy = in[1]; + *winz = in[2]; + return true; +} } bool @@ -874,11 +958,11 @@ float *scr, int n) { - GLdouble dProjection[16]; - GLdouble dModel[16]; - GLint viewport[4]; - double x, y, z; - int i; + GLfloat dProjection[16]; + GLfloat dModel[16]; + GLint viewport[4]; + float x, y, z; + int i; viewport[0] = output->x1 (); viewport[1] = screen->height () - output->y2 (); @@ -888,14 +972,14 @@ for (i = 0; i < 16; i++) { dModel[i] = transform.getMatrix ()[i]; - dProjection[i] = gScreen->projectionMatrix ()[i]; + dProjection[i] = gScreen->projectionMatrix ()->getMatrix ()[i]; } while (n--) { - if (!gluProject (object[0], object[1], object[2], - dModel, dProjection, viewport, - &x, &y, &z)) + if (!project (object[0], object[1], object[2], + dModel, dProjection, viewport, + &x, &y, &z)) return false; scr[0] = x; @@ -909,57 +993,56 @@ } bool -BlurScreen::loadFragmentProgram (GLuint *program, - const char *string) +BlurScreen::loadFragmentProgram (boost::shared_ptr &program, + const char *vertex, + const char *fragment) { - GLint errorPos; - - /* clear errors */ - glGetError (); - - if (!*program) - (*GL::genPrograms) (1, program); - - (*GL::bindProgram) (GL_FRAGMENT_PROGRAM_ARB, *program); - (*GL::programString) (GL_FRAGMENT_PROGRAM_ARB, - GL_PROGRAM_FORMAT_ASCII_ARB, - strlen (string), string); + if (!program) + program.reset (new GLProgram (CompString (vertex), + CompString (fragment))); - glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); - if (glGetError () != GL_NO_ERROR || errorPos != -1) + if (program && program->valid ()) + return true; + else { + program.reset (); compLogMessage ("blur", CompLogLevelError, - "Failed to load blur program %s", string); - - (*GL::deletePrograms) (1, program); - *program = 0; - + "Failed to load blur program %s", fragment); return false; } - - return true; } bool BlurScreen::loadFilterProgram (int numITC) { - char buffer[4096]; - char *targetString; - char *str = buffer; + std::stringstream svtx; + + /* A simple pass-thru vertex shader */ + svtx << "#ifdef GL_ES\n"\ + "precision mediump float;\n"\ + "#endif\n"\ + "uniform mat4 modelview;\n"\ + "uniform mat4 projection;\n"\ + "attribute vec4 position;\n"\ + "attribute vec2 texCoord0;\n"\ + "varying vec2 vTexCoord0;\n"\ + "\n"\ + "void main ()\n"\ + "{\n"\ + " vTexCoord0 = texCoord0;\n"\ + " gl_Position = projection * modelview * position;\n"\ + "}"; + + std::stringstream str; int i, j; int numIndirect; int numIndirectOp; int base, end, ITCbase; - if (target == GL_TEXTURE_2D) - targetString = (char *) "2D"; - else - targetString = (char *) "RECT"; + SamplerInfo info (getSamplerInfoForSize (*screen)); - str += sprintf (str, - "!!ARBfp1.0" - "ATTRIB texcoord = fragment.texcoord[0];" - "TEMP sum;"); + str << "varying vec2 vTexCoord0;\n"\ + "uniform sampler2D texture0;\n"; if (maxTemp - 1 > (numTexop + (numTexop - numITC)) * 2) { @@ -977,19 +1060,19 @@ multiple indirection steps */ j = (numIndirect > 1) ? 0 : numITC; + str << "\n"\ + "void main ()\n"\ + "{\n"; + for (i = 0; i < numIndirectOp; i++) - str += sprintf (str,"TEMP pix_%d, pix_%d;", i * 2, (i * 2) + 1); + str << " vec4 blur_pix_" << i * 2 << ", blur_pix_" << (i * 2) + 1 << ";\n"; for (i = j; i < numIndirectOp; i++) - str += sprintf (str,"TEMP coord_%d, coord_%d;", i * 2, (i * 2) + 1); + str << " vec2 blur_coord_" << i * 2 << ", blur_coord_" << (i * 2) + 1 << ";\n"; - str += sprintf (str, - "TEX sum, texcoord, texture[0], %s;", - targetString); - - str += sprintf (str, - "MUL sum, sum, %f;", - amp[numTexop]); + str << " vec4 blur_sum;\n"; + str << " blur_sum = " << info.func << " (texture0, vTexCoord0);\n"\ + " blur_sum = blur_sum * " << amp[numTexop] << ";\n"; for (j = 0; j < numIndirect; j++) { @@ -999,37 +1082,30 @@ ITCbase = MAX (numITC - base, 0); for (i = ITCbase; i < end; i++) - str += sprintf (str, - "ADD coord_%d, texcoord, {%g, 0.0, 0.0, 0.0};" - "SUB coord_%d, texcoord, {%g, 0.0, 0.0, 0.0};", - i * 2, pos[base + i] * tx, - (i * 2) + 1, pos[base + i] * tx); - + str << " blur_coord_" << i * 2 << " = vTexCoord0 + vec2 (" << pos[base + i] * tx << ", 0.0);\n"\ + " blur_coord_" << (i * 2) + 1 << " = vTexCoord0 - vec2 (" << pos[base + i] * tx << ", 0.0);\n"; +#if INDEPENDENT_TEX_SUPPORTED for (i = 0; i < ITCbase; i++) - str += sprintf (str, + str << sprintf (str, "TEX pix_%d, fragment.texcoord[%d], texture[0], %s;" "TEX pix_%d, fragment.texcoord[%d], texture[0], %s;", i * 2, ((i + base) * 2) + 1, targetString, (i * 2) + 1, ((i + base) * 2) + 2, targetString); - +#endif for (i = ITCbase; i < end; i++) - str += sprintf (str, - "TEX pix_%d, coord_%d, texture[0], %s;" - "TEX pix_%d, coord_%d, texture[0], %s;", - i * 2, i * 2, targetString, - (i * 2) + 1, (i * 2) + 1, targetString); + str << " blur_pix_" << (i * 2) << " = " << info.func << " (texture0, blur_coord_" << i * 2 << ");\n"\ + " blur_pix_" << (i * 2) + 1 << " = " << info.func << " (texture0, blur_coord_" << (i * 2) + 1 << ");\n"; for (i = 0; i < end * 2; i++) - str += sprintf (str, - "MAD sum, pix_%d, %f, sum;", - i, amp[base + (i / 2)]); + str << " blur_sum += blur_pix_" << i << " * " << amp[base + (i / 2)] << ";\n"; } - str += sprintf (str, - "MOV result.color, sum;" - "END"); + str << " gl_FragColor = blur_sum;\n"\ + "}"; - return loadFragmentProgram (&program, buffer); + return loadFragmentProgram (program, + svtx.str ().c_str (), + str.str ().c_str ()); } bool @@ -1038,51 +1114,7 @@ if (!fbo) return false; - (*GL::bindFramebuffer) (GL_FRAMEBUFFER_EXT, fbo); - - /* bind texture and check status the first time */ - if (!fboStatus) - { - (*GL::framebufferTexture2D) (GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT, - target, texture[1], - 0); - - int currStatus = (*GL::checkFramebufferStatus) (GL_FRAMEBUFFER_EXT); - if (currStatus != GL_FRAMEBUFFER_COMPLETE_EXT) - { - compLogMessage ("blur", CompLogLevelError, - "Framebuffer incomplete"); - - (*GL::bindFramebuffer) (GL_FRAMEBUFFER_EXT, 0); - (*GL::deleteFramebuffers) (1, &fbo); - - fbo = 0; - - return false; - } - else - fboStatus = true; - } - - glPushAttrib (GL_VIEWPORT_BIT | GL_ENABLE_BIT); - - glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT); - glReadBuffer (GL_COLOR_ATTACHMENT0_EXT); - - glDisable (GL_CLIP_PLANE0); - glDisable (GL_CLIP_PLANE1); - glDisable (GL_CLIP_PLANE2); - glDisable (GL_CLIP_PLANE3); - - glViewport (0, 0, width, height); - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); - glOrtho (0.0, width, 0.0, height, -1.0, 1.0); - glMatrixMode (GL_MODELVIEW); - glPushMatrix (); - glLoadIdentity (); + oldDrawFramebuffer = fbo->bind (); return true; } @@ -1090,37 +1122,22 @@ void BlurScreen::fboEpilogue () { - (*GL::bindFramebuffer) (GL_FRAMEBUFFER_EXT, 0); + oldDrawFramebuffer->bind (); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glDepthRange (0, 1); - glViewport (-1, -1, 2, 2); - glRasterPos2f (0, 0); - - gScreen->resetRasterPos (); - - glMatrixMode (GL_PROJECTION); - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - glPopMatrix (); + fbo->tex ()->enable (GLTexture::Good); + //GL::generateMipmap (fbo->tex ()->target ()); - glDrawBuffer (GL_BACK); - glReadBuffer (GL_BACK); - - glPopAttrib (); + fbo->tex ()->disable (); } bool BlurScreen::fboUpdate (BoxPtr pBox, int nBox) { - int i, y, iTC = 0; + float iTC = 0; bool wasCulled = glIsEnabled (GL_CULL_FACE); - if (GL::maxTextureUnits && optionGetIndependentTex ()) + if (GL::maxTextureUnits && optionGetIndependentTex () && false) iTC = MIN ((GL::maxTextureUnits - 1) / 2, numTexop); if (!program) @@ -1131,83 +1148,51 @@ return false; glDisable (GL_CULL_FACE); + GL::activeTexture (GL_TEXTURE0); + texture[0]->enable (GLTexture::Good); - glDisableClientState (GL_TEXTURE_COORD_ARRAY); - - glBindTexture (target, texture[0]); - - glEnable (GL_FRAGMENT_PROGRAM_ARB); - (*GL::bindProgram) (GL_FRAGMENT_PROGRAM_ARB, program); - - glBegin (GL_QUADS); + GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); while (nBox--) { - y = screen->height () - pBox->y2; - - for (i = 0; i < iTC; i++) - { - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2), - tx * (pBox->x1 + pos[i]), - ty * y); - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2) + 1, - tx * (pBox->x1 - pos[i]), - ty * y); - } + float x1 = pBox->x1; + float x2 = pBox->x2; + float y1 = screen->height () - pBox->y2; + float y2 = screen->height () - pBox->y1; + + GLfloat texCoords[] = + { + tx * x1, ty * y1, + tx * x1, ty * y2, + tx * x2, ty * y1, + tx * x2, ty * y2 + }; + + GLfloat vertices[] = + { + x1, y1, 0, + x1, y2, 0, + x2, y1, 0, + x2, y2, 0 + }; + + GLMatrix mv; + mv.toScreenSpace (output, -DEFAULT_Z_CAMERA); + + streamingBuffer->begin (GL_TRIANGLE_STRIP); + streamingBuffer->setProgram (program.get ()); + streamingBuffer->addTexCoords (0, 4, texCoords); + streamingBuffer->addVertices (4, vertices); - glTexCoord2f (tx * pBox->x1, ty * y); - glVertex2i (pBox->x1, y); - - for (i = 0; i < iTC; i++) - { - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2), - tx * (pBox->x2 + pos[i]), - ty * y); - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2) + 1, - tx * (pBox->x2 - pos[i]), - ty * y); - } + if (streamingBuffer->end ()) + streamingBuffer->render (mv); - glTexCoord2f (tx * pBox->x2, ty * y); - glVertex2i (pBox->x2, y); - - y = screen->height () - pBox->y1; - - for (i = 0; i < iTC; i++) - { - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2), - tx * (pBox->x2 + pos[i]), - ty * y); - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2) + 1, - tx * (pBox->x2 - pos[i]), - ty * y); - } - - glTexCoord2f (tx * pBox->x2, ty * y); - glVertex2i (pBox->x2, y); - - for (i = 0; i < iTC; i++) - { - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2), - tx * (pBox->x1 + pos[i]), - ty * y); - (*GL::multiTexCoord2f) (GL_TEXTURE1_ARB + (i * 2) + 1, - tx * (pBox->x1 - pos[i]), - ty * y); - } - - glTexCoord2f (tx * pBox->x1, ty * y); - glVertex2i (pBox->x1, y); + /* Unset program */ + streamingBuffer->setProgram (NULL); pBox++; } - glEnd (); - - glDisable (GL_FRAGMENT_PROGRAM_ARB); - - glEnableClientState (GL_TEXTURE_COORD_ARRAY); - if (wasCulled) glEnable (GL_CULL_FACE); @@ -1231,92 +1216,70 @@ float *scr; GLTexture::MatrixList ml; - GLWindow::Geometry *gm; - gWindow->geometry ().reset (); + gWindow->vertexBuffer ()->begin (); gWindow->glAddGeometry (ml, bScreen->tmpRegion2, infiniteRegion); - if (!gWindow->geometry ().vCount) + if (!gWindow->vertexBuffer ()->end ()) return; - gm = &gWindow->geometry (); + GLVertexBuffer *vb = gWindow->vertexBuffer (); - nVertices = (gm->indexCount) ? gm->indexCount: gm->vCount; + nVertices = vb->countVertices (); nQuadCombine = 1; - stride = gm->vertexStride; - vert = gm->vertices + (stride - 3); + stride = vb->getVertexStride (); + vert = vb->getVertices () + (stride - 3); - /* we need to find the best value here */ - if (nVertices <= MAX_VERTEX_PROJECT_COUNT) - { - for (i = 0; i < nVertices; i++) - { - if (gm->indexCount) - { - v = vert + (stride * gm->indices[i]); - } - else - { - v = vert + (stride * i); - } + /* construct quads from bounding vertices */ + minX = screen->width (); + maxX = 0; + minY = screen->height (); + maxY = 0; + minZ = 1000000; + maxZ = -1000000; - vertices[i * 3] = v[0]; - vertices[(i * 3) + 1] = v[1]; - vertices[(i * 3) + 2] = v[2]; - } - } - else + for (i = 0; i < vb->countVertices (); i++) { - minX = screen->width (); - maxX = 0; - minY = screen->height (); - maxY = 0; - minZ = 1000000; - maxZ = -1000000; - - for (i = 0; i < gm->vCount; i++) - { - v = vert + (stride * i); + v = vert + (stride * i); - if (v[0] < minX) - minX = v[0]; + if (v[0] < minX) + minX = v[0]; - if (v[0] > maxX) - maxX = v[0]; + if (v[0] > maxX) + maxX = v[0]; - if (v[1] < minY) - minY = v[1]; + if (v[1] < minY) + minY = v[1]; - if (v[1] > maxY) - maxY = v[1]; + if (v[1] > maxY) + maxY = v[1]; - if (v[2] < minZ) - minZ = v[2]; + if (v[2] < minZ) + minZ = v[2]; - if (v[2] > maxZ) - maxZ = v[2]; - } + if (v[2] > maxZ) + maxZ = v[2]; + } - vertices[0] = vertices[9] = minX; - vertices[1] = vertices[4] = minY; - vertices[3] = vertices[6] = maxX; - vertices[7] = vertices[10] = maxY; - vertices[2] = vertices[5] = maxZ; - vertices[8] = vertices[11] = maxZ; + vertices[0] = vertices[9] = minX; + vertices[1] = vertices[4] = minY; + vertices[3] = vertices[6] = maxX; + vertices[7] = vertices[10] = maxY; + vertices[2] = vertices[5] = maxZ; + vertices[8] = vertices[11] = maxZ; - nVertices = 4; + nVertices = 4; - if (maxZ != minZ) - { - vertices[12] = vertices[21] = minX; - vertices[13] = vertices[16] = minY; - vertices[15] = vertices[18] = maxX; - vertices[19] = vertices[22] = maxY; - vertices[14] = vertices[17] = minZ; - vertices[20] = vertices[23] = minZ; - nQuadCombine = 2; - } + if (maxZ != minZ) + { + vertices[12] = vertices[21] = minX; + vertices[13] = vertices[16] = minY; + vertices[15] = vertices[18] = maxX; + vertices[19] = vertices[22] = maxY; + vertices[14] = vertices[17] = minZ; + vertices[20] = vertices[23] = minZ; + nQuadCombine = 2; } if (!bScreen->projectVertices (output, transform, vertices, scrv, @@ -1349,10 +1312,10 @@ int x1, y1, x2, y2; - x1 = minX - bScreen->filterRadius; - y1 = screen->height () - maxY - bScreen->filterRadius; - x2 = maxX + bScreen->filterRadius + 0.5f; - y2 = screen->height () - minY + bScreen->filterRadius + 0.5f; + x1 = minX - bScreen->filterRadius - 0.5; + y1 = screen->height () - maxY - bScreen->filterRadius - 0.5; + x2 = maxX + bScreen->filterRadius + 0.5; + y2 = screen->height () - minY + bScreen->filterRadius + 0.5; bScreen->tmpRegion3 += CompRect (x1, y1, x2 - x1, y2 - y1); @@ -1360,21 +1323,15 @@ } } -bool -BlurWindow::updateDstTexture (const GLMatrix &transform, - CompRect *pExtents, - int clientThreshold) +void +BlurWindow::determineBlurRegion (int filter, + const GLMatrix &transform, + int clientThreshold) { - int y; - int filter; - - filter = bScreen->optionGetFilter (); - bScreen->tmpRegion3 = CompRegion (); if (filter == BlurOptions::FilterGaussian) { - if (state[BLUR_STATE_DECOR].threshold) { int xx, yy, ww, hh; @@ -1394,7 +1351,7 @@ // bottom xx = window->x () - window->output ().left; yy = window->y () + window->height (); - ww = window->width () + window->output ().left + + ww = window->width () + window->output ().left + window->output ().right; hh = window->output ().bottom; @@ -1410,7 +1367,7 @@ ww = window->output ().left; hh = window->height (); - bScreen->tmpRegion2 = bScreen->tmpRegion.intersected ( + bScreen->tmpRegion2 = bScreen->tmpRegion.intersected ( CompRect (xx, yy, ww, hh)); if (!bScreen->tmpRegion2.isEmpty ()) @@ -1422,7 +1379,7 @@ ww = window->output ().right; hh = window->height (); - bScreen->tmpRegion2 = bScreen->tmpRegion.intersected ( + bScreen->tmpRegion2 = bScreen->tmpRegion.intersected ( CompRect (xx, yy, ww, hh)); if (!bScreen->tmpRegion2.isEmpty ()) @@ -1451,141 +1408,147 @@ projectRegion (bScreen->output, transform); } - bScreen->tmpRegion = bScreen->region.intersected (bScreen->tmpRegion3); + projectedBlurRegion = bScreen->tmpRegion3; +} + +bool +BlurWindow::updateDstTexture (const GLMatrix &transform, + CompRect *pExtents, + unsigned int mask) +{ + bool ret = false; + int filter = bScreen->optionGetFilter (); + + /* Paint region n projected region */ + bScreen->tmpRegion = bScreen->region.intersected (projectedBlurRegion); + + if (!bScreen->blurOcclusion && + !(mask & PAINT_WINDOW_TRANSFORMED_MASK)) + bScreen->tmpRegion -= clip; if (bScreen->tmpRegion.isEmpty ()) return false; - *pExtents = bScreen->tmpRegion.boundingRect (); + CompRect br (bScreen->tmpRegion.boundingRect ()); - if (!bScreen->texture[0] || bScreen->width != screen->width () || - bScreen->height != screen->height ()) - { - int i, textures = 1; - - bScreen->width = screen->width (); - bScreen->height = screen->height (); + if (bScreen->texture.empty () || + CompSize (bScreen->texture[0]->width (), + bScreen->texture[0]->height ()) != + static_cast (*screen)) + { + bScreen->texture = GLTexture::imageDataToTexture (NULL, + *screen, + GL_RGB, +#if IMAGE_BYTE_ORDER == MSBFirst + GL_UNSIGNED_INT_8_8_8_8_REV); +#else + GL_UNSIGNED_BYTE); +#endif - if (GL::textureNonPowerOfTwo || - (POWER_OF_TWO (bScreen->width) && POWER_OF_TWO (bScreen->height))) + if (bScreen->texture[0]->target () == GL_TEXTURE_2D) { - bScreen->target = GL_TEXTURE_2D; - bScreen->tx = 1.0f / bScreen->width; - bScreen->ty = 1.0f / bScreen->height; + bScreen->tx = 1.0f / bScreen->texture[0]->width (); + bScreen->ty = 1.0f / bScreen->texture[0]->height (); } else { - bScreen->target = GL_TEXTURE_RECTANGLE_NV; bScreen->tx = 1; bScreen->ty = 1; } if (filter == BlurOptions::FilterGaussian) { - if (GL::fbo && !bScreen->fbo) - (*GL::genFramebuffers) (1, &bScreen->fbo); + bScreen->fbo->allocate (*screen, + NULL, + GL_BGRA); + + /* We have to bind it in order to get a status */ + GLFramebufferObject *old = bScreen->fbo->bind(); + bool status = bScreen->fbo->checkStatus (); + old->bind(); - if (!bScreen->fbo) + if (!status) compLogMessage ("blur", CompLogLevelError, "Failed to create framebuffer object"); - textures = 2; - } - - bScreen->fboStatus = false; + else + { + unsigned int filter = (bScreen->gScreen->driverHasBrokenFBOMipmaps () ? + GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR); + bScreen->gScreen->setTextureFilter (filter); - for (i = 0; i < textures; i++) - { - if (!bScreen->texture[i]) - glGenTextures (1, &bScreen->texture[i]); + bScreen->fbo->tex ()->enable (GLTexture::Good); - glBindTexture (bScreen->target, bScreen->texture[i]); + const CompRect &r (*bScreen->fbo->tex ()); - glTexImage2D (bScreen->target, 0, GL_RGB, - bScreen->width, - bScreen->height, - 0, GL_BGRA, + glCopyTexSubImage2D (bScreen->fbo->tex ()->target (), + 0, 0, 0, 0, 0, + r.width (), + r.height ()); -#if IMAGE_BYTE_ORDER == MSBFirst - GL_UNSIGNED_INT_8_8_8_8_REV, -#else - GL_UNSIGNED_BYTE, -#endif + if (!bScreen->gScreen->driverHasBrokenFBOMipmaps ()) + GL::generateMipmap (bScreen->fbo->tex ()->target ()); - NULL); + bScreen->fbo->tex ()->disable (); + } + } - glTexParameteri (bScreen->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri (bScreen->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + /* Set update region to entire screen */ + br.setGeometry (0, 0, + screen->width (), + screen->height ()); + } - if (filter == BlurOptions::FilterMipmap) - { - if (!GL::fbo) - { - compLogMessage ("blur", CompLogLevelWarn, - "GL_EXT_framebuffer_object extension " - "is required for mipmap filter"); - } - else if (bScreen->target != GL_TEXTURE_2D) - { - compLogMessage ("blur", CompLogLevelWarn, - "GL_ARB_texture_non_power_of_two " - "extension is required for mipmap filter"); - } - else - { - glTexParameteri (bScreen->target, GL_TEXTURE_MIN_FILTER, - GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri (bScreen->target, GL_TEXTURE_MAG_FILTER, - GL_LINEAR_MIPMAP_LINEAR); - } - } + *pExtents = br; - glTexParameteri (bScreen->target, GL_TEXTURE_WRAP_S, - GL_CLAMP_TO_EDGE); - glTexParameteri (bScreen->target, GL_TEXTURE_WRAP_T, - GL_CLAMP_TO_EDGE); + CompRegion *updateRegion = NULL; + updateRegion = &bScreen->tmpRegion; - glCopyTexSubImage2D (bScreen->target, 0, 0, 0, 0, 0, - bScreen->width, bScreen->height); - } - } - else + foreach (GLTexture *tex, bScreen->texture) { - glBindTexture (bScreen->target, bScreen->texture[0]); + /* We need to set the active texture filter to GL_LINEAR_MIPMAP_LINEAR */ + if (filter == BlurOptions::FilterMipmap && + !bScreen->gScreen->driverHasBrokenFBOMipmaps ()) + bScreen->gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR); - CompRect br = bScreen->tmpRegion.boundingRect (); + tex->enable (GLTexture::Good); - y = screen->height () - br.y2 (); + CompRect::vector rects (updateRegion->rects ()); - glCopyTexSubImage2D (bScreen->target, 0, - br.x1 (), y, - br.x1 (), y, - br.width (), - br.height ()); - } + foreach (const CompRect &r, rects) + { + int y = screen->height () - r.y2 (); - switch (filter) { - case BlurOptions::FilterGaussian: - return bScreen->fboUpdate (bScreen->tmpRegion.handle ()->rects, - bScreen->tmpRegion.numRects ()); - case BlurOptions::FilterMipmap: - if (GL::generateMipmap) - (*GL::generateMipmap) (bScreen->target); - break; - case BlurOptions::Filter4xbilinear: - break; - } + glCopyTexSubImage2D (bScreen->texture[0]->target (), 0, + r.x1 (), y, + r.x1 (), y, + r.width (), + r.height ()); + } - glBindTexture (bScreen->target, 0); + /* Force mipmap regeneration, because GLTexture assumes static + * textures and won't do it for us */ + if (filter == BlurOptions::FilterMipmap && + !bScreen->gScreen->driverHasBrokenFBOMipmaps ()) + GL::generateMipmap (tex->target ()); - return true; + if (filter == BlurOptions::FilterGaussian) + ret |= bScreen->fboUpdate (updateRegion->handle ()->rects, + updateRegion->numRects ()); + else + ret = true; + + tex->disable (); + } + + return ret; } bool -BlurWindow::glDraw (const GLMatrix &transform, - GLFragment::Attrib &attrib, - const CompRegion ®ion, - unsigned int mask) +BlurWindow::glDraw (const GLMatrix &transform, + const GLWindowPaintAttrib &attrib, + const CompRegion ®ion, + unsigned int mask) { bool status; @@ -1603,22 +1566,11 @@ { bool clipped = false; CompRect box (0, 0, 0, 0); - CompRegion reg; - bScreen->mvp = GLMatrix (bScreen->gScreen->projectionMatrix ()); + bScreen->mvp = *(bScreen->gScreen->projectionMatrix ()); bScreen->mvp *= transform; - if (mask & PAINT_WINDOW_TRANSFORMED_MASK) - reg = infiniteRegion; - else - reg = region; - - bScreen->tmpRegion = this->region.intersected (reg); - if (!bScreen->blurOcclusion && - !(mask & PAINT_WINDOW_TRANSFORMED_MASK)) - bScreen->tmpRegion -= clip; - - if (updateDstTexture (transform, &box, clientThreshold)) + if (updateDstTexture (transform, &box, mask)) { if (clientThreshold) { @@ -1672,11 +1624,17 @@ if (clipped) { GLTexture::MatrixList ml; + const CompRegion *reg = NULL; - gWindow->geometry ().reset (); + if (mask & PAINT_WINDOW_TRANSFORMED_MASK) + reg = &infiniteRegion; + else + reg = ®ion; - gWindow->glAddGeometry (ml, bScreen->tmpRegion, reg); - if (gWindow->geometry ().vCount) + gWindow->vertexBuffer ()->begin (); + gWindow->glAddGeometry (ml, bScreen->tmpRegion, *reg); + gWindow->vertexBuffer ()->color4f (1.0, 1.0, 1.0, 1.0); + if (gWindow->vertexBuffer ()->end ()) { CompRect clearBox = bScreen->stencilBox; @@ -1684,28 +1642,44 @@ glEnable (GL_STENCIL_TEST); glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + glStencilMask (1); if (clearBox.x2 () > clearBox.x1 () && clearBox.y2 () > clearBox.y1 ()) { - glPushAttrib (GL_SCISSOR_BIT); - glEnable (GL_SCISSOR_TEST); + /* We might have a previous scissor region, so we need + * to fetch it, however slow that might be .. */ + GLint scissorBox[4]; + GLboolean scissorEnabled; + + scissorEnabled = glIsEnabled (GL_SCISSOR_TEST); + glGetIntegerv (GL_SCISSOR_BOX, scissorBox); + + if (!scissorEnabled) + glEnable (GL_SCISSOR_TEST); + glScissor (clearBox.x1 (), screen->height () - clearBox.y2 (), clearBox.width (), clearBox.height ()); + glClearStencil (0); glClear (GL_STENCIL_BUFFER_BIT); - glPopAttrib (); + + if (!scissorEnabled) + glDisable (GL_SCISSOR_TEST); + + glScissor (scissorBox[0], scissorBox[1], + scissorBox[2], scissorBox[3]); } - glStencilFunc (GL_ALWAYS, 0x1, ~0); + glStencilFunc (GL_ALWAYS, 1, 1); glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); - glDisableClientState (GL_TEXTURE_COORD_ARRAY); - gWindow->glDrawGeometry (); - glEnableClientState (GL_TEXTURE_COORD_ARRAY); + /* Render a white polygon where the window is */ + gWindow->vertexBuffer ()->render (transform); glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glStencilMask (0); glDisable (GL_STENCIL_TEST); } } @@ -1720,10 +1694,248 @@ return status; } +namespace +{ +void setupShadersAndUniformsForDstBlur (GLTexture *texture, + GLWindow *gWindow, + BlurScreen *bScreen, + int &unit, + int &iTC, + float threshold) +{ + GLfloat dx, dy; + + switch (bScreen->optionGetFilter ()) + { + case BlurOptions::Filter4xbilinear: + { + dx = bScreen->tx / 2.1f; + dy = bScreen->ty / 2.1f; + + unit = 1; // FIXME!! + + const CompString &function ( + bScreen->getDstBlurFragmentFunction ( + texture, unit, 0, 0)); + + if (!function.empty ()) + { + (*GL::activeTexture) (GL_TEXTURE0 + unit); + bScreen->texture[0]->enable (GLTexture::Good); + gWindow->vertexBuffer ()->addTexCoords (unit, 0, NULL); + (*GL::activeTexture) (GL_TEXTURE0); + + gWindow->addShaders ("blur", + "", + function); + + gWindow->vertexBuffer ()->addUniform4f ("blur_translation", + bScreen->tx, bScreen->ty, + 0.0f, 0.0f); + + gWindow->vertexBuffer ()->addUniform4f ("blur_threshold", + threshold, + threshold, + threshold, + threshold); + + gWindow->vertexBuffer ()->addUniform4f ("blur_dxdy", + dx, dy, 0.0, 0.0); + } + } + break; + case BlurOptions::FilterGaussian: + { +#if INDEPENDENT_TEX_SUPPORTED + if (bScreen->optionGetIndependentTex ()) + { + /* leave one free texture unit for fragment position */ + iTC = MAX (0, GL::maxTextureUnits - + (gWindow->geometry ().texUnits + 1)); + if (iTC) + iTC = MIN (iTC / 2, bScreen->numTexop); + } +#endif + unit = 1; + + const CompString &function ( + bScreen->getDstBlurFragmentFunction ( + texture, unit, iTC, + gWindow->vertexBuffer ()->countTextures ())); + + if (!function.empty ()) + { + gWindow->addShaders ("blur", + "", + function); + + (*GL::activeTexture) (GL_TEXTURE0 + unit); + bScreen->texture[0]->enable (GLTexture::Good); + gWindow->vertexBuffer ()->addTexCoords (unit, 0, NULL); + (*GL::activeTexture) (GL_TEXTURE0 + unit + 1); + bScreen->fbo->tex ()->enable (GLTexture::Good); + gWindow->vertexBuffer ()->addTexCoords (unit + 1, 0, NULL); + (*GL::activeTexture) (GL_TEXTURE0); + + gWindow->vertexBuffer ()->addUniform4f ("blur_translation", + bScreen->tx, bScreen->ty, + 0.0f, 0.0f); + + gWindow->vertexBuffer ()->addUniform4f ("blur_threshold", + threshold, + threshold, + threshold, + threshold); +#if INDEPENDENT_TEX_SUPPORTED + if (iTC) + { + GLMatrix tm, rm; + float s_gen[4], t_gen[4], q_gen[4]; + + for (unsigned int i = 0; i < 16; i++) + tm[i] = 0; + tm[0] = (bScreen->output->width () / 2.0) * + bScreen->tx; + tm[5] = (bScreen->output->height () / 2.0) * + bScreen->ty; + tm[10] = 1; + + tm[12] = (bScreen->output->width () / 2.0 + + bScreen->output->x1 ()) * bScreen->tx; + tm[13] = (bScreen->output->height () / 2.0 + + screen->height () - + bScreen->output->y2 ()) * bScreen->ty; + tm[14] = 1; + tm[15] = 1; + + tm *= bScreen->mvp; + + for (int i = 0; i < iTC; i++) + { + (*GL::activeTexture) (GL_TEXTURE0 + + gWindow->geometry ().texUnits + (i * 2)); + + rm.reset (); + rm[13] = bScreen->ty * bScreen->pos[i]; + rm *= tm; + + s_gen[0] = rm[0]; + s_gen[1] = rm[4]; + s_gen[2] = rm[8]; + s_gen[3] = rm[12]; + t_gen[0] = rm[1]; + t_gen[1] = rm[5]; + t_gen[2] = rm[9]; + t_gen[3] = rm[13]; + q_gen[0] = rm[3]; + q_gen[1] = rm[7]; + q_gen[2] = rm[11]; + q_gen[3] = rm[15]; + + glTexGenfv (GL_T, GL_OBJECT_PLANE, t_gen); + glTexGenfv (GL_S, GL_OBJECT_PLANE, s_gen); + glTexGenfv (GL_Q, GL_OBJECT_PLANE, q_gen); + + glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, + GL_OBJECT_LINEAR); + glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, + GL_OBJECT_LINEAR); + glTexGeni (GL_Q, GL_TEXTURE_GEN_MODE, + GL_OBJECT_LINEAR); + + glEnable (GL_TEXTURE_GEN_S); + glEnable (GL_TEXTURE_GEN_T); + glEnable (GL_TEXTURE_GEN_Q); + + (*GL::activeTexture) (GL_TEXTURE0 + + gWindow->geometry ().texUnits + + 1 + (i * 2)); + + rm.reset (); + + rm[13] = -bScreen->ty * bScreen->pos[i]; + rm *= tm; + + s_gen[0] = rm[0]; + s_gen[1] = rm[4]; + s_gen[2] = rm[8]; + s_gen[3] = rm[12]; + t_gen[0] = rm[1]; + t_gen[1] = rm[5]; + t_gen[2] = rm[9]; + t_gen[3] = rm[13]; + q_gen[0] = rm[3]; + q_gen[1] = rm[7]; + q_gen[2] = rm[11]; + q_gen[3] = rm[15]; + + glTexGenfv (GL_T, GL_OBJECT_PLANE, t_gen); + glTexGenfv (GL_S, GL_OBJECT_PLANE, s_gen); + glTexGenfv (GL_Q, GL_OBJECT_PLANE, q_gen); + + glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, + GL_OBJECT_LINEAR); + glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, + GL_OBJECT_LINEAR); + glTexGeni (GL_Q, GL_TEXTURE_GEN_MODE, + GL_OBJECT_LINEAR); + + glEnable (GL_TEXTURE_GEN_S); + glEnable (GL_TEXTURE_GEN_T); + glEnable (GL_TEXTURE_GEN_Q); + } + + (*GL::activeTexture) (GL_TEXTURE0); + } +#endif + } + } + break; + case BlurOptions::FilterMipmap: + { + unit = 1; // FIXME!! + + const CompString &function ( + bScreen->getDstBlurFragmentFunction (texture, + unit, + 0, + 0)); + + if (!function.empty ()) + { + float lod = + bScreen->optionGetMipmapLod (); + + gWindow->addShaders ("blur", + "", + function); + + (*GL::activeTexture) (GL_TEXTURE0 + unit); + bScreen->texture[0]->enable (GLTexture::Good); + gWindow->vertexBuffer ()->addTexCoords (unit, 0, NULL); + (*GL::activeTexture) (GL_TEXTURE0); + + gWindow->vertexBuffer ()->addUniform4f ("blur_translation", + bScreen->tx, bScreen->ty, + 0.0f, lod); + + gWindow->vertexBuffer ()->addUniform4f ("blur_threshold", + threshold, + threshold, + threshold, + threshold); + } + } + break; + } +} +} + void -BlurWindow::glDrawTexture (GLTexture *texture, - GLFragment::Attrib &attrib, - unsigned int mask) +BlurWindow::glDrawTexture (GLTexture *texture, + const GLMatrix &matrix, + const GLWindowPaintAttrib &attrib, + unsigned int mask) { int state = BLUR_STATE_DECOR; @@ -1733,295 +1945,108 @@ if (blur || this->state[state].active) { - GLFragment::Attrib fa (attrib); - int param, function; int unit = 0; - GLfloat dx, dy; int iTC = 0; if (blur) { - param = fa.allocParameters (1); + GLfloat dx, dy; - function = bScreen->getSrcBlurFragmentFunction (texture, param); - if (function) + const CompString &function ( + bScreen->getSrcBlurFragmentFunction (texture)); + + if (!function.empty ()) { - fa.addFunction (function); + gWindow->addShaders ("focusblur", + "", + function); dx = ((texture->matrix ().xx / 2.1f) * blur) / 65535.0f; dy = ((texture->matrix ().yy / 2.1f) * blur) / 65535.0f; - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param, dx, dy, dx, -dy); + gWindow->vertexBuffer ()->addUniform4f ("focusblur_input_offset", + dx, dy, dx, -dy); /* bi-linear filtering is required */ mask |= PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK; } } + /* We are drawing the scraped texture, blur it */ if (this->state[state].active) { - GLFragment::Attrib dstFa (fa); - float threshold = (float) this->state[state].threshold; - - switch (bScreen->optionGetFilter ()) { - case BlurOptions::Filter4xbilinear: - dx = bScreen->tx / 2.1f; - dy = bScreen->ty / 2.1f; - - param = dstFa.allocParameters (3); - unit = dstFa.allocTextureUnits (1); - - function = bScreen->getDstBlurFragmentFunction ( - texture, param, unit, 0, 0); - if (function) - { - dstFa.addFunction (function); - - (*GL::activeTexture) (GL_TEXTURE0_ARB + unit); - glBindTexture (bScreen->target, bScreen->texture[0]); - (*GL::activeTexture) (GL_TEXTURE0_ARB); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param, - bScreen->tx, bScreen->ty, - 0.0f, 0.0f); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param + 1, - threshold, threshold, - threshold, threshold); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param + 2, - dx, dy, 0.0f, 0.0f); - } - break; - case BlurOptions::FilterGaussian: - if (bScreen->optionGetIndependentTex ()) - { - /* leave one free texture unit for fragment position */ - iTC = MAX (0, GL::maxTextureUnits - - (gWindow->geometry ().texUnits + 1)); - if (iTC) - iTC = MIN (iTC / 2, bScreen->numTexop); - } - - param = dstFa.allocParameters (2); - unit = dstFa.allocTextureUnits (2); - - function = bScreen->getDstBlurFragmentFunction ( - texture, param, unit, iTC, - gWindow->geometry ().texUnits); - - if (function) - { - dstFa.addFunction (function); - - (*GL::activeTexture) (GL_TEXTURE0_ARB + unit); - glBindTexture (bScreen->target, bScreen->texture[0]); - (*GL::activeTexture) (GL_TEXTURE0_ARB + unit + 1); - glBindTexture (bScreen->target, bScreen->texture[1]); - (*GL::activeTexture) (GL_TEXTURE0_ARB); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param, bScreen->tx, - bScreen->ty, 0.0f, 0.0f); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param + 1, - threshold, threshold, - threshold, threshold); - - if (iTC) - { - GLMatrix tm, rm; - float s_gen[4], t_gen[4], q_gen[4]; - - for (unsigned int i = 0; i < 16; i++) - tm[i] = 0; - tm[0] = (bScreen->output->width () / 2.0) * - bScreen->tx; - tm[5] = (bScreen->output->height () / 2.0) * - bScreen->ty; - tm[10] = 1; - - tm[12] = (bScreen->output->width () / 2.0 + - bScreen->output->x1 ()) * bScreen->tx; - tm[13] = (bScreen->output->height () / 2.0 + - screen->height () - - bScreen->output->y2 ()) * bScreen->ty; - tm[14] = 1; - tm[15] = 1; - - tm *= bScreen->mvp; - - for (int i = 0; i < iTC; i++) - { - (*GL::activeTexture) (GL_TEXTURE0_ARB + - gWindow->geometry ().texUnits + (i * 2)); - - rm.reset (); - rm[13] = bScreen->ty * bScreen->pos[i]; - rm *= tm; - - s_gen[0] = rm[0]; - s_gen[1] = rm[4]; - s_gen[2] = rm[8]; - s_gen[3] = rm[12]; - t_gen[0] = rm[1]; - t_gen[1] = rm[5]; - t_gen[2] = rm[9]; - t_gen[3] = rm[13]; - q_gen[0] = rm[3]; - q_gen[1] = rm[7]; - q_gen[2] = rm[11]; - q_gen[3] = rm[15]; - - glTexGenfv (GL_T, GL_OBJECT_PLANE, t_gen); - glTexGenfv (GL_S, GL_OBJECT_PLANE, s_gen); - glTexGenfv (GL_Q, GL_OBJECT_PLANE, q_gen); - - glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, - GL_OBJECT_LINEAR); - glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, - GL_OBJECT_LINEAR); - glTexGeni (GL_Q, GL_TEXTURE_GEN_MODE, - GL_OBJECT_LINEAR); - - glEnable (GL_TEXTURE_GEN_S); - glEnable (GL_TEXTURE_GEN_T); - glEnable (GL_TEXTURE_GEN_Q); - - (*GL::activeTexture) (GL_TEXTURE0_ARB + - gWindow->geometry ().texUnits + - 1 + (i * 2)); - - rm.reset (); - - rm[13] = -bScreen->ty * bScreen->pos[i]; - rm *= tm; - - s_gen[0] = rm[0]; - s_gen[1] = rm[4]; - s_gen[2] = rm[8]; - s_gen[3] = rm[12]; - t_gen[0] = rm[1]; - t_gen[1] = rm[5]; - t_gen[2] = rm[9]; - t_gen[3] = rm[13]; - q_gen[0] = rm[3]; - q_gen[1] = rm[7]; - q_gen[2] = rm[11]; - q_gen[3] = rm[15]; - - glTexGenfv (GL_T, GL_OBJECT_PLANE, t_gen); - glTexGenfv (GL_S, GL_OBJECT_PLANE, s_gen); - glTexGenfv (GL_Q, GL_OBJECT_PLANE, q_gen); - - glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, - GL_OBJECT_LINEAR); - glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, - GL_OBJECT_LINEAR); - glTexGeni (GL_Q, GL_TEXTURE_GEN_MODE, - GL_OBJECT_LINEAR); - - glEnable (GL_TEXTURE_GEN_S); - glEnable (GL_TEXTURE_GEN_T); - glEnable (GL_TEXTURE_GEN_Q); - } - - (*GL::activeTexture) (GL_TEXTURE0_ARB); - } - - } - break; - case BlurOptions::FilterMipmap: - param = dstFa.allocParameters (2); - unit = dstFa.allocTextureUnits (1); - - function = - bScreen->getDstBlurFragmentFunction (texture, param, - unit, 0, 0); - if (function) - { - float lod = - bScreen->optionGetMipmapLod (); - - dstFa.addFunction (function); - - (*GL::activeTexture) (GL_TEXTURE0_ARB + unit); - glBindTexture (bScreen->target, bScreen->texture[0]); - (*GL::activeTexture) (GL_TEXTURE0_ARB); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param, - bScreen->tx, bScreen->ty, - 0.0f, lod); - - (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, - param + 1, - threshold, threshold, - threshold, threshold); - } - break; - } + setupShadersAndUniformsForDstBlur (texture, + gWindow, + bScreen, + unit, + iTC, + this->state[state].threshold); if (this->state[state].clipped || (!bScreen->blurOcclusion && !clip.isEmpty ())) { glEnable (GL_STENCIL_TEST); + /* Don't touch the stencil buffer */ glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc (GL_EQUAL, 0x1, ~0); - /* draw region with destination blur */ - gWindow->glDrawTexture (texture, dstFa, mask); + /* Draw region with blur only where the stencil test passes */ + glStencilFunc (GL_EQUAL, 1, 1); - glStencilFunc (GL_EQUAL, 0, ~0); + /* draw region with destination blur - we are relying + * on a fairly awkward side-effect here which clears our + * active shader once this call is complete */ + gWindow->glDrawTexture (texture, matrix, attrib, mask); + + /* Allow drawing in everywhere but where we just drew */ + glStencilFunc (GL_EQUAL, 0, 1); /* draw region without destination blur */ - gWindow->glDrawTexture (texture, fa, mask); + gWindow->glDrawTexture (texture, matrix, attrib, mask); glDisable (GL_STENCIL_TEST); } else { /* draw with destination blur */ - gWindow->glDrawTexture (texture, dstFa, mask); + gWindow->glDrawTexture (texture, matrix, attrib, mask); } } else { - gWindow->glDrawTexture (texture, fa, mask); + gWindow->glDrawTexture (texture, matrix, attrib, mask); } if (unit) { - (*GL::activeTexture) (GL_TEXTURE0_ARB + unit); - glBindTexture (bScreen->target, 0); - (*GL::activeTexture) (GL_TEXTURE0_ARB + unit + 1); - glBindTexture (bScreen->target, 0); - (*GL::activeTexture) (GL_TEXTURE0_ARB); + (*GL::activeTexture) (GL_TEXTURE0 + unit); + bScreen->texture[0]->disable (); + (*GL::activeTexture) (GL_TEXTURE0 + unit + 1); + if (bScreen->fbo && + bScreen->fbo->tex ()) + bScreen->fbo->tex ()->disable (); + (*GL::activeTexture) (GL_TEXTURE0); } +#if INDEPENDENT_TEX_SUPPORTED if (iTC) { int i; for (i = gWindow->geometry ().texUnits; i < gWindow->geometry ().texUnits + (2 * iTC); i++) { - (*GL::activeTexture) (GL_TEXTURE0_ARB + i); + (*GL::activeTexture) (GL_TEXTURE0 + i); glDisable (GL_TEXTURE_GEN_S); glDisable (GL_TEXTURE_GEN_T); glDisable (GL_TEXTURE_GEN_Q); } - (*GL::activeTexture) (GL_TEXTURE0_ARB); + (*GL::activeTexture) (GL_TEXTURE0); } +#endif } else { - gWindow->glDrawTexture (texture, attrib, mask); + gWindow->glDrawTexture (texture, matrix, attrib, mask); } } @@ -2115,7 +2140,7 @@ screen->activeWindow ()); w = screen->findWindow (xid); - if (w && GL::fragmentProgram) + if (w && GL::shaders) { BLUR_SCREEN (screen); BLUR_WINDOW (w); @@ -2175,7 +2200,7 @@ cScreen->damageScreen (); break; case BlurOptions::AlphaBlur: - if (GL::fragmentProgram && optionGetAlphaBlur ()) + if (GL::shaders && optionGetAlphaBlur ()) alphaBlur = true; else alphaBlur = false; @@ -2228,12 +2253,15 @@ dstBlurFunctions (0), output (NULL), count (0), - program (0), maxTemp (32), - fbo (0), - fboStatus (0) + fbo (new GLFramebufferObject ()), + oldDrawFramebuffer (NULL), + determineProjectedBlurRegionsPass (false), + damageQuery (cScreen->getDamageQuery (boost::bind ( + &BlurScreen::markAreaDirty, + this, + _1))) { - blurAtom[BLUR_STATE_CLIENT] = XInternAtom (screen->dpy (), "_COMPIZ_WM_WINDOW_BLUR", 0); blurAtom[BLUR_STATE_DECOR] = @@ -2242,27 +2270,20 @@ blurTime = 1000.0f / optionGetBlurSpeed (); blurOcclusion = optionGetOcclusion (); - for (int i = 0; i < 2; i++) - texture[i] = 0; - glGetIntegerv (GL_STENCIL_BITS, &stencilBits); if (!stencilBits) compLogMessage ("blur", CompLogLevelWarn, "No stencil buffer. Region based blur disabled"); - /* We need GL_ARB_fragment_program for blur */ - if (GL::fragmentProgram) + /* We need GL_ARB_shading_language_100 for blur */ + if (GL::shaders) alphaBlur = optionGetAlphaBlur (); else alphaBlur = false; - if (GL::fragmentProgram) + if (GL::shaders) { - int tmp[4]; - GL::getProgramiv (GL_FRAGMENT_PROGRAM_ARB, - GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, - tmp); - maxTemp = tmp[0]; + maxTemp = 1024; // FIXME!!!!!!! } updateFilterRadius (); @@ -2277,20 +2298,7 @@ BlurScreen::~BlurScreen () { - foreach (BlurFunction &bf, srcBlurFunctions) - GLFragment::destroyFragmentFunction (bf.id); - foreach (BlurFunction &bf, dstBlurFunctions) - GLFragment::destroyFragmentFunction (bf.id); - cScreen->damageScreen (); - - if (fbo) - (*GL::deleteFramebuffers) (1, &fbo); - - for (int i = 0; i < 2; i++) - if (texture[i]) - glDeleteTextures (1, &texture[i]); - } BlurWindow::BlurWindow (CompWindow *w) : @@ -2329,10 +2337,11 @@ bool BlurPluginVTable::init () { - if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) && - CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) && - CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)) - return true; + if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) | + !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) | + !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)) + return false; - return false; + return true; } + diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/blur/src/blur.h compiz-0.9.12.2+16.10.20160517/plugins/blur/src/blur.h --- compiz-0.9.12.2+16.04.20160415/plugins/blur/src/blur.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/blur/src/blur.h 2016-05-17 02:52:47.000000000 +0000 @@ -23,32 +23,35 @@ * Author: David Reveman */ -#include "blur_options.h" - -#include -#include -#include +#include +#include #include #include #include - - #include -#include +#include "blur_options.h" + +#include +#include +#include +#include -extern const unsigned short BLUR_GAUSSIAN_RADIUS_MAX; -struct BlurFunction { +const unsigned short BLUR_GAUSSIAN_RADIUS_MAX = 15; - GLFragment::FunctionId id; +const unsigned short BLUR_STATE_CLIENT = 0; +const unsigned short BLUR_STATE_DECOR = 1; +const unsigned short BLUR_STATE_NUM = 2; +struct BlurFunction +{ + CompString shader; int target; - int param; - int unit; int startTC; int numITC; + int saturation; }; struct BlurBox { @@ -56,10 +59,6 @@ decor_point_t p2; }; -extern const unsigned short BLUR_STATE_CLIENT; -extern const unsigned short BLUR_STATE_DECOR; -extern const unsigned short BLUR_STATE_NUM; - struct BlurState { int threshold; std::vector box; @@ -88,6 +87,8 @@ void preparePaint (int); void donePaint (); + void damageCutoff (); + bool glPaintOutput (const GLScreenPaintAttrib &, const GLMatrix &, const CompRegion &, CompOutput *, unsigned int); @@ -99,12 +100,11 @@ void updateFilterRadius (); void blurReset (); - GLFragment::FunctionId getSrcBlurFragmentFunction (GLTexture *, int); - GLFragment::FunctionId getDstBlurFragmentFunction (GLTexture *texture, - int param, - int unit, - int numITC, - int startTC); + const CompString & getSrcBlurFragmentFunction (GLTexture *); + const CompString & getDstBlurFragmentFunction (GLTexture *texture, + int unit, + int numITC, + int startTC); bool projectVertices (CompOutput *output, const GLMatrix &transform, @@ -112,8 +112,9 @@ float *scr, int n); - bool loadFragmentProgram (GLuint *program, - const char *string); + bool loadFragmentProgram (boost::shared_ptr &program, + const char *vertex, + const char *fragment); bool loadFilterProgram (int numITC); @@ -152,24 +153,34 @@ CompOutput *output; int count; - GLuint texture[2]; + GLTexture::List texture; - GLenum target; float tx; float ty; int width; int height; - GLuint program; + boost::shared_ptr program; int maxTemp; - GLuint fbo; - bool fboStatus; + boost::shared_ptr fbo; + + GLFramebufferObject *oldDrawFramebuffer; float amp[BLUR_GAUSSIAN_RADIUS_MAX]; float pos[BLUR_GAUSSIAN_RADIUS_MAX]; int numTexop; GLMatrix mvp; + + bool determineProjectedBlurRegionsPass; + bool allowAreaDirtyOnOwnDamageBuffer; + CompRegion backbufferUpdateRegionThisFrame; + + compiz::composite::buffertracking::AgeDamageQuery::Ptr damageQuery; + + private: + + bool markAreaDirty (const CompRegion &r); }; class BlurWindow : @@ -188,11 +199,16 @@ bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &, const CompRegion &, unsigned int); - bool glDraw (const GLMatrix &, GLFragment::Attrib &, + void glTransformationComplete (const GLMatrix &matrix, + const CompRegion ®ion, + unsigned int mask); + + bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &, const CompRegion &, unsigned int); - void glDrawTexture (GLTexture *texture, GLFragment::Attrib &, + void glDrawTexture (GLTexture *texture, + const GLMatrix &, + const GLWindowPaintAttrib &, unsigned int); - void updateRegion (); void setBlur (int state, @@ -206,9 +222,13 @@ void projectRegion (CompOutput *output, const GLMatrix &transform); + void determineBlurRegion (int filter, + const GLMatrix &transform, + int clientThreshold); + bool updateDstTexture (const GLMatrix &transform, CompRect *pExtents, - int clientThreshold); + unsigned int mask); public: CompWindow *window; @@ -225,6 +245,7 @@ CompRegion region; CompRegion clip; + CompRegion projectedBlurRegion; }; #define BLUR_SCREEN(s) \ diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/plugins/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/plugins/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/CMakeLists.txt 2016-05-17 02:52:47.000000000 +0000 @@ -12,7 +12,6 @@ # temporarily disable plugins that aren't ported yet set (COMPIZ_DISABLE_PLUGIN_ANIMATIONADDON ON) set (COMPIZ_DISABLE_PLUGIN_BICUBIC ON) -set (COMPIZ_DISABLE_PLUGIN_BLUR ON) set (COMPIZ_DISABLE_PLUGIN_COLORFILTER ON) set (COMPIZ_DISABLE_PLUGIN_GROUP ON) set (COMPIZ_DISABLE_PLUGIN_LOGINOUT ON) diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/expo/expo.xml.in compiz-0.9.12.2+16.10.20160517/plugins/expo/expo.xml.in --- compiz-0.9.12.2+16.04.20160415/plugins/expo/expo.xml.in 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/expo/expo.xml.in 2016-05-17 02:52:53.000000000 +0000 @@ -149,6 +149,12 @@ <_long>Vertical offset (in pixels). 24 + + diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/scale/src/privates.h compiz-0.9.12.2+16.10.20160517/plugins/scale/src/privates.h --- compiz-0.9.12.2+16.04.20160415/plugins/scale/src/privates.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/scale/src/privates.h 2016-05-17 02:52:17.000000000 +0000 @@ -94,7 +94,9 @@ bool selectWindowAt (int x, int y, bool moveInputFocus); bool selectWindowAt (int x, int y); + void moveFocusWindow (CompWindow *); void moveFocusWindow (int dx, int dy); + void moveFocusWindow (int distance); void windowRemove (CompWindow *); @@ -117,8 +119,6 @@ Window hoveredWindow; Window previousActiveWindow; - KeyCode leftKeyCode, rightKeyCode, upKeyCode, downKeyCode; - bool grab; CompScreen::GrabHandle grabIndex; diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/scale/src/scale.cpp compiz-0.9.12.2+16.10.20160517/plugins/scale/src/scale.cpp --- compiz-0.9.12.2+16.04.20160415/plugins/scale/src/scale.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/scale/src/scale.cpp 2016-05-17 02:52:59.000000000 +0000 @@ -509,7 +509,7 @@ int nSlots = 0; y = optionGetYOffset() + workArea.y () + spacing; - height = (workArea.height () - optionGetYOffset() - (lines + 1) * spacing) / lines; + height = (workArea.height () - optionGetYOffset () - optionGetYBottomOffset () - (lines + 1) * spacing) / lines; for (int i = 0; i < lines; i++) { @@ -1528,13 +1528,67 @@ } void +PrivateScaleScreen::moveFocusWindow (int distance) +{ + CompWindow *selected; + CompWindow *next; + + next = NULL; + selected = screen->findWindow (selectedWindow ? selectedWindow : screen->activeWindow ()); + auto scaledWindows = windows; + + /* Sort windows to respect the natural grid view */ + scaledWindows.sort ([] (ScaleWindow *sw1, ScaleWindow *sw2) { + if (!sw1->priv->slot) + return !sw2->priv->slot; + if (!sw2->priv->slot) + return true; + + int cy1 = (sw1->priv->slot->y1 () + sw1->priv->slot->y2 ()) / 2; + int cy2 = (sw2->priv->slot->y1 () + sw2->priv->slot->y2 ()) / 2; + + if (abs (cy1 - cy2) < std::max (sw1->priv->slot->height (), sw2->priv->slot->height ()) / 2) + { + int cx1 = (sw1->priv->slot->x1 () + sw1->priv->slot->x2 ()) / 2; + int cx2 = (sw2->priv->slot->x1 () + sw2->priv->slot->x2 ()) / 2; + return cx1 < cx2; + } + + return cy1 < cy2; + }); + + if (selected && !scaledWindows.empty()) + { + SCALE_WINDOW (selected); + auto selected_it = std::find (scaledWindows.begin (), scaledWindows.end (), sw); + + if (selected_it != scaledWindows.end ()) + { + std::advance (selected_it, distance); + + if (selected_it == scaledWindows.end ()) + { + if (distance > 0) + selected_it = scaledWindows.begin (); + else if (distance < 0) + selected_it = std::prev (scaledWindows.end ()); + } + + next = (*selected_it)->window; + } + } + + moveFocusWindow (next); +} + +void PrivateScaleScreen::moveFocusWindow (int dx, int dy) { CompWindow *active; CompWindow *focus = NULL; - active = screen->findWindow (screen->activeWindow ()); + active = screen->findWindow (selectedWindow ? selectedWindow : screen->activeWindow ()); if (active) { SCALE_WINDOW (active); @@ -1547,9 +1601,9 @@ cx = (sw->priv->slot->x1 () + sw->priv->slot->x2 ()) / 2; cy = (sw->priv->slot->y1 () + sw->priv->slot->y2 ()) / 2; - foreach (CompWindow *w, screen->windows ()) + foreach (ScaleWindow *w, windows) { - slot = ScaleWindow::get (w)->priv->slot; + slot = w->priv->slot; if (!slot) continue; @@ -1566,23 +1620,29 @@ continue; min = d; - focus = w; + focus = w->window; } } } } + moveFocusWindow (focus); +} + +void +PrivateScaleScreen::moveFocusWindow (CompWindow *focus) +{ /* move focus to the last focused window if no slot window is currently focused */ if (!focus) { - foreach (CompWindow *w, screen->windows ()) + foreach (ScaleWindow *sw, windows) { - if (!ScaleWindow::get (w)->priv->slot) + if (!sw->priv->slot) continue; - if (!focus || focus->activeNum () < w->activeNum ()) - focus = w; + if (!focus || focus->activeNum () < sw->window->activeNum ()) + focus = sw->window; } } @@ -1719,14 +1779,23 @@ { if (grabIndex) { - if (event->xkey.keycode == leftKeyCode) + KeySym keySym = XkbKeycodeToKeysym (event->xany.display, + event->xkey.keycode, 0, 0); + if (keySym == XK_Left) moveFocusWindow (-1, 0); - else if (event->xkey.keycode == rightKeyCode) + else if (keySym == XK_Right) moveFocusWindow (1, 0); - else if (event->xkey.keycode == upKeyCode) + else if (keySym == XK_Up) moveFocusWindow (0, -1); - else if (event->xkey.keycode == downKeyCode) + else if (keySym == XK_Down) moveFocusWindow (0, 1); + else if (keySym == XK_Tab) + moveFocusWindow (!(event->xkey.state & ShiftMask) ? 1 : -1); + else if (keySym == XK_w && (event->xkey.state & ControlMask)) + { + if (CompWindow *selected = screen->findWindow (selectedWindow)) + selected->close (0); + } } } break; @@ -1752,6 +1821,7 @@ CompRect workArea (screen->currentOutputDev ().workArea ()); workArea.setX (workArea.x() + optionGetXOffset ()); workArea.setY (workArea.y() + optionGetYOffset ()); + workArea.setBottom (workArea.bottom () + optionGetYBottomOffset ()); if (workArea.contains (pointer)) { @@ -1962,11 +2032,6 @@ moreAdjust (false), nSlots (0) { - leftKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Left")); - rightKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Right")); - upKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Up")); - downKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Down")); - opacity = (OPAQUE * optionGetOpacity ()) / 100; hover.setCallback (boost::bind (&PrivateScaleScreen::hoverTimeout, this)); diff -Nru compiz-0.9.12.2+16.04.20160415/plugins/session/.gitignore compiz-0.9.12.2+16.10.20160517/plugins/session/.gitignore --- compiz-0.9.12.2+16.04.20160415/plugins/session/.gitignore 2016-05-24 12:06:18.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/plugins/session/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -build diff -Nru compiz-0.9.12.2+16.04.20160415/postinst/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/postinst/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/postinst/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/postinst/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -6,9 +6,5 @@ PROPERTY GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE FALSE) -if (USE_GSETTINGS) - - compiz_add_install_recompile_gsettings_schemas (${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas) - add_all_gsettings_schemas_to_local_recompilation_rule () - -endif (USE_GSETTINGS) +compiz_add_install_recompile_gsettings_schemas (${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas) +add_all_gsettings_schemas_to_local_recompilation_rule () diff -Nru compiz-0.9.12.2+16.04.20160415/src/event.cpp compiz-0.9.12.2+16.10.20160517/src/event.cpp --- compiz-0.9.12.2+16.04.20160415/src/event.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/src/event.cpp 2016-05-17 02:52:06.000000000 +0000 @@ -855,7 +855,7 @@ if (o.empty ()) { - o.resize (8); + o.resize (9); o[0].setName ("event_window", CompOption::TypeInt); o[1].setName ("window", CompOption::TypeInt); o[2].setName ("modifiers", CompOption::TypeInt); @@ -867,6 +867,7 @@ { o[6].reset (); o[7].reset (); + o[8].reset (); } switch (event->type) { @@ -936,10 +937,14 @@ o[6].setName ("keycode", CompOption::TypeInt); o[7].setName ("time", CompOption::TypeInt); + o[8].setName ("is_repeated", CompOption::TypeBool); o[6].value ().set ((int) event->xkey.keycode); o[7].value ().set ((int) event->xkey.time); + o[8].value ().set (nextKeyPressIsRepeated_); + nextKeyPressIsRepeated_ = false; + eventManager.resetPossibleTap(); foreach (CompPlugin *p, CompPlugin::getPlugins ()) { @@ -966,6 +971,19 @@ bool handled = false; + nextKeyPressIsRepeated_ = false; + if (XEventsQueued (dpy, QueuedAfterReading)) + { + XEvent nev; + XPeekEvent (dpy, &nev); + + if (nev.type == KeyPress && nev.xkey.time == event->xkey.time && + nev.xkey.keycode == event->xkey.keycode) + { + nextKeyPressIsRepeated_ = true; + } + } + foreach (CompPlugin *p, CompPlugin::getPlugins ()) { CompOption::Vector &options = p->vTable->getOptions (); @@ -1679,9 +1697,17 @@ if (w->isViewable ()) { if (w->type () == CompWindowTypeDesktopMask) - decrementDesktopWindowCount(); + { + decrementDesktopWindowCount (); + if (!w->alpha ()) + decrementOpaqueDesktopWindowCount (); + } else if (type == CompWindowTypeDesktopMask) - incrementDesktopWindowCount(); + { + incrementDesktopWindowCount (); + if (!w->alpha ()) + incrementOpaqueDesktopWindowCount (); + } } w->wmType () = type; diff -Nru compiz-0.9.12.2+16.04.20160415/src/privatescreen/tests/test-privatescreen.cpp compiz-0.9.12.2+16.10.20160517/src/privatescreen/tests/test-privatescreen.cpp --- compiz-0.9.12.2+16.04.20160415/src/privatescreen/tests/test-privatescreen.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/src/privatescreen/tests/test-privatescreen.cpp 2016-05-17 02:52:06.000000000 +0000 @@ -145,6 +145,7 @@ CompSize &size, void *&data)); MOCK_METHOD0(desktopWindowCount, int ()); + MOCK_METHOD0(opaqueDesktopWindowCount, int ()); MOCK_METHOD0(attrib, XWindowAttributes ()); MOCK_CONST_METHOD0(defaultIcon, CompIcon *()); virtual bool otherGrabExist (const char *, ...) { return false; } // TODO How to mock? @@ -183,7 +184,9 @@ MOCK_METHOD0(snDisplay, SnDisplay * ()); MOCK_CONST_METHOD0(createFailed, bool ()); MOCK_METHOD0(incrementDesktopWindowCount, void ()); + MOCK_METHOD0(incrementOpaqueDesktopWindowCount, void ()); MOCK_METHOD0(decrementDesktopWindowCount, void ()); + MOCK_METHOD0(decrementOpaqueDesktopWindowCount, void ()); MOCK_METHOD0(nextMapNum, unsigned int ()); MOCK_CONST_METHOD0(updatePassiveKeyGrabs, void ()); MOCK_METHOD1(updatePassiveButtonGrabs, void (Window serverFrame)); diff -Nru compiz-0.9.12.2+16.04.20160415/src/privatescreen.h compiz-0.9.12.2+16.10.20160517/src/privatescreen.h --- compiz-0.9.12.2+16.04.20160415/src/privatescreen.h 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/src/privatescreen.h 2016-05-17 02:52:06.000000000 +0000 @@ -542,10 +542,14 @@ DesktopWindowCount(); virtual ~DesktopWindowCount() {} virtual void incrementDesktopWindowCount(); + virtual void incrementOpaqueDesktopWindowCount(); virtual void decrementDesktopWindowCount(); + virtual void decrementOpaqueDesktopWindowCount(); virtual int desktopWindowCount(); + virtual int opaqueDesktopWindowCount(); private: - int count; + int countAll; + int countOpaque; }; class MapNum : @@ -818,6 +822,8 @@ compiz::private_screen::PluginManager pluginManager; compiz::private_screen::WindowManager& windowManager; CompOption::Vector resourceManager; + + bool nextKeyPressIsRepeated_; }; class CompManager diff -Nru compiz-0.9.12.2+16.04.20160415/src/screen.cpp compiz-0.9.12.2+16.10.20160517/src/screen.cpp --- compiz-0.9.12.2+16.04.20160415/src/screen.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/src/screen.cpp 2016-05-17 02:52:06.000000000 +0000 @@ -4565,7 +4565,13 @@ int cps::DesktopWindowCount::desktopWindowCount () { - return count; + return countAll; +} + +int +cps::DesktopWindowCount::opaqueDesktopWindowCount () +{ + return countOpaque; } unsigned int @@ -4879,19 +4885,32 @@ } cps::DesktopWindowCount::DesktopWindowCount() : -count(0) +countAll(0), countOpaque(0) { } void cps::DesktopWindowCount::incrementDesktopWindowCount() { - count++; + countAll++; } + +void +cps::DesktopWindowCount::incrementOpaqueDesktopWindowCount() +{ + countOpaque++; +} + void cps::DesktopWindowCount::decrementDesktopWindowCount() { - count--; + countAll--; +} + +void +cps::DesktopWindowCount::decrementOpaqueDesktopWindowCount() +{ + countOpaque--; } cps::MapNum::MapNum() : @@ -5451,7 +5470,8 @@ edgeWindow (None), edgeDelayTimer (), xdndWindow (None), - windowManager(windowManager) + windowManager(windowManager), + nextKeyPressIsRepeated_(false) { for (int i = 0; i < SCREEN_EDGE_NUM; i++) { diff -Nru compiz-0.9.12.2+16.04.20160415/src/window.cpp compiz-0.9.12.2+16.10.20160517/src/window.cpp --- compiz-0.9.12.2+16.04.20160415/src/window.cpp 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/src/window.cpp 2016-05-17 02:52:24.000000000 +0000 @@ -543,11 +543,11 @@ recalcType (); recalcActions (); + stateChangeNotify (oldState); if (priv->managed) screen->setWindowState (priv->state, priv->id); - stateChangeNotify (oldState); screen->matchPropertyChanged (this); } @@ -1372,7 +1372,11 @@ screen->updateClientList (); if (priv->type & CompWindowTypeDesktopMask) - screen->incrementDesktopWindowCount(); + { + screen->incrementDesktopWindowCount (); + if (!alpha ()) + screen->incrementOpaqueDesktopWindowCount (); + } if (priv->protocols & CompWindowProtocolSyncRequestMask) { @@ -1456,7 +1460,11 @@ return; if (priv->type == CompWindowTypeDesktopMask) - screen->decrementDesktopWindowCount(); + { + screen->decrementDesktopWindowCount (); + if (!alpha ()) + screen->decrementOpaqueDesktopWindowCount (); + } priv->attrib.map_state = IsUnmapped; priv->invisible = true; @@ -6333,7 +6341,11 @@ if (priv->attrib.map_state == IsViewable) { if (priv->type == CompWindowTypeDesktopMask) + { screen->decrementDesktopWindowCount (); + if (!alpha ()) + screen->decrementOpaqueDesktopWindowCount (); + } if (priv->destroyed && priv->struts) screen->updateWorkarea (); diff -Nru compiz-0.9.12.2+16.04.20160415/xslt/CMakeLists.txt compiz-0.9.12.2+16.10.20160517/xslt/CMakeLists.txt --- compiz-0.9.12.2+16.04.20160415/xslt/CMakeLists.txt 2016-04-15 05:30:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160517/xslt/CMakeLists.txt 2016-05-17 02:52:30.000000000 +0000 @@ -1,13 +1,10 @@ - set (_files bcop.xslt ) compiz_configure_file (compiz_gsettings_schemas.xslt.in compiz_gsettings_schemas.xslt) -if (USE_GSETTINGS) - list (APPEND _files ${CMAKE_CURRENT_BINARY_DIR}/compiz_gsettings_schemas.xslt) -endif () +list (APPEND _files ${CMAKE_CURRENT_BINARY_DIR}/compiz_gsettings_schemas.xslt) install ( FILES ${_files}