summaryrefslogtreecommitdiffstats
path: root/fresh-tooltips.patch
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@fedoraproject.org>2009-10-21 20:45:18 +0000
committerMatthias Clasen <mclasen@fedoraproject.org>2009-10-21 20:45:18 +0000
commit0adbc7bdaa3efae428ac82353a8976b336cf3cbd (patch)
treeac8999085b167df78598ef5a3d254d30745ec26a /fresh-tooltips.patch
parent60d6855a11d9a6a0d9fc534825cfdb6e7c710529 (diff)
downloadmetacity-0adbc7bdaa3efae428ac82353a8976b336cf3cbd.tar.gz
metacity-0adbc7bdaa3efae428ac82353a8976b336cf3cbd.tar.xz
metacity-0adbc7bdaa3efae428ac82353a8976b336cf3cbd.zip
match tooltip lookmetacity-2_28_0-4_fc12
Diffstat (limited to 'fresh-tooltips.patch')
-rw-r--r--fresh-tooltips.patch246
1 files changed, 246 insertions, 0 deletions
diff --git a/fresh-tooltips.patch b/fresh-tooltips.patch
new file mode 100644
index 0000000..8353506
--- /dev/null
+++ b/fresh-tooltips.patch
@@ -0,0 +1,246 @@
+--- metacity-2.28.0/src/ui/fixedtip.c 2009-10-21 16:28:48.651819365 -0400
++++ hacked/src/ui/fixedtip.c 2009-10-21 16:40:27.148814794 -0400
+@@ -50,13 +50,174 @@
+ */
+ static int screen_bottom_edge = 0;
+
++static void
++draw_round_rect (cairo_t *cr,
++ gdouble aspect,
++ gdouble x,
++ gdouble y,
++ gdouble corner_radius,
++ gdouble width,
++ gdouble height)
++{
++ gdouble radius = corner_radius / aspect;
++
++ cairo_move_to (cr, x + radius, y);
++
++ /* top-right, left of the corner */
++ cairo_line_to (cr, x + width - radius, y);
++
++ /* top-right, below the corner */
++ cairo_arc (cr,
++ x + width - radius, y + radius, radius,
++ -90.0f * G_PI / 180.0f, 0.0f * G_PI / 180.0f);
++
++ /* bottom-right, above the corner */
++ cairo_line_to (cr, x + width, y + height - radius);
++
++ /* bottom-right, left of the corner */
++ cairo_arc (cr,
++ x + width - radius, y + height - radius, radius,
++ 0.0f * G_PI / 180.0f, 90.0f * G_PI / 180.0f);
++
++ /* bottom-left, right of the corner */
++ cairo_line_to (cr, x + radius, y + height);
++
++ /* bottom-left, above the corner */
++ cairo_arc (cr,
++ x + radius, y + height - radius, radius,
++ 90.0f * G_PI / 180.0f, 180.0f * G_PI / 180.0f);
++
++ /* top-left, below the corner */
++ cairo_line_to (cr, x, y + radius);
++
++ /* top-left, right of the corner */
++ cairo_arc (cr,
++ x + radius, y + radius, radius,
++ 180.0f * G_PI / 180.0f, 270.0f * G_PI / 180.0f);
++
++ cairo_close_path (cr);
++}
++
++static void
++fill_background (GtkWidget *widget,
++ cairo_t *cr)
++{
++ GdkColor color;
++ gdouble r, g, b;
++ gint radius;
++ gdouble background_alpha;
++
++ if (gdk_screen_is_composited (gtk_widget_get_screen (widget)))
++ background_alpha = 0.90;
++ else
++ background_alpha = 1.0;
++
++ radius = MIN (widget->style->xthickness, widget->style->ythickness);
++ radius = MAX (radius, 1);
++
++ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
++ cairo_paint (cr);
++ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
++
++ draw_round_rect (cr,
++ 1.0, 1, 1, radius,
++ widget->allocation.width - 2,
++ widget->allocation.height - 2);
++
++ color = widget->style->bg [GTK_STATE_NORMAL];
++ r = (float)color.red / 65535.0;
++ g = (float)color.green / 65535.0;
++ b = (float)color.blue / 65535.0;
++ cairo_set_source_rgba (cr, r, g, b, background_alpha);
++ cairo_fill_preserve (cr);
++
++ color = widget->style->bg [GTK_STATE_SELECTED];
++ r = (float) color.red / 65535.0;
++ g = (float) color.green / 65535.0;
++ b = (float) color.blue / 65535.0;
++
++ cairo_set_source_rgba (cr, r, g, b, background_alpha);
++ cairo_set_line_width (cr, 1.0);
++ cairo_stroke (cr);
++}
++
++static void
++update_shape (GtkWidget *window)
++{
++ GdkBitmap *mask;
++ cairo_t *cr;
++ gint width, height;
++
++ gtk_window_get_size (GTK_WINDOW (window), &width, &height);
++
++ if (gdk_screen_is_composited (gtk_widget_get_screen (window)))
++ {
++ GdkRectangle rect;
++ GdkRegion *region;
++
++#if 0
++ gtk_widget_shape_combine_mask (tooltip->window, NULL, 0, 0);
++ return;
++#endif
++ /* This is a hack to keep the metacity compositor from slapping a
++ * * non-shaped shadow around the shaped tooltip
++ * */
++ rect.x = 0;
++ rect.y = 0;
++ rect.width = width;
++ rect.height = height;
++ region = gdk_region_rectangle (&rect);
++ gdk_window_shape_combine_region (window->window, region, 0, 0);
++ gdk_region_destroy (region);
++
++ return;
++ }
++
++ mask = (GdkBitmap *) gdk_pixmap_new (NULL, width, height, 1);
++ cr = gdk_cairo_create (mask);
++ if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
++ {
++ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
++ cairo_paint (cr);
++
++ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
++ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
++ draw_round_rect (cr, 1.0, 0, 0, 4, width, height);
++ cairo_fill (cr);
++
++ gtk_widget_shape_combine_mask (window, mask, 0, 0);
++ }
++ cairo_destroy (cr);
++
++ g_object_unref (mask);
++}
++
++
+ static gint
+-expose_handler (GtkTooltips *tooltips)
++expose_handler (GtkWidget *window)
+ {
+- gtk_paint_flat_box (tip->style, tip->window,
+- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+- NULL, tip, "tooltip",
+- 0, 0, -1, -1);
++ cairo_t *context;
++ cairo_surface_t *surface;
++ cairo_t *cr;
++
++ context = gdk_cairo_create (window->window);
++
++ cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
++ surface = cairo_surface_create_similar (cairo_get_target (context),
++ CAIRO_CONTENT_COLOR_ALPHA,
++ window->allocation.width,
++ window->allocation.height);
++ cr = cairo_create (surface);
++
++ fill_background (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 (window);
+
+ return FALSE;
+ }
+@@ -67,9 +228,10 @@
+ const char *markup_text)
+ {
+ int w, h;
+-
++ GtkWidget *alignment;
++
+ if (tip == NULL)
+- {
++ {
+ tip = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_window_set_type_hint (GTK_WINDOW(tip), GDK_WINDOW_TYPE_HINT_TOOLTIP);
+
+@@ -77,6 +239,7 @@
+ GdkScreen *gdk_screen;
+ GdkRectangle monitor;
+ gint mon_num;
++ GdkColormap *rgba;
+
+ gdk_screen = gdk_display_get_screen (gdk_display_get_default (),
+ screen_number);
+@@ -86,22 +249,34 @@
+ gdk_screen_get_monitor_geometry (gdk_screen, mon_num, &monitor);
+ screen_right_edge = monitor.x + monitor.width;
+ screen_bottom_edge = monitor.y + monitor.height;
++
++ rgba = gdk_screen_get_rgba_colormap (gdk_screen);
++ if (rgba)
++ gtk_widget_set_colormap (tip, rgba);
+ }
+-
++
+ gtk_widget_set_app_paintable (tip, TRUE);
+ gtk_window_set_resizable (GTK_WINDOW (tip), FALSE);
+- gtk_widget_set_name (tip, "gtk-tooltips");
+- gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
++ gtk_widget_set_name (tip, "gtk-tooltip");
++ gtk_widget_realize (tip);
+
+- g_signal_connect_swapped (tip, "expose_event",
+- G_CALLBACK (expose_handler), NULL);
++ g_signal_connect (tip, "expose_event",
++ G_CALLBACK (expose_handler), NULL);
++
++ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
++ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
++ tip->style->ythickness,
++ tip->style->ythickness,
++ tip->style->xthickness,
++ tip->style->xthickness);
++ gtk_widget_show (alignment);
++ gtk_container_add (GTK_CONTAINER (tip), alignment);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+- gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
+ gtk_widget_show (label);
+-
+- gtk_container_add (GTK_CONTAINER (tip), label);
++
++ gtk_container_add (GTK_CONTAINER (alignment), label);
+
+ g_signal_connect (tip, "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &tip);