basiliscos has asked for the wisdom of the Perl Monks concerning the following question:
Hello!
I need to show my Gtk2 application, when some "global" hotkey is been pressed. I tried to do that way, but it doesn't work:
I need to get the global key press asynchronously; when I fetch them directly/synchronously, than it works:#!/usr/bin/env perl use 5.12.0; use strict; use warnings; use AnyEvent; use Carp; use Devel::Comments; use Gtk2 -init; use X11::Protocol; use X11::Keyboard; my $window = Gtk2::Window->new ('toplevel'); my $button = Gtk2::Button->new ('Quit'); $button->signal_connect (clicked => sub { Gtk2->main_quit }); $window->add ($button); $window->show_all; my $x = X11::Protocol->new; my $k = X11::Keyboard->new($x); my $mask = $x->pack_event_mask('KeyPress'); $x->ChangeWindowAttributes($x->root, event_mask => $mask); $x->event_handler(sub { say "z"; }); my $seq = $x->GrabKey($k->KeysymToKeycode("z"), 'AnyModifier', $x->root, 1, 'Asynchronous', 'Asy +nchronous'); Gtk2->main;
The problem with the last piece of code, that it blocks all my GUI. The guys in Internet offered an solution to use separate pthread in such a blocking manner, but it's OK for C, and not OK for perl. Thanks a lot for any suggestions!$x->event_handler ('queue'); my %event = $x->next_event;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Gtk2 X11 GrabKey
by Rhandom (Curate) on Dec 14, 2013 at 22:11 UTC | |
Re: Gtk2 X11 GrabKey
by dcmertens (Scribe) on Dec 14, 2013 at 14:56 UTC | |
by Anonymous Monk on Dec 14, 2013 at 15:23 UTC | |
by basiliscos (Pilgrim) on Dec 14, 2013 at 16:05 UTC | |
by dcmertens (Scribe) on Dec 14, 2013 at 18:32 UTC | |
Re: Gtk2 X11 GrabKey
by zentara (Archbishop) on Dec 15, 2013 at 14:47 UTC | |
Re: Gtk2 X11 GrabKey
by Anonymous Monk on Dec 14, 2013 at 15:22 UTC | |
Re: Gtk2 X11 GrabKey
by basiliscos (Pilgrim) on Dec 21, 2013 at 17:53 UTC |
Back to
Seekers of Perl Wisdom