GTK+3 motion events and is_hint
- From: Donn <donn ingle gmail com>
- To: gtk-app-devel-list gnome org
- Subject: GTK+3 motion events and is_hint
- Date: Sat, 04 May 2013 14:55:44 +0200
Hi,
(Like in idiot I sent the first version of this to the wrong list!)
Hi, I'm new to GTK (and Vala). This is a Gtk+3.x question.
Can anyone explain why the event->is_hint always seems to return 1?
AFAICT the HINT_MASK is supposed to reduce the number of motion events
*and* send the occasional is_hint==true too.
ref: https://developer.gnome.org/gdk3/stable/gdk3-Events.html#GdkEventMask
I include a small vala sample at end. The motion_notify_event handler
never gets the chance to follow the else. i.e.
Am I grokking this wrong, or making a stupid mistake or .. other?
--
//valac --pkg gtk+-3.0 appname.vala
using Cairo;
namespace Demo {
public class Scribble : Gtk.DrawingArea {
public Scribble () {
this.add_events ( Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.POINTER_MOTION_HINT_MASK );
this.set_size_request (100,100);
}
private void draw_circ ( Cairo.Context cr ) {
var y = get_allocated_height () / 2;
var radius = double.min (get_allocated_width () / 2,
get_allocated_height () / 2) - 5;
cr.arc (y, y, radius, 0, 2 * Math.PI);
cr.set_source_rgb (1, 1, 1);
cr.fill_preserve ();
cr.set_source_rgb (0, 0, 0);
cr.stroke ();
}
public override bool draw ( Cairo.Context cr ) {
this.draw_circ ( cr);
return false;
}
public override bool motion_notify_event (Gdk.EventMotion event ) {
//Seems event.is_hint is *always* 1
//stdout.printf ( "is_hint: %d\n", event.is_hint );
if (event.is_hint == 1) {
stdout.printf ( "is hint\n" );
Gdk.Event.request_motions(event); //Always 1, so what's the point?
} else {
//Never gets here. Why?
stdout.printf ( "normal motion at: %G, %G\n", event.x, event.y );
}
return true; //false does not change anything either.
}
}
}
int main ( string[] args ) {
Gtk.init ( ref args );
var window = new Gtk.Window ();
var scribble = new Demo.Scribble ();
window.add (scribble);
window.show_all ();
window.destroy.connect (Gtk.main_quit);
Gtk.main ();
return 0;
}
--
PS - I have since asked this on Stackoverflow.
The url is:
http://stackoverflow.com/questions/16359775/gtk-motion-notify-event-is-hint-always-true
Thanks,
\d
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]