Re: Thinking about the tasklist



Using a UNIX signal isn't the best way most likely.  There are a number
of alternatives available, such as writing to a socket or named pipe, or
sending a dbus message from your program.  You could also do something
like an RPC or a CORBA-architecture using bonobo, though thats a bit
more complicated.

-Rob

On Wed, 2004-10-20 at 20:02 +0200, Jan Nieuwenhuizen wrote:
> Elijah Newren writes:
> 
> So, currently it can be done
> 
> > No it's not.  You either bind a key to an external command via
> > gconf[1],
> 
> in a silly way
> 
> > or you modify Metacity itself if you don't want to run an
> > external command.
> 
> or not at all.  We were talking about why `people were not writing
> their own pager/window nav applets'.  If the way to `configure'
> metacity is to hack it, I guess we found the answer: it cannot be done
> [currently].
> 
> > Why can't you just use an external command, as Rob previously
> > suggested?  (I believe you mentioned that your app took a long time
> > to start--but why not have that app just always be running in the
> > background, and have another app which launches quickly be bound to
> > the keybinding and forward the message to your real app?)
> 
> Yes, I tried that.  In fact, the first version used this hack
> 
>     WindowMenu *menu;
> 
>     #include <signal.h>
>     #include <fcntl.h>
> 
>     void sig_watcher (int);
>     void sig_catcher (gpointer, gint, GdkInputCondition);
>     int signal_fds[2];
> 
>     void
>     setup_signal()
>     {
>       /* Set up to catch signals */
> 
>       if (pipe (signal_fds) == 0)
>         {
>           long arg;
>           signal (SIGUSR1, sig_watcher);
>           gdk_input_add (signal_fds[0], GDK_INPUT_READ, sig_catcher, NULL);
>           arg = fcntl (signal_fds[0], F_GETFL);
>           fcntl (signal_fds[0], F_SETFL, arg | O_NONBLOCK);
>         }
> 
>     }
> 
>     /* Catch unix signals, write them to the pipe */
>     void
>     sig_watcher(int signum)
>     {
>       write (signal_fds[1], &signum, sizeof (signum));
>     }
> 
>     /* Get signals from the pipe.  *Now* it is safe to call gtk */
>     void
>     sig_catcher (gpointer d, gint fd, GdkInputCondition cond)
>     {
>       int signum;
> 
>       while (read(signal_fds[0], &signum, sizeof (signum)) > 0)
>         window_menu_popup_menu (menu, 0, 0);
>     }
> 
>     int
>     main (int argc, char **argv)
>     {
>      ...
>      setup_signal ();
>   
>     }
> 
> and a second app would `killall -USR1 keywise'.  But I deleted it
> before my first public release of keywise.c, because it's gross, I'm
> surely not the only one who needs it, and it will only give you a
> couple of key bindings, where eventually I'd like to have about 10.
> 
> In addition to the number of bindings, I'd like to be able to change
> them dynamically (like in a menu: hover above the window-group or an
> individual window, press a key, and have that bound to cycle that
> window-group or go to that individual window).
> 
> I could hardcode them for myself, but that won't work if you want to
> contribute a usable window switching metacity addon.  I don't think
> that spawning gconf-editor is the way we want to go.
> 
> > If Metacity wanted infinite configurability such as Sawfish was
> > designed for, Metacity wouldn't have been written--Sawfish was already
> > available.  (In other words, you can't do this in Metacity.  By
> > design.)
> 
> Ok, I see that.  And libwnck is quite an acceptable solution for me,
> esp. to test out new ideas, it's just the keybindings.
> 
> Jan.
> 




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