From 20bdb064387a72609b8ec1eccf6e2c6a6c0fcc3d Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 5 Sep 2012 20:56:31 +0800 Subject: [PATCH 01/39] Make non-metacity builds work again --- gtk/window-decorator/decorator.c | 25 +++++++++++--------- gtk/window-decorator/gwd-settings-notified.c | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gtk/window-decorator/decorator.c b/gtk/window-decorator/decorator.c index 4172a195c..0abbe8227 100644 --- a/gtk/window-decorator/decorator.c +++ b/gtk/window-decorator/decorator.c @@ -1034,17 +1034,8 @@ update_frames_shadows (gpointer key, } -void -cairo_get_shadow (decor_frame_t *d, decor_shadow_options_t *opts, gboolean active) -{ - if (active) - g_object_get (settings, "active-shadow", &opts, NULL); - else - g_object_get (settings, "inactive-shadow", &opts, NULL); -} - -void -meta_get_shadow (decor_frame_t *frame, decor_shadow_options_t *opts, gboolean active) +static void +get_shadow_common (decor_frame_t *d, decor_shadow_options_t *opts, gboolean active) { decor_shadow_options_t *setting_opts = NULL; @@ -1059,6 +1050,18 @@ meta_get_shadow (decor_frame_t *frame, decor_shadow_options_t *opts, gboolean ac } } +void +cairo_get_shadow (decor_frame_t *frame, decor_shadow_options_t *opts, gboolean active) +{ + get_shadow_common (frame, opts, active); +} + +void +meta_get_shadow (decor_frame_t *frame, decor_shadow_options_t *opts, gboolean active) +{ + get_shadow_common (frame, opts, active); +} + int update_shadow (void) { diff --git a/gtk/window-decorator/gwd-settings-notified.c b/gtk/window-decorator/gwd-settings-notified.c index b73bfc2b1..93e7bfc5b 100644 --- a/gtk/window-decorator/gwd-settings-notified.c +++ b/gtk/window-decorator/gwd-settings-notified.c @@ -173,6 +173,7 @@ gwd_settings_notified_impl_update_metacity_theme (GWDSettingsNotified *notified) static gboolean gwd_settings_notified_impl_update_metacity_button_layout (GWDSettingsNotified *notified) { +#ifdef USE_METACITY const gchar *button_layout; g_object_get (settings, "metacity-button-layout", &button_layout, NULL); @@ -191,6 +192,7 @@ gwd_settings_notified_impl_update_metacity_button_layout (GWDSettingsNotified *n return TRUE; } +#endif return FALSE; } -- GitLab From fd4828315f1d8f42ae9ebef2488620def37788d5 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 5 Sep 2012 22:25:35 +0800 Subject: [PATCH 02/39] Added some new utility files for cairo and metacity window decorations for the functions that we wanted to get under test, write tests for them too --- gtk/window-decorator/CMakeLists.txt | 10 ++- .../gwd-cairo-window-decoration-util.c | 57 +++++++++++++ .../gwd-cairo-window-decoration-util.h | 39 +++++++++ .../gwd-metacity-window-decoration-util.c | 41 ++++++++++ .../gwd-metacity-window-decoration-util.h | 40 +++++++++ gtk/window-decorator/gwd-settings-notified.c | 10 ++- gtk/window-decorator/tests/CMakeLists.txt | 31 +++++++ .../tests/test_gwd_cairo_decorations.cpp | 52 ++++++++++++ .../tests/test_gwd_metacity_decorations.cpp | 82 +++++++++++++++++++ .../tests/test_gwd_settings.cpp | 20 +++++ include/decoration.h | 4 + libdecoration/decoration.c | 2 +- 12 files changed, 385 insertions(+), 3 deletions(-) create mode 100644 gtk/window-decorator/gwd-cairo-window-decoration-util.c create mode 100644 gtk/window-decorator/gwd-cairo-window-decoration-util.h create mode 100644 gtk/window-decorator/gwd-metacity-window-decoration-util.c create mode 100644 gtk/window-decorator/gwd-metacity-window-decoration-util.h create mode 100644 gtk/window-decorator/tests/test_gwd_cairo_decorations.cpp create mode 100644 gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp diff --git a/gtk/window-decorator/CMakeLists.txt b/gtk/window-decorator/CMakeLists.txt index a377b155f..d62f28566 100644 --- a/gtk/window-decorator/CMakeLists.txt +++ b/gtk/window-decorator/CMakeLists.txt @@ -23,6 +23,12 @@ if (USE_GTK) ${COMPIZ_LINK_DIRS} ) + add_library (gtk_window_decorator_metacity_window_decoration_util + ${CMAKE_CURRENT_SOURCE_DIR}/gwd-metacity-window-decoration-util.c) + + add_library (gtk_window_decorator_cairo_window_decoration_util + ${CMAKE_CURRENT_SOURCE_DIR}/gwd-cairo-window-decoration-util.c) + add_library (gtk_window_decorator_settings_interface STATIC ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-interface.c) @@ -47,7 +53,9 @@ if (USE_GTK) gtk_window_decorator_settings_writable_interface gtk_window_decorator_settings gtk_window_decorator_settings_storage_interface - gtk_window_decorator_settings_storage_xproperty_interface) + gtk_window_decorator_settings_storage_xproperty_interface + gtk_window_decorator_metacity_window_decoration_util + gtk_window_decorator_cairo_window_decoration_util) if (USE_GCONF) set (gwd_schema ${CMAKE_CURRENT_BINARY_DIR}/gwd.schemas) diff --git a/gtk/window-decorator/gwd-cairo-window-decoration-util.c b/gtk/window-decorator/gwd-cairo-window-decoration-util.c new file mode 100644 index 000000000..c0614f510 --- /dev/null +++ b/gtk/window-decorator/gwd-cairo-window-decoration-util.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2010 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 "gwd-cairo-window-decoration-util.h" + +static const decor_extents_t gwd_cairo_window_decoration_default_win_extents = +{ + 6, 6, 10, 6 +}; + +static const decor_extents_t gwd_cairo_window_decoration_default_max_win_extents = +{ + 6, 6, 4, 6 +}; + +const decor_extents_t * +gwd_cairo_window_decoration_get_default_max_win_extents () +{ + return &gwd_cairo_window_decoration_default_max_win_extents; +} + + +const decor_extents_t * +gwd_cairo_window_decoration_get_default_win_extents () +{ + return &gwd_cairo_window_decoration_default_win_extents; +} + +void +gwd_cairo_window_decoration_get_extents (decor_extents_t *win_extents, + decor_extents_t *max_win_extents) +{ + memcpy (win_extents, + gwd_cairo_window_decoration_get_default_max_win_extents (), + sizeof (decor_extents_t)); + memcpy (max_win_extents, + gwd_cairo_window_decoration_get_default_win_extents (), + sizeof (decor_extents_t)); +} diff --git a/gtk/window-decorator/gwd-cairo-window-decoration-util.h b/gtk/window-decorator/gwd-cairo-window-decoration-util.h new file mode 100644 index 000000000..854047480 --- /dev/null +++ b/gtk/window-decorator/gwd-cairo-window-decoration-util.h @@ -0,0 +1,39 @@ +/* + * Copyright © 2010 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_CAIRO_WINDOW_DECORATION_UTIL_H +#define _GWD_CAIRO_WINDOW_DECORATION_UTIL_H + +#include + +G_BEGIN_DECLS + +typedef struct _decor_extents decor_extents_t; + +const decor_extents_t * gwd_cairo_window_decoration_get_default_max_win_extents (); +const decor_extents_t * gwd_cairo_window_decoration_get_default_win_extents (); + +void +gwd_cairo_window_decoration_get_extents (decor_extents_t *win_extents, + decor_extents_t *max_win_extents); + +G_END_DECLS; + +#endif diff --git a/gtk/window-decorator/gwd-metacity-window-decoration-util.c b/gtk/window-decorator/gwd-metacity-window-decoration-util.c new file mode 100644 index 000000000..68819747f --- /dev/null +++ b/gtk/window-decorator/gwd-metacity-window-decoration-util.c @@ -0,0 +1,41 @@ +/* + * Copyright © 2010 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 "gwd-metacity-window-decoration-util.h" + +gboolean +gwd_metacity_window_decoration_update_meta_theme (const gchar *theme, + GWDMetaThemeGetCurrentProc get_current, + GWDMetaThemeSetProc set_current) +{ + if (!theme) + return FALSE; + + if (!strlen (theme)) + return FALSE; + + (*set_current) (theme, TRUE); + if (!(*get_current) ()) + return FALSE; + + return TRUE; +} diff --git a/gtk/window-decorator/gwd-metacity-window-decoration-util.h b/gtk/window-decorator/gwd-metacity-window-decoration-util.h new file mode 100644 index 000000000..3d59554a5 --- /dev/null +++ b/gtk/window-decorator/gwd-metacity-window-decoration-util.h @@ -0,0 +1,40 @@ +/* + * Copyright © 2010 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_METACITY_WINDOW_DECORATION_UTIL_H +#define _GWD_METACITY_WINDOW_DECORATION_UTIL_H + +#include + +G_BEGIN_DECLS + +typedef struct _MetaTheme MetaTheme; +typedef MetaTheme * (*GWDMetaThemeGetCurrentProc) (); +typedef void (*GWDMetaThemeSetProc) (const gchar *theme, + gboolean force_update); + +gboolean +gwd_metacity_window_decoration_update_meta_theme (const gchar *theme, + GWDMetaThemeGetCurrentProc get_current, + GWDMetaThemeSetProc set_current); + +G_END_DECLS; + +#endif diff --git a/gtk/window-decorator/gwd-settings-notified.c b/gtk/window-decorator/gwd-settings-notified.c index 93e7bfc5b..5ce781ca1 100644 --- a/gtk/window-decorator/gwd-settings-notified.c +++ b/gtk/window-decorator/gwd-settings-notified.c @@ -124,7 +124,12 @@ gwd_settings_notified_impl_update_metacity_theme (GWDSettingsNotified *notified) { const gchar *theme = meta_theme; - if (theme) + /* meta_theme_get_current seems to return the last + * good theme now, so if one was already set this function + * will be ineffectual, so we need to check if the theme + * is obviously bad as the user intended to disable metacity + * themes */ + if (theme && strlen (theme)) { meta_theme_set_current (theme, TRUE); if (!meta_theme_get_current ()) @@ -133,6 +138,9 @@ gwd_settings_notified_impl_update_metacity_theme (GWDSettingsNotified *notified) meta_theme = NULL; } } + else + meta_theme = NULL; + } if (meta_theme) diff --git a/gtk/window-decorator/tests/CMakeLists.txt b/gtk/window-decorator/tests/CMakeLists.txt index 7d4e37d41..038b98f9f 100644 --- a/gtk/window-decorator/tests/CMakeLists.txt +++ b/gtk/window-decorator/tests/CMakeLists.txt @@ -111,4 +111,35 @@ if (COMPIZ_TEST_GTK_WINDOW_DECORATOR_FOUND) COVERAGE ${COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS}) + add_executable (compiz_test_gwd_cairo_decorations + ${CMAKE_CURRENT_SOURCE_DIR}/test_gwd_cairo_decorations.cpp) + + target_link_libraries (compiz_test_gwd_cairo_decorations + gtk_window_decorator_cairo_window_decoration_util + ${COMPIZ_TEST_GTK_WINDOW_DECORATOR_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + decoration) + + compiz_discover_tests (compiz_test_gwd_cairo_decorations COVERAGE + gtk_window_decorator_cairo_window_decoration_util) + + add_executable (compiz_test_gwd_metacity_decorations + ${CMAKE_CURRENT_SOURCE_DIR}/test_gwd_metacity_decorations.cpp) + + target_link_libraries (compiz_test_gwd_metacity_decorations + gtk_window_decorator_metacity_window_decoration_util + ${COMPIZ_TEST_GTK_WINDOW_DECORATOR_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + decoration) + + compiz_discover_tests (compiz_test_gwd_cairo_decorations COVERAGE + gtk_window_decorator_metacity_window_decoration_util) + + endif (COMPIZ_TEST_GTK_WINDOW_DECORATOR_FOUND) diff --git a/gtk/window-decorator/tests/test_gwd_cairo_decorations.cpp b/gtk/window-decorator/tests/test_gwd_cairo_decorations.cpp new file mode 100644 index 000000000..cc99d4838 --- /dev/null +++ b/gtk/window-decorator/tests/test_gwd_cairo_decorations.cpp @@ -0,0 +1,52 @@ +/* + * Copyright © 2010 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 "gwd-cairo-window-decoration-util.h" + +bool +operator== (const decor_extents_t &rhs, + const decor_extents_t &lhs) +{ + return decor_extents_cmp (&rhs, &lhs); +} + +class GWDCairoDecorationsTest : + public ::testing::Test +{ +}; + +namespace +{ + const decor_extents_t *defaultWinExtents = gwd_cairo_window_decoration_get_default_win_extents (); + const decor_extents_t *defaultMaxWinExtents = gwd_cairo_window_decoration_get_default_max_win_extents (); +} + +TEST (GWDCairoDecorationsTest, TestGetCairoDecorationExtents) +{ + decor_extents_t winExtents, maxWinExtents; + + gwd_cairo_window_decoration_get_extents (&winExtents, &maxWinExtents); + + EXPECT_EQ (winExtents, *defaultWinExtents); + EXPECT_EQ (maxWinExtents, *defaultMaxWinExtents); +} diff --git a/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp b/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp new file mode 100644 index 000000000..e77cc3db5 --- /dev/null +++ b/gtk/window-decorator/tests/test_gwd_metacity_decorations.cpp @@ -0,0 +1,82 @@ +/* + * Copyright © 2010 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-metacity-window-decoration-util.h" + +class GWDMetacityDecorationUtilTest : + public ::testing::Test +{ +}; + +MATCHER(IsTrue, "Is TRUE") { if (arg) return true; else return false; } +MATCHER(IsFalse, "Is FALSE") { if (!arg) return true; else return false; } + +namespace +{ + MetaTheme * get_current_returns_null () + { + return NULL; + } + + MetaTheme * get_current_returns_nonnull () + { + return (MetaTheme *) 1; + } + + void set_current_seam (const gchar *theme, + gboolean force) + { + } + + const std::string emptyTheme (""); + const std::string realTheme ("Adwaita"); + const std::string badTheme ("Clearlooks"); +} + +TEST (GWDMetacityDecorationUtilTest, TestNULLDecorationRevertsToCairo) +{ + EXPECT_THAT (gwd_metacity_window_decoration_update_meta_theme (NULL, + get_current_returns_nonnull, + set_current_seam), IsFalse ()); +} + +TEST (GWDMetacityDecorationUtilTest, TestEmptyStringDecorationRevertsToCairo) +{ + EXPECT_THAT (gwd_metacity_window_decoration_update_meta_theme (emptyTheme.c_str (), + get_current_returns_nonnull, + set_current_seam), IsFalse ()); +} + +TEST (GWDMetacityDecorationUtilTest, TestBadThemeStringDecorationRevertsToCairo) +{ + EXPECT_THAT (gwd_metacity_window_decoration_update_meta_theme (badTheme.c_str (), + get_current_returns_null, + set_current_seam), IsFalse ()); +} + +TEST (GWDMetacityDecorationUtilTest, TestGoodThemeStringDecorationUsesMetacity) +{ + EXPECT_THAT (gwd_metacity_window_decoration_update_meta_theme (realTheme.c_str (), + get_current_returns_nonnull, + set_current_seam), IsTrue ()); +} diff --git a/gtk/window-decorator/tests/test_gwd_settings.cpp b/gtk/window-decorator/tests/test_gwd_settings.cpp index f339b83e8..d542923b3 100644 --- a/gtk/window-decorator/tests/test_gwd_settings.cpp +++ b/gtk/window-decorator/tests/test_gwd_settings.cpp @@ -1,3 +1,23 @@ +/* + * Copyright © 2010 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 diff --git a/include/decoration.h b/include/decoration.h index 91d5e8883..9203dc903 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -510,6 +510,10 @@ decor_post_generate_request (Display *xdisplay, unsigned int frame_state, unsigned int frame_actions); +int +decor_extents_cmp (const decor_extents_t *a, + const decor_extents_t *b); + int decor_shadow_options_cmp (const decor_shadow_options_t *a, const decor_shadow_options_t *b); diff --git a/libdecoration/decoration.c b/libdecoration/decoration.c index 85c5f1b8d..fa57685b2 100644 --- a/libdecoration/decoration.c +++ b/libdecoration/decoration.c @@ -413,7 +413,7 @@ decor_quad_cmp (const decor_quad_t *a, const decor_quad_t *b) ); } -static int +int decor_extents_cmp (const decor_extents_t *a, const decor_extents_t *b) { /* Use binary | to avoid branch prediction slow-downs */ -- GitLab From b6e489c00c0757bd3c9f240ab0dd769ae018f0a9 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 5 Sep 2012 22:42:13 +0800 Subject: [PATCH 03/39] Use the new tested functions and more sensible logging --- gtk/window-decorator/cairo.c | 6 ++-- .../gwd-metacity-window-decoration-util.c | 5 ++++ gtk/window-decorator/gwd-settings-notified.c | 29 ++++--------------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/gtk/window-decorator/cairo.c b/gtk/window-decorator/cairo.c index c9da7a8c6..f2b564ea1 100644 --- a/gtk/window-decorator/cairo.c +++ b/gtk/window-decorator/cairo.c @@ -24,6 +24,7 @@ */ #include "gtk-window-decorator.h" +#include "gwd-cairo-window-decoration-util.h" void rounded_rectangle (cairo_t *cr, @@ -922,8 +923,9 @@ update_border_extents (decor_frame_t *frame) { frame = gwd_decor_frame_ref (frame); - frame->win_extents = frame->win_extents; - frame->max_win_extents = frame->win_extents; + gwd_cairo_window_decoration_get_extents (&frame->win_extents, + &frame->max_win_extents); + frame->titlebar_height = frame->max_titlebar_height = (frame->text_height < 17) ? 17 : frame->text_height; diff --git a/gtk/window-decorator/gwd-metacity-window-decoration-util.c b/gtk/window-decorator/gwd-metacity-window-decoration-util.c index 68819747f..ab6bcafe4 100644 --- a/gtk/window-decorator/gwd-metacity-window-decoration-util.c +++ b/gtk/window-decorator/gwd-metacity-window-decoration-util.c @@ -30,6 +30,11 @@ gwd_metacity_window_decoration_update_meta_theme (const gchar *theme, if (!theme) return FALSE; + /* meta_theme_get_current seems to return the last + * good theme now, so if one was already set this function + * will be ineffectual, so we need to check if the theme + * is obviously bad as the user intended to disable metacity + * themes */ if (!strlen (theme)) return FALSE; diff --git a/gtk/window-decorator/gwd-settings-notified.c b/gtk/window-decorator/gwd-settings-notified.c index 5ce781ca1..24138025b 100644 --- a/gtk/window-decorator/gwd-settings-notified.c +++ b/gtk/window-decorator/gwd-settings-notified.c @@ -22,6 +22,7 @@ #include "gwd-settings-notified-interface.h" #include "gwd-settings-notified.h" +#include "gwd-metacity-window-decoration-util.h" #include "gtk-window-decorator.h" @@ -120,30 +121,9 @@ gwd_settings_notified_impl_update_metacity_theme (GWDSettingsNotified *notified) const gchar *meta_theme = NULL; g_object_get (settings, "metacity-theme", &meta_theme, NULL); - if (meta_theme) - { - const gchar *theme = meta_theme; - - /* meta_theme_get_current seems to return the last - * good theme now, so if one was already set this function - * will be ineffectual, so we need to check if the theme - * is obviously bad as the user intended to disable metacity - * themes */ - if (theme && strlen (theme)) - { - meta_theme_set_current (theme, TRUE); - if (!meta_theme_get_current ()) - { - g_warning ("specified a theme that does not exist! falling back to cairo decoration\n"); - meta_theme = NULL; - } - } - else - meta_theme = NULL; - - } - - if (meta_theme) + if (gwd_metacity_window_decoration_update_meta_theme (meta_theme, + meta_theme_get_current, + meta_theme_set_current)) { theme_draw_window_decoration = meta_draw_window_decoration; theme_calc_decoration_size = meta_calc_decoration_size; @@ -155,6 +135,7 @@ gwd_settings_notified_impl_update_metacity_theme (GWDSettingsNotified *notified) } else { + g_log ("gtk-window-decorator", G_LOG_LEVEL_INFO, "using cairo decoration"); theme_draw_window_decoration = draw_window_decoration; theme_calc_decoration_size = calc_decoration_size; theme_update_border_extents = update_border_extents; -- GitLab From c4629ce03b0dd43266d48ead302dd757118371b3 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 5 Sep 2012 22:50:17 +0800 Subject: [PATCH 04/39] Correct the order of arguments for shade opacity and friends --- gtk/window-decorator/gwd-settings.c | 6 +++--- gtk/window-decorator/tests/CMakeLists.txt | 2 +- gtk/window-decorator/tests/test_gwd_settings.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gtk/window-decorator/gwd-settings.c b/gtk/window-decorator/gwd-settings.c index f52973d42..7dba02b93 100644 --- a/gtk/window-decorator/gwd-settings.c +++ b/gtk/window-decorator/gwd-settings.c @@ -358,10 +358,10 @@ gwd_settings_metacity_theme_changed (GWDSettingsWritable *settings, static gboolean gwd_settings_opacity_changed (GWDSettingsWritable *settings, - gdouble inactive_opacity, gdouble active_opacity, - gboolean inactive_shade_opacity, - gboolean active_shade_opacity) + gdouble inactive_opacity, + gboolean active_shade_opacity, + gboolean inactive_shade_opacity) { GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); diff --git a/gtk/window-decorator/tests/CMakeLists.txt b/gtk/window-decorator/tests/CMakeLists.txt index 038b98f9f..3346ae268 100644 --- a/gtk/window-decorator/tests/CMakeLists.txt +++ b/gtk/window-decorator/tests/CMakeLists.txt @@ -138,7 +138,7 @@ if (COMPIZ_TEST_GTK_WINDOW_DECORATOR_FOUND) ${GMOCK_MAIN_LIBRARY} decoration) - compiz_discover_tests (compiz_test_gwd_cairo_decorations COVERAGE + compiz_discover_tests (compiz_test_gwd_metacity_decorations COVERAGE gtk_window_decorator_metacity_window_decoration_util) diff --git a/gtk/window-decorator/tests/test_gwd_settings.cpp b/gtk/window-decorator/tests/test_gwd_settings.cpp index d542923b3..ba4149f75 100644 --- a/gtk/window-decorator/tests/test_gwd_settings.cpp +++ b/gtk/window-decorator/tests/test_gwd_settings.cpp @@ -924,10 +924,10 @@ TEST_F(GWDSettingsTest, TestMetacityOpacityChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); EXPECT_THAT (gwd_settings_writable_opacity_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::INACTIVE_OPACITY_VALUE, testing_values::ACTIVE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE, - testing_values::ACTIVE_SHADE_OPACITY_VALUE), GBooleanTrue ()); + testing_values::INACTIVE_OPACITY_VALUE, + testing_values::ACTIVE_SHADE_OPACITY_VALUE, + testing_values::INACTIVE_SHADE_OPACITY_VALUE), GBooleanTrue ()); AutoUnsetGValue metacityInactiveOpacityValue (G_TYPE_DOUBLE); AutoUnsetGValue metacityActiveOpacityValue (G_TYPE_DOUBLE); @@ -965,10 +965,10 @@ TEST_F(GWDSettingsTest, TestMetacityOpacityChanged) TEST_F(GWDSettingsTest, TestMetacityOpacityChangedIsDefault) { EXPECT_THAT (gwd_settings_writable_opacity_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - METACITY_INACTIVE_OPACITY_DEFAULT, METACITY_ACTIVE_OPACITY_DEFAULT, - METACITY_INACTIVE_SHADE_OPACITY_DEFAULT, - METACITY_ACTIVE_SHADE_OPACITY_DEFAULT), GBooleanFalse ()); + METACITY_INACTIVE_OPACITY_DEFAULT, + METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, + METACITY_INACTIVE_SHADE_OPACITY_DEFAULT), GBooleanFalse ()); } TEST_F(GWDSettingsTest, TestButtonLayoutChanged) -- GitLab From 66ae1f72b8e3e6f2928e35a97475547db192de92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 6 Sep 2012 12:53:59 +0200 Subject: [PATCH 05/39] Scale: select the window under the pointer, when the scale animation is over. --- plugins/scale/src/scale.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/scale/src/scale.cpp b/plugins/scale/src/scale.cpp index a8b1a760d..b915a839f 100644 --- a/plugins/scale/src/scale.cpp +++ b/plugins/scale/src/scale.cpp @@ -929,7 +929,10 @@ PrivateScaleScreen::donePaint () } } else if (state == ScaleScreen::Out) + { state = ScaleScreen::Wait; + selectWindowAt(pointerX, pointerY, true); + } } } -- GitLab From 991b804b2625c9783e33e2db6c8c1be122b37f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 6 Sep 2012 13:06:14 +0200 Subject: [PATCH 06/39] Scale: add public method to get the selected window. --- plugins/scale/include/scale/scale.h | 3 ++- plugins/scale/src/scale.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/scale/include/scale/scale.h b/plugins/scale/include/scale/scale.h index fc21f8fe2..235ec5de0 100644 --- a/plugins/scale/include/scale/scale.h +++ b/plugins/scale/include/scale/scale.h @@ -93,7 +93,8 @@ class ScaleScreen : State getState () const; ScaleType getType () const; - const Window & getHoveredWindow (); + const Window & getHoveredWindow () const; + const Window & getSelectedWindow () const; const CompMatch & getCustomMatch () const; const WindowList& getWindows () const; diff --git a/plugins/scale/src/scale.cpp b/plugins/scale/src/scale.cpp index b915a839f..8e1c1194a 100644 --- a/plugins/scale/src/scale.cpp +++ b/plugins/scale/src/scale.cpp @@ -1349,11 +1349,17 @@ ScaleWindow::setCurrentPosition (const ScalePosition &newPos) } const Window & -ScaleScreen::getHoveredWindow () +ScaleScreen::getHoveredWindow () const { return priv->hoveredWindow; } +const Window & +ScaleScreen::getSelectedWindow () const +{ + return priv->selectedWindow; +} + bool PrivateScaleScreen::selectWindowAt (int x, int y, -- GitLab From 7af3815b142b3b4e0687b54d6a1a21aafc5634c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 6 Sep 2012 13:10:11 +0200 Subject: [PATCH 07/39] Scale: follow the "click_to_focus" option to focus or not the window on animation completed --- plugins/scale/src/scale.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/scale/src/scale.cpp b/plugins/scale/src/scale.cpp index 8e1c1194a..d65c05ee2 100644 --- a/plugins/scale/src/scale.cpp +++ b/plugins/scale/src/scale.cpp @@ -931,7 +931,11 @@ PrivateScaleScreen::donePaint () else if (state == ScaleScreen::Out) { state = ScaleScreen::Wait; - selectWindowAt(pointerX, pointerY, true); + + // When the animation is completed, select the window under mouse + CompOption *o = screen->getOption ("click_to_focus"); + bool focus = (o && !o->value ().b ()); + selectWindowAt (pointerX, pointerY, focus); } } } -- GitLab From c40c5e73a68ebf74f6cfedd9587c6c0418d00759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 6 Sep 2012 14:07:50 +0200 Subject: [PATCH 08/39] Scale: introduce selectWindowAt (int x, int y) that would consider the "click_to_focus" option --- plugins/scale/src/privates.h | 1 + plugins/scale/src/scale.cpp | 32 +++++++++++++------------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/plugins/scale/src/privates.h b/plugins/scale/src/privates.h index 5f3ce6079..efa685a20 100644 --- a/plugins/scale/src/privates.h +++ b/plugins/scale/src/privates.h @@ -91,6 +91,7 @@ class PrivateScaleScreen : bool ensureDndRedirectWindow (); bool selectWindowAt (int x, int y, bool moveInputFocus); + bool selectWindowAt (int x, int y); void moveFocusWindow (int dx, int dy); diff --git a/plugins/scale/src/scale.cpp b/plugins/scale/src/scale.cpp index d65c05ee2..18c3854d1 100644 --- a/plugins/scale/src/scale.cpp +++ b/plugins/scale/src/scale.cpp @@ -933,9 +933,7 @@ PrivateScaleScreen::donePaint () state = ScaleScreen::Wait; // When the animation is completed, select the window under mouse - CompOption *o = screen->getOption ("click_to_focus"); - bool focus = (o && !o->value ().b ()); - selectWindowAt (pointerX, pointerY, focus); + selectWindowAt (pointerX, pointerY); } } } @@ -1392,6 +1390,16 @@ PrivateScaleScreen::selectWindowAt (int x, return false; } +bool +PrivateScaleScreen::selectWindowAt (int x, + int y) +{ + CompOption *o = screen->getOption ("click_to_focus"); + bool focus = (o && !o->value ().b ()); + + return selectWindowAt (x, y, focus); +} + void PrivateScaleScreen::moveFocusWindow (int dx, int dy) @@ -1611,15 +1619,7 @@ PrivateScaleScreen::handleEvent (XEvent *event) grabIndex && state != ScaleScreen::In) { - bool focus = false; - CompOption *o = screen->getOption ("click_to_focus"); - - if (o && !o->value ().b ()) - focus = true; - - selectWindowAt (event->xmotion.x_root, - event->xmotion.y_root, - focus); + selectWindowAt (event->xmotion.x_root, event->xmotion.y_root); } break; case DestroyNotify: @@ -1642,12 +1642,6 @@ PrivateScaleScreen::handleEvent (XEvent *event) w = screen->findWindow (event->xclient.window); if (w) { - bool focus = false; - CompOption *o = screen->getOption ("click_to_focus"); - - if (o && !o->value ().b ()) - focus = true; - if (w->id () == dndTarget) sendDndStatusMessage (event->xclient.data.l[0]); @@ -1675,7 +1669,7 @@ PrivateScaleScreen::handleEvent (XEvent *event) hover.start (time, (float) time * 1.2); } - selectWindowAt (pointerX, pointerY, focus); + selectWindowAt (pointerX, pointerY); } else { -- GitLab From 93b704572d4685451ecac5689c1faf6035d68849 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 7 Sep 2012 08:30:48 +0800 Subject: [PATCH 09/39] Fix copyrights in the newer files --- gtk/window-decorator/gwd-cairo-window-decoration-util.c | 3 +-- gtk/window-decorator/gwd-cairo-window-decoration-util.h | 3 +-- gtk/window-decorator/gwd-metacity-window-decoration-util.c | 3 +-- gtk/window-decorator/gwd-metacity-window-decoration-util.h | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gtk/window-decorator/gwd-cairo-window-decoration-util.c b/gtk/window-decorator/gwd-cairo-window-decoration-util.c index c0614f510..c135d1b19 100644 --- a/gtk/window-decorator/gwd-cairo-window-decoration-util.c +++ b/gtk/window-decorator/gwd-cairo-window-decoration-util.c @@ -1,5 +1,5 @@ /* - * Copyright © 2010 Canonical Ltd + * 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 @@ -17,7 +17,6 @@ * * Authored By: Sam Spilsbury */ - #include #include "gwd-cairo-window-decoration-util.h" diff --git a/gtk/window-decorator/gwd-cairo-window-decoration-util.h b/gtk/window-decorator/gwd-cairo-window-decoration-util.h index 854047480..42af2f9de 100644 --- a/gtk/window-decorator/gwd-cairo-window-decoration-util.h +++ b/gtk/window-decorator/gwd-cairo-window-decoration-util.h @@ -1,5 +1,5 @@ /* - * Copyright © 2010 Canonical Ltd + * 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 @@ -17,7 +17,6 @@ * * Authored By: Sam Spilsbury */ - #ifndef _GWD_CAIRO_WINDOW_DECORATION_UTIL_H #define _GWD_CAIRO_WINDOW_DECORATION_UTIL_H diff --git a/gtk/window-decorator/gwd-metacity-window-decoration-util.c b/gtk/window-decorator/gwd-metacity-window-decoration-util.c index ab6bcafe4..dc8851d18 100644 --- a/gtk/window-decorator/gwd-metacity-window-decoration-util.c +++ b/gtk/window-decorator/gwd-metacity-window-decoration-util.c @@ -1,5 +1,5 @@ /* - * Copyright © 2010 Canonical Ltd + * 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 @@ -17,7 +17,6 @@ * * Authored By: Sam Spilsbury */ - #include #include #include "gwd-metacity-window-decoration-util.h" diff --git a/gtk/window-decorator/gwd-metacity-window-decoration-util.h b/gtk/window-decorator/gwd-metacity-window-decoration-util.h index 3d59554a5..9a62833eb 100644 --- a/gtk/window-decorator/gwd-metacity-window-decoration-util.h +++ b/gtk/window-decorator/gwd-metacity-window-decoration-util.h @@ -1,5 +1,5 @@ /* - * Copyright © 2010 Canonical Ltd + * 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 @@ -17,7 +17,6 @@ * * Authored By: Sam Spilsbury */ - #ifndef _GWD_METACITY_WINDOW_DECORATION_UTIL_H #define _GWD_METACITY_WINDOW_DECORATION_UTIL_H -- GitLab From f24bbfdabbe3b331039347a3619f3984d71a73e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Sep 2012 11:25:29 +0300 Subject: [PATCH 10/39] Migrate profile independent keys separately --- .../compiz-profile-Default.convert | 60 ------------------- .../compiz-profile-active-Default.convert | 60 ------------------- .../compiz-profile-independent-keys.convert | 59 ++++++++++++++++++ .../03_migrate_profile_independent.py | 44 ++++++++++++++ 4 files changed, 103 insertions(+), 120 deletions(-) create mode 100644 postinst/convert-files/compiz-profile-independent-keys.convert create mode 100755 postinst/migration-scripts/03_migrate_profile_independent.py diff --git a/postinst/convert-files/compiz-profile-Default.convert b/postinst/convert-files/compiz-profile-Default.convert index 68ee37206..dfffe5eaf 100644 --- a/postinst/convert-files/compiz-profile-Default.convert +++ b/postinst/convert-files/compiz-profile-Default.convert @@ -108,63 +108,3 @@ top-edge-threshold = /apps/compizconfig-1/profiles/Default/plugins/grid/screen0/ top-left-corner-action = /apps/compizconfig-1/profiles/Default/plugins/grid/screen0/options/top_left_corner_action top-right-corner-action = /apps/compizconfig-1/profiles/Default/plugins/grid/screen0/options/top_right_corner_action - -[org.compiz.integrated] -run-command-terminal = /apps/metacity/global_keybindings/run_command_terminal -run-command-screenshot = /apps/metacity/global_keybindings/run_command_screenshot -run-command-window-screenshot = /apps/metacity/global_keybindings/run_command_window_screenshot -panel-run-dialog = /apps/metacity/global_keybindings/panel_run_dialog -panel-main-menu = /apps/metacity/global_keybindings/panel_main_menu - - -[org.gnome.desktop.wm.keybindings] -move-to-workspace-1 = /apps/metacity/window_keybindings/move_to_workspace_1 -move-to-workspace-2 = /apps/metacity/window_keybindings/move_to_workspace_2 -move-to-workspace-3 = /apps/metacity/window_keybindings/move_to_workspace_3 -move-to-workspace-4 = /apps/metacity/window_keybindings/move_to_workspace_4 -move-to-workspace-5 = /apps/metacity/window_keybindings/move_to_workspace_5 -move-to-workspace-6 = /apps/metacity/window_keybindings/move_to_workspace_6 -move-to-workspace-7 = /apps/metacity/window_keybindings/move_to_workspace_7 -move-to-workspace-8 = /apps/metacity/window_keybindings/move_to_workspace_8 -move-to-workspace-9 = /apps/metacity/window_keybindings/move_to_workspace_9 -move-to-workspace-10 = /apps/metacity/window_keybindings/move_to_workspace_10 -move-to-workspace-11 = /apps/metacity/window_keybindings/move_to_workspace_11 -move-to-workspace-12 = /apps/metacity/window_keybindings/move_to_workspace_12 -move-to-workspace-left = /apps/metacity/window_keybindings/move_to_workspace_left -move-to-workspace-right = /apps/metacity/window_keybindings/move_to_workspace_right -move-to-workspace-up = /apps/metacity/window_keybindings/move_to_workspace_up -move-to-workspace-down = /apps/metacity/window_keybindings/move_to_workspace_down -switch-windows = /apps/metacity/global_keybindings/switch_windows -switch-group = /apps/metacity/global_keybindings/switch_group -show-desktop = /apps/metacity/global_keybindings/show_desktop -switch-to-workspace-1 = /apps/metacity/global_keybindings/switch_to_workspace_1 -switch-to-workspace-2 = /apps/metacity/global_keybindings/switch_to_workspace_2 -switch-to-workspace-3 = /apps/metacity/global_keybindings/switch_to_workspace_3 -switch-to-workspace-4 = /apps/metacity/global_keybindings/switch_to_workspace_4 -switch-to-workspace-5 = /apps/metacity/global_keybindings/switch_to_workspace_5 -switch-to-workspace-6 = /apps/metacity/global_keybindings/switch_to_workspace_6 -switch-to-workspace-7 = /apps/metacity/global_keybindings/switch_to_workspace_7 -switch-to-workspace-8 = /apps/metacity/global_keybindings/switch_to_workspace_8 -switch-to-workspace-9 = /apps/metacity/global_keybindings/switch_to_workspace_9 -switch-to-workspace-10 = /apps/metacity/global_keybindings/switch_to_workspace_10 -switch-to-workspace-11 = /apps/metacity/global_keybindings/switch_to_workspace_11 -switch-to-workspace-12 = /apps/metacity/global_keybindings/switch_to_workspace_12 -switch-to-workspace-left = /apps/metacity/global_keybindings/switch_to_workspace_left -switch-to-workspace-right = /apps/metacity/global_keybindings/switch_to_workspace_right -switch-to-workspace-up = /apps/metacity/global_keybindings/switch_to_workspace_up -switch-to-workspace-down = /apps/metacity/global_keybindings/switch_to_workspace_down -activate-window-menu = /apps/metacity/window_keybindings/activate_window_menu -toggle-fullscreen = /apps/metacity/window_keybindings/toggle_fullscreen -toggle-maximized = /apps/metacity/window_keybindings/toggle_maximized -maximize = /apps/metacity/window_keybindings/maximize -unmaximize = /apps/metacity/window_keybindings/unmaximize -toggle-shaded = /apps/metacity/window_keybindings/toggle_shaded -close = /apps/metacity/window_keybindings/close -minimize = /apps/metacity/window_keybindings/minimize -begin-move = /apps/metacity/window_keybindings/begin_move -begin-resize = /apps/metacity/window_keybindings/begin_resize -raise = /apps/metacity/window_keybindings/raise -lower = /apps/metacity/window_keybindings/lower -maximize-vertically = /apps/metacity/window_keybindings/maximize_vertically -maximize-horizontally = /apps/metacity/window_keybindings/maximize_horizontally - diff --git a/postinst/convert-files/compiz-profile-active-Default.convert b/postinst/convert-files/compiz-profile-active-Default.convert index 0a8abb768..b99637b5e 100644 --- a/postinst/convert-files/compiz-profile-active-Default.convert +++ b/postinst/convert-files/compiz-profile-active-Default.convert @@ -108,63 +108,3 @@ top-edge-threshold = /apps/compiz-1/plugins/grid/screen0/options/top_edge_thresh top-left-corner-action = /apps/compiz-1/plugins/grid/screen0/options/top_left_corner_action top-right-corner-action = /apps/compiz-1/plugins/grid/screen0/options/top_right_corner_action - -[org.compiz.integrated] -run-command-terminal = /apps/metacity/global_keybindings/run_command_terminal -run-command-screenshot = /apps/metacity/global_keybindings/run_command_screenshot -run-command-window-screenshot = /apps/metacity/global_keybindings/run_command_window_screenshot -panel-run-dialog = /apps/metacity/global_keybindings/panel_run_dialog -panel-main-menu = /apps/metacity/global_keybindings/panel_main_menu - - -[org.gnome.desktop.wm.keybindings] -move-to-workspace-1 = /apps/metacity/window_keybindings/move_to_workspace_1 -move-to-workspace-2 = /apps/metacity/window_keybindings/move_to_workspace_2 -move-to-workspace-3 = /apps/metacity/window_keybindings/move_to_workspace_3 -move-to-workspace-4 = /apps/metacity/window_keybindings/move_to_workspace_4 -move-to-workspace-5 = /apps/metacity/window_keybindings/move_to_workspace_5 -move-to-workspace-6 = /apps/metacity/window_keybindings/move_to_workspace_6 -move-to-workspace-7 = /apps/metacity/window_keybindings/move_to_workspace_7 -move-to-workspace-8 = /apps/metacity/window_keybindings/move_to_workspace_8 -move-to-workspace-9 = /apps/metacity/window_keybindings/move_to_workspace_9 -move-to-workspace-10 = /apps/metacity/window_keybindings/move_to_workspace_10 -move-to-workspace-11 = /apps/metacity/window_keybindings/move_to_workspace_11 -move-to-workspace-12 = /apps/metacity/window_keybindings/move_to_workspace_12 -move-to-workspace-left = /apps/metacity/window_keybindings/move_to_workspace_left -move-to-workspace-right = /apps/metacity/window_keybindings/move_to_workspace_right -move-to-workspace-up = /apps/metacity/window_keybindings/move_to_workspace_up -move-to-workspace-down = /apps/metacity/window_keybindings/move_to_workspace_down -switch-windows = /apps/metacity/global_keybindings/switch_windows -switch-group = /apps/metacity/global_keybindings/switch_group -show-desktop = /apps/metacity/global_keybindings/show_desktop -switch-to-workspace-1 = /apps/metacity/global_keybindings/switch_to_workspace_1 -switch-to-workspace-2 = /apps/metacity/global_keybindings/switch_to_workspace_2 -switch-to-workspace-3 = /apps/metacity/global_keybindings/switch_to_workspace_3 -switch-to-workspace-4 = /apps/metacity/global_keybindings/switch_to_workspace_4 -switch-to-workspace-5 = /apps/metacity/global_keybindings/switch_to_workspace_5 -switch-to-workspace-6 = /apps/metacity/global_keybindings/switch_to_workspace_6 -switch-to-workspace-7 = /apps/metacity/global_keybindings/switch_to_workspace_7 -switch-to-workspace-8 = /apps/metacity/global_keybindings/switch_to_workspace_8 -switch-to-workspace-9 = /apps/metacity/global_keybindings/switch_to_workspace_9 -switch-to-workspace-10 = /apps/metacity/global_keybindings/switch_to_workspace_10 -switch-to-workspace-11 = /apps/metacity/global_keybindings/switch_to_workspace_11 -switch-to-workspace-12 = /apps/metacity/global_keybindings/switch_to_workspace_12 -switch-to-workspace-left = /apps/metacity/global_keybindings/switch_to_workspace_left -switch-to-workspace-right = /apps/metacity/global_keybindings/switch_to_workspace_right -switch-to-workspace-up = /apps/metacity/global_keybindings/switch_to_workspace_up -switch-to-workspace-down = /apps/metacity/global_keybindings/switch_to_workspace_down -activate-window-menu = /apps/metacity/window_keybindings/activate_window_menu -toggle-fullscreen = /apps/metacity/window_keybindings/toggle_fullscreen -toggle-maximized = /apps/metacity/window_keybindings/toggle_maximized -maximize = /apps/metacity/window_keybindings/maximize -unmaximize = /apps/metacity/window_keybindings/unmaximize -toggle-shaded = /apps/metacity/window_keybindings/toggle_shaded -close = /apps/metacity/window_keybindings/close -minimize = /apps/metacity/window_keybindings/minimize -begin-move = /apps/metacity/window_keybindings/begin_move -begin-resize = /apps/metacity/window_keybindings/begin_resize -raise = /apps/metacity/window_keybindings/raise -lower = /apps/metacity/window_keybindings/lower -maximize-vertically = /apps/metacity/window_keybindings/maximize_vertically -maximize-horizontally = /apps/metacity/window_keybindings/maximize_horizontally - diff --git a/postinst/convert-files/compiz-profile-independent-keys.convert b/postinst/convert-files/compiz-profile-independent-keys.convert new file mode 100644 index 000000000..b27758b7e --- /dev/null +++ b/postinst/convert-files/compiz-profile-independent-keys.convert @@ -0,0 +1,59 @@ +[org.compiz.integrated] +run-command-terminal = /apps/metacity/global_keybindings/run_command_terminal +run-command-screenshot = /apps/metacity/global_keybindings/run_command_screenshot +run-command-window-screenshot = /apps/metacity/global_keybindings/run_command_window_screenshot +panel-run-dialog = /apps/metacity/global_keybindings/panel_run_dialog +panel-main-menu = /apps/metacity/global_keybindings/panel_main_menu + + +[org.gnome.desktop.wm.keybindings] +move-to-workspace-1 = /apps/metacity/window_keybindings/move_to_workspace_1 +move-to-workspace-2 = /apps/metacity/window_keybindings/move_to_workspace_2 +move-to-workspace-3 = /apps/metacity/window_keybindings/move_to_workspace_3 +move-to-workspace-4 = /apps/metacity/window_keybindings/move_to_workspace_4 +move-to-workspace-5 = /apps/metacity/window_keybindings/move_to_workspace_5 +move-to-workspace-6 = /apps/metacity/window_keybindings/move_to_workspace_6 +move-to-workspace-7 = /apps/metacity/window_keybindings/move_to_workspace_7 +move-to-workspace-8 = /apps/metacity/window_keybindings/move_to_workspace_8 +move-to-workspace-9 = /apps/metacity/window_keybindings/move_to_workspace_9 +move-to-workspace-10 = /apps/metacity/window_keybindings/move_to_workspace_10 +move-to-workspace-11 = /apps/metacity/window_keybindings/move_to_workspace_11 +move-to-workspace-12 = /apps/metacity/window_keybindings/move_to_workspace_12 +move-to-workspace-left = /apps/metacity/window_keybindings/move_to_workspace_left +move-to-workspace-right = /apps/metacity/window_keybindings/move_to_workspace_right +move-to-workspace-up = /apps/metacity/window_keybindings/move_to_workspace_up +move-to-workspace-down = /apps/metacity/window_keybindings/move_to_workspace_down +switch-windows = /apps/metacity/global_keybindings/switch_windows +switch-group = /apps/metacity/global_keybindings/switch_group +show-desktop = /apps/metacity/global_keybindings/show_desktop +switch-to-workspace-1 = /apps/metacity/global_keybindings/switch_to_workspace_1 +switch-to-workspace-2 = /apps/metacity/global_keybindings/switch_to_workspace_2 +switch-to-workspace-3 = /apps/metacity/global_keybindings/switch_to_workspace_3 +switch-to-workspace-4 = /apps/metacity/global_keybindings/switch_to_workspace_4 +switch-to-workspace-5 = /apps/metacity/global_keybindings/switch_to_workspace_5 +switch-to-workspace-6 = /apps/metacity/global_keybindings/switch_to_workspace_6 +switch-to-workspace-7 = /apps/metacity/global_keybindings/switch_to_workspace_7 +switch-to-workspace-8 = /apps/metacity/global_keybindings/switch_to_workspace_8 +switch-to-workspace-9 = /apps/metacity/global_keybindings/switch_to_workspace_9 +switch-to-workspace-10 = /apps/metacity/global_keybindings/switch_to_workspace_10 +switch-to-workspace-11 = /apps/metacity/global_keybindings/switch_to_workspace_11 +switch-to-workspace-12 = /apps/metacity/global_keybindings/switch_to_workspace_12 +switch-to-workspace-left = /apps/metacity/global_keybindings/switch_to_workspace_left +switch-to-workspace-right = /apps/metacity/global_keybindings/switch_to_workspace_right +switch-to-workspace-up = /apps/metacity/global_keybindings/switch_to_workspace_up +switch-to-workspace-down = /apps/metacity/global_keybindings/switch_to_workspace_down +activate-window-menu = /apps/metacity/window_keybindings/activate_window_menu +toggle-fullscreen = /apps/metacity/window_keybindings/toggle_fullscreen +toggle-maximized = /apps/metacity/window_keybindings/toggle_maximized +maximize = /apps/metacity/window_keybindings/maximize +unmaximize = /apps/metacity/window_keybindings/unmaximize +toggle-shaded = /apps/metacity/window_keybindings/toggle_shaded +close = /apps/metacity/window_keybindings/close +minimize = /apps/metacity/window_keybindings/minimize +begin-move = /apps/metacity/window_keybindings/begin_move +begin-resize = /apps/metacity/window_keybindings/begin_resize +raise = /apps/metacity/window_keybindings/raise +lower = /apps/metacity/window_keybindings/lower +maximize-vertically = /apps/metacity/window_keybindings/maximize_vertically +maximize-horizontally = /apps/metacity/window_keybindings/maximize_horizontally + diff --git a/postinst/migration-scripts/03_migrate_profile_independent.py b/postinst/migration-scripts/03_migrate_profile_independent.py new file mode 100755 index 000000000..6a20eadf4 --- /dev/null +++ b/postinst/migration-scripts/03_migrate_profile_independent.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright (C) 2012 Canonical +# +# Authors: +# Łukasz 'sil2100' Zemczak +# Didier Roche +# +# 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; version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUTa +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import gconf +import glib +import subprocess +import os.path + +# this should point to the directory where all the .convert files are stored +CONVERT_PATH = "/usr/lib/compiz/migration/" + +def migrate_file(convert_file): + subprocess.Popen(["gsettings-data-convert", "--file={}{}".format(CONVERT_PATH, convert_file)]).communicate() + +def migrate_gconf_to_gsettings(): + client = gconf.client_get_default() + + if not client: + print "WARNING: no gconf client found. No transitionning will be done" + return + + print "Will migrate profile independent keys" + migrate_file('compiz-profile-independent-keys.convert') + +if __name__ == '__main__': + migrate_gconf_to_gsettings () -- GitLab From 53aa6510c48200244b1c41b796096447033f2400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 7 Sep 2012 19:38:35 +0200 Subject: [PATCH 11/39] Scale: increase the scale ABI --- plugins/scale/include/scale/scale.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scale/include/scale/scale.h b/plugins/scale/include/scale/scale.h index 235ec5de0..46ace72fc 100644 --- a/plugins/scale/include/scale/scale.h +++ b/plugins/scale/include/scale/scale.h @@ -31,7 +31,7 @@ #include #include -#define COMPIZ_SCALE_ABI 2 +#define COMPIZ_SCALE_ABI 3 class ScaleScreen; class PrivateScaleScreen; -- GitLab From b6fd7a24fcbb568e4895467e9d328e3d18a79064 Mon Sep 17 00:00:00 2001 From: MC Return Date: Sat, 8 Sep 2012 17:48:14 +0200 Subject: [PATCH 12/39] The unsigned int nFile can never be smaller than 0 (changed "if (nFile <= 0)" to "if (!nFile)") --- compizconfig/libcompizconfig/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compizconfig/libcompizconfig/src/main.c b/compizconfig/libcompizconfig/src/main.c index e6ff0de82..ea033ca66 100644 --- a/compizconfig/libcompizconfig/src/main.c +++ b/compizconfig/libcompizconfig/src/main.c @@ -4730,7 +4730,7 @@ ccsGetUpgradeFilesForProcessing (const char *upgradePath, struct dirent **nameList = NULL; unsigned int nFile = scandir (upgradePath, &nameList, upgradeNameFilter, alphasort); - if (nFile <= 0) + if (!nFile) return 0; *passedNameList = nameList; -- GitLab From ab312065ba67ba7d5e99728cc29f5ad0138ecad5 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 10 Sep 2012 15:49:26 +0800 Subject: [PATCH 13/39] Regenerate the local settings recompilation rule when cmake is re-run and ensure that we pull in all the dependencies --- CMakeLists.txt | 3 ++ cmake/CompizGSettings.cmake | 84 ++++++++++++++++++++++++++++--------- postinst/CMakeLists.txt | 6 ++- 3 files changed, 73 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 000252c2d..fd9f83664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,9 @@ set (compiz_metadatadir ${datadir}/compiz) set (COMPIZ_I18N_DIR ${CMAKE_SOURCE_DIR}/po) # Don't allow subdirectories to add schema recompile rule +set_property (GLOBAL + PROPERTY GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE + TRUE) set_property (GLOBAL PROPERTY COMPIZ_INHIBIT_ADD_INSTALL_RECOMPILE_RULE TRUE) diff --git a/cmake/CompizGSettings.cmake b/cmake/CompizGSettings.cmake index 162486b4d..13907218f 100644 --- a/cmake/CompizGSettings.cmake +++ b/cmake/CompizGSettings.cmake @@ -106,37 +106,83 @@ function (compiz_install_gsettings_schema _src _dst) USE_GSETTINGS) endfunction () -function (add_gsettings_schema_to_recompilation_list _target_name_for_schema) +function (add_gsettings_local_recompilation_rule _schemas) - find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) - mark_as_advanced (GLIB_COMPILE_SCHEMAS) + get_property (GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE_SET + GLOBAL + PROPERTY GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE + SET) + + if (GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE_SET) + get_property (GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE + GLOBAL + PROPERTY GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE) + else (GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE_SET) + set (GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE FALSE) + endif (GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE_SET) get_property (GSETTINGS_LOCAL_COMPILE_TARGET_SET GLOBAL PROPERTY GSETTINGS_LOCAL_COMPILE_TARGET_SET SET) - if (NOT GSETTINGS_LOCAL_COMPILE_TARGET_SET AND - GLIB_COMPILE_SCHEMAS) + if (NOT GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE AND + NOT GSETTINGS_LOCAL_COMPILE_TARGET_SET) - add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/gschemas.compiled - COMMAND ${GLIB_COMPILE_SCHEMAS} --targetdir=${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/ - ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/ - COMMENT "Recompiling GSettings schemas locally" - ) + find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) + mark_as_advanced (GLIB_COMPILE_SCHEMAS) + + if (GLIB_COMPILE_SCHEMAS) + + set (_compiled_gschemas ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/gschemas.compiled) + + # Invalidate the rule + if (EXISTS ${_compiled_gschemas}) + execute_process (COMMAND rm ${_compiled_gschemas}) + endif (EXISTS ${_compiled_gschemas}) + + add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/gschemas.compiled + COMMAND ${GLIB_COMPILE_SCHEMAS} --targetdir=${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/ + ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/ + COMMENT "Recompiling GSettings schemas locally" + DEPENDS ${${_schemas}} + ) + + add_custom_target (compiz_gsettings_compile_local ALL + DEPENDS ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/gschemas.compiled) - add_custom_target (compiz_gsettings_compile_local ALL - DEPENDS ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/gschemas.compiled) + set_property (GLOBAL + PROPERTY GSETTINGS_LOCAL_COMPILE_TARGET_SET + TRUE) - set_property (GLOBAL - PROPERTY GSETTINGS_LOCAL_COMPILE_TARGET_SET - TRUE) + endif (GLIB_COMPILE_SCHEMAS) - endif (NOT GSETTINGS_LOCAL_COMPILE_TARGET_SET AND - GLIB_COMPILE_SCHEMAS) + endif (NOT GSETTINGS_LOCAL_COMPILE_INHIBIT_RULE AND + NOT GSETTINGS_LOCAL_COMPILE_TARGET_SET) + +endfunction () + +function (add_all_gsettings_schemas_to_local_recompilation_rule) + + get_property (GSETTINGS_LOCAL_COMPILE_SCHEMAS + GLOBAL + PROPERTY GSETTINGS_LOCAL_COMPILE_SCHEMAS) + + # Deferencing it appears to just give it the first schema, that's not what + # we really want, so just pass the reference and double-dereference + # internally + add_gsettings_local_recompilation_rule (GSETTINGS_LOCAL_COMPILE_SCHEMAS) + +endfunction () + +function (add_gsettings_schema_to_recompilation_list _schema_file_name) + + set_property (GLOBAL + APPEND + PROPERTY GSETTINGS_LOCAL_COMPILE_SCHEMAS + "${_schema_file_name}") - add_dependencies (compiz_gsettings_compile_local - ${_target_name_for_schema}) + add_all_gsettings_schemas_to_local_recompilation_rule () endfunction () diff --git a/postinst/CMakeLists.txt b/postinst/CMakeLists.txt index bf884ef70..e79f934e5 100644 --- a/postinst/CMakeLists.txt +++ b/postinst/CMakeLists.txt @@ -1,10 +1,14 @@ -# Don't allow subdirectories to add schema recompile rule +# Allow setting the recompile rule again set_property (GLOBAL PROPERTY COMPIZ_INHIBIT_ADD_INSTALL_RECOMPILE_RULE FALSE) +set_property (GLOBAL + 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) -- GitLab From c3bda2cd5325d5fcb878f3b9ca42f7155efa3b20 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Mon, 10 Sep 2012 16:49:23 +0800 Subject: [PATCH 14/39] Bump version to 0.9.8.3 until a candidate for 0.9.8.4 is ready. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3e4f21925..b295667ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.8.2 +0.9.8.3 -- GitLab From 79b2970e67ac10608e073da9e71effac25a97ed9 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 10 Sep 2012 17:05:29 +0800 Subject: [PATCH 15/39] Don't map the style windows --- gtk/window-decorator/frames.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gtk/window-decorator/frames.c b/gtk/window-decorator/frames.c index 84db7972f..9d18797df 100644 --- a/gtk/window-decorator/frames.c +++ b/gtk/window-decorator/frames.c @@ -232,7 +232,6 @@ decor_frame_new (const gchar *type) gtk_widget_set_size_request (frame->style_window_rgba, 0, 0); gtk_window_move (GTK_WINDOW (frame->style_window_rgba), -100, -100); - gtk_widget_show_all (frame->style_window_rgba); frame->pango_context = gtk_widget_create_pango_context (frame->style_window_rgba); @@ -250,7 +249,6 @@ decor_frame_new (const gchar *type) gtk_widget_set_size_request (frame->style_window_rgb, 0, 0); gtk_window_move (GTK_WINDOW (frame->style_window_rgb), -100, -100); - gtk_widget_show_all (frame->style_window_rgb); g_signal_connect_data (frame->style_window_rgb, "style-set", G_CALLBACK (style_changed), -- GitLab From 487126a9e294cd22caed3f78f9330edfd522abf8 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 10 Sep 2012 17:19:31 +0800 Subject: [PATCH 16/39] attach-modal-dialogs comes from the mutter schema not the compiz one --- gtk/window-decorator/gwd-settings-storage-gsettings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/window-decorator/gwd-settings-storage-gsettings.c b/gtk/window-decorator/gwd-settings-storage-gsettings.c index 5e14cd2e4..20d285054 100644 --- a/gtk/window-decorator/gwd-settings-storage-gsettings.c +++ b/gtk/window-decorator/gwd-settings-storage-gsettings.c @@ -125,7 +125,7 @@ gwd_settings_storage_gsettings_update_attach_modal_dialogs (GWDSettingsStorage * GWDSettingsStorageGSettings *storage = GWD_SETTINGS_STORAGE_GSETTINGS (settings); GWDSettingsStorageGSettingsPrivate *priv = GET_PRIVATE (storage); - if (!priv->gwd) + if (!priv->mutter) return FALSE; return gwd_settings_writable_attach_modal_dialogs_changed (priv->writable, -- GitLab From 09efede2cdd8e247c6b827785b448e82ba37047f Mon Sep 17 00:00:00 2001 From: Albert Astals Date: Mon, 10 Sep 2012 17:17:57 +0200 Subject: [PATCH 17/39] Initialize the XWindowChanges in CompScreenImpl::moveViewport --- src/privatewindow.h | 1 + src/screen.cpp | 2 +- src/window.cpp | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/privatewindow.h b/src/privatewindow.h index e20b3b75b..8553c9c98 100644 --- a/src/privatewindow.h +++ b/src/privatewindow.h @@ -35,6 +35,7 @@ #include +#define XWINDOWCHANGES_INIT {0, 0, 0, 0, 0, None, 0} namespace compiz {namespace X11 { diff --git a/src/screen.cpp b/src/screen.cpp index fc0b9a88e..2cc636941 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -3929,7 +3929,7 @@ CompScreenImpl::moveViewport (int tx, int ty, bool sync) { CompWindow* const w(*i); unsigned int valueMask = CWX | CWY; - XWindowChanges xwc; + XWindowChanges xwc= XWINDOWCHANGES_INIT; if (w->onAllViewports ()) continue; diff --git a/src/window.cpp b/src/window.cpp index 45fde9305..b01fa6864 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -47,8 +47,6 @@ #include -#define XWINDOWCHANGES_INIT {0, 0, 0, 0, 0, None, 0} - PluginClassStorage::Indices windowPluginClassIndices (0); unsigned int -- GitLab From d2e2a53ad442bbf4f46d815202ed9bc26f774e33 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 11 Sep 2012 11:12:14 +0300 Subject: [PATCH 18/39] return -> sys.exit(1) --- postinst/migration-scripts/03_migrate_profile_independent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postinst/migration-scripts/03_migrate_profile_independent.py b/postinst/migration-scripts/03_migrate_profile_independent.py index 6a20eadf4..7e0b14c47 100755 --- a/postinst/migration-scripts/03_migrate_profile_independent.py +++ b/postinst/migration-scripts/03_migrate_profile_independent.py @@ -35,7 +35,7 @@ def migrate_gconf_to_gsettings(): if not client: print "WARNING: no gconf client found. No transitionning will be done" - return + sys.exit(1) print "Will migrate profile independent keys" migrate_file('compiz-profile-independent-keys.convert') -- GitLab From c5cc20ccaafc4b49f0ec0b79a67ead1b89e68679 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 11 Sep 2012 18:43:06 +0800 Subject: [PATCH 19/39] Workaround SubBuffer performance regression (LP: #1037411), which is actually Mesa bug #54763. --- plugins/opengl/include/opengl/doublebuffer.h | 3 ++- plugins/opengl/src/doublebuffer/src/double-buffer.cpp | 3 ++- plugins/opengl/src/screen.cpp | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/opengl/include/opengl/doublebuffer.h b/plugins/opengl/include/opengl/doublebuffer.h index d1cdc572f..964648fa3 100644 --- a/plugins/opengl/include/opengl/doublebuffer.h +++ b/plugins/opengl/include/opengl/doublebuffer.h @@ -23,7 +23,8 @@ class DoubleBuffer typedef enum { VSYNC, - PERSISTENT_BACK_BUFFER, + HAVE_PERSISTENT_BACK_BUFFER, + NEED_PERSISTENT_BACK_BUFFER, _NSETTINGS } Setting; diff --git a/plugins/opengl/src/doublebuffer/src/double-buffer.cpp b/plugins/opengl/src/doublebuffer/src/double-buffer.cpp index f8d16fba4..e72d85869 100644 --- a/plugins/opengl/src/doublebuffer/src/double-buffer.cpp +++ b/plugins/opengl/src/doublebuffer/src/double-buffer.cpp @@ -41,7 +41,8 @@ namespace opengl DoubleBuffer::DoubleBuffer () { setting[VSYNC] = true; - setting[PERSISTENT_BACK_BUFFER] = false; + setting[HAVE_PERSISTENT_BACK_BUFFER] = false; + setting[NEED_PERSISTENT_BACK_BUFFER] = false; } DoubleBuffer::~DoubleBuffer () diff --git a/plugins/opengl/src/screen.cpp b/plugins/opengl/src/screen.cpp index c3300b646..13e2b29fe 100644 --- a/plugins/opengl/src/screen.cpp +++ b/plugins/opengl/src/screen.cpp @@ -1762,7 +1762,8 @@ GLXDoubleBuffer::swap () const glXSwapBuffers (mDpy, mOutput); - if (!setting[PERSISTENT_BACK_BUFFER]) + if (setting[NEED_PERSISTENT_BACK_BUFFER] && + !setting[HAVE_PERSISTENT_BACK_BUFFER]) copyFrontToBack (); } @@ -2023,13 +2024,15 @@ PrivateGLScreen::paintOutputs (CompOutput::ptrList &outputs, gScreen->glPaintCompositedOutput (screen->region (), scratchFbo, mask); } + bool alwaysSwap = optionGetAlwaysSwapBuffers (); bool fullscreen = useFbo || - optionGetAlwaysSwapBuffers () || + alwaysSwap || ((mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) && commonFrontbuffer); doubleBuffer.set (DoubleBuffer::VSYNC, optionGetSyncToVblank ()); - doubleBuffer.set (DoubleBuffer::PERSISTENT_BACK_BUFFER, useFbo); + doubleBuffer.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, useFbo); + doubleBuffer.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, alwaysSwap); doubleBuffer.render (tmpRegion, fullscreen); lastMask = mask; -- GitLab From e270577672a196d6cbd96c84a8865810fca28ff9 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 12 Sep 2012 11:55:21 +0800 Subject: [PATCH 20/39] Add tests --- plugins/opengl/include/opengl/doublebuffer.h | 1 + .../src/doublebuffer/src/double-buffer.cpp | 7 +++++ .../tests/test-opengl-double-buffer.cpp | 28 +++++++++++++++++++ plugins/opengl/src/privates.h | 1 + plugins/opengl/src/screen.cpp | 8 ++---- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/plugins/opengl/include/opengl/doublebuffer.h b/plugins/opengl/include/opengl/doublebuffer.h index 964648fa3..d0e94525e 100644 --- a/plugins/opengl/include/opengl/doublebuffer.h +++ b/plugins/opengl/include/opengl/doublebuffer.h @@ -19,6 +19,7 @@ class DoubleBuffer virtual void blit (const CompRegion ®ion) const = 0; virtual bool fallbackBlitAvailable () const = 0; virtual void fallbackBlit (const CompRegion ®ion) const = 0; + virtual void copyFrontToBack () const = 0; typedef enum { diff --git a/plugins/opengl/src/doublebuffer/src/double-buffer.cpp b/plugins/opengl/src/doublebuffer/src/double-buffer.cpp index e72d85869..edb33aa90 100644 --- a/plugins/opengl/src/doublebuffer/src/double-buffer.cpp +++ b/plugins/opengl/src/doublebuffer/src/double-buffer.cpp @@ -60,7 +60,14 @@ DoubleBuffer::render (const CompRegion ®ion, bool fullscreen) { if (fullscreen) + { swap (); + if (setting[NEED_PERSISTENT_BACK_BUFFER] && + !setting[HAVE_PERSISTENT_BACK_BUFFER]) + { + copyFrontToBack (); + } + } else if (blitAvailable ()) blit (region); else if (fallbackBlitAvailable ()) diff --git a/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp b/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp index fbf2de9ae..e19431e91 100644 --- a/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp +++ b/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp @@ -18,6 +18,7 @@ class MockDoubleBuffer : MOCK_CONST_METHOD1 (blit, void (const CompRegion &)); MOCK_CONST_METHOD0 (fallbackBlitAvailable, bool ()); MOCK_CONST_METHOD1 (fallbackBlit, void (const CompRegion &)); + MOCK_CONST_METHOD0 (copyFrontToBack, void ()); }; class DoubleBufferTest : @@ -38,6 +39,7 @@ class CompizOpenGLDoubleBufferDeathTest : TEST_F(DoubleBufferTest, TestPaintedFullAlwaysSwaps) { EXPECT_CALL (db, swap ()); + EXPECT_CALL (db, copyFrontToBack ()).Times (0); db.render (blitRegion, true); } @@ -46,6 +48,32 @@ TEST_F(DoubleBufferTest, TestNoPaintedFullscreenOrFBOAlwaysBlitsSubBuffer) { EXPECT_CALL (db, blitAvailable ()).WillOnce (Return (true)); EXPECT_CALL (db, blit (_)); + EXPECT_CALL (db, copyFrontToBack ()).Times (0); + + db.render (blitRegion, false); +} + +TEST_F(DoubleBufferTest, SwapWithoutFBO) +{ + db.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, false); + db.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, true); + + EXPECT_CALL (db, swap ()); + EXPECT_CALL (db, copyFrontToBack ()).Times (1); + + db.render (blitRegion, true); + db.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, false); +} + +TEST_F(DoubleBufferTest, BlitWithoutFBO) +{ + db.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, false); + db.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, false); + + EXPECT_CALL (db, blitAvailable ()).WillRepeatedly (Return (true)); + EXPECT_CALL (db, blit (_)); + EXPECT_CALL (db, swap ()).Times (0); + EXPECT_CALL (db, copyFrontToBack ()).Times (0); db.render (blitRegion, false); } diff --git a/plugins/opengl/src/privates.h b/plugins/opengl/src/privates.h index 656c9c678..71fcec8f4 100644 --- a/plugins/opengl/src/privates.h +++ b/plugins/opengl/src/privates.h @@ -74,6 +74,7 @@ class GLXDoubleBuffer : void blit (const CompRegion ®ion) const; bool fallbackBlitAvailable () const; void fallbackBlit (const CompRegion ®ion) const; + void copyFrontToBack () const; protected: diff --git a/plugins/opengl/src/screen.cpp b/plugins/opengl/src/screen.cpp index 13e2b29fe..812e98800 100644 --- a/plugins/opengl/src/screen.cpp +++ b/plugins/opengl/src/screen.cpp @@ -1722,8 +1722,8 @@ GLDoubleBuffer::GLDoubleBuffer (Display *d, const CompSize &s) : #ifndef USE_GLES -static void -copyFrontToBack() +void +GLXDoubleBuffer::copyFrontToBack() const { int w = screen->width (); int h = screen->height (); @@ -1761,10 +1761,6 @@ GLXDoubleBuffer::swap () const GL::controlSwapVideoSync (setting[VSYNC]); glXSwapBuffers (mDpy, mOutput); - - if (setting[NEED_PERSISTENT_BACK_BUFFER] && - !setting[HAVE_PERSISTENT_BACK_BUFFER]) - copyFrontToBack (); } bool -- GitLab From b310abffa9c90352aaef3e25e866df58dc26c2ba Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 12 Sep 2012 12:01:02 +0800 Subject: [PATCH 21/39] And make sure it builds with USE_GLES --- plugins/opengl/src/privates.h | 1 + plugins/opengl/src/screen.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/plugins/opengl/src/privates.h b/plugins/opengl/src/privates.h index 71fcec8f4..67873919f 100644 --- a/plugins/opengl/src/privates.h +++ b/plugins/opengl/src/privates.h @@ -97,6 +97,7 @@ class EGLDoubleBuffer : void blit (const CompRegion ®ion) const; bool fallbackBlitAvailable () const; void fallbackBlit (const CompRegion ®ion) const; + void copyFrontToBack () const; private: diff --git a/plugins/opengl/src/screen.cpp b/plugins/opengl/src/screen.cpp index 812e98800..17c9d1e3b 100644 --- a/plugins/opengl/src/screen.cpp +++ b/plugins/opengl/src/screen.cpp @@ -1888,6 +1888,11 @@ EGLDoubleBuffer::fallbackBlit (const CompRegion ®ion) const { } +void +EGLDoubleBuffer::copyFrontToBack() const +{ +} + #endif void -- GitLab From d1c94d5e2b56a29977195d37029bb44012885141 Mon Sep 17 00:00:00 2001 From: MC Return Date: Wed, 12 Sep 2012 11:04:04 +0200 Subject: [PATCH 22/39] Changed the default placement of the benchmark window from 0,0 to 256,256 --- plugins/bench/bench.xml.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bench/bench.xml.in b/plugins/bench/bench.xml.in index dbfc0bfad..44aa7071a 100644 --- a/plugins/bench/bench.xml.in +++ b/plugins/bench/bench.xml.in @@ -50,14 +50,14 @@ -- GitLab From baf82c63a41b21eed47534b4e4cb58e83e981704 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 12 Sep 2012 18:19:47 +0800 Subject: [PATCH 23/39] Don't ever enter the subdir of a plugin that is disabled. (LP: #1049100) --- cmake/CompizCommon.cmake | 8 ++++++-- cmake/CompizPackage.cmake | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/CompizCommon.cmake b/cmake/CompizCommon.cmake index 139d0165d..8c3394d83 100644 --- a/cmake/CompizCommon.cmake +++ b/cmake/CompizCommon.cmake @@ -443,8 +443,12 @@ macro (compiz_add_plugins_in_folder folder) ) foreach (_plugin ${_plugins_in}) - get_filename_component (_plugin_dir ${_plugin} PATH) - add_subdirectory (${folder}/${_plugin_dir}) + get_filename_component (_plugin_dir ${_plugin} PATH) + string (TOUPPER ${_plugin_dir} _plugin_upper) + if (NOT COMPIZ_DISABLE_PLUGIN_${_plugin_upper}) + add_subdirectory (${folder}/${_plugin_dir}) + set (COMPIZ_ENABLED_PLUGIN_${_plugin_upper} Y CACHE INTERNAL "") + endif () endforeach () endmacro () diff --git a/cmake/CompizPackage.cmake b/cmake/CompizPackage.cmake index aae7c541b..8a34ad28c 100644 --- a/cmake/CompizPackage.cmake +++ b/cmake/CompizPackage.cmake @@ -67,7 +67,7 @@ function (compiz_print_plugin_stats _folder) string (TOUPPER ${_plugin_name} _PLUGIN) compiz_format_string (${_plugin_name} 14 _plugin_name) - if (COMPIZ_DISABLE_PLUGIN_${_PLUGIN}) + if (NOT COMPIZ_ENABLED_PLUGIN_${_PLUGIN}) compiz_color_message (" ${_plugin_name}: ${_escape}[1;34mDisabled${_escape}[0m") else () if (COMPIZ_${_PLUGIN}_BUILD) -- GitLab From 782efc9b97970e4c2ff615782f1cebbd4352d558 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 12 Sep 2012 18:45:58 +0800 Subject: [PATCH 24/39] Remove redundant line --- .../opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp b/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp index e19431e91..7160ca39e 100644 --- a/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp +++ b/plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp @@ -62,7 +62,6 @@ TEST_F(DoubleBufferTest, SwapWithoutFBO) EXPECT_CALL (db, copyFrontToBack ()).Times (1); db.render (blitRegion, true); - db.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, false); } TEST_F(DoubleBufferTest, BlitWithoutFBO) -- GitLab From 8ec4731689ceb971e438c834d5b5914dd36b9374 Mon Sep 17 00:00:00 2001 From: MC Return Date: Wed, 12 Sep 2012 13:53:12 +0200 Subject: [PATCH 25/39] Changed default placement to 100,50. --- plugins/bench/bench.xml.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bench/bench.xml.in b/plugins/bench/bench.xml.in index 44aa7071a..cc014121e 100644 --- a/plugins/bench/bench.xml.in +++ b/plugins/bench/bench.xml.in @@ -50,14 +50,14 @@ -- GitLab From dd6ba6c68c75c9a0f7335d907aa2a5801b88a1b0 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 13 Sep 2012 16:35:17 +0800 Subject: [PATCH 26/39] Avoid a NULL dereference and give a useful error message instead. (LP: #944653) --- plugins/opengl/src/screen.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/opengl/src/screen.cpp b/plugins/opengl/src/screen.cpp index 17c9d1e3b..ff294cf16 100644 --- a/plugins/opengl/src/screen.cpp +++ b/plugins/opengl/src/screen.cpp @@ -869,6 +869,16 @@ GLScreen::GLScreen (CompScreen *s) : glxExtensions = glXQueryExtensionsString (dpy, s->screenNum ()); + if (glxExtensions == NULL) + { + compLogMessage ("opengl", CompLogLevelFatal, + "glXQueryExtensionsString is NULL for screen %d", + s->screenNum ()); + screen->handleCompizEvent ("opengl", "fatal_fallback", o); + setFailed (); + return; + } + if (!strstr (glxExtensions, "GLX_SGIX_fbconfig")) { compLogMessage ("opengl", CompLogLevelFatal, -- GitLab From f8d05dd0f8b146b8bd4e413d24f481525d8a69f9 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 13 Sep 2012 18:58:13 +0800 Subject: [PATCH 27/39] Ensure window decorations always get rendered after the window, not before. This is how it was in compiz 0.9.7, and is required in order to resolve unity panel shadow bug 1045705. --- plugins/decor/src/decor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/decor/src/decor.cpp b/plugins/decor/src/decor.cpp index de8b7409e..c47db63a2 100644 --- a/plugins/decor/src/decor.cpp +++ b/plugins/decor/src/decor.cpp @@ -159,6 +159,8 @@ DecorWindow::glDraw (const GLMatrix &transform, { bool status; + status = gWindow->glDraw (transform, attrib, region, mask); + /* Don't render dock decorations (shadows) on just any old window */ if (!(window->type () & CompWindowTypeDockMask)) { @@ -198,8 +200,6 @@ DecorWindow::glDraw (const GLMatrix &transform, } } - status = gWindow->glDraw (transform, attrib, region, mask); - return status; } -- GitLab From 0da2d67e02e8833db7d417927c46057b27934e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Thu, 13 Sep 2012 17:59:37 +0200 Subject: [PATCH 28/39] It seems that with USE_GCONF disabled, the gsettings xslt files are not installed. I *think* this might help? --- xslt/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xslt/CMakeLists.txt b/xslt/CMakeLists.txt index 9477d92d0..6e3ea5d84 100644 --- a/xslt/CMakeLists.txt +++ b/xslt/CMakeLists.txt @@ -7,11 +7,10 @@ compiz_configure_file (compiz_gsettings_schemas.xslt.in compiz_gsettings_schemas if (USE_GCONF) list (APPEND _files compiz_gconf_schemas.xslt) - list (APPEND _files ${CMAKE_CURRENT_BINARY_DIR}/compiz_gsettings_schemas.xslt) endif () if (USE_GSETTINGS) - + list (APPEND _files ${CMAKE_CURRENT_BINARY_DIR}/compiz_gsettings_schemas.xslt) endif () install ( -- GitLab From 6e93ce3bc17237859b746670c99ec2813dade8f2 Mon Sep 17 00:00:00 2001 From: Iven Hsu Date: Fri, 14 Sep 2012 14:51:27 +0800 Subject: [PATCH 29/39] Fix "toggle by default" option of opacify plugin (LP: #1050752). --- plugins/opacify/src/opacify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/opacify/src/opacify.cpp b/plugins/opacify/src/opacify.cpp index 5c3bc1186..77d3034d1 100644 --- a/plugins/opacify/src/opacify.cpp +++ b/plugins/opacify/src/opacify.cpp @@ -414,7 +414,7 @@ OpacifyScreen::OpacifyScreen (CompScreen *screen) : optionSetTimeoutNotify (boost::bind (&OpacifyScreen::optionChanged, this, _1, _2)); - screen->handleEventSetEnabled (this, optionGetInitToggle ()); + setFunctions (optionGetInitToggle ()); } bool -- GitLab From 1ef73a201d326515d511ca0f5f0aab454b8fff54 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 17 Sep 2012 21:48:33 +0800 Subject: [PATCH 30/39] Walking skeleton for glx tfp bind code, failing tests: [ FAILED ] CompizOpenGLGLXTextureFromPixmapBindTest.TestTakesServerGrab [ FAILED ] CompizOpenGLGLXTextureFromPixmapBindTest.TestNoCallToCheckValidityIfInternalAndImmediateBind [ FAILED ] CompizOpenGLGLXTextureFromPixmapBindTest.TestCheckValidityIfExternalNoBindIfInvalid [ FAILED ] CompizOpenGLGLXTextureFromPixmapBindTest.TestCheckValidityIfExternalBindIfValid --- plugins/opengl/CMakeLists.txt | 4 + plugins/opengl/src/glxtfpbind/CMakeLists.txt | 30 ++++ .../src/glxtfpbind/include/glx-tfp-bind.h | 58 +++++++ .../src/glxtfpbind/src/glx-tfp-bind.cpp | 40 +++++ .../src/glxtfpbind/tests/CMakeLists.txt | 24 +++ .../tests/test-opengl-glx-tfp-bind.cpp | 153 ++++++++++++++++++ 6 files changed, 309 insertions(+) create mode 100644 plugins/opengl/src/glxtfpbind/CMakeLists.txt create mode 100644 plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h create mode 100644 plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp create mode 100644 plugins/opengl/src/glxtfpbind/tests/CMakeLists.txt create mode 100644 plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp diff --git a/plugins/opengl/CMakeLists.txt b/plugins/opengl/CMakeLists.txt index a8926a492..13c2a3ec8 100644 --- a/plugins/opengl/CMakeLists.txt +++ b/plugins/opengl/CMakeLists.txt @@ -5,10 +5,14 @@ include (CompizPlugin) set (INTERNAL_LIBRARIES compiz_opengl_double_buffer compiz_opengl_fsregion + compiz_opengl_glx_tfp_bind ) add_subdirectory (src/doublebuffer) add_subdirectory (src/fsregion) +add_subdirectory (src/glxtfpbind) + +include_directories (src/glxtfpbind/include) if (USE_GLES) compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD "-DUSE_GLES -std=c++0x" LIBRARIES ${OPENGLES2_LIBRARIES} ${INTERNAL_LIBRARIES} dl INCDIRS ${OPENGLES2_INCLUDE_DIR}) diff --git a/plugins/opengl/src/glxtfpbind/CMakeLists.txt b/plugins/opengl/src/glxtfpbind/CMakeLists.txt new file mode 100644 index 000000000..f48611cdb --- /dev/null +++ b/plugins/opengl/src/glxtfpbind/CMakeLists.txt @@ -0,0 +1,30 @@ +INCLUDE_DIRECTORIES ( + ${compiz_SOURCE_DIR}/src/servergrab/include + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src + + ${Boost_INCLUDE_DIRS} +) + +LINK_DIRECTORIES (${COMPIZ_LIBRARY_DIRS}) + +SET( + SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/src/glx-tfp-bind.cpp +) + +ADD_LIBRARY( + compiz_opengl_glx_tfp_bind STATIC + + ${SRCS} +) + +if (COMPIZ_BUILD_TESTING) +ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) +endif (COMPIZ_BUILD_TESTING) + +TARGET_LINK_LIBRARIES( + compiz_opengl_glx_tfp_bind + + compiz_servergrab +) diff --git a/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h b/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h new file mode 100644 index 000000000..c758f878c --- /dev/null +++ b/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h @@ -0,0 +1,58 @@ +/* + * Compiz, opengl plugin, GLX_EXT_texture_from_pixmap rebind logic + * + * Copyright (c) 2012 Canonical Ltd. + * Authors: Sam Spilsbury + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef _COMPIZ_OPENGL_GLX_TFP_BIND_H +#define _COMPIZ_OPENGL_GLX_TFP_BIND_H + +#include + +class ServerGrabInterface; +typedef unsigned long Pixmap; +typedef unsigned long GLXPixmap; + +namespace compiz +{ + namespace opengl + { + typedef boost::function PixmapCheckValidityFunc; + typedef boost::function BindTexImageEXTFunc; + typedef boost::function WaitGLXFunc; + + typedef enum _PixmapSource + { + InternallyManaged = 0, + ExternallyManaged = 1 + } PixmapSource; + + bool bindTexImageGLX (ServerGrabInterface *, + Pixmap, + GLXPixmap, + const PixmapCheckValidityFunc &, + const BindTexImageEXTFunc &, + const WaitGLXFunc &, + PixmapSource); + + } // namespace opengl +} // namespace compiz +#endif diff --git a/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp b/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp new file mode 100644 index 000000000..84894e57f --- /dev/null +++ b/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp @@ -0,0 +1,40 @@ +/* + * Compiz, opengl plugin, GLX_EXT_texture_from_pixmap rebind logic + * + * Copyright (c) 2012 Canonical Ltd. + * Authors: Sam Spilsbury + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "glx-tfp-bind.h" + +namespace cgl = compiz::opengl; + +bool +cgl::bindTexImageGLX (ServerGrabInterface *serverGrabInterface, + Pixmap x11Pixmap, + GLXPixmap glxPixmap, + const cgl::PixmapCheckValidityFunc &checkPixmapValidity, + const cgl::BindTexImageEXTFunc &bindTexImageEXT, + const cgl::WaitGLXFunc &waitGLX, + cgl::PixmapSource source) +{ + return false; +} diff --git a/plugins/opengl/src/glxtfpbind/tests/CMakeLists.txt b/plugins/opengl/src/glxtfpbind/tests/CMakeLists.txt new file mode 100644 index 000000000..43d4d2622 --- /dev/null +++ b/plugins/opengl/src/glxtfpbind/tests/CMakeLists.txt @@ -0,0 +1,24 @@ +find_library (GMOCK_LIBRARY gmock) +find_library (GMOCK_MAIN_LIBRARY gmock_main) + +if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND) + message ("Google Mock and Google Test not found - cannot build tests!") + set (COMPIZ_BUILD_TESTING OFF) +endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND) + +include_directories (${GTEST_INCLUDE_DIRS}) + +link_directories (${COMPIZ_LIBRARY_DIRS}) + +add_executable (compiz_test_opengl_glx_tfp_bind + ${CMAKE_CURRENT_SOURCE_DIR}/test-opengl-glx-tfp-bind.cpp) + +target_link_libraries (compiz_test_opengl_glx_tfp_bind + compiz_opengl_glx_tfp_bind + ${GTEST_BOTH_LIBRARIES} + ${GMOCK_LIBRARY} + ${GMOCK_MAIN_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. + ) + +compiz_discover_tests (compiz_test_opengl_glx_tfp_bind COVERAGE compiz_opengl_glx_tfp_bind) diff --git a/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp b/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp new file mode 100644 index 000000000..653d266b5 --- /dev/null +++ b/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp @@ -0,0 +1,153 @@ +#include + +#include +#include + +#include +#include "glx-tfp-bind.h" + +using ::testing::InSequence; +using ::testing::NiceMock; +using ::testing::StrictMock; +using ::testing::Return; + +namespace cgl = compiz::opengl; + +namespace +{ + const Pixmap pixmap = 1; + const GLXPixmap glxPixmap = 2; + + void emptyWaitGLX () {} + bool emptyCheckPixmap (Pixmap p) { return true; } + void emptyBindTexImage (GLXPixmap p) {} + + cgl::WaitGLXFunc waitGLX () { return boost::bind (emptyWaitGLX); } + cgl::PixmapCheckValidityFunc pixmapCheckValidity () { return boost::bind (emptyCheckPixmap, _1); } + cgl::BindTexImageEXTFunc bindTexImageEXT () { return boost::bind (emptyBindTexImage, _1); } +} + +class MockWaitGLX +{ + public: + + MOCK_METHOD0 (waitGLX, void ()); +}; + +class MockPixmapCheckValidity +{ + public: + + MOCK_METHOD1 (checkValidity, bool (Pixmap)); +}; + +class MockBindTexImageEXT +{ + public: + + MOCK_METHOD1 (bindTexImageEXT, void (GLXPixmap)); +}; + +class MockServerGrab : + public ServerGrabInterface +{ + public: + + MOCK_METHOD0 (grabServer, void ()); + MOCK_METHOD0 (syncServer, void ()); + MOCK_METHOD0 (ungrabServer, void ()); +}; + +TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestTakesServerGrab) +{ + MockServerGrab mockServerGrab; + InSequence s; + + EXPECT_CALL (mockServerGrab, grabServer ()); + EXPECT_CALL (mockServerGrab, ungrabServer ()); + EXPECT_CALL (mockServerGrab, syncServer ()); + + cgl::bindTexImageGLX (&mockServerGrab, + pixmap, + glxPixmap, + pixmapCheckValidity (), + bindTexImageEXT (), + waitGLX (), + cgl::InternallyManaged); +} + +TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestCallsWaitGLX) +{ + NiceMock mockServerGrab; + MockWaitGLX mockWaitGLX; + + cgl::WaitGLXFunc waitGLXFuncMock (boost::bind (&MockWaitGLX::waitGLX, &mockWaitGLX)); + cgl::bindTexImageGLX (&mockServerGrab, + pixmap, + glxPixmap, + pixmapCheckValidity (), + bindTexImageEXT (), + waitGLXFuncMock, + cgl::InternallyManaged); +} + +TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestNoCallToCheckValidityIfInternalAndImmediateBind) +{ + NiceMock mockServerGrab; + StrictMock mockPixmapCheck; + StrictMock mockBindTexImage; + + cgl::PixmapCheckValidityFunc pixmapCheckFunc (boost::bind (&MockPixmapCheckValidity::checkValidity, &mockPixmapCheck, _1)); + cgl::BindTexImageEXTFunc bindTexImageEXTFunc (boost::bind (&MockBindTexImageEXT::bindTexImageEXT, &mockBindTexImage, _1)); + + EXPECT_CALL (mockBindTexImage, bindTexImageEXT (glxPixmap)); + + EXPECT_TRUE (cgl::bindTexImageGLX (&mockServerGrab, + pixmap, + glxPixmap, + pixmapCheckFunc, + bindTexImageEXTFunc, + waitGLX (), + cgl::InternallyManaged)); +} + +TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestCheckValidityIfExternalNoBindIfInvalid) +{ + NiceMock mockServerGrab; + StrictMock mockPixmapCheck; + StrictMock mockBindTexImage; + + cgl::PixmapCheckValidityFunc pixmapCheckFunc (boost::bind (&MockPixmapCheckValidity::checkValidity, &mockPixmapCheck, _1)); + cgl::BindTexImageEXTFunc bindTexImageEXTFunc (boost::bind (&MockBindTexImageEXT::bindTexImageEXT, &mockBindTexImage, _1)); + + EXPECT_CALL (mockPixmapCheck, checkValidity (pixmap)).WillOnce (Return (false)); + + EXPECT_FALSE (cgl::bindTexImageGLX (&mockServerGrab, + pixmap, + glxPixmap, + pixmapCheckFunc, + bindTexImageEXTFunc, + waitGLX (), + cgl::ExternallyManaged)); +} + +TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestCheckValidityIfExternalBindIfValid) +{ + NiceMock mockServerGrab; + StrictMock mockPixmapCheck; + StrictMock mockBindTexImage; + + cgl::PixmapCheckValidityFunc pixmapCheckFunc (boost::bind (&MockPixmapCheckValidity::checkValidity, &mockPixmapCheck, _1)); + cgl::BindTexImageEXTFunc bindTexImageEXTFunc (boost::bind (&MockBindTexImageEXT::bindTexImageEXT, &mockBindTexImage, _1)); + + EXPECT_CALL (mockPixmapCheck, checkValidity (pixmap)).WillOnce (Return (true)); + EXPECT_CALL (mockBindTexImage, bindTexImageEXT (glxPixmap)); + + EXPECT_TRUE (cgl::bindTexImageGLX (&mockServerGrab, + pixmap, + glxPixmap, + pixmapCheckFunc, + bindTexImageEXTFunc, + waitGLX (), + cgl::ExternallyManaged)); +} -- GitLab From d07d71fbae6663811c1f1a2922094e12b4c58369 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 17 Sep 2012 21:52:30 +0800 Subject: [PATCH 31/39] Make the tests pass --- plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp | 14 +++++++++++++- .../glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp b/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp index 84894e57f..c6244ab22 100644 --- a/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp +++ b/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp @@ -36,5 +36,17 @@ cgl::bindTexImageGLX (ServerGrabInterface *serverGrabInterface, const cgl::WaitGLXFunc &waitGLX, cgl::PixmapSource source) { - return false; + ServerLock lock (serverGrabInterface); + + waitGLX (); + + /* External pixmaps can disappear on us, but not + * while we have a server grab at least */ + if (source == cgl::ExternallyManaged) + if (!checkPixmapValidity (x11Pixmap)) + return false; + + bindTexImageEXT (glxPixmap); + + return true; } diff --git a/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp b/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp index 653d266b5..edd10acbd 100644 --- a/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp +++ b/plugins/opengl/src/glxtfpbind/tests/test-opengl-glx-tfp-bind.cpp @@ -64,6 +64,7 @@ TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestTakesServerGrab) InSequence s; EXPECT_CALL (mockServerGrab, grabServer ()); + EXPECT_CALL (mockServerGrab, syncServer ()); EXPECT_CALL (mockServerGrab, ungrabServer ()); EXPECT_CALL (mockServerGrab, syncServer ()); @@ -82,6 +83,9 @@ TEST (CompizOpenGLGLXTextureFromPixmapBindTest, TestCallsWaitGLX) MockWaitGLX mockWaitGLX; cgl::WaitGLXFunc waitGLXFuncMock (boost::bind (&MockWaitGLX::waitGLX, &mockWaitGLX)); + + EXPECT_CALL (mockWaitGLX, waitGLX ()); + cgl::bindTexImageGLX (&mockServerGrab, pixmap, glxPixmap, -- GitLab From e31cee803db2c101453423b4ba62184fdeb4a67a Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 17 Sep 2012 22:32:28 +0800 Subject: [PATCH 32/39] Check that pixmaps which aren't managed by us actually exist before binding. It was possible for there to be a race condition for a pixmap to become invalid on the server side if the client which did have control over thier lifecycle freed them before we were done with them or disconnected. Drivers have normally handled this condition by reading the contents of the undefined memory directly without an error, however drivers such as LLVMpipe will effectively dereference an invalid pointer and crash when you do this. Eg: compiz crashed with SIGSEGV in memmove() from drisw_update_tex_buffer() from dri_set_tex_buffer2() from drisw_bind_tex_image() from __glXBindTexImageEXT() from TfpTexture::enable() Most of the time we don't need to employ this check. Its only when we know that we don't control the lifecycle of a pixmap that race conditions such as these can occurr. --- plugins/copytex/src/copytex.cpp | 9 +- plugins/copytex/src/copytex.h | 9 +- plugins/opengl/include/opengl/pixmapsource.h | 40 +++++++ plugins/opengl/include/opengl/texture.h | 15 ++- plugins/opengl/src/glxtfpbind/CMakeLists.txt | 1 + .../src/glxtfpbind/include/glx-tfp-bind.h | 7 +- .../src/glxtfpbind/src/glx-tfp-bind.cpp | 1 + plugins/opengl/src/privatetexture.h | 28 ++--- plugins/opengl/src/texture.cpp | 100 +++++++++++++++--- 9 files changed, 166 insertions(+), 44 deletions(-) create mode 100644 plugins/opengl/include/opengl/pixmapsource.h diff --git a/plugins/copytex/src/copytex.cpp b/plugins/copytex/src/copytex.cpp index b581c7e08..ed619a6f6 100644 --- a/plugins/copytex/src/copytex.cpp +++ b/plugins/copytex/src/copytex.cpp @@ -37,10 +37,11 @@ static GLTexture::Matrix _identity_matrix = { }; GLTexture::List -CopyPixmap::bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth) +CopyPixmap::bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + compiz::opengl::PixmapSource source) { if (depth != 32 && depth != 24) return GLTexture::List (); diff --git a/plugins/copytex/src/copytex.h b/plugins/copytex/src/copytex.h index b5228a70b..8530c5fba 100644 --- a/plugins/copytex/src/copytex.h +++ b/plugins/copytex/src/copytex.h @@ -52,10 +52,11 @@ class CopyPixmap { ~CopyPixmap (); - static GLTexture::List bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth); + static GLTexture::List bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + compiz::opengl::PixmapSource source); public: Textures textures; diff --git a/plugins/opengl/include/opengl/pixmapsource.h b/plugins/opengl/include/opengl/pixmapsource.h new file mode 100644 index 000000000..6c75207c7 --- /dev/null +++ b/plugins/opengl/include/opengl/pixmapsource.h @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2012 Canonical Ltd. + * Authors: Sam Spilsbury + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef _COMPIZ_OPENGL_PIXMAP_SOURCE_H +#define _COMPIZ_OPENGL_PIXMAP_SOURCE_H + +namespace compiz +{ + namespace opengl + { + typedef enum _PixmapSource + { + InternallyManaged = 0, + ExternallyManaged = 1 + } PixmapSource; + } +} + +#endif diff --git a/plugins/opengl/include/opengl/texture.h b/plugins/opengl/include/opengl/texture.h index 20d8faca6..b8b26f25c 100644 --- a/plugins/opengl/include/opengl/texture.h +++ b/plugins/opengl/include/opengl/texture.h @@ -43,6 +43,8 @@ #include +#include + #define POWER_OF_TWO(v) ((v & (v - 1)) == 0) @@ -104,7 +106,7 @@ class GLTexture : public CompRect { void clear (); }; - typedef boost::function BindPixmapProc; + typedef boost::function BindPixmapProc; typedef unsigned int BindPixmapHandle; public: @@ -181,11 +183,14 @@ class GLTexture : public CompRect { * @param width Specifies the width of the texture * @param height Specifies the height of the texture * @param depth Specifies the color depth of the texture + * @param source Whether the pixmap lifecycle is managed externall */ - static List bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth); + static List bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + compiz::opengl::PixmapSource source + = compiz::opengl::InternallyManaged); /** * Returns a GLTexture::List with the contents of of diff --git a/plugins/opengl/src/glxtfpbind/CMakeLists.txt b/plugins/opengl/src/glxtfpbind/CMakeLists.txt index f48611cdb..e0b8622d1 100644 --- a/plugins/opengl/src/glxtfpbind/CMakeLists.txt +++ b/plugins/opengl/src/glxtfpbind/CMakeLists.txt @@ -1,5 +1,6 @@ INCLUDE_DIRECTORIES ( ${compiz_SOURCE_DIR}/src/servergrab/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../include ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src diff --git a/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h b/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h index c758f878c..6b2161998 100644 --- a/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h +++ b/plugins/opengl/src/glxtfpbind/include/glx-tfp-bind.h @@ -25,6 +25,7 @@ #ifndef _COMPIZ_OPENGL_GLX_TFP_BIND_H #define _COMPIZ_OPENGL_GLX_TFP_BIND_H +#include #include class ServerGrabInterface; @@ -39,12 +40,6 @@ namespace compiz typedef boost::function BindTexImageEXTFunc; typedef boost::function WaitGLXFunc; - typedef enum _PixmapSource - { - InternallyManaged = 0, - ExternallyManaged = 1 - } PixmapSource; - bool bindTexImageGLX (ServerGrabInterface *, Pixmap, GLXPixmap, diff --git a/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp b/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp index c6244ab22..3a2625e7a 100644 --- a/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp +++ b/plugins/opengl/src/glxtfpbind/src/glx-tfp-bind.cpp @@ -22,6 +22,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +#include #include #include "glx-tfp-bind.h" diff --git a/plugins/opengl/src/privatetexture.h b/plugins/opengl/src/privatetexture.h index b3c5a168d..014850f0c 100644 --- a/plugins/opengl/src/privatetexture.h +++ b/plugins/opengl/src/privatetexture.h @@ -79,10 +79,11 @@ class EglTexture : public GLTexture { void enable (Filter filter); - static List bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth); + static List bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + compiz::opengl::PixmapSource source); public: bool damaged; @@ -102,16 +103,19 @@ class TfpTexture : public GLTexture { bool bindTexImage (const GLXPixmap &); void releaseTexImage (); - static List bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth); + static List bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + compiz::opengl::PixmapSource source); public: - GLXPixmap pixmap; - bool damaged; - Damage damage; - bool updateMipMap; + Pixmap x11Pixmap; + GLXPixmap pixmap; + bool damaged; + Damage damage; + bool updateMipMap; + compiz::opengl::PixmapSource source; }; extern std::map boundPixmapTex; diff --git a/plugins/opengl/src/texture.cpp b/plugins/opengl/src/texture.cpp index ee27b0da6..970edf072 100644 --- a/plugins/opengl/src/texture.cpp +++ b/plugins/opengl/src/texture.cpp @@ -31,11 +31,17 @@ #include #include +#include + #include #include #include #include "privates.h" +#include "glx-tfp-bind.h" + +namespace cgl = compiz::opengl; + #ifdef USE_GLES std::map boundPixmapTex; #else @@ -421,23 +427,58 @@ GLTexture::incRef (GLTexture *tex) } GLTexture::List -GLTexture::bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth) +GLTexture::bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + compiz::opengl::PixmapSource source) { GLTexture::List rv; foreach (BindPixmapProc &proc, GLScreen::get (screen)->priv->bindPixmap) { if (!proc.empty ()) - rv = proc (pixmap, width, height, depth); + rv = proc (pixmap, width, height, depth, source); if (rv.size ()) return rv; } return GLTexture::List (); } +namespace +{ + bool checkPixmapValidityGLX (Pixmap pixmap) + { + Window windowReturn; + unsigned int uiReturn; + int iReturn; + + if (!XGetGeometry (screen->dpy (), + pixmap, + &windowReturn, + &iReturn, + &iReturn, + &uiReturn, + &uiReturn, + &uiReturn, + &uiReturn)) + return false; + return true; + } + + const cgl::WaitGLXFunc & waitGLXFunc () + { + static const cgl::WaitGLXFunc f (boost::bind (glXWaitX)); + return f; + } + + const cgl::PixmapCheckValidityFunc & checkPixmapValidityFunc () + { + static const cgl::PixmapCheckValidityFunc f (boost::bind (checkPixmapValidityGLX, _1)); + return f; + } +} + #ifdef USE_GLES EglTexture::EglTexture () : damaged (true), @@ -538,6 +579,20 @@ EglTexture::enable (GLTexture::Filter filter) } #else +namespace +{ + const cgl::BindTexImageEXTFunc & bindTexImageEXT () + { + static int *attrib_list = NULL; + static const cgl::BindTexImageEXTFunc f (boost::bind (GL::bindTexImage, + screen->dpy (), + _1, + GLX_FRONT_LEFT_EXT, + attrib_list)); + return f; + } +} + TfpTexture::TfpTexture () : pixmap (0), damaged (true), @@ -569,10 +624,13 @@ TfpTexture::~TfpTexture () bool TfpTexture::bindTexImage (const GLXPixmap &glxPixmap) { - ServerLock sg (screen->serverGrabInterface ()); - glXWaitX (); - (*GL::bindTexImage) (screen->dpy (), glxPixmap, GLX_FRONT_LEFT_EXT, NULL); - return true; + return compiz::opengl::bindTexImageGLX (screen->serverGrabInterface (), + x11Pixmap, + glxPixmap, + checkPixmapValidityFunc (), + bindTexImageEXT (), + waitGLXFunc (), + source); } void @@ -582,10 +640,11 @@ TfpTexture::releaseTexImage () } GLTexture::List -TfpTexture::bindPixmapToTexture (Pixmap pixmap, - int width, - int height, - int depth) +TfpTexture::bindPixmapToTexture (Pixmap pixmap, + int width, + int height, + int depth, + cgl::PixmapSource source) { if ((int) width > GL::maxTextureSize || (int) height > GL::maxTextureSize || !GL::textureFromPixmap) @@ -650,6 +709,19 @@ TfpTexture::bindPixmapToTexture (Pixmap pixmap, attribs[i++] = None; + /* We need to take a server grab here if the pixmap is + * externally managed as we need to be able to query + * if it actually exists */ + boost::scoped_ptr lock; + + if (source == cgl::ExternallyManaged) + { + lock.reset (new ServerLock (screen->serverGrabInterface ())); + + if (!checkPixmapValidityGLX (pixmap)) + return false; + } + glxPixmap = (*GL::createPixmap) (screen->dpy (), config->fbConfig, pixmap, attribs); @@ -711,6 +783,8 @@ TfpTexture::bindPixmapToTexture (Pixmap pixmap, tex->setData (texTarget, matrix, mipmap); tex->setGeometry (0, 0, width, height); tex->pixmap = glxPixmap; + tex->x11Pixmap = pixmap; + tex->source = source; rv[0] = tex; -- GitLab From b356b116ccca451f32c9352d13fca33850271786 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 17 Sep 2012 22:36:00 +0800 Subject: [PATCH 33/39] Bump ABI --- plugins/opengl/include/opengl/opengl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/opengl/include/opengl/opengl.h b/plugins/opengl/include/opengl/opengl.h index b96ae6b07..dfa094c15 100644 --- a/plugins/opengl/include/opengl/opengl.h +++ b/plugins/opengl/include/opengl/opengl.h @@ -50,7 +50,7 @@ #include #include -#define COMPIZ_OPENGL_ABI 5 +#define COMPIZ_OPENGL_ABI 6 /* * Some plugins check for #ifdef USE_MODERN_COMPIZ_GL. Support it for now, but -- GitLab From 28218d3d4d1671b2b19d3fc66df4c09bbcf946a2 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 17 Sep 2012 23:25:00 +0800 Subject: [PATCH 34/39] Actually provide the hint --- plugins/decor/src/decor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/decor/src/decor.cpp b/plugins/decor/src/decor.cpp index c47db63a2..b1a0aacc2 100644 --- a/plugins/decor/src/decor.cpp +++ b/plugins/decor/src/decor.cpp @@ -337,7 +337,9 @@ DecorTexture::DecorTexture (DecorPixmapInterface::Ptr pixmap) : } bindFailed = false; - textures = GLTexture::bindPixmapToTexture (pixmap->getPixmap (), width, height, depth); + textures = GLTexture::bindPixmapToTexture (pixmap->getPixmap (), + width, height, depth, + compiz::opengl::ExternallyManaged); if (textures.size () != 1) { bindFailed = true; -- GitLab From e9a25a177d8df09deaeb21386000a75738bb008c Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 18 Sep 2012 15:03:41 +0800 Subject: [PATCH 35/39] Sam's proposed patch, from: https://code.launchpad.net/~vanvugt/compiz/fix-unredirect-flicker/+merge/124632/comments/268309/+download --- plugins/opengl/src/fsregion/fsregion.cpp | 25 ++++++++- plugins/opengl/src/fsregion/fsregion.h | 6 ++- .../src/fsregion/tests/test-fsregion.cpp | 11 ++++ plugins/opengl/src/paint.cpp | 51 +++++++++++-------- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/plugins/opengl/src/fsregion/fsregion.cpp b/plugins/opengl/src/fsregion/fsregion.cpp index 264b4ad3d..99ad9fdb2 100644 --- a/plugins/opengl/src/fsregion/fsregion.cpp +++ b/plugins/opengl/src/fsregion/fsregion.cpp @@ -30,7 +30,8 @@ namespace opengl { FullscreenRegion::FullscreenRegion (const CompRect &rect) : covered (false), - untouched (rect) + untouched (rect), + orig (untouched) { } @@ -38,8 +39,19 @@ bool FullscreenRegion::isCoveredBy (const CompRegion ®ion, WinFlags flags) { bool fullscreen = false; + /* We don't want to unredirect desktop or alpha windows, or consider them + * as not-occluding other fullscreen windows */ + const bool canBeConsideredAsCovering = !(flags & (Desktop | Alpha)); + /* The region of this fullscreen window covers the existing untouched area + * of this monitor */ + const bool coversUntouchedRegion = region == untouched; - if (!covered && !(flags & (Desktop | Alpha)) && region == untouched) + /* This window covers the fullscreen area of this monitor, consider + * the monitor covered and don't allow any further windows on this + * monitor to be considered fullscreen */ + if (!covered && + canBeConsideredAsCovering && + coversUntouchedRegion) { covered = true; fullscreen = true; @@ -50,5 +62,14 @@ FullscreenRegion::isCoveredBy (const CompRegion ®ion, WinFlags flags) return fullscreen; } +bool +FullscreenRegion::allowRedirection (const CompRegion ®ion) +{ + /* Don't allow existing unredirected windows that cover this + * region to be redirected again as they were probably unredirected + * on another monitor */ + return region.intersects (orig); +} + } // namespace opengl } // namespace compiz diff --git a/plugins/opengl/src/fsregion/fsregion.h b/plugins/opengl/src/fsregion/fsregion.h index bd178399f..735349277 100644 --- a/plugins/opengl/src/fsregion/fsregion.h +++ b/plugins/opengl/src/fsregion/fsregion.h @@ -36,8 +36,8 @@ class FullscreenRegion public: typedef enum { - Desktop = 1, - Alpha = 2 + Desktop = 1 << 0, + Alpha = 1 << 1, } WinFlag; typedef unsigned int WinFlags; @@ -46,10 +46,12 @@ public: // isCoveredBy is called for windows from TOP to BOTTOM bool isCoveredBy (const CompRegion ®ion, WinFlags flags = 0); + bool allowRedirection (const CompRegion ®ion); private: bool covered; CompRegion untouched; + CompRegion orig; }; } // namespace opengl diff --git a/plugins/opengl/src/fsregion/tests/test-fsregion.cpp b/plugins/opengl/src/fsregion/tests/test-fsregion.cpp index 961600e84..b0d633384 100644 --- a/plugins/opengl/src/fsregion/tests/test-fsregion.cpp +++ b/plugins/opengl/src/fsregion/tests/test-fsregion.cpp @@ -137,4 +137,15 @@ TEST (OpenGLFullscreenRegion, Overflow) FullscreenRegion::Desktop)); } +TEST (OpenGLFullscreenRegion, KeepUnredirectedStateIfNotOnMonitor) +{ + FullscreenRegion monitor (CompRect (0, 0, 1024, 768)); + CompRegion window (1025, 0, 1024, 768); + /* Eg, not covering the monitor, should be redirected */ + EXPECT_FALSE (monitor.isCoveredBy (window)); + /* Don't allow the redirection however, because we weren't + * covering the monitor at all. */ + EXPECT_FALSE (monitor.allowRedirection (window)); +} + diff --git a/plugins/opengl/src/paint.cpp b/plugins/opengl/src/paint.cpp index 50e27745e..91cb97962 100644 --- a/plugins/opengl/src/paint.cpp +++ b/plugins/opengl/src/paint.cpp @@ -245,7 +245,7 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, CompWindow *w; GLWindow *gw; int windowMask, odMask; - CompWindow *fullscreenWindow = NULL; + CompWindowList unredirectedFullscreenWindows; bool status, unredirectFS; bool withOffset = false; GLMatrix vTransform; @@ -350,32 +350,38 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, * beneath them and so neither should be unredirected in that case. */ if (unredirectFS && - !(mask & PAINT_SCREEN_TRANSFORMED_MASK) && - fs.isCoveredBy (w->region (), flags)) + !(mask & PAINT_SCREEN_TRANSFORMED_MASK) && + fs.isCoveredBy (w->region (), flags)) { - fullscreenWindow = w; + unredirectedFullscreenWindows.push_back (w); } else { - CompositeWindow *cw = CompositeWindow::get (w); - if (!cw->redirected ()) - { - // 1. GLWindow::release to force gw->priv->needsRebind - gw->release (); - - // 2. GLWindow::bind, which redirects the window, - // rebinds the pixmap, and then rebinds the pixmap - // to a texture. - gw->bind (); - - // 3. Your window is now redirected again with the - // latest pixmap contents. - } + CompositeWindow *cw = CompositeWindow::get (w); + if (!cw->redirected ()) + { + if (fs.allowRedirection (w->region ())) + { + // 1. GLWindow::release to force gw->priv->needsRebind + gw->release (); + + // 2. GLWindow::bind, which redirects the window, + // rebinds the pixmap, and then rebinds the pixmap + // to a texture. + gw->bind (); + + // 3. Your window is now redirected again with the + // latest pixmap contents. + } + else + unredirectedFullscreenWindows.push_back (w); + } } } } - if (fullscreenWindow) + /* Unredirect any redirected fullscreen windows */ + foreach (CompWindow *fullscreenWindow, unredirectedFullscreenWindows) CompositeWindow::get (fullscreenWindow)->unredirect (); if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK)) @@ -389,8 +395,11 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, if (w->destroyed ()) continue; - if (w == fullscreenWindow) - continue; + if (!unredirectedFullscreenWindows.empty ()) + if (std::find (unredirectedFullscreenWindows.begin (), + unredirectedFullscreenWindows.end (), + w) != unredirectedFullscreenWindows.end ()) + continue; if (!w->shaded ()) { -- GitLab From 06a26b05991cf438b786caf1758c35c53ca9e3f7 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 18 Sep 2012 15:54:10 +0800 Subject: [PATCH 36/39] Remove non-functional style changes --- plugins/opengl/src/fsregion/fsregion.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/plugins/opengl/src/fsregion/fsregion.cpp b/plugins/opengl/src/fsregion/fsregion.cpp index 99ad9fdb2..b8b8c3343 100644 --- a/plugins/opengl/src/fsregion/fsregion.cpp +++ b/plugins/opengl/src/fsregion/fsregion.cpp @@ -39,19 +39,8 @@ bool FullscreenRegion::isCoveredBy (const CompRegion ®ion, WinFlags flags) { bool fullscreen = false; - /* We don't want to unredirect desktop or alpha windows, or consider them - * as not-occluding other fullscreen windows */ - const bool canBeConsideredAsCovering = !(flags & (Desktop | Alpha)); - /* The region of this fullscreen window covers the existing untouched area - * of this monitor */ - const bool coversUntouchedRegion = region == untouched; - /* This window covers the fullscreen area of this monitor, consider - * the monitor covered and don't allow any further windows on this - * monitor to be considered fullscreen */ - if (!covered && - canBeConsideredAsCovering && - coversUntouchedRegion) + if (!covered && !(flags & (Desktop | Alpha)) && region == untouched) { covered = true; fullscreen = true; -- GitLab From 271864376bbbe0a3b264f1024644711d9efe926b Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 18 Sep 2012 16:05:55 +0800 Subject: [PATCH 37/39] Don't use a list or vector when you actually need a std::set. --- plugins/opengl/src/paint.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/opengl/src/paint.cpp b/plugins/opengl/src/paint.cpp index 91cb97962..55c482515 100644 --- a/plugins/opengl/src/paint.cpp +++ b/plugins/opengl/src/paint.cpp @@ -27,6 +27,7 @@ #include "privates.h" +#include #include #include #include @@ -245,11 +246,11 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, CompWindow *w; GLWindow *gw; int windowMask, odMask; - CompWindowList unredirectedFullscreenWindows; bool status, unredirectFS; bool withOffset = false; GLMatrix vTransform; CompPoint offXY; + std::set unredirected; CompWindowList pl; CompWindowList::reverse_iterator rit; @@ -353,7 +354,7 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, !(mask & PAINT_SCREEN_TRANSFORMED_MASK) && fs.isCoveredBy (w->region (), flags)) { - unredirectedFullscreenWindows.push_back (w); + unredirected.insert (w); } else { @@ -374,14 +375,16 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, // latest pixmap contents. } else - unredirectedFullscreenWindows.push_back (w); + { + unredirected.insert (w); + } } } } } /* Unredirect any redirected fullscreen windows */ - foreach (CompWindow *fullscreenWindow, unredirectedFullscreenWindows) + foreach (CompWindow *fullscreenWindow, unredirected) CompositeWindow::get (fullscreenWindow)->unredirect (); if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK)) @@ -395,11 +398,8 @@ PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, if (w->destroyed ()) continue; - if (!unredirectedFullscreenWindows.empty ()) - if (std::find (unredirectedFullscreenWindows.begin (), - unredirectedFullscreenWindows.end (), - w) != unredirectedFullscreenWindows.end ()) - continue; + if (unredirected.find (w) != unredirected.end ()) + continue; if (!w->shaded ()) { -- GitLab From 6e0d5154a889913e7698e6660c15aa7d822e0aea Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 18 Sep 2012 16:07:49 +0800 Subject: [PATCH 38/39] Remove non-functional style changes --- plugins/opengl/src/fsregion/fsregion.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/opengl/src/fsregion/fsregion.h b/plugins/opengl/src/fsregion/fsregion.h index 735349277..1b7461f91 100644 --- a/plugins/opengl/src/fsregion/fsregion.h +++ b/plugins/opengl/src/fsregion/fsregion.h @@ -36,8 +36,8 @@ class FullscreenRegion public: typedef enum { - Desktop = 1 << 0, - Alpha = 1 << 1, + Desktop = 1, + Alpha = 2 } WinFlag; typedef unsigned int WinFlags; -- GitLab From dad617dbdc76e8f5cdf9b3e31a0cdac6d4b19e32 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 18 Sep 2012 16:09:02 +0800 Subject: [PATCH 39/39] Remove extra blank line at end of file --- plugins/opengl/src/fsregion/tests/test-fsregion.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/opengl/src/fsregion/tests/test-fsregion.cpp b/plugins/opengl/src/fsregion/tests/test-fsregion.cpp index b0d633384..e0e4dfb14 100644 --- a/plugins/opengl/src/fsregion/tests/test-fsregion.cpp +++ b/plugins/opengl/src/fsregion/tests/test-fsregion.cpp @@ -148,4 +148,3 @@ TEST (OpenGLFullscreenRegion, KeepUnredirectedStateIfNotOnMonitor) EXPECT_FALSE (monitor.allowRedirection (window)); } - -- GitLab