|
|
42 |
#include "ClientLayerManager.h" |
42 |
#include "ClientLayerManager.h" |
43 |
#include "BasicLayers.h" |
43 |
#include "BasicLayers.h" |
44 |
#include "libdisplay/GonkDisplay.h" |
44 |
#include "libdisplay/GonkDisplay.h" |
45 |
#include "pixelflinger/format.h" |
45 |
#include "pixelflinger/format.h" |
46 |
#include "mozilla/BasicEvents.h" |
46 |
#include "mozilla/BasicEvents.h" |
47 |
#include "mozilla/gfx/2D.h" |
47 |
#include "mozilla/gfx/2D.h" |
48 |
#include "mozilla/layers/APZCTreeManager.h" |
48 |
#include "mozilla/layers/APZCTreeManager.h" |
49 |
#include "mozilla/layers/CompositorParent.h" |
49 |
#include "mozilla/layers/CompositorParent.h" |
|
|
50 |
#include "mozilla/layers/InputAPZContext.h" |
51 |
#include "mozilla/MouseEvents.h" |
52 |
#include "mozilla/TouchEvents.h" |
50 |
#include "ParentProcessController.h" |
53 |
#include "ParentProcessController.h" |
51 |
#include "nsThreadUtils.h" |
54 |
#include "nsThreadUtils.h" |
52 |
#include "HwcComposer2D.h" |
55 |
#include "HwcComposer2D.h" |
53 |
|
56 |
|
54 |
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args) |
57 |
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args) |
55 |
#define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "Gonk", ## args) |
58 |
#define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "Gonk", ## args) |
56 |
#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "Gonk", ## args) |
59 |
#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "Gonk", ## args) |
57 |
|
60 |
|
|
223 |
CompositorVsyncDispatcher* vsyncDispatcher = gFocusedWindow->GetCompositorVsyncDispatcher(); |
226 |
CompositorVsyncDispatcher* vsyncDispatcher = gFocusedWindow->GetCompositorVsyncDispatcher(); |
224 |
// During bootup, there is a delay between when the nsWindow is created |
227 |
// During bootup, there is a delay between when the nsWindow is created |
225 |
// and when the Compositor is created, but vsync is already turned on |
228 |
// and when the Compositor is created, but vsync is already turned on |
226 |
if (vsyncDispatcher) { |
229 |
if (vsyncDispatcher) { |
227 |
vsyncDispatcher->NotifyVsync(aVsyncTimestamp); |
230 |
vsyncDispatcher->NotifyVsync(aVsyncTimestamp); |
228 |
} |
231 |
} |
229 |
} |
232 |
} |
230 |
|
233 |
|
231 |
nsEventStatus |
234 |
/*static*/ nsEventStatus |
232 |
nsWindow::DispatchInputEvent(WidgetGUIEvent& aEvent, bool* aWasCaptured) |
235 |
nsWindow::DispatchInputEvent(WidgetGUIEvent& aEvent) |
233 |
{ |
236 |
{ |
234 |
if (aWasCaptured) { |
|
|
235 |
*aWasCaptured = false; |
236 |
} |
237 |
if (!gFocusedWindow) { |
237 |
if (!gFocusedWindow) { |
238 |
return nsEventStatus_eIgnore; |
238 |
return nsEventStatus_eIgnore; |
239 |
} |
239 |
} |
240 |
|
240 |
|
241 |
gFocusedWindow->UserActivity(); |
241 |
gFocusedWindow->UserActivity(); |
242 |
|
242 |
|
|
|
243 |
nsEventStatus status; |
243 |
aEvent.widget = gFocusedWindow; |
244 |
aEvent.widget = gFocusedWindow; |
|
|
245 |
gFocusedWindow->DispatchEvent(&aEvent, status); |
246 |
return status; |
247 |
} |
248 |
|
249 |
/*static*/ void |
250 |
nsWindow::DispatchTouchInput(MultiTouchInput& aInput) |
251 |
{ |
252 |
if (!gFocusedWindow) { |
253 |
return; |
254 |
} |
255 |
|
256 |
gFocusedWindow->UserActivity(); |
257 |
gFocusedWindow->DispatchTouchInputViaAPZ(aInput); |
258 |
} |
259 |
|
260 |
void |
261 |
nsWindow::DispatchTouchInputViaAPZ(MultiTouchInput& aInput) |
262 |
{ |
263 |
if (!mAPZC) { |
264 |
return; |
265 |
} |
266 |
|
267 |
// First send it through the APZ code |
268 |
mozilla::layers::ScrollableLayerGuid guid; |
269 |
uint64_t inputBlockId; |
270 |
nsEventStatus rv = mAPZC->ReceiveInputEvent(aInput, &guid, &inputBlockId); |
271 |
// If the APZ says to drop it, then we drop it |
272 |
if (rv == nsEventStatus_eConsumeNoDefault) { |
273 |
return; |
274 |
} |
244 |
|
275 |
|
|
|
276 |
// Convert it to an event we can send to Gecko |
277 |
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this); |
278 |
|
279 |
// If there is an event capturing child process, send it directly there. |
280 |
// This happens if we already sent a touchstart event through the root |
281 |
// process hit test and it ended up going to a child process. The event |
282 |
// capturing process should get all subsequent touch events in the same |
283 |
// event block. In this case the TryCapture call below will return true, |
284 |
// and the child process will take care of responding to the event as needed |
285 |
// so we don't need to do anything else here. |
245 |
if (TabParent* capturer = TabParent::GetEventCapturer()) { |
286 |
if (TabParent* capturer = TabParent::GetEventCapturer()) { |
246 |
bool captured = capturer->TryCapture(aEvent); |
287 |
InputAPZContext context(guid, inputBlockId); |
247 |
if (aWasCaptured) { |
288 |
if (capturer->TryCapture(event)) { |
248 |
*aWasCaptured = captured; |
289 |
return; |
249 |
} |
|
|
250 |
if (captured) { |
251 |
return nsEventStatus_eConsumeNoDefault; |
252 |
} |
290 |
} |
253 |
} |
291 |
} |
254 |
|
292 |
|
255 |
nsEventStatus status; |
293 |
// If it didn't get captured, dispatch the event into the gecko root process |
256 |
gFocusedWindow->DispatchEvent(&aEvent, status); |
294 |
// for "normal" flow. The event might get sent to the child process still, |
257 |
return status; |
295 |
// but if it doesn't we need to notify the APZ of various things. All of |
|
|
296 |
// that happens in DispatchEventForAPZ |
297 |
rv = DispatchEventForAPZ(&event, guid, inputBlockId); |
298 |
|
299 |
// Finally, if the touch event had only one touch point, generate a mouse |
300 |
// event for it and send it through the gecko root process. |
301 |
// Technically we should not need to do this if the touch event was routed |
302 |
// to the child process, but that seems to expose a bug in B2G where the |
303 |
// keyboard doesn't go away in some cases. |
304 |
// Also for now we're dispatching mouse events from all touch events because |
305 |
// we need this for click events to work in the chrome process. Once we have |
306 |
// APZ and ChromeProcessController::HandleSingleTap working for the chrome |
307 |
// process we shouldn't need to do this at all. |
308 |
if (event.touches.Length() == 1) { |
309 |
WidgetMouseEvent mouseEvent = aInput.ToWidgetMouseEvent(this); |
310 |
if (mouseEvent.message != NS_EVENT_NULL) { |
311 |
mouseEvent.mFlags.mNoCrossProcessBoundaryForwarding = (rv == nsEventStatus_eConsumeNoDefault); |
312 |
DispatchEvent(&mouseEvent, rv); |
313 |
} |
314 |
} |
258 |
} |
315 |
} |
259 |
|
316 |
|
260 |
NS_IMETHODIMP |
317 |
NS_IMETHODIMP |
261 |
nsWindow::Create(nsIWidget *aParent, |
318 |
nsWindow::Create(nsIWidget *aParent, |
262 |
void *aNativeParent, |
319 |
void *aNativeParent, |
263 |
const nsIntRect &aRect, |
320 |
const nsIntRect &aRect, |
264 |
nsDeviceContext *aContext, |
321 |
nsDeviceContext *aContext, |
265 |
nsWidgetInitData *aInitData) |
322 |
nsWidgetInitData *aInitData) |