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.
This commit is contained in:
Carlos Garnacho 2011-06-19 00:11:42 +02:00
parent 1e8f10826a
commit e62076f055
16 changed files with 125 additions and 49 deletions

View File

@ -79,13 +79,15 @@ libmutter_la_SOURCES = \
core/core.c \ core/core.c \
core/delete.c \ core/delete.c \
core/device.c \ core/device.c \
core/device.h \ meta/device.h \
core/device-keyboard.c \ core/device-keyboard.c \
core/device-keyboard.h \ core/device-keyboard.h \
core/device-pointer.c \ core/device-pointer.c \
core/device-pointer.h \ core/device-pointer.h \
core/device-private.h \
core/device-map.c \ 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.c \
core/device-map-core.h \ core/device-map-core.h \
core/devices-core.c \ core/devices-core.c \
@ -189,6 +191,8 @@ libmutterinclude_base_headers = \
meta/common.h \ meta/common.h \
meta/compositor-mutter.h \ meta/compositor-mutter.h \
meta/compositor.h \ meta/compositor.h \
meta/device.h \
meta/device-map.h \
meta/display.h \ meta/display.h \
meta/errors.h \ meta/errors.h \
meta/gradient.h \ meta/gradient.h \

View File

@ -31,7 +31,7 @@
#define META_DEVICE_KEYBOARD_H #define META_DEVICE_KEYBOARD_H
#include "display-private.h" #include "display-private.h"
#include "device.h" #include "device-private.h"
#define META_TYPE_DEVICE_KEYBOARD (meta_device_keyboard_get_type ()) #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)) #define META_DEVICE_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_KEYBOARD, MetaDeviceKeyboard))

View File

@ -32,7 +32,7 @@
typedef struct _MetaDeviceMapCore MetaDeviceMapCore; typedef struct _MetaDeviceMapCore MetaDeviceMapCore;
typedef struct _MetaDeviceMapCoreClass MetaDeviceMapCoreClass; 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_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)) #define META_DEVICE_MAP_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MAP_CORE, MetaDeviceMapCore))

View File

@ -27,21 +27,13 @@
* 02111-1307, USA. * 02111-1307, USA.
*/ */
#ifndef META_DEVICE_MAP_H #ifndef META_DEVICE_MAP_PRIVATE_H
#define META_DEVICE_MAP_H #define META_DEVICE_MAP_PRIVATE_H
typedef struct _MetaDeviceMap MetaDeviceMap;
typedef struct _MetaDeviceMapClass MetaDeviceMapClass;
#include <meta/device-map.h>
#include <meta/device.h>
#include "display-private.h" #include "display-private.h"
#include "device.h" #include "device-private.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))
struct _MetaDeviceMap struct _MetaDeviceMap
{ {
@ -90,11 +82,6 @@ void meta_device_map_add_device (MetaDeviceMap *device_map,
void meta_device_map_remove_device (MetaDeviceMap *device_map, void meta_device_map_remove_device (MetaDeviceMap *device_map,
MetaDevice *device); 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, gboolean meta_device_map_grab_key (MetaDeviceMap *device_map,
Window xwindow, Window xwindow,
guint keycode, guint keycode,
@ -115,5 +102,4 @@ void meta_device_map_ungrab_button (MetaDeviceMap *device_map,
guint n_button, guint n_button,
guint modifiers); guint modifiers);
#endif /* META_DEVICE_MAP_PRIVATE_H */
#endif /* META_DEVICE_MAP_H */

View File

@ -32,7 +32,7 @@
typedef struct _MetaDeviceMapXI2 MetaDeviceMapXI2; typedef struct _MetaDeviceMapXI2 MetaDeviceMapXI2;
typedef struct _MetaDeviceMapXI2Class MetaDeviceMapXI2Class; 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_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)) #define META_DEVICE_MAP_XI2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MAP_XI2, MetaDeviceMapXI2))

View File

@ -22,7 +22,7 @@
*/ */
#include "config.h" #include "config.h"
#include "device-map.h" #include "device-map-private.h"
#include "device-map-core.h" #include "device-map-core.h"
#ifdef HAVE_XINPUT2 #ifdef HAVE_XINPUT2
@ -250,6 +250,15 @@ meta_device_map_new (MetaDisplay *display,
NULL); 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 * MetaDevice *
meta_device_map_lookup (MetaDeviceMap *device_map, meta_device_map_lookup (MetaDeviceMap *device_map,
gint device_id) gint device_id)
@ -263,6 +272,14 @@ meta_device_map_lookup (MetaDeviceMap *device_map,
GINT_TO_POINTER (device_id)); 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 * MetaDisplay *
meta_device_map_get_display (MetaDeviceMap *device_map) meta_device_map_get_display (MetaDeviceMap *device_map)
{ {

View File

@ -32,7 +32,7 @@
#include "display-private.h" #include "display-private.h"
#include <meta/screen.h> #include <meta/screen.h>
#include "device.h" #include "device-private.h"
#define META_TYPE_DEVICE_POINTER (meta_device_pointer_get_type ()) #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)) #define META_DEVICE_POINTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_POINTER, MetaDevicePointer))

View File

@ -27,21 +27,12 @@
* 02111-1307, USA. * 02111-1307, USA.
*/ */
#ifndef META_DEVICE_H #ifndef META_DEVICE_PRIVATE_H
#define META_DEVICE_H #define META_DEVICE_PRIVATE_H
typedef struct _MetaDevice MetaDevice;
typedef struct _MetaDeviceClass MetaDeviceClass;
#include <meta/device.h>
#include "display-private.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 struct _MetaDevice
{ {
GObject parent_instance; GObject parent_instance;
@ -69,9 +60,6 @@ struct _MetaDeviceClass
GType meta_device_get_type (void) G_GNUC_CONST; 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, void meta_device_allow_events (MetaDevice *device,
int mode, int mode,
Time time); Time time);
@ -88,6 +76,5 @@ void meta_device_ungrab (MetaDevice *device,
void meta_device_pair_devices (MetaDevice *device, void meta_device_pair_devices (MetaDevice *device,
MetaDevice *other_device); MetaDevice *other_device);
MetaDevice * meta_device_get_paired_device (MetaDevice *device);
#endif /* META_DEVICE_H */ #endif /* META_DEVICE_PRIVATE_H */

View File

@ -22,7 +22,7 @@
*/ */
#include <config.h> #include <config.h>
#include "device.h" #include "device-private.h"
G_DEFINE_ABSTRACT_TYPE (MetaDevice, meta_device, G_TYPE_OBJECT) G_DEFINE_ABSTRACT_TYPE (MetaDevice, meta_device, G_TYPE_OBJECT)
@ -148,6 +148,14 @@ meta_device_get_id (MetaDevice *device)
return priv->device_id; 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 * MetaDisplay *
meta_device_get_display (MetaDevice *device) 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"); 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 * MetaDevice *
meta_device_get_paired_device (MetaDevice *device) meta_device_get_paired_device (MetaDevice *device)
{ {

View File

@ -38,7 +38,7 @@
#include <meta/boxes.h> #include <meta/boxes.h>
#include <meta/display.h> #include <meta/display.h>
#include "keybindings-private.h" #include "keybindings-private.h"
#include "device-map.h" #include "device-map-private.h"
#include <meta/prefs.h> #include <meta/prefs.h>
#ifdef HAVE_STARTUP_NOTIFICATION #ifdef HAVE_STARTUP_NOTIFICATION

View File

@ -48,7 +48,7 @@
#include "xprops.h" #include "xprops.h"
#include "workspace-private.h" #include "workspace-private.h"
#include "bell.h" #include "bell.h"
#include "device.h" #include "device-private.h"
#include "input-events.h" #include "input-events.h"
#include <meta/compositor.h> #include <meta/compositor.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
@ -5511,3 +5511,19 @@ meta_display_get_leader_window (MetaDisplay *display)
{ {
return display->leader_window; 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;
}

View File

@ -24,7 +24,7 @@
#include <config.h> #include <config.h>
#include "input-events.h" #include "input-events.h"
#include "devices-core.h" #include "devices-core.h"
#include "device-map.h" #include "device-map-private.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
#ifdef HAVE_XINPUT2 #ifdef HAVE_XINPUT2

View File

@ -33,7 +33,7 @@
#include <config.h> #include <config.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "display-private.h" #include "display-private.h"
#include "device-map.h" #include <meta/device-map.h>
gboolean meta_input_event_get_type (MetaDisplay *display, gboolean meta_input_event_get_type (MetaDisplay *display,
XEvent *ev, XEvent *ev,

45
src/meta/device-map.h Normal file
View File

@ -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

View File

@ -28,6 +28,7 @@
#include <meta/types.h> #include <meta/types.h>
#include <meta/prefs.h> #include <meta/prefs.h>
#include <meta/common.h> #include <meta/common.h>
#include <meta/device-map.h>
typedef enum typedef enum
{ {
@ -162,4 +163,6 @@ void meta_display_unmanage_screen (MetaDisplay *display,
MetaScreen *screen, MetaScreen *screen,
guint32 timestamp); guint32 timestamp);
MetaDeviceMap * meta_display_get_device_map (MetaDisplay *display);
#endif #endif

View File

@ -32,6 +32,8 @@ typedef struct _MetaFrame MetaFrame;
typedef struct _MetaScreen MetaScreen; typedef struct _MetaScreen MetaScreen;
typedef struct _MetaWindow MetaWindow; typedef struct _MetaWindow MetaWindow;
typedef struct _MetaWorkspace MetaWorkspace; typedef struct _MetaWorkspace MetaWorkspace;
typedef struct _MetaDevice MetaDevice;
typedef struct _MetaDeviceMap MetaDeviceMap;
/** /**
* MetaGroup: (skip) * MetaGroup: (skip)
* *