Revert a couple of commits from upstream that broke gnome-screensaver.

Bug report filed.
This commit is contained in:
ajacoutot 2010-05-02 08:42:25 +00:00
parent d07dde9be0
commit 9bace42950
3 changed files with 522 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.23 2010/04/24 08:35:15 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.24 2010/05/02 08:42:25 ajacoutot Exp $
SHARED_ONLY= Yes
@ -6,6 +6,7 @@ COMMENT= keyboard configuration library
GNOME_PROJECT= libgnomekbd
GNOME_VERSION= 2.30.1
PKGNAME= ${DISTNAME}p0
SHARED_LIBS += gnomekbd 4.0 # .5.0
SHARED_LIBS += gnomekbdui 4.0 # .5.0

View File

@ -0,0 +1,247 @@
$OpenBSD: patch-libgnomekbd_gkbd-indicator_c,v 1.1 2010/05/02 08:42:25 ajacoutot Exp $
Revert upstream commit that broke gnome-screensaver:
342b82bfd0308275618180652dc56e7d9b663642
--- libgnomekbd/gkbd-indicator.c.orig Mon Mar 29 00:27:04 2010
+++ libgnomekbd/gkbd-indicator.c Sun May 2 10:30:25 2010
@@ -273,9 +273,6 @@ flag_exposed (GtkWidget * flag, GdkEventExpose * event
int ih = gdk_pixbuf_get_height (image);
GtkAllocation allocation;
gboolean scaling_needed;
- double xwiratio, ywiratio, wiratio;
- int sw, sh, ox, oy;
- GdkPixbuf *scaled;
gtk_widget_get_allocation (flag, &allocation);
scaling_needed =
@@ -284,19 +281,19 @@ flag_exposed (GtkWidget * flag, GdkEventExpose * event
(allocation.width >= iw && allocation.height == ih));
/* widget-to-image scales, X and Y */
- xwiratio = 1.0 * allocation.width / iw;
- ywiratio = 1.0 * allocation.height / ih;
- wiratio = xwiratio < ywiratio ? xwiratio : ywiratio;
+ double xwiratio = 1.0 * allocation.width / iw;
+ double ywiratio = 1.0 * allocation.height / ih;
+ double wiratio = xwiratio < ywiratio ? xwiratio : ywiratio;
/* scaled width and height */
- sw = iw * wiratio;
- sh = ih * wiratio;
+ int sw = iw * wiratio;
+ int sh = ih * wiratio;
/* offsets */
- ox = (allocation.width - sw) >> 1;
- oy = (allocation.height - sh) >> 1;
+ int ox = (allocation.width - sw) >> 1;
+ int oy = (allocation.height - sh) >> 1;
- scaled =
+ GdkPixbuf *scaled =
scaling_needed ? gdk_pixbuf_scale_simple (image, sw, sh,
GDK_INTERP_HYPER) :
image;
@@ -312,89 +309,6 @@ flag_exposed (GtkWidget * flag, GdkEventExpose * event
g_object_unref (G_OBJECT (scaled));
}
-gchar *
-gkbd_indicator_extract_layout_name (int group, XklEngine * engine,
- GkbdKeyboardConfig * kbd_cfg,
- gchar ** short_group_names,
- gchar ** full_group_names)
-{
- char *layout_name;
- if (group < g_strv_length (short_group_names)) {
- if (xkl_engine_get_features (engine) &
- XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
- char *full_layout_name = (char *)
- g_slist_nth_data (kbd_cfg->layouts_variants,
- group);
- char *variant_name;
- if (!gkbd_keyboard_config_split_items
- (full_layout_name, &layout_name,
- &variant_name))
- /* just in case */
- layout_name = full_layout_name;
-
- /* make it freeable */
- layout_name = g_strdup (layout_name);
-
- if (short_group_names != NULL) {
- char *short_group_name =
- short_group_names[group];
- if (short_group_name != NULL
- && *short_group_name != '\0') {
- /* drop the long name */
- g_free (layout_name);
- layout_name =
- g_strdup (short_group_name);
- }
- }
- } else {
- layout_name = g_strdup (full_group_names[group]);
- }
- }
-
- if (layout_name == NULL)
- layout_name = g_strdup ("??");
-
- return layout_name;
-}
-
-gchar *
-gkbd_indicator_create_label_title (int group, GHashTable ** ln2cnt_map,
- gchar * layout_name)
-{
- gpointer pcounter = NULL;
- char *prev_layout_name = NULL;
- char *lbl_title = NULL;
- int counter = 0;
-
- if (group == 0) {
- *ln2cnt_map =
- g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- }
-
- /* Process layouts with repeating description */
- if (g_hash_table_lookup_extended
- (*ln2cnt_map, layout_name, (gpointer *) & prev_layout_name,
- &pcounter)) {
- /* "next" same description */
- gchar appendix[10] = "";
- gint utf8length;
- gunichar cidx;
- counter = GPOINTER_TO_INT (pcounter);
- /* Unicode subscript 2, 3, 4 */
- cidx = 0x2081 + counter;
- utf8length = g_unichar_to_utf8 (cidx, appendix);
- appendix[utf8length] = '\0';
- lbl_title = g_strconcat (layout_name, appendix, NULL);
- } else {
- /* "first" time this description */
- lbl_title = g_strdup (layout_name);
- }
- g_hash_table_insert (*ln2cnt_map, layout_name,
- GINT_TO_POINTER (counter + 1));
- return lbl_title;
-}
-
static GtkWidget *
gkbd_indicator_prepare_drawing (GkbdIndicator * gki, int group)
{
@@ -417,32 +331,96 @@ gkbd_indicator_prepare_drawing (GkbdIndicator * gki, i
G_CALLBACK (flag_exposed), image);
gtk_container_add (GTK_CONTAINER (ebox), flag);
} else {
+ gpointer pcounter = NULL;
+ char *prev_layout_name = NULL, **ppln;
char *lbl_title = NULL;
+ int counter = 0;
char *layout_name = NULL;
GtkWidget *align, *label;
- static GHashTable *ln2cnt_map = NULL;
+ /**
+ * Map "short desciption" ->
+ * number of layouts in the configuration
+ * having this short description
+ */
+ static GHashTable *short_descrs = NULL;
- layout_name =
- gkbd_indicator_extract_layout_name (group,
- globals.engine,
- &globals.kbd_cfg,
- globals.short_group_names,
- globals.full_group_names);
+ if (group == 0)
+ short_descrs =
+ g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
- lbl_title =
- gkbd_indicator_create_label_title (group,
- &ln2cnt_map,
- layout_name);
+ if (group < g_strv_length (globals.short_group_names)) {
+ if (xkl_engine_get_features (globals.engine) &
+ XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
+ char *full_layout_name = (char *)
+ g_slist_nth_data (globals.kbd_cfg.
+ layouts_variants,
+ group);
+ char *variant_name;
+ if (!gkbd_keyboard_config_split_items
+ (full_layout_name, &layout_name,
+ &variant_name))
+ /* just in case */
+ layout_name = full_layout_name;
+
+ /* make it freeable */
+ layout_name = g_strdup (layout_name);
+
+ if (globals.short_group_names != NULL) {
+ char *short_group_name =
+ globals.short_group_names
+ [group];
+ if (short_group_name != NULL
+ && *short_group_name != '\0') {
+ /* drop the long name */
+ g_free (layout_name);
+ layout_name =
+ g_strdup
+ (short_group_name);
+ }
+ }
+ } else {
+ layout_name =
+ g_strdup (globals.full_group_names
+ [group]);
+ }
+ }
+
+ if (layout_name == NULL)
+ layout_name = g_strdup ("??");
+
+ /* Process layouts with repeating description */
+ ppln = &prev_layout_name;
+ if (g_hash_table_lookup_extended
+ (short_descrs, layout_name,
+ (gpointer *) ppln, &pcounter)) {
+ /* "next" same description */
+ gchar appendix[10] = "";
+ gint utf8length;
+ gunichar cidx;
+ counter = GPOINTER_TO_INT (pcounter);
+ /* Unicode subscript 2, 3, 4 */
+ cidx = 0x2081 + counter;
+ utf8length = g_unichar_to_utf8 (cidx, appendix);
+ appendix[utf8length] = '\0';
+ lbl_title =
+ g_strconcat (layout_name, appendix, NULL);
+ } else {
+ /* "first" time this description */
+ lbl_title = g_strdup (layout_name);
+ }
+ g_hash_table_insert (short_descrs, layout_name,
+ GINT_TO_POINTER (counter + 1));
+
align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
label = gtk_label_new (lbl_title);
g_free (lbl_title);
gtk_label_set_angle (GTK_LABEL (label), gki->priv->angle);
- if (group + 1 ==
- xkl_engine_get_num_groups (globals.engine)) {
- g_hash_table_destroy (ln2cnt_map);
- ln2cnt_map = NULL;
+ if (group == xkl_engine_get_num_groups (globals.engine)) {
+ g_hash_table_destroy (short_descrs);
+ short_descrs = NULL;
}
gtk_container_add (GTK_CONTAINER (align), label);

View File

@ -0,0 +1,273 @@
$OpenBSD: patch-libgnomekbd_gkbd-status_c,v 1.1 2010/05/02 08:42:25 ajacoutot Exp $
Revert upstream commits that broke gnome-screensaver:
9b4b27724e97686521b7daacf7f8c4c4936e339b
342b82bfd0308275618180652dc56e7d9b663642
--- libgnomekbd/gkbd-status.c.orig Sat Apr 17 03:09:30 2010
+++ libgnomekbd/gkbd-status.c Sun May 2 10:30:25 2010
@@ -43,10 +43,7 @@ typedef struct _gki_globals {
gchar **full_group_names;
gchar **short_group_names;
- gint current_width;
- gint current_height;
- int real_width;
-
+ gint current_size;
GSList *icons; /* list of GdkPixbuf */
GSList *widget_instances; /* list of GkbdStatus */
gulong state_changed_handler;
@@ -125,32 +122,12 @@ gkbd_status_activate (GkbdStatus * gki)
gkbd_desktop_config_lock_next_group (&globals.cfg);
}
-/* hackish xref */
-extern gchar *gkbd_indicator_extract_layout_name (int group,
- XklEngine * engine,
- GkbdKeyboardConfig *
- kbd_cfg,
- gchar **
- short_group_names,
- gchar **
- full_group_names);
-
-extern gchar *gkbd_indicator_create_label_title (int group,
- GHashTable **
- ln2cnt_map,
- gchar * layout_name);
-
static void
gkbd_status_render_cairo (cairo_t * cr, int group)
{
+ cairo_text_extents_t te;
+ gchar *lbl = globals.short_group_names[group];
double r, g, b;
- PangoFontDescription *pfd;
- PangoContext *pcc;
- PangoLayout *pl;
- int lwidth, lheight;
- gchar *layout_name, *lbl_title;
- cairo_font_options_t *fo;
- static GHashTable *ln2cnt_map = NULL;
if (globals.ind_cfg.background_color != NULL &&
globals.ind_cfg.background_color[0] != 0) {
@@ -158,8 +135,8 @@ gkbd_status_render_cairo (cairo_t * cr, int group)
(globals.ind_cfg.background_color, "%lg %lg %lg", &r,
&g, &b) == 3) {
cairo_set_source_rgb (cr, r, g, b);
- cairo_rectangle (cr, 0, 0, globals.current_width,
- globals.current_height);
+ cairo_rectangle (cr, 0, 0, globals.current_size,
+ globals.current_size);
cairo_fill (cr);
}
}
@@ -180,65 +157,19 @@ gkbd_status_render_cairo (cairo_t * cr, int group)
CAIRO_FONT_WEIGHT_NORMAL);
}
- pfd = pango_font_description_new ();
- pango_font_description_set_family (pfd,
- globals.ind_cfg.font_family);
- pango_font_description_set_style (pfd, PANGO_STYLE_NORMAL);
- pango_font_description_set_weight (pfd, PANGO_WEIGHT_NORMAL);
- pango_font_description_set_size (pfd,
- globals.ind_cfg.font_size *
- PANGO_SCALE);
-
- pcc = pango_cairo_create_context (cr);
-
- fo = cairo_font_options_copy (gdk_screen_get_font_options
- (gdk_screen_get_default ()));
- /* SUBPIXEL antialiasing gives bad results on in-memory images */
- if (cairo_font_options_get_antialias (fo) ==
- CAIRO_ANTIALIAS_SUBPIXEL)
- cairo_font_options_set_antialias (fo,
- CAIRO_ANTIALIAS_GRAY);
- pango_cairo_context_set_font_options (pcc, fo);
-
- pl = pango_layout_new (pcc);
-
- layout_name = gkbd_indicator_extract_layout_name (group,
- globals.engine,
- &globals.kbd_cfg,
- globals.short_group_names,
- globals.full_group_names);
- lbl_title =
- gkbd_indicator_create_label_title (group, &ln2cnt_map,
- layout_name);
-
- if (group + 1 == xkl_engine_get_num_groups (globals.engine)) {
- g_hash_table_destroy (ln2cnt_map);
- ln2cnt_map = NULL;
+ if (globals.ind_cfg.font_size > 0) {
+ cairo_set_font_size (cr, globals.ind_cfg.font_size);
}
- pango_layout_set_text (pl, lbl_title, -1);
-
- g_free (lbl_title);
-
- pango_layout_set_font_description (pl, pfd);
- pango_layout_get_size (pl, &lwidth, &lheight);
-
+ cairo_text_extents (cr, lbl, &te);
cairo_move_to (cr,
- (globals.current_width - lwidth / PANGO_SCALE) / 2,
- (globals.current_height -
- lheight / PANGO_SCALE) / 2);
+ (globals.current_size >> 1) - te.width / 2 -
+ te.x_bearing,
+ (globals.current_size >> 1) - te.height / 2 -
+ te.y_bearing);
+ cairo_show_text (cr, lbl);
- pango_cairo_show_layout (cr, pl);
-
- pango_font_description_free (pfd);
- g_object_unref (pl);
- g_object_unref (pcc);
- cairo_font_options_destroy (fo);
cairo_destroy (cr);
-
- globals.real_width = (lwidth / PANGO_SCALE) + 4;
- if (globals.real_width > globals.current_width)
- globals.real_width = globals.current_width;
}
static inline guint8
@@ -249,33 +180,27 @@ convert_color_channel (guint8 src, guint8 alpha)
static void
convert_bgra_to_rgba (guint8 const *src, guint8 * dst, int width,
- int height, int new_width)
+ int height)
{
- int xoffset = width - new_width;
-
- /* *4 */
- int ptr_step = xoffset << 2;
-
+ guint8 const *src_pixel = src;
+ guint8 *dst_pixel = dst;
int x, y;
- /* / 2 * 4 */
- src = src + ((xoffset >> 1) << 2);
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dst_pixel[0] =
+ convert_color_channel (src_pixel[2],
+ src_pixel[3]);
+ dst_pixel[1] =
+ convert_color_channel (src_pixel[1],
+ src_pixel[3]);
+ dst_pixel[2] =
+ convert_color_channel (src_pixel[0],
+ src_pixel[3]);
+ dst_pixel[3] = src_pixel[3];
- for (y = height; --y >= 0; src += ptr_step) {
- for (x = new_width; --x >= 0;) {
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- dst[0] = convert_color_channel (src[2], src[3]);
- dst[1] = convert_color_channel (src[1], src[3]);
- dst[2] = convert_color_channel (src[0], src[3]);
- dst[3] = src[3];
-#else
- dst[0] = convert_color_channel (src[1], src[0]);
- dst[1] = convert_color_channel (src[2], src[0]);
- dst[2] = convert_color_channel (src[3], src[0]);
- dst[3] = src[0];
-#endif
- dst += 4;
- src += 4;
+ dst_pixel += 4;
+ src_pixel += 4;
}
}
}
@@ -287,7 +212,7 @@ gkbd_status_prepare_drawing (GkbdStatus * gki, int gro
char *image_filename;
GdkPixbuf *image;
- if (globals.current_width == 0)
+ if (globals.current_size == 0)
return NULL;
if (globals.ind_cfg.show_flags) {
@@ -298,8 +223,8 @@ gkbd_status_prepare_drawing (GkbdStatus * gki, int gro
group);
image = gdk_pixbuf_new_from_file_at_size (image_filename,
- globals.current_width,
- globals.current_height,
+ globals.current_size,
+ globals.current_size,
&gerror);
if (image == NULL) {
@@ -338,25 +263,25 @@ gkbd_status_prepare_drawing (GkbdStatus * gki, int gro
} else {
cairo_surface_t *cs =
cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- globals.current_width,
- globals.current_height);
+ globals.current_size,
+ globals.current_size);
unsigned char *cairo_data;
guchar *pixbuf_data;
gkbd_status_render_cairo (cairo_create (cs), group);
cairo_data = cairo_image_surface_get_data (cs);
+ pixbuf_data =
+ g_new0 (guchar,
+ 4 * globals.current_size *
+ globals.current_size);
+ convert_bgra_to_rgba (cairo_data, pixbuf_data,
+ globals.current_size,
+ globals.current_size);
+
#if 0
char pngfilename[20];
g_sprintf (pngfilename, "label%d.png", group);
cairo_surface_write_to_png (cs, pngfilename);
#endif
- pixbuf_data =
- g_new0 (guchar,
- 4 * globals.real_width *
- globals.current_height);
- convert_bgra_to_rgba (cairo_data, pixbuf_data,
- globals.current_width,
- globals.current_height,
- globals.real_width);
cairo_surface_destroy (cs);
@@ -364,10 +289,9 @@ gkbd_status_prepare_drawing (GkbdStatus * gki, int gro
GDK_COLORSPACE_RGB,
TRUE,
8,
- globals.real_width,
- globals.current_height,
- globals.real_width *
- 4,
+ globals.current_size,
+ globals.current_size,
+ globals.current_size * 4,
(GdkPixbufDestroyNotify)
g_free, NULL);
xkl_debug (150,
@@ -608,9 +532,8 @@ gkbd_status_stop_listen (void)
static void
gkbd_status_size_changed (GkbdStatus * gki, gint size)
{
- if (globals.current_height != size) {
- globals.current_height = size;
- globals.current_width = size * 3 / 2;
+ if (globals.current_size != size) {
+ globals.current_size = size;
gkbd_status_reinit_ui (gki);
}
}