Determine dimensions of full-screen macOS application windows below the camera housing notch - swift

I need to determine the dimensions of a full-screen application window on a display with a camera housing notch. I'm using a Mac Book Pro (14-inch, 2021) but I'm looking for a general technique. Crucially, I need to do this from outside the full-screen application itself before it is launched, so I can predict the window position in advance in an application testing/screen-capture scenario.
The full screen size including the notch region is reported from NSScreen frame as 1512x982. The safeAreaInsets are reported as top = 32.0 with the other three edges being zero. Subtracting the top inset gives a size of 1512x950, yet full-screen applications (I'm using Chromium) report a maximised window size of 1512x945, which is what we might expect as it has a 16:10 aspect ratio. For example, SwitchResX allows setting the resolution to 1512x945 HiDPI 16:10 to ignore the notch area.
The regions returned by auxiliaryTopLeftArea and auxiliaryTopRightArea also have a height of 32.
Confusingly, visibleFrame reports 1512x944 (not 945) and I'm not sure where the one pixel discrepancy is coming from.
What API calls can I make to determine the dimensions of the full-screen application area?

Related

How to make responsible camera for multiplie resolutions?

I m working and some 2d game for mobile phones relate to chess, and I have a trouble with show board for different resolutions of mobile screens.
Here u can see how it must be on 9:16 resolution:
https://drive.google.com/open?id=1MFt-FtEtqkk7QWQC2oAtMBA0WAgOIV4h
And how it looks on smaller screen:
https://drive.google.com/open?id=11WLYZwHEa9ijXbekzUbE5ZbjbEnjZ6Lb
How can I protect my chess board from cropping?
Answer: it depends on how you want it to look.
If you just want it to fit perfectly horizontally, you need to perform 3 steps:
Evaluate the width of the Sprite (with Sprite.bounds)
Evaluate the width of the current screen (with Screen.width and using the main Camera)
Scale the Sprite to fit the screen
If you are using UI elements, you can do the same thing but you won't need to use Camera, just scaling according to the Screen width (look for RectTransform.deltaSize to give you the size of a UI element).
If you are using UI, also consider using layout groups, they help you with fitting the content to screen size.
Anyway, in a device with small width, maybe the table will get too small and you might have to think about better options to display the board instead of just scaling with screen width.

Unity game scene is not in full screen on mobile

I'am having problem making my app be full screen on all device. on my device, w/c is a low end Jelly bean phone doesn't give me the right resolution I want.
Here is my desired output:
this is still in editor, resolution 1080px by 1920px in Portrait mode
here is the output on my device:
as you can see, you can see a blue part on the screen.
Thanks in advance.
It looks like your background is visible from behind your geometry, the aspect ratio of two screenshot is different. It looks like you designed the game in a 278x490 resolution (aspect 1:1.762) and displaying it in a 480x800 resolution (aspect ratio 1:1.666).
You should always design for the lowest possible aspect ratio, then you don't have this problem.
You have two solutions:
You should add some walls/roofs to make margins that will be visible on wider devices
You can shorten the length of the corridor by scaling the game field up so the width fits.

Unity GUITexture doesnt display correctly

so i am making a game for android but the display window no matter what ratio i choose from the list the GUI textures never show same size as my phone or tablet so making things very hard to work out correct sizes and positions etc
is there anything i may be doing wrong or is this normal for GUI texturesin the display window?
i'm running a xperia 2 and a xperia z2 tablet in-case it is needed
My limited research shows that the Xperia Z2 is 1920x1080. So, in order to actually see the game view in the editor, you have to have a monitor that is bigger than 1920x1080 to display both the 1920x1080 game view plus the border.
If you happen to have a monitor with a resolution higher than 1920x1080, which is not common, then you can add your own 1920x1080 (Fixed Resolution) setting to the Editor and actually be able to increase the size of the window until the game view reaches 1920x1080.

Calculate the distance between the iPhone and a door, knowing their physical widths

I have this scenario:
I know the physical (not only in pixel) size of the screen of the iPhone.
Also I know the width of a door.
Now, if I have the iPhone camera on (with UIImagePicker or whatever), and I am in the position where the width of the door fits perfectly in the width of the camera, and the iPhone stands perfectly vertical, is it possible to know the distance between the iPhone and the door?
It would depend on the camera specs which vary between devices. For this reason I would try to sample some data with a ruler - for instance take a 3' wide plank, align the edges perfectly and measure distance. Do this with varying widths on different devices and you'll have a formula per device (basic algebra)

Strategy to create a screen resolution independent java desktop application?

I have been been programming with java using eclipse for a few months and would consider myself at an intermediate level, and i have a vb.net background originally.
I have a question about screen resolution( in pixels) and auto-scaling my application with two parts
A) When you design a desktop application with swing( or JavaFX ) do you actually calculate the pixel width and height of every single component and then scale it up or down in code by detecting the screen resolution at startup? Scene-Builder for JavaFX, Eclipse Windows Builder Gridbag layout and GroupLayout have the facility to do it with a couple of clicks, and it is relatively easy . If it IS calculated and handcoded then that means I'll have to spend a lot of time planning ahead for each control.
B) Is there a common consensus over a screen resolution ( 1024x768 e.g.) to design the application for "initially" ( and then scaling all controls according to detected screen resolution)? My monitor has 1920x1080 resolution but I am confused which resolution should i begin designing my application in. 1024x768 seems reasonable to me.
Thank you very much for your time
I've done all my work in Java Swing, so this might not be appropriate for other GUI sets.
Layout all the components within panels and one frame.
Pack the frame.
Print out the size of the frame.
If the frame is too big, put some components in a scroll pane.
Repeat until the frame is the desired size.
In other words, I'm concerned with the functionality of the GUI. I don't care how big it is, unless it's too big for a display.
I put together an alarm clock that has a frame of 170 x 152 pixels. It sits in the lower right hand corner of my display.
I put together a clock / calendar that has a frame of 1097 X 522 pixels. It sits in the upper right hand corner of my display.
I put together a Cobol Paragraph Structure display where I maximized the frame to the size of the display, mainly so the paragraph name tree had the maximum amount of space.