Re: a patch for at-poke



Hi Michael,

I found the way to do that all in gdk abstraction. The new patch is attached. I think it is better now. If no other comments, I will ask Bill to help me commit it.

Regards,
--Bolian

Michael Meeks wrote:

Hi Bolian,

On Mon, 2003-05-26 at 11:08, Bolian Yin wrote:
I am using your at-poke.  Thanks for your great work.

	Well; Padraig has been doing the lifting since I abandoned it in action
;-)

I have a patch for it which can draw a rectangle on the current selected widget by at-poke.

	It looks nice;

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?

	The feature looks uber-cool; I imagine Bill'd love this for his
up-coming at-poke demo's ;-)

+	/* 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);

	I'd rather prefer to do this with the gdk abstraction, but I guess that
the IncludeInferiors isn't working for you ? :-)

	If that's the case - then please do commit; this looks great.

	Regards,

		Michael.

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	27 May 2003 02:53:05 -0000
@@ -29,6 +29,8 @@
 #include <glade/glade-xml.h>
 #include <libgnomeui/gnome-ui-init.h>
 
+#include <gdk/gdk.h>
+
 #include "graphics.h"
 #include "child-listener.h"
 #include "accessible-listener.h"
@@ -312,6 +314,61 @@
 	AccessibleComponent_unref (component);
 }
 
+/* the stuff to blink */
+static int blink_count = 4;
+static int blink_interval = 200;  /* 0.2 s */
+static int blink_x = 0, blink_y = 0, blink_w = 0, blink_h = 0;
+static GtkWidget *blink_widget = NULL;
+
+static gboolean
+draw_root_subwin(gpointer data)
+{
+	GdkDisplay *display = gdk_display_get_default();
+	GdkScreen *screen = gdk_display_get_default_screen(display);
+	GdkWindow *root_window = gdk_screen_get_root_window(screen);
+ 
+	GdkGC *gc = gdk_gc_new(root_window);
+
+	/* grab mouse for the invisible widget when we are blinking */
+	if (!blink_widget) {
+		blink_widget = gtk_invisible_new_for_screen(screen);
+		gtk_widget_show(blink_widget);
+		gtk_grab_add(blink_widget);
+	}
+
+	/* set subwindow mode, function and line attributes for our GC */
+	gdk_gc_set_subwindow(gc, GDK_INCLUDE_INFERIORS);
+	gdk_gc_set_function(gc, GDK_INVERT);
+	gdk_gc_set_line_attributes(gc, 3, GDK_LINE_SOLID,
+				   GDK_CAP_BUTT, GDK_JOIN_MITER);
+	gdk_draw_rectangle(root_window, gc, FALSE,
+			   blink_x, blink_y, blink_w, blink_h);
+	g_object_unref(gc);
+
+	--blink_count;
+
+	/* return FALSE will destroy the timer. */
+	if (blink_count <= 0) {
+		gtk_grab_remove(blink_widget);
+		gtk_widget_destroy(blink_widget);
+		blink_widget = 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]