wayland: Introduce MetaWaylandInput/MetaWaylandEventInterface
MetaWaylandInput is an object that will become in charge of handling
input events on their way to the Wayland socket. It keeps a stack
of event handlers, and propagates events and changes across them in
order to have them emit Wayland events, or change focus.
Each of these event handlers has a MetaWaylandEventInterface, this
is a vtable meant to replace MetaWaylandPointerGrabInterface and
MetaWaylandKeyboardGrabInterface in an unified manner, with the
following methods:
- get_focus_surface: to return the focus surface for a device/sequence.
Since several handlers will want to delegate logic on previous
handlers, it is optional to chain up with
meta_wayland_event_handler_chain_up_get_focus_surface().
- focus: To trigger a focus change for a device/sequence, since
event handlers are daisy chained by default, it is mandatory to
chain up with meta_wayland_event_handler_chain_up_focus(), either
with the given surface, or passing NULL to let later handlers
unset their state.
- press/motion/release: Unified handlers for pointer/touch/stylus
input, they chain up like event handlers do.
- key: Key event handler, propagates like event handlers do.
- other: Fallthrough for other events (pad, scroll, ...), propagates
like event handlers do.
Since there is a variety of expected behaviors, and the possibility
of stacking for some of the existing Wayland "grabs", this provides
the mechanism for that to happen.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2023-11-02 17:05:02 +01:00
|
|
|
/*
|
|
|
|
* Interface for Wayland events
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
|
|
#include "clutter/clutter.h"
|
|
|
|
#include "wayland/meta-wayland-types.h"
|
|
|
|
|
|
|
|
#define META_TYPE_WAYLAND_INPUT (meta_wayland_input_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (MetaWaylandInput,
|
|
|
|
meta_wayland_input,
|
|
|
|
META, WAYLAND_INPUT,
|
|
|
|
GObject);
|
|
|
|
|
|
|
|
typedef struct _MetaWaylandEventHandler MetaWaylandEventHandler;
|
|
|
|
|
|
|
|
typedef struct _MetaWaylandEventInterface MetaWaylandEventInterface;
|
|
|
|
|
|
|
|
struct _MetaWaylandEventInterface
|
|
|
|
{
|
|
|
|
MetaWaylandSurface * (*get_focus_surface) (MetaWaylandEventHandler *handler,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
/* Pointer/stylus/touch */
|
|
|
|
void (*focus) (MetaWaylandEventHandler *handler,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
MetaWaylandSurface *surface,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
gboolean (*motion) (MetaWaylandEventHandler *handler,
|
|
|
|
const ClutterEvent *event,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
gboolean (*press) (MetaWaylandEventHandler *handler,
|
|
|
|
const ClutterEvent *event,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
gboolean (*release) (MetaWaylandEventHandler *handler,
|
|
|
|
const ClutterEvent *event,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
/* Key */
|
|
|
|
gboolean (*key) (MetaWaylandEventHandler *handler,
|
|
|
|
const ClutterEvent *event,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
/* Other (Pads/IM/...) */
|
|
|
|
gboolean (*other) (MetaWaylandEventHandler *handler,
|
|
|
|
const ClutterEvent *event,
|
|
|
|
gpointer user_data);
|
|
|
|
};
|
|
|
|
|
|
|
|
MetaWaylandInput * meta_wayland_input_new (MetaWaylandSeat *seat);
|
|
|
|
|
|
|
|
MetaWaylandEventHandler * meta_wayland_input_attach_event_handler (MetaWaylandInput *input,
|
|
|
|
const MetaWaylandEventInterface *iface,
|
2023-11-17 23:29:39 +01:00
|
|
|
gboolean grab,
|
wayland: Introduce MetaWaylandInput/MetaWaylandEventInterface
MetaWaylandInput is an object that will become in charge of handling
input events on their way to the Wayland socket. It keeps a stack
of event handlers, and propagates events and changes across them in
order to have them emit Wayland events, or change focus.
Each of these event handlers has a MetaWaylandEventInterface, this
is a vtable meant to replace MetaWaylandPointerGrabInterface and
MetaWaylandKeyboardGrabInterface in an unified manner, with the
following methods:
- get_focus_surface: to return the focus surface for a device/sequence.
Since several handlers will want to delegate logic on previous
handlers, it is optional to chain up with
meta_wayland_event_handler_chain_up_get_focus_surface().
- focus: To trigger a focus change for a device/sequence, since
event handlers are daisy chained by default, it is mandatory to
chain up with meta_wayland_event_handler_chain_up_focus(), either
with the given surface, or passing NULL to let later handlers
unset their state.
- press/motion/release: Unified handlers for pointer/touch/stylus
input, they chain up like event handlers do.
- key: Key event handler, propagates like event handlers do.
- other: Fallthrough for other events (pad, scroll, ...), propagates
like event handlers do.
Since there is a variety of expected behaviors, and the possibility
of stacking for some of the existing Wayland "grabs", this provides
the mechanism for that to happen.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2023-11-02 17:05:02 +01:00
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
gboolean meta_wayland_input_is_current_handler (MetaWaylandInput *input,
|
|
|
|
MetaWaylandEventHandler *handler);
|
|
|
|
|
|
|
|
void meta_wayland_input_detach_event_handler (MetaWaylandInput *input,
|
|
|
|
MetaWaylandEventHandler *handler);
|
|
|
|
|
|
|
|
gboolean meta_wayland_input_handle_event (MetaWaylandInput *input,
|
|
|
|
const ClutterEvent *event);
|
|
|
|
|
|
|
|
void meta_wayland_input_invalidate_focus (MetaWaylandInput *input,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence);
|
|
|
|
|
|
|
|
MetaWaylandSurface * meta_wayland_event_handler_chain_up_get_focus_surface (MetaWaylandEventHandler *handler,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence);
|
|
|
|
|
|
|
|
void meta_wayland_event_handler_chain_up_focus (MetaWaylandEventHandler *handler,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
MetaWaylandSurface *surface);
|