summaryrefslogtreecommitdiff
path: root/gdk/win32/gdkevents-win32.c
diff options
context:
space:
mode:
authorРуслан Ижбулатов <lrn1986@gmail.com>2018-03-24 16:39:13 +0000
committerРуслан Ижбулатов <lrn1986@gmail.com>2018-03-29 17:43:55 +0000
commitef01e6ee52aa3b0f4776bdeb524d0967a0f3dd0f (patch)
tree7e2c3eb562ec4517bd986bc943541765b5ff547b /gdk/win32/gdkevents-win32.c
parent38b4c8d1fa868441fc1ec83d9242b42c26c9ca19 (diff)
downloadgtk+-ef01e6ee52aa3b0f4776bdeb524d0967a0f3dd0f.tar.gz
GDK W32: Adapt to event filter removal
Add a new W32 backend-specific message filtering mechanism. Works roughly the same way old event filtering did, but without events (events are GDK/X11 concept that never really made sense on W32), so there's no functionality for 'altering' events being emitted. If an event needs to be emitted in response to a message do it yourself. Implemented like this, it should give better performance than if we were to use GLib signals for this, since W32 sends a LOT of messages (unlike X11, which doesn't send events as often) all the time, and invoking the signal machinery on *each* message would probably be bad. https://bugzilla.gnome.org/show_bug.cgi?id=773299
Diffstat (limited to 'gdk/win32/gdkevents-win32.c')
-rw-r--r--gdk/win32/gdkevents-win32.c76
1 files changed, 17 insertions, 59 deletions
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index dab4d7542f..bb422d91a4 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -1016,43 +1016,30 @@ fill_key_event_string (GdkEvent *event)
}
}
-static GdkFilterReturn
-apply_event_filters (GdkSurface *window,
- MSG *msg,
- GList **filters)
+static GdkWin32MessageFilterReturn
+apply_message_filters (GdkDisplay *display,
+ MSG *msg,
+ gint *ret_valp,
+ GList **filters)
{
- GdkFilterReturn result = GDK_FILTER_CONTINUE;
- GdkEvent *event;
- GdkDisplay *display;
+ GdkWin32MessageFilterReturn result = GDK_WIN32_MESSAGE_FILTER_CONTINUE;
GList *node;
GList *tmp_list;
- event = gdk_event_new (GDK_NOTHING);
- event->any.surface = g_object_ref (window);
- event->any.flags |= GDK_EVENT_PENDING;
-
- display = gdk_display_get_default ();
-
- /* I think GdkFilterFunc semantics require the passed-in event
- * to already be in the queue. The filter func can generate
- * more events and append them after it if it likes.
- */
- node = _gdk_event_queue_append (display, event);
-
tmp_list = *filters;
while (tmp_list)
{
- GdkEventFilter *filter = (GdkEventFilter *) tmp_list->data;
+ GdkWin32MessageFilter *filter = (GdkWin32MessageFilter *) tmp_list->data;
GList *node;
- if ((filter->flags & GDK_EVENT_FILTER_REMOVED) != 0)
+ if (filter->removed)
{
tmp_list = tmp_list->next;
continue;
}
filter->ref_count++;
- result = filter->function (msg, event, filter->data);
+ result = filter->function (display, msg, ret_valp, filter->data);
/* get the next node after running the function since the
function may add or remove a next node */
@@ -1067,23 +1054,10 @@ apply_event_filters (GdkSurface *window,
g_free (filter);
}
- if (result != GDK_FILTER_CONTINUE)
+ if (result != GDK_WIN32_MESSAGE_FILTER_CONTINUE)
break;
}
- if (result == GDK_FILTER_CONTINUE || result == GDK_FILTER_REMOVE)
- {
- _gdk_event_queue_remove_link (display, node);
- g_list_free_1 (node);
- gdk_event_free (event);
- }
- else /* GDK_FILTER_TRANSLATE */
- {
- event->any.flags &= ~GDK_EVENT_PENDING;
- fixup_event (event);
- GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
- }
-
return result;
}
@@ -2290,22 +2264,19 @@ gdk_event_translate (MSG *msg,
STGMEDIUM *property_change_data;
display = gdk_display_get_default ();
- window = gdk_win32_handle_table_lookup (msg->hwnd);
+ win32_display = GDK_WIN32_DISPLAY (display);
- if (_gdk_default_filters)
+ if (win32_display->filters)
{
- /* Apply global filters */
+ /* Apply display filters */
+ GdkWin32MessageFilterReturn result = apply_message_filters (win32_display, msg, ret_valp, &win32_display->filters);
- GdkFilterReturn result = apply_event_filters (window, msg, &_gdk_default_filters);
-
- /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
- * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
- * we return TRUE, and DefWindowProcW() will not be called.
- */
- if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
+ if (result == GDK_WIN32_MESSAGE_FILTER_REMOVE)
return TRUE;
}
+ window = gdk_win32_handle_table_lookup (msg->hwnd);
+
if (window == NULL)
{
/* XXX Handle WM_QUIT here ? */
@@ -2342,19 +2313,6 @@ gdk_event_translate (MSG *msg,
*/
#define return GOTO_DONE_INSTEAD
- if (!GDK_SURFACE_DESTROYED (window) && window->filters)
- {
- /* Apply per-window filters */
-
- GdkFilterReturn result = apply_event_filters (window, msg, &window->filters);
-
- if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
- {
- return_val = TRUE;
- goto done;
- }
- }
-
if (msg->message == aerosnap_message)
_gdk_win32_surface_handle_aerosnap (gdk_surface_get_toplevel (window),
(GdkWin32AeroSnapCombo) msg->wParam);