2010-11-12 12:18:58 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-12 12:18:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gdkeventsource.h"
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
#include "gdksurfaceprivate.h"
|
2017-11-23 09:22:23 +00:00
|
|
|
#include "gdkframeclockprivate.h"
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2010-11-25 11:33:07 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
static gboolean gdk_event_source_prepare (GSource *source,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *timeout);
|
2010-11-12 12:18:58 +00:00
|
|
|
static gboolean gdk_event_source_check (GSource *source);
|
|
|
|
static gboolean gdk_event_source_dispatch (GSource *source,
|
|
|
|
GSourceFunc callback,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gdk_event_source_finalize (GSource *source);
|
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
#define HAS_FOCUS(toplevel) \
|
2010-11-12 12:18:58 +00:00
|
|
|
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
|
|
|
|
|
|
|
|
struct _GdkEventSource
|
|
|
|
{
|
|
|
|
GSource source;
|
|
|
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
GPollFD event_poll_fd;
|
|
|
|
};
|
|
|
|
|
|
|
|
static GSourceFuncs event_funcs = {
|
|
|
|
gdk_event_source_prepare,
|
|
|
|
gdk_event_source_check,
|
|
|
|
gdk_event_source_dispatch,
|
|
|
|
gdk_event_source_finalize
|
|
|
|
};
|
|
|
|
|
|
|
|
static GList *event_sources = NULL;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_event_source_prepare (GSource *source,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *timeout)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
GdkDisplay *display = ((GdkEventSource*) source)->display;
|
|
|
|
gboolean retval;
|
|
|
|
|
|
|
|
*timeout = -1;
|
2013-02-20 17:27:07 +00:00
|
|
|
|
2013-11-11 23:04:34 +00:00
|
|
|
retval = (_gdk_event_queue_find_first (display) != NULL);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_event_source_check (GSource *source)
|
|
|
|
{
|
|
|
|
GdkEventSource *event_source = (GdkEventSource*) source;
|
|
|
|
gboolean retval;
|
|
|
|
|
2013-11-11 23:04:34 +00:00
|
|
|
if (event_source->display->event_pause_count > 0 ||
|
|
|
|
event_source->event_poll_fd.revents & G_IO_IN)
|
2010-11-15 19:08:18 +00:00
|
|
|
retval = (_gdk_event_queue_find_first (event_source->display) != NULL);
|
2010-11-12 12:18:58 +00:00
|
|
|
else
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-11-25 11:33:07 +00:00
|
|
|
void
|
2019-03-29 10:03:38 +00:00
|
|
|
_gdk_broadway_events_got_input (GdkDisplay *display,
|
|
|
|
BroadwayInputMsg *message)
|
2010-11-25 11:33:07 +00:00
|
|
|
{
|
2014-10-25 14:31:31 +00:00
|
|
|
GdkBroadwayDisplay *display_broadway;
|
2018-03-21 08:17:50 +00:00
|
|
|
GdkSurface *surface;
|
2010-11-25 11:33:07 +00:00
|
|
|
GdkEvent *event = NULL;
|
|
|
|
GList *node;
|
|
|
|
|
2014-10-25 14:31:31 +00:00
|
|
|
display_broadway = GDK_BROADWAY_DISPLAY (display);
|
2013-11-12 15:11:15 +00:00
|
|
|
|
2011-04-01 13:08:28 +00:00
|
|
|
switch (message->base.type) {
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_ENTER:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
|
|
|
if (surface)
|
2010-11-25 11:33:07 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_crossing_event_new (GDK_ENTER_NOTIFY,
|
2020-02-15 00:07:09 +00:00
|
|
|
surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_pointer,
|
2020-02-15 00:07:09 +00:00
|
|
|
message->base.time,
|
|
|
|
message->pointer.state,
|
|
|
|
message->pointer.win_x,
|
|
|
|
message->pointer.win_y,
|
|
|
|
message->crossing.mode,
|
|
|
|
GDK_NOTIFY_ANCESTOR);
|
2017-12-05 13:38:57 +00:00
|
|
|
|
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2010-11-25 11:33:07 +00:00
|
|
|
}
|
2011-03-11 20:10:23 +00:00
|
|
|
break;
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_LEAVE:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
|
|
|
if (surface)
|
2011-03-11 20:10:23 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_crossing_event_new (GDK_LEAVE_NOTIFY,
|
2020-02-15 00:07:09 +00:00
|
|
|
surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_pointer,
|
2020-02-15 00:07:09 +00:00
|
|
|
message->base.time,
|
|
|
|
message->pointer.state,
|
|
|
|
message->pointer.win_x,
|
|
|
|
message->pointer.win_y,
|
|
|
|
message->crossing.mode,
|
|
|
|
GDK_NOTIFY_ANCESTOR);
|
2017-12-05 13:38:57 +00:00
|
|
|
|
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2011-03-11 20:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_POINTER_MOVE:
|
2011-04-15 14:31:56 +00:00
|
|
|
if (_gdk_broadway_moveresize_handle_event (display, message))
|
|
|
|
break;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
|
|
|
if (surface)
|
2010-11-25 11:33:07 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_motion_event_new (surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_pointer,
|
2020-02-15 00:07:09 +00:00
|
|
|
NULL,
|
|
|
|
message->base.time,
|
|
|
|
message->pointer.state,
|
|
|
|
message->pointer.win_x,
|
|
|
|
message->pointer.win_y,
|
|
|
|
NULL);
|
2017-12-05 13:38:57 +00:00
|
|
|
|
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2010-11-25 11:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_BUTTON_PRESS:
|
|
|
|
case BROADWAY_EVENT_BUTTON_RELEASE:
|
2019-03-29 10:44:46 +00:00
|
|
|
if (message->base.type != BROADWAY_EVENT_BUTTON_PRESS &&
|
2017-12-05 13:38:57 +00:00
|
|
|
_gdk_broadway_moveresize_handle_event (display, message))
|
2011-04-15 14:31:56 +00:00
|
|
|
break;
|
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
|
|
|
if (surface)
|
2010-11-25 11:33:07 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_button_event_new (message->base.type == BROADWAY_EVENT_BUTTON_PRESS
|
2020-02-15 00:07:09 +00:00
|
|
|
? GDK_BUTTON_PRESS
|
|
|
|
: GDK_BUTTON_RELEASE,
|
|
|
|
surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_pointer,
|
2020-02-15 00:07:09 +00:00
|
|
|
NULL,
|
|
|
|
message->base.time,
|
|
|
|
message->pointer.state,
|
|
|
|
message->button.button,
|
|
|
|
message->pointer.win_x,
|
|
|
|
message->pointer.win_y,
|
|
|
|
NULL);
|
2017-12-05 13:38:57 +00:00
|
|
|
|
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2010-11-25 11:33:07 +00:00
|
|
|
}
|
|
|
|
|
2010-11-25 20:57:31 +00:00
|
|
|
break;
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_SCROLL:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_surface_id));
|
|
|
|
if (surface)
|
2010-11-25 20:57:31 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_scroll_event_new_discrete (surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_pointer,
|
2020-02-15 00:07:09 +00:00
|
|
|
NULL,
|
|
|
|
message->base.time,
|
2020-10-31 22:21:04 +00:00
|
|
|
message->pointer.state,
|
2020-02-15 00:07:09 +00:00
|
|
|
message->scroll.dir == 0
|
|
|
|
? GDK_SCROLL_UP
|
|
|
|
: GDK_SCROLL_DOWN,
|
|
|
|
FALSE);
|
2020-05-16 16:27:22 +00:00
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2010-11-25 20:57:31 +00:00
|
|
|
}
|
|
|
|
|
2013-11-12 15:11:15 +00:00
|
|
|
break;
|
|
|
|
case BROADWAY_EVENT_TOUCH:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->touch.event_surface_id));
|
|
|
|
if (surface)
|
2013-11-12 15:11:15 +00:00
|
|
|
{
|
|
|
|
GdkEventType event_type = 0;
|
2020-02-15 00:07:09 +00:00
|
|
|
GdkModifierType state;
|
2013-11-12 15:11:15 +00:00
|
|
|
|
|
|
|
switch (message->touch.touch_type) {
|
|
|
|
case 0:
|
|
|
|
event_type = GDK_TOUCH_BEGIN;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
event_type = GDK_TOUCH_UPDATE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
event_type = GDK_TOUCH_END;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_printerr ("_gdk_broadway_events_got_input - Unknown touch type %d\n", message->touch.touch_type);
|
|
|
|
}
|
|
|
|
|
2013-11-12 15:44:30 +00:00
|
|
|
if (event_type != GDK_TOUCH_BEGIN &&
|
2013-11-14 10:03:10 +00:00
|
|
|
message->touch.is_emulated && _gdk_broadway_moveresize_handle_event (display, message))
|
2013-11-12 15:44:30 +00:00
|
|
|
break;
|
|
|
|
|
2020-02-15 00:07:09 +00:00
|
|
|
state = message->touch.state;
|
2013-11-12 15:11:15 +00:00
|
|
|
if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE)
|
2020-02-15 00:07:09 +00:00
|
|
|
state |= GDK_BUTTON1_MASK;
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touch_event_new (event_type,
|
2020-02-15 00:07:09 +00:00
|
|
|
GUINT_TO_POINTER (message->touch.sequence_id),
|
|
|
|
surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_pointer,
|
2020-02-15 00:07:09 +00:00
|
|
|
message->base.time,
|
|
|
|
state,
|
|
|
|
message->touch.win_x,
|
|
|
|
message->touch.win_y,
|
|
|
|
NULL,
|
|
|
|
message->touch.is_emulated);
|
2013-11-12 15:11:15 +00:00
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2013-11-12 15:11:15 +00:00
|
|
|
}
|
|
|
|
|
2010-11-25 20:57:31 +00:00
|
|
|
break;
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_KEY_PRESS:
|
|
|
|
case BROADWAY_EVENT_KEY_RELEASE:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht,
|
2017-12-05 13:38:57 +00:00
|
|
|
GINT_TO_POINTER (message->key.surface_id));
|
2018-03-21 08:17:50 +00:00
|
|
|
if (surface)
|
2010-11-25 20:57:31 +00:00
|
|
|
{
|
2020-04-05 18:40:55 +00:00
|
|
|
GdkTranslatedKey translated;
|
|
|
|
translated.keyval = message->key.key;
|
|
|
|
translated.consumed = 0;
|
|
|
|
translated.layout = 0;
|
|
|
|
translated.level = 0;
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_key_event_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
|
2020-02-15 00:07:09 +00:00
|
|
|
? GDK_KEY_PRESS
|
|
|
|
: GDK_KEY_RELEASE,
|
|
|
|
surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_keyboard,
|
2020-02-15 00:07:09 +00:00
|
|
|
message->base.time,
|
|
|
|
message->key.key,
|
2020-04-05 18:40:55 +00:00
|
|
|
message->key.state,
|
|
|
|
FALSE,
|
|
|
|
&translated,
|
|
|
|
&translated);
|
2010-11-25 20:57:31 +00:00
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2010-11-25 20:57:31 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 13:56:31 +00:00
|
|
|
break;
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_GRAB_NOTIFY:
|
|
|
|
case BROADWAY_EVENT_UNGRAB_NOTIFY:
|
2020-05-16 16:27:22 +00:00
|
|
|
_gdk_display_device_grab_update (display,
|
|
|
|
display_broadway->core_pointer,
|
|
|
|
message->base.serial);
|
2010-11-25 11:33:07 +00:00
|
|
|
break;
|
2011-04-06 14:39:07 +00:00
|
|
|
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_CONFIGURE_NOTIFY:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->configure_notify.id));
|
|
|
|
if (surface)
|
2011-04-06 14:39:07 +00:00
|
|
|
{
|
2020-12-02 14:29:54 +00:00
|
|
|
gdk_surface_request_layout (surface);
|
2017-12-05 13:38:57 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (surface->resize_count >= 1)
|
2017-12-05 13:38:57 +00:00
|
|
|
{
|
2018-03-21 08:17:50 +00:00
|
|
|
surface->resize_count -= 1;
|
2017-12-05 13:38:57 +00:00
|
|
|
|
2018-03-21 08:17:50 +00:00
|
|
|
if (surface->resize_count == 0)
|
|
|
|
_gdk_broadway_moveresize_configure_done (display, surface);
|
2017-12-05 13:38:57 +00:00
|
|
|
}
|
2011-04-06 14:39:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-11-23 09:22:23 +00:00
|
|
|
case BROADWAY_EVENT_ROUNDTRIP_NOTIFY:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->roundtrip_notify.id));
|
|
|
|
if (surface)
|
|
|
|
_gdk_broadway_roundtrip_notify (surface, message->roundtrip_notify.tag, message->roundtrip_notify.local);
|
2017-11-23 09:22:23 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-20 12:40:31 +00:00
|
|
|
case BROADWAY_EVENT_SCREEN_SIZE_CHANGED:
|
2017-11-01 18:46:26 +00:00
|
|
|
_gdk_broadway_display_size_changed (display, &message->screen_resize_notify);
|
2011-04-07 13:10:39 +00:00
|
|
|
break;
|
|
|
|
|
2013-11-12 11:03:50 +00:00
|
|
|
case BROADWAY_EVENT_FOCUS:
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.old_id));
|
|
|
|
if (surface)
|
2013-11-13 11:10:29 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_focus_event_new (surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_keyboard,
|
2020-02-15 00:07:09 +00:00
|
|
|
FALSE);
|
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2013-11-13 11:10:29 +00:00
|
|
|
}
|
2018-03-21 08:17:50 +00:00
|
|
|
surface = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->focus.new_id));
|
|
|
|
if (surface)
|
2013-11-12 11:03:50 +00:00
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_focus_event_new (surface,
|
2020-05-16 16:27:22 +00:00
|
|
|
display_broadway->core_keyboard,
|
2020-02-15 00:07:09 +00:00
|
|
|
TRUE);
|
|
|
|
|
2017-12-05 13:38:57 +00:00
|
|
|
node = _gdk_event_queue_append (display, event);
|
|
|
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
2013-11-12 11:03:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-11-25 11:33:07 +00:00
|
|
|
default:
|
2012-12-19 11:37:02 +00:00
|
|
|
g_printerr ("_gdk_broadway_events_got_input - Unknown input command %c\n", message->base.type);
|
2010-11-25 11:33:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-12 12:18:58 +00:00
|
|
|
void
|
2011-01-06 22:36:44 +00:00
|
|
|
_gdk_broadway_display_queue_events (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_event_source_dispatch (GSource *source,
|
|
|
|
GSourceFunc callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = ((GdkEventSource*) source)->display;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
event = gdk_display_get_event (display);
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
{
|
2010-12-04 21:28:31 +00:00
|
|
|
_gdk_event_emit (event);
|
2010-11-12 12:18:58 +00:00
|
|
|
|
2020-02-15 20:07:24 +00:00
|
|
|
gdk_event_unref (event);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_event_source_finalize (GSource *source)
|
|
|
|
{
|
|
|
|
GdkEventSource *event_source = (GdkEventSource *)source;
|
|
|
|
|
2010-11-15 19:08:18 +00:00
|
|
|
event_sources = g_list_remove (event_sources, event_source);
|
2010-11-12 12:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GSource *
|
2011-01-06 22:36:44 +00:00
|
|
|
_gdk_broadway_event_source_new (GdkDisplay *display)
|
2010-11-12 12:18:58 +00:00
|
|
|
{
|
|
|
|
GSource *source;
|
|
|
|
GdkEventSource *event_source;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
source = g_source_new (&event_funcs, sizeof (GdkEventSource));
|
2010-11-16 11:33:02 +00:00
|
|
|
name = g_strdup_printf ("GDK Broadway Event source (%s)",
|
2017-12-05 13:38:57 +00:00
|
|
|
gdk_display_get_name (display));
|
2010-11-12 12:18:58 +00:00
|
|
|
g_source_set_name (source, name);
|
|
|
|
g_free (name);
|
|
|
|
event_source = (GdkEventSource *) source;
|
|
|
|
event_source->display = display;
|
|
|
|
|
|
|
|
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
|
|
|
|
g_source_set_can_recurse (source, TRUE);
|
|
|
|
g_source_attach (source, NULL);
|
|
|
|
|
|
|
|
event_sources = g_list_prepend (event_sources, source);
|
|
|
|
|
|
|
|
return source;
|
|
|
|
}
|