summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2015-10-16 10:19:57 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-10 08:32:49 +0100
commit3f1114d829882a50d924335f7e14c7637034f99f (patch)
treefda18555c1c02738c723f874ff9bd68996090a1c
parent1811704a904dd4ceb1f36c958624064bd3f54ad6 (diff)
ecore_cocoa: fix live resize of windows
This was a tricky little bastard! When a window is live resized, the NSWindow which is the target of the live resize will wait for a kevent from the window manager, until live resizing is done. So... live resizing is synchronous and blocks the main thread... hence ecore_main_loop. - When live resize starts, the Ecore_Timer which polls NSRunLoop is paused. - When the window is resized, the ecore_main_loop is run manually with ecore_main_loop_iterate() to process Ecore events (mostly Ecore_Evas) - When live resize finished, the Ecore_Timer which polls NSRunLoop is resumed. @fix
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_app.h3
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_app.m15
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m22
3 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_app.h b/src/lib/ecore_cocoa/ecore_cocoa_app.h
index 3e206395c3..0cc01615af 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_app.h
+++ b/src/lib/ecore_cocoa/ecore_cocoa_app.h
@@ -18,6 +18,9 @@
18- (id)init; 18- (id)init;
19- (void)internalUpdate; 19- (void)internalUpdate;
20 20
21- (void) pauseNSRunLoopMonitoring;
22- (void) resumeNSRunLoopMonitoring;
23
21@end 24@end
22 25
23 26
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_app.m b/src/lib/ecore_cocoa/ecore_cocoa_app.m
index e7598abd25..066d29f12e 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_app.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_app.m
@@ -95,6 +95,21 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED)
95 [super sendEvent:anEvent]; 95 [super sendEvent:anEvent];
96} 96}
97 97
98- (void) pauseNSRunLoopMonitoring
99{
100 /*
101 * After calling this method, we will run an iteration of
102 * the main loop. We don't want this timer to be fired while
103 * calling manually the ecore loop, because it will query the
104 * NSRunLoop, which blocks during live resize.
105 */
106 ecore_timer_freeze(_timer);
107}
108
109- (void) resumeNSRunLoopMonitoring
110{
111 ecore_timer_thaw(_timer);
112}
98 113
99@end 114@end
100 115
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index e4c904e02e..25a7c58c5a 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -8,6 +8,7 @@
8#include <Ecore_Cocoa.h> 8#include <Ecore_Cocoa.h>
9#include <Ecore_Cocoa_Cursor.h> 9#include <Ecore_Cocoa_Cursor.h>
10#import "ecore_cocoa_window.h" 10#import "ecore_cocoa_window.h"
11#import "ecore_cocoa_app.h"
11#include "ecore_cocoa_private.h" 12#include "ecore_cocoa_private.h"
12 13
13static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST]; 14static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
@@ -83,6 +84,17 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
83 (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get()); 84 (([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
84 event->wid = [notif object]; 85 event->wid = [notif object];
85 ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL); 86 ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL);
87
88 /*
89 * During live resize, NSRunLoop blocks, and prevent the ecore_main_loop
90 * to be run.
91 * This, combined with the -pauseNSRunLoopMonitoring and
92 * -resumeNSRunLoopMonitoring methods invoked in
93 * -windowWillStartLiveResize and -windowDidEndLiveResize
94 * allow the ecore_main_loop to run withing NSRunLoop during the
95 * live resizing of a window.
96 */
97 ecore_main_loop_iterate();
86} 98}
87 99
88- (void)windowDidBecomeKey:(NSNotification *)notification 100- (void)windowDidBecomeKey:(NSNotification *)notification
@@ -99,6 +111,16 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
99 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL); 111 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL);
100} 112}
101 113
114- (void) windowWillStartLiveResize:(NSNotification *) EINA_UNUSED notification
115{
116 [NSApp pauseNSRunLoopMonitoring];
117}
118
119- (void) windowDidEndLiveResize:(NSNotification *) EINA_UNUSED notification
120{
121 [NSApp resumeNSRunLoopMonitoring];
122}
123
102- (void)windowDidResignKey:(NSNotification *)notification 124- (void)windowDidResignKey:(NSNotification *)notification
103{ 125{
104 Ecore_Cocoa_Event_Window *e; 126 Ecore_Cocoa_Event_Window *e;