mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
window: Make meta_window_has_pointer() per protocol implemented
https://bugzilla.gnome.org/show_bug.cgi?id=769936
This commit is contained in:
parent
3b3f40a1aa
commit
9fb891d216
@ -484,6 +484,7 @@ struct _MetaWindowClass
|
||||
void (*update_main_monitor) (MetaWindow *window);
|
||||
void (*main_monitor_changed) (MetaWindow *window,
|
||||
const MetaMonitorInfo *old);
|
||||
gboolean (*has_pointer) (MetaWindow *window);
|
||||
};
|
||||
|
||||
/* These differ from window->has_foo_func in that they consider
|
||||
|
@ -7535,52 +7535,10 @@ mouse_mode_focus (MetaWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
window_has_pointer_wayland (MetaWindow *window)
|
||||
{
|
||||
ClutterDeviceManager *dm;
|
||||
ClutterInputDevice *dev;
|
||||
ClutterActor *pointer_actor, *window_actor;
|
||||
|
||||
dm = clutter_device_manager_get_default ();
|
||||
dev = clutter_device_manager_get_core_device (dm, CLUTTER_POINTER_DEVICE);
|
||||
pointer_actor = clutter_input_device_get_pointer_actor (dev);
|
||||
window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window));
|
||||
|
||||
return pointer_actor && clutter_actor_contains (window_actor, pointer_actor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
window_has_pointer_x11 (MetaWindow *window)
|
||||
{
|
||||
MetaDisplay *display = window->display;
|
||||
MetaScreen *screen = window->screen;
|
||||
Window root, child;
|
||||
double root_x, root_y, x, y;
|
||||
XIButtonState buttons;
|
||||
XIModifierState mods;
|
||||
XIGroupState group;
|
||||
|
||||
meta_error_trap_push (display);
|
||||
XIQueryPointer (display->xdisplay,
|
||||
META_VIRTUAL_CORE_POINTER_ID,
|
||||
screen->xroot,
|
||||
&root, &child,
|
||||
&root_x, &root_y, &x, &y,
|
||||
&buttons, &mods, &group);
|
||||
meta_error_trap_pop (display);
|
||||
free (buttons.mask);
|
||||
|
||||
return meta_display_lookup_x_window (display, child) == window;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_window_has_pointer (MetaWindow *window)
|
||||
{
|
||||
if (meta_is_wayland_compositor ())
|
||||
return window_has_pointer_wayland (window);
|
||||
else
|
||||
return window_has_pointer_x11 (window);
|
||||
return META_WINDOW_GET_CLASS (window)->has_pointer (window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -419,6 +419,21 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
|
||||
meta_window_emit_size_changed (window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_window_wayland_has_pointer (MetaWindow *window)
|
||||
{
|
||||
ClutterDeviceManager *dm;
|
||||
ClutterInputDevice *dev;
|
||||
ClutterActor *pointer_actor, *window_actor;
|
||||
|
||||
dm = clutter_device_manager_get_default ();
|
||||
dev = clutter_device_manager_get_core_device (dm, CLUTTER_POINTER_DEVICE);
|
||||
pointer_actor = clutter_input_device_get_pointer_actor (dev);
|
||||
window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window));
|
||||
|
||||
return pointer_actor && clutter_actor_contains (window_actor, pointer_actor);
|
||||
}
|
||||
|
||||
static void
|
||||
appears_focused_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@ -453,6 +468,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
|
||||
window_class->move_resize_internal = meta_window_wayland_move_resize_internal;
|
||||
window_class->update_main_monitor = meta_window_wayland_update_main_monitor;
|
||||
window_class->main_monitor_changed = meta_window_wayland_main_monitor_changed;
|
||||
window_class->has_pointer = meta_window_wayland_has_pointer;
|
||||
}
|
||||
|
||||
MetaWindow *
|
||||
|
@ -1481,6 +1481,30 @@ meta_window_x11_main_monitor_changed (MetaWindow *window,
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_window_x11_has_pointer (MetaWindow *window)
|
||||
{
|
||||
MetaDisplay *display = window->display;
|
||||
MetaScreen *screen = window->screen;
|
||||
Window root, child;
|
||||
double root_x, root_y, x, y;
|
||||
XIButtonState buttons;
|
||||
XIModifierState mods;
|
||||
XIGroupState group;
|
||||
|
||||
meta_error_trap_push (display);
|
||||
XIQueryPointer (display->xdisplay,
|
||||
META_VIRTUAL_CORE_POINTER_ID,
|
||||
screen->xroot,
|
||||
&root, &child,
|
||||
&root_x, &root_y, &x, &y,
|
||||
&buttons, &mods, &group);
|
||||
meta_error_trap_pop (display);
|
||||
free (buttons.mask);
|
||||
|
||||
return meta_display_lookup_x_window (display, child) == window;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_x11_class_init (MetaWindowX11Class *klass)
|
||||
{
|
||||
@ -1501,6 +1525,7 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
|
||||
window_class->update_icon = meta_window_x11_update_icon;
|
||||
window_class->update_main_monitor = meta_window_x11_update_main_monitor;
|
||||
window_class->main_monitor_changed = meta_window_x11_main_monitor_changed;
|
||||
window_class->has_pointer = meta_window_x11_has_pointer;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user