The Battle for Wesnoth  1.15.5+dev
apple_video.mm
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 by Martin HrubĂ˝ <hrubymar10@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13  */
14 
15 #ifdef __APPLE__
16 #include <TargetConditionals.h>
17 #ifdef TARGET_OS_OSX
18 
19 #include "apple_video.hpp"
20 
21 #import <AppKit/AppKit.h>
22 #import <Foundation/Foundation.h>
23 
24 namespace desktop {
25 namespace apple {
26  CGFloat get_scale_factor(int display_index) {
27  CGFloat scale_factor = 1.0f;
28 
29  NSArray *screens = [NSScreen screens];
30 
31  if ([screens[display_index] respondsToSelector:@selector(backingScaleFactor)]) { // Mac OS X 10.7 and later
32  scale_factor = [screens[display_index] backingScaleFactor];
33  }
34 
35  return scale_factor;
36  }
37 } // end namespace apple
38 } // end namespace desktop
39 
40 #endif //end TARGET_OS_OSX
41 #endif //end __APPLE__
CGFloat get_scale_factor(int display_index)