Remove compatibility for GTK+-2.0

While the Meego developers agreed to switching mutter to GTK+-3.0
unconditionally a while ago, Canonical used a GTK+-2.0 build for their
Unity project. As Canonical now announced a switch to compiz as their
window manager, there is no longer a reason to maintain GTK+-2.0
compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=633133
This commit is contained in:
Florian Müllner 2010-10-25 20:44:30 +02:00
parent 95a7f0269a
commit b445ee3763
37 changed files with 158 additions and 1381 deletions

View File

@ -127,35 +127,11 @@ if test "$enable_compile_warnings" != no ; then
fi fi
changequote([,])dnl changequote([,])dnl
AC_MSG_CHECKING([which gtk+ version to compile against]) GTK_MIN_VERSION=2.90.7
AC_ARG_WITH([gtk], CANBERRA_GTK=libcanberra-gtk3
AC_HELP_STRING([--with-gtk=3.0|2.0], CANBERRA_GTK_VERSION=0.26
[which gtk+ version to compile against (default: 3.0)]),
[case "$with_gtk" in
2.0|3.0) ;;
*) AC_MSG_ERROR([invalid gtk+ version specified]);;
esac],
[with_gtk=3.0])
AC_MSG_RESULT([$with_gtk])
case "$with_gtk" in MUTTER_PC_MODULES="gtk+-3.0 >= $GTK_MIN_VERSION pango >= 1.2.0 cairo >= 1.10.0"
2.0) GTK_API_VERSION=2.0
GTK_MIN_VERSION=2.18
CANBERRA_GTK=libcanberra-gtk
CANBERRA_GTK_VERSION=0.24
;;
3.0) GTK_API_VERSION=3.0
GTK_MIN_VERSION=2.90.7
CANBERRA_GTK=libcanberra-gtk3
CANBERRA_GTK_VERSION=0.26
AC_DEFINE(USE_CAIRO_REGION, 1, [Use cairo_region_t instead of GdkRegion])
;;
esac
AM_CONDITIONAL(INSTALL_LIBMUTTER_PRIVATE, test "$with_gtk" = "3.0")
MUTTER_PC_MODULES="gtk+-$GTK_API_VERSION >= $GTK_MIN_VERSION pango >= 1.2.0 cairo >= 1.10.0"
AC_SUBST(GTK_API_VERSION)
AC_ARG_ENABLE(gconf, AC_ARG_ENABLE(gconf,
AC_HELP_STRING([--disable-gconf], AC_HELP_STRING([--disable-gconf],
@ -215,8 +191,8 @@ AM_GLIB_GNU_GETTEXT
# GRegex requires Glib-2.14.0 # GRegex requires Glib-2.14.0
PKG_CHECK_MODULES(ALL, glib-2.0 >= 2.14.0) PKG_CHECK_MODULES(ALL, glib-2.0 >= 2.14.0)
# gtk_window_set_icon_name requires gtk2+-2.6.0 # gtk_window_set_icon_name requires gtk2+-2.6.0
PKG_CHECK_MODULES(MUTTER_MESSAGE, gtk+-$GTK_API_VERSION >= $GTK_MIN_VERSION) PKG_CHECK_MODULES(MUTTER_MESSAGE, gtk+-3.0 >= $GTK_MIN_VERSION)
PKG_CHECK_MODULES(MUTTER_WINDOW_DEMO, gtk+-$GTK_API_VERSION >= $GTK_MIN_VERSION) PKG_CHECK_MODULES(MUTTER_WINDOW_DEMO, gtk+-3.0 >= $GTK_MIN_VERSION)
# Unconditionally use this dir to avoid a circular dep with gnomecc # Unconditionally use this dir to avoid a circular dep with gnomecc
GNOME_KEYBINDINGS_KEYSDIR="${datadir}/gnome-control-center/keybindings" GNOME_KEYBINDINGS_KEYSDIR="${datadir}/gnome-control-center/keybindings"
@ -574,7 +550,7 @@ fi
dnl ========================================================================== dnl ==========================================================================
echo " echo "
mutter-$VERSION (using gtk+-${GTK_API_VERSION}): mutter-$VERSION
prefix: ${prefix} prefix: ${prefix}
source code location: ${srcdir} source code location: ${srcdir}

View File

@ -1,11 +1,7 @@
# Flag build for parallelism; see https://savannah.gnu.org/patch/?6905 # Flag build for parallelism; see https://savannah.gnu.org/patch/?6905
.AUTOPARALLEL: .AUTOPARALLEL:
if INSTALL_LIBMUTTER_PRIVATE
lib_LTLIBRARIES = libmutter-private.la lib_LTLIBRARIES = libmutter-private.la
else
noinst_LTLIBRARIES = libmutter-private.la
endif
SUBDIRS=wm-tester tools compositor/plugins SUBDIRS=wm-tester tools compositor/plugins
@ -44,10 +40,6 @@ mutter_SOURCES= \
compositor/shadow.h \ compositor/shadow.h \
compositor/tidy/tidy-texture-frame.c \ compositor/tidy/tidy-texture-frame.c \
compositor/tidy/tidy-texture-frame.h \ compositor/tidy/tidy-texture-frame.h \
gdk-compat.h \
gtk-compat.h \
gdk2-drawing-utils.c \
gdk2-drawing-utils.h \
include/compositor.h \ include/compositor.h \
include/meta-plugin.h \ include/meta-plugin.h \
include/meta-window-actor.h \ include/meta-window-actor.h \
@ -147,8 +139,6 @@ libmutter_private_la_SOURCES= \
include/common.h \ include/common.h \
ui/preview-widget.c \ ui/preview-widget.c \
ui/preview-widget.h \ ui/preview-widget.h \
gdk2-drawing-utils.c \
gdk2-drawing-utils.h \
ui/theme-parser.c \ ui/theme-parser.c \
ui/theme.c \ ui/theme.c \
ui/theme.h ui/theme.h
@ -186,17 +176,11 @@ libmutterinclude_extra_headers = \
ui/preview-widget.h \ ui/preview-widget.h \
include/atomnames.h include/atomnames.h
if INSTALL_LIBMUTTER_PRIVATE
libmutterincludedir = $(includedir)/mutter/mutter-private libmutterincludedir = $(includedir)/mutter/mutter-private
libmutterinclude_HEADERS = \ libmutterinclude_HEADERS = \
$(libmutterinclude_base_headers) \ $(libmutterinclude_base_headers) \
$(libmutterinclude_extra_headers) $(libmutterinclude_extra_headers)
else
noinst_HEADERS = \
$(libmutterinclude_base_headers) \
$(libmutterinclude_extra_headers)
endif
mutter_theme_viewer_SOURCES= \ mutter_theme_viewer_SOURCES= \
ui/theme-viewer.c ui/theme-viewer.c
@ -226,11 +210,11 @@ Meta-$(api_version).gir: $(G_IR_SCANNER) mutter $(libmutterinclude_HEADERS) $(mu
--warn-all \ --warn-all \
--warn-error \ --warn-error \
--include=GObject-2.0 \ --include=GObject-2.0 \
--include=Gdk-@GTK_API_VERSION@ \ --include=Gdk-3.0 \
--include=Gtk-@GTK_API_VERSION@ \ --include=Gtk-3.0 \
--include=Clutter-1.0 \ --include=Clutter-1.0 \
--pkg=clutter-1.0 \ --pkg=clutter-1.0 \
--pkg=gtk+-@GTK_API_VERSION@ \ --pkg=gtk+-3.0 \
--include=xlib-2.0 \ --include=xlib-2.0 \
--include=xfixes-4.0 \ --include=xfixes-4.0 \
--program=$$pwd/mutter \ --program=$$pwd/mutter \
@ -305,11 +289,9 @@ CLEANFILES = \
inlinepixbufs.h: $(IMAGES) inlinepixbufs.h: $(IMAGES)
$(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) >$(srcdir)/inlinepixbufs.h $(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) >$(srcdir)/inlinepixbufs.h
if INSTALL_LIBMUTTER_PRIVATE
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libmutter-private.pc mutter-plugins.pc pkgconfig_DATA = libmutter-private.pc mutter-plugins.pc
endif
EXTRA_DIST=$(desktopfiles_files) \ EXTRA_DIST=$(desktopfiles_files) \
$(wmproperties_files) \ $(wmproperties_files) \

View File

@ -444,7 +444,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual); XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
XSync (xdisplay, FALSE); XSync (xdisplay, FALSE);
if (meta_error_trap_pop_with_return (display, FALSE)) if (meta_error_trap_pop_with_return (display))
{ {
g_warning ("Another compositing manager is running on screen %i", g_warning ("Another compositing manager is running on screen %i",
screen_number); screen_number);
@ -568,7 +568,7 @@ meta_compositor_add_window (MetaCompositor *compositor,
add_win (window); add_win (window);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
void void

View File

@ -272,7 +272,7 @@ window_decorated_notify (MetaWindow *mw,
{ {
meta_error_trap_push (display); meta_error_trap_push (display);
XDamageDestroy (xdisplay, priv->damage); XDamageDestroy (xdisplay, priv->damage);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
priv->damage = None; priv->damage = None;
} }
@ -411,7 +411,7 @@ meta_window_actor_dispose (GObject *object)
{ {
meta_error_trap_push (display); meta_error_trap_push (display);
XDamageDestroy (xdisplay, priv->damage); XDamageDestroy (xdisplay, priv->damage);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
priv->damage = None; priv->damage = None;
} }
@ -1582,7 +1582,7 @@ check_needs_pixmap (MetaWindowActor *self)
priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow); priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow);
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
{ {
/* Probably a BadMatch if the window isn't viewable; we could /* Probably a BadMatch if the window isn't viewable; we could
* GrabServer/GetWindowAttributes/NameWindowPixmap/UngrabServer/Sync * GrabServer/GetWindowAttributes/NameWindowPixmap/UngrabServer/Sync
@ -1630,7 +1630,7 @@ check_needs_pixmap (MetaWindowActor *self)
full = TRUE; full = TRUE;
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
priv->needs_pixmap = FALSE; priv->needs_pixmap = FALSE;
} }
@ -1718,7 +1718,7 @@ check_needs_reshape (MetaWindowActor *self)
ShapeBounding, ShapeBounding,
&n_rects, &n_rects,
&ordering); &ordering);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
if (rects) if (rects)
{ {
@ -1766,7 +1766,7 @@ meta_window_actor_pre_paint (MetaWindowActor *self)
{ {
meta_error_trap_push (display); meta_error_trap_push (display);
XDamageSubtract (xdisplay, priv->damage, None, None); XDamageSubtract (xdisplay, priv->damage, None, None);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
priv->received_damage = FALSE; priv->received_damage = FALSE;
} }

View File

@ -348,7 +348,7 @@ meta_core_lower_beneath_focus_window (Display *xdisplay,
xwindow, xwindow,
CWSibling | CWStackMode, CWSibling | CWStackMode,
&changes); &changes);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
void void

View File

@ -136,7 +136,7 @@ meta_window_delete (MetaWindow *window,
window->desc); window->desc);
XKillClient (window->display->xdisplay, window->xwindow); XKillClient (window->display->xdisplay, window->xwindow);
} }
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
meta_display_ping_window (window->display, meta_display_ping_window (window->display,
window, window,
@ -200,7 +200,7 @@ meta_window_kill (MetaWindow *window)
window->desc); window->desc);
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XKillClient (window->display->xdisplay, window->xwindow); XKillClient (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
void void

View File

@ -347,7 +347,7 @@ sn_error_trap_pop (SnDisplay *sn_display,
MetaDisplay *display; MetaDisplay *display;
display = meta_display_for_x_display (xdisplay); display = meta_display_for_x_display (xdisplay);
if (display != NULL) if (display != NULL)
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
#endif #endif
@ -890,7 +890,7 @@ meta_display_open (void)
timestamp); timestamp);
} }
meta_error_trap_pop (the_display, FALSE); meta_error_trap_pop (the_display);
} }
meta_display_ungrab (the_display); meta_display_ungrab (the_display);
@ -1099,7 +1099,7 @@ meta_display_screen_for_xwindow (MetaDisplay *display,
meta_error_trap_push (display); meta_error_trap_push (display);
attr.screen = NULL; attr.screen = NULL;
result = XGetWindowAttributes (display->xdisplay, xwindow, &attr); result = XGetWindowAttributes (display->xdisplay, xwindow, &attr);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
/* Note, XGetWindowAttributes is on all kinds of crack /* Note, XGetWindowAttributes is on all kinds of crack
* and returns 1 on success 0 on failure, rather than Success * and returns 1 on success 0 on failure, rather than Success
@ -1492,7 +1492,7 @@ window_raise_with_delay_callback (void *data)
window->xwindow, window->xwindow,
&root, &child, &root, &child,
&root_x, &root_y, &x, &y, &mask); &root_x, &root_y, &x, &y, &mask);
meta_error_trap_pop (window->display, TRUE); meta_error_trap_pop (window->display);
point_in_window = point_in_window =
(window->frame && POINT_IN_RECT (root_x, root_y, window->frame->rect)) || (window->frame && POINT_IN_RECT (root_x, root_y, window->frame->rect)) ||
@ -2208,7 +2208,7 @@ event_callback (XEvent *event,
window->frame->xwindow); window->frame->xwindow);
meta_error_trap_push (display); meta_error_trap_push (display);
meta_window_destroy_frame (window->frame->window); meta_window_destroy_frame (window->frame->window);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
else else
{ {
@ -2377,7 +2377,7 @@ event_callback (XEvent *event,
meta_error_trap_push (display); meta_error_trap_push (display);
XConfigureWindow (display->xdisplay, event->xconfigurerequest.window, XConfigureWindow (display->xdisplay, event->xconfigurerequest.window,
xwcm, &xwc); xwcm, &xwc);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
else else
{ {
@ -3148,7 +3148,7 @@ meta_spew_event (MetaDisplay *display,
meta_error_trap_push (display); meta_error_trap_push (display);
str = XGetAtomName (display->xdisplay, str = XGetAtomName (display->xdisplay,
event->xproperty.atom); event->xproperty.atom);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
if (event->xproperty.state == PropertyNewValue) if (event->xproperty.state == PropertyNewValue)
state = "PropertyNewValue"; state = "PropertyNewValue";
@ -3182,7 +3182,7 @@ meta_spew_event (MetaDisplay *display,
meta_error_trap_push (display); meta_error_trap_push (display);
str = XGetAtomName (display->xdisplay, str = XGetAtomName (display->xdisplay,
event->xclient.message_type); event->xclient.message_type);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
extra = g_strdup_printf ("type: %s format: %d\n", extra = g_strdup_printf ("type: %s format: %d\n",
str ? str : "(unknown atom)", str ? str : "(unknown atom)",
event->xclient.format); event->xclient.format);
@ -3460,7 +3460,7 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Changed pointer with XChangeActivePointerGrab()\n"); "Changed pointer with XChangeActivePointerGrab()\n");
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Error trapped from XChangeActivePointerGrab()\n"); "Error trapped from XChangeActivePointerGrab()\n");
@ -3493,7 +3493,7 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
"XGrabPointer() failed time %u\n", "XGrabPointer() failed time %u\n",
timestamp); timestamp);
} }
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
} }
#undef GRAB_MASK #undef GRAB_MASK
@ -3669,7 +3669,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
XSyncCAEvents, XSyncCAEvents,
&values); &values);
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
display->grab_sync_request_alarm = None; display->grab_sync_request_alarm = None;
meta_topic (META_DEBUG_RESIZING, meta_topic (META_DEBUG_RESIZING,
@ -3888,7 +3888,7 @@ meta_change_button_grab (MetaDisplay *display,
{ {
int result; int result;
result = meta_error_trap_pop_with_return (display, FALSE); result = meta_error_trap_pop_with_return (display);
if (result != Success) if (result != Success)
meta_verbose ("Failed to %s button %d with mask 0x%x for window 0x%lx error code %d\n", meta_verbose ("Failed to %s button %d with mask 0x%x for window 0x%lx error code %d\n",
@ -3899,7 +3899,7 @@ meta_change_button_grab (MetaDisplay *display,
++ignored_mask; ++ignored_mask;
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
void void
@ -4083,7 +4083,7 @@ meta_display_update_active_window_hint (MetaDisplay *display)
XA_WINDOW, XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1); 32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
tmp = tmp->next; tmp = tmp->next;
} }
@ -4363,7 +4363,7 @@ process_request_frame_extents (MetaDisplay *display,
display->atom__NET_FRAME_EXTENTS, display->atom__NET_FRAME_EXTENTS,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 4); 32, PropModeReplace, (guchar*) data, 4);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
meta_XFree (hints); meta_XFree (hints);
} }
@ -4841,11 +4841,11 @@ convert_property (MetaDisplay *display,
(unsigned char *)icccm_version, 2); (unsigned char *)icccm_version, 2);
else else
{ {
meta_error_trap_pop_with_return (display, FALSE); meta_error_trap_pop_with_return (display);
return FALSE; return FALSE;
} }
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
return FALSE; return FALSE;
/* Be sure the PropertyNotify has arrived so we /* Be sure the PropertyNotify has arrived so we
@ -4877,7 +4877,7 @@ process_selection_request (MetaDisplay *display,
meta_error_trap_push (display); meta_error_trap_push (display);
str = XGetAtomName (display->xdisplay, str = XGetAtomName (display->xdisplay,
event->xselectionrequest.selection); event->xselectionrequest.selection);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
meta_verbose ("Selection request with selection %s window 0x%lx not a WM_Sn selection we recognize\n", meta_verbose ("Selection request with selection %s window 0x%lx not a WM_Sn selection we recognize\n",
str ? str : "(bad atom)", event->xselectionrequest.owner); str ? str : "(bad atom)", event->xselectionrequest.owner);
@ -4911,11 +4911,11 @@ process_selection_request (MetaDisplay *display,
display->atom_ATOM_PAIR, display->atom_ATOM_PAIR,
&type, &format, &num, &rest, &data) != Success) &type, &format, &num, &rest, &data) != Success)
{ {
meta_error_trap_pop_with_return (display, TRUE); meta_error_trap_pop_with_return (display);
return; return;
} }
if (meta_error_trap_pop_with_return (display, TRUE) == Success) if (meta_error_trap_pop_with_return (display) == Success)
{ {
/* FIXME: to be 100% correct, should deal with rest > 0, /* FIXME: to be 100% correct, should deal with rest > 0,
* but since we have 4 possible targets, we will hardly ever * but since we have 4 possible targets, we will hardly ever
@ -4938,7 +4938,7 @@ process_selection_request (MetaDisplay *display,
event->xselectionrequest.property, event->xselectionrequest.property,
display->atom_ATOM_PAIR, display->atom_ATOM_PAIR,
32, PropModeReplace, data, num); 32, PropModeReplace, data, num);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
meta_XFree (data); meta_XFree (data);
} }
} }
@ -4994,7 +4994,7 @@ process_selection_clear (MetaDisplay *display,
meta_error_trap_push (display); meta_error_trap_push (display);
str = XGetAtomName (display->xdisplay, str = XGetAtomName (display->xdisplay,
event->xselectionclear.selection); event->xselectionclear.selection);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
meta_verbose ("Selection clear with selection %s window 0x%lx not a WM_Sn selection we recognize\n", meta_verbose ("Selection clear with selection %s window 0x%lx not a WM_Sn selection we recognize\n",
str ? str : "(bad atom)", event->xselectionclear.window); str ? str : "(bad atom)", event->xselectionclear.window);
@ -5366,7 +5366,7 @@ meta_display_set_input_focus_window (MetaDisplay *display,
focus_frame ? window->frame->xwindow : window->xwindow, focus_frame ? window->frame->xwindow : window->xwindow,
RevertToPointerRoot, RevertToPointerRoot,
timestamp); timestamp);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
display->expected_focus_window = window; display->expected_focus_window = window;
display->last_focus_time = timestamp; display->last_focus_time = timestamp;

View File

@ -28,7 +28,6 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtk.h> /* Only for GTK_CHECK_VERSION */
/* In GTK+-3.0, the error trapping code was significantly rewritten. The new code /* In GTK+-3.0, the error trapping code was significantly rewritten. The new code
* has some neat features (like knowing automatically if a sync is needed or not * has some neat features (like knowing automatically if a sync is needed or not
@ -41,26 +40,6 @@
* use the GTK+ handling straight-up. * use the GTK+ handling straight-up.
* (See https://bugzilla.gnome.org/show_bug.cgi?id=630216 for restoring logging.) * (See https://bugzilla.gnome.org/show_bug.cgi?id=630216 for restoring logging.)
*/ */
#if GTK_CHECK_VERSION(2, 90, 0)
#define USE_GDK_ERROR_HANDLERS 1
#endif
#ifndef USE_GDK_ERROR_HANDLERS
static int x_error_handler (Display *display,
XErrorEvent *error);
static int x_io_error_handler (Display *display);
#endif
void
meta_errors_init (void)
{
#ifndef USE_GDK_ERROR_HANDLERS
XSetErrorHandler (x_error_handler);
XSetIOErrorHandler (x_io_error_handler);
#endif
}
#ifdef USE_GDK_ERROR_HANDLERS
void void
meta_error_trap_push (MetaDisplay *display) meta_error_trap_push (MetaDisplay *display)
@ -69,8 +48,7 @@ meta_error_trap_push (MetaDisplay *display)
} }
void void
meta_error_trap_pop (MetaDisplay *display, meta_error_trap_pop (MetaDisplay *display)
gboolean last_request_was_roundtrip)
{ {
gdk_error_trap_pop_ignored (); gdk_error_trap_pop_ignored ();
} }
@ -82,220 +60,7 @@ meta_error_trap_push_with_return (MetaDisplay *display)
} }
int int
meta_error_trap_pop_with_return (MetaDisplay *display, meta_error_trap_pop_with_return (MetaDisplay *display)
gboolean last_request_was_roundtrip)
{ {
return gdk_error_trap_pop (); return gdk_error_trap_pop ();
} }
#else /* !USE_GDK_ERROR_HANDLERS */
static void
meta_error_trap_push_internal (MetaDisplay *display,
gboolean need_sync)
{
/* GDK resets the error handler on each push */
int (* old_error_handler) (Display *,
XErrorEvent *);
if (need_sync)
{
XSync (display->xdisplay, False);
}
gdk_error_trap_push ();
/* old_error_handler will just be equal to x_error_handler
* for nested traps
*/
old_error_handler = XSetErrorHandler (x_error_handler);
/* Replace GDK handler, but save it so we can chain up */
if (display->error_trap_handler == NULL)
{
g_assert (display->error_traps == 0);
display->error_trap_handler = old_error_handler;
g_assert (display->error_trap_handler != x_error_handler);
}
display->error_traps += 1;
meta_topic (META_DEBUG_ERRORS, "%d traps remain\n", display->error_traps);
}
static int
meta_error_trap_pop_internal (MetaDisplay *display,
gboolean need_sync)
{
int result;
g_assert (display->error_traps > 0);
if (need_sync)
{
XSync (display->xdisplay, False);
}
result = gdk_error_trap_pop ();
display->error_traps -= 1;
if (display->error_traps == 0)
{
/* check that GDK put our handler back; this
* assumes that there are no pending GDK traps from GDK itself
*/
int (* restored_error_handler) (Display *,
XErrorEvent *);
restored_error_handler = XSetErrorHandler (x_error_handler);
/* remove this */
display->error_trap_handler = NULL;
}
meta_topic (META_DEBUG_ERRORS, "%d traps\n", display->error_traps);
return result;
}
void
meta_error_trap_push (MetaDisplay *display)
{
meta_error_trap_push_internal (display, FALSE);
}
void
meta_error_trap_pop (MetaDisplay *display,
gboolean last_request_was_roundtrip)
{
gboolean need_sync;
/* we only have to sync when popping the outermost trap */
need_sync = (display->error_traps == 1 && !last_request_was_roundtrip);
if (need_sync)
meta_topic (META_DEBUG_SYNC, "Syncing on error_trap_pop, traps = %d, roundtrip = %d\n",
display->error_traps, last_request_was_roundtrip);
display->error_trap_synced_at_last_pop = need_sync || last_request_was_roundtrip;
meta_error_trap_pop_internal (display, need_sync);
}
void
meta_error_trap_push_with_return (MetaDisplay *display)
{
gboolean need_sync;
/* We don't sync on push_with_return if there are no traps
* currently, because we assume that any errors were either covered
* by a previous pop, or were fatal.
*
* More generally, we don't sync if we were synchronized last time
* we popped. This is known to be the case if there are no traps,
* but we also keep a flag so we know whether it's the case otherwise.
*/
if (!display->error_trap_synced_at_last_pop)
need_sync = TRUE;
else
need_sync = FALSE;
if (need_sync)
meta_topic (META_DEBUG_SYNC, "Syncing on error_trap_push_with_return, traps = %d\n",
display->error_traps);
meta_error_trap_push_internal (display, FALSE);
}
int
meta_error_trap_pop_with_return (MetaDisplay *display,
gboolean last_request_was_roundtrip)
{
if (!last_request_was_roundtrip)
meta_topic (META_DEBUG_SYNC, "Syncing on error_trap_pop_with_return, traps = %d, roundtrip = %d\n",
display->error_traps, last_request_was_roundtrip);
display->error_trap_synced_at_last_pop = TRUE;
return meta_error_trap_pop_internal (display,
!last_request_was_roundtrip);
}
static int
x_error_handler (Display *xdisplay,
XErrorEvent *error)
{
int retval;
gchar buf[64];
MetaDisplay *display;
XGetErrorText (xdisplay, error->error_code, buf, 63);
display = meta_display_for_x_display (xdisplay);
/* Display can be NULL here Xlib only has one global error handler; and
* there might be other displays open in the process.
*/
if (display && display->error_traps > 0)
{
/* we're in an error trap, chain to the trap handler
* saved from GDK
*/
meta_verbose ("X error: %s serial %ld error_code %d request_code %d minor_code %d)\n",
buf,
error->serial,
error->error_code,
error->request_code,
error->minor_code);
g_assert (display->error_trap_handler != NULL);
g_assert (display->error_trap_handler != x_error_handler);
retval = (* display->error_trap_handler) (xdisplay, error);
}
else
{
meta_bug ("Unexpected X error: %s serial %ld error_code %d request_code %d minor_code %d)\n",
buf,
error->serial,
error->error_code,
error->request_code,
error->minor_code);
retval = 1; /* compiler warning */
}
return retval;
}
static int
x_io_error_handler (Display *xdisplay)
{
MetaDisplay *display;
display = meta_display_for_x_display (xdisplay);
if (errno == EPIPE)
{
meta_warning (_("Lost connection to the display '%s';\n"
"most likely the X server was shut down or you killed/destroyed\n"
"the window manager.\n"),
display ? display->name : DisplayString (xdisplay));
}
else
{
meta_warning (_("Fatal IO error %d (%s) on display '%s'.\n"),
errno, g_strerror (errno),
display ? display->name : DisplayString (xdisplay));
}
/* Xlib would force an exit anyhow */
exit (1);
return 0;
}
#endif /* USE_GDK_ERROR_HANDLERS */

View File

@ -153,7 +153,7 @@ meta_window_ensure_frame (MetaWindow *window)
window->rect.x, window->rect.x,
window->rect.y); window->rect.y);
/* FIXME handle this error */ /* FIXME handle this error */
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
/* stick frame to the window */ /* stick frame to the window */
window->frame = frame; window->frame = frame;
@ -217,7 +217,7 @@ meta_window_destroy_frame (MetaWindow *window)
*/ */
window->frame->rect.x, window->frame->rect.x,
window->frame->rect.y); window->frame->rect.y);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
meta_ui_destroy_frame_window (window->screen->ui, frame->xwindow); meta_ui_destroy_frame_window (window->screen->ui, frame->xwindow);

View File

@ -241,7 +241,7 @@ read_rgb_icon (MetaDisplay *display,
0, G_MAXLONG, 0, G_MAXLONG,
False, XA_CARDINAL, &type, &format, &nitems, False, XA_CARDINAL, &type, &format, &nitems,
&bytes_after, &data); &bytes_after, &data);
err = meta_error_trap_pop_with_return (display, TRUE); err = meta_error_trap_pop_with_return (display);
if (err != Success || if (err != Success ||
result != Success) result != Success)
@ -406,7 +406,7 @@ try_pixmap_and_mask (MetaDisplay *display,
w, h); w, h);
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
if (mask) if (mask)
{ {
@ -482,7 +482,7 @@ get_kwm_win_icon (MetaDisplay *display,
&bytes_after, &data); &bytes_after, &data);
icons = (Pixmap *)data; icons = (Pixmap *)data;
err = meta_error_trap_pop_with_return (display, TRUE); err = meta_error_trap_pop_with_return (display);
if (err != Success || if (err != Success ||
result != Success) result != Success)
return; return;

View File

@ -470,7 +470,7 @@ regrab_key_bindings (MetaDisplay *display)
tmp = tmp->next; tmp = tmp->next;
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
g_slist_free (windows); g_slist_free (windows);
} }
@ -700,7 +700,7 @@ meta_change_keygrab (MetaDisplay *display,
{ {
int result; int result;
result = meta_error_trap_pop_with_return (display, FALSE); result = meta_error_trap_pop_with_return (display);
if (grab && result != Success) if (grab && result != Success)
{ {
@ -716,7 +716,7 @@ meta_change_keygrab (MetaDisplay *display,
++ignored_mask; ++ignored_mask;
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
static void static void
@ -758,7 +758,7 @@ grab_keys (MetaKeyBinding *bindings,
++i; ++i;
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
static void static void
@ -777,14 +777,14 @@ ungrab_all_keys (MetaDisplay *display,
{ {
int result; int result;
result = meta_error_trap_pop_with_return (display, FALSE); result = meta_error_trap_pop_with_return (display);
if (result != Success) if (result != Success)
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ungrabbing all keys on 0x%lx failed\n", xwindow); "Ungrabbing all keys on 0x%lx failed\n", xwindow);
} }
else else
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
void void
@ -916,7 +916,7 @@ grab_keyboard (MetaDisplay *display,
if (grab_status != GrabSuccess) if (grab_status != GrabSuccess)
{ {
meta_error_trap_pop_with_return (display, TRUE); meta_error_trap_pop_with_return (display);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"XGrabKeyboard() returned failure status %s time %u\n", "XGrabKeyboard() returned failure status %s time %u\n",
grab_status_to_string (grab_status), grab_status_to_string (grab_status),
@ -925,7 +925,7 @@ grab_keyboard (MetaDisplay *display,
} }
else else
{ {
result = meta_error_trap_pop_with_return (display, TRUE); result = meta_error_trap_pop_with_return (display);
if (result != Success) if (result != Success)
{ {
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
@ -948,7 +948,7 @@ ungrab_keyboard (MetaDisplay *display, guint32 timestamp)
"Ungrabbing keyboard with timestamp %u\n", "Ungrabbing keyboard with timestamp %u\n",
timestamp); timestamp);
XUngrabKeyboard (display->xdisplay, timestamp); XUngrabKeyboard (display->xdisplay, timestamp);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
gboolean gboolean
@ -2899,7 +2899,7 @@ handle_panel (MetaDisplay *display,
StructureNotifyMask, StructureNotifyMask,
(XEvent*) &ev); (XEvent*) &ev);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
static void static void

View File

@ -623,9 +623,6 @@ main (int argc, char **argv)
g_option_context_free (ctx); g_option_context_free (ctx);
/* must be after UI init so we can override GDK handlers */
meta_errors_init ();
/* Load prefs */ /* Load prefs */
meta_prefs_init (); meta_prefs_init ();
meta_prefs_add_listener (prefs_changed_callback, NULL); meta_prefs_add_listener (prefs_changed_callback, NULL);

View File

@ -601,7 +601,7 @@ meta_screen_new (MetaDisplay *display,
attrs.event_mask = StructureNotifyMask; attrs.event_mask = StructureNotifyMask;
XChangeWindowAttributes (xdisplay, XChangeWindowAttributes (xdisplay,
current_wm_sn_owner, CWEventMask, &attrs); current_wm_sn_owner, CWEventMask, &attrs);
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
current_wm_sn_owner = None; /* don't wait for it to die later on */ current_wm_sn_owner = None; /* don't wait for it to die later on */
} }
@ -670,7 +670,7 @@ meta_screen_new (MetaDisplay *display,
KeyPressMask | KeyReleaseMask | KeyPressMask | KeyReleaseMask |
FocusChangeMask | StructureNotifyMask | FocusChangeMask | StructureNotifyMask |
ExposureMask | attr.your_event_mask); ExposureMask | attr.your_event_mask);
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
{ {
meta_warning (_("Screen %d on display \"%s\" already has a window manager\n"), meta_warning (_("Screen %d on display \"%s\" already has a window manager\n"),
number, display->name); number, display->name);
@ -856,7 +856,7 @@ meta_screen_free (MetaScreen *screen,
meta_error_trap_push_with_return (screen->display); meta_error_trap_push_with_return (screen->display);
XSelectInput (screen->display->xdisplay, screen->xroot, 0); XSelectInput (screen->display->xdisplay, screen->xroot, 0);
if (meta_error_trap_pop_with_return (screen->display, FALSE) != Success) if (meta_error_trap_pop_with_return (screen->display) != Success)
meta_warning (_("Could not release screen %d on display \"%s\"\n"), meta_warning (_("Could not release screen %d on display \"%s\"\n"),
screen->number, screen->display->name); screen->number, screen->display->name);
@ -913,7 +913,7 @@ list_windows (MetaScreen *screen)
XGetWindowAttributes (screen->display->xdisplay, XGetWindowAttributes (screen->display->xdisplay,
children[i], &info->attrs); children[i], &info->attrs);
if (meta_error_trap_pop_with_return (screen->display, TRUE)) if (meta_error_trap_pop_with_return (screen->display))
{ {
meta_verbose ("Failed to get attributes for window 0x%lx\n", meta_verbose ("Failed to get attributes for window 0x%lx\n",
children[i]); children[i]);
@ -1220,7 +1220,7 @@ set_number_of_spaces_hint (MetaScreen *screen,
screen->display->atom__NET_NUMBER_OF_DESKTOPS, screen->display->atom__NET_NUMBER_OF_DESKTOPS,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1); 32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
} }
static void static void
@ -1241,7 +1241,7 @@ set_desktop_geometry_hint (MetaScreen *screen)
screen->display->atom__NET_DESKTOP_GEOMETRY, screen->display->atom__NET_DESKTOP_GEOMETRY,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 2); 32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
} }
static void static void
@ -1265,7 +1265,7 @@ set_desktop_viewport_hint (MetaScreen *screen)
screen->display->atom__NET_DESKTOP_VIEWPORT, screen->display->atom__NET_DESKTOP_VIEWPORT,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 2); 32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
} }
void void
@ -1839,7 +1839,7 @@ meta_screen_get_mouse_window (MetaScreen *screen,
&win_x_return, &win_x_return,
&win_y_return, &win_y_return,
&mask_return); &mask_return);
meta_error_trap_pop (screen->display, TRUE); meta_error_trap_pop (screen->display);
window = meta_stack_get_default_focus_window_at_point (screen->stack, window = meta_stack_get_default_focus_window_at_point (screen->stack,
screen->active_workspace, screen->active_workspace,
@ -2242,7 +2242,7 @@ set_workspace_names (MetaScreen *screen)
screen->display->atom_UTF8_STRING, screen->display->atom_UTF8_STRING,
8, PropModeReplace, 8, PropModeReplace,
(unsigned char *)flattened->str, flattened->len); (unsigned char *)flattened->str, flattened->len);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
g_string_free (flattened, TRUE); g_string_free (flattened, TRUE);
} }
@ -2346,7 +2346,7 @@ set_work_area_hint (MetaScreen *screen)
XA_CARDINAL, 32, PropModeReplace, XA_CARDINAL, 32, PropModeReplace,
(guchar*) data, num_workspaces*4); (guchar*) data, num_workspaces*4);
g_free (data); g_free (data);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
g_signal_emit (screen, screen_signals[WORKAREAS_CHANGED], 0); g_signal_emit (screen, screen_signals[WORKAREAS_CHANGED], 0);
} }
@ -2721,7 +2721,7 @@ meta_screen_update_showing_desktop_hint (MetaScreen *screen)
screen->display->atom__NET_SHOWING_DESKTOP, screen->display->atom__NET_SHOWING_DESKTOP,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1); 32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
} }
static void static void

View File

@ -1026,7 +1026,7 @@ raise_window_relative_to_managed_windows (MetaScreen *screen,
xwindow, xwindow,
CWSibling | CWStackMode, CWSibling | CWStackMode,
&changes); &changes);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
break; break;
} }
@ -1046,7 +1046,7 @@ raise_window_relative_to_managed_windows (MetaScreen *screen,
XNextRequest (screen->display->xdisplay)); XNextRequest (screen->display->xdisplay));
XLowerWindow (screen->display->xdisplay, XLowerWindow (screen->display->xdisplay,
xwindow); xwindow);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
} }
} }
@ -1267,7 +1267,7 @@ stack_sync_to_server (MetaStack *stack)
all_hidden->len); all_hidden->len);
g_array_free (all_hidden, TRUE); g_array_free (all_hidden, TRUE);
meta_error_trap_pop (stack->screen->display, FALSE); meta_error_trap_pop (stack->screen->display);
/* on error, a window was destroyed; it should eventually /* on error, a window was destroyed; it should eventually
* get removed from the stacking list when we unmanage it * get removed from the stacking list when we unmanage it
* and we'll fix stacking at that time. * and we'll fix stacking at that time.

View File

@ -442,7 +442,7 @@ set_title_text (MetaWindow *window,
XDeleteProperty (window->display->xdisplay, XDeleteProperty (window->display->xdisplay,
window->xwindow, window->xwindow,
atom); atom);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
return modified; return modified;

View File

@ -484,11 +484,11 @@ meta_window_new (MetaDisplay *display,
if (XGetWindowAttributes (display->xdisplay,xwindow, &attrs)) if (XGetWindowAttributes (display->xdisplay,xwindow, &attrs))
{ {
if(meta_error_trap_pop_with_return (display, TRUE) != Success) if(meta_error_trap_pop_with_return (display) != Success)
{ {
meta_verbose ("Failed to get attributes for window 0x%lx\n", meta_verbose ("Failed to get attributes for window 0x%lx\n",
xwindow); xwindow);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
meta_display_ungrab (display); meta_display_ungrab (display);
return NULL; return NULL;
} }
@ -499,16 +499,16 @@ meta_window_new (MetaDisplay *display,
} }
else else
{ {
meta_error_trap_pop_with_return (display, TRUE); meta_error_trap_pop_with_return (display);
meta_verbose ("Failed to get attributes for window 0x%lx\n", meta_verbose ("Failed to get attributes for window 0x%lx\n",
xwindow); xwindow);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
meta_display_ungrab (display); meta_display_ungrab (display);
return NULL; return NULL;
} }
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
meta_display_ungrab (display); meta_display_ungrab (display);
return window; return window;
@ -607,7 +607,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
(state == IconicState || state == NormalState))) (state == IconicState || state == NormalState)))
{ {
meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow); meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow);
meta_error_trap_pop (display, TRUE); meta_error_trap_pop (display);
meta_display_ungrab (display); meta_display_ungrab (display);
return NULL; return NULL;
} }
@ -629,7 +629,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
*/ */
meta_error_trap_push_with_return (display); meta_error_trap_push_with_return (display);
XAddToSaveSet (display->xdisplay, xwindow); XAddToSaveSet (display->xdisplay, xwindow);
meta_error_trap_pop_with_return (display, FALSE); meta_error_trap_pop_with_return (display);
event_mask = event_mask =
PropertyChangeMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask | EnterWindowMask | LeaveWindowMask |
@ -685,11 +685,11 @@ meta_window_new_with_attrs (MetaDisplay *display,
&set_attrs); &set_attrs);
} }
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
{ {
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n", meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
xwindow); xwindow);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
meta_display_ungrab (display); meta_display_ungrab (display);
return NULL; return NULL;
} }
@ -1162,7 +1162,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
!window->initially_iconic) !window->initially_iconic)
unminimize_window_and_all_transient_parents (window); unminimize_window_and_all_transient_parents (window);
meta_error_trap_pop (display, FALSE); /* pop the XSync()-reducing trap */ meta_error_trap_pop (display); /* pop the XSync()-reducing trap */
meta_display_ungrab (display); meta_display_ungrab (display);
window->constructing = FALSE; window->constructing = FALSE;
@ -1482,7 +1482,7 @@ meta_window_unmanage (MetaWindow *window,
window->xwindow, window->xwindow,
window->display->atom__NET_WM_FULLSCREEN_MONITORS); window->display->atom__NET_WM_FULLSCREEN_MONITORS);
set_wm_state (window, WithdrawnState); set_wm_state (window, WithdrawnState);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
else else
{ {
@ -1493,7 +1493,7 @@ meta_window_unmanage (MetaWindow *window,
{ {
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
set_wm_state (window, NormalState); set_wm_state (window, NormalState);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
/* And we need to be sure the window is mapped so other WMs /* And we need to be sure the window is mapped so other WMs
@ -1502,7 +1502,7 @@ meta_window_unmanage (MetaWindow *window,
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XMapWindow (window->display->xdisplay, XMapWindow (window->display->xdisplay,
window->xwindow); window->xwindow);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
meta_window_ungrab_keys (window); meta_window_ungrab_keys (window);
@ -1550,7 +1550,7 @@ meta_window_unmanage (MetaWindow *window,
XShapeSelectInput (window->display->xdisplay, window->xwindow, NoEventMask); XShapeSelectInput (window->display->xdisplay, window->xwindow, NoEventMask);
#endif #endif
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
g_signal_emit (window, window_signals[UNMANAGED], 0); g_signal_emit (window, window_signals[UNMANAGED], 0);
@ -1577,7 +1577,7 @@ set_wm_state (MetaWindow *window,
window->display->atom_WM_STATE, window->display->atom_WM_STATE,
window->display->atom_WM_STATE, window->display->atom_WM_STATE,
32, PropModeReplace, (guchar*) data, 2); 32, PropModeReplace, (guchar*) data, 2);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
static void static void
@ -1655,7 +1655,7 @@ set_net_wm_state (MetaWindow *window)
window->display->atom__NET_WM_STATE, window->display->atom__NET_WM_STATE,
XA_ATOM, XA_ATOM,
32, PropModeReplace, (guchar*) data, i); 32, PropModeReplace, (guchar*) data, i);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
if (window->fullscreen) if (window->fullscreen)
{ {
@ -1671,7 +1671,7 @@ set_net_wm_state (MetaWindow *window)
window->display->atom__NET_WM_FULLSCREEN_MONITORS, window->display->atom__NET_WM_FULLSCREEN_MONITORS,
XA_CARDINAL, 32, PropModeReplace, XA_CARDINAL, 32, PropModeReplace,
(guchar*) data, 4); (guchar*) data, 4);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
} }
@ -2414,7 +2414,7 @@ map_client_window (MetaWindow *window)
window->mapped = TRUE; window->mapped = TRUE;
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XMapWindow (window->display->xdisplay, window->xwindow); XMapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
return TRUE; return TRUE;
} }
@ -2438,7 +2438,7 @@ unmap_client_window (MetaWindow *window,
window->unmaps_pending += 1; window->unmaps_pending += 1;
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XUnmapWindow (window->display->xdisplay, window->xwindow); XUnmapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
return TRUE; return TRUE;
} }
@ -4323,7 +4323,7 @@ meta_window_move_resize_internal (MetaWindow *window,
mask, mask,
&values); &values);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
if (!configure_frame_first && window->frame) if (!configure_frame_first && window->frame)
@ -5026,7 +5026,7 @@ update_net_frame_extents (MetaWindow *window)
window->display->atom__NET_FRAME_EXTENTS, window->display->atom__NET_FRAME_EXTENTS,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 4); 32, PropModeReplace, (guchar*) data, 4);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
void void
@ -5053,7 +5053,7 @@ meta_window_set_current_workspace_hint (MetaWindow *window)
window->display->atom__NET_WM_DESKTOP, window->display->atom__NET_WM_DESKTOP,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1); 32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
static gboolean static gboolean
@ -5178,7 +5178,7 @@ meta_window_send_icccm_message (MetaWindow *window,
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XSendEvent (window->display->xdisplay, XSendEvent (window->display->xdisplay,
window->xwindow, False, 0, (XEvent*) &ev); window->xwindow, False, 0, (XEvent*) &ev);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
void void
@ -5583,12 +5583,12 @@ meta_window_client_message (MetaWindow *window,
meta_error_trap_push_with_return (display); meta_error_trap_push_with_return (display);
str1 = XGetAtomName (display->xdisplay, first); str1 = XGetAtomName (display->xdisplay, first);
if (meta_error_trap_pop_with_return (display, TRUE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
str1 = NULL; str1 = NULL;
meta_error_trap_push_with_return (display); meta_error_trap_push_with_return (display);
str2 = XGetAtomName (display->xdisplay, second); str2 = XGetAtomName (display->xdisplay, second);
if (meta_error_trap_pop_with_return (display, TRUE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
str2 = NULL; str2 = NULL;
meta_verbose ("Request to change _NET_WM_STATE action %lu atom1: %s atom2: %s\n", meta_verbose ("Request to change _NET_WM_STATE action %lu atom1: %s atom2: %s\n",
@ -5876,7 +5876,7 @@ meta_window_client_message (MetaWindow *window,
&query_root_x, &query_root_y, &query_root_x, &query_root_y,
&x, &y, &x, &y,
&mask); &mask);
meta_error_trap_pop (window->display, TRUE); meta_error_trap_pop (window->display);
if (mask & Button1Mask) if (mask & Button1Mask)
button = 1; button = 1;
@ -6112,7 +6112,7 @@ meta_window_notify_focus (MetaWindow *window,
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XInstallColormap (window->display->xdisplay, XInstallColormap (window->display->xdisplay,
window->colormap); window->colormap);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
/* move into FOCUSED_WINDOW layer */ /* move into FOCUSED_WINDOW layer */
meta_window_update_layer (window); meta_window_update_layer (window);
@ -6175,7 +6175,7 @@ meta_window_notify_focus (MetaWindow *window,
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
XUninstallColormap (window->display->xdisplay, XUninstallColormap (window->display->xdisplay,
window->colormap); window->colormap);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
/* move out of FOCUSED_WINDOW layer */ /* move out of FOCUSED_WINDOW layer */
meta_window_update_layer (window); meta_window_update_layer (window);
@ -6266,7 +6266,7 @@ send_configure_notify (MetaWindow *window)
XSendEvent (window->display->xdisplay, XSendEvent (window->display->xdisplay,
window->xwindow, window->xwindow,
False, StructureNotifyMask, &event); False, StructureNotifyMask, &event);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
/* FIXME: @rect should be marked (out), but gjs doesn't currently support /* FIXME: @rect should be marked (out), but gjs doesn't currently support
@ -6502,7 +6502,7 @@ meta_window_update_net_wm_type (MetaWindow *window)
{ {
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
str = XGetAtomName (window->display->xdisplay, window->type_atom); str = XGetAtomName (window->display->xdisplay, window->type_atom);
meta_error_trap_pop (window->display, TRUE); meta_error_trap_pop (window->display);
} }
meta_verbose ("Window %s type atom %s\n", window->desc, meta_verbose ("Window %s type atom %s\n", window->desc,
@ -6863,7 +6863,7 @@ recalc_window_type (MetaWindow *window)
meta_error_trap_push (window->display); meta_error_trap_push (window->display);
atom_name = XGetAtomName (window->display->xdisplay, atom_name = XGetAtomName (window->display->xdisplay,
window->type_atom); window->type_atom);
meta_error_trap_pop (window->display, TRUE); meta_error_trap_pop (window->display);
meta_warning ("Unrecognized type atom [%s] set for %s \n", meta_warning ("Unrecognized type atom [%s] set for %s \n",
atom_name ? atom_name : "unknown", atom_name ? atom_name : "unknown",
@ -7021,7 +7021,7 @@ set_allowed_actions_hint (MetaWindow *window)
window->display->atom__NET_WM_ALLOWED_ACTIONS, window->display->atom__NET_WM_ALLOWED_ACTIONS,
XA_ATOM, XA_ATOM,
32, PropModeReplace, (guchar*) data, i); 32, PropModeReplace, (guchar*) data, i);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
#undef MAX_N_ACTIONS #undef MAX_N_ACTIONS
} }
@ -8493,7 +8493,7 @@ meta_window_set_gravity (MetaWindow *window,
CWWinGravity, CWWinGravity,
&attrs); &attrs);
meta_error_trap_pop (window->display, FALSE); meta_error_trap_pop (window->display);
} }
static void static void
@ -8937,7 +8937,7 @@ warp_grab_pointer (MetaWindow *window,
0, 0, 0, 0, 0, 0, 0, 0,
*x, *y); *x, *y);
if (meta_error_trap_pop_with_return (display, FALSE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
{ {
meta_verbose ("Failed to warp pointer for window %s\n", meta_verbose ("Failed to warp pointer for window %s\n",
window->desc); window->desc);

View File

@ -765,7 +765,7 @@ set_active_space_hint (MetaScreen *screen)
screen->display->atom__NET_CURRENT_DESKTOP, screen->display->atom__NET_CURRENT_DESKTOP,
XA_CARDINAL, XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1); 32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (screen->display, FALSE); meta_error_trap_pop (screen->display);
} }
void void

View File

@ -126,7 +126,7 @@ validate_or_free_results (GetPropertyResults *results,
type_name = XGetAtomName (results->display->xdisplay, results->type); type_name = XGetAtomName (results->display->xdisplay, results->type);
expected_name = XGetAtomName (results->display->xdisplay, expected_type); expected_name = XGetAtomName (results->display->xdisplay, expected_type);
prop_name = XGetAtomName (results->display->xdisplay, results->xatom); prop_name = XGetAtomName (results->display->xdisplay, results->xatom);
meta_error_trap_pop (results->display, TRUE); meta_error_trap_pop (results->display);
w = meta_display_lookup_x_window (results->display, results->xwindow); w = meta_display_lookup_x_window (results->display, results->xwindow);
@ -204,11 +204,11 @@ get_property (MetaDisplay *display,
{ {
if (results->prop) if (results->prop)
XFree (results->prop); XFree (results->prop);
meta_error_trap_pop_with_return (display, TRUE); meta_error_trap_pop_with_return (display);
return FALSE; return FALSE;
} }
if (meta_error_trap_pop_with_return (display, TRUE) != Success) if (meta_error_trap_pop_with_return (display) != Success)
{ {
if (results->prop) if (results->prop)
XFree (results->prop); XFree (results->prop);
@ -490,7 +490,7 @@ utf8_list_from_results (GetPropertyResults *results,
meta_error_trap_push (results->display); meta_error_trap_push (results->display);
name = XGetAtomName (results->display->xdisplay, results->xatom); name = XGetAtomName (results->display->xdisplay, results->xatom);
meta_error_trap_pop (results->display, TRUE); meta_error_trap_pop (results->display);
meta_warning (_("Property %s on window 0x%lx contained invalid UTF-8 for item %d in the list\n"), meta_warning (_("Property %s on window 0x%lx contained invalid UTF-8 for item %d in the list\n"),
name, results->xwindow, i); name, results->xwindow, i);
meta_XFree (name); meta_XFree (name);
@ -547,7 +547,7 @@ meta_prop_set_utf8_string_hint (MetaDisplay *display,
xwindow, atom, xwindow, atom,
display->atom_UTF8_STRING, display->atom_UTF8_STRING,
8, PropModeReplace, (guchar*) val, strlen (val)); 8, PropModeReplace, (guchar*) val, strlen (val));
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display);
} }
static gboolean static gboolean

View File

@ -1,80 +0,0 @@
#ifndef __GDK_COMPAT_H__
#define __GDK_COMPAT_H__
#include <gdk/gdk.h>
#include <math.h>
/* Provide a compatibility layer for accessor function introduced
* in GTK+ 2.22 which we need to build without deprecated GDK symbols.
* That way it is still possible to build with GTK+ 2.18 when not
* using GDK_DISABLE_DEPRECATED.
*/
#if !GTK_CHECK_VERSION (2, 21, 1)
#define gdk_visual_get_depth(v) GDK_VISUAL(v)->depth
#endif /* GTK_CHECK_VERSION (2, 21, 1) */
#if !GTK_CHECK_VERSION (2, 90, 8)
#define gdk_window_get_screen gdk_drawable_get_screen
#define gdk_pixbuf_get_from_window(window, src_x, src_y, width, height) \
gdk_pixbuf_get_from_drawable(NULL, window, NULL, src_x, src_y, 0, 0, width, height)
static inline int
gdk_window_get_width (GdkWindow *window)
{
int width;
gdk_drawable_get_size (window, &width, NULL);
return width;
}
static inline int
gdk_window_get_height (GdkWindow *window)
{
int height;
gdk_drawable_get_size (window, NULL, &height);
return height;
}
static inline gboolean
gdk_cairo_get_clip_rectangle (cairo_t *cr,
GdkRectangle *rect)
{
double x1, y1, x2, y2;
gboolean clip_exists;
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
clip_exists = x1 < x2 && y1 < y2;
if (rect)
{
x1 = floor (x1);
y1 = floor (y1);
x2 = ceil (x2);
y2 = ceil (y2);
rect->x = CLAMP (x1, G_MININT, G_MAXINT);
rect->y = CLAMP (y1, G_MININT, G_MAXINT);
rect->width = CLAMP (x2 - x1, G_MININT, G_MAXINT);
rect->height = CLAMP (y2 - y1, G_MININT, G_MAXINT);
}
return clip_exists;
}
#endif /* GTK_CHECK_VERSION (2, 90, 8) */
/* Compatibility with old GDK key symbols */
#ifndef GDK_KEY_Escape
#define GDK_KEY_Escape GDK_Escape
#endif /* GDK_KEY_Escape */
#endif /* __GDK_COMPAT_H__ */

View File

@ -1,177 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2010 Red Hat Inc.
*
* 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.
*/
#include <config.h>
#include "gdk2-drawing-utils.h"
#include <math.h>
#include "gdk-compat.h"
#ifndef USE_GTK3
static const cairo_user_data_key_t context_key;
cairo_t *
meta_cairo_create (GdkDrawable *drawable)
{
cairo_t *cr;
cr = gdk_cairo_create (drawable);
cairo_set_user_data (cr, &context_key, drawable, NULL);
return cr;
}
static GdkWindow *
extract_window (cairo_t *cr,
int *dx,
int *dy,
GdkRectangle *clip_area)
{
GdkWindow *window = cairo_get_user_data (cr, &context_key);
cairo_matrix_t matrix;
g_assert (dx != NULL);
g_assert (dy != NULL);
g_assert (clip_area != NULL);
/* lots of stuff that mustn't happen because we can't cope with it. */
if (window == NULL)
{
g_error ("Could not get the GdkWindow from the cairo context passed to\n"
"theme drawing functions. A GdkWindow must be set on all cairo\n"
"context passed to theme drawing functions when using GTK2.\n"
"Please use meta_cairo_create() to create the Cairo context.\n");
}
cairo_get_matrix (cr, &matrix);
if (matrix.xx != 1.0 || matrix.yy != 1.0 ||
matrix.xy != 0.0 || matrix.yx != 0.0 ||
floor (matrix.x0) != matrix.x0 ||
floor (matrix.y0) != matrix.y0)
{
g_error ("GTK2 drawing requires that the matrix set on the cairo context\n"
"is an integer translation, however that is not the case.\n");
}
gdk_cairo_get_clip_rectangle (cr, clip_area);
clip_area->x += matrix.x0;
clip_area->y += matrix.y0;
*dx = matrix.x0;
*dy = matrix.y0;
return window;
}
void
meta_paint_vline (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkWidget *widget,
const gchar *detail,
gint y1_,
gint y2_,
gint x)
{
int dx, dy;
GdkWindow *window;
GdkRectangle area;
window = extract_window (cr, &dx, &dy, &area);
gtk_paint_vline (style, window, state_type, &area,
widget, detail, y1_ + dy, y2_ + dy, x + dx);
}
void
meta_paint_arrow (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
GtkWidget *widget,
const gchar *detail,
GtkArrowType arrow_type,
gboolean fill,
gint x,
gint y,
gint width,
gint height)
{
int dx, dy;
GdkWindow *window;
GdkRectangle area;
window = extract_window (cr, &dx, &dy, &area);
gtk_paint_arrow (style, window, state_type, shadow_type,
&area, widget, detail, arrow_type,
fill, x + dx, y + dy, width, height);
}
void
meta_paint_box (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y,
gint width,
gint height)
{
int dx, dy;
GdkWindow *window;
GdkRectangle area;
window = extract_window (cr, &dx, &dy, &area);
gtk_paint_box (style, window, state_type, shadow_type,
&area, widget, detail,
x + dx, y + dy, width, height);
}
void
meta_paint_flat_box (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y,
gint width,
gint height)
{
int dx, dy;
GdkWindow *window;
GdkRectangle area;
window = extract_window (cr, &dx, &dy, &area);
gtk_paint_flat_box (style, window, state_type, shadow_type,
&area, widget, detail,
x + dx, y + dy, width, height);
}
#endif /* USE_GTK3 */

View File

@ -1,100 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2010 Red Hat Inc.
*
* 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 __GTK3_COMPAT_H__
#define __GTK3_COMPAT_H__
#include <gtk/gtk.h>
#if GTK_CHECK_VERSION (2, 90, 8)
#define USE_GTK3 1
#define MetaPixmap cairo_surface_t
#define meta_pixmap_new(window, w, h) gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR, w, h)
#define meta_pixmap_free(pixmap) cairo_surface_destroy (pixmap)
#define meta_pixmap_cairo_create(pixmap) cairo_create (pixmap)
#define meta_cairo_set_source_pixmap(cr, pixmap, x, y) cairo_set_source_surface (cr, pixmap, x, y)
#define meta_paint_vline gtk_paint_vline
#define meta_paint_box gtk_paint_box
#define meta_paint_arrow gtk_paint_arrow
#define meta_paint_flat_box gtk_paint_flat_box
#else /* GTK_VERSION < 2.90.8 */
#undef USE_GTK3
#define MetaPixmap GdkPixmap
#define meta_pixmap_new(window, w, h) gdk_pixmap_new (window, w, h, -1)
#define meta_pixmap_free(pixmap) g_object_unref (pixmap)
#define meta_pixmap_cairo_create(pixmap) meta_cairo_create (pixmap)
#define meta_cairo_set_source_pixmap(cr, pixmap, x, y) gdk_cairo_set_source_pixmap (cr, pixmap, x, y)
/* This function only exists for GTK2 code. */
cairo_t * meta_cairo_create (GdkDrawable *drawable);
void meta_paint_vline (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkWidget *widget,
const gchar *detail,
gint y1_,
gint y2_,
gint x);
void meta_paint_arrow (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
GtkWidget *widget,
const gchar *detail,
GtkArrowType arrow_type,
gboolean fill,
gint x,
gint y,
gint width,
gint height);
void meta_paint_box (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y,
gint width,
gint height);
void meta_paint_flat_box (GtkStyle *style,
cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y,
gint width,
gint height);
#endif /* GTK_VERSION < 2.90.8 */
#endif /* __GTK3_COMPAT_H__ */

View File

@ -1,26 +0,0 @@
#ifndef __GTK_COMPAT_H__
#define __GTK_COMPAT_H__
#include <gtk/gtk.h>
/* Provide a compatibility layer for accessor function introduces
* in GTK+ 2.20 which we need to build with GSEAL_ENABLE.
* That way it is still possible to build with GTK+ 2.18 when not
* using GSEAL_ENABLE
*/
#if !GTK_CHECK_VERSION (2, 20, 0)
#define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED (w)
#define gtk_widget_get_requisition(w,r) (*r = GTK_WIDGET (w)->requisition)
#define gtk_widget_set_mapped(w,m) \
G_STMT_START { \
if (m) \
GTK_WIDGET_SET_FLAGS (w, GTK_MAPPED); \
else \
GTK_WIDGET_UNSET_FLAGS (w, GTK_MAPPED); \
} G_STMT_END
#endif /* GTK_CHECK_VERSION */
#endif /* __GTK_COMPAT_H__ */

View File

@ -29,16 +29,12 @@
#include "util.h" #include "util.h"
#include "display.h" #include "display.h"
void meta_errors_init (void);
void meta_error_trap_push (MetaDisplay *display); void meta_error_trap_push (MetaDisplay *display);
void meta_error_trap_pop (MetaDisplay *display, void meta_error_trap_pop (MetaDisplay *display);
gboolean last_request_was_roundtrip);
void meta_error_trap_push_with_return (MetaDisplay *display); void meta_error_trap_push_with_return (MetaDisplay *display);
/* returns X error code, or 0 for no error */ /* returns X error code, or 0 for no error */
int meta_error_trap_pop_with_return (MetaDisplay *display, int meta_error_trap_pop_with_return (MetaDisplay *display);
gboolean last_request_was_roundtrip);
#endif #endif

View File

@ -6,7 +6,7 @@ libgnome_serverdir=@libexecdir@
Name: libmutter-private Name: libmutter-private
Description: Mutter internals shared Description: Mutter internals shared
Requires: gtk+-@GTK_API_VERSION@ Requires: gtk+-3.0
Version: @VERSION@ Version: @VERSION@
Libs: -L${libdir} -lmutter-private Libs: -L${libdir} -lmutter-private
Cflags: -I${includedir}/mutter Cflags: -I${includedir}/mutter

View File

@ -29,8 +29,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include "gdk-compat.h"
static GtkWidget *grab_widget = NULL; static GtkWidget *grab_widget = NULL;
static GtkWidget *display_window = NULL; static GtkWidget *display_window = NULL;
static int last_grab_x = 0; static int last_grab_x = 0;

View File

@ -24,8 +24,6 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <unistd.h> #include <unistd.h>
#include "gtk-compat.h"
static GtkWidget* do_appwindow (void); static GtkWidget* do_appwindow (void);
static gboolean aspect_on; static gboolean aspect_on;

View File

@ -25,8 +25,6 @@
#include "fixedtip.h" #include "fixedtip.h"
#include "ui.h" #include "ui.h"
#include "gdk2-drawing-utils.h"
/** /**
* The floating rectangle. This is a GtkWindow, and it contains * The floating rectangle. This is a GtkWindow, and it contains
* the "label" widget, below. * the "label" widget, below.
@ -52,7 +50,6 @@ static int screen_right_edge = 0;
*/ */
static int screen_bottom_edge = 0; static int screen_bottom_edge = 0;
#ifdef USE_GTK3
static gboolean static gboolean
draw_handler (GtkWidget *tooltips, draw_handler (GtkWidget *tooltips,
cairo_t *cr, cairo_t *cr,
@ -68,21 +65,6 @@ draw_handler (GtkWidget *tooltips,
return FALSE; return FALSE;
} }
#else /* !USE_GTK3 */
static gint
expose_handler (GtkWidget *tooltips,
GdkEventExpose *event,
gpointer user_data)
{
gtk_paint_flat_box (gtk_widget_get_style (tip),
gtk_widget_get_window (tip),
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, tip, "tooltip",
0, 0, -1, -1);
return FALSE;
}
#endif /* !USE_GTK3 */
void void
meta_fixed_tip_show (Display *xdisplay, int screen_number, meta_fixed_tip_show (Display *xdisplay, int screen_number,
@ -116,13 +98,8 @@ meta_fixed_tip_show (Display *xdisplay, int screen_number,
gtk_widget_set_name (tip, "gtk-tooltips"); gtk_widget_set_name (tip, "gtk-tooltips");
gtk_container_set_border_width (GTK_CONTAINER (tip), 4); gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
#ifdef USE_GTK3
g_signal_connect (tip, "draw", g_signal_connect (tip, "draw",
G_CALLBACK (draw_handler), NULL); G_CALLBACK (draw_handler), NULL);
#else
g_signal_connect (tip, "expose_event",
G_CALLBACK (expose_handler), NULL);
#endif
label = gtk_label_new (NULL); label = gtk_label_new (NULL);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);

View File

@ -35,10 +35,6 @@
#include "prefs.h" #include "prefs.h"
#include "ui.h" #include "ui.h"
#include "gdk2-drawing-utils.h"
#include "gtk-compat.h"
#include "gdk-compat.h"
#include <cairo-xlib.h> #include <cairo-xlib.h>
#ifdef HAVE_SHAPE #ifdef HAVE_SHAPE
@ -47,11 +43,7 @@
#define DEFAULT_INNER_BUTTON_BORDER 3 #define DEFAULT_INNER_BUTTON_BORDER 3
#ifdef USE_GTK3
static void meta_frames_destroy (GtkWidget *object); static void meta_frames_destroy (GtkWidget *object);
#else
static void meta_frames_destroy (GtkObject *object);
#endif
static void meta_frames_finalize (GObject *object); static void meta_frames_finalize (GObject *object);
static void meta_frames_style_set (GtkWidget *widget, static void meta_frames_style_set (GtkWidget *widget,
GtkStyle *prev_style); GtkStyle *prev_style);
@ -69,13 +61,8 @@ static gboolean meta_frames_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event); GdkEventMotion *event);
static gboolean meta_frames_destroy_event (GtkWidget *widget, static gboolean meta_frames_destroy_event (GtkWidget *widget,
GdkEventAny *event); GdkEventAny *event);
#ifdef USE_GTK3
static gboolean meta_frames_draw (GtkWidget *widget, static gboolean meta_frames_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
#else
static gboolean meta_frames_expose_event (GtkWidget *widget,
GdkEventExpose *event);
#endif
static gboolean meta_frames_enter_notify_event (GtkWidget *widget, static gboolean meta_frames_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event); GdkEventCrossing *event);
static gboolean meta_frames_leave_notify_event (GtkWidget *widget, static gboolean meta_frames_leave_notify_event (GtkWidget *widget,
@ -148,22 +135,14 @@ meta_frames_class_init (MetaFramesClass *class)
gobject_class->constructor = meta_frames_constructor; gobject_class->constructor = meta_frames_constructor;
gobject_class->finalize = meta_frames_finalize; gobject_class->finalize = meta_frames_finalize;
#ifdef USE_GTK3
widget_class->destroy = meta_frames_destroy; widget_class->destroy = meta_frames_destroy;
#else
GTK_OBJECT_CLASS (class)->destroy = meta_frames_destroy;
#endif
widget_class->style_set = meta_frames_style_set; widget_class->style_set = meta_frames_style_set;
widget_class->map = meta_frames_map; widget_class->map = meta_frames_map;
widget_class->unmap = meta_frames_unmap; widget_class->unmap = meta_frames_unmap;
#ifdef USE_GTK3
widget_class->draw = meta_frames_draw; widget_class->draw = meta_frames_draw;
#else
widget_class->expose_event = meta_frames_expose_event;
#endif
widget_class->destroy_event = meta_frames_destroy_event; widget_class->destroy_event = meta_frames_destroy_event;
widget_class->button_press_event = meta_frames_button_press_event; widget_class->button_press_event = meta_frames_button_press_event;
widget_class->button_release_event = meta_frames_button_release_event; widget_class->button_release_event = meta_frames_button_release_event;
@ -238,13 +217,8 @@ listify_func (gpointer key, gpointer value, gpointer data)
*listp = g_slist_prepend (*listp, value); *listp = g_slist_prepend (*listp, value);
} }
#ifdef USE_GTK3
static void static void
meta_frames_destroy (GtkWidget *object) meta_frames_destroy (GtkWidget *object)
#else
static void
meta_frames_destroy (GtkObject *object)
#endif
{ {
GSList *winlist; GSList *winlist;
GSList *tmp; GSList *tmp;
@ -268,11 +242,7 @@ meta_frames_destroy (GtkObject *object)
} }
g_slist_free (winlist); g_slist_free (winlist);
#ifdef USE_GTK3
GTK_WIDGET_CLASS (meta_frames_parent_class)->destroy (object); GTK_WIDGET_CLASS (meta_frames_parent_class)->destroy (object);
#else
GTK_OBJECT_CLASS (meta_frames_parent_class)->destroy (object);
#endif
} }
static void static void
@ -300,7 +270,7 @@ meta_frames_finalize (GObject *object)
typedef struct typedef struct
{ {
cairo_rectangle_int_t rect; cairo_rectangle_int_t rect;
MetaPixmap *pixmap; cairo_surface_t *pixmap;
} CachedFramePiece; } CachedFramePiece;
typedef struct typedef struct
@ -337,7 +307,7 @@ invalidate_cache (MetaFrames *frames,
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
if (pixels->piece[i].pixmap) if (pixels->piece[i].pixmap)
meta_pixmap_free (pixels->piece[i].pixmap); cairo_surface_destroy (pixels->piece[i].pixmap);
g_free (pixels); g_free (pixels);
g_hash_table_remove (frames->cache, frame); g_hash_table_remove (frames->cache, frame);
@ -2036,53 +2006,6 @@ meta_frames_destroy_event (GtkWidget *widget,
return TRUE; return TRUE;
} }
#if !GTK_CHECK_VERSION(2,21,6)
/* Copied from GDK */
static cairo_surface_t *
_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable)
{
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable);
}
static cairo_pattern_t *
gdk_window_get_background_pattern (GdkWindow *window)
{
GdkWindowObject *private = (GdkWindowObject *) window;
cairo_pattern_t *pattern;
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG)
pattern = NULL;
else if (private->bg_pixmap != GDK_NO_BG &&
private->bg_pixmap != NULL)
{
static cairo_user_data_key_t key;
cairo_surface_t *surface;
surface = _gdk_drawable_ref_cairo_surface (private->bg_pixmap);
pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_pattern_set_user_data (pattern,
&key,
g_object_ref (private->bg_pixmap),
g_object_unref);
}
else
{
pattern =
cairo_pattern_create_rgb (private->bg_color.red / 65535.,
private->bg_color.green / 65535.,
private->bg_color.blue / 65535.);
}
return pattern;
}
#endif
static void static void
setup_bg_cr (cairo_t *cr, GdkWindow *window, int x_offset, int y_offset) setup_bg_cr (cairo_t *cr, GdkWindow *window, int x_offset, int y_offset)
@ -2109,22 +2032,23 @@ setup_bg_cr (cairo_t *cr, GdkWindow *window, int x_offset, int y_offset)
/* Returns a pixmap with a piece of the windows frame painted on it. /* Returns a pixmap with a piece of the windows frame painted on it.
*/ */
static MetaPixmap * static cairo_surface_t *
generate_pixmap (MetaFrames *frames, generate_pixmap (MetaFrames *frames,
MetaUIFrame *frame, MetaUIFrame *frame,
cairo_rectangle_int_t *rect) cairo_rectangle_int_t *rect)
{ {
MetaPixmap *result; cairo_surface_t *result;
cairo_t *cr; cairo_t *cr;
/* do not create a pixmap for nonexisting areas */ /* do not create a pixmap for nonexisting areas */
if (rect->width <= 0 || rect->height <= 0) if (rect->width <= 0 || rect->height <= 0)
return NULL; return NULL;
result = meta_pixmap_new (frame->window, result = gdk_window_create_similar_surface (frame->window,
rect->width, rect->height); CAIRO_CONTENT_COLOR,
rect->width, rect->height);
cr = meta_pixmap_cairo_create (result); cr = cairo_create (result);
cairo_translate (cr, -rect->x, -rect->y); cairo_translate (cr, -rect->x, -rect->y);
setup_bg_cr (cr, frame->window, 0, 0); setup_bg_cr (cr, frame->window, 0, 0);
@ -2295,8 +2219,8 @@ cached_pixels_draw (CachedPixels *pixels,
if (piece->pixmap) if (piece->pixmap)
{ {
meta_cairo_set_source_pixmap (cr, piece->pixmap, cairo_set_source_surface (cr, piece->pixmap,
piece->rect.x, piece->rect.y); piece->rect.x, piece->rect.y);
cairo_paint (cr); cairo_paint (cr);
region_piece = cairo_region_create_rectangle (&piece->rect); region_piece = cairo_region_create_rectangle (&piece->rect);
@ -2306,7 +2230,6 @@ cached_pixels_draw (CachedPixels *pixels,
} }
} }
#ifdef USE_GTK3
static gboolean static gboolean
meta_frames_draw (GtkWidget *widget, meta_frames_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
@ -2373,75 +2296,6 @@ meta_frames_draw (GtkWidget *widget,
return TRUE; return TRUE;
} }
#else /* !USE_GTK3 */
static gboolean
meta_frames_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
MetaUIFrame *frame;
MetaFrames *frames;
CachedPixels *pixels;
cairo_region_t *region;
int i, n_areas;
GdkRectangle *event_rectangles;
int n_event_rectangles;
cairo_t *cr;
frames = META_FRAMES (widget);
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
if (frame == NULL)
return FALSE;
if (frames->expose_delay_count > 0)
{
/* Redraw this entire frame later */
frame->expose_delayed = TRUE;
return TRUE;
}
populate_cache (frames, frame);
/* Count on GdkRectangle and cairo_rectangle_int_t being identical */
gdk_region_get_rectangles (event->region, &event_rectangles, &n_event_rectangles);
region = cairo_region_create_rectangles ((cairo_rectangle_int_t *)event_rectangles,
n_event_rectangles);
g_free (event_rectangles);
pixels = get_cache (frames, frame);
cr = gdk_cairo_create (event->window);
cached_pixels_draw (pixels, cr, region);
cairo_destroy (cr);
clip_to_screen (region, frame);
subtract_client_area (region, frame);
n_areas = cairo_region_num_rectangles (region);
for (i = 0; i < n_areas; i++)
{
GdkRectangle area;
/* Count on GdkRectangle and cairo_rectangle_int_t being identical */
cairo_region_get_rectangle (region, i, (cairo_rectangle_int_t *)&area);
gdk_window_begin_paint_rect (event->window, &area);
cr = gdk_cairo_create (event->window);
/* no need to clip, begin_paint_region ensures the pixmap
* is only as big as the rect we use. */
meta_frames_paint (frames, frame, cr);
cairo_destroy (cr);
gdk_window_end_paint (event->window);
}
cairo_region_destroy (region);
return TRUE;
}
#endif /* !USE_GTK3 */
static void static void
meta_frames_paint (MetaFrames *frames, meta_frames_paint (MetaFrames *frames,

View File

@ -33,8 +33,6 @@
#include "metaaccellabel.h" #include "metaaccellabel.h"
#include "ui.h" #include "ui.h"
#include "gdk-compat.h"
typedef struct _MenuItem MenuItem; typedef struct _MenuItem MenuItem;
typedef struct _MenuData MenuData; typedef struct _MenuData MenuData;

View File

@ -37,24 +37,12 @@
#include <string.h> #include <string.h>
#include "util.h" #include "util.h"
#include "gtk-compat.h"
#include "gdk2-drawing-utils.h"
#ifdef USE_GTK3
static void meta_accel_label_destroy (GtkWidget *object); static void meta_accel_label_destroy (GtkWidget *object);
#else
static void meta_accel_label_destroy (GtkObject *object);
#endif
static void meta_accel_label_finalize (GObject *object); static void meta_accel_label_finalize (GObject *object);
static void meta_accel_label_size_request (GtkWidget *widget, static void meta_accel_label_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
#ifdef USE_GTK3
static gboolean meta_accel_label_draw (GtkWidget *widget, static gboolean meta_accel_label_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
#else
static gboolean meta_accel_label_expose_event (GtkWidget *widget,
GdkEventExpose *event);
#endif
static void meta_accel_label_update (MetaAccelLabel *accel_label); static void meta_accel_label_update (MetaAccelLabel *accel_label);
static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label); static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label);
@ -69,18 +57,10 @@ meta_accel_label_class_init (MetaAccelLabelClass *class)
gobject_class->finalize = meta_accel_label_finalize; gobject_class->finalize = meta_accel_label_finalize;
#ifdef USE_GTK3
widget_class->destroy = meta_accel_label_destroy; widget_class->destroy = meta_accel_label_destroy;
#else
GTK_OBJECT_CLASS (class)->destroy = meta_accel_label_destroy;
#endif
widget_class->size_request = meta_accel_label_size_request; widget_class->size_request = meta_accel_label_size_request;
#ifdef USE_GTK3
widget_class->draw = meta_accel_label_draw; widget_class->draw = meta_accel_label_draw;
#else
widget_class->expose_event = meta_accel_label_expose_event;
#endif
class->signal_quote1 = g_strdup ("<:"); class->signal_quote1 = g_strdup ("<:");
class->signal_quote2 = g_strdup (":>"); class->signal_quote2 = g_strdup (":>");
@ -173,13 +153,8 @@ meta_accel_label_new_with_mnemonic (const gchar *string)
return GTK_WIDGET (accel_label); return GTK_WIDGET (accel_label);
} }
#ifdef USE_GTK3
static void static void
meta_accel_label_destroy (GtkWidget *object) meta_accel_label_destroy (GtkWidget *object)
#else
static void
meta_accel_label_destroy (GtkObject *object)
#endif
{ {
MetaAccelLabel *accel_label = META_ACCEL_LABEL (object); MetaAccelLabel *accel_label = META_ACCEL_LABEL (object);
@ -190,11 +165,7 @@ meta_accel_label_destroy (GtkObject *object)
accel_label->accel_mods = 0; accel_label->accel_mods = 0;
accel_label->accel_key = 0; accel_label->accel_key = 0;
#ifdef USE_GTK3
GTK_WIDGET_CLASS (meta_accel_label_parent_class)->destroy (object); GTK_WIDGET_CLASS (meta_accel_label_parent_class)->destroy (object);
#else
GTK_OBJECT_CLASS (meta_accel_label_parent_class)->destroy (object);
#endif
} }
static void static void
@ -251,7 +222,6 @@ meta_accel_label_size_request (GtkWidget *widget,
g_object_unref (G_OBJECT (layout)); g_object_unref (G_OBJECT (layout));
} }
#ifdef USE_GTK3
/* Mostly taken from GTK3. */ /* Mostly taken from GTK3. */
static gboolean static gboolean
meta_accel_label_draw (GtkWidget *widget, meta_accel_label_draw (GtkWidget *widget,
@ -338,89 +308,6 @@ meta_accel_label_draw (GtkWidget *widget,
return FALSE; return FALSE;
} }
#else /* !USE_GTK3 */
static gboolean
meta_accel_label_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
MetaAccelLabel *accel_label = META_ACCEL_LABEL (widget);
GtkMisc *misc = GTK_MISC (accel_label);
PangoLayout *layout;
if (gtk_widget_is_drawable (GTK_WIDGET (accel_label)))
{
GtkAllocation allocation;
GtkRequisition requisition;
int ac_width;
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_get_requisition (widget, &requisition);
ac_width = meta_accel_label_get_accel_width (accel_label);
if (allocation.width >= requisition.width + ac_width)
{
GtkTextDirection direction = gtk_widget_get_direction (widget);
gfloat xalign, yalign;
gint x, y;
gint xpad, ypad;
gtk_misc_get_padding (misc, &xpad, &ypad);
gtk_misc_get_alignment (misc, &xalign, &yalign);
if (direction == GTK_TEXT_DIR_RTL)
{
allocation.x += ac_width;
}
allocation.width -= ac_width;
gtk_widget_set_allocation (widget, &allocation);
if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event)
GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event (widget, event);
if (direction == GTK_TEXT_DIR_RTL)
{
allocation.x -= ac_width;
}
allocation.width += ac_width;
gtk_widget_set_allocation (widget, &allocation);
if (direction == GTK_TEXT_DIR_RTL)
{
x = allocation.x + xpad;
}
else
{
x = allocation.x + allocation.width - xpad - ac_width;
}
y = (allocation.y * (1.0 - yalign) +
(allocation.y + allocation.height -
(requisition.height - ypad * 2)) * yalign) + 1.5;
layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
gtk_paint_layout (gtk_widget_get_style (widget),
gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
FALSE,
&event->area,
widget,
"accellabel",
x, y,
layout);
g_object_unref (G_OBJECT (layout));
}
else
{
if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event)
GTK_WIDGET_CLASS (meta_accel_label_parent_class)->expose_event (widget, event);
}
}
return FALSE;
}
#endif /* !USE_GTK3 */
static void static void
meta_accel_label_update (MetaAccelLabel *accel_label) meta_accel_label_update (MetaAccelLabel *accel_label)

View File

@ -28,19 +28,12 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "preview-widget.h" #include "preview-widget.h"
#include "gdk2-drawing-utils.h"
static void meta_preview_size_request (GtkWidget *widget, static void meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req); GtkRequisition *req);
static void meta_preview_size_allocate (GtkWidget *widget, static void meta_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
#ifdef USE_GTK3
static gboolean meta_preview_draw (GtkWidget *widget, static gboolean meta_preview_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
#else
static gboolean meta_preview_expose (GtkWidget *widget,
GdkEventExpose *event);
#endif
static void meta_preview_finalize (GObject *object); static void meta_preview_finalize (GObject *object);
G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN); G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN);
@ -55,11 +48,7 @@ meta_preview_class_init (MetaPreviewClass *class)
gobject_class->finalize = meta_preview_finalize; gobject_class->finalize = meta_preview_finalize;
#ifdef USE_GTK3
widget_class->draw = meta_preview_draw; widget_class->draw = meta_preview_draw;
#else
widget_class->expose_event = meta_preview_expose;
#endif
widget_class->size_request = meta_preview_size_request; widget_class->size_request = meta_preview_size_request;
widget_class->size_allocate = meta_preview_size_allocate; widget_class->size_allocate = meta_preview_size_allocate;
} }
@ -194,7 +183,6 @@ ensure_info (MetaPreview *preview)
} }
} }
#ifdef USE_GTK3
static gboolean static gboolean
meta_preview_draw (GtkWidget *widget, meta_preview_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
@ -203,21 +191,6 @@ meta_preview_draw (GtkWidget *widget,
GtkAllocation allocation; GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
#else
static gboolean
meta_preview_expose (GtkWidget *widget,
GdkEventExpose *event)
{
cairo_t *cr = meta_cairo_create (gtk_widget_get_window (widget));
MetaPreview *preview = META_PREVIEW (widget);
GtkAllocation allocation;
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
gtk_widget_get_allocation (widget, &allocation);
cairo_translate (cr, allocation.x, allocation.y);
#endif
if (preview->theme) if (preview->theme)
{ {
@ -262,15 +235,8 @@ meta_preview_expose (GtkWidget *widget,
cairo_restore (cr); cairo_restore (cr);
} }
#ifdef USE_GTK3
/* draw child */ /* draw child */
return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr); return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr);
#else
cairo_destroy (cr);
/* draw child */
return GTK_WIDGET_CLASS (meta_preview_parent_class)->expose_event (widget, event);
#endif
} }
static void static void

View File

@ -26,7 +26,6 @@
#include "util.h" #include "util.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include "gtk-compat.h"
struct _MetaResizePopup struct _MetaResizePopup
{ {

View File

@ -36,9 +36,6 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <math.h> #include <math.h>
#include "gtk-compat.h"
#include "gdk2-drawing-utils.h"
#define OUTSIDE_SELECT_RECT 2 #define OUTSIDE_SELECT_RECT 2
#define INSIDE_SELECT_RECT 2 #define INSIDE_SELECT_RECT 2
@ -74,21 +71,11 @@ static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace);
static void select_workspace (GtkWidget *widget); static void select_workspace (GtkWidget *widget);
static void unselect_workspace (GtkWidget *widget); static void unselect_workspace (GtkWidget *widget);
#ifdef USE_GTK3
static gboolean static gboolean
outline_window_draw (GtkWidget *widget, outline_window_draw (GtkWidget *widget,
cairo_t *cr, cairo_t *cr,
gpointer data) gpointer data)
{ {
#else /* !USE_GTK3 */
static gboolean
outline_window_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
cairo_t *cr = gdk_cairo_create (event->window);
#endif /* !USE_GTK3 */
MetaTabPopup *popup; MetaTabPopup *popup;
TabEntry *te; TabEntry *te;
GtkStyle *style; GtkStyle *style;
@ -116,10 +103,6 @@ outline_window_expose (GtkWidget *widget,
te->inner_rect.height + 1); te->inner_rect.height + 1);
cairo_stroke (cr); cairo_stroke (cr);
#ifndef USE_GTK3
cairo_destroy (cr);
#endif
return FALSE; return FALSE;
} }
@ -260,13 +243,8 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
gtk_widget_set_app_paintable (popup->outline_window, TRUE); gtk_widget_set_app_paintable (popup->outline_window, TRUE);
gtk_widget_realize (popup->outline_window); gtk_widget_realize (popup->outline_window);
#ifdef USE_GTK3
g_signal_connect (G_OBJECT (popup->outline_window), "draw", g_signal_connect (G_OBJECT (popup->outline_window), "draw",
G_CALLBACK (outline_window_draw), popup); G_CALLBACK (outline_window_draw), popup);
#else
g_signal_connect (G_OBJECT (popup->outline_window), "expose_event",
G_CALLBACK (outline_window_expose), popup);
#endif
popup->window = gtk_window_new (GTK_WINDOW_POPUP); popup->window = gtk_window_new (GTK_WINDOW_POPUP);
@ -499,6 +477,9 @@ display_entry (MetaTabPopup *popup,
if (popup->outline) if (popup->outline)
{ {
cairo_region_t *region;
cairo_region_t *inner_region;
window = gtk_widget_get_window (popup->outline_window); window = gtk_widget_get_window (popup->outline_window);
/* Do stuff behind gtk's back */ /* Do stuff behind gtk's back */
@ -516,40 +497,20 @@ display_entry (MetaTabPopup *popup,
gdk_window_set_background (window, gdk_window_set_background (window,
&gtk_widget_get_style (popup->outline_window)->black); &gtk_widget_get_style (popup->outline_window)->black);
#if GTK_CHECK_VERSION (2, 90, 8) /* gtk3 */
{
cairo_region_t *region;
cairo_region_t *inner_region;
region = cairo_region_create_rectangle (&rect);
inner_region = cairo_region_create_rectangle (&te->inner_rect);
cairo_region_subtract (region, inner_region);
cairo_region_destroy (inner_region);
gdk_window_shape_combine_region (window,
region,
0, 0);
cairo_region_destroy (region); region = cairo_region_create_rectangle (&rect);
} inner_region = cairo_region_create_rectangle (&te->inner_rect);
#else /* gtk2 */ cairo_region_subtract (region, inner_region);
{ cairo_region_destroy (inner_region);
GdkRegion *region;
GdkRegion *inner_region;
region = gdk_region_rectangle (&rect); gdk_window_shape_combine_region (window,
inner_region = gdk_region_rectangle (&te->inner_rect); region,
gdk_region_subtract (region, inner_region); 0, 0);
gdk_region_destroy (inner_region);
gdk_window_shape_combine_region (window, cairo_region_destroy (region);
region,
0, 0);
gdk_region_destroy (region);
}
#endif /* gtk2 */
/* This should piss off gtk a bit, but we don't want to raise /* This should piss off gtk a bit, but we don't want to raise
* above the tab popup. So, instead of calling gtk_widget_show, * above the tab popup. So, instead of calling gtk_widget_show,
@ -693,13 +654,8 @@ unselect_image (GtkWidget *widget)
} }
static void meta_select_image_class_init (MetaSelectImageClass *klass); static void meta_select_image_class_init (MetaSelectImageClass *klass);
#if USE_GTK3
static gboolean meta_select_image_draw (GtkWidget *widget, static gboolean meta_select_image_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
#else
static gboolean meta_select_image_expose_event (GtkWidget *widget,
GdkEventExpose *event);
#endif
static GtkImageClass *parent_class; static GtkImageClass *parent_class;
@ -738,14 +694,9 @@ meta_select_image_class_init (MetaSelectImageClass *klass)
widget_class = GTK_WIDGET_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass);
#if USE_GTK3
widget_class->draw = meta_select_image_draw; widget_class->draw = meta_select_image_draw;
#else
widget_class->expose_event = meta_select_image_expose_event;
#endif
} }
#if USE_GTK3
static gboolean static gboolean
meta_select_image_draw (GtkWidget *widget, meta_select_image_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
@ -753,19 +704,6 @@ meta_select_image_draw (GtkWidget *widget,
GtkAllocation allocation; GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
#else /* !USE_GTK3 */
static gboolean
meta_select_image_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
GtkAllocation allocation;
cairo_t *cr = gdk_cairo_create (event->window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
gtk_widget_get_allocation (widget, &allocation);
cairo_translate (cr, allocation.x, allocation.y);
#endif
if (META_SELECT_IMAGE (widget)->selected) if (META_SELECT_IMAGE (widget)->selected)
{ {
@ -806,13 +744,7 @@ meta_select_image_expose_event (GtkWidget *widget,
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
} }
#ifdef USE_GTK3
return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
#else
cairo_destroy (cr);
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
#endif /* !USE_GTK3 */
} }
#define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ()) #define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ())
@ -876,13 +808,8 @@ unselect_workspace (GtkWidget *widget)
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass); static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
#if USE_GTK3
static gboolean meta_select_workspace_draw (GtkWidget *widget, static gboolean meta_select_workspace_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
#else
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
GdkEventExpose *event);
#endif
GType GType
meta_select_workspace_get_type (void) meta_select_workspace_get_type (void)
@ -920,11 +847,7 @@ meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass)
widget_class = GTK_WIDGET_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass);
#if USE_GTK3
widget_class->draw = meta_select_workspace_draw; widget_class->draw = meta_select_workspace_draw;
#else
widget_class->expose_event = meta_select_workspace_expose_event;
#endif
} }
/** /**
@ -961,18 +884,10 @@ meta_convert_meta_to_wnck (MetaWindow *window, MetaScreen *screen)
} }
#ifdef USE_GTK3
static gboolean static gboolean
meta_select_workspace_draw (GtkWidget *widget, meta_select_workspace_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
{ {
#else /* !USE_GTK3 */
static gboolean
meta_select_workspace_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
cairo_t *cr = gdk_cairo_create (event->window);
#endif /* !USE_GTK3 */
MetaWorkspace *workspace; MetaWorkspace *workspace;
WnckWindowDisplayInfo *windows; WnckWindowDisplayInfo *windows;
GtkAllocation allocation; GtkAllocation allocation;
@ -1047,9 +962,5 @@ meta_select_workspace_expose_event (GtkWidget *widget,
cairo_stroke (cr); cairo_stroke (cr);
} }
#ifndef USE_GTK3
cairo_destroy (cr);
#endif
return TRUE; return TRUE;
} }

View File

@ -34,8 +34,6 @@
#define _(x) dgettext (GETTEXT_PACKAGE, x) #define _(x) dgettext (GETTEXT_PACKAGE, x)
#define N_(x) x #define N_(x) x
#include "gdk2-drawing-utils.h"
/* We need to compute all different button arrangements /* We need to compute all different button arrangements
* in terms of button location. We don't care about * in terms of button location. We don't care about
* different arrangements in terms of button function. * different arrangements in terms of button function.
@ -942,7 +940,7 @@ static void
run_theme_benchmark (void) run_theme_benchmark (void)
{ {
GtkWidget* widget; GtkWidget* widget;
MetaPixmap *pixmap; cairo_surface_t *pixmap;
int top_height, bottom_height, left_width, right_width; int top_height, bottom_height, left_width, right_width;
MetaButtonState button_states[META_BUTTON_TYPE_LAST] = MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
{ {
@ -1006,11 +1004,12 @@ run_theme_benchmark (void)
/* Creating the pixmap in the loop is right, since /* Creating the pixmap in the loop is right, since
* GDK does the same with its double buffering. * GDK does the same with its double buffering.
*/ */
pixmap = meta_pixmap_new (gtk_widget_get_window (widget), pixmap = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
client_width + left_width + right_width, CAIRO_CONTENT_COLOR,
client_height + top_height + bottom_height); client_width + left_width + right_width,
client_height + top_height + bottom_height);
cr = meta_pixmap_cairo_create (pixmap); cr = cairo_create (pixmap);
meta_theme_draw_frame (global_theme, meta_theme_draw_frame (global_theme,
widget, widget,
@ -1026,7 +1025,7 @@ run_theme_benchmark (void)
meta_preview_get_icon ()); meta_preview_get_icon ());
cairo_destroy (cr); cairo_destroy (cr);
meta_pixmap_free (pixmap); cairo_surface_destroy (pixmap);
++i; ++i;
client_width += inc; client_width += inc;

View File

@ -61,10 +61,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include "gtk-compat.h"
#include "gdk-compat.h"
#include "gdk2-drawing-utils.h"
#define GDK_COLOR_RGBA(color) \ #define GDK_COLOR_RGBA(color) \
((guint32) (0xff | \ ((guint32) (0xff | \
(((color).red / 256) << 24) | \ (((color).red / 256) << 24) | \
@ -3712,7 +3708,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.gtk_arrow.width, env); rwidth = parse_size_unchecked (op->data.gtk_arrow.width, env);
rheight = parse_size_unchecked (op->data.gtk_arrow.height, env); rheight = parse_size_unchecked (op->data.gtk_arrow.height, env);
meta_paint_arrow (style_gtk, gtk_paint_arrow (style_gtk,
cr, cr,
op->data.gtk_arrow.state, op->data.gtk_arrow.state,
op->data.gtk_arrow.shadow, op->data.gtk_arrow.shadow,
@ -3733,7 +3729,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.gtk_box.width, env); rwidth = parse_size_unchecked (op->data.gtk_box.width, env);
rheight = parse_size_unchecked (op->data.gtk_box.height, env); rheight = parse_size_unchecked (op->data.gtk_box.height, env);
meta_paint_box (style_gtk, gtk_paint_box (style_gtk,
cr, cr,
op->data.gtk_box.state, op->data.gtk_box.state,
op->data.gtk_box.shadow, op->data.gtk_box.shadow,
@ -3751,7 +3747,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
ry1 = parse_y_position_unchecked (op->data.gtk_vline.y1, env); ry1 = parse_y_position_unchecked (op->data.gtk_vline.y1, env);
ry2 = parse_y_position_unchecked (op->data.gtk_vline.y2, env); ry2 = parse_y_position_unchecked (op->data.gtk_vline.y2, env);
meta_paint_vline (style_gtk, gtk_paint_vline (style_gtk,
cr, cr,
op->data.gtk_vline.state, op->data.gtk_vline.state,
widget, widget,

View File

@ -29,8 +29,6 @@
#include "tile-preview.h" #include "tile-preview.h"
#include "core.h" #include "core.h"
#include "gdk2-drawing-utils.h"
#define OUTLINE_WIDTH 5 /* frame width in non-composite case */ #define OUTLINE_WIDTH 5 /* frame width in non-composite case */
@ -46,20 +44,11 @@ struct _MetaTilePreview {
gboolean has_alpha: 1; gboolean has_alpha: 1;
}; };
#ifdef USE_GTK3
static gboolean static gboolean
meta_tile_preview_draw (GtkWidget *widget, meta_tile_preview_draw (GtkWidget *widget,
cairo_t *cr, cairo_t *cr,
gpointer user_data) gpointer user_data)
{ {
#else
static gboolean
meta_tile_preview_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
{
cairo_t *cr = gdk_cairo_create (event->window);
#endif
MetaTilePreview *preview = user_data; MetaTilePreview *preview = user_data;
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
@ -98,10 +87,6 @@ meta_tile_preview_expose (GtkWidget *widget,
preview->tile_rect.height - 1); preview->tile_rect.height - 1);
cairo_stroke (cr); cairo_stroke (cr);
#ifndef USE_GTK3
cairo_destroy (cr);
#endif
return FALSE; return FALSE;
} }
@ -163,13 +148,8 @@ meta_tile_preview_new (int screen_number,
if (preview->has_alpha) if (preview->has_alpha)
{ {
#ifdef USE_GTK3
gtk_widget_set_visual (preview->preview_window, gtk_widget_set_visual (preview->preview_window,
gdk_screen_get_rgba_visual (screen)); gdk_screen_get_rgba_visual (screen));
#else
gtk_widget_set_colormap (preview->preview_window,
gdk_screen_get_rgba_colormap (screen));
#endif
g_signal_connect (preview->preview_window, "style-set", g_signal_connect (preview->preview_window, "style-set",
G_CALLBACK (on_preview_window_style_set), preview); G_CALLBACK (on_preview_window_style_set), preview);
@ -181,15 +161,8 @@ meta_tile_preview_new (int screen_number,
*/ */
preview->create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); preview->create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
gtk_widget_realize (preview->preview_window); gtk_widget_realize (preview->preview_window);
#ifdef USE_GTK3
g_signal_connect (preview->preview_window, "draw", g_signal_connect (preview->preview_window, "draw",
G_CALLBACK (meta_tile_preview_draw), preview); G_CALLBACK (meta_tile_preview_draw), preview);
#else
gdk_window_set_back_pixmap (gtk_widget_get_window (preview->preview_window),
NULL, FALSE);
g_signal_connect (preview->preview_window, "expose-event",
G_CALLBACK (meta_tile_preview_expose), preview);
#endif
return preview; return preview;
} }
@ -239,6 +212,7 @@ meta_tile_preview_show (MetaTilePreview *preview,
if (!preview->has_alpha) if (!preview->has_alpha)
{ {
cairo_region_t *outer_region, *inner_region;
GdkRectangle outer_rect, inner_rect; GdkRectangle outer_rect, inner_rect;
GdkColor black; GdkColor black;
@ -254,33 +228,14 @@ meta_tile_preview_show (MetaTilePreview *preview,
inner_rect.width = outer_rect.width - 2 * OUTLINE_WIDTH; inner_rect.width = outer_rect.width - 2 * OUTLINE_WIDTH;
inner_rect.height = outer_rect.height - 2 * OUTLINE_WIDTH; inner_rect.height = outer_rect.height - 2 * OUTLINE_WIDTH;
#if GTK_CHECK_VERSION (2, 90, 8) /* gtk3 */ outer_region = cairo_region_create_rectangle (&outer_rect);
{ inner_region = cairo_region_create_rectangle (&inner_rect);
cairo_region_t *outer_region, *inner_region;
outer_region = cairo_region_create_rectangle (&outer_rect); cairo_region_subtract (outer_region, inner_region);
inner_region = cairo_region_create_rectangle (&inner_rect); cairo_region_destroy (inner_region);
cairo_region_subtract (outer_region, inner_region); gdk_window_shape_combine_region (window, outer_region, 0, 0);
cairo_region_destroy (inner_region); cairo_region_destroy (outer_region);
gdk_window_shape_combine_region (window, outer_region, 0, 0);
cairo_region_destroy (outer_region);
}
#else /* gtk2 */
{
GdkRegion *outer_region, *inner_region;
outer_region = gdk_region_rectangle (&outer_rect);
inner_region = gdk_region_rectangle (&inner_rect);
gdk_region_subtract (outer_region, inner_region);
gdk_region_destroy (inner_region);
gdk_window_shape_combine_region (window, outer_region, 0, 0);
gdk_region_destroy (outer_region);
}
#endif /* gtk2 */
} }
} }

View File

@ -32,8 +32,6 @@
#include "theme-private.h" #include "theme-private.h"
#include "inlinepixbufs.h" #include "inlinepixbufs.h"
#include "gdk-compat.h"
#include "gdk2-drawing-utils.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -174,9 +172,6 @@ meta_ui_create_frame_window (MetaUI *ui,
gint attributes_mask; gint attributes_mask;
GdkWindow *window; GdkWindow *window;
GdkVisual *visual; GdkVisual *visual;
#ifndef USE_GTK3
GdkColormap *cmap = gdk_screen_get_default_colormap (screen);
#endif
/* Default depth/visual handles clients with weird visuals; they can /* Default depth/visual handles clients with weird visuals; they can
* always be children of the root depth/visual obviously, but * always be children of the root depth/visual obviously, but
@ -189,9 +184,6 @@ meta_ui_create_frame_window (MetaUI *ui,
{ {
visual = gdk_x11_screen_lookup_visual (screen, visual = gdk_x11_screen_lookup_visual (screen,
XVisualIDFromVisual (xvisual)); XVisualIDFromVisual (xvisual));
#ifndef USE_GTK3
cmap = gdk_colormap_new (visual, FALSE);
#endif
} }
attrs.title = NULL; attrs.title = NULL;
@ -207,9 +199,6 @@ meta_ui_create_frame_window (MetaUI *ui,
attrs.y = y; attrs.y = y;
attrs.wclass = GDK_INPUT_OUTPUT; attrs.wclass = GDK_INPUT_OUTPUT;
attrs.visual = visual; attrs.visual = visual;
#ifndef USE_GTK3
attrs.colormap = cmap;
#endif
attrs.window_type = GDK_WINDOW_CHILD; attrs.window_type = GDK_WINDOW_CHILD;
attrs.cursor = NULL; attrs.cursor = NULL;
attrs.wmclass_name = NULL; attrs.wmclass_name = NULL;
@ -219,11 +208,7 @@ meta_ui_create_frame_window (MetaUI *ui,
attrs.width = width; attrs.width = width;
attrs.height = height; attrs.height = height;
#ifdef USE_GTK3
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
#else
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
#endif
/* We make an assumption that gdk_window_new() is going to call /* We make an assumption that gdk_window_new() is going to call
* XCreateWindow as it's first operation; this seems to be true currently * XCreateWindow as it's first operation; this seems to be true currently
@ -370,7 +355,6 @@ meta_ui_window_menu_free (MetaWindowMenu *menu)
meta_window_menu_free (menu); meta_window_menu_free (menu);
} }
#ifdef USE_GTK3
GdkPixbuf* GdkPixbuf*
meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap, meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap,
int src_x, int src_x,
@ -420,84 +404,6 @@ meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap,
return retval; return retval;
} }
#else /* !USE_GTK3 */
static GdkColormap*
get_cmap (GdkPixmap *pixmap)
{
GdkColormap *cmap;
cmap = gdk_drawable_get_colormap (pixmap);
if (cmap)
g_object_ref (G_OBJECT (cmap));
if (cmap == NULL)
{
if (gdk_drawable_get_depth (pixmap) == 1)
{
meta_verbose ("Using NULL colormap for snapshotting bitmap\n");
cmap = NULL;
}
else
{
meta_verbose ("Using system cmap to snapshot pixmap\n");
cmap = gdk_screen_get_system_colormap (gdk_drawable_get_screen (pixmap));
g_object_ref (G_OBJECT (cmap));
}
}
/* Be sure we aren't going to blow up due to visual mismatch */
if (cmap &&
(gdk_visual_get_depth (gdk_colormap_get_visual (cmap)) !=
gdk_drawable_get_depth (pixmap)))
{
cmap = NULL;
meta_verbose ("Switching back to NULL cmap because of depth mismatch\n");
}
return cmap;
}
GdkPixbuf*
meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap,
int src_x,
int src_y,
int width,
int height)
{
GdkDrawable *drawable;
GdkPixbuf *retval;
GdkColormap *cmap;
retval = NULL;
cmap = NULL;
drawable = gdk_xid_table_lookup (xpixmap);
if (drawable)
g_object_ref (G_OBJECT (drawable));
else
drawable = gdk_pixmap_foreign_new (xpixmap);
if (drawable)
{
cmap = get_cmap (drawable);
retval = gdk_pixbuf_get_from_drawable (NULL,
drawable,
cmap,
src_x, src_y,
0, 0,
width, height);
}
if (cmap)
g_object_unref (G_OBJECT (cmap));
if (drawable)
g_object_unref (G_OBJECT (drawable));
return retval;
}
#endif /* !USE_GTK3 */
void void
meta_ui_push_delay_exposes (MetaUI *ui) meta_ui_push_delay_exposes (MetaUI *ui)