[Lazarus] Write to root window?

Graeme Geldenhuys graemeg.lists at gmail.com
Tue May 25 16:59:00 CEST 2010


On 25 May 2010 16:09, Jon Foster  wrote:
> I imagine its possible but I haven't a clue to know even where to beg in
> looking. Is it possible to write to the root window in X (i386 Linux)?
> I'd like to manipulate some images and write them there.


No idea how to do it via LCL, but here is a small sample of code I use
for a fpGUI utility application which draws a rectangular outline
around components/windows (of any X11 application) under the mouse
pointer.

The trick is to draw to the DefaultRootWindow(display) result of
whatever display you are working with.

-------------------------

procedure TMainForm.DrawOutline;
begin
  if not FOutlineDrawn then
  begin
    XSync(fpgApplication.Display, False);
    XDrawRectangle(
        fpgApplication.Display,
        DefaultRootWindow(fpgApplication.Display),
        FOutlineGC,
        newrect.Left, newrect.Top, newrect.Width, newrect.Height);
    lastrect := newrect;
    FOutlineDrawn := True;
    lblPos.Text := Format('(%d,%d)', [newrect.Left, newRect.Top]);
    lblSize.Text := Format('(%d,%d)', [newrect.Width, newRect.Height]);
    lblHandle.Text := IntToHex(last_child, 6);
  end;
end;
-------------------------


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/




More information about the Lazarus mailing list