2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 #include <dali/internal/window-system/common/event-handler.h>
\r
21 // EXTERNAL INCLUDES
\r
23 #include <dali/public-api/adaptor-framework/window.h>
\r
25 #include <dali/public-api/common/vector-wrapper.h>
\r
26 #include <dali/public-api/events/touch-point.h>
\r
27 #include <dali/public-api/events/key-event.h>
\r
28 #include <dali/public-api/events/wheel-event.h>
\r
29 #include <dali/integration-api/debug.h>
\r
30 #include <dali/integration-api/events/key-event-integ.h>
\r
31 #include <dali/integration-api/events/touch-event-integ.h>
\r
32 #include <dali/integration-api/events/hover-event-integ.h>
\r
33 #include <dali/integration-api/events/wheel-event-integ.h>
\r
34 #include <WindowsEventSystem.h>
\r
36 // INTERNAL INCLUDES
\r
37 #include <dali/internal/input/common/gesture-manager.h>
\r
38 #include <dali/internal/window-system/windows/window-render-surface-ecore-win.h>
\r
39 #include <dali/internal/clipboard/common/clipboard-impl.h>
\r
40 #include <dali/internal/input/common/key-impl.h>
\r
41 #include <dali/internal/input/common/physical-keyboard-impl.h>
\r
42 #include <dali/internal/styling/common/style-monitor-impl.h>
\r
43 #include <dali/internal/system/common/core-event-interface.h>
\r
45 #include <Windows.h>
\r
53 using namespace Win32System;
\r
58 #if defined(DEBUG_ENABLED)
\r
61 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
\r
62 Integration::Log::Filter* gClientMessageLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_CLIENT_MESSAGE");
\r
63 Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
\r
64 Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
\r
65 Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
\r
66 } // unnamed namespace
\r
72 const std::string DEFAULT_DEVICE_NAME = "";
\r
73 const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
\r
74 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
\r
76 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
\r
78 #ifndef DALI_PROFILE_UBUNTU
\r
79 const char * CLIPBOARD_ATOM = "CBHM_MSG";
\r
80 const char * CLIPBOARD_SET_OWNER_MESSAGE = "SET_OWNER";
\r
81 #endif // DALI_PROFILE_UBUNTU
\r
83 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
\r
86 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
\r
87 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
\r
88 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
\r
89 * @return the Ecore_IMF_Keyboard_Modifiers output.
\r
92 static bool IsDeviceButton(int keyCode)
\r
112 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
\r
114 int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
\r
116 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
\r
118 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
\r
121 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
\r
123 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
\r
126 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
\r
128 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
\r
131 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
\r
133 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
\r
136 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
\r
138 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
\r
141 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
\r
145 // Copied from x server
\r
146 // Copied from x server
\r
148 void GetNanoseconds(uint64_t& timeInNanoseconds)
\r
150 Win32WindowSystem::GetNanoseconds(timeInNanoseconds);
\r
153 // Copied from x server
\r
154 unsigned int GetCurrentMilliSeconds(void)
\r
156 return Win32WindowSystem::GetCurrentMilliSeconds();
\r
158 } // unnamed namespace
\r
160 // Impl to hide EFL implementation.
\r
161 struct EventHandler::Impl
\r
163 // Construction & Destruction
\r
168 Impl( EventHandler* handler, Ecore_Win_Window window )
\r
169 : mHandler( handler ),
\r
170 mEcoreEventHandler(),
\r
173 #ifdef DALI_ELDBUS_AVAILABLE
\r
174 , mSessionConnection( NULL ),
\r
175 mA11yConnection( NULL )
\r
178 // Only register for touch and key events if we have a window
\r
181 // Register Touch events
\r
182 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
\r
183 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
\r
184 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
\r
185 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, handler ) ); // process mouse out event like up event
\r
187 // Register Mouse wheel events
\r
188 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
\r
190 // Register Key events
\r
191 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
\r
192 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
\r
194 // Register Focus events
\r
195 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
\r
196 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
\r
198 // Register Window damage events
\r
199 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, handler ) );
\r
201 // Enable Drag & Drop and register DnD events
\r
202 //ecore_win_dnd_aware_set( window, EINA_TRUE );
\r
203 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_XDND_ENTER, EcoreEventDndEnter, handler) );
\r
204 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_XDND_POSITION, EcoreEventDndPosition, handler) );
\r
205 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_XDND_LEAVE, EcoreEventDndLeave, handler) );
\r
206 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_XDND_DROP, EcoreEventDndDrop, handler) );
\r
207 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_XDND_FINISHED, EcoreEventDndFinished, handler) );
\r
208 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_XDND_STATUS, EcoreEventDndStatus, handler) );
\r
210 // Register Client message events - accessibility etc.
\r
211 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, handler ) );
\r
213 // Register Selection event - clipboard selection, Drag & Drop selection etc.
\r
214 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, handler ) );
\r
215 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WIN_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, handler ) );
\r
217 Win32WindowSystem::AddListener(EventEntry);
\r
226 #ifndef DALI_PROFILE_UBUNTU
\r
227 //vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
\r
228 //vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
\r
229 #endif // DALI_PROFILE_UBUNTU
\r
231 for( std::vector<Ecore_Event_Handler>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
\r
233 ecore_event_handler_del( *iter );
\r
236 #ifdef DALI_ELDBUS_AVAILABLE
\r
237 // Close down ElDBus
\r
238 if( mA11yConnection )
\r
240 eldbus_connection_unref( mA11yConnection );
\r
243 if( mSessionConnection )
\r
245 eldbus_connection_unref( mSessionConnection );
\r
249 #endif // DALI_ELDBUS_AVAILABLE
\r
254 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
256 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
257 static void EventEntry(long hWnd, unsigned int uMsg, long wParam, long lParam)
\r
259 EventCallback callback = GetCallback(uMsg);
\r
260 EventHandler *handler = ( EventHandler* )GetEventHandler(uMsg);
\r
262 if (NULL != callback)
\r
264 //EventHandler *handler = new EventHandler();
\r
265 TWinEventInfo eventInfo(hWnd, uMsg, wParam, lParam);
\r
266 callback(handler, uMsg, &eventInfo);
\r
270 * Called when a touch down is received.
\r
272 static bool EcoreEventMouseButtonDown( void* data, int type, TWinEventInfo *event )
\r
274 Ecore_Event_Mouse_Button touchEvent = *((Ecore_Event_Mouse_Button*)event);
\r
275 EventHandler* handler( (EventHandler*)data );
\r
277 touchEvent.x = LOWORD(event->lParam);
\r
278 touchEvent.y = HIWORD(event->lParam);
\r
279 touchEvent.multi.device = DEVICE_MOUSE;
\r
281 if ( touchEvent.window == handler->mImpl->mWindow )
\r
283 PointState::Type state ( PointState::DOWN );
\r
285 // Check if the buttons field is set and ensure it's the primary touch button.
\r
286 // If this event was triggered by buttons other than the primary button (used for touch), then
\r
287 // just send an interrupted event to Core.
\r
288 if ( touchEvent.buttons && (touchEvent.buttons != PRIMARY_TOUCH_BUTTON_ID ) )
\r
290 state = PointState::INTERRUPTED;
\r
293 Integration::Point point;
\r
294 point.SetDeviceId( touchEvent.multi.device );
\r
295 point.SetState( state );
\r
296 point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + Win32WindowSystem::GetEdgeHeight() ) );
\r
297 point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
\r
298 point.SetPressure( touchEvent.multi.pressure );
\r
299 point.SetAngle( Degree( touchEvent.multi.angle ) );
\r
300 handler->SendEvent( point, touchEvent.timestamp );
\r
303 return ECORE_CALLBACK_PASS_ON;
\r
307 * Called when a touch up is received.
\r
309 static bool EcoreEventMouseButtonUp( void* data, int type, TWinEventInfo *event )
\r
311 Ecore_Event_Mouse_Button touchEvent = *((Ecore_Event_Mouse_Button*)event);
\r
312 EventHandler* handler( (EventHandler*)data );
\r
314 touchEvent.x = LOWORD(event->lParam);
\r
315 touchEvent.y = HIWORD(event->lParam);
\r
316 touchEvent.multi.device = DEVICE_MOUSE;
\r
318 if ( touchEvent.window == handler->mImpl->mWindow )
\r
320 Integration::Point point;
\r
321 point.SetDeviceId(touchEvent.multi.device );
\r
322 point.SetState( PointState::UP );
\r
323 point.SetScreenPosition( Vector2(touchEvent.x, touchEvent.y + Win32WindowSystem::GetEdgeHeight() ) );
\r
324 point.SetRadius(touchEvent.multi.radius, Vector2(touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
\r
325 point.SetPressure(touchEvent.multi.pressure );
\r
326 point.SetAngle( Degree(touchEvent.multi.angle ) );
\r
327 handler->SendEvent( point, touchEvent.timestamp );
\r
330 return ECORE_CALLBACK_PASS_ON;
\r
334 * Called when a touch motion is received.
\r
336 static bool EcoreEventMouseButtonMove( void* data, int type, TWinEventInfo *event )
\r
338 Ecore_Event_Mouse_Button touchEvent = *((Ecore_Event_Mouse_Button*)event);
\r
339 touchEvent.timestamp = GetTickCount();
\r
341 EventHandler* handler( (EventHandler*)data );
\r
343 touchEvent.x = LOWORD(event->lParam);
\r
344 touchEvent.y = HIWORD(event->lParam);
\r
345 touchEvent.multi.device = DEVICE_MOUSE;
\r
347 if (touchEvent.window == handler->mImpl->mWindow )
\r
349 Integration::Point point;
\r
350 point.SetDeviceId(touchEvent.multi.device );
\r
351 point.SetState( PointState::MOTION );
\r
352 point.SetScreenPosition( Vector2(touchEvent.x, touchEvent.y + Win32WindowSystem::GetEdgeHeight() ) );
\r
353 point.SetRadius(touchEvent.multi.radius, Vector2(touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
\r
354 point.SetPressure(touchEvent.multi.pressure );
\r
355 point.SetAngle( Degree(touchEvent.multi.angle ) );
\r
356 handler->SendEvent( point, touchEvent.timestamp );
\r
359 return ECORE_CALLBACK_PASS_ON;
\r
362 static bool EcoreEventMouseOut( void* data, int type, TWinEventInfo *event )
\r
364 return ECORE_CALLBACK_PASS_ON;
\r
367 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
369 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
372 * Called when a mouse wheel is received.
\r
374 static bool EcoreEventMouseWheel( void* data, int type, TWinEventInfo *event )
\r
376 Ecore_Event_Mouse_Wheel mouseWheelEvent = *((Ecore_Event_Mouse_Wheel*)event);
\r
377 mouseWheelEvent.x = LOWORD(event->lParam);
\r
378 mouseWheelEvent.y = HIWORD(event->lParam);
\r
380 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT Ecore_Event_Mouse_Wheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
\r
382 EventHandler* handler( (EventHandler*)data );
\r
383 if ( mouseWheelEvent.window == handler->mImpl->mWindow )
\r
385 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2(mouseWheelEvent.x, mouseWheelEvent.y), mouseWheelEvent.z, mouseWheelEvent.timestamp );
\r
386 handler->SendWheelEvent( wheelEvent );
\r
388 return ECORE_CALLBACK_PASS_ON;
\r
392 * Called when a custom wheel is received.
\r
394 static bool EcoreEventCustomWheel( void* data, int type, TWinEventInfo *event )
\r
396 return ECORE_CALLBACK_PASS_ON;
\r
399 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
401 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
404 * Called when a key down is received.
\r
407 static bool EcoreEventKeyDown( void* data, int type, TWinEventInfo *event )
\r
409 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
\r
411 EventHandler* handler( (EventHandler*)data );
\r
413 if( event->mWindow == handler->mImpl->mWindow )
\r
415 int keyCode = event->wParam;
\r
416 std::string keyName( Win32WindowSystem::GetKeyName( keyCode ) );
\r
417 std::string keyString( "" );
\r
418 std::string compose ( "" );
\r
421 unsigned long time( 0 );
\r
423 // Ensure key event string is not NULL as keys like SHIFT have a null string.
\r
424 keyString.push_back( event->wParam );
\r
426 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
\r
427 handler->SendEvent( keyEvent );
\r
430 return ECORE_CALLBACK_PASS_ON;
\r
434 * Called when a key up is received.
\r
436 static bool EcoreEventKeyUp( void* data, int type, TWinEventInfo *event )
\r
438 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp \n" );
\r
440 EventHandler* handler( (EventHandler*)data );
\r
442 if( event->mWindow == handler->mImpl->mWindow )
\r
444 int keyCode = event->wParam;
\r
445 std::string keyName( Win32WindowSystem::GetKeyName( keyCode ) );
\r
446 std::string keyString( "" );
\r
447 std::string compose( "" );
\r
449 int modifier( 0/*keyEvent->modifiers*/ );
\r
450 unsigned long time( 0 );
\r
452 // Ensure key event string is not NULL as keys like SHIFT have a null string.
\r
453 keyString.push_back( event->wParam );
\r
455 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
\r
457 handler->SendEvent( keyEvent );
\r
460 return ECORE_CALLBACK_PASS_ON;
\r
463 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
464 // Window Callbacks
\r
465 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
468 * Called when the window gains focus.
\r
470 static bool EcoreEventWindowFocusIn( void* data, int type, TWinEventInfo *event )
\r
472 EventHandler* handler( (EventHandler*)data );
\r
474 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
\r
476 // If the window gains focus and we hid the keyboard then show it again.
\r
477 if (event->mWindow == handler->mImpl->mWindow )
\r
479 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
\r
482 return ECORE_CALLBACK_PASS_ON;
\r
486 * Called when the window loses focus.
\r
488 static bool EcoreEventWindowFocusOut( void* data, int type, TWinEventInfo *event )
\r
490 return ECORE_CALLBACK_PASS_ON;
\r
494 * Called when the window is damaged.
\r
496 static bool EcoreEventWindowDamaged(void *data, int type, TWinEventInfo *event)
\r
498 Ecore_Event_Mouse_Button* windowDamagedEvent( (Ecore_Event_Mouse_Button*)event );
\r
499 EventHandler* handler( (EventHandler*)data );
\r
501 if( windowDamagedEvent->window == handler->mImpl->mWindow )
\r
509 handler->SendEvent( area );
\r
512 return ECORE_CALLBACK_PASS_ON;
\r
516 * Called when the window properties are changed.
\r
517 * We are only interested in the font change.
\r
521 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
522 // Drag & Drop Callbacks
\r
523 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
526 * Called when a dragged item enters our window's bounds.
\r
527 * This is when items are dragged INTO our window.
\r
529 static bool EcoreEventDndEnter( void* data, int type, TWinEventInfo *event )
\r
531 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
\r
532 return ECORE_CALLBACK_PASS_ON;
\r
536 * Called when a dragged item is moved within our window.
\r
537 * This is when items are dragged INTO our window.
\r
539 static bool EcoreEventDndPosition( void* data, int type, TWinEventInfo *event )
\r
541 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
\r
542 return ECORE_CALLBACK_PASS_ON;
\r
546 * Called when a dragged item leaves our window's bounds.
\r
547 * This is when items are dragged INTO our window.
\r
549 static bool EcoreEventDndLeave( void* data, int type, TWinEventInfo *event )
\r
551 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
\r
552 return ECORE_CALLBACK_PASS_ON;
\r
556 * Called when the dragged item is dropped within our window's bounds.
\r
557 * This is when items are dragged INTO our window.
\r
559 static bool EcoreEventDndDrop( void* data, int type, TWinEventInfo *event )
\r
561 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
\r
562 return ECORE_CALLBACK_PASS_ON;
\r
566 * Called when a dragged item is moved from our window and the target window has done processing it.
\r
567 * This is when items are dragged FROM our window.
\r
569 static bool EcoreEventDndFinished( void* data, int type, TWinEventInfo *event )
\r
571 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
\r
572 return ECORE_CALLBACK_PASS_ON;
\r
576 * Called when a dragged item is moved from our window and the target window has sent us a status.
\r
577 * This is when items are dragged FROM our window.
\r
579 static bool EcoreEventDndStatus( void* data, int type, TWinEventInfo *event )
\r
581 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
\r
582 return ECORE_CALLBACK_PASS_ON;
\r
586 * Called when the client messages (i.e. the accessibility events) are received.
\r
588 static bool EcoreEventClientMessage( void* data, int type, TWinEventInfo *event )
\r
590 return ECORE_CALLBACK_PASS_ON;
\r
594 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
595 // ElDBus Accessibility Callbacks
\r
596 /////////////////////////////////////////////////////////////////////////////////////////////////
\r
599 * Called when the source window notifies us the content in clipboard is selected.
\r
601 static bool EcoreEventSelectionClear( void* data, int type, TWinEventInfo *event )
\r
603 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
\r
604 return ECORE_CALLBACK_PASS_ON;
\r
608 * Called when the source window sends us about the selected content.
\r
609 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
\r
611 static bool EcoreEventSelectionNotify( void* data, int type, TWinEventInfo *event )
\r
613 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
\r
614 return ECORE_CALLBACK_PASS_ON;
\r
618 EventHandler* mHandler;
\r
619 std::vector<Ecore_Event_Handler> mEcoreEventHandler;
\r
620 Ecore_Win_Window mWindow;
\r
623 #ifdef DALI_ELDBUS_AVAILABLE
\r
624 Eldbus_Connection* mSessionConnection;
\r
625 Eldbus_Connection* mA11yConnection;
\r
629 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
\r
630 : mCoreEventInterface( coreEventInterface ),
\r
631 mGestureManager( gestureManager ),
\r
632 mStyleMonitor( StyleMonitor::Get() ),
\r
633 mDamageObserver( damageObserver ),
\r
634 mRotationObserver( NULL ),
\r
635 mDragAndDropDetector( dndDetector ),
\r
636 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
\r
637 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
\r
638 mClipboard( Clipboard::Get() ),
\r
642 Ecore_Win_Window window = 0;
\r
644 // this code only works with the WindowRenderSurface so need to downcast
\r
645 WindowRenderSurfaceEcoreWin* ecoreSurface = static_cast< WindowRenderSurfaceEcoreWin* >( surface );
\r
648 // enable multi touch
\r
649 window = ecoreSurface->GetWinWindow();
\r
652 mImpl = new Impl(this, window);
\r
655 EventHandler::~EventHandler()
\r
659 mGestureManager.Stop();
\r
662 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
\r
666 timeStamp = GetCurrentMilliSeconds();
\r
669 Integration::TouchEvent touchEvent;
\r
670 Integration::HoverEvent hoverEvent;
\r
671 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
\r
672 if(type != Integration::TouchEventCombiner::DispatchNone )
\r
674 DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y);
\r
676 // First the touch and/or hover event & related gesture events are queued
\r
677 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
\r
679 mCoreEventInterface.QueueCoreEvent( touchEvent );
\r
680 mGestureManager.SendEvent(touchEvent);
\r
683 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
\r
685 mCoreEventInterface.QueueCoreEvent( hoverEvent );
\r
688 // Next the events are processed with a single call into Core
\r
689 mCoreEventInterface.ProcessCoreEvents();
\r
693 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
\r
695 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
\r
696 if ( physicalKeyboard )
\r
698 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
\r
700 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
\r
704 // Send to KeyEvent Core.
\r
705 mCoreEventInterface.QueueCoreEvent( keyEvent );
\r
706 mCoreEventInterface.ProcessCoreEvents();
\r
709 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
\r
711 // Create WheelEvent and send to Core.
\r
712 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
\r
713 mCoreEventInterface.QueueCoreEvent( event );
\r
714 mCoreEventInterface.ProcessCoreEvents();
\r
717 void EventHandler::SendEvent( StyleChange::Type styleChange )
\r
719 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
\r
720 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
\r
723 void EventHandler::SendEvent( const DamageArea& area )
\r
725 mDamageObserver.OnDamaged( area );
\r
728 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
\r
730 if( mRotationObserver != NULL )
\r
732 mRotationObserver->OnRotationPrepare( event );
\r
736 void EventHandler::SendRotationRequestEvent( )
\r
738 if( mRotationObserver != NULL )
\r
740 mRotationObserver->OnRotationRequest( );
\r
744 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
\r
746 Integration::Point convertedPoint( point );
\r
748 SendEvent(convertedPoint, timeStamp);
\r
751 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
\r
753 SendWheelEvent( wheelEvent );
\r
756 void EventHandler::FeedKeyEvent( KeyEvent& event )
\r
758 Integration::KeyEvent convertedEvent( event );
\r
759 SendEvent( convertedEvent );
\r
762 void EventHandler::FeedEvent( Integration::Event& event )
\r
764 mCoreEventInterface.QueueCoreEvent( event );
\r
765 mCoreEventInterface.ProcessCoreEvents();
\r
768 void EventHandler::Reset()
\r
772 // Any touch listeners should be told of the interruption.
\r
773 Integration::TouchEvent event;
\r
774 Integration::Point point;
\r
775 point.SetState( PointState::INTERRUPTED );
\r
776 event.AddPoint( point );
\r
778 // First the touch event & related gesture events are queued
\r
779 mCoreEventInterface.QueueCoreEvent( event );
\r
780 mGestureManager.SendEvent( event );
\r
782 // Next the events are processed with a single call into Core
\r
783 mCoreEventInterface.ProcessCoreEvents();
\r
786 void EventHandler::Pause()
\r
792 void EventHandler::Resume()
\r
798 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
\r
800 mDragAndDropDetector = detector;
\r
803 void EventHandler::SetRotationObserver( RotationObserver* observer )
\r
805 mRotationObserver = observer;
\r
808 } // namespace Adaptor
\r
810 } // namespace Internal
\r
812 } // namespace Dali
\r