summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2016-08-26 16:35:31 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-08-26 19:05:48 +0200
commit7397b9fbe9d9fb3b810c287de8d48051c368bd8b (patch)
tree83ce6ac05419863113ec115883a027a6bc71bede /src/lib/ecore_cocoa
parent8d41099f9e75564e60cdeb7eb5188ddc02b1025d (diff)
ecore_cocoa: refactor resizing request
Diffstat (limited to 'src/lib/ecore_cocoa')
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.h2
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m37
2 files changed, 24 insertions, 15 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.h b/src/lib/ecore_cocoa/ecore_cocoa_window.h
index a30240fc69..6eee03f52b 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.h
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.h
@@ -15,5 +15,7 @@
15 15
16- (BOOL)isFullScreen; 16- (BOOL)isFullScreen;
17 17
18- (BOOL) requestResize: (NSSize) size;
19
18@end 20@end
19 21
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index 08436148ca..5908b596cb 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -54,6 +54,26 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
54 return YES; 54 return YES;
55} 55}
56 56
57- (BOOL) requestResize: (NSSize) size
58{
59 Ecore_Cocoa_Event_Window_Resize_Request *event;
60
61 event = malloc(sizeof(*event));
62 if (EINA_UNLIKELY(event == NULL))
63 {
64 CRI("Failed to allocate Ecore_Cocoa_Event_Window_Resize_Request");
65 return NO;
66 }
67
68 event->w = size.width;
69 event->h = size.height -
70 (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
71 event->cocoa_window = self;
72 ecore_event_add(ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST, event, NULL, NULL);
73
74 return YES;
75}
76
57- (void)windowWillClose:(NSNotification *) notification 77- (void)windowWillClose:(NSNotification *) notification
58{ 78{
59 Ecore_Cocoa_Event_Window_Destroy *event; 79 Ecore_Cocoa_Event_Window_Destroy *event;
@@ -68,11 +88,8 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
68 ecore_event_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, event, NULL, NULL); 88 ecore_event_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, event, NULL, NULL);
69} 89}
70 90
71- (void)windowDidResize:(NSNotification *) notif 91- (void)windowDidResize:(NSNotification *) EINA_UNUSED notif
72{ 92{
73 Ecore_Cocoa_Event_Window_Resize_Request *event;
74 NSSize size = self.frame.size;
75
76 /* 93 /*
77 * Only throw a resize event and manipulate the main loop when 94 * Only throw a resize event and manipulate the main loop when
78 * we are 100% sure we are in a live resize, and the main loop 95 * we are 100% sure we are in a live resize, and the main loop
@@ -80,17 +97,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
80 */ 97 */
81 if (_live_resize > 0) 98 if (_live_resize > 0)
82 { 99 {
83 event = malloc(sizeof(*event)); 100 [self requestResize: self.frame.size];
84 if (EINA_UNLIKELY(event == NULL))
85 {
86 CRI("Failed to allocate Ecore_Cocoa_Event_Window_Resize_Request");
87 return;
88 }
89 event->w = size.width;
90 event->h = size.height -
91 (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
92 event->cocoa_window = [notif object];
93 ecore_event_add(ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST, event, NULL, NULL);
94 101
95 /* 102 /*
96 * During live resize, NSRunLoop blocks, and prevent the ecore_main_loop 103 * During live resize, NSRunLoop blocks, and prevent the ecore_main_loop