Forum: Ruby Gtk and root window

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C63e105d68d1e5e8dcba755d15de7a22?d=identicon&s=25 Eustáquio Rangel (taq)
on 2006-02-18 20:39
(Received via mailing list)
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! :-)
4913bcb685792f601ae9813b4713abb9?d=identicon&s=25 Detlef Reichl (Guest)
on 2006-02-18 20:57
(Received via mailing list)
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! :-)
>

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
C63e105d68d1e5e8dcba755d15de7a22?d=identicon&s=25 Eustáquio Rangel (taq)
on 2006-02-18 21:22
(Received via mailing list)
> 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. :-)

Thanks again!
4913bcb685792f601ae9813b4713abb9?d=identicon&s=25 Detlef Reichl (Guest)
on 2006-02-18 22:28
(Received via mailing list)
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. :-)
>

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
C63e105d68d1e5e8dcba755d15de7a22?d=identicon&s=25 Eustáquio Rangel (taq)
on 2006-02-18 22:41
(Received via mailing list)
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. :-)

> 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,
C63e105d68d1e5e8dcba755d15de7a22?d=identicon&s=25 Eustáquio Rangel (taq)
on 2006-02-18 23:05
(Received via mailing list)
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. :-)

Thanks again for that tip!
This topic is locked and can not be replied to.