[mutter/wip/xinput2r: 32/68] devices: Make MetaDevice/MetaDeviceMap partly public



commit 0c962b2c1d225635731c5d67e4d1b3460cea72f3
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 19 00:11:42 2011 +0200

    devices: Make MetaDevice/MetaDeviceMap partly public
    
    MetaDevice is quite limited outside of the core, mostly useful
    to represent a device, and get the paired one.

 src/Makefile.am                                 |    8 +++-
 src/core/device-keyboard.h                      |    2 +-
 src/core/device-map-core.h                      |    2 +-
 src/core/{device-map.h => device-map-private.h} |   26 +++----------
 src/core/device-map-xi2.h                       |    2 +-
 src/core/device-map.c                           |   19 +++++++++-
 src/core/device-pointer.h                       |    2 +-
 src/core/{device.h => device-private.h}         |   21 ++---------
 src/core/device.c                               |   18 +++++++++-
 src/core/display-private.h                      |    2 +-
 src/core/display.c                              |   18 +++++++++-
 src/core/input-events.c                         |    2 +-
 src/core/input-events.h                         |    2 +-
 src/meta/device-map.h                           |   45 +++++++++++++++++++++++
 src/meta/display.h                              |    2 +
 src/meta/types.h                                |    2 +
 16 files changed, 124 insertions(+), 49 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fd01073..b3d0dcc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,13 +76,15 @@ libmutter_la_SOURCES =				\
 	core/core.c				\
 	core/delete.c				\
 	core/device.c				\
-	core/device.h				\
+	meta/device.h				\
 	core/device-keyboard.c			\
 	core/device-keyboard.h			\
 	core/device-pointer.c			\
 	core/device-pointer.h			\
+	core/device-private.h			\
 	core/device-map.c			\
-	core/device-map.h			\
+	meta/device-map.h			\
+	core/device-map-private.h		\
 	core/device-map-core.c			\
 	core/device-map-core.h			\
 	core/devices-core.c			\
@@ -183,6 +185,8 @@ libmutterinclude_base_headers =		\
 	meta/common.h				\
 	meta/compositor-mutter.h		\
 	meta/compositor.h			\
+	meta/device.h				\
+	meta/device-map.h			\
 	meta/display.h				\
 	meta/errors.h				\
 	meta/gradient.h				\
diff --git a/src/core/device-keyboard.h b/src/core/device-keyboard.h
index 795e9b1..b811a4a 100644
--- a/src/core/device-keyboard.h
+++ b/src/core/device-keyboard.h
@@ -31,7 +31,7 @@
 #define META_DEVICE_KEYBOARD_H
 
 #include "display-private.h"
-#include "device.h"
+#include "device-private.h"
 
 #define META_TYPE_DEVICE_KEYBOARD            (meta_device_keyboard_get_type ())
 #define META_DEVICE_KEYBOARD(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_KEYBOARD, MetaDeviceKeyboard))
diff --git a/src/core/device-map-core.h b/src/core/device-map-core.h
index d9773de..f252d4c 100644
--- a/src/core/device-map-core.h
+++ b/src/core/device-map-core.h
@@ -32,7 +32,7 @@
 typedef struct _MetaDeviceMapCore MetaDeviceMapCore;
 typedef struct _MetaDeviceMapCoreClass MetaDeviceMapCoreClass;
 
-#include "device-map.h"
+#include "device-map-private.h"
 
 #define META_TYPE_DEVICE_MAP_CORE            (meta_device_map_core_get_type ())
 #define META_DEVICE_MAP_CORE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MAP_CORE, MetaDeviceMapCore))
diff --git a/src/core/device-map.h b/src/core/device-map-private.h
similarity index 80%
rename from src/core/device-map.h
rename to src/core/device-map-private.h
index b0e31f9..28e75f2 100644
--- a/src/core/device-map.h
+++ b/src/core/device-map-private.h
@@ -27,21 +27,13 @@
  * 02111-1307, USA.
  */
 
-#ifndef META_DEVICE_MAP_H
-#define META_DEVICE_MAP_H
-
-typedef struct _MetaDeviceMap MetaDeviceMap;
-typedef struct _MetaDeviceMapClass MetaDeviceMapClass;
+#ifndef META_DEVICE_MAP_PRIVATE_H
+#define META_DEVICE_MAP_PRIVATE_H
 
+#include <meta/device-map.h>
+#include <meta/device.h>
 #include "display-private.h"
-#include "device.h"
-
-#define META_TYPE_DEVICE_MAP            (meta_device_map_get_type ())
-#define META_DEVICE_MAP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MAP, MetaDeviceMap))
-#define META_DEVICE_MAP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_DEVICE_MAP, MetaDeviceMapClass))
-#define META_IS_DEVICE_MAP(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_DEVICE_MAP))
-#define META_IS_DEVICE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  META_TYPE_DEVICE_MAP))
-#define META_DEVICE_MAP_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  META_TYPE_DEVICE_MAP, MetaDeviceMapClass))
+#include "device-private.h"
 
 struct _MetaDeviceMap
 {
@@ -90,11 +82,6 @@ void            meta_device_map_add_device    (MetaDeviceMap *device_map,
 void            meta_device_map_remove_device (MetaDeviceMap *device_map,
                                                MetaDevice    *device);
 
-MetaDevice *    meta_device_map_lookup (MetaDeviceMap *device_map,
-                                        gint           device_id);
-
-MetaDisplay *   meta_device_map_get_display (MetaDeviceMap *device_map);
-
 gboolean meta_device_map_grab_key        (MetaDeviceMap      *device_map,
                                           Window              xwindow,
                                           guint               keycode,
@@ -115,5 +102,4 @@ void     meta_device_map_ungrab_button   (MetaDeviceMap      *device_map,
                                           guint               n_button,
                                           guint               modifiers);
 
-
-#endif /* META_DEVICE_MAP_H */
+#endif /* META_DEVICE_MAP_PRIVATE_H */
diff --git a/src/core/device-map-xi2.h b/src/core/device-map-xi2.h
index be3830a..61602fc 100644
--- a/src/core/device-map-xi2.h
+++ b/src/core/device-map-xi2.h
@@ -32,7 +32,7 @@
 typedef struct _MetaDeviceMapXI2 MetaDeviceMapXI2;
 typedef struct _MetaDeviceMapXI2Class MetaDeviceMapXI2Class;
 
-#include "device-map.h"
+#include "device-map-private.h"
 
 #define META_TYPE_DEVICE_MAP_XI2            (meta_device_map_xi2_get_type ())
 #define META_DEVICE_MAP_XI2(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MAP_XI2, MetaDeviceMapXI2))
diff --git a/src/core/device-map.c b/src/core/device-map.c
index df0f0da..aed7ad3 100644
--- a/src/core/device-map.c
+++ b/src/core/device-map.c
@@ -22,7 +22,7 @@
  */
 
 #include "config.h"
-#include "device-map.h"
+#include "device-map-private.h"
 #include "device-map-core.h"
 
 #ifdef HAVE_XINPUT2
@@ -250,6 +250,15 @@ meta_device_map_new (MetaDisplay *display,
                        NULL);
 }
 
+/**
+ * meta_device_map_lookup:
+ * @device_map: a #MetaDeviceMap
+ * @device_id: ID for a device
+ *
+ * returns the device corresponding to @device_id
+ *
+ * Returns: (transfer none): (allow-none): The matching device, or %NULL.
+ **/
 MetaDevice *
 meta_device_map_lookup (MetaDeviceMap *device_map,
                         gint           device_id)
@@ -263,6 +272,14 @@ meta_device_map_lookup (MetaDeviceMap *device_map,
                               GINT_TO_POINTER (device_id));
 }
 
+/**
+ * meta_device_map_get_display:
+ * @device_map: a #MetaDeviceMap
+ *
+ * Returns the #MetaDisplay to which @device_map belongs to.
+ *
+ * Returns: (transfer none): The #MetaDisplay.
+ **/
 MetaDisplay *
 meta_device_map_get_display (MetaDeviceMap *device_map)
 {
diff --git a/src/core/device-pointer.h b/src/core/device-pointer.h
index e0e439f..1a45aac 100644
--- a/src/core/device-pointer.h
+++ b/src/core/device-pointer.h
@@ -32,7 +32,7 @@
 
 #include "display-private.h"
 #include <meta/screen.h>
-#include "device.h"
+#include "device-private.h"
 
 #define META_TYPE_DEVICE_POINTER            (meta_device_pointer_get_type ())
 #define META_DEVICE_POINTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_POINTER, MetaDevicePointer))
diff --git a/src/core/device.h b/src/core/device-private.h
similarity index 74%
rename from src/core/device.h
rename to src/core/device-private.h
index 5bb0bec..7c049f4 100644
--- a/src/core/device.h
+++ b/src/core/device-private.h
@@ -27,21 +27,12 @@
  * 02111-1307, USA.
  */
 
-#ifndef META_DEVICE_H
-#define META_DEVICE_H
-
-typedef struct _MetaDevice MetaDevice;
-typedef struct _MetaDeviceClass MetaDeviceClass;
+#ifndef META_DEVICE_PRIVATE_H
+#define META_DEVICE_PRIVATE_H
 
+#include <meta/device.h>
 #include "display-private.h"
 
-#define META_TYPE_DEVICE            (meta_device_get_type ())
-#define META_DEVICE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE, MetaDevice))
-#define META_DEVICE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_DEVICE, MetaDeviceClass))
-#define META_IS_DEVICE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_DEVICE))
-#define META_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  META_TYPE_DEVICE))
-#define META_DEVICE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  META_TYPE_DEVICE, MetaDeviceClass))
-
 struct _MetaDevice
 {
   GObject parent_instance;
@@ -69,9 +60,6 @@ struct _MetaDeviceClass
 
 GType        meta_device_get_type     (void) G_GNUC_CONST;
 
-int          meta_device_get_id       (MetaDevice  *device);
-MetaDisplay *meta_device_get_display  (MetaDevice *device);
-
 void         meta_device_allow_events (MetaDevice  *device,
                                        int          mode,
                                        Time         time);
@@ -88,6 +76,5 @@ void         meta_device_ungrab       (MetaDevice *device,
 
 void         meta_device_pair_devices      (MetaDevice *device,
                                             MetaDevice *other_device);
-MetaDevice * meta_device_get_paired_device (MetaDevice *device);
 
-#endif /* META_DEVICE_H */
+#endif /* META_DEVICE_PRIVATE_H */
diff --git a/src/core/device.c b/src/core/device.c
index 216d2e9..d31b74b 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -22,7 +22,7 @@
  */
 
 #include <config.h>
-#include "device.h"
+#include "device-private.h"
 
 G_DEFINE_ABSTRACT_TYPE (MetaDevice, meta_device, G_TYPE_OBJECT)
 
@@ -148,6 +148,14 @@ meta_device_get_id (MetaDevice *device)
   return priv->device_id;
 }
 
+/**
+ * meta_device_get_display:
+ * @device: a #MetaDevice
+ *
+ * Returns the #MetaDisplay to which the device belongs
+ *
+ * Returns: (transfer none): the #MetaDisplay to which the device belongs
+ **/
 MetaDisplay *
 meta_device_get_display (MetaDevice *device)
 {
@@ -242,6 +250,14 @@ meta_device_pair_devices (MetaDevice *device,
   g_object_notify (G_OBJECT (other_device), "paired-device");
 }
 
+/**
+ * meta_device_get_paired_device:
+ * @device: a #MetaDevice
+ *
+ * Returns the paired device. Devices come in keyboard/pointer pairs.
+ *
+ * Returns: (transfer none): The paired device.
+ **/
 MetaDevice *
 meta_device_get_paired_device (MetaDevice *device)
 {
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 67a8c43..fb5fa20 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -38,7 +38,7 @@
 #include <meta/boxes.h>
 #include <meta/display.h>
 #include "keybindings-private.h"
-#include "device-map.h"
+#include "device-map-private.h"
 #include <meta/prefs.h>
 
 #ifdef HAVE_STARTUP_NOTIFICATION
diff --git a/src/core/display.c b/src/core/display.c
index 76ffa0f..ff21ea6 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -49,7 +49,7 @@
 #include "xprops.h"
 #include "workspace-private.h"
 #include "bell.h"
-#include "device.h"
+#include "device-private.h"
 #include "input-events.h"
 #include <meta/compositor.h>
 #include <meta/compositor-mutter.h>
@@ -5730,3 +5730,19 @@ meta_display_clear_mouse_mode (MetaDisplay *display)
 {
   display->mouse_mode = FALSE;
 }
+
+/**
+ * meta_display_get_device_map:
+ * @display: a #MetaDisplay
+ *
+ * Returns the MetaDeviceMap used to handle the display devices.
+ *
+ * Returns: (transfer none): The display's #MetaDeviceMap
+ **/
+MetaDeviceMap *
+meta_display_get_device_map (MetaDisplay *display)
+{
+  g_return_val_if_fail (META_IS_DISPLAY (display), NULL);
+
+  return display->device_map;
+}
diff --git a/src/core/input-events.c b/src/core/input-events.c
index 246582a..c24c78a 100644
--- a/src/core/input-events.c
+++ b/src/core/input-events.c
@@ -24,7 +24,7 @@
 #include <config.h>
 #include "input-events.h"
 #include "devices-core.h"
-#include "device-map.h"
+#include "device-map-private.h"
 #include <X11/Xlib.h>
 
 #ifdef HAVE_XINPUT2
diff --git a/src/core/input-events.h b/src/core/input-events.h
index 1107055..356cd16 100644
--- a/src/core/input-events.h
+++ b/src/core/input-events.h
@@ -33,7 +33,7 @@
 #include <config.h>
 #include <X11/Xlib.h>
 #include "display-private.h"
-#include "device-map.h"
+#include <meta/device-map.h>
 
 gboolean meta_input_event_get_type          (MetaDisplay *display,
                                              XEvent      *ev,
diff --git a/src/meta/device-map.h b/src/meta/device-map.h
new file mode 100644
index 0000000..102980f
--- /dev/null
+++ b/src/meta/device-map.h
@@ -0,0 +1,45 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2011 Carlos Garnacho
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_DEVICE_MAP_H
+#define META_DEVICE_MAP_H
+
+#include <glib-object.h>
+#include <meta/types.h>
+#include <meta/device.h>
+
+#define META_TYPE_DEVICE_MAP            (meta_device_map_get_type ())
+#define META_DEVICE_MAP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MAP, MetaDeviceMap))
+#define META_DEVICE_MAP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_DEVICE_MAP, MetaDeviceMapClass))
+#define META_IS_DEVICE_MAP(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_DEVICE_MAP))
+#define META_IS_DEVICE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  META_TYPE_DEVICE_MAP))
+#define META_DEVICE_MAP_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  META_TYPE_DEVICE_MAP, MetaDeviceMapClass))
+
+typedef struct _MetaDeviceMapClass   MetaDeviceMapClass;
+
+GType           meta_device_map_get_type (void) G_GNUC_CONST;
+
+MetaDevice *    meta_device_map_lookup      (MetaDeviceMap *device_map,
+					     gint           device_id);
+
+MetaDisplay *   meta_device_map_get_display (MetaDeviceMap *device_map);
+
+#endif
diff --git a/src/meta/display.h b/src/meta/display.h
index 04d545c..7e14fcc 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -28,6 +28,7 @@
 #include <meta/types.h>
 #include <meta/prefs.h>
 #include <meta/common.h>
+#include <meta/device-map.h>
 
 typedef enum
 {
@@ -176,5 +177,6 @@ void meta_display_unmanage_screen (MetaDisplay *display,
                                    guint32      timestamp);
 
 void meta_display_clear_mouse_mode (MetaDisplay *display);
+MetaDeviceMap * meta_display_get_device_map (MetaDisplay *display);
 
 #endif
diff --git a/src/meta/types.h b/src/meta/types.h
index 2583320..d256aea 100644
--- a/src/meta/types.h
+++ b/src/meta/types.h
@@ -32,6 +32,8 @@ typedef struct _MetaFrame       MetaFrame;
 typedef struct _MetaScreen      MetaScreen;
 typedef struct _MetaWindow      MetaWindow;
 typedef struct _MetaWorkspace   MetaWorkspace;
+typedef struct _MetaDevice      MetaDevice;
+typedef struct _MetaDeviceMap   MetaDeviceMap;
 /**
  * MetaGroup: (skip)
  *



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