summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa
diff options
context:
space:
mode:
authorRaoul Hecky <raoul.hecky@gmail.com>2014-06-08 21:50:42 +0200
committerCedric BAIL <c.bail@partner.samsung.com>2014-06-18 11:34:07 +0200
commit6f2d060c80b980db44e78e958bca06b1c372780c (patch)
treecf608dc92a966fc8ff60c3e097925b2be81156b5 /src/lib/ecore_cocoa
parentfc4d108b5f7aa6397d482ca5a575456b3cdf314f (diff)
ecore_cocoa: add code from old branch
Diffstat (limited to 'src/lib/ecore_cocoa')
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa.h9
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h12
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m218
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m466
4 files changed, 369 insertions, 336 deletions
diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa.h b/src/lib/ecore_cocoa/Ecore_Cocoa.h
index 51c8ead21b..3e24a1af37 100644
--- a/src/lib/ecore_cocoa/Ecore_Cocoa.h
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa.h
@@ -30,6 +30,7 @@ extern "C" {
30#endif 30#endif
31 31
32typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window; 32typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
33typedef struct _Ecore_Cocoa_Screen Ecore_Cocoa_Screen;
33 34
34EAPI extern int ECORE_COCOA_EVENT_GOT_FOCUS; 35EAPI extern int ECORE_COCOA_EVENT_GOT_FOCUS;
35EAPI extern int ECORE_COCOA_EVENT_LOST_FOCUS; 36EAPI extern int ECORE_COCOA_EVENT_LOST_FOCUS;
@@ -43,6 +44,10 @@ struct _Ecore_Cocoa_Event_Video_Resize
43 int h; 44 int h;
44}; 45};
45 46
47struct _Ecore_Cocoa_Screen
48{
49 int dummy;
50};
46 51
47/* Core */ 52/* Core */
48 53
@@ -50,6 +55,10 @@ EAPI int ecore_cocoa_init(void);
50EAPI int ecore_cocoa_shutdown(void); 55EAPI int ecore_cocoa_shutdown(void);
51EAPI void ecore_cocoa_feed_events(void); 56EAPI void ecore_cocoa_feed_events(void);
52 57
58/* Screen */
59
60EAPI void ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h);
61
53/* Window */ 62/* Window */
54 63
55EAPI Ecore_Cocoa_Window *ecore_cocoa_window_new(int x, 64EAPI Ecore_Cocoa_Window *ecore_cocoa_window_new(int x,
diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h b/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h
index f238df2977..53b17ed23f 100644
--- a/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h
@@ -14,8 +14,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
14{ 0, "0x00", "" }, 14{ 0, "0x00", "" },
15{ 0, "First", "" }, 15{ 0, "First", "" },
16{ 3, "Return", "\015" }, 16{ 3, "Return", "\015" },
17// OS-X's backspace and Delete are reversed! 17{ 8, "Delete", "\010" },
18{ 8, "Delete", "\010" },
19{ 9, "Tab", "\011" }, 18{ 9, "Tab", "\011" },
20{ 12, "Clear", "" }, 19{ 12, "Clear", "" },
21{ 13, "Return", "\015" }, 20{ 13, "Return", "\015" },
@@ -91,11 +90,10 @@ static const struct _ecore_cocoa_keys_s keystable[] =
91{ 123, "braceleft", "" }, 90{ 123, "braceleft", "" },
92{ 124, "pipe", "" }, 91{ 124, "pipe", "" },
93{ 125, "braceright", "" }, 92{ 125, "braceright", "" },
94// OS-X's backspace and Delete are reversed! 93{ 127, "BackSpace", "\177" },
95{ 127, "BackSpace", "\177" },
96{ 126, "asciitilde", "~" }, 94{ 126, "asciitilde", "~" },
97 95
98{ 160, "w0", "" }, 96{ 160, "w0", "" },
99{ 161, "w1", "" }, 97{ 161, "w1", "" },
100{ 162, "w2", "" }, 98{ 162, "w2", "" },
101{ 163, "w3", "" }, 99{ 163, "w3", "" },
@@ -259,8 +257,8 @@ static const struct _ecore_cocoa_keys_s keystable[] =
259{ NSClearLineFunctionKey, "Num_Lock", "" }, 257{ NSClearLineFunctionKey, "Num_Lock", "" },
260{ 301, "Caps_Lock", "" }, 258{ 301, "Caps_Lock", "" },
261{ NSScrollLockFunctionKey, "Scroll_Lock", "" }, 259{ NSScrollLockFunctionKey, "Scroll_Lock", "" },
262{ 303, "Shift_R", "" }, 260{ 303, "Shift_R", "Shift_R" },
263{ 304, "Shift_L", "" }, 261{ 304, "Shift_L", "Shift_L" },
264{ 305, "Control_R", "" }, 262{ 305, "Control_R", "" },
265{ 306, "Control_L", "" }, 263{ 306, "Control_L", "" },
266{ 307, "Alt_R", "" }, 264{ 307, "Alt_R", "" },
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index 59bc02814b..856961371a 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -2,7 +2,8 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <Cocoa/Cocoa.h> 5#import <Cocoa/Cocoa.h>
6#import "ecore_cocoa_window.h"
6 7
7#include <Eina.h> 8#include <Eina.h>
8 9
@@ -23,54 +24,6 @@ static int _ecore_cocoa_init_count = 0;
23 24
24static int old_flags; 25static int old_flags;
25 26
26static unsigned int
27_ecore_cocoa_event_modifiers(int mod)
28{
29 unsigned int modifiers = 0;
30
31 if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
32 if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL;
33 if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALT;
34 if(mod & NSAlphaShiftKeyMask) modifiers |= ECORE_EVENT_LOCK_CAPS;
35
36 return modifiers;
37}
38
39static Ecore_Event_Key*
40_ecore_cocoa_event_key(NSEvent *nsevent, double timestamp)
41{
42 Ecore_Event_Key *ev;
43 unsigned int i;
44 int flags = [nsevent modifierFlags];
45
46 ev = malloc(sizeof(Ecore_Event_Key));
47 if (!ev) return NULL;
48
49 ev->timestamp = timestamp;
50 ev->window = 0;
51 ev->event_window = 0;
52 ev->modifiers = _ecore_cocoa_event_modifiers(flags);
53 ev->key = NULL;
54 ev->compose = NULL;
55
56 printf("key code : %d\n", [[nsevent charactersIgnoringModifiers] characterAtIndex:0]);
57
58 for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i)
59 if (keystable[i].code == [[nsevent charactersIgnoringModifiers] characterAtIndex:0])
60 {
61 printf("keycode : %d key pressed : %s\n", keystable[i].code, keystable[i].name);
62 ev->keyname = keystable[i].name;
63 ev->key = ev->keyname;
64 ev->string = keystable[i].compose;
65
66 return ev;
67 }
68 free(ev);
69 return NULL;
70}
71
72
73
74EAPI int 27EAPI int
75ecore_cocoa_init(void) 28ecore_cocoa_init(void)
76{ 29{
@@ -107,9 +60,25 @@ ecore_cocoa_shutdown(void)
107 return _ecore_cocoa_init_count; 60 return _ecore_cocoa_init_count;
108} 61}
109 62
63static unsigned int
64_ecore_cocoa_event_modifiers(unsigned int mod)
65{
66 unsigned int modifiers = 0;
67
68 if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
69 if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL;
70 if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALT;
71 if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN;
72 if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM;
73
74 printf("key modifiers: %d, %d\n", mod, modifiers);
75 return modifiers;
76}
77
110EAPI void 78EAPI void
111ecore_cocoa_feed_events(void) 79ecore_cocoa_feed_events(void)
112{ 80{
81 Ecore_Event *ev;
113 NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0.001]; 82 NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0.001];
114 NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask 83 NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
115 untilDate:date 84 untilDate:date
@@ -139,7 +108,8 @@ ecore_cocoa_feed_events(void)
139 ev->root.x = ev->x; 108 ev->root.x = ev->x;
140 ev->root.y = ev->y; 109 ev->root.y = ev->y;
141 ev->timestamp = time; 110 ev->timestamp = time;
142 ev->window = [event window]; 111 ev->window = window.ecore_window_data;
112 ev->event_window = ev->window;
143 ev->modifiers = 0; /* FIXME: keep modifier around. */ 113 ev->modifiers = 0; /* FIXME: keep modifier around. */
144 114
145 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); 115 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
@@ -163,15 +133,13 @@ ecore_cocoa_feed_events(void)
163 ev->root.x = ev->x; 133 ev->root.x = ev->x;
164 ev->root.y = ev->y; 134 ev->root.y = ev->y;
165 ev->timestamp = time; 135 ev->timestamp = time;
166 136 switch ([event buttonNumber])
167 if ([event buttonNumber] == 0) 137 {
168 ev->buttons = 1; 138 case 0: ev->buttons = 1; break;
169 else if ([event buttonNumber] == 2) 139 case 1: ev->buttons = 3; break;
170 ev->buttons = 2; 140 case 2: ev->buttons = 2; break;
171 else 141 default: ev->buttons = 0; break;
172 ev->buttons = 3; 142 }
173
174 printf("ev buttons : %d - %d\n", ev->buttons, [event buttonNumber]);
175 ev->window = window.ecore_window_data; 143 ev->window = window.ecore_window_data;
176 ev->event_window = ev->window; 144 ev->event_window = ev->window;
177 145
@@ -206,14 +174,13 @@ ecore_cocoa_feed_events(void)
206 ev->root.x = ev->x; 174 ev->root.x = ev->x;
207 ev->root.y = ev->y; 175 ev->root.y = ev->y;
208 ev->timestamp = time; 176 ev->timestamp = time;
209 177 switch ([event buttonNumber])
210 if ([event buttonNumber] == 0) 178 {
211 ev->buttons = 1; 179 case 0: ev->buttons = 1; break;
212 else if ([event buttonNumber] == 2) 180 case 1: ev->buttons = 3; break;
213 ev->buttons = 2; 181 case 2: ev->buttons = 2; break;
214 else 182 default: ev->buttons = 0; break;
215 ev->buttons = 3; 183 }
216
217 ev->window = window.ecore_window_data; 184 ev->window = window.ecore_window_data;
218 ev->event_window = ev->window; 185 ev->event_window = ev->window;
219 186
@@ -235,60 +202,117 @@ ecore_cocoa_feed_events(void)
235 case NSKeyDown: 202 case NSKeyDown:
236 { 203 {
237 Ecore_Event_Key *ev; 204 Ecore_Event_Key *ev;
205 unsigned int i;
238 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 206 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
239 207
240 ev = _ecore_cocoa_event_key(event, time); 208 ev = calloc(1, sizeof (Ecore_Event_Key));
241 if (!ev) return; 209 if (!ev) return;
210 ev->timestamp = time;
211 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
242 212
243 ev->window = window.ecore_window_data; 213 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
244 ev->event_window = ev->window; 214 {
245 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); 215 if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0]))
216 {
217 printf("Key pressed : %s\n", keystable[i].name);
218 ev->keyname = keystable[i].name;
219 ev->key = keystable[i].name;
220 ev->string = keystable[i].compose;
221 ev->window = window.ecore_window_data;
222 ev->event_window = ev->window;
223 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
224 return;
225 }
226 }
246 227
247 break; 228 break;
248 } 229 }
249 case NSKeyUp: 230 case NSKeyUp:
250 { 231 {
251 Ecore_Event_Key *ev; 232 Ecore_Event_Key *ev;
233 unsigned int i;
252 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 234 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
253 235
254 ev = _ecore_cocoa_event_key(event, time); 236 printf("Key Up\n");
237
238 ev = calloc(1, sizeof (Ecore_Event_Key));
255 if (!ev) return; 239 if (!ev) return;
240 ev->timestamp = time;
241 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
256 242
257 ev->window = window.ecore_window_data; 243 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
258 ev->event_window = ev->window; 244 {
259 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); 245 if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0]))
246 {
247 ev->keyname = keystable[i].name;
248 ev->key = keystable[i].name;
249 ev->string = keystable[i].compose;
250 ev->window = window.ecore_window_data;
251 ev->event_window = ev->window;
252 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
253 return;
254 }
255 }
260 256
261 break; 257 break;
262 } 258 }
263 case NSFlagsChanged: 259 case NSFlagsChanged:
264 { 260 {
265
266 int flags = [event modifierFlags]; 261 int flags = [event modifierFlags];
267 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
268 Ecore_Event_Key *ev;
269 262
270 ev = calloc(1, sizeof(Ecore_Event_Key)); 263 Ecore_Event_Key *evDown = NULL;
271 if (!ev) return; 264 Ecore_Event_Key *evUp = NULL;
272 265
266 evDown = calloc(1, sizeof (Ecore_Event_Key));
267 if (!evDown) return;
268
269 evUp = calloc(1, sizeof (Ecore_Event_Key));
270 if (!evUp)
271 {
272 free(evDown);
273 return;
274 }
275
276 // Turn special key flags on
273 if (flags & NSShiftKeyMask) 277 if (flags & NSShiftKeyMask)
274 ev->keyname = "Shift_L"; 278 evDown->keyname = "Shift_L";
275 else if (flags & NSControlKeyMask) 279 else if (flags & NSControlKeyMask)
276 ev->keyname = "Control_L"; 280 evDown->keyname = "Control_L";
277 else if (flags & NSAlternateKeyMask) 281 else if (flags & NSAlternateKeyMask)
278 ev->keyname = "Alt_L"; 282 evDown->keyname = "Alt_L";
279 else if (flags & NSCommandKeyMask) 283 else if (flags & NSCommandKeyMask)
280 ev->keyname = "Super_L"; 284 evDown->keyname = "Super_L";
281 else if (flags & NSAlphaShiftKeyMask) 285 else if (flags & NSAlphaShiftKeyMask)
282 ev->keyname = "Caps_Lock"; 286 evDown->keyname = "Caps_Lock";
287
288 if (evDown->keyname)
289 {
290 evDown->timestamp = time;
291 evDown->string = "";
292 ecore_event_add(ECORE_EVENT_KEY_DOWN, evDown, NULL, NULL);
293 old_flags = flags;
294 break;
295 }
283 296
284 if (ev->keyname) 297 int changed_flags = flags ^ old_flags;
298
299 // Turn special key flags off
300 if (changed_flags & NSShiftKeyMask)
301 evUp->keyname = "Shift_L";
302 else if (changed_flags & NSControlKeyMask)
303 evUp->keyname = "Control_L";
304 else if (changed_flags & NSAlternateKeyMask)
305 evUp->keyname = "Alt_L";
306 else if (changed_flags & NSCommandKeyMask)
307 evUp->keyname = "Super_L";
308 else if (changed_flags & NSAlphaShiftKeyMask)
309 evUp->keyname = "Caps_Lock";
310
311 if (evUp->keyname)
285 { 312 {
286 ev->key = ev->keyname; 313 evUp->timestamp = time;
287 ev->timestamp = time; 314 evUp->string = "";
288 ev->string = ""; 315 ecore_event_add(ECORE_EVENT_KEY_UP, evUp, NULL, NULL);
289 ev->modifiers = _ecore_cocoa_event_modifiers(flags);
290 printf("Flags changed keyup\n");
291 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
292 old_flags = flags; 316 old_flags = flags;
293 break; 317 break;
294 } 318 }
@@ -306,6 +330,7 @@ ecore_cocoa_feed_events(void)
306 } 330 }
307 case NSScrollWheel: 331 case NSScrollWheel:
308 { 332 {
333 printf("Scroll Wheel\n");
309 break; 334 break;
310 } 335 }
311 default: 336 default:
@@ -317,3 +342,12 @@ ecore_cocoa_feed_events(void)
317 342
318 [event release]; 343 [event release];
319} 344}
345
346EAPI void
347ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h)
348{
349 NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size;
350
351 if (w) *w = (int)pt.width;
352 if (h) *h = (int)pt.height;
353}
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index b58854f472..8890107426 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -1,237 +1,229 @@
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#import "ecore_cocoa_window.h" 5#import "ecore_cocoa_window.h"
6#include "Ecore_Cocoa.h" 6
7#include "ecore_cocoa_private.h" 7@implementation EcoreCocoaWindow
8 8
9@implementation EcoreCocoaWindow 9@synthesize ecore_window_data;
10 10
11@synthesize ecore_window_data; 11- (id) initWithContentRect: (NSRect) contentRect
12 12 styleMask: (unsigned int) aStyle
13- (id) initWithContentRect: (NSRect) contentRect 13 backing: (NSBackingStoreType) bufferingType
14 styleMask: (unsigned int) aStyle 14 defer: (BOOL) flag
15 backing: (NSBackingStoreType) bufferingType 15{
16 defer: (BOOL) flag 16 if (![super initWithContentRect: contentRect
17{ 17 styleMask: aStyle
18 if (![super initWithContentRect: contentRect 18 backing: bufferingType
19 styleMask: aStyle 19 defer: flag]) return nil;
20 backing: bufferingType 20
21 defer: flag]) return nil; 21 [self setBackgroundColor: [NSColor whiteColor]];
22 22 [self makeKeyWindow];
23 [self setBackgroundColor: [NSColor whiteColor]]; 23 [self setDelegate:self];
24 [self makeKeyWindow]; 24 [self setAcceptsMouseMovedEvents:YES];
25 [self setDelegate:self]; 25
26 [self setAcceptsMouseMovedEvents:YES]; 26 return self;
27 27}
28 return self; 28
29} 29- (BOOL)acceptsFirstResponder
30 30{
31- (BOOL)acceptsFirstResponder 31 return YES;
32{ 32}
33 return YES; 33
34} 34- (BOOL)canBecomeKeyWindow
35 35{
36- (BOOL)canBecomeKeyWindow 36 return YES;
37{ 37}
38 return YES; 38
39} 39- (void)windowWillClose:(NSNotification *)notification
40 40{
41- (void)windowWillClose:(NSNotification *)notification 41 NSLog(@"window is going to be closed");
42{ 42}
43 NSLog(@"window is going to be closed"); 43
44} 44@end
45 45
46- (void)windowDidResize:(NSNotification *)notification { 46#include "Ecore_Cocoa.h"
47 NSRect content_rect = [self contentRectForFrameRect:[self frame]]; 47#include "ecore_cocoa_private.h"
48 Ecore_Cocoa_Window *window = ecore_window_data; 48
49 ecore_cocoa_window_resize(window, content_rect.size.width, content_rect.size.height); 49static float _title_bar_height(void)
50 printf("THIS IS A RESIZE......................%gx%g\n", content_rect.size.width, content_rect.size.height); 50{
51} 51 NSRect frame = NSMakeRect (0, 0, 100, 100);
52 52 NSRect contentRect;
53@end 53
54 54 contentRect = [NSWindow contentRectForFrameRect: frame
55 55 styleMask: NSTitledWindowMask];
56 56
57static float _title_bar_height(void) 57 return (frame.size.height - contentRect.size.height);
58{ 58}
59 NSRect frame = NSMakeRect (0, 0, 100, 100); 59
60 NSRect contentRect; 60Ecore_Cocoa_Window *
61 61ecore_cocoa_window_new(int x,
62 contentRect = [NSWindow contentRectForFrameRect: frame 62 int y,
63 styleMask: NSTitledWindowMask]; 63 int width,
64 64 int height)
65 return (frame.size.height - contentRect.size.height); 65{
66} 66 Ecore_Cocoa_Window *w;
67 67
68Ecore_Cocoa_Window * 68 EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc]
69ecore_cocoa_window_new(int x, 69 initWithContentRect:NSMakeRect(x, y, width, height)
70 int y, 70 styleMask:(NSTitledWindowMask |
71 int width, 71 NSClosableWindowMask |
72 int height) 72 NSResizableWindowMask |
73{ 73 NSMiniaturizableWindowMask)
74 Ecore_Cocoa_Window *w; 74 backing:NSBackingStoreBuffered
75 75 defer:NO];
76 EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height) 76
77 styleMask:(NSTitledWindowMask | 77 if (!window)
78 NSClosableWindowMask | 78 return NULL;
79 NSResizableWindowMask | 79
80 NSMiniaturizableWindowMask) 80 //Set the process to be a foreground process,
81 backing:NSBackingStoreBuffered 81 //without that it prevents the window to become the key window and
82 defer:NO]; 82 //receive all mouse mouve events.
83 83 ProcessSerialNumber psn;
84 if (!window) 84 GetCurrentProcess(&psn);
85 return NULL; 85 TransformProcessType(&psn, kProcessTransformToForegroundApplication);
86 86 SetFrontProcess(&psn);
87 //Set the process to be a foreground process, 87
88 //without that it prevents the window to become the key window and 88 w = calloc(1, sizeof(Ecore_Cocoa_Window));
89 //receive all mouse mouve events. 89 w->window = window;
90 ProcessSerialNumber psn; 90 w->borderless = 0;
91 GetCurrentProcess(&psn); 91
92 TransformProcessType(&psn, kProcessTransformToForegroundApplication); 92 window.ecore_window_data = w;
93 SetFrontProcess(&psn); 93
94 94 return w;
95 w = calloc(1, sizeof(Ecore_Cocoa_Window)); 95}
96 w->window = window; 96
97 w->borderless = 0; 97void
98 98ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
99 window.ecore_window_data = w; 99{
100 100 if (!window)
101 return w; 101 return;
102} 102
103 103 [window->window release];
104void 104 free(window);
105ecore_cocoa_window_free(Ecore_Cocoa_Window *window) 105}
106{ 106
107 if (!window) 107void
108 return; 108ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
109 109 int x,
110 [window->window release]; 110 int y)
111 free(window); 111{
112} 112 NSRect win_frame;
113 113
114void 114 if (!window)
115ecore_cocoa_window_move(Ecore_Cocoa_Window *window, 115 return;
116 int x, 116
117 int y) 117 win_frame = [window->window frame];
118{ 118 win_frame.origin.x = x;
119 NSRect win_frame; 119 win_frame.origin.y = y;
120 120
121 if (!window) 121 [window->window setFrame:win_frame display:YES];
122 return; 122}
123 123
124 win_frame = [window->window frame]; 124void
125 win_frame.origin.x = x; 125ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
126 win_frame.origin.y = y; 126 int width,
127 127 int height)
128 [window->window setFrame:win_frame display:YES]; 128{
129} 129 if (!window)
130 130 return;
131void 131
132ecore_cocoa_window_resize(Ecore_Cocoa_Window *window, 132 NSRect win_frame;
133 int width, 133
134 int height) 134 if (!window)
135{ 135 return;
136 if (!window) 136
137 return; 137 win_frame = [window->window frame];
138 138 win_frame.size.height = height + _title_bar_height();
139 NSRect win_frame; 139 win_frame.size.width = width;
140 140
141 if (!window) 141 [window->window setFrame:win_frame display:YES];
142 return; 142}
143 143
144 win_frame = [window->window frame]; 144void
145 win_frame.size.height = height + _title_bar_height(); 145ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
146 win_frame.size.width = width; 146 int x,
147 printf("Resize ..............\n"); 147 int y,
148 [window->window setFrame:win_frame display:YES]; 148 int width,
149 //ecore_event_add(ECORE_COCOA_EVENT_RESIZE, NULL, NULL, NULL); 149 int height)
150} 150{
151 151 if (!window)
152void 152 return;
153ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window, 153
154 int x, 154 NSRect win_frame;
155 int y, 155
156 int width, 156 if (!window)
157 int height) 157 return;
158{ 158
159 if (!window) 159 win_frame = [window->window frame];
160 return; 160 win_frame.size.height = height + _title_bar_height();
161 161 win_frame.size.width = width;
162 NSRect win_frame; 162 win_frame.origin.x = x;
163 163 win_frame.origin.y = y;
164 if (!window) 164
165 return; 165 [window->window setFrame:win_frame display:YES];
166 166}
167 win_frame = [window->window frame]; 167
168 win_frame.size.height = height + _title_bar_height(); 168void
169 win_frame.size.width = width; 169ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title)
170 win_frame.origin.x = x; 170{
171 win_frame.origin.y = y; 171 if (!window || !title)
172 172 return;
173 [window->window setFrame:win_frame display:YES]; 173
174} 174 [window->window setTitle:[NSString stringWithUTF8String:title]];
175 175}
176void 176
177ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title) 177void
178{ 178ecore_cocoa_window_show(Ecore_Cocoa_Window *window)
179 if (!window || !title) 179{
180 return; 180 if (!window || [window->window isVisible])
181 181 {
182 [window->window setTitle:[NSString stringWithUTF8String:title]]; 182 printf("Window(%p) is not visible\n", window->window);
183} 183 return;
184 184 }
185void 185
186ecore_cocoa_window_show(Ecore_Cocoa_Window *window) 186 [window->window makeKeyAndOrderFront:NSApp];
187{ 187}
188 if (!window || [window->window isVisible]) 188
189 { 189void
190 printf("Window(%p) is not visible\n", window->window); 190ecore_cocoa_window_hide(Ecore_Cocoa_Window *window)
191 return; 191{
192 } 192 if (!window || ![window->window isVisible])
193 193 return;
194 [window->window makeKeyAndOrderFront:NSApp]; 194
195} 195 [window->window orderOut:NSApp];
196 196}
197void 197
198ecore_cocoa_window_hide(Ecore_Cocoa_Window *window) 198void
199{ 199ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
200 if (!window || ![window->window isVisible]) 200 int on)
201 return; 201{
202 202 if (!window)
203 [window->window orderOut:NSApp]; 203 return;
204} 204
205 205 if (on)
206void 206 [window->window setContentBorderThickness:0.0
207ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window, 207 forEdje:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge];
208 int on) 208}
209{ 209
210 if (!window) 210void
211 return; 211ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
212 212 void *view)
213 if (on) 213{
214 [window->window setContentBorderThickness:0.0 214 if (!window || !view)
215 forEdje:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge]; 215 return;
216} 216
217 217 //[[window->window contentView] addSubview:view];
218void 218 [window->window setContentView:view];
219ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window, 219
220 void *view) 220 NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[view frame]
221{ 221 options:NSTrackingMouseMoved |
222 if (!window || !view) 222 NSTrackingActiveInActiveApp |
223 return; 223 NSTrackingInVisibleRect
224 224 owner:view
225 //[[window->window contentView] addSubview:view]; 225 userInfo:nil];
226 [window->window setContentView:view]; 226 [view addTrackingArea:area];
227 227
228 NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[view frame] 228 [area release];
229 options:NSTrackingMouseMoved | 229}
230 NSTrackingActiveInActiveApp |
231 NSTrackingInVisibleRect
232 owner:view
233 userInfo:nil];
234 [view addTrackingArea:area];
235
236 [area release];
237}