Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2014-09-18 22:24:48 +0000
committerArun Thondapu2014-10-01 14:26:57 +0000
commit4cdc1e7237ed4ed5f9297953113ca3141adaaffe (patch)
tree0ffe77428fc850e9fb46dcf66c78d9a20d204999
parente90ab2125687aa309a4ccb3b915236a2c38bbe42 (diff)
downloadeclipse.platform.swt-4cdc1e7237ed4ed5f9297953113ca3141adaaffe.tar.gz
eclipse.platform.swt-4cdc1e7237ed4ed5f9297953113ca3141adaaffe.tar.xz
eclipse.platform.swt-4cdc1e7237ed4ed5f9297953113ca3141adaaffe.zip
Bug 444303 - UI Responsiveness Monitoring produces false positives on
Mac Cocoa Replaced SWT.Sleep and SWT.Wakeup events by more general SWT.PreExternalEventDispatch and SWT.PostExternalEventDispatch events and added sending of these events in places that previously required filters. With this approach the remaining filter for Cocoa can be removed from MonitoringPreferenceInitializer. The filters on other platforms can also be removed once sendPreExternalEventDispatchEvent/sendPostExternalEventDispatchEvent calls are added to the methods that are currently listed in the filters or to the methods calling them. Change-Id: Iaca1b5e4021be40f3e9fcbb079cf99d1b6dba069 Signed-off-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java101
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java56
6 files changed, 134 insertions, 105 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
index 4a7d140896..cf3095ba42 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
@@ -1108,12 +1108,14 @@ void mouseDown(long /*int*/ id, long /*int*/ sel, long /*int*/ theEvent) {
// while the view's cell editor is open we crash while tearing down the
// popup window. Fix is to retain the view before letting Cocoa track
// the mouse events.
-
+
+ display.sendPreExternalEventDispatchEvent();
// 'view' will be cleared if disposed during the mouseDown so cache it.
NSView viewCopy = view;
viewCopy.retain();
super.mouseDown(id, sel, theEvent);
viewCopy.release();
+ display.sendPostExternalEventDispatchEvent();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 4e5e710a8d..0f7e0509e1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -4175,7 +4175,7 @@ void sendEvent (int eventType, Event event) {
event.display = this;
event.type = eventType;
if (event.time == 0) event.time = getLastEventTime ();
- sendEvent(eventTable, event);
+ sendEvent (eventTable, event);
}
void sendEvent (EventTable table, Event event) {
@@ -4183,11 +4183,11 @@ void sendEvent (EventTable table, Event event) {
sendEventCount++;
if (!filterEvent (event)) {
if (table != null) {
- sendPreEvent(event);
+ sendPreEvent (event);
try {
table.sendEvent (event);
} finally {
- sendPostEvent(event);
+ sendPostEvent (event);
}
}
}
@@ -4196,34 +4196,36 @@ void sendEvent (EventTable table, Event event) {
}
}
-void sendPreEvent(Event event) {
+void sendPreEvent (Event event) {
if (event == null || (event.type != SWT.PreEvent && event.type != SWT.PostEvent
- && event.type != SWT.Sleep && event.type != SWT.Wakeup)) {
- if (this.eventTable != null && this.eventTable.hooks(SWT.PreEvent)) {
- sendEvent(SWT.PreEvent, null);
+ && event.type != SWT.PreExternalEventDispatch
+ && event.type != SWT.PostExternalEventDispatch)) {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PreEvent)) {
+ sendEvent (SWT.PreEvent, null);
}
}
}
-void sendPostEvent(Event event) {
+void sendPostEvent (Event event) {
if (event == null || (event.type != SWT.PreEvent && event.type != SWT.PostEvent
- && event.type != SWT.Sleep && event.type != SWT.Wakeup)) {
- if (this.eventTable != null && this.eventTable.hooks(SWT.PostEvent)) {
- sendEvent(SWT.PostEvent, null);
+ && event.type != SWT.PreExternalEventDispatch
+ && event.type != SWT.PostExternalEventDispatch)) {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PostEvent)) {
+ sendEvent (SWT.PostEvent, null);
}
}
}
-void sendSleepEvent() {
- if (this.eventTable != null && this.eventTable.hooks(SWT.Sleep)) {
- sendEvent(SWT.Sleep, null);
- }
+void sendPreExternalEventDispatchEvent() {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PreExternalEventDispatch)) {
+ sendEvent (SWT.PreExternalEventDispatch, null);
+ }
}
-void sendWakeupEvent() {
- if (this.eventTable != null && this.eventTable.hooks(SWT.Wakeup)) {
- sendEvent(SWT.Wakeup, null);
- }
+void sendPostExternalEventDispatchEvent() {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PostExternalEventDispatch)) {
+ sendEvent (SWT.PostExternalEventDispatch, null);
+ }
}
static NSString getApplicationName() {
@@ -4675,7 +4677,7 @@ public void setSynchronizer (Synchronizer synchronizer) {
public boolean sleep () {
checkDevice ();
if (getMessageCount () != 0) return true;
- sendSleepEvent();
+ sendPreExternalEventDispatchEvent();
try {
addPool();
allowTimers = runAsyncMessages = false;
@@ -4684,7 +4686,7 @@ public boolean sleep () {
} finally {
removePool();
}
- sendWakeupEvent();
+ sendPostExternalEventDispatchEvent();
return true;
}
@@ -4985,37 +4987,42 @@ void applicationDidResignActive (long /*int*/ id, long /*int*/ sel, long /*int*/
long /*int*/ applicationNextEventMatchingMask (long /*int*/ id, long /*int*/ sel, long /*int*/ mask, long /*int*/ expiration, long /*int*/ mode, long /*int*/ dequeue) {
if (dequeue != 0 && trackingControl != null && !trackingControl.isDisposed()) runDeferredEvents();
- objc_super super_struct = new objc_super();
- super_struct.receiver = id;
- super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
- long /*int*/ result = OS.objc_msgSendSuper(super_struct, sel, mask, expiration, mode, dequeue != 0);
- if (result != 0) {
- /*
- * Feature of Cocoa. When an NSComboBox's items list is visible it runs an event
- * loop that will close the list in response to a processed NSApplicationDefined
- * event.
- *
- * Mozilla-style Browsers are a common source of NSApplicationDefined events that
- * will cause this to happen, which is not desirable in the context of SWT. The
- * workaround is to detect this case and to not return the event that would trigger
- * this to happen.
- */
- if (dequeue != 0 && currentCombo != null && !currentCombo.isDisposed()) {
- NSEvent nsEvent = new NSEvent(result);
- if (mozillaRunning) {
- if (nsEvent.type() == OS.NSApplicationDefined) {
- return 0;
+ sendPreExternalEventDispatchEvent();
+ try {
+ objc_super super_struct = new objc_super();
+ super_struct.receiver = id;
+ super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
+ long /*int*/ result = OS.objc_msgSendSuper(super_struct, sel, mask, expiration, mode, dequeue != 0);
+ if (result != 0) {
+ /*
+ * Feature of Cocoa. When an NSComboBox's items list is visible it runs an event
+ * loop that will close the list in response to a processed NSApplicationDefined
+ * event.
+ *
+ * Mozilla-style Browsers are a common source of NSApplicationDefined events that
+ * will cause this to happen, which is not desirable in the context of SWT. The
+ * workaround is to detect this case and to not return the event that would trigger
+ * this to happen.
+ */
+ if (dequeue != 0 && currentCombo != null && !currentCombo.isDisposed()) {
+ NSEvent nsEvent = new NSEvent(result);
+ if (mozillaRunning) {
+ if (nsEvent.type() == OS.NSApplicationDefined) {
+ return 0;
+ }
+ }
+ if (nsEvent.type() == OS.NSKeyDown) {
+ currentCombo.sendTrackingKeyEvent(nsEvent, SWT.KeyDown);
}
}
- if (nsEvent.type() == OS.NSKeyDown) {
- currentCombo.sendTrackingKeyEvent(nsEvent, SWT.KeyDown);
+ if (dequeue != 0 && trackingControl != null && !trackingControl.isDisposed()) {
+ applicationSendTrackingEvent(new NSEvent(result), trackingControl);
}
}
- if (dequeue != 0 && trackingControl != null && !trackingControl.isDisposed()) {
- applicationSendTrackingEvent(new NSEvent(result), trackingControl);
- }
+ return result;
+ } finally {
+ sendPostExternalEventDispatchEvent();
}
- return result;
}
void applicationSendTrackingEvent (NSEvent nsEvent, Control trackingControl) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index 38ce5a398c..d196bec5b7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -794,26 +794,42 @@ public class SWT {
public static final int PostEvent = 51;
/**
- * The Sleep event type (value is 52).
+ * The PreExternalEventDispatch event type (value is 52).
*
* <p>
- * This event is sent before Display.sleep goes into an interruptible sleep.
+ * This event is sent before calling a blocking method that does its own event dispatch outside
+ * of the SWT code.
* </p>
*
- * @since 3.103
+ * @since 3.104
*/
- public static final int Sleep = 52;
+ public static final int PreExternalEventDispatch = 52;
/**
- * The Wakeup event type (value is 53).
+ * The PostExternalEventDispatch event type (value is 53).
*
* <p>
- * This event is sent after Display.sleep wakes up from an interruptible sleep.
+ * This event is sent after calling a blocking method that does its own event dispatch outside
+ * of the SWT code.
* </p>
*
+ * @since 3.104
+ */
+ public static final int PostExternalEventDispatch = 53;
+
+ /**
+ * @deprecated The same as PreExternalEventDispatch (value is 52).
+ * @since 3.103
+ */
+ @Deprecated
+ public static final int Sleep = PreExternalEventDispatch;
+
+ /**
+ * @deprecated The same as PostExternalEventDispatch (value is 53).
* @since 3.103
*/
- public static final int Wakeup = 53;
+ @Deprecated
+ public static final int Wakeup = PostExternalEventDispatch;
/* Event Details */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index de4e560e25..24a88c6522 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -2332,16 +2332,16 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
* half a second.
*/
long timeout = System.currentTimeMillis() + 500;
+ display.sendPreExternalEventDispatchEvent();
while (System.currentTimeMillis() < timeout) {
eventPtr = OS.gdk_event_get ();
if (eventPtr != 0) {
break;
} else {
- display.sendSleepEvent();
try {Thread.sleep(50);} catch (Exception ex) {}
- display.sendWakeupEvent();
}
}
+ display.sendPostExternalEventDispatchEvent();
if (eventPtr == 0) return dragOnTimeout;
switch (OS.GDK_EVENT_TYPE (eventPtr)) {
case OS.GDK_MOTION_NOTIFY: {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index e93dbf0a49..bab40d62b6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -4268,7 +4268,7 @@ public boolean sleep () {
return false;
}
if (getMessageCount () != 0) return true;
- sendSleepEvent();
+ sendPreExternalEventDispatchEvent ();
if (fds == 0) {
allocated_nfds = 2;
fds = OS.g_malloc (OS.GPollFD_sizeof () * allocated_nfds);
@@ -4313,7 +4313,7 @@ public boolean sleep () {
}
} while (!result && getMessageCount () == 0 && !wake);
wake = false;
- sendWakeupEvent();
+ sendPostExternalEventDispatchEvent ();
return true;
}
@@ -4454,47 +4454,49 @@ void sendEvent (int eventType, Event event) {
event.type = eventType;
if (event.time == 0) event.time = getLastEventTime ();
if (!filterEvent (event)) {
- if (eventTable != null) sendEvent(eventTable, event);
+ if (eventTable != null) sendEvent (eventTable, event);
}
}
-void sendEvent(EventTable eventTable, Event event) {
- sendPreEvent(event);
+void sendEvent (EventTable eventTable, Event event) {
+ sendPreEvent (event);
try {
eventTable.sendEvent (event);
} finally {
- sendPostEvent(event);
+ sendPostEvent (event);
}
}
void sendPreEvent(Event event) {
if (event == null || (event.type != SWT.PreEvent && event.type != SWT.PostEvent
- && event.type != SWT.Sleep && event.type != SWT.Wakeup)) {
- if (this.eventTable != null && this.eventTable.hooks(SWT.PreEvent)) {
- sendEvent(SWT.PreEvent, null);
+ && event.type != SWT.PreExternalEventDispatch
+ && event.type != SWT.PostExternalEventDispatch)) {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PreEvent)) {
+ sendEvent (SWT.PreEvent, null);
}
}
}
void sendPostEvent(Event event) {
if (event == null || (event.type != SWT.PreEvent && event.type != SWT.PostEvent
- && event.type != SWT.Sleep && event.type != SWT.Wakeup)) {
- if (this.eventTable != null && this.eventTable.hooks(SWT.PostEvent)) {
- sendEvent(SWT.PostEvent, null);
+ && event.type != SWT.PreExternalEventDispatch
+ && event.type != SWT.PostExternalEventDispatch)) {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PostEvent)) {
+ sendEvent (SWT.PostEvent, null);
}
}
}
-void sendSleepEvent() {
- if (this.eventTable != null && this.eventTable.hooks(SWT.Sleep)) {
- sendEvent(SWT.Sleep, null);
- }
+void sendPreExternalEventDispatchEvent() {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PreExternalEventDispatch)) {
+ sendEvent(SWT.PreExternalEventDispatch, null);
+ }
}
-void sendWakeupEvent() {
- if (this.eventTable != null && this.eventTable.hooks(SWT.Wakeup)) {
- sendEvent(SWT.Wakeup, null);
- }
+void sendPostExternalEventDispatchEvent() {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PostExternalEventDispatch)) {
+ sendEvent (SWT.PostExternalEventDispatch, null);
+ }
}
void setCurrentCaret (Caret caret) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index e5d7894009..66da49a85b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are responsible for managing the
@@ -1380,7 +1380,7 @@ public Widget findWidget (Widget widget, long /*int*/ id) {
long /*int*/ foregroundIdleProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lParam) {
if (code >= 0) {
if (runMessages && getMessageCount () != 0) {
- sendWakeupEvent();
+ sendPostExternalEventDispatchEvent ();
if (runMessagesInIdle) {
if (runMessagesInMessageProc) {
OS.PostMessage (hwndMessage, SWT_RUNASYNC, 0, 0);
@@ -1404,7 +1404,7 @@ long /*int*/ foregroundIdleProc (long /*int*/ code, long /*int*/ wParam, long /*
MSG msg = new MSG();
int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT;
if (!OS.PeekMessage (msg, 0, 0, 0, flags)) wakeThread ();
- sendSleepEvent();
+ sendPreExternalEventDispatchEvent ();
}
}
return OS.CallNextHookEx (idleHook, (int)/*64*/code, wParam, lParam);
@@ -4343,47 +4343,49 @@ void sendEvent (int eventType, Event event) {
event.type = eventType;
if (event.time == 0) event.time = getLastEventTime ();
if (!filterEvent (event)) {
- if (eventTable != null) sendEvent(eventTable, event);
+ if (eventTable != null) sendEvent (eventTable, event);
}
}
-void sendEvent(EventTable eventTable, Event event) {
- sendPreEvent(event);
+void sendEvent (EventTable eventTable, Event event) {
+ sendPreEvent (event);
try {
eventTable.sendEvent (event);
} finally {
- sendPostEvent(event);
+ sendPostEvent (event);
}
}
-void sendPreEvent(Event event) {
+void sendPreEvent (Event event) {
if (event == null || (event.type != SWT.PreEvent && event.type != SWT.PostEvent
- && event.type != SWT.Sleep && event.type != SWT.Wakeup)) {
- if (this.eventTable != null && this.eventTable.hooks(SWT.PreEvent)) {
- sendEvent(SWT.PreEvent, null);
+ && event.type != SWT.PreExternalEventDispatch
+ && event.type != SWT.PostExternalEventDispatch)) {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PreEvent)) {
+ sendEvent (SWT.PreEvent, null);
}
}
}
-void sendPostEvent(Event event) {
+void sendPostEvent (Event event) {
if (event == null || (event.type != SWT.PreEvent && event.type != SWT.PostEvent
- && event.type != SWT.Sleep && event.type != SWT.Wakeup)) {
- if (this.eventTable != null && this.eventTable.hooks(SWT.PostEvent)) {
- sendEvent(SWT.PostEvent, null);
+ && event.type != SWT.PreExternalEventDispatch
+ && event.type != SWT.PostExternalEventDispatch)) {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PostEvent)) {
+ sendEvent (SWT.PostEvent, null);
}
}
}
-void sendSleepEvent() {
- if (this.eventTable != null && this.eventTable.hooks(SWT.Sleep)) {
- sendEvent(SWT.Sleep, null);
- }
+void sendPreExternalEventDispatchEvent () {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PreExternalEventDispatch)) {
+ sendEvent (SWT.PreExternalEventDispatch, null);
+ }
}
-void sendWakeupEvent() {
- if (this.eventTable != null && this.eventTable.hooks(SWT.Wakeup)) {
- sendEvent(SWT.Wakeup, null);
- }
+void sendPostExternalEventDispatchEvent() {
+ if (this.eventTable != null && this.eventTable.hooks (SWT.PostExternalEventDispatch)) {
+ sendEvent (SWT.PostExternalEventDispatch, null);
+ }
}
/**
@@ -4694,14 +4696,14 @@ int shiftedKey (int key) {
public boolean sleep () {
checkDevice ();
if (runMessages && getMessageCount () != 0) return true;
- sendSleepEvent();
+ sendPreExternalEventDispatchEvent ();
if (OS.IsWinCE) {
OS.MsgWaitForMultipleObjectsEx (0, 0, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE);
- sendWakeupEvent();
+ sendPostExternalEventDispatchEvent();
return true;
}
boolean result = OS.WaitMessage ();
- sendWakeupEvent();
+ sendPostExternalEventDispatchEvent ();
return result;
}

Back to the top