Live Thumbnail of Widgets

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Live Thumbnail of Widgets

Gerald Nunn
I work on the Tilix terminal emulator and I'm looking at enhancing some
functionality. At the moment Tilix uses a siderbar rather then tabs to
manage multiple pages (or sessions as they are referred to in Tilix). This
sidebar is in a GTKRevealer that can be popped out and shown as needed and
in the sidebar I render thumbnails of the pages as a visual cue to help the
user select the desired page/session. A screenshot of the sidebar can be
seen here:

https://gnunn1.github.io/tilix-web/assets/images/gallery/tilix-screenshot-2.png

At the moment the rendering of thumbnails for off-screen pages is
relatively expensive. In order for the rendering to work, I need to create
a GTKOffscreenWindow, re-parent the widget to it, draw to a surface and
finally render the thumbnail. The whole process takes between 10 to 30 ms.
In the current design where the rendering happens when the sidebar is
popped out it's fast enough.

I'd like to have the option of making the sidebar permanently visible in
addition to the revealer. One thing that's been holding me back on this is
the expectation that as soon as it becomes permanently visible there is an
expectation that the contents would be updated real time or least near real
time. My rendering time of 10 to 30 ms is just a bit too slow for that
particularly if it's being called very regularly.

I was thinking of switching from using GTKNotebook to a custom solution
which would host the non-visible pages in GTKOffScreenWindow and simply
re-parent them to a visible GtkBox when it becomes the active page/session.
I was looking at POCing this approach out a bit however it strikes me as
having a certain amount of ugliness that I can't help but feel there is a
better way.

I'm looking for some advice on alternative solutions that would fit my
needs. In an ideal solution, the thumbnails would be updated real time
similar to the windows in gnome-shell when you go into overview mode.
However any solution that increases the rendering speed sufficiently to
permit buffered but near real-time updates would be sufficient as well.

I'm not well versed in the lower intricacies of GTK hence why I thought it
would be a good idea to ask for advice before I go too far and end up going
in the wrong direction.

Cheers,

Gerald
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Live Thumbnail of Widgets

infirit
On 20/05/17 16:27, Gerald Nunn wrote:
> I'm looking for some advice on alternative solutions that would fit my
> needs. In an ideal solution, the thumbnails would be updated real time
> similar to the windows in gnome-shell when you go into overview mode.
> However any solution that increases the rendering speed sufficiently to
> permit buffered but near real-time updates would be sufficient as well.

I never done anything like this so please anyone correct me if I am
wrong, but..

Have you though about connecting to the widget's draw signal? With it
you get a cairo context which one usually draws on but I can imagine you
could just as well create a pixbuf  miniature. So, get the surface from
the cairo context with cairo_get_target, then use
gdk_pixbuf_get_from_surface to create the pixbuf.

~infirit

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Live Thumbnail of Widgets

Gergely Polonkai
On Fri, Jun 2, 2017, 20:57 infirit <[hidden email]> wrote:

> On 20/05/17 16:27, Gerald Nunn wrote:
> > I'm looking for some advice on alternative solutions that would fit my
> > needs. In an ideal solution, the thumbnails would be updated real time
> > similar to the windows in gnome-shell when you go into overview mode.
> > However any solution that increases the rendering speed sufficiently to
> > permit buffered but near real-time updates would be sufficient as well.
>
> I never done anything like this so please anyone correct me if I am
> wrong, but..
>
> Have you though about connecting to the widget's draw signal? With it
> you get a cairo context which one usually draws on but I can imagine you
> could just as well create a pixbuf  miniature. So, get the surface from
> the cairo context with cairo_get_target, then use
> gdk_pixbuf_get_from_surface to create the pixbuf.
>
> ~infirit
>

If I get it right, whenever you want to draw the thumbnail, you reparent
the widget to an offscreen window. How about reparenting them at the moment
they disappear from eyesight, and leaving them there until it needs to be
displayed? That might save you some CPU time.

Also, I would probably use the widget itself as the thumbnail, shielded by
an unclickable, transparent layer. However, all the rescaling that has to
be done this way may introduce significant CPU usage.

Maybe you should take a look into the sources of Boxes. I don't remember,
how they generate the thumbnails for the VM screens, but it might help.

Best,
Gergely

>
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Loading...