Permalink
Browse files

Fix obsolete code in sheet.c (obsolescence w.r.t. gtk-3.4)

  • Loading branch information...
1 parent 2c742cb commit 5461a79ce6a2df259c9b1b71ba7ffb96578e57c3 Marc Lorber committed May 17, 2012
Showing with 33 additions and 8 deletions.
  1. +3 −0 ChangeLog
  2. +30 −8 src/sheet/sheet.c
View
@@ -1,3 +1,6 @@
+Thu, 17 May 2012 Marc Lorber <Lorber.Marc@wanadoo.fr>
+ * Replacement of obsolete code in sheet.c: gtk_widget_get_pointer.
+ The creplaced code is based on what has been implemented in evince.
Sun, 13 May 2012 Marc Lorber <Lorber.Marc@wanadoo.fr>
* Modification of part-browser.c to fix a warning while quitting
oregano
View
@@ -208,14 +208,36 @@ sheet_finalize (GObject *object)
void
sheet_get_pointer (Sheet *sheet, gdouble *x, gdouble *y)
{
- GtkWidget *widget;
- GtkAdjustment *hadjustment;
- GtkAdjustment *vadjustment;
- gdouble value, x1, y1;
- gint _x, _y;
-
- gdk_window_get_device_position (GDK_WINDOW (sheet), GDK_SOURCE_MOUSE,
- &_x, &_y, NULL);
+ GtkWidget *widget;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
+ gdouble value, x1, y1;
+ gint _x, _y;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device_pointer;
+ GdkRectangle allocation;
+
+
+ // gtk_widget_get_pointer (GTK_WIDGET (sheet), &_x, &_y);
+ // replaced by a code copied from evince
+
+ if (!gtk_widget_get_realized (GTK_WIDGET (sheet)))
+ return;
+
+ device_manager = gdk_display_get_device_manager (
+ gtk_widget_get_display (GTK_WIDGET (sheet)));
+ device_pointer = gdk_device_manager_get_client_pointer (device_manager);
+ gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (sheet)),
+ device_pointer,
+ &_x, &_y, NULL);
+ if (!gtk_widget_get_has_window (GTK_WIDGET (sheet)))
+ return;
+
+ gtk_widget_get_allocation (GTK_WIDGET (sheet), &allocation);
+
+ _x -= allocation.x;
+ _y -= allocation.y;
+
x1 = (gdouble) _x;
y1 = (gdouble) _y;

0 comments on commit 5461a79

Please sign in to comment.