2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <events/event-handler.h>
22 // Ecore is littered with C style cast
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wold-style-cast"
26 #include <Ecore_Input.h>
30 #include <X11/extensions/XInput2.h>
31 #include <X11/extensions/XI2.h>
37 #ifndef DALI_PROFILE_UBUNTU
39 #include <vconf-keys.h>
40 #endif // DALI_PROFILE_UBUNTU
42 #ifdef DALI_ELDBUS_AVAILABLE
44 #endif // DALI_ELDBUS_AVAILABLE
46 #include <dali/public-api/common/vector-wrapper.h>
47 #include <dali/public-api/events/touch-point.h>
48 #include <dali/public-api/events/key-event.h>
49 #include <dali/public-api/events/wheel-event.h>
50 #include <dali/integration-api/debug.h>
51 #include <dali/integration-api/events/key-event-integ.h>
52 #include <dali/integration-api/events/touch-event-integ.h>
53 #include <dali/integration-api/events/hover-event-integ.h>
54 #include <dali/integration-api/events/wheel-event-integ.h>
57 #include <events/gesture-manager.h>
58 #include <window-render-surface.h>
59 #include <clipboard-impl.h>
61 #include <physical-keyboard-impl.h>
62 #include <style-monitor-impl.h>
63 #include <base/core-event-interface.h>
74 #if defined(DEBUG_ENABLED)
77 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
78 Integration::Log::Filter* gClientMessageLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_CLIENT_MESSAGE");
79 Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
80 Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
81 Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
82 } // unnamed namespace
89 const char * DETENT_DEVICE_NAME = "tizen_detent";
90 const std::string DEFAULT_DEVICE_NAME = "";
91 const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
92 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
95 #define A11Y_BUS "org.a11y.Bus"
96 #define A11Y_INTERFACE "org.a11y.Bus"
97 #define A11Y_PATH "/org/a11y/bus"
98 #define A11Y_GET_ADDRESS "GetAddress"
99 #define BUS "com.samsung.EModule"
100 #define INTERFACE "com.samsung.GestureNavigation"
101 #define PATH "/com/samsung/GestureNavigation"
102 #define SIGNAL "GestureDetected"
104 #ifndef DALI_PROFILE_UBUNTU
105 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
106 #endif // DALI_PROFILE_UBUNTU
108 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
110 #ifndef DALI_PROFILE_UBUNTU
111 const char * CLIPBOARD_ATOM = "CBHM_MSG";
112 const char * CLIPBOARD_SET_OWNER_MESSAGE = "SET_OWNER";
113 #endif // DALI_PROFILE_UBUNTU
115 /// The atoms required by Ecore for Drag & Drop behaviour.
116 Ecore_X_Atom DRAG_AND_DROP_ATOMS[] =
118 ECORE_X_ATOM_XDND_ACTION_COPY,
121 /// The types that we support.
122 const char * DRAG_AND_DROP_TYPES[] =
124 ECORE_X_SELECTION_TARGET_UTF8_STRING,
127 const unsigned int DRAG_AND_DROP_ATOMS_NUMBER = sizeof( DRAG_AND_DROP_ATOMS ) / sizeof( Ecore_X_Atom );
128 const unsigned int DRAG_AND_DROP_TYPES_NUMBER = sizeof( DRAG_AND_DROP_TYPES ) / sizeof( const char * );
130 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
132 #ifdef DALI_ELDBUS_AVAILABLE
133 // DBus gesture string matching lists.
134 // TODO: This needs moving to its own module.
135 const char * ElDBusAccessibilityFingerCountStrings[] =
141 const unsigned int FingerCountStringsTotal = sizeof( ElDBusAccessibilityFingerCountStrings ) / sizeof( ElDBusAccessibilityFingerCountStrings[0] );
146 GESTURE_TYPE_SINGLE_TAP,
147 GESTURE_TYPE_DOUBLE_TAP,
148 GESTURE_TYPE_TRIPLE_TAP
150 struct GestureTypeTable
153 const GestureType type;
155 GestureTypeTable ElDBusAccessibilityFullEventTypeStrings[] =
157 { "Hover", GESTURE_TYPE_HOVER },
158 { "SingleTap", GESTURE_TYPE_SINGLE_TAP },
159 { "DoubleTap", GESTURE_TYPE_DOUBLE_TAP },
160 { "TripleTap", GESTURE_TYPE_TRIPLE_TAP }
162 const unsigned int FullEventTypeStringsTotal = sizeof( ElDBusAccessibilityFullEventTypeStrings ) / sizeof( ElDBusAccessibilityFullEventTypeStrings[0] );
165 SUB_GESTURE_TYPE_NONE,
166 SUB_GESTURE_TYPE_FLICK
168 struct SubGestureTypeTable
171 const SubGestureType type;
173 SubGestureTypeTable ElDBusAccessibilityDirectionalEventTypeStrings[] =
175 { "Flick", SUB_GESTURE_TYPE_FLICK }
177 const unsigned int DirectionalEventTypeStringsTotal = sizeof( ElDBusAccessibilityDirectionalEventTypeStrings ) / sizeof( ElDBusAccessibilityDirectionalEventTypeStrings[0] );
178 enum GestureDirection
180 GESTURE_DIRECTION_NONE,
181 GESTURE_DIRECTION_UP,
182 GESTURE_DIRECTION_DOWN,
183 GESTURE_DIRECTION_LEFT,
184 GESTURE_DIRECTION_RIGHT,
185 GESTURE_DIRECTION_UP_RETURN,
186 GESTURE_DIRECTION_DOWN_RETURN,
187 GESTURE_DIRECTION_LEFT_RETURN,
188 GESTURE_DIRECTION_RIGHT_RETURN
190 struct GestureDirectionTable
193 const GestureDirection direction;
195 GestureDirectionTable ElDBusAccessibilityDirectionStrings[] =
197 { "Up", GESTURE_DIRECTION_UP },
198 { "Down", GESTURE_DIRECTION_DOWN },
199 { "Left", GESTURE_DIRECTION_LEFT },
200 { "Right", GESTURE_DIRECTION_RIGHT },
201 { "UpReturn", GESTURE_DIRECTION_UP_RETURN },
202 { "DownReturn", GESTURE_DIRECTION_DOWN_RETURN },
203 { "LeftReturn", GESTURE_DIRECTION_LEFT_RETURN },
204 { "RightReturn", GESTURE_DIRECTION_RIGHT_RETURN }
206 const unsigned int DirectionStringsTotal = sizeof( ElDBusAccessibilityDirectionStrings ) / sizeof( ElDBusAccessibilityDirectionStrings[0] );
207 #endif // DALI_ELDBUS_AVAILABLE
210 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
211 * @param[in] modifier the Ecore_Event_Modifier input.
212 * @return the Ecore_IMF_Keyboard_Locks output.
214 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
216 unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
218 if( modifier & ECORE_EVENT_LOCK_NUM )
220 lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
223 if( modifier & ECORE_EVENT_LOCK_CAPS )
225 lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
228 if( modifier & ECORE_EVENT_LOCK_SCROLL )
230 lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
233 return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
237 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
238 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
239 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
240 * @return the Ecore_IMF_Keyboard_Modifiers output.
242 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
244 unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
247 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
249 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
252 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
254 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
257 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
259 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
262 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
264 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
267 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
269 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
272 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
276 // Copied from x server
277 static unsigned int GetCurrentMilliSeconds(void)
282 static clockid_t clockid;
286 #ifdef CLOCK_MONOTONIC_COARSE
287 if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
288 (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
290 clockid = CLOCK_MONOTONIC_COARSE;
294 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
296 clockid = CLOCK_MONOTONIC;
303 if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
305 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
308 gettimeofday(&tv, NULL);
309 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
312 } // unnamed namespace
314 // Impl to hide EFL implementation.
315 struct EventHandler::Impl
317 // Construction & Destruction
322 Impl( EventHandler* handler, Ecore_X_Window window )
323 : mHandler( handler ),
324 mEcoreEventHandler(),
327 #ifdef DALI_ELDBUS_AVAILABLE
328 , mSessionConnection( NULL ),
329 mA11yConnection( NULL )
332 // Only register for touch and key events if we have a window
335 // Register Touch events
336 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
337 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
338 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
339 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, handler ) ); // process mouse out event like up event
341 // Register Mouse wheel events
342 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
344 // Register Key events
345 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
346 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
348 // Register Focus events
349 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
350 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
352 // Register Window damage events
353 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, handler ) );
355 // Enable Drag & Drop and register DnD events
356 ecore_x_dnd_aware_set( window, EINA_TRUE );
357 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_ENTER, EcoreEventDndEnter, handler) );
358 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_POSITION, EcoreEventDndPosition, handler) );
359 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_LEAVE, EcoreEventDndLeave, handler) );
360 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_DROP, EcoreEventDndDrop, handler) );
361 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_FINISHED, EcoreEventDndFinished, handler) );
362 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_STATUS, EcoreEventDndStatus, handler) );
364 // Register Client message events - accessibility etc.
365 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, handler ) );
367 // Register Selection event - clipboard selection, Drag & Drop selection etc.
368 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, handler ) );
369 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, handler ) );
371 // Initialize Xi2 system
372 Display* display = static_cast< Display* >(ecore_x_display_get());
373 Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
374 int opcode = 0, event = 0, error = 0;
375 int major = XI_2_Major;
376 int minor = XI_2_Minor;
378 XIEventMask xiEventMask;
380 // Check if X input extension available
381 if( XQueryExtension( display, "XInputExtension", &opcode, &event, &error ) )
383 // We support version 2.0
384 if( XIQueryVersion( display, &major, &minor ) != BadRequest )
386 xiEventMask.deviceid = XIAllDevices;
390 XIDeviceInfo* deviceInfo = NULL;
391 deviceInfo = XIQueryDevice( display, XIAllDevices, &deviceCount );
393 for( int i = 0; i < deviceCount; i++ )
395 if( !strncmp( deviceInfo[i].name, DETENT_DEVICE_NAME, strlen( DETENT_DEVICE_NAME ) ) )
397 xiEventMask.deviceid = deviceInfo[i].deviceid;
405 mXiDeviceId = xiEventMask.deviceid;
408 Dali::Vector< unsigned char > mask;
409 std::size_t xiMaskLen = XIMaskLen( XI_LASTEVENT );
410 mask.Reserve( xiMaskLen );
411 xiEventMask.mask = mask.Begin();
413 XISetMask( xiEventMask.mask, XI_RawMotion );
415 xiEventMask.mask_len = xiMaskLen * sizeof( unsigned char );
417 int ret = XISelectEvents( display, rootWindow, &xiEventMask, 1 );
420 // Register custom wheel events
421 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_GENERIC, EcoreEventCustomWheel, handler ) );
425 DALI_LOG_INFO( gImfLogging, Debug::General, "Failed to Select Events\n" );
429 if( deviceInfo != NULL )
431 XIFreeDeviceInfo( deviceInfo );
436 DALI_LOG_INFO( gImfLogging, Debug::General, "Failed to query XI Version\n" );
441 DALI_LOG_INFO( gImfLogging, Debug::General, "Failed to query XInputExtension\n" );
444 #ifndef DALI_PROFILE_UBUNTU
445 // Register Vconf notify - font name, font size and style
446 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, handler );
447 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
448 #endif // DALI_PROFILE_UBUNTU
450 #ifdef DALI_ELDBUS_AVAILABLE
452 // Initialize ElDBus.
453 DALI_LOG_INFO( gImfLogging, Debug::General, "Starting DBus Initialization\n" );
456 mSessionConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SESSION );
458 Eldbus_Object *a11yObject = eldbus_object_get( mSessionConnection, A11Y_BUS, A11Y_PATH );
459 Eldbus_Proxy *elDBusManager = eldbus_proxy_get( a11yObject, A11Y_INTERFACE );
461 // Pass in handler in the cb_data field so we can access the accessibility adaptor within the callback.
462 eldbus_proxy_call( elDBusManager, A11Y_GET_ADDRESS, EcoreElDBusInitialisation, handler, -1, "" );
464 DALI_LOG_INFO( gImfLogging, Debug::General, "Finished DBus Initialization\n" );
466 #endif // DALI_ELDBUS_AVAILABLE
475 #ifndef DALI_PROFILE_UBUNTU
476 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
477 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
478 #endif // DALI_PROFILE_UBUNTU
480 for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
482 ecore_event_handler_del( *iter );
485 #ifdef DALI_ELDBUS_AVAILABLE
487 if( mA11yConnection )
489 eldbus_connection_unref( mA11yConnection );
492 if( mSessionConnection )
494 eldbus_connection_unref( mSessionConnection );
498 #endif // DALI_ELDBUS_AVAILABLE
503 /////////////////////////////////////////////////////////////////////////////////////////////////
505 /////////////////////////////////////////////////////////////////////////////////////////////////
508 * Called when a touch down is received.
510 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
512 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
513 EventHandler* handler( (EventHandler*)data );
515 if ( touchEvent->window == handler->mImpl->mWindow )
517 PointState::Type state ( PointState::DOWN );
519 // Check if the buttons field is set and ensure it's the primary touch button.
520 // If this event was triggered by buttons other than the primary button (used for touch), then
521 // just send an interrupted event to Core.
522 if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
524 state = PointState::INTERRUPTED;
527 Integration::Point point;
528 point.SetDeviceId( touchEvent->multi.device );
529 point.SetState( state );
530 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
531 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
532 point.SetPressure( touchEvent->multi.pressure );
533 point.SetAngle( Degree( touchEvent->multi.angle ) );
534 handler->SendEvent( point, touchEvent->timestamp );
537 return ECORE_CALLBACK_PASS_ON;
541 * Called when a touch up is received.
543 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
545 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
546 EventHandler* handler( (EventHandler*)data );
548 if ( touchEvent->window == handler->mImpl->mWindow )
550 Integration::Point point;
551 point.SetDeviceId( touchEvent->multi.device );
552 point.SetState( PointState::UP );
553 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
554 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
555 point.SetPressure( touchEvent->multi.pressure );
556 point.SetAngle( Degree( touchEvent->multi.angle ) );
557 handler->SendEvent( point, touchEvent->timestamp );
560 return ECORE_CALLBACK_PASS_ON;
564 * Called when a touch motion is received.
566 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
568 Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
569 EventHandler* handler( (EventHandler*)data );
571 if ( touchEvent->window == handler->mImpl->mWindow )
573 Integration::Point point;
574 point.SetDeviceId( touchEvent->multi.device );
575 point.SetState( PointState::MOTION );
576 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
577 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
578 point.SetPressure( touchEvent->multi.pressure );
579 point.SetAngle( Degree( touchEvent->multi.angle ) );
580 handler->SendEvent( point, touchEvent->timestamp );
583 return ECORE_CALLBACK_PASS_ON;
586 /////////////////////////////////////////////////////////////////////////////////////////////////
588 /////////////////////////////////////////////////////////////////////////////////////////////////
591 * Called when a mouse wheel is received.
593 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
595 Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
597 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 );
599 EventHandler* handler( (EventHandler*)data );
600 if ( mouseWheelEvent->window == handler->mImpl->mWindow )
602 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp );
603 handler->SendWheelEvent( wheelEvent );
605 return ECORE_CALLBACK_PASS_ON;
609 * Called when a custom wheel is received.
611 static Eina_Bool EcoreEventCustomWheel( void* data, int type, void* event )
613 Ecore_X_Event_Generic *genericEvent( (Ecore_X_Event_Generic*)event );
614 EventHandler* handler( (EventHandler*)data );
616 switch( genericEvent->evtype )
620 XIRawEvent* xiRawEvent = static_cast< XIRawEvent* >( genericEvent->data );
621 unsigned int timeStamp = 0;
623 if( xiRawEvent->deviceid != handler->mImpl->mXiDeviceId )
625 return ECORE_CALLBACK_PASS_ON;
628 // X(0): rotate: NOT USED
632 double* value = xiRawEvent->raw_values;
634 if( XIMaskIsSet( xiRawEvent->valuators.mask, 1) )
636 timeStamp = static_cast< unsigned int >( *(value + 1) );
639 if( XIMaskIsSet( xiRawEvent->valuators.mask, 2) )
641 // if z == 1, clockwise
642 // otherwise counter-clockwise
643 int z = static_cast< int >( *(value + 2) );
645 // In DALi, positive value means clockwise, and negative value means counter-clockwise
651 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventCustomWheel: z: %d\n", z );
653 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), z, timeStamp );
654 handler->SendWheelEvent( wheelEvent );
664 return ECORE_CALLBACK_PASS_ON;
667 /////////////////////////////////////////////////////////////////////////////////////////////////
669 /////////////////////////////////////////////////////////////////////////////////////////////////
672 * Called when a key down is received.
674 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
676 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
678 EventHandler* handler( (EventHandler*)data );
679 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
680 bool eventHandled( false );
682 // If a device key then skip ecore_imf_context_filter_event.
683 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
685 Ecore_IMF_Context* imfContext = NULL;
686 Dali::ImfManager imfManager( ImfManager::Get() );
689 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
694 // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
695 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
696 ecoreKeyDownEvent.keyname = keyEvent->keyname;
697 ecoreKeyDownEvent.key = keyEvent->key;
698 ecoreKeyDownEvent.string = keyEvent->string;
699 ecoreKeyDownEvent.compose = keyEvent->compose;
700 ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
701 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
702 ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
703 #ifdef ECORE_IMF_1_13
704 ecoreKeyDownEvent.dev_name = "";
705 ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
706 ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
707 #endif // ECORE_IMF_1_13
709 eventHandled = ecore_imf_context_filter_event( imfContext,
710 ECORE_IMF_EVENT_KEY_DOWN,
711 (Ecore_IMF_Event *) &ecoreKeyDownEvent );
713 // If the event has not been handled by IMF then check if we should reset our IMF context
716 if ( !strcmp( keyEvent->keyname, "Escape" ) ||
717 !strcmp( keyEvent->keyname, "Return" ) ||
718 !strcmp( keyEvent->keyname, "KP_Enter" ) )
720 ecore_imf_context_reset( imfContext );
726 // If the event wasn't handled then we should send a key event.
729 if ( keyEvent->window == handler->mImpl->mWindow )
731 std::string keyName( keyEvent->keyname );
732 std::string keyString( "" );
733 int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
734 int modifier( keyEvent->modifiers );
735 unsigned long time = keyEvent->timestamp;
737 // Ensure key event string is not NULL as keys like SHIFT have a null string.
738 if ( keyEvent->string )
740 keyString = keyEvent->string;
743 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
744 handler->SendEvent( keyEvent );
748 return ECORE_CALLBACK_PASS_ON;
752 * Called when a key up is received.
754 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
756 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp \n" );
758 EventHandler* handler( (EventHandler*)data );
759 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
760 bool eventHandled( false );
762 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
763 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
765 Ecore_IMF_Context* imfContext = NULL;
766 Dali::ImfManager imfManager( ImfManager::Get() );
769 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
774 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
775 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
776 ecoreKeyUpEvent.keyname = keyEvent->keyname;
777 ecoreKeyUpEvent.key = keyEvent->key;
778 ecoreKeyUpEvent.string = keyEvent->string;
779 ecoreKeyUpEvent.compose = keyEvent->compose;
780 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
781 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
782 ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
783 #ifdef ECORE_IMF_1_13
784 ecoreKeyUpEvent.dev_name = "";
785 #endif // ECORE_IMF_1_13
787 eventHandled = ecore_imf_context_filter_event( imfContext,
788 ECORE_IMF_EVENT_KEY_UP,
789 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
793 // If the event wasn't handled then we should send a key event.
796 if ( keyEvent->window == handler->mImpl->mWindow )
798 std::string keyName( keyEvent->keyname );
799 std::string keyString( "" );
800 int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
801 int modifier( keyEvent->modifiers );
802 unsigned long time( keyEvent->timestamp );
804 // Ensure key event string is not NULL as keys like SHIFT have a null string.
805 if ( keyEvent->string )
807 keyString = keyEvent->string;
810 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
812 handler->SendEvent( keyEvent );
816 return ECORE_CALLBACK_PASS_ON;
819 /////////////////////////////////////////////////////////////////////////////////////////////////
821 /////////////////////////////////////////////////////////////////////////////////////////////////
824 * Called when the window gains focus.
826 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
828 Ecore_X_Event_Window_Focus_In* focusInEvent( (Ecore_X_Event_Window_Focus_In*)event );
829 EventHandler* handler( (EventHandler*)data );
831 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
833 // If the window gains focus and we hid the keyboard then show it again.
834 if ( focusInEvent->win == handler->mImpl->mWindow )
836 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
838 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
840 Dali::ImfManager imfManager( ImfManager::Get() );
843 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
844 if( imfManagerImpl.RestoreAfterFocusLost() )
846 imfManagerImpl.Activate();
850 // No need to connect callbacks as KeyboardStatusChanged will be called.
853 return ECORE_CALLBACK_PASS_ON;
857 * Called when the window loses focus.
859 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
861 Ecore_X_Event_Window_Focus_Out* focusOutEvent( (Ecore_X_Event_Window_Focus_Out*)event );
862 EventHandler* handler( (EventHandler*)data );
864 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
866 // If the window loses focus then hide the keyboard.
867 if ( focusOutEvent->win == handler->mImpl->mWindow )
869 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
871 Dali::ImfManager imfManager( ImfManager::Get() );
874 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
875 if( imfManagerImpl.RestoreAfterFocusLost() )
877 imfManagerImpl.Deactivate();
882 // Clipboard don't support that whether clipboard is shown or not. Hide clipboard.
883 Dali::Clipboard clipboard = Clipboard::Get();
884 clipboard.HideClipboard();
887 return ECORE_CALLBACK_PASS_ON;
891 * Called when the window is damaged.
893 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
895 Ecore_X_Event_Window_Damage* windowDamagedEvent( (Ecore_X_Event_Window_Damage*)event );
896 EventHandler* handler( (EventHandler*)data );
898 if( windowDamagedEvent->win == handler->mImpl->mWindow )
901 area.x = windowDamagedEvent->x;
902 area.y = windowDamagedEvent->y;
903 area.width = windowDamagedEvent->w;
904 area.height = windowDamagedEvent->h;
906 handler->SendEvent( area );
909 return ECORE_CALLBACK_PASS_ON;
913 * Called when the window properties are changed.
914 * We are only interested in the font change.
918 /////////////////////////////////////////////////////////////////////////////////////////////////
919 // Drag & Drop Callbacks
920 /////////////////////////////////////////////////////////////////////////////////////////////////
923 * Called when a dragged item enters our window's bounds.
924 * This is when items are dragged INTO our window.
926 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
928 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
930 Ecore_X_Event_Xdnd_Enter* enterEvent( (Ecore_X_Event_Xdnd_Enter*) event );
931 EventHandler* handler( (EventHandler*)data );
932 Ecore_X_Window window ( handler->mImpl->mWindow );
934 if ( enterEvent->win == window )
936 DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
938 // Check whether the Drag & Drop detector has Drag & Drop behaviour enabled before we accept.
939 if ( dndDetector && dndDetector->IsEnabled() )
941 // Tell Ecore that we want to enable drop in the entire window.
942 Ecore_X_Rectangle rect;
944 ecore_x_window_geometry_get( window, NULL, NULL, (int*)&rect.width, (int*)&rect.height );
946 // Tell Ecore that we are able to process a drop.
947 ecore_x_dnd_send_status( EINA_TRUE, EINA_FALSE, rect, ECORE_X_ATOM_XDND_DROP );
949 // Register the required atoms and types.
950 ecore_x_dnd_actions_set( window, DRAG_AND_DROP_ATOMS, DRAG_AND_DROP_ATOMS_NUMBER );
951 ecore_x_dnd_types_set( window, DRAG_AND_DROP_TYPES, DRAG_AND_DROP_TYPES_NUMBER );
953 // Request to get the content from Ecore.
954 ecore_x_selection_xdnd_request( window, ECORE_X_SELECTION_TARGET_UTF8_STRING );
956 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndEnter: Requesting Drag & Drop\n" );
958 // Clear the previous content
959 dndDetector->ClearContent();
961 // Emit the entered signal
962 dndDetector->EmitEnteredSignal();
966 return ECORE_CALLBACK_PASS_ON;
970 * Called when a dragged item is moved within our window.
971 * This is when items are dragged INTO our window.
973 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
975 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
977 Ecore_X_Event_Xdnd_Position* positionEvent( (Ecore_X_Event_Xdnd_Position*) event );
978 EventHandler* handler( (EventHandler*)data );
980 if ( positionEvent->win == handler->mImpl->mWindow )
982 DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
984 // If we have a detector then update its latest position.
987 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::General, "EcoreEventDndPosition: position ( %d x %d )\n", positionEvent->position.x, positionEvent->position.y );
988 dndDetector->SetPosition( Vector2( positionEvent->position.x, positionEvent->position.y ));
989 dndDetector->EmitMovedSignal();
993 return ECORE_CALLBACK_PASS_ON;
997 * Called when a dragged item leaves our window's bounds.
998 * This is when items are dragged INTO our window.
1000 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
1002 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
1004 Ecore_X_Event_Xdnd_Leave* leaveEvent( (Ecore_X_Event_Xdnd_Leave*) event );
1005 EventHandler* handler( (EventHandler*)data );
1007 if ( leaveEvent->win == handler->mImpl->mWindow )
1009 DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
1011 // If we have a detector then clear its content and emit the exited-signal. Also tell Ecore that we have finished.
1014 dndDetector->ClearContent();
1015 dndDetector->EmitExitedSignal();
1017 ecore_x_dnd_send_finished();
1019 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndLeave: Finished\n" );
1023 return ECORE_CALLBACK_PASS_ON;
1027 * Called when the dragged item is dropped within our window's bounds.
1028 * This is when items are dragged INTO our window.
1030 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
1032 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
1034 Ecore_X_Event_Xdnd_Drop* dropEvent ( (Ecore_X_Event_Xdnd_Drop*) event);
1035 EventHandler* handler( (EventHandler*)data );
1037 if ( dropEvent->win == handler->mImpl->mWindow )
1039 DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
1041 // Something has been dropped, inform the detector (if we have one) and tell Ecore that we have finished.
1044 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::General, "EcoreEventDndDrop: position ( %d x %d )\n", dropEvent->position.x, dropEvent->position.y );
1046 dndDetector->SetPosition( Vector2( dropEvent->position.x, dropEvent->position.y ) );
1047 dndDetector->EmitDroppedSignal();
1048 ecore_x_dnd_send_finished();
1050 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndDrop: Finished\n" );
1054 return ECORE_CALLBACK_PASS_ON;
1058 * Called when a dragged item is moved from our window and the target window has done processing it.
1059 * This is when items are dragged FROM our window.
1061 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
1063 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
1064 return ECORE_CALLBACK_PASS_ON;
1068 * Called when a dragged item is moved from our window and the target window has sent us a status.
1069 * This is when items are dragged FROM our window.
1071 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
1073 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
1074 return ECORE_CALLBACK_PASS_ON;
1078 * Called when the client messages (i.e. the accessibility events) are received.
1080 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
1082 #ifndef DALI_PROFILE_UBUNTU
1083 Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
1084 EventHandler* handler( (EventHandler*)data );
1086 if (clientMessageEvent->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
1088 if ( ( (unsigned int)clientMessageEvent->data.l[0] == handler->mImpl->mWindow ) && handler->mAccessibilityAdaptor )
1090 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
1092 if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_SCROLL)
1094 // 2 finger touch & move, 2 finger flick
1096 // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
1099 TouchPoint::State state(TouchPoint::Down);
1101 if ((unsigned int)clientMessageEvent->data.l[2] == 0)
1103 state = TouchPoint::Down; // mouse down
1105 else if ((unsigned int)clientMessageEvent->data.l[2] == 1)
1107 state = TouchPoint::Motion; // mouse move
1109 else if ((unsigned int)clientMessageEvent->data.l[2] == 2)
1111 state = TouchPoint::Up; // mouse up
1115 state = TouchPoint::Interrupted; // error
1118 DALI_LOG_INFO(gClientMessageLogFilter, Debug::General,
1119 "[%s:%d] [%d] %d, %d\n", __FUNCTION__, __LINE__,
1120 (unsigned int)clientMessageEvent->data.l[2],
1121 (unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4]);
1123 // Send touch event to accessibility adaptor.
1124 TouchPoint point( 0, state, (float)clientMessageEvent->data.l[3], (float)clientMessageEvent->data.l[4] );
1126 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
1127 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
1129 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_MOUSE)
1131 // 1 finger double tap and hold
1133 // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
1136 TouchPoint::State state(TouchPoint::Down);
1138 if ((unsigned int)clientMessageEvent->data.l[2] == 0)
1140 state = TouchPoint::Down; // mouse down
1142 else if ((unsigned int)clientMessageEvent->data.l[2] == 1)
1144 state = TouchPoint::Motion; // mouse move
1146 else if ((unsigned int)clientMessageEvent->data.l[2] == 2)
1148 state = TouchPoint::Up; // mouse up
1152 state = TouchPoint::Interrupted; // error
1155 DALI_LOG_INFO(gClientMessageLogFilter, Debug::General,
1156 "[%s:%d] [%d] %d, %d\n", __FUNCTION__, __LINE__,
1157 (unsigned int)clientMessageEvent->data.l[2],
1158 (unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4]);
1160 // Send touch event to accessibility adaptor.
1161 TouchPoint point( 0, state, (float)clientMessageEvent->data.l[3], (float)clientMessageEvent->data.l[4] );
1163 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
1164 accessibilityAdaptor->HandleActionTouchEvent( point, GetCurrentMilliSeconds() );
1166 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_BACK)
1168 // 2 finger circle draw, do back
1169 accessibilityAdaptor->HandleActionBackEvent();
1171 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
1173 // one finger flick down
1174 // focus next object
1175 if(accessibilityAdaptor)
1177 accessibilityAdaptor->HandleActionNextEvent();
1180 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
1182 // one finger flick up
1183 // focus previous object
1184 if(accessibilityAdaptor)
1186 accessibilityAdaptor->HandleActionPreviousEvent();
1189 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
1191 // one finger double tap
1192 // same as one finger tap in normal mode (i.e. execute focused actor)
1193 if(accessibilityAdaptor)
1195 accessibilityAdaptor->HandleActionActivateEvent();
1198 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
1201 // focus & read an actor at ( e->data.l[2], e->data.l[3] ) position according to finger
1202 if(accessibilityAdaptor)
1204 accessibilityAdaptor->HandleActionReadEvent((unsigned int)clientMessageEvent->data.l[2], (unsigned int)clientMessageEvent->data.l[3], true /* allow read again*/);
1207 #if defined(DALI_PROFILE_MOBILE)
1208 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_OVER)
1210 // one finger tap & move
1211 // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
1214 // focus & read an actor at (x, y) position according to finger
1215 if(accessibilityAdaptor && (unsigned int)clientMessageEvent->data.l[2] == 1 /*only work for move event*/)
1217 accessibilityAdaptor->HandleActionReadEvent((unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4], false /* not allow read again*/);
1221 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
1223 // one finger flick right
1224 // focus next object
1225 if(accessibilityAdaptor)
1227 accessibilityAdaptor->HandleActionReadNextEvent();
1230 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
1232 // one finger flick left
1233 // focus previous object
1234 if(accessibilityAdaptor)
1236 accessibilityAdaptor->HandleActionReadPreviousEvent();
1239 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
1241 // double down and move (right, up)
1242 // change slider value
1243 if(accessibilityAdaptor)
1245 accessibilityAdaptor->HandleActionUpEvent();
1248 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
1250 // double down and move (left, down)
1251 // change slider value
1252 if(accessibilityAdaptor)
1254 accessibilityAdaptor->HandleActionDownEvent();
1257 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ENABLE)
1259 if(accessibilityAdaptor)
1261 accessibilityAdaptor->HandleActionEnableEvent();
1264 else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DISABLE)
1266 if(accessibilityAdaptor)
1268 accessibilityAdaptor->HandleActionDisableEvent();
1271 // TODO: some more actions could be added later
1274 else if(clientMessageEvent->message_type == ecore_x_atom_get(CLIPBOARD_ATOM))
1276 std::string message(clientMessageEvent->data.b);
1277 if( message == CLIPBOARD_SET_OWNER_MESSAGE)
1279 // Claim the ownership of the SECONDARY selection.
1280 ecore_x_selection_secondary_set(handler->mImpl->mWindow, "", 1);
1282 // Show the clipboard window
1283 Dali::Clipboard clipboard = Dali::Clipboard::Get();
1284 clipboard.ShowClipboard();
1287 else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE )
1289 RotationEvent rotationEvent;
1290 rotationEvent.angle = static_cast<int>(clientMessageEvent->data.l[1]);
1291 rotationEvent.winResize = static_cast<int>(clientMessageEvent->data.l[2]);
1292 rotationEvent.width = static_cast<int>(clientMessageEvent->data.l[3]);
1293 rotationEvent.height = static_cast<int>(clientMessageEvent->data.l[4]);
1294 handler->SendRotationPrepareEvent( rotationEvent );
1296 else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST )
1298 handler->SendRotationRequestEvent();
1301 #endif // DALI_PROFILE_UBUNTU
1302 return ECORE_CALLBACK_PASS_ON;
1306 /////////////////////////////////////////////////////////////////////////////////////////////////
1307 // ElDBus Accessibility Callbacks
1308 /////////////////////////////////////////////////////////////////////////////////////////////////
1310 #ifdef DALI_ELDBUS_AVAILABLE
1311 // Callback for Ecore ElDBus accessibility events.
1312 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
1314 EventHandler* handler = static_cast< EventHandler* >( context );
1315 // Ignore any accessibility events when paused.
1316 if( handler->mPaused )
1321 if ( !handler->mAccessibilityAdaptor )
1323 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
1327 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
1328 if ( !accessibilityAdaptor )
1330 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
1334 const char *gestureName;
1338 // The string defines the arg-list's respective types.
1339 if( !eldbus_message_arguments_get( message, "siiiiu", &gestureName, &xS, &yS, &xE, &yE, &state ) )
1341 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1344 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %s Args: %d,%d,%d,%d State: %d\n", gestureName, xS, yS, xE, yE );
1346 unsigned int fingers = 0;
1347 char* stringPosition = ( char* )gestureName;
1349 // Check how many fingers the gesture uses.
1350 for( unsigned int i = 0; i < FingerCountStringsTotal; ++i )
1352 unsigned int matchLength = strlen( ElDBusAccessibilityFingerCountStrings[ i ] );
1353 if( strncmp( gestureName, ElDBusAccessibilityFingerCountStrings[ i ], matchLength ) == 0 )
1356 stringPosition += matchLength;
1363 // Error: invalid gesture.
1367 GestureType gestureType = GESTURE_TYPE_NONE;
1368 SubGestureType subGestureType = SUB_GESTURE_TYPE_NONE;
1369 GestureDirection direction = GESTURE_DIRECTION_NONE;
1371 // Check for full gesture type names first.
1372 for( unsigned int i = 0; i < FullEventTypeStringsTotal; ++i )
1374 unsigned int matchLength = strlen( ElDBusAccessibilityFullEventTypeStrings[ i ].name );
1375 if( strncmp( stringPosition, ElDBusAccessibilityFullEventTypeStrings[ i ].name, matchLength ) == 0 )
1377 gestureType = ElDBusAccessibilityFullEventTypeStrings[ i ].type;
1382 // If we didn't find a full gesture, check for sub gesture type names.
1383 if( gestureType == GESTURE_TYPE_NONE )
1385 // No full gesture name found, look for partial types.
1386 for( unsigned int i = 0; i < DirectionalEventTypeStringsTotal; ++i )
1388 unsigned int matchLength = strlen( ElDBusAccessibilityDirectionalEventTypeStrings[ i ].name );
1389 if( strncmp( stringPosition, ElDBusAccessibilityDirectionalEventTypeStrings[ i ].name, matchLength ) == 0 )
1391 subGestureType = ElDBusAccessibilityDirectionalEventTypeStrings[ i ].type;
1392 stringPosition += matchLength;
1397 if( subGestureType == SUB_GESTURE_TYPE_NONE )
1399 // ERROR: Gesture not recognised.
1403 // If the gesture was a sub type, get it's respective direction.
1404 for( unsigned int i = 0; i < DirectionStringsTotal; ++i )
1406 unsigned int matchLength = strlen( ElDBusAccessibilityDirectionStrings[ i ].name );
1407 if( strncmp( stringPosition, ElDBusAccessibilityDirectionStrings[ i ].name, matchLength ) == 0 )
1409 direction = ElDBusAccessibilityDirectionStrings[ i ].direction;
1410 stringPosition += matchLength;
1415 if( direction == GESTURE_DIRECTION_NONE )
1417 // ERROR: Gesture not recognised.
1422 // Action the detected gesture here.
1423 if( gestureType != GESTURE_TYPE_NONE )
1425 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Fingers: %d Gesture type: %d\n", fingers, gestureType );
1429 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Fingers: %d Gesture sub type: %d Gesture direction: %d\n",
1430 fingers, subGestureType, direction );
1433 // Create a touch point object.
1434 TouchPoint::State touchPointState( TouchPoint::Down );
1437 touchPointState = TouchPoint::Down; // Mouse down.
1439 else if ( state == 1 )
1441 touchPointState = TouchPoint::Motion; // Mouse move.
1443 else if ( state == 2 )
1445 touchPointState = TouchPoint::Up; // Mouse up.
1449 touchPointState = TouchPoint::Interrupted; // Error.
1452 // Send touch event to accessibility adaptor.
1453 TouchPoint point( 0, touchPointState, (float)xS, (float)yS );
1455 // Perform actions based on received gestures.
1456 // Note: This is seperated from the reading so we can (in future)
1457 // have other input readers without changing the below code.
1462 if( gestureType == GESTURE_TYPE_SINGLE_TAP || ( gestureType == GESTURE_TYPE_HOVER && touchPointState == TouchPoint::Motion ) )
1465 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1467 else if( gestureType == GESTURE_TYPE_DOUBLE_TAP )
1469 if( false ) // TODO: how to detect double tap + hold?
1471 // Move or drag icon / view more options for selected items.
1472 // accessibilityAdaptor->HandleActionTouchEvent( point, GetCurrentMilliSeconds() );
1476 // Activate selected item / active edit mode.
1477 accessibilityAdaptor->HandleActionActivateEvent();
1480 else if( gestureType == GESTURE_TYPE_TRIPLE_TAP )
1483 accessibilityAdaptor->HandleActionZoomEvent();
1485 else if( subGestureType == SUB_GESTURE_TYPE_FLICK )
1487 if( direction == GESTURE_DIRECTION_LEFT )
1489 // Move to previous item.
1490 accessibilityAdaptor->HandleActionReadPreviousEvent();
1492 else if( direction == GESTURE_DIRECTION_RIGHT )
1494 // Move to next item.
1495 accessibilityAdaptor->HandleActionReadNextEvent();
1497 else if( direction == GESTURE_DIRECTION_UP )
1499 // Move to next item.
1500 accessibilityAdaptor->HandleActionPreviousEvent();
1502 else if( direction == GESTURE_DIRECTION_DOWN )
1504 // Move to next item.
1505 accessibilityAdaptor->HandleActionNextEvent();
1507 else if( direction == GESTURE_DIRECTION_LEFT_RETURN )
1509 // Scroll up to the previous page
1510 accessibilityAdaptor->HandleActionPageUpEvent();
1512 else if( direction == GESTURE_DIRECTION_RIGHT_RETURN )
1514 // Scroll down to the next page
1515 accessibilityAdaptor->HandleActionPageDownEvent();
1517 else if( direction == GESTURE_DIRECTION_UP_RETURN )
1519 // Move to the first item on screen
1520 accessibilityAdaptor->HandleActionMoveToFirstEvent();
1522 else if( direction == GESTURE_DIRECTION_DOWN_RETURN )
1524 // Move to the last item on screen
1525 accessibilityAdaptor->HandleActionMoveToLastEvent();
1533 if( gestureType == GESTURE_TYPE_HOVER )
1535 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
1536 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
1538 else if( gestureType == GESTURE_TYPE_SINGLE_TAP )
1540 // Pause/Resume current speech
1541 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1543 else if( gestureType == GESTURE_TYPE_DOUBLE_TAP )
1545 // Start/Stop current action
1546 accessibilityAdaptor->HandleActionStartStopEvent();
1548 else if( gestureType == GESTURE_TYPE_TRIPLE_TAP )
1550 // Read information from indicator
1551 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1553 else if( subGestureType == SUB_GESTURE_TYPE_FLICK )
1555 if( direction == GESTURE_DIRECTION_LEFT )
1557 // Scroll left to the previous page
1558 accessibilityAdaptor->HandleActionPageLeftEvent();
1560 else if( direction == GESTURE_DIRECTION_RIGHT )
1562 // Scroll right to the next page
1563 accessibilityAdaptor->HandleActionPageRightEvent();
1565 else if( direction == GESTURE_DIRECTION_UP )
1567 // Scroll up the list.
1568 accessibilityAdaptor->HandleActionScrollUpEvent();
1570 else if( direction == GESTURE_DIRECTION_DOWN )
1572 // Scroll down the list.
1573 accessibilityAdaptor->HandleActionScrollDownEvent();
1581 if( gestureType == GESTURE_TYPE_SINGLE_TAP )
1583 // Read from top item on screen continuously.
1584 accessibilityAdaptor->HandleActionReadFromTopEvent();
1586 else if( gestureType == GESTURE_TYPE_DOUBLE_TAP )
1588 // Read from next item continuously.
1589 accessibilityAdaptor->HandleActionReadFromNextEvent();
1596 // Callback for to set up Ecore ElDBus for accessibility callbacks.
1597 static void EcoreElDBusInitialisation( void *handle, const Eldbus_Message *message, Eldbus_Pending *pending EINA_UNUSED )
1599 Eldbus_Object *object;
1600 Eldbus_Proxy *manager;
1601 const char *a11yBusAddress = NULL;
1602 EventHandler* handler = static_cast< EventHandler* >( handle );
1604 // The string defines the arg-list's respective types.
1605 if( !eldbus_message_arguments_get( message, "s", &a11yBusAddress ) )
1607 DALI_LOG_ERROR( "EcoreElDBusInitialisation: Error getting arguments\n" );
1610 DALI_LOG_INFO( gImfLogging, Debug::General, "Ecore ElDBus Accessibility address: %s\n", a11yBusAddress );
1612 handler->mImpl->mA11yConnection = eldbus_address_connection_get( a11yBusAddress );
1614 object = eldbus_object_get( handler->mImpl->mA11yConnection, BUS, PATH );
1615 manager = eldbus_proxy_get( object, INTERFACE );
1617 // Pass the callback data through to the signal handler.
1618 eldbus_proxy_signal_handler_add( manager, SIGNAL, OnEcoreElDBusAccessibilityNotification, handle );
1620 #endif // DALI_ELDBUS_AVAILABLE
1623 * Called when the source window notifies us the content in clipboard is selected.
1625 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1627 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1628 Ecore_X_Event_Selection_Clear* selectionClearEvent( (Ecore_X_Event_Selection_Clear*) event );
1629 EventHandler* handler( (EventHandler*)data );
1631 if ( selectionClearEvent->win == handler->mImpl->mWindow )
1633 if ( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
1635 // Request to get the content from Ecore.
1636 ecore_x_selection_secondary_request(selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT);
1639 return ECORE_CALLBACK_PASS_ON;
1643 * Called when the source window sends us about the selected content.
1644 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1646 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1648 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1650 Ecore_X_Event_Selection_Notify* selectionNotifyEvent( (Ecore_X_Event_Selection_Notify*) event );
1651 EventHandler* handler( (EventHandler*)data );
1653 if ( selectionNotifyEvent->win == handler->mImpl->mWindow )
1655 Ecore_X_Selection_Data* selectionData( (Ecore_X_Selection_Data*) selectionNotifyEvent->data );
1656 if ( selectionData->data )
1658 if ( selectionNotifyEvent->selection == ECORE_X_SELECTION_XDND )
1660 DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
1662 // We have got the content that is to be dropped, inform the DndListener (if we have one).
1665 std::string content( (char*) selectionData->data, selectionData->length );
1666 dndDetector->SetContent( content );
1668 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d):\n" , selectionData->length );
1669 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
1670 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "%s\n", selectionData->data );
1671 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
1674 else if ( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
1676 // We have got the selected content, inform the clipboard event listener (if we have one).
1677 if ( handler->mClipboardEventNotifier )
1679 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1680 std::string content( (char*) selectionData->data, selectionData->length );
1681 clipboardEventNotifier.SetContent( content );
1682 clipboardEventNotifier.EmitContentSelectedSignal();
1685 // Claim the ownership of the SECONDARY selection.
1686 ecore_x_selection_secondary_set(handler->mImpl->mWindow, "", 1);
1688 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d):\n" , selectionData->length );
1689 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
1690 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "%s\n", selectionData->data );
1691 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
1695 return ECORE_CALLBACK_PASS_ON;
1699 #ifndef DALI_PROFILE_UBUNTU
1700 /////////////////////////////////////////////////////////////////////////////////////////////////
1702 /////////////////////////////////////////////////////////////////////////////////////////////////
1704 * Called when a font name is changed.
1706 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1708 EventHandler* handler = static_cast<EventHandler*>( data );
1709 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1713 * Called when a font size is changed.
1715 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1717 DALI_LOG_INFO(gTouchEventLogFilter, Debug::Verbose, "VconfNotifyFontSizeChanged\n" );
1718 EventHandler* handler = static_cast<EventHandler*>( data );
1719 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1721 #endif // DALI_PROFILE_UBUNTU
1724 EventHandler* mHandler;
1725 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1726 Ecore_X_Window mWindow;
1729 #ifdef DALI_ELDBUS_AVAILABLE
1730 Eldbus_Connection* mSessionConnection;
1731 Eldbus_Connection* mA11yConnection;
1735 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1736 : mCoreEventInterface( coreEventInterface ),
1737 mGestureManager( gestureManager ),
1738 mStyleMonitor( StyleMonitor::Get() ),
1739 mDamageObserver( damageObserver ),
1740 mRotationObserver( NULL ),
1741 mDragAndDropDetector( dndDetector ),
1742 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1743 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1744 mClipboard( Clipboard::Get() ),
1748 Ecore_X_Window window = 0;
1750 // this code only works with the EcoreX11 RenderSurface so need to downcast
1751 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1754 // enable multi touch
1755 window = ecoreSurface->GetXWindow();
1758 mImpl = new Impl(this, window);
1761 EventHandler::~EventHandler()
1765 mGestureManager.Stop();
1768 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1772 timeStamp = GetCurrentMilliSeconds();
1775 Integration::TouchEvent touchEvent;
1776 Integration::HoverEvent hoverEvent;
1777 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1778 if(type != Integration::TouchEventCombiner::DispatchNone )
1780 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);
1782 // First the touch and/or hover event & related gesture events are queued
1783 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1785 mCoreEventInterface.QueueCoreEvent( touchEvent );
1786 mGestureManager.SendEvent(touchEvent);
1789 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1791 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1794 // Next the events are processed with a single call into Core
1795 mCoreEventInterface.ProcessCoreEvents();
1799 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
1801 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1802 if ( physicalKeyboard )
1804 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
1806 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1810 // Send to KeyEvent Core.
1811 mCoreEventInterface.QueueCoreEvent( keyEvent );
1812 mCoreEventInterface.ProcessCoreEvents();
1815 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1817 // Create WheelEvent and send to Core.
1818 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1819 mCoreEventInterface.QueueCoreEvent( event );
1820 mCoreEventInterface.ProcessCoreEvents();
1823 void EventHandler::SendEvent( StyleChange::Type styleChange )
1825 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1826 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1829 void EventHandler::SendEvent( const DamageArea& area )
1831 mDamageObserver.OnDamaged( area );
1834 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1836 if( mRotationObserver != NULL )
1838 mRotationObserver->OnRotationPrepare( event );
1842 void EventHandler::SendRotationRequestEvent( )
1844 if( mRotationObserver != NULL )
1846 mRotationObserver->OnRotationRequest( );
1850 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1852 Integration::Point convertedPoint( point );
1854 SendEvent(convertedPoint, timeStamp);
1857 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1859 SendWheelEvent( wheelEvent );
1862 void EventHandler::FeedKeyEvent( KeyEvent& event )
1864 Integration::KeyEvent convertedEvent( event );
1865 SendEvent( convertedEvent );
1868 void EventHandler::FeedEvent( Integration::Event& event )
1870 mCoreEventInterface.QueueCoreEvent( event );
1871 mCoreEventInterface.ProcessCoreEvents();
1874 void EventHandler::Reset()
1878 // Any touch listeners should be told of the interruption.
1879 Integration::TouchEvent event;
1880 Integration::Point point;
1881 point.SetState( PointState::INTERRUPTED );
1882 event.AddPoint( point );
1884 // First the touch event & related gesture events are queued
1885 mCoreEventInterface.QueueCoreEvent( event );
1886 mGestureManager.SendEvent( event );
1888 // Next the events are processed with a single call into Core
1889 mCoreEventInterface.ProcessCoreEvents();
1892 void EventHandler::Pause()
1898 void EventHandler::Resume()
1904 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1906 mDragAndDropDetector = detector;
1909 void EventHandler::SetRotationObserver( RotationObserver* observer )
1911 mRotationObserver = observer;
1914 } // namespace Adaptor
1916 } // namespace Internal
1920 #pragma GCC diagnostic pop