mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
x11: Add a Keymap ancillary object
We should try to abstract everything that is related with the key mapping to its own object, to avoid complicating ClutterBackendX11 any further.
This commit is contained in:
parent
d345a61e6c
commit
bea657d3d5
@ -46,6 +46,8 @@ libclutter_x11_la_SOURCES = \
|
||||
$(srcdir)/clutter-event-x11.c \
|
||||
$(srcdir)/clutter-input-device-x11.h \
|
||||
$(srcdir)/clutter-input-device-x11.c \
|
||||
$(srcdir)/clutter-keymap-x11.h \
|
||||
$(srcdir)/clutter-keymap-x11.c \
|
||||
$(srcdir)/clutter-settings-x11.h \
|
||||
$(srcdir)/clutter-stage-x11.h \
|
||||
$(srcdir)/clutter-stage-x11.c \
|
||||
|
@ -319,6 +319,12 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
|
||||
"backend", backend_x11,
|
||||
NULL);
|
||||
|
||||
/* register keymap */
|
||||
backend_x11->keymap =
|
||||
g_object_new (CLUTTER_TYPE_KEYMAP_X11,
|
||||
"backend", backend_x11,
|
||||
NULL);
|
||||
|
||||
/* create XSETTINGS client */
|
||||
backend_x11->xsettings =
|
||||
_clutter_xsettings_client_new (backend_x11->xdpy,
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "clutter-x11.h"
|
||||
|
||||
#include "clutter-keymap-x11.h"
|
||||
#include "xsettings/xsettings-client.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -88,6 +89,8 @@ struct _ClutterBackendX11
|
||||
|
||||
XSettingsClient *xsettings;
|
||||
Window xsettings_xwin;
|
||||
|
||||
ClutterKeymapX11 *keymap;
|
||||
};
|
||||
|
||||
struct _ClutterBackendX11Class
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "clutter-stage-x11.h"
|
||||
#include "clutter-backend-x11.h"
|
||||
#include "clutter-keymap-x11.h"
|
||||
#include "clutter-x11.h"
|
||||
|
||||
#include "../clutter-backend.h"
|
||||
@ -343,19 +344,6 @@ translate_key_event (ClutterBackend *backend,
|
||||
event_x11 = _clutter_event_x11_new ();
|
||||
_clutter_event_set_platform_data (event, event_x11);
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
event_x11->key_group = XkbGroupForCoreState (xevent->xkey.state);
|
||||
|
||||
CLUTTER_NOTE (EVENT, "Key group: %d (xkb enabled: yes)",
|
||||
event_x11->key_group);
|
||||
#else
|
||||
/* we force the key group to 0 */
|
||||
event_x11->key_group = 0;
|
||||
|
||||
CLUTTER_NOTE (EVENT, "Key group: %d (xkb enabled: no)",
|
||||
event_x11->key_group);
|
||||
#endif /* HAVE_XKB */
|
||||
|
||||
event->key.time = xevent->xkey.time;
|
||||
event->key.modifier_state = (ClutterModifierType) xevent->xkey.state;
|
||||
event->key.hardware_keycode = xevent->xkey.keycode;
|
||||
@ -366,6 +354,9 @@ translate_key_event (ClutterBackend *backend,
|
||||
xevent->xkey.keycode,
|
||||
0);
|
||||
|
||||
event_x11->key_group =
|
||||
_clutter_keymap_x11_get_key_group (event->key.modifier_state);
|
||||
|
||||
/* unicode_value is the printable representation */
|
||||
n = XLookupString (&xevent->xkey, buffer, sizeof (buffer) - 1, NULL, NULL);
|
||||
|
||||
|
123
clutter/x11/clutter-keymap-x11.c
Normal file
123
clutter/x11/clutter-keymap-x11.c
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010 Intel Corp.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-keymap-x11.h"
|
||||
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#ifdef HAVE_XINPUT
|
||||
#include <X11/extensions/XInput.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
#include <X11/XKBlib.h>
|
||||
#endif
|
||||
|
||||
typedef struct _ClutterKeymapX11Class ClutterKeymapX11Class;
|
||||
|
||||
struct _ClutterKeymapX11
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
ClutterBackend *backend;
|
||||
};
|
||||
|
||||
struct _ClutterKeymapX11Class
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_BACKEND
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ClutterKeymapX11, clutter_keymap_x11, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
clutter_keymap_x11_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterKeymapX11 *keymap = CLUTTER_KEYMAP_X11 (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BACKEND:
|
||||
keymap->backend = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_keymap_x11_finalize (GObject *gobject)
|
||||
{
|
||||
G_OBJECT_CLASS (clutter_keymap_x11_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_keymap_x11_class_init (ClutterKeymapX11Class *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
gobject_class->set_property = clutter_keymap_x11_set_property;
|
||||
gobject_class->finalize = clutter_keymap_x11_finalize;
|
||||
|
||||
pspec = g_param_spec_object ("backend",
|
||||
"Backend",
|
||||
"The Clutter backend",
|
||||
CLUTTER_TYPE_BACKEND,
|
||||
CLUTTER_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (gobject_class, PROP_BACKEND, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_keymap_x11_init (ClutterKeymapX11 *keymap)
|
||||
{
|
||||
}
|
||||
|
||||
gint
|
||||
_clutter_keymap_x11_get_key_group (ClutterModifierType state)
|
||||
{
|
||||
#ifdef HAVE_XKB
|
||||
return XkbGroupForCoreState (state);
|
||||
#else
|
||||
return 0;
|
||||
#endif /* HAVE_XKB */
|
||||
}
|
44
clutter/x11/clutter-keymap-x11.h
Normal file
44
clutter/x11/clutter-keymap-x11.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2009 Intel Corp.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_KEYMAP_X11_H__
|
||||
#define __CLUTTER_KEYMAP_X11_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-event.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_KEYMAP_X11 (clutter_keymap_x11_get_type ())
|
||||
#define CLUTTER_KEYMAP_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_KEYMAP_X11, ClutterKeymapX11))
|
||||
#define CLUTTER_IS_KEYMAP_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_KEYMAP_X11))
|
||||
|
||||
typedef struct _ClutterKeymapX11 ClutterKeymapX11;
|
||||
|
||||
GType clutter_keymap_x11_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gint _clutter_keymap_x11_get_key_group (ClutterModifierType state);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_KEYMAP_X11_H__ */
|
Loading…
Reference in New Issue
Block a user