I'd like to be able to draw on the root window in Linux. I.e. make an OSD.
I'm using Gnome.
Code samples or links to them would be appreciated.
I'd like to be able to draw on the root window in Linux. I.e. make an OSD.
I'm using Gnome.
Code samples or links to them would be appreciated.
It is possible, but you will not see anything in GNOME. Nautilus, GNOME's file manager, opens its own window on top of root X window to display icons. Because of that the root X window is fully covered... so there is no point in drawing on it.
If you want to make OSD, either you should use a library like XOSD, or open your own X window and make it translucent. In fact, XOSD's source code should be a good example of how to do this.
Whole library seems to be implemented in one file: xosd.c.
use X11::Protocol;
my $x = X11::Protocol->new();
my $desktop;
my ($root,undef,@kids)=$x->QueryTree($x->{'root'});
printf "%10x:\tRoot\n", $root;
foreach (@kids){
my $gdkw = Gtk2::Gdk::Window->foreign_new($_);
printf ("%10x:\tDesktop\n",$gdkw->get_xid),$desktop=$gdkw,last if $gdkw->get_type_hint eq 'desktop';
}
$desktop=Gtk2::Gdk::Window->foreign_new($root) if ! $desktop;
#------------------------------------------
I can find desktop, verified by xwininfo. But, I lost the code which can draw desktop, seems used "set_back_pixmap".
Now cairo can draw on any windows very simply, just use
$cr = Gtk2::Gdk::Cairo::Context->create ($drawable);
But, this does not work on desktop. Perhaps due to kernel update? Or I messed up now on Ubuntu 10.04-3.
© 2022 - 2024 — McMap. All rights reserved.