summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@gmail.com>2014-07-10 20:04:24 +0200
committerRaoul Hecky <raoul.hecky@gmail.com>2014-07-10 20:04:24 +0200
commitbe077f079d11a2fc9b7b38fc325f897d5847a3a0 (patch)
tree8b40a0efe938522ffaa02978c2b68b0e5efaf2d7 /src/lib/ecore_cocoa
parent5a3080cd5d2788c9034bcf44f3282223a34df07e (diff)
ecore_cocoa: Introduce canvas resizing + warning fixes
Summary: Add support for canvas resizing: the window was resizable but its content was not resized. Reviewers: raster, raoulh, naguirre, cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1163
Diffstat (limited to 'src/lib/ecore_cocoa')
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa.h2
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m17
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m29
3 files changed, 42 insertions, 6 deletions
diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa.h b/src/lib/ecore_cocoa/Ecore_Cocoa.h
index 3e24a1af37..0bd8dd27f7 100644
--- a/src/lib/ecore_cocoa/Ecore_Cocoa.h
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa.h
@@ -148,6 +148,8 @@ EAPI void ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
148EAPI void ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window, 148EAPI void ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
149 void *view); 149 void *view);
150 150
151EAPI int ecore_cocoa_titlebar_height_get(void);
152
151 153
152#ifdef __cplusplus 154#ifdef __cplusplus
153} 155}
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index 856961371a..d2303e7fb9 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -351,3 +351,20 @@ ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h)
351 if (w) *w = (int)pt.width; 351 if (w) *w = (int)pt.width;
352 if (h) *h = (int)pt.height; 352 if (h) *h = (int)pt.height;
353} 353}
354
355EAPI int
356ecore_cocoa_titlebar_height_get(void)
357{
358 static int height = -1;
359
360 if (height == -1)
361 {
362 NSRect frame = NSMakeRect(0, 0, 100, 100);
363 NSRect contentRect;
364 contentRect = [NSWindow contentRectForFrameRect:frame
365 styleMask:NSTitledWindowMask];
366 height = (frame.size.height - contentRect.size.height);
367 }
368 return height;
369}
370
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index 8890107426..297a425e23 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -2,6 +2,8 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <Ecore.h>
6#include <Ecore_Cocoa.h>
5#import "ecore_cocoa_window.h" 7#import "ecore_cocoa_window.h"
6 8
7@implementation EcoreCocoaWindow 9@implementation EcoreCocoaWindow
@@ -38,11 +40,29 @@
38 40
39- (void)windowWillClose:(NSNotification *)notification 41- (void)windowWillClose:(NSNotification *)notification
40{ 42{
41 NSLog(@"window is going to be closed"); 43 NSLog(@"window is going to be closed");
44}
45
46- (void)windowDidResize:(NSNotification *)notif
47{
48 Ecore_Cocoa_Event_Video_Resize *event;
49 NSSize size = self.frame.size;
50
51 event = malloc(sizeof(Ecore_Cocoa_Event_Video_Resize));
52 if (event == NULL)
53 {
54 // FIXME Use Eina_Log
55 printf("Failed to allocate Ecore_Cocoa_Event_Video_Resize\n");
56 return;
57 }
58 event->w = size.width;
59 event->h = size.height - ecore_cocoa_titlebar_height_get();
60 ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL);
42} 61}
43 62
44@end 63@end
45 64
65
46#include "Ecore_Cocoa.h" 66#include "Ecore_Cocoa.h"
47#include "ecore_cocoa_private.h" 67#include "ecore_cocoa_private.h"
48 68
@@ -126,13 +146,10 @@ ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
126 int width, 146 int width,
127 int height) 147 int height)
128{ 148{
129 if (!window) 149 if (!window) return;
130 return;
131 150
132 NSRect win_frame; 151 NSRect win_frame;
133 152
134 if (!window)
135 return;
136 153
137 win_frame = [window->window frame]; 154 win_frame = [window->window frame];
138 win_frame.size.height = height + _title_bar_height(); 155 win_frame.size.height = height + _title_bar_height();
@@ -204,7 +221,7 @@ ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
204 221
205 if (on) 222 if (on)
206 [window->window setContentBorderThickness:0.0 223 [window->window setContentBorderThickness:0.0
207 forEdje:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge]; 224 forEdge:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge];
208} 225}
209 226
210void 227void