[gnumeric] GUI: Fix problems with tooltip positions.



commit bff4e086b8e9bb460db771d13d32975f48f9b626
Author: Morten Welinder <terra gnome org>
Date:   Tue Jun 23 13:34:17 2009 -0400

    GUI: Fix problems with tooltip positions.

 ChangeLog         |    9 +++++++++
 NEWS              |    1 +
 src/gui-util.c    |   23 +++++++++++++++++++++++
 src/gui-util.h    |    3 +++
 src/item-bar.c    |   10 +++++-----
 src/item-cursor.c |   13 +++++++------
 src/item-grid.c   |    9 ++++-----
 7 files changed, 52 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fad790d..6d430c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-06-23  Morten Welinder  <terra gnome org>
+
+	* src/item-cursor.c (item_cursor_tip_setlabel,
+	cb_cursor_come_to_rest, item_bar_event): Use
+	gnm_canvas_get_position.
+
+	* src/gui-util.c (gnm_canvas_get_position): New function working
+	around gdk bug.  Fixes #586590.
+
 2009-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/print-info.c (gnm_page_breaks_clean): we can't and don't need
diff --git a/NEWS b/NEWS
index 4cd4c33..df2d6d5 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,7 @@ Morten:
 	* Implement new functions COTH and ACOTH.  [#586170]
 	* Fix tsa crashes.  [#586191, #586427]
 	* Fix IF problems with empties and arrays.  [#586218, #586312]
+	* Fix problem with tooltip positions.  [#586590]
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.8
diff --git a/src/gui-util.c b/src/gui-util.c
index 01e60dc..116bfd9 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -1347,3 +1347,26 @@ gnm_dialog_setup_destroy_handlers (GtkDialog *dialog,
 			  G_CALLBACK (cb_gnm_dialog_setup_destroy_handlers),
 			  dd);
 }
+
+
+void
+gnm_canvas_get_position (FooCanvas *canvas, int *x, int *y, int px, int py)
+{
+	GtkWidget *cw = GTK_WIDGET (canvas);
+	GdkWindow *cbw = GTK_LAYOUT (cw)->bin_window;
+	int wx, wy, ox, oy;
+	double pdx, pdy;
+
+	/*
+	 * Get offsets for the 16-bit X11 system within the 32-bit gdk system.
+	 * I don't think this should be necessary, see bug 586756.
+	 */
+	gdk_window_get_internal_paint_info (cbw, NULL, &ox, &oy);
+
+	gdk_window_get_origin (cbw, &wx, &wy);
+
+	foo_canvas_world_to_window (canvas, px, py, &pdx, &pdy);
+
+	*x = (int)pdx + wx - ox;
+	*y = (int)pdy + wy - oy;
+}
diff --git a/src/gui-util.h b/src/gui-util.h
index eb42025..9e76b9d 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -124,6 +124,9 @@ void gnm_dialog_setup_destroy_handlers (GtkDialog *dialog,
 					WBCGtk *wbcg,
 					GnmDialogDestroyOptions what);
 
+void gnm_canvas_get_position (FooCanvas *canvas, int *x, int *y,
+			      int px, int py);
+
 G_END_DECLS
 
 #endif /* _GNM_GUI_UTIL_H_ */
diff --git a/src/item-bar.c b/src/item-bar.c
index f507df4..4d3b774 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -965,9 +965,11 @@ item_bar_event (FooCanvasItem *item, GdkEvent *e)
 
 			if (ib->tip == NULL) {
 				GtkWidget *cw = GTK_WIDGET (canvas);
-				GdkWindow *cbw = GTK_LAYOUT (canvas)->bin_window;
 				int wx, wy;
-				gdk_window_get_origin (cbw, &wx, &wy);
+
+				gnm_canvas_get_position (canvas, &wx, &wy,
+							 e->button.x,
+							 e->button.y);
 				ib->tip = gnumeric_create_tooltip (cw);
 				colrow_tip_setlabel (ib, is_cols, ib->colrow_resize_size);
 				/* Position above the current point for both
@@ -976,9 +978,7 @@ item_bar_event (FooCanvasItem *item, GdkEvent *e)
 				 * the tip under the cursor which can have odd
 				 * effects on the event stream.  win32 was
 				 * different from X. */
-				gnumeric_position_tooltip (ib->tip,
-							   wx + e->button.x,
-							   wy + e->button.y,
+				gnumeric_position_tooltip (ib->tip, wx, wy,
 							   TRUE);
 				gtk_widget_show_all (gtk_widget_get_toplevel (ib->tip));
 			}
diff --git a/src/item-cursor.c b/src/item-cursor.c
index ba82db0..4e6a7db 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -1062,14 +1062,15 @@ static void
 item_cursor_tip_setlabel (ItemCursor *ic, char const *text)
 {
 	if (ic->tip == NULL) {
-		GtkWidget *cw = GTK_WIDGET (FOO_CANVAS_ITEM (ic)->canvas);
-		GdkWindow *cbw = GTK_LAYOUT (cw)->bin_window;
+		FooCanvas *canvas = FOO_CANVAS_ITEM (ic)->canvas;
+		GtkWidget *cw = GTK_WIDGET (canvas);
 		int wx, wy;
-		gdk_window_get_origin (cbw, &wx, &wy);
+
+		gnm_canvas_get_position (canvas, &wx, &wy,
+					 ic->last_x, ic->last_y);
 		ic->tip = gnumeric_create_tooltip (cw);
-		gnumeric_position_tooltip (ic->tip,
-					   wx + ic->last_x,
-					   wy + ic->last_y, TRUE);
+
+		gnumeric_position_tooltip (ic->tip, wx, wy, TRUE);
 		gtk_widget_show_all (gtk_widget_get_toplevel (ic->tip));
 	}
 
diff --git a/src/item-grid.c b/src/item-grid.c
index e9025e5..8705d1c 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -967,13 +967,12 @@ cb_cursor_come_to_rest (ItemGrid *ig)
 
 		if (ig->tip == NULL && strlen (tiptext) > 0) {
 			GtkWidget *cw = GTK_WIDGET (canvas);
-			GdkWindow *cbw = GTK_LAYOUT (canvas)->bin_window;
 			int wx, wy;
-			gdk_window_get_origin (cbw, &wx, &wy);
+
+			gnm_canvas_get_position (canvas, &wx, &wy,
+						 ig->last_x, ig->last_y);
 			ig->tip = gnumeric_create_tooltip (cw);
-			gnumeric_position_tooltip (ig->tip,
-						   wx + ig->last_x,
-						   wy + ig->last_y, TRUE);
+			gnumeric_position_tooltip (ig->tip, wx, wy, TRUE);
 			gtk_label_set_text (GTK_LABEL (ig->tip), tiptext);
 			gtk_widget_show_all (gtk_widget_get_toplevel (ig->tip));
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]