2017-05-26 16:55:30 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2017, Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author(s): Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*/
|
|
|
|
|
2019-02-24 20:29:08 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkeventcontrollerlegacy
|
|
|
|
* @Short_description: Event controller for miscellaneous events
|
|
|
|
* @Title: GtkEventControllerLegacy
|
|
|
|
* @See_also: #GtkEventController
|
|
|
|
*
|
|
|
|
* #GtkEventControllerLegacy is an event controller that gives you
|
|
|
|
* direct access to the event stream. It should only be used as a
|
|
|
|
* last resort if none of the other event controllers or gestures
|
|
|
|
* do the job.
|
|
|
|
**/
|
|
|
|
|
2017-05-26 16:55:30 +00:00
|
|
|
#include "config.h"
|
2019-02-24 20:29:08 +00:00
|
|
|
|
2018-10-12 15:30:59 +00:00
|
|
|
#include "gtkeventcontrollerlegacy.h"
|
|
|
|
#include "gtkeventcontrollerprivate.h"
|
|
|
|
#include "gtkmarshalers.h"
|
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
|
|
|
struct _GtkEventControllerLegacy
|
|
|
|
{
|
|
|
|
GtkEventController parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkEventControllerLegacyClass
|
|
|
|
{
|
|
|
|
GtkEventControllerClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EVENT,
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS] = { 0, };
|
2017-05-26 16:55:30 +00:00
|
|
|
|
2018-03-08 22:24:30 +00:00
|
|
|
G_DEFINE_TYPE (GtkEventControllerLegacy, gtk_event_controller_legacy,
|
2017-05-26 16:55:30 +00:00
|
|
|
GTK_TYPE_EVENT_CONTROLLER)
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_event_controller_legacy_handle_event (GtkEventController *controller,
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event,
|
2020-02-13 05:08:49 +00:00
|
|
|
double x,
|
|
|
|
double y)
|
2017-05-26 16:55:30 +00:00
|
|
|
{
|
2018-10-12 15:30:59 +00:00
|
|
|
gboolean handled;
|
2017-05-26 16:55:30 +00:00
|
|
|
|
2018-10-12 15:30:59 +00:00
|
|
|
g_signal_emit (controller, signals[EVENT], 0, event, &handled);
|
|
|
|
|
|
|
|
return handled;
|
2017-05-26 16:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-08 22:24:30 +00:00
|
|
|
gtk_event_controller_legacy_class_init (GtkEventControllerLegacyClass *klass)
|
2017-05-26 16:55:30 +00:00
|
|
|
{
|
|
|
|
GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
|
|
|
|
|
|
|
controller_class->handle_event = gtk_event_controller_legacy_handle_event;
|
2018-10-12 15:30:59 +00:00
|
|
|
|
|
|
|
/**
|
2018-11-08 04:19:30 +00:00
|
|
|
* GtkEventControllerLegacy::event:
|
2018-10-12 15:30:59 +00:00
|
|
|
* @controller: the object which received the signal.
|
|
|
|
* @event: the #GdkEvent which triggered this signal
|
|
|
|
*
|
2019-02-24 20:29:08 +00:00
|
|
|
* Emitted for each GDK event delivered to @controller.
|
2018-10-12 15:30:59 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE to stop other handlers from being invoked for the event
|
2019-02-24 20:29:08 +00:00
|
|
|
* and the emission of this signal. %FALSE to propagate the event further.
|
2018-10-12 15:30:59 +00:00
|
|
|
*/
|
|
|
|
signals[EVENT] =
|
|
|
|
g_signal_new (I_("event"),
|
2018-11-08 04:19:30 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, _gtk_boolean_handled_accumulator, NULL,
|
|
|
|
_gtk_marshal_BOOLEAN__OBJECT,
|
|
|
|
G_TYPE_BOOLEAN, 1,
|
|
|
|
GDK_TYPE_EVENT);
|
|
|
|
|
2018-10-12 15:30:59 +00:00
|
|
|
g_signal_set_va_marshaller (signals[EVENT], G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_BOOLEAN__OBJECTv);
|
2017-05-26 16:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-08 22:24:30 +00:00
|
|
|
gtk_event_controller_legacy_init (GtkEventControllerLegacy *controller)
|
2017-05-26 16:55:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-24 20:29:08 +00:00
|
|
|
/**
|
|
|
|
* gtk_event_controller_legacy_new:
|
|
|
|
*
|
|
|
|
* Creates a new legacy event controller.
|
|
|
|
*
|
|
|
|
* Returns: the newly created event controller.
|
|
|
|
*/
|
2017-05-26 16:55:30 +00:00
|
|
|
GtkEventController *
|
2018-03-08 22:24:30 +00:00
|
|
|
gtk_event_controller_legacy_new (void)
|
2017-05-26 16:55:30 +00:00
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_EVENT_CONTROLLER_LEGACY,
|
|
|
|
NULL);
|
|
|
|
}
|