Re: Managing focus through a GtkSocket - anyone??

Neil Bird <neil fnxweb com> writes:

> Owen Taylor wrote:
> > Could you provide some more examples of:
> >  - What are trying to do
> >  - What happens
> >  - What you expect to happen.
>   See attached; should be straightforward to make. They're two
> progs. ripped from the GTK examples.
>   In essence: I want to be notified of focus within plugin
> 'text'. If you:
> % ./text 0
>   ... then moving the pointer in & out gives the focus-in event
> to it: it prints "<text-event>".
>   Hoever, the same thing as a plugin:
> % ./rangewidgets &
> [1] 9537
> ./text 0x8800015     # output from rangewidgets - type this in
> % ./text 0x8800015
>   ... puts text inside rangewidgets as expected, but nothing I
> then do will cause 'text' to print out the event text - it seems
> to just not get those events.
As long as the focus is actually on the text widget or one
of the other widgets inside the plug, I get the events

If the focus is on one of the widgets in the parent, then no,
the focus-in/focus-out events will not be received.

Really, the focus-in focus-out on the GtkPlug are implementation
details ... from the point of view of a programmer, there
are two places where you can catch keystrokes:

 - The real toplevel window
 - Individual widgets

And those are the same places it makes sense to listen for
focus-in/focus-out events. A GtkPlug is an intermediate
container, and it makes no more sense to listen for
focus-in/focus-out there than on a GtkHBox. 

(Well, a bit more sense, since you will sometimes receive
focus in events on the GtkPlug. But the focus-in event
on the GtkPlug doesn't mean the real toplevel got focus,
it means that a widget within the GtkPlug got focus.)
> > Focusing with Plug/Socket is supposed to work identically
> > as without plug/socket. And to my knowledge this is
> > the case for 1.2.10 + patch. (Other versions might show
> > various small defects, but will mostly work like this.)
>   Then I guess I'm probably doing something daft!
> > What if you try programs like the GNOME control center -
> > does focusing work there for you?
>   It's a bit difficult to draw a parallel there; that sort of
> thing works as I'd expect, but AFAIK none of it relies upon
> receipt of focus events within the plugins.

How do you think things like drawing the focus indicators work?

Before you make gvim work within a plug-socket, you might need to make
it work as a widget ... it sounds like it doesn't use the widget model
of keystroke and focus handling but tries to listen for those on the

Remember that GtkPlug/GtkSocket is a device for embedding widgets, not
for embedding toplevels. ... there is no real sensible behavior for
a toplevel within another toplevel.


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