+ CGRect bounds = [[UIScreen mainScreen] bounds];
+ if ( bounds.size.height > r.size.height )
+ {
+ // portrait
+ if ( x )
+ *x = r.origin.x;
+ if ( y )
+ *y = r.origin.y;
+ if ( width )
+ *width = r.size.width;
+ if ( height )
+ *height = r.size.height;
+ }
+ else
+ {
+ // landscape
+ if ( x )
+ *x = r.origin.y;
+ if ( y )
+ *y = r.origin.x;
+ if ( width )
+ *width = r.size.height;
+ if ( height )
+ *height = r.size.width;
+ }
+#else
+ // it's easier to treat the status bar as an element of the toplevel window
+ // instead of the desktop in order to support easy rotation