I want to write a script that detects when the user moves a Gtk2 window across the desktop.
Specifically, I want to know when the user releases the mouse button, at the end of the drag operation, so that I can check the window's new position.
This C tutorial has the right idea, but I can't work out how to do the same thing in Perl:
http://zetcode.com/tutorials/gtktutorial/gtkevents/
The Gtk2 Perl tutorial covers drag-and-drop operations, but I don't want to drop the Gtk2 window into another widget:
http://gtk2-perl.sourceforge.net/doc/gtk2-perl-study-guide/c5651.html
How can I amend the script below?
#!/usr/bin/perl package dragwin; use strict; use diagnostics; use warnings; use Gtk2 '-init'; # Want to detect when the user drags a window across the desktop # Specifically, when the user releases their mouse button, meaning the # drag operation has finished # Create the window my $window = Gtk2::Window->new(); $window->set_title('Drag me!'); $window->set_position('center'); $window->set_default_size(300, 300); $window->set_border_width(5); $window->signal_connect (destroy => sub { Gtk2->main_quit; }); # We want to detect the end of a drag, but this doesn't work $window->signal_connect('event' => sub { my ($widget, $event) = @_; print "Window event type: " . $event->type . "\n"; }); # Open the window $window->show_all(); Gtk2->main();
In reply to Gtk2 window dragging by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |