Browse Source

Init window in the center of the screen.

Dario Manesku 10 years ago
parent
commit
b46aadcaf7
1 changed files with 5 additions and 2 deletions
  1. 5 2
      examples/common/entry/entry_osx.mm

+ 5 - 2
examples/common/entry/entry_osx.mm

@@ -413,8 +413,12 @@ namespace entry
 					| NSResizableWindowMask
 					| NSResizableWindowMask
 					;
 					;
 
 
+			NSRect screenRect = [[NSScreen mainScreen] frame];
+			const float centerX = (screenRect.size.width  - (float)ENTRY_DEFAULT_WIDTH )*0.5f;
+			const float centerY = (screenRect.size.height - (float)ENTRY_DEFAULT_HEIGHT)*0.5f;
+
 			m_windowAlloc.alloc();
 			m_windowAlloc.alloc();
-			NSRect rect = NSMakeRect(0, 0, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
+			NSRect rect = NSMakeRect(centerX, centerY, (float)ENTRY_DEFAULT_WIDTH, (float)ENTRY_DEFAULT_HEIGHT);
 			NSWindow* window = [[NSWindow alloc]
 			NSWindow* window = [[NSWindow alloc]
 				initWithContentRect:rect
 				initWithContentRect:rect
 				styleMask:m_style
 				styleMask:m_style
@@ -422,7 +426,6 @@ namespace entry
 			];
 			];
 			NSString* appName = [[NSProcessInfo processInfo] processName];
 			NSString* appName = [[NSProcessInfo processInfo] processName];
 			[window setTitle:appName];
 			[window setTitle:appName];
-			[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
 			[window makeKeyAndOrderFront:window];
 			[window makeKeyAndOrderFront:window];
 			[window setAcceptsMouseMovedEvents:YES];
 			[window setAcceptsMouseMovedEvents:YES];
 			[window setBackgroundColor:[NSColor blackColor]];
 			[window setBackgroundColor:[NSColor blackColor]];