|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
|
|
Scribble ExampleI am playing around with muppet's scribble example and it's working like
a charm but if i move the mouse cursor very fast there are only single rectangles drawn. It seems to me that the needed events (motion_notify) are not passed fast enough. Is there any way to prevent this or a workaround? Greetings Mario _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Wed, 09 Jul 2008 15:01:30 +0200
Mario Kemper <mario.kemper@...> wrote: >I am playing around with muppet's scribble example and it's working like >a charm but if i move the mouse cursor very fast there are only single >rectangles drawn. >It seems to me that the needed events (motion_notify) are not passed >fast enough. Is there any way to prevent this or a workaround? > >Greetings >Mario Draw lines instead of the rectangle. You start with a 0 line, and as you move the mouse, push the new x,y coords onto the line. It will appear smooth. I have a crude example on a Gnome2::Canvas, you can probably adapt it to the Drawing area, and fix the glitches. It draws a continous line, starting at 0,0. You probably want to initiate a new line at the first button click position, and make a new line on each button click. Maybe instead of a single line, have multiple lines in %lines. #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Gnome2::Canvas; use Glib qw(TRUE FALSE); my $draw_flag = 0; my $window = Gtk2::Window->new; $window->signal_connect( destroy => sub { exit } ); $window->set_default_size( 500, 500 ); my $vbox = Gtk2::VBox->new; $vbox->set_border_width(4); $vbox->show; my $hbox = Gtk2::HBox->new(FALSE, 4); $vbox->pack_start($hbox, FALSE, FALSE, 0); $hbox->show; $window->add($vbox); my $scroller = Gtk2::ScrolledWindow->new; my $canvas = Gnome2::Canvas->new(); my $white = Gtk2::Gdk::Color->new (0xFFFF,0xFFFF,0xFFFF); $canvas->modify_bg('normal',$white); $scroller->add( $canvas ); $vbox->pack_start($scroller, 1, 1, 0); $canvas->set_scroll_region( 0, 0, 700, 700 ); $window->show_all; my $root = $canvas->root; my $text = Gnome2::Canvas::Item->new( $root, 'Gnome2::Canvas::Text', x => 20, y => 15, fill_color => 'black', font => 'Sans 14', anchor => 'GTK_ANCHOR_NW', text => 'Click to start drawing, release to stop' ); $canvas->signal_connect (event => \&event_handler); my $points = [0,0,0,0]; #need at least 2 points to start my $line2= Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Line', points => $points, fill_color => "red", width_units => 3.0, cap_style => 'projecting', join_style => 'miter', ); my $p = $line2->get('points'); print "@$p\n"; my ($x,$y) = @$p; # Zoom my $z = Gtk2::Label->new("Zoom:"); $hbox->pack_start($z, FALSE, FALSE, 0); $z->show; my $adj = Gtk2::Adjustment->new(1, 0.05, 100, 0.05, 0.5, 0.5); my $sb = Gtk2::SpinButton->new($adj, 0, 2); $adj->signal_connect("value-changed", \&zoom_changed, $canvas); $sb->set_size_request(60, -1); $hbox->pack_start($sb, FALSE, FALSE, 10); $sb->show; # Create PDF my $bpdf = Gtk2::Button->new_with_label('screenshot'); $hbox->pack_start($bpdf, FALSE, FALSE, 0); $bpdf->show; $bpdf->signal_connect("clicked", \&write_screenshot, $canvas); $window->show_all(); Gtk2->main; ############################## sub event_handler{ my ( $widget, $event ) = @_; print $widget ,' ',$event->type,"\n"; if ( $event->type eq "button-press" ) { $draw_flag = 1; } if ( $event->type eq "button-release" ) { $draw_flag = 0; } if ( $event->type eq "focus-change" ) { return 0; } if ( $event->type eq "expose" ) { return 0; } if($draw_flag){ #left with motion-notify if ( $event->type eq "motion-notify"){ my ($x,$y) = ($event->x,$event->y); print "$x $y\n"; my $scale = $adj->get_value; print "scale->$scale\n"; my $scaled_x = $scale * $x; my $scaled_y = $scale * $y; print 'scaled ',$scaled_x,' ',$scaled_y,"\n"; push @$points,$x/$scale,$y/$scale; $line2->set(points=>$points); my $p = $line2->get('points'); print "@$p\n"; } } } sub zoom_changed { my ($adj, $canvas) = @_; $canvas->set_pixels_per_unit($adj->get_value); } __END__ zentara -- I'm not really a human, but I play one on earth. http://zentara.net/CandyGram_for_Mongo.html _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Wed, 09 Jul 2008 15:01:30 +0200
Mario Kemper <mario.kemper@...> wrote: >I am playing around with muppet's scribble example and it's working like >a charm but if i move the mouse cursor very fast there are only single >rectangles drawn. >It seems to me that the needed events (motion_notify) are not passed >fast enough. Is there any way to prevent this or a workaround? Here is a little better example. It handles multiple draws separately. If you use the Goo::Canvas, you can save the whole scrolled region. Gnome2::Canvas only allows screenshots. #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Gnome2::Canvas; use Glib qw(TRUE FALSE); my $draw_flag = 0; my %lines; # way to store multiple continuous lines my $count = 0; my $window = Gtk2::Window->new; $window->signal_connect( destroy => sub { exit } ); $window->set_default_size( 500, 500 ); my $vbox = Gtk2::VBox->new; $vbox->set_border_width(4); $vbox->show; my $hbox = Gtk2::HBox->new(FALSE, 4); $vbox->pack_start($hbox, FALSE, FALSE, 0); $hbox->show; $window->add($vbox); my $scroller = Gtk2::ScrolledWindow->new; my $canvas = Gnome2::Canvas->new(); my $white = Gtk2::Gdk::Color->new (0xFFFF,0xFFFF,0xFFFF); $canvas->modify_bg('normal',$white); $scroller->add( $canvas ); $vbox->pack_start($scroller, 1, 1, 0); $canvas->set_scroll_region( 0, 0, 700, 700 ); $window->show_all; my $root = $canvas->root; my $text = Gnome2::Canvas::Item->new( $root, 'Gnome2::Canvas::Text', x => 20, y => 15, fill_color => 'black', font => 'Sans 14', anchor => 'GTK_ANCHOR_NW', text => 'Click to start and stop drawing....Drag Mouse' ); $canvas->signal_connect (event => \&event_handler); # Zoom my $z = Gtk2::Label->new("Zoom:"); $hbox->pack_start($z, FALSE, FALSE, 0); $z->show; my $adj = Gtk2::Adjustment->new(1, 0.05, 100, 0.05, 0.5, 0.5); my $sb = Gtk2::SpinButton->new($adj, 0, 2); $adj->signal_connect("value-changed", \&zoom_changed, $canvas); $sb->set_size_request(60, -1); $hbox->pack_start($sb, FALSE, FALSE, 10); $sb->show; my $button1 = Gtk2::Button->new_from_stock('Screenshot'); $hbox->pack_start( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&screenshot ); $window->show_all(); Gtk2->main; ############################## sub event_handler{ my ( $widget, $event ) = @_; #print $widget ,' ',$event->type,"\n"; my $scale = $adj->get_value; # print "scale->$scale\n"; if ( $event->type eq "button-press" ) { $draw_flag = 1; #start a new line curve $count++; my ($x,$y) = ($event->x,$event->y); # print "$x $y\n"; $lines{$count}{'points'} = [$x/$scale,$y/$scale,$x/$scale,$y/$scale]; #need at least 2 points $lines{$count}{'line'} = Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Line', points => $lines{$count}{'points'}, fill_color => "red", width_units => 3.0, cap_style => 'projecting', join_style => 'miter', ); } if ( $event->type eq "button-release" ) { $draw_flag = 0; } if ( $event->type eq "focus-change" ) { return 0; } if ( $event->type eq "expose" ) { return 0; } if($draw_flag){ #left with motion-notify if ( $event->type eq "motion-notify"){ my ($x,$y) = ($event->x,$event->y); # print "$x $y\n"; push @{$lines{$count}{'points'}},$x/$scale,$y/$scale; $lines{$count}{'line'}->set(points=>$lines{$count}{'points'}); # my $p = $lines{$count}{'line'}->get('points'); # print "@$p\n"; } } } sub zoom_changed { my ($adj, $canvas) = @_; $canvas->set_pixels_per_unit($adj->get_value); } sub screenshot{ #we are going to save the visible canvas my ($width, $height) = $canvas->window->get_size; # create blank pixbuf to hold the image my $gdkpixbuf = Gtk2::Gdk::Pixbuf->new ('rgb', 0, 8, $width, $height); $gdkpixbuf->get_from_drawable ($canvas->window, undef, 0, 0, 0, 0, $width, $height); #only jpeg and png is supported !!!! it's 'jpeg', not 'jpg' $gdkpixbuf->save ("$0.jpg", 'jpeg', quality => 100); return FALSE; } #$pixbuf->save ($filename, 'jpeg', quality => '100'); # Currently only a few parameters exist. JPEG images can be saved # with a "quality" parameter; its value should be in the range # [0,100]. Text chunks can be attached to PNG images by specifying # parameters of the form "tEXt::key", where key is an ASCII string of # length 1-79. The values are UTF-8 encoded strings. __END__ zentara -- I'm not really a human, but I play one on earth. http://zentara.net/CandyGram_for_Mongo.html _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleWow, thanks. This is a great example.
I'll go through it, but i am pretty sure that this solves my problem. Am Mittwoch, den 09.07.2008, 14:09 -0400 schrieb zentara: > > #!/usr/bin/perl > use warnings; > use strict; > use Gtk2 -init; > use Gnome2::Canvas; > use Glib qw(TRUE FALSE); > > my $draw_flag = 0; > my %lines; # way to store multiple continuous lines > my $count = 0; > > my $window = Gtk2::Window->new; > $window->signal_connect( destroy => sub { exit } ); > $window->set_default_size( 500, 500 ); > > my $vbox = Gtk2::VBox->new; > $vbox->set_border_width(4); > $vbox->show; > > my $hbox = Gtk2::HBox->new(FALSE, 4); > $vbox->pack_start($hbox, FALSE, FALSE, 0); > $hbox->show; > > $window->add($vbox); > > my $scroller = Gtk2::ScrolledWindow->new; > my $canvas = Gnome2::Canvas->new(); > my $white = Gtk2::Gdk::Color->new (0xFFFF,0xFFFF,0xFFFF); > $canvas->modify_bg('normal',$white); > > $scroller->add( $canvas ); > $vbox->pack_start($scroller, 1, 1, 0); > > $canvas->set_scroll_region( 0, 0, 700, 700 ); > $window->show_all; > > my $root = $canvas->root; > > my $text = Gnome2::Canvas::Item->new( > $root, 'Gnome2::Canvas::Text', > x => 20, > y => 15, > fill_color => 'black', > font => 'Sans 14', > anchor => 'GTK_ANCHOR_NW', > text => 'Click to start and stop drawing....Drag Mouse' > ); > > > $canvas->signal_connect (event => \&event_handler); > > # Zoom > my $z = Gtk2::Label->new("Zoom:"); > $hbox->pack_start($z, FALSE, FALSE, 0); > $z->show; > > my $adj = Gtk2::Adjustment->new(1, 0.05, 100, 0.05, 0.5, 0.5); > my $sb = Gtk2::SpinButton->new($adj, 0, 2); > $adj->signal_connect("value-changed", \&zoom_changed, $canvas); > $sb->set_size_request(60, -1); > $hbox->pack_start($sb, FALSE, FALSE, 10); > $sb->show; > > my $button1 = Gtk2::Button->new_from_stock('Screenshot'); > $hbox->pack_start( $button1, FALSE, FALSE, 0 ); > $button1->signal_connect( clicked => \&screenshot ); > > > $window->show_all(); > > Gtk2->main; > > ############################## > > sub event_handler{ > my ( $widget, $event ) = @_; > #print $widget ,' ',$event->type,"\n"; > > my $scale = $adj->get_value; > # print "scale->$scale\n"; > > if ( $event->type eq "button-press" ) { > $draw_flag = 1; > > #start a new line curve > $count++; > > my ($x,$y) = ($event->x,$event->y); > # print "$x $y\n"; > > $lines{$count}{'points'} = [$x/$scale,$y/$scale,$x/$scale, > $y/$scale]; #need at least 2 points > $lines{$count}{'line'} = Gnome2::Canvas::Item->new ($root, > 'Gnome2::Canvas::Line', > points => $lines{$count}{'points'}, > fill_color => "red", > width_units => 3.0, > cap_style => 'projecting', > join_style => 'miter', > ); > } > > if ( $event->type eq "button-release" ) { > $draw_flag = 0; > } > > > if ( $event->type eq "focus-change" ) { > return 0; > } > > if ( $event->type eq "expose" ) { > return 0; > } > > > if($draw_flag){ > #left with motion-notify > if ( $event->type eq "motion-notify"){ > my ($x,$y) = ($event->x,$event->y); > # print "$x $y\n"; > > push @{$lines{$count}{'points'}},$x/$scale,$y/$scale; > > $lines{$count}{'line'}->set(points=>$lines{$count}{'points'}); > > # my $p = $lines{$count}{'line'}->get('points'); > # print "@$p\n"; > } > } > > } > > > sub zoom_changed { > my ($adj, $canvas) = @_; > $canvas->set_pixels_per_unit($adj->get_value); > } > > > sub screenshot{ > > #we are going to save the visible canvas > my ($width, $height) = $canvas->window->get_size; > > # create blank pixbuf to hold the image > my $gdkpixbuf = Gtk2::Gdk::Pixbuf->new ('rgb', > 0, > 8, > $width, > $height); > > $gdkpixbuf->get_from_drawable ($canvas->window, > undef, 0, 0, 0, 0, $width, $height); > > #only jpeg and png is supported !!!! it's 'jpeg', not 'jpg' > $gdkpixbuf->save ("$0.jpg", 'jpeg', quality => 100); > return FALSE; > } > > #$pixbuf->save ($filename, 'jpeg', quality => '100'); > # Currently only a few parameters exist. JPEG images can be saved > # with a "quality" parameter; its value should be in the range > # [0,100]. Text chunks can be attached to PNG images by specifying > # parameters of the form "tEXt::key", where key is an ASCII string of > # length 1-79. The values are UTF-8 encoded strings. _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
|
|
|
Re: Scribble ExampleOn Jul 10, 2008, at 8:09 AM, Mario Kemper wrote: > Now i know to draw on a canvas. Do you have any ideas on how i can > draw > on a foreign window? A GdkWindow isa GdkDrawable, so stuff like Gtk2::Gdk::Drawable::draw_rectangle(), draw_line(), draw_drawable(), etc, should all Just Work. -- The Master in the art of living makes little distinction between his work and his play, his labor and his leisure, his mind and his body, his education and his recreation, his love and his religion. He hardly knows which is which. He simply pursues his vision of excellence in whatever he does, leaving others to decide whether he is working or playing. To him he is always doing both. -- Zen Philosophy _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Fri, 11 Jul 2008 23:50:37 -0400
muppet <scott@...> wrote: > >On Jul 10, 2008, at 8:09 AM, Mario Kemper wrote: > >> Now i know to draw on a canvas. Do you have any ideas on how i can >> draw >> on a foreign window? > >A GdkWindow isa GdkDrawable, so stuff like >Gtk2::Gdk::Drawable::draw_rectangle(), draw_line(), draw_drawable(), >etc, should all Just Work. In my experimenting around, If I have the xid of the foreign window, I can use Gtk2::Gdk::Window->foreign_new($xid) to get the low level window and take a screenshot. But to actually draw on that foreign window, seems to be more difficult. In my intuitive zen musings, I'm tending to think that you can't draw on it unless you somehow make it writable from your app, or if you lay a transparent window on top of it, and draw to your transparent window. There are 2 foreign window types, AND A Gdk window with parent, and I'm wondering what the difference is? window = Gtk2::Gdk::Window->new ($parent, $attributes_ref) $parent (Gtk2::Gdk::Window or undef window = Gtk2::Gdk::Window->foreign_new ($anid) ยท $anid (Gtk2::Gdk::NativeWindow) window = Gtk2::Gdk::Window->foreign_new_for_display ($display, $anid) Any thoughts on this? What is the $attributes_ref? Which of the 3 window creation methods above, the best to use to actually draw on the target foreign window? I'm hoping for a clue, or I will have to spend an afternoon experimenting. :-) The concept Mario had was a screenshot grabbing mouse drag which created a dashed rectangle on a foreign area. Would that dashed rectangle be drawn on the foreign gdk window itself, or on a transparent gdk window which you overlay over the target? I'm leaning toward a transparent overlay, since you would not be actually writing to the other app's space directly, and would seem to be more secure. ?? Thanks, zentara -- I'm not really a human, but I play one on earth. http://zentara.net/CandyGram_for_Mongo.html _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Sat, 12 Jul 2008 08:53:51 -0400
zentara <zentara1@...> wrote: >On Fri, 11 Jul 2008 23:50:37 -0400 >muppet <scott@...> wrote: > >> >>On Jul 10, 2008, at 8:09 AM, Mario Kemper wrote: >> >>> Now i know to draw on a canvas. Do you have any ideas on how i can >>> draw >>> on a foreign window? >> >>A GdkWindow isa GdkDrawable, so stuff like >>Gtk2::Gdk::Drawable::draw_rectangle(), draw_line(), draw_drawable(), >>etc, should all Just Work. >Hi, > >In my experimenting around, If I have the xid of the foreign window, >I can use Gtk2::Gdk::Window->foreign_new($xid) to get the low level window >and take a screenshot. But to actually draw on that foreign window, seems to >be more difficult. > Hi, this is the result of my experiments. I can write to the gdk foreign window, and even move it, but I can't scribble to it with the mouse. The problem seems to be you can't assign events to the gdk window from another window, so the mouse is useless on it. Is there a trick I'm missing? There are 2 attachments. One is the target script called Z, and the other launches it, starts itself, then tries to manipulate the gdk window. Thanks, zentara -- I'm not really a human, but I play one on earth. http://zentara.net/CandyGram_for_Mongo.html _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleThanks for your example, again. I changed a few lines and now you can
receive events from the foreign window. The disadvantage of this method is that you don't reach the Gtk2 MainLoop anymore so the buttons are not drawn for example but i didn't investigate in this direction ;-) Here are my changes (the complete files are attached): $window->show_all(); #~ Gtk2->main; my $mainloop = Glib::MainLoop->new (undef, 0); Glib::Idle->add (\&my_callback, undef, 0); $mainloop->run; ##################################### sub my_callback { my $event = Gtk2::Gdk::Event->get; warn "event ".$event->type."\n" if defined($event); return TRUE; } ##################################### ##################################### sub delete_event { #~ Gtk2->main_quit; $mainloop->quit; return FALSE; } thanks, mario Am Sonntag, den 13.07.2008, 09:08 -0400 schrieb zentara: > On Sat, 12 Jul 2008 08:53:51 -0400 > zentara <zentara1@...> wrote: > > >On Fri, 11 Jul 2008 23:50:37 -0400 > >muppet <scott@...> wrote: > > > >> > >>On Jul 10, 2008, at 8:09 AM, Mario Kemper wrote: > >> > >>> Now i know to draw on a canvas. Do you have any ideas on how i can > >>> draw > >>> on a foreign window? > >> > >>A GdkWindow isa GdkDrawable, so stuff like > >>Gtk2::Gdk::Drawable::draw_rectangle(), draw_line(), draw_drawable(), > >>etc, should all Just Work. > >Hi, > > > >In my experimenting around, If I have the xid of the foreign window, > >I can use Gtk2::Gdk::Window->foreign_new($xid) to get the low level window > >and take a screenshot. But to actually draw on that foreign window, seems to > >be more difficult. > > > > > Hi, this is the result of my experiments. I can write to the gdk foreign window, > and even move it, but I can't scribble to it with the mouse. > The problem seems to be you can't assign events to the gdk window from > another window, so the mouse is useless on it. > > Is there a trick I'm missing? There are 2 attachments. One is the target > script called Z, and the other launches it, starts itself, then tries > to manipulate the gdk window. > > Thanks, > zentara > > > -- > I'm not really a human, but I play one on earth. > http://zentara.net/CandyGram_for_Mongo.html > _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Jul 13, 2008, at 9:08 AM, zentara wrote: > Hi, this is the result of my experiments. I can write to the gdk > foreign window, > and even move it, but I can't scribble to it with the mouse. > The problem seems to be you can't assign events to the gdk window from > another window, so the mouse is useless on it. > > Is there a trick I'm missing? There are 2 attachments. One is the > target > script called Z, and the other launches it, starts itself, then tries > to manipulate the gdk window. (My line numbers are different, i had to hack up something to replace the Wnck code on my system.) GLib-GObject-WARNING **: gsignal.c:1657: signal `event' is invalid for instance `0x8889b68' at ./screenshot-foreign-write-scribble line 49. GdkWindow is a GObject but has no signals. You're thinking of the GtkWidget::event signal. If you want integration with the event system, you'll have to wrap the GdkWindow up in a GtkWidget, and enable an event filter. (Oops, gdk_window_add_filter() has never been implemented in the bindings...) I'm a bit confused, what's the actual goal, here? If you just want to capture the contents of the other window, it seems that readonly access you get here is fine. If you want something more elaborate, then xswallow or GtkPlug/GtkSocket may be more appropriate. -- Me: What's that in your mouth? Zella: *swallows laboriously* Nothing. Me: What did you just swallow? Zella: A booger. Me: Baby girl, don't eat boogers. That's gross. Zella: But it was in my nose. _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Sun, 13 Jul 2008 13:13:00 -0400
muppet <scott@...> wrote: > >On Jul 13, 2008, at 9:08 AM, zentara wrote: > >> Hi, this is the result of my experiments. I can write to the gdk >> foreign window, >> and even move it, but I can't scribble to it with the mouse. >> The problem seems to be you can't assign events to the gdk window from >> another window, so the mouse is useless on it. >GdkWindow is a GObject but has no signals. You're thinking of the >GtkWidget::event signal. If you want integration with the event >system, you'll have to wrap the GdkWindow up in a GtkWidget, and >enable an event filter. (Oops, gdk_window_add_filter() has never been >implemented in the bindings...) > > >I'm a bit confused, what's the actual goal, here? If you just want to >capture the contents of the other window, it seems that readonly >access you get here is fine. If you want something more elaborate, >then xswallow or GtkPlug/GtkSocket may be more appropriate. (mouse drag drawing) to make selections on a foreign window. Off list, we have managed to draw to the drawing area, but as my example showed, no mouse events could be detected. BUT Mario did find a way to detect the foreign window mouse events by replacing the mainloop. See attachment for the example code. But there are glitches, like the main script buttons stopped working. Maybe you could see a way to improve the custom mainloop in the attachment to get it working? I tried sprinkling a bunch of Gtk2->main_iteration while Gtk2->events_pending; in all the callbacks, and seemed to help a bit, but it's not perfect. And you are right, this is just a stupid code trick, so please don't waste time on it, but if you see something obvious, we would appreciate it. Thanks, zentara -- I'm not really a human, but I play one on earth. http://zentara.net/CandyGram_for_Mongo.html _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble Examplezentara <zentara1@...> writes:
> > Off list, we have managed to draw to the drawing area, but as my example > showed, no mouse events could be detected. Maybe a "pointer_grab" would be easier, if you've got a mapped toplevel window of your own on screen. It'd send move events there, instead of trying to select them in the foreign window. _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleThanks for your input Kevin.
The goal of our attempts is to recreate the behavior of ksnapshot, the KDE Screenshot Tool. You select a window by its xid and while hovering over it we want to draw a rectangle around the current subwindow to indicate the size of it. In the end you should be able to take a screenshot of the selected subwindow (that is currently not a problem because it's a drawable and it's easy to save it). (maybe someone is interested in the code: http://websvn.kde.org/branches/KDE/4.1/kdegraphics/ksnapshot/) At the moment I have less time working on this issue because i have an university exam next week ;-( I will give it a try after my exam and keep "pointer_grab" at the back of my mind. Currently i am thinking that zentara's example of laying a transparent Gtk2 window over the selected one and then draw to the transparent window is a very good idea as well. Thanks all you folks for help but don't spent too much time on my "problem". Am Dienstag, den 15.07.2008, 10:07 +1000 schrieb Kevin Ryde: > zentara <zentara1@...> writes: > > > > Off list, we have managed to draw to the drawing area, but as my example > > showed, no mouse events could be detected. > > Maybe a "pointer_grab" would be easier, if you've got a mapped toplevel > window of your own on screen. It'd send move events there, instead of > trying to select them in the foreign window. > _______________________________________________ > gtk-perl-list mailing list > gtk-perl-list@... > http://mail.gnome.org/mailman/listinfo/gtk-perl-list _______________________________________________ gtk-perl-list mailing list gtk-perl-list@... http://mail.gnome.org/mailman/listinfo/gtk-perl-list |
|
|
Re: Scribble ExampleOn Jul 15, 2008, at 4:51 AM, Mario Kemper wrote: > The goal of our attempts is to recreate the behavior of ksnapshot, the > KDE Screenshot Tool. You select a window by its xid and while hovering > over it we want to draw a rectangle around the current subwindow to > indicate the size of it. In the end you should be able to take a > screenshot of the selected subwindow (that is currently not a problem > because it's a drawable and it's easy to sav |