Sign in Join

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

Mailing lists / lazarus / 2010-06

Gtk2 question

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

SteveG

Is it at all possible to determine which application (eg gedit/etc) had focus 'before' clicking on my laz app.

Or another way -

Is there a laz/fpc call to retrieve the window stack order for GTK2

Thanks - SteveG

Reply by email

Hans-Peter Diettrich
to SteveG
Is it at all possible to determine which application (eg gedit/etc) had focus 'before' clicking on my laz app.

This is more a question of the window manager (KDE, Gnome...), not of the widgetset. Such support is almost missing (not implemented), e.g. it's still impossible to dock forms on Linux, and the "single taskbar button" also does not work on some distros.

DoDi

Reply by email

zeljko
to SteveG: Is it at all possible to determine which application (eg gedit/etc) had focus 'before'…
SteveG wrote
Is it at all possible to determine which application (eg gedit/etc) had focus 'before' clicking on my laz app.

Yes, Theo already answered, but it's not so easy.When you click any form of your laz app it grabs focus so I guess it will be hard to determine what app (if any) had focus before.Don't know why do you need that but think that polling is the only way to get it (or even use Application.OnIdle).In laz 0.9.29 gtk2 Application.Activate/Deactivate is fixed so you know exactly when your app stealed global focus/or lost it.

Or another way - Is there a laz/fpc call to retrieve the window stack order for GTK2

Screen.CustomFormsZOrdered[]

zeljko

Reply by email

theo
to zeljko
zeljko wrote
Screen.CustomFormsZOrdered[]

But I guess that's for your own application windows only, right?

Given the context, I think the op wanted the order of X toplevel-windows. I have written some code which does this using Xlib. If this is what you need SteveG, I can prepare the code for more general use.

Reply by email

zeljko
to theo
theo wrote
zeljko wrote: > Screen.CustomFormsZOrdered[] But I guess that's for your own application windows only, right?

Yep, if he want to get complete X11 tree he can do that via XLib and (now guessing from my mind) use XQueryTree() and friends.

zeljko

Reply by email

theo
to zeljko

/zeljko wrote:

/> Yep, if he want to get complete X11 tree he can do that via XLib and (now

guessing from my mind) use XQueryTree() and friends.

Yes.
I had already some code but hacked a class today.
The code and an example is here: http://www.theo.ch/lazarus/winlist.zip

The example lists toplevel windows with several properties. If you doubleclick an item, the selected window gets raised, focused and wm-activated plus the desktop is switched if necessary.

It's certainly not perfect but works here.

It should also solve the op's problem, because the list is in stack order. The window below the active window ist the second last in the list. Please test, if you like.

Reply by email

SteveG
to theo
theo wrote 21 lines
/zeljko wrote: /> Yep, if he want to get complete X11 tree he can do that via XLib and (now > guessing from my mind) use XQueryTree() and friends. Yes. I had already some code but hacked a class today. The code and an example is here: http://www.theo.ch/lazarus/winlist.zip The example lists toplevel windows with several properties. If you doubleclick an item, the selected window gets raised, focused and wm-activated plus the desktop is switched if necessary. It's certainly not perfect but works here. It should also solve the op's problem, because the list is in stack order. The window below the active window ist the second last in the list. Please test, if you like.

My apologies for the late response to this (away for a month)

Theo - this works perfectly and solves my problem :)

Very much appreciated

SteveG

Reply by email