a patch for at-poke



Hi Michael,

I am using your at-poke.  Thanks for your great work.
I have a patch for it which can draw a rectangle on the current selected widget by at-poke. This patch explictly use many Xlib calls, I don't know if you like it to be checked in cvs. But I think it is really helpful, because there are so may items in the at-poke tree, I cannot relate them to the widgets of applications. What's your opinion about the patch?

Thanks,
Bolian

? a
Index: poke.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/poke.c,v
retrieving revision 1.31
diff -u -r1.31 poke.c
--- poke.c	4 Feb 2003 11:45:31 -0000	1.31
+++ poke.c	26 May 2003 09:05:10 -0000
@@ -29,6 +29,8 @@
 #include <glade/glade-xml.h>
 #include <libgnomeui/gnome-ui-init.h>
 
+#include <gdk/gdkx.h>
+
 #include "graphics.h"
 #include "child-listener.h"
 #include "accessible-listener.h"
@@ -312,6 +314,61 @@
 	AccessibleComponent_unref (component);
 }
 
+static int blink_count = 4;
+static int blink_interval = 200;  /* 0.2 ms */
+static int blink_x = 0, blink_y = 0, blink_w = 0, blink_h = 0;
+static GtkWidget *blinkWidget = NULL;
+
+static gboolean
+draw_root_subwin(gpointer data)
+{
+	XGCValues gcValues;
+	GC gc;
+
+	GdkDisplay * display = gdk_display_get_default();
+	Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
+	GdkScreen *screen = gdk_display_get_default_screen (display);
+	GdkWindow *root_window = gdk_screen_get_root_window (screen);
+	Window xroot_window = GDK_WINDOW_XID (root_window);
+
+	if (!blinkWidget) {
+		blinkWidget = gtk_invisible_new_for_screen (screen);
+		gtk_widget_show(blinkWidget);
+		gtk_grab_add(blinkWidget);
+	}
+
+	/* create GC, and set it's subwindow mode and function */
+	gc = XCreateGC(xdisplay, xroot_window, 0, &gcValues);
+	XSetSubwindowMode(xdisplay, gc, IncludeInferiors);
+	XSetFunction(xdisplay, gc, GXinvert);
+	XSetLineAttributes(xdisplay, gc, 6, LineSolid, CapButt, JoinMiter);
+
+	XDrawRectangle(xdisplay, xroot_window, gc, blink_x, blink_y, blink_w, blink_h);
+	XFreeGC(xdisplay, gc);
+
+	--blink_count;
+	/* return FALSE will destroy the timer. */
+	if (blink_count == 0) {
+		gtk_grab_remove(blinkWidget);
+		gtk_widget_destroy(blinkWidget);
+		blinkWidget = NULL;
+		return FALSE;
+	}
+	return TRUE;
+}
+
+static void
+component_blink_extens(long int x, long int y, long int w, long int h)
+{
+	blink_count = 4;  /* this should be an even number */
+	blink_x = x;
+	blink_y = y;
+	blink_w = w;
+	blink_h = h;
+
+	g_timeout_add(blink_interval, draw_root_subwin, NULL);
+}
+
 static void
 update_if_component (Poker *poker, AccessibleComponent *component)
 {
@@ -335,8 +392,14 @@
 		{ 0, NULL }
 	};
 
+	/* make our blinks */
 	AccessibleComponent_getExtents (
-		component, &x, &y, &w, &h, poker->ctype);
+		component, &x, &y, &w, &h, SPI_COORD_TYPE_SCREEN);
+	component_blink_extens(x, y, w, h);
+
+	if (poker->ctype != SPI_COORD_TYPE_SCREEN)
+		AccessibleComponent_getExtents (
+						component, &x, &y, &w, &h, poker->ctype);
 
 	widget = glade_xml_get_widget (poker->xml, "component_if_position");
 	txt = g_strdup_printf ("%ld, %ld", x, y);


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