summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa/ecore_cocoa_window.m
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@gmail.com>2014-07-23 16:56:16 +0200
committerRaoul Hecky <raoul.hecky@gmail.com>2014-07-23 16:56:16 +0200
commitf8235ff5c155ff97488850e19c60e65b6712c3f2 (patch)
tree772354f12a321089da7356f425fef5746178916d /src/lib/ecore_cocoa/ecore_cocoa_window.m
parent572b7aa92f44a954751be5fdfb896a1db5a7898b (diff)
ecore_cocoa: Lion fullscreen workaround + warning fixes
Summary: Warnings and deprecated code fixes. I started to implement the OSX-Lion fullscreen style. Reviewers: cedric, naguirre, raster, raoulh Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1175
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m84
1 files changed, 41 insertions, 43 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index 297a425e23..ab4a78ce13 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -15,9 +15,9 @@
15 backing: (NSBackingStoreType) bufferingType 15 backing: (NSBackingStoreType) bufferingType
16 defer: (BOOL) flag 16 defer: (BOOL) flag
17{ 17{
18 if (![super initWithContentRect: contentRect 18 if (![super initWithContentRect: contentRect
19 styleMask: aStyle 19 styleMask: aStyle
20 backing: bufferingType 20 backing: bufferingType
21 defer: flag]) return nil; 21 defer: flag]) return nil;
22 22
23 [self setBackgroundColor: [NSColor whiteColor]]; 23 [self setBackgroundColor: [NSColor whiteColor]];
@@ -25,9 +25,16 @@
25 [self setDelegate:self]; 25 [self setDelegate:self];
26 [self setAcceptsMouseMovedEvents:YES]; 26 [self setAcceptsMouseMovedEvents:YES];
27 27
28 [self setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
29
28 return self; 30 return self;
29} 31}
30 32
33- (BOOL)isFullScreen
34{
35 return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
36}
37
31- (BOOL)acceptsFirstResponder 38- (BOOL)acceptsFirstResponder
32{ 39{
33 return YES; 40 return YES;
@@ -38,12 +45,12 @@
38 return YES; 45 return YES;
39} 46}
40 47
41- (void)windowWillClose:(NSNotification *)notification 48- (void)windowWillClose:(NSNotification *) EINA_UNUSED notification
42{ 49{
43 NSLog(@"window is going to be closed"); 50 NSLog(@"window is going to be closed");
44} 51}
45 52
46- (void)windowDidResize:(NSNotification *)notif 53- (void)windowDidResize:(NSNotification *) EINA_UNUSED notif
47{ 54{
48 Ecore_Cocoa_Event_Video_Resize *event; 55 Ecore_Cocoa_Event_Video_Resize *event;
49 NSSize size = self.frame.size; 56 NSSize size = self.frame.size;
@@ -56,7 +63,9 @@
56 return; 63 return;
57 } 64 }
58 event->w = size.width; 65 event->w = size.width;
59 event->h = size.height - ecore_cocoa_titlebar_height_get(); 66 event->h = size.height -
67 (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
68 printf("Is fullscreen: %i\n", [self isFullScreen]);
60 ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL); 69 ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL);
61} 70}
62 71
@@ -66,17 +75,6 @@
66#include "Ecore_Cocoa.h" 75#include "Ecore_Cocoa.h"
67#include "ecore_cocoa_private.h" 76#include "ecore_cocoa_private.h"
68 77
69static float _title_bar_height(void)
70{
71 NSRect frame = NSMakeRect (0, 0, 100, 100);
72 NSRect contentRect;
73
74 contentRect = [NSWindow contentRectForFrameRect: frame
75 styleMask: NSTitledWindowMask];
76
77 return (frame.size.height - contentRect.size.height);
78}
79
80Ecore_Cocoa_Window * 78Ecore_Cocoa_Window *
81ecore_cocoa_window_new(int x, 79ecore_cocoa_window_new(int x,
82 int y, 80 int y,
@@ -85,27 +83,29 @@ ecore_cocoa_window_new(int x,
85{ 83{
86 Ecore_Cocoa_Window *w; 84 Ecore_Cocoa_Window *w;
87 85
88 EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] 86 EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height)
89 initWithContentRect:NSMakeRect(x, y, width, height) 87 styleMask:(NSTitledWindowMask |
90 styleMask:(NSTitledWindowMask | 88 NSClosableWindowMask |
91 NSClosableWindowMask | 89 NSResizableWindowMask |
92 NSResizableWindowMask | 90 NSMiniaturizableWindowMask)
93 NSMiniaturizableWindowMask) 91 backing:NSBackingStoreBuffered
94 backing:NSBackingStoreBuffered 92 defer:NO];
95 defer:NO];
96 93
97 if (!window) 94 if (!window)
98 return NULL; 95 return NULL;
99 96
100 //Set the process to be a foreground process, 97 //Set the process to be a foreground process,
101 //without that it prevents the window to become the key window and 98 //without that it prevents the window to become the key window and
102 //receive all mouse mouve events. 99 //receive all mouse mouve events.
103 ProcessSerialNumber psn; 100 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
104 GetCurrentProcess(&psn); 101 [NSApp activateIgnoringOtherApps:YES];
105 TransformProcessType(&psn, kProcessTransformToForegroundApplication); 102
106 SetFrontProcess(&psn);
107 103
108 w = calloc(1, sizeof(Ecore_Cocoa_Window)); 104 w = calloc(1, sizeof(Ecore_Cocoa_Window));
105 if (w == NULL)
106 {
107 return NULL;
108 }
109 w->window = window; 109 w->window = window;
110 w->borderless = 0; 110 w->borderless = 0;
111 111
@@ -150,9 +150,9 @@ ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
150 150
151 NSRect win_frame; 151 NSRect win_frame;
152 152
153
154 win_frame = [window->window frame]; 153 win_frame = [window->window frame];
155 win_frame.size.height = height + _title_bar_height(); 154 win_frame.size.height = height +
155 (([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
156 win_frame.size.width = width; 156 win_frame.size.width = width;
157 157
158 [window->window setFrame:win_frame display:YES]; 158 [window->window setFrame:win_frame display:YES];
@@ -165,16 +165,13 @@ ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
165 int width, 165 int width,
166 int height) 166 int height)
167{ 167{
168 if (!window) 168 if (!window) return;
169 return;
170 169
171 NSRect win_frame; 170 NSRect win_frame;
172 171
173 if (!window)
174 return;
175
176 win_frame = [window->window frame]; 172 win_frame = [window->window frame];
177 win_frame.size.height = height + _title_bar_height(); 173 win_frame.size.height = height +
174 (([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
178 win_frame.size.width = width; 175 win_frame.size.width = width;
179 win_frame.origin.x = x; 176 win_frame.origin.x = x;
180 win_frame.origin.y = y; 177 win_frame.origin.y = y;
@@ -232,15 +229,16 @@ ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
232 return; 229 return;
233 230
234 //[[window->window contentView] addSubview:view]; 231 //[[window->window contentView] addSubview:view];
232 NSView *v = view;
235 [window->window setContentView:view]; 233 [window->window setContentView:view];
236 234
237 NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[view frame] 235 NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[v frame]
238 options:NSTrackingMouseMoved | 236 options:NSTrackingMouseMoved |
239 NSTrackingActiveInActiveApp | 237 NSTrackingActiveInActiveApp |
240 NSTrackingInVisibleRect 238 NSTrackingInVisibleRect
241 owner:view 239 owner:v
242 userInfo:nil]; 240 userInfo:nil];
243 [view addTrackingArea:area]; 241 [v addTrackingArea:area];
244 242
245 [area release]; 243 [area release];
246} 244}