[Gambas-user] Test Screen.Available values

Bruce Steers bsteers4 at gmail.com
Mon May 22 12:09:52 CEST 2023


Thanks Martin and thanks for testing but as I previously said
Screen.AvailableWidth and AvailableHeight are not reliable on all configs
so your code will also fail.
On my system it works for gtk3 but none of the others.
I already have a fix for QT now using gb.desktop.x11

BruceS

On Mon, 22 May 2023 at 09:35, Martín <mbelmonte at belmotek.net> wrote:

> Hi,
>
> Perhaps the following code may be useful
>
> ' Gambas class file
>
> Export
>
> Static Public Sub Fix(o As Object, Optional s As Integer = -1)
>
>    Dim x As Integer
>
>    x = Screen(s)
>
>    o.x = Screens[x].AvailableX + Screens[x].AvailableWidth / 2 - o.W / 2
>    o.y = Screens[x].AvailableY + Screens[x].AvailableHeight / 2 - o.H / 2
>
> End
>
> Static Public Sub Shoot(o As Object, Optional s As Integer = -1,
> Optional sPath As String = "/tmp/bro.png", Optional iQua As Integer = 100)
>
>    Dim x As Integer
>
>    x = Screen(s)
>
>    Desktop.Screenshot(Screens[x].X, Screens[x].Y, Screens[x].Width,
> Screens[x].Height).Save(sPath, iQua)
>
> End
>
> Static Private Function Screen(s As Integer) As Integer
>
>    Dim n, b, x As Integer
>
>    If s = -1 Then
>      For n = 0 To Screens.Count - 1
>        If Screens[n].AvailableWidth > b Then
>          b = Screens[n].AvailableWidth
>          x = n
>        Endif
>      Next
>    Else
>      If s < Screens.Count Then
>        x = s
>      Else
>        x = 0
>      Endif
>    Endif
>
>    Return x
>
> End
>
> Best regards
>
> Martin.
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230522/30565e56/attachment-0001.htm>


More information about the User mailing list