Commit a1cee7fa authored by Benjamin Otte's avatar Benjamin Otte
Browse files

surface: Kill event masks

In particular, this patch removes:
  gdk_surface_get_events()
  gdk_surface_set_events()
  gdk_surface_get_device_events()
  gdk_surface_set_device_events()

Event masks so far still exist for grabs.
parent d0ebdf00
......@@ -282,8 +282,6 @@ gdk_surface_get_toplevel
gdk_surface_get_children
gdk_surface_get_children_with_user_data
gdk_surface_peek_children
gdk_surface_get_events
gdk_surface_set_events
gdk_surface_set_icon_name
gdk_surface_set_transient_for
gdk_surface_set_role
......@@ -301,8 +299,6 @@ gdk_surface_get_support_multidevice
gdk_surface_set_support_multidevice
gdk_surface_get_device_cursor
gdk_surface_set_device_cursor
gdk_surface_get_device_events
gdk_surface_set_device_events
<SUBSECTION>
gdk_surface_coords_from_parent
......
......@@ -179,41 +179,6 @@
</para>
</refsect2>
<refsect2 id="event-masks">
<title>Event masks</title>
<para>
Each widget instance has a basic event mask and another per input device,
which determine the types of input event it receives. Each event mask set
on a widget is added to the corresponding (basic or per-device) event mask
for the widget’s #GdkSurface, and all child #GdkSurfaces.
</para>
<para>
Filtering events against event masks happens inside #GdkSurface, which
exposes event masks to the windowing system to reduce the number of events
GDK receives from it. On receiving an event, it is filtered against the
#GdkSurface’s mask for the input device, if set. Otherwise, it is filtered
against the #GdkSurface’s basic event mask.
</para>
<para>
This means that widgets must add to the event mask for each event type
they expect to receive, using gtk_widget_set_events() or
gtk_widget_add_events() to preserve the existing mask. Widgets which are
aware of floating devices should use gtk_widget_set_device_events() or
gtk_widget_add_device_events(), and must explicitly enable the device
using gtk_widget_set_device_enabled(). See the #GdkDeviceManager
documentation for more information.
</para>
<para>
All standard widgets set the event mask for all events they expect to
receive, and it is not necessary to modify this. Masks should be set when
implementing a new widget.
</para>
</refsect2>
<refsect2>
<title>Touch events</title>
......
......@@ -61,9 +61,6 @@ static GdkSurface * gdk_broadway_device_surface_at_position (GdkDevice *de
gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_broadway_device_select_surface_events (GdkDevice *device,
GdkSurface *surface,
GdkEventMask event_mask);
G_DEFINE_TYPE (GdkBroadwayDevice, gdk_broadway_device, GDK_TYPE_DEVICE)
......@@ -81,7 +78,6 @@ gdk_broadway_device_class_init (GdkBroadwayDeviceClass *klass)
device_class->grab = gdk_broadway_device_grab;
device_class->ungrab = gdk_broadway_device_ungrab;
device_class->surface_at_position = gdk_broadway_device_surface_at_position;
device_class->select_surface_events = gdk_broadway_device_select_surface_events;
}
static void
......@@ -325,9 +321,3 @@ gdk_broadway_device_surface_at_position (GdkDevice *device,
return surface;
}
static void
gdk_broadway_device_select_surface_events (GdkDevice *device,
GdkSurface *surface,
GdkEventMask event_mask)
{
}
......@@ -101,7 +101,6 @@ void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
void _gdk_broadway_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes);
gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
......
......@@ -207,7 +207,6 @@ void
_gdk_broadway_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes)
{
GdkSurfaceImplBroadway *impl;
......@@ -323,10 +322,9 @@ gdk_surface_broadway_show (GdkSurface *surface,
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
impl->visible = TRUE;
if (surface->event_mask & GDK_STRUCTURE_MASK)
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
if (surface->parent)
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
......@@ -344,10 +342,9 @@ gdk_surface_broadway_hide (GdkSurface *surface)
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
impl->visible = FALSE;
if (surface->event_mask & GDK_STRUCTURE_MASK)
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
if (surface->parent)
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
......@@ -620,24 +617,6 @@ gdk_surface_broadway_get_device_state (GdkSurface *surface,
return child != NULL;
}
static GdkEventMask
gdk_surface_broadway_get_events (GdkSurface *surface)
{
if (GDK_SURFACE_DESTROYED (surface))
return 0;
return 0;
}
static void
gdk_surface_broadway_set_events (GdkSurface *surface,
GdkEventMask event_mask)
{
if (!GDK_SURFACE_DESTROYED (surface))
{
}
}
static void
gdk_surface_broadway_input_shape_combine_region (GdkSurface *surface,
const cairo_region_t *shape_region,
......@@ -1359,8 +1338,6 @@ gdk_surface_impl_broadway_class_init (GdkSurfaceImplBroadwayClass *klass)
impl_class->show = gdk_surface_broadway_show;
impl_class->hide = gdk_surface_broadway_hide;
impl_class->withdraw = gdk_surface_broadway_withdraw;
impl_class->set_events = gdk_surface_broadway_set_events;
impl_class->get_events = gdk_surface_broadway_get_events;
impl_class->raise = gdk_surface_broadway_raise;
impl_class->lower = gdk_surface_broadway_lower;
impl_class->restack_toplevel = gdk_surface_broadway_restack_toplevel;
......
......@@ -112,9 +112,6 @@ struct _GdkDeviceClass
double *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
void (* select_surface_events) (GdkDevice *device,
GdkSurface *surface,
GdkEventMask event_mask);
};
void _gdk_device_set_associated_device (GdkDevice *device,
......
......@@ -1311,17 +1311,15 @@ _gdk_display_event_data_free (GdkDisplay *display,
}
void
_gdk_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes)
gdk_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkSurfaceAttr *attributes)
{
GDK_DISPLAY_GET_CLASS (display)->create_surface_impl (display,
surface,
real_parent,
event_mask,
attributes);
surface,
real_parent,
attributes);
}
GdkSurface *
......
......@@ -144,7 +144,6 @@ struct _GdkDisplayClass
void (*create_surface_impl) (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes);
GdkKeymap * (*get_keymap) (GdkDisplay *display);
......@@ -231,10 +230,9 @@ void _gdk_display_event_data_copy (GdkDisplay *display
GdkEvent *new_event);
void _gdk_display_event_data_free (GdkDisplay *display,
GdkEvent *event);
void _gdk_display_create_surface_impl (GdkDisplay *display,
void gdk_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes);
GdkSurface * _gdk_display_create_surface (GdkDisplay *display);
......
......@@ -150,7 +150,6 @@ struct _GdkSurface
gint x;
gint y;
GdkEventMask event_mask;
guint8 surface_type;
guint8 resize_count;
......@@ -206,7 +205,6 @@ struct _GdkSurface
cairo_region_t *input_shape;
GList *devices_inside;
GHashTable *device_events;
GdkFrameClock *frame_clock; /* NULL to use from parent or default */
......
......@@ -321,9 +321,6 @@ seat_removed_cb (GdkDisplay *display,
surface->devices_inside = g_list_remove (surface->devices_inside, device);
g_hash_table_remove (surface->device_cursor, device);
if (surface->device_events)
g_hash_table_remove (surface->device_events, device);
}
static void
......@@ -369,9 +366,6 @@ gdk_surface_finalize (GObject *object)
if (surface->device_cursor)
g_hash_table_destroy (surface->device_cursor);
if (surface->device_events)
g_hash_table_destroy (surface->device_events);
if (surface->devices_inside)
g_list_free (surface->devices_inside);
......@@ -601,45 +595,6 @@ _gdk_surface_update_size (GdkSurface *surface)
recompute_visible_regions (surface, FALSE);
}
static GdkEventMask
get_native_device_event_mask (GdkSurface *private,
GdkDevice *device)
{
GdkEventMask event_mask;
if (device)
event_mask = GPOINTER_TO_INT (g_hash_table_lookup (private->device_events, device));
else
event_mask = private->event_mask;
if (private->surface_type == GDK_SURFACE_FOREIGN)
return event_mask;
else
{
GdkEventMask mask;
mask = private->event_mask;
/* We need thse for all native surfaces so we can
emulate events on children: */
mask |=
GDK_EXPOSURE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_TOUCH_MASK |
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_SCROLL_MASK;
return mask;
}
}
static GdkEventMask
get_native_event_mask (GdkSurface *private)
{
return get_native_device_event_mask (private, NULL);
}
GdkSurface*
gdk_surface_new (GdkDisplay *display,
GdkSurface *parent,
......@@ -647,7 +602,6 @@ gdk_surface_new (GdkDisplay *display,
{
GdkSurface *surface;
gboolean native;
GdkEventMask event_mask;
g_return_val_if_fail (attributes != NULL, NULL);
......@@ -714,8 +668,6 @@ gdk_surface_new (GdkDisplay *display,
return NULL;
}
surface->event_mask = GDK_ALL_EVENTS_MASK;
if (attributes->wclass == GDK_INPUT_OUTPUT)
{
surface->input_only = FALSE;
......@@ -745,10 +697,8 @@ gdk_surface_new (GdkDisplay *display,
if (native)
{
event_mask = get_native_event_mask (surface);
/* Create the impl */
_gdk_display_create_surface_impl (display, surface, parent, event_mask, attributes);
gdk_display_create_surface_impl (display, surface, parent, attributes);
surface->impl_surface = surface;
}
else
......@@ -2345,10 +2295,9 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
if (!was_mapped && !gdk_surface_has_impl (surface))
{
if (surface->event_mask & GDK_STRUCTURE_MASK)
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
if (surface->parent)
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
}
......@@ -2656,10 +2605,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
if (was_mapped && !gdk_surface_has_impl (surface))
{
if (surface->event_mask & GDK_STRUCTURE_MASK)
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
if (surface->parent)
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
}
......@@ -2697,10 +2645,9 @@ gdk_surface_withdraw (GdkSurface *surface)
if (was_mapped)
{
if (surface->event_mask & GDK_STRUCTURE_MASK)
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
if (surface->parent && surface->parent->event_mask & GDK_SUBSTRUCTURE_MASK)
if (surface->parent)
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
}
......@@ -2712,140 +2659,6 @@ gdk_surface_withdraw (GdkSurface *surface)
}
}
/**
* gdk_surface_set_events:
* @surface: a #GdkSurface
* @event_mask: event mask for @surface
*
* The event mask for a surface determines which events will be reported
* for that surface from all master input devices. For example, an event mask
* including #GDK_BUTTON_PRESS_MASK means the surface should report button
* press events. The event mask is the bitwise OR of values from the
* #GdkEventMask enumeration.
*
* See the [input handling overview][event-masks] for details.
**/
void
gdk_surface_set_events (GdkSurface *surface,
GdkEventMask event_mask)
{
GdkSurfaceImplClass *impl_class;
g_return_if_fail (GDK_IS_SURFACE (surface));
if (surface->destroyed)
return;
surface->event_mask = event_mask;
if (gdk_surface_has_impl (surface))
{
impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
impl_class->set_events (surface,
get_native_event_mask (surface));
}
}
/**
* gdk_surface_get_events:
* @surface: a #GdkSurface
*
* Gets the event mask for @surface for all master input devices. See
* gdk_surface_set_events().
*
* Returns: event mask for @surface
**/
GdkEventMask
gdk_surface_get_events (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), 0);
if (surface->destroyed)
return 0;
return surface->event_mask;
}
/**
* gdk_surface_set_device_events:
* @surface: a #GdkSurface
* @device: #GdkDevice to enable events for.
* @event_mask: event mask for @surface
*
* Sets the event mask for a given device (Normally a floating device, not
* attached to any visible pointer) to @surface. For example, an event mask
* including #GDK_BUTTON_PRESS_MASK means the surface should report button
* press events. The event mask is the bitwise OR of values from the
* #GdkEventMask enumeration.
*
* See the [input handling overview][event-masks] for details.
**/
void
gdk_surface_set_device_events (GdkSurface *surface,
GdkDevice *device,
GdkEventMask event_mask)
{
GdkEventMask device_mask;
GdkSurface *native;
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (GDK_IS_DEVICE (device));
if (GDK_SURFACE_DESTROYED (surface))
return;
if (G_UNLIKELY (!surface->device_events))
surface->device_events = g_hash_table_new (NULL, NULL);
if (event_mask == 0)
{
/* FIXME: unsetting events on a master device
* would restore surface->event_mask
*/
g_hash_table_remove (surface->device_events, device);
}
else
g_hash_table_insert (surface->device_events, device,
GINT_TO_POINTER (event_mask));
native = gdk_surface_get_toplevel (surface);
device_mask = get_native_device_event_mask (surface, device);
GDK_DEVICE_GET_CLASS (device)->select_surface_events (device, native, device_mask);
}
/**
* gdk_surface_get_device_events:
* @surface: a #GdkSurface.
* @device: a #GdkDevice.
*
* Returns the event mask for @surface corresponding to an specific device.
*
* Returns: device event mask for @surface
**/
GdkEventMask
gdk_surface_get_device_events (GdkSurface *surface,
GdkDevice *device)
{
GdkEventMask mask;
g_return_val_if_fail (GDK_IS_SURFACE (surface), 0);
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
if (GDK_SURFACE_DESTROYED (surface))
return 0;
if (!surface->device_events)
return 0;
mask = GPOINTER_TO_INT (g_hash_table_lookup (surface->device_events, device));
/* FIXME: device could be controlled by surface->event_mask */
return mask;
}
static void
gdk_surface_move_resize_toplevel (GdkSurface *surface,
gboolean with_move,
......
......@@ -685,19 +685,6 @@ GDK_AVAILABLE_IN_ALL
GList * gdk_surface_get_children_with_user_data (GdkSurface *surface,
gpointer user_data);
GDK_AVAILABLE_IN_ALL
GdkEventMask gdk_surface_get_events (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_events (GdkSurface *surface,
GdkEventMask event_mask);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_device_events (GdkSurface *surface,
GdkDevice *device,
GdkEventMask event_mask);
GDK_AVAILABLE_IN_ALL
GdkEventMask gdk_surface_get_device_events (GdkSurface *surface,
GdkDevice *device);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_icon_list (GdkSurface *surface,
GList *surfaces);
......
......@@ -76,10 +76,6 @@ struct _GdkSurfaceImplClass
gint rect_anchor_dx,
gint rect_anchor_dy);
GdkEventMask (* get_events) (GdkSurface *surface);
void (* set_events) (GdkSurface *surface,
GdkEventMask event_mask);
void (* get_geometry) (GdkSurface *surface,
gint *x,
gint *y,
......
......@@ -76,9 +76,6 @@ static GdkSurface * gdk_quartz_device_core_surface_at_position (GdkDevice
gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_quartz_device_core_select_surface_events (GdkDevice *device,
GdkSurface *window,
GdkEventMask event_mask);
G_DEFINE_TYPE (GdkQuartzDeviceCore, gdk_quartz_device_core, GDK_TYPE_DEVICE)
......@@ -96,7 +93,6 @@ gdk_quartz_device_core_class_init (GdkQuartzDeviceCoreClass *klass)
device_class->grab = gdk_quartz_device_core_grab;
device_class->ungrab = gdk_quartz_device_core_ungrab;
device_class->surface_at_position = gdk_quartz_device_core_surface_at_position;
device_class->select_surface_events = gdk_quartz_device_core_select_surface_events;
}
static void
......@@ -349,10 +345,3 @@ gdk_quartz_device_core_surface_at_position (GdkDevice *device,
return found_window;
}
static void
gdk_quartz_device_core_select_surface_events (GdkDevice *device,
GdkSurface *window,
GdkEventMask event_mask)
{
/* The mask is set in the common code. */
}
......@@ -65,7 +65,6 @@ void _gdk_quartz_display_after_process_all_updates (GdkDisplay *display);
void _gdk_quartz_display_create_surface_impl (GdkDisplay *display,
GdkSurface *window,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes);
/* Display methods - keymap */
......
......@@ -731,7 +731,6 @@ void
_gdk_quartz_display_create_surface_impl (GdkDisplay *display,
GdkSurface *window,
GdkSurface *real_parent,
GdkEventMask event_mask,
GdkSurfaceAttr *attributes)
{
GdkSurfaceImplQuartz *impl;
......@@ -1615,22 +1614,6 @@ gdk_surface_quartz_get_device_state (GdkSurface *window,
x, y, mask) != NULL;
}
static GdkEventMask
gdk_surface_quartz_get_events (GdkSurface *window)
{
if (GDK_SURFACE_DESTROYED (window))
return 0;
else
return window->event_mask;
}
static void
gdk_surface_quartz_set_events (GdkSurface *window,
GdkEventMask event_mask)
{
/* The mask is set in the common code. */
}
static void
gdk_quartz_surface_set_urgency_hint (GdkSurface *window,
gboolean urgent)
......@@ -2746,8 +2729,6 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass)
impl_class->show = gdk_surface_quartz_show;
impl_class->hide = gdk_surface_quartz_hide;
impl_class->withdraw = gdk_surface_quartz_withdraw;
impl_class->set_events = gdk_surface_quartz_set_events;
impl_class->get_events = gdk_surface_quartz_get_events;
impl_class->raise = gdk_surface_quartz_raise;
impl_class->lower = gdk_surface_quartz_lower;
impl_class->restack_toplevel = gdk_surface_quartz_restack_toplevel;
......
......@@ -865,13 +865,6 @@ gdk_wayland_device_surface_at_position (GdkDevice *device,
return pointer->focus;
}