Re: Freeze screen



On Thu, 28 Sep 2006 16:14:41 -0400
zentara <zentara1 sbcglobal net> wrote:

On Thu, 28 Sep 2006 16:59:20 +0200
Dieter Schicker <dieter schicker uni-graz at> wrote:

how can I "freeze" (and "unfreeze") the screen like it is done when the
user is asked for his password when he wants to perform an
administrative task?

Thanks in advance
Dieter

I know muppet said it needed c (as in gtksu ) to do it, but I was toying around
today and came up with this.

It will lock the whole X server screen when you press the grab_global
button. The Quit button will still work, as will 'q'.
This is just a rudimentary demo.
I'll leave it up to you to apply it to a popup, and the password asking.

#!/usr/bin/perl
use warnings;
use strict;
use Glib qw/TRUE FALSE/;
use Gtk2::Gdk::Keysyms;
use Gtk2 '-init';

$|++;  #for beeps

my $window = Gtk2::Window->new('toplevel');
$window->set_title('Z');
$window ->signal_connect( 'destroy' => \&delete_event );
$window->set_border_width(10);
$window->set_size_request(300,200);

my $vbox = Gtk2::VBox->new( FALSE, 6 );
$window->add($vbox);
$vbox->set_border_width(2);

my $hbox= Gtk2::HBox->new( FALSE, 6 );
$vbox->pack_end($hbox,FALSE,FALSE,0);
$hbox->set_border_width(2);

my $button = Gtk2::Button->new_from_stock('gtk-quit');
$hbox->pack_end( $button, FALSE, FALSE, 0 );
$button->signal_connect( clicked => \&delete_event );

my $button1 = Gtk2::Button->new('Global Grab');
$hbox->pack_end( $button1, FALSE, FALSE, 0 );
$button1->signal_connect( clicked => sub{
  my $rc;
  $rc = 
Gtk2::Gdk->pointer_grab($window->window,1,['button-press-mask','button-release-mask','pointer-motion-mask'],undef,undef,Gtk2->get_current_event_time);
  print "$rc\n";
  $rc = Gtk2::Gdk->keyboard_grab($window->window,0,Gtk2->get_current_event_time);
  print "$rc\n";
} );

$window->set_position('center');

$window->show_all();

$window->signal_connect( 'key_release_event' => \&keyrelease );

$window->signal_connect (event => sub {
   my ($item, $event) = @_;
   warn "event ".$event->type."\n";
   print chr(07); #beep
   return 0;  #return 1 prevents window from closing 
  # return 0 lets the signal thru
});

Gtk2->main;

#####################################
sub delete_event {
Gtk2->main_quit;
return FALSE;
}  

sub keyrelease {
    my ( $widget, $event ) = @_;
    print $event->keyval,"\n";
    print chr(07); #beep
    if ( $event->keyval == $Gtk2::Gdk::Keysyms{q} ) {
        Gtk2->main_quit;
    }
    else {
        print "key was ", chr( $event->keyval ), "\n";
    }
}



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



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