diff options
author | Jean Guyomarc'h <jean.guyomarch@openwide.fr> | 2016-08-26 16:35:31 +0200 |
---|---|---|
committer | Jean Guyomarc'h <jean@guyomarch.bzh> | 2016-08-26 19:05:48 +0200 |
commit | 7397b9fbe9d9fb3b810c287de8d48051c368bd8b (patch) | |
tree | 83ce6ac05419863113ec115883a027a6bc71bede /src | |
parent | 8d41099f9e75564e60cdeb7eb5188ddc02b1025d (diff) |
ecore_cocoa: refactor resizing request
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_window.h | 2 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_window.m | 37 |
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 |