Re: GTK+3 motion events and is_hint

2013-05-17 Thread Donn

Anyone?

\d
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK+3 motion events and is_hint

2013-05-17 Thread Tristan Van Berkom
This is a good question, actually I haven't used this feature since GTK+2...

I'd be curious to know the answer but here is my input anyway.

Your application doesn't do much between is_hint events, so it could
be that if you were slow handling the hint events, you might receive
events that are not 'is_hint' in between the regular 'is_hint' events.

FWIW, I don't think you should be concerned about which events are
'is_hint' or not 'is_hint'.

Rather, the hint mask traditionally prevents you from receiving too many
motion events that are queued up while your widget is processing a previous
event, and the call to gdk_event_request_motions() tells GDK that your
GdkWindow is ready to handle more motion events.

Actually, I don't see why you should be trying to handle the 'is_hint' events
any differently from the normal events (it should be enough to just call
gdk_event_request_motions() at the end of a motion-notify-event handler,
after you're done processing the event).

Cheers,
-Tristan

On Fri, May 17, 2013 at 6:15 PM, Donn donn.in...@gmail.com wrote:
 Anyone?


 \d
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK+3 motion events and is_hint

2013-05-17 Thread Donn

On 17/05/2013 11:29, Tristan Van Berkom wrote:

This is a good question, actually I haven't used this feature since
GTK+2... I'd be curious to know the answer but here is my input
anyway.

Tristan,
 Thanks so much for responding. I will try your suggestions and perhaps 
clarity will come in time. I do think it's a GTK+3 quirk. In the 
meantime, I will keep coding - better to aim for finished than perfect.


\d

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GTK+3 motion events and is_hint

2013-05-04 Thread Donn

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
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list