-static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
-{
- if (!win->HasVMT()) return;
- if (g_blockEventsOnDrag) return;
-
- float diff = win->m_adjust->value - win->m_oldPos;
- if (fabs(diff) < 0.2) return;
-
- wxEventType command = wxEVT_NULL;
-
- float line_step = win->m_adjust->step_increment;
- float page_step = win->m_adjust->page_increment;
-
- if (win->m_isScrolling)
- {
- command = wxEVT_SCROLL_THUMBTRACK;
- }
- else
- {
- if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
- else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
- else command = wxEVT_SCROLL_THUMBTRACK;
- }
-
- int value = (int)(win->m_adjust->value+0.5);
-
- int orient = wxHORIZONTAL;
- if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL;
-
- wxScrollEvent event( command, win->GetId(), value, orient );
- event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( event );
-
+// FIXME: is GtkScrollType really passed to us as 2nd argument?
+
+extern "C" {
+static void gtk_scrollbar_callback( GtkAdjustment *adjust,
+ SCROLLBAR_CBACK_ARG
+ wxScrollBar *win )
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (!win->m_hasVMT) return;
+ if (g_blockEventsOnDrag) return;
+
+ float diff = adjust->value - win->m_oldPos;
+ if (fabs(diff) < sensitivity) return;
+
+ win->m_oldPos = adjust->value;
+
+ wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
+
+ double dvalue = adjust->value;
+ int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
+
+ int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
+
+ // throw a LINEUP / LINEDOWN event if necessary
+ if (g_currentUpDownEvent != wxEVT_NULL)
+ {
+ wxScrollEvent event( g_currentUpDownEvent, win->GetId(), value, orient );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+ }
+
+ // throw other event (wxEVT_SCROLL_THUMBTRACK)
+ wxScrollEvent event( command, win->GetId(), value, orient );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+