Commit 106047ff authored by Matthias Clasen's avatar Matthias Clasen

Detangle includes for GdkDeviceManager subclasses

parent b1aaa10b
......@@ -27,6 +27,7 @@ libgdk_x11_la_SOURCES = \
gdkdeviceprivate-xi.h \
gdkdevicemanager-core-x11.c \
gdkdevicemanager-x11.c \
gdkdevicemanagerprivate-core.h \
gdkdisplaymanager-x11.c \
gdkdisplay-x11.c \
gdkdisplay-x11.h \
......@@ -79,11 +80,17 @@ libgdkinclude_HEADERS = \
gdkx.h
libgdkx11include_HEADERS += \
gdkx11applaunchcontext.h \
gdkx11cursor.h \
gdkx11device-core.h \
gdkx11device-xi.h \
gdkx11device-xi2.h \
gdkx11devicemanager-core.h \
gdkx11devicemanager-xi.h \
gdkx11devicemanager-xi2.h \
gdkx11display.h \
gdkx11displaymanager.h \
gdkx11dnd.h \
gdkx11keys.h \
gdkx11property.h \
gdkx11screen.h \
......
......@@ -20,9 +20,9 @@
#include "config.h"
#include "gdkx11devicemanager-core.h"
#include "gdkdevicemanagerprivate-core.h"
#include "gdkx11device-core.h"
#include "gdkdevicemanagerprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkeventtranslator.h"
......
......@@ -58,8 +58,8 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
device_manager_xi2 = g_object_new (GDK_TYPE_X11_DEVICE_MANAGER_XI2,
"display", display,
"opcode", opcode,
NULL);
device_manager_xi2->opcode = opcode;
return GDK_DEVICE_MANAGER (device_manager_xi2);
}
......
......@@ -20,6 +20,7 @@
#include "config.h"
#include "gdkx11devicemanager-xi.h"
#include "gdkdevicemanagerprivate-core.h"
#include "gdkdeviceprivate-xi.h"
#include "gdkdevicemanagerprivate.h"
......@@ -30,14 +31,22 @@
#include <X11/extensions/XInput.h>
struct _GdkX11DeviceManagerXIPrivate
struct _GdkX11DeviceManagerXI
{
GdkX11DeviceManagerCore parent_object;
GHashTable *id_table;
gint event_base;
GList *devices;
gboolean ignore_core_events;
};
struct _GdkX11DeviceManagerXIClass
{
GdkX11DeviceManagerCoreClass parent_class;
};
static void gdk_x11_device_manager_xi_constructed (GObject *object);
static void gdk_x11_device_manager_xi_dispose (GObject *object);
static void gdk_x11_device_manager_xi_set_property (GObject *object,
......@@ -87,8 +96,6 @@ gdk_x11_device_manager_xi_class_init (GdkX11DeviceManagerXIClass *klass)
P_("Event base for XInput events"),
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (object_class, sizeof (GdkX11DeviceManagerXIPrivate));
}
static GdkFilterReturn
......@@ -116,14 +123,8 @@ window_input_info_filter (GdkXEvent *xevent,
static void
gdk_x11_device_manager_xi_init (GdkX11DeviceManagerXI *device_manager)
{
GdkX11DeviceManagerXIPrivate *priv;
device_manager->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (device_manager,
GDK_TYPE_X11_DEVICE_MANAGER_XI,
GdkX11DeviceManagerXIPrivate);
priv->id_table = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_object_unref);
device_manager->id_table = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_object_unref);
gdk_window_add_filter (NULL, window_input_info_filter, device_manager);
}
......@@ -262,12 +263,12 @@ create_device (GdkDeviceManager *device_manager,
static void
gdk_x11_device_manager_xi_constructed (GObject *object)
{
GdkX11DeviceManagerXIPrivate *priv;
GdkX11DeviceManagerXI *device_manager;
XDeviceInfo *devices;
gint i, num_devices;
GdkDisplay *display;
priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
device_manager = GDK_X11_DEVICE_MANAGER_XI (object);
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
devices = XListInputDevices (GDK_DISPLAY_XDISPLAY (display), &num_devices);
......@@ -279,8 +280,8 @@ gdk_x11_device_manager_xi_constructed (GObject *object)
display, &devices[i]);
if (device)
{
priv->devices = g_list_prepend (priv->devices, device);
g_hash_table_insert (priv->id_table,
device_manager->devices = g_list_prepend (device_manager->devices, device);
g_hash_table_insert (device_manager->id_table,
GINT_TO_POINTER (devices[i].id),
g_object_ref (device));
}
......@@ -289,7 +290,7 @@ gdk_x11_device_manager_xi_constructed (GObject *object)
XFreeDeviceList (devices);
gdk_x11_register_standard_event_type (display,
priv->event_base,
device_manager->event_base,
15 /* Number of events */);
if (G_OBJECT_CLASS (gdk_x11_device_manager_xi_parent_class)->constructed)
......@@ -299,18 +300,17 @@ gdk_x11_device_manager_xi_constructed (GObject *object)
static void
gdk_x11_device_manager_xi_dispose (GObject *object)
{
GdkX11DeviceManagerXIPrivate *priv;
priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
GdkX11DeviceManagerXI *device_manager;
g_list_foreach (priv->devices, (GFunc) g_object_unref, NULL);
g_list_free (priv->devices);
priv->devices = NULL;
device_manager = GDK_X11_DEVICE_MANAGER_XI (object);
g_list_foreach (device_manager->devices, (GFunc) g_object_unref, NULL);
g_list_free (device_manager->devices);
device_manager->devices = NULL;
if (priv->id_table != NULL)
if (device_manager->id_table != NULL)
{
g_hash_table_destroy (priv->id_table);
priv->id_table = NULL;
g_hash_table_destroy (device_manager->id_table);
device_manager->id_table = NULL;
}
gdk_window_remove_filter (NULL, window_input_info_filter, object);
......@@ -324,14 +324,14 @@ gdk_x11_device_manager_xi_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GdkX11DeviceManagerXIPrivate *priv;
GdkX11DeviceManagerXI *device_manager;
priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
device_manager = GDK_X11_DEVICE_MANAGER_XI (object);
switch (prop_id)
{
case PROP_EVENT_BASE:
priv->event_base = g_value_get_int (value);
device_manager->event_base = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -345,14 +345,14 @@ gdk_x11_device_manager_xi_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GdkX11DeviceManagerXIPrivate *priv;
GdkX11DeviceManagerXI *device_manager;
priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
device_manager = GDK_X11_DEVICE_MANAGER_XI (object);
switch (prop_id)
{
case PROP_EVENT_BASE:
g_value_set_int (value, priv->event_base);
g_value_set_int (value, device_manager->event_base);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -379,13 +379,13 @@ translate_state (guint state, guint device_state)
}
static GdkDevice *
lookup_device (GdkX11DeviceManagerXI *device_manager,
lookup_device (GdkX11DeviceManagerXI *manager,
XEvent *xevent)
{
GdkX11DeviceManagerXIPrivate *priv;
GdkX11DeviceManagerXI *device_manager;
guint32 device_id;
priv = GDK_X11_DEVICE_MANAGER_XI (device_manager)->priv;
device_manager = GDK_X11_DEVICE_MANAGER_XI (manager);
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
but it's potentially faster than scanning through the types of
......@@ -393,7 +393,7 @@ lookup_device (GdkX11DeviceManagerXI *device_manager,
the types for the device anyways */
device_id = ((XDeviceButtonEvent *)xevent)->deviceid;
return g_hash_table_lookup (priv->id_table, GINT_TO_POINTER (device_id));
return g_hash_table_lookup (device_manager->id_table, GINT_TO_POINTER (device_id));
}
static gboolean
......@@ -402,7 +402,6 @@ gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
GdkEvent *event,
XEvent *xevent)
{
GdkX11DeviceManagerXIPrivate *priv;
GdkX11DeviceManagerXI *device_manager;
GdkEventTranslatorIface *parent_iface;
GdkX11DeviceXI *device_xi;
......@@ -411,9 +410,8 @@ gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
parent_iface = g_type_interface_peek_parent (GDK_EVENT_TRANSLATOR_GET_IFACE (translator));
device_manager = GDK_X11_DEVICE_MANAGER_XI (translator);
priv = device_manager->priv;
if (!priv->ignore_core_events &&
if (!device_manager->ignore_core_events &&
parent_iface->translate_event (translator, display, event, xevent))
return TRUE;
......@@ -550,7 +548,7 @@ gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->motion.device = device;
if (device_xi->in_proximity)
priv->ignore_core_events = TRUE;
device_manager->ignore_core_events = TRUE;
event->motion.x_root = (gdouble) xdme->x_root;
event->motion.y_root = (gdouble) xdme->y_root;
......@@ -598,13 +596,13 @@ gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
{
event->proximity.type = GDK_PROXIMITY_IN;
device_xi->in_proximity = TRUE;
priv->ignore_core_events = TRUE;
device_manager->ignore_core_events = TRUE;
}
else
{
event->proximity.type = GDK_PROXIMITY_OUT;
device_xi->in_proximity = FALSE;
priv->ignore_core_events = FALSE;
device_manager->ignore_core_events = FALSE;
}
event->proximity.device = device;
......@@ -647,18 +645,18 @@ gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
}
static GList *
gdk_x11_device_manager_xi_list_devices (GdkDeviceManager *device_manager,
gdk_x11_device_manager_xi_list_devices (GdkDeviceManager *manager,
GdkDeviceType type)
{
GdkX11DeviceManagerXIPrivate *priv;
GdkX11DeviceManagerXI *device_manager;
priv = GDK_X11_DEVICE_MANAGER_XI (device_manager)->priv;
device_manager = GDK_X11_DEVICE_MANAGER_XI (manager);
if (type == GDK_DEVICE_TYPE_MASTER)
return GDK_DEVICE_MANAGER_CLASS (gdk_x11_device_manager_xi_parent_class)->list_devices (device_manager, type);
return GDK_DEVICE_MANAGER_CLASS (gdk_x11_device_manager_xi_parent_class)->list_devices (manager, type);
else if (type == GDK_DEVICE_TYPE_FLOATING)
{
return g_list_copy (priv->devices);
return g_list_copy (device_manager->devices);
}
else
return NULL;
......
......@@ -22,19 +22,48 @@
#include "gdkx11devicemanager-xi2.h"
#include "gdkx11device-xi2.h"
#include "gdkkeysyms.h"
#include "gdkdevicemanagerprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkeventtranslator.h"
#include "gdkprivate-x11.h"
#include "gdkintl.h"
#include "gdkkeysyms.h"
#include <string.h>
struct _GdkX11DeviceManagerXI2
{
GdkDeviceManager parent_object;
GHashTable *id_table;
GList *master_devices;
GList *slave_devices;
GdkDevice *client_pointer;
gint opcode;
};
struct _GdkX11DeviceManagerXI2Class
{
GdkDeviceManagerClass parent_class;
};
#define HAS_FOCUS(toplevel) ((toplevel)->has_focus || (toplevel)->has_pointer_focus)
static void gdk_x11_device_manager_xi2_constructed (GObject *object);
static void gdk_x11_device_manager_xi2_dispose (GObject *object);
static void gdk_x11_device_manager_xi2_constructed (GObject *object);
static void gdk_x11_device_manager_xi2_dispose (GObject *object);
static void gdk_x11_device_manager_xi2_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gdk_x11_device_manager_xi2_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static GList * gdk_x11_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
......@@ -57,6 +86,11 @@ G_DEFINE_TYPE_WITH_CODE (GdkX11DeviceManagerXI2, gdk_x11_device_manager_xi2, GDK
gdk_x11_device_manager_xi2_event_translator_init))
enum {
PROP_0,
PROP_OPCODE
};
static void
gdk_x11_device_manager_xi2_class_init (GdkX11DeviceManagerXI2Class *klass)
{
......@@ -65,9 +99,19 @@ gdk_x11_device_manager_xi2_class_init (GdkX11DeviceManagerXI2Class *klass)
object_class->constructed = gdk_x11_device_manager_xi2_constructed;
object_class->dispose = gdk_x11_device_manager_xi2_dispose;
object_class->set_property = gdk_x11_device_manager_xi2_set_property;
object_class->get_property = gdk_x11_device_manager_xi2_get_property;
device_manager_class->list_devices = gdk_x11_device_manager_xi2_list_devices;
device_manager_class->get_client_pointer = gdk_x11_device_manager_xi2_get_client_pointer;
g_object_class_install_property (object_class,
PROP_OPCODE,
g_param_spec_int ("opcode",
P_("Opcode"),
P_("Opcode for XInput2 requests"),
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
......@@ -491,6 +535,48 @@ gdk_x11_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager)
GINT_TO_POINTER (device_id));
}
static void
gdk_x11_device_manager_xi2_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdkX11DeviceManagerXI2 *device_manager;
device_manager = GDK_X11_DEVICE_MANAGER_XI2 (object);
switch (prop_id)
{
case PROP_OPCODE:
device_manager->opcode = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_x11_device_manager_xi2_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GdkX11DeviceManagerXI2 *device_manager;
device_manager = GDK_X11_DEVICE_MANAGER_XI2 (object);
switch (prop_id)
{
case PROP_OPCODE:
g_value_set_int (value, device_manager->opcode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_x11_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface)
{
......
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__
#define __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__
#include "gdkx11devicemanager-core.h"
#include "gdkdevicemanagerprivate.h"
G_BEGIN_DECLS
struct _GdkX11DeviceManagerCore
{
GdkDeviceManager parent_object;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
};
struct _GdkX11DeviceManagerCoreClass
{
GdkDeviceManagerClass parent_class;
};
G_END_DECLS
#endif /* __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__ */
......@@ -17,8 +17,8 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_XI_PRIVATE_H__
#define __GDK_DEVICE_XI_PRIVATE_H__
#ifndef __GDK_DEVICE_PRIVATE_XI_H__
#define __GDK_DEVICE_PRIVATE_XI_H__
#include "gdkx11device-xi.h"
#include "gdkdeviceprivate.h"
......@@ -55,4 +55,4 @@ struct _GdkX11DeviceXIClass
G_END_DECLS
#endif /* __GDK_DEVICE_XI_PRIVATE_H__ */
#endif /* __GDK_DEVICE_PRIVATE_XI_H__ */
......@@ -20,7 +20,7 @@
#ifndef __GDK_X11_DEVICE_MANAGER_CORE_H__
#define __GDK_X11_DEVICE_MANAGER_CORE_H__
#include "gdkdevicemanagerprivate.h"
#include <gdk/gdk.h>
G_BEGIN_DECLS
......@@ -34,17 +34,6 @@ G_BEGIN_DECLS
typedef struct _GdkX11DeviceManagerCore GdkX11DeviceManagerCore;
typedef struct _GdkX11DeviceManagerCoreClass GdkX11DeviceManagerCoreClass;
struct _GdkX11DeviceManagerCore
{
GdkDeviceManager parent_object;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
};
struct _GdkX11DeviceManagerCoreClass
{
GdkDeviceManagerClass parent_class;
};
GType gdk_x11_device_manager_core_get_type (void) G_GNUC_CONST;
......
......@@ -20,7 +20,7 @@
#ifndef __GDK_X11_DEVICE_MANAGER_XI_H__
#define __GDK_X11_DEVICE_MANAGER_XI_H__
#include "gdkx11devicemanager-core.h"
#include <gdk/gdk.h>
G_BEGIN_DECLS
......@@ -32,24 +32,12 @@ G_BEGIN_DECLS
#define GDK_X11_DEVICE_MANAGER_XI_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI, GdkX11DeviceManagerXIClass))
typedef struct _GdkX11DeviceManagerXI GdkX11DeviceManagerXI;
typedef struct _GdkX11DeviceManagerXIPrivate GdkX11DeviceManagerXIPrivate;
typedef struct _GdkX11DeviceManagerXIClass GdkX11DeviceManagerXIClass;
struct _GdkX11DeviceManagerXI
{
GdkX11DeviceManagerCore parent_object;
/*< private >*/
GdkX11DeviceManagerXIPrivate *priv;
};
struct _GdkX11DeviceManagerXIClass
{
GdkX11DeviceManagerCoreClass parent_class;
};
GType gdk_x11_device_manager_xi_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_X11_DEVICE_MANAGER_XI_H__ */
......@@ -20,7 +20,7 @@
#ifndef __GDK_X11_DEVICE_MANAGER_XI2_H__
#define __GDK_X11_DEVICE_MANAGER_XI2_H__
#include "gdkdevicemanagerprivate.h"
#include <gdk/gdk.h>
#include <X11/extensions/XInput2.h>
......@@ -36,26 +36,6 @@ G_BEGIN_DECLS
typedef struct _GdkX11DeviceManagerXI2 GdkX11DeviceManagerXI2;
typedef struct _GdkX11DeviceManagerXI2Class GdkX11DeviceManagerXI2Class;
struct _GdkX11DeviceManagerXI2
{
GdkDeviceManager parent_object;
/*< private >*/
GHashTable *id_table;
GList *master_devices;
GList *slave_devices;
GdkDevice *client_pointer;
gint opcode;
};
struct _GdkX11DeviceManagerXI2Class
{
GdkDeviceManagerClass parent_class;
};
GType gdk_x11_device_manager_xi2_get_type (void) G_GNUC_CONST;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment