diff --git a/src/Makefile.am b/src/Makefile.am index 6abfecd4f..9c617fb81 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 \ @@ -186,6 +188,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 795e9b17e..b811a4aa8 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 d9773de62..f252d4c0e 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 b0e31f9d9..28e75f2fa 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 +#include #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 be3830a3f..61602fc75 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 df0f0da74..aed7ad3dc 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 e0e439f9f..1a45aacf1 100644 --- a/src/core/device-pointer.h +++ b/src/core/device-pointer.h @@ -32,7 +32,7 @@ #include "display-private.h" #include -#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 5bb0beca9..7c049f402 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 #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 216d2e998..d31b74be5 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -22,7 +22,7 @@ */ #include -#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 194ef1461..7e428ff45 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -38,7 +38,7 @@ #include #include #include "keybindings-private.h" -#include "device-map.h" +#include "device-map-private.h" #include #ifdef HAVE_STARTUP_NOTIFICATION diff --git a/src/core/display.c b/src/core/display.c index 94bbc90d4..812f760f2 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -48,7 +48,7 @@ #include "xprops.h" #include "workspace-private.h" #include "bell.h" -#include "device.h" +#include "device-private.h" #include "input-events.h" #include #include @@ -5537,3 +5537,19 @@ meta_display_get_leader_window (MetaDisplay *display) { return display->leader_window; } + +/** + * 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 246582af6..c24c78a91 100644 --- a/src/core/input-events.c +++ b/src/core/input-events.c @@ -24,7 +24,7 @@ #include #include "input-events.h" #include "devices-core.h" -#include "device-map.h" +#include "device-map-private.h" #include #ifdef HAVE_XINPUT2 diff --git a/src/core/input-events.h b/src/core/input-events.h index 11070558c..356cd16f6 100644 --- a/src/core/input-events.h +++ b/src/core/input-events.h @@ -33,7 +33,7 @@ #include #include #include "display-private.h" -#include "device-map.h" +#include 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 000000000..102980f06 --- /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 +#include +#include + +#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 f4ac20f7a..4196d7dc7 100644 --- a/src/meta/display.h +++ b/src/meta/display.h @@ -28,6 +28,7 @@ #include #include #include +#include typedef enum { @@ -155,4 +156,6 @@ GSList *meta_display_sort_windows_by_stacking (MetaDisplay *display, Window meta_display_get_leader_window (MetaDisplay *display); +MetaDeviceMap * meta_display_get_device_map (MetaDisplay *display); + #endif diff --git a/src/meta/types.h b/src/meta/types.h index 25833207d..d256aeac7 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) *