1

We have a specific scenarion in gtk based application, where there is a toplevel gtk window containing gtkwidgets which are actually webviews created by webkit.

Our use case is such that we need to fire a resize of the child widgets(webview) after hiding the toplevel gtkwindow because the application makes a transition from one scene to another. This ends up in a situation that the resize only happens when we show the toplevel window because the callback to resize the child widgets is registered with the size_allocate signal which only gets emmitted during the show call.

A workaround for this problem could be that we register the callback for the configure_event signal instead of the size_allocate because configure_event signal is emitted even if the window is in hidden state.(in case of size_allocate signal, the signal is scheduled to get emitted only on the next show call, so we have a graphics nuisance that the transition isnt seamless.) Now, the problem is that the configure_event is only emitted for the toplevel window and not for the child widgets.

We tested a simple gtk sample in which we created a toplevel window and a button. Following observations we can make out of it:

  1. if we do not register any callback for either the toplevel or the button, the button gets resized along with the toplevel.(gtk defaultly resizes all child widgets as per toplevel's resize)
  2. As soon as we register a configure_event callback for the toplevel window, and return true from it.. the child button stops resizing as the toplevel is resized.But when we return false from this callback, the button starts resizing along with the toplevel window.So there must be some event that gets propogated to the child button that does the auto resize of the button.

Now two questions:

  1. What is this event that gets propogated to the child widget which on returning false doesnt get to the widget?(we didnt get any callback for configure_event registered for the child button)

  2. As our case has a custom webview widget, it does not behave as the standard gtk button widget behaves for the configure_event.So the only way out is to know which event do we register for,register a callback for it and call a custom resize on the webview widget from that callback.

1 Answer 1

0

the return value of the callback matters. A TRUE has the meaning I handled this, do not propagte this event any further down the widget tree. A FALSE propagates the event further. It has nothing to do with any other event.

4
  • Our requirement is to register a callback for the moment the event propogates from the toplevel to child widgets on returning false from the toplevel callback.Because for standard gtk widgets.. this might not be required as internally manages to resize the child widgets like a button. But for our usecase our gtkwidget does not behave as a standard gtk widget like a button.. so we have to tell it specifically using a registered callback to resize the webview content.
    – ashishsony
    Apr 5, 2014 at 6:56
  • I do not see the issue here. What stops you from doing your custom resize foo (or calling your function which does that) either in a callback you attach to either "draw" (if the scene is somewhat static, no animation) or "configure-event"?
    – drahnr
    Apr 5, 2014 at 8:11
  • Because configure-event callback gets hit for toplevel only. Not for the child widgets.and the webkit that controls the child is another module that is separate from the module(browser ui) that creates the top-level. Doing it on draw is not feasable because the idea is to get done with all the resizing work before the show of the page is done, because there is a specific transition phase in our app that leads to an artifact of showing the old unsized view for a split second, then the resided view. This is why we want to finish with resizing work before we actually show
    – ashishsony
    Apr 5, 2014 at 8:37
  • Then overwrite the klass->draw defaulthandler (the function pointer, this is supposed to do the actual drawing, callbacks hooked to "draw" signal are processed afterwards) and do your resize foo. Then call you widgets actual drawing fun (save the content of ->draw before overwriting and save it in i.e. ->backup - add this func pointer yourself to that "class"). After finishing your resize foo call ->backup in your custom function you assigned to ->draw. I guess configure event is consumed by the first container widget, but I did not investigate.
    – drahnr
    Apr 5, 2014 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.