? autom4te.cache
? gnome-mag-struts.diff
? cursors/Makefile
? cursors/Makefile.in
? cursors/1_32/Makefile
? cursors/1_32/Makefile.in
? test/control-client
? test/mag-test
Index: magnifier/magnifier-main.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier-main.c,v
retrieving revision 1.29
diff -u -r1.29 magnifier-main.c
--- magnifier/magnifier-main.c	8 Apr 2004 20:57:19 -0000	1.29
+++ magnifier/magnifier-main.c	10 Jun 2004 22:40:47 -0000
@@ -65,6 +65,7 @@
 	int   border_width;
 	unsigned long  border_color;
 	int   test_pattern;
+        int   is_override_redirect;
 } MagnifierOptions;
 
 static MagnifierOptions global_options = { ":0.0",
@@ -93,6 +94,7 @@
 					   1,
 					   0,
 					   0,
+					   0,
 					   0
                                          };
 
@@ -122,6 +124,7 @@
 	{"border-size", 'b', POPT_ARG_INT, &global_options.border_width, '\0', "width of border", NULL},
 	{"border-color", 'c', POPT_ARG_LONG, &global_options.border_color, '\0', "border color specified as (A)RGB 23-bit value, Alpha-MSB", NULL},
 	{"use-test-pattern", '\0', POPT_ARG_NONE, &global_options.test_pattern, '\0', "use test pattern as source", NULL},
+	{"override-redirect", '\0', POPT_ARG_NONE, &global_options.is_override_redirect, '\0', "make the magnifier window totally unmanaged by the window manager", NULL},
 	POPT_AUTOHELP
 	{NULL, 0, 0, NULL, 0, 0}
 };
@@ -382,7 +385,7 @@
   /* FIXME */
   gtk_init (&argc, &argv);
 
-  magnifier = magnifier_new ();
+  magnifier = magnifier_new (global_options.is_override_redirect);
   fprintf (stderr, "New magnifier created.\n");
   
   properties = GNOME_Magnifier_Magnifier_getProperties (
Index: magnifier/magnifier-private.h
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier-private.h,v
retrieving revision 1.5
diff -u -r1.5 magnifier-private.h
--- magnifier/magnifier-private.h	8 Apr 2004 19:30:41 -0000	1.5
+++ magnifier/magnifier-private.h	10 Jun 2004 22:40:47 -0000
@@ -40,7 +40,7 @@
         int cursor_default_size_y;
 	gboolean crosswire;
 	GdkBitmap *cursor_mask;
-	int cursor_x;
+ 	int cursor_x;
 	int cursor_y;
 	int cursor_hotspot_x;
 	int cursor_hotspot_y;
Index: magnifier/magnifier.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.c,v
retrieving revision 1.43
diff -u -r1.43 magnifier.c
--- magnifier/magnifier.c	14 May 2004 11:20:18 -0000	1.43
+++ magnifier/magnifier.c	10 Jun 2004 22:40:49 -0000
@@ -39,12 +39,24 @@
 #include "zoom-region-private.h"
 #include "GNOME_Magnifier.h"
 
-
-#define MAG_WINDOW_OVERRIDE_REDIRECT
-
 static GObjectClass *parent_class = NULL;
 
 enum {
+	STRUT_LEFT = 0,
+	STRUT_RIGHT = 1,
+	STRUT_TOP = 2,
+	STRUT_BOTTOM = 3,
+	STRUT_LEFT_START = 4,
+	STRUT_LEFT_END = 5,
+	STRUT_RIGHT_START = 6,
+	STRUT_RIGHT_END = 7,
+	STRUT_TOP_START = 8,
+	STRUT_TOP_END = 9,
+	STRUT_BOTTOM_START = 10,
+	STRUT_BOTTOM_END = 11
+};
+
+enum {
 	MAGNIFIER_SOURCE_DISPLAY_PROP,
 	MAGNIFIER_TARGET_DISPLAY_PROP,
 	MAGNIFIER_SOURCE_SIZE_PROP,
@@ -66,6 +78,9 @@
 
 static void magnifier_transform_cursor (Magnifier *magnifier);
 static void magnifier_init_cursor_set (Magnifier *magnifier, gchar *cursor_set);
+static gboolean magnifier_check_set_struts (Magnifier *magnifier);
+static gboolean magnifier_reset_struts_at_idle (gpointer data);
+static gboolean _is_override_redirect = FALSE;
 
 gboolean
 magnifier_error_check (void)
@@ -781,6 +796,100 @@
 	magnifier_transform_cursor (magnifier);
 }
 
+static gboolean 
+magnifier_reset_struts_at_idle (gpointer data)
+{
+	if (data)
+	{
+		Magnifier *magnifier = MAGNIFIER (data);
+		if (magnifier->priv && GTK_WIDGET_REALIZED (magnifier->priv->w) && 
+		    magnifier_check_set_struts (magnifier))
+		{
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+static gboolean
+magnifier_check_set_struts (Magnifier *magnifier)
+{
+	/* TODO: don't do this if we're using Composite */
+	if (magnifier &&
+	    magnifier->priv && magnifier->priv->w && GTK_WIDGET_REALIZED (magnifier->priv->w) &&
+	    magnifier->priv->w->window) 
+	{
+		Atom atom_strut = gdk_x11_get_xatom_by_name ("_NET_WM_STRUT");
+		Atom atom_strut_partial = gdk_x11_get_xatom_by_name ("_NET_WM_STRUT_PARTIAL");
+		guint32 struts[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+		GtkWidget *widget = magnifier->priv->w;
+		gint width = gdk_screen_get_width (
+			gdk_display_get_screen (magnifier->target_display,
+						magnifier->target_screen_num));
+		gint height = gdk_screen_get_height (
+			gdk_display_get_screen (magnifier->target_display,
+						magnifier->target_screen_num));
+
+		gint right_margin, left_margin, top_margin, bottom_margin;
+		gint wx, wy, ww, wh;
+
+		gtk_window_get_position (GTK_WINDOW (magnifier->priv->w), &wx, &wy);
+		gtk_window_get_size (GTK_WINDOW (magnifier->priv->w), &ww, &wh);
+
+		left_margin = wx;
+		right_margin = (width - ww) - wx;
+		top_margin = wy;
+		bottom_margin = (height - wh) - wy;
+
+		/* set the WM_STRUT properties on the appropriate side */
+		if (bottom_margin > top_margin && 
+		    bottom_margin > left_margin &&
+		    bottom_margin > right_margin)
+		{
+			struts[STRUT_TOP] = wh + wy;
+			struts[STRUT_TOP_START] = wx;
+			struts[STRUT_TOP_END] = wx + ww;
+		} 
+		else if (top_margin > bottom_margin && 
+			 top_margin > left_margin &&
+			 top_margin > right_margin)
+		{
+			struts[STRUT_BOTTOM] = height - wh - wy;
+			struts[STRUT_BOTTOM_START] = wx;
+			struts[STRUT_BOTTOM_END] = wx + ww;
+		}
+		else if (right_margin > left_margin &&
+			 right_margin > top_margin &&
+			 right_margin > bottom_margin)
+		{
+			struts[STRUT_LEFT] = wx;
+			struts[STRUT_LEFT_START] = wy;
+			struts[STRUT_LEFT_END] = wh + wy;
+		}
+		else 
+		{
+			struts[STRUT_RIGHT] = wx;
+			struts[STRUT_RIGHT_START] = wy;
+			struts[STRUT_RIGHT_END] = wy + wh;
+		}
+		
+		gdk_error_trap_push ();
+		XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window), 
+				 GDK_WINDOW_XWINDOW (widget->window), 
+				 atom_strut,
+				 XA_CARDINAL, 32, PropModeReplace,
+				 (guchar *) &struts, 4);
+		XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window), 
+				 GDK_WINDOW_XWINDOW (widget->window), 
+				 atom_strut_partial,
+				 XA_CARDINAL, 32, PropModeReplace,
+				 (guchar *) &struts, 12); 
+		gdk_error_trap_pop ();
+		return TRUE;
+	}
+	return FALSE;
+}
+
 static void
 magnifier_get_property (BonoboPropertyBag *bag,
 			BonoboArg *arg,
@@ -872,6 +981,7 @@
 					magnifier->source_screen_num));
 		magnifier_warp_cursor_to_screen (magnifier);
 		magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
+		magnifier_check_set_struts (magnifier);
 		break;
 	case MAGNIFIER_TARGET_DISPLAY_PROP:
 		full_display_string = BONOBO_ARG_GET_STRING (arg);
@@ -889,6 +999,7 @@
 		magnifier_get_display_rect_bounds (magnifier, &magnifier->target_bounds, TRUE);
 		magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
 		magnifier_reparent_zoom_regions (magnifier);
+		magnifier_check_set_struts (magnifier);
 		break;
 	case MAGNIFIER_SOURCE_SIZE_PROP:
 	        magnifier->source_bounds = BONOBO_ARG_GET_GENERAL (arg,
@@ -1325,15 +1436,14 @@
 static void
 magnifier_init_window (Magnifier *magnifier)
 {
+	GtkWindowType mag_win_type = GTK_WINDOW_TOPLEVEL;
+	if (_is_override_redirect) mag_win_type = GTK_WINDOW_POPUP;
+
 	magnifier->priv->w =
 		g_object_connect (gtk_widget_new (gtk_window_get_type (),
 						  "user_data", NULL,
 						  "can_focus", FALSE,
-#ifdef MAG_WINDOW_OVERRIDE_REDIRECT
-						  "type", GTK_WINDOW_POPUP,
-#else
-						  "type", GTK_WINDOW_TOPLEVEL,
-#endif
+						  "type", mag_win_type,  
 						  "title", "magnifier",
 						  "allow_grow", TRUE,
 						  "allow_shrink", TRUE,
@@ -1397,19 +1507,24 @@
 }
 
 Magnifier *
-magnifier_new (void)
+magnifier_new (gboolean override_redirect)
 {
 	Magnifier *mag;
 	int ret;
 
+	_is_override_redirect = override_redirect;
+
 	mag = g_object_new (magnifier_get_type(), NULL);
+	
 	ret = bonobo_activation_active_server_register (
 		MAGNIFIER_OAFIID, BONOBO_OBJREF (mag));
 	if (ret != Bonobo_ACTIVATION_REG_SUCCESS)
 	    g_error ("Error registering magnifier server.\n");
 	else
 	    g_message ("The magnifier server was successfully registred.\n");
-	
+
+	g_idle_add (magnifier_reset_struts_at_idle, mag);
+
 	return mag;
 }
 
Index: magnifier/magnifier.h
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.h,v
retrieving revision 1.11
diff -u -r1.11 magnifier.h
--- magnifier/magnifier.h	8 Apr 2004 19:30:41 -0000	1.11
+++ magnifier/magnifier.h	10 Jun 2004 22:40:49 -0000
@@ -74,7 +74,7 @@
 GdkDrawable *magnifier_get_cursor    (Magnifier *magnifier);
 GType        magnifier_get_type      (void);
 GdkWindow   *magnifier_get_root      (Magnifier *magnifier);
-Magnifier   *magnifier_new           (void);
+Magnifier   *magnifier_new           (gboolean override_redirect);
 gboolean     magnifier_error_check   (void);
 void         magnifier_notify_damage (Magnifier *magnifier, XRectangle *rect);
 
