rpms/gtk2/F-12 tooltip-positioning.patch, NONE, 1.1 fresh-tooltips.patch, 1.3, 1.4 gtk2.spec, 1.421, 1.422
Matthias Clasen
mclasen at fedoraproject.org
Fri Oct 23 21:25:44 UTC 2009
Author: mclasen
Update of /cvs/pkgs/rpms/gtk2/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv16796
Modified Files:
fresh-tooltips.patch gtk2.spec
Added Files:
tooltip-positioning.patch
Log Message:
More tooltip tweaks
tooltip-positioning.patch:
gtktooltip.c | 147 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 113 insertions(+), 34 deletions(-)
--- NEW FILE tooltip-positioning.patch ---
diff -up gtk+-2.18.3/gtk/gtktooltip.c.positioning gtk+-2.18.3/gtk/gtktooltip.c
--- gtk+-2.18.3/gtk/gtktooltip.c.positioning 2009-10-23 13:12:16.205437913 -0400
+++ gtk+-2.18.3/gtk/gtktooltip.c 2009-10-23 13:52:15.922749329 -0400
@@ -1023,57 +1023,134 @@ gtk_tooltip_position (GtkTooltip *toolti
GtkWidget *new_tooltip_widget)
{
gint x, y;
+ gint wx, wy;
GdkScreen *screen;
+ gint monitor_num;
+ GdkRectangle monitor;
+ GtkRequisition requisition;
+ guint cursor_size;
+
+#define MAX_DISTANCE 32
tooltip->tooltip_widget = new_tooltip_widget;
+ screen = gtk_widget_get_screen (new_tooltip_widget);
+
+ gtk_widget_size_request (GTK_WIDGET (tooltip->current_window), &requisition);
+
+ monitor_num = gdk_screen_get_monitor_at_point (screen,
+ tooltip->last_x,
+ tooltip->last_y);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ gdk_window_get_origin (new_tooltip_widget->window, &wx, &wy);
+ if (GTK_WIDGET_NO_WINDOW (new_tooltip_widget))
+ {
+ wx += new_tooltip_widget->allocation.x;
+ wy += new_tooltip_widget->allocation.y;
+ }
+
/* Position the tooltip */
- /* FIXME: should we swap this when RTL is enabled? */
- if (tooltip->keyboard_mode_enabled)
+
+ cursor_size = gdk_display_get_default_cursor_size (display);
+
+ /* Try below */
+ x = wx + new_tooltip_widget->allocation.width / 2 - requisition.width / 2;
+ y = wy + new_tooltip_widget->allocation.height + 4;
+
+ if (y + requisition.height <= monitor.y + monitor.height)
{
- gdk_window_get_origin (new_tooltip_widget->window, &x, &y);
- if (GTK_WIDGET_NO_WINDOW (new_tooltip_widget))
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
+
+ if (y <= tooltip->last_y + cursor_size + MAX_DISTANCE)
{
- x += new_tooltip_widget->allocation.x;
- y += new_tooltip_widget->allocation.y;
- }
+ if (tooltip->last_x + cursor_size + MAX_DISTANCE < x)
+ x = tooltip->last_x + cursor_size + MAX_DISTANCE;
+ else if (x + requisition.width < tooltip->last_x - MAX_DISTANCE)
+ x = tooltip->last_x - MAX_DISTANCE - requisition.width;
- /* For keyboard mode we position the tooltip below the widget,
- * right of the center of the widget.
- */
- x += new_tooltip_widget->allocation.width / 2;
- y += new_tooltip_widget->allocation.height + 4;
+ goto found;
+ }
+ }
+
+ /* Try above */
+ x = wx + new_tooltip_widget->allocation.width / 2 - requisition.width / 2;
+ y = wy - requisition.height - 4;
+
+ if (y >= monitor.y)
+ {
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
+
+ if (y + requisition.height >= tooltip->last_y - MAX_DISTANCE)
+ {
+ if (tooltip->last_x + cursor_size + MAX_DISTANCE < x)
+ x = tooltip->last_x + cursor_size + MAX_DISTANCE;
+ else if (x + requisition.width < tooltip->last_x - MAX_DISTANCE)
+ x = tooltip->last_x - MAX_DISTANCE - requisition.width;
+
+ goto found;
+ }
}
- else
+
+ /* Try right FIXME: flip on rtl ? */
+ x = wx + new_tooltip_widget->allocation.width + 4;
+ y = wy + new_tooltip_widget->allocation.height / 2 - requisition.height / 2;
+
+ if (x + requisition.width <= monitor.x + monitor.width)
{
- guint cursor_size;
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
- x = tooltip->last_x;
- y = tooltip->last_y;
+ if (x <= tooltip->last_x + cursor_size + MAX_DISTANCE)
+ {
+ if (tooltip->last_y + cursor_size + MAX_DISTANCE < y)
+ y = tooltip->last_y + cursor_size + MAX_DISTANCE;
+ else if (y + requisition.height < tooltip->last_y - MAX_DISTANCE)
+ y = tooltip->last_y - MAX_DISTANCE - requisition.height;
- /* For mouse mode, we position the tooltip right of the cursor,
- * a little below the cursor's center.
- */
- cursor_size = gdk_display_get_default_cursor_size (display);
- x += cursor_size / 2;
- y += cursor_size / 2;
+ goto found;
+ }
}
- screen = gtk_widget_get_screen (new_tooltip_widget);
+ /* Try left FIXME: flip on rtl ? */
+ x = wx - requisition.width - 4;
+ y = wy + new_tooltip_widget->allocation.height / 2 - requisition.height / 2;
- /* Show it */
- if (tooltip->current_window)
+ if (x >= monitor.x)
{
- gint monitor_num;
- GdkRectangle monitor;
- GtkRequisition requisition;
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
- gtk_widget_size_request (GTK_WIDGET (tooltip->current_window),
- &requisition);
+ if (x + requisition.width >= tooltip->last_x - MAX_DISTANCE)
+ {
+ if (tooltip->last_y + cursor_size + MAX_DISTANCE < y)
+ y = tooltip->last_y + cursor_size + MAX_DISTANCE;
+ else if (y + requisition.height < tooltip->last_y - MAX_DISTANCE)
+ y = tooltip->last_y - MAX_DISTANCE - requisition.height;
- monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ goto found;
+ }
+ }
+ /* Fallback */
+ if (tooltip->keyboard_mode_enabled)
+ {
+ x = wx + new_tooltip_widget->allocation.width / 2 - requisition.width / 2;
+ y = wy + new_tooltip_widget->allocation.height + 4;
+ }
+ else
+ {
+ /* At cursor */
+ x = tooltip->last_x + cursor_size * 3 / 4;
+ y = tooltip->last_y + cursor_size * 3 / 4;
+ }
+
+found:
+ /* Show it */
+ if (tooltip->current_window)
+ {
if (x + requisition.width > monitor.x + monitor.width)
x -= x - (monitor.x + monitor.width) + requisition.width;
else if (x < monitor.x)
@@ -1081,7 +1158,9 @@ gtk_tooltip_position (GtkTooltip *toolti
if (y + requisition.height > monitor.y + monitor.height)
y -= y - (monitor.y + monitor.height) + requisition.height;
-
+ else if (y < monitor.y)
+ y = monitor.y;
+
if (!tooltip->keyboard_mode_enabled)
{
/* don't pop up under the pointer */
@@ -1089,7 +1168,7 @@ gtk_tooltip_position (GtkTooltip *toolti
y <= tooltip->last_y && tooltip->last_y < y + requisition.height)
y = tooltip->last_y - requisition.height - 2;
}
-
+
gtk_window_move (GTK_WINDOW (tooltip->current_window), x, y);
gtk_widget_show (GTK_WIDGET (tooltip->current_window));
}
fresh-tooltips.patch:
gtktooltip.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
gtkwidget.c | 8 +
2 files changed, 243 insertions(+), 19 deletions(-)
Index: fresh-tooltips.patch
===================================================================
RCS file: /cvs/pkgs/rpms/gtk2/F-12/fresh-tooltips.patch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -r1.3 -r1.4
--- fresh-tooltips.patch 21 Oct 2009 21:07:22 -0000 1.3
+++ fresh-tooltips.patch 23 Oct 2009 21:25:41 -0000 1.4
@@ -1,6 +1,6 @@
diff -up gtk+-2.18.3/gtk/gtktooltip.c.fresh-tooltips gtk+-2.18.3/gtk/gtktooltip.c
--- gtk+-2.18.3/gtk/gtktooltip.c.fresh-tooltips 2009-10-16 10:35:45.000000000 -0400
-+++ gtk+-2.18.3/gtk/gtktooltip.c 2009-10-21 16:46:25.035809299 -0400
++++ gtk+-2.18.3/gtk/gtktooltip.c 2009-10-23 17:18:46.556129731 -0400
@@ -95,6 +95,7 @@ static void gtk_tooltip_display_cl
GtkTooltip *tooltip);
static void gtk_tooltip_set_last_window (GtkTooltip *tooltip,
@@ -9,7 +9,7 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
G_DEFINE_TYPE (GtkTooltip, gtk_tooltip, G_TYPE_OBJECT);
-@@ -110,8 +111,18 @@ gtk_tooltip_class_init (GtkTooltipClass
+@@ -110,8 +111,25 @@ gtk_tooltip_class_init (GtkTooltipClass
}
static void
@@ -20,6 +20,13 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
+}
+
+static void
++on_realized (GtkWidget *window,
++ GtkTooltip *tooltip)
++{
++ update_shape (tooltip);
++}
++
++static void
gtk_tooltip_init (GtkTooltip *tooltip)
{
+ GdkScreen *screen;
@@ -28,7 +35,7 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
tooltip->timeout_id = 0;
tooltip->browse_mode_timeout_id = 0;
-@@ -127,8 +138,15 @@ gtk_tooltip_init (GtkTooltip *tooltip)
+@@ -127,8 +145,15 @@ gtk_tooltip_init (GtkTooltip *tooltip)
tooltip->last_window = NULL;
tooltip->window = g_object_ref (gtk_window_new (GTK_WINDOW_POPUP));
@@ -44,7 +51,7 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
gtk_widget_set_app_paintable (tooltip->window, TRUE);
gtk_window_set_resizable (GTK_WINDOW (tooltip->window), FALSE);
gtk_widget_set_name (tooltip->window, "gtk-tooltip");
-@@ -145,7 +163,7 @@ gtk_tooltip_init (GtkTooltip *tooltip)
+@@ -145,7 +170,7 @@ gtk_tooltip_init (GtkTooltip *tooltip)
gtk_widget_show (tooltip->alignment);
g_signal_connect_swapped (tooltip->window, "style-set",
@@ -53,17 +60,19 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
g_signal_connect_swapped (tooltip->window, "expose-event",
G_CALLBACK (gtk_tooltip_paint_window), tooltip);
-@@ -162,6 +180,9 @@ gtk_tooltip_init (GtkTooltip *tooltip)
+@@ -162,6 +187,11 @@ gtk_tooltip_init (GtkTooltip *tooltip)
gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->label,
FALSE, FALSE, 0);
+ g_signal_connect (tooltip->window, "composited-changed",
+ G_CALLBACK (on_composited_changed), tooltip);
++ g_signal_connect (tooltip->window, "realize",
++ G_CALLBACK (on_realized), tooltip);
+
tooltip->custom_widget = NULL;
}
-@@ -318,9 +339,9 @@ gtk_tooltip_set_icon_from_stock (GtkTool
+@@ -318,9 +348,9 @@ gtk_tooltip_set_icon_from_stock (GtkTool
* Since: 2.14
*/
void
@@ -76,7 +85,7 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
{
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
-@@ -471,27 +492,184 @@ static void
+@@ -471,27 +501,213 @@ static void
gtk_tooltip_window_style_set (GtkTooltip *tooltip)
{
gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment),
@@ -190,6 +199,15 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
+ GdkBitmap *mask;
+ cairo_t *cr;
+ gint width, height;
++ gboolean new_style;
++
++ gtk_widget_style_get (tooltip->window, "new-tooltip-style", &new_style, NULL);
++
++ if (!new_style)
++ {
++ gtk_widget_shape_combine_mask (tooltip->window, NULL, 0, 0);
++ return;
++ }
+
+ gtk_window_get_size (GTK_WINDOW (tooltip->window), &width, &height);
+
@@ -250,32 +268,52 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
- 0, 0,
- tooltip->window->allocation.width,
- tooltip->window->allocation.height);
-+ cairo_t *context;
-+ cairo_surface_t *surface;
-+ cairo_t *cr;
-+
-+ context = gdk_cairo_create (tooltip->window->window);
-+
-+ cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
-+ surface = cairo_surface_create_similar (cairo_get_target (context),
-+ CAIRO_CONTENT_COLOR_ALPHA,
-+ tooltip->window->allocation.width,
-+ tooltip->window->allocation.height);
-+ cr = cairo_create (surface);
++ gboolean new_style;
+
-+ fill_background (tooltip->window, cr);
++ gtk_widget_style_get (tooltip->window, "new-tooltip-style", &new_style, NULL);
+
-+ cairo_destroy (cr);
-+ cairo_set_source_surface (context, surface, 0, 0);
-+ cairo_paint (context);
-+ cairo_surface_destroy (surface);
-+ cairo_destroy (context);
++ if (new_style)
++ {
++ cairo_t *context;
++ cairo_surface_t *surface;
++ cairo_t *cr;
++
++ context = gdk_cairo_create (tooltip->window->window);
++
++ cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
++ surface = cairo_surface_create_similar (cairo_get_target (context),
++ CAIRO_CONTENT_COLOR_ALPHA,
++ tooltip->window->allocation.width,
++ tooltip->window->allocation.height);
++ cr = cairo_create (surface);
++
++ fill_background (tooltip->window, cr);
++
++ cairo_destroy (cr);
++ cairo_set_source_surface (context, surface, 0, 0);
++ cairo_paint (context);
++ cairo_surface_destroy (surface);
++ cairo_destroy (context);
+
-+ update_shape (tooltip);
++ update_shape (tooltip);
++ }
++ else
++ {
++ gtk_paint_flat_box (tooltip->window->style,
++ tooltip->window->window,
++ GTK_STATE_NORMAL,
++ GTK_SHADOW_OUT,
++ NULL,
++ tooltip->window,
++ "tooltip",
++ 0, 0,
++ tooltip->window->allocation.width,
++ tooltip->window->allocation.height);
++ }
return FALSE;
}
-@@ -631,7 +809,7 @@ find_widget_under_pointer (GdkWindow *wi
+@@ -631,7 +847,7 @@ find_widget_under_pointer (GdkWindow *wi
#ifdef DEBUG_TOOLTIP
g_print ("event window %p (belonging to %p (%s)) (%d, %d)\n",
@@ -284,3 +322,21 @@ diff -up gtk+-2.18.3/gtk/gtktooltip.c.fr
*x, *y);
#endif
+diff -up gtk+-2.18.3/gtk/gtkwidget.c.fresh-tooltips gtk+-2.18.3/gtk/gtkwidget.c
+--- gtk+-2.18.3/gtk/gtkwidget.c.fresh-tooltips 2009-10-23 17:15:46.311135255 -0400
++++ gtk+-2.18.3/gtk/gtkwidget.c 2009-10-23 17:16:11.050128828 -0400
+@@ -2386,6 +2386,14 @@ gtk_widget_class_init (GtkWidgetClass *k
+ P_("The length of vertical scroll arrows"),
+ 1, G_MAXINT, 16,
+ GTK_PARAM_READABLE));
++
++ gtk_widget_class_install_style_property (klass,
++ g_param_spec_boolean ("new-tooltip-style",
++ NULL,
++ NULL,
++ FALSE,
++ GTK_PARAM_READABLE));
++
+ }
+
+ static void
Index: gtk2.spec
===================================================================
RCS file: /cvs/pkgs/rpms/gtk2/F-12/gtk2.spec,v
retrieving revision 1.421
retrieving revision 1.422
diff -u -p -r1.421 -r1.422
--- gtk2.spec 23 Oct 2009 01:28:28 -0000 1.421
+++ gtk2.spec 23 Oct 2009 21:25:42 -0000 1.422
@@ -17,7 +17,7 @@
Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X
Name: gtk2
Version: %{base_version}
-Release: 9%{?dist}
+Release: 10%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
Source: http://download.gnome.org/sources/gtk+/2.18/gtk+-%{version}.tar.bz2
@@ -37,6 +37,7 @@ Patch4: fresh-tooltips.patch
Patch5: zerosize.patch
Patch6: compose-sequences.patch
Patch7: symbolic-color-parsing.patch
+Patch8: tooltip-positioning.patch
BuildRequires: atk-devel >= %{atk_version}
BuildRequires: pango-devel >= %{pango_version}
@@ -155,6 +156,7 @@ This package contains developer document
%patch5 -p1 -b .zerosize
%patch6 -p1 -b .compose-sequences
%patch7 -p1 -b .symbolic-color-parsing
+%patch8 -p1 -b .tooltip-positioning
%build
libtoolize --force --copy
@@ -391,6 +393,10 @@ fi
%changelog
+* Fri Oct 23 2009 Matthias Clasen <mclasen at redhat.com> - 2.18.3-10
+- Tweak tooltip positioning
+- Make new tooltip style an opt-in theme choice
+
* Thu Oct 22 2009 Matthias Clasen <mclasen at redhat.com> - 2.18.3-9
- Fix a problem with parsing symbolic colors in rc files (#528662)
More information about the fedora-extras-commits
mailing list