summaryrefslogtreecommitdiff
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
parent8d41099f9e75564e60cdeb7eb5188ddc02b1025d (diff)
downloadefl-7397b9fbe9d9fb3b810c287de8d48051c368bd8b.tar.gz
ecore_cocoa: refactor resizing request
-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 @@
- (BOOL)isFullScreen;
+- (BOOL) requestResize: (NSSize) size;
+
@end
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];
return YES;
}
+- (BOOL) requestResize: (NSSize) size
+{
+ Ecore_Cocoa_Event_Window_Resize_Request *event;
+
+ event = malloc(sizeof(*event));
+ if (EINA_UNLIKELY(event == NULL))
+ {
+ CRI("Failed to allocate Ecore_Cocoa_Event_Window_Resize_Request");
+ return NO;
+ }
+
+ event->w = size.width;
+ event->h = size.height -
+ (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
+ event->cocoa_window = self;
+ ecore_event_add(ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST, event, NULL, NULL);
+
+ return YES;
+}
+
- (void)windowWillClose:(NSNotification *) notification
{
Ecore_Cocoa_Event_Window_Destroy *event;
@@ -68,11 +88,8 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
ecore_event_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, event, NULL, NULL);
}
-- (void)windowDidResize:(NSNotification *) notif
+- (void)windowDidResize:(NSNotification *) EINA_UNUSED notif
{
- Ecore_Cocoa_Event_Window_Resize_Request *event;
- NSSize size = self.frame.size;
-
/*
* Only throw a resize event and manipulate the main loop when
* 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];
*/
if (_live_resize > 0)
{
- event = malloc(sizeof(*event));
- if (EINA_UNLIKELY(event == NULL))
- {
- CRI("Failed to allocate Ecore_Cocoa_Event_Window_Resize_Request");
- return;
- }
- event->w = size.width;
- event->h = size.height -
- (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
- event->cocoa_window = [notif object];
- ecore_event_add(ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST, event, NULL, NULL);
+ [self requestResize: self.frame.size];
/*
* During live resize, NSRunLoop blocks, and prevent the ecore_main_loop