[gnome-mag/cairo-port] Restore cursor-color property, although is currently ignored



commit cd8edc7426d4317b7da5afccca40155a17798e74
Author: Fernando Herrera <fherrera onirica com>
Date:   Fri Aug 13 18:29:10 2010 +0200

    Restore cursor-color property, although is currently ignored

 configure.in               |    4 ++--
 magnifier/magnifier-main.c |    4 ++++
 magnifier/magnifier.c      |   35 +++++++++++++++++++++++------------
 magnifier/magnifier.h      |    1 +
 4 files changed, 30 insertions(+), 14 deletions(-)
---
diff --git a/configure.in b/configure.in
index f9f9a8c..f746dc9 100644
--- a/configure.in
+++ b/configure.in
@@ -243,7 +243,7 @@ AC_SUBST(LIBDEPS_CFLAGS)
 
 PKG_CHECK_MODULES(DEPS, [
 	glib-2.0		>= 2.25.9
-	gtk+-2.0		>= 2.21.2
+	gtk+-3.0		>= 2.21.2
 	gdk-pixbuf-2.0		>= 2.21.2
 ])
 AC_SUBST(DEPS_LIBS)
@@ -251,7 +251,7 @@ AC_SUBST(DEPS_CFLAGS)
 
 PKG_CHECK_MODULES(TEST, [
 	glib-2.0		>= 2.25.9
-	gtk+-2.0		>= 2.21.2
+	gtk+-3.0		>= 2.21.2
 	gdk-pixbuf-2.0		>= 2.21.2
 ])
 AC_SUBST(TEST_LIBS)
diff --git a/magnifier/magnifier-main.c b/magnifier/magnifier-main.c
index bc5f2bc..c6580d7 100644
--- a/magnifier/magnifier-main.c
+++ b/magnifier/magnifier-main.c
@@ -53,6 +53,7 @@ typedef struct {
 	gint      mouse_poll_time;
 	gint      cursor_size;
 	gdouble   cursor_scale_factor;
+	gint64    cursor_color;
 	gboolean  vertical_split;
 	gboolean  horizontal_split;
 	gboolean  fullscreen;
@@ -89,6 +90,7 @@ static MagnifierOptions global_options = { NULL,      /* target_display */
 					   50,        /* mouse_poll_time */
 					   0,         /* cursor_size */
 					   0.0F,      /* cursor_scale_factor */
+					   0xFF000000,/* cursor_color */
 					   0,         /* vertical_split */
 					   0,         /* horizontal_split */
 					   0,         /* fullscreen */
@@ -119,6 +121,7 @@ static GOptionEntry magnifier_options [] = {
 	{"source-display", 's', 0, G_OPTION_ARG_STRING, &global_options.source_display, "specify display to magnify", NULL},
 	{"cursor-set", 0, 0, G_OPTION_ARG_STRING, &global_options.cursor_set, "cursor set to use in target display", NULL},
 	{"cursor-size", 0, 0, G_OPTION_ARG_INT, &global_options.cursor_size, "cursor size to use (overrides cursor-scale-factor)", NULL},
+	{"cursor-color", 0, 0, G_OPTION_ARG_INT64, &global_options.cursor_color, "cursor color (applied to \'black\' pixels)", NULL},
 	{"cursor-scale-factor", 0, 0, G_OPTION_ARG_DOUBLE, &global_options.cursor_scale_factor, "cursor scale factor", NULL},
 	{"vertical", 'v', 0, G_OPTION_ARG_NONE, &global_options.vertical_split, "split screen vertically (if target display = source display)", NULL},
 	{"horizontal", 'h', 0, G_OPTION_ARG_NONE, &global_options.horizontal_split, "split screen horizontally (if target display = source display)", NULL},
@@ -380,6 +383,7 @@ main (int argc, char** argv)
 		"cursor-size", global_options.cursor_size,
 		"cursor-scale-factor", global_options.cursor_scale_factor != 0.0F ?
 		global_options.cursor_scale_factor : global_options.zoom_factor,
+		"cursor-color", global_options.cursor_color,
 		NULL);
 
   if (!global_options.show_crosswires)
diff --git a/magnifier/magnifier.c b/magnifier/magnifier.c
index 515a288..672eba7 100644
--- a/magnifier/magnifier.c
+++ b/magnifier/magnifier.c
@@ -53,6 +53,7 @@ enum {
 	MAGNIFIER_CURSOR_SET_PROP,
 	MAGNIFIER_CURSOR_SIZE_PROP,
 	MAGNIFIER_CURSOR_ZOOM_PROP,
+	MAGNIFIER_CURSOR_COLOR_PROP,
 	MAGNIFIER_CURSOR_DEFAULT_SIZE_PROP,
 	MAGNIFIER_CROSSWIRE_SIZE_PROP,
 	MAGNIFIER_CROSSWIRE_LENGTH_PROP,
@@ -846,6 +847,8 @@ get_property_cb (GDBusConnection *connection,
 		retval = g_variant_new_array (G_VARIANT_TYPE_INT32, children, 2);
 	} else if (g_strcmp0 (property_name, "CursorZoom") == 0) {
 		retval = g_variant_new_double (magnifier->cursor_scale_factor);
+	} else if (g_strcmp0 (property_name, "CursorColor") == 0) {
+		retval = g_variant_new_uint32 (magnifier->cursor_color);
 	} else if (g_strcmp0 (property_name, "CursorDefaultSize") == 0) {
 		gint32 csize = 0;
 
@@ -918,17 +921,10 @@ set_property_cb (GDBusConnection *connection,
 		g_object_set (magnifier,
 			      "cursor-scale-factor", g_variant_get_double (value),
 			      NULL);
-	} else if (g_strcmp0 (property_name, "CursorHotspot") == 0) {
-		const int *items;
-		gsize      n_items;
-		Point      point;
-
-		items = g_variant_get_fixed_array (value, &n_items, sizeof (gint32));
-		if (n_items == 2) {
-			point.x = items[0];
-			point.y = items[1];
-		}
-		g_object_set (magnifier, "cursor-hotspot", &point, NULL);
+	} else if (g_strcmp0 (property_name, "CursorColor") == 0) {
+		g_object_set (magnifier,
+			      "cursor-color", g_variant_get_uint32 (value),
+			      NULL);
 	} else if (g_strcmp0 (property_name, "CrosswireSize") == 0) {
 		g_object_set (magnifier,
 			      "crosswire-size", g_variant_get_int32 (value),
@@ -992,7 +988,6 @@ static const gchar introspection_xml[] =
     "<property name='CursorSize' type='i' access='readwrite'/>"
     "<property name='CursorZoom' type='d' access='readwrite'/>"
     "<property name='CursorColor' type='u' access='readwrite'/>"
-    "<property name='CursorHotspot' type='ai' access='readwrite'/>"
     "<property name='CrosswireSize' type='i' access='readwrite'/>"
     "<property name='CrosswireLength' type='i' access='readwrite'/>"
     "<property name='CrosswireClip' type='b' access='readwrite'/>"
@@ -1077,6 +1072,9 @@ magnifier_gobject_get_property (GObject    *object,
 	case MAGNIFIER_CURSOR_ZOOM_PROP:
 		g_value_set_float (value, magnifier->cursor_scale_factor);
 		break;
+	case MAGNIFIER_CURSOR_COLOR_PROP:
+		g_value_set_ulong (value, magnifier->cursor_color);
+		break;
 	case MAGNIFIER_CURSOR_DEFAULT_SIZE_PROP: {
 		int csize = 0;
 
@@ -1291,6 +1289,11 @@ magnifier_gobject_set_property (GObject      *object,
 		magnifier->cursor_scale_factor = g_value_get_float (value);
 		DBG (fprintf (stderr, "Setting cursor scale factor: \t%f\n", (float) magnifier->cursor_scale_factor));
 		break;
+	case MAGNIFIER_CURSOR_COLOR_PROP:
+		magnifier->cursor_color = g_value_get_ulong (value);
+		//magnifier_transform_cursor (magnifier);
+		DBG (fprintf (stderr, "Setting cursor color: \t%u\n", (unsigned) magnifier->cursor_color));
+		break;
 	case MAGNIFIER_CROSSWIRE_SIZE_PROP:
 		magnifier->crosswire_size = g_value_get_int (value);
 		DBG (fprintf (stderr, "Setting crosswire size: \t%d\n", magnifier->crosswire_size));
@@ -1324,6 +1327,7 @@ magnifier_init (Magnifier *magnifier)
 	magnifier->priv = MAGNIFIER_GET_PRIVATE (magnifier);
 
 	magnifier->cursor_scale_factor = 1.0F;
+	magnifier->cursor_color = 0xFF000000;
 	magnifier->crosswire_size = 1;
 	magnifier->priv->use_source_cursor = TRUE;
 	magnifier_init_cursor_set (magnifier, "default");
@@ -1429,6 +1433,13 @@ magnifier_class_init (MagnifierClass *klass)
 							     0, G_MAXFLOAT, 1.0F,
 							     G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
+					 MAGNIFIER_CURSOR_COLOR_PROP,
+					 g_param_spec_ulong ("cursor-color",
+							     "CursorColor",
+							     "foreground color for 1-bit cursors, as ARGB",
+							     0, G_MAXULONG, 0xFF000000,
+							     G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
 					 MAGNIFIER_CURSOR_DEFAULT_SIZE_PROP,
 					 g_param_spec_int ("cursor-default-size",
 							   "CursorDefaultSize",
diff --git a/magnifier/magnifier.h b/magnifier/magnifier.h
index cfd640e..43bd93c 100644
--- a/magnifier/magnifier.h
+++ b/magnifier/magnifier.h
@@ -59,6 +59,7 @@ typedef struct {
 	gchar             *cursor_set;
 	gint               cursor_size_x;
 	gint               cursor_size_y;
+	guint32            cursor_color;
 	float              cursor_scale_factor;
 	RectBounds         source_bounds;
 	RectBounds         target_bounds;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]