[mutter/wip/multitouch: 35/73] core: Add meta_device_keyboard_[gs]et_focus_window()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/multitouch: 35/73] core: Add meta_device_keyboard_[gs]et_focus_window()
- Date: Mon, 31 Oct 2011 00:19:38 +0000 (UTC)
commit df044a0035b7687a9d0b902e1bf9ddd24365179d
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jul 3 18:19:05 2011 +0200
core: Add meta_device_keyboard_[gs]et_focus_window()
These functions are meant to replace X[GS]etInputFocus() calls across
the core.
src/core/device-keyboard.c | 30 ++++++++++++++++++++++++++++++
src/core/device-keyboard.h | 10 ++++++++++
src/core/devices-core.c | 31 +++++++++++++++++++++++++++++++
src/core/devices-xi2.c | 33 +++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/src/core/device-keyboard.c b/src/core/device-keyboard.c
index ce16cbb..f33c1d2 100644
--- a/src/core/device-keyboard.c
+++ b/src/core/device-keyboard.c
@@ -37,3 +37,33 @@ static void
meta_device_keyboard_init (MetaDeviceKeyboard *keyboard)
{
}
+
+Window
+meta_device_keyboard_get_focus_window (MetaDeviceKeyboard *keyboard)
+{
+ MetaDeviceKeyboardClass *klass;
+
+ g_return_val_if_fail (META_IS_DEVICE_KEYBOARD (keyboard), None);
+
+ klass = META_DEVICE_KEYBOARD_GET_CLASS (keyboard);
+
+ if (!klass->get_focus_window)
+ return None;
+
+ return (klass->get_focus_window) (keyboard);
+}
+
+void
+meta_device_keyboard_set_focus_window (MetaDeviceKeyboard *keyboard,
+ Window xwindow,
+ Time timestamp)
+{
+ MetaDeviceKeyboardClass *klass;
+
+ g_return_if_fail (META_IS_DEVICE_KEYBOARD (keyboard));
+
+ klass = META_DEVICE_KEYBOARD_GET_CLASS (keyboard);
+
+ if (klass->set_focus_window)
+ (klass->set_focus_window) (keyboard, xwindow, timestamp);
+}
diff --git a/src/core/device-keyboard.h b/src/core/device-keyboard.h
index b811a4a..8fb0972 100644
--- a/src/core/device-keyboard.h
+++ b/src/core/device-keyboard.h
@@ -51,9 +51,19 @@ struct _MetaDeviceKeyboard
struct _MetaDeviceKeyboardClass
{
MetaDeviceClass parent_instance;
+
+ Window (* get_focus_window) (MetaDeviceKeyboard *keyboard);
+ void (* set_focus_window) (MetaDeviceKeyboard *keyboard,
+ Window xwindow,
+ Time timestamp);
};
GType meta_device_keyboard_get_type (void) G_GNUC_CONST;
+Window meta_device_keyboard_get_focus_window (MetaDeviceKeyboard *keyboard);
+void meta_device_keyboard_set_focus_window (MetaDeviceKeyboard *keyboard,
+ Window xwindow,
+ Time timestamp);
+
#endif /* META_DEVICE_KEYBOARD_H */
diff --git a/src/core/devices-core.c b/src/core/devices-core.c
index d4ad7cf..6848dc8 100644
--- a/src/core/devices-core.c
+++ b/src/core/devices-core.c
@@ -200,11 +200,42 @@ meta_device_keyboard_core_ungrab (MetaDevice *device,
XUngrabKeyboard (display->xdisplay, time);
}
+static Window
+meta_device_keyboard_core_get_focus_window (MetaDeviceKeyboard *keyboard)
+{
+ MetaDisplay *display;
+ Window xwindow;
+ int unused;
+
+ display = meta_device_get_display (META_DEVICE (keyboard));
+ XGetInputFocus (display->xdisplay, &xwindow, &unused);
+
+ return xwindow;
+}
+
+static void
+meta_device_keyboard_core_set_focus_window (MetaDeviceKeyboard *keyboard,
+ Window xwindow,
+ Time timestamp)
+{
+ MetaDisplay *display;
+
+ display = meta_device_get_display (META_DEVICE (keyboard));
+ XSetInputFocus (display->xdisplay,
+ xwindow,
+ RevertToPointerRoot,
+ timestamp);
+}
+
static void
meta_device_keyboard_core_class_init (MetaDeviceKeyboardCoreClass *klass)
{
+ MetaDeviceKeyboardClass *keyboard_class = META_DEVICE_KEYBOARD_CLASS (klass);
MetaDeviceClass *device_class = META_DEVICE_CLASS (klass);
+ keyboard_class->get_focus_window = meta_device_keyboard_core_get_focus_window;
+ keyboard_class->set_focus_window = meta_device_keyboard_core_set_focus_window;
+
device_class->allow_events = meta_device_core_common_allow_events;
device_class->grab = meta_device_keyboard_core_grab;
device_class->ungrab = meta_device_keyboard_core_ungrab;
diff --git a/src/core/devices-xi2.c b/src/core/devices-xi2.c
index f50d205..ab2f68d 100644
--- a/src/core/devices-xi2.c
+++ b/src/core/devices-xi2.c
@@ -281,11 +281,44 @@ G_DEFINE_TYPE (MetaDeviceKeyboardXI2,
meta_device_keyboard_xi2,
META_TYPE_DEVICE_KEYBOARD)
+static Window
+meta_device_keyboard_xi2_get_focus_window (MetaDeviceKeyboard *keyboard)
+{
+ MetaDisplay *display;
+ Window xwindow;
+
+ display = meta_device_get_display (META_DEVICE (keyboard));
+ XIGetFocus (display->xdisplay,
+ meta_device_get_id (META_DEVICE (keyboard)),
+ &xwindow);
+
+ return xwindow;
+}
+
+static void
+meta_device_keyboard_xi2_set_focus_window (MetaDeviceKeyboard *keyboard,
+ Window xwindow,
+ Time timestamp)
+{
+ MetaDisplay *display;
+
+ display = meta_device_get_display (META_DEVICE (keyboard));
+
+ XISetFocus (display->xdisplay,
+ meta_device_get_id (META_DEVICE (keyboard)),
+ xwindow,
+ timestamp);
+}
+
static void
meta_device_keyboard_xi2_class_init (MetaDeviceKeyboardXI2Class *klass)
{
+ MetaDeviceKeyboardClass *keyboard_class = META_DEVICE_KEYBOARD_CLASS (klass);
MetaDeviceClass *device_class = META_DEVICE_CLASS (klass);
+ keyboard_class->get_focus_window = meta_device_keyboard_xi2_get_focus_window;
+ keyboard_class->set_focus_window = meta_device_keyboard_xi2_set_focus_window;
+
device_class->allow_events = meta_device_xi2_common_allow_events;
device_class->grab = meta_device_xi2_common_grab;
device_class->ungrab = meta_device_xi2_common_ungrab;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]