Page 1 of 1

Desktop.windows give only active window [solved]

Posted: Thursday 7th October 2021 5:43pm
by Zeke99
I'm trying to align a transparent window on top of another window (a mediaplayer window) and therefore it would be very helpful to get the X and Y coordinates for both windows.

I found a code example in the Gambas Book (gambas-buch.de) chapter 15.4 which does exactly what I want.

Code: Select all

Public Sub Button1_Click()

  Dim dtWindow As DesktopWindow
  Desktop.Windows.Refresh()
 
  For Each dtWindow In Desktop.Windows
    If dtWindow.SkipTaskbar = False Then
       Print "Window.Name = \"" & dtWindow.Name & "\" , X = " & dtWindow.X & " , Y = " & dtWindow.Y
    Endif 
  Next 
 
End
The problem is that I only recieve the active window and nothing else. In the book they recieve all windows, not only the active one.
I have included gb.desktop and gb.desktop.x11.
Gambas version is 3.16.3 on Linux mint 20.1 Cinnamon.

Obviously I'm doing something wrong or missing some important stuff but what?

Ps Will be a measuring microscope when finished

Re: Desktop.windows give only active window

Posted: Friday 8th October 2021 12:31am
by BruceSteers
that code works completely as expected for me on mint

[System]
Gambas=3.16.90 51cf626fa (bruces-patched)
OperatingSystem=Linux
Kernel=5.4.0-84-generic
Architecture=x86_64
Distribution=Linux Mint 20.2 Uma
Desktop=Cinnamon


Result
Window.Name = "Computer" , X = 256 , Y = 194
Window.Name = "MediaPlay" , X = 39 , Y = 328
Window.Name = "Gambas ONE - Post a reply — Mozilla Firefox" , X = 49 , Y = 76
Window.Name = "Startup.module - _aa 0.0.28 — Gambas 3 - DEVELOPMENT VERSION, USE AT YOUR OWN RISK!" , X = 147 , Y = 122

Did you try it without the "If dtWindow.SkipTaskbar" bit?
Public Sub Button1_Click()

  Dim dtWindow As DesktopWindow
  Desktop.Windows.Refresh()
 
  For Each dtWindow In Desktop.Windows
       Print "Window.Name = \"" & dtWindow.Name & "\" , X = " & dtWindow.X & " , Y = " & dtWindow.Y
  Next 
 
End

Re: Desktop.windows give only active window

Posted: Friday 8th October 2021 2:51pm
by cogier
Have a look at the attached program and see if that helps you.
LineUp-0.0.1.tar.gz
(33.67 KiB) Downloaded 275 times

Re: Desktop.windows give only active window

Posted: Sunday 10th October 2021 6:47pm
by Zeke99
Thank's a lot BruceSteers and Cogier for your answers.
I took a new computer, made a fresh Linux Mint 20.2 and a Gambas ppa:-install and now it works like a charm. I don't know what's wrong with the old computer but it's obviously local to that computer.
Have a nice day everyone!

Re: Desktop.windows give only active window [solved]

Posted: Sunday 10th October 2021 6:54pm
by Zeke99
And your example was really cool, Cogier.
Will see if I can use it together with the mediaplayer window.

Re: Desktop.windows give only active window [solved]

Posted: Monday 11th October 2021 8:12am
by BruceSteers
I know a lot of gambas features requires x11 , if your other system uses wayland then various things will not work as expected.

That's about all i can think of.

I'm sure you'll figure it out.
:)