Page 1 of 1

DesktopWidth(0) returns wrong value

Posted: Mon Jan 13, 2025 11:06 pm
by robertfern
I have a Dell UltraSharp U3417W monitor. Its screen resolution is 3440w x 1440h.
On PureBasic 6.12 LTS, DesktopWidth(0) returns 1440, same as DesktopHeight(0)

Code: Select all

Result = ExamineDesktops()
WinWidth.l = DesktopWidth(0) : WinHeight.l = DesktopHeight(0)
Debug "WindWidth = " + WinWidth
Debug "WinHeight = " + WinHeight
I had to use Cocoa like so

Code: Select all

Global VS.NSRect
Global Dim Screens.NSRect(0)

Procedure GetAvailableScreens()
  Protected ScreenArray = CocoaMessage(0, 0, "NSScreen screens")
  Protected i.l, NumScreens = CocoaMessage(0, ScreenArray, "count")
  ReDim Screens(NumScreens - 1)
  While i < NumScreens
    CocoaMessage(@Screens(i), CocoaMessage(0, ScreenArray, "objectAtIndex:", i), "frame")
    If i = 0
      CocoaMessage(@VS, CocoaMessage(0, ScreenArray, "objectAtIndex:", i), "visibleFrame")
    EndIf
    i + 1
  Wend
  ProcedureReturn NumScreens
EndProcedure

NumScreens.l = GetAvailableScreens()
winWidth = VS\size\width : winHeight = VS\size\height
Debug "WindWidth = " + WinWidth
Debug "WinHeight = " + WinHeight
** EDIT ** - It works correctly on my Mac mini at Home, with the same OS, But It has an external GPU and a 4k monitor

Re: DesktopWidth(0) returns wrong value

Posted: Tue Jan 14, 2025 9:45 am
by Shardik
When obtaining seemingly incorrect results with DesktopWidth(), DesktopHeight() and ExamineDesktops() you should check your system settings:

System settings > Displays

Then you should click onto "Other options..." and then activate "Display resolutions in list". After this action the screen resolutions are displayed and the current default resolution has the suffix "Default". I presume that your screen resolution 3440x1440 is possible and you may activate it but the resolution might be too high, so that you have difficulties to read the text because it has become very small.

I fell into the same trap with my iMac 2019 5K screen:
viewtopic.php?p=628033#p628033
viewtopic.php?p=628068#p628068

Re: DesktopWidth(0) returns wrong value

Posted: Wed Jan 15, 2025 2:06 pm
by Fred
I wonder why you use "visibleFrame" for the screen 0 ? In our code, we only use frame as it should be the correct value to use. Could you also try with the 6.20 beta 2 ?

Re: DesktopWidth(0) returns wrong value

Posted: Thu Jan 16, 2025 12:52 am
by robertfern
From what I understand, visibleFrame is the screen size with the menubar height and doc height removed.
I think!