Sign in Join

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

Mailing lists / lazarus / 2012-11

Getting X Window handle ?

14 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Van Canneyt

Hello,

I'm trying to embed the VLC player (using the videolan DLLS) in a LCL application. On Windows, this works fine. On Linux, this does not work.

The reason is that the VideoLan library expects the native window handle. On Windows, TWinControl.Handle provides this.

On Linux, TWinControl.Handle returns the GTK widget pointer if I'm using GTK. (I imagine it will be something similar when using Qt)

How can I get access to the low-level X window handle (id) of a TWinControl on Linux ?

As soon as I get that working, I can donate the TLCLVCLplayer code for inclusion in Lazarus (about 50 lines of code).

The widget-set independent code will go in FPC subversion later today. It can be used on any platform, but will only show video in a free-floating window.

Michael.

Reply by email

zeljko
to Michael Van Canneyt
Michael Van Canneyt wrote 13 lines
Hello, I'm trying to embed the VLC player (using the videolan DLLS) in a LCL application. On Windows, this works fine. On Linux, this does not work. The reason is that the VideoLan library expects the native window handle. On Windows, TWinControl.Handle provides this. On Linux, TWinControl.Handle returns the GTK widget pointer if I'm using GTK. (I imagine it will be something similar when using Qt) How can I get access to the low-level X window handle (id) of a TWinControl on Linux ?

It's not so problematic. in lcl/widgetset/qt or in gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 TWindow from GdkWindow.

zeljko

Reply by email

Michael Van Canneyt
to zeljko
zeljko wrote 18 lines
On Monday 05 of November 2012 10:35:45 Michael Van Canneyt wrote: > Hello, > > I'm trying to embed the VLC player (using the videolan DLLS) in a LCL > application. On Windows, this works fine. On Linux, this does not work. > > The reason is that the VideoLan library expects the native window handle. > On Windows, TWinControl.Handle provides this. > > On Linux, TWinControl.Handle returns the GTK widget pointer if I'm using > GTK. (I imagine it will be something similar when using Qt) > > How can I get access to the low-level X window handle (id) of a TWinControl > on Linux ? It's not so problematic. in lcl/widgetset/qt or in gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 TWindow from GdkWindow.

Actually, it is in gtk2proc, FormToX11Window :-)

Thanks.

The function could accept a TWinControl instead of TCustomForm I would think. Maybe an overloaded version can be added. The code is the same.

I'd even suggest adding a GetNativeHandle : Pointer to TWinControl, but I suspect that will encounter some resistance :-)

Michael.

Reply by email

zeljko
to Michael Van Canneyt
Michael Van Canneyt wrote 29 lines
On Mon, 5 Nov 2012, zeljko wrote: > On Monday 05 of November 2012 10:35:45 Michael Van Canneyt wrote: >> Hello, >> >> I'm trying to embed the VLC player (using the videolan DLLS) in a LCL >> application. On Windows, this works fine. On Linux, this does not work. >> >> The reason is that the VideoLan library expects the native window >> handle. On Windows, TWinControl.Handle provides this. >> >> On Linux, TWinControl.Handle returns the GTK widget pointer if I'm using >> GTK. (I imagine it will be something similar when using Qt) >> >> How can I get access to the low-level X window handle (id) of a >> TWinControl on Linux ? > > It's not so problematic. in lcl/widgetset/qt or in > gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 TWindow > from GdkWindow. Actually, it is in gtk2proc, FormToX11Window :-) Thanks. The function could accept a TWinControl instead of TCustomForm I would think. Maybe an overloaded version can be added. The code is the same. I'd even suggest adding a GetNativeHandle : Pointer to TWinControl, but I suspect that will encounter some resistance :-)

Yes, I'm suspicious about it too :)

zeljko

Reply by email

Kostas Michalopoulos
to zeljko

I'd like such a function myself too, sometimes it is useful to access the *real* native window regardless of the widgetset you use (GTK, Qt, Carbon, etc).

zeljko wrote 40 lines
On Monday 05 of November 2012 11:24:41 Michael Van Canneyt wrote: > On Mon, 5 Nov 2012, zeljko wrote: > > On Monday 05 of November 2012 10:35:45 Michael Van Canneyt wrote: > >> Hello, > >> > >> I'm trying to embed the VLC player (using the videolan DLLS) in a LCL > >> application. On Windows, this works fine. On Linux, this does not work. > >> > >> The reason is that the VideoLan library expects the native window > >> handle. On Windows, TWinControl.Handle provides this. > >> > >> On Linux, TWinControl.Handle returns the GTK widget pointer if I'm using > >> GTK. (I imagine it will be something similar when using Qt) > >> > >> How can I get access to the low-level X window handle (id) of a > >> TWinControl on Linux ? > > > > It's not so problematic. in lcl/widgetset/qt or in > > gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 TWindow > > from GdkWindow. > > Actually, it is in gtk2proc, FormToX11Window :-) > > Thanks. > > The function could accept a TWinControl instead of TCustomForm I would > think. Maybe an overloaded version can be added. The code is the same. > > I'd even suggest adding a GetNativeHandle : Pointer to TWinControl, > but I suspect that will encounter some resistance :-) Yes, I'm suspicious about it too :) zeljko -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Hans-Peter Diettrich
to Michael Van Canneyt: Actually, it is in gtk2proc, FormToX11Window :-) Thanks. The function could accept a…
Show quoted text 15 lines
>> How can I get access to the low-level X window handle (id) of a >> TWinControl >> on Linux ? > > It's not so problematic. in lcl/widgetset/qt or in > gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 > TWindow from > GdkWindow. Actually, it is in gtk2proc, FormToX11Window :-) Thanks. The function could accept a TWinControl instead of TCustomForm I would think.

AFAIK X11 only supports handles for top level windows, managed by the window manager.

DoDi

Reply by email

Unknown author
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 20 lines
Michael Van Canneyt schrieb: >>> How can I get access to the low-level X window handle (id) of a >>> TWinControl >>> on Linux ? >> >> It's not so problematic. in lcl/widgetset/qt or in >> gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 TWindow >> from >> GdkWindow. > > Actually, it is in gtk2proc, FormToX11Window :-) > > Thanks. > > The function could accept a TWinControl instead of TCustomForm I would > think. AFAIK X11 only supports handles for top level windows, managed by the window manager.

This is not correct.

Michael.

Reply by email

Mark Morgan Lloyd
to Kostas Michalopoulos: I'd like such a function myself too, sometimes it is useful to access the *real* native…
Kostas Michalopoulos wrote
I'd like such a function myself too, sometimes it is useful to access the *real* native window regardless of the widgetset you use (GTK, Qt, Carbon, etc).

Definitely agreed. In my case so that a program can disable the screen saver whilst it's running using xdg-screensaver.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

zeljko
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 7 lines
Kostas Michalopoulos wrote: > I'd like such a function myself too, sometimes it is useful to access > the *real* native window regardless of the widgetset you use (GTK, Qt, > Carbon, etc). Definitely agreed. In my case so that a program can disable the screen saver whilst it's running using xdg-screensaver.

Maybe we can add LCLIntf.GetNativeHandle(Handle: HWND): PtrUInt ?

zeljko

Reply by email

zeljko
to Unknown author: This is not correct. Michael.
Show quoted text 22 lines
On Tue, 6 Nov 2012, Hans-Peter Diettrich wrote: > Michael Van Canneyt schrieb: >>>> How can I get access to the low-level X window handle (id) of a >>>> TWinControl >>>> on Linux ? >>> >>> It's not so problematic. in lcl/widgetset/qt or in >>> gtk2widgetset.inc (there's IFDEF X11 or similar) which gets X11 TWindow >>> from >>> GdkWindow. >> >> Actually, it is in gtk2proc, FormToX11Window :-) >> >> Thanks. >> >> The function could accept a TWinControl instead of TCustomForm I would >> think. > > AFAIK X11 only supports handles for top level windows, managed by the > window manager. This is not correct.

+1. It's correct ONLY if widgetset lib (qt, gtk2) uses alien widgets, in that case form is only x11 handle, but (at least with qt) you can always create an widget as "native" ,so it'll have native x11 handle (panel,button ...anything).

zeljko

Reply by email

Mark Morgan Lloyd
to zeljko: Maybe we can add LCLIntf.GetNativeHandle(Handle: HWND): PtrUInt ? zeljko
zeljko wrote 9 lines
On Tuesday 06 of November 2012 10:20:03 Mark Morgan Lloyd wrote: > Kostas Michalopoulos wrote: >> I'd like such a function myself too, sometimes it is useful to access >> the *real* native window regardless of the widgetset you use (GTK, Qt, >> Carbon, etc). > Definitely agreed. In my case so that a program can disable the screen > saver whilst it's running using xdg-screensaver. Maybe we can add LCLIntf.GetNativeHandle(Handle: HWND): PtrUInt ?

+1 here. I had to resort to calling xwininfo, since it was the only way I could be absolutely confident that the ID was always correct irrespective of the combination of wm/desktop and display manager.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Kostas Michalopoulos
to Mark Morgan Lloyd

Why not a TContol (or TWinControl) method?

Mark Morgan Lloyd wrote 33 lines
zeljko wrote: > > On Tuesday 06 of November 2012 10:20:03 Mark Morgan Lloyd wrote: >> >> Kostas Michalopoulos wrote: >>> >>> I'd like such a function myself too, sometimes it is useful to access >>> the *real* native window regardless of the widgetset you use (GTK, Qt, >>> Carbon, etc). >> >> Definitely agreed. In my case so that a program can disable the screen >> saver whilst it's running using xdg-screensaver. > > > Maybe we can add LCLIntf.GetNativeHandle(Handle: HWND): PtrUInt ? +1 here. I had to resort to calling xwininfo, since it was the only way I could be absolutely confident that the ID was always correct irrespective of the combination of wm/desktop and display manager. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

zeljko
to Kostas Michalopoulos
Kostas Michalopoulos wrote
Why not a TContol (or TWinControl) method?

TControl does not have handle, so if it's implemented in LCL it should be TWinControl.

zeljko

Show quoted text 39 lines
On Tue, Nov 6, 2012 at 11:04 AM, Mark Morgan Lloyd wrote: > zeljko wrote: >> On Tuesday 06 of November 2012 10:20:03 Mark Morgan Lloyd wrote: >>> Kostas Michalopoulos wrote: >>>> I'd like such a function myself too, sometimes it is useful to access >>>> the *real* native window regardless of the widgetset you use (GTK, Qt, >>>> Carbon, etc). >>> >>> Definitely agreed. In my case so that a program can disable the screen >>> saver whilst it's running using xdg-screensaver. >> >> Maybe we can add LCLIntf.GetNativeHandle(Handle: HWND): PtrUInt ? > > +1 here. I had to resort to calling xwininfo, since it was the only way I > could be absolutely confident that the ID was always correct irrespective > of the combination of wm/desktop and display manager. > > > -- > Mark Morgan Lloyd > markMLl .AT. telemetry.co .DOT. uk > > [Opinions above are the author's, not those of his employers or > colleagues] > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Kostas Michalopoulos
to zeljko

Yeah i wasn't sure which one is the handle-less which is why i mentioned both :-P

zeljko wrote 54 lines
On Tuesday 06 of November 2012 11:44:04 Kostas Michalopoulos wrote: > Why not a TContol (or TWinControl) method? TControl does not have handle, so if it's implemented in LCL it should be TWinControl. zeljko > > On Tue, Nov 6, 2012 at 11:04 AM, Mark Morgan Lloyd > > wrote: > > zeljko wrote: > >> On Tuesday 06 of November 2012 10:20:03 Mark Morgan Lloyd wrote: > >>> Kostas Michalopoulos wrote: > >>>> I'd like such a function myself too, sometimes it is useful to access > >>>> the *real* native window regardless of the widgetset you use (GTK, Qt, > >>>> Carbon, etc). > >>> > >>> Definitely agreed. In my case so that a program can disable the screen > >>> saver whilst it's running using xdg-screensaver. > >> > >> Maybe we can add LCLIntf.GetNativeHandle(Handle: HWND): PtrUInt ? > > > > +1 here. I had to resort to calling xwininfo, since it was the only way I > > could be absolutely confident that the ID was always correct irrespective > > of the combination of wm/desktop and display manager. > > > > > > -- > > Mark Morgan Lloyd > > markMLl .AT. telemetry.co .DOT. uk > > > > [Opinions above are the author's, not those of his employers or > > colleagues] > > > > -- > > _______________________________________________ > > Lazarus mailing list > > > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email