SWT: GTK_INCLUDE_INFERIORS worst enemy (Sash Widget)

Good day my fellow Developers and Engineers,

 In my previous post I’ve written about INCLUDE_INFERIORS in Tracker Widget

Today I’ve started working on  Sash Widget’s drawBand() method, and guess what I have found there ?

….”Exactly, my old “friend” OS.GTK_INCLUDE_INFERIORS.”


In Sash widget, INCLUDE_INFERIORS call is needed to put stippled rectangle ON TOP of  the parent.handle.

If you try to draw rectangle without INCLUDE_INFERIORS, it appears below the parent.handle, thus you won’t be able to see it.

Hackish solution to GDK INCLUDE_INFERIORS

After “googling” this issue, I have found  this article, that seems very popular, as it is referenced by many websites.

In short, article suggests to create  “cairo” from “gtk_window”, than to create a “surface” that points to this “cairo”, and finally to create new “cairo_new” that uses surface that points to the first “cairo”. Got confused ? Yeah, me too!

Let’s try it again:

 1.  source_surface -> takes as target -> cairo (that references GTK window)
 2.  cairo_new -> uses source_surface (thus drawing on a surface that is on top of cairo)

I think  that this is very hackish way, to achieve effect of INCLUDE_INFERIORS, but it works and I would be fully satisfied with this hack, if I didn’t need to change the color of Sash.

Why Hackish way cannot be used in Sash ?

There are two important things I need to do to replicate  GDK Sash:

1. Make it appear on mouse click
2. Make it stippled or at least make it in some neat light grey colour. ( as stippling is considered outdated , maybe proposal of light grey would be accepted upstream)

Make it appear on mouse click is done by replacing:

OS.gdk_gc_set_function (gc, OS.GDK_XOR);


Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_DIFFERENCE);

Point number 2  is done in Cairo by changing source rgb:

Cairo.cairo_set_source_rgb(cairo, 1, 1, 1);

In theory, to change color of Sash to  light grey, I would just need  to change  RGB number to something like “0.3,0.3,0.3” in the function above, and  celebrate my success.

 Unfortunately,  hackish way of replicating INCLUDE_INFERIORS, will not allow me to change RGB in this case. As I have said above, we are using cairo as target_surface, thus when I change color of Sash, it will change color of handle itself, and it is definitely not the way, I need it to behave.

Want to try it yourself and get updates on this issue ?

If you want to try it yourself:


I have opened a bug regarding this issue. Fastest way to get updates on this issue is to include yourself to CC list in this bug:


I will also post solution here, so everyone could use it, when this issue is resolved.




Check out more posts on “SWT migration From GTK+ 2 to GTK+ 3”


About Anatoly Spektor

My name is Anatoly Spektor (originally Anatolijs Spektors) I am Software and Web Developer. I have worked in Seneca Center for Development of Open Technology on Big Blue Button Add-on - Polling Module, Red Hat and some other places :) I am an author of the book 'Eclipse Debugging How To', Muay Thai fighter and amateur photographer ;)
This entry was posted in Cairo Graphics Library, Eclipse Development, open-source, Red Hat, SWT and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s