This commit is contained in:
Matthias Clasen 2007-05-20 04:49:36 +00:00
parent 65c997e17d
commit c9477143df
8 changed files with 7 additions and 572 deletions

View File

@ -1 +1 @@
libgnomekbd-2.18.0.tar.bz2 libgnomekbd-2.18.1.tar.bz2

View File

@ -1,19 +0,0 @@
--- libgnomekbd-0.1/libgnomekbd/gkbd-keyboard-config.c.memalloc 2006-10-28 01:13:02.000000000 -0400
+++ libgnomekbd-0.1/libgnomekbd/gkbd-keyboard-config.c 2006-10-28 01:13:27.000000000 -0400
@@ -25,7 +25,6 @@
#include <X11/keysym.h>
#include <glib/gi18n.h>
-//#include <gdk/gdkx.h>
#include <libgnome/gnome-program.h>
#include <gkbd-keyboard-config.h>
@@ -558,6 +557,8 @@
XklConfigRec * data)
{
gboolean own_data = data == NULL;
+ if (own_data)
+ data = xkl_config_rec_new ();
if (xkl_config_rec_get_from_backup (data, kbd_config->engine))
gkbd_keyboard_config_copy_from_xkl_config (kbd_config,
data);

View File

@ -1,411 +0,0 @@
--- libgnomekbd-2.17.2/libgnomekbd/gkbd-keyboard-drawing.c.corner 2007-01-24 15:21:42.000000000 -0500
+++ libgnomekbd-2.17.2/libgnomekbd/gkbd-keyboard-drawing.c 2007-01-24 15:23:24.000000000 -0500
@@ -66,14 +66,227 @@
* cos (M_PI * angle / 1800.0);
}
+static gdouble
+length (gdouble x, gdouble y)
+{
+ return sqrt (x*x + y*y);
+}
+
+static gdouble
+point_line_distance (gdouble ax, gdouble ay,
+ gdouble nx, gdouble ny)
+{
+ return ax * nx + ay * ny;
+}
+
+static void
+normal_form (gdouble ax, gdouble ay,
+ gdouble bx, gdouble by,
+ gdouble *nx, gdouble *ny, gdouble *d)
+{
+ gdouble l;
+
+ *nx = by - ay;
+ *ny = ax - bx;
+
+ l = length (*nx, *ny);
+
+ *nx /= l;
+ *ny /= l;
+
+ *d = point_line_distance (ax, ay, *nx, *ny);
+}
+
+static void
+inverse (gdouble a, gdouble b, gdouble c, gdouble d,
+ gdouble *e, gdouble *f, gdouble *g, gdouble *h)
+{
+ gdouble det;
+
+ det = a*d - b*c;
+
+ *e = d / det;
+ *f = -b / det;
+ *g = -c / det;
+ *h = a / det;
+}
+
+static void
+multiply (gdouble a, gdouble b, gdouble c, gdouble d,
+ gdouble e, gdouble f,
+ gdouble *x, gdouble *y)
+{
+ *x = a*e + b*f;
+ *y = c*e + d*f;
+}
+
+static void
+intersect (gdouble n1x, gdouble n1y, gdouble d1,
+ gdouble n2x, gdouble n2y, gdouble d2,
+ gdouble *x, gdouble *y)
+{
+ gdouble e, f, g, h;
+
+ inverse (n1x, n1y, n2x, n2y, &e, &f, &g, &h);
+ multiply (e, f, g, h, d1, d2, x, y);
+}
+
+
+/* draw an angle from the current point to b and then to c,
+ * with a rounded corner of the given radius.
+ */
+static void
+rounded_corner (cairo_t *cr,
+ gdouble bx, gdouble by,
+ gdouble cx, gdouble cy,
+ gdouble radius)
+{
+ gdouble ax, ay;
+ gdouble n1x, n1y, d1;
+ gdouble n2x, n2y, d2;
+ gdouble pd1, pd2;
+ gdouble ix, iy;
+ gdouble dist1, dist2;
+ gdouble nx, ny, d;
+ gdouble a1x, a1y, c1x, c1y;
+ gdouble phi1, phi2;
+
+ cairo_get_current_point (cr, &ax, &ay);
+
+ /* make sure radius is not too large */
+ dist1 = length (bx - ax, by - ay);
+ dist2 = length (cx - bx, cy - by);
+
+ radius = MIN (radius, MIN (dist1, dist2));
+
+ /* construct normal forms of the lines */
+ normal_form (ax, ay, bx, by, &n1x, &n1y, &d1);
+ normal_form (bx, by, cx, cy, &n2x, &n2y, &d2);
+
+ /* find which side of the line a,b the point c is on */
+ if (point_line_distance (cx, cy, n1x, n1y) < d1)
+ pd1 = d1 - radius;
+ else
+ pd1 = d1 + radius;
+
+ /* find which side of the line b,c the point a is on */
+ if (point_line_distance (ax, ay, n2x, n2y) < d2)
+ pd2 = d2 - radius;
+ else
+ pd2 = d2 + radius;
+
+ /* intersect the parallels to find the center of the arc */
+ intersect (n1x, n1y, pd1, n2x, n2y, pd2, &ix, &iy);
+
+ nx = (bx - ax) / dist1;
+ ny = (by - ay) / dist1;
+ d = point_line_distance (ix, iy, nx, ny);
+
+ /* a1 is the point on the line a-b where the arc starts */
+ intersect (n1x, n1y, d1, nx, ny, d, &a1x, &a1y);
+
+ nx = (cx - bx) / dist2;
+ ny = (cy - by) / dist2;
+ d = point_line_distance (ix, iy, nx, ny);
+
+ /* c1 is the point on the line b-c where the arc ends */
+ intersect (n2x, n2y, d2, nx, ny, d, &c1x, &c1y);
+
+ /* determine the first angle */
+ if (a1x - ix == 0)
+ phi1 = (a1y - iy > 0) ? M_PI_2 : 3*M_PI_2;
+ else if (a1x - ix > 0)
+ phi1 = atan ((a1y - iy)/(a1x - ix));
+ else
+ phi1 = M_PI + atan ((a1y - iy)/(a1x - ix));
+
+ /* determine the second angle */
+ if (c1x - ix == 0)
+ phi2 = (c1y - iy > 0) ? M_PI_2 : 3*M_PI_2;
+ else if (c1x - ix > 0)
+ phi2 = atan ((c1y - iy)/(c1x - ix));
+ else
+ phi2 = M_PI + atan ((c1y - iy)/(c1x - ix));
+
+ /* compute the difference between phi2 and phi1 mod 2pi */
+ d = phi2 - phi1;
+ while (d < 0)
+ d += 2*M_PI;
+ while (d > 2*M_PI)
+ d -= 2*M_PI;
+
+ cairo_line_to (cr, a1x, a1y);
+
+ /* pick the short arc from phi1 to phi2 */
+ if (d < M_PI)
+ cairo_arc (cr, ix, iy, radius, phi1, phi2);
+ else
+ cairo_arc_negative (cr, ix, iy, radius, phi1, phi2);
+
+ cairo_line_to (cr, cx, cy);
+}
+
+static void
+draw (cairo_t *cr,
+ gint width,
+ gint height)
+{
+ gdouble x0 = 100;
+ gdouble y0 = 100;
+ gdouble x1 = 200;
+ gdouble y1 = 100;
+ gdouble x2 = 180;
+ gdouble y2 = 200;
+ gdouble x3 = 240;
+ gdouble y3 = 190;
+
+ gdouble radius = 20;
+
+ cairo_move_to (cr, x0, y0);
+
+ rounded_corner (cr, x1, y1, (x1+x2)/2, (y1+y2)/2, radius);
+ rounded_corner (cr, x2, y2, x3, y3, radius);
+
+ cairo_stroke (cr);
+}
+
+static void
+rounded_polygon (cairo_t *cr,
+ gboolean filled,
+ gdouble radius,
+ GdkPoint *points,
+ gint num_points)
+{
+ gint i, j;
+
+ cairo_move_to (cr,
+ (gdouble)(points[num_points - 1].x + points[0].x)/2,
+ (gdouble)(points[num_points - 1].y + points[0].y)/2);
+
+ for (i = 0; i < num_points; i++)
+ {
+ j = (i + 1) % num_points;
+ rounded_corner (cr, (gdouble)points[i].x, (gdouble)points[i].y,
+ (gdouble)(points[i].x + points[j].x)/2,
+ (gdouble)(points[i].y + points[j].y)/2,
+ radius);
+ };
+ cairo_close_path (cr);
+
+ if (filled)
+ cairo_fill (cr);
+ else
+ cairo_stroke (cr);
+}
+
static void
draw_polygon (GkbdKeyboardDrawing * drawing,
GdkColor * fill_color,
gint xkb_x,
- gint xkb_y, XkbPointRec * xkb_points, guint num_points)
+ gint xkb_y, XkbPointRec * xkb_points, guint num_points, gdouble radius)
{
GtkStateType state = GTK_WIDGET_STATE (GTK_WIDGET (drawing));
- GdkGC *gc;
+ cairo_t *cr;
GdkPoint *points;
gboolean filled;
gint i;
@@ -82,14 +295,15 @@
return;
if (fill_color) {
- gc = gdk_gc_new (GTK_WIDGET (drawing)->window);
- gdk_gc_set_rgb_fg_color (gc, fill_color);
- filled = TRUE;
+ filled = TRUE;
} else {
- gc = GTK_WIDGET (drawing)->style->dark_gc[state];
+ fill_color = &GTK_WIDGET (drawing)->style->dark[state];
filled = FALSE;
}
+ cr = gdk_cairo_create (GDK_DRAWABLE (drawing->pixmap));
+ gdk_cairo_set_source_color (cr, fill_color);
+
points = g_new (GdkPoint, num_points);
for (i = 0; i < num_points; i++) {
@@ -99,11 +313,64 @@
xkb_to_pixmap_coord (drawing, xkb_y + xkb_points[i].y);
}
- gdk_draw_polygon (drawing->pixmap, gc, filled, points, num_points);
+ rounded_polygon (cr, filled, radius, points, num_points);
g_free (points);
- if (fill_color)
- g_object_unref (gc);
+}
+
+static void
+curve_rectangle (cairo_t *cr,
+ gdouble x0,
+ gdouble y0,
+ gdouble width,
+ gdouble height,
+ gdouble radius)
+{
+ gdouble x1, y1;
+
+ if (!width || !height)
+ return;
+
+ x1 = x0 + width;
+ y1 = y0 + height;
+
+ radius = MIN(radius, MIN(width / 2, height / 2));
+
+ cairo_move_to (cr, x0, y0 + radius);
+ cairo_arc (cr, x0 + radius, y0 + radius, radius, M_PI, 3*M_PI/2);
+ cairo_line_to (cr, x1 - radius, y0);
+ cairo_arc (cr, x1 - radius, y0 + radius, radius, 3*M_PI/2, 2*M_PI);
+ cairo_line_to (cr, x1, y1 - radius);
+ cairo_arc (cr, x1 - radius, y1 - radius, radius, 0, M_PI/2);
+ cairo_line_to (cr, x0 + radius, y1);
+ cairo_arc (cr, x0 + radius, y1 - radius, radius, M_PI/2, M_PI);
+
+ cairo_close_path (cr);
+}
+
+static void
+draw_curve_rectangle (GdkPixmap *pixmap,
+ gboolean filled,
+ GdkColor *fill_color,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gint radius)
+{
+ cairo_t *cr;
+
+ cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
+ curve_rectangle (cr, x, y, width, height, radius);
+
+ gdk_cairo_set_source_color (cr, fill_color);
+
+ if (filled)
+ cairo_fill (cr);
+ else
+ cairo_stroke (cr);
+
+ cairo_destroy (cr);
}
/* x, y, width, height are in the xkb coordinate system */
@@ -111,7 +378,7 @@
draw_rectangle (GkbdKeyboardDrawing * drawing,
GdkColor * fill_color,
gint angle,
- gint xkb_x, gint xkb_y, gint xkb_width, gint xkb_height)
+ gint xkb_x, gint xkb_y, gint xkb_width, gint xkb_height, gint radius)
{
if (drawing->pixmap == NULL)
return;
@@ -121,14 +388,11 @@
GTK_WIDGET_STATE (GTK_WIDGET (drawing));
gint x, y, width, height;
gboolean filled;
- GdkGC *gc;
if (fill_color) {
- gc = gdk_gc_new (GTK_WIDGET (drawing)->window);
- gdk_gc_set_rgb_fg_color (gc, fill_color);
filled = TRUE;
} else {
- gc = GTK_WIDGET (drawing)->style->dark_gc[state];
+ fill_color = &GTK_WIDGET (drawing)->style->dark[state];
filled = FALSE;
}
@@ -139,11 +403,8 @@
height =
xkb_to_pixmap_coord (drawing, xkb_y + xkb_height) - y;
- gdk_draw_rectangle (drawing->pixmap, gc, filled, x, y,
- width, height);
-
- if (fill_color)
- g_object_unref (gc);
+ draw_curve_rectangle (drawing->pixmap, filled, fill_color,
+ x, y, width, height, radius);
} else {
XkbPointRec points[4];
gint x, y;
@@ -164,7 +425,7 @@
points[3].y = y;
/* the points we've calculated are relative to 0,0 */
- draw_polygon (drawing, fill_color, 0, 0, points, 4);
+ draw_polygon (drawing, fill_color, 0, 0, points, 4, radius);
}
}
@@ -181,7 +442,7 @@
if (color)
draw_rectangle (drawing, color, angle, origin_x,
origin_y, outline->points[0].x,
- outline->points[0].y);
+ outline->points[0].y, outline->corner_radius);
#ifdef KBDRAW_DEBUG
printf ("points:%p\n", outline->points);
@@ -191,7 +452,7 @@
draw_rectangle (drawing, NULL, angle, origin_x, origin_y,
outline->points[0].x,
- outline->points[0].y);
+ outline->points[0].y, outline->corner_radius);
} else if (outline->num_points == 2) {
gint rotated_x0, rotated_y0;
@@ -202,19 +463,20 @@
if (color)
draw_rectangle (drawing, color, angle, rotated_x0,
rotated_y0, outline->points[1].x,
- outline->points[1].y);
+ outline->points[1].y, outline->corner_radius);
draw_rectangle (drawing, NULL, angle, rotated_x0,
rotated_y0, outline->points[1].x,
- outline->points[1].y);
+ outline->points[1].y, outline->corner_radius);
} else {
if (color)
draw_polygon (drawing, color, origin_x, origin_y,
outline->points,
- outline->num_points);
+ outline->num_points, outline->corner_radius);
draw_polygon (drawing, NULL, origin_x, origin_y,
- outline->points, outline->num_points);
+ outline->points, outline->num_points,
+ outline->corner_radius);
}
}

View File

@ -1,25 +0,0 @@
--- libgnomekbd-2.17.2/libgnomekbd/gkbd-keyboard-drawing.c.label-color 2007-01-24 14:36:58.000000000 -0500
+++ libgnomekbd-2.17.2/libgnomekbd/gkbd-keyboard-drawing.c 2007-01-24 14:39:12.000000000 -0500
@@ -489,6 +489,9 @@
gint angle, gint x, gint y, PangoLayout * layout)
{
GtkStateType state = GTK_WIDGET_STATE (GTK_WIDGET (drawing));
+ GdkColor *color;
+
+ color = drawing->colors + (drawing->xkb->geom->label_color - drawing->xkb->geom->colors);
if (drawing->pixmap == NULL)
return;
@@ -502,9 +505,9 @@
drawing->angle = angle;
}
- gdk_draw_layout (drawing->pixmap,
- GTK_WIDGET (drawing)->style->text_gc[state], x, y,
- drawing->layout);
+ gdk_draw_layout_with_colors (drawing->pixmap,
+ GTK_WIDGET (drawing)->style->text_gc[state], x, y,
+ drawing->layout, color, NULL);
}
static void

View File

@ -1,55 +0,0 @@
--- libgnomekbd-2.17.2/libgnomekbd/gkbd-keyboard-drawing.c.primary 2007-01-24 14:41:18.000000000 -0500
+++ libgnomekbd-2.17.2/libgnomekbd/gkbd-keyboard-drawing.c 2007-01-24 14:47:27.000000000 -0500
@@ -677,9 +677,22 @@
shape->num_outlines);
#endif
- for (i = 0; i < 1 /* shape->num_outlines */ ; i++)
- draw_outline (drawing, shape->outlines + i, color,
- key->angle, key->origin_x, key->origin_y);
+ /* draw the primary outline */
+ draw_outline (drawing, shape->primary ? shape->primary : shape->outlines,
+ color, key->angle, key->origin_x, key->origin_y);
+#if 0
+ /* don't draw other outlines for now, since
+ * the text placement does not take them into account
+ */
+ for (i = 0; i < shape->num_outlines; i++)
+ {
+ if (shape->outlines + i == shape->approx ||
+ shape->outlines + i == shape->primary)
+ continue;
+ draw_outline (drawing, shape->outlines + i, NULL,
+ key->angle, key->origin_x, key->origin_y);
+ }
+#endif
draw_key_label (drawing, key->keycode, key->angle, key->origin_x,
key->origin_y, shape->bounds.x2, shape->bounds.y2);
@@ -822,11 +835,21 @@
shape = drawing->xkb->geom->shapes + shape_doodad->shape_ndx;
color = drawing->colors + shape_doodad->color_ndx;
- for (i = 0; i < shape->num_outlines; i++)
- draw_outline (drawing, shape->outlines + i, color,
- doodad->angle,
- doodad->origin_x + shape_doodad->left,
- doodad->origin_y + shape_doodad->top);
+ /* draw the primary outline filled */
+ draw_outline (drawing, shape->primary ? shape->primary : shape->outlines,
+ color, doodad->angle,
+ doodad->origin_x + shape_doodad->left,
+ doodad->origin_y + shape_doodad->top);
+
+ /* stroke the other outlines */
+ for (i = 0; i < shape->num_outlines; i++) {
+ if (shape->outlines + i == shape->approx ||
+ shape->outlines + i == shape->primary)
+ continue;
+ draw_outline (drawing, shape->outlines + i, NULL, doodad->angle,
+ doodad->origin_x + shape_doodad->left,
+ doodad->origin_y + shape_doodad->top);
+ }
}
static void

View File

@ -1,49 +0,0 @@
--- libgnomekbd-2.18.0/libgnomekbd/gkbd-keyboard-drawing.c.rotated-text 2007-02-03 20:30:49.000000000 -0500
+++ libgnomekbd-2.18.0/libgnomekbd/gkbd-keyboard-drawing.c 2007-03-13 18:24:54.000000000 -0400
@@ -470,9 +470,6 @@
gint angle, gint x, gint y, PangoLayout * layout)
{
GtkStateType state = GTK_WIDGET_STATE (GTK_WIDGET (drawing));
- PangoLayoutLine *line;
- gint x_off, y_off;
- gint i;
if (drawing->pixmap == NULL)
return;
@@ -486,36 +483,6 @@
drawing->angle = angle;
}
- i = 0;
- y_off = 0;
- for (line = pango_layout_get_line (drawing->layout, i);
- line != NULL;
- line = pango_layout_get_line (drawing->layout, ++i)) {
- GSList *runp;
- PangoRectangle line_extents;
-
- x_off = 0;
-
- for (runp = line->runs; runp != NULL; runp = runp->next) {
- PangoGlyphItem *run = runp->data;
- gint j;
-
- for (j = 0; j < run->glyphs->num_glyphs; j++) {
- PangoGlyphGeometry *geometry;
-
- geometry =
- &run->glyphs->glyphs[j].geometry;
-
- x_off += geometry->width;
- }
- }
-
- pango_layout_line_get_extents (line, NULL, &line_extents);
- y_off +=
- line_extents.height +
- pango_layout_get_spacing (drawing->layout);
- }
-
gdk_draw_layout (drawing->pixmap,
GTK_WIDGET (drawing)->style->text_gc[state], x, y,
drawing->layout);

View File

@ -1,6 +1,6 @@
Name: libgnomekbd Name: libgnomekbd
Version: 2.18.0 Version: 2.18.1
Release: 2%{?dist} Release: 1%{?dist}
Summary: A keyboard configuration library Summary: A keyboard configuration library
Group: System Environment/Libraries Group: System Environment/Libraries
@ -9,12 +9,6 @@ URL: http://gswitchit.sourceforge.net
Source0: http://ftp.gnome.org/pub/gnome/sources/libgnomekbd/2.18/libgnomekbd-%{version}.tar.bz2 Source0: http://ftp.gnome.org/pub/gnome/sources/libgnomekbd/2.18/libgnomekbd-%{version}.tar.bz2
# http://bugzilla.gnome.org/show_bug.cgi?id=365590 # http://bugzilla.gnome.org/show_bug.cgi?id=365590
Patch1: libgnomekbd-0.1-werror.patch Patch1: libgnomekbd-0.1-werror.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=352777
Patch2: libgnomekbd-2.18.0-rotated-text.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=352778
Patch3: libgnomekbd-2.17.2-label-color.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=352779
Patch4: libgnomekbd-2.17.2-corner.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=353163 # http://bugzilla.gnome.org/show_bug.cgi?id=353163
Patch5: libgnomekbd-2.17.2-redraw.patch Patch5: libgnomekbd-2.17.2-redraw.patch
@ -60,9 +54,6 @@ developing applications that use libgnomekbd.
%prep %prep
%setup -q %setup -q
%patch1 -p1 -b .werror %patch1 -p1 -b .werror
%patch2 -p1 -b .rotated-text
%patch3 -p1 -b .label-color
%patch4 -p1 -b .corner
%patch5 -p1 -b .redraw %patch5 -p1 -b .redraw
%build %build
@ -134,6 +125,9 @@ touch --no-create %{_datadir}/icons/hicolor || :
%changelog %changelog
* Sun May 20 2007 Matthias Clasen <mclasen@redhat.com> - 2.18.1-1
- Update to 2.18.1
* Wed Apr 4 2007 Matthias Clasen <mclasen@redhat.com> - 2.18.0-2 * Wed Apr 4 2007 Matthias Clasen <mclasen@redhat.com> - 2.18.0-2
- Fix a typo in URL - Fix a typo in URL

View File

@ -1 +1 @@
f176e026158f678144511fb343ec7269 libgnomekbd-2.18.0.tar.bz2 4d69db2ad5f7e8e71ed4fa167381e239 libgnomekbd-2.18.1.tar.bz2