Re: Is (x,y) int or double?



Dennis Bjorklund <db zigo dhs org> writes:

> How come that in GdkEventMotion the x and y coordinates are of type
> gdouble, but in the function gdk_window_get_pointer() the x and y
> coordinates are of type gint.
> 
> Yet, in GGAD (still the best documentation) this is the example:
> 
>   double x, y;
> 
>   x = event->motion.x;
>   y = event->motion.y;
> 
>   if (event->motion.is_hint)
>     gdk_window_get_pointer(event->window, &x, &y, NULL);
> 
> I thought the idea with double as coordinates was for input devices that
> are more fine grained then the normal mouse. But then this extra precision
> is lost if you use gdk_window_get_pointer().

void     gdk_device_get_state    (GdkDevice         *device,
				  GdkWindow         *window,
				  gdouble           *axes,
				  GdkModifierType   *mask);

Is the extended form of gdk_window_get_pointer() that allows
you to get the full precision and extra axes that are in
GdkEvent for extended input devices.

[
In 2.0. The 1.x function is:

void          gdk_input_window_get_pointer   (GdkWindow        *window,
                                              guint32           deviceid,
                                              gdouble          *x,
                                              gdouble          *y,
                                              gdouble          *pressure,
                                              gdouble          *xtilt,
                                              gdouble          *ytilt,
                                              GdkModifierType  *mask);
]

 
> It's the same thing in both gtk 1.2 and gtk 2.0. Also, the flag "gint16
> is_hint" in GdkEventMotion sounds like it should be a gboolean in gtk 2.0.
> But I guess it's a lot of these things left from the earlier days.

It's a gint16 flag to save space. We'd probably do:

 guint is_hint : 1

these days, but it doesn't really matter in this context. 
(You can't use bit fields with gboolean, since gboolean
is a typedef for int.)
 
Regards,
                                        Owen



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