Re: Allow a GtkWindow to prevent losing focus



On Wed, Jul 26, 2006 at 10:42:10AM +0200, Mardy wrote:
  I made a subclass of GtkWindow for my particular needs, among which
there is this important one: when the user clicks on another window
of the same class in the same application, the window which currently
owns the focus should be notified of the event, and if needed be able to
prevent the focus to change.

I've seen the focus-in-event and focus-out-event, but they are called
only after the focus has been moved.

It's the window manager what gives windows focus and it can
do it on a keyboard shortcut, on a mere mouse-over (with
point-to-focus policy), or even by some scripted action.  The
window manager can be also set not to pass the click events
that gave a window focus to the window.  So generally the
window just gets focus and has to deal with it.

Is there some way to achive this behaviour, other than calling
gtk_window_present() to restore the focus to the window which originally
owned it?

Focus can be refused altogether with gdk_window_set_accept_focus()
(note this does not guarantee the window manager won't try
to give the window focus anyway, but sane window managers
respect it) but I suppose this is not what you need.  It
should be possible to refuse focus, track mouse clicks and
if you decide the window should get focus then accept focus
and explicitly take it.  But this strongly interferes with
user window managing settings so I already regret I told you
it...

Yeti


--
Anonyms eat their boogers.



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