--- libs/gcu/glview.h.bak 2014-08-06 16:55:11.955767991 +0200 +++ libs/gcu/glview.h 2014-08-12 06:25:44.025863255 +0200 @@ -134,11 +134,11 @@ A Matrix reprenting the scene spatial or /*! A matrix */ - double m_Lastx; + gdouble m_Lastx; /*! A Matrix */ - double m_Lasty; + gdouble m_Lasty; /*! The view height. */ --- libs/gcugtk/glview.h.bak 2014-08-12 08:13:34.694217801 +0200 +++ libs/gcugtk/glview.h 2014-08-12 20:17:53.225123998 +0200 @@ -102,6 +102,7 @@ The associated widget. private: bool m_bInit; + bool m_DragFlag = false; GdkWindow *m_Window; GLXContext m_Context; XVisualInfo *m_VisualInfo; --- libs/gcugtk/glview.cc.bak 2014-08-12 08:03:46.698700904 +0200 +++ libs/gcugtk/glview.cc 2014-08-12 20:20:52.703145161 +0200 @@ -45,6 +45,7 @@ public: static bool OnDraw (GLView* View, cairo_t *cr); static bool OnMotion (G_GNUC_UNUSED GtkWidget *widget, GdkEventMotion *event, GLView* View); static bool OnPressed (G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event, GLView* View); + static bool OnReleased (G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event, GLView* View); }; // Callbacks @@ -113,37 +114,36 @@ bool GLViewPrivate::OnDraw (GLView* View bool GLViewPrivate::OnMotion (GtkWidget *, GdkEventMotion *event, GLView* View) { - gint x, y; - GdkModifierType state; - - if (event->is_hint) - gdk_window_get_device_position (event->window, event->device, &x, &y, &state); - else { - x = (gint) event->x; - y = (gint) event->y; - state = (GdkModifierType) event->state; - } - if (state & GDK_BUTTON1_MASK) { - if ((x == View->m_Lastx) && (y == View->m_Lasty)) - return false; + if (View->m_DragFlag) { View->m_Doc->SetDirty (true); - View->Rotate (x - View->m_Lastx, y - View->m_Lasty); - View->m_Lastx = x; - View->m_Lasty = y; + View->Rotate (event->x - View->m_Lastx, event->y - View->m_Lasty); + View->m_Lastx = event->x; + View->m_Lasty = event->y; gtk_widget_queue_draw_area (View->m_Widget, 0, 0, View->m_WindowWidth, View->m_WindowHeight); + gdk_event_request_motions(event); /* handles is_hint events */ } return true; } bool GLViewPrivate::OnPressed (GtkWidget *, GdkEventButton *event, GLView* View) { - if (event->button == 1) { - // beginning of drag, reset mouse position - View->m_Lastx = event->x; - View->m_Lasty = event->y; - return true; - } - return false; + if (event->button == 1) { + // beginning of drag, reset mouse position + View->m_Lastx = event->x; + View->m_Lasty = event->y; + View->m_DragFlag = true; + return true; + } + return false; +} + +bool GLViewPrivate::OnReleased (GtkWidget *, GdkEventButton *event, GLView* View) +{ + if (event->button == 1) { + View->m_DragFlag = false; + return true; + } + return false; } GLView::GLView (gcu::GLDocument* pDoc) throw (std::runtime_error): gcu::GLView (pDoc), Printable () @@ -184,6 +184,9 @@ GLView::GLView (gcu::GLDocument* pDoc) t // When a mouse button is pressed g_signal_connect (G_OBJECT (m_Widget), "button_press_event", G_CALLBACK (GLViewPrivate::OnPressed), this); + // When a mouse button is released + g_signal_connect (G_OBJECT (m_Widget), "button_release_event", + G_CALLBACK (GLViewPrivate::OnReleased), this); gtk_widget_show (GTK_WIDGET (m_Widget)); SetHasBackground (true);