From 0b8a57bcbac86d073e3c418c965b1483509bec64 Mon Sep 17 00:00:00 2001 From: Jon Nettleton Date: Thu, 7 May 2009 17:56:27 -0400 Subject: [PATCH] There can be only one compositor engine Mutter is a Clutter-based compositing manager. So, remove the code for the XRender-based compositor, and make it mandatory to have XComposite, XRender and Clutter. Run-time support for non-composited operation is left for now. * src/compositor/mutter/: Move files from this subdirectory into the main compositor/ directory. * compositor/compositor-xrender.ccompositor/compositor-xrender.h: Remove * include/compositor-clutter.h: Remove this stray file, it had been replaced with compositor-mutter.h some time back. http://bugzilla.gnome.org/show_bug.cgi?id=581813 --- configure.in | 95 +- src/Makefile.am | 36 +- src/compositor/{mutter => }/README | 0 .../{mutter => }/compositor-mutter.c | 55 +- src/compositor/compositor-xrender.c | 3067 ----------------- src/compositor/compositor-xrender.h | 31 - src/compositor/compositor.c | 65 +- src/compositor/{mutter => }/mutter-module.c | 0 src/compositor/{mutter => }/mutter-module.h | 0 .../{mutter => }/mutter-plugin-manager.c | 0 .../{mutter => }/mutter-plugin-manager.h | 0 src/compositor/{mutter => }/mutter-plugin.c | 0 .../{mutter => }/mutter-shaped-texture.c | 0 .../{mutter => }/mutter-shaped-texture.h | 0 .../{mutter => }/plugins/Makefile.am | 4 - src/compositor/{mutter => }/plugins/README | 0 src/compositor/{mutter => }/plugins/default.c | 0 .../{mutter => }/tidy/tidy-texture-frame.c | 0 .../{mutter => }/tidy/tidy-texture-frame.h | 0 src/core/display-private.h | 36 +- src/core/display.c | 20 +- src/core/frame.c | 2 - src/core/main.c | 36 +- src/core/prefs.c | 54 +- src/core/screen-private.h | 2 - src/core/screen.c | 11 +- src/core/window-private.h | 2 - src/core/window.c | 4 - src/core/workspace.c | 22 +- src/include/compositor-clutter.h | 77 - src/include/compositor.h | 3 - src/include/prefs.h | 10 - src/include/screen.h | 2 - 33 files changed, 50 insertions(+), 3584 deletions(-) rename src/compositor/{mutter => }/README (100%) rename src/compositor/{mutter => }/compositor-mutter.c (98%) delete mode 100644 src/compositor/compositor-xrender.c delete mode 100644 src/compositor/compositor-xrender.h rename src/compositor/{mutter => }/mutter-module.c (100%) rename src/compositor/{mutter => }/mutter-module.h (100%) rename src/compositor/{mutter => }/mutter-plugin-manager.c (100%) rename src/compositor/{mutter => }/mutter-plugin-manager.h (100%) rename src/compositor/{mutter => }/mutter-plugin.c (100%) rename src/compositor/{mutter => }/mutter-shaped-texture.c (100%) rename src/compositor/{mutter => }/mutter-shaped-texture.h (100%) rename src/compositor/{mutter => }/plugins/Makefile.am (97%) rename src/compositor/{mutter => }/plugins/README (100%) rename src/compositor/{mutter => }/plugins/default.c (100%) rename src/compositor/{mutter => }/tidy/tidy-texture-frame.c (100%) rename src/compositor/{mutter => }/tidy/tidy-texture-frame.h (100%) delete mode 100644 src/include/compositor-clutter.h diff --git a/configure.in b/configure.in index a3d318fa9..0c933b915 100644 --- a/configure.in +++ b/configure.in @@ -153,16 +153,6 @@ AC_ARG_ENABLE(startup-notification, [disable mutter's startup notification support, for embedded/size-sensitive custom non-GNOME builds]),, enable_startup_notification=auto) -AC_ARG_ENABLE(compositor, - AC_HELP_STRING([--disable-compositor], - [disable mutter's compositing manager]),, - enable_compositor=auto) - -AC_ARG_WITH(clutter, - AC_HELP_STRING([--without-clutter], - [disable the use of clutter for compositing]),, - with_clutter=auto) - AC_ARG_WITH(introspection, AC_HELP_STRING([--without-introspection], [disable the use of GObject introspection]),, @@ -173,11 +163,6 @@ AC_ARG_ENABLE(xsync, [disable mutter's use of the XSync extension]),, enable_xsync=auto) -AC_ARG_ENABLE(render, - AC_HELP_STRING([--disable-render], - [disable mutter's use of the RENDER extension]),, - enable_render=auto) - AC_ARG_ENABLE(shape, AC_HELP_STRING([--disable-shape], [disable mutter's use of the shaped window extension]),, @@ -231,43 +216,10 @@ else echo "Building without libstartup-notification" fi -## init this, it gets set either in the compositor check below -## or the render-specific check later -have_xrender=no - XCOMPOSITE_VERSION=0.2 -if test x$enable_compositor = xyes; then - have_xcomposite=yes -elif test x$enable_compositor = xauto; then - echo "Building compositing manager by default now." - have_xcomposite=yes -else - have_xcomposite=no -fi -if test x$with_clutter = xyes; then - have_xcomposite=yes - have_clutter=yes -elif test x$with_clutter = xauto; then - echo "Building clutter compositing manager by default now." - have_xcomposite=yes - have_clutter=yes -else - have_clutter=no -fi - -AM_CONDITIONAL(WITH_CLUTTER, test "$have_clutter" = "yes") - -if test x$have_xcomposite = xyes; then - AC_MSG_CHECKING([Xcomposite >= $XCOMPOSITE_VERSION]) - if $PKG_CONFIG --atleast-version $XCOMPOSITE_VERSION xcomposite; then - AC_MSG_RESULT([yes]) - else - AC_MSG_ERROR([no. Use --disable-compositor to disable.]) - fi -fi - -if test x$have_xcomposite = xyes; then +AC_MSG_CHECKING([Xcomposite >= $XCOMPOSITE_VERSION]) +if $PKG_CONFIG --atleast-version $XCOMPOSITE_VERSION xcomposite; then MUTTER_PC_MODULES="$MUTTER_PC_MODULES xcomposite >= $XCOMPOSITE_VERSION xfixes xrender xdamage" AC_DEFINE(HAVE_COMPOSITE_EXTENSIONS, 1, [Building with compositing manager support]) echo "Building with compositing manager" @@ -275,42 +227,13 @@ if test x$have_xcomposite = xyes; then ## force on render also have_xrender=yes else - echo "Building without compositing manager" -fi - -## if no compositor, still possibly enable render -if test x$have_xcomposite = xno; then - XRENDER_VERSION=0.0 - AC_MSG_CHECKING([xrender >= $XRENDER_VERSION]) - if $PKG_CONFIG --atleast-version $XRENDER_VERSION xrender; then - have_xrender=yes - else - have_xrender=no - fi - AC_MSG_RESULT($have_xrender) - - if test x$enable_render = xyes; then - have_xrender=yes - echo "Render support forced on" - elif test x$enable_render = xauto; then - true - else - have_xrender=no - fi - - if test x$have_xrender = xyes; then - echo "Building with Render" - MUTTER_PC_MODULES="$MUTTER_PC_MODULES xrender >= $XRENDER_VERSION" - fi -fi ## have_composite - -if test x$have_xrender = xyes; then - AC_DEFINE(HAVE_RENDER, , [Building with Render extension support]) + AC_MSG_ERROR([no. Mutter requires the Xcomposite extension to build.]) fi +CLUTTER_VERSION=0.9.3 CLUTTER_PACKAGE=clutter-0.9 AC_SUBST(CLUTTER_PACKAGE) -if test x$have_clutter = xyes; then +if $PKG_CONFIG --atleast-version $CLUTTER_VERSION $CLUTTER_PACKAGE ; then MUTTER_PC_MODULES="$MUTTER_PC_MODULES $CLUTTER_PACKAGE " PKG_CHECK_MODULES(CLUTTER, $CLUTTER_PACKAGE) AC_DEFINE(WITH_CLUTTER, , [Building with Clutter compositor]) @@ -327,6 +250,8 @@ if test x$have_clutter = xyes; then AC_DEFINE(HAVE_GLX_TEXTURE_PIXMAP, , [Is ClutterGLXTexturePixmap available?]) fi +else + AC_MSG_ERROR([no. Mutter requires Clutter version $CLUTTER_VERSION.]) fi if test x$with_introspection != xno; then @@ -578,7 +503,7 @@ src/wm-tester/Makefile src/libmutter-private.pc src/mutter-plugins.pc src/tools/Makefile -src/compositor/mutter/plugins/Makefile +src/compositor/plugins/Makefile po/Makefile.in ]) @@ -611,15 +536,11 @@ mutter-$VERSION: XFree86 Xinerama: ${use_xfree_xinerama} Solaris Xinerama: ${use_solaris_xinerama} Startup notification: ${have_startup_notification} - Compositing manager: ${have_xcomposite} Introspection: ${have_introspection} Session management: ${found_sm} Shape extension: ${found_shape} - Resize-and-rotate: ${found_randr} Xsync: ${found_xsync} - Render: ${have_xrender} Xcursor: ${have_xcursor} - Clutter: ${have_clutter} " MUTTER_MINOR_VERSION=mutter_minor_version diff --git a/src/Makefile.am b/src/Makefile.am index 1d3924857..10700017e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,10 +1,6 @@ lib_LTLIBRARIES = libmutter-private.la -SUBDIRS=wm-tester tools - -if WITH_CLUTTER -SUBDIRS += compositor/mutter/plugins -endif +SUBDIRS=wm-tester tools compositor/plugins INCLUDES=@MUTTER_CFLAGS@ -I $(srcdir)/include -I$(srcdir)/compositor -DMUTTER_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMUTTER_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DMUTTER_PKGDATADIR=\"$(pkgdatadir)\" -DMUTTER_DATADIR=\"$(datadir)\" -DG_LOG_DOMAIN=\"mutter\" -DSN_API_NOT_YET_FROZEN=1 -DMUTTER_MAJOR_VERSION=$(MUTTER_MAJOR_VERSION) -DMUTTER_MINOR_VERSION=$(MUTTER_MINOR_VERSION) -DMUTTER_MICRO_VERSION=$(MUTTER_MICRO_VERSION) -DMUTTER_PLUGIN_API_VERSION=$(MUTTER_PLUGIN_API_VERSION) -DMUTTER_PKGLIBDIR=\"$(pkglibdir)\" -DMUTTER_PLUGIN_DIR=\"@MUTTER_PLUGIN_DIR@\" @@ -21,9 +17,19 @@ mutter_SOURCES= \ include/boxes.h \ compositor/compositor.c \ compositor/compositor-private.h \ - compositor/compositor-xrender.c \ - compositor/compositor-xrender.h \ + compositor/compositor-mutter.c \ + compositor/mutter-module.c \ + compositor/mutter-module.h \ + compositor/mutter-plugin.c \ + compositor/mutter-plugin-manager.c \ + compositor/mutter-plugin-manager.h \ + compositor/mutter-shaped-texture.c \ + compositor/mutter-shaped-texture.h \ + compositor/tidy/tidy-texture-frame.c \ + compositor/tidy/tidy-texture-frame.h \ include/compositor.h \ + include/mutter-plugin.h \ + include/compositor-mutter.h \ core/constraints.c \ core/constraints.h \ core/core.c \ @@ -108,22 +114,6 @@ mutter_SOURCES= \ ui/ui.c \ include/all-keybindings.h -if WITH_CLUTTER -mutter_SOURCES += \ - compositor/mutter/compositor-mutter.c \ - compositor/mutter/mutter-shaped-texture.c \ - compositor/mutter/mutter-shaped-texture.h \ - compositor/mutter/mutter-plugin-manager.c \ - compositor/mutter/mutter-plugin-manager.h \ - compositor/mutter/tidy/tidy-texture-frame.c \ - compositor/mutter/tidy/tidy-texture-frame.h \ - compositor/mutter/mutter-module.c \ - compositor/mutter/mutter-module.h \ - compositor/mutter/mutter-plugin.c \ - include/mutter-plugin.h \ - include/compositor-mutter.h -endif - # by setting libmutter_private_la_CFLAGS, the files shared with # mutter proper will be compiled with different names. libmutter_private_la_CFLAGS = diff --git a/src/compositor/mutter/README b/src/compositor/README similarity index 100% rename from src/compositor/mutter/README rename to src/compositor/README diff --git a/src/compositor/mutter/compositor-mutter.c b/src/compositor/compositor-mutter.c similarity index 98% rename from src/compositor/mutter/compositor-mutter.c rename to src/compositor/compositor-mutter.c index 92f797add..3c937aa42 100644 --- a/src/compositor/mutter/compositor-mutter.c +++ b/src/compositor/compositor-mutter.c @@ -11,7 +11,7 @@ #include -#include "../../core/window-private.h" +#include "../core/window-private.h" #include "display.h" #include "screen.h" #include "frame.h" @@ -105,7 +105,6 @@ meta_xattrs_get_type (void) static unsigned char* shadow_gaussian_make_tile (void); -#ifdef HAVE_COMPOSITE_EXTENSIONS static inline gboolean composite_at_least_version (MetaDisplay *display, int maj, int min) { @@ -117,7 +116,6 @@ composite_at_least_version (MetaDisplay *display, int maj, int min) return (major > maj || (major == maj && minor >= min)); } -#endif typedef struct _Mutter { @@ -1143,9 +1141,6 @@ mutter_window_effect_completed (MutterWindow *cw, gulong event) static void clutter_cmp_destroy (MetaCompositor *compositor) { -#ifdef HAVE_COMPOSITE_EXTENSIONS - -#endif } static void @@ -1854,7 +1849,6 @@ static void clutter_cmp_manage_screen (MetaCompositor *compositor, MetaScreen *screen) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MetaCompScreen *info; MetaDisplay *display = meta_screen_get_display (screen); Display *xdisplay = meta_display_get_xdisplay (display); @@ -1972,23 +1966,18 @@ clutter_cmp_manage_screen (MetaCompositor *compositor, clutter_actor_show (info->overlay_group); clutter_actor_show (info->stage); -#endif } static void clutter_cmp_unmanage_screen (MetaCompositor *compositor, MetaScreen *screen) { -#ifdef HAVE_COMPOSITE_EXTENSIONS - -#endif } static void clutter_cmp_add_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MetaScreen *screen = meta_window_get_screen (window); MetaDisplay *display = meta_screen_get_display (screen); @@ -1998,14 +1987,12 @@ clutter_cmp_add_window (MetaCompositor *compositor, add_win (window); meta_error_trap_pop (display, FALSE); -#endif } static void clutter_cmp_remove_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = NULL; DEBUG_TRACE ("clutter_cmp_remove_window\n"); @@ -2014,7 +2001,6 @@ clutter_cmp_remove_window (MetaCompositor *compositor, return; destroy_win (cw); -#endif } static void @@ -2022,9 +2008,6 @@ clutter_cmp_set_updates (MetaCompositor *compositor, MetaWindow *window, gboolean update) { -#ifdef HAVE_COMPOSITE_EXTENSIONS - -#endif } static gboolean @@ -2032,7 +2015,6 @@ clutter_cmp_process_event (MetaCompositor *compositor, XEvent *event, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS Mutter *xrc = (Mutter *) compositor; if (window) @@ -2115,18 +2097,13 @@ clutter_cmp_process_event (MetaCompositor *compositor, * GTK+ windows in the same process, GTK+ needs the ConfigureNotify event, for example. */ return FALSE; -#endif } static Pixmap clutter_cmp_get_window_pixmap (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS return None; -#else - return None; -#endif } static void @@ -2134,35 +2111,28 @@ clutter_cmp_set_active_window (MetaCompositor *compositor, MetaScreen *screen, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS - -#endif } static void clutter_cmp_map_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); DEBUG_TRACE ("clutter_cmp_map_window\n"); if (!cw) return; map_win (cw); -#endif } static void clutter_cmp_unmap_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); DEBUG_TRACE ("clutter_cmp_unmap_window\n"); if (!cw) return; unmap_win (cw); -#endif } static void @@ -2171,7 +2141,6 @@ clutter_cmp_minimize_window (MetaCompositor *compositor, MetaRectangle *window_rect, MetaRectangle *icon_rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -2197,7 +2166,6 @@ clutter_cmp_minimize_window (MetaCompositor *compositor, cw->priv->is_minimized = TRUE; cw->priv->minimize_in_progress--; } -#endif } static void @@ -2206,7 +2174,6 @@ clutter_cmp_unminimize_window (MetaCompositor *compositor, MetaRectangle *window_rect, MetaRectangle *icon_rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS #if 0 MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); @@ -2239,7 +2206,6 @@ clutter_cmp_unminimize_window (MetaCompositor *compositor, map_win (cw); #endif -#endif } @@ -2248,7 +2214,6 @@ clutter_cmp_maximize_window (MetaCompositor *compositor, MetaWindow *window, MetaRectangle *rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -2270,7 +2235,6 @@ clutter_cmp_maximize_window (MetaCompositor *compositor, { cw->priv->maximize_in_progress--; } -#endif } static void @@ -2278,7 +2242,6 @@ clutter_cmp_unmaximize_window (MetaCompositor *compositor, MetaWindow *window, MetaRectangle *rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -2300,14 +2263,12 @@ clutter_cmp_unmaximize_window (MetaCompositor *compositor, { cw->priv->unmaximize_in_progress--; } -#endif } static void clutter_cmp_update_workspace_geometry (MetaCompositor *compositor, MetaWorkspace *workspace) { -#ifdef HAVE_COMPOSITE_EXTENSIONS #if 0 /* FIXME -- should do away with this function in favour of MetaWorkspace * signal. @@ -2325,7 +2286,6 @@ clutter_cmp_update_workspace_geometry (MetaCompositor *compositor, mutter_plugin_manager_update_workspace (mgr, workspace); #endif -#endif } static void @@ -2335,7 +2295,6 @@ clutter_cmp_switch_workspace (MetaCompositor *compositor, MetaWorkspace *to, MetaMotionDirection direction) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MetaCompScreen *info; gint to_indx, from_indx; @@ -2406,7 +2365,6 @@ clutter_cmp_switch_workspace (MetaCompositor *compositor, */ mutter_finish_workspace_switch (info); } -#endif } static void @@ -2555,7 +2513,6 @@ static void clutter_cmp_sync_window_geometry (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -2567,8 +2524,6 @@ clutter_cmp_sync_window_geometry (MetaCompositor *compositor, return; sync_actor_position (cw); - -#endif } static void @@ -2577,7 +2532,6 @@ clutter_cmp_sync_screen_size (MetaCompositor *compositor, guint width, guint height) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MetaCompScreen *info = meta_screen_get_compositor_data (screen); DEBUG_TRACE ("clutter_cmp_sync_screen_size\n"); @@ -2588,7 +2542,6 @@ clutter_cmp_sync_screen_size (MetaCompositor *compositor, meta_verbose ("Changed size for stage on screen %d to %dx%d\n", meta_screen_get_screen_number (screen), width, height); -#endif } static MetaCompositor comp_info = { @@ -2618,7 +2571,6 @@ static MetaCompositor comp_info = { MetaCompositor * mutter_new (MetaDisplay *display) { -#ifdef HAVE_COMPOSITE_EXTENSIONS char *atom_names[] = { "_XROOTPMAP_ID", "_XSETROOT_ID", @@ -2669,9 +2621,6 @@ mutter_new (MetaDisplay *display) free (data); return compositor; -#else - return NULL; -#endif } Window @@ -2978,5 +2927,3 @@ shadow_gaussian_make_tile () return data; } - - diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c deleted file mode 100644 index 74a881bad..000000000 --- a/src/compositor/compositor-xrender.c +++ /dev/null @@ -1,3067 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -/* - * Copyright (C) 2007 Iain Holmes - * Based on xcompmgr - (c) 2003 Keith Packard - * xfwm4 - (c) 2005-2007 Olivier Fourdan - * - * 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. - */ - -#define _GNU_SOURCE -#define _XOPEN_SOURCE 600 /* for usleep() */ - -#include - -#ifdef HAVE_COMPOSITE_EXTENSIONS - -#include -#include -#include -#include - -#include - -#include "display.h" -#include "screen.h" -#include "frame.h" -#include "errors.h" -#include "window.h" -#include "compositor-private.h" -#include "compositor-xrender.h" -#include "xprops.h" -#include -#include -#include -#include -#include -#include - -#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2 -#define HAVE_NAME_WINDOW_PIXMAP 1 -#endif - -#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 3 -#define HAVE_COW 1 -#else -/* Don't have a cow man...HAAHAAHAA */ -#endif - -#define USE_IDLE_REPAINT 1 - -#ifdef HAVE_COMPOSITE_EXTENSIONS -static inline gboolean -composite_at_least_version (MetaDisplay *display, - int maj, int min) -{ - static int major = -1; - static int minor = -1; - - if (major == -1) - meta_display_get_compositor_version (display, &major, &minor); - - return (major > maj || (major == maj && minor >= min)); -} - -#define have_name_window_pixmap(display) \ - composite_at_least_version (display, 0, 2) -#define have_cow(display) \ - composite_at_least_version (display, 0, 3) - -#endif - -typedef enum _MetaShadowType -{ - META_SHADOW_SMALL, - META_SHADOW_MEDIUM, - META_SHADOW_LARGE, - LAST_SHADOW_TYPE -} MetaShadowType; - -typedef struct _MetaCompositorXRender -{ - MetaCompositor compositor; - - MetaDisplay *display; - - Atom atom_x_root_pixmap; - Atom atom_x_set_root; - Atom atom_net_wm_window_opacity; - Atom atom_net_wm_window_type_dnd; - - Atom atom_net_wm_window_type; - Atom atom_net_wm_window_type_desktop; - Atom atom_net_wm_window_type_dock; - Atom atom_net_wm_window_type_menu; - Atom atom_net_wm_window_type_dialog; - Atom atom_net_wm_window_type_normal; - Atom atom_net_wm_window_type_utility; - Atom atom_net_wm_window_type_splash; - Atom atom_net_wm_window_type_toolbar; - Atom atom_net_wm_window_type_dropdown_menu; - Atom atom_net_wm_window_type_tooltip; - -#ifdef USE_IDLE_REPAINT - guint repaint_id; -#endif - guint enabled : 1; - guint show_redraw : 1; - guint debug : 1; -} MetaCompositorXRender; - -typedef struct _conv -{ - int size; - double *data; -} conv; - -typedef struct _shadow -{ - conv *gaussian_map; - guchar *shadow_corner; - guchar *shadow_top; -} shadow; - -typedef struct _MetaCompScreen -{ - MetaScreen *screen; - GList *windows; - GHashTable *windows_by_xid; - - MetaWindow *focus_window; - - Window output; - - gboolean have_shadows; - shadow *shadows[LAST_SHADOW_TYPE]; - - Picture root_picture; - Picture root_buffer; - Picture black_picture; - Picture trans_black_picture; - Picture root_tile; - XserverRegion all_damage; - - guint overlays; - gboolean compositor_active; - gboolean clip_changed; - - GSList *dock_windows; -} MetaCompScreen; - -typedef struct _MetaCompWindow -{ - MetaScreen *screen; - MetaWindow *window; /* May be NULL if this window isn't managed by Metacity */ - Window id; - XWindowAttributes attrs; - -#ifdef HAVE_NAME_WINDOW_PIXMAP - Pixmap back_pixmap; - - /* When the window is shaded back_pixmap will be replaced with the pixmap - for the shaded window. This is a copy of the original unshaded window - so that we can still see what the window looked like when it is needed - for the _get_window_pixmap function */ - Pixmap shaded_back_pixmap; -#endif - - int mode; - - gboolean damaged; - gboolean shaped; - - MetaCompWindowType type; - - Damage damage; - Picture picture; - Picture alpha_pict; - - gboolean needs_shadow; - MetaShadowType shadow_type; - Picture shadow_pict; - - XserverRegion border_size; - XserverRegion extents; - - Picture shadow; - int shadow_dx; - int shadow_dy; - int shadow_width; - int shadow_height; - - guint opacity; - - XserverRegion border_clip; - - gboolean updates_frozen; - gboolean update_pending; -} MetaCompWindow; - -#define OPAQUE 0xffffffff - -#define WINDOW_SOLID 0 -#define WINDOW_ARGB 1 - -#define SHADOW_SMALL_RADIUS 3.0 -#define SHADOW_MEDIUM_RADIUS 6.0 -#define SHADOW_LARGE_RADIUS 12.0 - -#define SHADOW_SMALL_OFFSET_X (SHADOW_SMALL_RADIUS * -3 / 2) -#define SHADOW_SMALL_OFFSET_Y (SHADOW_SMALL_RADIUS * -3 / 2) -#define SHADOW_MEDIUM_OFFSET_X (SHADOW_MEDIUM_RADIUS * -3 / 2) -#define SHADOW_MEDIUM_OFFSET_Y (SHADOW_MEDIUM_RADIUS * -5 / 4) -#define SHADOW_LARGE_OFFSET_X -15 -#define SHADOW_LARGE_OFFSET_Y -15 - -#define SHADOW_OPACITY 0.66 - -#define TRANS_OPACITY 0.75 - -#define DISPLAY_COMPOSITOR(display) ((MetaCompositorXRender *) meta_display_get_compositor (display)) - -/* Gaussian stuff for creating the shadows */ -static double -gaussian (double r, - double x, - double y) -{ - return ((1 / (sqrt (2 * G_PI * r))) * - exp ((- (x * x + y * y)) / (2 * r * r))); -} - -static conv * -make_gaussian_map (double r) -{ - conv *c; - int size, centre; - int x, y; - double t, g; - - size = ((int) ceil ((r * 3)) + 1) & ~1; - centre = size / 2; - c = g_malloc (sizeof (conv) + size * size * sizeof (double)); - c->size = size; - c->data = (double *) (c + 1); - t = 0.0; - - for (y = 0; y < size; y++) - { - for (x = 0; x < size; x++) - { - g = gaussian (r, (double) (x - centre), (double) (y - centre)); - t += g; - c->data[y * size + x] = g; - } - } - - for (y = 0; y < size; y++) - { - for (x = 0; x < size; x++) - { - c->data[y * size + x] /= t; - } - } - - return c; -} - -static void -dump_xserver_region (const char *location, - MetaDisplay *display, - XserverRegion region) -{ - MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display); - Display *xdisplay = meta_display_get_xdisplay (display); - int nrects; - XRectangle *rects; - XRectangle bounds; - - if (!compositor->debug) - return; - - if (region) - { - rects = XFixesFetchRegionAndBounds (xdisplay, region, &nrects, &bounds); - if (nrects > 0) - { - int i; - fprintf (stderr, "%s (XSR): %d rects, bounds: %d,%d (%d,%d)\n", - location, nrects, bounds.x, bounds.y, bounds.width, bounds.height); - for (i = 1; i < nrects; i++) - fprintf (stderr, "\t%d,%d (%d,%d)\n", - rects[i].x, rects[i].y, rects[i].width, rects[i].height); - } - else - fprintf (stderr, "%s (XSR): empty\n", location); - XFree (rects); - } - else - fprintf (stderr, "%s (XSR): null\n", location); -} - -/* -* A picture will help -* -* -center 0 width width+center -* -center +-----+-------------------+-----+ -* | | | | -* | | | | -* 0 +-----+-------------------+-----+ -* | | | | -* | | | | -* | | | | -* height +-----+-------------------+-----+ -* | | | | -* height+ | | | | -* center +-----+-------------------+-----+ -*/ -static guchar -sum_gaussian (conv *map, - double opacity, - int x, - int y, - int width, - int height) -{ - double *g_data, *g_line; - double v; - int fx, fy; - int fx_start, fx_end; - int fy_start, fy_end; - int g_size, centre; - - g_line = map->data; - g_size = map->size; - centre = g_size / 2; - fx_start = centre - x; - if (fx_start < 0) - fx_start = 0; - - fx_end = width + centre - x; - if (fx_end > g_size) - fx_end = g_size; - - fy_start = centre - y; - if (fy_start < 0) - fy_start = 0; - - fy_end = height + centre - y; - if (fy_end > g_size) - fy_end = g_size; - - g_line = g_line + fy_start * g_size + fx_start; - - v = 0.0; - for (fy = fy_start; fy < fy_end; fy++) - { - g_data = g_line; - g_line += g_size; - - for (fx = fx_start; fx < fx_end; fx++) - v += *g_data++; - } - - if (v > 1.0) - v = 1.0; - - return ((guchar) (v * opacity * 255.0)); -} - -/* precompute shadow corners and sides to save time for large windows */ -static void -presum_gaussian (shadow *shad) -{ - int centre; - int opacity, x, y; - int msize; - conv *map; - - map = shad->gaussian_map; - msize = map->size; - centre = map->size / 2; - - if (shad->shadow_corner) - g_free (shad->shadow_corner); - if (shad->shadow_top) - g_free (shad->shadow_top); - - shad->shadow_corner = (guchar *)(g_malloc ((msize + 1) * (msize + 1) * 26)); - shad->shadow_top = (guchar *) (g_malloc ((msize + 1) * 26)); - - for (x = 0; x <= msize; x++) - { - - shad->shadow_top[25 * (msize + 1) + x] = - sum_gaussian (map, 1, x - centre, centre, msize * 2, msize * 2); - for (opacity = 0; opacity < 25; opacity++) - { - shad->shadow_top[opacity * (msize + 1) + x] = - shad->shadow_top[25 * (msize + 1) + x] * opacity / 25; - } - - for (y = 0; y <= x; y++) - { - shad->shadow_corner[25 * (msize + 1) * (msize + 1) - + y * (msize + 1) - + x] - = sum_gaussian (map, 1, x - centre, y - centre, - msize * 2, msize * 2); - - shad->shadow_corner[25 * (msize + 1) * (msize + 1) - + x * (msize + 1) + y] = - shad->shadow_corner[25 * (msize + 1) * (msize + 1) - + y * (msize + 1) + x]; - - for (opacity = 0; opacity < 25; opacity++) - { - shad->shadow_corner[opacity * (msize + 1) * (msize + 1) - + y * (msize + 1) + x] - = shad->shadow_corner[opacity * (msize + 1) * (msize + 1) - + x * (msize + 1) + y] - = shad->shadow_corner[25 * (msize + 1) * (msize + 1) - + y * (msize + 1) + x] * opacity / 25; - } - } - } -} - -static void -generate_shadows (MetaCompScreen *info) -{ - double radii[LAST_SHADOW_TYPE] = {SHADOW_SMALL_RADIUS, - SHADOW_MEDIUM_RADIUS, - SHADOW_LARGE_RADIUS}; - int i; - - for (i = 0; i < LAST_SHADOW_TYPE; i++) { - shadow *shad = g_new0 (shadow, 1); - - shad->gaussian_map = make_gaussian_map (radii[i]); - presum_gaussian (shad); - - info->shadows[i] = shad; - } -} - -static XImage * -make_shadow (MetaDisplay *display, - MetaScreen *screen, - MetaShadowType shadow_type, - double opacity, - int width, - int height) -{ - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XImage *ximage; - guchar *data; - shadow *shad; - int msize; - int ylimit, xlimit; - int swidth, sheight; - int centre; - int x, y; - guchar d; - int x_diff; - int opacity_int = (int)(opacity * 25); - int screen_number = meta_screen_get_screen_number (screen); - - if (info==NULL) - { - return NULL; - } - - shad = info->shadows[shadow_type]; - msize = shad->gaussian_map->size; - swidth = width + msize; - sheight = height + msize; - centre = msize / 2; - - data = g_malloc (swidth * sheight * sizeof (guchar)); - - ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, screen_number), - 8, ZPixmap, 0, (char *) data, - swidth, sheight, 8, swidth * sizeof (guchar)); - if (!ximage) - { - g_free (data); - return NULL; - } - - /* - * Build the gaussian in sections - */ - - /* - * centre (fill the complete data array - */ - if (msize > 0) - d = shad->shadow_top[opacity_int * (msize + 1) + msize]; - else - d = sum_gaussian (shad->gaussian_map, opacity, centre, - centre, width, height); - memset (data, d, sheight * swidth); - - /* - * corners - */ - ylimit = msize; - if (ylimit > sheight / 2) - ylimit = (sheight + 1) / 2; - - xlimit = msize; - if (xlimit > swidth / 2) - xlimit = (swidth + 1) / 2; - - for (y = 0; y < ylimit; y++) - { - for (x = 0; x < xlimit; x++) - { - - if (xlimit == msize && ylimit == msize) - d = shad->shadow_corner[opacity_int * (msize + 1) * (msize + 1) + y * (msize + 1) + x]; - else - d = sum_gaussian (shad->gaussian_map, opacity, x - centre, - y - centre, width, height); - - data[y * swidth + x] = d; - data[(sheight - y - 1) * swidth + x] = d; - data[(sheight - y - 1) * swidth + (swidth - x - 1)] = d; - data[y * swidth + (swidth - x - 1)] = d; - } - } - - /* top/bottom */ - x_diff = swidth - (msize * 2); - if (x_diff > 0 && ylimit > 0) - { - for (y = 0; y < ylimit; y++) - { - if (ylimit == msize) - d = shad->shadow_top[opacity_int * (msize + 1) + y]; - else - d = sum_gaussian (shad->gaussian_map, opacity, centre, - y - centre, width, height); - - memset (&data[y * swidth + msize], d, x_diff); - memset (&data[(sheight - y - 1) * swidth + msize], d, x_diff); - } - } - - /* - * sides - */ - for (x = 0; x < xlimit; x++) - { - if (xlimit == msize) - d = shad->shadow_top[opacity_int * (msize + 1) + x]; - else - d = sum_gaussian (shad->gaussian_map, opacity, x - centre, - centre, width, height); - - for (y = msize; y < sheight - msize; y++) - { - data[y * swidth + x] = d; - data[y * swidth + (swidth - x - 1)] = d; - } - } - - return ximage; -} - -static Picture -shadow_picture (MetaDisplay *display, - MetaScreen *screen, - MetaShadowType shadow_type, - double opacity, - Picture alpha_pict, - int width, - int height, - int *wp, - int *hp) -{ - Display *xdisplay = meta_display_get_xdisplay (display); - XImage *shadow_image; - Pixmap shadow_pixmap; - Picture shadow_picture; - Window xroot = meta_screen_get_xroot (screen); - GC gc; - - shadow_image = make_shadow (display, screen, shadow_type, - opacity, width, height); - if (!shadow_image) - return None; - - shadow_pixmap = XCreatePixmap (xdisplay, xroot, - shadow_image->width, shadow_image->height, 8); - if (!shadow_pixmap) - { - XDestroyImage (shadow_image); - return None; - } - - shadow_picture = XRenderCreatePicture (xdisplay, shadow_pixmap, - XRenderFindStandardFormat (xdisplay, -PictStandardA8), - 0, 0); - if (!shadow_picture) - { - XDestroyImage (shadow_image); - XFreePixmap (xdisplay, shadow_pixmap); - return None; - } - - gc = XCreateGC (xdisplay, shadow_pixmap, 0, 0); - if (!gc) - { - XDestroyImage (shadow_image); - XFreePixmap (xdisplay, shadow_pixmap); - XRenderFreePicture (xdisplay, shadow_picture); - return None; - } - - XPutImage (xdisplay, shadow_pixmap, gc, shadow_image, 0, 0, 0, 0, - shadow_image->width, shadow_image->height); - *wp = shadow_image->width; - *hp = shadow_image->height; - - XFreeGC (xdisplay, gc); - XDestroyImage (shadow_image); - XFreePixmap (xdisplay, shadow_pixmap); - - return shadow_picture; -} - -static MetaCompWindow * -find_window_for_screen (MetaScreen *screen, - Window xwindow) -{ - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - - if (info == NULL) - return NULL; - - return g_hash_table_lookup (info->windows_by_xid, (gpointer) xwindow); -} - -static MetaCompWindow * -find_window_in_display (MetaDisplay *display, - Window xwindow) -{ - GSList *index; - - for (index = meta_display_get_screens (display); index; index = index->next) - { - MetaCompWindow *cw = find_window_for_screen (index->data, xwindow); - - if (cw != NULL) - return cw; - } - - return NULL; -} - -static MetaCompWindow * -find_window_for_child_window_in_display (MetaDisplay *display, - Window xwindow) -{ - Window ignored1, *ignored2; - Window parent; - guint ignored_children; - - XQueryTree (meta_display_get_xdisplay (display), xwindow, &ignored1, - &parent, &ignored2, &ignored_children); - - if (parent != None) - return find_window_in_display (display, parent); - - return NULL; -} - -static Picture -solid_picture (MetaDisplay *display, - MetaScreen *screen, - gboolean argb, - double a, - double r, - double g, - double b) -{ - Display *xdisplay = meta_display_get_xdisplay (display); - Pixmap pixmap; - Picture picture; - XRenderPictureAttributes pa; - XRenderPictFormat *render_format; - XRenderColor c; - Window xroot = meta_screen_get_xroot (screen); - - render_format = XRenderFindStandardFormat (xdisplay, - argb ? PictStandardARGB32 : PictStandardA8); - - pixmap = XCreatePixmap (xdisplay, xroot, 1, 1, argb ? 32 : 8); - g_return_val_if_fail (pixmap != None, None); - - pa.repeat = TRUE; - picture = XRenderCreatePicture (xdisplay, pixmap, render_format, - CPRepeat, &pa); - if (picture == None) - { - XFreePixmap (xdisplay, pixmap); - g_warning ("(picture != None) failed"); - return None; - } - - c.alpha = a * 0xffff; - c.red = r * 0xffff; - c.green = g * 0xffff; - c.blue = b * 0xffff; - - XRenderFillRectangle (xdisplay, PictOpSrc, picture, &c, 0, 0, 1, 1); - XFreePixmap (xdisplay, pixmap); - - return picture; -} - -static Picture -root_tile (MetaScreen *screen) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - Picture picture; - Pixmap pixmap; - gboolean fill = FALSE; - XRenderPictureAttributes pa; - XRenderPictFormat *format; - int p; - Atom background_atoms[2]; - Atom pixmap_atom; - int screen_number = meta_screen_get_screen_number (screen); - Window xroot = meta_screen_get_xroot (screen); - - pixmap = None; - background_atoms[0] = DISPLAY_COMPOSITOR (display)->atom_x_root_pixmap; - background_atoms[1] = DISPLAY_COMPOSITOR (display)->atom_x_set_root; - - pixmap_atom = XInternAtom (xdisplay, "PIXMAP", False); - for (p = 0; p < 2; p++) - { - Atom actual_type; - int actual_format; - gulong nitems, bytes_after; - guchar *prop; - - if (XGetWindowProperty (xdisplay, xroot, - background_atoms[p], - 0, 4, FALSE, AnyPropertyType, - &actual_type, &actual_format, - &nitems, &bytes_after, &prop) == Success) - { - if (actual_type == pixmap_atom && - actual_format == 32 && - nitems == 1) - { - memcpy (&pixmap, prop, 4); - XFree (prop); - fill = FALSE; - break; - } - } - } - - if (!pixmap) - { - pixmap = XCreatePixmap (xdisplay, xroot, 1, 1, - DefaultDepth (xdisplay, screen_number)); - g_return_val_if_fail (pixmap != None, None); - fill = TRUE; - } - - pa.repeat = TRUE; - format = XRenderFindVisualFormat (xdisplay, DefaultVisual (xdisplay, - screen_number)); - g_return_val_if_fail (format != NULL, None); - - picture = XRenderCreatePicture (xdisplay, pixmap, format, CPRepeat, &pa); - if ((picture != None) && (fill)) - { - XRenderColor c; - - /* Background default to just plain ugly grey */ - c.red = 0x8080; - c.green = 0x8080; - c.blue = 0x8080; - c.alpha = 0xffff; - - XRenderFillRectangle (xdisplay, PictOpSrc, picture, &c, 0, 0, 1, 1); - XFreePixmap (xdisplay, pixmap); - } - - return picture; -} - -static Picture -create_root_buffer (MetaScreen *screen) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - Picture pict; - XRenderPictFormat *format; - Pixmap root_pixmap; - Visual *visual; - int depth, screen_width, screen_height, screen_number; - - if (info == NULL) - { - return None; - } - - meta_screen_get_size (screen, &screen_width, &screen_height); - screen_number = meta_screen_get_screen_number (screen); - visual = DefaultVisual (xdisplay, screen_number); - depth = DefaultDepth (xdisplay, screen_number); - - format = XRenderFindVisualFormat (xdisplay, visual); - g_return_val_if_fail (format != NULL, None); - - root_pixmap = XCreatePixmap (xdisplay, info->output, - screen_width, screen_height, depth); - g_return_val_if_fail (root_pixmap != None, None); - - pict = XRenderCreatePicture (xdisplay, root_pixmap, format, 0, NULL); - XFreePixmap (xdisplay, root_pixmap); - - return pict; -} - -static void -paint_root (MetaScreen *screen, - Picture root_buffer) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - int width, height; - - if (info == NULL) - { - return; - } - - g_return_if_fail (root_buffer != None); - - if (info->root_tile == None) - { - info->root_tile = root_tile (screen); - g_return_if_fail (info->root_tile != None); - } - - meta_screen_get_size (screen, &width, &height); - XRenderComposite (xdisplay, PictOpSrc, info->root_tile, None, root_buffer, - 0, 0, 0, 0, 0, 0, width, height); -} - -static gboolean -window_has_shadow (MetaCompWindow *cw) -{ - MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen); - - if (info == NULL || info->have_shadows == FALSE) - return FALSE; - - /* Always put a shadow around windows with a frame - This should override - the restriction about not putting a shadow around shaped windows - as the frame might be the reason the window is shaped */ - if (cw->window) - { - if (meta_window_get_frame (cw->window)) { - meta_verbose ("Window has shadow because it has a frame\n"); - return TRUE; - } - } - - /* Never put a shadow around shaped windows */ - if (cw->shaped) { - meta_verbose ("Window has no shadow as it is shaped\n"); - return FALSE; - } - - /* Don't put shadow around DND icon windows */ - if (cw->type == META_COMP_WINDOW_DND || - cw->type == META_COMP_WINDOW_DESKTOP) { - meta_verbose ("Window has no shadow as it is DND or Desktop\n"); - return FALSE; - } - - if (cw->mode != WINDOW_ARGB) { - meta_verbose ("Window has shadow as it is not ARGB\n"); - return TRUE; - } - - if (cw->type == META_COMP_WINDOW_MENU || - cw->type == META_COMP_WINDOW_DROPDOWN_MENU) { - meta_verbose ("Window has shadow as it is a menu\n"); - return TRUE; - } - - if (cw->type == META_COMP_WINDOW_TOOLTIP) { - meta_verbose ("Window has shadow as it is a tooltip\n"); - return TRUE; - } - - meta_verbose ("Window has no shadow as it fell through\n"); - return FALSE; -} - -double shadow_offsets_x[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_X, - SHADOW_MEDIUM_OFFSET_X, - SHADOW_LARGE_OFFSET_X}; -double shadow_offsets_y[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_Y, - SHADOW_MEDIUM_OFFSET_Y, - SHADOW_LARGE_OFFSET_Y}; -static XserverRegion -win_extents (MetaCompWindow *cw) -{ - MetaScreen *screen = cw->screen; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XRectangle r; - - r.x = cw->attrs.x; - r.y = cw->attrs.y; - r.width = cw->attrs.width + cw->attrs.border_width * 2; - r.height = cw->attrs.height + cw->attrs.border_width * 2; - - if (cw->needs_shadow) - { - XRectangle sr; - - cw->shadow_dx = shadow_offsets_x [cw->shadow_type]; - cw->shadow_dy = shadow_offsets_y [cw->shadow_type]; - - if (!cw->shadow) - { - double opacity = SHADOW_OPACITY; - if (cw->opacity != (guint) OPAQUE) - opacity = opacity * ((double) cw->opacity) / ((double) OPAQUE); - - cw->shadow = shadow_picture (display, screen, cw->shadow_type, - opacity, cw->alpha_pict, - cw->attrs.width + cw->attrs.border_width * 2, - cw->attrs.height + cw->attrs.border_width * 2, - &cw->shadow_width, &cw->shadow_height); - } - - sr.x = cw->attrs.x + cw->shadow_dx; - sr.y = cw->attrs.y + cw->shadow_dy; - sr.width = cw->shadow_width; - sr.height = cw->shadow_height; - - if (sr.x < r.x) - { - r.width = (r.x + r.width) - sr.x; - r.x = sr.x; - } - - if (sr.y < r.y) - { - r.height = (r.y + r.height) - sr.y; - r.y = sr.y; - } - - if (sr.x + sr.width > r.x + r.width) - r.width = sr.x + sr.width - r.x; - - if (sr.y + sr.height > r.y + r.height) - r.height = sr.y + sr.height - r.y; - } - - return XFixesCreateRegion (xdisplay, &r, 1); -} - -static XserverRegion -border_size (MetaCompWindow *cw) -{ - MetaScreen *screen = cw->screen; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XserverRegion border; - - meta_error_trap_push (display); - border = XFixesCreateRegionFromWindow (xdisplay, cw->id, - WindowRegionBounding); - meta_error_trap_pop (display, FALSE); - - g_return_val_if_fail (border != None, None); - XFixesTranslateRegion (xdisplay, border, - cw->attrs.x + cw->attrs.border_width, - cw->attrs.y + cw->attrs.border_width); - return border; -} - -static XRenderPictFormat * -get_window_format (MetaCompWindow *cw) -{ - MetaScreen *screen = cw->screen; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XRenderPictFormat *format; - int screen_number = meta_screen_get_screen_number (screen); - - format = XRenderFindVisualFormat (xdisplay, cw->attrs.visual); - if (!format) - format = XRenderFindVisualFormat (xdisplay, - DefaultVisual (xdisplay, screen_number)); - return format; -} - -static Picture -get_window_picture (MetaCompWindow *cw) -{ - MetaScreen *screen = cw->screen; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XRenderPictureAttributes pa; - XRenderPictFormat *format; - Drawable draw; - - draw = cw->id; - - meta_error_trap_push (display); - -#ifdef HAVE_NAME_WINDOW_PIXMAP - if (have_name_window_pixmap (display)) - { - if (cw->back_pixmap == None) - cw->back_pixmap = XCompositeNameWindowPixmap (xdisplay, cw->id); - - if (cw->back_pixmap != None) - draw = cw->back_pixmap; - } -#endif - - format = get_window_format (cw); - if (format) - { - Picture pict; - - pa.subwindow_mode = IncludeInferiors; - - pict = XRenderCreatePicture (xdisplay, draw, format, CPSubwindowMode, &pa); - meta_error_trap_pop (display, FALSE); - - return pict; - } - - meta_error_trap_pop (display, FALSE); - return None; -} - -static void -paint_dock_shadows (MetaScreen *screen, - Picture root_buffer, - XserverRegion region) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - GSList *d; - - if (info == NULL) - { - return; - } - - for (d = info->dock_windows; d; d = d->next) - { - MetaCompWindow *cw = d->data; - XserverRegion shadow_clip; - - if (cw->shadow) - { - shadow_clip = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesIntersectRegion (xdisplay, shadow_clip, - cw->border_clip, region); - - XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, shadow_clip); - - XRenderComposite (xdisplay, PictOpOver, info->black_picture, - cw->shadow, root_buffer, - 0, 0, 0, 0, - cw->attrs.x + cw->shadow_dx, - cw->attrs.y + cw->shadow_dy, - cw->shadow_width, cw->shadow_height); - XFixesDestroyRegion (xdisplay, shadow_clip); - } - } -} - -static void -paint_windows (MetaScreen *screen, - GList *windows, - Picture root_buffer, - XserverRegion region) -{ - MetaDisplay *display = meta_screen_get_display (screen); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - GList *index, *last; - int screen_width, screen_height, screen_number; - Window xroot; - MetaCompWindow *cw; - XserverRegion paint_region, desktop_region; - - if (info == NULL) - { - return; - } - - meta_screen_get_size (screen, &screen_width, &screen_height); - screen_number = meta_screen_get_screen_number (screen); - xroot = meta_screen_get_xroot (screen); - - if (region == None) - { - XRectangle r; - r.x = 0; - r.y = 0; - r.width = screen_width; - r.height = screen_height; - paint_region = XFixesCreateRegion (xdisplay, &r, 1); - } - else - { - paint_region = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, paint_region, region); - } - - desktop_region = None; - - /* - * Painting from top to bottom, reducing the clipping area at - * each iteration. Only the opaque windows are painted 1st. - */ - last = NULL; - for (index = windows; index; index = index->next) - { - /* Store the last window we dealt with */ - last = index; - - cw = (MetaCompWindow *) index->data; - if (!cw->damaged) - { - /* Not damaged */ - continue; - } - -#if 0 - if ((cw->attrs.x + cw->attrs.width < 1) || - (cw->attrs.y + cw->attrs.height < 1) || - (cw->attrs.x >= screen_width) || (cw->attrs.y >= screen_height)) - { - /* Off screen */ - continue; - } -#endif - - if (cw->picture == None) - cw->picture = get_window_picture (cw); - - /* If the clip region of the screen has been changed - then we need to recreate the extents of the window */ - if (info->clip_changed) - { - if (cw->border_size) - { - XFixesDestroyRegion (xdisplay, cw->border_size); - cw->border_size = None; - } - -#if 0 - if (cw->extents) - { - XFixesDestroyRegion (xdisplay, cw->extents); - cw->extents = None; - } -#endif - } - - if (cw->border_size == None) - cw->border_size = border_size (cw); - - if (cw->extents == None) - cw->extents = win_extents (cw); - - if (cw->mode == WINDOW_SOLID) - { - int x, y, wid, hei; - -#ifdef HAVE_NAME_WINDOW_PIXMAP - if (have_name_window_pixmap (display)) - { - x = cw->attrs.x; - y = cw->attrs.y; - wid = cw->attrs.width + cw->attrs.border_width * 2; - hei = cw->attrs.height + cw->attrs.border_width * 2; - } - else -#endif - { - x = cw->attrs.x + cw->attrs.border_width; - y = cw->attrs.y + cw->attrs.border_width; - wid = cw->attrs.width; - hei = cw->attrs.height; - } - - XFixesSetPictureClipRegion (xdisplay, root_buffer, - 0, 0, paint_region); - XRenderComposite (xdisplay, PictOpSrc, cw->picture, - None, root_buffer, 0, 0, 0, 0, - x, y, wid, hei); - - if (cw->type == META_COMP_WINDOW_DESKTOP) - { - desktop_region = XFixesCreateRegion (xdisplay, 0, 0); - XFixesCopyRegion (xdisplay, desktop_region, paint_region); - } - - XFixesSubtractRegion (xdisplay, paint_region, - paint_region, cw->border_size); - } - - if (!cw->border_clip) - { - cw->border_clip = XFixesCreateRegion (xdisplay, 0, 0); - XFixesCopyRegion (xdisplay, cw->border_clip, paint_region); - } - } - - XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, paint_region); - paint_root (screen, root_buffer); - - paint_dock_shadows (screen, root_buffer, desktop_region == None ? - paint_region : desktop_region); - if (desktop_region != None) - XFixesDestroyRegion (xdisplay, desktop_region); - - /* - * Painting from bottom to top, translucent windows and shadows are painted - */ - for (index = last; index; index = index->prev) - { - cw = (MetaCompWindow *) index->data; - - if (cw->picture) - { - if (cw->shadow && cw->type != META_COMP_WINDOW_DOCK) - { - XserverRegion shadow_clip; - - shadow_clip = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesSubtractRegion (xdisplay, shadow_clip, cw->border_clip, - cw->border_size); - XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, - shadow_clip); - - XRenderComposite (xdisplay, PictOpOver, info->black_picture, - cw->shadow, root_buffer, - 0, 0, 0, 0, - cw->attrs.x + cw->shadow_dx, - cw->attrs.y + cw->shadow_dy, - cw->shadow_width, cw->shadow_height); - if (shadow_clip) - XFixesDestroyRegion (xdisplay, shadow_clip); - } - - if ((cw->opacity != (guint) OPAQUE) && !(cw->alpha_pict)) - { - cw->alpha_pict = solid_picture (display, screen, FALSE, - (double) cw->opacity / OPAQUE, - 0, 0, 0); - } - - XFixesIntersectRegion (xdisplay, cw->border_clip, cw->border_clip, - cw->border_size); - XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, - cw->border_clip); - if (cw->mode == WINDOW_ARGB) - { - int x, y, wid, hei; -#ifdef HAVE_NAME_WINDOW_PIXMAP - if (have_name_window_pixmap (display)) - { - x = cw->attrs.x; - y = cw->attrs.y; - wid = cw->attrs.width + cw->attrs.border_width * 2; - hei = cw->attrs.height + cw->attrs.border_width * 2; - } - else -#endif - { - x = cw->attrs.x + cw->attrs.border_width; - y = cw->attrs.y + cw->attrs.border_width; - wid = cw->attrs.width; - hei = cw->attrs.height; - } - - XRenderComposite (xdisplay, PictOpOver, cw->picture, - cw->alpha_pict, root_buffer, 0, 0, 0, 0, - x, y, wid, hei); - } - } - - if (cw->border_clip) - { - XFixesDestroyRegion (xdisplay, cw->border_clip); - cw->border_clip = None; - } - } - - XFixesDestroyRegion (xdisplay, paint_region); -} - -static void -paint_all (MetaScreen *screen, - XserverRegion region) -{ - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - int screen_width, screen_height; - - /* Set clipping to the given region */ - XFixesSetPictureClipRegion (xdisplay, info->root_picture, 0, 0, region); - - meta_screen_get_size (screen, &screen_width, &screen_height); - - if (DISPLAY_COMPOSITOR (display)->show_redraw) - { - Picture overlay; - - dump_xserver_region ("paint_all", display, region); - - /* Make a random colour overlay */ - overlay = solid_picture (display, screen, TRUE, 1, /* 0.3, alpha */ - ((double) (rand () % 100)) / 100.0, - ((double) (rand () % 100)) / 100.0, - ((double) (rand () % 100)) / 100.0); - - XRenderComposite (xdisplay, PictOpOver, overlay, None, info->root_picture, - 0, 0, 0, 0, 0, 0, screen_width, screen_height); - XRenderFreePicture (xdisplay, overlay); - XFlush (xdisplay); - usleep (100 * 1000); - } - - if (info->root_buffer == None) - info->root_buffer = create_root_buffer (screen); - - paint_windows (screen, info->windows, info->root_buffer, region); - - XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0, region); - XRenderComposite (xdisplay, PictOpSrc, info->root_buffer, None, - info->root_picture, 0, 0, 0, 0, 0, 0, - screen_width, screen_height); -} - -static void -repair_screen (MetaScreen *screen) -{ - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - - if (info!=NULL && info->all_damage != None) - { - meta_error_trap_push (display); - paint_all (screen, info->all_damage); - XFixesDestroyRegion (xdisplay, info->all_damage); - info->all_damage = None; - info->clip_changed = FALSE; - meta_error_trap_pop (display, FALSE); - } -} - -static void -repair_display (MetaDisplay *display) -{ - GSList *screens = meta_display_get_screens (display); - MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display); - -#ifdef USE_IDLE_REPAINT - if (compositor->repaint_id > 0) - { - g_source_remove (compositor->repaint_id); - compositor->repaint_id = 0; - } -#endif - - for (; screens; screens = screens->next) - repair_screen ((MetaScreen *) screens->data); -} - -#ifdef USE_IDLE_REPAINT -static gboolean -compositor_idle_cb (gpointer data) -{ - MetaCompositorXRender *compositor = (MetaCompositorXRender *) data; - - compositor->repaint_id = 0; - repair_display (compositor->display); - - return FALSE; -} - -static void -add_repair (MetaDisplay *display) -{ - MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display); - - if (compositor->repaint_id > 0) - return; - -#if 1 - compositor->repaint_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, - compositor_idle_cb, compositor, - NULL); -#else - /* Limit it to 50fps */ - compositor->repaint_id = g_timeout_add_full (G_PRIORITY_HIGH, 20, - compositor_idle_cb, compositor, - NULL); -#endif -} -#endif - -static void -add_damage (MetaScreen *screen, - XserverRegion damage) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - - /* dump_xserver_region ("add_damage", display, damage); */ - - if (info != NULL && info->all_damage) - { - XFixesUnionRegion (xdisplay, info->all_damage, info->all_damage, damage); - XFixesDestroyRegion (xdisplay, damage); - } - else - info->all_damage = damage; - -#ifdef USE_IDLE_REPAINT - add_repair (display); -#endif -} - -static void -damage_screen (MetaScreen *screen) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XserverRegion region; - int width, height; - XRectangle r; - - r.x = 0; - r.y = 0; - meta_screen_get_size (screen, &width, &height); - r.width = width; - r.height = height; - - region = XFixesCreateRegion (xdisplay, &r, 1); - dump_xserver_region ("damage_screen", display, region); - add_damage (screen, region); -} - -static void -repair_win (MetaCompWindow *cw) -{ - MetaScreen *screen = cw->screen; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XserverRegion parts; - - meta_error_trap_push (display); - if (!cw->damaged) - { - parts = win_extents (cw); - XDamageSubtract (xdisplay, cw->damage, None, None); - } - else - { - parts = XFixesCreateRegion (xdisplay, 0, 0); - XDamageSubtract (xdisplay, cw->damage, None, parts); - XFixesTranslateRegion (xdisplay, parts, - cw->attrs.x + cw->attrs.border_width, - cw->attrs.y + cw->attrs.border_width); - } - - meta_error_trap_pop (display, FALSE); - - dump_xserver_region ("repair_win", display, parts); - add_damage (screen, parts); - cw->damaged = TRUE; -} - -static void -free_win (MetaCompWindow *cw, - gboolean destroy) -{ - MetaDisplay *display = meta_screen_get_display (cw->screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen); - -#ifdef HAVE_NAME_WINDOW_PIXMAP - if (have_name_window_pixmap (display)) - { - /* See comment in map_win */ - if (cw->back_pixmap && destroy) - { - XFreePixmap (xdisplay, cw->back_pixmap); - cw->back_pixmap = None; - } - - if (cw->shaded_back_pixmap && destroy) - { - XFreePixmap (xdisplay, cw->shaded_back_pixmap); - cw->shaded_back_pixmap = None; - } - } -#endif - - if (cw->picture) - { - XRenderFreePicture (xdisplay, cw->picture); - cw->picture = None; - } - - if (cw->shadow) - { - XRenderFreePicture (xdisplay, cw->shadow); - cw->shadow = None; - } - - if (cw->alpha_pict) - { - XRenderFreePicture (xdisplay, cw->alpha_pict); - cw->alpha_pict = None; - } - - if (cw->shadow_pict) - { - XRenderFreePicture (xdisplay, cw->shadow_pict); - cw->shadow_pict = None; - } - - if (cw->border_size) - { - XFixesDestroyRegion (xdisplay, cw->border_size); - cw->border_size = None; - } - - if (cw->border_clip) - { - XFixesDestroyRegion (xdisplay, cw->border_clip); - cw->border_clip = None; - } - - if (cw->extents) - { - XFixesDestroyRegion (xdisplay, cw->extents); - cw->extents = None; - } - - if (destroy) - { - if (cw->damage != None) { - meta_error_trap_push (display); - XDamageDestroy (xdisplay, cw->damage); - meta_error_trap_pop (display, FALSE); - - cw->damage = None; - } - - /* The window may not have been added to the list in this case, - but we can check anyway */ - if (info!=NULL && cw->type == META_COMP_WINDOW_DOCK) - info->dock_windows = g_slist_remove (info->dock_windows, cw); - - g_free (cw); - } -} - -static void -map_win (MetaDisplay *display, - MetaScreen *screen, - Window id) -{ - MetaCompWindow *cw = find_window_for_screen (screen, id); - Display *xdisplay = meta_display_get_xdisplay (display); - - if (cw == NULL) - return; - -#ifdef HAVE_NAME_WINDOW_PIXMAP - /* The reason we deallocate this here and not in unmap - is so that we will still have a valid pixmap for - whenever the window is unmapped */ - if (cw->back_pixmap) - { - XFreePixmap (xdisplay, cw->back_pixmap); - cw->back_pixmap = None; - } - - if (cw->shaded_back_pixmap) - { - XFreePixmap (xdisplay, cw->shaded_back_pixmap); - cw->shaded_back_pixmap = None; - } -#endif - - cw->attrs.map_state = IsViewable; - cw->damaged = FALSE; -} - -static void -unmap_win (MetaDisplay *display, - MetaScreen *screen, - Window id) -{ - MetaCompWindow *cw = find_window_for_screen (screen, id); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - - if (cw == NULL || info == NULL) - { - return; - } - - if (cw->window && cw->window == info->focus_window) - info->focus_window = NULL; - - cw->attrs.map_state = IsUnmapped; - cw->damaged = FALSE; - - if (cw->extents != None) - { - dump_xserver_region ("unmap_win", display, cw->extents); - add_damage (screen, cw->extents); - cw->extents = None; - } - - free_win (cw, FALSE); - info->clip_changed = TRUE; -} - -static void -determine_mode (MetaDisplay *display, - MetaScreen *screen, - MetaCompWindow *cw) -{ - XRenderPictFormat *format; - Display *xdisplay = meta_display_get_xdisplay (display); - - if (cw->alpha_pict) - { - XRenderFreePicture (xdisplay, cw->alpha_pict); - cw->alpha_pict = None; - } - - if (cw->shadow_pict) - { - XRenderFreePicture (xdisplay, cw->shadow_pict); - cw->shadow_pict = None; - } - - if (cw->attrs.class == InputOnly) - format = NULL; - else - format = XRenderFindVisualFormat (xdisplay, cw->attrs.visual); - - if ((format && format->type == PictTypeDirect && format->direct.alphaMask) - || cw->opacity != (guint) OPAQUE) - cw->mode = WINDOW_ARGB; - else - cw->mode = WINDOW_SOLID; - - if (cw->extents) - { - XserverRegion damage; - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, cw->extents); - - dump_xserver_region ("determine_mode", display, damage); - add_damage (screen, damage); - } -} - -static gboolean -is_shaped (MetaDisplay *display, - Window xwindow) -{ - Display *xdisplay = meta_display_get_xdisplay (display); - int xws, yws, xbs, ybs; - unsigned wws, hws, wbs, hbs; - int bounding_shaped, clip_shaped; - - if (meta_display_has_shape (display)) - { - XShapeQueryExtents (xdisplay, xwindow, &bounding_shaped, - &xws, &yws, &wws, &hws, &clip_shaped, - &xbs, &ybs, &wbs, &hbs); - return (bounding_shaped != 0); - } - - return FALSE; -} - -static void -get_window_type (MetaDisplay *display, - MetaCompWindow *cw) -{ - MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display); - int n_atoms; - Atom *atoms, type_atom; - int i; - - type_atom = None; - n_atoms = 0; - atoms = NULL; - - meta_prop_get_atom_list (display, cw->id, - compositor->atom_net_wm_window_type, - &atoms, &n_atoms); - - for (i = 0; i < n_atoms; i++) - { - if (atoms[i] == compositor->atom_net_wm_window_type_dnd || - atoms[i] == compositor->atom_net_wm_window_type_desktop || - atoms[i] == compositor->atom_net_wm_window_type_dock || - atoms[i] == compositor->atom_net_wm_window_type_toolbar || - atoms[i] == compositor->atom_net_wm_window_type_menu || - atoms[i] == compositor->atom_net_wm_window_type_dialog || - atoms[i] == compositor->atom_net_wm_window_type_normal || - atoms[i] == compositor->atom_net_wm_window_type_utility || - atoms[i] == compositor->atom_net_wm_window_type_splash || - atoms[i] == compositor->atom_net_wm_window_type_dropdown_menu || - atoms[i] == compositor->atom_net_wm_window_type_tooltip) - { - type_atom = atoms[i]; - break; - } - } - - meta_XFree (atoms); - - if (type_atom == compositor->atom_net_wm_window_type_dnd) - cw->type = META_COMP_WINDOW_DND; - else if (type_atom == compositor->atom_net_wm_window_type_desktop) - cw->type = META_COMP_WINDOW_DESKTOP; - else if (type_atom == compositor->atom_net_wm_window_type_dock) - cw->type = META_COMP_WINDOW_DOCK; - else if (type_atom == compositor->atom_net_wm_window_type_menu) - cw->type = META_COMP_WINDOW_MENU; - else if (type_atom == compositor->atom_net_wm_window_type_dropdown_menu) - cw->type = META_COMP_WINDOW_DROPDOWN_MENU; - else if (type_atom == compositor->atom_net_wm_window_type_tooltip) - cw->type = META_COMP_WINDOW_TOOLTIP; - else - cw->type = META_COMP_WINDOW_NORMAL; - -/* meta_verbose ("Window is %d\n", cw->type); */ -} - -/* Must be called with an error trap in place */ -static void -add_win (MetaScreen *screen, - MetaWindow *window, - Window xwindow) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - MetaCompWindow *cw; - gulong event_mask; - - if (info == NULL) - return; - - if (xwindow == info->output) - return; - - cw = g_new0 (MetaCompWindow, 1); - cw->screen = screen; - cw->window = window; - cw->id = xwindow; - - if (!XGetWindowAttributes (xdisplay, xwindow, &cw->attrs)) - { - g_free (cw); - return; - } - get_window_type (display, cw); - - /* If Metacity has decided not to manage this window then the input events - won't have been set on the window */ - event_mask = cw->attrs.your_event_mask | PropertyChangeMask; - - XSelectInput (xdisplay, xwindow, event_mask); - - -#ifdef HAVE_NAME_WINDOW_PIXMAP - cw->back_pixmap = None; - cw->shaded_back_pixmap = None; -#endif - - cw->damaged = FALSE; - cw->shaped = is_shaped (display, xwindow); - - if (cw->attrs.class == InputOnly) - cw->damage = None; - else - cw->damage = XDamageCreate (xdisplay, xwindow, XDamageReportNonEmpty); - - cw->alpha_pict = None; - cw->shadow_pict = None; - cw->border_size = None; - cw->extents = None; - cw->shadow = None; - cw->shadow_dx = 0; - cw->shadow_dy = 0; - cw->shadow_width = 0; - cw->shadow_height = 0; - - if (window && meta_window_has_focus (window)) - cw->shadow_type = META_SHADOW_LARGE; - else - cw->shadow_type = META_SHADOW_MEDIUM; - - cw->opacity = OPAQUE; - - cw->border_clip = None; - - determine_mode (display, screen, cw); - cw->needs_shadow = window_has_shadow (cw); - - /* Only add the window to the list of docks if it needs a shadow */ - if (cw->type == META_COMP_WINDOW_DOCK && cw->needs_shadow) - { - meta_verbose ("Appending %p to dock windows\n", cw); - info->dock_windows = g_slist_append (info->dock_windows, cw); - } - - /* Add this to the list at the top of the stack - before it is mapped so that map_win can find it again */ - info->windows = g_list_prepend (info->windows, cw); - g_hash_table_insert (info->windows_by_xid, (gpointer) xwindow, cw); - - if (cw->attrs.map_state == IsViewable) - map_win (display, screen, xwindow); -} - -static void -destroy_win (MetaDisplay *display, - Window xwindow, - gboolean gone) -{ - MetaScreen *screen; - MetaCompScreen *info; - MetaCompWindow *cw; - - cw = find_window_in_display (display, xwindow); - - if (cw == NULL) - return; - - screen = cw->screen; - - if (cw->extents != None) - { - dump_xserver_region ("destroy_win", display, cw->extents); - add_damage (screen, cw->extents); - cw->extents = None; - } - - info = meta_screen_get_compositor_data (screen); - if (info != NULL) - { - info->windows = g_list_remove (info->windows, (gconstpointer) cw); - g_hash_table_remove (info->windows_by_xid, (gpointer) xwindow); - } - - free_win (cw, TRUE); -} - -static void -restack_win (MetaCompWindow *cw, - Window above) -{ - MetaScreen *screen; - MetaCompScreen *info; - Window previous_above; - GList *sibling, *next; - - screen = cw->screen; - info = meta_screen_get_compositor_data (screen); - - if (info == NULL) - { - return; - } - - sibling = g_list_find (info->windows, (gconstpointer) cw); - next = g_list_next (sibling); - previous_above = None; - - if (next) - { - MetaCompWindow *ncw = (MetaCompWindow *) next->data; - previous_above = ncw->id; - } - - /* If above is set to None, the window whose state was changed is on - * the bottom of the stack with respect to sibling. - */ - if (above == None) - { - /* Insert at bottom of window stack */ - info->windows = g_list_delete_link (info->windows, sibling); - info->windows = g_list_append (info->windows, cw); - } - else if (previous_above != above) - { - GList *index; - - for (index = info->windows; index; index = index->next) { - MetaCompWindow *cw2 = (MetaCompWindow *) index->data; - if (cw2->id == above) - break; - } - - if (index != NULL) - { - info->windows = g_list_delete_link (info->windows, sibling); - info->windows = g_list_insert_before (info->windows, index, cw); - } - } -} - -static void -resize_win (MetaCompWindow *cw, - int x, - int y, - int width, - int height, - int border_width, - gboolean override_redirect) -{ - MetaScreen *screen = cw->screen; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - XserverRegion damage; - gboolean debug; - - debug = DISPLAY_COMPOSITOR (display)->debug; - - if (cw->extents) - { - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, cw->extents); - } - else - { - damage = None; - if (debug) - fprintf (stderr, "no extents to damage !\n"); - } - - /* { // Damage whole screen each time ! ;-) - XRectangle r; - - r.x = 0; - r.y = 0; - meta_screen_get_size (screen, &r.width, &r.height); - fprintf (stderr, "Damage whole screen %d,%d (%d %d)\n", - r.x, r.y, r.width, r.height); - - damage = XFixesCreateRegion (xdisplay, &r, 1); - } */ - - cw->attrs.x = x; - cw->attrs.y = y; - - if (cw->attrs.width != width || cw->attrs.height != height) - { -#ifdef HAVE_NAME_WINDOW_PIXMAP - if (have_name_window_pixmap (display)) - { - if (cw->shaded_back_pixmap) - { - XFreePixmap (xdisplay, cw->shaded_back_pixmap); - cw->shaded_back_pixmap = None; - } - - if (cw->back_pixmap) - { - /* If the window is shaded, we store the old backing pixmap - so we can return a proper image of the window */ - if (cw->window && meta_window_is_shaded (cw->window)) - { - cw->shaded_back_pixmap = cw->back_pixmap; - cw->back_pixmap = None; - } - else - { - XFreePixmap (xdisplay, cw->back_pixmap); - cw->back_pixmap = None; - } - } - } -#endif - if (cw->picture) - { - XRenderFreePicture (xdisplay, cw->picture); - cw->picture = None; - } - - if (cw->shadow) - { - XRenderFreePicture (xdisplay, cw->shadow); - cw->shadow = None; - } - } - - cw->attrs.width = width; - cw->attrs.height = height; - cw->attrs.border_width = border_width; - cw->attrs.override_redirect = override_redirect; - - if (cw->extents) - XFixesDestroyRegion (xdisplay, cw->extents); - - cw->extents = win_extents (cw); - - if (damage) - { - if (debug) - fprintf (stderr, "Inexplicable intersection with new extents!\n"); - - XFixesUnionRegion (xdisplay, damage, damage, cw->extents); - } - else - { - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, cw->extents); - } - - dump_xserver_region ("resize_win", display, damage); - add_damage (screen, damage); - - if (info != NULL) - { - info->clip_changed = TRUE; - } -} - -/* event processors must all be called with an error trap in place */ -static void -process_circulate_notify (MetaCompositorXRender *compositor, - XCirculateEvent *event) -{ - MetaCompWindow *cw = find_window_in_display (compositor->display, - event->window); - MetaCompWindow *top; - MetaCompScreen *info; - MetaScreen *screen; - GList *first; - Window above; - - if (!cw) - return; - - screen = cw->screen; - info = meta_screen_get_compositor_data (screen); - first = info->windows; - top = (MetaCompWindow *) first->data; - - if ((event->place == PlaceOnTop) && top) - above = top->id; - else - above = None; - restack_win (cw, above); - - if (info != NULL) - { - info->clip_changed = TRUE; - } - -#ifdef USE_IDLE_REPAINT - add_repair (compositor->display); -#endif -} - -static void -process_configure_notify (MetaCompositorXRender *compositor, - XConfigureEvent *event) -{ - MetaDisplay *display = compositor->display; - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompWindow *cw = find_window_in_display (display, event->window); - - if (cw) - { -#if 0 - int x = -1, y = -1, width = -1, height = -1; - int ex = -1, ey = -1, ewidth = -1, eheight = -1; - MetaRectangle *rect; - - if (cw->window) { - rect = meta_window_get_rect (cw->window); - x = rect->x; - y = rect->y; - width = rect->width; - height = rect->height; - } - fprintf (stderr, "configure notify xy (%d %d) -> (%d %d), wh (%d %d) -> (%d %d)\n", - x, y, event->x, event->y, - width, height, event->width, event->height); -#endif - - if (compositor->debug) - { - fprintf (stderr, "configure notify %d %d %d\n", cw->damaged, - cw->shaped, cw->needs_shadow); - dump_xserver_region ("\textents", display, cw->extents); - fprintf (stderr, "\txy (%d %d), wh (%d %d)\n", - event->x, event->y, event->width, event->height); - } - - restack_win (cw, event->above); - resize_win (cw, event->x, event->y, event->width, event->height, - event->border_width, event->override_redirect); - } - else - { - MetaScreen *screen; - MetaCompScreen *info; - - /* Might be the root window? */ - screen = meta_display_screen_for_root (display, event->window); - if (screen == NULL) - return; - - info = meta_screen_get_compositor_data (screen); - if (info != NULL && info->root_buffer) - { - XRenderFreePicture (xdisplay, info->root_buffer); - info->root_buffer = None; - } - - damage_screen (screen); - } -} - -static void -process_property_notify (MetaCompositorXRender *compositor, - XPropertyEvent *event) -{ - MetaDisplay *display = compositor->display; - Display *xdisplay = meta_display_get_xdisplay (display); - MetaScreen *screen; - int p; - Atom background_atoms[2]; - - /* Check for the background property changing */ - background_atoms[0] = compositor->atom_x_root_pixmap; - background_atoms[1] = compositor->atom_x_set_root; - - for (p = 0; p < 2; p++) - { - if (event->atom == background_atoms[p]) - { - screen = meta_display_screen_for_root (display, event->window); - if (screen) - { - MetaCompScreen *info = meta_screen_get_compositor_data (screen); - Window xroot = meta_screen_get_xroot (screen); - - if (info != NULL && info->root_tile) - { - XClearArea (xdisplay, xroot, 0, 0, 0, 0, TRUE); - XRenderFreePicture (xdisplay, info->root_tile); - info->root_tile = None; - - /* Damage the whole screen as we may need to redraw the - background ourselves */ - damage_screen (screen); -#ifdef USE_IDLE_REPAINT - add_repair (display); -#endif - - return; - } - } - } - } - - /* Check for the opacity changing */ - if (event->atom == compositor->atom_net_wm_window_opacity) - { - MetaCompWindow *cw = find_window_in_display (display, event->window); - gulong value; - - if (!cw) - { - /* Applications can set this for their toplevel windows, so - * this must be propagated to the window managed by the compositor - */ - cw = find_window_for_child_window_in_display (display, event->window); - } - - if (!cw) - return; - - if (meta_prop_get_cardinal (display, event->window, - compositor->atom_net_wm_window_opacity, - &value) == FALSE) - value = OPAQUE; - - cw->opacity = (guint)value; - determine_mode (display, cw->screen, cw); - cw->needs_shadow = window_has_shadow (cw); - - if (cw->shadow) - { - XRenderFreePicture (xdisplay, cw->shadow); - cw->shadow = None; - } - - if (cw->extents) - XFixesDestroyRegion (xdisplay, cw->extents); - cw->extents = win_extents (cw); - - cw->damaged = TRUE; -#ifdef USE_IDLE_REPAINT - add_repair (display); -#endif - - return; - } - - if (event->atom == compositor->atom_net_wm_window_type) { - MetaCompWindow *cw = find_window_in_display (display, event->window); - - if (!cw) - return; - - get_window_type (display, cw); - cw->needs_shadow = window_has_shadow (cw); - return; - } -} - -static void -expose_area (MetaScreen *screen, - XRectangle *rects, - int nrects) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XserverRegion region; - - region = XFixesCreateRegion (xdisplay, rects, nrects); - - dump_xserver_region ("expose_area", display, region); - add_damage (screen, region); -} - -static void -process_expose (MetaCompositorXRender *compositor, - XExposeEvent *event) -{ - MetaCompWindow *cw = find_window_in_display (compositor->display, - event->window); - MetaScreen *screen = NULL; - XRectangle rect[1]; - int origin_x = 0, origin_y = 0; - - if (cw != NULL) - { - screen = cw->screen; - origin_x = cw->attrs.x; /* + cw->attrs.border_width; ? */ - origin_y = cw->attrs.y; /* + cw->attrs.border_width; ? */ - } - else - { - screen = meta_display_screen_for_root (compositor->display, - event->window); - if (screen == NULL) - return; - } - - rect[0].x = event->x + origin_x; - rect[0].y = event->y + origin_y; - rect[0].width = event->width; - rect[0].height = event->height; - - expose_area (screen, rect, 1); -} - -static void -process_unmap (MetaCompositorXRender *compositor, - XUnmapEvent *event) -{ - MetaCompWindow *cw; - - if (event->from_configure) - { - /* Ignore unmap caused by parent's resize */ - return; - } - - - cw = find_window_in_display (compositor->display, event->window); - if (cw) - unmap_win (compositor->display, cw->screen, event->window); -} - -static void -process_map (MetaCompositorXRender *compositor, - XMapEvent *event) -{ - MetaCompWindow *cw = find_window_in_display (compositor->display, - event->window); - - if (cw) - map_win (compositor->display, cw->screen, event->window); -} - -static void -process_reparent (MetaCompositorXRender *compositor, - XReparentEvent *event, - MetaWindow *window) -{ - MetaScreen *screen; - - screen = meta_display_screen_for_root (compositor->display, event->parent); - if (screen != NULL) - add_win (screen, window, event->window); - else - destroy_win (compositor->display, event->window, FALSE); -} - -static void -process_create (MetaCompositorXRender *compositor, - XCreateWindowEvent *event, - MetaWindow *window) -{ - MetaScreen *screen; - /* We are only interested in top level windows, others will - be caught by normal metacity functions */ - - screen = meta_display_screen_for_root (compositor->display, event->parent); - if (screen == NULL) - return; - - if (!find_window_in_display (compositor->display, event->window)) - add_win (screen, window, event->window); -} - -static void -process_destroy (MetaCompositorXRender *compositor, - XDestroyWindowEvent *event) -{ - destroy_win (compositor->display, event->window, FALSE); -} - -static gboolean -process_damage (MetaCompositorXRender *compositor, - XDamageNotifyEvent *event) -{ - MetaCompWindow *cw = find_window_in_display (compositor->display, - event->drawable); - if (cw == NULL) - return FALSE; - - repair_win (cw); - -#ifdef USE_IDLE_REPAINT - if (event->more == FALSE) - add_repair (compositor->display); -#endif - - return TRUE; -} - -static void -process_shape (MetaCompositorXRender *compositor, - XShapeEvent *event) -{ - MetaCompWindow *cw = find_window_in_display (compositor->display, - event->window); - - if (cw == NULL) - return; - - if (event->kind == ShapeBounding) - { - if (!event->shaped && cw->shaped) - cw->shaped = FALSE; - - resize_win (cw, cw->attrs.x, cw->attrs.y, - event->width + event->x, event->height + event->y, - cw->attrs.border_width, cw->attrs.override_redirect); - - if (event->shaped && !cw->shaped) - cw->shaped = TRUE; - } -} - -static int -timeout_debug (MetaCompositorXRender *compositor) -{ - compositor->show_redraw = (g_getenv ("METACITY_DEBUG_REDRAWS") != NULL); - compositor->debug = (g_getenv ("METACITY_DEBUG_COMPOSITOR") != NULL); - - return FALSE; -} - -static void -xrender_add_window (MetaCompositor *compositor, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor; - MetaScreen *screen = meta_window_get_screen (window); - - meta_error_trap_push (xrc->display); - add_win (screen, window, meta_window_get_xwindow (window)); - meta_error_trap_pop (xrc->display, FALSE); -#endif -} - -static void -xrender_remove_window (MetaCompositor *compositor, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS -#endif -} - -static void -show_overlay_window (MetaScreen *screen, - Window cow) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - -#ifdef HAVE_COW - if (have_cow (display)) - { - XserverRegion region; - - region = XFixesCreateRegion (xdisplay, NULL, 0); - - XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, 0); - XFixesSetWindowShapeRegion (xdisplay, cow, ShapeInput, 0, 0, region); - - XFixesDestroyRegion (xdisplay, region); - - damage_screen (screen); - } -#endif -} - -static void -hide_overlay_window (MetaScreen *screen, - Window cow) -{ -#ifdef HAVE_COW - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XserverRegion region; - - region = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, region); - XFixesDestroyRegion (xdisplay, region); -#endif -} - -static Window -get_output_window (MetaScreen *screen) -{ - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - Window output, xroot; - - xroot = meta_screen_get_xroot (screen); - -#ifdef HAVE_COW - if (have_cow (display)) - { - output = XCompositeGetOverlayWindow (xdisplay, xroot); - XSelectInput (xdisplay, output, ExposureMask); - } - else -#endif - { - output = xroot; - } - - return output; -} - -static void -xrender_manage_screen (MetaCompositor *compositor, - MetaScreen *screen) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - MetaCompScreen *info; - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - XRenderPictureAttributes pa; - XRenderPictFormat *visual_format; - int screen_number = meta_screen_get_screen_number (screen); - Window xroot = meta_screen_get_xroot (screen); - - /* Check if the screen is already managed */ - if (meta_screen_get_compositor_data (screen)) - return; - - gdk_error_trap_push (); - XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual); - XSync (xdisplay, FALSE); - - if (gdk_error_trap_pop ()) - { - g_warning ("Another compositing manager is running on screen %i", - screen_number); - return; - } - - info = g_new0 (MetaCompScreen, 1); - info->screen = screen; - - meta_screen_set_compositor_data (screen, info); - - visual_format = XRenderFindVisualFormat (xdisplay, DefaultVisual (xdisplay, - screen_number)); - if (!visual_format) - { - g_warning ("Cannot find visual format on screen %i", screen_number); - return; - } - - info->output = get_output_window (screen); - - pa.subwindow_mode = IncludeInferiors; - info->root_picture = XRenderCreatePicture (xdisplay, info->output, - visual_format, - CPSubwindowMode, &pa); - if (info->root_picture == None) - { - g_warning ("Cannot create root picture on screen %i", screen_number); - return; - } - - info->root_buffer = None; - info->black_picture = solid_picture (display, screen, TRUE, 1, 0, 0, 0); - - info->root_tile = None; - info->all_damage = None; - - info->windows = NULL; - info->windows_by_xid = g_hash_table_new (g_direct_hash, g_direct_equal); - - info->focus_window = meta_display_get_focus_window (display); - - info->compositor_active = TRUE; - info->overlays = 0; - info->clip_changed = TRUE; - - info->have_shadows = (g_getenv("META_DEBUG_NO_SHADOW") == NULL); - if (info->have_shadows) - { - meta_verbose ("Enabling shadows\n"); - generate_shadows (info); - } - else - meta_verbose ("Disabling shadows\n"); - - XClearArea (xdisplay, info->output, 0, 0, 0, 0, TRUE); - - meta_screen_set_cm_selection (screen); - - /* Now we're up and running we can show the output if needed */ - show_overlay_window (screen, info->output); -#endif -} - -static void -xrender_unmanage_screen (MetaCompositor *compositor, - MetaScreen *screen) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - MetaDisplay *display = meta_screen_get_display (screen); - Display *xdisplay = meta_display_get_xdisplay (display); - MetaCompScreen *info; - Window xroot = meta_screen_get_xroot (screen); - GList *index; - - info = meta_screen_get_compositor_data (screen); - - /* This screen isn't managed */ - if (info == NULL) - return; - - hide_overlay_window (screen, info->output); - - /* Destroy the windows */ - for (index = info->windows; index; index = index->next) - { - MetaCompWindow *cw = (MetaCompWindow *) index->data; - free_win (cw, TRUE); - } - g_list_free (info->windows); - g_hash_table_destroy (info->windows_by_xid); - - if (info->root_picture) - XRenderFreePicture (xdisplay, info->root_picture); - - if (info->black_picture) - XRenderFreePicture (xdisplay, info->black_picture); - - if (info->have_shadows) - { - int i; - - for (i = 0; i < LAST_SHADOW_TYPE; i++) - g_free (info->shadows[i]->gaussian_map); - } - - XCompositeUnredirectSubwindows (xdisplay, xroot, - CompositeRedirectManual); - meta_screen_unset_cm_selection (screen); - -#ifdef HAVE_COW - XCompositeReleaseOverlayWindow (xdisplay, info->output); -#endif - - g_free (info); - - meta_screen_set_compositor_data (screen, NULL); -#endif -} - -static void -xrender_set_updates (MetaCompositor *compositor, - MetaWindow *window, - gboolean updates) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - -#endif -} - -static void -xrender_destroy (MetaCompositor *compositor) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - g_free (compositor); -#endif -} - -#if 0 -/* Taking these out because they're empty and never called, and the - * compiler complains -- tthurman - */ - -static void -xrender_begin_move (MetaCompositor *compositor, - MetaWindow *window, - MetaRectangle *initial, - int grab_x, - int grab_y) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS -#endif -} - -static void -xrender_update_move (MetaCompositor *compositor, - MetaWindow *window, - int x, - int y) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS -#endif -} - -static void -xrender_end_move (MetaCompositor *compositor, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS -#endif -} - -static void -xrender_free_window (MetaCompositor *compositor, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - /* FIXME: When an undecorated window is hidden this is called, - but the window does not get readded if it is subsequentally shown again - See http://bugzilla.gnome.org/show_bug.cgi?id=504876 - - I don't *think* theres any need for this call anyway, leaving it out - does not seem to cause any side effects so far, but I should check with - someone who understands more. */ - /* destroy_win (compositor->display, window->xwindow, FALSE); */ -#endif -} -#endif /* 0 */ - -static gboolean -xrender_process_event (MetaCompositor *compositor, - XEvent *event, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor; - /* - * This trap is so that none of the compositor functions cause - * X errors. This is really a hack, but I'm afraid I don't understand - * enough about Metacity/X to know how else you are supposed to do it - */ - meta_error_trap_push (xrc->display); - switch (event->type) - { - case CirculateNotify: - process_circulate_notify (xrc, (XCirculateEvent *) event); - break; - - case ConfigureNotify: - process_configure_notify (xrc, (XConfigureEvent *) event); - break; - - case PropertyNotify: - process_property_notify (xrc, (XPropertyEvent *) event); - break; - - case Expose: - process_expose (xrc, (XExposeEvent *) event); - break; - - case UnmapNotify: - process_unmap (xrc, (XUnmapEvent *) event); - break; - - case MapNotify: - process_map (xrc, (XMapEvent *) event); - break; - - case ReparentNotify: - process_reparent (xrc, (XReparentEvent *) event, window); - break; - - case CreateNotify: - process_create (xrc, (XCreateWindowEvent *) event, window); - break; - - case DestroyNotify: - process_destroy (xrc, (XDestroyWindowEvent *) event); - break; - - default: - if (event->type == meta_display_get_damage_event_base (xrc->display) + XDamageNotify) - process_damage (xrc, (XDamageNotifyEvent *) event); -#ifdef HAVE_SHAPE - else if (event->type == meta_display_get_shape_event_base (xrc->display) + ShapeNotify) - process_shape (xrc, (XShapeEvent *) event); -#endif /* HAVE_SHAPE */ - else - { - meta_error_trap_pop (xrc->display, FALSE); - return FALSE; - } - break; - } - - meta_error_trap_pop (xrc->display, FALSE); -#ifndef USE_IDLE_REPAINT - repair_display (xrc->display); -#endif - - return FALSE; -#endif -} - -static Pixmap -xrender_get_window_pixmap (MetaCompositor *compositor, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - MetaCompWindow *cw = NULL; - MetaScreen *screen = meta_window_get_screen (window); - MetaFrame *frame = meta_window_get_frame (window); - - cw = find_window_for_screen (screen, frame ? meta_frame_get_xwindow (frame) : - meta_window_get_xwindow (window)); - if (cw == NULL) - return None; - -#ifdef HAVE_NAME_WINDOW_PIXMAP - if (have_name_window_pixmap (meta_window_get_display (window))) - { - if (meta_window_is_shaded (window)) - return cw->shaded_back_pixmap; - else - return cw->back_pixmap; - } - else -#endif - return None; -#endif -} - -static void -xrender_set_active_window (MetaCompositor *compositor, - MetaScreen *screen, - MetaWindow *window) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor; - MetaDisplay *display; - Display *xdisplay; - MetaCompWindow *old_focus = NULL, *new_focus = NULL; - MetaCompScreen *info = NULL; - MetaWindow *old_focus_win = NULL; - - if (compositor == NULL) - return; - - display = xrc->display; - xdisplay = meta_display_get_xdisplay (display); - info = meta_screen_get_compositor_data (screen); - - if (info != NULL) - { - old_focus_win = info->focus_window; - } - - if (old_focus_win) - { - MetaFrame *f = meta_window_get_frame (old_focus_win); - - old_focus = find_window_for_screen (screen, - f ? meta_frame_get_xwindow (f) : - meta_window_get_xwindow (old_focus_win)); - } - - if (window) - { - MetaFrame *f = meta_window_get_frame (window); - new_focus = find_window_for_screen (screen, - f ? meta_frame_get_xwindow (f) : - meta_window_get_xwindow (window)); - } - - if (info != NULL) - { - info->focus_window = window; - } - - if (old_focus) - { - XserverRegion damage; - - /* Tear down old shadows */ - old_focus->shadow_type = META_SHADOW_MEDIUM; - determine_mode (display, screen, old_focus); - old_focus->needs_shadow = window_has_shadow (old_focus); - - if (old_focus->attrs.map_state == IsViewable) - { - if (old_focus->shadow) - { - XRenderFreePicture (xdisplay, old_focus->shadow); - old_focus->shadow = None; - } - - if (old_focus->extents) - { - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, old_focus->extents); - XFixesDestroyRegion (xdisplay, old_focus->extents); - } - else - damage = None; - - /* Build new extents */ - old_focus->extents = win_extents (old_focus); - - if (damage) - XFixesUnionRegion (xdisplay, damage, damage, old_focus->extents); - else - { - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, old_focus->extents); - } - - dump_xserver_region ("resize_win", display, damage); - add_damage (screen, damage); - - if (info != NULL) - { - info->clip_changed = TRUE; - } - } - } - - if (new_focus) - { - XserverRegion damage; - - new_focus->shadow_type = META_SHADOW_LARGE; - determine_mode (display, screen, new_focus); - new_focus->needs_shadow = window_has_shadow (new_focus); - - if (new_focus->shadow) - { - XRenderFreePicture (xdisplay, new_focus->shadow); - new_focus->shadow = None; - } - - if (new_focus->extents) - { - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, new_focus->extents); - XFixesDestroyRegion (xdisplay, new_focus->extents); - } - else - damage = None; - - /* Build new extents */ - new_focus->extents = win_extents (new_focus); - - if (damage) - XFixesUnionRegion (xdisplay, damage, damage, new_focus->extents); - else - { - damage = XFixesCreateRegion (xdisplay, NULL, 0); - XFixesCopyRegion (xdisplay, damage, new_focus->extents); - } - - dump_xserver_region ("resize_win", display, damage); - add_damage (screen, damage); - - if (info != NULL) - { - info->clip_changed = TRUE; - } - } -#ifdef USE_IDLE_REPAINT - add_repair (display); -#endif -#endif -} - -static MetaCompositor comp_info = { - xrender_destroy, - xrender_manage_screen, - xrender_unmanage_screen, - xrender_add_window, - xrender_remove_window, - xrender_set_updates, - xrender_process_event, - xrender_get_window_pixmap, - xrender_set_active_window -}; - -MetaCompositor * -meta_compositor_xrender_new (MetaDisplay *display) -{ -#ifdef HAVE_COMPOSITE_EXTENSIONS - char *atom_names[] = { - "_XROOTPMAP_ID", - "_XSETROOT_ID", - "_NET_WM_WINDOW_OPACITY", - "_NET_WM_WINDOW_TYPE_DND", - "_NET_WM_WINDOW_TYPE", - "_NET_WM_WINDOW_TYPE_DESKTOP", - "_NET_WM_WINDOW_TYPE_DOCK", - "_NET_WM_WINDOW_TYPE_MENU", - "_NET_WM_WINDOW_TYPE_DIALOG", - "_NET_WM_WINDOW_TYPE_NORMAL", - "_NET_WM_WINDOW_TYPE_UTILITY", - "_NET_WM_WINDOW_TYPE_SPLASH", - "_NET_WM_WINDOW_TYPE_TOOLBAR", - "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", - "_NET_WM_WINDOW_TYPE_TOOLTIP" - }; - Atom atoms[G_N_ELEMENTS(atom_names)]; - MetaCompositorXRender *xrc; - MetaCompositor *compositor; - Display *xdisplay = meta_display_get_xdisplay (display); - - xrc = g_new (MetaCompositorXRender, 1); - xrc->compositor = comp_info; - - compositor = (MetaCompositor *) xrc; - - xrc->display = display; - - meta_verbose ("Creating %d atoms\n", (int) G_N_ELEMENTS (atom_names)); - XInternAtoms (xdisplay, atom_names, G_N_ELEMENTS (atom_names), - False, atoms); - - xrc->atom_x_root_pixmap = atoms[0]; - xrc->atom_x_set_root = atoms[1]; - xrc->atom_net_wm_window_opacity = atoms[2]; - xrc->atom_net_wm_window_type_dnd = atoms[3]; - xrc->atom_net_wm_window_type = atoms[4]; - xrc->atom_net_wm_window_type_desktop = atoms[5]; - xrc->atom_net_wm_window_type_dock = atoms[6]; - xrc->atom_net_wm_window_type_menu = atoms[7]; - xrc->atom_net_wm_window_type_dialog = atoms[8]; - xrc->atom_net_wm_window_type_normal = atoms[9]; - xrc->atom_net_wm_window_type_utility = atoms[10]; - xrc->atom_net_wm_window_type_splash = atoms[11]; - xrc->atom_net_wm_window_type_toolbar = atoms[12]; - xrc->atom_net_wm_window_type_dropdown_menu = atoms[13]; - xrc->atom_net_wm_window_type_tooltip = atoms[14]; - -#ifdef USE_IDLE_REPAINT - meta_verbose ("Using idle repaint\n"); - xrc->repaint_id = 0; -#endif - - xrc->enabled = TRUE; - g_timeout_add (2000, (GSourceFunc) timeout_debug, xrc); - - return compositor; -#else - return NULL; -#endif -} - -#endif /* HAVE_COMPOSITE_EXTENSIONS */ - diff --git a/src/compositor/compositor-xrender.h b/src/compositor/compositor-xrender.h deleted file mode 100644 index 5c8a36c01..000000000 --- a/src/compositor/compositor-xrender.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -/* - * Copyright (C) 2007 Iain Holmes - * Based on xcompmgr - (c) 2003 Keith Packard - * xfwm4 - (c) 2005-2007 Olivier Fourdan - * - * 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. - */ - -#ifndef META_COMPOSITOR_XRENDER_H_ -#define META_COMPOSITOR_XRENDER_H_ - -#include "types.h" - -MetaCompositor *meta_compositor_xrender_new (MetaDisplay *display); - -#endif diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 733ba3815..3890ee8cb 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -21,78 +21,52 @@ #include #include "compositor-private.h" -#include "compositor-xrender.h" -#include "prefs.h" - -#ifdef WITH_CLUTTER #include "compositor-mutter.h" -int meta_compositor_can_use_clutter__ = 0; -#endif +#include "prefs.h" MetaCompositor * meta_compositor_new (MetaDisplay *display) { -#ifdef HAVE_COMPOSITE_EXTENSIONS -#ifdef WITH_CLUTTER - /* At some point we would have a way to select between backends */ - /* return meta_compositor_xrender_new (display); */ - if (meta_compositor_can_use_clutter__ && !meta_prefs_get_clutter_disabled ()) - return mutter_new (display); - else -#endif - return meta_compositor_xrender_new (display); -#else - return NULL; -#endif + return mutter_new (display); } void meta_compositor_destroy (MetaCompositor *compositor) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->destroy) compositor->destroy (compositor); -#endif } void meta_compositor_add_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->add_window) compositor->add_window (compositor, window); -#endif } void meta_compositor_remove_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->remove_window) compositor->remove_window (compositor, window); -#endif } void meta_compositor_manage_screen (MetaCompositor *compositor, MetaScreen *screen) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->manage_screen) compositor->manage_screen (compositor, screen); -#endif } void meta_compositor_unmanage_screen (MetaCompositor *compositor, MetaScreen *screen) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->unmanage_screen) compositor->unmanage_screen (compositor, screen); -#endif } void @@ -100,10 +74,8 @@ meta_compositor_set_updates (MetaCompositor *compositor, MetaWindow *window, gboolean updates) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->set_updates) compositor->set_updates (compositor, window, updates); -#endif } gboolean @@ -111,26 +83,20 @@ meta_compositor_process_event (MetaCompositor *compositor, XEvent *event, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->process_event) return compositor->process_event (compositor, event, window); else return FALSE; -#endif } Pixmap meta_compositor_get_window_pixmap (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->get_window_pixmap) return compositor->get_window_pixmap (compositor, window); else return None; -#else - return None; -#endif } void @@ -138,10 +104,8 @@ meta_compositor_set_active_window (MetaCompositor *compositor, MetaScreen *screen, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->set_active_window) compositor->set_active_window (compositor, screen, window); -#endif } /* These functions are unused at the moment */ @@ -169,20 +133,16 @@ void meta_compositor_map_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->map_window) compositor->map_window (compositor, window); -#endif } void meta_compositor_unmap_window (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->unmap_window) compositor->unmap_window (compositor, window); -#endif } void @@ -191,10 +151,8 @@ meta_compositor_minimize_window (MetaCompositor *compositor, MetaRectangle *window_rect, MetaRectangle *icon_rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->minimize_window) compositor->minimize_window (compositor, window, window_rect, icon_rect); -#endif } void @@ -203,10 +161,8 @@ meta_compositor_unminimize_window (MetaCompositor *compositor, MetaRectangle *window_rect, MetaRectangle *icon_rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->unminimize_window) compositor->unminimize_window (compositor, window, window_rect, icon_rect); -#endif } void @@ -214,10 +170,8 @@ meta_compositor_maximize_window (MetaCompositor *compositor, MetaWindow *window, MetaRectangle *window_rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->maximize_window) compositor->maximize_window (compositor, window, window_rect); -#endif } void @@ -225,20 +179,16 @@ meta_compositor_unmaximize_window (MetaCompositor *compositor, MetaWindow *window, MetaRectangle *window_rect) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->unmaximize_window) compositor->unmaximize_window (compositor, window, window_rect); -#endif } void meta_compositor_update_workspace_geometry (MetaCompositor *compositor, MetaWorkspace *workspace) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->update_workspace_geometry) compositor->update_workspace_geometry (compositor, workspace); -#endif } void @@ -248,10 +198,8 @@ meta_compositor_switch_workspace (MetaCompositor *compositor, MetaWorkspace *to, MetaMotionDirection direction) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->switch_workspace) compositor->switch_workspace (compositor, screen, from, to, direction); -#endif } void @@ -259,10 +207,8 @@ meta_compositor_sync_stack (MetaCompositor *compositor, MetaScreen *screen, GList *stack) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->sync_stack) compositor->sync_stack (compositor, screen, stack); -#endif } void @@ -271,20 +217,16 @@ meta_compositor_set_window_hidden (MetaCompositor *compositor, MetaWindow *window, gboolean hidden) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->set_window_hidden) compositor->set_window_hidden (compositor, screen, window, hidden); -#endif } void meta_compositor_sync_window_geometry (MetaCompositor *compositor, MetaWindow *window) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->sync_window_geometry) compositor->sync_window_geometry (compositor, window); -#endif } void @@ -293,9 +235,6 @@ meta_compositor_sync_screen_size (MetaCompositor *compositor, guint width, guint height) { -#ifdef HAVE_COMPOSITE_EXTENSIONS if (compositor && compositor->sync_screen_size) compositor->sync_screen_size (compositor, screen, width, height); -#endif } - diff --git a/src/compositor/mutter/mutter-module.c b/src/compositor/mutter-module.c similarity index 100% rename from src/compositor/mutter/mutter-module.c rename to src/compositor/mutter-module.c diff --git a/src/compositor/mutter/mutter-module.h b/src/compositor/mutter-module.h similarity index 100% rename from src/compositor/mutter/mutter-module.h rename to src/compositor/mutter-module.h diff --git a/src/compositor/mutter/mutter-plugin-manager.c b/src/compositor/mutter-plugin-manager.c similarity index 100% rename from src/compositor/mutter/mutter-plugin-manager.c rename to src/compositor/mutter-plugin-manager.c diff --git a/src/compositor/mutter/mutter-plugin-manager.h b/src/compositor/mutter-plugin-manager.h similarity index 100% rename from src/compositor/mutter/mutter-plugin-manager.h rename to src/compositor/mutter-plugin-manager.h diff --git a/src/compositor/mutter/mutter-plugin.c b/src/compositor/mutter-plugin.c similarity index 100% rename from src/compositor/mutter/mutter-plugin.c rename to src/compositor/mutter-plugin.c diff --git a/src/compositor/mutter/mutter-shaped-texture.c b/src/compositor/mutter-shaped-texture.c similarity index 100% rename from src/compositor/mutter/mutter-shaped-texture.c rename to src/compositor/mutter-shaped-texture.c diff --git a/src/compositor/mutter/mutter-shaped-texture.h b/src/compositor/mutter-shaped-texture.h similarity index 100% rename from src/compositor/mutter/mutter-shaped-texture.h rename to src/compositor/mutter-shaped-texture.h diff --git a/src/compositor/mutter/plugins/Makefile.am b/src/compositor/plugins/Makefile.am similarity index 97% rename from src/compositor/mutter/plugins/Makefile.am rename to src/compositor/plugins/Makefile.am index 329629869..0c9d4bda1 100644 --- a/src/compositor/mutter/plugins/Makefile.am +++ b/src/compositor/plugins/Makefile.am @@ -1,8 +1,6 @@ pkglibdir=@MUTTER_PLUGIN_DIR@ -if WITH_CLUTTER - INCLUDES=@MUTTER_CFLAGS@ -I $(top_srcdir)/src/include -DMUTTER_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMUTTER_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DMUTTER_PKGDATADIR=\"$(pkgdatadir)\" -DMUTTER_DATADIR=\"$(datadir)\" -DG_LOG_DOMAIN=\"mutter\" -DSN_API_NOT_YET_FROZEN=1 -DMUTTER_MAJOR_VERSION=$(MUTTER_MAJOR_VERSION) -DMUTTER_MINOR_VERSION=$(MUTTER_MINOR_VERSION) -DMUTTER_MICRO_VERSION=$(MUTTER_MICRO_VERSION) -DMUTTER_PLUGIN_API_VERSION=$(MUTTER_PLUGIN_API_VERSION) -DMUTTER_PLUGIN_DIR=\"@MUTTER_PLUGIN_DIR@\" default_la_CFLAGS = -fPIC @@ -18,5 +16,3 @@ pkglib_LTLIBRARIES = default.la install-exec-hook: -rm $(DESTDIR)$(pkglibdir)/*.a -rm $(DESTDIR)$(pkglibdir)/*.la - -endif diff --git a/src/compositor/mutter/plugins/README b/src/compositor/plugins/README similarity index 100% rename from src/compositor/mutter/plugins/README rename to src/compositor/plugins/README diff --git a/src/compositor/mutter/plugins/default.c b/src/compositor/plugins/default.c similarity index 100% rename from src/compositor/mutter/plugins/default.c rename to src/compositor/plugins/default.c diff --git a/src/compositor/mutter/tidy/tidy-texture-frame.c b/src/compositor/tidy/tidy-texture-frame.c similarity index 100% rename from src/compositor/mutter/tidy/tidy-texture-frame.c rename to src/compositor/tidy/tidy-texture-frame.c diff --git a/src/compositor/mutter/tidy/tidy-texture-frame.h b/src/compositor/tidy/tidy-texture-frame.h similarity index 100% rename from src/compositor/mutter/tidy/tidy-texture-frame.h rename to src/compositor/tidy/tidy-texture-frame.h diff --git a/src/core/display-private.h b/src/core/display-private.h index 413bf7cda..3e0507524 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -249,6 +249,18 @@ struct _MetaDisplay /* Managed by compositor.c */ MetaCompositor *compositor; + + int render_event_base; + int render_error_base; + + int composite_event_base; + int composite_error_base; + int composite_major_version; + int composite_minor_version; + int damage_event_base; + int damage_error_base; + int xfixes_event_base; + int xfixes_error_base; #ifdef HAVE_STARTUP_NOTIFICATION SnDisplay *sn_display; @@ -261,20 +273,6 @@ struct _MetaDisplay int shape_event_base; int shape_error_base; #endif -#ifdef HAVE_RENDER - int render_event_base; - int render_error_base; -#endif -#ifdef HAVE_COMPOSITE_EXTENSIONS - int composite_event_base; - int composite_error_base; - int composite_major_version; - int composite_minor_version; - int damage_event_base; - int damage_error_base; - int xfixes_event_base; - int xfixes_error_base; -#endif #ifdef HAVE_XSYNC unsigned int have_xsync : 1; #define META_DISPLAY_HAS_XSYNC(display) ((display)->have_xsync) @@ -287,24 +285,14 @@ struct _MetaDisplay #else #define META_DISPLAY_HAS_SHAPE(display) FALSE #endif -#ifdef HAVE_RENDER unsigned int have_render : 1; #define META_DISPLAY_HAS_RENDER(display) ((display)->have_render) -#else -#define META_DISPLAY_HAS_RENDER(display) FALSE -#endif -#ifdef HAVE_COMPOSITE_EXTENSIONS unsigned int have_composite : 1; unsigned int have_damage : 1; unsigned int have_xfixes : 1; #define META_DISPLAY_HAS_COMPOSITE(display) ((display)->have_composite) #define META_DISPLAY_HAS_DAMAGE(display) ((display)->have_damage) #define META_DISPLAY_HAS_XFIXES(display) ((display)->have_xfixes) -#else -#define META_DISPLAY_HAS_COMPOSITE(display) FALSE -#define META_DISPLAY_HAS_DAMAGE(display) FALSE -#define META_DISPLAY_HAS_XFIXES(display) FALSE -#endif }; struct _MetaDisplayClass diff --git a/src/core/display.c b/src/core/display.c index d1abfb88b..0a3fb445a 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -62,20 +62,16 @@ #ifdef HAVE_SHAPE #include #endif -#ifdef HAVE_RENDER -#include -#endif #ifdef HAVE_XKB #include #endif #ifdef HAVE_XCURSOR #include #endif -#ifdef HAVE_COMPOSITE_EXTENSIONS +#include #include #include #include -#endif #include #define GRAB_OP_IS_WINDOW_SWITCH(g) \ @@ -546,7 +542,6 @@ meta_display_open (void) meta_verbose ("Not compiled with Shape support\n"); #endif /* !HAVE_SHAPE */ -#ifdef HAVE_RENDER { the_display->have_render = FALSE; @@ -567,11 +562,7 @@ meta_display_open (void) the_display->render_error_base, the_display->render_event_base); } -#else /* HAVE_RENDER */ - meta_verbose ("Not compiled with Render support\n"); -#endif /* !HAVE_RENDER */ -#ifdef HAVE_COMPOSITE_EXTENSIONS { the_display->have_composite = FALSE; @@ -647,9 +638,6 @@ meta_display_open (void) the_display->xfixes_error_base, the_display->xfixes_event_base); } -#else /* HAVE_COMPOSITE_EXTENSIONS */ - meta_verbose ("Not compiled with Composite support\n"); -#endif /* !HAVE_COMPOSITE_EXTENSIONS */ #ifdef HAVE_XCURSOR { @@ -5204,7 +5192,6 @@ meta_display_overlay_key_activate (MetaDisplay *display) g_signal_emit (display, display_signals[OVERLAY_KEY], 0); } -#ifdef HAVE_COMPOSITE_EXTENSIONS void meta_display_get_compositor_version (MetaDisplay *display, int *major, @@ -5213,7 +5200,6 @@ meta_display_get_compositor_version (MetaDisplay *display, *major = display->composite_major_version; *minor = display->composite_minor_version; } -#endif Display * meta_display_get_xdisplay (MetaDisplay *display) @@ -5257,15 +5243,12 @@ meta_display_get_focus_window (MetaDisplay *display) return display->focus_window; } -#ifdef HAVE_COMPOSITE_EXTENSIONS int meta_display_get_damage_event_base (MetaDisplay *display) { return display->damage_event_base; } -#endif -#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_SHAPE int meta_display_get_shape_event_base (MetaDisplay *display) @@ -5273,7 +5256,6 @@ meta_display_get_shape_event_base (MetaDisplay *display) return display->shape_event_base; } #endif -#endif Atom meta_display_get_atom (MetaDisplay *display, MetaAtom meta_atom) { diff --git a/src/core/frame.c b/src/core/frame.c index 12d84bee9..0468da38b 100644 --- a/src/core/frame.c +++ b/src/core/frame.c @@ -29,9 +29,7 @@ #include "errors.h" #include "keybindings-private.h" -#ifdef HAVE_RENDER #include -#endif #define EVENT_MASK (SubstructureRedirectMask | \ StructureNotifyMask | SubstructureNotifyMask | \ diff --git a/src/core/main.c b/src/core/main.c index b815709a0..c074b74ec 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -69,14 +69,12 @@ #include #include -#ifdef WITH_CLUTTER #include #include -#endif #ifdef HAVE_INTROSPECTION #include -#include "compositor/mutter/mutter-plugin-manager.h" +#include "compositor/mutter-plugin-manager.h" #endif /** @@ -178,11 +176,6 @@ meta_print_compilation_info (void) #else meta_verbose ("Compiled without startup notification\n"); #endif -#ifdef HAVE_COMPOSITE_EXTENSIONS - meta_verbose ("Compiled with composite extensions\n"); -#else - meta_verbose ("Compiled without composite extensions\n"); -#endif } /** @@ -237,12 +230,7 @@ typedef struct gchar *introspect; } MetaArguments; -#ifdef HAVE_COMPOSITE_EXTENSIONS #define COMPOSITE_OPTS_FLAGS 0 -#else /* HAVE_COMPOSITE_EXTENSIONS */ -/* No compositor, so don't show the arguments in --help */ -#define COMPOSITE_OPTS_FLAGS G_OPTION_FLAG_HIDDEN -#endif /* HAVE_COMPOSITE_EXTENSIONS */ /** * Parses argc and argv and returns the @@ -316,14 +304,12 @@ meta_parse_options (int *argc, char ***argv, N_("Turn compositing off"), NULL }, -#ifdef WITH_CLUTTER { "mutter-plugins", 0, 0, G_OPTION_ARG_STRING, &my_args.mutter_plugins, N_("Comma-separated list of compositor plugins"), "PLUGINS" }, -#endif { "no-tab-popup", 0, 0, G_OPTION_ARG_NONE, &my_args.no_tab_popup, @@ -344,15 +330,7 @@ meta_parse_options (int *argc, char ***argv, ctx = g_option_context_new (NULL); g_option_context_add_main_entries (ctx, options, "mutter"); - -#ifdef WITH_CLUTTER - /* - * This function is only available in clutter >= 0.8.2 - */ -#if CLUTTER_CHECK_VERSION(0,8,2) g_option_context_add_group (ctx, clutter_get_option_group_without_init ()); -#endif -#endif if (!g_option_context_parse (ctx, argc, argv, &error)) { @@ -365,8 +343,6 @@ meta_parse_options (int *argc, char ***argv, return ctx; } - -#ifdef WITH_CLUTTER /* Mutter is responsible for pulling events off the X queue, so Clutter * doesn't need (and shouldn't) run its normal event source which polls * the X fd, but we do have to deal with dispatching events that accumulate @@ -419,19 +395,15 @@ meta_clutter_init (GOptionContext *ctx, int *argc, char ***argv) if (CLUTTER_INIT_SUCCESS == clutter_init (argc, argv)) { - meta_compositor_can_use_clutter__ = 1; - GSource *source = g_source_new (&event_funcs, sizeof (GSource)); g_source_attach (source, NULL); g_source_unref (source); } else { - g_message ("Unable to initialize Clutter.\n"); - meta_compositor_can_use_clutter__ = 0; + meta_fatal ("Unable to initialize Clutter.\n"); } } -#endif /** * Selects which display Mutter should use. It first tries to use @@ -581,7 +553,6 @@ main (int argc, char **argv) /* Parse command line arguments.*/ ctx = meta_parse_options (&argc, &argv, &meta_args); -#ifdef WITH_CLUTTER /* This must come before the introspect below, so we load all the plugins * in order to get their get_type functions. */ @@ -603,7 +574,6 @@ main (int argc, char **argv) g_slist_free(plugins_list); g_strfreev (plugins); } -#endif /* WITH_CLUTTER */ #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUTTER_PKGLIBDIR); @@ -648,12 +618,10 @@ main (int argc, char **argv) meta_ui_init (&argc, &argv); -#ifdef WITH_CLUTTER /* * Clutter can only be initialized after the UI. */ meta_clutter_init (ctx, &argc, &argv); -#endif g_option_context_free (ctx); diff --git a/src/core/prefs.c b/src/core/prefs.c index 84ba94cc2..0b9e82af4 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -64,10 +64,7 @@ #define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_" -#ifdef WITH_CLUTTER -#define KEY_CLUTTER_DISABLED "/apps/mutter/general/clutter_disabled" #define KEY_CLUTTER_PLUGINS "/apps/mutter/general/clutter_plugins" -#endif #define KEY_LIVE_HIDDEN_WINDOWS "/apps/mutter/general/live_hidden_windows" @@ -115,11 +112,8 @@ static char *terminal_command = NULL; static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, }; -#ifdef WITH_CLUTTER -static gboolean clutter_disabled = FALSE; static gboolean clutter_plugins_overridden = FALSE; static GSList *clutter_plugins = NULL; -#endif static gboolean live_hidden_windows = FALSE; @@ -428,13 +422,6 @@ static MetaBoolPreference preferences_bool[] = &resize_with_right_button, FALSE, }, -#ifdef WITH_CLUTTER - { "/apps/mutter/general/clutter_disabled", - META_PREF_CLUTTER_DISABLED, - &clutter_disabled, - FALSE, - }, -#endif { "/apps/mutter/general/live_hidden_windows", META_PREF_LIVE_HIDDEN_WINDOWS, &live_hidden_windows, @@ -1068,13 +1055,11 @@ meta_prefs_init (void) handle_preference_init_string (); handle_preference_init_int (); -#ifdef WITH_CLUTTER if (!clutter_plugins_overridden) clutter_plugins = gconf_client_get_list (default_client, KEY_CLUTTER_PLUGINS, GCONF_VALUE_STRING, &err); cleanup_error (&err); -#endif /* @@@ Is there any reason we don't do the add_dir here? */ for (gconf_dir_cursor=gconf_dirs_we_are_interested_in; @@ -1223,7 +1208,6 @@ change_notify (GConfClient *client, { queue_changed (META_PREF_KEYBINDINGS); } -#ifdef WITH_CLUTTER else if (g_str_equal (key, KEY_CLUTTER_PLUGINS) && !clutter_plugins_overridden) { GError *err = NULL; @@ -1241,7 +1225,6 @@ change_notify (GConfClient *client, clutter_plugins = l; queue_changed (META_PREF_CLUTTER_PLUGINS); } -#endif else { meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Mutter\n", @@ -1825,14 +1808,13 @@ meta_preference_to_string (MetaPreference pref) case META_PREF_RESIZE_WITH_RIGHT_BUTTON: return "RESIZE_WITH_RIGHT_BUTTON"; -#ifdef WITH_CLUTTER - case META_PREF_CLUTTER_DISABLED: - return "CLUTTER_DISABLED"; + case META_PREF_CLUTTER_PLUGINS: return "CLUTTER_PLUGINS"; -#endif + case META_PREF_LIVE_HIDDEN_WINDOWS: return "LIVE_HIDDEN_WINDOWS"; + case META_PREF_NO_TAB_POPUP: return "NO_TAB_POPUP"; } @@ -2847,35 +2829,6 @@ meta_prefs_set_compositing_manager (gboolean whether) #endif } -#ifdef WITH_CLUTTER -gboolean -meta_prefs_get_clutter_disabled (void) -{ - return clutter_disabled; -} - -void -meta_prefs_set_clutter_disabled (gboolean whether) -{ -#ifdef HAVE_GCONF - GError *err = NULL; - - gconf_client_set_bool (default_client, - KEY_CLUTTER_DISABLED, - whether, - &err); - - if (err) - { - meta_warning (_("Error setting clutter status status: %s\n"), - err->message); - g_error_free (err); - } -#else - clutter_disabled = whether; -#endif -} - GSList * meta_prefs_get_clutter_plugins (void) { @@ -2914,7 +2867,6 @@ meta_prefs_override_clutter_plugins (GSList *list) clutter_plugins = g_slist_reverse (clutter_plugins); } -#endif gboolean meta_prefs_get_live_hidden_windows (void) diff --git a/src/core/screen-private.h b/src/core/screen-private.h index 101b462e2..51a430da3 100644 --- a/src/core/screen-private.h +++ b/src/core/screen-private.h @@ -117,9 +117,7 @@ struct _MetaScreen guint startup_sequence_timeout; #endif -#ifdef HAVE_COMPOSITE_EXTENSIONS Window wm_cm_selection_window; -#endif guint work_area_idle; diff --git a/src/core/screen.c b/src/core/screen.c index 9b0a95e4d..b0c633060 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -604,10 +604,7 @@ meta_screen_new (MetaDisplay *display, LeaveWindowMask | EnterWindowMask | KeyPressMask | KeyReleaseMask | FocusChangeMask | StructureNotifyMask | -#ifdef HAVE_COMPOSITE_EXTENSIONS - ExposureMask | -#endif - attr.your_event_mask); + ExposureMask | attr.your_event_mask); if (meta_error_trap_pop_with_return (display, FALSE) != Success) { meta_warning (_("Screen %d on display \"%s\" already has a window manager\n"), @@ -638,11 +635,9 @@ meta_screen_new (MetaDisplay *display, screen->wm_sn_atom = wm_sn_atom; screen->wm_sn_timestamp = manager_timestamp; -#ifdef HAVE_COMPOSITE_EXTENSIONS screen->wm_cm_selection_window = meta_create_offscreen_window (xdisplay, xroot, NoEventMask); -#endif screen->work_area_idle = 0; screen->active_workspace = NULL; @@ -939,7 +934,6 @@ meta_screen_manage_all_windows (MetaScreen *screen) void meta_screen_composite_all_windows (MetaScreen *screen) { -#ifdef HAVE_COMPOSITE_EXTENSIONS MetaDisplay *display; GSList *windows, *tmp; @@ -955,7 +949,6 @@ meta_screen_composite_all_windows (MetaScreen *screen) /* initialize the compositor's view of the stacking order */ meta_stack_tracker_sync_stack (screen->stack_tracker); -#endif } /** @@ -2967,7 +2960,6 @@ meta_screen_set_compositor_data (MetaScreen *screen, screen->compositor_data = compositor; } -#ifdef HAVE_COMPOSITE_EXTENSIONS void meta_screen_set_cm_selection (MetaScreen *screen) { @@ -2991,7 +2983,6 @@ meta_screen_unset_cm_selection (MetaScreen *screen) a = XInternAtom (screen->display->xdisplay, selection, FALSE); XSetSelectionOwner (screen->display->xdisplay, a, None, CurrentTime); } -#endif /* HAVE_COMPOSITE_EXTENSIONS */ GList * meta_screen_get_workspaces (MetaScreen *screen) diff --git a/src/core/window-private.h b/src/core/window-private.h index e576343a8..a2aa4d449 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -358,9 +358,7 @@ struct _MetaWindow /* maintained by group.c */ MetaGroup *group; -#ifdef HAVE_COMPOSITE_EXTENSIONS GObject *compositor_private; -#endif }; struct _MetaWindowClass diff --git a/src/core/window.c b/src/core/window.c index 5558e0cd7..b1c261e8a 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -53,9 +53,7 @@ #include #endif -#ifdef HAVE_COMPOSITE_EXTENSIONS #include -#endif static int destroying_windows_disallowed = 0; @@ -463,14 +461,12 @@ meta_window_new_with_attrs (MetaDisplay *display, /* any windows created via meta_create_offscreen_window: */ (attrs->x == -100 && attrs->y == -100 && attrs->width == 1 && attrs->height == 1) || -#ifdef HAVE_COMPOSITE_EXTENSIONS xwindow == screen->wm_cm_selection_window || xwindow == screen->guard_window || (display->compositor && xwindow == XCompositeGetOverlayWindow (display->xdisplay, screen->xroot) ) -#endif ) ) { meta_verbose ("Not managing our own windows\n"); diff --git a/src/core/workspace.c b/src/core/workspace.c index 481b564c7..0deaf69b8 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -29,9 +29,7 @@ #include "errors.h" #include "prefs.h" -#ifdef HAVE_COMPOSITE_EXTENSIONS #include "compositor.h" -#endif #include #include @@ -531,7 +529,6 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace, meta_workspace_focus_default_window (workspace, NULL, timestamp); } -#ifdef HAVE_COMPOSITE_EXTENSIONS { /* * Notify the compositor that the active workspace changed. @@ -583,7 +580,6 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace, meta_compositor_switch_workspace (comp, screen, old, workspace, direction); } -#endif } void @@ -926,18 +922,14 @@ ensure_work_areas_validated (MetaWorkspace *workspace) /* We're all done, YAAY! Record that everything has been validated. */ workspace->work_areas_invalid = FALSE; -#ifdef HAVE_COMPOSITE_EXTENSIONS - { - /* - * Notify the compositor that the workspace geometry has changed. - */ - MetaScreen *screen = workspace->screen; - MetaDisplay *display = meta_screen_get_display (screen); - MetaCompositor *comp = meta_display_get_compositor (display); + /* + * Notify the compositor that the workspace geometry has changed. + */ + MetaScreen *screen = workspace->screen; + MetaDisplay *display = meta_screen_get_display (screen); + MetaCompositor *comp = meta_display_get_compositor (display); - meta_compositor_update_workspace_geometry (comp, workspace); - } -#endif + meta_compositor_update_workspace_geometry (comp, workspace); } /** diff --git a/src/include/compositor-clutter.h b/src/include/compositor-clutter.h deleted file mode 100644 index 62754ccf7..000000000 --- a/src/include/compositor-clutter.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -/* - * Copyright (C) 2008 Matthew Allum - * Copyright (C) 2007 Iain Holmes - * Based on xcompmgr - (c) 2003 Keith Packard - * xfwm4 - (c) 2005-2007 Olivier Fourdan - * - * 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. - */ - -#ifndef META_COMPOSITOR_CLUTTER_H_ -#define META_COMPOSITOR_CLUTTER_H_ - -#include -#include - -#include "types.h" - -/* - * MetaCompWindow object (ClutterGroup sub-class) - */ -#define META_TYPE_COMP_WINDOW (meta_comp_window_get_type ()) -#define META_COMP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_COMP_WINDOW, MetaCompWindow)) -#define META_COMP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_COMP_WINDOW, MetaCompWindowClass)) -#define IS_META_COMP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_COMP_WINDOW_TYPE)) -#define META_IS_COMP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_COMP_WINDOW)) -#define META_COMP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_COMP_WINDOW, MetaCompWindowClass)) - -typedef struct _MetaCompWindow MetaCompWindow; -typedef struct _MetaCompWindowClass MetaCompWindowClass; -typedef struct _MetaCompWindowPrivate MetaCompWindowPrivate; - -struct _MetaCompWindowClass -{ - ClutterGroupClass parent_class; -}; - -struct _MetaCompWindow -{ - ClutterGroup parent; - - MetaCompWindowPrivate *priv; -}; - -GType meta_comp_window_get_type (void); - -Window meta_comp_window_get_x_window (MetaCompWindow *mcw); -MetaCompWindowType meta_comp_window_get_window_type (MetaCompWindow *mcw); -gint meta_comp_window_get_workspace (MetaCompWindow *mcw); - - -/* Compositor API */ -MetaCompositor *meta_compositor_clutter_new (MetaDisplay *display); - -void meta_compositor_clutter_window_effect_completed (MetaCompWindow *actor, gulong event); - -ClutterActor * meta_compositor_clutter_get_stage_for_screen (MetaScreen *screen); -ClutterActor * meta_compositor_clutter_get_overlay_group_for_screen (MetaScreen *screen); - -Window meta_compositor_clutter_get_overlay_window (MetaScreen *screen); - - -#endif diff --git a/src/include/compositor.h b/src/include/compositor.h index b36883315..bcc0ebce8 100644 --- a/src/include/compositor.h +++ b/src/include/compositor.h @@ -53,9 +53,6 @@ typedef enum _MetaCompWindowType } MetaCompWindowType; -#ifdef WITH_CLUTTER -extern int meta_compositor_can_use_clutter__; -#endif MetaCompositor *meta_compositor_new (MetaDisplay *display); void meta_compositor_destroy (MetaCompositor *compositor); diff --git a/src/include/prefs.h b/src/include/prefs.h index 284e54c2c..82bd5b752 100644 --- a/src/include/prefs.h +++ b/src/include/prefs.h @@ -60,10 +60,7 @@ typedef enum META_PREF_CURSOR_SIZE, META_PREF_COMPOSITING_MANAGER, META_PREF_RESIZE_WITH_RIGHT_BUTTON, -#ifdef WITH_CLUTTER - META_PREF_CLUTTER_DISABLED, META_PREF_CLUTTER_PLUGINS, -#endif META_PREF_LIVE_HIDDEN_WINDOWS, META_PREF_NO_TAB_POPUP, } MetaPreference; @@ -128,11 +125,6 @@ gboolean meta_prefs_get_compositing_manager (void); */ void meta_prefs_set_compositing_manager (gboolean whether); -#ifdef WITH_CLUTTER - -gboolean meta_prefs_get_clutter_disabled (void); -void meta_prefs_set_clutter_disabled (gboolean whether); - GSList * meta_prefs_get_clutter_plugins (void); /** @@ -150,8 +142,6 @@ void meta_prefs_set_clutter_plugins (GSList *list); */ void meta_prefs_override_clutter_plugins (GSList *list); -#endif - gboolean meta_prefs_get_live_hidden_windows (void); void meta_prefs_set_live_hidden_windows (gboolean whether); diff --git a/src/include/screen.h b/src/include/screen.h index 3bdcf160a..ccaac18ed 100644 --- a/src/include/screen.h +++ b/src/include/screen.h @@ -51,10 +51,8 @@ void meta_screen_set_compositor_data (MetaScreen *screen, MetaScreen *meta_screen_for_x_screen (Screen *xscreen); -#ifdef HAVE_COMPOSITE_EXTENSIONS void meta_screen_set_cm_selection (MetaScreen *screen); void meta_screen_unset_cm_selection (MetaScreen *screen); -#endif GList *meta_screen_get_workspaces (MetaScreen *screen);