diff options
author | Stefan Schmidt <stefan@osg.samsung.com> | 2015-09-04 14:07:52 +0200 |
---|---|---|
committer | Stefan Schmidt <stefan@osg.samsung.com> | 2015-09-04 14:54:07 +0200 |
commit | 56560329aefe08da71efeaab9cf820c31810e537 (patch) | |
tree | 2c31a6b89eb6d39f8c62ac9a98675f8a74cb33e7 /src/lib/ecore_cocoa | |
parent | 5f8d0450d50569abb00c2adc5cf9eba8f2b1a6af (diff) |
ecore: cocoa: convert dos to unix line endings
Diffstat (limited to 'src/lib/ecore_cocoa')
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_window.m | 992 |
1 files changed, 496 insertions, 496 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m index 2fd4bab189..92aa309d5e 100644 --- a/src/lib/ecore_cocoa/ecore_cocoa_window.m +++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m | |||
@@ -1,496 +1,496 @@ | |||
1 | #ifdef HAVE_CONFIG_H | 1 | #ifdef HAVE_CONFIG_H |
2 | # include <config.h> | 2 | # include <config.h> |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #include <Ecore_Input.h> | 5 | #include <Ecore_Input.h> |
6 | 6 | ||
7 | #include <Ecore.h> | 7 | #include <Ecore.h> |
8 | #include <Ecore_Cocoa.h> | 8 | #include <Ecore_Cocoa.h> |
9 | #import "ecore_cocoa_window.h" | 9 | #import "ecore_cocoa_window.h" |
10 | #include "ecore_cocoa_private.h" | 10 | #include "ecore_cocoa_private.h" |
11 | 11 | ||
12 | @implementation EcoreCocoaWindow | 12 | @implementation EcoreCocoaWindow |
13 | 13 | ||
14 | @synthesize ecore_window_data; | 14 | @synthesize ecore_window_data; |
15 | 15 | ||
16 | - (id) initWithContentRect: (NSRect) contentRect | 16 | - (id) initWithContentRect: (NSRect) contentRect |
17 | styleMask: (unsigned int) aStyle | 17 | styleMask: (unsigned int) aStyle |
18 | backing: (NSBackingStoreType) bufferingType | 18 | backing: (NSBackingStoreType) bufferingType |
19 | defer: (BOOL) flag | 19 | defer: (BOOL) flag |
20 | { | 20 | { |
21 | if (![super initWithContentRect: contentRect | 21 | if (![super initWithContentRect: contentRect |
22 | styleMask: aStyle | 22 | styleMask: aStyle |
23 | backing: bufferingType | 23 | backing: bufferingType |
24 | defer: flag]) return nil; | 24 | defer: flag]) return nil; |
25 | 25 | ||
26 | [self setBackgroundColor: [NSColor whiteColor]]; | 26 | [self setBackgroundColor: [NSColor whiteColor]]; |
27 | [self makeKeyWindow]; | 27 | [self makeKeyWindow]; |
28 | [self setDelegate:self]; | 28 | [self setDelegate:self]; |
29 | [self setAcceptsMouseMovedEvents:YES]; | 29 | [self setAcceptsMouseMovedEvents:YES]; |
30 | 30 | ||
31 | [self setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; | 31 | [self setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; |
32 | 32 | ||
33 | return self; | 33 | return self; |
34 | } | 34 | } |
35 | 35 | ||
36 | - (BOOL)isFullScreen | 36 | - (BOOL)isFullScreen |
37 | { | 37 | { |
38 | return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask); | 38 | return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask); |
39 | } | 39 | } |
40 | 40 | ||
41 | - (BOOL)acceptsFirstResponder | 41 | - (BOOL)acceptsFirstResponder |
42 | { | 42 | { |
43 | return YES; | 43 | return YES; |
44 | } | 44 | } |
45 | 45 | ||
46 | - (BOOL)canBecomeKeyWindow | 46 | - (BOOL)canBecomeKeyWindow |
47 | { | 47 | { |
48 | return YES; | 48 | return YES; |
49 | } | 49 | } |
50 | 50 | ||
51 | - (void)windowWillClose:(NSNotification *) EINA_UNUSED notification | 51 | - (void)windowWillClose:(NSNotification *) EINA_UNUSED notification |
52 | { | 52 | { |
53 | NSLog(@"window is going to be closed"); | 53 | NSLog(@"window is going to be closed"); |
54 | Ecore_Cocoa_Event_Window *event; | 54 | Ecore_Cocoa_Event_Window *event; |
55 | 55 | ||
56 | event = malloc(sizeof(Ecore_Cocoa_Event_Window)); | 56 | event = malloc(sizeof(Ecore_Cocoa_Event_Window)); |
57 | if (event == NULL) | 57 | if (event == NULL) |
58 | { | 58 | { |
59 | // FIXME Use Eina_Log | 59 | // FIXME Use Eina_Log |
60 | printf("Failed to allocate Ecore_Cocoa_Event_Window_destroy\n"); | 60 | printf("Failed to allocate Ecore_Cocoa_Event_Window_destroy\n"); |
61 | return; | 61 | return; |
62 | } | 62 | } |
63 | event->wid = [notification object]; | 63 | event->wid = [notification object]; |
64 | ecore_event_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, event, NULL, NULL); | 64 | ecore_event_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, event, NULL, NULL); |
65 | } | 65 | } |
66 | 66 | ||
67 | - (void)windowDidResize:(NSNotification *) EINA_UNUSED notif | 67 | - (void)windowDidResize:(NSNotification *) EINA_UNUSED notif |
68 | { | 68 | { |
69 | Ecore_Cocoa_Event_Video_Resize *event; | 69 | Ecore_Cocoa_Event_Video_Resize *event; |
70 | NSSize size = self.frame.size; | 70 | NSSize size = self.frame.size; |
71 | 71 | ||
72 | event = malloc(sizeof(Ecore_Cocoa_Event_Video_Resize)); | 72 | event = malloc(sizeof(Ecore_Cocoa_Event_Video_Resize)); |
73 | if (event == NULL) | 73 | if (event == NULL) |
74 | { | 74 | { |
75 | DBG("Failed to allocate Ecore_Cocoa_Event_Video_Resize\n"); | 75 | DBG("Failed to allocate Ecore_Cocoa_Event_Video_Resize\n"); |
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | event->w = size.width; | 78 | event->w = size.width; |
79 | event->h = size.height - | 79 | event->h = size.height - |
80 | (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); | 80 | (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); |
81 | event->wid = [notif object]; | 81 | event->wid = [notif object]; |
82 | ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL); | 82 | ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL); |
83 | } | 83 | } |
84 | 84 | ||
85 | - (void)windowDidBecomeKey:(NSNotification *)notification | 85 | - (void)windowDidBecomeKey:(NSNotification *)notification |
86 | { | 86 | { |
87 | Ecore_Cocoa_Event_Window *e; | 87 | Ecore_Cocoa_Event_Window *e; |
88 | 88 | ||
89 | e = malloc(sizeof(Ecore_Cocoa_Event_Window)); | 89 | e = malloc(sizeof(Ecore_Cocoa_Event_Window)); |
90 | if (!e) | 90 | if (!e) |
91 | { | 91 | { |
92 | DBG("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n"); | 92 | DBG("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n"); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | e->wid = [notification object]; | 95 | e->wid = [notification object]; |
96 | ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL); | 96 | ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL); |
97 | } | 97 | } |
98 | 98 | ||
99 | - (void)windowDidResignKey:(NSNotification *)notification | 99 | - (void)windowDidResignKey:(NSNotification *)notification |
100 | { | 100 | { |
101 | Ecore_Cocoa_Event_Window *e; | 101 | Ecore_Cocoa_Event_Window *e; |
102 | 102 | ||
103 | e = malloc(sizeof(Ecore_Cocoa_Event_Window)); | 103 | e = malloc(sizeof(Ecore_Cocoa_Event_Window)); |
104 | if (!e) | 104 | if (!e) |
105 | { | 105 | { |
106 | DBG("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n"); | 106 | DBG("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n"); |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | e->wid = [notification object]; | 109 | e->wid = [notification object]; |
110 | ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, e, NULL, NULL); | 110 | ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, e, NULL, NULL); |
111 | } | 111 | } |
112 | 112 | ||
113 | - (void) mouseDown:(NSEvent*) event | 113 | - (void) mouseDown:(NSEvent*) event |
114 | { | 114 | { |
115 | unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); | 115 | unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); |
116 | 116 | ||
117 | NSView *view = [self contentView]; | 117 | NSView *view = [self contentView]; |
118 | NSPoint event_location = [event locationInWindow]; | 118 | NSPoint event_location = [event locationInWindow]; |
119 | NSPoint pt = [view convertPoint:event_location fromView:nil]; | 119 | NSPoint pt = [view convertPoint:event_location fromView:nil]; |
120 | 120 | ||
121 | int h = [view frame].size.height; | 121 | int h = [view frame].size.height; |
122 | int x = pt.x; | 122 | int x = pt.x; |
123 | int y = h - pt.y; | 123 | int y = h - pt.y; |
124 | 124 | ||
125 | Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); | 125 | Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); |
126 | if (!ev) return; | 126 | if (!ev) return; |
127 | 127 | ||
128 | ev->x = x; | 128 | ev->x = x; |
129 | ev->y = y; | 129 | ev->y = y; |
130 | ev->root.x = ev->x; | 130 | ev->root.x = ev->x; |
131 | ev->root.y = ev->y; | 131 | ev->root.y = ev->y; |
132 | ev->timestamp = time; | 132 | ev->timestamp = time; |
133 | switch ([event buttonNumber]) | 133 | switch ([event buttonNumber]) |
134 | { | 134 | { |
135 | case 0: ev->buttons = 1; break; | 135 | case 0: ev->buttons = 1; break; |
136 | case 1: ev->buttons = 3; break; | 136 | case 1: ev->buttons = 3; break; |
137 | case 2: ev->buttons = 2; break; | 137 | case 2: ev->buttons = 2; break; |
138 | default: ev->buttons = 0; break; | 138 | default: ev->buttons = 0; break; |
139 | } | 139 | } |
140 | ev->window = (Ecore_Window)self.ecore_window_data; | 140 | ev->window = (Ecore_Window)self.ecore_window_data; |
141 | ev->event_window = ev->window; | 141 | ev->event_window = ev->window; |
142 | 142 | ||
143 | if ([event clickCount] == 2) | 143 | if ([event clickCount] == 2) |
144 | ev->double_click = 1; | 144 | ev->double_click = 1; |
145 | else | 145 | else |
146 | ev->double_click = 0; | 146 | ev->double_click = 0; |
147 | 147 | ||
148 | if ([event clickCount] >= 3) | 148 | if ([event clickCount] >= 3) |
149 | ev->triple_click = 1; | 149 | ev->triple_click = 1; |
150 | else | 150 | else |
151 | ev->triple_click = 0; | 151 | ev->triple_click = 0; |
152 | 152 | ||
153 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); | 153 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); |
154 | } | 154 | } |
155 | 155 | ||
156 | - (void) rightMouseDown:(NSEvent*) event | 156 | - (void) rightMouseDown:(NSEvent*) event |
157 | { | 157 | { |
158 | [self mouseDown: event]; | 158 | [self mouseDown: event]; |
159 | } | 159 | } |
160 | 160 | ||
161 | - (void) otherMouseDown:(NSEvent*) event | 161 | - (void) otherMouseDown:(NSEvent*) event |
162 | { | 162 | { |
163 | [self mouseDown: event]; | 163 | [self mouseDown: event]; |
164 | } | 164 | } |
165 | 165 | ||
166 | - (void) mouseUp:(NSEvent*) event | 166 | - (void) mouseUp:(NSEvent*) event |
167 | { | 167 | { |
168 | unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); | 168 | unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); |
169 | 169 | ||
170 | NSView *view = [self contentView]; | 170 | NSView *view = [self contentView]; |
171 | NSPoint event_location = [event locationInWindow]; | 171 | NSPoint event_location = [event locationInWindow]; |
172 | NSPoint pt = [view convertPoint:event_location fromView:nil]; | 172 | NSPoint pt = [view convertPoint:event_location fromView:nil]; |
173 | 173 | ||
174 | int h = [view frame].size.height; | 174 | int h = [view frame].size.height; |
175 | int x = pt.x; | 175 | int x = pt.x; |
176 | int y = h - pt.y; | 176 | int y = h - pt.y; |
177 | 177 | ||
178 | Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); | 178 | Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); |
179 | if (!ev) return; | 179 | if (!ev) return; |
180 | 180 | ||
181 | ev->x = x; | 181 | ev->x = x; |
182 | ev->y = y; | 182 | ev->y = y; |
183 | ev->root.x = ev->x; | 183 | ev->root.x = ev->x; |
184 | ev->root.y = ev->y; | 184 | ev->root.y = ev->y; |
185 | ev->timestamp = time; | 185 | ev->timestamp = time; |
186 | switch ([event buttonNumber]) | 186 | switch ([event buttonNumber]) |
187 | { | 187 | { |
188 | case 0: ev->buttons = 1; break; | 188 | case 0: ev->buttons = 1; break; |
189 | case 1: ev->buttons = 3; break; | 189 | case 1: ev->buttons = 3; break; |
190 | case 2: ev->buttons = 2; break; | 190 | case 2: ev->buttons = 2; break; |
191 | default: ev->buttons = 0; break; | 191 | default: ev->buttons = 0; break; |
192 | } | 192 | } |
193 | ev->window = (Ecore_Window)self.ecore_window_data; | 193 | ev->window = (Ecore_Window)self.ecore_window_data; |
194 | ev->event_window = ev->window; | 194 | ev->event_window = ev->window; |
195 | 195 | ||
196 | if ([event clickCount] == 2) | 196 | if ([event clickCount] == 2) |
197 | ev->double_click = 1; | 197 | ev->double_click = 1; |
198 | else | 198 | else |
199 | ev->double_click = 0; | 199 | ev->double_click = 0; |
200 | 200 | ||
201 | if ([event clickCount] >= 3) | 201 | if ([event clickCount] >= 3) |
202 | ev->triple_click = 1; | 202 | ev->triple_click = 1; |
203 | else | 203 | else |
204 | ev->triple_click = 0; | 204 | ev->triple_click = 0; |
205 | 205 | ||
206 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); | 206 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); |
207 | } | 207 | } |
208 | 208 | ||
209 | - (void) rightMouseUp:(NSEvent*) event | 209 | - (void) rightMouseUp:(NSEvent*) event |
210 | { | 210 | { |
211 | [self mouseUp: event]; | 211 | [self mouseUp: event]; |
212 | } | 212 | } |
213 | 213 | ||
214 | - (void) otherMouseUp:(NSEvent*) event | 214 | - (void) otherMouseUp:(NSEvent*) event |
215 | { | 215 | { |
216 | [self mouseUp: event]; | 216 | [self mouseUp: event]; |
217 | } | 217 | } |
218 | 218 | ||
219 | - (void) mouseMoved:(NSEvent*) event | 219 | - (void) mouseMoved:(NSEvent*) event |
220 | { | 220 | { |
221 | Ecore_Event_Mouse_Move * ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)); | 221 | Ecore_Event_Mouse_Move * ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)); |
222 | if (!ev) return; | 222 | if (!ev) return; |
223 | 223 | ||
224 | NSView *view = [self contentView]; | 224 | NSView *view = [self contentView]; |
225 | NSPoint event_location = [event locationInWindow]; | 225 | NSPoint event_location = [event locationInWindow]; |
226 | NSPoint pt = [view convertPoint:event_location fromView:nil]; | 226 | NSPoint pt = [view convertPoint:event_location fromView:nil]; |
227 | 227 | ||
228 | ev->x = pt.x; | 228 | ev->x = pt.x; |
229 | ev->y = [view frame].size.height - pt.y; | 229 | ev->y = [view frame].size.height - pt.y; |
230 | ev->root.x = ev->x; | 230 | ev->root.x = ev->x; |
231 | ev->root.y = ev->y; | 231 | ev->root.y = ev->y; |
232 | ev->timestamp = time; | 232 | ev->timestamp = time; |
233 | ev->window = (Ecore_Window)self.ecore_window_data; | 233 | ev->window = (Ecore_Window)self.ecore_window_data; |
234 | ev->event_window = ev->window; | 234 | ev->event_window = ev->window; |
235 | ev->modifiers = 0; /* FIXME: keep modifier around. */ | 235 | ev->modifiers = 0; /* FIXME: keep modifier around. */ |
236 | 236 | ||
237 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); | 237 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); |
238 | } | 238 | } |
239 | 239 | ||
240 | - (void) mouseDragged: (NSEvent*) event | 240 | - (void) mouseDragged: (NSEvent*) event |
241 | { | 241 | { |
242 | [self mouseMoved:event]; | 242 | [self mouseMoved:event]; |
243 | } | 243 | } |
244 | 244 | ||
245 | @end | 245 | @end |
246 | 246 | ||
247 | Ecore_Cocoa_Window * | 247 | Ecore_Cocoa_Window * |
248 | ecore_cocoa_window_new(int x, | 248 | ecore_cocoa_window_new(int x, |
249 | int y, | 249 | int y, |
250 | int width, | 250 | int width, |
251 | int height) | 251 | int height) |
252 | { | 252 | { |
253 | Ecore_Cocoa_Window *w; | 253 | Ecore_Cocoa_Window *w; |
254 | 254 | ||
255 | EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height) | 255 | EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height) |
256 | styleMask:(NSTitledWindowMask | | 256 | styleMask:(NSTitledWindowMask | |
257 | NSClosableWindowMask | | 257 | NSClosableWindowMask | |
258 | NSResizableWindowMask | | 258 | NSResizableWindowMask | |
259 | NSMiniaturizableWindowMask) | 259 | NSMiniaturizableWindowMask) |
260 | backing:NSBackingStoreBuffered | 260 | backing:NSBackingStoreBuffered |
261 | defer:NO]; | 261 | defer:NO]; |
262 | 262 | ||
263 | if (!window) | 263 | if (!window) |
264 | return NULL; | 264 | return NULL; |
265 | 265 | ||
266 | //Set the process to be a foreground process, | 266 | //Set the process to be a foreground process, |
267 | //without that it prevents the window to become the key window and | 267 | //without that it prevents the window to become the key window and |
268 | //receive all mouse mouve events. | 268 | //receive all mouse mouve events. |
269 | [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; | 269 | [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; |
270 | [NSApp activateIgnoringOtherApps:YES]; | 270 | [NSApp activateIgnoringOtherApps:YES]; |
271 | 271 | ||
272 | 272 | ||
273 | w = calloc(1, sizeof(Ecore_Cocoa_Window)); | 273 | w = calloc(1, sizeof(Ecore_Cocoa_Window)); |
274 | if (w == NULL) | 274 | if (w == NULL) |
275 | { | 275 | { |
276 | return NULL; | 276 | return NULL; |
277 | } | 277 | } |
278 | w->window = window; | 278 | w->window = window; |
279 | w->borderless = 0; | 279 | w->borderless = 0; |
280 | 280 | ||
281 | window.ecore_window_data = w; | 281 | window.ecore_window_data = w; |
282 | 282 | ||
283 | return w; | 283 | return w; |
284 | } | 284 | } |
285 | 285 | ||
286 | void | 286 | void |
287 | ecore_cocoa_window_free(Ecore_Cocoa_Window *window) | 287 | ecore_cocoa_window_free(Ecore_Cocoa_Window *window) |
288 | { | 288 | { |
289 | if (!window) | 289 | if (!window) |
290 | return; | 290 | return; |
291 | 291 | ||
292 | [window->window release]; | 292 | [window->window release]; |
293 | free(window); | 293 | free(window); |
294 | } | 294 | } |
295 | 295 | ||
296 | void | 296 | void |
297 | ecore_cocoa_window_size_min_set(Ecore_Cocoa_Window *window, | 297 | ecore_cocoa_window_size_min_set(Ecore_Cocoa_Window *window, |
298 | unsigned int w, | 298 | unsigned int w, |
299 | unsigned int h) | 299 | unsigned int h) |
300 | { | 300 | { |
301 | if (!window) | 301 | if (!window) |
302 | return; | 302 | return; |
303 | NSSize size = {w,h}; | 303 | NSSize size = {w,h}; |
304 | window->window.contentMinSize = size; | 304 | window->window.contentMinSize = size; |
305 | } | 305 | } |
306 | 306 | ||
307 | void | 307 | void |
308 | ecore_cocoa_window_size_max_set(Ecore_Cocoa_Window *window, | 308 | ecore_cocoa_window_size_max_set(Ecore_Cocoa_Window *window, |
309 | unsigned int w, | 309 | unsigned int w, |
310 | unsigned int h) | 310 | unsigned int h) |
311 | { | 311 | { |
312 | if (!window) | 312 | if (!window) |
313 | return; | 313 | return; |
314 | NSSize size = {w,h}; | 314 | NSSize size = {w,h}; |
315 | window->window.contentMaxSize = size; | 315 | window->window.contentMaxSize = size; |
316 | } | 316 | } |
317 | 317 | ||
318 | void | 318 | void |
319 | ecore_cocoa_window_size_step_set(Ecore_Cocoa_Window *window, | 319 | ecore_cocoa_window_size_step_set(Ecore_Cocoa_Window *window, |
320 | unsigned int w, | 320 | unsigned int w, |
321 | unsigned int h) | 321 | unsigned int h) |
322 | { | 322 | { |
323 | if (!window) | 323 | if (!window) |
324 | return; | 324 | return; |
325 | NSSize size = {w,h}; | 325 | NSSize size = {w,h}; |
326 | window->window.contentResizeIncrements = size; | 326 | window->window.contentResizeIncrements = size; |
327 | } | 327 | } |
328 | 328 | ||
329 | void | 329 | void |
330 | ecore_cocoa_window_move(Ecore_Cocoa_Window *window, | 330 | ecore_cocoa_window_move(Ecore_Cocoa_Window *window, |
331 | int x, | 331 | int x, |
332 | int y) | 332 | int y) |
333 | { | 333 | { |
334 | NSRect win_frame; | 334 | NSRect win_frame; |
335 | 335 | ||
336 | if (!window) | 336 | if (!window) |
337 | return; | 337 | return; |
338 | 338 | ||
339 | win_frame = [window->window frame]; | 339 | win_frame = [window->window frame]; |
340 | win_frame.origin.x = x; | 340 | win_frame.origin.x = x; |
341 | win_frame.origin.y = y; | 341 | win_frame.origin.y = y; |
342 | 342 | ||
343 | [window->window setFrame:win_frame display:YES]; | 343 | [window->window setFrame:win_frame display:YES]; |
344 | } | 344 | } |
345 | 345 | ||
346 | void | 346 | void |
347 | ecore_cocoa_window_resize(Ecore_Cocoa_Window *window, | 347 | ecore_cocoa_window_resize(Ecore_Cocoa_Window *window, |
348 | int width, | 348 | int width, |
349 | int height) | 349 | int height) |
350 | { | 350 | { |
351 | if (!window) return; | 351 | if (!window) return; |
352 | 352 | ||
353 | NSRect win_frame; | 353 | NSRect win_frame; |
354 | 354 | ||
355 | win_frame = [window->window frame]; | 355 | win_frame = [window->window frame]; |
356 | win_frame.size.height = height + | 356 | win_frame.size.height = height + |
357 | (([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); | 357 | (([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); |
358 | win_frame.size.width = width; | 358 | win_frame.size.width = width; |
359 | 359 | ||
360 | [window->window setFrame:win_frame display:YES]; | 360 | [window->window setFrame:win_frame display:YES]; |
361 | } | 361 | } |
362 | 362 | ||
363 | void | 363 | void |
364 | ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window, | 364 | ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window, |
365 | int x, | 365 | int x, |
366 | int y, | 366 | int y, |
367 | int width, | 367 | int width, |
368 | int height) | 368 | int height) |
369 | { | 369 | { |
370 | if (!window) return; | 370 | if (!window) return; |
371 | 371 | ||
372 | NSRect win_frame; | 372 | NSRect win_frame; |
373 | 373 | ||
374 | win_frame = [window->window frame]; | 374 | win_frame = [window->window frame]; |
375 | win_frame.size.height = height + | 375 | win_frame.size.height = height + |
376 | (([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); | 376 | (([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); |
377 | win_frame.size.width = width; | 377 | win_frame.size.width = width; |
378 | win_frame.origin.x = x; | 378 | win_frame.origin.x = x; |
379 | win_frame.origin.y = y; | 379 | win_frame.origin.y = y; |
380 | 380 | ||
381 | [window->window setFrame:win_frame display:YES]; | 381 | [window->window setFrame:win_frame display:YES]; |
382 | } | 382 | } |
383 | 383 | ||
384 | void | 384 | void |
385 | ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title) | 385 | ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title) |
386 | { | 386 | { |
387 | if (!window || !title) | 387 | if (!window || !title) |
388 | return; | 388 | return; |
389 | 389 | ||
390 | [window->window setTitle:[NSString stringWithUTF8String:title]]; | 390 | [window->window setTitle:[NSString stringWithUTF8String:title]]; |
391 | } | 391 | } |
392 | 392 | ||
393 | void | 393 | void |
394 | ecore_cocoa_window_show(Ecore_Cocoa_Window *window) | 394 | ecore_cocoa_window_show(Ecore_Cocoa_Window *window) |
395 | { | 395 | { |
396 | if (!window || [window->window isVisible]) | 396 | if (!window || [window->window isVisible]) |
397 | { | 397 | { |
398 | DBG("Window(%p) is not visible\n", window->window); | 398 | DBG("Window(%p) is not visible\n", window->window); |
399 | return; | 399 | return; |
400 | } | 400 | } |
401 | 401 | ||
402 | [window->window makeKeyAndOrderFront:NSApp]; | 402 | [window->window makeKeyAndOrderFront:NSApp]; |
403 | } | 403 | } |
404 | 404 | ||
405 | void | 405 | void |
406 | ecore_cocoa_window_hide(Ecore_Cocoa_Window *window) | 406 | ecore_cocoa_window_hide(Ecore_Cocoa_Window *window) |
407 | { | 407 | { |
408 | if (!window || ![window->window isVisible]) | 408 | if (!window || ![window->window isVisible]) |
409 | return; | 409 | return; |
410 | 410 | ||
411 | [window->window orderOut:NSApp]; | 411 | [window->window orderOut:NSApp]; |
412 | } | 412 | } |
413 | 413 | ||
414 | void ecore_cocoa_window_raise(Ecore_Cocoa_Window *window) | 414 | void ecore_cocoa_window_raise(Ecore_Cocoa_Window *window) |
415 | { | 415 | { |
416 | if (!window) | 416 | if (!window) |
417 | return; | 417 | return; |
418 | 418 | ||
419 | [window->window orderFront:nil]; | 419 | [window->window orderFront:nil]; |
420 | } | 420 | } |
421 | 421 | ||
422 | void ecore_cocoa_window_lower(Ecore_Cocoa_Window *window) | 422 | void ecore_cocoa_window_lower(Ecore_Cocoa_Window *window) |
423 | { | 423 | { |
424 | if (!window) | 424 | if (!window) |
425 | return; | 425 | return; |
426 | 426 | ||
427 | [window->window orderBack:nil]; | 427 | [window->window orderBack:nil]; |
428 | } | 428 | } |
429 | 429 | ||
430 | void ecore_cocoa_window_activate(Ecore_Cocoa_Window *window) | 430 | void ecore_cocoa_window_activate(Ecore_Cocoa_Window *window) |
431 | { | 431 | { |
432 | if (!window) | 432 | if (!window) |
433 | return; | 433 | return; |
434 | 434 | ||
435 | [window->window makeKeyAndOrderFront:nil]; | 435 | [window->window makeKeyAndOrderFront:nil]; |
436 | } | 436 | } |
437 | 437 | ||
438 | void ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window, | 438 | void ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window, |
439 | int on) | 439 | int on) |
440 | { | 440 | { |
441 | if (!window) | 441 | if (!window) |
442 | return; | 442 | return; |
443 | 443 | ||
444 | if (on) | 444 | if (on) |
445 | { | 445 | { |
446 | [window->window miniaturize:nil]; | 446 | [window->window miniaturize:nil]; |
447 | } | 447 | } |
448 | else | 448 | else |
449 | { | 449 | { |
450 | [window->window deminiaturize:nil]; | 450 | [window->window deminiaturize:nil]; |
451 | } | 451 | } |
452 | } | 452 | } |
453 | 453 | ||
454 | void | 454 | void |
455 | ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window, | 455 | ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window, |
456 | int on) | 456 | int on) |
457 | { | 457 | { |
458 | if (!window) | 458 | if (!window) |
459 | return; | 459 | return; |
460 | 460 | ||
461 | if (on) | 461 | if (on) |
462 | [window->window setContentBorderThickness:0.0 | 462 | [window->window setContentBorderThickness:0.0 |
463 | forEdge:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge]; | 463 | forEdge:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge]; |
464 | } | 464 | } |
465 | 465 | ||
466 | void | 466 | void |
467 | ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window, | 467 | ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window, |
468 | void *view) | 468 | void *view) |
469 | { | 469 | { |
470 | if (!window || !view) | 470 | if (!window || !view) |
471 | return; | 471 | return; |
472 | 472 | ||
473 | //[[window->window contentView] addSubview:view]; | 473 | //[[window->window contentView] addSubview:view]; |
474 | NSView *v = view; | 474 | NSView *v = view; |
475 | [window->window setContentView:view]; | 475 | [window->window setContentView:view]; |
476 | 476 | ||
477 | NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[v frame] | 477 | NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[v frame] |
478 | options:NSTrackingMouseMoved | | 478 | options:NSTrackingMouseMoved | |
479 | NSTrackingActiveInActiveApp | | 479 | NSTrackingActiveInActiveApp | |
480 | NSTrackingInVisibleRect | 480 | NSTrackingInVisibleRect |
481 | owner:v | 481 | owner:v |
482 | userInfo:nil]; | 482 | userInfo:nil]; |
483 | [v addTrackingArea:area]; | 483 | [v addTrackingArea:area]; |
484 | 484 | ||
485 | [area release]; | 485 | [area release]; |
486 | } | 486 | } |
487 | 487 | ||
488 | Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *window) | 488 | Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *window) |
489 | { | 489 | { |
490 | if (!window) | 490 | if (!window) |
491 | return 0; | 491 | return 0; |
492 | 492 | ||
493 | DBG("Return : %p", window->window); | 493 | DBG("Return : %p", window->window); |
494 | 494 | ||
495 | return window->window; | 495 | return window->window; |
496 | } | 496 | } |