diff options
author | Raoul Hecky <raoul.hecky@gmail.com> | 2014-06-08 21:50:42 +0200 |
---|---|---|
committer | Cedric BAIL <c.bail@partner.samsung.com> | 2014-06-18 11:34:07 +0200 |
commit | 6f2d060c80b980db44e78e958bca06b1c372780c (patch) | |
tree | cf608dc92a966fc8ff60c3e097925b2be81156b5 | |
parent | fc4d108b5f7aa6397d482ca5a575456b3cdf314f (diff) | |
download | efl-6f2d060c80b980db44e78e958bca06b1c372780c.tar.gz |
ecore_cocoa: add code from old branch
-rw-r--r-- | src/lib/ecore_cocoa/Ecore_Cocoa.h | 9 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h | 12 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa.m | 218 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_window.m | 466 |
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" { #endif typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window; +typedef struct _Ecore_Cocoa_Screen Ecore_Cocoa_Screen; EAPI extern int ECORE_COCOA_EVENT_GOT_FOCUS; EAPI extern int ECORE_COCOA_EVENT_LOST_FOCUS; @@ -43,6 +44,10 @@ struct _Ecore_Cocoa_Event_Video_Resize int h; }; +struct _Ecore_Cocoa_Screen +{ + int dummy; +}; /* Core */ @@ -50,6 +55,10 @@ EAPI int ecore_cocoa_init(void); EAPI int ecore_cocoa_shutdown(void); EAPI void ecore_cocoa_feed_events(void); +/* Screen */ + +EAPI void ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h); + /* Window */ EAPI 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[] = { 0, "0x00", "" }, { 0, "First", "" }, { 3, "Return", "\015" }, -// OS-X's backspace and Delete are reversed! -{ 8, "Delete", "\010" }, +{ 8, "Delete", "\010" }, { 9, "Tab", "\011" }, { 12, "Clear", "" }, { 13, "Return", "\015" }, @@ -91,11 +90,10 @@ static const struct _ecore_cocoa_keys_s keystable[] = { 123, "braceleft", "" }, { 124, "pipe", "" }, { 125, "braceright", "" }, -// OS-X's backspace and Delete are reversed! -{ 127, "BackSpace", "\177" }, +{ 127, "BackSpace", "\177" }, { 126, "asciitilde", "~" }, -{ 160, "w0", "" }, +{ 160, "w0", "" }, { 161, "w1", "" }, { 162, "w2", "" }, { 163, "w3", "" }, @@ -259,8 +257,8 @@ static const struct _ecore_cocoa_keys_s keystable[] = { NSClearLineFunctionKey, "Num_Lock", "" }, { 301, "Caps_Lock", "" }, { NSScrollLockFunctionKey, "Scroll_Lock", "" }, -{ 303, "Shift_R", "" }, -{ 304, "Shift_L", "" }, +{ 303, "Shift_R", "Shift_R" }, +{ 304, "Shift_L", "Shift_L" }, { 305, "Control_R", "" }, { 306, "Control_L", "" }, { 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 @@ # include <config.h> #endif -#include <Cocoa/Cocoa.h> +#import <Cocoa/Cocoa.h> +#import "ecore_cocoa_window.h" #include <Eina.h> @@ -23,54 +24,6 @@ static int _ecore_cocoa_init_count = 0; static int old_flags; -static unsigned int -_ecore_cocoa_event_modifiers(int mod) -{ - unsigned int modifiers = 0; - - if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT; - if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL; - if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALT; - if(mod & NSAlphaShiftKeyMask) modifiers |= ECORE_EVENT_LOCK_CAPS; - - return modifiers; -} - -static Ecore_Event_Key* -_ecore_cocoa_event_key(NSEvent *nsevent, double timestamp) -{ - Ecore_Event_Key *ev; - unsigned int i; - int flags = [nsevent modifierFlags]; - - ev = malloc(sizeof(Ecore_Event_Key)); - if (!ev) return NULL; - - ev->timestamp = timestamp; - ev->window = 0; - ev->event_window = 0; - ev->modifiers = _ecore_cocoa_event_modifiers(flags); - ev->key = NULL; - ev->compose = NULL; - - printf("key code : %d\n", [[nsevent charactersIgnoringModifiers] characterAtIndex:0]); - - for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i) - if (keystable[i].code == [[nsevent charactersIgnoringModifiers] characterAtIndex:0]) - { - printf("keycode : %d key pressed : %s\n", keystable[i].code, keystable[i].name); - ev->keyname = keystable[i].name; - ev->key = ev->keyname; - ev->string = keystable[i].compose; - - return ev; - } - free(ev); - return NULL; -} - - - EAPI int ecore_cocoa_init(void) { @@ -107,9 +60,25 @@ ecore_cocoa_shutdown(void) return _ecore_cocoa_init_count; } +static unsigned int +_ecore_cocoa_event_modifiers(unsigned int mod) +{ + unsigned int modifiers = 0; + + if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT; + if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL; + if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALT; + if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN; + if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM; + + printf("key modifiers: %d, %d\n", mod, modifiers); + return modifiers; +} + EAPI void ecore_cocoa_feed_events(void) { + Ecore_Event *ev; NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0.001]; NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:date @@ -139,7 +108,8 @@ ecore_cocoa_feed_events(void) ev->root.x = ev->x; ev->root.y = ev->y; ev->timestamp = time; - ev->window = [event window]; + ev->window = window.ecore_window_data; + ev->event_window = ev->window; ev->modifiers = 0; /* FIXME: keep modifier around. */ ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); @@ -163,15 +133,13 @@ ecore_cocoa_feed_events(void) ev->root.x = ev->x; ev->root.y = ev->y; ev->timestamp = time; - - if ([event buttonNumber] == 0) - ev->buttons = 1; - else if ([event buttonNumber] == 2) - ev->buttons = 2; - else - ev->buttons = 3; - - printf("ev buttons : %d - %d\n", ev->buttons, [event buttonNumber]); + switch ([event buttonNumber]) + { + case 0: ev->buttons = 1; break; + case 1: ev->buttons = 3; break; + case 2: ev->buttons = 2; break; + default: ev->buttons = 0; break; + } ev->window = window.ecore_window_data; ev->event_window = ev->window; @@ -206,14 +174,13 @@ ecore_cocoa_feed_events(void) ev->root.x = ev->x; ev->root.y = ev->y; ev->timestamp = time; - - if ([event buttonNumber] == 0) - ev->buttons = 1; - else if ([event buttonNumber] == 2) - ev->buttons = 2; - else - ev->buttons = 3; - + switch ([event buttonNumber]) + { + case 0: ev->buttons = 1; break; + case 1: ev->buttons = 3; break; + case 2: ev->buttons = 2; break; + default: ev->buttons = 0; break; + } ev->window = window.ecore_window_data; ev->event_window = ev->window; @@ -235,60 +202,117 @@ ecore_cocoa_feed_events(void) case NSKeyDown: { Ecore_Event_Key *ev; + unsigned int i; EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; - ev = _ecore_cocoa_event_key(event, time); + ev = calloc(1, sizeof (Ecore_Event_Key)); if (!ev) return; + ev->timestamp = time; + ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]); - ev->window = window.ecore_window_data; - ev->event_window = ev->window; - ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); + for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i) + { + if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0])) + { + printf("Key pressed : %s\n", keystable[i].name); + ev->keyname = keystable[i].name; + ev->key = keystable[i].name; + ev->string = keystable[i].compose; + ev->window = window.ecore_window_data; + ev->event_window = ev->window; + ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); + return; + } + } break; } case NSKeyUp: { Ecore_Event_Key *ev; + unsigned int i; EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; - ev = _ecore_cocoa_event_key(event, time); + printf("Key Up\n"); + + ev = calloc(1, sizeof (Ecore_Event_Key)); if (!ev) return; + ev->timestamp = time; + ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]); - ev->window = window.ecore_window_data; - ev->event_window = ev->window; - ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); + for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i) + { + if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0])) + { + ev->keyname = keystable[i].name; + ev->key = keystable[i].name; + ev->string = keystable[i].compose; + ev->window = window.ecore_window_data; + ev->event_window = ev->window; + ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); + return; + } + } break; } case NSFlagsChanged: { - int flags = [event modifierFlags]; - EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; - Ecore_Event_Key *ev; - ev = calloc(1, sizeof(Ecore_Event_Key)); - if (!ev) return; + Ecore_Event_Key *evDown = NULL; + Ecore_Event_Key *evUp = NULL; + evDown = calloc(1, sizeof (Ecore_Event_Key)); + if (!evDown) return; + + evUp = calloc(1, sizeof (Ecore_Event_Key)); + if (!evUp) + { + free(evDown); + return; + } + + // Turn special key flags on if (flags & NSShiftKeyMask) - ev->keyname = "Shift_L"; + evDown->keyname = "Shift_L"; else if (flags & NSControlKeyMask) - ev->keyname = "Control_L"; + evDown->keyname = "Control_L"; else if (flags & NSAlternateKeyMask) - ev->keyname = "Alt_L"; + evDown->keyname = "Alt_L"; else if (flags & NSCommandKeyMask) - ev->keyname = "Super_L"; + evDown->keyname = "Super_L"; else if (flags & NSAlphaShiftKeyMask) - ev->keyname = "Caps_Lock"; + evDown->keyname = "Caps_Lock"; + + if (evDown->keyname) + { + evDown->timestamp = time; + evDown->string = ""; + ecore_event_add(ECORE_EVENT_KEY_DOWN, evDown, NULL, NULL); + old_flags = flags; + break; + } - if (ev->keyname) + int changed_flags = flags ^ old_flags; + + // Turn special key flags off + if (changed_flags & NSShiftKeyMask) + evUp->keyname = "Shift_L"; + else if (changed_flags & NSControlKeyMask) + evUp->keyname = "Control_L"; + else if (changed_flags & NSAlternateKeyMask) + evUp->keyname = "Alt_L"; + else if (changed_flags & NSCommandKeyMask) + evUp->keyname = "Super_L"; + else if (changed_flags & NSAlphaShiftKeyMask) + evUp->keyname = "Caps_Lock"; + + if (evUp->keyname) { - ev->key = ev->keyname; - ev->timestamp = time; - ev->string = ""; - ev->modifiers = _ecore_cocoa_event_modifiers(flags); - printf("Flags changed keyup\n"); - ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); + evUp->timestamp = time; + evUp->string = ""; + ecore_event_add(ECORE_EVENT_KEY_UP, evUp, NULL, NULL); old_flags = flags; break; } @@ -306,6 +330,7 @@ ecore_cocoa_feed_events(void) } case NSScrollWheel: { + printf("Scroll Wheel\n"); break; } default: @@ -317,3 +342,12 @@ ecore_cocoa_feed_events(void) [event release]; } + +EAPI void +ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h) +{ + NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size; + + if (w) *w = (int)pt.width; + if (h) *h = (int)pt.height; +} 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 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#import "ecore_cocoa_window.h" -#include "Ecore_Cocoa.h" -#include "ecore_cocoa_private.h" - -@implementation EcoreCocoaWindow - -@synthesize ecore_window_data; - -- (id) initWithContentRect: (NSRect) contentRect - styleMask: (unsigned int) aStyle - backing: (NSBackingStoreType) bufferingType - defer: (BOOL) flag -{ - if (![super initWithContentRect: contentRect - styleMask: aStyle - backing: bufferingType - defer: flag]) return nil; - - [self setBackgroundColor: [NSColor whiteColor]]; - [self makeKeyWindow]; - [self setDelegate:self]; - [self setAcceptsMouseMovedEvents:YES]; - - return self; -} - -- (BOOL)acceptsFirstResponder -{ - return YES; -} - -- (BOOL)canBecomeKeyWindow -{ - return YES; -} - -- (void)windowWillClose:(NSNotification *)notification -{ - NSLog(@"window is going to be closed"); -} - -- (void)windowDidResize:(NSNotification *)notification { - NSRect content_rect = [self contentRectForFrameRect:[self frame]]; - Ecore_Cocoa_Window *window = ecore_window_data; - ecore_cocoa_window_resize(window, content_rect.size.width, content_rect.size.height); - printf("THIS IS A RESIZE......................%gx%g\n", content_rect.size.width, content_rect.size.height); -} - -@end - - - -static float _title_bar_height(void) -{ - NSRect frame = NSMakeRect (0, 0, 100, 100); - NSRect contentRect; - - contentRect = [NSWindow contentRectForFrameRect: frame - styleMask: NSTitledWindowMask]; - - return (frame.size.height - contentRect.size.height); -} - -Ecore_Cocoa_Window * -ecore_cocoa_window_new(int x, - int y, - int width, - int height) -{ - Ecore_Cocoa_Window *w; - - EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height) - styleMask:(NSTitledWindowMask | - NSClosableWindowMask | - NSResizableWindowMask | - NSMiniaturizableWindowMask) - backing:NSBackingStoreBuffered - defer:NO]; - - if (!window) - return NULL; - - //Set the process to be a foreground process, - //without that it prevents the window to become the key window and - //receive all mouse mouve events. - ProcessSerialNumber psn; - GetCurrentProcess(&psn); - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - SetFrontProcess(&psn); - - w = calloc(1, sizeof(Ecore_Cocoa_Window)); - w->window = window; - w->borderless = 0; - - window.ecore_window_data = w; - - return w; -} - -void -ecore_cocoa_window_free(Ecore_Cocoa_Window *window) -{ - if (!window) - return; - - [window->window release]; - free(window); -} - -void -ecore_cocoa_window_move(Ecore_Cocoa_Window *window, - int x, - int y) -{ - NSRect win_frame; - - if (!window) - return; - - win_frame = [window->window frame]; - win_frame.origin.x = x; - win_frame.origin.y = y; - - [window->window setFrame:win_frame display:YES]; -} - -void -ecore_cocoa_window_resize(Ecore_Cocoa_Window *window, - int width, - int height) -{ - if (!window) - return; - - NSRect win_frame; - - if (!window) - return; - - win_frame = [window->window frame]; - win_frame.size.height = height + _title_bar_height(); - win_frame.size.width = width; - printf("Resize ..............\n"); - [window->window setFrame:win_frame display:YES]; - //ecore_event_add(ECORE_COCOA_EVENT_RESIZE, NULL, NULL, NULL); -} - -void -ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window, - int x, - int y, - int width, - int height) -{ - if (!window) - return; - - NSRect win_frame; - - if (!window) - return; - - win_frame = [window->window frame]; - win_frame.size.height = height + _title_bar_height(); - win_frame.size.width = width; - win_frame.origin.x = x; - win_frame.origin.y = y; - - [window->window setFrame:win_frame display:YES]; -} - -void -ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title) -{ - if (!window || !title) - return; - - [window->window setTitle:[NSString stringWithUTF8String:title]]; -} - -void -ecore_cocoa_window_show(Ecore_Cocoa_Window *window) -{ - if (!window || [window->window isVisible]) - { - printf("Window(%p) is not visible\n", window->window); - return; - } - - [window->window makeKeyAndOrderFront:NSApp]; -} - -void -ecore_cocoa_window_hide(Ecore_Cocoa_Window *window) -{ - if (!window || ![window->window isVisible]) - return; - - [window->window orderOut:NSApp]; -} - -void -ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window, - int on) -{ - if (!window) - return; - - if (on) - [window->window setContentBorderThickness:0.0 - forEdje:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge]; -} - -void -ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window, - void *view) -{ - if (!window || !view) - return; - - //[[window->window contentView] addSubview:view]; - [window->window setContentView:view]; - - NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[view frame] - options:NSTrackingMouseMoved | - NSTrackingActiveInActiveApp | - NSTrackingInVisibleRect - owner:view - userInfo:nil]; - [view addTrackingArea:area]; - - [area release]; -} +#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#import "ecore_cocoa_window.h"
+
+@implementation EcoreCocoaWindow
+
+@synthesize ecore_window_data;
+
+- (id) initWithContentRect: (NSRect) contentRect
+ styleMask: (unsigned int) aStyle
+ backing: (NSBackingStoreType) bufferingType
+ defer: (BOOL) flag
+{
+ if (![super initWithContentRect: contentRect
+ styleMask: aStyle
+ backing: bufferingType
+ defer: flag]) return nil;
+
+ [self setBackgroundColor: [NSColor whiteColor]];
+ [self makeKeyWindow];
+ [self setDelegate:self];
+ [self setAcceptsMouseMovedEvents:YES];
+
+ return self;
+}
+
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
+- (BOOL)canBecomeKeyWindow
+{
+ return YES;
+}
+
+- (void)windowWillClose:(NSNotification *)notification
+{
+ NSLog(@"window is going to be closed");
+}
+
+@end
+
+#include "Ecore_Cocoa.h"
+#include "ecore_cocoa_private.h"
+
+static float _title_bar_height(void)
+{
+ NSRect frame = NSMakeRect (0, 0, 100, 100);
+ NSRect contentRect;
+
+ contentRect = [NSWindow contentRectForFrameRect: frame
+ styleMask: NSTitledWindowMask];
+
+ return (frame.size.height - contentRect.size.height);
+}
+
+Ecore_Cocoa_Window *
+ecore_cocoa_window_new(int x,
+ int y,
+ int width,
+ int height)
+{
+ Ecore_Cocoa_Window *w;
+
+ EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc]
+ initWithContentRect:NSMakeRect(x, y, width, height)
+ styleMask:(NSTitledWindowMask |
+ NSClosableWindowMask |
+ NSResizableWindowMask |
+ NSMiniaturizableWindowMask)
+ backing:NSBackingStoreBuffered
+ defer:NO];
+
+ if (!window)
+ return NULL;
+
+ //Set the process to be a foreground process,
+ //without that it prevents the window to become the key window and
+ //receive all mouse mouve events.
+ ProcessSerialNumber psn;
+ GetCurrentProcess(&psn);
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ SetFrontProcess(&psn);
+
+ w = calloc(1, sizeof(Ecore_Cocoa_Window));
+ w->window = window;
+ w->borderless = 0;
+
+ window.ecore_window_data = w;
+
+ return w;
+}
+
+void
+ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
+{
+ if (!window)
+ return;
+
+ [window->window release];
+ free(window);
+}
+
+void
+ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
+ int x,
+ int y)
+{
+ NSRect win_frame;
+
+ if (!window)
+ return;
+
+ win_frame = [window->window frame];
+ win_frame.origin.x = x;
+ win_frame.origin.y = y;
+
+ [window->window setFrame:win_frame display:YES];
+}
+
+void
+ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
+ int width,
+ int height)
+{
+ if (!window)
+ return;
+
+ NSRect win_frame;
+
+ if (!window)
+ return;
+
+ win_frame = [window->window frame];
+ win_frame.size.height = height + _title_bar_height();
+ win_frame.size.width = width;
+
+ [window->window setFrame:win_frame display:YES];
+}
+
+void
+ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ if (!window)
+ return;
+
+ NSRect win_frame;
+
+ if (!window)
+ return;
+
+ win_frame = [window->window frame];
+ win_frame.size.height = height + _title_bar_height();
+ win_frame.size.width = width;
+ win_frame.origin.x = x;
+ win_frame.origin.y = y;
+
+ [window->window setFrame:win_frame display:YES];
+}
+
+void
+ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title)
+{
+ if (!window || !title)
+ return;
+
+ [window->window setTitle:[NSString stringWithUTF8String:title]];
+}
+
+void
+ecore_cocoa_window_show(Ecore_Cocoa_Window *window)
+{
+ if (!window || [window->window isVisible])
+ {
+ printf("Window(%p) is not visible\n", window->window);
+ return;
+ }
+
+ [window->window makeKeyAndOrderFront:NSApp];
+}
+
+void
+ecore_cocoa_window_hide(Ecore_Cocoa_Window *window)
+{
+ if (!window || ![window->window isVisible])
+ return;
+
+ [window->window orderOut:NSApp];
+}
+
+void
+ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
+ int on)
+{
+ if (!window)
+ return;
+
+ if (on)
+ [window->window setContentBorderThickness:0.0
+ forEdje:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge];
+}
+
+void
+ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
+ void *view)
+{
+ if (!window || !view)
+ return;
+
+ //[[window->window contentView] addSubview:view];
+ [window->window setContentView:view];
+
+ NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[view frame]
+ options:NSTrackingMouseMoved |
+ NSTrackingActiveInActiveApp |
+ NSTrackingInVisibleRect
+ owner:view
+ userInfo:nil];
+ [view addTrackingArea:area];
+
+ [area release];
+}
|