diff --git a/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch b/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch index 42e1685c..a97e0856 100644 --- a/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch +++ b/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch @@ -1,6 +1,6 @@ --- a/cpp_src/widgets_bridge.cpp +++ b/cpp_src/widgets_bridge.cpp -@@ -0,0 +1,989 @@ +@@ -0,0 +1,1009 @@ +// widgets_bridge.cpp — alkane-toolkit extension to wx-rs +// Adds the widget/event surface the toolkit UI needs on top of the upstream +// render-callback bridge (which is kept untouched). @@ -36,12 +36,21 @@ +#include +#include +#include ++#ifdef __WXGTK__ ++// For native GtkTreeView rubber-band (click-drag) selection, which wx does not ++// enable and which cannot be done via wx mouse events on GTK (the native widget ++// grabs the pointer during a drag). Guarded so non-GTK builds are unaffected. ++#include ++#endif + +typedef void (*WxWidgetEventFn)(int kind, long p1, long p2); +static WxWidgetEventFn g_widget_event = nullptr; + -+// Anchor row per data-view control for rubber-band (click-drag) range select. ++#ifndef __WXGTK__ ++// Anchor row per data-view control for the wx-mouse-event rubber-band fallback ++// (non-GTK platforms; GTK uses native GtkTreeView rubber-banding instead). +static std::map g_drag_anchor; ++#endif + +// Event kinds (must match Rust WxEventKind in src/widgets.rs) +enum WxWidgetEventKind { @@ -490,10 +499,20 @@ + dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) { + if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0); + }); -+ // Rubber-band (click-drag) range selection: wxDataViewCtrl has none natively -+ // (only ctrl/shift-click), so track it here. LEFT_DOWN records the anchor row -+ // (and lets the native handler select it); dragging with the button down -+ // extends the selection to the row under the cursor. ++ // Rubber-band (click-drag) range selection. wxDataViewCtrl has none natively. ++#ifdef __WXGTK__ ++ // On GTK the control wraps a GtkTreeView, which supports native rubber-band ++ // selection -- just not enabled by wx. Enable it directly. (wx delivers no ++ // MOTION events during the native drag, so the mouse-event fallback below is ++ // inapplicable on GTK.) ++ { ++ GtkWidget* tv = dv->GtkGetTreeView(); ++ if (tv) gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE); ++ } ++#else ++ // Non-GTK fallback: track a drag anchor and extend the selection to the row ++ // under the cursor. LEFT_DOWN records the anchor (and lets the native handler ++ // select it); dragging with the button down selects the inclusive range. + dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) { + wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject(); + if (!dv) { e.Skip(); return; } @@ -534,6 +553,7 @@ + if (dv) g_drag_anchor.erase(dv); + e.Skip(); + }); ++#endif + // Row activation (double-click / Enter): report the row + column so the app + // can, e.g., open the miner's IP in a browser. + dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) { diff --git a/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp b/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp index 26a341e1..7cc6daa0 100644 --- a/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp +++ b/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp @@ -33,12 +33,21 @@ #include #include #include +#ifdef __WXGTK__ +// For native GtkTreeView rubber-band (click-drag) selection, which wx does not +// enable and which cannot be done via wx mouse events on GTK (the native widget +// grabs the pointer during a drag). Guarded so non-GTK builds are unaffected. +#include +#endif typedef void (*WxWidgetEventFn)(int kind, long p1, long p2); static WxWidgetEventFn g_widget_event = nullptr; -// Anchor row per data-view control for rubber-band (click-drag) range select. +#ifndef __WXGTK__ +// Anchor row per data-view control for the wx-mouse-event rubber-band fallback +// (non-GTK platforms; GTK uses native GtkTreeView rubber-banding instead). static std::map g_drag_anchor; +#endif // Event kinds (must match Rust WxEventKind in src/widgets.rs) enum WxWidgetEventKind { @@ -487,10 +496,20 @@ void* wxbr_dvlc(void* parent) { dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) { if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0); }); - // Rubber-band (click-drag) range selection: wxDataViewCtrl has none natively - // (only ctrl/shift-click), so track it here. LEFT_DOWN records the anchor row - // (and lets the native handler select it); dragging with the button down - // extends the selection to the row under the cursor. + // Rubber-band (click-drag) range selection. wxDataViewCtrl has none natively. +#ifdef __WXGTK__ + // On GTK the control wraps a GtkTreeView, which supports native rubber-band + // selection -- just not enabled by wx. Enable it directly. (wx delivers no + // MOTION events during the native drag, so the mouse-event fallback below is + // inapplicable on GTK.) + { + GtkWidget* tv = dv->GtkGetTreeView(); + if (tv) gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE); + } +#else + // Non-GTK fallback: track a drag anchor and extend the selection to the row + // under the cursor. LEFT_DOWN records the anchor (and lets the native handler + // select it); dragging with the button down selects the inclusive range. dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) { wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject(); if (!dv) { e.Skip(); return; } @@ -531,6 +550,7 @@ void* wxbr_dvlc(void* parent) { if (dv) g_drag_anchor.erase(dv); e.Skip(); }); +#endif // Row activation (double-click / Enter): report the row + column so the app // can, e.g., open the miner's IP in a browser. dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {