public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* Making gdk-event-area work
@ 2000-09-04  3:37 Mark Seaborn
  2000-09-05 11:41 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Seaborn @ 2000-09-04  3:37 UTC (permalink / raw)
  To: guile-gtk

Here's a patch to make gdk-event-area work.  It doesn't handle the
case when the event isn't an expose event very prettily.
(Incidentally, converting rectangles to pairs of pairs isn't very
nice.  Are there any plans to use a more abstract data type?)


diff -u guile-gtk-0.19/gdk-1.2.defs guile-gtk-0.19-new/gdk-1.2.defs
--- guile-gtk-0.19/gdk-1.2.defs	Tue May 23 13:19:23 2000
+++ guile-gtk-0.19-new/gdk-1.2.defs	Sun Sep  3 18:47:35 2000
@@ -526,9 +526,9 @@
   bool
   ((GdkEvent event)))
 
-;(define-func gdk_event_area
-;  rect
-;  ((GdkEvent event)))
+(define-func gdk_event_area
+  rect
+  ((GdkEvent event)))
 
 (define-func gdk_event_visibility_state
   GdkVisibilityState
diff -u guile-gtk-0.19/gtk-support.c guile-gtk-0.19-new/gtk-support.c
--- guile-gtk-0.19/gtk-support.c	Tue May 23 10:48:16 2000
+++ guile-gtk-0.19-new/gtk-support.c	Sun Sep  3 20:22:59 2000
@@ -121,15 +121,18 @@
   return event->any.send_event;
 }
 
-GdkRectangle *
+GdkRectangle
 gdk_event_area (GdkEvent *event)
 {
   switch (event->any.type)
     {
     case GDK_EXPOSE:
-      return &event->expose.area;
+      return event->expose.area;
     default:
-      return NULL;
+      {
+	GdkRectangle r = { 0, 0, 0, 0 };
+	return r;
+      }
     }
 }
 
diff -u guile-gtk-0.19/guile-gtk.h guile-gtk-0.19-new/guile-gtk.h
--- guile-gtk-0.19/guile-gtk.h	Tue May 16 21:19:52 2000
+++ guile-gtk-0.19-new/guile-gtk.h	Sun Sep  3 20:20:19 2000
@@ -192,7 +192,7 @@
 GdkEventType gdk_event_type (GdkEvent *event);
 GdkWindow *gdk_event_window (GdkEvent *event);
 gboolean gdk_event_send_event (GdkEvent *event);
-GdkRectangle *gdk_event_area (GdkEvent *event);
+GdkRectangle gdk_event_area (GdkEvent *event);
 GdkVisibilityState gdk_event_visibility_state (GdkEvent *event);
 guint32 gdk_event_time (GdkEvent *event);
 gdouble gdk_event_x (GdkEvent *event);


-- 
         Mark Seaborn
   - mseaborn@bigfoot.com - http://members.xoom.com/mseaborn/ -

  A few months in the laboratory often saves several hours at the library.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Making gdk-event-area work
  2000-09-04  3:37 Making gdk-event-area work Mark Seaborn
@ 2000-09-05 11:41 ` Marius Vollmer
  2000-09-06 13:32   ` Mark Seaborn
  0 siblings, 1 reply; 4+ messages in thread
From: Marius Vollmer @ 2000-09-05 11:41 UTC (permalink / raw)
  To: Mark Seaborn; +Cc: guile-gtk

Mark Seaborn <mseaborn@argonet.co.uk> writes:

> Here's a patch to make gdk-event-area work.

Thanks!  I have applied it.

2000-09-05  Marius Vollmer  <mvo@zagadka.ping.de>

	* gdk-1.2.defs, gdk-1.3.defs (gdk_event_area): Uncomment.  *
	gtk-support.c, guile-gtk.h (gdk_event_area): Return A
	GdkRectangle, not a pointer to it.  Thanks to Mark Seaborn!

> It doesn't handle the case when the event isn't an expose event very
> prettily.

I think it's OK.  The other functions aren't any better.

> (Incidentally, converting rectangles to pairs of pairs isn't very
> nice.  Are there any plans to use a more abstract data type?)

There are no plans, but also no big objections to change it, I think.
What do you think is not nice about the current way?  You could always
build an abstraction on top of it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Making gdk-event-area work
  2000-09-05 11:41 ` Marius Vollmer
@ 2000-09-06 13:32   ` Mark Seaborn
  2000-09-10  7:40     ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Seaborn @ 2000-09-06 13:32 UTC (permalink / raw)
  To: guile-gtk

Marius Vollmer <mvo@zagadka.ping.de> writes:

> Mark Seaborn <mseaborn@argonet.co.uk> writes:
> 
> > Here's a patch to make gdk-event-area work.
> 
> Thanks!  I have applied it.

Thanks.

[snip]
> > (Incidentally, converting rectangles to pairs of pairs isn't very
> > nice.  Are there any plans to use a more abstract data type?)
> 
> There are no plans, but also no big objections to change it, I think.
> What do you think is not nice about the current way?

Pairs are usually used to represent lists, and a lot of static type
systems only let you store lists in the cdr of a pair.  It's true
there are times when improper lists are useful, but I don't like being 
gratuitously incompatible with other type systems.  I might want my
Scheme code to interoperate with them later.

It's also not very readable using `car', `cdr', etc. for this.  I
suggest providing some accessor functions, `bbox-min-x', `bbox-min-y', 
etc., and saying the representation might change in a later version.

> You could always build an abstraction on top of it.

I'd end up building abstractions on top of every library I use. :-)

-- 
         Mark Seaborn
   - mseaborn@bigfoot.com - http://members.xoom.com/mseaborn/ -

        ``We are quite lucky really this year because Christmas
               falls on Christmas day'' -- Bobby Gould

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Making gdk-event-area work
  2000-09-06 13:32   ` Mark Seaborn
@ 2000-09-10  7:40     ` Marius Vollmer
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2000-09-10  7:40 UTC (permalink / raw)
  To: Mark Seaborn; +Cc: guile-gtk

Mark Seaborn <mseaborn@argonet.co.uk> writes:

> Pairs are usually used to represent lists, and a lot of static type
> systems only let you store lists in the cdr of a pair.

If that a static type system is intended to be used with Scheme, then
it is fundamentally broken.  Pairs are used in a non-list manner all
the time, for association lists, for binary trees, etc.

> It's true there are times when improper lists are useful, but I
> don't like being gratuitously incompatible with other type systems.
> I might want my Scheme code to interoperate with them later.

I think this fear is unfounded.  There is no way that such a type
system could be used extensively with Scheme.
 
> It's also not very readable using `car', `cdr', etc. for this.  I
> suggest providing some accessor functions, `bbox-min-x',
> `bbox-min-y', etc., and saying the representation might change in a
> later version.

Yes, that's a good point.  We might want to change to using Goops, for
example, and have proper types for 2D-points and stuff.  What about
names like

    gdk-point-x            car
    gdk-point-y            cdr

    gdk-rect-pos           car
    gdk-rect-size          cdr
    gdk-rect-x             caar
    gdk-rect-y             cdar
    gdk-rect-w             cadr
    gdk-rect-h             cddr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-09-10  7:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-04  3:37 Making gdk-event-area work Mark Seaborn
2000-09-05 11:41 ` Marius Vollmer
2000-09-06 13:32   ` Mark Seaborn
2000-09-10  7:40     ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).