For who’s interested here following is how I managed to solve the problem.
I modified three functions: UIViewComponentPeer:getBounds(), UIViewComponentPeer::setBounds() and UIViewComponentPeer::displayRotated().
[code]Rectangle UIViewComponentPeer::getBounds (const bool global) const
{
CGRect r = view.frame;
if (global && view.window != nil)
{
r = [view convertRect: r toView: view.window];
r = [view.window convertRect: r toWindow: nil];
const Rectangle<int> windowBounds (realScreenPosToRotated (convertToRectInt (r)));
return windowBounds;
}
return convertToRectInt (r);
}
[/code]
[code]void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen)
{
fullScreen = isNowFullScreen;
w = jmax (0, w);
h = jmax (0, h);
if (isSharedWindow)
{
CGRect r = CGRectMake ((CGFloat) x, (CGFloat) y, (CGFloat) w, (CGFloat) h);
if (view.frame.size.width != r.size.width
|| view.frame.size.height != r.size.height)
[view setNeedsDisplay];
view.frame = r;
}
else
{
const Rectangle<int> bounds (rotatedScreenPosToReal (Rectangle<int> (x, y, w, h)));
window.frame = convertToCGRect (bounds);
view.frame = CGRectMake (0, 0, (CGFloat) w, (CGFloat) h);
handleMovedOrResized();
}
}
[/code]
void UIViewComponentPeer::displayRotated()
{
Desktop& desktop = Desktop::getInstance();
const Rectangle<int> oldArea (component->getBounds());
const Rectangle<int> oldDesktop (desktop.getDisplays().getMainDisplay().userArea);
const_cast <Desktop::Displays&> (desktop.getDisplays()).refresh();
if (fullScreen)
{
fullScreen = false;
setFullScreen (true);
}
else if (! isSharedWindow)
{
Desktop::DisplayOrientation orientation = Desktop::getInstance().getCurrentOrientation();
switch (orientation)
{
case Desktop::upright:
window.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
break;
case Desktop::upsideDown:
window.transform = CGAffineTransformMake(-1, 0, 0, -1, 0, 0);
break;
case Desktop::rotatedClockwise:
window.transform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
break;
case Desktop::rotatedAntiClockwise:
window.transform = CGAffineTransformMake(0, 1, -1, 0, 0, 0);
break;
default:;
}
view.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
// this will place the Peer window center at same relative position of the old desktop, but will keep size unchanged
const float cx = (oldArea.getX() + (oldArea.getWidth() / 2)) / (float) oldDesktop.getWidth();
const float cy = (oldArea.getY() + (oldArea.getHeight() / 2)) / (float) oldDesktop.getHeight();
const Rectangle<int> newDesktop (desktop.getDisplays().getMainDisplay().userArea);
int x = newDesktop.getWidth() * cx - (oldArea.getWidth()/ 2);
int y = newDesktop.getHeight() * cy - (oldArea.getHeight() / 2);
setBounds (x, y, oldArea.getWidth(), oldArea.getHeight(), false);
// const float l = oldArea.getX() / (float) oldDesktop.getWidth();
// const float r = oldArea.getRight() / (float) oldDesktop.getWidth();
// const float t = oldArea.getY() / (float) oldDesktop.getHeight();
// const float b = oldArea.getBottom() / (float) oldDesktop.getHeight();
//
// const Rectangle<int> newDesktop (desktop.getDisplays().getMainDisplay().userArea);
//
// setBounds ((int) (l * newDesktop.getWidth()),
// (int) (t * newDesktop.getHeight()),
// (int) ((r - l) * newDesktop.getWidth()),
// (int) ((b - t) * newDesktop.getHeight()),
// false);
}
}
Alf