[mutter/wayland] Move meta_clutter_init into a new file



commit 89b931435d386c647ac17b2a60355ff7d10447a8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 31 23:00:07 2014 -0400

    Move meta_clutter_init into a new file
    
    We'll use this to get the initialization between the Wayland and
    X11 compositor codepaths back in sync.

 src/Makefile.am             |    2 +
 src/backends/meta-backend.c |   95 +++++++++++++++++++++++++++++++++++++++++++
 src/backends/meta-backend.h |   30 +++++++++++++
 src/core/main.c             |   67 +------------------------------
 4 files changed, 128 insertions(+), 66 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6eb4dc5..a1983bd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,6 +51,8 @@ wayland_protocols = \
        wayland/protocol/xserver.xml
 
 libmutter_wayland_la_SOURCES =                 \
+       backends/meta-backend.c                 \
+       backends/meta-backend.h                 \
        backends/meta-cursor.c                  \
        backends/meta-cursor.h                  \
        backends/meta-cursor-private.h          \
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
new file mode 100644
index 0000000..b4de3f6
--- /dev/null
+++ b/src/backends/meta-backend.c
@@ -0,0 +1,95 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2014 Red Hat
+ *
+ * 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.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+#include "config.h"
+
+#include "meta-backend.h"
+
+#include <gdk/gdkx.h>
+#include <clutter/clutter.h>
+#include <clutter/x11/clutter-x11.h>
+
+/* Mutter is responsible for pulling events off the X queue, so Clutter
+ * doesn't need (and shouldn't) run its normal event source which polls
+ * the X fd, but we do have to deal with dispatching events that accumulate
+ * in the clutter queue. This happens, for example, when clutter generate
+ * enter/leave events on mouse motion - several events are queued in the
+ * clutter queue but only one dispatched. It could also happen because of
+ * explicit calls to clutter_event_put(). We add a very simple custom
+ * event loop source which is simply responsible for pulling events off
+ * of the queue and dispatching them before we block for new events.
+ */
+
+static gboolean
+event_prepare (GSource    *source,
+               gint       *timeout_)
+{
+  *timeout_ = -1;
+
+  return clutter_events_pending ();
+}
+
+static gboolean
+event_check (GSource *source)
+{
+  return clutter_events_pending ();
+}
+
+static gboolean
+event_dispatch (GSource    *source,
+                GSourceFunc callback,
+                gpointer    user_data)
+{
+  ClutterEvent *event = clutter_event_get ();
+
+  if (event)
+    {
+      clutter_do_event (event);
+      clutter_event_free (event);
+    }
+
+  return TRUE;
+}
+
+static GSourceFuncs event_funcs = {
+  event_prepare,
+  event_check,
+  event_dispatch
+};
+
+void
+meta_clutter_init (void)
+{
+  GSource *source;
+
+  clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+  clutter_x11_disable_event_retrieval ();
+
+  if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
+    g_error ("Unable to initialize Clutter.\n");
+
+  source = g_source_new (&event_funcs, sizeof (GSource));
+  g_source_attach (source, NULL);
+  g_source_unref (source);
+}
diff --git a/src/backends/meta-backend.h b/src/backends/meta-backend.h
new file mode 100644
index 0000000..4c4ee1f
--- /dev/null
+++ b/src/backends/meta-backend.h
@@ -0,0 +1,30 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2014 Red Hat
+ *
+ * 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.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+#ifndef META_BACKEND_H
+#define META_BACKEND_H
+
+void meta_clutter_init (void);
+
+#endif /* META_BACKEND_H */
diff --git a/src/core/main.c b/src/core/main.c
index 4ccf75a..c0aeeb6 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -55,7 +55,6 @@
 
 #include <glib-object.h>
 #include <glib-unix.h>
-#include <gdk/gdkx.h>
 
 #include <stdlib.h>
 #include <sys/types.h>
@@ -71,7 +70,6 @@
 #include <unistd.h>
 
 #include <clutter/clutter.h>
-#include <clutter/x11/clutter-x11.h>
 
 #ifdef HAVE_INTROSPECTION
 #include <girepository.h>
@@ -80,6 +78,7 @@
 #include "x11/session.h"
 
 #include "wayland/meta-wayland.h"
+#include "backends/meta-backend.h"
 
 /*
  * The exit code we'll return to our parent process when we eventually die.
@@ -267,70 +266,6 @@ meta_get_option_context (void)
   return ctx;
 }
 
-/* Mutter is responsible for pulling events off the X queue, so Clutter
- * doesn't need (and shouldn't) run its normal event source which polls
- * the X fd, but we do have to deal with dispatching events that accumulate
- * in the clutter queue. This happens, for example, when clutter generate
- * enter/leave events on mouse motion - several events are queued in the
- * clutter queue but only one dispatched. It could also happen because of
- * explicit calls to clutter_event_put(). We add a very simple custom
- * event loop source which is simply responsible for pulling events off
- * of the queue and dispatching them before we block for new events.
- */
-
-static gboolean 
-event_prepare (GSource    *source,
-               gint       *timeout_)
-{
-  *timeout_ = -1;
-
-  return clutter_events_pending ();
-}
-
-static gboolean 
-event_check (GSource *source)
-{
-  return clutter_events_pending ();
-}
-
-static gboolean
-event_dispatch (GSource    *source,
-                GSourceFunc callback,
-                gpointer    user_data)
-{
-  ClutterEvent *event = clutter_event_get ();
-
-  if (event)
-    {
-      clutter_do_event (event);
-      clutter_event_free (event);
-    }
-
-  return TRUE;
-}
-
-static GSourceFuncs event_funcs = {
-  event_prepare,
-  event_check,
-  event_dispatch
-};
-
-static void
-meta_clutter_init (void)
-{
-  GSource *source;
-
-  clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
-  clutter_x11_disable_event_retrieval ();
-
-  if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
-    meta_fatal ("Unable to initialize Clutter.\n");
-
-  source = g_source_new (&event_funcs, sizeof (GSource));
-  g_source_attach (source, NULL);
-  g_source_unref (source);
-}
-
 /**
  * meta_select_display:
  *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]