DesktopWidth(0) returns wrong value

Post bugreports for the Mac OSX version here
User avatar
robertfern
User
User
Posts: 38
Joined: Fri Feb 02, 2018 10:33 pm
Location: New Jersey

DesktopWidth(0) returns wrong value

Post 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
Mac OSX Ventura & Windows 10, PB 6.12
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: DesktopWidth(0) returns wrong value

Post 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
Fred
Administrator
Administrator
Posts: 18161
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: DesktopWidth(0) returns wrong value

Post 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 ?
User avatar
robertfern
User
User
Posts: 38
Joined: Fri Feb 02, 2018 10:33 pm
Location: New Jersey

Re: DesktopWidth(0) returns wrong value

Post by robertfern »

From what I understand, visibleFrame is the screen size with the menubar height and doc height removed.
I think!
Mac OSX Ventura & Windows 10, PB 6.12
Post Reply