Gtk and root window

Hi!
Is there a way to draw something on the root window
using Gtk/Gdk? For example, draw a filled rectangle
there with some info labels.
Thanks! :slight_smile:

Am Sonntag, den 19.02.2006, 04:37 +0900 schrieb Eustaquio Rangel de
Oliveira J:

Hi!
Is there a way to draw something on the root window
using Gtk/Gdk? For example, draw a filled rectangle
there with some info labels.
Thanks! :slight_smile:

Hi,

with

Gdk::Window.default_root_window

you get the root window, which you can use with all Gdk drawing
functions.

But if you run GNOME the main window is completely covered by a nautilus
window. On this window you can’t draw afaik cause it is owned by an
other process.

Cheers
detlef

Hi,

Hi, thanks for your quick answer!

with
Gdk::Window.default_root_window
you get the root window, which you can use with all
Gdk drawing
functions.

I’m kind of new on this Ruby graphics thing, I’m
searching for some examples but I’m not finding some
very clear.
Could you please show me how to draw a rectangle on
the screen (on root window or even on a gtk window)?
If I have a starting point will be easier to go on and
not bore you more with this kind of thing. :slight_smile:

Thanks again!

Am Sonntag, den 19.02.2006, 05:19 +0900 schrieb Eustaquio Rangel de
Oliveira J:

I’m kind of new on this Ruby graphics thing, I’m
searching for some examples but I’m not finding some
very clear.
Could you please show me how to draw a rectangle on
the screen (on root window or even on a gtk window)?
If I have a starting point will be easier to go on and
not bore you more with this kind of thing. :slight_smile:

require ‘gtk2’

Gtk.init

win = Gdk::Window.default_root_window

gc = Gdk::GC.new win
win.draw_rectangle gc, true, 100, 100, 300, 400

Gtk.main

Hi,

i don’t think that you will get much of it, if you don’t understand how
X drawing works.

To get into the drawing concepts of Gdk the “X lib programming manual”
is the best starting point, even if it is quite hard. I don’t know of a
better tutorial.

Cheers
detlef

Hi.

But if you run GNOME the main window is completely
covered by a nautilus
window. On this window you can’t draw afaik cause it
is owned by an
other process.

Argh. XFCE4 also does not allow to draw on the root
window, that’s why my initial tests were not working.
When I run your code and saw nothing there, I closed
XFCE and started Fluxbox and all worked fine.
The root window is owned by xfdesktop. Seems that I’ll
need to find another way to do that. :slight_smile:

Thanks again for that tip!

Hi!

require ‘gtk2’
Gtk.init
win = Gdk::Window.default_root_window
gc = Gdk::GC.new win
win.draw_rectangle gc, true, 100, 100, 300, 400
Gtk.main

Thank you so much! I’ll run the code here. :slight_smile:

i don’t think that you will get much of it, if you
don’t understand how
X drawing works.
To get into the drawing concepts of Gdk the “X lib
programming manual”
is the best starting point, even if it is quite
hard. I don’t know of a
better tutorial.

Searching for it now. Thanks again, I’ll take a look!

Best regards,