|
|
8063f1 |
diff -up metacity-2.30.2/src/ui/fixedtip.c.fresh-tooltips metacity-2.30.2/src/ui/fixedtip.c
|
|
|
8063f1 |
--- metacity-2.30.2/src/ui/fixedtip.c.fresh-tooltips 2010-09-04 12:09:53.000000000 -0400
|
|
|
8063f1 |
+++ metacity-2.30.2/src/ui/fixedtip.c 2010-09-29 13:27:27.931194002 -0400
|
|
|
8063f1 |
@@ -50,23 +50,214 @@ static int screen_right_edge = 0;
|
|
|
8063f1 |
*/
|
|
|
8063f1 |
static int screen_bottom_edge = 0;
|
|
|
8063f1 |
|
|
|
8063f1 |
+static void
|
|
|
8063f1 |
+draw_round_rect (cairo_t *cr,
|
|
|
8063f1 |
+ gdouble aspect,
|
|
|
8063f1 |
+ gdouble x,
|
|
|
8063f1 |
+ gdouble y,
|
|
|
8063f1 |
+ gdouble corner_radius,
|
|
|
8063f1 |
+ gdouble width,
|
|
|
8063f1 |
+ gdouble height)
|
|
|
8063f1 |
+{
|
|
|
8063f1 |
+ gdouble radius = corner_radius / aspect;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_move_to (cr, x + radius, y);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* top-right, left of the corner */
|
|
|
8063f1 |
+ cairo_line_to (cr, x + width - radius, y);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* top-right, below the corner */
|
|
|
8063f1 |
+ cairo_arc (cr,
|
|
|
8063f1 |
+ x + width - radius, y + radius, radius,
|
|
|
8063f1 |
+ -90.0f * G_PI / 180.0f, 0.0f * G_PI / 180.0f);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* bottom-right, above the corner */
|
|
|
8063f1 |
+ cairo_line_to (cr, x + width, y + height - radius);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* bottom-right, left of the corner */
|
|
|
8063f1 |
+ cairo_arc (cr,
|
|
|
8063f1 |
+ x + width - radius, y + height - radius, radius,
|
|
|
8063f1 |
+ 0.0f * G_PI / 180.0f, 90.0f * G_PI / 180.0f);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* bottom-left, right of the corner */
|
|
|
8063f1 |
+ cairo_line_to (cr, x + radius, y + height);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* bottom-left, above the corner */
|
|
|
8063f1 |
+ cairo_arc (cr,
|
|
|
8063f1 |
+ x + radius, y + height - radius, radius,
|
|
|
8063f1 |
+ 90.0f * G_PI / 180.0f, 180.0f * G_PI / 180.0f);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* top-left, below the corner */
|
|
|
8063f1 |
+ cairo_line_to (cr, x, y + radius);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ /* top-left, right of the corner */
|
|
|
8063f1 |
+ cairo_arc (cr,
|
|
|
8063f1 |
+ x + radius, y + radius, radius,
|
|
|
8063f1 |
+ 180.0f * G_PI / 180.0f, 270.0f * G_PI / 180.0f);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_close_path (cr);
|
|
|
8063f1 |
+}
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+static void
|
|
|
8063f1 |
+fill_background (GtkWidget *widget,
|
|
|
8063f1 |
+ cairo_t *cr)
|
|
|
8063f1 |
+{
|
|
|
8063f1 |
+ GdkColor color;
|
|
|
8063f1 |
+ gdouble r, g, b;
|
|
|
8063f1 |
+ gint radius;
|
|
|
8063f1 |
+ gdouble background_alpha;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ if (gdk_screen_is_composited (gtk_widget_get_screen (widget)))
|
|
|
8063f1 |
+ background_alpha = 0.90;
|
|
|
8063f1 |
+ else
|
|
|
8063f1 |
+ background_alpha = 1.0;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ radius = MIN (widget->style->xthickness, widget->style->ythickness);
|
|
|
8063f1 |
+ radius = MAX (radius, 1);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
|
|
8063f1 |
+ cairo_paint (cr);
|
|
|
8063f1 |
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ draw_round_rect (cr,
|
|
|
8063f1 |
+ 1.0, 0.5, 0.5, radius,
|
|
|
8063f1 |
+ widget->allocation.width - 1,
|
|
|
8063f1 |
+ widget->allocation.height - 1);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ color = widget->style->bg [GTK_STATE_NORMAL];
|
|
|
8063f1 |
+ r = (float)color.red / 65535.0;
|
|
|
8063f1 |
+ g = (float)color.green / 65535.0;
|
|
|
8063f1 |
+ b = (float)color.blue / 65535.0;
|
|
|
8063f1 |
+ cairo_set_source_rgba (cr, r, g, b, background_alpha);
|
|
|
8063f1 |
+ cairo_fill_preserve (cr);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ color = widget->style->bg [GTK_STATE_SELECTED];
|
|
|
8063f1 |
+ r = (float) color.red / 65535.0;
|
|
|
8063f1 |
+ g = (float) color.green / 65535.0;
|
|
|
8063f1 |
+ b = (float) color.blue / 65535.0;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_set_source_rgba (cr, r, g, b, background_alpha);
|
|
|
8063f1 |
+ cairo_set_line_width (cr, 1.0);
|
|
|
8063f1 |
+ cairo_stroke (cr);
|
|
|
8063f1 |
+}
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+static void
|
|
|
8063f1 |
+update_shape (GtkWidget *window)
|
|
|
8063f1 |
+{
|
|
|
8063f1 |
+ GdkBitmap *mask;
|
|
|
8063f1 |
+ cairo_t *cr;
|
|
|
8063f1 |
+ gint width, height;
|
|
|
8063f1 |
+ gint radius;
|
|
|
8063f1 |
+ gboolean new_style;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ gtk_widget_style_get (window, "new-tooltip-style", &new_style, NULL);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ if (!new_style)
|
|
|
8063f1 |
+ {
|
|
|
8063f1 |
+ gtk_widget_shape_combine_mask (window, NULL, 0, 0);
|
|
|
8063f1 |
+ return;
|
|
|
8063f1 |
+ }
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ gtk_window_get_size (GTK_WINDOW (window), &width, &height);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ if (gdk_screen_is_composited (gtk_widget_get_screen (window)))
|
|
|
8063f1 |
+ {
|
|
|
8063f1 |
+ gtk_widget_shape_combine_mask (window, NULL, 0, 0);
|
|
|
8063f1 |
+ return;
|
|
|
8063f1 |
+ }
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ radius = MIN (window->style->xthickness, window->style->ythickness);
|
|
|
8063f1 |
+ radius = MAX (radius, 1);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ mask = (GdkBitmap *) gdk_pixmap_new (NULL, width, height, 1);
|
|
|
8063f1 |
+ cr = gdk_cairo_create (mask);
|
|
|
8063f1 |
+ if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
|
|
|
8063f1 |
+ {
|
|
|
8063f1 |
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
|
|
8063f1 |
+ cairo_paint (cr);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
|
|
8063f1 |
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
|
|
8063f1 |
+ draw_round_rect (cr, 1.0, 0, 0, radius + 1, width, height);
|
|
|
8063f1 |
+ cairo_fill (cr);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ gtk_widget_shape_combine_mask (window, mask, 0, 0);
|
|
|
8063f1 |
+ }
|
|
|
8063f1 |
+ cairo_destroy (cr);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ g_object_unref (mask);
|
|
|
8063f1 |
+}
|
|
|
8063f1 |
+
|
|
|
8063f1 |
static gint
|
|
|
8063f1 |
-expose_handler (GtkTooltip *tooltips)
|
|
|
8063f1 |
+expose_handler (GtkWidget *window)
|
|
|
8063f1 |
{
|
|
|
8063f1 |
- gtk_paint_flat_box (gtk_widget_get_style (tip), gtk_widget_get_window (tip),
|
|
|
8063f1 |
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
|
|
8063f1 |
- NULL, tip, "tooltip",
|
|
|
8063f1 |
- 0, 0, -1, -1);
|
|
|
8063f1 |
+ cairo_t *context;
|
|
|
8063f1 |
+ cairo_surface_t *surface;
|
|
|
8063f1 |
+ cairo_t *cr;
|
|
|
8063f1 |
+ gboolean new_style;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ gtk_widget_style_get (window, "new-tooltip-style", &new_style, NULL);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ if (new_style)
|
|
|
8063f1 |
+ {
|
|
|
8063f1 |
+ context = gdk_cairo_create (window->window);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
|
|
|
8063f1 |
+ surface = cairo_surface_create_similar (cairo_get_target (context),
|
|
|
8063f1 |
+ CAIRO_CONTENT_COLOR_ALPHA,
|
|
|
8063f1 |
+ window->allocation.width,
|
|
|
8063f1 |
+ window->allocation.height);
|
|
|
8063f1 |
+ cr = cairo_create (surface);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ fill_background (window, cr);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ cairo_destroy (cr);
|
|
|
8063f1 |
+ cairo_set_source_surface (context, surface, 0, 0);
|
|
|
8063f1 |
+ cairo_paint (context);
|
|
|
8063f1 |
+ cairo_surface_destroy (surface);
|
|
|
8063f1 |
+ cairo_destroy (context);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ update_shape (window);
|
|
|
8063f1 |
+ }
|
|
|
8063f1 |
+ else
|
|
|
8063f1 |
+ {
|
|
|
8063f1 |
+ gtk_paint_flat_box (window->style,
|
|
|
8063f1 |
+ window->window,
|
|
|
8063f1 |
+ GTK_STATE_NORMAL,
|
|
|
8063f1 |
+ GTK_SHADOW_OUT,
|
|
|
8063f1 |
+ NULL,
|
|
|
8063f1 |
+ window,
|
|
|
8063f1 |
+ "tooltip",
|
|
|
8063f1 |
+ 0, 0,
|
|
|
8063f1 |
+ window->allocation.width,
|
|
|
8063f1 |
+ window->allocation.height);
|
|
|
8063f1 |
+ }
|
|
|
8063f1 |
|
|
|
8063f1 |
return FALSE;
|
|
|
8063f1 |
}
|
|
|
8063f1 |
|
|
|
8063f1 |
+static void
|
|
|
8063f1 |
+on_style_set (GtkWidget *widget, GtkStyle *prev)
|
|
|
8063f1 |
+{
|
|
|
8063f1 |
+ GtkWidget *alignment;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ alignment = gtk_bin_get_child (GTK_BIN (widget));
|
|
|
8063f1 |
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
|
|
|
8063f1 |
+ widget->style->ythickness,
|
|
|
8063f1 |
+ widget->style->ythickness,
|
|
|
8063f1 |
+ widget->style->xthickness,
|
|
|
8063f1 |
+ widget->style->xthickness);
|
|
|
8063f1 |
+ gtk_widget_queue_draw (widget);
|
|
|
8063f1 |
+}
|
|
|
8063f1 |
+
|
|
|
8063f1 |
void
|
|
|
8063f1 |
meta_fixed_tip_show (Display *xdisplay, int screen_number,
|
|
|
8063f1 |
int root_x, int root_y,
|
|
|
8063f1 |
const char *markup_text)
|
|
|
8063f1 |
{
|
|
|
8063f1 |
int w, h;
|
|
|
8063f1 |
+ GtkWidget *alignment;
|
|
|
8063f1 |
|
|
|
8063f1 |
if (tip == NULL)
|
|
|
8063f1 |
{
|
|
|
8063f1 |
@@ -77,6 +268,7 @@ meta_fixed_tip_show (Display *xdisplay,
|
|
|
8063f1 |
GdkScreen *gdk_screen;
|
|
|
8063f1 |
GdkRectangle monitor;
|
|
|
8063f1 |
gint mon_num;
|
|
|
8063f1 |
+ GdkColormap *rgba;
|
|
|
8063f1 |
|
|
|
8063f1 |
gdk_screen = gdk_display_get_screen (gdk_display_get_default (),
|
|
|
8063f1 |
screen_number);
|
|
|
8063f1 |
@@ -86,25 +278,47 @@ meta_fixed_tip_show (Display *xdisplay,
|
|
|
8063f1 |
gdk_screen_get_monitor_geometry (gdk_screen, mon_num, &monitor);
|
|
|
8063f1 |
screen_right_edge = monitor.x + monitor.width;
|
|
|
8063f1 |
screen_bottom_edge = monitor.y + monitor.height;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ rgba = gdk_screen_get_rgba_colormap (gdk_screen);
|
|
|
8063f1 |
+ if (rgba)
|
|
|
8063f1 |
+ gtk_widget_set_colormap (tip, rgba);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+#if 0
|
|
|
8063f1 |
+ g_signal_connect (tip, "composited-changed",
|
|
|
8063f1 |
+ G_CALLBACK (on_composited_changed), NULL);
|
|
|
8063f1 |
+ g_signal_connect (tip, "realize",
|
|
|
8063f1 |
+ G_CALLBACK (on_realized), NULL);
|
|
|
8063f1 |
+#endif
|
|
|
8063f1 |
}
|
|
|
8063f1 |
-
|
|
|
8063f1 |
+
|
|
|
8063f1 |
gtk_widget_set_app_paintable (tip, TRUE);
|
|
|
8063f1 |
gtk_window_set_resizable (GTK_WINDOW (tip), FALSE);
|
|
|
8063f1 |
- gtk_widget_set_name (tip, "gtk-tooltips");
|
|
|
8063f1 |
- gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
|
|
|
8063f1 |
+ gtk_widget_set_name (tip, "gtk-tooltip");
|
|
|
8063f1 |
+ gtk_widget_realize (tip);
|
|
|
8063f1 |
|
|
|
8063f1 |
- g_signal_connect_swapped (tip, "expose_event",
|
|
|
8063f1 |
- G_CALLBACK (expose_handler), NULL);
|
|
|
8063f1 |
+ g_signal_connect (tip, "expose_event",
|
|
|
8063f1 |
+ G_CALLBACK (expose_handler), NULL);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
|
|
|
8063f1 |
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
|
|
|
8063f1 |
+ tip->style->ythickness,
|
|
|
8063f1 |
+ tip->style->ythickness,
|
|
|
8063f1 |
+ tip->style->xthickness,
|
|
|
8063f1 |
+ tip->style->xthickness);
|
|
|
8063f1 |
+ gtk_widget_show (alignment);
|
|
|
8063f1 |
+ gtk_container_add (GTK_CONTAINER (tip), alignment);
|
|
|
8063f1 |
|
|
|
8063f1 |
label = gtk_label_new (NULL);
|
|
|
8063f1 |
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
|
8063f1 |
- gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
|
|
|
8063f1 |
gtk_widget_show (label);
|
|
|
8063f1 |
-
|
|
|
8063f1 |
- gtk_container_add (GTK_CONTAINER (tip), label);
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ gtk_container_add (GTK_CONTAINER (alignment), label);
|
|
|
8063f1 |
|
|
|
8063f1 |
g_signal_connect (tip, "destroy",
|
|
|
8063f1 |
G_CALLBACK (gtk_widget_destroyed), &tip;;
|
|
|
8063f1 |
+
|
|
|
8063f1 |
+ g_signal_connect (tip, "style-set",
|
|
|
8063f1 |
+ G_CALLBACK (on_style_set), NULL);
|
|
|
8063f1 |
}
|
|
|
8063f1 |
|
|
|
8063f1 |
gtk_label_set_markup (GTK_LABEL (label), markup_text);
|