From 5e4bbd0f45e8f4c742658837d288dab81566996a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 15 May 2012 10:04:11 +0000 Subject: [PATCH] Fix pasting large amounts of text in wxGTK. We need to process GDK_PROPERTY_NOTIFY events when yielding for wxEVT_CATEGORY_CLIPBOARD, otherwise we never receive large selections. As GDK_PROPERTY_NOTIFY can be also used for non-clipboard stuff, exceptionally assign 2 categories to it and process it in either case. Closes #14284. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/gtk/evtloop.cpp | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 709dc58866..0a83eb5c63 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -556,6 +556,7 @@ GTK: - Implement wxDirDialog::Create() and wxFileDialog::Create() (vinayakgarg). - Fix const methods display in assert dialog (vinayakgarg). - Implement native tab art for wxAUI (Jens Lody and Teodor Petrov). +- Fix pasting large amounts of text (Bradley Hawkins). MSW: diff --git a/src/gtk/evtloop.cpp b/src/gtk/evtloop.cpp index a35be35ab0..8f6426f428 100644 --- a/src/gtk/evtloop.cpp +++ b/src/gtk/evtloop.cpp @@ -229,7 +229,11 @@ static void wxgtk_main_do_event(GdkEvent* event, void* data) // new event types (since new event types are always added in GDK with non // conflicting values for ABI compatibility). - wxEventCategory cat = wxEVT_CATEGORY_UNKNOWN; + // Some events (currently only a single one) may be used for more than one + // category, so we need 2 variables. The second one will remain "unknown" + // in most cases. + wxEventCategory cat = wxEVT_CATEGORY_UNKNOWN, + cat2 = wxEVT_CATEGORY_UNKNOWN; switch (event->type) { case GDK_SELECTION_REQUEST: @@ -252,6 +256,14 @@ static void wxgtk_main_do_event(GdkEvent* event, void* data) cat = wxEVT_CATEGORY_USER_INPUT; break; + case GDK_PROPERTY_NOTIFY: + // This one is special: it can be used for UI purposes but also for + // clipboard operations, so allow it in both cases (we probably could + // examine the event itself to distinguish between the two cases but + // this would be unnecessarily complicated). + cat2 = wxEVT_CATEGORY_CLIPBOARD; + // Fall through. + case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: @@ -259,7 +271,6 @@ static void wxgtk_main_do_event(GdkEvent* event, void* data) case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: case GDK_VISIBILITY_NOTIFY: - case GDK_PROPERTY_NOTIFY: case GDK_FOCUS_CHANGE: case GDK_CONFIGURE: @@ -296,11 +307,19 @@ static void wxgtk_main_do_event(GdkEvent* event, void* data) wxGUIEventLoop* evtloop = static_cast(data); // is this event allowed now? - if (evtloop->IsEventAllowedInsideYield(cat)) - gtk_main_do_event(event); // process it now + if (evtloop->IsEventAllowedInsideYield(cat) || + (cat2 != wxEVT_CATEGORY_UNKNOWN && + evtloop->IsEventAllowedInsideYield(cat2))) + { + // process it now + gtk_main_do_event(event); + } else if (event->type != GDK_NOTHING) + { + // process it later (but make a copy; the caller will free the event + // pointer) evtloop->StoreGdkEventForLaterProcessing(gdk_event_copy(event)); - // process it later (but make a copy; the caller will free the event pointer) + } } }