[glom] CanvasItemMovable: Create the drag cursor for the specific display.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] CanvasItemMovable: Create the drag cursor for the specific display.
- Date: Tue, 2 Dec 2014 20:55:04 +0000 (UTC)
commit 498cb60048156cdb88fd52401b3863b20960f95d
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Dec 2 21:53:56 2014 +0100
CanvasItemMovable: Create the drag cursor for the specific display.
This avoids using the deprecated Gdk::Cursor constructor that
doesn't take a Gdk::Display.
glom/utility_widgets/canvas/canvas_item_movable.cc | 30 ++++++++++++-------
glom/utility_widgets/canvas/canvas_item_movable.h | 5 +--
2 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/glom/utility_widgets/canvas/canvas_item_movable.cc
b/glom/utility_widgets/canvas/canvas_item_movable.cc
index 1acb4f0..030c8c1 100644
--- a/glom/utility_widgets/canvas/canvas_item_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_item_movable.cc
@@ -32,6 +32,17 @@
#include <gdkmm/cursor.h>
#include <iostream>
+namespace {
+
+static Glib::RefPtr<Gdk::Cursor> create_drag_cursor(GdkEventAny* event, Gdk::CursorType cursor_type)
+{
+ Glib::RefPtr<Gdk::Window> window = Glib::wrap(event->window, true);
+ Glib::RefPtr<Gdk::Display> display = window->get_display();
+ return Gdk::Cursor::create(display, cursor_type);
+}
+
+} //anonymous namespace
+
namespace Glom
{
@@ -61,7 +72,6 @@ CanvasItemMovable::~CanvasItemMovable()
{
}
-
bool CanvasItemMovable::on_button_press_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventButton*
event)
{
//std::cout << G_STRFUNC << ": DEBUG" << std::endl;
@@ -87,7 +97,10 @@ bool CanvasItemMovable::on_button_press_event(const Glib::RefPtr<Goocanvas::Item
Goocanvas::Canvas* canvas = get_parent_canvas_widget();
if(canvas)
{
- canvas->pointer_grab(item, Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_RELEASE_MASK, m_drag_cursor,
event->time);
+ canvas->pointer_grab(item,
+ Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_RELEASE_MASK,
+ create_drag_cursor((GdkEventAny*)event, m_drag_cursor_type),
+ event->time);
}
m_dragging = true;
@@ -234,9 +247,9 @@ bool CanvasItemMovable::on_button_release_event(const Glib::RefPtr<Goocanvas::It
return true;
}
-bool CanvasItemMovable::on_enter_notify_event(const Glib::RefPtr<Goocanvas::Item>& /* target */,
GdkEventCrossing* /* event */)
+bool CanvasItemMovable::on_enter_notify_event(const Glib::RefPtr<Goocanvas::Item>& /* target */,
GdkEventCrossing* event)
{
- set_cursor(m_drag_cursor);
+ set_cursor(create_drag_cursor((GdkEventAny*)event, m_drag_cursor_type));
return false; //We didn't fully handle this event - let other signal handlers (even for other items)
handle it too.
}
@@ -264,14 +277,9 @@ CanvasItemMovable::type_signal_selected CanvasItemMovable::signal_selected()
return m_signal_selected;
}
-void CanvasItemMovable::set_drag_cursor(const Glib::RefPtr<Gdk::Cursor>& cursor)
-{
- m_drag_cursor = cursor;
-}
-
-void CanvasItemMovable::set_drag_cursor(Gdk::CursorType cursor)
+void CanvasItemMovable::set_drag_cursor(Gdk::CursorType cursor_type)
{
- m_drag_cursor = Gdk::Cursor::create(cursor);
+ m_drag_cursor_type = cursor_type;
}
void CanvasItemMovable::set_cursor(const Glib::RefPtr<Gdk::Cursor>& cursor)
diff --git a/glom/utility_widgets/canvas/canvas_item_movable.h
b/glom/utility_widgets/canvas/canvas_item_movable.h
index beb8d55..5c65cee 100644
--- a/glom/utility_widgets/canvas/canvas_item_movable.h
+++ b/glom/utility_widgets/canvas/canvas_item_movable.h
@@ -57,8 +57,7 @@ public:
*/
virtual void set_width_height(double width, double height) = 0;
- void set_drag_cursor(Gdk::CursorType cursor);
- void set_drag_cursor(const Glib::RefPtr<Gdk::Cursor>& cursor);
+ void set_drag_cursor(Gdk::CursorType cursor_type);
/** For instance,
*
@@ -149,7 +148,7 @@ private:
double m_drag_start_cursor_x, m_drag_start_cursor_y;
double m_drag_start_position_x, m_drag_start_position_y;
double m_drag_latest_position_x, m_drag_latest_position_y; //To discover how much the latest motion_event
has moved the item.
- Glib::RefPtr<Gdk::Cursor> m_drag_cursor;
+ Gdk::CursorType m_drag_cursor_type;
protected:
Glib::RefPtr<const CanvasGroupGrid> m_grid;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]