Re: Points vs pixels in a bash script

2020-06-10 Thread Gabriel Zachmann via Cocoa-dev

> 
> python -c 'import AppKit ; print 
> AppKit.NSScreen.screens()[0].frame().size.width'
> 


Thanks a million! that even works for multi-monitor setups correctly.


>> tells me the resolution of the screen in the same units (of course) as
> 
> This will not work if you have multiple monitors attached.
> 

Thanks a lot for the hint - you are right, of course.

Best, G.



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-10 Thread Saagar Jha via Cocoa-dev

Saagar Jha

> On Jun 10, 2020, at 13:52, Ken Thomases via Cocoa-dev 
>  wrote:
> 
> On Jun 9, 2020, at 8:11 AM, Gabriel Zachmann  wrote:
>> 
>>> In particular, you're not taking into account the current screen resolution 
>>> (a.k.a. display mode).  The user can select different scaling for a Retina 
>>> display in System Preferences > Displays.
>> 
>> Good point.
>> I wasn't taking that into consideration.
>> 
>> So, what would be a robust way to determine whether or not a window (as 
>> reported by "System Events") has a fullscreen size?
>> 
>> Or is there another way to determine whether or not an app is in fullscreen?
>> 
>>> First, you're going to have to explain exactly what you're planning to do 
>>> with the results of your calculation.  Do you really want the physical 
>>> screen size?  Or do you want the size of the 
>> 
>> I only want to have a little shell script 
>> (or other little utility ) that runs inconspicuously in the background (or 
>> in the top right menu bar) and launches a specific app once the user has 
>> been inactive for a while,
>> UNLESS there is another app running at the moment in fullscreen.
>> 
>> Does anyone have some code they could share?
> 
> You could do, for example:
> 
> python -c 'import AppKit ; print 
> AppKit.NSScreen.screens()[0].frame().size.width'

Note that this will make the Python rocket ship pop into your Dock for a split 
second, so I’m not sure I could call this “inconspicuous” :P

(Also, if you, like me, have another Python installed on your system, make sure 
you’re not using that when trying the code above as it’s unlikely to work.)

> 
> Similarly for height.
> 
> Regards,
> Ken
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com
> 
> This email sent to saa...@saagarjha.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-10 Thread Ken Thomases via Cocoa-dev
On Jun 9, 2020, at 8:11 AM, Gabriel Zachmann  wrote:
> 
>> In particular, you're not taking into account the current screen resolution 
>> (a.k.a. display mode).  The user can select different scaling for a Retina 
>> display in System Preferences > Displays.
> 
> Good point.
> I wasn't taking that into consideration.
> 
> So, what would be a robust way to determine whether or not a window (as 
> reported by "System Events") has a fullscreen size?
> 
> Or is there another way to determine whether or not an app is in fullscreen?
> 
>> First, you're going to have to explain exactly what you're planning to do 
>> with the results of your calculation.  Do you really want the physical 
>> screen size?  Or do you want the size of the 
> 
> I only want to have a little shell script 
> (or other little utility ) that runs inconspicuously in the background (or in 
> the top right menu bar) and launches a specific app once the user has been 
> inactive for a while,
> UNLESS there is another app running at the moment in fullscreen.
> 
> Does anyone have some code they could share?

You could do, for example:

python -c 'import AppKit ; print 
AppKit.NSScreen.screens()[0].frame().size.width'

Similarly for height.

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-10 Thread Clark Cox via Cocoa-dev



> On Jun 10, 2020, at 12:06 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> For the record: I believe I have found a solution:
> 
>  tell application "Finder" to get bounds of window of desktop
> 
> tells me the resolution of the screen in the same units (of course) as

This will not work if you have multiple monitors attached.

For example, on my machine, at the moment, it returns:

"{-1792, -366, 6720, 1890}"


> 
>  tell application "System Events" to get the title of every window of every 
> process
> 
> lateron.
> 
> Thanks again to everyone who chimed in.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-10 Thread Gabriel Zachmann via Cocoa-dev
For the record: I believe I have found a solution:

  tell application "Finder" to get bounds of window of desktop

tells me the resolution of the screen in the same units (of course) as

  tell application "System Events" to get the title of every window of every 
process

lateron.

Thanks again to everyone who chimed in.




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-09 Thread Alex Zavatone via Cocoa-dev
Don’t you need to find out what the pixels per inch of the display is first?  
At 72 dpi or ppi, a pixel = a point.  

Can you get that info first?  

> On Jun 8, 2020, at 4:43 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I know this mailing list might not be the perfect fit for my question,
> but maybe someone has an idea.
> 
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
> 
> Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process
> 
> (which I execute from my bash script using osascript) apparently does NOT 
> return window sizes in pixels. I guess it's the strange "Apple points" units. 
> According to my experiments, on my MacBook Pro Retina, for instance, a 
> fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
> By contrast, system_profiler reports 2880 x 1800.
> 
> So, the question is: how can I determine the screen size of a Mac from my 
> bash script in the same units like "System Events" uses? 
> Or, how can I determine the factor by which I have to convert pixels into 
> those other units?
> 
> 
> Many thanks in advance for any insights or hints.
> 
> Best regards, Gabriel
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-09 Thread Gabriel Zachmann via Cocoa-dev
> you're not taking into account the current screen resolution (a.k.a. display 
> mode).  The user
>  [...]
> necessarily have to build a C utility for it.  You can invoke the Swift 
> interpreter to execute 

Thanks a lot for your hints, but unfortunately , I don't have the time to learn 
Swift or PyObjC.
(This is not my day job.)

And lacking any other quick fix for the moment,
I would even be happy with a non-perfect solution.

When my Macbook is only connected to the external monitor (lid closed),
everything is fine:
system_profiler reports a screen resolution of 2560 x 1440,
and "System Events" reports a full-screen window with exactly the same 
resolution.
Incidentally, the macbook uses the Radeon for rendering (as reported by 
system_profiler).

Now, when the Macbook uses only the built-in LCD display (no other monitor),
then it does not work, because
system_profiler reports a screen resolution of "2880 x 1800 Retina",
and "System Events" reports a full-screen window with 1680 x 1050.

I could hard-code the values for windows in full-screen mode, 
but a slightly more generic solution would be nice.

Best, G.





smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-09 Thread Gabriel Zachmann via Cocoa-dev
> In particular, you're not taking into account the current screen resolution 
> (a.k.a. display mode).  The user can select different scaling for a Retina 
> display in System Preferences > Displays.

Good point.
I wasn't taking that into consideration.

So, what would be a robust way to determine whether or not a window (as 
reported by "System Events") has a fullscreen size?

Or is there another way to determine whether or not an app is in fullscreen?

> First, you're going to have to explain exactly what you're planning to do 
> with the results of your calculation.  Do you really want the physical screen 
> size?  Or do you want the size of the 

I only want to have a little shell script 
(or other little utility ) that runs inconspicuously in the background (or in 
the top right menu bar) and launches a specific app once the user has been 
inactive for a while,
UNLESS there is another app running at the moment in fullscreen.

Does anyone have some code they could share?


Best regards, Gabriel




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-09 Thread Gabriel Zachmann via Cocoa-dev
> 
> I don’t have an answer to your question, but to add some clarity Points are 
> scale factor independent unit of measurement.  On a retina display there are 
> 2 pixels per point.  On a non-retina display there is 1 pixel per point.  Say 
> Apple comes out with a display with a scale 

Thanks a lot for the clarification.

Yes, that is what the doc's tell.
That is also the reason why I am suspicious whether the measures I see in the 
output of "System Events" are given in those Apple points.
Because the factor I calculate is neither 1 nor 2.

But that is just aside, since I don't really care about the factor.
All that matters is that what "System Events" reports is in different units 
than what system_profiler reports.


Best, G.





smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Ken Thomases via Cocoa-dev
Except that Apple specifically says they're not.  From High Resolution 
Guidelines for OS X 
>:

> Note: The term points has its origin in the print industry, which defines 72 
> points as to equal 1 inch in physical space. When used in reference to high 
> resolution in OS X, points in user space do not have any relation to 
> measurements in the physical world.

In any case, it would be impossible for points to correspond to 1/72 of an 
inch, because a given physical screen size can correspond to a different number 
of points, depending on the display mode.

Regards,
Ken

> On Jun 8, 2020, at 6:01 PM, Jeff Younker via Cocoa-dev 
>  wrote:
> 
> Just as an aside, points are not Apple-specifc. They are a typesetting unit
> equivalent to 1/72 of an inch. It's the same unit used for font sizes.
> 
> -jeff
> 
> 
> On Mon, Jun 8, 2020 at 2:43 PM Gabriel Zachmann via Cocoa-dev <
> cocoa-dev@lists.apple.com> wrote:
> 
>> I know this mailing list might not be the perfect fit for my question,
>> but maybe someone has an idea.
>> 
>> I have a problem converting points (I think) to pixels in a bash script.
>> I'd rather not write an extra C/Cocoa utility for that.
>> 
>> Using
>>   system_profiler SPDisplaysDataType
>> I can retrieve the size of a Mac's display in pixels.
>> 
>> However, the command
>> 
>>   tell application "System Events" to get the size of every window of
>> every process
>> 
>> (which I execute from my bash script using osascript) apparently does NOT
>> return window sizes in pixels. I guess it's the strange "Apple points"
>> units. According to my experiments, on my MacBook Pro Retina, for instance,
>> a fullscreen app (e.g., Keynote presentation) has a window size of 1680 x
>> 1050.
>> By contrast, system_profiler reports 2880 x 1800.
>> 
>> So, the question is: how can I determine the screen size of a Mac from my
>> bash script in the same units like "System Events" uses?
>> Or, how can I determine the factor by which I have to convert pixels into
>> those other units?
>> 
>> 
>> Many thanks in advance for any insights or hints.
>> 
>> Best regards, Gabriel
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/jeff%40drinktomi.com
>> 
>> This email sent to j...@drinktomi.com
>> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/ken%40codeweavers.com
> 
> This email sent to k...@codeweavers.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Jeff Younker via Cocoa-dev
Just as an aside, points are not Apple-specifc. They are a typesetting unit
equivalent to 1/72 of an inch. It's the same unit used for font sizes.

-jeff


On Mon, Jun 8, 2020 at 2:43 PM Gabriel Zachmann via Cocoa-dev <
cocoa-dev@lists.apple.com> wrote:

> I know this mailing list might not be the perfect fit for my question,
> but maybe someone has an idea.
>
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
>
> Using
>system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels.
>
> However, the command
>
>tell application "System Events" to get the size of every window of
> every process
>
> (which I execute from my bash script using osascript) apparently does NOT
> return window sizes in pixels. I guess it's the strange "Apple points"
> units. According to my experiments, on my MacBook Pro Retina, for instance,
> a fullscreen app (e.g., Keynote presentation) has a window size of 1680 x
> 1050.
> By contrast, system_profiler reports 2880 x 1800.
>
> So, the question is: how can I determine the screen size of a Mac from my
> bash script in the same units like "System Events" uses?
> Or, how can I determine the factor by which I have to convert pixels into
> those other units?
>
>
> Many thanks in advance for any insights or hints.
>
> Best regards, Gabriel
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/jeff%40drinktomi.com
>
> This email sent to j...@drinktomi.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Carl Hoefs via Cocoa-dev
Note that your AppleScript returns the size of ALL monitors combined. 
With four 1920x1080 monitors in a 2x2 arrangement it shows:

0, 0, 3840, 2160

-Carl



> On Jun 8, 2020, at 3:44 PM, Marco S Hyman via Cocoa-dev 
>  wrote:
> 
> Using
>>  system_profiler SPDisplaysDataType
>> I can retrieve the size of a Mac's display in pixels. 
>> 
>> However, the command
>> 
>>  tell application "System Events" to get the size of every window of every 
>> process
> 
> 
> tell application “Finder”
> set screen_resolution to bounds of window of desktop
> end tell
> 
> screen_resolution on my 5K iMac is 0, 0, 2560, 1440
> 
> Marc
> ___

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Steve Christensen via Cocoa-dev
I don’t have an answer for your question, and I know that this doesn’t actually 
answer it below, but it may still provide some info to help you move forward.

The windowing system is always working in points from a coordinates point of 
view. So window.frame and view.frame are in points, not pixels. This allows 
drawing to be abstracted across screens that have different point scales 
(pixel-to-point size ratio). You specify everything in points and what that 
means when it’s time for the actual drawing to occur on a particular screen is 
handled for you.

I would suggest that you check out the NSScreen class, which provides 
properties such as the frame (in points) and backingScaleFactor (pixel-to-point 
ratio), as well as methods to convert between point- and pixel-based NSRects. 
Since it’s possible to, for example, have a 2x Retina display as the main 
screen and plug in an older 1x display, then move the window so it straddles 
the two screens, then there will not be a single scale value when calculating 
the number of pixels per point.

You can do things like iterate over all attached screens and find the largest 
backingScaleFactor, then use that to calculate the pixel size for an image, for 
example.


> On Jun 8, 2020, at 2:43 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I know this mailing list might not be the perfect fit for my question,
> but maybe someone has an idea.
> 
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
> 
> Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process
> 
> (which I execute from my bash script using osascript) apparently does NOT 
> return window sizes in pixels. I guess it's the strange "Apple points" units. 
> According to my experiments, on my MacBook Pro Retina, for instance, a 
> fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
> By contrast, system_profiler reports 2880 x 1800.
> 
> So, the question is: how can I determine the screen size of a Mac from my 
> bash script in the same units like "System Events" uses? 
> Or, how can I determine the factor by which I have to convert pixels into 
> those other units?
> 
> 
> Many thanks in advance for any insights or hints.
> 
> Best regards, Gabriel

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Marco S Hyman via Cocoa-dev
Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process


tell application “Finder”
set screen_resolution to bounds of window of desktop
end tell

screen_resolution on my 5K iMac is 0, 0, 2560, 1440

Marc
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Ken Thomases via Cocoa-dev
On Jun 8, 2020, at 4:43 PM, Gabriel Zachmann via Cocoa-dev 
 wrote:
> 
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
> 
> Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process
> 
> (which I execute from my bash script using osascript) apparently does NOT 
> return window sizes in pixels. I guess it's the strange "Apple points" units. 
> According to my experiments, on my MacBook Pro Retina, for instance, a 
> fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
> By contrast, system_profiler reports 2880 x 1800.
> 
> So, the question is: how can I determine the screen size of a Mac from my 
> bash script in the same units like "System Events" uses? 
> Or, how can I determine the factor by which I have to convert pixels into 
> those other units?

I'm not sure what you're trying to do necessarily makes sense.  In particular, 
you're not taking into account the current screen resolution (a.k.a. display 
mode).  The user can select different scaling for a Retina display in System 
Preferences > Displays.  So, a screen with that's physically 5120x2880 pixels 
is, by default, in a mode that's 2560x1440 points and 5120x2880 pixels in the 
backing buffer.  However, it may also be in a mode that's just 1600x900 points 
with a 3200x1800-pixel backing buffer.  Or a mode that's 3200x1800 points with 
a 6400x3600-pixel backing buffer (which is ultimately scaled down to the 
5120x2880 physical pixels of the display).

So, basically what I'm saying is that there's no fixed relationship between 
points (for window sizes, etc.) and the number of physical pixels of a 
display's size, even if you know the screen is a Retina display.

First, you're going to have to explain exactly what you're planning to do with 
the results of your calculation.  Do you really want the physical screen size?  
Or do you want the size of the current display mode?

Then, you probably are going to have to use APIs to get the info you need.  
However, you don't necessarily have to build a C utility for it.  You can 
invoke the Swift interpreter to execute code from your script.  Or, you could 
use Python and the PyObjC bridge.

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Points vs pixels in a bash script

2020-06-08 Thread Rob Petrovec via Cocoa-dev
I don’t have an answer to your question, but to add some clarity Points are 
scale factor independent unit of measurement.  On a retina display there are 2 
pixels per point.  On a non-retina display there is 1 pixel per point.  Say 
Apple comes out with a display with a scale factor of 17.  That would mean that 
there are 17 pixels per point.  Hope that helps.

—Rob



> On Jun 8, 2020, at 3:43 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I know this mailing list might not be the perfect fit for my question,
> but maybe someone has an idea.
> 
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
> 
> Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process
> 
> (which I execute from my bash script using osascript) apparently does NOT 
> return window sizes in pixels. I guess it's the strange "Apple points" units. 
> According to my experiments, on my MacBook Pro Retina, for instance, a 
> fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
> By contrast, system_profiler reports 2880 x 1800.
> 
> So, the question is: how can I determine the screen size of a Mac from my 
> bash script in the same units like "System Events" uses? 
> Or, how can I determine the factor by which I have to convert pixels into 
> those other units?
> 
> 
> Many thanks in advance for any insights or hints.
> 
> Best regards, Gabriel
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/petrock%40mac.com
> 
> This email sent to petr...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Points vs pixels in a bash script

2020-06-08 Thread Gabriel Zachmann via Cocoa-dev
I know this mailing list might not be the perfect fit for my question,
but maybe someone has an idea.

I have a problem converting points (I think) to pixels in a bash script.
I'd rather not write an extra C/Cocoa utility for that.

Using
   system_profiler SPDisplaysDataType
I can retrieve the size of a Mac's display in pixels. 

However, the command

   tell application "System Events" to get the size of every window of every 
process

(which I execute from my bash script using osascript) apparently does NOT 
return window sizes in pixels. I guess it's the strange "Apple points" units. 
According to my experiments, on my MacBook Pro Retina, for instance, a 
fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
By contrast, system_profiler reports 2880 x 1800.

So, the question is: how can I determine the screen size of a Mac from my bash 
script in the same units like "System Events" uses? 
Or, how can I determine the factor by which I have to convert pixels into those 
other units?


Many thanks in advance for any insights or hints.

Best regards, Gabriel



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com