Re: double_buffered and scrolled_window



On 16 April 2018 at 10:19, Dov Grobgeld <dov grobgeld gmail com> wrote:
Hi all,

After lots of years I finally got around to porting my widget GtkImageViewer to gtk3. After doing lots of reading of man pages, did I realize that i can turn off double buffering.

I wonder what kind of man pages did you read, considering that the API reference of gtk_widget_set_double_buffered() clearly states that it's deprecated and doesn't do anything remotely useful:

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-double-buffered

You should *never* disable double buffering — and you should never need it. Double buffering is an intrinsic characteristic of the windowing system; if you disable it, it means you're literally owning the rendering pipeline — which is why it's still used by applications that render their own UI inside a GTK top level, like Firefox or LibreOffice. Given their user base, we try to avoid breaking their use cases, but we do not really recommend other people try doing that.

GTK widgets should always use the rendering pipeline provided by GTK, not work around it; we do not make any guarantees if you decide to eschew that.

I honestly couldn't read your code because it's using Gob — something that has long since been deprecated and it's not even remotely up to date with the GObject and GTK best practices. From what I could glean:

 - it seems you started from the GtkDrawingArea code, which has some backward-compatibility functionality, like a custom window and the need to send configure events; those are not needed in newly written code
 - you're not using the GTK 3.22 API; for instance, you should be calling gtk_widget_register_window() when creating a new GdkWindow inside the realize() function
 - you're still using GdkPixbuf to do scaling and compositing, instead of using Cairo
 - you're using a client input/output GdkWindow for rendering, instead of rendering directly on the parent's surface
 - you're using a background color and compositing it, instead of using the style system to render the background and border
 - you should be using the Gesture API, instead of connecting to each event in order to do zoom and scroll

There is a wiki page on how to write widgets: https://wiki.gnome.org/HowDoI/CustomWidgets

Ciao,
 Emmanuele.

--


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