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