summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArmin Krezović <krezovic.armin@gmail.com>2017-08-26 18:28:53 +0200
committerJonas Ådahl <jadahl@gmail.com>2018-07-06 19:47:16 +0200
commitc64d5ad8af0712390c1ff10795a578cb31a0bb9b (patch)
treedf4796415c390c8fd5386afdd7210107362a67bb /src
parentdacc041d0c0ddefa99085158dcbdeb13949b3cd0 (diff)
downloadmutter-c64d5ad8af0712390c1ff10795a578cb31a0bb9b.tar.gz
Move X11 extension queries to MetaX11Display
Also split extension queries into their own functions https://bugzilla.gnome.org/show_bug.cgi?id=759538
Diffstat (limited to 'src')
-rw-r--r--src/backends/meta-cursor-tracker.c5
-rw-r--r--src/backends/x11/meta-barrier-x11.c2
-rw-r--r--src/compositor/compositor.c4
-rw-r--r--src/core/display-private.h31
-rw-r--r--src/core/display.c204
-rw-r--r--src/core/screen.c2
-rw-r--r--src/meta/display.h6
-rw-r--r--src/meta/meta-x11-display.h5
-rw-r--r--src/wayland/meta-xwayland-selection.c4
-rw-r--r--src/x11/events.c26
-rw-r--r--src/x11/meta-x11-display-private.h30
-rw-r--r--src/x11/meta-x11-display.c222
-rw-r--r--src/x11/window-x11.c8
13 files changed, 293 insertions, 256 deletions
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 6244f11ee..f571fa1d3 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -43,6 +43,7 @@
#include "meta-backend-private.h"
#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
+#include "x11/meta-x11-display-private.h"
G_DEFINE_TYPE (MetaCursorTracker, meta_cursor_tracker, G_TYPE_OBJECT);
@@ -195,13 +196,13 @@ gboolean
meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
XEvent *xevent)
{
- MetaDisplay *display = meta_get_display ();
+ MetaX11Display *x11_display = meta_get_display ()->x11_display;
XFixesCursorNotifyEvent *notify_event;
if (meta_is_wayland_compositor ())
return FALSE;
- if (xevent->xany.type != display->xfixes_event_base + XFixesCursorNotify)
+ if (xevent->xany.type != x11_display->xfixes_event_base + XFixesCursorNotify)
return FALSE;
notify_event = (XFixesCursorNotifyEvent *)xevent;
diff --git a/src/backends/x11/meta-barrier-x11.c b/src/backends/x11/meta-barrier-x11.c
index c56e3442e..cccbab966 100644
--- a/src/backends/x11/meta-barrier-x11.c
+++ b/src/backends/x11/meta-barrier-x11.c
@@ -71,7 +71,7 @@ _meta_barrier_impl_x11_release (MetaBarrierImpl *impl,
MetaDisplay *display = priv->barrier->priv->display;
Display *dpy = meta_x11_display_get_xdisplay (display->x11_display);
- if (META_DISPLAY_HAS_XINPUT_23 (display))
+ if (META_X11_DISPLAY_HAS_XINPUT_23 (display->x11_display))
{
XIBarrierReleasePointer (dpy,
META_VIRTUAL_CORE_POINTER_ID,
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index fde89c58c..df3cd76f5 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -747,8 +747,10 @@ meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event,
MetaWindow *window)
{
+ MetaX11Display *x11_display = compositor->display->x11_display;
+
if (!meta_is_wayland_compositor () &&
- event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify)
+ event->type == meta_x11_display_get_damage_event_base (x11_display) + XDamageNotify)
{
/* Core code doesn't handle damage events, so we need to extract the MetaWindow
* ourselves
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 9a22cc5a8..73da74890 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -257,40 +257,9 @@ struct _MetaDisplay
MetaAlarmFilter alarm_filter;
gpointer alarm_filter_data;
- int composite_event_base;
- int composite_error_base;
- int composite_major_version;
- int composite_minor_version;
- int damage_event_base;
- int damage_error_base;
- int xfixes_event_base;
- int xfixes_error_base;
- int xinput_error_base;
- int xinput_event_base;
- int xinput_opcode;
-
ClutterActor *current_pad_osd;
MetaStartupNotification *startup_notification;
-
- int xsync_event_base;
- int xsync_error_base;
- int shape_event_base;
- int shape_error_base;
- unsigned int have_xsync : 1;
-#define META_DISPLAY_HAS_XSYNC(display) ((display)->have_xsync)
- unsigned int have_shape : 1;
-#define META_DISPLAY_HAS_SHAPE(display) ((display)->have_shape)
- unsigned int have_composite : 1;
- unsigned int have_damage : 1;
-#define META_DISPLAY_HAS_COMPOSITE(display) ((display)->have_composite)
-#define META_DISPLAY_HAS_DAMAGE(display) ((display)->have_damage)
-#ifdef HAVE_XI23
- gboolean have_xinput_23 : 1;
-#define META_DISPLAY_HAS_XINPUT_23(display) ((display)->have_xinput_23)
-#else
-#define META_DISPLAY_HAS_XINPUT_23(display) FALSE
-#endif /* HAVE_XI23 */
};
struct _MetaDisplayClass
diff --git a/src/core/display.c b/src/core/display.c
index a2ef315e3..03b10dc62 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -474,15 +474,19 @@ meta_display_remove_pending_pings_for_window (MetaDisplay *display,
static void
enable_compositor (MetaDisplay *display)
{
- if (!META_DISPLAY_HAS_COMPOSITE (display) ||
- !META_DISPLAY_HAS_DAMAGE (display))
+ MetaX11Display *x11_display = display->x11_display;
+
+ if (!META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ||
+ !META_X11_DISPLAY_HAS_DAMAGE (x11_display))
{
meta_warning ("Missing %s extension required for compositing",
- !META_DISPLAY_HAS_COMPOSITE (display) ? "composite" : "damage");
+ !META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ?
+ "composite" : "damage");
return;
}
- int version = (display->composite_major_version * 10) + display->composite_minor_version;
+ int version = (x11_display->composite_major_version * 10) +
+ x11_display->composite_minor_version;
if (version < 3)
{
meta_warning ("Your version of COMPOSITE is too old.");
@@ -692,167 +696,6 @@ meta_display_open (void)
display->xids = g_hash_table_new (meta_unsigned_long_hash,
meta_unsigned_long_equal);
- {
- int major, minor;
-
- display->have_xsync = FALSE;
-
- display->xsync_error_base = 0;
- display->xsync_event_base = 0;
-
- /* I don't think we really have to fill these in */
- major = SYNC_MAJOR_VERSION;
- minor = SYNC_MINOR_VERSION;
-
- if (!XSyncQueryExtension (xdisplay,
- &display->xsync_event_base,
- &display->xsync_error_base) ||
- !XSyncInitialize (xdisplay,
- &major, &minor))
- {
- display->xsync_error_base = 0;
- display->xsync_event_base = 0;
- }
- else
- {
- display->have_xsync = TRUE;
- XSyncSetPriority (xdisplay, None, 10);
- }
-
- meta_verbose ("Attempted to init Xsync, found version %d.%d error base %d event base %d\n",
- major, minor,
- display->xsync_error_base,
- display->xsync_event_base);
- }
-
- {
- display->have_shape = FALSE;
-
- display->shape_error_base = 0;
- display->shape_event_base = 0;
-
- if (!XShapeQueryExtension (xdisplay,
- &display->shape_event_base,
- &display->shape_error_base))
- {
- display->shape_error_base = 0;
- display->shape_event_base = 0;
- }
- else
- display->have_shape = TRUE;
-
- meta_verbose ("Attempted to init Shape, found error base %d event base %d\n",
- display->shape_error_base,
- display->shape_event_base);
- }
-
- {
- display->have_composite = FALSE;
-
- display->composite_error_base = 0;
- display->composite_event_base = 0;
-
- if (!XCompositeQueryExtension (xdisplay,
- &display->composite_event_base,
- &display->composite_error_base))
- {
- display->composite_error_base = 0;
- display->composite_event_base = 0;
- }
- else
- {
- display->composite_major_version = 0;
- display->composite_minor_version = 0;
- if (XCompositeQueryVersion (xdisplay,
- &display->composite_major_version,
- &display->composite_minor_version))
- {
- display->have_composite = TRUE;
- }
- else
- {
- display->composite_major_version = 0;
- display->composite_minor_version = 0;
- }
- }
-
- meta_verbose ("Attempted to init Composite, found error base %d event base %d "
- "extn ver %d %d\n",
- display->composite_error_base,
- display->composite_event_base,
- display->composite_major_version,
- display->composite_minor_version);
-
- display->have_damage = FALSE;
-
- display->damage_error_base = 0;
- display->damage_event_base = 0;
-
- if (!XDamageQueryExtension (xdisplay,
- &display->damage_event_base,
- &display->damage_error_base))
- {
- display->damage_error_base = 0;
- display->damage_event_base = 0;
- }
- else
- display->have_damage = TRUE;
-
- meta_verbose ("Attempted to init Damage, found error base %d event base %d\n",
- display->damage_error_base,
- display->damage_event_base);
-
- display->xfixes_error_base = 0;
- display->xfixes_event_base = 0;
-
- if (XFixesQueryExtension (xdisplay,
- &display->xfixes_event_base,
- &display->xfixes_error_base))
- {
- int xfixes_major, xfixes_minor;
-
- XFixesQueryVersion (xdisplay, &xfixes_major, &xfixes_minor);
-
- if (xfixes_major * 100 + xfixes_minor < 500)
- meta_fatal ("Mutter requires XFixes 5.0");
- }
- else
- {
- meta_fatal ("Mutter requires XFixes 5.0");
- }
-
- meta_verbose ("Attempted to init XFixes, found error base %d event base %d\n",
- display->xfixes_error_base,
- display->xfixes_event_base);
- }
-
- {
- int major = 2, minor = 3;
- gboolean has_xi = FALSE;
-
- if (XQueryExtension (xdisplay,
- "XInputExtension",
- &display->xinput_opcode,
- &display->xinput_error_base,
- &display->xinput_event_base))
- {
- if (XIQueryVersion (xdisplay, &major, &minor) == Success)
- {
- int version = (major * 10) + minor;
- if (version >= 22)
- has_xi = TRUE;
-
-#ifdef HAVE_XI23
- if (version >= 23)
- display->have_xinput_23 = TRUE;
-#endif /* HAVE_XI23 */
- }
- }
-
- if (!has_xi)
- meta_fatal ("X server doesn't have the XInput extension, version 2.2 or newer\n");
- }
-
update_cursor_theme ();
/* Create the leader window here. Set its properties and
@@ -2904,17 +2747,6 @@ meta_display_modifiers_accelerator_activate (MetaDisplay *display)
}
/**
- * meta_display_get_xinput_opcode: (skip)
- * @display: a #MetaDisplay
- *
- */
-int
-meta_display_get_xinput_opcode (MetaDisplay *display)
-{
- return display->xinput_opcode;
-}
-
-/**
* meta_display_supports_extended_barriers:
* @display: a #MetaDisplay
*
@@ -2937,7 +2769,7 @@ meta_display_supports_extended_barriers (MetaDisplay *display)
if (META_IS_BACKEND_X11 (meta_get_backend ()))
{
- return (META_DISPLAY_HAS_XINPUT_23 (display) &&
+ return (META_X11_DISPLAY_HAS_XINPUT_23 (display->x11_display) &&
!meta_is_wayland_compositor());
}
@@ -2966,12 +2798,6 @@ meta_display_get_x11_display (MetaDisplay *display)
return display->x11_display;
}
-gboolean
-meta_display_has_shape (MetaDisplay *display)
-{
- return META_DISPLAY_HAS_SHAPE (display);
-}
-
/**
* meta_display_get_focus_window:
* @display: a #MetaDisplay
@@ -2988,18 +2814,6 @@ meta_display_get_focus_window (MetaDisplay *display)
return display->focus_window;
}
-int
-meta_display_get_damage_event_base (MetaDisplay *display)
-{
- return display->damage_event_base;
-}
-
-int
-meta_display_get_shape_event_base (MetaDisplay *display)
-{
- return display->shape_event_base;
-}
-
/**
* meta_display_clear_mouse_mode:
* @display: a #MetaDisplay
diff --git a/src/core/screen.c b/src/core/screen.c
index 8f29b6548..e6ef78700 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -677,7 +677,7 @@ meta_screen_new (MetaDisplay *display,
XISetMask (mask.mask, XI_FocusIn);
XISetMask (mask.mask, XI_FocusOut);
#ifdef HAVE_XI23
- if (META_DISPLAY_HAS_XINPUT_23 (display))
+ if (META_X11_DISPLAY_HAS_XINPUT_23 (display->x11_display))
{
XISetMask (mask.mask, XI_BarrierHit);
XISetMask (mask.mask, XI_BarrierLeave);
diff --git a/src/meta/display.h b/src/meta/display.h
index 150ec958c..fa11c259c 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -73,22 +73,16 @@ GType meta_display_get_type (void) G_GNUC_CONST;
#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0)
-int meta_display_get_xinput_opcode (MetaDisplay *display);
gboolean meta_display_supports_extended_barriers (MetaDisplay *display);
MetaCompositor *meta_display_get_compositor (MetaDisplay *display);
MetaX11Display *meta_display_get_x11_display (MetaDisplay *display);
-gboolean meta_display_has_shape (MetaDisplay *display);
-
MetaWindow *meta_display_get_focus_window (MetaDisplay *display);
gboolean meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
Window xwindow);
-int meta_display_get_damage_event_base (MetaDisplay *display);
-int meta_display_get_shape_event_base (MetaDisplay *display);
-
gboolean meta_display_xserver_time_is_before (MetaDisplay *display,
guint32 time1,
guint32 time2);
diff --git a/src/meta/meta-x11-display.h b/src/meta/meta-x11-display.h
index ca150833d..f1bda49e6 100644
--- a/src/meta/meta-x11-display.h
+++ b/src/meta/meta-x11-display.h
@@ -34,4 +34,9 @@ int meta_x11_display_get_screen_number (MetaX11Display *x11_display);
Display *meta_x11_display_get_xdisplay (MetaX11Display *x11_display);
Window meta_x11_display_get_xroot (MetaX11Display *x11_display);
+int meta_x11_display_get_xinput_opcode (MetaX11Display *x11_display);
+int meta_x11_display_get_damage_event_base (MetaX11Display *x11_display);
+int meta_x11_display_get_shape_event_base (MetaX11Display *x11_display);
+gboolean meta_x11_display_has_shape (MetaX11Display *x11_display);
+
#endif /* META_X11_DISPLAY_H */
diff --git a/src/wayland/meta-xwayland-selection.c b/src/wayland/meta-xwayland-selection.c
index 5158ffb43..b70687bbd 100644
--- a/src/wayland/meta-xwayland-selection.c
+++ b/src/wayland/meta-xwayland-selection.c
@@ -1673,9 +1673,9 @@ meta_xwayland_selection_handle_event (XEvent *xevent)
return meta_xwayland_selection_handle_client_message (compositor, xevent);
default:
{
- MetaDisplay *display = meta_get_display ();
+ MetaX11Display *x11_display = meta_get_display ()->x11_display;
- if (xevent->type - display->xfixes_event_base == XFixesSelectionNotify)
+ if (xevent->type - x11_display->xfixes_event_base == XFixesSelectionNotify)
return meta_xwayland_selection_handle_xfixes_selection_notify (compositor, xevent);
return FALSE;
diff --git a/src/x11/events.c b/src/x11/events.c
index 11cebeade..24878775e 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -49,7 +49,7 @@ get_input_event (MetaDisplay *display,
XEvent *event)
{
if (event->type == GenericEvent &&
- event->xcookie.extension == display->xinput_opcode)
+ event->xcookie.extension == display->x11_display->xinput_opcode)
{
XIEvent *input_event;
@@ -189,8 +189,8 @@ event_get_modified_window (MetaDisplay *display,
return None;
default:
- if (META_DISPLAY_HAS_SHAPE (display) &&
- event->type == (display->shape_event_base + ShapeNotify))
+ if (META_X11_DISPLAY_HAS_SHAPE (display->x11_display) &&
+ event->type == (display->x11_display->shape_event_base + ShapeNotify))
{
XShapeEvent *sev = (XShapeEvent*) event;
return sev->window;
@@ -583,8 +583,8 @@ meta_spew_core_event (MetaDisplay *display,
name = "MappingNotify";
break;
default:
- if (META_DISPLAY_HAS_XSYNC (display) &&
- event->type == (display->xsync_event_base + XSyncAlarmNotify))
+ if (META_X11_DISPLAY_HAS_XSYNC (display->x11_display) &&
+ event->type == (display->x11_display->xsync_event_base + XSyncAlarmNotify))
{
XSyncAlarmNotifyEvent *aevent = (XSyncAlarmNotifyEvent*) event;
@@ -601,8 +601,8 @@ meta_spew_core_event (MetaDisplay *display,
alarm_state_to_string (aevent->state));
}
else
- if (META_DISPLAY_HAS_SHAPE (display) &&
- event->type == (display->shape_event_base + ShapeNotify))
+ if (META_X11_DISPLAY_HAS_SHAPE (display->x11_display) &&
+ event->type == (display->x11_display->shape_event_base + ShapeNotify))
{
XShapeEvent *sev = (XShapeEvent*) event;
@@ -675,10 +675,10 @@ meta_spew_event_print (MetaDisplay *display,
event->type == NoExpose)
return;
- if (event->type == (display->damage_event_base + XDamageNotify))
+ if (event->type == (display->x11_display->damage_event_base + XDamageNotify))
return;
- if (event->type == (display->xsync_event_base + XSyncAlarmNotify))
+ if (event->type == (display->x11_display->xsync_event_base + XSyncAlarmNotify))
return;
if (event->type == PropertyNotify &&
@@ -1216,8 +1216,8 @@ handle_other_xevent (MetaDisplay *display,
window = NULL;
}
- if (META_DISPLAY_HAS_XSYNC (display) &&
- event->type == (display->xsync_event_base + XSyncAlarmNotify))
+ if (META_X11_DISPLAY_HAS_XSYNC (x11_display) &&
+ event->type == (x11_display->xsync_event_base + XSyncAlarmNotify))
{
MetaWindow *alarm_window = meta_display_lookup_sync_alarm (display,
((XSyncAlarmNotifyEvent*)event)->alarm);
@@ -1242,8 +1242,8 @@ handle_other_xevent (MetaDisplay *display,
goto out;
}
- if (META_DISPLAY_HAS_SHAPE (display) &&
- event->type == (display->shape_event_base + ShapeNotify))
+ if (META_X11_DISPLAY_HAS_SHAPE (x11_display) &&
+ event->type == (x11_display->shape_event_base + ShapeNotify))
{
bypass_gtk = TRUE; /* GTK doesn't want to see this really */
diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h
index b559485b7..731375d4a 100644
--- a/src/x11/meta-x11-display-private.h
+++ b/src/x11/meta-x11-display-private.h
@@ -53,6 +53,36 @@ struct _MetaX11Display
#define item(x) Atom atom_##x;
#include "x11/atomnames.h"
#undef item
+
+ int composite_event_base;
+ int composite_error_base;
+ int composite_major_version;
+ int composite_minor_version;
+ int damage_event_base;
+ int damage_error_base;
+ int xfixes_event_base;
+ int xfixes_error_base;
+ int xinput_error_base;
+ int xinput_event_base;
+ int xinput_opcode;
+ int xsync_event_base;
+ int xsync_error_base;
+ int shape_event_base;
+ int shape_error_base;
+ unsigned int have_xsync : 1;
+#define META_X11_DISPLAY_HAS_XSYNC(x11_display) ((x11_display)->have_xsync)
+ unsigned int have_shape : 1;
+#define META_X11_DISPLAY_HAS_SHAPE(x11_display) ((x11_display)->have_shape)
+ unsigned int have_composite : 1;
+ unsigned int have_damage : 1;
+#define META_X11_DISPLAY_HAS_COMPOSITE(x11_display) ((x11_display)->have_composite)
+#define META_X11_DISPLAY_HAS_DAMAGE(x11_display) ((x11_display)->have_damage)
+#ifdef HAVE_XI23
+ gboolean have_xinput_23 : 1;
+#define META_X11_DISPLAY_HAS_XINPUT_23(x11_display) ((x11_display)->have_xinput_23)
+#else
+#define META_X11_DISPLAY_HAS_XINPUT_23(x11_display) FALSE
+#endif /* HAVE_XI23 */
};
MetaX11Display *meta_x11_display_new (MetaDisplay *display, GError **error);
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 82f53745e..d05535c3c 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -38,6 +38,15 @@
#include <unistd.h>
#include <X11/Xatom.h>
+#ifdef HAVE_RANDR
+#include <X11/extensions/Xrandr.h>
+#endif
+#include <X11/extensions/shape.h>
+#include <X11/Xcursor/Xcursor.h>
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/Xfixes.h>
+
#include "core/util-private.h"
#include "meta/errors.h"
@@ -95,6 +104,183 @@ meta_x11_display_init (MetaX11Display *x11_display)
{
}
+static void
+query_xsync_extension (MetaX11Display *x11_display)
+{
+ int major, minor;
+
+ x11_display->have_xsync = FALSE;
+
+ x11_display->xsync_error_base = 0;
+ x11_display->xsync_event_base = 0;
+
+ /* I don't think we really have to fill these in */
+ major = SYNC_MAJOR_VERSION;
+ minor = SYNC_MINOR_VERSION;
+
+ if (!XSyncQueryExtension (x11_display->xdisplay,
+ &x11_display->xsync_event_base,
+ &x11_display->xsync_error_base) ||
+ !XSyncInitialize (x11_display->xdisplay,
+ &major, &minor))
+ {
+ x11_display->xsync_error_base = 0;
+ x11_display->xsync_event_base = 0;
+ }
+ else
+ {
+ x11_display->have_xsync = TRUE;
+ XSyncSetPriority (x11_display->xdisplay, None, 10);
+ }
+
+ meta_verbose ("Attempted to init Xsync, found version %d.%d error base %d event base %d\n",
+ major, minor,
+ x11_display->xsync_error_base,
+ x11_display->xsync_event_base);
+}
+
+static void
+query_xshape_extension (MetaX11Display *x11_display)
+{
+ x11_display->have_shape = FALSE;
+
+ x11_display->shape_error_base = 0;
+ x11_display->shape_event_base = 0;
+
+ if (!XShapeQueryExtension (x11_display->xdisplay,
+ &x11_display->shape_event_base,
+ &x11_display->shape_error_base))
+ {
+ x11_display->shape_error_base = 0;
+ x11_display->shape_event_base = 0;
+ }
+ else
+ x11_display->have_shape = TRUE;
+
+ meta_verbose ("Attempted to init Shape, found error base %d event base %d\n",
+ x11_display->shape_error_base,
+ x11_display->shape_event_base);
+}
+
+static void
+query_xcomposite_extension (MetaX11Display *x11_display)
+{
+ x11_display->have_composite = FALSE;
+
+ x11_display->composite_error_base = 0;
+ x11_display->composite_event_base = 0;
+
+ if (!XCompositeQueryExtension (x11_display->xdisplay,
+ &x11_display->composite_event_base,
+ &x11_display->composite_error_base))
+ {
+ x11_display->composite_error_base = 0;
+ x11_display->composite_event_base = 0;
+ }
+ else
+ {
+ x11_display->composite_major_version = 0;
+ x11_display->composite_minor_version = 0;
+ if (XCompositeQueryVersion (x11_display->xdisplay,
+ &x11_display->composite_major_version,
+ &x11_display->composite_minor_version))
+ {
+ x11_display->have_composite = TRUE;
+ }
+ else
+ {
+ x11_display->composite_major_version = 0;
+ x11_display->composite_minor_version = 0;
+ }
+ }
+
+ meta_verbose ("Attempted to init Composite, found error base %d event base %d "
+ "extn ver %d %d\n",
+ x11_display->composite_error_base,
+ x11_display->composite_event_base,
+ x11_display->composite_major_version,
+ x11_display->composite_minor_version);
+}
+
+static void
+query_xdamage_extension (MetaX11Display *x11_display)
+{
+ x11_display->have_damage = FALSE;
+
+ x11_display->damage_error_base = 0;
+ x11_display->damage_event_base = 0;
+
+ if (!XDamageQueryExtension (x11_display->xdisplay,
+ &x11_display->damage_event_base,
+ &x11_display->damage_error_base))
+ {
+ x11_display->damage_error_base = 0;
+ x11_display->damage_event_base = 0;
+ }
+ else
+ x11_display->have_damage = TRUE;
+
+ meta_verbose ("Attempted to init Damage, found error base %d event base %d\n",
+ x11_display->damage_error_base,
+ x11_display->damage_event_base);
+}
+
+static void
+query_xfixes_extension (MetaX11Display *x11_display)
+{
+ x11_display->xfixes_error_base = 0;
+ x11_display->xfixes_event_base = 0;
+
+ if (XFixesQueryExtension (x11_display->xdisplay,
+ &x11_display->xfixes_event_base,
+ &x11_display->xfixes_error_base))
+ {
+ int xfixes_major, xfixes_minor;
+
+ XFixesQueryVersion (x11_display->xdisplay, &xfixes_major, &xfixes_minor);
+
+ if (xfixes_major * 100 + xfixes_minor < 500)
+ meta_fatal ("Mutter requires XFixes 5.0");
+ }
+ else
+ {
+ meta_fatal ("Mutter requires XFixes 5.0");
+ }
+
+ meta_verbose ("Attempted to init XFixes, found error base %d event base %d\n",
+ x11_display->xfixes_error_base,
+ x11_display->xfixes_event_base);
+}
+
+static void
+query_xi_extension (MetaX11Display *x11_display)
+{
+ int major = 2, minor = 3;
+ gboolean has_xi = FALSE;
+
+ if (XQueryExtension (x11_display->xdisplay,
+ "XInputExtension",
+ &x11_display->xinput_opcode,
+ &x11_display->xinput_error_base,
+ &x11_display->xinput_event_base))
+ {
+ if (XIQueryVersion (x11_display->xdisplay, &major, &minor) == Success)
+ {
+ int version = (major * 10) + minor;
+ if (version >= 22)
+ has_xi = TRUE;
+
+#ifdef HAVE_XI23
+ if (version >= 23)
+ x11_display->have_xinput_23 = TRUE;
+#endif /* HAVE_XI23 */
+ }
+ }
+
+ if (!has_xi)
+ meta_fatal ("X server doesn't have the XInput extension, version 2.2 or newer\n");
+}
+
/**
* meta_x11_display_new:
*
@@ -193,6 +379,13 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
#include "x11/atomnames.h"
#undef item
+ query_xsync_extension (x11_display);
+ query_xshape_extension (x11_display);
+ query_xcomposite_extension (x11_display);
+ query_xdamage_extension (x11_display);
+ query_xfixes_extension (x11_display);
+ query_xi_extension (x11_display);
+
return x11_display;
}
@@ -224,6 +417,35 @@ meta_x11_display_get_xroot (MetaX11Display *x11_display)
return x11_display->xroot;
}
+/**
+ * meta_x11_display_get_xinput_opcode: (skip)
+ * @x11_display: a #MetaX11Display
+ *
+ */
+int
+meta_x11_display_get_xinput_opcode (MetaX11Display *x11_display)
+{
+ return x11_display->xinput_opcode;
+}
+
+int
+meta_x11_display_get_damage_event_base (MetaX11Display *x11_display)
+{
+ return x11_display->damage_event_base;
+}
+
+int
+meta_x11_display_get_shape_event_base (MetaX11Display *x11_display)
+{
+ return x11_display->shape_event_base;
+}
+
+gboolean
+meta_x11_display_has_shape (MetaX11Display *x11_display)
+{
+ return META_X11_DISPLAY_HAS_SHAPE (x11_display);
+}
+
Window
meta_x11_display_create_offscreen_window (MetaX11Display *x11_display,
Window parent,
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 0341279ae..d7910a1a8 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -650,7 +650,7 @@ meta_window_x11_unmanage (MetaWindow *window)
window->user_time_window = None;
}
- if (META_DISPLAY_HAS_SHAPE (window->display))
+ if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
XShapeSelectInput (x11_display->xdisplay, window->xwindow, NoEventMask);
meta_window_ungrab_keys (window);
@@ -1797,7 +1797,7 @@ meta_window_x11_update_input_region (MetaWindow *window)
return;
}
- if (META_DISPLAY_HAS_SHAPE (window->display))
+ if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
{
/* Translate the set of XShape rectangles that we
* get from the X server to a cairo_region. */
@@ -1900,7 +1900,7 @@ meta_window_x11_update_shape_region (MetaWindow *window)
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
cairo_region_t *region = NULL;
- if (META_DISPLAY_HAS_SHAPE (window->display))
+ if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
{
/* Translate the set of XShape rectangles that we
* get from the X server to a cairo_region. */
@@ -3140,7 +3140,7 @@ meta_window_x11_new (MetaDisplay *display,
XISelectEvents (x11_display->xdisplay, xwindow, &mask, 1);
}
- if (META_DISPLAY_HAS_SHAPE (display))
+ if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
XShapeSelectInput (x11_display->xdisplay, xwindow, ShapeNotifyMask);
/* Get rid of any borders */