rpms/metacity/F-12 fresh-tooltips.patch, NONE, 1.1 metacity.spec, 1.205, 1.206

Matthias Clasen mclasen at fedoraproject.org
Wed Oct 21 20:45:18 UTC 2009


Author: mclasen

Update of /cvs/pkgs/rpms/metacity/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21366

Modified Files:
	metacity.spec 
Added Files:
	fresh-tooltips.patch 
Log Message:
match tooltip look


fresh-tooltips.patch:
 fixedtip.c |  205 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 190 insertions(+), 15 deletions(-)

--- NEW FILE fresh-tooltips.patch ---
--- 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);


Index: metacity.spec
===================================================================
RCS file: /cvs/pkgs/rpms/metacity/F-12/metacity.spec,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -p -r1.205 -r1.206
--- metacity.spec	15 Oct 2009 18:00:24 -0000	1.205
+++ metacity.spec	21 Oct 2009 20:45:18 -0000	1.206
@@ -1,7 +1,7 @@
 Summary: Unobtrusive window manager
 Name: metacity
 Version: 2.28.0
-Release: 3%{?dist}
+Release: 4%{?dist}
 URL: http://download.gnome.org/sources/metacity/
 Source0: http://download.gnome.org/sources/metacity/2.28/metacity-%{version}.tar.bz2
 # http://bugzilla.gnome.org/show_bug.cgi?id=558723
@@ -19,6 +19,7 @@ Patch9: 0001-tooltip-set-window-type-hin
 
 # fedora specific patches
 Patch10: workspaces.patch
+Patch11: fresh-tooltips.patch
 
 License: GPLv2+
 Group: User Interface/Desktops
@@ -85,6 +86,7 @@ API. This package exists purely for tech
 %patch8 -p1 -b .sound-cache
 %patch9 -p1 -b .tooltip
 %patch10 -p1 -b .workspaces
+%patch11 -p1 -b .fresh-tooltips
 
 # force regeneration
 rm src/metacity.schemas
@@ -192,6 +194,9 @@ fi
 %{_mandir}/man1/metacity-window-demo.1.gz
 
 %changelog
+* Wed Oct 21 2009 Matthias Clasen <mclasen at redhat.cm> - 2.28.0-4
+- Make tooltips look match GTK+
+
 * Thu Oct 15 2009 Matthias Clasen <mclasen at redhat.cm> - 2.28.0-3
 - Tweak the default number of workspaces
 




More information about the fedora-extras-commits mailing list