Desktop.windows give only active window [solved]

Post your Gambas programming questions here.
Post Reply
Zeke99
Posts: 10
Joined: Tuesday 12th January 2021 7:44pm

Desktop.windows give only active window [solved]

Post 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
Last edited by Zeke99 on Sunday 10th October 2021 6:49pm, edited 1 time in total.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Desktop.windows give only active window

Post 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
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Desktop.windows give only active window

Post 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 272 times
Zeke99
Posts: 10
Joined: Tuesday 12th January 2021 7:44pm

Re: Desktop.windows give only active window

Post 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!
Zeke99
Posts: 10
Joined: Tuesday 12th January 2021 7:44pm

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

Post by Zeke99 »

And your example was really cool, Cogier.
Will see if I can use it together with the mediaplayer window.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

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

Post 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.
:)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply