mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
core: Add meta_device_keyboard_[gs]et_focus_window()
These functions are meant to replace X[GS]etInputFocus() calls across the core.
This commit is contained in:
parent
154730a3d9
commit
df044a0035
@ -37,3 +37,33 @@ static void
|
|||||||
meta_device_keyboard_init (MetaDeviceKeyboard *keyboard)
|
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);
|
||||||
|
}
|
||||||
|
@ -51,9 +51,19 @@ struct _MetaDeviceKeyboard
|
|||||||
struct _MetaDeviceKeyboardClass
|
struct _MetaDeviceKeyboardClass
|
||||||
{
|
{
|
||||||
MetaDeviceClass parent_instance;
|
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;
|
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 */
|
#endif /* META_DEVICE_KEYBOARD_H */
|
||||||
|
@ -200,11 +200,42 @@ meta_device_keyboard_core_ungrab (MetaDevice *device,
|
|||||||
XUngrabKeyboard (display->xdisplay, time);
|
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
|
static void
|
||||||
meta_device_keyboard_core_class_init (MetaDeviceKeyboardCoreClass *klass)
|
meta_device_keyboard_core_class_init (MetaDeviceKeyboardCoreClass *klass)
|
||||||
{
|
{
|
||||||
|
MetaDeviceKeyboardClass *keyboard_class = META_DEVICE_KEYBOARD_CLASS (klass);
|
||||||
MetaDeviceClass *device_class = META_DEVICE_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->allow_events = meta_device_core_common_allow_events;
|
||||||
device_class->grab = meta_device_keyboard_core_grab;
|
device_class->grab = meta_device_keyboard_core_grab;
|
||||||
device_class->ungrab = meta_device_keyboard_core_ungrab;
|
device_class->ungrab = meta_device_keyboard_core_ungrab;
|
||||||
|
@ -281,11 +281,44 @@ G_DEFINE_TYPE (MetaDeviceKeyboardXI2,
|
|||||||
meta_device_keyboard_xi2,
|
meta_device_keyboard_xi2,
|
||||||
META_TYPE_DEVICE_KEYBOARD)
|
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
|
static void
|
||||||
meta_device_keyboard_xi2_class_init (MetaDeviceKeyboardXI2Class *klass)
|
meta_device_keyboard_xi2_class_init (MetaDeviceKeyboardXI2Class *klass)
|
||||||
{
|
{
|
||||||
|
MetaDeviceKeyboardClass *keyboard_class = META_DEVICE_KEYBOARD_CLASS (klass);
|
||||||
MetaDeviceClass *device_class = META_DEVICE_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->allow_events = meta_device_xi2_common_allow_events;
|
||||||
device_class->grab = meta_device_xi2_common_grab;
|
device_class->grab = meta_device_xi2_common_grab;
|
||||||
device_class->ungrab = meta_device_xi2_common_ungrab;
|
device_class->ungrab = meta_device_xi2_common_ungrab;
|
||||||
|
Loading…
Reference in New Issue
Block a user