Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-08

Linux Window Handles

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

SteveG

Having a problem understanding the usage of window handles in Linux

Windows (XP):
I can use the Win API to control (hide/show/etc) all windows, including ones created by Laz using the handles supplied by Laz (eg Form1.Handle)
- they seem to be exactly the same as Windows handles.

Linux (Ubuntu 8.04):
I can find no correlation between the Laz supplied window handle (Form1.Handle), and the X11 required handle - found using 'xwininfo -int -tree' (and clicking on Form1 of testapp)
As an example, Laz returned 138531872, xwininfo returned 62915166.

Obviously I need to convert or look elsewhere - anybody know how or where ?

As an aside to this, how do I determine the 'main/important' window handle from the list returned by
'xwininfo -int -root' (all windows belonging to root window) - these numbers dont all seem to be top level for an application either. I am using xquerytree from xwin to cycle all windows/children, but dont know how to determine which is the relevant 'top'.

Thanks - SteveG

Reply by email

Graeme Geldenhuys
to SteveG
SteveG wrote 7 lines
Having a problem understanding the usage of window handles in Linux Linux (Ubuntu 8.04): I can find no correlation between the Laz supplied window handle (Form1.Handle), and the X11 required handle - found using 'xwininfo -int -tree' (and clicking on Form1 of testapp) As an example, Laz returned 138531872, xwininfo returned 62915166.

I think the following is true, but I might be wrong. Due to the fact that LCL doesn't talk directly to XLib (unlike fpGUI), it returns some GTK object handle. I guess you need to find a way to convert or query the actual X11 handle from that GTK object handle. This is just a guess.

As an aside to this, how do I determine the 'main/important' window handle from the list returned by

I simply use "xwininfo -tree" and gives me the following results, after I clicked on the window I am interested in.

----------------------[ start ]------------------------------ graemeg at graemeg-laptop:~$ xwininfo -tree

xwininfo: Please select the window about which you would like information by clicking the
mouse in that window.

xwininfo: Window id: 0x2e000a4 "Vodafone Mobile Connect Card driver for Linux"

Root window id: 0x5b (the root window) (has no name) Parent window id: 0x100013d (has no name)
25 children:
0x2e000fd (has no name): () 578x15+2+468 +1305+1150 0x2e000fc (has no name): () 15x3+583+462 +1886+1144 0x2e000f5 (has no name): () 576x1+3+463 +1306+1145 1 child:
0x2e000f6 (has no name): () 566x1+5+5 +1311+1150 1 child:
0x2e000f7 (has no name): () 566x1+0+0 +1311+1150 0x2e000f4 (has no name): () 600x27+0+433 +1303+1115 0x2e000f3 (has no name): () 168x87+416+307 +1719+989 0x2e000d8 (has no name): () 168x87+242+307 +1545+989 <...snip....>
------------[ end ]-----------------

Now that clearly shows the root id (desktop or Root window id: 0x5b) and the main window I clicked on (Parent window id: 0x100013d) and then it's 25 children with their positions.

Regards,
- Graeme -

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

Reply by email

SteveG
to Graeme Geldenhuys

Thanks Graeme
I will see if I can find how to convert from GTK to LCL handles (your theory sounds good)
I have been waiting for fpGUI to be stable enough to use anyway (from the LCL point of view),
so this issue may be a null point soon anyway for me.

'xwininfo' does indeed find the 'main' window, but I am calling 'xquerytree' to get a list of windows
and children (using xwininfo just for testing), and dont seem to be able to find how to determine which is the 'main' from the returned data (seem to be a lot of 'no name' windows in the tree - many at the top level)

Graeme Geldenhuys wrote 68 lines
On Sun, Aug 3, 2008 at 6:37 AM, SteveG wrote: > Having a problem understanding the usage of window handles in Linux > > Linux (Ubuntu 8.04): > I can find no correlation between the Laz supplied window handle > (Form1.Handle), and the X11 required handle - found using 'xwininfo -int > -tree' (and clicking on Form1 of testapp) > As an example, Laz returned 138531872, xwininfo returned 62915166. > I think the following is true, but I might be wrong. Due to the fact that LCL doesn't talk directly to XLib (unlike fpGUI), it returns some GTK object handle. I guess you need to find a way to convert or query the actual X11 handle from that GTK object handle. This is just a guess. > As an aside to this, how do I determine the 'main/important' window > handle from the list returned by > I simply use "xwininfo -tree" and gives me the following results, after I clicked on the window I am interested in. ----------------------[ start ]------------------------------ graemeg at graemeg-laptop:~$ xwininfo -tree xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x2e000a4 "Vodafone Mobile Connect Card driver for Linux" Root window id: 0x5b (the root window) (has no name) Parent window id: 0x100013d (has no name) 25 children: 0x2e000fd (has no name): () 578x15+2+468 +1305+1150 0x2e000fc (has no name): () 15x3+583+462 +1886+1144 0x2e000f5 (has no name): () 576x1+3+463 +1306+1145 1 child: 0x2e000f6 (has no name): () 566x1+5+5 +1311+1150 1 child: 0x2e000f7 (has no name): () 566x1+0+0 +1311+1150 0x2e000f4 (has no name): () 600x27+0+433 +1303+1115 0x2e000f3 (has no name): () 168x87+416+307 +1719+989 0x2e000d8 (has no name): () 168x87+242+307 +1545+989 <...snip....> ------------[ end ]----------------- Now that clearly shows the root id (desktop or Root window id: 0x5b) and the main window I clicked on (Parent window id: 0x100013d) and then it's 25 children with their positions. Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

SteveG
to SteveG

So far I have found that Laz uses a Gtk pointer to a structure rather than a window handle directly.
Anybody know what type of structure (and where to find it) ?

SteveG wrote 93 lines
Thanks Graeme I will see if I can find how to convert from GTK to LCL handles (your theory sounds good) I have been waiting for fpGUI to be stable enough to use anyway (from the LCL point of view), so this issue may be a null point soon anyway for me. 'xwininfo' does indeed find the 'main' window, but I am calling 'xquerytree' to get a list of windows and children (using xwininfo just for testing), and dont seem to be able to find how to determine which is the 'main' from the returned data (seem to be a lot of 'no name' windows in the tree - many at the top level) Graeme Geldenhuys wrote: > On Sun, Aug 3, 2008 at 6:37 AM, SteveG wrote: > > >> Having a problem understanding the usage of window handles in Linux >> >> Linux (Ubuntu 8.04): >> I can find no correlation between the Laz supplied window handle >> (Form1.Handle), and the X11 required handle - found using 'xwininfo -int >> -tree' (and clicking on Form1 of testapp) >> As an example, Laz returned 138531872, xwininfo returned 62915166. >> >> > I think the following is true, but I might be wrong. Due to the fact > that LCL doesn't talk directly to XLib (unlike fpGUI), it returns some > GTK object handle. I guess you need to find a way to convert or query > the actual X11 handle from that GTK object handle. This is just a > guess. > > > >> As an aside to this, how do I determine the 'main/important' window >> handle from the list returned by >> >> > I simply use "xwininfo -tree" and gives me the following results, > after I clicked on the window I am interested in. > > ----------------------[ start ]------------------------------ > graemeg at graemeg-laptop:~$ xwininfo -tree > > xwininfo: Please select the window about which you > would like information by clicking the > mouse in that window. > > xwininfo: Window id: 0x2e000a4 "Vodafone Mobile Connect Card driver for Linux" > > Root window id: 0x5b (the root window) (has no name) > Parent window id: 0x100013d (has no name) > 25 children: > 0x2e000fd (has no name): () 578x15+2+468 +1305+1150 > 0x2e000fc (has no name): () 15x3+583+462 +1886+1144 > 0x2e000f5 (has no name): () 576x1+3+463 +1306+1145 > 1 child: > 0x2e000f6 (has no name): () 566x1+5+5 +1311+1150 > 1 child: > 0x2e000f7 (has no name): () 566x1+0+0 +1311+1150 > 0x2e000f4 (has no name): () 600x27+0+433 +1303+1115 > 0x2e000f3 (has no name): () 168x87+416+307 +1719+989 > 0x2e000d8 (has no name): () 168x87+242+307 +1545+989 > <...snip....> > ------------[ end ]----------------- > > Now that clearly shows the root id (desktop or Root window id: 0x5b) > and the main window I clicked on (Parent window id: 0x100013d) and > then it's 25 children with their positions. > > > Regards, > - Graeme - > > > _______________________________________________ > fpGUI - a cross-platform Free Pascal GUI toolkit > http://opensoft.homeip.net/fpgui/ > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > > > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

SteveG
to SteveG
Found the code necessary to get the GTK handle from a Lazarus handle
(for GTK2)
fWindow(int64) := GDK_WINDOW_XWINDOW( pointer(
PGtkWidget(Form1.Handle)^.Window ) );

add gtk2, gdk2x to the 'uses' section

Show quoted text 112 lines
So far I have found that Laz uses a Gtk pointer to a structure rather than a window handle directly. Anybody know what type of structure (and where to find it) ? SteveG wrote: > Thanks Graeme > I will see if I can find how to convert from GTK to LCL handles (your > theory sounds good) > I have been waiting for fpGUI to be stable enough to use anyway (from > the LCL point of view), > so this issue may be a null point soon anyway for me. > > 'xwininfo' does indeed find the 'main' window, but I am calling > 'xquerytree' to get a list of windows > and children (using xwininfo just for testing), and dont seem to be able > to find how to determine which is the 'main' from the returned data > (seem to be a lot of 'no name' windows in the tree - many at the top level) > > Graeme Geldenhuys wrote: > > >> On Sun, Aug 3, 2008 at 6:37 AM, SteveG wrote: >> >> >> >>> Having a problem understanding the usage of window handles in Linux >>> >>> Linux (Ubuntu 8.04): >>> I can find no correlation between the Laz supplied window handle >>> (Form1.Handle), and the X11 required handle - found using 'xwininfo -int >>> -tree' (and clicking on Form1 of testapp) >>> As an example, Laz returned 138531872, xwininfo returned 62915166. >>> >>> >>> >> I think the following is true, but I might be wrong. Due to the fact >> that LCL doesn't talk directly to XLib (unlike fpGUI), it returns some >> GTK object handle. I guess you need to find a way to convert or query >> the actual X11 handle from that GTK object handle. This is just a >> guess. >> >> >> >> >>> As an aside to this, how do I determine the 'main/important' window >>> handle from the list returned by >>> >>> >>> >> I simply use "xwininfo -tree" and gives me the following results, >> after I clicked on the window I am interested in. >> >> ----------------------[ start ]------------------------------ >> graemeg at graemeg-laptop:~$ xwininfo -tree >> >> xwininfo: Please select the window about which you >> would like information by clicking the >> mouse in that window. >> >> xwininfo: Window id: 0x2e000a4 "Vodafone Mobile Connect Card driver for Linux" >> >> Root window id: 0x5b (the root window) (has no name) >> Parent window id: 0x100013d (has no name) >> 25 children: >> 0x2e000fd (has no name): () 578x15+2+468 +1305+1150 >> 0x2e000fc (has no name): () 15x3+583+462 +1886+1144 >> 0x2e000f5 (has no name): () 576x1+3+463 +1306+1145 >> 1 child: >> 0x2e000f6 (has no name): () 566x1+5+5 +1311+1150 >> 1 child: >> 0x2e000f7 (has no name): () 566x1+0+0 +1311+1150 >> 0x2e000f4 (has no name): () 600x27+0+433 +1303+1115 >> 0x2e000f3 (has no name): () 168x87+416+307 +1719+989 >> 0x2e000d8 (has no name): () 168x87+242+307 +1545+989 >> <...snip....> >> ------------[ end ]----------------- >> >> Now that clearly shows the root id (desktop or Root window id: 0x5b) >> and the main window I clicked on (Parent window id: 0x100013d) and >> then it's 25 children with their positions. >> >> >> Regards, >> - Graeme - >> >> >> _______________________________________________ >> fpGUI - a cross-platform Free Pascal GUI toolkit >> http://opensoft.homeip.net/fpgui/ >> _______________________________________________ >> Lazarus mailing list >> >> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus >> >> >> >> > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > > > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to SteveG
Show quoted text 6 lines
Found the code necessary to get the GTK handle from a Lazarus handle (for GTK2) fWindow(int64) := GDK_WINDOW_XWINDOW( pointer( PGtkWidget(Form1.Handle)^.Window ) ); add gtk2, gdk2x to the 'uses' section

More generic:

uses gtkproc, gdk2x;
  XWindow:=GDK_WINDOW_XWINDOW(GetControlWindow(PGtkWidget(Control.Handle)));

Mattias

Reply by email